当前位置:网站首页>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
边栏推荐
- Three schemes of ZK double machine room
- Strings and characters
- JMeter Foundation
- Interview and lecture summary 1
- Rhsca day 11 operation
- Online troubleshooting
- Summary of automated testing framework
- Collection of practical string functions
- [Galaxy Kirin V10] [server] set time synchronization of intranet server
- Fundamentals of database operation
猜你喜欢
[machine] [server] Taishan 200
[Galaxy Kirin V10] [desktop and server] FRP intranet penetration
IPv6 comprehensive experiment
JMeter common configuration components and parameterization
Dichotomy search (C language)
[Galaxy Kirin V10] [desktop] build NFS to realize disk sharing
Hidden C2 tunnel -- use of icmpsh of ICMP
Dynamic memory management
VLAN part of switching technology
C language - stack
随机推荐
The most ideal automated testing model, how to achieve layering of automated testing
Application and Optimization Practice of redis in vivo push platform
Iterator generators and modules
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
Jianzhi offer 04 (implemented in C language)
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
OSPF comprehensive experiment
Rhsca day 11 operation
Rhcsa12
Interview and lecture summary 1
Linked list operation can never change without its roots
JMeter assembly point technology and logic controller
Snake (C language)
51 data analysis post
MFC document view framework (relationship between classes)
Evolution from monomer architecture to microservice architecture
Rhcsa operation
[Galaxy Kirin V10] [server] NUMA Technology
Two way process republication + routing policy
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool