Facility Control

 View Only
Expand all | Collapse all

Global Constraints / External Constraints

  • 1.  Global Constraints / External Constraints

    Posted 01-15-2021 21:31

    Hey all,

    I commonly make use of the same list of constraints copy/pasted to multiple parameters, and I've been trying to solve a smarter and cleaner way to do this.

    I've seen things mentioned on the forums before like Global Constraints and External Constraints, which sounds like the right direction, but am having trouble finding any resources on how to actually accomplish it. 

    Both sound super useful for different situations that I could actively use; sharing a list of constraints to multiple parameters in a single panel, as well as creating a list of constraints for multiple panels to look at.

    Any help or direction would be appreciated! Thanks!



  • 2.  RE: Global Constraints / External Constraints

    Posted 01-29-2021 13:44

    Hello, 

    I believe that you can create txt file with all data that you want to make global, and then just reference to that file with 'Script file location' in the API component. You can link multiple panels to single txt API file wich will contain all your global variables.

    Hopes that help,

     

    Alex. 


    #DashBoard


  • 3.  RE: Global Constraints / External Constraints

    Posted 01-29-2021 14:26

    Hi Mike

    Are you looking to reuse the same constraint multiple times in the same panel or to use it across multiple panels?


    #DashBoard


  • 4.  RE: Global Constraints / External Constraints

    Posted 01-29-2021 16:31

    Hey <x-zendesk-user data-user-name="James Peltzer">372651266391</x-zendesk-user>

    I certainly have use cases for both, but being able to use the same constraints multiple times in the same panel would probably clean up my panel code the most.

    And using the same constraints across multiple panels would be a nice bonus!

    <x-zendesk-user data-user-name="alex samih-zade">378647052751</x-zendesk-user>

    I think I've gotten that far in the past, but never been able to make it work, probably due to formatting or syntax. I'm pretty novice to coding and have never actually done anything yet that reaches outside of the panel besides through Datalinq or Rosstalk to XPression.

     

    I've seen James' Ross-U video on External Constraints, but it was more of an introduction of the feature rather than a tutorial on how it works


    #DashBoard


  • 5.  RE: Global Constraints / External Constraints

    Posted 02-05-2021 00:28

    Hey <x-zendesk-user data-user-name="James Peltzer">372651266391</x-zendesk-user>, just a gentle reminder poke.

    Still hoping for some direction on these topics.


    #DashBoard


  • 6.  RE: Global Constraints / External Constraints

    Posted 02-05-2021 20:20

    Hi Mike
    Sorry about the delay - we do have approaches that I had hoped would work but they are not enabled on the self-contained data source panels.

    You can still use the <constraint/> tag to create a new identified constraint but, to use them here, you would need to use a piece of script to update them:

    <abs contexttype="opengear" id="_top" keepalive="false" style="">
    <meta>
    <params>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 1" oid="Choice_1" precision="0" type="INT32" value="0" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 2" oid="Choice_2" precision="0" type="INT32" value="0" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 3" oid="Choice_3" precision="0" type="INT32" value="0" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 4" oid="Choice_4" precision="0" type="INT32" value="1" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 5" oid="Choice_5" precision="0" type="INT32" value="0" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    </params>
    <constraint constrainttype="INT_CHOICE" id="my-constraint" precision="0">
    <constraint key="0">zero</constraint>
    <constraint key="1">one</constraint>
    <constraint key="2">two</constraint>
    </constraint>
    <api immediate="true">params.replaceConstraint('Choice_1', 'my-constraint');
    params.replaceConstraint('Choice_2', 'my-constraint');
    params.replaceConstraint('Choice_3', 'my-constraint');
    params.replaceConstraint('Choice_4', 'my-constraint');
    params.replaceConstraint('Choice_5', 'my-constraint');</api>
    </meta>
    <simplegrid cols="1" height="409" left="70" top="73" vspace="2" width="489">
    <param expand="true" oid="Choice_1" showlabel="false"/>
    <param expand="true" oid="Choice_2" showlabel="false"/>
    <param expand="true" oid="Choice_3" showlabel="false"/>
    <param expand="true" oid="Choice_4" showlabel="false"/>
    <param expand="true" oid="Choice_5" showlabel="false"/>
    </simplegrid>
    </abs>

     

    If you wanted to take a step further and read your value list from a file, you could do this (reads from a file called choices.txt in the same folder as the panel with one choice on each line):

    <abs contexttype="opengear" id="_top" keepalive="false" style="">
    <meta>
    <params>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 1" oid="Choice_1" precision="0" type="INT32" value="0" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 2" oid="Choice_2" precision="0" type="INT32" value="0" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 3" oid="Choice_3" precision="0" type="INT32" value="0" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 4" oid="Choice_4" precision="0" type="INT32" value="1" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    <param access="1" constrainttype="INT_CHOICE" name="Choice 5" oid="Choice_5" precision="0" type="INT32" value="0" widget="combo">
    <constraint key="0">a</constraint>
    </param>
    </params>
    <api immediate="true">var content = ogscript.post('choices.txt', null);
    if (content != null)
    {
    var values = content.trim().split('\n');
    var constraint = params.createIntChoiceConstraint(values);
    params.replaceConstraint('Choice_1', constraint);
    params.replaceConstraint('Choice_2', constraint);
    params.replaceConstraint('Choice_3', constraint);
    params.replaceConstraint('Choice_4', constraint);
    params.replaceConstraint('Choice_5', constraint);
    }

    </api>
    </meta>
    <simplegrid cols="1" height="409" left="70" top="73" vspace="2" width="489">
    <param expand="true" oid="Choice_1" showlabel="false"/>
    <param expand="true" oid="Choice_2" showlabel="false"/>
    <param expand="true" oid="Choice_3" showlabel="false"/>
    <param expand="true" oid="Choice_4" showlabel="false"/>
    <param expand="true" oid="Choice_5" showlabel="false"/>
    </simplegrid>
    </abs>

    #DashBoard


  • 7.  RE: Global Constraints / External Constraints

    Posted 02-05-2021 20:43

    Awesome! The second one is definitely what I'm after.

    I've got your test panel working with a choices.txt I made.
    So, following that logic; I should be able to replace 'choices.txt' with a filepath and have multiple panels use the same file, right? And will that also work over the network?

    Also, I can see the API is doing the brunt of the work and it's onLoad. Can I also trigger the API say when you click on one of the dropdowns? That, rather than copying/customizing the code into a task on each dropdown.

    Thanks for the help <x-zendesk-user data-user-name="James Peltzer">372651266391</x-zendesk-user>!


    #DashBoard


  • 8.  RE: Global Constraints / External Constraints

    Posted 02-05-2021 20:47

    Hi MIke

    You can put the code from the API into a function and call the function wherever you want - eg. here you can trigger updateConstraints() whenever you want:

    <api immediate="true">

    function updateConstraints()
    {var content = ogscript.post('choices.txt', null);
    if (content != null)
    {
    var values = content.trim().split('\n');
    var constraint = params.createIntChoiceConstraint(values);
    params.replaceConstraint('Choice_1', constraint);
    params.replaceConstraint('Choice_2', constraint);
    params.replaceConstraint('Choice_3', constraint);
    params.replaceConstraint('Choice_4', constraint);
    params.replaceConstraint('Choice_5', constraint);
    }

    }

    updateConstraints();

    </api>

     

    If you wanted to move choices.txt to a different location, you would just update the path in ogscript.post.  I will caution you that, if you are loading over a network, you should do ogscript.asyncPost and actually handle the update in the callback to avoid blocking your panel from running if the network is slow/down.


    #DashBoard


  • 9.  RE: Global Constraints / External Constraints

    Posted 02-05-2021 21:07

    Perfect!

    And if I understand this part correctly; if I put that code/function in a script file, and link the API to that file, it'll work just the same as well, right?

     

    You start to lose me as soon as you bring up .post and async.Post, it still feels a bit above me at the moment. The reasoning makes sense though!
    I will say, the panels themselves are already located on Network storage, and due to our productions, we have much bigger problems if our network is having issues.

    Thanks so much, James!


    #DashBoard


  • 10.  RE: Global Constraints / External Constraints

    Posted 10-26-2022 11:42
    ​Hey @James Peltzer (wow it's hard to find you in a huge list of James'es)
    New development on this today that maybe you or somebody else could offer a quick fix on.

    So, we've been successfully updating constraints using external .txt files for quite a long time now.
    My main use case is to have a toggle button that shows/hides a menu, and that button will execute the function that updates dropdowns in the shown menu. This has been working awesomely for almost 2 years judging by the dates of these old posts.

    But, finally today I was alerted to an issue. The Dashboard panel was, not locking up, but sort of lagging or stalling out for many seconds at a time whenever one of these toggles was pressed, which was really hindering normal production. We limped through until off air where I can dig in and get a look at things, and I tracked the issue back to this function and turns out the cause was that the .txt file being tagged must have been deleted by an operator.
    I re-built the file, refreshed the panel and all is good again.

    So, happy ending, but I'm wondering if there's a way to prevent this behavior if it were to happen again in the future!
    I would think the if (content != null) would do it, but since not I'm guessing the stalling is actually coming from the content = ogscript.post('filepath', null);

    What would be the right path to handle this?

    ------------------------------
    Mike DeMarco
    Video Production Engineer
    Las Vegas United States
    ------------------------------



  • 11.  RE: Global Constraints / External Constraints

    Posted 03-25-2021 18:23

    Hey <x-zendesk-user data-user-name="James Peltzer">372651266391</x-zendesk-user>! Sorry to resurrect, but I have a new question concerning a similar topic.

    With your help, I've succeeded at writing constraints to parameters with an API from an External File.
    I've also succeeded at figuring out how to create a <constraint> in my meta and have a parameter use that constraint using ID Reference.

    Now, I'm trying to combine the two; writing to a <constraint> from an external file and then reference it from multiple parameters.
    I'm guessing all the ways I've tried aren't working because the <constraint> is not a parameter, but maybe I'm missing something.
    I've been weighing the benefits of one over the other for our workflow, but if I can solve having both, that would be the best! Appreciate any help. Thanks!


    #DashBoard


  • 12.  RE: Global Constraints / External Constraints

    Posted 03-25-2021 20:35

    Hi Mike

    Are you able to post an example of what you're currently doing? If you already have identified constraints working, you should be able to use params.replaceIdentifiedConstraint(id, constraintObject).


    #DashBoard


  • 13.  RE: Global Constraints / External Constraints

    Posted 03-25-2021 21:03

    Sure thing! I'll try and include everything relevant.

    Here's the constraint (edited down, it's much longer than this)

    <constraint constrainttype="STRING_CHOICE" id="trackList" precision="0">
    <constraint>ALBANY</constraint>
    <constraint>ALBURY</constraint>
    <constraint>ARARAT</constraint>
    <constraint>ARMIDALE</constraint>
    <constraint>ASCOT</constraint>
    <constraint>ATHERTON</constraint>
    </constraint>

    And here's parameters that use that constraint:

    <param access="1" maxlength="0" name="TrackNameA" oid="TrackNameA" type="STRING" value="ALBANY" widget="combo"/>
    <param access="1" maxlength="0" name="TrackNameB" oid="TrackNameB" type="STRING" value="BAIRNSDALE" widget="combo"/>
    <param access="1" maxlength="0" name="TrackNameC" oid="TrackNameC" type="STRING" value="CANBERRA" widget="combo"/>
    <param access="1" maxlength="0" name="TrackNameD" oid="TrackNameD" type="STRING" value="DEAGON" widget="combo"/>
    <param access="1" maxlength="0" name="TrackA_UpNext" oid="TrackA_UpNext" type="STRING" value="ALBANY" widget="combo"/>
    <param access="1" maxlength="0" name="TrackB_UpNext" oid="TrackB_UpNext" type="STRING" value="BAIRNSDALE" widget="combo"/>
    <param access="1" maxlength="0" name="TrackC_UpNext" oid="TrackC_UpNext" type="STRING" value="CANBERRA" widget="combo"/>
    <param access="1" maxlength="0" name="TrackD_UpNext" oid="TrackD_UpNext" type="STRING" value="DEAGON" widget="combo"/>

    And the params on the panel:

    <table bottom="60" left="20" right="20" top="25">
    <tr>
    <label colspan="2" fill="both" header="true" height="20" left="40" name="Tracks" pheight="20" pwidth="243" rowspan="1" style="txt-align:center;" top="40"/>
    </tr>
    <tr>
    <label anchor="north" colspan="1" fill="both" left="20" name="&lt;html&gt;&lt;left&gt;A&lt;br&gt;&lt;br&gt;B&lt;br&gt;&lt;br&gt;C&lt;br&gt;&lt;br&gt;D" pheight="166" pwidth="40" rowspan="4" style="txt-align:center;" top="40" width="40"/>
    <param colspan="1" constraint="trackList" constrainttype="ID_REFERENCE" expand="true" fill="both" left="60" name="" oid="TrackNameA" pheight="41" precision="0" pwidth="203" rowspan="1" top="40" type="STRING_PARAM" weightx="1.0" weighty="1.0"/>
    </tr>
    <tr>
    <param colspan="1" constraint="trackList" constrainttype="ID_REFERENCE" expand="true" fill="both" left="60" name="" oid="TrackNameB" pheight="41" precision="0" pwidth="203" rowspan="1" top="80" type="STRING_PARAM" weightx="1.0" weighty="1.0"/>
    </tr>
    <tr>
    <param colspan="1" constraint="trackList" constrainttype="ID_REFERENCE" expand="true" fill="both" left="60" name="" oid="TrackNameC" pheight="42" precision="0" pwidth="203" rowspan="1" top="120" type="STRING_PARAM" weightx="1.0" weighty="1.0"/>
    </tr>
    <tr>
    <param colspan="1" constraint="trackList" constrainttype="ID_REFERENCE" expand="true" fill="both" left="60" name="" oid="TrackNameD" pheight="42" precision="0" pwidth="203" rowspan="1" top="160" type="STRING_PARAM" weightx="1.0" weighty="1.0"/>
    </tr>

     

    The original function I was using here works perfect (without the template constraint):

    function AUS_Tracks() {
        var path = "//APOLLO/Operations/Master Control/Config Files/Custom Panels/z_Scripts/Tracks/";
        var content = ogscript.post(path + 'Tracks (AUS).txt', null)
        if (content != null) {
            var values = content.trim().split('\n');
            values = values.sort()
            var constraint = params.createStringChoiceConstraint(values);

            params.replaceConstraint('TrackNameA', constraint);
            params.replaceConstraint('TrackNameB', constraint);
            params.replaceConstraint('TrackNameC', constraint);
            params.replaceConstraint('TrackNameD', constraint);

            params.replaceConstraint('TrackA_UpNext', constraint);
            params.replaceConstraint('TrackB_UpNext', constraint);
            params.replaceConstraint('TrackC_UpNext', constraint);
            params.replaceConstraint('TrackD_UpNext', constraint);
        }
    }

    I have tried a few of the different replaceConstraint functions, like this one, but honestly don't understand the difference:

    function AUS_Tracks() {
        var path = "//APOLLO/Operations/Master Control/Config Files/Custom Panels/z_Scripts/Tracks/";
        var content = ogscript.post(path + 'Tracks (AUS).txt', null)
        var trackList = params.getIdentifiedConstraint('trackList');
        if (content != null) {
            var values = content.trim().split('\n');
            values = values.sort()
            var constraint = params.createStringChoiceConstraint(values);
            params.replaceIdentifiedConstraint(trackList, constraint);
            //params.replaceConstraint('trackList', constraint);
        }
    }

    I am able to make some progress with this, but it seems little unreliable.
    I get a new Constraint Value in the dropdown: "com.rossvideo.gear.param.ConstraintStringChoice@3c2" and while the correct options will appear in the parameter choices, they disappear on refresh unless I open each parameter and apply changes, definitely not good for operators.
    Likewise; the <constraint> that I'm trying to point them to in my meta does not receive the constraint list.

    Hope all that makes sense! Thanks <x-zendesk-user data-user-name="James Peltzer">372651266391</x-zendesk-user>

     

     

     


    #DashBoard