Parallel Processing
This new article was suggested by the interesting feed-back from RoboProEntwickler aka. Michael.
There is a very simple way to stop processes in ROBOPro. All processes created in a subprogram are terminated as soon as the main thread of the sub-program leaves the sub-program. So all you have to do is to create the processes you want to terminate in sub-programs. I'm not going to discuss here the difference between distributed processing (reference), parallel processing (reference) and concurrent processing (reference). Please check the provided references linked to the well explained Wikipedia articles. Robo Pro makes parallel processing very easy with its GUI. This is a tremendous feature worth considering. Basically, what I want to do is perform different actions at the same time and close them all at once in a clean way. As usual, all the Robo Pro program files are available for download. See the downloads section below. |
Main Program
First Attempt
On this first attempt, all the processes are included on the Parallels sub-program.
When the main thread is terminated, so are the others. Note the two unlinked STOP instructions, which doesn't look very clean. When the main process stops, all the processes stop at once. The update was prompted by the feed-back I received from RoboProEntwickler aka. Michael. Ending the processes properly is of cause recommended, but not required. ROBOPro does proper stack unwinding when a process is killed when the context of the process ends. There's no possibility to add specific pre-end instructions to prepare the exit. For example, I can't switch on a red light for the most-right process before everything stops. This first attempt is technically valid, but we may need extra functionalities. |
Second Attempt
Based on the first attempt, I include a control to check all on-going operations with pre-end instructions are completed before exiting.
This is an answer for a functional requirement. For example, based on my previous projects:
Each thread sends the value =1 to a AND gate, which triggers the exit back to each thread. The AND gate secures all the threads have ended their respective jobs before allowing the full exit. The right-most process could now include pre-end instructions, switching on the Lampe indicator. |
Third Attempt
Based on the second attempt, I use the procedures END_Process and END_Test I presented on the Multi-Tasking End Management Procedure.
As usual with Robo Pro, elaborated program aren't easy to read. |
Forth Attempt
Based on the third attempt, the specific code of each thread is moved into separate sub-programs, Parallel-1, Parallel-2 and Parallel-3 respectively.
Adding a new thread is easier. The only tricky step is to add a new input to the AND gate. |
Here are the associated sub-sub-programs, Parallel-1, Parallel-2 and Parallel-3.
To make things easier to understand, just compare how the projects behave:
On Robo Pro, select Simulation as interface and check the red lamp when you push the exit Bouton button. The step-by-step debugging could also help. |
Downloads
Download the driver with an example for RoboPro.
These files are under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. |
|
Minimum Number of Procedures
A specific un-documented parameter should be set to avoid an error message.
Go on Main Program > Properties pane, and set Minimum number of procedures from 5 by default to 16.
Go on Main Program > Properties pane, and set Minimum number of procedures from 5 by default to 16.