
Home |
|
PegLight
|

Examples |

Index |
|
 |
|
|
 |
|
Overview |
Derived from class
PegThing
|
 |
|
The PegLight class, although itself a derived class,
is the base class used to implement a state driven object
called a statelight.
At any instant, the object's graphical display indicates the state of
an external process which the statelight represents. The PegLight
class provides the services which allow an object derived from it to follow
the state transitions of the external process.
For example, a process control valve might be represented
by a simple graphic that is green when open and red when shut. A traffic light
is another example in which the color of the light provides the state information.
The PegLight class name has been coined from the traffic light analogy.
KwikPeg includes two statelight classes derived from the PegLight
class. The PegColorLight class uses shapes and color to provide
state information.
The PegBitmapLight class uses bitmap images to draw graphics
which represent the object states.
The PegLight class supports up to 65535 possible states for
each derived statelight object.
 |
To use the PegLight class or its derivatives,
your KwikPeg configuration must have the following option enabled: |
| |
Drawing: HMI graphics |
|
|
 |
 |
|
PegColorLight
PegBitmapLight
The PegLight class supports
the following style flags:
FF_NONE | No frame. |
FF_THIN | Thin frame. |
FF_THICK | Thick 3D frame. |
FF_RAISED | Raised 3D frame. |
FF_RECESSED | Recessed 3D frame. |
Constructors:
 |
 |
PegLight(const PegRect &Rect,
|
| |

WORD wNumStates,
|
| |

WORD wStyle)
|
 |
PegLight(SIGNED iLeft, SIGNED iTop,
|
| |

WORD wNumStates,
|
| |

WORD wStyle)
|
The first constructor creates a derived statelight
in the rectangle specified by parameter Rect.
The second constructor creates a derived statelight
with its top left corner located at (iLeft,iTop).
By default, an object created in this fashion will have a
width and height of 100 pixels.
For both constructors, the following parameters are provided.
Parameter wNumStates defines the number of states which
the statelight can assume.
The allowable states are numbered from 0 to
wNumStates-1.
The initial state is set to 0.
The frame style will be governed by the style flags provided by
parameter wStyle.
Public Functions:
 |
 |
virtual WORD DecrementState(
|
| |

BOOL bRedraw = TRUE)
|
This function decrements the current state of the statelight.
The state value will wrap from 0 to mwNumStates-1
where mwNumStates is the maximum
number of states which the statelight supports.
This function returns the final state value.
If parameter bRedraw is TRUE, the statelight
will be redrawn to reflect its updated state.
 |
 |
WORD GetCurrentState(void) const
|
This inline function returns the current state of the statelight.
 |
 |
WORD GetNumStates(void) const
|
This inline function returns the maximum number of states
supported by the statelight.
 |
 |
virtual WORD IncrementState(
|
| |

BOOL bRedraw = TRUE)
|
This function increments the current state of the statelight.
The state value will wrap from mwNumStates-1 to 0
where mwNumStates is the maximum
number of states which the statelight supports.
This function returns the final state value.
If parameter bRedraw is TRUE, the statelight
will be redrawn to reflect its updated state.
 |
 |
WORD SetNumStates(WORD wNumStates) const
|
This function sets the number of states supported by the statelight
to wNumStates. If wNumStates is 0,
the number of states is left unaltered.
If the current state of the statelight exceeds the revised upper limit,
the current state is set to wNumStates-1.
This function returns the revised number of states
supported by the statelight.
 |
 |
virtual WORD SetState(
|
| |

WORD wState,
|
| |

BOOL bRedraw = TRUE)
|
This function sets the current state of the statelight to wState.
If wState is outside the range 0 to
mwNumStates-1, where mwNumStates is the maximum
number of states which the statelight supports, the state will not be altered.
This function returns the final state value.
If parameter bRedraw is TRUE, the statelight
will be redrawn to reflect its updated state.
The PegColorLight
class and the PegBitmapLight
class provide examples of statelights derived from the PegLight
class.