Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
laki_icu_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张宏
laki_icu_app
Commits
bccdf520
Commit
bccdf520
authored
Jun 24, 2026
by
张宏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11111
parent
e779c58a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
491 additions
and
2 deletions
+491
-2
device_control_bloc.dart
lib/blocs/device_control/device_control_bloc.dart
+0
-0
device_control_event.dart
lib/blocs/device_control/device_control_event.dart
+349
-0
device_control_state.dart
lib/blocs/device_control/device_control_state.dart
+123
-0
main.dart
lib/main.dart
+18
-2
device_control_bo.dart
lib/models/bo/device_control_bo.dart
+0
-0
pubspec.yaml
pubspec.yaml
+1
-0
No files found.
lib/blocs/device_control/device_control_bloc.dart
0 → 100644
View file @
bccdf520
This diff is collapsed.
Click to expand it.
lib/blocs/device_control/device_control_event.dart
0 → 100644
View file @
bccdf520
import
'package:equatable/equatable.dart'
;
import
'package:laki_icu_app/models/bo/device_control_bo.dart'
;
/// 用途:设备控制事件基类
abstract
class
DeviceControlEvent
extends
Equatable
{
const
DeviceControlEvent
();
@override
List
<
Object
?>
get
props
=>
[];
}
// ==================== 基础事件 ====================
/// 加载设备控制数据
class
DeviceControlLoadRequested
extends
DeviceControlEvent
{
const
DeviceControlLoadRequested
();
}
/// 更新设备控制全部数据
class
DeviceControlDataUpdated
extends
DeviceControlEvent
{
final
DeviceControlBO
data
;
const
DeviceControlDataUpdated
(
this
.
data
);
@override
List
<
Object
?>
get
props
=>
[
data
];
}
// ==================== 设备SN事件 ====================
/// 获取设备SN(从MCU获取)
class
DeviceControlSnFetched
extends
DeviceControlEvent
{
final
String
?
sn
;
const
DeviceControlSnFetched
(
this
.
sn
);
@override
List
<
Object
?>
get
props
=>
[
sn
];
}
/// 设置设备SN(用户配置,发送给MCU)
class
DeviceControlSnChanged
extends
DeviceControlEvent
{
final
String
?
sn
;
const
DeviceControlSnChanged
(
this
.
sn
);
@override
List
<
Object
?>
get
props
=>
[
sn
];
}
// ==================== 舱内温度控制事件 ====================
/// 获取舱内温度当前值(从MCU获取)
class
DeviceControlCabinTempCurrentValueFetched
extends
DeviceControlEvent
{
final
String
currentValue
;
const
DeviceControlCabinTempCurrentValueFetched
(
this
.
currentValue
);
@override
List
<
Object
?>
get
props
=>
[
currentValue
];
}
/// 设置舱内温度设定值(用户配置,发送给MCU)
class
DeviceControlCabinTempSetValueChanged
extends
DeviceControlEvent
{
final
String
setValue
;
const
DeviceControlCabinTempSetValueChanged
(
this
.
setValue
);
@override
List
<
Object
?>
get
props
=>
[
setValue
];
}
/// 设置舱内温度开关
class
DeviceControlCabinTempSwitchChanged
extends
DeviceControlEvent
{
final
bool
isOn
;
const
DeviceControlCabinTempSwitchChanged
(
this
.
isOn
);
@override
List
<
Object
?>
get
props
=>
[
isOn
];
}
// ==================== 舱内湿度控制事件 ====================
/// 获取舱内湿度当前值(从MCU获取)
class
DeviceControlCabinHumidityCurrentValueFetched
extends
DeviceControlEvent
{
final
String
currentValue
;
const
DeviceControlCabinHumidityCurrentValueFetched
(
this
.
currentValue
);
@override
List
<
Object
?>
get
props
=>
[
currentValue
];
}
/// 设置舱内湿度设定值(用户配置,发送给MCU)
class
DeviceControlCabinHumiditySetValueChanged
extends
DeviceControlEvent
{
final
String
setValue
;
const
DeviceControlCabinHumiditySetValueChanged
(
this
.
setValue
);
@override
List
<
Object
?>
get
props
=>
[
setValue
];
}
/// 设置舱内湿度开关
class
DeviceControlCabinHumiditySwitchChanged
extends
DeviceControlEvent
{
final
bool
isOn
;
const
DeviceControlCabinHumiditySwitchChanged
(
this
.
isOn
);
@override
List
<
Object
?>
get
props
=>
[
isOn
];
}
// ==================== 氧气浓度控制事件 ====================
/// 获取氧气浓度当前值(从MCU获取)
class
DeviceControlOxygenConcentrationCurrentValueFetched
extends
DeviceControlEvent
{
final
String
currentValue
;
const
DeviceControlOxygenConcentrationCurrentValueFetched
(
this
.
currentValue
);
@override
List
<
Object
?>
get
props
=>
[
currentValue
];
}
/// 设置氧气浓度设定值(用户配置,发送给MCU)
class
DeviceControlOxygenConcentrationSetValueChanged
extends
DeviceControlEvent
{
final
String
setValue
;
const
DeviceControlOxygenConcentrationSetValueChanged
(
this
.
setValue
);
@override
List
<
Object
?>
get
props
=>
[
setValue
];
}
/// 设置氧气浓度开关
class
DeviceControlOxygenConcentrationSwitchChanged
extends
DeviceControlEvent
{
final
bool
isOn
;
const
DeviceControlOxygenConcentrationSwitchChanged
(
this
.
isOn
);
@override
List
<
Object
?>
get
props
=>
[
isOn
];
}
// ==================== 二氧化碳浓度控制事件 ====================
/// 获取二氧化碳浓度当前值(从MCU获取)
class
DeviceControlCO2ConcentrationCurrentValueFetched
extends
DeviceControlEvent
{
final
String
currentValue
;
const
DeviceControlCO2ConcentrationCurrentValueFetched
(
this
.
currentValue
);
@override
List
<
Object
?>
get
props
=>
[
currentValue
];
}
/// 设置二氧化碳浓度告警阈值(用户配置,发送给MCU)
class
DeviceControlCO2ConcentrationAlarmThresholdChanged
extends
DeviceControlEvent
{
final
String
alarmThreshold
;
const
DeviceControlCO2ConcentrationAlarmThresholdChanged
(
this
.
alarmThreshold
);
@override
List
<
Object
?>
get
props
=>
[
alarmThreshold
];
}
// ==================== 护理等级控制事件 ====================
/// 设置护理等级(用户配置,发送给MCU)
class
DeviceControlCareLevelChanged
extends
DeviceControlEvent
{
final
CareLevel
level
;
const
DeviceControlCareLevelChanged
(
this
.
level
);
@override
List
<
Object
?>
get
props
=>
[
level
];
}
// ==================== 新风进化控制事件 ====================
/// 设置新风模式(用户配置,发送给MCU)
class
DeviceControlFreshAirModeChanged
extends
DeviceControlEvent
{
final
FreshAirMode
mode
;
const
DeviceControlFreshAirModeChanged
(
this
.
mode
);
@override
List
<
Object
?>
get
props
=>
[
mode
];
}
// ==================== 风速调节控制事件 ====================
/// 设置风速模式(用户配置,发送给MCU)
class
DeviceControlWindSpeedModeChanged
extends
DeviceControlEvent
{
final
WindSpeedMode
mode
;
const
DeviceControlWindSpeedModeChanged
(
this
.
mode
);
@override
List
<
Object
?>
get
props
=>
[
mode
];
}
// ==================== 雾化时间设置事件 ====================
/// 设置雾化时间(用户配置,发送给MCU)
class
DeviceControlNebulizationTimeChanged
extends
DeviceControlEvent
{
final
String
minutes
;
const
DeviceControlNebulizationTimeChanged
(
this
.
minutes
);
@override
List
<
Object
?>
get
props
=>
[
minutes
];
}
// ==================== 消毒时间设置事件 ====================
/// 设置消毒时间(用户配置,发送给MCU)
class
DeviceControlDisinfectionTimeChanged
extends
DeviceControlEvent
{
final
String
minutes
;
const
DeviceControlDisinfectionTimeChanged
(
this
.
minutes
);
@override
List
<
Object
?>
get
props
=>
[
minutes
];
}
// ==================== 开放供氧控制事件 ====================
/// 设置开放供氧开关(用户配置,发送给MCU)
class
DeviceControlOpenOxygenSwitchChanged
extends
DeviceControlEvent
{
final
bool
isOn
;
const
DeviceControlOpenOxygenSwitchChanged
(
this
.
isOn
);
@override
List
<
Object
?>
get
props
=>
[
isOn
];
}
// ==================== 供氧计时事件 ====================
/// 更新供氧计时(从MCU获取)
class
DeviceControlOxygenTimerUpdated
extends
DeviceControlEvent
{
final
String
hours
;
final
String
minutes
;
final
String
seconds
;
const
DeviceControlOxygenTimerUpdated
(
this
.
hours
,
this
.
minutes
,
this
.
seconds
);
@override
List
<
Object
?>
get
props
=>
[
hours
,
minutes
,
seconds
];
}
/// 清零供氧计时(用户操作)
class
DeviceControlOxygenTimerCleared
extends
DeviceControlEvent
{
const
DeviceControlOxygenTimerCleared
();
}
// ==================== 循环模式控制事件 ====================
/// 设置循环模式(用户配置,发送给MCU)
class
DeviceControlCirculationModeChanged
extends
DeviceControlEvent
{
final
CirculationMode
mode
;
const
DeviceControlCirculationModeChanged
(
this
.
mode
);
@override
List
<
Object
?>
get
props
=>
[
mode
];
}
// ==================== 灯光控制事件 ====================
/// 设置检查灯开关(用户配置,发送给MCU)
class
DeviceControlCheckLightSwitchChanged
extends
DeviceControlEvent
{
final
bool
isOn
;
const
DeviceControlCheckLightSwitchChanged
(
this
.
isOn
);
@override
List
<
Object
?>
get
props
=>
[
isOn
];
}
/// 设置照明灯开关(用户配置,发送给MCU)
class
DeviceControlIlluminationLightSwitchChanged
extends
DeviceControlEvent
{
final
bool
isOn
;
const
DeviceControlIlluminationLightSwitchChanged
(
this
.
isOn
);
@override
List
<
Object
?>
get
props
=>
[
isOn
];
}
/// 设置蓝光灯开关(用户配置,发送给MCU)
class
DeviceControlBlueLightSwitchChanged
extends
DeviceControlEvent
{
final
bool
isOn
;
const
DeviceControlBlueLightSwitchChanged
(
this
.
isOn
);
@override
List
<
Object
?>
get
props
=>
[
isOn
];
}
/// 设置红光灯开关(用户配置,发送给MCU)
class
DeviceControlRedLightSwitchChanged
extends
DeviceControlEvent
{
final
bool
isOn
;
const
DeviceControlRedLightSwitchChanged
(
this
.
isOn
);
@override
List
<
Object
?>
get
props
=>
[
isOn
];
}
// ==================== 全局统计数据事件 ====================
/// 更新总运行时长(从MCU获取)
class
DeviceControlTotalRunTimeUpdated
extends
DeviceControlEvent
{
final
String
totalRunTime
;
const
DeviceControlTotalRunTimeUpdated
(
this
.
totalRunTime
);
@override
List
<
Object
?>
get
props
=>
[
totalRunTime
];
}
/// 更新环境温度(从MCU获取)
class
DeviceControlEnvironmentTempUpdated
extends
DeviceControlEvent
{
final
String
environmentTemp
;
const
DeviceControlEnvironmentTempUpdated
(
this
.
environmentTemp
);
@override
List
<
Object
?>
get
props
=>
[
environmentTemp
];
}
/// 更新总制氧时长(从MCU获取)
class
DeviceControlTotalOxygenTimeUpdated
extends
DeviceControlEvent
{
final
String
totalOxygenTime
;
const
DeviceControlTotalOxygenTimeUpdated
(
this
.
totalOxygenTime
);
@override
List
<
Object
?>
get
props
=>
[
totalOxygenTime
];
}
/// 初始化设备设置(用户操作,重置为默认值)
class
DeviceControlResetSettings
extends
DeviceControlEvent
{
const
DeviceControlResetSettings
();
}
lib/blocs/device_control/device_control_state.dart
0 → 100644
View file @
bccdf520
import
'package:equatable/equatable.dart'
;
import
'package:laki_icu_app/models/bo/device_control_bo.dart'
;
/// 默认的 DeviceControlBO 数据(所有字段为初始值)
const
DeviceControlBO
_defaultDeviceControlBO
=
DeviceControlBO
(
sn:
null
,
totalRunTime:
'0h'
,
environmentTemp:
'25.0℃'
,
totalOxygenTime:
'0h'
,
cabinTemp:
TemperatureControlBO
(
currentValue:
'24'
,
setValue:
'24'
,
unit:
'℃'
,
isOn:
false
,
),
cabinHumidity:
HumidityControlBO
(
currentValue:
'24'
,
setValue:
'50'
,
unit:
'%'
,
isOn:
false
,
),
oxygenConcentration:
OxygenConcentrationBO
(
currentValue:
'24'
,
setValue:
'90'
,
unit:
'%'
,
isOn:
true
,
),
co2Concentration:
CO2ConcentrationBO
(
currentValue:
'2400'
,
alarmThreshold:
'4000'
,
unit:
'PPM'
,
),
careLevel:
CareLevelControlBO
(
currentLevel:
CareLevel
.
special
,
),
freshAir:
FreshAirControlBO
(
mode:
FreshAirMode
.
auto
,
description:
'CO₂超设定值时自动启动外循环净化,当降至2000ppm后,本功能自动关闭'
,
),
windSpeed:
WindSpeedControlBO
(
currentMode:
WindSpeedMode
.
sleep
,
),
nebulizationTime:
NebulizationTimeBO
(
setMinutes:
'00'
,
),
disinfectionTime:
DisinfectionTimeBO
(
setMinutes:
'14'
,
),
openOxygen:
OpenOxygenControlBO
(
isOn:
false
,
description:
'开启后风扇打开,制冷、加热和循环等设备暂停。
\n
*保持设备周围空气相对禁止,严禁烟火'
,
),
oxygenTimer:
OxygenTimerBO
(
hours:
'00'
,
minutes:
'00'
,
seconds:
'00'
,
),
circulationMode:
CirculationModeBO
(
currentMode:
CirculationMode
.
external
,
),
lightControl:
LightControlBO
(
checkLightOn:
false
,
illuminationOn:
false
,
blueLightOn:
false
,
redLightOn:
false
,
),
);
/// 用途:设备控制状态
/// 涉及页面:设备控制页面
class
DeviceControlState
extends
Equatable
{
/// 设备控制数据
final
DeviceControlBO
data
;
/// 用户设置(仅包含用户可配置的字段,用于 hydrated_bloc 持久化)
final
DeviceControlUserSettings
userSettings
;
/// 加载状态
final
bool
isLoading
;
/// 错误信息
final
String
?
error
;
const
DeviceControlState
({
this
.
data
=
_defaultDeviceControlBO
,
this
.
userSettings
=
const
DeviceControlUserSettings
(),
this
.
isLoading
=
false
,
this
.
error
,
});
DeviceControlState
copyWith
({
DeviceControlBO
?
data
,
DeviceControlUserSettings
?
userSettings
,
bool
?
isLoading
,
String
?
error
,
bool
clearError
=
false
,
})
{
return
DeviceControlState
(
data:
data
??
this
.
data
,
userSettings:
userSettings
??
this
.
userSettings
,
isLoading:
isLoading
??
this
.
isLoading
,
error:
clearError
?
null
:
error
??
this
.
error
,
);
}
/// 从持久化存储中恢复状态(仅恢复用户设置,MCU值使用默认值)
factory
DeviceControlState
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
final
userSettings
=
DeviceControlUserSettings
.
fromJson
(
json
);
final
data
=
userSettings
.
applyTo
(
_defaultDeviceControlBO
);
return
DeviceControlState
(
data:
data
,
userSettings:
userSettings
,
);
}
/// 序列化为持久化存储(仅持久化用户设置,不包含MCU获取的值)
Map
<
String
,
dynamic
>
toJson
()
{
return
userSettings
.
toJson
();
}
@override
List
<
Object
?>
get
props
=>
[
data
,
userSettings
,
isLoading
,
error
];
}
lib/main.dart
View file @
bccdf520
...
@@ -3,6 +3,8 @@ import 'package:flutter/foundation.dart';
...
@@ -3,6 +3,8 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:hydrated_bloc/hydrated_bloc.dart'
;
import
'package:path_provider/path_provider.dart'
;
import
'package:laki_icu_app/blocs/auth/auth_bloc.dart'
;
import
'package:laki_icu_app/blocs/auth/auth_bloc.dart'
;
import
'package:laki_icu_app/blocs/auth/auth_event.dart'
;
import
'package:laki_icu_app/blocs/auth/auth_event.dart'
;
import
'package:laki_icu_app/blocs/auth/auth_state.dart'
;
import
'package:laki_icu_app/blocs/auth/auth_state.dart'
;
...
@@ -27,10 +29,17 @@ import 'package:flutter_ume_kit_dio_plus/flutter_ume_kit_dio_plus.dart';
...
@@ -27,10 +29,17 @@ import 'package:flutter_ume_kit_dio_plus/flutter_ume_kit_dio_plus.dart';
// import 'package:flutter_ume_kit_show_code_plus/flutter_ume_kit_show_code_plus.dart';
// import 'package:flutter_ume_kit_show_code_plus/flutter_ume_kit_show_code_plus.dart';
import
'package:flutter_ume_kit_ui_plus/flutter_ume_kit_ui_plus.dart'
;
import
'package:flutter_ume_kit_ui_plus/flutter_ume_kit_ui_plus.dart'
;
import
'package:laki_icu_app/blocs/device_control/device_control_bloc.dart'
;
import
'package:marionette_flutter/marionette_flutter.dart'
;
import
'package:marionette_flutter/marionette_flutter.dart'
;
void
main
(
List
<
String
>
args
)
{
Future
<
void
>
main
(
List
<
String
>
args
)
async
{
// WidgetsFlutterBinding.ensureInitialized();
// WidgetsFlutterBinding.ensureInitialized();
// 初始化 HydratedBloc 存储(用于持久化设备控制用户设置等)
WidgetsFlutterBinding
.
ensureInitialized
();
final
storageDirectory
=
await
getApplicationDocumentsDirectory
();
HydratedBloc
.
storage
=
await
HydratedStorage
.
build
(
storageDirectory:
storageDirectory
,
);
// UME 调试工具(仅 Debug 模式启用)
// UME 调试工具(仅 Debug 模式启用)
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
...
@@ -43,7 +52,6 @@ void main(List<String> args) {
...
@@ -43,7 +52,6 @@ void main(List<String> args) {
// ..register(DioInspector(dio: ApiClient.instance().dio));
// ..register(DioInspector(dio: ApiClient.instance().dio));
runApp
(
UMEWidget
(
enable:
true
,
child:
const
MyApp
()));
runApp
(
UMEWidget
(
enable:
true
,
child:
const
MyApp
()));
}
else
{
}
else
{
WidgetsFlutterBinding
.
ensureInitialized
();
runApp
(
const
MyApp
());
runApp
(
const
MyApp
());
}
}
// runApp(const MyApp());
// runApp(const MyApp());
...
@@ -63,6 +71,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -63,6 +71,7 @@ class _MyAppState extends State<MyApp> {
late
final
AppRouter
_appRouter
;
late
final
AppRouter
_appRouter
;
late
final
AuthBloc
_authBloc
;
late
final
AuthBloc
_authBloc
;
BluetoothReadBloc
?
_bluetoothReadBloc
;
BluetoothReadBloc
?
_bluetoothReadBloc
;
DeviceControlBloc
?
_deviceControlBloc
;
StreamSubscription
?
_tokenExpiredSubscription
;
StreamSubscription
?
_tokenExpiredSubscription
;
bool
_isInitializing
=
true
;
bool
_isInitializing
=
true
;
...
@@ -71,6 +80,9 @@ class _MyAppState extends State<MyApp> {
...
@@ -71,6 +80,9 @@ class _MyAppState extends State<MyApp> {
storageService:
_storageService
,
storageService:
_storageService
,
);
);
DeviceControlBloc
get
_deviceControlBlocInstance
=>
_deviceControlBloc
??=
DeviceControlBloc
();
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
...
@@ -154,6 +166,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -154,6 +166,7 @@ class _MyAppState extends State<MyApp> {
_tokenExpiredSubscription
?.
cancel
();
_tokenExpiredSubscription
?.
cancel
();
_authBloc
.
close
();
_authBloc
.
close
();
_bluetoothReadBloc
?.
close
();
_bluetoothReadBloc
?.
close
();
_deviceControlBloc
?.
close
();
super
.
dispose
();
super
.
dispose
();
}
}
...
@@ -168,6 +181,9 @@ class _MyAppState extends State<MyApp> {
...
@@ -168,6 +181,9 @@ class _MyAppState extends State<MyApp> {
BlocProvider
<
BluetoothReadBloc
>.
value
(
BlocProvider
<
BluetoothReadBloc
>.
value
(
value:
_bluetoothReadBlocInstance
,
value:
_bluetoothReadBlocInstance
,
),
),
BlocProvider
<
DeviceControlBloc
>.
value
(
value:
_deviceControlBlocInstance
,
),
// BlocProvider<CounterBloc>(create: (_) => CounterBloc()),
// BlocProvider<CounterBloc>(create: (_) => CounterBloc()),
],
],
child:
MultiBlocListener
(
child:
MultiBlocListener
(
...
...
lib/models/bo/device_control_bo.dart
0 → 100644
View file @
bccdf520
This diff is collapsed.
Click to expand it.
pubspec.yaml
View file @
bccdf520
...
@@ -60,6 +60,7 @@ dependencies:
...
@@ -60,6 +60,7 @@ dependencies:
flutter_reactive_ble
:
^5.5.0
flutter_reactive_ble
:
^5.5.0
mqtt_client
:
^10.5.1
mqtt_client
:
^10.5.1
marionette_flutter
:
^0.5.0
marionette_flutter
:
^0.5.0
hydrated_bloc
:
^9.1.5
dev_dependencies
:
dev_dependencies
:
flutter_test
:
flutter_test
:
sdk
:
flutter
sdk
:
flutter
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment