Programmability¶
Programability The properties of an visualization element can not only be defined by a static setting or by a “normal” project variable, but also by the components of a structure variable, which is exclusively used for programming visualization elements.
For this purpose the structure VisualObjectType is available in the library SysLibVisu.lib. Its components can be used to define most of the element properties.
Note
In case of multiple definition of a element property the value of the “normal” project variables will overwrite that of the structure variable and both will overwrite a static definition.
In order to configure the element properties by using a structure variable, do the following:
Open the configuration dialog, category ‘Programmability’ and enter a new, unique (!) variable name in the field ‘Object Name’. For this purpose you must activate the option by a mouse-click in the checkbox. The variable automatically will be declared with type ‘VisualObjectType’, a structure which is contained in the library ‘SysLibVisu.Lib’. The declaration is done implicitely and not visible for the user. Make sure that the library is included in the library manager.
After the next compile the newly assigned structure variable will be available in the project. (Hint: Activate the Intellisense functionality ‘List components’ in the project options, category Editor, in order to get the structure components in a selection list as soon as the variable name followed by a dot is entered).
Example: If you have defined a Object Name “visu1_line” for a visualization element, then you can program the line width of this element by e.g. “visu1_line.nLIneWidth:=4”.
The structure VisualObjectType
The following table will show you all components of the structure and references to the corresponding items in the different categories of the configuration dialog:
At the beginning of the component name the data type is integrated:
- n INT
- dw DWORD
- b BOOL
- st STRING
Component (+Data type) | Effect | Example (the Object Name “vis1” has been defined for the element) | corresponding entries in configuration dialog: |
---|---|---|---|
nXOffset : INT; | Shift element in X-direction | vis1.nXOffset:=val2; (element is set to position X=val2) |
- Cat. Motion absolute: X-Offset |
nYOffset : INT; | Shift element in Y-direction | vis1.nYOffset:=22; (element is set to position Y=val2) |
- Cat. Motion absolute: Y-Offset |
nScale : INT; | Change of the size | vis1.nScale:=plc_prg.scale_var; (element size changes linear with change of value of plc_prg.scale_var) |
- Cat. Motion absolute: Scaling |
nAngle : INT; | Rotating element around its center | vis1.anglevar:=15; (element rotates clockwise by 15 ) |
- Cat. Motion absolute: angle |
bInvisible : BOOL; | Element is visible / invisible | vis1.visible:=TRUE; (element is invisible) |
- Cat. Color: No color inside + No frame color - Cat. Colorvariables: Fillcolor + Framecolor |
stTextDisplay : STRING; | Text is displayed in element | vis1.TextDisplay:=’ON / OFF’; element is inscribed with this text |
- Cat. Text: entry at ‘Content’ |
bToggleColor : BOOL; | color change when toggling between TRUE and FALSE | As soon as alarm_var gets TRUE, the element gets the color defined via the components dwFillColorAlarm, dwFrameColorAlarm resp. via the settings in category ‘Colorvariables’ or ‘Color’. | - Cat. Input: Toggle variable + - Cat. Variables: Change color |
bInputDisabled: BOOL; | if FALSE: Inputs in category ‘Input’ are ignored | vis1.bInputDisabled:=FALSE; (no input is possible for this elementt) | - Cat. Variables: ‘Disable Input’ |
stTooltipDisplay:STRING; | Text of the tooltip | vis1.stTooltipDisplay:=’Switch for …..’; | - Cat. Text for Tooltip: Entry in ‘Content:’ |
dwTextFlags:DWORD; | Text position: 1 left justified 2 right justified: 4 centered horizontally 8 top 10 bottom 20 centered vertically Note: Always set a horizontal and a vertical position (addition of values)! |
vis1.dwTextFlags:=24; (Text will be placed in the center of the element (4 + 20) |
- Cat. Text: Horizontal and Vertical options - Cat. Textvariables: Textflags |
dwTextColor : DWORD; | Text color (definition of colors see subsequent to this table) |
vis1.dwTextColor := 16#00FF0000; (Text is blue-colored) |
- Cat. Text: Font | Color - Cat. Textvariables: Textcolor |
nFontHeight : INT; | Font height in Pixel should be in range 10-96 | vis1.nFontHeight:=16; (Text height is 16 pt) |
- Cat. Text: Font | Grad - Cat. Textvariables: Font heigth |
dwFontFlags : DWORD; | Font display. Available flags: 1 italic 2 fett 4 underlined 8 canceled + combinations by adding values |
vis1.dwFontFlags:=10; (Text is displayed blue and canceled) |
- Cat. Text: Schrift | Schriftschnitt - Cat. Textvariables: Fontflags |
stFontName : STRING; | Change font | vis1.stFontName:=’Arial’; (Arial is used) |
- Cat. Text: Schrift | Schriftart - Cat. Textvariables: Fontname |
nLineWidth : INT; | Line width of the frame (pixels) | vis1.nLWidth:=3; (Frame width is 3 Pixels) |
- Cat. Line width |
dwFillColor : DWORD; | Fill color (definition of colors see subsequent to this table) |
vis1.dwFillColor”:=16#00FF0000; (Element ist im “Normalzustand” blau) |
- Cat. Color: Color | Inside - Cat. Colorvariables: Inside |
dwFillColorAlarm : DWORD; | Fill color as soon as bToggleColor gets TRUE, see above) (definition of colors see subsequent to this table) |
vis1.dwFillColorAlarm:=16#00808080; (as soon as Variable togglevar gets TRUE, the element will be displayed grey-colored) |
- Cat. Color: Alarm color | Inside - Cat. Colorvariables: Inside Alarm |
dwFrameColor: DWORD; | Frame color (definition of colors see subsequent to this table) |
vis1.dwFrameColor:=16#00FF0000; (Frame is blue-colored) |
- Cat. Color: Color | Frame - Cat. Colorvariables: Frame |
dwFrameColorAlarm: DWORD; | Fill color as soon as bFrameColor gets TRUE, see above (definition of colors see subsequent to this table) |
vis1.dwFrameColorAlarm:=16#00808080; (as soon as Variable vis1.bToggleColor gets TRUE, the frame will be displayed grey-colored) |
- Cat. Color: Alarm color | Frame - Cat. Colorvariables: Frame Alarm |
dwFillFlags: DWORD; | Color, as defined by the color variables, can be displayed or ignored 0 = show color >0 = ignore setting | vis1.dwFillFlags:=1; (element gets invisible) |
- Cat. Color: No color inside + No frame color - Cat. Colorvariables: Fillflags |
dwFrameFlags: DWORD; | Display of frame: 0 full 1 dashed ( — ) 2 dotted ( ) 3 dash-point ( _._._ ) 4 dash-point-point (_.._.. ) 8 blind out line |
vis1.FrameFlags:=1; (Frame will be displayed as dashed line) |
- Cat. Colorvariables: Frameflags |
Defining color values
Example: e1.dwFillColor := 16#00FF00FF;
A color is entered as a hex number which is composed of the Blue/Green/Red (RGB) components. The first two zeros after “16#” should be set to in each case, to fill the DWORD size. For each color value 256 (0-255) colors are available.
- FF Blue component
- 00 Green component
- FF Red component
Example for a blinking visualization element\ \
Define a global variable ‘blink1’ of type VisualObjectType in the configuration of a rectangle. In a program of function block the value of a component of the structure can be modified.
PROGRAM PLC_PRG
VAR
n:INT:=0;
bMod:BOOL:=TRUE;
END_VAR
(* Blinking element *)
n:=n+1;
bMod:= (n MOD 20) > 10;
IF bMod THEN
blinker.nFillColor := 16#00808080; (* Grau *)
ELSE blinker.nFillColor := 16#00FF0000; (* Blau *)
END_IF