Example Limit Checking

The main goal of this example demonstrates how to use the TRIGGER.LT and TRIGGER.GT tags to limit the min and max values of an internalRAM variable using the increment and decrement methods. For a detailed description of Internal RAM variables and methods, see the Internal RAM documentation. This example uses two image icons for incrementing and decrementing the value stored at Internal RAM variable 0. A numeric field widget is used to request and display the value stored at Internal RAM variable 0. The value stored at Internal RAM variable 0 is limited to a minimum value of 60 and a maximum value of 90 by using two META tags. Internal RAM variable 0 is initialized to a predefined value by including an initialization file via a META tag. Here is a snapshot of what the HTML page looks like in a " WYSIWYG" tool:


Figure 1.

Figure 1 has a total of three META tags in the head section of the HTML document. The first META tag instructs the HTMLCompiler to use an initialization file named climateInits.ini. The META tag syntax is as follows:

< META NAME=" initInternalRAM" SRC=" climateInits.ini" >

The initialization file named climateInits.ini is composed of the following text:

#Internal Ram Declarations

#Byte Initializations

InternalRAM.byte(0) = 75

Notice that Internal RAM variable 0 is initialized to a value of 75. To create a numeric field named desiredTemp that uses the byte value returned by InternalRAM.byte(0).value() as its input, the following is used:

< APPLET CODE=" Field.class" WIDTH=" 41" HEIGHT=" 20" ALIGN=" bottom" NAME=" desiredTemp" >
< PARAM NAME=" href" VALUE=" Amulet:InternalRAM.byte(0).value()" >
< PARAM NAME=" fontSize" VALUE=" 4" >
< PARAM NAME=" fontStyle" VALUE=" plain" >
< PARAM NAME=" min" VALUE=" 60" >
< PARAM NAME=" max" VALUE=" 90" >
< PARAM NAME=" printf" VALUE=" Status = %2i" >
< PARAM NAME=" minFld" VALUE=" 60" >
< PARAM NAME=" maxFld" VALUE=" 90" >
< PARAM NAME=" updateRate" VALUE=" .33,.01" >
< PARAM NAME=" horizontalAlign" VALUE=" right" >
< PARAM NAME=" verticalAlign" VALUE=" middle" >
< /APPLET>

desiredTemp
updates every 33 msec after the initial request which happens 10 msec immediately after the page is loaded. To create a custom button named up which attempts to increment the desired temperature displayed by the numeric field, the following is used:

< APPLET CODE=" CustomButton.class" width=" 26" HEIGHT=" 16" ALIGN=" bottom" NAME=" up" >
< PARAM NAME=" href" VALUE=" Amulet:document.Increment.forceUpdate()" >
< PARAM NAME=" onButtonPress" VALUE=" invert" >
< PARAM NAME=" upImage" VALUE=" up.gif" >
< PARAM NAME=" downImage" VALUE=" up.gif" >
< PARAM NAME=" repeatDelay" VALUE=" 1" >
< PARAM NAME=" repeatRate" VALUE=" 0.1" >
< /APPLET>

Notice that the href does not directly increment the value stored at Internal RAM variable 0, but instead forces a META tag named Increment to update. The META tag syntax is as follows:
The first META tag instructs the HTMLCompiler to use an initialization file named climateInits.ini. The META tag syntax is as follows:

< META HTTP-EQUIV=" REFRESH" CONTENT=" 0 ONVAR=Amulet:InternalRAM.byte(0).value() TRIGGER.LT=90
URL=Amulet:InternalRAM.byte(0).increment() NAME=Increment" >


The only time Increment will request the value stored at Internal RAM variable 0 is when its forceUpdate() method is called since the ONVAR frequency is set to 0. If the value returned from Internal RAM is less than the TRIGGER.LT value of 90, then the function Amulet:InternalRAM.byte(0).increment() is called. To create a custom button named down which attempts to decrement the desired temperature displayed by the numeric field, the following is used:

< APPLET CODE=" CustomButton.class" width=" 26" HEIGHT=" 16" ALIGN=" bottom" NAME=" down" >
< PARAM NAME=" href" VALUE=" Amulet:document.Decrement.forceUpdate()" >
< PARAM NAME=" onButtonPress" VALUE=" invert" >
< PARAM NAME=" upImage" VALUE=" down.gif" >
< PARAM NAME=" downImage" VALUE=" down.gif" >
< PARAM NAME=" repeatDelay" VALUE=" 1" >
< PARAM NAME=" repeatRate" VALUE=" 0.1" >
< /APPLET>

Notice that the href does not directly decrement the value stored at Internal RAM variable 0, but instead forces a META tag named Decrement to update. The META tag syntax is as follows:

< META HTTP-EQUIV=" REFRESH" CONTENT=" 0 ONVAR=Amulet:InternalRAM.byte(0).value() TRIGGER.GT=60
URL=Amulet:InternalRAM.byte(0).decrement() NAME=Decrement" >


The only time Decrement will request the value stored at Internal RAM variable 0 is when its forceUpdate() method is called since the ONVAR frequency is set to 0. If the value returned from Internal RAM is greater than the TRIGGER.GT value of 60, then the function Amulet:InternalRAM.byte(0).decrement() is called.

NOTES:

  • In order to program this example into the Amulet module, the above HTML page can be found in \Projects\Examples\LimitChecking\CompileMe.htm subdirectory of the Amulet main directory. By default, the Amulet main directory is C:\Program Files\Amulet, however you may have specified a different path during the install.



© 2003-2005 Amulet Technologies. U.S. and Foreign Patents Pending.
µ HTML is a Trademark of Amulet Technologies