当前位置:网站首页>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
边栏推荐
- software test
- Day06 list job
- Dichotomy search (C language)
- Performance test method
- Rhsca day 11 operation
- Regular expression
- IPv6 comprehensive experiment
- Talk about scalability
- Network connection (III) functions and similarities and differences of hubs, switches and routers, routing tables and tables in switches, why do you need address translation and packet filtering?
- Debug:==42==ERROR: AddressSanitizer: heap-buffer-overflow on address
猜你喜欢

How to use diff and patch to update the source code

system design

20 minutes to learn what XML is_ XML learning notes_ What is an XML file_ Basic grammatical rules_ How to parse

Evolution from monomer architecture to microservice architecture

From programmers to large-scale distributed architects, where are you (I)

Article publishing experiment
![[Galaxy Kirin V10] [server] FTP introduction and common scenario construction](/img/ef/f0f722aaabdc2d98723cad63d520e0.jpg)
[Galaxy Kirin V10] [server] FTP introduction and common scenario construction

Dichotomy search (C language)

On binary tree (C language)

Application and Optimization Practice of redis in vivo push platform
随机推荐
[Galaxy Kirin V10] [desktop] FTP common scene setup
Jemeter script recording
JMeter assembly point technology and logic controller
Hidden C2 tunnel -- use of icmpsh of ICMP
[Galaxy Kirin V10] [server] NUMA Technology
Article publishing experiment
The most ideal automated testing model, how to achieve layering of automated testing
Write a program to judge whether the two arrays are equal, and then write a similar program to compare the two vectors.
Snake (C language)
[Galaxy Kirin V10] [desktop] printer
The future education examination system cannot answer questions, and there is no response after clicking on the options, and the answers will not be recorded
Delayed message center design
[untitled]
Architecture introduction
Map container
Latex error: missing delimiter (. Inserted) {\xi \left( {p,{p_q}} \right)} \right|}}
Linked list operation can never change without its roots
Personal thoughts on the development of game automation protocol testing tool
From programmers to large-scale distributed architects, where are you (I)
Si vous ne connaissez pas ces quatre modes de mise en cache, vous osez dire que vous connaissez la mise en cache?