overviewPreface
In practical application scenarios, users often need to control the start and stop of TSMaster built-in function modules according to a certain logic and time sequence. TSMaster software has built-in C/Python applets and graphic programs, which allow developers to precisely control the operation of these modules through programming. This article will focus on sharing with you how to control the start and stop of TSMaster built-in modules through C code.
Keywords in this article: run_form, stop_form, C applet, COM
Catalog/catalog
● Window start and stop functions
● Built-in applet to control the start and stop of other applets
● Program start/stop control via COM
I. run_form and stop_form functions
The built-in TSMaster applets are run_form function and stop_form function, which are used to control the start and pause of the TSMatser working window. For example, for the CAN / CAN FD transmitter window, these two functions allow us to program the control of the CAN / CAN FD transmitter window to start or stop sending messages.
Second, the use of small programs to control the start and stop of other small programs
Through the run_form function and the stop function can be realized on the TSMaster window start and stop to achieve control, where the window naturally includes the C applet window, Python applet window and graphics program window. This way we can control each other through the code between the program start and pause.
🔜 As in Figure 2, we created two C applets, named "C Code Editor [1]" and "C Code Editor [2]", and we implemented the control of C applet 1 in the key event of C applet 2, and printed the start information to the system message in the program start event and program stop event of C applet 2. We implement the control of C applet 2 in the key event of C applet 1, and print the startup information to the system message in the program start event and program stop event of C applet 2.
In some test scenarios we need to control a number of applets in a sequential loop start and pause, you can call the terminate_application function in each applet to end the current applet when you need to stop the current applet, and then use the run_form function to start the next C applet in the end-of-program event.
🔜 As in Fig. 3, we close this applet and start the next applet two seconds after the start of each applet, which implements cyclic control of C applets 1, 2, and 3.
In addition to the use of these two functions need to pay attention to one point, in the use of the window name as the entry parameter must be the name of the window to enter the complete, for example, Figure 2, the use of these two functions to control the start and stop of the program need to be complete to enter the "C Code Editor [1]", rather than just " 1", otherwise it will report an error in the system message window that the window cannot be found.
III. Start-stop control of small programs via COM
TSMaster opens COM interface to facilitate developers to call and control TSMaster project through external programs, but does not open the run_form and stop_form interfaces similar to applets to directly control the start and stop of small programs in TSMaster project.
However, it doesn't mean that we can't control the start and stop of the small programs in the TSMaster project through the external program, we can always open a small program in the controlled TSMaster project, and control the start and stop of the other small programs through the variable change events in this small program, so we can control the start and stop of the small programs in the TSMaster project indirectly by the external program through the COM interface of the system variable call. This allows an external program to indirectly control the start and stop of small programs in the TSMaster project by calling the COM interface of a system variable.
Steps to control the TSMaster applet via COM:
1. Set up an auto-start applet in the controlled TSMaster applet, associate a variable change event with this applet, and use the run_form function and stop_form function to control other applets in the variable change event.
2. In the external program that calls the COM component, use the load_project function to import the TSMaster project that needs to be controlled, configure the number of channels and the mapping of this property, and then use the connect function to start the TSMaster project.
3. Use set_system_var_generic to assign values to the system variables in the TSMaster project, and trigger the variable change event in the C applet to call the run_form and stop_form functions to realize the control of starting and stopping the TSMaster applet.