340 lines
12 KiB
Plaintext
340 lines
12 KiB
Plaintext
import fonts.fontAwesome;
|
|
import win.ui;
|
|
import console;
|
|
/*DSG{{*/
|
|
show = win.form(text="P417上位机";right=984;bottom=602;bgcolor=16777215;border="dialog frame";style=33554432)
|
|
show.add(
|
|
bkplus={cls="bkplus";left=49;top=93;right=880;bottom=372;ah=1;aw=1;background="\res\P417.png";z=1};
|
|
button={cls="button";text="Button";left=381;top=425;right=507;bottom=451;hide=1;z=31};
|
|
button2={cls="button";text="左";left=253;top=512;right=352;bottom=571;hide=1;z=43};
|
|
button3={cls="button";text="右";left=437;top=512;right=536;bottom=571;hide=1;z=44};
|
|
checkbox={cls="checkbox";text="点亮";left=112;top=31;right=198;bottom=68;ah=1;aw=1;bgcolor=16777215;checked=1;font=LOGFONT(h=-22);z=3};
|
|
checkbox2={cls="checkbox";text="白天";left=208;top=32;right=294;bottom=69;ah=1;aw=1;bgcolor=16777215;checked=1;font=LOGFONT(h=-22);z=20};
|
|
checkbox3={cls="checkbox";text="发送";left=20;top=30;right=106;bottom=67;ah=1;aw=1;bgcolor=16777215;checked=1;font=LOGFONT(h=-22);z=42};
|
|
plLeft={cls="plus";left=103;top=129;right=334;bottom=331;ah=1;aw=1;border={color=-7114533;width=1};z=2};
|
|
plRight={cls="plus";left=596;top=131;right=827;bottom=333;ah=1;aw=1;border={color=-7114533;width=1};z=26};
|
|
stDebug={cls="static";text="Static";left=378;top=465;right=493;bottom=492;hide=1;transparent=1;z=27};
|
|
stDebug2={cls="static";text="Static";left=376;top=498;right=512;bottom=525;hide=1;transparent=1;z=28};
|
|
stKeyL1={cls="static";text="Static";left=276;top=136;right=321;bottom=182;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=4};
|
|
stKeyL2={cls="static";text="Static";left=276;top=204;right=321;bottom=250;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=5};
|
|
stKeyL3={cls="static";text="Static";left=276;top=276;right=321;bottom=322;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=6};
|
|
stKeyLdown={cls="static";text="Static";left=13;top=127;right=38;bottom=152;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=11};
|
|
stKeyLleft={cls="static";text="Static";left=13;top=165;right=38;bottom=190;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;notify=1;z=9};
|
|
stKeyLok={cls="static";text="Static";left=13;top=202;right=38;bottom=227;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=8};
|
|
stKeyLright={cls="static";text="Static";left=13;top=240;right=38;bottom=265;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=10};
|
|
stKeyLup={cls="static";text="Static";left=13;top=89;right=38;bottom=114;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=7};
|
|
stKeyR1={cls="static";text="Static";left=904;top=60;right=929;bottom=85;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=12};
|
|
stKeyR2={cls="static";text="Static";left=904;top=97;right=929;bottom=122;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=13};
|
|
stKeyR3={cls="static";text="Static";left=904;top=135;right=929;bottom=160;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=14};
|
|
stKeyRdown={cls="static";text="Static";left=904;top=210;right=929;bottom=235;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=17};
|
|
stKeyRleft={cls="static";text="Static";left=904;top=247;right=929;bottom=272;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=18};
|
|
stKeyRok={cls="static";text="Static";left=904;top=322;right=929;bottom=347;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=16};
|
|
stKeyRright={cls="static";text="Static";left=904;top=285;right=929;bottom=310;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=19};
|
|
stKeyRup={cls="static";text="Static";left=904;top=172;right=929;bottom=197;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=15};
|
|
stLeftCommonFaullt={cls="static";text="0";left=195;top=569;right=217;bottom=594;font=LOGFONT(h=-18);transparent=1;z=37};
|
|
stLeftPF={cls="static";text="0";left=195;top=514;right=218;bottom=539;font=LOGFONT(h=-18);transparent=1;z=35};
|
|
stLeftTF={cls="static";text="0";left=195;top=487;right=219;bottom=512;font=LOGFONT(h=-18);transparent=1;z=34};
|
|
stLeftVF={cls="static";text="0";left=195;top=541;right=219;bottom=566;font=LOGFONT(h=-18);transparent=1;z=36};
|
|
stLocl={cls="static";left=180;top=225;right=220;bottom=265;align="center";bgcolor=65280;center=1;font=LOGFONT(name='FontAwesome');z=29};
|
|
stLocr={cls="static";left=790;top=226;right=830;bottom=266;align="center";bgcolor=65280;center=1;font=LOGFONT(name='FontAwesome');z=30};
|
|
stRightCommonFaullt={cls="static";text="0";left=722;top=538;right=746;bottom=563;font=LOGFONT(h=-18);transparent=1;z=41};
|
|
stRightPF={cls="static";text="0";left=722;top=483;right=746;bottom=508;font=LOGFONT(h=-18);transparent=1;z=39};
|
|
stRightTF={cls="static";text="0";left=722;top=456;right=746;bottom=481;font=LOGFONT(h=-18);transparent=1;z=38};
|
|
stRightVF={cls="static";text="0";left=722;top=510;right=746;bottom=535;font=LOGFONT(h=-18);transparent=1;z=40};
|
|
stZBl={cls="static";text="坐标";left=3;top=368;right=423;bottom=416;align="center";center=1;font=LOGFONT(h=-30);transparent=1;z=24};
|
|
stZBr={cls="static";text="坐标";left=481;top=384;right=901;bottom=432;align="center";center=1;font=LOGFONT(h=-30);transparent=1;z=25};
|
|
static={cls="static";text="0x305 RES status";left=97;top=412;right=266;bottom=447;font=LOGFONT(h=-20);notify=1;transparent=1;z=45};
|
|
static2={cls="static";text="亮度:";left=348;top=30;right=420;bottom=69;ah=1;align="center";aw=1;center=1;font=LOGFONT(h=-22);transparent=1;z=23};
|
|
static3={cls="static";text="触摸错误
|
|
压力错误
|
|
震动错误
|
|
其它错误";left=94;top=491;right=185;bottom=600;font=LOGFONT(h=-18);transparent=1;z=32};
|
|
static4={cls="static";text="触摸错误
|
|
压力错误
|
|
震动错误
|
|
其它错误";left=624;top=460;right=715;bottom=569;font=LOGFONT(h=-18);transparent=1;z=33};
|
|
static5={cls="static";text="0x305 ADAS status";left=95;top=437;right=269;bottom=472;font=LOGFONT(h=-20);notify=1;transparent=1;z=46};
|
|
static6={cls="static";text="0x305 CNCL status";left=96;top=460;right=271;bottom=495;font=LOGFONT(h=-20);transparent=1;z=47};
|
|
static7={cls="static";text="0";left=278;top=414;right=308;bottom=449;font=LOGFONT(h=-20);transparent=1;z=48};
|
|
static8={cls="static";text="0";left=279;top=437;right=309;bottom=472;font=LOGFONT(h=-20);transparent=1;z=49};
|
|
static9={cls="static";text="0";left=278;top=464;right=308;bottom=499;font=LOGFONT(h=-20);transparent=1;z=50};
|
|
stlight={cls="static";text="7";left=416;top=30;right=460;bottom=69;ah=1;align="center";aw=1;center=1;font=LOGFONT(h=-22);transparent=1;z=22};
|
|
trackbar={cls="trackbar";left=472;top=39;right=882;bottom=69;ah=1;aw=1;bgcolor=16777215;max=15;min=0;z=21}
|
|
)
|
|
/*}}*/
|
|
|
|
//import usb2canfd;
|
|
import win.timer
|
|
var showtimer = win.timer( winform ,50);
|
|
showtimer.onTimer = function(){
|
|
DisplayKey();
|
|
}
|
|
|
|
Displayl = function(str){
|
|
show.stZBl.text = str;
|
|
}
|
|
Displayr = function(str){
|
|
show.stZBr.text = str;
|
|
}
|
|
|
|
DisplayKey = function(){
|
|
if(mainForm == null){
|
|
return ;
|
|
}
|
|
show.stKeyL1.text = keyL1;
|
|
show.stKeyL2.text = keyL2;
|
|
show.stKeyL3.text = keyL3;
|
|
show.stKeyL1.hide = keyL1==0?1:0;
|
|
show.stKeyL2.hide = keyL2==0?1:0;
|
|
show.stKeyL3.hide = keyL3==0?1:0;
|
|
/*
|
|
show.stKeyLup.text = keyLup;
|
|
show.stKeyLdown.text = keyLdown;
|
|
show.stKeyLleft.text = keyLleft;
|
|
show.stKeyLright.text = keyLright;
|
|
show.stKeyLok.text = keyLok;
|
|
|
|
show.stKeyR1.text = keyR1;
|
|
show.stKeyR2.text = keyR2;
|
|
show.stKeyR3.text = keyR3;
|
|
show.stKeyRup.text = keyRup;
|
|
show.stKeyRdown.text = keyRdown;
|
|
show.stKeyRleft.text = keyRleft;
|
|
show.stKeyRright.text = keyRright;
|
|
show.stKeyRok.text = keyRok;
|
|
*/
|
|
show.stLeftTF.text = LeftTouchFault;
|
|
show.stLeftVF.text = LeftVibrationFault;
|
|
show.stLeftPF.text = LeftPressSensorFault;
|
|
show.stLeftCommonFaullt.text = LeftCommonFault;
|
|
|
|
show.stRightTF.text = RightTouchFault;
|
|
show.stRightVF.text = RightVibrationFault;
|
|
show.stRightPF.text = RightPressSensorFault;
|
|
show.stRightCommonFaullt.text = RightCommonFault;
|
|
Displayl("get 0x300 (" + plx + ',' + ply + ') status:' + pls);
|
|
show.static7.text = keyL1;
|
|
show.static8.text = keyL2;
|
|
show.static9.text = keyL3;
|
|
if((plx == 0)&&(ply == 0))
|
|
{
|
|
show.stLocl.hide=1;
|
|
}
|
|
else
|
|
{
|
|
show.stLocl.hide=0;
|
|
SetLeftPos(plx,ply);
|
|
|
|
show.stLocl.redraw()
|
|
}
|
|
|
|
Displayr("get 0x309 ("+prx + ',' + pry + ') status:' + prs);
|
|
if((prx == 0)&&(pry == 0))
|
|
{
|
|
show.stLocr.hide=1;
|
|
}
|
|
else
|
|
{
|
|
show.stLocr.hide=0;
|
|
SetRightPos(prx,pry);
|
|
show.stLocr.redraw();
|
|
|
|
}
|
|
}
|
|
|
|
txdata = {0,0,0,0, 0,0,0,0};
|
|
if(show.checkbox.checked){
|
|
txdata[6] = 0x08;
|
|
}
|
|
else {
|
|
txdata[6] = 0x00;
|
|
}
|
|
if(show.checkbox2.checked){
|
|
txdata[3] = 0x40;
|
|
}
|
|
else {
|
|
txdata[3] = 0x00;
|
|
}
|
|
|
|
|
|
show.checkbox.oncommand = function(id,event){
|
|
if(show.checkbox.checked){
|
|
txdata[6] = 0x08;
|
|
}
|
|
else {
|
|
txdata[6] = 0x00;
|
|
}
|
|
CT_UpdateCANTxMsg(0x30,200,txdata);
|
|
}
|
|
|
|
show.checkbox2.oncommand = function(id,event){
|
|
if(show.checkbox2.checked){
|
|
txdata[3] = 0x40;
|
|
}
|
|
else {
|
|
txdata[3] = 0x00;
|
|
}
|
|
CT_UpdateCANTxMsg(0x30,200,txdata);
|
|
}
|
|
|
|
show.trackbar.oncommand = function(id,event,pos){
|
|
if( event == 0x8/*_TB_ENDTRACK*/ ){
|
|
show.stlight.text = show.trackbar.pos;
|
|
txdata[1] = show.trackbar.pos;
|
|
CT_UpdateCANTxMsg(0x30,200,txdata);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
show.trackbar.pos = 7;
|
|
|
|
if(mainForm != null){
|
|
CT_UpdateCANTxMsg(0x30,200,txdata);
|
|
showtimer.enable();
|
|
}
|
|
|
|
/*
|
|
var x,y,cx,cy = show.plRight.getPos();
|
|
var str = string.format("x = %d,y = %d,cx = %d,cy = %d",x,y,cx,cy);
|
|
show.stDebug.text = str;
|
|
show.onMouseDown = function(wParam,lParam){
|
|
var x,y = win.getMessagePos(lParam);
|
|
var str = string.format("x = %d,y = %d",x,y);
|
|
show.stDebug2.text = str;
|
|
}
|
|
*/
|
|
|
|
Lrange = {};Rrange = {};
|
|
Lrange.x,Lrange.y,Lrange.cx,Lrange.cy = show.plLeft.getPos();
|
|
Rrange.x,Rrange.y,Rrange.cx,Rrange.cy = show.plRight.getPos();
|
|
|
|
|
|
|
|
SetLeftPos = function(getx,gety){
|
|
var posx = 0,posy = 0;
|
|
posx = Lrange.x + Lrange.cx - (getx/255*Lrange.cx) - 6;
|
|
posy = Lrange.y + (gety/255*Lrange.cy) - 26;
|
|
show.stLocl.setPos(posx,posy);
|
|
show.stLocl.text = pls;
|
|
|
|
}
|
|
SetRightPos = function(getx,gety){
|
|
var posx = 0,posy = 0;
|
|
if(getx == 0){
|
|
getx = 60;
|
|
}
|
|
posx = Rrange.x + (getx/255*Rrange.cx) - 40;
|
|
posy = Rrange.y + (gety/255*Rrange.cy) - 30;
|
|
show.stLocr.setPos(posx,posy);
|
|
show.stLocr.text = prs;
|
|
}
|
|
|
|
/*
|
|
show.onDrawBackgroundEnd = function(hdc,rc){
|
|
var x,y,cx,cy = show.plRight.getPos();
|
|
var str = string.format("x = %d,y = %d,cx = %d,cy = %d",x,y,cx,cy);
|
|
show.stDebug.text = str;
|
|
}
|
|
*/
|
|
FreshPos = function(){
|
|
var x,y,cx,cy = show.plRight.getPos();
|
|
var str = string.format("x = %d,y = %d,cx = %d,cy = %d",x,y,cx,cy);
|
|
show.stDebug.text = str;
|
|
Lrange = {};
|
|
Rrange = {};
|
|
Lrange.x,Lrange.y,Lrange.cx,Lrange.cy = show.plLeft.getPos();
|
|
Rrange.x,Rrange.y,Rrange.cx,Rrange.cy = show.plRight.getPos();
|
|
|
|
}
|
|
|
|
show.onActivateApp = function(activated,threadId){
|
|
if(activated){
|
|
|
|
}
|
|
}
|
|
|
|
show.button.oncommand = function(id,event){
|
|
var x,y,cx,cy = show.plLeft.getPos();
|
|
var str = string.format("x = %d,y = %d,cx = %d,cy = %d",x,y,cx,cy);
|
|
show.stDebug.text = str;
|
|
show.plLeft.setPos(,,cy/253*289,cy);
|
|
}
|
|
|
|
show.onPosChanged = function(flags,hwndInsertAfter,x,y,cx,cy){
|
|
var x,y,cx,cy = show.plLeft.getPos();
|
|
var str = string.format("x = %d,y = %d,cx = %d,cy = %d",x,y,cx,cy);
|
|
show.stDebug.text = str;
|
|
}
|
|
|
|
show.wndproc = function(hwnd,message,wparam,lparam){
|
|
|
|
select(message) {//判断消息类型
|
|
|
|
case 0x112/*_WM_SYSCOMMAND*/{
|
|
if(wparam == 0xF030/*_SC_MAXIMIZE*/){
|
|
var x,y,cx,cy = show.getPos();
|
|
var Screen_cx,Screen_cy = win.getScreen();
|
|
show.setPos(0,0,Screen_cx,Screen_cy/cx*Screen_cx);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
//无返回值则继续调用默认回调函数
|
|
}
|
|
|
|
show.checkbox3.oncommand = function(id,event){
|
|
|
|
|
|
if(show.checkbox3.checked){
|
|
CT_UpdateCANTxMsg(0x30,200,txdata);
|
|
show.checkbox.disabled = false;
|
|
show.checkbox2.disabled = false;
|
|
show.trackbar.disabled = false;
|
|
}
|
|
else {
|
|
CT_UpdateCANTxMsg(0x30,0,txdata);
|
|
show.checkbox.disabled = true;
|
|
show.checkbox2.disabled = true;
|
|
show.trackbar.disabled = true;
|
|
}
|
|
|
|
}
|
|
|
|
show.button2.oncommand = function(id,event){
|
|
CT_SetDiagID(0x720,0x620);
|
|
CT_Diag10(0x03);
|
|
win.delay(20,1);
|
|
CT_Diag2EVal1B(0x9001,0x01);
|
|
}
|
|
|
|
show.button3.oncommand = function(id,event){
|
|
CT_SetDiagID(0x710,0x610);
|
|
CT_Diag10(0x03);
|
|
win.delay(20,1);
|
|
CT_Diag2EVal1B(0x9001,0x01);
|
|
}
|
|
|
|
import win.ui.accelerator;
|
|
var accelerator = win.ui.accelerator({
|
|
|
|
{
|
|
alt = true; vkey = 'Q'#;
|
|
oncommand = function() show.button2.oncommand();//show.msgbox("ALT+1");
|
|
};
|
|
|
|
{
|
|
alt = true; vkey = 'W'#;
|
|
oncommand = function() show.button3.oncommand();//show.msgbox("ALT+2");
|
|
};
|
|
|
|
},show );
|
|
|
|
|
|
show.show();
|
|
FreshPos();
|
|
return win.loopMessage(); |