Facility Control

 View Only
  • 1.  Can't set parameter constraints

    Posted 02-20-2019 07:19

    I am trying to build a dashboard to control the display of a baseball GIP on a videoboard.

    I'd like to display the batting orders as a list of toggle buttons. Unfortunately I am having trouble setting the parameter constraints through scripting.

    I started with the example shared in this post, which seemed to work. https://discussions.rossvideo.com/fo...8156#post18156

    Building off of that, I tried to generate the list of constraints from a statcrew XML. Copious amounts of ogscript.debug proves that I have extracted the correct data from the XML, but I am unable to set the constraint correctly.




    I am expecting the constraint to look like the following:

    36 Bob Smith
    28 John Doe
    2 Alice Bob



    Instead, it winds up looking like this: 

    0 [object Object]
    1 [object Object]
    2 [object Object]



    My dashboard panel is below. Any idea what I'm screwing up?

    <abs contexttype="opengear" gridsize="20" style="">
       <meta>
          <params>
             <param access="1" constrainttype="INT_CHOICE" name="Home Players" oid="homePlayers" precision="0" type="INT16" value="0" widget="radio-toggle">
                <constraint key="0">[object Object]</constraint>
                <constraint key="1">[object Object]</constraint>
                <constraint key="2">[object Object]</constraint>
                <constraint key="3">[object Object]</constraint>
                <constraint key="4">[object Object]</constraint>
                <constraint key="5">[object Object]</constraint>
             </param>
             <param access="1" maxlength="0" name="Stat Crew Path" oid="stat_crew_path" type="STRING" value="file:/c:/Users/Bob/Desktop/base.xml" widget="default"/>
          </params>
       </meta>
       <button buttontype="push" height="60" left="340" name="Alice and friends" top="260" width="120">
          <task tasktype="ogscript">var choiceArray = [];
    
    var numbers = [1, 5, 10];
    var names = ["Alice", "Bob", "Susan"];
    
    for (var x = 0; x &lt; numbers.length; x++) {
       choiceArray.push({"key":numbers[x], "value":names[x]});
       ogscript.debug("Added " + numbers[x] + " " + names[x]);
    }
    
    var choiceConstraint = params.createIntChoiceConstraint(choiceArray);
    params.replaceConstraint("homePlayers", choiceConstraint);</task>
       </button>
       <table height="980" left="820" maxperrow="1" top="80" width="200">
          <tr>
             <param colspan="1" expand="true" fill="both" oid="homePlayers" rowspan="1" showlabel="false" weightx="1.0" weighty="1.0"/>
          </tr>
       </table>
       <button buttontype="push" height="120" left="200" name="Refresh Home" top="260" width="140">
          <task tasktype="ogscript">var numbers = [];
    var names = [];
    
    var rss = ogscript.parseXML(params.getValue('stat_crew_path', 0));
    if (rss != null) {
       var playerList = ogscript.runXPath("/bsgame/team[@vh='H']/player[not(@name='TEAM')]", rss);
       for (var x = 0; x &lt; playerList.length; x++) {
          numbers.push(playerList.item(x).getAttribute("uni"));
          names.push(playerList.item(x).getAttribute("name"));
       }
    }
    
    //var numbers = [1, 5, 10];
    //var names = ["Alice", "Bob", "Susan"];
    
    var choiceArray = [];
    for (var x = 0; x &lt; numbers.length &amp;&amp; x &lt; 3; x++) {
       choiceArray.push({key:numbers[x], value:names[x]});
       ogscript.debug("Added " + numbers[x] + " " + names[x]);
    }
    
    var choiceConstraint = params.createIntChoiceConstraint(choiceArray);
    params.replaceConstraint("homePlayers", choiceConstraint);</task>
       </button>
       <button buttontype="push" height="60" left="340" name="Lots of bobs" top="320" width="120">
          <task tasktype="ogscript">var choiceArray = [];
    
    for (var x = 0; x &lt; 80; x++) {
       choiceArray.push({"key":x, "value":"bob"});
    }
    
    var choiceConstraint = params.createIntChoiceConstraint(choiceArray);
    params.replaceConstraint("homePlayers", choiceConstraint);</task>
       </button>
    </abs>



  • 2.  RE: Can't set parameter constraints

    Posted 02-20-2019 18:56
    I figured out my issue. The data being read from statcrew had the jersey numbers as strings, instead of integers. Just needed to do a parseInt() when building the choice array.
    #DashBoard


  • 3.  RE: Can't set parameter constraints

    Posted 10-04-2019 22:10

    You just saved my life - thanks for that parseInt() nonsense!


    #DashBoard