增加log记录、VIN记录
This commit is contained in:
parent
3df8c235b0
commit
f12c067215
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
/dist
|
||||
/.build
|
||||
/log
|
||||
/配置文件.ini
|
||||
|
@ -9,10 +9,8 @@ static={cls="static";text="Static";left=21;top=17;right=458;bottom=340;transpare
|
||||
|
||||
更新履历 = /*
|
||||
V0.1_20230320: 初版
|
||||
V0.2_20230321: 修复右板无法刷写,增加点亮功能,增加更改履历
|
||||
V0.3_20230321: 修复关闭界面后程序没有完全关闭的问题
|
||||
V0.4_20230322: 修复偶发刷写卡在请求下载的问题
|
||||
V0.5_20230401: 兼容0331程序无法读DID
|
||||
V0.2_20240921: 中英文版本
|
||||
v0.3_20241009: 增加日志记录;增加VIN记录;
|
||||
*/
|
||||
|
||||
winform.button.oncommand = function(id,event){
|
||||
|
149
main.aardio
149
main.aardio
@ -1,7 +1,7 @@
|
||||
import fonts.fontAwesome;
|
||||
import win.ui;
|
||||
/*DSG{{*/
|
||||
mainForm = win.form(text="CAN_Bootloader";right=699;bottom=465;border="dialog frame";max=false)
|
||||
mainForm = win.form(text="CAN_Bootloader";right=699;bottom=473;border="dialog frame";max=false)
|
||||
mainForm.add(
|
||||
btnFlashLeft={cls="button";text="左侧刷写
|
||||
Left side flashing";left=30;top=129;right=168;bottom=243;z=2};
|
||||
@ -15,17 +15,60 @@ Waiting for flashing";left=33;top=375;right=316;bottom=460;bgcolor=12639424;z=10
|
||||
progress={cls="progress";left=361;top=435;right=689;bottom=463;edge=1;max=100;min=0;z=4};
|
||||
static={cls="static";text='\uF127';left=43;top=30;right=114;bottom=98;align="center";center=1;color=255;font=LOGFONT(h=-56;name='FontAwesome');transparent=1;z=8};
|
||||
static2={cls="static";text="设备未连接,请先连接设备";left=126;top=42;right=326;bottom=91;transparent=1;z=9};
|
||||
static3={cls="static";text="刷写进度 Brush writing progress";left=361;top=410;right=688;bottom=430;transparent=1;z=5};
|
||||
static5={cls="static";text="V0.2_20240921";left=545;top=1;right=689;bottom=17;align="right";center=1;notify=1;transparent=1;z=6}
|
||||
static3={cls="static";text="刷写进度 Flashing writing progress";left=361;top=410;right=688;bottom=430;transparent=1;z=5};
|
||||
static4={cls="static";text="no.";left=39;top=102;right=141;bottom=122;align="right";transparent=1;z=11};
|
||||
static5={cls="static";text="V0.3_20241009";left=545;top=1;right=689;bottom=17;align="right";center=1;notify=1;transparent=1;z=6};
|
||||
static6={cls="static";text="00000";left=145;top=102;right=203;bottom=120;transparent=1;z=12}
|
||||
)
|
||||
/*}}*/
|
||||
|
||||
import win;
|
||||
import usb2canfd;
|
||||
import win.timer;
|
||||
import win.inputBox;
|
||||
import fsys.ini;
|
||||
|
||||
import console
|
||||
|
||||
// 获取当前时间
|
||||
var currentDate = time.now()
|
||||
|
||||
// 设置格式化字符串为 "YYYYMMDD"
|
||||
currentDate.format = "%Y%m%d"
|
||||
|
||||
|
||||
side_now = "";
|
||||
|
||||
var bootstate = false;//boot状态标志
|
||||
|
||||
var inifile=fsys.ini("\配置文件.ini");
|
||||
//读取小节对象
|
||||
sec = inifile.getSection("计数");
|
||||
|
||||
if(sec.当前计数 == null){
|
||||
sec.当前计数 = 1;
|
||||
sec.左成功 = 0;
|
||||
sec.左失败 = 0;
|
||||
sec.右成功 = 0;
|
||||
sec.右失败 = 0;
|
||||
//sec.VIN = "YSM4ZPAA0SF405299";
|
||||
sec.save()
|
||||
}
|
||||
|
||||
当前计数 = sec.当前计数;
|
||||
左成功 = sec.左成功;
|
||||
左失败 = sec.左失败;
|
||||
右成功 = sec.右成功;
|
||||
右失败 = sec.右失败;
|
||||
|
||||
//console.dump(sec);
|
||||
|
||||
mainForm.static6.text = string.format("%05d",当前计数);
|
||||
|
||||
//VINCODE = sec.VIN;
|
||||
|
||||
//console.log(VINCODE);
|
||||
|
||||
Display = function(str){//显示日志
|
||||
var nowtime = time();
|
||||
nowtime.format="%H:%M:%S";
|
||||
@ -45,6 +88,21 @@ else {
|
||||
");
|
||||
}
|
||||
|
||||
var write_log_file = function(id,ifsuccess,vin){
|
||||
if(ifsuccess){
|
||||
success = "success";
|
||||
}
|
||||
else {
|
||||
success = "failed";
|
||||
}
|
||||
|
||||
var vinr6 = string.right(vin,6);
|
||||
var logfile_name = string.format("\log\%05d_%s_%s_%s.txt",当前计数,success,vinr6,side_now);
|
||||
//console.log(logfile_name);
|
||||
//string.save(logfile_name,"VIN = " ++ vin);
|
||||
string.save(logfile_name,'test');
|
||||
string.save(logfile_name, mainForm.edit.text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -82,11 +140,18 @@ listener.$SendEnd = function(isSuccess){
|
||||
bootstate = false;
|
||||
if(isSuccess == true){
|
||||
Display("刷写成功,用时 " + usetime + " S")
|
||||
Display("Brushed successfully, took "+usetime+" S
|
||||
Display("Flashing successfully, took "+usetime+" S
|
||||
");
|
||||
mainForm.plus.text = "刷写完成\Brushed successfully";
|
||||
mainForm.plus.text = "刷写完成\Flashing successfully";
|
||||
//mainForm.plus.bgcolor = 0x32CD32;
|
||||
mainForm.plus.background = 0xFF32CD32;
|
||||
if(side_now == "L"){
|
||||
左成功 += 1;
|
||||
}
|
||||
else {
|
||||
右成功 += 1;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
Display("刷写失败");
|
||||
@ -95,8 +160,25 @@ listener.$SendEnd = function(isSuccess){
|
||||
mainForm.plus.text = "刷写失败 Flashing failed";
|
||||
//mainForm.plus.bgcolor = 0x2200E3;
|
||||
mainForm.plus.background = 0xFFE30022;
|
||||
if(side_now == "L"){
|
||||
左失败 += 1;
|
||||
}
|
||||
else {
|
||||
右失败 += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
write_log_file(当前计数,isSuccess,VINCODE);
|
||||
当前计数 += 1;
|
||||
mainForm.static6.text = string.format("%05d",当前计数);
|
||||
sec.当前计数 = 当前计数;
|
||||
sec.左成功 = 左成功;
|
||||
sec.左失败 = 左失败;
|
||||
sec.右成功 = 右成功;
|
||||
sec.右失败 = 右失败;
|
||||
//sec.VIN = VINCODE;
|
||||
sec.save();
|
||||
}
|
||||
import thread.table;
|
||||
thrdTable = thread.table("多线程共享数据");
|
||||
@ -137,6 +219,7 @@ var DiagStopReq = function(){
|
||||
//import console;
|
||||
//console.log("1");
|
||||
mainForm.btnFlashLeft.oncommand = function(id,event){
|
||||
|
||||
if(thrdTable.设备连接状态 == 0){
|
||||
Display("设备未连接");
|
||||
Display("device not connected
|
||||
@ -152,12 +235,27 @@ mainForm.btnFlashLeft.oncommand = function(id,event){
|
||||
");
|
||||
return;
|
||||
}
|
||||
// 创建一个输入对话框
|
||||
var inputBox = win.inputBox();
|
||||
inputBox.info.text = "请输入VIN码:";
|
||||
inputBox.input.text = VINCODE;
|
||||
inputBox.text = "输入VIN码";
|
||||
// 显示输入对话框并获取用户输入
|
||||
var result = inputBox.doModal();
|
||||
if(result == null){
|
||||
Display('请输入正确的VIN');
|
||||
Display('Please enter the correct VIN\n')
|
||||
return;
|
||||
}
|
||||
VINCODE = result;
|
||||
side_now = "L";
|
||||
bootstate = true;
|
||||
mainForm.edit.text = "";
|
||||
Display("VIN:" ++ VINCODE ++ '\n');
|
||||
::PostThreadMessage(thrdId,106,0x720,0x620);//自定义消息
|
||||
Display("开始刷写流程");
|
||||
Display("Start flashing process
|
||||
");
|
||||
Display(tostring(currentDate));
|
||||
Display("左侧开始刷写流程");
|
||||
Display('Start flashing process\n');
|
||||
starttime = time.now();
|
||||
DiagBootReq(1);//左侧
|
||||
}
|
||||
@ -212,8 +310,8 @@ autoconnect.onTimer = function(){
|
||||
|
||||
}
|
||||
else {
|
||||
import console;
|
||||
console.log(thrdTable["电源电压"])
|
||||
//import console;
|
||||
//console.log(thrdTable["电源电压"])
|
||||
autoconnect_state = 3;
|
||||
}
|
||||
|
||||
@ -260,14 +358,31 @@ mainForm.btnFlashRight.oncommand = function(id,event){
|
||||
");
|
||||
return;
|
||||
}
|
||||
// 创建一个输入对话框
|
||||
var inputBox = win.inputBox();
|
||||
inputBox.info.text = "请输入VIN码:";
|
||||
//inputBox.input.text = VINCODE;
|
||||
inputBox.text = "输入VIN码";
|
||||
// 显示输入对话框并获取用户输入
|
||||
var result = inputBox.doModal();
|
||||
if(result == null ){
|
||||
Display('请输入正确的VIN');
|
||||
Display('Please enter the correct VIN\n')
|
||||
return;
|
||||
}
|
||||
VINCODE = result;
|
||||
|
||||
side_now = "R";
|
||||
bootstate = true;
|
||||
mainForm.edit.text = "";
|
||||
Display("VIN:" ++ VINCODE ++ '\n');
|
||||
::PostThreadMessage(thrdId,106,0x710,0x610);//自定义消息
|
||||
Display("开始刷写流程");
|
||||
Display(tostring(currentDate));
|
||||
Display("右侧开始刷写流程");
|
||||
Display("Start flashing process
|
||||
");
|
||||
starttime = time.now();
|
||||
DiagBootReq(2);//左侧
|
||||
DiagBootReq(2);//
|
||||
}
|
||||
|
||||
mainForm.btnStopBoot.oncommand = function(id,event){
|
||||
@ -278,6 +393,16 @@ autoconnect.enable();
|
||||
|
||||
//import console;
|
||||
//console.log("io.exis = ",io.exist("\res\P417_SWTL_20240709.S19"));
|
||||
click_times = 0;
|
||||
mainForm.static5.oncommand = function(id,event){
|
||||
click_times+=1;
|
||||
if(click_times >= 5){
|
||||
|
||||
var frmChild = mainForm.loadForm("\dlg\about.aardio");
|
||||
frmChild.show();
|
||||
click_times = 0;
|
||||
}
|
||||
}
|
||||
|
||||
thrdHandle,thrdId = thread.create( CanThread );
|
||||
mainForm.show();
|
||||
|
@ -324,9 +324,23 @@ boottimer.onTimer = function(){
|
||||
FuncBootSeq();
|
||||
}
|
||||
|
||||
LeftVibrationFault = 0;
|
||||
LeftTouchFault = 0;
|
||||
LeftPressSensorFault = 0;
|
||||
LeftCommonFault = 0;
|
||||
|
||||
RightVibrationFault = 0;
|
||||
RightTouchFault = 0;
|
||||
RightPressSensorFault = 0;
|
||||
RightCommonFault = 0;
|
||||
|
||||
timer1 = win.timer(,1);
|
||||
diagresp = {}
|
||||
|
||||
getbitdata = function(byte,startbit,len){
|
||||
return ((byte>>startbit) & ((1<<len) - 1));
|
||||
}
|
||||
|
||||
timer1.onTimer = function(){
|
||||
if(CANHw.isConnected() == false){
|
||||
return;
|
||||
@ -369,8 +383,24 @@ timer1.onTimer = function(){
|
||||
}
|
||||
}
|
||||
else {
|
||||
//console.log(..string.format("%x",ret[i].id));
|
||||
//显示报文
|
||||
var id = ret[i].id & 0x7FFFFFFF;
|
||||
select(id) {
|
||||
case 0x34 {
|
||||
//console.log("get 0x34");
|
||||
LeftVibrationFault = getbitdata(ret[i].data[1],0,2);
|
||||
LeftTouchFault = getbitdata(ret[i].data[1],2,2);
|
||||
LeftPressSensorFault = getbitdata(ret[i].data[1],4,3);
|
||||
LeftCommonFault = getbitdata(ret[i].data[1],7,1);
|
||||
}
|
||||
case 0x38 {
|
||||
RightVibrationFault = getbitdata(ret[i].data[1],0,2);
|
||||
RightTouchFault = getbitdata(ret[i].data[1],2,2);
|
||||
RightPressSensorFault = getbitdata(ret[i].data[1],4,3);
|
||||
RightCommonFault = getbitdata(ret[i].data[1],7,1);
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ FuncWait = function(sid){
|
||||
}
|
||||
else {
|
||||
FuncDisplay("刷写错误 步骤" + bootstate);
|
||||
FuncDisplay("Brushing error steps" + bootstate++"
|
||||
FuncDisplay("Flashing error steps" + bootstate++"
|
||||
");
|
||||
boottimer.disable();
|
||||
thread.command.$SendEnd(false);
|
||||
@ -38,8 +38,7 @@ FuncWait = function(sid){
|
||||
bootcount += 1;
|
||||
if(bootcount >= 400){
|
||||
FuncDisplay("步骤" + bootstate + "超时 " + tostring(sid,16));
|
||||
FuncDisplay("Step" + bootstate + " Timeout " + tostring(sid,16)++"
|
||||
");
|
||||
FuncDisplay("Step" + bootstate + " Timeout " + tostring(sid,16)++'\n');
|
||||
thread.command.$SendEnd(false);
|
||||
boottimer.disable();
|
||||
return 3;//超时
|
||||
@ -221,6 +220,19 @@ FuncBootSeq = function(){
|
||||
boottime = 1;
|
||||
nextstate(0);
|
||||
delaycount = 0;
|
||||
if(DiagReqID == 0x720){
|
||||
FuncDisplay("LeftVibrationFault = " ++ LeftVibrationFault);
|
||||
FuncDisplay("LeftTouchFault = " ++ LeftTouchFault);
|
||||
FuncDisplay("LeftPressSensorFault = " ++ LeftPressSensorFault);
|
||||
FuncDisplay("LeftCommonFault = " ++ LeftCommonFault);
|
||||
}
|
||||
else {
|
||||
FuncDisplay("RightVibrationFault = " ++ RightVibrationFault);
|
||||
FuncDisplay("RightTouchFault = " ++ RightTouchFault);
|
||||
FuncDisplay("RightPressSensorFault = " ++ RightPressSensorFault);
|
||||
FuncDisplay("RightCommonFault = " ++ RightCommonFault);
|
||||
}
|
||||
FuncDisplay('\n');
|
||||
/*
|
||||
if(sendstate == 0){
|
||||
//FuncSendBlockInit(0);
|
||||
@ -554,8 +566,7 @@ FuncBootSeq = function(){
|
||||
case 23 {
|
||||
if(sendstate == 0){
|
||||
FuncDisplay("读取版本");
|
||||
FuncDisplay("Read version
|
||||
");
|
||||
FuncDisplay('Read version\n');
|
||||
FuncReadDID(0xF195);//读取软件版本
|
||||
delaycount = 0;
|
||||
FuncClearState();
|
||||
@ -571,8 +582,7 @@ FuncBootSeq = function(){
|
||||
case 24 {
|
||||
if(sendstate == 0){
|
||||
FuncDisplay("读取软件日期");
|
||||
FuncDisplay("Read software date
|
||||
");
|
||||
FuncDisplay('Read software date \n');
|
||||
FuncReadDID(0xF18A);//读取软件版本
|
||||
FuncClearState();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user