Facility Control

 View Only
  • 1.  Pick list from JSON array

    Posted 08-16-2016 13:36
    Hello,

    I'm looking for a way to put a JSON array in a parameter that would be presented as a file pick list. I'm getting the file list from a http post to a webservice. The list at the moment looks like this:

    ["Clip", "Clip_1", "Clip_2", "Clip_3", "Clip_4", "Clip_5", "Clip_6", "Clip_7", "Clip_8"] but could evolve to include other information like clip length e.g. {"clips": [{"name" : "Clip", "length' : "00:00:30:00"},{"name" : "Clip_2", "length' : "00:00:30:00"},{"name" : "Clip", "length' : "00:00:30:00"}]} I tried to use the asyncPost "Include Response" parameter(which indicates the webservice is sending a JSON response) to create a parameter, but with no luck. I could not find much information about this in the documentation either. Thanks, Sebastien


  • 2.  RE: Pick list from JSON array

    Posted 08-17-2016 14:18

    I would recommend using a new string constraint type added in DashBoard 8.1 that allows for string key/value pairs. Your JSON data could go as the parameter key and your display name could go as the value.

    Here is a demo that shows the necessary ogScript commands:

    <meta>
    <params>
    <param access="1" constraintstrict="true" constrainttype="STRING_STRING_CHOICE" maxlength="0" name="String/String Choice" oid="params.mychoice" stateless="true" type="STRING" value="" widget="default">
    <constraint key="empty">No Choices</constraint>
    </param>
    </params>
    </meta>
    <param expand="true" height="58" left="18" oid="params.mychoice" showlabel="false" top="16" width="347">
    <task tasktype="ogscript">ogscript.debug('MY VALUE IS: ' + this.getValue());</task>
    </param>
    <button buttontype="push" height="60" left="374" name="Create Choices" top="17" width="136">
    <task tasktype="ogscript">var choices = [];
    choices.push({"value":"Choice Name", "key":"I CAN PUT JSON DATA HERE"});
    choices.push({"value":"Choice Name 2", "key":"I CAN PUT MORE JSON DATA HERE"});
    choices.push({"value":"Choice Name 3", "key":"I CAN PUT EVEN MORE JSON DATA HERE"});

    var newConstraint = params.createStringStringChoiceConstraint(choices);
    params.replaceConstraint('params.mychoice', newConstraint);</task>
    </button>


    #DashBoard


  • 3.  RE: Pick list from JSON array

    Posted 08-22-2016 12:39
    OK, will try this.

    However, I was more curious about the "createParam" og script function, which the manual states "Creates a parameter based on a JSON

    parameter definition", however, there is no information about how those JSON parameter definition should be formatted.

    Also, I'm not sure how I should handle a variable number of choices given the solution provided. My JSON data contains a list of files available on a playout server, which has a dynamic number of object. It looks to me that this solution would work for a known number of objects only.

    Thanks
    #DashBoard


  • 4.  RE: Pick list from JSON array

    Posted 08-22-2016 17:09
    Never mind the "dynamic number of object" part, I see I can do this in the "choices.push" part.

    #DashBoard


  • 5.  RE: Pick list from JSON array

    Posted 08-23-2016 13:48

    You are correct: the JSON definition of parameters is currently defined in the openGear Developer's Guide and was not included in the ogScript/OGLML CustomPanel documentation.

    If you save this as my-data.ogjson, you should be able to point a CustomPanel at the file and use its tools to create additional JSON parameters in the file to see their definition:

    {
        "payload": {
            "slot": 0,
            "menu-groups": {
                "status": {
                    "name": "status",
                    "menus": {
                        "0": {
                            "name": "Product",
                            "id": 0,
                            "unique": -1,
                            "disabled": false,
                            "hidden": false,
                            "oids": [
                                "0x105",
                                "0xFF01"
                            ]
                        }
                    },
                    "menuid": 0
                },
                "config": {
                    "name": "config",
                    "menus": {
                        "256": {
                            "name": "Basic Setup",
                            "id": 256,
                            "unique": 300,
                            "disabled": false,
                            "hidden": false,
                            "oids": [
                                "0xFF01",
                            ]
                        },
                    },
                    "menuid": 1
                }
            },
            "params": {
                "_d_0x105": {
                    "oid": "0x105",
                    "name": "Product",
                    "readonly": true,
                    "type": "STRING",
                    "widget": "default",
                    "maxlength": 0,
                    "totallength": 0,
                    "value": "PERMANENT_DEVICE_NAME_HERE"
                },
                "_d_0xFF01": {
                    "oid": "0xFF01",
                    "name": "Display Name",
                    "readonly": false,
                    "type": "STRING",
                    "widget": "text",
                    "maxlength": 100,
                    "totallength": 100,
                    "value": "VISIBLE_DEVIE_NAME_HERE"
                },
                "_d_params.param1": {
                    "oid": "params.param1",
                    "name": "My first parameter",
                    "readonly": false,
                    "type": "STRING",
                    "widget": "default",
                    "maxlength": 0,
                    "totallength": 0,
                    "value": "My value!"
                }
            }
        },
        "type": "device",
        "slot": 0
    }



    #DashBoard


  • 6.  RE: Pick list from JSON array

    Posted 08-24-2016 13:11
    Thanks, I got it to work with using your first example.

    #DashBoard