One final tutorial, this one using the Logix Table and Sensors.
For this tutorial, we'll setup a switch on pin 6 to control the state of the signal setup in the previous tutorial. I'm using pin 6 as the inputs_and_outputs sketch maps this to input Hardware address 1 with the following line of code:
To use the switch we need a Sensor (JMRI's equivalent to an input).
(1) Open the Sensors Table. (Tools->Tables->Sensors)
(2) Click Add...
(3) Set the following:
Hardware Address: 1
User Name: Switch
(4) Click OK. You should see your new switch appear. Mine has a system name of CS1 (CMRI Sensor 1)
(5) Connect a push button between pin 6 and GND. If you don't have a button, you can just use a piece of wire.
(6) When the button is unpressed (or the wire removed), you should see the sensor state as 'Inactive'. When the button is pressed (wire connected to gnd), you should see the sensor state as 'Active'
The button is now set up. So lets make JMRI control the signal based on the button. This is done using the Logix table.
(7) Go to Tools->Tables->Logix
(8) Click Add...
(9) Check the "Automatically Generate System Name" box
(10) Set the Logix user name to something like "Signal Control"
(11) Click "Create Logix" (if you see an error message about duplicate names, ignore it, its a bug)
(12) In the logix table, you should see your new Logix element. There is a button at the end of it which says "Select". Click on that, then click "Edit"
(13) Click the New Conditional button
(14) Enter a user name like "Button Pressed"
(15) Click "Add State Variable"
(16) Set the variable type to "Sensor"
Enter the sensor name, in my case CS1
Set the state to Active
and then click Update.
(17) Click "Add Action"
(18) Set the "Action Group" to "Signal Head"
Enter your signal head name from the previous tutorial. Mine was called CH1 (You can find this from the Signal Heads table)
Set the "Action Type" to "Set Signal Head Appearence"
Set the "Signal Head Appearance" to Green
Set the "Change Option" to "On change to true"
(19) Click Update. You should see your action appear
(20) Repeat steps 18 and 19, only this time select:
Set the "Signal Head Appearance" to Red
Set the "Change Option" to "On change to false"
(21) Click 'Update Conditional'. This saves your new Logix conditional.
(22) Click the 'Done' button to finish editing the Logix.
Your new Logix is set up. What you should see happening is that when you press the button connected to D6, the signal goes Green. When you release the button, the signal goes Red.
While you probably wont be using buttons, you may still find this tutorial useful. It is possible to set up Sensors which are virtual (i.e. have no Hardware Address). These sensors can be placed on virtual control panels.
Lets change that sensor to be virtual.
(23) Got to the Sensors table and click "Add..."
(24) Set the System to 'Internal'
Set the Hardware Address to 1
Set the User Name to "Virtual Button" (or anything of your choosing)
(25) Click OK.
(26) You should see a new sensor called IS1 (Internal Sensor Hardware Address 1)
(27) Go to the Logix Table
(28) Click the Select button next to your Logix and click Edit (The same as in step 11)
(29) Next to your conditional, click "Edit"
(30) Now you should see the conditional you set up previously. Click the Edit button next to the state variable (Sensor "CS1" state is Sensor Active)
(31) Change the sensor name to "IS1"
(32) Click Update, the Update Conditional, the Done.
(33) Your logix has been changed. If you go to the Sensor table again, you should see next to your internal sensor a button telling you its state.
(34) If you press that button you should now see your signal change from Red to Green depending on the state of this sensor.