天津市网站建设公司wordpress在哪里注册
news/
2025/9/24 6:58:28/
文章来源:
天津市网站建设公司,wordpress在哪里注册,天津网站制作套餐,网站弹出广告gif出处1 事件概述
CAPL是一种面向过程、由事件驱动的类C语言。
事件驱动针对于顺序执行#xff0c;其区别如下#xff1a;
顺序执行#xff1a;顺序执行流程中#xff0c;子例程或过程函数按照代码编写顺序逐句执行。
事件驱动#xff1a;CAPL程序由事件驱动#xff0c;工程…1 事件概述
CAPL是一种面向过程、由事件驱动的类C语言。
事件驱动针对于顺序执行其区别如下
顺序执行顺序执行流程中子例程或过程函数按照代码编写顺序逐句执行。
事件驱动CAPL程序由事件驱动工程运行过程中发生指定的事件时才会运行相应的事件处理函数。 顺序执行VS事件驱动
在CAPL中添加事件处理函数 重要的事件处理函数 事件总览 [3] 2 事件详解
事件起始关键字 on
on后加某种事件工程运行时条件触发则执行函数体内的语句。
关键字this
系统变量、环境变量或CAN报文事件中可以用this关键字访问其指代的数据内容如
on envvar Switch {
// Declare a CAN message to be transmitteed
message Controller msg;// Read out the value of the switch
// Assign to the signal Stop
msg.Stop getvalue(this);
// Output the message on the bus
output(msg);
}
系统事件
系统事件主要用于处理CANoe测量系统的控制功能主要有on start、on preStart、onstopMeasurement、on preStop、on keynewKey以及on timer 系统事件Example
//on preStart procedureon preStart
{write(Measurement started!);msg_Count 0;
}//on start procedureon start
{write(start Node A);setTimer(cycTimer,20);CallAllOnEnvVar(); // CANoe only
}//on preStop procedureon preStop
{message ShutdownReq m;output(m);DeferStop(1000);
}//on stopMeasurement procedureon stopMeasurement
{write(Message 0x%x received: %d, msg.id, msg_Count);
}
CAN控制器事件
当CAN控制器或错误计数器状态变化时调用CAN控制器事件。 CAN控制器事件Example
//on errorPassive procedure
on errorPassive {...write(CAN Controller is in errorPassive state)write( errorCountTX %d, this.errorCountTX);write( errorCountRX %d, this.errorCountRX);
};//on busOff procedure
on busOff
{int errRxCnt;int errTxCnt;int channel;double timestamp; // [seconds]timestamp (double)timeNow() / (double)100000;channel this.can;errRxCnt this.errorCountRX;errTxCnt this.errorCountTX;Write(Bus Off: time%f channel%d, errRxCnt%d, errTxCnt%d,timestamp, channel, errRxCnt, errTxCnt);resetCanEx(channel);
}
CAN报文/信号事件
CAN报文或信号变化时调用报文/信号事件。 CAN报文/信号事件
报文事件 信号事件
on signal LightSwitch::OnOff
{v1 this.raw;v2 $LightSwitch::OnOff.raw;
}
定时器事件
定义好定时器变量后由SetTimer函数设置定时器间隔并启动定时器。当定时器运行到设定的时间间隔时触发定时器事件并执行on timer函数体中的程序。
msTimer myTimer;
message 100 msg;
...
on key a {setTimer(myTimer,20);
}
...
on timer myTimer {output(msg);
}
键盘事件
通过定义键盘事件用户可以在工程运行时通过点击键盘触发预先定义的行为。这在实际开发和测试时非常常用。比如用户可以在任意时刻向总线发送特定的消息、改变信号或系统变量的值或是启动停止测量。
系统变量/环境变量事件
系统变量和环境变量事件分别是对系统变量和环境变量发生变化时的响应。
系统变量事件
on sysvar IO::DI_0
{
$Gateway::IOValue this;
}
环境变量事件
on envvar Switch {
// Declare a CAN message to be transmitteed
message Controller msg;// Read out the value of the switch
// Assign to the signal Stop
msg.Stop getvalue(this);
// Output the message on the bus
output(msg);
}
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/915137.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!