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) > 0)
{
params.setValue('Percent', 0, ( ( params.getValue('Value_1', 0) / params.getValue('Value_2', 0)) * 100));
} else {
params.setValue('Percent', 0, 0);
}
/*!!
<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="" />
<block id="1001" type="param_Value 2 (Value_2)[0]" x="10" y="10" w="243" SET="" />
<block id="1007" type="param_Percent (Percent)[0]" x="1821" y="60" w="243" SET="ID:1011" />
<block id="1011" type="math_multiply" x="1573" y="60" VALUE="ID:1005" VAL_1="100" w="218" VAL_1_1="" />
<block id="1005" type="math_divide" x="1325" y="60" VALUE="ID:1004" VAL_1="ID:1006" w="218" VAL_1_1="" />
<block id="1004" type="param_Value 1 (Value_1)[0]" x="1052" y="60" w="243" SET="" />
<block id="1006" type="param_Value 2 (Value_2)[0]" x="1052" y="122" w="243" SET="" />
<block id="1002" type="param_Percent (Percent)[0]" x="779" y="100" w="243" SET="ID:1008" />
<block id="1008" type="number" x="581" y="100" w="168" VALUE="0" />
!!*/
}
/*!!<checksum>65d4cc99fa5007e3375bee379f3bb69c</checksum>!!*/</api>
</meta>
<param expand="true" height="73" left="217" oid="Value_1" top="23" width="160">
<task tasktype="ogscript">
/*! block id=1009 !*/
updatePercent()
/*!!
<block id="1009" type="function_updatePercent" x="10" y="100" w="243" />
!!*/
/*!!<checksum>73ddb62a27445d0ace6794520d077fcb</checksum>!!*/</task>
</param>
<param expand="true" height="68" left="214" oid="Value_2" top="121" width="166">
<task tasktype="ogscript">
/*! block id=1010 !*/
updatePercent()
/*!!
<block id="1010" type="function_updatePercent" x="10" y="100" w="243" />
!!*/
/*!!<checksum>2e1368e569a705385b634379cbd2a75d</checksum>!!*/</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 { } }
}
/*!!
<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="" />
<block id="1013" type="param_Values (Values)[0]" x="10" y="10" w="243" SET="" />
<block id="1015" type="param_Value 1 (Value_1)[0]" x="1350" y="60" w="243" SET="ID:1016" next="ID:1014" />
<block id="1016" type="number" x="1152" y="60" w="168" VALUE="0" />
<block id="1014" type="param_Value 2 (Value_2)[0]" x="1350" y="154" w="243" SET="ID:1017" next="ID:1020" />
<block id="1017" type="number" x="1152" y="154" w="168" VALUE="100" />
<block id="1020" type="param_Values (Values)[0]" x="1350" y="226" w="243" SET="ID:1021" />
<block id="1021" type="number" x="1152" y="226" w="168" VALUE="0" />
<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="" />
<block id="1019" type="param_Values (Values)[0]" x="581" y="100" w="243" SET="" />
<block id="1022" type="param_Value 1 (Value_1)[0]" x="2392" y="150" w="243" SET="ID:1024" next="ID:1023" />
<block id="1024" type="number" x="2194" y="150" w="168" VALUE="50" />
<block id="1023" type="param_Value 2 (Value_2)[0]" x="2392" y="298" w="243" SET="ID:1025" next="ID:1026" />
<block id="1025" type="number" x="2194" y="298" w="168" VALUE="100" />
<block id="1026" type="param_Values (Values)[0]" x="2392" y="370" w="243" SET="ID:1027" />
<block id="1027" type="number" x="2194" y="370" w="168" VALUE="0" />
<block id="1028" type="if" x="1896" y="190" w="268" INPUT1="ID:1029" OPERATION="equals" INPUT2="3" TRUE="ID:1030" FALSE="" IGNORE="" />
<block id="1029" type="param_Values (Values)[0]" x="1623" y="190" w="243" SET="" />
<block id="1030" type="param_Value 1 (Value_1)[0]" x="2863" y="240" w="243" SET="ID:1032" next="ID:1031" />
<block id="1032" type="number" x="2665" y="240" w="168" VALUE="100" />
<block id="1031" type="param_Value 2 (Value_2)[0]" x="2863" y="442" w="243" SET="ID:1033" next="ID:1034" />
<block id="1033" type="number" x="2665" y="442" w="168" VALUE="100" />
<block id="1034" type="param_Values (Values)[0]" x="2863" y="514" w="243" SET="ID:1035" />
<block id="1035" type="number" x="2665" y="514" w="168" VALUE="0" />
!!*/
/*!!<checksum>3fe878a1727c374dabbad5e1d13bdee3</checksum>!!*/</task>
</param>
</abs>
Cheers.
James
#DashBoard