How do I view, display and control keyers on Acuity?

Using Dashboard, how do I:

a) query the state of certain keyers (on or off)

b) display this state on a button (this is probably easy once the state is known), and

c) set the state to a specific ‘ON’ or ‘OFF’ regardless of current state (equivalent to Acuity’s Cut/Trans Key ON or OFF custom control ‘Insert Special’ command)? Again, probably easy if it’s based on first determining current state.

I already have a valid connection to Acuity and can run custom controls from DB.

a) KEYSTATE ME:KEY
b) The KEYSTATE message will respond with “Key is OFF” or "Key is “ON” - use this with ogScript to call params.setValue of your key state parameter with the correct value
c) You’ll want to keep track of the current state of the key and, when your button is pressed, call KEYCUT or KEYAUTO if the current state is not the state you want.

Below, you’ll see an example of a panel that tracks the key state in a timer (checking every second) and updates a toggle button to show the current state. Changing the toggle button results in the key being transitioned off/on.

Note: You’ll want to make sure Cmd Response is set to “OFF” in your RTalk-IN on the Acuity for this particular panel to work properly.

for (var i = 0; i < params.getElementCount(‘Key’); i++)
{
updateKeyState(params.getValue(‘ME_Number’, 0), (i + 1));
}


/*

  • This function is passed to our rosstalk sender

  • It will parse-out the “Key is …” response to the KEYSTATE query and update the parameter
    */
    function updateParameters(success, cmd, result)
    {
    if (result != null)
    {
    result = result.toLowerCase(); //Set it to lowercase so we don’t have to worry about On vs ON vs on
    }

    if (result != null && result.indexOf(‘key is ‘) >= 0)
    {
    var onAir = result.indexOf(‘on’) > 0;
    var cmdSplit = cmd.split(’:’); //Find out which KEY/ME this response is for
    if (cmdSplit.length == 2)
    {
    var me = parseInt(cmdSplit[0].substr(-1));
    var key = parseInt(cmdSplit[1].substr(0, 1));

      var newValue = 0;
      if (onAir)
      {
         newValue = 1;
      }
    
      ogscript.putObject(me + ":" + key, newValue);      //Update our internal values before we set the parameter to avoid setting the keystate again
      params.setValue('Key', (key - 1), newValue);
    

    }
    }
    }

function updateKeyState(meNumber, keyToCheck)
{
var deviceIP = params.getValue(‘Host_Name’, 0);
var devicePort = parseInt(params.getValue(‘Port_Number’, 0));

var command = 'KEYSTATE ’ + meNumber + ‘:’ + keyToCheck + ‘\r\n’;
rosstalk.sendMessageWithResponse(deviceIP, devicePort, command, ‘\n’, updateParameters);
}


ME 1
ME 2
ME 3
ME 4


Key 1
Key 1
Key 2
Key 2
Key 3
Key 3
Key 4
Key 4




var keyIndex = this.getIndex() + 1; //Our array starts with index 0 and goes to 3 - we need to change this to 1 - 4 var newState = this.getValue(); //Get the parameter's value var meNum = params.getValue('ME_Number', 0); //Get the current ME value

var stateKey = meNum + ‘:’ + keyIndex; //keep track of the previous value so we know whether or not to send something to the switcher
var oldState = ogscript.getObject(stateKey); //Get the ‘internal value’ of the key state
if (newState != oldState) //if the ‘internal value’ is equal to the parameter value, do nothing
{
ogscript.putObject(stateKey, newState); //Otherwise, update the internal value
rosstalk.sendMessage(params.getValue(‘Host_Name’, 0), parseInt(params.getValue(‘Port_Number’, 0)), 'KEYAUTO ’ + meNum + ‘:’ + keyIndex); //Trigger the RossTalk message
ogscript.asyncExec(function()
{
updateKeyState(meNum, keyIndex);
}, 500);
}

[#DashBoard](https://livinglive.community/search?s=tags%3A%22DashBoard%22&executesearch=true)

Brilliant, James - I just had to check the ‘ogScript’ box after copying this in (I’m new to Dashboard) and it worked perfectly. So much appreciated!!

Edit: actually, it had nothing to do with the checkbox, it just took a minute before the communication was working.Oddly enough, it doesn’t work when I put the frame IP in; I have to use the panel IP. But it works; I’m happy.
#DashBoard