temp.dart 790 B

12345678910111213141516171819202122232425262728
  1. import 'package:vnote_device_plugin/consts/status.dart';
  2. import 'package:vnote_device_plugin/devices/base.dart';
  3. import 'package:vnote_device_plugin/event_type.dart';
  4. class TempDeviceWorker extends DeviceWorkerBase {
  5. TempDeviceWorker({
  6. required super.model,
  7. required super.mac,
  8. }) : super(
  9. "temp",
  10. maxStatus: 1003,
  11. minStatus: 1000,
  12. );
  13. final successEvent = FEventHandler<double>();
  14. final errorEvent = FEventHandler<String>();
  15. @override
  16. void onEventCallback(int status, Map<String, dynamic> data) {
  17. if (VDeviceSdkStatus.EXAM_TEMP_ERROR == status) {
  18. errorEvent.emit(this, "Error"); //TODO:
  19. } else {
  20. //TODO: 处理过高or过低
  21. final value = data["TEMP"];
  22. successEvent.emit(this, value);
  23. }
  24. }
  25. }