overviewPreface
Today, we will introduce you to the TSMaster's small function of how to draw curves in the graph of bus load factor. To achieve this function, you need to use the statistics and graph/panel functions in TSMaster.
Step 1
Add com.enable_bus_statistics(true) to the C script startup event to enable the bus statistics timer to calculate bus statistics.
Step 2
After running the C script, you can find the current bus load factor variable in System Variables - Internal Variables.
Why is this operation necessary? This is because the endogenous system variables are automatically generated and released following the system.
For example, if CAN1 is added, statistics related to StaticsCAN1 will be generated dynamically; if CAN1 is deleted, these statistics will disappear. This means that the statistics module is started together with the TSMaster by default. If the TSMaster application is not started, the statistics module will not be started and the statistics system variables will not be visible in the system variables. We can use the API of the C applet to start the statistics module, so that we can get the system variables related to the statistics device information without starting the project.
Step 3
Add the system variable of bus load rate in the graph window to observe the graph, while loading the EngSpeed signal in the DBC.
Step 4
1. Add graphics, input/output box, and image button controls to the panel; set the number of signals for the graphics control to 2 and bind the bus load rate variable of channel 2 with the input/output box control; bind the second signal of the graphics to the EngSpeed signal in the DBC.
2. Set the number of graphics for the Image button control to 3, with corresponding Values of 1, 2 and 3, bind the variable Bus_load_status created in the C applet, and then use the corresponding image (Image) to represent the status of the bus load through this control.
3. In the C applet, the CAN receive event reads the value of the system variable bus load rate to judge the status value, the send event will be triggered after each successful message is sent, while capturing the falling edge of EngSpeed when the load rate exceeds 80%, leaving some comments at the falling edge moment, the implementation code is as follows.
PointHit immediately to enter the same star official website>> Get Technical Support
More TSMaster video tutorials>> Click to view