【灵冰肌】CAPL编程例子

上传人:我*** 文档编号:133124793 上传时间:2020-05-24 格式:PDF 页数:5 大小:300.58KB
返回 下载 相关 举报
【灵冰肌】CAPL编程例子_第1页
第1页 / 共5页
【灵冰肌】CAPL编程例子_第2页
第2页 / 共5页
【灵冰肌】CAPL编程例子_第3页
第3页 / 共5页
【灵冰肌】CAPL编程例子_第4页
第4页 / 共5页
【灵冰肌】CAPL编程例子_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《【灵冰肌】CAPL编程例子》由会员分享,可在线阅读,更多相关《【灵冰肌】CAPL编程例子(5页珍藏版)》请在金锄头文库上搜索。

1、CAPL 编程例子 Example 1 Event Message Transmission 1 Example 2 Periodic Message Transmission 1 Example 3 Conditionally Periodic Message Transmission 2 Example 4 Responding to a Received Message 2 Example 5 Reading the Data within a Received Message 3 Example 6 Responding to a message after a delay 3 Exa

2、mple 7 Measuring the Time Between Periodic Messages 4 Example 8 Using CAPL to control logging 4 Example 9 Responding to a change in an Environmental Variable 5 Example 1 Event Message Transmission 定义了 ID 为 0 x555 长度为 1 的消息值为 0 xAA 按键 b 触发发送 variables message 0 x555 msg1 dlc 1 on key b msg1 byte 0 0

3、xAA output msg1 Example 2 Periodic Message Transmission 定义了 ID 为 0 x555 长度为 1 的消息 按照周期 100ms 值 发送 variables message 0 x555 msg1 dlc 1 mstimer timer1 define timer1 on start setTimer timer1 100 initialize timer to 100msec on timer timer1 setTimer timer1 100 reset timer msg1 byte 0 msg1 byte 0 1 change

4、 the data output msg1 output message CAPL 编程例子 Example 3 Conditionally Periodic Message Transmission 定义了 ID 为 0 x400 长度为 1 的消息 按住 a 有效触发发送 按照周期 200ms 值 发送 variables message 0 x400 msgA dlc 1 mstimer timerA int conditionA 0 initialize conditionA off on key a conditionA conditionA toggle conditionA if

5、 conditionA 1 if condition is active setTimer timerA 200 then start timer on timer timerA if conditionA 1 if condition is still true setTimer timerA 200 then continue timer msgA byte 0 msgA byte 0 1 change the data output msgA output message Example 4 Responding to a Received Message on message ABSd

6、ata EngineData message WheelInfo wMsg Define a new message Print a message to the screen write Message lX received on CAN ld this ID this CAN Send out another message output cdMsg CAPL 编程例子 Example 5 Reading the Data within a Received Message on message EngineData long product Read EngSpeed and EngT

7、emp signals product this EngSpeed phys this EngTemp phys write The product of the engine speed and write engine temperature is l product on message EngineTemp byte value float temp value this byte 0 Scale the number so we get 2 decimal places temp float 100 write The temperature is lf degrees temp E

8、xample 6 Responding to a message after a delay Variables Timer delayTimer Seconds based timer long delayTimerPeriod 5 Delay of 5 seconds on message doorState if this Closed 1 setTimer delayTimer delayTimerPeriod else Do sth if doors are open on timer delayTimer message DomeLight dlMsg dlMsg Status 0

9、 Turn off dome light output dlMsg CAPL 编程例子 Example 7 Measuring the Time Between Periodic Messages Method 1 on message 0 x101 long lastTime 0 write Message 0 x101 recevied at ld this TIME write Time interval lf milliseconds this TIME lastTime 100 0 lastTime this TIME Method 2 variables message 0 x20

10、2 saveMsg on message 0 x202 write Message 0 x202 received at this TIME write Time interval ld milliseconds timeDiff saveMsg this saveMsg this saveMsg declared globally Example 8 Using CAPL to control logging on message 0 x101 Set the PreTrigger time to 1 second 1000 ms setPreTrigger 1000 Set the Pos

11、tTrigger time to 5 seconds 5000 ms setPostTrigger 5000 Set the name and path of the log file setLogFileName c logs log101 Trigger logging trigger CAPL 编程例子 Example 9 Responding to a change in an Environmental Variable 改变环境变量的响应 on envVar switchState int switchValue switchValue getValue this switch switchValue case 0 write Switch is now off break case 1 write Switch is now on break default write Switch returned an illegal value break on start CallAllOnEnvVar

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号