Facility Control

 View Only
  • 1.  Param integer past to a on/off toggle

    Posted 01-30-2020 15:14

    What I am trying to do here, is get a range constraint number spinner from 0-9999 to pass a number for example 7596 a toggle ON/OFF button, while adding brackets to the number like so for 'ON' <7596> and </7596> for 'OFF'. Then if the number changes it will also change inside the <>.

    The spinner oid=ID# (ID) and the toggle oid=TTbillboard (0xA).

    I have tried a lot of variations I just have never been successful in the number getting to the toggle. I also would like to make this in visual basic to others to understand or be able to edit.

     



  • 2.  RE: Param integer past to a on/off toggle

    Posted 01-30-2020 22:43

    Hi Shawn,

    I have written some ogScript code which I hope will solve your problem.

    A short explanation of the code: it will create a spinner widget, a toggle button widget and a label. As the numbers are changed by the spinner, they will update values in the label. If the toggle button is 'ON', the number will display as [7596]. If the toggle button is 'OFF', the number will display as [/7596].

    I hope the code below solves your problem. Please feel free to reach out if need be.

     

    <abs contexttype="opengear" id="_top" keepalive="false" style="">
    <meta>
    <params>
    <param access="1" constraint="0.0;9999.0;0.0;9999.0;1" constrainttype="INT_STEP_RANGE" name="spinner" oid="0x2" precision="0" type="INT16" value="42" widget="spinner"/>
    <param access="1" constrainttype="INT_CHOICE" name="button" oid="0x3" precision="0" type="INT16" value="0" widget="radio-toggle">
    <constraint key="0">ON</constraint>
    <constraint key="1">OFF</constraint>
    </param>
    </params>
    </meta>
    <label height="59" id="status" left="19" name="" style="txt-align:center;bg#dark;bdr:etched;font:bold;" top="20" width="281"/>
    <param expand="true" height="58" left="21" oid="0x2" top="101" width="80">
    <task tasktype="ogscript">if (params.getValue('0x3', 0) == 1)
    {
    ogscript.rename("status", '['+params.getValue('0x2', 0)+']');
    } else {
    ogscript.rename("status", '[/'+params.getValue('0x2', 0)+']');
    }</task>
    </param>
    <param constrainttype="INT_CHOICE" expand="true" height="63" left="218" oid="0x3" precision="0" style="style:toggleButton;" top="97" widget="toggle" width="82">
    <constraint key="0">OFF</constraint>
    <constraint key="1">ON</constraint>
    <task tasktype="ogscript"/>
    <task tasktype="ogscript">if (params.getValue('0x3', 0) == 1)
    {
    ogscript.rename("status", '['+params.getValue('0x2', 0)+']');
    } else {
    ogscript.rename("status", '[/'+params.getValue('0x2', 0)+']');
    }</task>
    </param>
    </abs>

    #DashBoard


  • 3.  RE: Param integer past to a on/off toggle

    Posted 01-31-2020 00:28

    Thank you Daniyal, I had to get this done really quickly, so I called tech support and they helped me get it working with the following code!

     

    /*! block id=1061,1051,1072,1054 !*/
    switch (params.getValue('0xA', 0))
    {
    case "ON":
    rosstalk.sendMessage("IP address", 50119, "<" + params.getValue('ID', 0) +">" , null);
    break;
    case "OFF":
    rosstalk.sendMessage("IP address", 50119, "</" + params.getValue('ID', 0) +">", null);
    break;
    }

    ogscript.debug( "</" + params.getValue('ID', 0) +">");
    /*!!
    <block id="1061" type="switch" x="462" y="339" w="268" VALUE="ID:1051" STATEMENT="ID:1072" statementtag_STATEMENT="ON" STATEMENT_0="ID:1054" statementtag_STATEMENT_0="OFF" STATEMENT_1="" />
    <block id="1051" type="param__top&amp;TTbillboard (0xA)[0]" x="222" y="340" w="243" SET="" />
    <block id="1072" type="ogscript_sendtcpstring" x="1096" y="161" w="318" HOST="64.147.132.87" PORT="50119" STRING="&lt;ID#&gt;" CALLBACK="null" />
    <block id="1054" type="ogscript_sendtcpstring" x="1095" y="372" w="318" HOST="64.147.132.87" PORT="50119" STRING="&lt;/(ID)&gt;" CALLBACK="null" />
    !!*/
    /*!!<checksum>a34369aa896b8621d062475cfbbcf984</checksum>!!*/


    #DashBoard