Hi Bo,
Its important to recognize that the Alarm Table constraint is evaluating bits and not decimal values. This can lead to a bit of confusion.
A common way to have a light turn red or green is to send the text parameter an embedded colour code. In the code snippet below, I have a ogScript function that evaluates if the passed value is 1 or 0 and will update the light colour. I have used an unconstrained type in this example.
NOTE: You can choose whether or not to send text along with the colour code.
Please let me know if you have any questions.
<abs contexttype="opengear" gridsize="20" id="_top" keepalive="false">
<meta>
<params>
<param access="1" maxlength="0" name="alarm" oid="alarm" type="STRING" value="Disconnection<#ff0000>" widget="default"/>
</params>
<api>function setAlarm(num){
switch(num) {
case 0:
params.setValue("alarm", 0, "Disconnection<#ff0000>");
break;
case 1:
params.setValue("alarm", 0, "<#13E40C>");
break;
}
}</api>
</meta>
<param expand="true" height="100" left="60" oid="alarm" top="200" widget="12" width="120"/>
<button buttontype="push" height="40" left="180" name="Send 0" top="200" width="180">
<task tasktype="ogscript">setAlarm(0);</task>
</button>
<button buttontype="push" height="40" left="180" name="Send 1" top="260" width="180">
<task tasktype="ogscript">setAlarm(1);</task>
</button>
</abs>
#DashBoard