Facility Control

 View Only
  • 1.  Changing Parameter Constraints

    Posted 11-18-2016 21:14
    I need to be able to change a parameter's constraints based on a selection made in the panel. For example, I need a parameter to have the following options based on a toggle selection.

    0 = DAK Constraints need to be 0, 7 and 10
    1 = DASH Constraints need to be 0, 1 and 2

    0 can technically be influenced by a secondary data selection too, but I'll start small.

    Thanks!


  • 2.  RE: Changing Parameter Constraints

    Posted 11-18-2016 21:24

    This is a simple panel that replaces a parameter's constraint.It contains all of the basic pieces you would need to do what you're talking about.

    Check it out and let me know if you have any additional questions.

    Cheers!

    James

    <abs contexttype="opengear" style="">
    <meta>
    <params>
    <param access="1" constrainttype="INT_CHOICE" name="Test Toggling" oid="params.testtoggle" precision="0" type="INT16_ARRAY" value="0;0;0;0" widget="13">
    <constraint key="0">1080i</constraint>
    <constraint key="1">1080i</constraint>
    <constraint key="0">720p</constraint>
    <constraint key="1">720p</constraint>
    <constraint key="0">NTSC</constraint>
    <constraint key="1">NTSC</constraint>
    <constraint key="0">Bork</constraint>
    <constraint key="1">Bork</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Constriant Toggle" oid="Constriant_Toggle" precision="0" type="INT32" value="0" widget="radio-toggle">
    <constraint key="0">Constraint 1</constraint>
    <constraint key="1">Constraint 2</constraint>
    </param>
    </params>
    </meta>
    <simplegrid height="160" left="16" top="14" width="593">
    <param expand="true" oid="params.testtoggle" showlabel="false" style="style:toggleButton;"/>
    </simplegrid>
    <param expand="true" height="90" left="20" oid="Constriant_Toggle" style="style:toggleButton;" top="199" width="583">
    <task tasktype="ogscript">// creating an array to hold the constraint values
    var cArray = new Array();
    //obtaining the value of the ConstraintToggle parameter to decide which constraint list should be pushed into the arrray
    if (this.getValue() == 0)
    {
    // Placing the values into the array if the ConstraintToggle parameter is equal to 0
    // each value has two keys assigned to it because when the array is converted into a choice constraint option the key's determine which option has been selected by spewing out the value 1
    cArray.push({key:0,value:'1080i'});
    cArray.push({key:1,value:'1080i'});
    cArray.push({key:0,value:'1080p'});
    cArray.push({key:1,value:'1080p'});
    cArray.push({key:0,value:'720p'});
    cArray.push({key:1,value:'720p'});
    cArray.push({key:0,value:'480i'});
    cArray.push({key:1,value:'480i'});
    }
    else
    {
    // Placing the values into the array if the ConstraintToggle parameter is equal to 1
    // each value has two keys assigned to it because when the array is converted into a choice constraint option the key's determine which option has been selected by spewing out the value 1
    cArray.push({key:0,value:'One Fish'});
    cArray.push({key:1,value:'One Fish'});
    cArray.push({key:0,value:'Two Fish'});
    cArray.push({key:1,value:'Two Fish'});
    cArray.push({key:0,value:'Red Fish'});
    cArray.push({key:1,value:'Red Fish'});
    cArray.push({key:0,value:'Blue Fish'});
    cArray.push({key:1,value:'Blue Fish'});
    }

    // using the params.createIntChoiceConstraint function to convert the values in the array a choice constraint option
    var choiceConstraint = params.createIntChoiceConstraint(cArray);
    // the params.replaceConstraint function replaces the current choice constraint on the ConstraintParameter with the choiceConstraint variable.
    params.replaceConstraint('params.testtoggle', choiceConstraint);
    </task>
    </param>
    </abs>


    #DashBoard


  • 3.  RE: Changing Parameter Constraints

    Posted 11-19-2016 20:40
    I copied your code above and was able to get it to run. I tired to duplicate by hand what you did and failed miserably. At any rate, I don't know what I'm supposed to be linking to on the XPression side. I need it to send out a singular value - in my case it's 0,1 or 2 (option1) or 0,7 or 10 (option2). In my case the labels can be the same, but the data they associate with is different.
    #DashBoard


  • 4.  RE: Changing Parameter Constraints

    Posted 11-21-2016 18:30

    Admittedly, the previous example doesn't solve quite what you're trying to do (it shows how to create a button array with different labels for each element). What you're talking about would be changing the choices for a single parameter.

    I've adapted the example to do just that. Let's see if this gets us a little closer:

    <abs contexttype="opengear" style="">
       <meta>
          <params>
             <param access="1" constrainttype="INT_CHOICE" name="Test  Toggling" oid="params.testtoggle" precision="0" type="INT16" value="10" widget="radio-toggle">
                <constraint key="0">Choice 0</constraint>
                <constraint key="1">Choice 1</constraint>
                <constraint key="2">Choice 2</constraint>
             </param>
             <param access="1" constrainttype="INT_CHOICE" name="Constriant Toggle" oid="Constriant_Toggle" precision="0" type="INT32" value="0" widget="radio-toggle">
                <constraint key="0">Constraint 1</constraint>
                <constraint key="1">Constraint 2</constraint>
             </param>
          </params>
       </meta>
       <simplegrid height="160" left="16" top="14" width="593">
          <param expand="true" oid="params.testtoggle" showlabel="false" style="style:toggleButton;"/>
       </simplegrid>
       <param expand="true" height="90" left="20" oid="Constriant_Toggle" style="style:toggleButton;" top="199" width="583">
          <task tasktype="ogscript">// creating an array to hold the constraint values 
    var cArray = new Array();
    //obtaining the value of the ConstraintToggle parameter to decide which constraint list should be pushed into the arrray
    if (this.getValue() == 0)
    {
       // Placing the values into the array if the ConstraintToggle parameter is equal to 0
       // each value has two keys assigned to it because when the array is converted into a choice constraint option the key's determine which option has been selected by spewing out the value 1
       cArray.push({key:0,value:'Choice 0'});
       cArray.push({key:1,value:'Choice 1'});
       cArray.push({key:2,value:'Choice 2'});
    }
    else
    {
        // Placing the values into the array if the ConstraintToggle parameter is equal to 1
        // each value has two keys assigned to it because when the array is converted into a choice constraint option the key's determine which option has been selected by spewing out the value 1
       cArray.push({key:0,value:'Other 0'});
       cArray.push({key:71,value:'Other 7'});
       cArray.push({key:10,value:'Other 10'});
    }
    
    // using the params.createIntChoiceConstraint function to convert the values in the array a choice constraint option
    var choiceConstraint = params.createIntChoiceConstraint(cArray);
    // the params.replaceConstraint function replaces the current choice constraint on the ConstraintParameter with the choiceConstraint variable.
    params.replaceConstraint('params.testtoggle', choiceConstraint);</task>
       </param>
    </abs>

    #DashBoard


  • 5.  RE: Changing Parameter Constraints

    Posted 11-22-2016 17:08
    I managed to get it to work after all. I think I was thrown off by the data being ordered by the OID and not the name I gave the parameter.
    Thanks for the help!
    #DashBoard