当前位置:网站首页>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
边栏推荐
- [machine] [server] Taishan 200
- The most detailed teaching -- realize win10 multi-user remote login to intranet machine at the same time -- win10+frp+rdpwrap+ Alibaba cloud server
- The most ideal automated testing model, how to achieve layering of automated testing
- Rhcsa learning practice
- RHCE - day one
- [Galaxy Kirin V10] [server] iSCSI deployment
- Seven examples to understand the storage rules of shaped data on each bit
- Jemeter plug-in technology
- Basic data types of MySQL
- Evolution from monomer architecture to microservice architecture
猜你喜欢

Introduction to extensible system architecture

Rhcsa day 10 operation

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

What is an excellent architect in my heart?

Discussion | has large AI become autonomous? Lecun, chief scientist of openai

JMeter assembly point technology and logic controller

Architecture introduction

Unittest+airtest+beatiulreport combine the three to make a beautiful test report

Deepmind proposed a Zuan AI, which specially outputs network attack language

DDL statement of MySQL Foundation
随机推荐
Seven examples to understand the storage rules of shaped data on each bit
If you don't know these four caching modes, dare you say you understand caching?
Huge number multiplication (C language)
DCL statement of MySQL Foundation
[machine] [server] Taishan 200
Recursive method to achieve full permutation (C language)
Dynamic memory management
[Galaxy Kirin V10] [server] FTP introduction and common scenario construction
Architecture introduction
Basic data types of MySQL
Two way process republication + routing policy
Talk about scalability
Rhcsa learning practice
Performance test method
51 data analysis post
IPv6 comprehensive experiment
Write a program to judge whether the two arrays are equal, and then write a similar program to compare the two vectors.
Unittest+airtest+beatiulreport combine the three to make a beautiful test report
Linked list operation can never change without its roots
Ten key performance indicators of software applications