<< Click to Display Table of Contents >> Navigation: 3. Script Language > Parallel-Robot Operations > Parallel Robot Operations |
MiniRobotLanguage (MRL)
PRE. Command
Parallel Robot run End
Intention
The command PRR. can be used to start a parallel running robot. For this purpose it starts a block containing the script for the new robot. The PRE. command will end this script-block.
PRR. and PRE. must always be used in Pairs. They can be nested, a Parallel-Robot can start another parallel robot and so on.
The parallel-robot will knows all variables that the starting robot knows at the starting time.
From that time each robot works in his own address-space and with its own variables.
Technically it looks like this:
PRR.
' Script that the parallel-robot will execute
' This is the END for the Parallel robot
END.
PRE.$$RET
' Here the Main-Robot continues with his script
The Main Robot will not execute anything that is between the PRR. and the PRE.
The PRE. is not an END.-command for the Parallel-Robot.
The PRE. just tells the Main robot where to continue, and it gives the communication handle of the parallel-robot to the main-robot.If you want the Parallel-Robot to end at the PRE., place an END. command there. If you do not place an END. command there, the parallel-robot will walk over the PRE. into the Main-robots-script and continue running it.
In fact the Parallel-Robot starts with a 1:1 copy of the full script including all subroutines. The parallel robot will also start with a copy of all variables that the main robot had at this time. In fact he is more a "Clone" then a brother to the main-robot. As a result, a parallel robot can call all subroutines in the script, because he has a complete 1:1 copy of the script..
More Infos:
You can send variables to another running robot using PRV. Unless the Robot is on another "Private Desktop".
You can wait for a variable from another running robot using WFV.
You can set a global Signal that multiple running Robots will see, using SGS. and check if such a signal exist, using IGS.
Here is an Example that shows how you can wait for 5 Parallel Processes to end.
Click on the 5 Messageboxes and see what happens.
VAO.$$TIB=
FOR.§§LOP|1|5
' Run 5 Robots
PRR.0
MBX.!
END.
PRE.$$TIC
'$$TIC is the Window-Handle of the new Robot for use with PRV.
' The Kom-Handle is on TOS for use with WRS.
VAR.$$TID=$tos$
' Collect the Tickets separated with ","
$$TIB=$$TIB,$$TID
PRT.$$TIB
NEX.
' Wait until they end
WRS.!$$TIB
ENR.
Syntax
PRE.[P1][|P2]
Parameter Explanation
P1 - (out) - will be given the WIndow-Handle of the started Robot. Which is the same as a window-handle. The Communicationshandle will be placed on TOS for use with WRS..
P2 - (in) - Timeout in sec. to wait for the robot to start.
You will also find these values on the Stack:
1. Window-Handle-New Robot.
2. On the second stack place is the "Ticket-Number" for use with WRS. / GRS. / IRS.
technically, its the same number, but prefixed with a "H".
Example
'**********************************************
' PRR./PRE./PRV. - Sample 1
' Shows that the Parallel-Robot starts with
' all variables as they have been at starting-time
' of the starting robot.
' It can also use all Subroutines in this file.
'**********************************************
VAR.$$INP=0
VAR.$$TXT=Peter
PRT. I am the Main Robot.
'-----------------------------------------------------------
PRR.
PRT.I am Parallel-Robot-Nr. #pri# from #prc#.
PRT.I am Son #pri# of $$TXT.
:Loop
WFV.$$INP|10
PRT. Variable set to: $$INP
GSB.wait
'JIV.$$INP=1|out
JMP.Loop
:out
END.
PRE.$$RET|0
GRS.$$RET|$$RES
'-----------------------------------------------------------
PRT.KOM-H: $$RET
PRT.I have #prc# running parallel robots and PlugIns.
PAU.1
FOR.$$MYL|1|300
VAN.$$INP=1.342587459
PRV.$$RET|$$INP
VAC.$$INP=12,31,(2*45),(5+67)
PRV.$$RET|$$INP
VAP.$$INP=142,32
PRV.$$RET|$$INP
PAU.0.23
NEX.
' This will end the parallel robot
VAN.$$INP=1
PRV.$$RET|$$INP
PAU.2
DMP.
MBX.!
END.
'-----------------------------------------------------------
:wait
PAU.0.5
RET.
'-----------------------------------------------------------
Remarks
The Parallel-Robot starts with the full script. Therefore do not forget the END. before the PRE. Otherwise the Parallelrobot will just walk over the PRE. into the Script of the starting robot. Then both will try to do the same script at the same time.
Limitations:
It is possible to start more then one Parallel-running robot, actually up to 8.
Each robot uses quite some system resources/memory therefore you should not run too many, depending on your CPU number and memory capacity.
Each robot runs independently from the moment he starts with his script.
It may or may not be possible to use this feature to install multiple software products at the same time. This depends on the used installer and the setup-program.
See also:
• ! Smart Package Robot 's Parallel Robot Operations
• PRE. - Parallelrobot-Run-End
• PRV. - Parallel-Robot send Variable
• WFV. - Wait-For-VariableChange
• SGS - Set Global Signal (Mutex)