Reputation: 497
I have a CAPL file attached to a CAN node that periodically sends a message using the 'output' function. How can I use a second CAPL file to block the node sending the message (while doing everything that the node does) ?
Upvotes: 0
Views: 6896
Reputation: 11
You can stop all your cyclic messages, by canceling timers of Each message
Example:
message can1.0x12 message1;
msTimer tmessage1;
on timer tmessage1
{
output(message1); // sending message
setTimer(tmessage1,100); // set the cyclic time as 100ms
}
on envVar envmessage1
{
if (getValue(envmessage1) == 1)
{
setTimer(tmessage1,100); // set and start the cyclic time as 100ms
}
else
{
cancelTimer(tmessage1); // cancel the cyclic timer
}
}
if you just do envmessage1 = 0
in another node, it will stop the message, like the same for all messages, have to write environment variable, then you can control other Node messages.
Upvotes: 1
Reputation: 512
You can create a sysvar in your simulation, which will be used as a switch in your simulated *.can
Network node.
You just have to condition the output code to the value of the system variable you created.
if (Sysvar_SimEnabled)
{
output(message);
output(message1);
output(message3);
}
This Sysvar_SimEnabled
will be a global variable, thus can be set to any value from another *.can
CAPL Network node.
Upvotes: 1
Reputation: 17979
You can add an output filter to your node, as shown below, to block the messages.
Upvotes: 3