```
FUNCTION_BLOCK AnalogToSwitch
TITLE = \'Analog to Switch Conversion\'
VERSION : INT := 1;
INPUT :
IN_Value : REAL; (* The analog value to be converted *)
High_Alarm : REAL; (* The high alarm limit *)
Low_Alarm : REAL; (* The low alarm limit *)
HH_Alarm : REAL; (* The high-high alarm limit *)
LL_Alarm : REAL; (* The low-low alarm limit *)
Alarm_Time : TIME; (* The time required to trigger an alarm *)
OUTPUT :
Switch_Value : BOOL; (* The converted switch value *)
Alarm_Activated : BOOL; (* Indicates if an alarm has been activated *)
VAR_OUTPUT :
Alarm_Reset : BOOL; (* Indicates that the alarm has been reset *)
VAR :
Last_Value : REAL; (* The input value from the last cycle *)
Counter : INT; (* Counter for alarm triggering *)
(* Main code *)
IF Reset THEN
Last_Value := 0;
Counter := 0;
Switch_Value := FALSE;
Alarm_Activated := FALSE;
Alarm_Reset := FALSE;
ELSE
(* Compare the input value to the alarm limits *)