Facility Control

 View Only
  • 1.  HTTP Trigger Rename Button

    Posted 20 days ago

    I can rename a panel element in DashBoard, but the button on the HTTP Trigger Web Page does not rename.

    Is this expected behaviour?

    What I'm really trying to do is use a web api to revel parameters without having to wrote my own handler.

    Does that already exist?

    Thanks



    ------------------------------
    Simon
    ------------------------------


  • 2.  RE: HTTP Trigger Rename Button

    Posted 18 days ago

    The webserver for this port creates a script that will send triggers if accessed in a browser, to send the same triggers insert '/ajax/' into the url before the trigger ID.

    <!-- Panel with 4 buttons that trigger the GPI when clicked -->
    <?xml version="1.0" encoding="UTF-8"?><abs contexttype="opengear" httptriggerport="12345" id="_top" keepalive="false">
        <meta name="styles">
            <style id="color_1" value="bdr#red;bdr:thick;"/>
            <style id="color_2" value="bdr#green;bdr:thick;"/>
            <style id="color_3" value="bdr#teal;bdr:thick;"/>
            <style id="color_4" value="bdr#orange;bdr:thick;"/>
        </meta>
        <abs height="300" id="border" left="10" top="10" width="300">
            <table bottom="5" left="5" right="5" top="5">
                <tr>
                    <button buttontype="push" colspan="1" fill="both" gpi="color-1" name="Color 1" rowspan="1" style="bg#red;" weightx="1.0" weighty="1.0">
                        <task tasktype="ogscript">ogscript.setStyle('border', 'style:color_1');</task>
                    </button>
                    <button buttontype="push" colspan="1" fill="both" gpi="color-2" name="Color 2" rowspan="1" style="bg#green;" weightx="1.0" weighty="1.0">
                        <task tasktype="ogscript">ogscript.setStyle('border', 'style:color_2');</task>
                    </button>
                </tr>
                <tr>
                    <button buttontype="push" colspan="1" fill="both" gpi="color-3" name="Color 3" rowspan="1" style="bg#teal;" weightx="1.0" weighty="1.0">
                        <task tasktype="ogscript">ogscript.setStyle('border', 'style:color_3');</task>
                    </button>
                    <button buttontype="push" colspan="1" fill="both" gpi="color-4" name="Color 4" rowspan="1" style="bg#orange;" weightx="1.0" weighty="1.0">
                        <task tasktype="ogscript">ogscript.setStyle('border', 'style:color_4');</task>
                    </button>
                </tr>
            </table>
        </abs>
    </abs>
    
    <!-- Panel to send a message to the GPI -->
    <?xml version="1.0" encoding="UTF-8"?><abs contexttype="opengear" id="_top" keepalive="false">
        <meta>
            <params>
                <param access="1" maxlength="0" name="host" oid="host" type="STRING" value="localhost" widget="default"/>
                <param access="1" maxlength="0" name="port" oid="port" type="STRING" value="12345" widget="default"/>
                <param access="1" maxlength="0" name="message" oid="message" type="STRING" value="color-3" widget="default"/>
            </params>
        </meta>
        <abs height="230" left="10" style="bdr#buttonbg;bdr:thick;" top="10" width="485">
            <table bottom="5" left="5" right="5" top="5">
                <tr>
                    <simplegrid cols="2" colspan="1" fill="both" rowspan="1" weightx="1.0" weighty="1.0">
                        <label name="Host" style="txt-align:center"/>
                        <param expand="true" oid="host" showlabel="false"/>
                    </simplegrid>
                </tr>
                <tr>
                    <simplegrid cols="2" colspan="1" fill="both" rowspan="1" weightx="1.0" weighty="1.0">
                        <label name="Port" style="txt-align:center"/>
                        <param expand="true" oid="port" showlabel="false"/>
                    </simplegrid>
                </tr>
                <tr>
                    <simplegrid cols="2" colspan="1" fill="both" rowspan="1" weightx="1.0" weighty="1.0">
                        <label name="Message" style="txt-align:center"/>
                        <param expand="true" oid="message" showlabel="false"/>
                    </simplegrid>
                </tr>
                <tr>
                    <button buttontype="push" colspan="1" fill="both" name="Send" rowspan="1" weightx="1.0" weighty="1.0">
                        <task tasktype="ogscript">var host = params.getValue('host', 0);
    var port = params.getValue('port', 0);
    var message = params.getValue('message', 0);
    // Construct URL for triggering the GPI: /ajax/{gpi-name}
    var url = 'http://' + host + ':' + port + '/ajax/' + message;
    
    function callback(result) {
        if (result) {
            ogscript.debug("[HTTP_Trigger] Error: " + JSON.stringify(result, null, 2));
        } else {
            ogscript.debug("[HTTP_Trigger] Trigger sent successfully");
        }
    }
    // Use GET method to trigger the GPI (matches the dashboard button behavior)
    ogscript.asyncHTTP(url, "GET", null, null, callback, true);</task>
                    </button>
                </tr>
            </table>
        </abs>
    </abs>
    


    ------------------------------
    Richard Crutwell
    Ross Video UK
    ------------------------------