diff --git a/lib/delay_period_on_off.dart b/lib/delay_period_on_off.dart index 2250a7a..1dfd04b 100644 --- a/lib/delay_period_on_off.dart +++ b/lib/delay_period_on_off.dart @@ -43,9 +43,9 @@ class _DelayPeriodOnOffPageState extends ConsumerState { _timerForData = Timer.periodic(const Duration(seconds: 1), (timer) { final load = ref.watch(Global.connectionProvider).load; load.queryDelayOn(); - Future.delayed(const Duration(milliseconds: 100)).then((_) => load.queryDelayOff()); - Future.delayed(const Duration(milliseconds: 200)).then((_) => load.queryPeriodOn()); - Future.delayed(const Duration(milliseconds: 300)).then((_) => load.queryPeriodOff()); + Future.delayed(const Duration(milliseconds: 100), load.queryDelayOff); + Future.delayed(const Duration(milliseconds: 200), load.queryPeriodOn); + Future.delayed(const Duration(milliseconds: 300), load.queryPeriodOff); }); } diff --git a/lib/export_data.dart b/lib/export_data.dart index e94fd17..b6096cf 100644 --- a/lib/export_data.dart +++ b/lib/export_data.dart @@ -41,7 +41,7 @@ class _ExportPageState extends ConsumerState { void initState() { super.initState(); _nameCtrller.text = "m328v6_" + DateTime.now().format('yyyymmdd_HHMMSS') + ".xlsx"; - Future.delayed(const Duration(milliseconds: 500)).then(requestPermission); //延时确认权限并获取路径 + Future.delayed(const Duration(milliseconds: 500), requestPermission); //延时确认权限并获取路径 } @override diff --git a/lib/i18n/load_stats_page.i18n.dart b/lib/i18n/load_stats_page.i18n.dart index 7cf550d..ab54c00 100644 --- a/lib/i18n/load_stats_page.i18n.dart +++ b/lib/i18n/load_stats_page.i18n.dart @@ -49,27 +49,27 @@ extension Localization on String { } + { "en_us": "Initial Ah", - "zh_cn": "初始安时", + "zh_cn": "初始容量", } + { "en_us": "Ah", - "zh_cn": "本次安时", + "zh_cn": "本次容量", } + { "en_us": "Total Ah", - "zh_cn": "总安时", + "zh_cn": "累积容量", } + { "en_us": "Initial Wh", - "zh_cn": "初始瓦时", + "zh_cn": "初始能量", } + { "en_us": "Wh", - "zh_cn": "本次瓦时", + "zh_cn": "本次能量", } + { "en_us": "Total Wh", - "zh_cn": "总瓦时", + "zh_cn": "累积能量", } + { "en_us": "Mode", diff --git a/lib/load_stats_page.dart b/lib/load_stats_page.dart index 73b8b6a..41e1f5f 100644 --- a/lib/load_stats_page.dart +++ b/lib/load_stats_page.dart @@ -206,7 +206,7 @@ class _ExportLoadStatsPageState extends ConsumerState { void initState() { super.initState(); _nameCtrller.text = "load_stats_" + DateTime.now().format('yyyymmdd_HHMMSS') + ".xlsx"; - Future.delayed(const Duration(milliseconds: 500)).then(requestPermission); //延时确认权限并获取路径 + Future.delayed(const Duration(milliseconds: 500), requestPermission); //延时确认权限并获取路径 } @override diff --git a/lib/load_testers/max_i_tester.dart b/lib/load_testers/max_i_tester.dart index 28cba35..569c6a9 100644 --- a/lib/load_testers/max_i_tester.dart +++ b/lib/load_testers/max_i_tester.dart @@ -470,7 +470,7 @@ class _MaxITesterPageState extends ConsumerState { if (_stepTime == 0) { _stepTime = 1; } - Future.delayed(Duration(milliseconds: (_stepTime * 1000) - 500)).then((_) { + Future.delayed(Duration(milliseconds: (_stepTime * 1000) - 500), () { load.setI(65.535); Future.delayed(const Duration(milliseconds: 100), () => load.setV(65.535)); }); diff --git a/lib/main_page.dart b/lib/main_page.dart index 2f9bf10..ed9d255 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -72,7 +72,7 @@ class _MainPageState extends ConsumerState with AutomaticKeepAliveClie Global.bus.addListener(EventBus.connectionChanged, connectionChanged); Global.bus.addListener(EventBus.curvaFilterDotNumChanged, curvaFilterDotNumChanged); Global.bus.addListener(EventBus.setLoadOnOff, setLoadOnOffReceived); - Future.delayed(const Duration(seconds: 5)).then(checkNewVersion); //延时确定是否需要检查新版本 + Future.delayed(const Duration(seconds: 5), checkNewVersion); //延时确定是否需要检查新版本 _timerForExtraData = PausableTimer(const Duration(seconds: 3), qeuryVersionPeriodic); _timerForExtraData.pause(); @@ -84,7 +84,7 @@ class _MainPageState extends ConsumerState with AutomaticKeepAliveClie void qeuryVersionPeriodic() { final load = ref.read(Global.connectionProvider).load; load.requestExtraData(); - Future.delayed(const Duration(milliseconds: 100)).then((_) => load.queryVersion()); + Future.delayed(const Duration(milliseconds: 100), load.queryVersion); //_timerForExtraData..reset()..start(); } @@ -170,8 +170,8 @@ class _MainPageState extends ConsumerState with AutomaticKeepAliveClie connProvider.serial.registerListenFunction(newSrlDataReceived); //连接后马上查询下位机版本号,请求上报额外数据 - Future.delayed(const Duration(milliseconds: 250)).then((_) => connProvider.load.queryVersion()); - Future.delayed(const Duration(seconds: 500)).then((_) => connProvider.load.requestExtraData()); + Future.delayed(const Duration(milliseconds: 250), connProvider.load.queryVersion); + Future.delayed(const Duration(milliseconds: 500), connProvider.load.requestExtraData); _timerForExtraData..reset()..start(); } else { //断开连接 final rdProvider = ref.read(Global.runningDataProvider); @@ -911,7 +911,9 @@ class _MainPageState extends ConsumerState with AutomaticKeepAliveClie ///使用和下位机一样的计算功率算法,保证和下位机显示一致(因为下位机仅使用整数运算) ///最后的除以100是因为下位机使用10毫瓦为单位 + /// 2022-03-22 配置下位机修改,不需要复杂的计算公式了 double calP(int v, int i) { - return (((v ~/ 10) * i).toInt() ~/ 1000) / 100; + //return (((v ~/ 10) * i).toInt() ~/ 1000) / 100; + return ((v * i) ~/ 10000) / 100; } } diff --git a/lib/settings/settings.dart b/lib/settings/settings.dart index 7e72ae5..581ffcd 100644 --- a/lib/settings/settings.dart +++ b/lib/settings/settings.dart @@ -356,7 +356,7 @@ class _SettingsPageState extends ConsumerState { String? ret = await showInputDialog(context: context, title: "Enter a value from 0.000 to 1.000 (V)".i18n, initialText: Global.curvaFilterThreshold.toStringAsFixed(3), - formatters: [DecimalTextInputFormatter(), CustomMaxValueInputFormatter(1.0)], + //formatters: [DecimalTextInputFormatter(), CustomMaxValueInputFormatter(1.0)], ); if (ret != null) {