1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import 'package:vitalapp/pages/medical/controllers/base.dart';
- import 'package:vnote_device_plugin/consts/types.dart';
- import 'package:vnote_device_plugin/devices/base.dart';
- import 'package:fis_common/logger/logger.dart';
- import 'package:vnote_device_plugin/devices/heart.dart';
- import 'package:vnote_device_plugin/devices/ic_reader.dart';
- import 'package:vnote_device_plugin/devices/nibp.dart';
- import 'package:vnote_device_plugin/devices/sp_o2.dart';
- import 'package:vnote_device_plugin/devices/sugar.dart';
- import 'package:vnote_device_plugin/devices/temp.dart';
- import 'package:vnote_device_plugin/devices/twelve_heart.dart';
- import 'package:vnote_device_plugin/devices/urine.dart';
- import 'package:vnote_device_plugin/devices/weight.dart';
- import 'package:vnote_device_plugin/devices/weight_height.dart';
- class DeviceControllerManager extends BaseDeviceController<DeviceWorkerBase> {
- DeviceControllerManager(
- this.type,
- super.model,
- super.mac,
- ) : super();
- final String type;
- DeviceWorkerBase? deviceWorker;
- @override
- DeviceWorkerBase createWorker() {
- if (deviceWorker != null) {
- logger.i('DeviceControllerManager:$type disconnect start');
- deviceWorker?.disconnect().then((value) {
- logger.i('DeviceControllerManager:$type disconnect end');
- deviceWorker?.dispose();
- logger.i('DeviceControllerManager:$type dispose');
- });
- }
- logger.i('DeviceControllerManager:$type create');
- print('DeviceControllerManager:$type create');
- return _createWorker();
- }
- @override
- void dispose() {
- super.dispose();
- deviceWorker = null;
- logger.i('DeviceControllerManager:$type dispose');
- print('DeviceControllerManager:$type dispose');
- }
- DeviceWorkerBase _createWorker() {
- switch (type) {
- //体重
- case DeviceTypes.WEIGHT:
- deviceWorker = WeightDeviceWorker(mac: super.mac, model: model);
- break;
- //心率
- case DeviceTypes.HEART:
- deviceWorker = HeartDeviceWorker(mac: super.mac, model: model);
- break;
- //血压
- case DeviceTypes.NIBP:
- deviceWorker = NibpDeviceWorker(mac: super.mac, model: model);
- break;
- //血氧
- case DeviceTypes.SPO2:
- deviceWorker = SpO2DeviceWorker(mac: super.mac, model: model);
- break;
- //血糖
- case DeviceTypes.SUGAR:
- deviceWorker = SugarDeviceWorker(mac: super.mac, model: model);
- break;
- //温度
- case DeviceTypes.TEMP:
- deviceWorker = TempDeviceWorker(mac: super.mac, model: model);
- break;
- //尿常规
- case DeviceTypes.URINE:
- deviceWorker = UrineDeviceWorker(mac: super.mac, model: model);
- break;
- case DeviceTypes.IC_READER:
- deviceWorker = ICReaderDeviceWorker(mac: super.mac, model: model);
- break;
- case DeviceTypes.TWELVEHEART:
- deviceWorker = TwelveHeartDeviceWorker(mac: super.mac, model: model);
- break;
- case DeviceTypes.WEIGHTHEIGHT:
- deviceWorker = WeightHeightDeviceWorker(mac: super.mac, model: model);
- break;
- }
- return deviceWorker!;
- }
- }
|