2023-03-14 15:49:33 +08:00
|
|
|
import win.ui;
|
|
|
|
/*DSG{{*/
|
|
|
|
var winform = win.form(text="aardio form";right=984;bottom=599;bgcolor=16777215)
|
|
|
|
winform.add(
|
2023-03-25 17:03:26 +08:00
|
|
|
btn1001={cls="button";text="默认会话";left=28;top=58;right=115;bottom=88;ah=1;aw=1;z=4};
|
|
|
|
btn1003={cls="button";text="扩展会话";left=126;top=58;right=213;bottom=88;ah=1;aw=1;z=5};
|
2023-04-11 17:06:18 +08:00
|
|
|
btnConvert={cls="button";text="转换";left=541;top=463;right=619;bottom=493;ah=1;aw=1;z=46};
|
2023-07-26 15:48:18 +08:00
|
|
|
btnRead7022={cls="button";text="预压值";left=232;top=212;right=319;bottom=242;ah=1;aw=1;z=54};
|
2023-04-11 17:06:18 +08:00
|
|
|
btnReadConfig={cls="button";text="读取配置";left=531;top=545;right=625;bottom=578;z=48};
|
2023-07-26 15:48:18 +08:00
|
|
|
btnReadF187={cls="button";text="ECU零件号";left=232;top=255;right=319;bottom=285;ah=1;aw=1;z=18};
|
|
|
|
btnReadF18A={cls="button";text="供应商ID";left=35;top=255;right=122;bottom=285;ah=1;aw=1;z=19};
|
|
|
|
btnReadF190={cls="button";text="VIN码";left=133;top=255;right=220;bottom=285;ah=1;aw=1;z=20};
|
|
|
|
btnReadF193={cls="button";text="硬件版本";left=35;top=298;right=122;bottom=328;ah=1;aw=1;z=22};
|
|
|
|
btnReadF195={cls="button";text="软件版本";left=133;top=298;right=222;bottom=328;ah=1;aw=1;z=23};
|
|
|
|
btnReadF198={cls="button";text="维修店代码";left=133;top=213;right=220;bottom=243;ah=1;aw=1;z=21};
|
|
|
|
btnReadF199={cls="button";text="刷写日期";left=35;top=213;right=122;bottom=243;ah=1;aw=1;z=17};
|
2023-03-25 17:03:26 +08:00
|
|
|
btnReadPressTh={cls="button";text="读取";left=420;top=418;right=507;bottom=448;ah=1;aw=1;z=10};
|
2023-07-26 15:48:18 +08:00
|
|
|
btnWrite9001={cls="button";text="触发震动";left=43;top=404;right=282;bottom=434;ah=1;aw=1;z=24};
|
|
|
|
btnWrite9002={cls="button";text="写入参考电压";left=182;top=442;right=282;bottom=472;ah=1;aw=1;z=27};
|
|
|
|
btnWrite9003={cls="button";text="写入增益";left=181;top=480;right=282;bottom=510;ah=1;aw=1;z=28};
|
|
|
|
btnWrite9004={cls="button";text="写入周期";left=182;top=518;right=283;bottom=548;ah=1;aw=1;z=51};
|
|
|
|
btnWriteA00100={cls="button";text="调试帧关";left=126;top=98;right=213;bottom=128;ah=1;aw=1;z=53};
|
|
|
|
btnWriteA00101={cls="button";text="调试帧开";left=27;top=98;right=114;bottom=128;ah=1;aw=1;z=52};
|
2023-04-11 17:06:18 +08:00
|
|
|
btnWriteConfig={cls="button";text="写入配置";left=415;top=545;right=510;bottom=570;hide=1;z=49};
|
2023-03-25 17:03:26 +08:00
|
|
|
btnWritePressTh={cls="button";text="写入";left=524;top=418;right=611;bottom=448;ah=1;aw=1;z=11};
|
|
|
|
cb3E={cls="checkbox";text="3E保持";left=232;top=64;right=306;bottom=86;ah=1;aw=1;bgcolor=16777215;z=6};
|
2023-07-26 15:48:18 +08:00
|
|
|
cbbDacRef={cls="combobox";left=43;top=442;right=173;bottom=468;ah=1;aw=1;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=25};
|
|
|
|
cbbMotorGain={cls="combobox";left=43;top=480;right=173;bottom=506;ah=1;aw=1;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=26};
|
2023-04-11 17:06:18 +08:00
|
|
|
combobox={cls="combobox";left=408;top=508;right=629;bottom=534;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=47};
|
2023-07-26 15:48:18 +08:00
|
|
|
edDACPeriod={cls="edit";text="80";left=43;top=518;right=173;bottom=550;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=50};
|
2023-04-11 17:06:18 +08:00
|
|
|
edFactor={cls="edit";text="1.0";left=457;top=464;right=531;bottom=491;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);z=44};
|
|
|
|
edLog={cls="edit";left=649;top=12;right=970;bottom=586;ah=1;aw=1;edge=1;font=LOGFONT(h=-18);multiline=1;z=12};
|
|
|
|
edPressTh1={cls="edit";text="500";left=531;top=97;right=605;bottom=124;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=9};
|
|
|
|
edPressTh2={cls="edit";text="500";left=531;top=136;right=605;bottom=163;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=37};
|
|
|
|
edPressTh3={cls="edit";text="500";left=531;top=175;right=605;bottom=202;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=38};
|
|
|
|
edPressTh4={cls="edit";text="500";left=531;top=215;right=605;bottom=242;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=39};
|
|
|
|
edPressTh5={cls="edit";text="500";left=531;top=254;right=605;bottom=281;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=40};
|
|
|
|
edPressTh6={cls="edit";text="500";left=531;top=294;right=605;bottom=321;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=41};
|
|
|
|
edPressTh7={cls="edit";text="500";left=531;top=333;right=605;bottom=360;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=42};
|
|
|
|
edPressTh8={cls="edit";text="500";left=531;top=373;right=605;bottom=400;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=43};
|
|
|
|
groupbox={cls="groupbox";text="标定";left=398;top=13;right=638;bottom=586;ah=1;aw=1;edge=1;z=1};
|
2023-07-26 15:48:18 +08:00
|
|
|
groupbox2={cls="groupbox";text="读取DID";left=20;top=181;right=329;bottom=347;ah=1;aw=1;edge=1;z=3};
|
|
|
|
groupbox3={cls="groupbox";text="震动";left=20;top=365;right=329;bottom=581;ah=1;aw=1;edge=1;z=2};
|
2023-03-25 17:03:26 +08:00
|
|
|
rbLeft={cls="radiobutton";text="左侧";left=61;top=15;right=115;bottom=35;ah=1;aw=1;bgcolor=16777215;checked=1;group=1;z=7};
|
|
|
|
rbPressTh={cls="radiobutton";text="压力";left=440;top=35;right=506;bottom=61;ah=1;aw=1;bgcolor=16777215;checked=1;group=1;z=15};
|
|
|
|
rbRight={cls="radiobutton";text="右侧";left=141;top=15;right=195;bottom=35;ah=1;aw=1;bgcolor=16777215;z=8};
|
|
|
|
rbTouchTh={cls="radiobutton";text="触摸";left=529;top=35;right=595;bottom=61;ah=1;aw=1;bgcolor=16777215;z=16};
|
|
|
|
static={cls="static";text="按键";left=445;top=67;right=500;bottom=96;ah=1;aw=1;font=LOGFONT(h=-18);transparent=1;z=13};
|
|
|
|
static10={cls="static";text="OK";left=420;top=371;right=521;bottom=398;center=1;font=LOGFONT(h=-18);transparent=1;z=36};
|
2023-04-11 17:06:18 +08:00
|
|
|
static11={cls="static";text="系数";left=411;top=463;right=449;bottom=490;center=1;font=LOGFONT(h=-18);transparent=1;z=45};
|
2023-03-25 17:03:26 +08:00
|
|
|
static2={cls="static";text="阈值";left=543;top=68;right=598;bottom=97;ah=1;aw=1;font=LOGFONT(h=-18);notify=1;transparent=1;z=14};
|
|
|
|
static3={cls="static";text="恢复/语音";left=420;top=97;right=521;bottom=124;center=1;font=LOGFONT(h=-18);transparent=1;z=29};
|
|
|
|
static4={cls="static";text="巡航/菜单";left=420;top=136;right=521;bottom=163;center=1;font=LOGFONT(h=-18);transparent=1;z=30};
|
|
|
|
static5={cls="static";text="取消/返回";left=420;top=175;right=521;bottom=202;center=1;font=LOGFONT(h=-18);transparent=1;z=31};
|
|
|
|
static6={cls="static";text="上";left=420;top=214;right=521;bottom=238;center=1;font=LOGFONT(h=-18);transparent=1;z=32};
|
|
|
|
static7={cls="static";text="下";left=420;top=254;right=521;bottom=281;center=1;font=LOGFONT(h=-18);transparent=1;z=33};
|
|
|
|
static8={cls="static";text="左";left=420;top=293;right=521;bottom=320;center=1;font=LOGFONT(h=-18);transparent=1;z=34};
|
|
|
|
static9={cls="static";text="右";left=420;top=332;right=521;bottom=359;center=1;font=LOGFONT(h=-18);transparent=1;z=35}
|
2023-03-14 15:49:33 +08:00
|
|
|
)
|
|
|
|
/*}}*/
|
|
|
|
|
|
|
|
LSW_KeyArr = {"恢复","巡航","取消","上","下","左","右","OK"};
|
|
|
|
RSW_KeyArr = {"语音","菜单","返回","上","下","左","右","OK"};
|
|
|
|
Motor_refArr = {"0x0 1V0","0x1 1V1","0x2 1V2","0x3 1V25","0x4 2V0","0x5 2V2","0x6 2V4","0x7 2V5"};
|
|
|
|
Motor_gainArr = {"Level0","Level1","Level2","Level3"}
|
2023-03-25 17:03:26 +08:00
|
|
|
|
2023-03-14 15:49:33 +08:00
|
|
|
|
|
|
|
winform.cbbDacRef.clear();
|
|
|
|
for(k,v in Motor_refArr){
|
|
|
|
winform.cbbDacRef.add(v);
|
|
|
|
}
|
|
|
|
winform.cbbDacRef.selIndex = 1;
|
|
|
|
|
|
|
|
winform.cbbMotorGain.clear();
|
|
|
|
for(k,v in Motor_gainArr){
|
|
|
|
winform.cbbMotorGain.add(v);
|
|
|
|
}
|
|
|
|
winform.cbbMotorGain.selIndex = 1;
|
|
|
|
|
|
|
|
import win.timer;
|
|
|
|
|
|
|
|
Diag3E_Timer = win.timer(winform,4000);
|
|
|
|
Diag3E_Timer.onTimer = function(){
|
|
|
|
CT_Diag3E();
|
|
|
|
}
|
|
|
|
|
|
|
|
Display = function(str){
|
|
|
|
var nowtime = time();
|
|
|
|
nowtime.format="%H:%M:%S";
|
|
|
|
winform.edLog.print(tostring(nowtime) + " " + str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
winform.rbLeft.oncommand = function(id,event){
|
|
|
|
CT_SetDiagID(0x720,0x620);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.rbRight.oncommand = function(id,event){
|
|
|
|
CT_SetDiagID(0x710,0x610);
|
2023-03-25 17:03:26 +08:00
|
|
|
|
2023-03-14 15:49:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
winform.btn1001.oncommand = function(id,event){
|
|
|
|
CT_Diag10(0x01);
|
|
|
|
}
|
|
|
|
winform.btn1003.oncommand = function(id,event){
|
|
|
|
CT_Diag10(0x03);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.cb3E.oncommand = function(id,event){
|
|
|
|
if(winform.cb3E.checked == true){
|
|
|
|
Diag3E_Timer.enable();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Diag3E_Timer.disable();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GetReadThResp = function(did){
|
|
|
|
var ret = CT_GetLastDiagResp();
|
|
|
|
if(ret == null){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(ret.sid == 0x62 && (#ret.data >= 4)){
|
|
|
|
var getdid = (ret.data[1]<<8) + ret.data[2];
|
|
|
|
if(getdid == did){
|
|
|
|
var val = (ret.data[3]<<8) + ret.data[4];
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
winform.btnReadPressTh.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
var didbase = winform.rbPressTh.checked?0x9020:0x9010;
|
2023-03-25 17:03:26 +08:00
|
|
|
for(name,ctrl in winform.eachControl("edit","edPressTh\d") ){
|
|
|
|
ctrl.text = 0//string.right(name,1);
|
|
|
|
var did = didbase + tonumber(string.right(name,1)) - 1;
|
|
|
|
CT_Diag22(did);
|
2023-04-11 17:06:18 +08:00
|
|
|
win.delay(30,1);
|
2023-03-25 17:03:26 +08:00
|
|
|
var ret = GetReadThResp(did);
|
|
|
|
if(ret != 0){
|
|
|
|
ctrl.text = ret;
|
|
|
|
}
|
2023-03-14 15:49:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnWritePressTh.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x03);
|
2023-07-26 15:48:18 +08:00
|
|
|
win.delay(50,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
var didbase = winform.rbPressTh.checked?0x9020:0x9010;
|
2023-03-25 17:03:26 +08:00
|
|
|
for(name,ctrl in winform.eachControl("edit","edPressTh\d") ){
|
|
|
|
//ctrl.text = 0//string.right(name,1);
|
|
|
|
var did = didbase + tonumber(string.right(name,1)) - 1;
|
|
|
|
var val = tonumber(ctrl.text);
|
2023-07-26 15:48:18 +08:00
|
|
|
if(val == 0){
|
|
|
|
continue;
|
|
|
|
}
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag2EVal2B(did,val);
|
2023-07-26 15:48:18 +08:00
|
|
|
win.delay(50,1);
|
2023-03-25 17:03:26 +08:00
|
|
|
var ret = GetReadThResp(did);
|
|
|
|
if(ret != 0){
|
|
|
|
ctrl.text = ret;
|
|
|
|
}
|
|
|
|
}
|
2023-03-14 15:49:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnWrite9001.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x03);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
CT_Diag2EVal1B(0x9001,0x01);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnWrite9002.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x03);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
var val = winform.cbbDacRef.selIndex - 1;
|
|
|
|
CT_Diag2EVal1B(0x9002,val);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnWrite9003.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x03);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
var val = winform.cbbMotorGain.selIndex - 1;
|
|
|
|
CT_Diag2EVal1B(0x9003,val);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnReadF199.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
CT_Diag22(0xF199);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnReadF198.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
CT_Diag22(0xF198);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnReadF18A.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
CT_Diag22(0xF18A);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnReadF190.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
CT_Diag22(0xF190);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnReadF187.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
CT_Diag22(0xF187);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnReadF193.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
CT_Diag22(0xF193);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnReadF195.oncommand = function(id,event){
|
2023-03-25 17:03:26 +08:00
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
2023-03-14 15:49:33 +08:00
|
|
|
CT_Diag22(0xF195);
|
|
|
|
}
|
|
|
|
|
2023-04-11 17:06:18 +08:00
|
|
|
winform.btnConvert.oncommand = function(id,event){
|
|
|
|
for(name,ctrl in winform.eachControl("edit","edPressTh\d") ){
|
|
|
|
var val = tonumber(ctrl.text);
|
|
|
|
var x = tonumber(winform.edFactor.text);
|
|
|
|
if(math.isFinite(x) && math.isFinite(val)){
|
|
|
|
ctrl.text = math.round(x * val);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
import fsys.ini;
|
|
|
|
var ini_file = fsys.ini("\配置文件.ini");
|
|
|
|
var allconfig = ini_file.readSectionNames();
|
|
|
|
for(k,v in allconfig){
|
|
|
|
winform.combobox.add(v);
|
|
|
|
}
|
|
|
|
winform.combobox.selIndex = 1;
|
|
|
|
winform.btnReadConfig.oncommand = function(id,event){
|
|
|
|
var sec = ini_file.getSection(winform.combobox.selText);
|
|
|
|
winform.edPressTh1.text = sec.key1;
|
|
|
|
winform.edPressTh2.text = sec.key2;
|
|
|
|
winform.edPressTh3.text = sec.key3;
|
|
|
|
winform.edPressTh4.text = sec.上;
|
|
|
|
winform.edPressTh5.text = sec.下;
|
|
|
|
winform.edPressTh6.text = sec.左;
|
|
|
|
winform.edPressTh7.text = sec.右;
|
|
|
|
winform.edPressTh8.text = sec.OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnWriteConfig.oncommand = function(id,event){
|
|
|
|
var sec = ini_file.getSection("小节名称");
|
|
|
|
sec.key1 = 500;
|
|
|
|
sec.key2 = 500;
|
|
|
|
sec.key3 = 500;
|
|
|
|
sec.上 = 500;
|
|
|
|
sec.下 = 500;
|
|
|
|
sec.左 = 500;
|
|
|
|
sec.右 = 500;
|
|
|
|
sec.OK = 500;
|
|
|
|
sec.save();
|
|
|
|
}
|
|
|
|
|
2023-07-26 15:48:18 +08:00
|
|
|
winform.btnWrite9004.oncommand = function(id,event){
|
|
|
|
CT_Diag10(0x03);
|
|
|
|
win.delay(20,1);
|
|
|
|
var val = tonumber(winform.edDACPeriod.text);
|
|
|
|
CT_Diag2EVal1B(0x9004,val);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnWriteA00101.oncommand = function(id,event){
|
|
|
|
CT_Diag10(0x03);
|
|
|
|
win.delay(20,1);
|
|
|
|
CT_Diag2EVal1B(0xA001,0x01);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnWriteA00100.oncommand = function(id,event){
|
|
|
|
CT_Diag10(0x03);
|
|
|
|
win.delay(20,1);
|
|
|
|
CT_Diag2EVal1B(0xA001,0x00);
|
|
|
|
}
|
|
|
|
|
|
|
|
winform.btnRead7022.oncommand = function(id,event){
|
|
|
|
CT_Diag10(0x01);
|
|
|
|
win.delay(20,1);
|
|
|
|
CT_Diag22(0x7022);
|
|
|
|
}
|
|
|
|
|
2023-03-14 15:49:33 +08:00
|
|
|
winform.group();
|
|
|
|
|
|
|
|
winform.show();
|
|
|
|
win.loopMessage();
|
|
|
|
return winform;
|