P417_host/dlg/diagnostic.aardio
2023-03-14 15:49:33 +08:00

189 lines
6.2 KiB
Plaintext

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=984;bottom=599;bgcolor=16777215)
winform.add(
btn1001={cls="button";text="默认会话";left=28;top=58;right=115;bottom=88;z=3};
btn1003={cls="button";text="扩展会话";left=126;top=58;right=213;bottom=88;z=4};
btnReadF187={cls="button";text="ECU零件号";left=234;top=183;right=321;bottom=213;z=19};
btnReadF18A={cls="button";text="供应商ID";left=37;top=183;right=124;bottom=213;z=20};
btnReadF190={cls="button";text="VIN码";left=135;top=183;right=222;bottom=213;z=21};
btnReadF193={cls="button";text="硬件版本";left=37;top=226;right=124;bottom=256;z=23};
btnReadF195={cls="button";text="软件版本";left=135;top=226;right=224;bottom=256;z=24};
btnReadF198={cls="button";text="维修店代码";left=135;top=141;right=222;bottom=171;z=22};
btnReadF199={cls="button";text="刷写日期";left=37;top=141;right=124;bottom=171;z=18};
btnReadPressTh={cls="button";text="读取";left=381;top=130;right=468;bottom=160;z=10};
btnWrite9001={cls="button";text="触发震动";left=45;top=332;right=284;bottom=362;z=25};
btnWrite9002={cls="button";text="写入参考电压";left=184;top=370;right=284;bottom=400;z=28};
btnWrite9003={cls="button";text="写入增益";left=183;top=408;right=284;bottom=438;z=29};
btnWritePressTh={cls="button";text="写入";left=479;top=130;right=566;bottom=160;z=11};
cb3E={cls="checkbox";text="3E保持";left=232;top=64;right=306;bottom=86;bgcolor=16777215;z=5};
cbbDacRef={cls="combobox";left=45;top=370;right=175;bottom=396;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=26};
cbbKeyName={cls="combobox";left=382;top=93;right=489;bottom=119;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=8};
cbbMotorGain={cls="combobox";left=45;top=408;right=175;bottom=434;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=27};
edLog={cls="edit";left=649;top=12;right=970;bottom=578;edge=1;font=LOGFONT(h=-18);multiline=1;z=12};
edPressTh={cls="edit";text="500";left=495;top=93;right=569;bottom=123;align="center";edge=1;font=LOGFONT(h=-18);multiline=1;num=1;z=9};
groupbox={cls="groupbox";text="标定";left=362;top=9;right=590;bottom=182;edge=1;z=13};
groupbox2={cls="groupbox";text="读取DID";left=22;top=109;right=331;bottom=275;edge=1;z=2};
groupbox3={cls="groupbox";text="震动";left=22;top=293;right=331;bottom=459;edge=1;z=1};
rbLeft={cls="radiobutton";text="左侧";left=61;top=15;right=115;bottom=35;bgcolor=16777215;checked=1;group=1;z=6};
rbPressTh={cls="radiobutton";text="压力";left=405;top=31;right=471;bottom=57;bgcolor=16777215;checked=1;group=1;z=16};
rbRight={cls="radiobutton";text="右侧";left=141;top=15;right=195;bottom=35;bgcolor=16777215;z=7};
rbTouchTh={cls="radiobutton";text="触摸";left=494;top=31;right=560;bottom=57;bgcolor=16777215;z=17};
static={cls="static";text="按键";left=403;top=63;right=458;bottom=92;font=LOGFONT(h=-18);transparent=1;z=14};
static2={cls="static";text="阈值";left=504;top=62;right=559;bottom=91;font=LOGFONT(h=-18);notify=1;transparent=1;z=15}
)
/*}}*/
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"}
winform.cbbKeyName.clear();
for(k,v in LSW_KeyArr){
winform.cbbKeyName.add(v);
}
winform.cbbKeyName.selIndex = 1;
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.cbbKeyName.clear();
for(k,v in LSW_KeyArr){
winform.cbbKeyName.add(v);
}
winform.cbbKeyName.selIndex = 1;
}
winform.rbRight.oncommand = function(id,event){
CT_SetDiagID(0x710,0x610);
winform.cbbKeyName.clear();
for(k,v in RSW_KeyArr){
winform.cbbKeyName.add(v);
}
winform.cbbKeyName.selIndex = 1;
}
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){
var didbase = winform.rbPressTh.checked?0x9020:0x9010;
var did = didbase + (winform.cbbKeyName.selIndex - 1);
CT_Diag22(did);
win.delay(100,1);
var ret = GetReadThResp(did);
if(ret != 0){
winform.edPressTh.text = ret;
}
}
winform.btnWritePressTh.oncommand = function(id,event){
var didbase = winform.rbPressTh.checked?0x9020:0x9010;
var val = tonumber(winform.edPressTh.text);
var did = didbase + (winform.cbbKeyName.selIndex - 1);
CT_Diag2EVal2B(did,val);
}
winform.btnWrite9001.oncommand = function(id,event){
CT_Diag2EVal1B(0x9001,0x01);
}
winform.btnWrite9002.oncommand = function(id,event){
var val = winform.cbbDacRef.selIndex - 1;
CT_Diag2EVal1B(0x9002,val);
}
winform.btnWrite9003.oncommand = function(id,event){
var val = winform.cbbMotorGain.selIndex - 1;
CT_Diag2EVal1B(0x9003,val);
}
winform.btnReadF199.oncommand = function(id,event){
CT_Diag22(0xF199);
}
winform.btnReadF198.oncommand = function(id,event){
CT_Diag22(0xF198);
}
winform.btnReadF18A.oncommand = function(id,event){
CT_Diag22(0xF18A);
}
winform.btnReadF190.oncommand = function(id,event){
CT_Diag22(0xF190);
}
winform.btnReadF187.oncommand = function(id,event){
CT_Diag22(0xF187);
}
winform.btnReadF193.oncommand = function(id,event){
CT_Diag22(0xF193);
}
winform.btnReadF195.oncommand = function(id,event){
CT_Diag22(0xF195);
}
winform.group();
winform.show();
win.loopMessage();
return winform;