这篇文章聊聊在工作中遇到的问题和分享一些好玩的函数
halt();暂停模拟=断点
variables
{
message InspectMessage gMsgInspect;
message BreakPointMessage gMsgBreakPoint;
message BreakPointMessage2 gMsgBreakPoint2;
msTimer tSignalUpdateBreakPoint;
byte gBreakPointMsgByte0 ;
byte gBreakPointMsgByte1 ;
byte gBreakPointMsgByte2 ;
byte gBreakPointMsgByte3 ;
byte gBreakPointMsgByte4 ;
byte gBreakPointMsgByte5 ;
byte gBreakPointMsgByte6 ;
byte gBreakPointMsgByte7 ;
byte gInspectMsgByte0 ;
byte gInspectMsgByte1 ;
byte gInspectMsgByte2 ;
byte gInspectMsgByte3 ;
byte gInspectMsgByte4 ;
byte gInspectMsgByte5 ;
byte gInspectMsgByte6 ;
byte gInspectMsgByte7 ;
}
on message InspectMessage
{
gMsgInspect = this;
gInspectMsgByte0 = gMsgInspect.SigInspect0;
gInspectMsgByte1 = gMsgInspect.SigInspect1;
gInspectMsgByte2 = gMsgInspect.SigInspect2;
gInspectMsgByte3 = gMsgInspect.SigInspect3;
gInspectMsgByte4 = gMsgInspect.SigInspect4;
gInspectMsgByte5 = gMsgInspect.SigInspect5;
gInspectMsgByte6 = gMsgInspect.SigInspect6;
gInspectMsgByte7 = gMsgInspect.SigInspect7;
// Inspect() function will update
// the variables in the debugger window
if(@sysvar::Inspect::InspectOnOff)
{
inspect();
}
}
on start
{
@sysvar::Inspect::InspectOnOff = 0;
@sysvar::BreakPoint::TimerBreakPoint = 0;
@sysvar::BreakPoint::MessageBreakPointOnOff = 0;
@sysvar::BreakPoint::SignalBreakPoint = 0;
setTimer(tSignalUpdateBreakPoint,2000);
}
on message BreakPointMessage
{
int CAPLError;
int SigPointValue;
SigPointValue = this.SigBPoint0;
if(@sysvar::BreakPoint::SetError)
{
if(SigPointValue == 0 && @sysvar::BreakPoint::SignalBreakPoint)
{
halt();
}
CAPLError = (1.0/this.SigBPoint0); // Diff through 0
}
}
on timer tSignalUpdateBreakPoint
{
if(@sysvar::BreakPoint::TimerBreakPoint)
{
@sysvar::BreakPoint::TimerBreakPoint = 0;
}
setTimer(this,2000);
}
on message BreakPointMessage2
{
gMsgBreakPoint2 = this;
// halt() function will halt the simulation, if the
// message comes into the on message handler
if(@sysvar::BreakPoint::MessageBreakPointOnOff)
{
@sysvar::BreakPoint::MessageBreakPointOnOff = 0;
halt();
}
saveMessageBytes();
}
void saveMessageBytes()
{
gBreakPointMsgByte0 = gMsgBreakPoint2.SigBPoint0;
gBreakPointMsgByte1 = gMsgBreakPoint2.SigBPoint1;
gBreakPointMsgByte2 = gMsgBreakPoint2.SigBPoint2;
gBreakPointMsgByte3 = gMsgBreakPoint2.SigBPoint3;
gBreakPointMsgByte4 = gMsgBreakPoint2.SigBPoint4;
gBreakPointMsgByte5 = gMsgBreakPoint2.SigBPoint5;
gBreakPointMsgByte6 = gMsgBreakPoint2.SigBPoint6;
gBreakPointMsgByte7 = gMsgBreakPoint2.SigBPoint7;
}
stop():停止运行上位机
if (IsSimulated()) // don't activate tests when running in simulated mode
{
WriteLineEx(wrCAPLSink, wrError
, "This demo cannot run in simulated mode!");
stop();
}
linChangeSchedTable(dword tableIndex, dword slotIndex, dword onSlotIndex)
实现调度表的调度(切换的调度表,切换的调度表的报文,上一个调度表终止调度的报文)
on start
{
//linStopScheduler();
linChangeSchedTable(2,2);
}
on key 'a'
{
linChangeSchedTable(2,2,4);
}
linRunSchedTableNTimes (1, 2, -2, -1);暂时只支持仿真模式,真实节点不确定是否可用
报错1:Start of measurement aborted:复制上位机后添加dbc出现此报错建议,重新新建一个工程环境