Action Examples

Internal I/O

Using din[#].state == 1 and rout[#].state == 1 are for referencing if inputs and outputs of the JNIOR I/O are high or low. (1 being High, 0 being low) The example above shows an if block action checking if din[1].state == 1, which means the if block won't run unless Input 1 is High, and if it is, then pulse output 1 for 5 seconds.

Temperature and Enviromental I/O

Using the temperature and humidity taken from the environmental sensor, you can perform an action based on those values. The example above shows a while block, and with a environmental sensor module hooked up to the JNIOR, you can have a task that will run a loop that logs the temperature until the temperature of the room drops to a certain number.

Validate Days of the Week

When performing actions, you can reference the day of the week to control when certain actions will perform. The example above shows two if statements, one setting output 1 to high if its Monday - Friday, and another setting output 2 to high if its Saturday or Sunday.

Send And Receive Data

The Device Send action is used for sending AND receiving data from TCP, UDP and Serial Devices. The example above shows a Device Send using a TCP Device created in the Device Tab to send the data "Test Data" to it. The Listen For Response checkbox is checked, which means we want to receive data that gets returned from that TCP device after sending our data. This adds two more fields to the actions that assigns the device's response to a variable to reference, and lets you choose if that response's data type is a string or bytes. The amount of time the action waits for a response is 2 seconds before giving up listening for return data. The actions after the Device Send are used to show how to interact and view the data. We can use the variable we assigned for the response inside our logging and user alert actions to view or record the response from the device we sent to. Even though we can choose what data type the response is, we may want to see differnt types of this data. The logging action after the send shows the hexutils.bytestohex syntax, which converts the response from bytes to hex. The user alert action after the send shows the string.frombytes syntax, which converts the response from bytes to a string.

Generate Random Number

A random number can be generated when needed. The example above logs 40 randomly generated numbers, and shows two ways you can define a randomly generated number. Both expressions start by using math.random() which is the function that generates random numbers. After that, two different types of parameters can be entered. The first expression uses 10, and that will generate a random number between the zero and ten each time it goes through the loop and log it. The second expression uses two numbers, 10.0 and 20.0 and then the function will generate a random number between the these two numbers. Since the second expressions numbers are in double format, the numbers generated are doubles as well, and can have decimals unlike the first expression. Since we are logging the variables, when they are entered into the log action they are given double curly braces.

Validate Time of Day

When performing actions, you can reference the time of day to control certain actions as well. The example above shows two if statements, setting output 1 to high for 5 seconds if its before 2:45pm, or setting output 2 to high for 5 seconds if its after 2:25pm. The time is based on 24 hours, so 11:59pm is 23:59.

4-20 and 10volt I/O

The 10volt and 4-20ma expansion modules I/O can be used to control actions based off their values. The example above shows that if the 10volt goes above 5, then it sets itself to zero, and if the 4-20ma output is greater then 10 then it sets itself back to 4.

Logical Operators

The Logical Operators are logic operations that succeed when certain conditions are met. The two Logic Operators available are the AND Operator (&&) and the OR Operator (||) The AND Operator succeeds when all conditions used for it are met. The OR Operator succeeds when at least one of its conditions are met. The example above uses both Logic Operators, starting with the Or Operator and then using the AND Operator. (rout[2].state == 1 || time.isAfter("14:00")) && rout[1].state == 1 evaluates as "If Relay Output 2 is on OR the Time is after 2:00pm, AND Relay Output 1 is on, close Relay Output 3." The parenthesis are needed because order of operations evaluates AND Operators before OR Operators.