当前位置:网站首页>Canoe the second simulation engineering xvehicle 3 CAPL programming (operation)
Canoe the second simulation engineering xvehicle 3 CAPL programming (operation)
2022-07-04 10:50:00 【picoasis】
The main content of this paper is :XVehicle Node functions and corresponding CAPL Detailed procedure .
This article is from 《CANoe Development from entry to mastery 》.
Catalog
X-Vehicle Engineering node - Signal diagram
X-Vehicle Engineering node - Signal diagram

( Let's take a look at the picture )
environment variable : Node IO The signal , It can be used for panel or real IO
System variables :ECU Node internal variables
establish CAPL file
simulation setup Interface ECU When editing the database , The database file that will be generated , And the corresponding nodes Import simulation setup Generate .
stay simulation setup Interface , In the corresponding ECU Right click , Separately build engine.can, door.can, display.can, Save in nodes Under the folder .

Engine Node CAPL
engine Nodes need to be operated according to users , Sending signal , Corresponding ECU The function is :
- On receiving ‘ Turn on and off the engine ’ In operation , take OnOff The signal Update to message EngineState On .
- When the engine speed changes , Judge whether it is necessary to EngineSpeed The signal is updated to the message EngineState On .
- If the engine is on On, Then update the message EngineState Of EngineSpeed The signal
- If the engine is off Off, Then the message EngineSpeed Should be 0
The code is as follows :
/*@!Encoding:936*/
/*
function :
1. When the engine switch acts , Update message EngineState Signal in OnOff
2. The logical relationship between engine switch and engine speed :
- When the engine is running , The engine speed can be updated
- When the engine is off , The engine speed is automatically set to 0
*/
includes
{
}
variables
{
}
// When the engine starts , Update the speed information of the message
On sysvar sysvar::Engine::EngineStateSwitch
{
$EngineState::OnOff = @this;
if(@this)
$EngineState::EngineSpeed = @sysvar::Engine::EngineSpeedEntry;
else
$EngineState::EngineSpeed = 0;
}
// When the speed control changes , Update the speed information of the message
On sysvar sysvar::Engine::EngineSpeedEntry
{
if(@sysvar::Engine::EngineStateSwitch){
$EngineState::EngineSpeed = @this;
}
}Door Node CAPL
Door Nodes are operated by users , Send the door opening message :
Send message :DoorState( The signal :Door_L,Door_R)
Because in Panel The message has been associated with the door switch control in the design , therefore CAPL This part of the code is not required in .
The following code is , Add some write Debug I / O function of window .
/*@!Encoding:936*/
/* function :
write Debug output function of window : By calling functions , Output information that users care about .
SetwriteDbgLevel Set functions and writeDbgLevel Output function
(1)key'0' Turn off debugging information output ,Key'1' Turn on debug information output
(2) Check the message DoorState The receiving direction of ,
- When the debugging information output function is turned on , It can be output to Write window
- Theoretically , node Door You should not receive messages sent by other nodes DoorState
*/
includes
{
}
variables
{
int gDebugCounterTX = 0;
int gDebugCounterTXRQ = 0;
int gDebugCounterRX = 0;
}
On start
{
setWriteDbgLevel(0);// Set up debugLevel by 0, No output debug Information
}
// Check the message DoorState The transmission of Direction
On message DoorState
{
// If the direction is TX
if (this.dir == TX)
{
gDebugCounterTX++;
if(gDebugCounterTX==10)
{
writeDbgLevel(1,"DoorState TX recieved by node %NODE_NAME% ");
gDebugCounterTX = 0;
}
}
// If the direction is TXRQ
if (this.dir == TXREQUEST)
{
gDebugCounterTXRQ++;
if(gDebugCounterTXRQ==10)
{
writeDbgLevel(1,"DoorState TXREQUEST recieved by node %NODE_NAME% ");
gDebugCounterTXRQ = 0;
}
}
// If the direction is RX
if (this.dir == RX)
{
gDebugCounterRX++;
if(gDebugCounterRX==10)
{
writeDbgLevel(1,"Error: DoorState RX recieved by node %NODE_NAME% ");
gDebugCounterRX = 0;
}
}
}
// Processing keys '0' event : prohibit debug Information output
On key '0'
{
setWriteDbgLevel(0);
}
// Processing keys '1' event : Turn on debug Information output
On key '1'
{
setWriteDbgLevel(1);
}Display Node CAPL
Display The node receives data from Door and Engine Message of , Read message signal , Displayed on the panel .
therefore ,Display Its function is to monitor message events .
Received EngineState When the message , Read EngineState The signal , Displayed on the instrument panel and digital meter respectively .
Received DoorState When the message , Read Door_L、Door_R The signal , Assign to your own environment variable , Control the display of door opening status .
/*@!Encoding:936*/
/* Receive message , And show it on the panel .
Engine on state : Associated with the signal EngineState::EngineStateSwitch, It will update automatically
Engine speed Exhibition :on message EngineState
Door status display :on message DoorState
*/
includes
{
}
variables
{
}
on message EngineState
{
if (this.dir == RX)
{
@sysvar::Engine::EngineSpeedDspMeter = this.EngineSpeed/1000.0;
}
}
on message DoorState
{
if (this.dir == RX)
{
@EnvDoorState = this.Door_L + this.Door_R*2;
}
}thus , The program of the node is edited .
XVehicle The project is finished . The normal operation is as follows .( Another day )
END
边栏推荐
- BGP advanced experiment
- Deepmind proposed a Zuan AI, which specially outputs network attack language
- 183 sets of free resume templates to help everyone find a good job
- Installation of ES plug-in in Google browser
- BGP ---- border gateway routing protocol ----- basic experiment
- [Galaxy Kirin V10] [desktop] login system flash back
- Add t more space to your computer (no need to add hard disk)
- Three schemes of ZK double machine room
- Collection of practical string functions
- Two way process republication + routing policy
猜你喜欢

Occasional pit compiled by idea
![[Galaxy Kirin V10] [server] FTP introduction and common scenario construction](/img/ef/f0f722aaabdc2d98723cad63d520e0.jpg)
[Galaxy Kirin V10] [server] FTP introduction and common scenario construction

Article publishing experiment

OSPF comprehensive experiment

Open the neural network "black box"! Unveil the mystery of machine learning system with natural language
![[Galaxy Kirin V10] [server] NFS setup](/img/ed/bd7f1a1e4924a615cb143a680a2ac7.jpg)
[Galaxy Kirin V10] [server] NFS setup

Introduction to extensible system architecture

system design

The bamboo shadow sweeps the steps, the dust does not move, and the moon passes through the marsh without trace -- in-depth understanding of the pointer

Collection of practical string functions
随机推荐
Introduction to tree and binary tree
leetcode842. Split the array into Fibonacci sequences
Write a program to judge whether the elements contained in a vector < int> container are 9.20: exactly the same as those in a list < int> container.
Collection of practical string functions
Personal thoughts on the development of game automation protocol testing tool
Hidden C2 tunnel -- use of icmpsh of ICMP
2022 ape circle recruitment project (software development)
RHCE day 3
VLAN part of switching technology
Sword finger offer 31 Stack push in and pop-up sequence
Performance test method
What is an excellent architect in my heart?
Terms related to hacker technology
Virtual machine configuration network
Idea SSH channel configuration
[Galaxy Kirin V10] [server] system partition expansion
[advantages and disadvantages of outsourcing software development in 2022]
Fundamentals of database operation
Crawl Zhejiang industry and trade news page
Write a program to define an array with 10 int elements, and take its position in the array as the initial value of each element.