Service Condition

Parent Previous Next

Service Condition

The Service Condition type is used when the user wants to execute the script according to a specific condition. The condition is verified at every determined interval and if the condition is satisfied the script will be executed, until the condition becomes false.


There are three fields in the Service Condition document:


.     Type: A ComboBox to select if the document will be a condition or a trigger type. In this case this property will have the "Condition" value selected.


.     Expression: Set the condition that will be verified at every interval. This field can be filled with:

.     true: The script will always be executed.

.     Users condition: The script will be executed every time the condition is true. For example: @TagCondition == false.

.     false: The script will only be executed if called explicitly from another script. To call it explicitly, just write:


NameOfServiceDocument();.


For example, if we have a service named: ServiceTest, to call it, we will have to write: ServiceTest(); in another script.


.     Interval (ms): Determines the interval of time that the service will compare the condition. This field is configured in milliseconds.



Configuration


To configure a Condition Service, follow the steps below:


1.   In the Type ComboBox field, select the value Condition.


2.   Insert the desired condition that will activate the service. For example: @TagCondition == 4.


3.   Click the Check button or press "Enter" to verify if the script is correct.


3.1.   If it is correct, continue in the next step.


3.2.   If not, revise the script inserted.


4.   Insert the interval of time (in milliseconds)  that the condition will be verified in the Interval field. For example: 1000(1 second).


5.   Insert the Script to be executed when the condition is satisfied.


6.   Click the "Verify" Button in the Ribbon.


6.1.   If it is correct, the Service is fully configured.


6.2.   If not, revise the script inserted.




.     Condition satisfied:


.     In the expression of the Service document, the user sets the following condition: @TagBoolean == true;


In the Interval field, the user sets the value to 1000 milliseconds and in the script the user sets the following code: @TagIncrement++;


When the RunTime starts, the @TagBoolean has value "false", so the service will not be executed and the @TagIncrement will not have its value incremented. When the @TagBoolean has its value changed to "True", the @TagIncrement will start to increase their value until the @TagBoolean returns to "False" value.




.     Explicit call of the Service:


.    Create a new Service document named Service1.

.    The type of this document will be "Condition".

.    In the Expression field, insert the value "False" (without the quotation marks).

.    In the script, set the following code: @TagIncrement++;




.     Then, create a Graphic Document named Test, and then create a Button object. In the ScriptDock of the Button, set the following code in the MouseDown action:


       Service1();


graphic



.    Set the Test document as the Startup Screen and start the RunTime. When the user clicks the button, the Service1 will be executed and the @TagIncrement will have its value increased.