218 lines
7.5 KiB
Plaintext
218 lines
7.5 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";max=false;style=33554432)
|
||
|
show.add(
|
||
|
bkplus={cls="bkplus";left=29;top=77;right=948;bottom=388;ah=1;aw=1;background="\res\P417.png";dl=1;dt=1;repeat="scale";z=1};
|
||
|
checkbox={cls="checkbox";text="点亮";left=112;top=31;right=169;bottom=55;bgcolor=16777215;z=3};
|
||
|
checkbox2={cls="checkbox";text="白天";left=174;top=32;right=231;bottom=56;bgcolor=16777215;checked=1;z=20};
|
||
|
plLeft={cls="plus";left=87;top=119;right=351;bottom=342;ah=1;aw=1;border={color=-7114533;width=1};z=2};
|
||
|
plRight={cls="plus";left=627;top=119;right=891;bottom=342;ah=1;aw=1;border={color=-7114533;width=1};z=26};
|
||
|
stDebug={cls="static";text="Static";left=376;top=455;right=618;bottom=482;hide=1;transparent=1;z=27};
|
||
|
stDebug2={cls="static";text="Static";left=376;top=494;right=618;bottom=521;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=139;top=544;right=184;bottom=590;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=11};
|
||
|
stKeyLleft={cls="static";text="Static";left=85;top=498;right=130;bottom=544;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=9};
|
||
|
stKeyLok={cls="static";text="Static";left=141;top=500;right=186;bottom=546;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=8};
|
||
|
stKeyLright={cls="static";text="Static";left=202;top=501;right=247;bottom=547;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=10};
|
||
|
stKeyLup={cls="static";text="Static";left=134;top=450;right=179;bottom=496;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=7};
|
||
|
stKeyR1={cls="static";text="Static";left=682;top=454;right=727;bottom=500;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=12};
|
||
|
stKeyR2={cls="static";text="Static";left=681;top=491;right=726;bottom=537;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=13};
|
||
|
stKeyR3={cls="static";text="Static";left=681;top=527;right=726;bottom=573;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=14};
|
||
|
stKeyRdown={cls="static";text="Static";left=792;top=542;right=837;bottom=588;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=17};
|
||
|
stKeyRleft={cls="static";text="Static";left=741;top=501;right=786;bottom=547;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=18};
|
||
|
stKeyRok={cls="static";text="Static";left=792;top=500;right=837;bottom=546;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=16};
|
||
|
stKeyRright={cls="static";text="Static";left=833;top=498;right=878;bottom=544;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=19};
|
||
|
stKeyRup={cls="static";text="Static";left=791;top=465;right=836;bottom=511;ah=1;align="center";aw=1;bgcolor=65280;center=1;hide=1;z=15};
|
||
|
stLocl={cls="static";left=180;top=225;right=192;bottom=237;bgcolor=255;color=255;font=LOGFONT(name='FontAwesome');z=29};
|
||
|
stLocr={cls="static";left=790;top=226;right=802;bottom=238;bgcolor=255;color=255;font=LOGFONT(name='FontAwesome');z=30};
|
||
|
stZBl={cls="static";text="坐标";left=10;top=393;right=430;bottom=441;align="center";center=1;font=LOGFONT(h=-30);transparent=1;z=24};
|
||
|
stZBr={cls="static";text="坐标";left=542;top=393;right=962;bottom=441;align="center";center=1;font=LOGFONT(h=-30);transparent=1;z=25};
|
||
|
static2={cls="static";text="亮度:";left=229;top=25;right=301;bottom=64;align="center";center=1;transparent=1;z=23};
|
||
|
stlight={cls="static";text="7";left=287;top=25;right=331;bottom=64;align="center";center=1;transparent=1;z=22};
|
||
|
trackbar={cls="trackbar";left=334;top=26;right=744;bottom=56;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;
|
||
|
|
||
|
Displayl("get 0x300 (" + plx + ',' + ply + ') status:' + pls);
|
||
|
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) - 6;
|
||
|
show.stLocl.setPos(posx,posy);
|
||
|
}
|
||
|
SetRightPos = function(getx,gety){
|
||
|
var posx = 0,posy = 0;
|
||
|
if(getx == 0){
|
||
|
getx = 50;
|
||
|
}
|
||
|
posx = Rrange.x + (getx/255*Rrange.cx) - 6;
|
||
|
posy = Rrange.y + (gety/255*Rrange.cy) - 6;
|
||
|
show.stLocr.setPos(posx,posy);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
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.show();
|
||
|
FreshPos();
|
||
|
return win.loopMessage();
|