Facility Control

 View Only
  • 1.  Triggers for Numeric Choice Counter

    Posted 01-31-2018 22:32

    I'm making a Control Panel for a Stats Person for basketball coverage. I have 3 Parameters: Field Goal Attempts; Field Goals Made; and Field Goal Percentage. I have Field Goal Attempts and Field Goals Made assigned to two different Numeric Choice Counters, so the stats person can use the arrow up/down controls to keep track during game play easily. Now, the place I first ran into issues was that I also want to increase/decrease Field Goal Attempts when Field Goals Made has increased/decreased, because if a goal is made it was also attempted. I tried to make a Task using the Visual Logic Math Controller for Increment Parameter, but that incremented up even when pressing the down arrow or even when the number value was corrected manually. I feel like I might need the “trigger values” for those Up and Down arrow buttons, but I have no idea what those values/ogScripts are. One other thing I’m not sure about is how to go about executing the calculation for the Field Goal Percentage Parameter. I mean the math is pretty straight forward, BUT I’m not sure the most efficient way to execute these calculations. On the one hand I thought I could use a counter that does all of these calculations every 0.2 seconds, but there will be a list of 30ish players on this CP with the exact same layout of Attempts/Made/Percentage for numerous things like Free Throws, 3pointers, and Field Goals, so it seems like a lot of needless calculations when nothing changes for a few minutes. Another thought I had was I could use “triggers” again that are associated with any change to the editable parameters. Here I feel like I’m totally lost on how to go about that. If anyone can help in any way I’d appreciate that. Thanks.



  • 2.  RE: Triggers for Numeric Choice Counter

    Posted 02-01-2018 15:15

    Hi Roger.
    It might be helpful for you to post your panel so we can take a look at where things stand.

    You'll find a fairly useful thread on using the math functions of Visual Logic here: https://discussions.rossvideo.com/forum/default-forum-gc1/dashboard-gc43/12389-calculating-stats-percentage

    If your percentage is being calculated as the result of another parameter changing, I absolutely do not recommend using a timer. There are several ways to go about this but what you want to do is add a task to the parameter(s) whose change will impact the percentage. If multiple parameters cause the value to change, I would create an tag and create a function that does the actual math - you can then call that function from each parameter using visual logic.

    If you send your panel over, I'll can give you a quick example of how this can be done.

    As for changing whether you increment/decrement/do-nothing, you'll want to use the visual logic "Conditional" blocks to make sure you do different actions based on the value of you parameter.

    Here is an example panel you may find useful.

    <abs contexttype="opengear">
         <meta>
            <params>
               <param access="1" constraint="0.0;100.0;0.0;100.0;1" constrainttype="INT_STEP_RANGE" name="Value 1" oid="Value_1" precision="0" type="INT32" value="0" widget="spinner"/>
               <param access="1" constraint="0.0;100.0;0.0;100.0;1" constrainttype="INT_STEP_RANGE" name="Value 2" oid="Value_2" precision="0" type="INT32" value="100" widget="spinner"/>
               <param access="1" constraint="0.0;100.0;0.0;100.0;1" constrainttype="INT_STEP_RANGE" name="Percent" oid="Percent" precision="0" type="INT32" value="0" widget="spinner"/>
               <param access="1" constrainttype="INT_CHOICE" name="Values" oid="Values" precision="0" type="INT32" value="0" widget="default">
                  <constraint key="0">Do Nothing</constraint>
                  <constraint key="1">0%</constraint>
                  <constraint key="2">50%</constraint>
                  <constraint key="3">100%</constraint>
               </param>
            </params>
            <api>
      function updatePercent() {
       
       
       
       
      /*! block id=1000,1001,1007,1011,1005,1004,1006,1002,1008 !*/
      if ( params.getValue('Value_2', 0)  &gt;  0)
      {
      params.setValue('Percent', 0, ( ( params.getValue('Value_1', 0) /  params.getValue('Value_2', 0)) * 100));
      } else {
      params.setValue('Percent', 0, 0);
      }
      /*!!
        &lt;block id="1000" type="if" x="283" y="10" w="268" INPUT1="ID:1001" OPERATION="is bigger than" INPUT2="0" TRUE="ID:1007" FALSE="ID:1002" IGNORE="" /&gt;
      &lt;block id="1001" type="param_Value 2 (Value_2)[0]" x="10" y="10" w="243" SET="" /&gt;
      &lt;block id="1007" type="param_Percent (Percent)[0]" x="1821" y="60" w="243" SET="ID:1011" /&gt;
      &lt;block id="1011" type="math_multiply" x="1573" y="60" VALUE="ID:1005" VAL_1="100" w="218" VAL_1_1="" /&gt;
      &lt;block id="1005" type="math_divide" x="1325" y="60" VALUE="ID:1004" VAL_1="ID:1006" w="218" VAL_1_1="" /&gt;
      &lt;block id="1004" type="param_Value 1 (Value_1)[0]" x="1052" y="60" w="243" SET="" /&gt;
      &lt;block id="1006" type="param_Value 2 (Value_2)[0]" x="1052" y="122" w="243" SET="" /&gt;
      &lt;block id="1002" type="param_Percent (Percent)[0]" x="779" y="100" w="243" SET="ID:1008" /&gt;
      &lt;block id="1008" type="number" x="581" y="100" w="168" VALUE="0" /&gt;
      !!*/
      }
       
       
       
       
       
      /*!!&lt;checksum&gt;65d4cc99fa5007e3375bee379f3bb69c&lt;/checksum&gt;!!*/</api>
         </meta>
         <param expand="true" height="73" left="217" oid="Value_1" top="23" width="160">
            <task tasktype="ogscript">
       
       
      /*! block id=1009 !*/
      updatePercent()
      /*!!
       &lt;block id="1009" type="function_updatePercent" x="10" y="100" w="243" /&gt;
      !!*/
      /*!!&lt;checksum&gt;73ddb62a27445d0ace6794520d077fcb&lt;/checksum&gt;!!*/</task>
         </param>
         <param expand="true" height="68" left="214" oid="Value_2" top="121" width="166">
            <task tasktype="ogscript">
       
       
      /*! block id=1010 !*/
      updatePercent()
      /*!!
       &lt;block id="1010" type="function_updatePercent" x="10" y="100" w="243" /&gt;
      !!*/
      /*!!&lt;checksum&gt;2e1368e569a705385b634379cbd2a75d&lt;/checksum&gt;!!*/</task>
         </param>
         <param expand="true" height="54" left="419" oid="Percent" top="76" width="161"/>
         <label height="49" left="59" name="Value 1: " style="txt-align:east;" top="30" width="136"/>
         <label height="49" left="60" name="Value 2: " style="txt-align:east;" top="133" width="136"/>
         <label height="43" left="589" name="%" style="txt-align:west;" top="81" width="63"/>
         <param expand="true" height="49" left="100" oid="Values" top="217" width="345">
            <task tasktype="ogscript">
       
       
      /*! block id=1012,1013,1015,1016,1014,1017,1020,1021,1018,1019,1022,1024,1023,1025,1026,1027,1028,1029,1030,1032,1031,1033,1034,1035 !*/
      if (params.getValue('Values', 0)  ==  1)
      {
      params.setValue('Value_1', 0, 0);
      params.setValue('Value_2', 0, 100);
      params.setValue('Values', 0, 0);
      } else {
      if (params.getValue('Values', 0)  ==  2) { params.setValue('Value_1', 0, 50);
      params.setValue('Value_2', 0, 100);
      params.setValue('Values', 0, 0);
      } else { if (params.getValue('Values', 0)  ==  3) { params.setValue('Value_1', 0, 100);
      params.setValue('Value_2', 0, 100);
      params.setValue('Values', 0, 0);
      } else {  } }
      }
      /*!!
       &lt;block id="1012" type="if" x="283" y="10" w="268" INPUT1="ID:1013" OPERATION="equals" INPUT2="1" TRUE="ID:1015" FALSE="ID:1018" IGNORE="" /&gt;
      &lt;block id="1013" type="param_Values (Values)[0]" x="10" y="10" w="243" SET="" /&gt;
      &lt;block id="1015" type="param_Value 1 (Value_1)[0]" x="1350" y="60" w="243" SET="ID:1016"  next="ID:1014" /&gt;
      &lt;block id="1016" type="number" x="1152" y="60" w="168" VALUE="0" /&gt;
      &lt;block id="1014" type="param_Value 2 (Value_2)[0]" x="1350" y="154" w="243" SET="ID:1017"  next="ID:1020" /&gt;
      &lt;block id="1017" type="number" x="1152" y="154" w="168" VALUE="100" /&gt;
      &lt;block id="1020" type="param_Values (Values)[0]" x="1350" y="226" w="243" SET="ID:1021" /&gt;
      &lt;block id="1021" type="number" x="1152" y="226" w="168" VALUE="0" /&gt;
      &lt;block id="1018" type="if" x="854" y="100" w="268" INPUT1="ID:1019" OPERATION="equals" INPUT2="2" TRUE="ID:1022" FALSE="ID:1028" IGNORE="" /&gt;
      &lt;block id="1019" type="param_Values (Values)[0]" x="581" y="100" w="243" SET="" /&gt;
      &lt;block id="1022" type="param_Value 1 (Value_1)[0]" x="2392" y="150" w="243" SET="ID:1024"  next="ID:1023" /&gt;
      &lt;block id="1024" type="number" x="2194" y="150" w="168" VALUE="50" /&gt;
      &lt;block id="1023" type="param_Value 2 (Value_2)[0]" x="2392" y="298" w="243" SET="ID:1025"  next="ID:1026" /&gt;
      &lt;block id="1025" type="number" x="2194" y="298" w="168" VALUE="100" /&gt;
      &lt;block id="1026" type="param_Values (Values)[0]" x="2392" y="370" w="243" SET="ID:1027" /&gt;
      &lt;block id="1027" type="number" x="2194" y="370" w="168" VALUE="0" /&gt;
      &lt;block id="1028" type="if" x="1896" y="190" w="268" INPUT1="ID:1029" OPERATION="equals" INPUT2="3" TRUE="ID:1030" FALSE="" IGNORE="" /&gt;
      &lt;block id="1029" type="param_Values (Values)[0]" x="1623" y="190" w="243" SET="" /&gt;
      &lt;block id="1030" type="param_Value 1 (Value_1)[0]" x="2863" y="240" w="243" SET="ID:1032"  next="ID:1031" /&gt;
      &lt;block id="1032" type="number" x="2665" y="240" w="168" VALUE="100" /&gt;
      &lt;block id="1031" type="param_Value 2 (Value_2)[0]" x="2863" y="442" w="243" SET="ID:1033"  next="ID:1034" /&gt;
      &lt;block id="1033" type="number" x="2665" y="442" w="168" VALUE="100" /&gt;
      &lt;block id="1034" type="param_Values (Values)[0]" x="2863" y="514" w="243" SET="ID:1035" /&gt;
      &lt;block id="1035" type="number" x="2665" y="514" w="168" VALUE="0" /&gt;
      !!*/
      /*!!&lt;checksum&gt;3fe878a1727c374dabbad5e1d13bdee3&lt;/checksum&gt;!!*/</task>
         </param>
      </abs>

    Cheers.

    James


    #DashBoard


  • 3.  RE: Triggers for Numeric Choice Counter

    Posted 02-28-2018 13:24
    thanks James. all of this info has been super helpful. I'm slowly but surely creating this Stats Panel, but I'm kinda stuck again. Can you help me integrate some of these features into my Panel? The main thing I need is to link the up/down actions of all of my "MADE" Counter widgets with the up/down Triggers of the respective Attempts Counter widgets. So that would mean 2PTM increase/decrease should also increase/decrease 2PTA, and 3PTM increase/decrease should also increase/decrease 3PTA, and finally FTM increase/decrease should also increase/decrease FTA. Thanks.
    #DashBoard


  • 4.  RE: Triggers for Numeric Choice Counter

    Posted 02-28-2018 15:07

    There are several ways to go about solving this issue. The biggest challenge comes from needing to know how much your parameter has changed in value (has it gone up by 1 or down by 1).

    One way would be to make another parameter that you don't display. This parameter would keep track of the previous value that you had so you know if you went up or down:

    var delta = params.getValue('MY_PARAM', 0) - params.getValue('MY_PREVIOUS_VALUE', 0);
    params.setValueRelative('LINKED_PARAMETER_OID', 0, delta);
    params.setValue('MY_PREVIOUS_VALUE', 0, this.getValue());


    You may also want to consider restructuring your code to make use functions. This way, you can write your logic once and just use Visual Logic to call your functions.

    For example, when updating the percent, you care about 3 parameters: GOALS, ATTEMPTS, PERCENT. We could make a single function to divide GOALS by ATTEMPTS and store the result in PERCENT and take the 3 parameter OIDs as arguments:

      <api>
      function updatePercent(oid1, oid2, output) 
      {
        if ( params.getValue(oid2, 0)  &gt;  0)
        {
          params.setValue(output, 0, ( ( params.getValue(oid1, 0) /  params.getValue(oid2, 0)) * 100));
        } else {
          params.setValue(output, 0, 0);
      }</api>

    we can then just call: updatePercent('OID_1', 'OID_2', 'PERCENT_OID');


    #DashBoard


  • 5.  RE: Triggers for Numeric Choice Counter

    Posted 02-28-2018 17:31
    ok. i'll give all of this syntax a shot. thanks.
    #DashBoard


  • 6.  RE: Triggers for Numeric Choice Counter

    Posted 03-01-2018 19:25
    so i just plugged in all of this code you gave me to link the MADE params to the ATTEMPTS params, and it works fantastic. thanks a million. i never would have figured that out on my own. now, about the second bit of code here that you recommended for me to tidy it all up...can i make these APIs with the wysiwyg Visual Editor? bc im still pretty elementary with javascript and this code looks pretty advanced. i have faith I could plug this code in with no problems, but I also want to create more of these stats pages for other sports such as Baseball, and I think I could run into some pretty long math equations and I could need specific formatting for the results, and I was just starting to get the hang of the VE.

    There are several ways to go about solving this issue. The biggest challenge comes from needing to know how much your parameter has changed in value (has it gone up by 1 or down by 1).

    One way would be to make another parameter that you don't display. This parameter would keep track of the previous value that you had so you know if you went up or down:

    var delta = params.getValue('MY_PARAM', 0) - params.getValue('MY_PREVIOUS_VALUE', 0);
    params.setValueRelative('LINKED_PARAMETER_OID', 0, delta);
    params.setValue('MY_PREVIOUS_VALUE', 0, this.getValue());


    You may also want to consider restructuring your code to make use functions. This way, you can write your logic once and just use Visual Logic to call your functions.

    For example, when updating the percent, you care about 3 parameters: GOALS, ATTEMPTS, PERCENT. We could make a single function to divide GOALS by ATTEMPTS and store the result in PERCENT and take the 3 parameter OIDs as arguments:

    <api>
    function updatePercent(oid1, oid2, output)
    {
    if ( params.getValue(oid2, 0) &gt; 0)
    {
    params.setValue(output, 0, ( ( params.getValue(oid1, 0) / params.getValue(oid2, 0)) * 100));
    } else {
    params.setValue(output, 0, 0);
    }</api>


    we can then just call: updatePercent('OID_1', 'OID_2', 'PERCENT_OID');


    #DashBoard