Tag Archive: logic

You can use the scheduling in Cinema.jar to schedule macros daily, weekly or monthly. When Cinema.jar is installed and executed for the first time it will create 3 default keys. They will look like this in the registry. 

Below are examples for the logic you can implement in Cinema using these registries.

OnIOChange

This logic expression will be checked whenever the JNIOR I/O changes. The I/O that can be monitored are the internal inputs and outputs on the JNIOR as well as any outputs on a 4 relay output expansion module.

OnIOChange, din1 and din2, run test

For the above example, each time either input 1 or 2 changes, the logic rule (din1 AND din2) will be evaluated and the macro (test) will execute if both inputs are ON.

OnPreshowClient()

This logic expression will be checked whenever the Preshow Client in Cinema.JAR receives a message. To specify the string/message that will cause the logic to be evaluated put it inside the parenthesis.

OnPreshowClient(start), din3 and din4, run preshow start

For the above example, each time the device connected to the JNIOR as the Preshow Client sends the string “start” to Cinema.JAR, the logic rule (din3 AND din4) will be evaluated and the macro (preshow start) will execute if both inputs are ON.

OnCinemaServer()

This logic expression will be checked whenever the Cinema Server Client in Cinema.JAR receives a message. To specify the string/message that will cause the logic to be evaluated put it inside the parenthesis.

OnCinemaServer(movie), din5 or din6, run movie start

For the above example, each time the device connected to the JNIOR as the Cinema Server Client sends the string “movie”, the logic (din5 OR din6) will be evaluated and the macro (movie start) will be run if either digital input is ON.

OnMacro()

This logic expression will be evaluated whenever the named macro has been requested to run. This logic expression can be used as a ‘lock’ to make sure certain macros can only execute when a certain I/O state exists or cannot be executed when a certain I/O state exists. To specify the macro that is bound by this logic place its name inside the parenthesis.

OnMacro(flat start), din7

For the above example, if the macro “flat start” is triggered to run via any method, the logic (din7) will be checked. If (din7) is ON, the macro will be allowed to run. If (din7) is OFF, the macro will not be allowed to run. 

Below is an example registry using some of the examples above.

Tasker implements lots of different logic. One such instance are Logic Operators, specifically the AND Operator (&&) and OR Operator (||). We will start with the AND Operator, which will succeed if separate conditions are met simultaneously. For example, lets say we want to close Relay Output 3, but only if Relay Outputs 1 AND 2 are closed. To create this logic in Tasker, we’ll create an empty Task and add an If Statement to it, followed by adding a Close Relay 3 action inside the If Statement. Here we’ll enter the following:

rout[1].state == 1 && rout[2].state ==1

This statement evaluates as “If Relay Output 1 AND Relay Output 2 are closed, then close Relay Output 3”. Now if Relay Outputs 1 and 2 were closed when this Task runs, it will pass the If Statement condition and close Output 3.

&& goes between the two conditions that both need to be met

Next is the OR Operator which is less strict then the AND Operator, as its condition succeeds when at least one of multiple conditions are met. Lets use a similar example as before where we want to close Relay Output 3, but this time if EITHER Relay Outputs 1 and 2 are closed. We’ll do the same thing we did for the AND Operator by creating an empty task and adding an If Statement to it along with a Close Relay 3 action inside the If Statement. Here we’ll enter the following:

rout[1].state == 1 || rout[2].state ==1

This statement evaluates as “If either Relay Output 1 or Relay Output 2 are on, then close Relay Output 3”.

|| goes between the conditions where only one of them needs to be met

Lastly, a more advanced example can use both Operators in a logic statement at once. For example, lets say we want close Relay Output 3 if Relay Outputs 1 AND 2 are closer, OR if the time of day is past 2:00pm. We’ll add another if statement in an empty Task and add a Close Relay 4 action inside of it. Here we’ll enter the following:

(rout[1].state == 1 && rout[2].state == 1) || time.isAfter(“14:00”)

This statement evaluates as “If either Relay Output 1 and Relay Output 2 are on, or the current time is past 2:00pm, close Relay Output 3”.

() goes around the “rout[1].state == 1 && rout[2].state == 1” to group them together separately from the time function

The TaskerApplication has a lot of different functionality built into its actions, but it also can handle logic too. One of those actions that you can create in Tasker is the If block action. This post will create two If blocks in Tasker, one being the If block and the other being the If/else block.

Create an If Block

To start, create a new workspace by going to the File Drop-Down and selecting new. After that, go into the Task tab of Tasker and select the “Add Task” button. Once you name your Task, you’ll click on it and select the “Add Action” button. This will bring up the Action Dialog box. Here we need to select the If block action in the Control Structures section of the Action Dialog box. Once we have our If block in the task, we’ll want to add one more action inside of the If block by selecting the “Add Action” button inside of the If block. Here we’ll also select the Pulse Output Relay action.

Tasker If Example empty

Setting the If Block Actions

Now that our actions have been added to the Task, we can now configure them to do what we want. For this example, we are going to configure the if statement to activate when Input 1 goes high. To check if the input is high, for the If block value field we’ll enter din[1].state == 1.

With this, the If block will Pulse Output Relay 1 for 1 second if Input 1 is high.

Tasker If Example

Create an If/Else Block

In the workspace, go into the Task tab of Tasker and select the “Add Task” button. Once you name your Task, you’ll click on it and select the “Add Action” button. This will bring up the Action Dialog box. Here we need to select the If/else block action in the Control Structures section of the Action Dialog box. Once we have our If block in the task, we’ll want to add two more actions inside of the If/else block by selecting the “Add Action” button inside of the If/else block. Here we’ll select the Pulse Output Relay action inside the conditional part of the If/else block , and the Pulse Output Relay action inside for the “else” part of the If/else block.

Tasker If/Else Example empty

Setting the If/Else Block Actions

With the actions being added to the Task, we can now configure them to do what we want. For this example, we are going to configure the If block to Pulse Output Relay 1 when Input 1 goes high, and Pulse Output Relay 2 when Input 1 isn’t high. For the If/else block value field, to check if the input is high we’ll enter din[1].state == 1. For the first Pulse Output Relay, we’ll set the channel to 1, and for the other pulse relay we’ll set the channel to 2.

With this, the If/else block should Pulse Output Relay 1 for 1 second when Input 1 is high, and Pulse Output Relay 2 for 1 second when Input 1 is not high.

Tasker If/Else Example