Skip to content

Commit

Permalink
v1.2.1
Browse files Browse the repository at this point in the history
1. 双击曲线区域可以查看每次放电的统计信息
2. 配合下位机V6.31,将功率单位修改为10毫瓦(显示小数点后两位)
3. 配合下位机V6.31,将恒阻模式的电阻单位修改为10毫欧
  • Loading branch information
cdhigh committed Mar 21, 2022
1 parent 5a71e71 commit d98b1ef
Show file tree
Hide file tree
Showing 17 changed files with 832 additions and 125 deletions.
55 changes: 17 additions & 38 deletions buildApk.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,57 +160,46 @@ def process():
shutil.copyfile(UNI_SERIAL_FILE, bakUniSerialDart)
shutil.copyfile(GLOBAL_FILE, bakGlobalsDart)

#开始修改文件
version, foundFlag = modifyPubspecYaml()
if not version:
print('\nVersion string not found in pubspec.yaml\n')
#恢复备份文件
#闭包函数,恢复备份文件
def restoreBakFiles():
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
shutil.rmtree(bakDir)
try:
shutil.rmtree(bakDir)
except:
pass

#开始修改文件
version, foundFlag = modifyPubspecYaml()
if not version:
print('\nVersion string not found in pubspec.yaml\n')
#恢复备份文件
restoreBakFiles()
os.system('pause')
return

ok = input('\nVersion found [{}]\n\nCorrect?[y/n]'.format(version))
if ok.lower() not in ('', 'y', 'yes', 'ok'):
#恢复备份文件
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
shutil.rmtree(bakDir)
restoreBakFiles()
return

foundFlag |= modifyUniSerialDart()
foundFlag |= modifyGlobalDart(version)
if (foundFlag != MODIFIED_ALL_MASK):
print('foundFlag : 0x{:x} != 0x{:x}!'.format(foundFlag, MODIFIED_ALL_MASK))
#恢复备份文件
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
shutil.rmtree(bakDir)
restoreBakFiles()
return

ok = input('\nPlease confirm modifications in pubspec.yaml/uni_serial.dart/globals.dart\n\nCorrect?[y/n]')
if ok.lower() not in ('', 'y', 'yes', 'ok'):
#恢复备份文件
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
shutil.rmtree(bakDir)
restoreBakFiles()
return


Expand All @@ -234,17 +223,7 @@ def process():
print("\n\nCopy apk file failed: {}\n\n".format(ste(e)))

#恢复备份文件
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
try:
shutil.rmtree(bakDir)
except:
#print("Delete backup directory [{}] failed:".format(bakDir))
pass
restoreBakFiles()

elaspsedTime = datetime.datetime.now() - startTime
print('\nExecution time : {}\n'.format(elaspsedTime))
Expand Down
55 changes: 17 additions & 38 deletions buildWindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,57 +158,46 @@ def process():
shutil.copyfile(UNI_SERIAL_FILE, bakUniSerialDart)
shutil.copyfile(GLOBAL_FILE, bakGlobalsDart)

#开始修改文件
version, foundFlag = modifyPubspecYaml()
if not version:
print('\nVersion string not found in pubspec.yaml\n')
#恢复备份文件
#闭包函数,恢复备份文件
def restoreBakFiles():
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
shutil.rmtree(bakDir)
try:
shutil.rmtree(bakDir)
except:
pass

#开始修改文件
version, foundFlag = modifyPubspecYaml()
if not version:
print('\nVersion string not found in pubspec.yaml\n')
#恢复备份文件
restoreBakFiles()
os.system('pause')
return

ok = input('\nVersion found [{}]\n\nCorrect?[y/n]'.format(version))
if ok.lower() not in ('', 'y', 'yes', 'ok'):
#恢复备份文件
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
shutil.rmtree(bakDir)
restoreBakFiles()
return

foundFlag |= modifyUniSerialDart()
foundFlag |= modifyGlobalDart(version)
if (foundFlag != MODIFIED_ALL_MASK):
print('foundFlag : 0x{:x} != 0x{:x}!'.format(foundFlag, MODIFIED_ALL_MASK))
#恢复备份文件
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
shutil.rmtree(bakDir)
restoreBakFiles()
return

ok = input('\nPlease confirm modifications in pubspec.yaml/uni_serial.dart/globals.dart\n\nCorrect?[y/n]')
if ok.lower() not in ('', 'y', 'yes', 'ok'):
#恢复备份文件
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
shutil.rmtree(bakDir)
restoreBakFiles()
return


Expand All @@ -232,17 +221,7 @@ def process():
print("\n\nCompress release directory failed: {}\n\n".format(ste(e)))

#恢复备份文件
os.remove(PUB_YAML_FILE)
os.remove(UNI_SERIAL_FILE)
os.remove(GLOBAL_FILE)
shutil.copyfile(bakPubspecYaml, PUB_YAML_FILE)
shutil.copyfile(bakUniSerialDart, UNI_SERIAL_FILE)
shutil.copyfile(bakGlobalsDart, GLOBAL_FILE)
try:
shutil.rmtree(bakDir)
except:
#print("Cannot delete backup directory {}".format(bakDir))
pass
restoreBakFiles()

