Facility Control

 View Only
  • 1.  Color based on parameter

    Posted 10-07-2019 14:45

    So I know you can populate a parameter based on another parameter using replaceConstraint, but what about pushing a parameter to a preset color value? or just pushing to a color in general?

     

    I have a hex value, but it will change depending on what team is playing, and wanted to have all associated buttons change color along with it, but not sure if there is a way to script a parameter into a color?



  • 2.  RE: Color based on parameter

    Posted 10-09-2019 09:24

    Sure you can! At least on regular buttons. Not sure how this would work on a toggle button, as they have two "states" and two appereances. But this will work on a regular button at least:

    <abs contexttype="opengear" dblinqport="2222" gridsize="20" id="_top">
    <meta>
    <params>
    <param access="1" maxlength="0" name="color" oid="color" type="STRING" value="#1C08C9" widget="default"/>
    </params>
    </meta>

    <param expand="true" height="80" left="20" oid="color" top="20" widget="color-picker-popup" width="180"/>
    <button buttontype="push" height="100" left="20" name="Set color" top="120" width="180">
    <task tasktype="ogscript">var col = params.getValue('color', 0);
    var x = col.length;
    if (x == 9) {
    col = '#' + col.substring(3);
    }

    ogscript.setStyle('btn1', 'bg'+col);
    ogscript.setStyle('btn2', 'bg'+col);
    ogscript.setStyle('btn3', 'bg'+col);</task>
    </button>
    <button buttontype="push" height="80" id="btn1" left="280" top="20" width="160"/>
    <button buttontype="push" height="80" id="btn2" left="280" top="120" width="160"/>
    <button buttontype="push" height="80" id="btn3" left="280" top="220" width="160"/>
    </abs>

    The reason I have that "if" in there to look for the lenght of the string is because if you touch the transparency value of the color picker, DashBoard will put that in as a hex value before the RGB.
    If you dont touch it, the value will be #RRGGBB, however if you do touch it and it is anything other than 0, the value will be #AARRGGBB, so the "if" is simply to remove the alpha/transparency. 


    #DashBoard


  • 3.  RE: Color based on parameter

    Posted 10-09-2019 13:42

    There is another option as well. You can define your own color constant and use it throughout your UI. The color constant can use parameter substitution to take its value from a parameter.  Combine those 2 properties and you get this:

    <abs contexttype="opengear" keepalive="true">
    <meta>
    <params>
    <param access="1" maxlength="0" name="Team Color" oid="Team_Color" type="STRING" value="#67FF98" widget="color-picker-popup"/>
    <param access="1" constrainttype="INT_CHOICE" name="Buttons" oid="Buttons" precision="0" type="INT32" value="0" widget="radio-toggle">
    <constraint key="0">One</constraint>
    <constraint key="1">Two</constraint>
    <constraint key="2">Three</constraint>
    </param>
    </params>
    <color id="teamcolor" value="%value['Team_Color'][0]%"/>
    </meta>
    <param expand="true" height="67" left="21" oid="Team_Color" top="18" width="389"/>
    <label height="107" left="21" name="My Team!" style="txt-align:center;font:bold;size:Biggest;fg#teamcolor;" top="98" width="1370"/>
    <param expand="true" height="106" left="21" oid="Buttons" style="t:bg#teamcolor;f:bg#dark;" top="218" width="566"/>
    <button buttontype="push" height="77" left="418" name="Refresh" top="14" width="127">
    <task tasktype="ogscript">ogscript.reload(null);</task>
    </button>
    </abs>

     

     


    #DashBoard