Facility Control

 View Only
  • 1.  Toggle Buttons with Xpression

    Posted 09-14-2018 22:24
    We'd like to use a Dashboard toggle button to animate a graphic on then animate off when the button is pressed again. The graphic has a looping element so the main scene director is set to loop. When we are finished, we'd like the button to toggle to an "off" position and that would run the Animate Off Scene Director that is set with a transition on the scene. How do we build the toggle button in Dashboard? Do we need to set up parameters and/or what should we select as the button Task(s)?



  • 2.  RE: Toggle Buttons with Xpression

    Posted 09-15-2018 17:47

    You need a "parameter" button. In wich you can track if it's turned "on" or "off".
    Then a simple if/else command on the button that reads the new value when clicked, and sends the correct command to Xpression based on the buttons on/off state.

    Here's a minimal DashBoard example with a toggle button:

    <abs contexttype="opengear" gridsize="20" id="_top">
       <meta>
          <params>
             <param access="1" constrainttype="INT_CHOICE" name="Button" oid="Button" precision="0" type="INT32" value="0" widget="toggle">
                <constraint key="0">On</constraint>
                <constraint key="1">Off</constraint>
             </param>
             <param access="1" maxlength="0" name="placeholder" oid="placeholder" type="STRING" value="" widget="text"/>
          </params>
       </meta>
       <param expand="true" height="100" left="200" oid="Button" style="style:toggleButton;" top="260" width="200">
          <task tasktype="ogscript">var btn = params.getValue('Button', 0); //Get the new state of the button
    
    if (btn == 1) {
       params.setValue('placeholder', 0, 'Run first Xpression code.');
       // PLACE YOUR XPRESSION CODE HERE FOR WHEN CLICKED ON
    } else {
       params.setValue('placeholder', 0, 'Run second Xpression code.');
       // PLACE YOUR XPRESSION CODE HERE FOR WHEN CLICKED OFF
    }</task>
       </param>
       <param expand="true" height="60" left="440" oid="placeholder" top="280" width="260"/>
    </abs>

    #DashBoard


  • 3.  RE: Toggle Buttons with Xpression

    Posted 11-23-2018 08:16

    iam new in dashboard. i dont know what am i missing once i copy past your Code on tak og script MR. astalsberg it work for the first time but as i tried to make another buttom its not working . here is the code

     

    <abs contexttype="opengear" gridsize="20" id="_top">
    <meta>
    <params>
    <param access="1" constrainttype="INT_CHOICE" name="Button" oid="Button" precision="0" type="INT32" value="0" widget="toggle">
    <constraint key="0">On</constraint>
    <constraint key="1">Off</constraint>
    </param>
    <param access="1" maxlength="0" name="placeholder" oid="placeholder" type="STRING" value="" widget="text"/>
    </params>
    </meta>
    <param expand="true" height="100" left="200" oid="Button" style="style:toggleButton;" top="260" width="200">
    <task tasktype="ogscript">var btn = params.getValue('Button', 0); //Get the new state of the button

    if (btn == 1) {
    params.setValue('placeholder', 0, 'Run first Xpression code.');
    rosstalk.sendMessage('localhost', 7788, 'SEQI 0006');
    } else {
    params.setValue('placeholder', 0, 'Run second Xpression code.');
    rosstalk.sendMessage('localhost', 7788, 'SEQO 0006');
    }</task>
    </param>
    <param expand="true" height="60" left="440" oid="placeholder" top="280" width="260"/>
    </abs>

    #DashBoard


  • 4.  RE: Toggle Buttons with Xpression

    Posted 11-26-2018 10:25

    Here's another example, this time with 3 buttons. Each one with their own parameter.
    The buttons should also trigger Xpression sequences 6, 7 and 8 on your setup.

    Good luck!

     

    <abs contexttype="opengear" gridsize="20" id="_top">
       <meta>
          <params>
             <param access="1" constrainttype="INT_CHOICE" name="Button" oid="Button" precision="0" type="INT32" value="0" widget="toggle">
                <constraint key="0">Take On</constraint>
                <constraint key="1">Take Off</constraint>
             </param>
             <param access="1" maxlength="0" name="placeholder" oid="placeholder" type="STRING" value="XPR Sequence 1 out." widget="text"/>
             <param access="1" constrainttype="INT_CHOICE" name="Button3" oid="Button3" precision="0" type="INT32" value="0" widget="toggle">
                <constraint key="0">Take On</constraint>
                <constraint key="1">Take Off</constraint>
             </param>
             <param access="1" constrainttype="INT_CHOICE" name="Button2" oid="Button2" precision="0" type="INT32" value="0" widget="toggle">
                <constraint key="0">Take On</constraint>
                <constraint key="1">Take Off</constraint>
             </param>
             <param access="1" maxlength="0" name="placeholder2" oid="placeholder2" type="STRING" value="XPR Sequence 2 out." widget="text"/>
             <param access="1" maxlength="0" name="placeholder3" oid="placeholder3" type="STRING" value="XPR Sequence 3 out." widget="text"/>
          </params>
       </meta>
       <param expand="true" height="100" left="200" oid="Button" style="bg#3A3A3A;t:bg#D70000;" top="260" width="200">
          <task tasktype="ogscript">var btn = params.getValue('Button', 0); //Get the new state of the button
    
    if (btn == 1) {
    params.setValue('placeholder', 0, 'XPR Sequence 1 in.');
    rosstalk.sendMessage('localhost', 7788, 'SEQI 0006');
    } else {
    params.setValue('placeholder', 0, 'XPR Sequence 1 out.');
    rosstalk.sendMessage('localhost', 7788, 'SEQO 0006');
    }</task>
       </param>
       <param expand="true" height="60" left="440" oid="placeholder" top="280" width="260"/>
       <param expand="true" height="100" left="200" oid="Button3" style="bg#3A3A3A;t:bg#D70000;" top="500" width="200">
          <task tasktype="ogscript">var btn = params.getValue('Button3', 0);
    
    if (btn == 1) {
    params.setValue('placeholder3', 0, 'XPR Sequence 3 in.');
    rosstalk.sendMessage('localhost', 7788, 'SEQI 0008');
    } else {
    params.setValue('placeholder3', 0, 'XPR Sequence 3 out.');
    rosstalk.sendMessage('localhost', 7788, 'SEQO 0008');
    }</task>
       </param>
       <param expand="true" height="100" left="200" oid="Button2" showlabel="false" style="bg#3A3A3A;t:bg#D70000;" top="380" width="200">
          <task tasktype="ogscript">var btn = params.getValue('Button2', 0);
    
    if (btn == 1) {
    params.setValue('placeholder2', 0, 'XPR Sequence 2 in.');
    rosstalk.sendMessage('localhost', 7788, 'SEQI 0007');
    } else {
    params.setValue('placeholder2', 0, 'XPR Sequence 2 out.');
    rosstalk.sendMessage('localhost', 7788, 'SEQO 0007');
    }</task>
       </param>
       <param expand="true" height="60" left="440" oid="placeholder2" top="400" width="260"/>
       <param expand="true" height="60" left="440" oid="placeholder3" top="520" width="260"/>
    </abs>

    #DashBoard


  • 5.  RE: Toggle Buttons with Xpression

    Posted 11-28-2018 19:47
    You also have access to all the take item information by using the XPression Dashboard plugin that was added in 8.4. It installs with DB, so you probably already have it.

    With that you can make much more interactive panels. I'm assuming your XP Studio is running, and it has a project that is open with take items in the Sequencer View.

    Here is how:

    1. Add your XP to the tree (see XPstep1 image), by using the Green Plus in the Basic Tree View. Enter the IP of the XP and give it a name (I called mine SpareXP).
    2. In your panel, go to PanelBuilder mode, create a Basic Canvas, double click on it, and point its "openGear or XPression Datalinq" source to the XP. (see XPstep2 image).
    3. Then in that canvas, you have access to all the parameters that are fed to us by the XP. You can drop one of those parameters right in the abs if you want.

    1. For example, if you want the state of take item 10200, you can use the Param button (See XPstep3 image)
    2. Drag a box in the canvas, and it will popup a list of the parameters.
    2. Type "take" plus the takeid you care about, and it will filter the parameters for that take item.
    3. You can then click on the state one, and click on "OK". You will probalby get an empty box, unless that take item is on air, since the state is empty (off air).

    4. If you want to make a button that takes that item on air, you can create a button, and use visual logic to take the item on air (See XPstep4 image).
    1. In the canvas, create a button.
    2. Give it a name (if you want)
    3. Click on Add to give it a task.
    4. The XP should already be in your devices and parameters tree, open it up, and open up the "Commands" subtree.
    5. Find the "Take" command and drag it into your script.
    6. Enter the takeid for the item you want to take to air, and click on "OK", and get out of PanelBuilder mode.

    When you click on the button, you should see the state go to "online" (assuming it goes online in XP).

    5. You can react to that state changing and change your UI if you want to (i.e. change the color of a button, or a label, or something). For example, if you want the button to go from red to green when the state changes, you can do something like the following
    1. Give your button an ID (see XPstep5). I gave mine an id of "takebutton".
    2. Double click on the param that shows the state that we added in the last step 3 above.
    3. Click on the Add to add a task. That task will trigger any time the parameter changes value. (see XPstep6 image for the next few steps).
    4. In the Devices & Parameters tree, type in "take" + the takeid that you care about.
    5. Find the "state" subparameter for that take item, and drag it on.
    6. In the control and APIs type "if" into the search bar. Drag an if block on and connect it to your parameter, like in the picture. Also set the condition to "equals" and the input2 to "online".
    7. Do the same thing again, searching for a "set style" block. Drag 2 of them on, set both of their ids as "takebutton", connect them like in the picture to the true and false of the "if" block, and set the style strings to set the bg, like in the picture (one to red, one to green).
    8. Click on OK.

    Once you have done that, when the state changes, your button should go from red to green.

    This is just a small sample of what you could do. You could monitor for the state to be "paused" and change the button to be yellow. You can change the behaviour of the button based on the state (if it's offline, bring it online, otherwise, take it offline). Etc, etc. The sky's the limit.

    Hopefully this was useful.



    #DashBoard


  • 6.  RE: Toggle Buttons with Xpression

    Posted 11-28-2018 19:48
    I could only post 5 photos in the last post, here is the 6th.

    #DashBoard


  • 7.  RE: Toggle Buttons with Xpression

    Posted 11-28-2018 19:52
    Also, I just remembered, that you need to have the right license in XPression for this to work. If you add your XP and double click on the sequencer panel in the XP tree, you will see if the license is not valid. If it's not valid, there will be a popup saying your license is not valid. If you don't have that popup, you're probably good to go.
    #DashBoard