Skip to content

Commit

Permalink
V1.1.0
Browse files Browse the repository at this point in the history
1. 增加“自动重连”功能,和电子负载的连接异常中断后能自动重新连接(限制5分钟内)
2. 增加将原始放电数据导出到XLSX(带折线图)和TXT功能
  • Loading branch information
cdhigh committed Mar 4, 2022
1 parent c665e56 commit abb9abc
Show file tree
Hide file tree
Showing 33 changed files with 1,000 additions and 211 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# m328v6上位机APP
# m328v6数控电子负载上位机APP

这个是针对一乐论坛 M8V6数控电子负载 的 升级版 M328V6数控电子负载 的新版上位机。
[M328V6数控电子负载](https://www.yleee.com.cn/thread-90734-1-1.html)
这个是一乐论坛[M8V6数控电子负载]的升级版[M328V6数控电子负载]的新版上位机。
[M328V6数控电子负载制作链接](https://www.yleee.com.cn/thread-90734-1-1.html)

## 特性:
1. 支持Android, iOS, Windows, Mac OS, Linux
1. 支持Android, iOS, Windows, Mac OS, Linux(注1,2)
2. 支持多语种
3. 支持OTG有线连接USB串口和无线连接蓝牙串口
3. 支持OTG有线连接USB串口/无线连接蓝牙串口/主板原生串口
4. 支持全功能的控制下位机
5. 支持放电曲线显示
6. 支持保持屏幕常亮
5. 支持放电曲线显示
6. 支持保持屏幕常亮

*注1:仅提供Android/Windows二进制包,其他平台需要自己编译*
*注2:windows版本仅支持64位Windows7及更新的系统*




## 屏幕截图:

Expand Down
6 changes: 5 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<application
android:label="m328v6"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down Expand Up @@ -49,6 +50,9 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>

Expand Down
Binary file modified assets/fonts/iconfont.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion buildApk.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
DART_LIBSERIAL_STUB_PAT = re.compile(r"^(/{0,2})(import 'flutter_libserialport_stub.dart' as lib_serial;.*)$")

#"lib/common/globals.dart
GLOBAL_VERSION_PAT = re.compile(r"^( *static +const +version += +[\"'])(1.0.0)([\"'].*)$")
GLOBAL_VERSION_PAT = re.compile(r"^( *static +const +version += +[\"'])([0-9\.]+)([\"'].*)$")

VERSION_MASK = 0x01
YAML_LIBSERIAL_MASK = 0x02
Expand Down
2 changes: 1 addition & 1 deletion buildWindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
DART_LIBSERIAL_STUB_PAT = re.compile(r"^(/{0,2})(import 'flutter_libserialport_stub.dart' as lib_serial;.*)$")

#"lib/common/globals.dart
GLOBAL_VERSION_PAT = re.compile(r"^( *static +const +version += +[\"'])(1.0.0)([\"'].*)$")
GLOBAL_VERSION_PAT = re.compile(r"^( *static +const +version += +[\"'])([0-9\.]+)([\"'].*)$")

VERSION_MASK = 0x01
YAML_LIBSERIAL_MASK = 0x02
Expand Down
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 1.1.0
1. 增加“自动重连”功能,和电子负载的连接异常中断后能自动重新连接(限制5分钟内)
2. 增加将原始放电数据导出到XLSX(带折线图)和TXT功能
注:Android低于5.1版本不能选择导出目录,默认导出到下载目录

# 1.0.0 - M328V6 App的第一个版本
1. 支持放电曲线绘制
2. 支持控制下位机


4 changes: 4 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,9 @@
<string>https</string>
<string>http</string>
</array>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
</dict>
</plist>
20 changes: 20 additions & 0 deletions lib/common/common_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ String readableSeconds(int seconds) {
}
}

///比较两个版本号,确定新版本号是否比老版本号更新,
///版本号格式为:1.1.0,可能在最后还有一个修订版本号: 1.1.0+1,但是会忽略修订版本号(我不用修订版本号)
bool isVersionGreaterThan(String newVersion, String currVersion){
final newV = newVersion.replaceAll("+", ".").split(".");
final currV = currVersion.replaceAll("+", ".").split(".");
final maxSeg = min(newV.length, currV.length);
for (var i = 0 ; i <= maxSeg - 1; i++) {
final vn = int.tryParse(newV[i]);
final vc = int.tryParse(currV[i]);
if ((vn == null) || (vc == null)) {
return false;
}

if (vn != vc) {
return (vn > vc);
}
}
return false;
}

///将字节数转换为可以直读的字符串(比如:xxx KB, xxx MB)
String formatBytes(int bytes, {int decimals=2}) {
if (bytes <= 0) {
Expand Down
20 changes: 14 additions & 6 deletions lib/common/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ enum KeepScreenOption {
///小部分为程序共用的变量
class Global {
//版本号注意需要使用单引号,让buildXXX.py能找的到
static const version = '1.0.0';
static const version = '1.1.0';
static const buildNumber = "";

static late final SharedPreferences prefs;

static bool firstTimeRuning = true; //是否是本应用第一次运行
static int checkUpdateFrequency = 7; //检查新版本频率(天数)
static DateTime lastCheckUpdateTime = DateTime(1970); //上次检查新版本的时标
static int defaultBaudRate = 19200; //默认波特率
static late final SharedPreferences prefs;
static String selectedLanguage = ''; //当前选择的语种,空则为自动
static String selectedTheme = ''; //当前选择的主题,空则为自动
static Color homePageBackgroundColor = const Color(0xff0e0e0e); //主导航页面的背景颜色
Expand All @@ -43,10 +43,11 @@ class Global {
static KeepScreenOption keepScreenOn = KeepScreenOption.always;
static DateTime lastPaused = DateTime.now(); //上次切换到后台的时间
static DateTime lastHeartBeat = DateTime.now(); //上次接收到下位机的时间
static bool offlineMode = false; //是否处于离线模式
static String lastSerialPort = "";
static int lastBaudRate = 19200;
static bool autoReconnect = true; //是否异常中断后自动重连
static int curvaFilterDotNum = 3; //放电曲线的平滑点数
static double curvaFilterThreshold = 0.1; //放电曲线平滑阀值,大于此数值的点不被平均滤波

//各种tile的背景色和分割色
static Color get tileBkColor => Colors.white;
Expand All @@ -69,11 +70,16 @@ class Global {
keepScreenOn = KeepScreenOption.values[onValue];
lastSerialPort = prefs.getString('lastSerialPort') ?? "";
lastBaudRate = prefs.getInt('lastBaudRate') ?? 19200;
autoReconnect = prefs.getBool('autoReconnect') ?? true;
curvaFilterDotNum = prefs.getInt('curvaFilterDotNum') ?? 3;
if (curvaFilterDotNum == 0) {
curvaFilterDotNum = 1;
} else if (curvaFilterDotNum > 10) {
curvaFilterDotNum = 10;
} else if (curvaFilterDotNum > 9) {
curvaFilterDotNum = 9;
}
curvaFilterThreshold = prefs.getDouble('curvaFilterThreshold') ?? 0.1;
if (curvaFilterThreshold > 1.0) {
curvaFilterThreshold = 1.0;
}
} catch (e) {
//print(e.toString());
Expand All @@ -93,7 +99,9 @@ class Global {
prefs.setInt("keepScreenOn", keepScreenOn.index);
prefs.setString("lastSerialPort", lastSerialPort);
prefs.setInt('lastBaudRate', lastBaudRate);
prefs.setBool('autoReconnect', autoReconnect);
prefs.setInt('curvaFilterDotNum', curvaFilterDotNum);
prefs.setDouble('curvaFilterThreshold', curvaFilterThreshold);
}

///这个全局key要注册到MaterialApp的navigatorKey属性
Expand Down
7 changes: 7 additions & 0 deletions lib/common/iconfont.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@ import 'package:flutter/widgets.dart';
class IconFont {
static const String _family = 'iconfont';
IconFont._();
static const IconData device3 = IconData(0xe785, fontFamily: _family);
static const IconData device2 = IconData(0xe664, fontFamily: _family);
static const IconData device = IconData(0xe642, fontFamily: _family);
static const IconData fileType = IconData(0xe618, fontFamily: _family);
static const IconData connect = IconData(0xe6c0, fontFamily: _family);
static const IconData disconnect = IconData(0xe66b, fontFamily: _family);
static const IconData dot3 = IconData(0xe656, fontFamily: _family);
static const IconData serialPort = IconData(0xe895, fontFamily: _family);
}
1 change: 1 addition & 0 deletions lib/common/widget_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ Decoration containerDivider({bool left=false, bool top=false, bool right=false,
)
);
}

Loading

0 comments on commit abb9abc

Please sign in to comment.