Facility Control

 View Only
Expand all | Collapse all

Renaming Parameter Constraints from another Parameter

  • 1.  Renaming Parameter Constraints from another Parameter

    Posted 05-01-2018 22:22
    Trying to accomplish something similar to what was discussed in this old thread:

    https://discussions.rossvideo.com/forum/default-forum-gc1/dashboard-gc43/6697-button-label-by-parameter

    I've spent some time with Visual Logic between Dashboard and XPression, but I'm essentially entirely new to actual scripting.

    The goal is to have editable drop downs where you can select or type in event names for incoming feeds and have them filter out to different places.
    I've already got the names updating on Multiviewers and Audio Mixers, but I'd love to also be able to dynamically update the constraint names on a group of Toggle Buttons.

    Any insight is appreciated, thanks!


  • 2.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-03-2018 21:28

    It sounds like you're basically looking to do something like this:

    <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">
          <meta>
             <ogscript/>
          </meta>
          <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:1,value:'Other 1'});
       cArray.push({key:2,value:'Other 2'});
    }
    
    // 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>



    Note, you can also change the numbers associated with the choices if you want.


    #DashBoard


  • 3.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-04-2018 19:49
    Looks a bit over my head at first glance, but all the comments should get me through.
    I'll dig into it!

    Thanks James!
    #DashBoard


  • 4.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-04-2018 21:05
    If you run into trouble, don't hesitate to follow-up. For now, you can save the example code as its own custom panel to see it in action.

    James
    #DashBoard


  • 5.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-09-2018 18:55
    Hey James, so a little bit of follow up.

    For the most part, I'm following the code you gave me, Thank You.

    Compared to the Toggle system you sent, the system I initially created (and is already working on Mnemonics and Audio Mixer names) is more Set/Reset, so you make your up to 10 editable dropdown selections, and hit a button to send those selections to the naming parameters, while another Reset button sends default preset name values to the same parameters.

    I'm not saying it needs to fit what I've laid out, since I believe I can convert to the toggle approach and in the end may be functionally better for my operators; but how do I make my dropdowns fill the array like the ConstraintToggle currently is? It may be a simple syntax problem on my part, but I can't figure out how to put a user-generated value rather then a preset value in that 'else' section of the code.


    And one more question;
    How does the ' this.getValue() ' part of the code work?
    In the little bit of searching I could try I couldn't find any reference to "this", so I was just hoping to get some clarification on how that works.

    Sorry if these are simple questions..

    Thanks again for all your help.
    #DashBoard


  • 6.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-10-2018 13:45
    Hi Mike.
    In this case, I'm setting the parameter based on 2 hard-coded presets. In your case, when the button is pressed, you would read the values out of your editable drop-downs to create the new constraints (you would have no "if" statement).

    When used inside of a parameter task, "this" is the equivalent of calling params.getParam("OID_OF_THE_PARAMETER_THE_TASK_IS_ATTACHED_TO", INDEX_OF_THE_CHANGED_PARAMETER)
    #DashBoard


  • 7.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-14-2018 22:51
    @jamespeltzer Hi there, followup question on this.
    We did this a way back when I asked a similar question, and this was a nice, and dare I say even better example. And I'm incorporating it into my current project.
    However I have hit somewhat of a snag.

    The paramter updates with constraints as it should. However I am trying to count the constraints/options in the dropdown.
    params.getElementCount(OID); does not work, as it only ever returns 1 regardless of the amount of choices.
    And params.getAllValues also returns an array wit just 1 entry in it.
    #DashBoard


  • 8.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-15-2018 13:08
    @astalsberg Are you overriding the parameter's constraint or are you setting the new constraint in the parameter VIEW?
    It might be worth having you send a code snippet on this one to identify the problem.

    James

    #DashBoard


  • 9.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-15-2018 17:40

    I suppose this would be the easiest example really...
    Just a way to get the total number of options in the dropdown, after we replace the Constraints for that parameter...

    <abs contexttype="opengear" id="_top">
       <meta>
          <params>
             <param access="1" constrainttype="INT_CHOICE" name="test" oid="0x2" precision="0" type="INT16" value="0" widget="combo">
                <constraint key="0">---</constraint>
             </param>
             <param access="1" maxlength="0" name="result" oid="0x3" type="STRING" value="1.0" widget="default"/>
          </params>
       </meta>
       <meta>
          <api immediate="true">function test() {
       var cArray = new Array();
      
       //These values would come from either an XML or JSON import. But for this example, I just use your code above.
       cArray.push({key:0,value:'Choice 0'});
       cArray.push({key:1,value:'Choice 1'});
       cArray.push({key:2,value:'Choice 2'});
    
       var choiceConstraint = params.createIntChoiceConstraint(cArray);
       params.replaceConstraint(0x2, choiceConstraint);
    }</api>
          <ogscript handles="onload">test();</ogscript>
          
       </meta>
      
    
    <param expand="true" height="72" left="143" oid="0x2" showlabel="false" top="128" width="375"/>
       <button buttontype="push" height="63" left="565" name="Get total number of options" top="130" width="185">
          <task tasktype="ogscript">var x = params.getElementCount(0x2);
    params.setValue(0x3, 0, x);
    </task>
       </button>
    <param expand="true" height="64" left="777" oid="0x3" showlabel="false" top="131" width="91"/>
    </abs>

    #DashBoard


  • 10.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-15-2018 20:32
    @astalsberg In your example, you only have 1 element in your array at all times. You have a choice constraint with 3 choices but only one parameter "value" at a time.

    You can get the number of choices in your choice constraint with:
    var x = params.getConstraint(0x2).getChoices().length;
    params.setValue(0x3, 0, x);


    getChoices() returns an array of "NamedChoice" objects (not quite the same as the JSON objects you would have built to create it). They have getValue() and getName() methods to get their numeric value or string names.

    J
    #DashBoard


  • 11.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-16-2018 16:48
    Thanks once again!

    I've been digging through the ogscript referance guide, but that's a first time I've seen the "getChoices()" function.
    Is there an updated version of the reference guide anywhere? Or in the making?
    #DashBoard


  • 12.  RE: Renaming Parameter Constraints from another Parameter

    Posted 05-17-2018 18:41
    The most current documentation available is baked into the help manual inside of the software. It would be listed as "in the making" for updates right now.

    James
    #DashBoard