elaspsedTime = datetime.datetime.now() - startTime
print('\nExecution time : {}\n'.format(elaspsedTime))
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.2.1
1. 双击曲线区域可以查看每次放电的统计信息
2. 配合下位机V6.31,将功率单位修改为10毫瓦(显示小数点后两位)
3. 配合下位机V6.31,将恒阻模式的电阻单位修改为10毫欧

# 1.2.0
1. 增加 "测试电源输出能力" 测试项
2. 增加 "测试电源短路保护能力" 测试项
Expand Down
2 changes: 1 addition & 1 deletion lib/common/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum KeepScreenOption {
///小部分为程序共用的变量
class Global {
//版本号注意需要使用单引号,让buildXXX.py能找的到
static const version = '1.2.0';
static const version = '1.2.1';
static const buildNumber = "";

static late final SharedPreferences prefs;
Expand Down
11 changes: 11 additions & 0 deletions lib/common/when.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
import 'bisect.dart';
import '../i18n/common.i18n.dart';

extension WhenDuration on Duration {
///将Duration转换为HH:MM:SS格式的字符串
String toTimeString() {
String twoDigits(int n) => n.toString().padLeft(2, "0");
String twoDigitMinutes = twoDigits(inMinutes.remainder(60));
String twoDigitSeconds = twoDigits(inSeconds.remainder(60));
return "${twoDigits(inHours)}:$twoDigitMinutes:$twoDigitSeconds";
}
}


extension When on DateTime {
///快捷函数,返回: yyyy-mm-dd HH:MM:SS格式
String toStdString() => format('yyyy-mm-dd HH:MM:SS');
Expand Down
175 changes: 175 additions & 0 deletions lib/i18n/load_stats_page.i18n.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/// 放电统计信息页面的国际化翻译文件
import 'package:i18n_extension/i18n_extension.dart';

extension Localization on String {
static var t = Translations("en_us") +
{
"en_us": "Load Stats",
"zh_cn": "放电统计信息",
} +
{
"en_us": "Export",
"zh_cn": "导出",
} +
{
"en_us": "No data",
"zh_cn": "没有数据",
} +
{
"en_us": "Click to add remark",
"zh_cn": "点击添加备注",
} +
{
"en_us": "Input a remark",
"zh_cn": "输入备注",
} +
{
"en_us": "Initial V",
"zh_cn": "初始电压",
} +
{
"en_us": "End V",
"zh_cn": "结束电压",
} +
{
"en_us": "Average V",
"zh_cn": "平均电压",
} +
{
"en_us": "Initial I",
"zh_cn": "初始电流",
} +
{
"en_us": "End I",
"zh_cn": "结束电流",
} +
{
"en_us": "Average I",
"zh_cn": "平均电流",
} +
{
"en_us": "Initial Ah",
"zh_cn": "初始安时",
} +
{
"en_us": "Ah",
"zh_cn": "本次安时",
} +
{
"en_us": "Total Ah",
"zh_cn": "总安时",
} +
{
"en_us": "Initial Wh",
"zh_cn": "初始瓦时",
} +
{
"en_us": "Wh",
"zh_cn": "本次瓦时",
} +
{
"en_us": "Total Wh",
"zh_cn": "总瓦时",
} +
{
"en_us": "Mode",
"zh_cn": "放电模式",
} +
{
"en_us": "CC",
"zh_cn": "恒流",
} +
{
"en_us": "CR",
"zh_cn": "恒阻",
} +
{
"en_us": "CP",
"zh_cn": "恒功率",
} +
{
"en_us": "CR value",
"zh_cn": "恒阻值",
} +
{
"en_us": "CP value",
"zh_cn": "恒功率值",
} +
{
"en_us": "Rd",
"zh_cn": "直流内阻",
} +
{
"en_us": "Ra",
"zh_cn": "交流内阻",
} +
{
"en_us": "Head sink",
"zh_cn": "散热器温度",
} +
{
"en_us": "Board",
"zh_cn": "主板温度",
} +
{
"en_us": "Start time",
"zh_cn": "开始时间",
} +
{
"en_us": "End time",
"zh_cn": "结束时间",
} +
{
"en_us": "Duration",
"zh_cn": "持续时间",
} +
{
"en_us": "Export load stats data",
"zh_cn": "导出放电统计数据",
} +
{
"en_us": "Export folder",
"zh_cn": "导出目录",
} +
{
"en_us": "Select a folder to save",
"zh_cn": "选择一个保存目录",
} +
{
"en_us": "File name",
"zh_cn": "文件名",
} +
{
"en_us": "Enter a name to save",
"zh_cn": "输入一个保存文件名",
} +
{
"en_us": "Success",
"zh_cn": "成功",
} +
{
"en_us": "Export load stats file success",
"zh_cn": "导出放电统计信息文件成功",
} +
{
"en_us": "Item",
"zh_cn": "条目",
} +
{
"en_us": "Value",
"zh_cn": "数值",
} +
{
"en_us": "Unit",
"zh_cn": "单位",
} +
{
"en_us": "Remark",
"zh_cn": "备注",
};

String get i18n => localize(this, t);

//"Hello %s, this is %s".i18n.fill(["John", "Mary"])
String fill(List<Object> params) => localizeFill(this, params);
}
Loading

0 comments on commit d98b1ef

Please sign in to comment.