Facility Control

 View Only
  • 1.  Widget development - Internal / Extrenal api and params

    Posted 08-18-2025 05:35

    Hi,

    I have written a couple of widgets that are working well but I wanted to add a status param that would be used to update the tree view status indicators.
    I have successfully done this with a simple grid file using the jsonport param, but I am getting stuck with the widget.

    The issue relates to where the param is defined. 

    • If it is in the <!--INTERNAL PARAMETERS --> section, my internal api can change its state, but it is not visible in the tree view or main grid file.
    • If it is in the <!-- ACTUAL CONTENT --> section, my internal api can't change its state, but it is visible in the tree view or main grid file.

    The names of the sections say it all! But is there a way of getting my internal api to change the state of a param in the main code.



    ------------------------------
    Richard Hills
    ------------------------------


  • 2.  RE: Widget development - Internal / Extrenal api and params

    Posted 08-18-2025 10:06

    Hi Richard

    You're right that any parameter defined within a widget will not impact your overall status.  Your best bet would be to add a config parameter to your widget to pass the OID of the parameter from "ACTUAL CONTENT" that you want it to modify for its status info - your widget can modify the values of parameters from the rest of your panel - they just typically need to know which OID to use.  

    <abs contexttype="opengear" id="_top" keepalive="false" style="">
       <meta>
          <params>
             <param access="1" constrainttype="ALARM_TABLE" name="My Alarm 1" oid="alarm1" precision="0" stateless="true" type="INT16" value="0" widget="default">
                <constraint key="0" severity="0">OK</constraint>
                <constraint key="1" severity="1">Warning!</constraint>
                <constraint key="2" severity="2">ERROR!</constraint>
             </param>
             <param access="1" constrainttype="ALARM_TABLE" name="My Alarm 2" oid="alarm2" precision="0" stateless="true" type="INT16" value="0" widget="default">
                <constraint key="0" severity="0">OK</constraint>
                <constraint key="1" severity="1">Warning!</constraint>
                <constraint key="2" severity="2">ERROR!</constraint>
             </param>
             <param access="1" constrainttype="ALARM_TABLE" name="My Alarm 3" oid="alarm3" precision="0" stateless="true" type="INT16" value="0" widget="default">
                <constraint key="0" severity="0">OK</constraint>
                <constraint key="1" severity="1">Warning!</constraint>
                <constraint key="2" severity="2">ERROR!</constraint>
             </param>
          </params>
          <widgets>
             <widgetdescriptor id="my-alarming-widget">
                <config>
                   <params>
                      <param access="1" maxlength="0" name="Alarm OID" oid="Alarm_OID" type="STRING" value="" widget="text"/>
                      <param access="1" constrainttype="INT_CHOICE" name="Alarm Value" oid="Alarm_Value" precision="0" type="INT16" value="0" widget="combo">
                         <constraint key="0">OFF</constraint>
                         <constraint key="1">OK</constraint>
                         <constraint key="2">WARN</constraint>
                         <constraint key="4">ERROR</constraint>
                      </param>
                   </params>
                </config>
                <oglml>
                   <abs>
                      <param bottom="0" expand="true" left="0" oid="Alarm_Value" right="0" runtasksonload="true" showlabel="false" top="0">
                         <task>var alarmOID = params.getValue('Alarm_OID', 0);
    if (alarmOID != "") {
       var alarmParam = params.getParam(alarmOID, 0);
       if (alarmParam != null) {
          alarmParam.setValue(this.getValue());
       }
    }
    </task>
                      </param>
                   </abs>
                </oglml>
             </widgetdescriptor>
          </widgets>
       </meta>
       <simplegrid height="111" hspace="5" left="23" rows="1" top="117" width="631">
          <param expand="true" oid="alarm1" showlabel="false"/>
          <param expand="true" oid="alarm2" showlabel="false"/>
          <param expand="true" oid="alarm3" showlabel="false"/>
       </simplegrid>
       <simplegrid height="44" hspace="5" left="23" rows="1" top="240" width="634">
          <widget widgetid="my-alarming-widget">
             <config>
                <params>
                   <param oid="Alarm_OID" value="alarm1"/>
                   <param oid="Alarm_Value" value="0"/>
                </params>
             </config>
          </widget>
          <widget widgetid="my-alarming-widget">
             <config>
                <params>
                   <param oid="Alarm_OID" value="alarm2"/>
                   <param oid="Alarm_Value" value="0"/>
                </params>
             </config>
          </widget>
          <widget widgetid="my-alarming-widget">
             <config>
                <params>
                   <param oid="Alarm_OID" value="alarm3"/>
                </params>
             </config>
          </widget>
       </simplegrid>
    </abs>
    



    ------------------------------
    James Peltzer
    Ross Video
    ------------------------------



  • 3.  RE: Widget development - Internal / Extrenal api and params

    Posted 08-21-2025 16:43

    Here is an alternate example where the widget itself fires-up a jsonport and publishes a virtual device with an alarm state. It doesn't provide a full UI for the remote device but it does share its parameters.

    <abs contexttype="opengear" id="_top" keepalive="false" style="">
       <meta>
          <params/>
          <widgets>
             <widgetdescriptor id="my-alarming-widget">
                <config>
                   <params>
                      <param access="1" maxlength="0" name="JSON Port" oid="JSON_PORT" type="INT16" value="0" widget="spinner"/>
                      <param access="1" name="Device Name Display" oid="Display_Name" precision="0" type="STRING" value="This Widget" widget="text"/>
                   </params>
                </config>
                <oglml>
                   <abs contexttype="opengear" jsonport="%value['JSON_PORT'][0]%">
                      <meta>
                         <params>
                            <param access="1" name="Device Name" oid="0x105" precision="0" type="STRING" value="Alarm Device" widget="default"/>
                            <param access="1" name="Device Name Display" oid="0xFF01" precision="0" type="STRING" value="This Widget" widget="text"/>
                            <param access="1" constrainttype="ALARM_TABLE" name="My Alarm" oid="alarm1" precision="0" stateless="true" type="INT16" value="0" widget="default">
                               <constraint key="0" severity="0">OK</constraint>
                               <constraint key="1" severity="1">Warning!</constraint>
                               <constraint key="2" severity="2">ERROR!</constraint>
                            </param>
                            <param access="1" constrainttype="INT_CHOICE" name="Alarm Value" oid="Alarm_Value" precision="0" type="INT16" value="0" widget="combo">
                               <constraint key="0">OFF</constraint>
                               <constraint key="1">OK</constraint>
                               <constraint key="2">WARN</constraint>
                               <constraint key="4">ERROR</constraint>
                            </param>
                         </params>
                         <ogscript handles="onload">params.setValue('0xFF01', 0, params.getValue('Display_Name', 0));</ogscript>
                      </meta>
                      <param expand="true" height="30" left="0" oid="0xFF01" right="0" runtasksonload="true" showlabel="false" top="0">
                         <task>var alarmParam = params.getParam('alarm1', 0);
       if (alarmParam != null) {
          alarmParam.setValue(this.getValue());
       }</task>
                      </param>
                      <param bottom="0" expand="true" left="0" oid="Alarm_Value" right="0" runtasksonload="true" showlabel="false" top="30">
                         <task>var alarmParam = params.getParam('alarm1', 0);
       if (alarmParam != null) {
          alarmParam.setValue(this.getValue());
       }</task>
                      </param>
                   </abs>
                </oglml>
             </widgetdescriptor>
          </widgets>
       </meta>
       <simplegrid height="184" hspace="5" left="44" rows="1" top="38" width="460">
          <widget widgetid="my-alarming-widget">
             <config>
                <params>
                   <param oid="JSON_PORT" value="5300"/>
                   <param oid="Alarm_Value" value="4"/>
                   <param oid="Display_Name" value="TEST"/>
                </params>
             </config>
          </widget>
       </simplegrid>
       <simplegrid height="184" hspace="5" left="522" rows="1" top="39" width="460">
          <widget widgetid="my-alarming-widget">
             <config>
                <params>
                   <param oid="JSON_PORT" value="5302"/>
                   <param oid="Alarm_Value" value="4"/>
                   <param oid="Display_Name" value="TEST 2"/>
                </params>
             </config>
          </widget>
       </simplegrid>
    </abs>
    


    ------------------------------
    James Peltzer
    Ross Video
    ------------------------------