Facility Control

 View Only
  • 1.  Dashboard U - Structs???

    Posted 06-16-2019 22:11

    So... I'm looking at Structs again...
    Simply because my main DashBoard has gotten so big that the parameter values are getting somewhat out of hand, and yes, structs would help me...

    However, after just reading up on structs in the help documentation, and from the documentation itself... Cant find it really (except a few posts on the forums), and there's nothing on DashBoard U about it... Sooooo... Possible to get a "Structs for Dummies" in the DashBoard U?

     

    -------------------------------------

     

    Edit: So, after sitting with this way too late into the early hours, I've gotten a bit further, but then again, I end up with alot of questions as well.

    I do have teh table working now, and with the correct data showing. I did also find the example DashBoards with adding a new row to the table, and also found the p.additive config part as well. All good...
    I got the w.selectedparameter (or what it was called again) to work, so I got an integer parameter showing what index is selected and getting that value etc...

    Now, here's a list of new questions then...

    1. On a select of say index 3 on a table containing 10 rows, and 3 collums. Say that when I select the row with index 3 (being the 4th row visually), I want to get the value from col3 (lets say the headers are simply col1, col2, col3), and use that value for other stuff. How do I access the data to further program with?

      Update: Ok! Figured this one out.

    2. I assume I can read and write data to a row not nessasarily chosen in the table by defining the index at wich to get/insert data?

      Update: Ok! Figured this one out. Answer is yes of course. Just making sure...

    3. How would I go about deleting a row in the table? Say if I want to delete row 6 (index 5) in a table of 10 rows.

      Update: For just parameter arrays, that could be done with a simple params.getParam(OiD, 5).remove(); But cant quite figure this one out for structs.

    4. When I did this with the parameter tables instead where parameters make up the table. Turning on the rearrange did not actually change the index value of that entry, but rather just rearranged it visually.
      What is the case with structs?

      Update: Turns out YES! Using the integer parameter to select index/rows after turning on the w.reorder and it actually reorderes the array and not just visually.

    5. In a table with 3 entries, I wish to add another row, but I want to add it between row 2 and 3. How would I go about this with a struct?

      Update: Still in the blanks on this one...

    I think that about sums up what I need of functionality now.
    Will probably be more later, but more on that when it comes to it!



  • 2.  RE: Dashboard U - Structs???

    Posted 06-19-2019 22:16

    3. params.getParam('OID_OF_STRUCT', ROW_INDEX).remove();

    4. Create a new array, use params.getAllValues('OID_OF_STRUCT') to get the old array, push values from the old array onto the new array, insert your new row where you want, add the remainder of the array, use params.setAllValues('OID_OF_STRUCT', newArray) to update the structure.

     

    //INSERT A NEW ELEMENT AT INDEX 2 WITH SUB OIDS OF "name", "identifier", and "position"

    var allValues = params.getAllValues('playerList');
    var newValues = [];
    for (var i = 0; i < allValues.length; i++)
    {
    if (i == 2)
    {
    newValues.push({"name": "inserted", "identifier": "My ID", "position": "new"});
    }
    newValues.push(allValues[i]);
    }

    params.setAllValues('playerList', newValues);

    #DashBoard


  • 3.  RE: Dashboard U - Structs???

    Posted 06-21-2019 10:12

    Thank you James!
    I was sure I had tried that way of deleting a row, but will give it another go.

    And I like the nifty place in between sollution you got there. Nice!

    Now... Last few things...

    1. Is it possible to add style to a row? Like a different color background?

    2. When you have a struct parameter in your DashBard, and enter the "parameters" menu for "Add/Edit Parameters" window... Is there a way to set this to NOT have all the structs open and showing what is inside.
      Would make it a whole lot easier to handle for sure.

    Thanks again for the usual amazing support.


    #DashBoard


  • 4.  RE: Dashboard U - Structs???

    Posted 10-14-2019 14:03

    Hi Aleksander, 

     

    In #1 of your top post, are you saying you got the value from a cell that you clicked in?

    If so, how did you accomplish this?

     

    Thanks,

    Taylor


    #DashBoard


  • 5.  RE: Dashboard U - Structs???

    Posted 10-14-2019 14:34

    Hi there Taylor!

    In the Config Options for a structs table, you add the "w.selectionparam" and the OID of an int parameter on your DashBoard.
    Now the table itself is not really giving you the output, but the selectionparam does.

    With this enabled, anytime you click a row in the structs table, the row selected (selectionparam) will change to reflect the index of the row selected (0-based). Now, in that parameter that shows what index/row you've selected, add a task, where it gets the value of self, and then use that to pull out the contents of that row.
    Or if you want a button to get the values, make sure to pull the current value of selectionparam to get the values from the selected row.

    Example board here:

    <abs contexttype="opengear" gridsize="20" style="">
    <meta>
    <params>
    <param access="1" constrainttype="STRUCT" name="Race Definition" oid="raceDefinition" structtype="raceInfo" type="STRUCT" widget="table">
    <value>
    <subparam access="1" maxlength="-1" name="Race Name" suboid="name" type="STRING" value="Test" widget="default"/>
    <subparam access="1" maxlength="-1" name="Id" suboid="identifier" type="STRING" value="Test" widget="default"/>
    </value>
    <config key="p.additive">true</config>
    </param>
    <param access="1" constrainttype="STRUCT" name="Race Definition" oid="raceList" structtype="raceInfo" templateoid="raceDefinition" type="STRUCT_ARRAY" widget="table">
    <value>
    <subparam suboid="name" value="Name 0"/>
    <subparam suboid="identifier" value="ID 0"/>
    </value>
    <value>
    <subparam suboid="name" value="Name 1"/>
    <subparam suboid="identifier" value="ID 1"/>
    </value>
    <value>
    <subparam suboid="name" value="Name 2"/>
    <subparam suboid="identifier" value="ID 2"/>
    </value>
    <value>
    <subparam suboid="name" value="Name 3"/>
    <subparam suboid="identifier" value="ID 3"/>
    </value>
    <value>
    <subparam suboid="name" value="Name 4"/>
    <subparam suboid="identifier" value="ID 4"/>
    </value>
    </param>
    <param access="1" constrainttype="INT_NULL" name="selected" oid="selected" precision="0" type="INT16" value="5" widget="default"/>
    <param access="1" constraint="0.0;100.0;0.0;100.0;1" constrainttype="INT_STEP_RANGE" name="insert" oid="insert" precision="0" type="INT32" value="5" widget="spinner"/>
    </params>
    </meta>
    <param element="0" expand="true" height="300" left="20" oid="raceList" showlabel="false" top="20" width="440">
    <config key="w.selectionparam">selected</config>
    <config key="w.reorder">true</config>
    </param>
    <button buttontype="push" height="60" left="20" name="Add" top="340" width="300">
    <task tasktype="ogscript">var structCount = params.getElementCount('raceList');

    if (structCount == 1 &amp;&amp; params.getValue('raceList.0.identifier', 0) == "") // If this is the first element and it has not been set yet
    {
    structCount = 0;
    }

    var newValue = {
    "name": "Name " + structCount,
    "identifier": "ID " + structCount
    };

    params.setValue('raceList', structCount, newValue);</task>
    </button>
    <button buttontype="push" height="60" left="320" name="Clear" top="340" width="140">
    <task tasktype="ogscript">var empty = [{"name":"", "identifier":""}];
    params.setAllValues('raceList', empty);</task>
    </button>
    <param expand="true" height="40" left="480" oid="selected" showlabel="false" top="60" width="160"/>
    <button buttontype="push" height="80" left="20" name="Get value" top="420" width="240">
    <task tasktype="ogscript">var x = params.getValue('selected', 0);
    var race = params.getValue('raceList.' + x + '.name', 0);
    var id = params.getValue('raceList.' + x + '.identifier', 0);

    ogscript.debug('------------');
    ogscript.debug('Race selected: ' + race);
    ogscript.debug('Race ID selected: ' + id);</task>
    </button>





    <button buttontype="push" height="80" left="260" name="Delete selected" top="420" width="200">
    <task tasktype="ogscript">var x = params.getValue('selected', 0);

    params.getParam('raceList', x).remove();</task>
    </button>
    <label height="40" left="480" name="selection param" style="txt-align:center;font:bold;" top="20" width="160"/>
    </abs>

    #DashBoard


  • 6.  RE: Dashboard U - Structs???

    Posted 10-14-2019 14:44

    Ahhh! Thank you. It was staring me right in the face. 

     

    I'm going to keep working with this but I think it should do exactly what I need. 

     

    Thanks for the quick reply!


    #DashBoard