Crestron Components Lib - Showcase App

ch5-button common: receiveStateShow, receiveStateShowPulse, receiveStateHidePulse

Emulator Scenario (click to expand)
{
  "cues": [
    {
      "type": "boolean",
      "event": "hall_lights_tap",
      "trigger": true,
      "actions": [
        {
          "state": "hall_lights_selected",
          "type": "boolean",
          "logic": "toggle"
        }
      ]
    },
    {
      "type": "b",
      "event": "sig_trig_pulse1",
      "trigger": "&change",
      "actions": [
        {
          "state": "a_pulse1",
          "type": "boolean",
          "logic": "pulse"
        }
      ]
    },
    {
      "type": "b",
      "event": "sig_trig_pulse2",
      "trigger": "&change",
      "actions": [
        {
          "state": "a_pulse2",
          "type": "boolean",
          "logic": "pulse"
        }
      ]
    },
    {
      "type": "boolean",
      "event": "toggle_btn_visibility",
      "trigger": true,
      "actions": [
        {
          "state": "show_button",
          "type": "boolean",
          "logic": "toggle"
        }
      ]
    }
  ],
  "onStart": [
    {
      "type": "b",
      "state": "hall_lights_selected",
      "value": true
    },
    {
      "type": "b",
      "state": "show_button",
      "value": false
    }
  ]
}

Press the Load button to load the scenario.

Press the Run button to run the scenario. You only need to do this if the scenario (the json) has an onStart key.

The Emulator Scenario JSON contains an array of cues and an optional array onStart A cue is defined by: type:string, signal:string, trigger:boolean|string|number, actions:array. An action is defined by: type:string, signal:string, logic:string ... plus other fields ( depending on type)

type for cue or for action can be the string:

  • b or boolean - for a boolean signal
  • n or number or numeric - for a number signal
  • s or string - for a string signal
  • o or object - for an object signal

signal for cue or for action is a string representing the name of the signal:

trigger can be either a fixed value of the same type as the signal, or the string "&change". If it is a fixed value then, when the emulator detects that the signal has changed to the value given in trigger then it also executes the actions for that signal. If the value is the string "&change", regardless of signal type, then the actions are executed on any change in the value of the signal.

logic can be:

  • link - passes the value received on the incoming join through to the outgoing join. Using this between incompatible join types will attempt to cast the value. In the event of a cast failure the value will be set to false, 0 or "" (empty string)
  • set - assigns a specific value to the join. This requires a 5th key of 'value' and the specific value to assign. ie. {"signal":"light_level", "type":"n", "logic": "set","value":5}. If the 5th key is omitted, the default value will be sent (false, 0, "" or {})
  • toggle - (boolean Only) reads the current state and changes it to the opposite state
  • pulse - (boolean Only) value goes high and then low.
  • increment - (Numeric Only) reads the current value of the analog and adds an offset. This logic accepts an optional 5th key of 'offset which determines how many to incrementby. ie. {"signal":"volume_level","type":"n", "logic":"increment","offset":5}. If this 5th key is omitted, the default offset of 1 will be applied.
  • decrement - (Numeric Only) reads the current value of the analog and subtracts an offset. This logic accepts an optional 5th key of 'offset which determines how many to decrement by. ie. {"signal":"volume_level","type":"n", "logic":"decrement","offset":5}. If this 5th key is omitted, the default offset of 1 will be applied.

RCB logic can be accomplished by defining an action containing an object signal of RCB type:
{ "rcb":{ "value": numeric_value, "time": duration_in_ms } }
Scenario example:


    {
      "cues": [
        {
          "type": "boolean",
          "signal": "trigger",
          "trigger": true,
          "actions": [
            {
              "signal": "action1",
              "type": "boolean",
              "logic": "toggle"
            },
            {
                "signal": "rcb_signal",
                "type": "object",
                "logic": "set",
                "value": {
                    "rcb":{
                        "value": 101,
                        "time": 1500
                    }
                }
            }
          ]
        }
      ],
      "onStart": [
      ]
    }
    

ch5-button (ch5-common) noshowType, receiveStateShow

A click on the trigger button will result in a change for the signal hall_lights_tap which in turn will change the hall_lights_selected signal ( see definition of the emulator scenario in the json at the top of the page)

The noshowType attribute can have the following values: visibility, none, remove. This attribute controls the way the ch5 element will be hidden: 'visibility:hidden', 'display:none' and for 'remove' the ch5 element is detached from the DOM. In the case of 'remove', in order to be able to add the element again ( should the signal change in value), references are kept for the parent element.


next is remove
next is display
next is visibility
<ch5-button label="trigger change in signal" sendEventOnClick="hall_lights_tap"></ch5-button>
<hr>
<div style="border:1px solid red;">next is remove</div>
<ch5-button type="success" shape="rectangle" label="remove" noshowType="remove" receiveStateShow="hall_lights_selected"></ch5-button>
<div style="border:1px solid red;">next is display</div>
<ch5-button type="success" shape="rectangle" label="display" noshowType="display" receiveStateShow="hall_lights_selected"></ch5-button>
<div style="border:1px solid red;">next is visibility</div>
<ch5-button type="success" shape="rectangle" label="visibility" noshowType="visibility" receiveStateShow="hall_lights_selected"></ch5-button>
<div style="border:1px solid red;height:20px;width:20px;"></div>

ch5-button (ch5-common) noshowType, receiveStateShowPulse,receiveStateHidePulseShow

If the buttons are already visible then triggering a pulse for receiveStateShowPulse will have no effect.

If the buttons are not visible then triggering a pulse for receiveStateShowPulse will make them visible.

If the buttons are already visible then triggering a pulse for receiveStateHidePulse will hide them.

If the buttons are not visible then triggering a pulse for receiveStateHidePulse will have no effect.


next is remove
next is display
next is visibility
<ch5-button label="trigger pulse (to show)" sendEventOnClick="sig_pulse_show"></ch5-button>

<ch5-button label="trigger pulse (to hide)" sendEventOnClick="sig_pulse_hide"></ch5-button>

<hr/>
<div style="border:1px solid red;">next is remove</div>
<ch5-button type="success" shape="rectangle" label="remove"
             noshowType="remove"
             receiveStateShowPulse="sig_pulse_show"
             receiveStateHidePulse="sig_pulse_hide"></ch5-button>
<div style="border:1px solid red;">next is display</div>
<ch5-button type="success" shape="rectangle" label="none"
             noshowType="display"
             receiveStateShowPulse="sig_pulse_show"
             receiveStateHidePulse="sig_pulse_hide"></ch5-button>
<div style="border:1px solid red;">next is visibility</div>
<ch5-button type="success" shape="rectangle" label="visibility"
             noshowType="visibility"
             receiveStateShowPulse="sig_pulse_show"
             receiveStateHidePulse="sig_pulse_hide"></ch5-button>
<div style="border:1px solid red;height:20px;width:20px;"></div>

ch5-button (ch5-common) sendEventOnShow

When the button gets shown it will also send a true value on the signal defined in sendEventOnShow

<ch5-button label="toggle show" sendEventOnClick="toggle_btn_visibility"></ch5-button>
<hr>
<ch5-button debug type="success" shape="rectangle" label="Button that sends a signal when it becomes visible"
             noshowType="display" receiveStateShow="show_button" sendEventOnShow="button_shown"></ch5-button>