Facility Control

 View Only
  • 1.  OGP Commands

    Posted 20 days ago

    Hi

    I'm writing a device panel, and the development guide suggests I should be able to expose commands in the device, not just parameters.

    It isn't clear how I do this.

    How do I expose a function on a device panel to a client panel?

    eg. matrixRoute(src, dst);

    And dynamically create parameters using params.createParam do not seem to be exportable on the device - is that right?

    Thanks.



    ------------------------------
    Simon Liddicott
    Systems Engineer
    ------------------------------



  • 2.  RE: OGP Commands

    Posted 20 days ago

    Hi Simon,

    You'll want to expose this as an OGP command on the device, rather than as a function in the CustomPanel.

    In the device resource declaration, add a command such as matrixRoute with src and dst as arguments, typically using a STRUCT value. Once the device is added as a data source in DashBoard, the CustomPanel can execute that command through Visual Logic or ogScript.

    So:

    matrixRoute(src, dst)

    would be modelled as a device command like:

    command: matrixRoute
    arguments: src, dst

    There is also an example for this covered under the Device Resource Declarations → commands / command section of the CustomPanel Development Guide.



    ------------------------------
    Kiran Adhikari
    ------------------------------



  • 3.  RE: OGP Commands

    Posted 19 days ago

    Hi Kiran

    Thanks for responding.

    That's what I'm trying to do, but the examples don't give enough context.

    Are you able to share an example where this has been implemented?

    Thank you.



    ------------------------------
    Simon Liddicott
    Systems Engineer
    ------------------------------



  • 4.  RE: OGP Commands

    Posted 17 days ago

    I've managed to get the command advertised:

    }

            "commands": {
                "_d_testCommand": {
                    "oid": "testCommand",
                    "name": "testCommand",
                    "type": "STRING",
                    "readonly": false,
                    "widget": "default",
                    "maxlength": 0,
                    "totallength": 0,
                    "value": "",
                    "response": false
                },
        }

    But it never calls the function.
    I've tried adding as ogscript with the command oid and ogscript id matching, adding it as an API function and also adding a remote trigger:


    function testCommand(event)
    {

    ogscript.debug("hello");

    }
    ogscript.addRemoteTrigger(testCommand);

    I can see in wireshark the execute command request is sent:

    {"payload":{"oid":"testCommand"},"slot":0,"type":"cmd-exe"}


    How am I supposed to define the function so that it is executed this way?

    Thanks.



    ------------------------------
    Simon Liddicott
    Systems Engineer
    ------------------------------



  • 5.  RE: OGP Commands

    Posted 17 days ago

    Hi Simon,

    Yes, once you have the command set up on the device, it can be invoked from the custom panel using:

    params.executeCommand(CMD_NAME, ARGS, CALLBACK);

    For example, if I had a add_device command, it can be called from the panel like this:

    params.executeCommand("cmds.add_device", {"connection_settings": cs}, null);

    In your case, it could be:

    params.executeCommand("cmds.matrixRoute", {"src": src, "dst": dst}, null);

    In the custom panel, if I assign this task to a button click, it could look something like this:

    <button buttontype="push" height="66" left="224" name="matrix" top="53" width="146">
        <task tasktype="ogscript">
            params.executeCommand("cmds.matrixRoute", {"src": 1, "dst": 2}, null);
        </task>
    </button>


    ------------------------------
    Kiran Adhikari
    ------------------------------



  • 6.  RE: OGP Commands

    Posted 17 days ago

    Hi Kiran

    Thanks.

    The command is showing on the device, and the custom panel is calling the command, but...

    the api function is not being run.

    How does the command entry in the device resource config map to an actual function?

    Thank you.



    ------------------------------
    Simon Liddicott
    Systems Engineer
    ------------------------------