GRAPHICS class modules (also discussed in AppMod.src Root File for a Standard Application) are graphic modules used to draw a tag on a system page. When defined outside of a tag module, the same module can be used by several tags, and can easily be replaced by modifying the application's AppMod.src file's code without modifying the tag's code. This is accomplished by defining a Shared variable (see Shared Variables) in the tag module with a class of GRAPHICS.
For example, within the tag module's code, declare the new Shared variable in a manner similar to the example shown below:
[ (GRAPHICS)
Shared ColorRange;
]
Any number of graphics modules may be specified in the list of GRAPHICS variables defined in the tag module. For example, the code for an analog input tag declares eight Shared GRAPHICS variables.
[ (GRAPHICS)
Shared TopBar;
Shared RightBar;
Shared LeftBar;
Shared BottomBar;
Shared Number;
Shared Meter1;
Shared Meter2;
Shared Meter3;
]
There must be a module with the same name as the Shared variable declared in the GRAPHICS section of the application's AppMod.src file.
[ (GRAPHICS) { Modules that are shared drawing methods for tags }
ColorRange Module "ColorRange.src";
]
If the Shared variable has a default value, the default value is used as the name of the module for which to search in the AppMod.src file in the GRAPHICS class. This module will behave as if it were a part of the tag with one exception; all references in the graphics modules to variables within the tag must be preceded with a backslash (\).
A second mechanism allows graphic modules created by a user to be added to existing tag modules without modifying the tag's code. This is done by placing a shared POINTS class variable within the graphics module.
[ (POINTS)
Shared AnalogInput;
]
This variable must be named the same as the tag module to which it should attach. The graphics module is attached to the identified tag module to provide an additional drawing method for the tags of that type. If the tag already has an "internal" graphics module of the same name, the external graphics module attachment will fail. For this reason, it is desirable to keep the drawing modules for a tag external to the tag code so that they can be readily replaced by users without modifying the tag code (to which they may, or may not have access). Any number of tag modules may be specified in the list of POINTS variables defined in the graphics module.
[ (POINTS)
Shared AnalogInput;
Shared AnalogOutput;
Shared Function;
]
All of these variables should be Shared (see Shared Variables) to conserve RAM. If one of these variables has a default value, this default value is used as the name added to the tag module, rather than the variable name itself.
GRAPHICS class modules must call the "\Common" module with four parameters specifying the area on the screen that the drawing object occupies. The Common module handles all of the common drawing object functions that are implemented in the graphic drawing modules. These functions typically include a call to the "Navigator" module, the "PostIt" module, and the "PkTrend" module, as well as calls to code for control dialog boxes. Any external graphic modules must make a call to the "Common" module within the tag. The "Common" module takes four parameters that define the area of the screen occupied by the drawing object. The four parameters of the "Common" module are:
• Left – Any numeric expression for the object's left side coordinate.
• Bottom – Any numeric expression for the object's bottom coordinate.
• Right – Any numeric expression for the object's right side coordinate.
• Top – Any numeric expression for the object's top coordinate.