Sometimes all you need is a simple indication telling you the state of the device you are dealing with. Power indicator of you will. It provides visual feedback which is essential for everybody who uses the device. In the virtual world it is more or less the same. You trigger a signal and you expect something confirming the action to happen. In the general case we rely on a simple light indicator to do so.
In Process Simulate we can model such a behavior quite easily. We only need a resource with proper geometry and a script. The code emphasizes/deemphasizes a particular entity of the resource or the resource itself to represent a light being turned on or off. Here is a sample FB:
FUNCTION_BLOCK "MAIN"
VERSION:1.0
VAR_INPUT
in : BOOL; // Turns the light ON/OFF
END_VAR
VAR_OUTPUT
out : BOOL; // Indicates the state of the light
END_VAR
VAR
tone : "ARGB";
emphasized : BOOL;
END_VAR
BEGIN
#tone.alpha := 1; // 0% transparency
#tone.r := 16#FF; // yellow color
#tone.g := 16#FF; //
#tone.b := 16#00; //
IF #in THEN
IF NOT #emphasized THEN
EMPHASIZE(NAME:='1_XT_4', COLOR:=#tone);
#emphasized := true;
END_IF;
ELSE
IF #emphasized THEN
DEEMPHASIZE(NAME:='1_XT_4', COLOR:=#tone);
#emphasized := false;
END_IF;
END_IF;
END_FUNCTION_BLOCK
There is nothing complex here. The name of the entity (1_XT_4) that needs to be emphasized/deemphasized is provided to the EMPHASIZE/DEEMPHASIZE function along with the desired color.
Very well!
Now you have a LED in Process Simulate that can be wired to any other logic.
It is up to you to decide what that will be.
See you!
Comments