/*@!Encoding:936*/
includes
{
}
variables
{
message VDPC_0x1A0 msg_1A0;
float sigvalue;
msTimer timer_1A0;
message VDPSWS_0x256 msg_256;
msTimer timer_256;
msTimer timesleep_100;
float x;
long timeBuffer[10];
long time[8];
}
on start{
setTimer(timer_1A0,20);
setTimer(timer_256,20);
}
on timer timer_1A0{
//$VDPC_0x1A0::VdpcLoclLoVPwrMod=1;
//$VDPC_0x1A0::VdpcLowVPwrMod=3;
msg_1A0.VdpcLowVPwrMod=3;
msg_1A0.VdpcLoclLoVPwrMod=3;//On
output(msg_1A0);
setTimer(timer_1A0,20);
}
on key 'd'{
//满足进入dragmod的条件
write("~~~ key D pressed ~~~");
msg_1A0.VdpcActGear=1; //P
msg_1A0.VdpcBrkSts=1;
addTimeToMeasurementStartTime(timeNowNS(), time);
write("key c event occured on %02d/%02d/%02d %02d:%02d:%02d.%-6d",
time[5]+1, time[4], time[6]-100, time[3], time[2], time[1], time[0]);
}
on signal CdpDrgModReq
{
if(this == 0x1)
{
write("get the dragmod request");
msg_1A0.VdpcActGear=3;//N
msg_1A0.VdpcDrgModSts=1;
write("time1:%ld",timeNow());
/*
write("time1:%ld",timeNow());
x= timeNow();
while(1){
write("time1:%ld",timeNow());
if (timeNow()-x>200000){
break;
}
}*/
setTimer(timesleep_100,1000);
}
}
on timer timesleep_100{
write("time1:%ld",timeNow());
write("delay 100ms");
//延时100ms
msg_1A0.VdpcActGear=4;//D
msg_1A0.VdpcDrgModSts=0;//off
}
on timer timer_256{
output(msg_256);
setTimer(timer_256,50);
}
on key 'p'{
write("~~~ key p pressed ");
msg_256.VdpcSwsLeRollrSwtPsdSts =1;
msg_256.VdpcSwsRiRollrSwtPsdSts =1;
}
on key 'c'{
//cancelTimer(timer_256);
msg_256.VdpcSwsLeRollrSwtPsdSts =0;
msg_256.VdpcSwsRiRollrSwtPsdSts =0;
write("cancel timer_256");
}
on busOff
{
resetCanEx(1);
resetCanEx(2);
resetCanEx(3);
}
/*
//getLocalTimeString(timeBuffer);
//获取按下键盘c的时间
addTimeToMeasurementStartTime(timeNowNS(), time);
write("key c event occured on %02d/%02d/%02d %02d:%02d:%02d.%-6d",
time[5]+1, time[4], time[6]-100, time[3], time[2], time[1], time[0]);
//Program / Model key c event occured on 02/28/24 14:15:46.816
while(1){
int i =1;
if(i>35000){break;}
i+=1;
}
addTimeToMeasurementStartTime(timeNowNS(), time);
write("key c event occured on %02d/%02d/%02d %02d:%02d:%02d.%-3d",
time[5]+1, time[4], time[6]-100, time[3], time[2], time[1], time[0]);
*/