P417_host/dlg/diagnostic.aardio

358 lines
13 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;ah=1;aw=1;z=4};
btn1003={cls="button";text="扩展会话";left=126;top=58;right=213;bottom=88;ah=1;aw=1;z=5};
btnConvert={cls="button";text="转换";left=541;top=463;right=619;bottom=493;ah=1;aw=1;z=46};
btnRead7022={cls="button";text="预压值";left=232;top=212;right=319;bottom=242;ah=1;aw=1;z=54};
btnRead9002={cls="button";text="读取";left=294;top=409;right=382;bottom=439;z=59};
btnRead9003={cls="button";text="读取";left=293;top=449;right=381;bottom=479;z=60};
btnRead9004={cls="button";text="读取";left=294;top=486;right=382;bottom=516;z=61};
btnReadConfig={cls="button";text="读取配置";left=531;top=545;right=625;bottom=578;z=48};
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};
btnReadPressTh={cls="button";text="读取";left=420;top=418;right=507;bottom=448;ah=1;aw=1;z=10};
btnWrite9001={cls="button";text="触发震动";left=42;top=373;right=157;bottom=403;ah=1;aw=1;z=24};
btnWrite9002={cls="button";text="写入参考电压";left=181;top=411;right=281;bottom=441;ah=1;aw=1;z=27};
btnWrite9003={cls="button";text="写入增益";left=180;top=449;right=281;bottom=479;ah=1;aw=1;z=28};
btnWrite9004={cls="button";text="写入周期";left=181;top=487;right=282;bottom=517;ah=1;aw=1;z=51};
btnWrite9005={cls="button";text="写入波形";left=181;top=528;right=282;bottom=558;ah=1;aw=1;z=57};
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};
btnWriteConfig={cls="button";text="写入配置";left=415;top=545;right=510;bottom=570;hide=1;z=49};
btnWritePressTh={cls="button";text="写入";left=524;top=418;right=611;bottom=448;ah=1;aw=1;z=11};
button={cls="button";text="震动5次";left=175;top=372;right=282;bottom=402;ah=1;aw=1;z=55};
cb3E={cls="checkbox";text="3E保持";left=232;top=64;right=306;bottom=86;ah=1;aw=1;bgcolor=16777215;z=6};
cbbDacRef={cls="combobox";left=42;top=411;right=172;bottom=437;ah=1;aw=1;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=25};
cbbMotorGain={cls="combobox";left=42;top=449;right=172;bottom=475;ah=1;aw=1;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=26};
combobox={cls="combobox";left=408;top=508;right=629;bottom=534;edge=1;font=LOGFONT(h=-18);items={};mode="dropdown";z=47};
edDACPeriod={cls="edit";text="80";left=42;top=487;right=172;bottom=519;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);num=1;z=50};
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;autohscroll=false;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};
edWaveID={cls="edit";text="0";left=42;top=528;right=149;bottom=560;ah=1;align="center";aw=1;edge=1;font=LOGFONT(h=-18);multiline=1;num=1;z=56};
groupbox={cls="groupbox";text="标定";left=398;top=13;right=638;bottom=586;ah=1;aw=1;edge=1;z=1};
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=351;right=390;bottom=580;ah=1;aw=1;edge=1;z=2};
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};
spin={cls="spin";left=152;top=527;right=172;bottom=558;z=58};
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};
static11={cls="static";text="系数";left=411;top=463;right=449;bottom=490;center=1;font=LOGFONT(h=-18);transparent=1;z=45};
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}
)
/*}}*/
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.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";
var side = winform.rbLeft.checked?"(左侧)":"(右侧)";
winform.edLog.print(tostring(nowtime) ++ " " ++ side ++ str);
}
winform.rbLeft.oncommand = function(id,event){
CT_SetDiagID(0x720,0x620);
}
winform.rbRight.oncommand = function(id,event){
CT_SetDiagID(0x710,0x610);
}
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();
}
}
//import console;
winform.btnReadPressTh.oncommand = function(id,event){
CT_Diag10(0x01);
win.delay(20,1);
var didbase = winform.rbPressTh.checked?0x9020:0x9010;
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);
win.delay(30,1);
var ret = GetReadThResp(did);
if(ret != 0){
ctrl.text = ret;
}
}
}
winform.btnWritePressTh.oncommand = function(id,event){
CT_Diag10(0x03);
win.delay(50,1);
var didbase = winform.rbPressTh.checked?0x9020:0x9010;
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);
if(val == 0){
continue;
}
CT_Diag2EVal2B(did,val);
win.delay(50,1);
var ret = GetReadThResp(did);
if(ret != 0){
ctrl.text = ret;
}
}
}
winform.btnWrite9001.oncommand = function(id,event){
CT_Diag10(0x03);
win.delay(20,1);
CT_Diag2EVal1B(0x9001,0x01);
}
winform.btnWrite9002.oncommand = function(id,event){
CT_Diag10(0x03);
win.delay(20,1);
var val = winform.cbbDacRef.selIndex - 1;
CT_Diag2EVal1B(0x9002,val);
}
winform.btnWrite9003.oncommand = function(id,event){
CT_Diag10(0x03);
win.delay(20,1);
var val = winform.cbbMotorGain.selIndex - 1;
CT_Diag2EVal1B(0x9003,val);
}
winform.btnReadF199.oncommand = function(id,event){
CT_Diag10(0x01);
win.delay(20,1);
CT_Diag22(0xF199);
}
winform.btnReadF198.oncommand = function(id,event){
CT_Diag10(0x01);
win.delay(20,1);
CT_Diag22(0xF198);
}
winform.btnReadF18A.oncommand = function(id,event){
CT_Diag10(0x01);
win.delay(20,1);
CT_Diag22(0xF18A);
}
winform.btnReadF190.oncommand = function(id,event){
CT_Diag10(0x01);
win.delay(20,1);
CT_Diag22(0xF190);
}
winform.btnReadF187.oncommand = function(id,event){
CT_Diag10(0x01);
win.delay(20,1);
CT_Diag22(0xF187);
}
winform.btnReadF193.oncommand = function(id,event){
CT_Diag10(0x01);
win.delay(20,1);
CT_Diag22(0xF193);
}
winform.btnReadF195.oncommand = function(id,event){
CT_Diag10(0x01);
win.delay(20,1);
CT_Diag22(0xF195);
}
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();
}
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);
}
import win.timer;
timer1s = win.timer(winform,1000);
timer1s.onTimer = function(){
//win.delay(20,1);
CT_Diag2EVal1B(0x9001,0x01);
}
timer1s.onEnd = function(){
//Display("5次震动完成")
}
winform.button.oncommand = function(id,event){
CT_Diag10(0x03);
win.delay(20,10);
timer1s.enable(1000,5)
}
winform.btnWrite9005.oncommand = function(id,event){
CT_Diag10(0x03);
win.delay(20,1);
var val = tonumber(winform.edWaveID.text);
CT_Diag2EVal1B(0x9005,val);
}
winform.btnRead9002.oncommand = function(id,event){
var did = 0x9002;
CT_Diag22(did);
win.delay(50,1);
var ret = GetReadThResp(did);
if(ret < 8){
winform.cbbDacRef.selIndex = ret + 1;
}
}
winform.btnRead9003.oncommand = function(id,event){
var did = 0x9003;
CT_Diag22(did);
win.delay(50,1);
var ret = GetReadThResp(did);
if(ret < 4){
winform.cbbMotorGain.selIndex = ret + 1;
}
}
winform.btnRead9004.oncommand = function(id,event){
var did = 0x9004;
CT_Diag22(did);
win.delay(50,1);
var ret = GetReadThResp(did);
if(ret != 0){
winform.edDACPeriod.text = ret;
}
}
winform.spin.buddy = winform.edWaveID;
winform.spin.setRange(0,14); //一定要设置数值的上下限
winform.spin.pos = 0;//设置数值
winform.spin.inc = 1;//设置每次点击箭头的增减量(步长)
winform.group();
winform.show();
win.loopMessage();
return winform;