Monday, February 24, 2014

Cold/Warm boot.

Example Main Program

(* setup initial retain values - first time.
   They will be read back from config file after a first time.*) 
 
IF (Cold = FALSE) THEN
    Enable := FALSE;
    HiHiLimit := 100.0;
    HiLimit := 90.0;

    ReturnStatus := Event_Clear();
    ReturnStatus := Event_Log(State_Cold, 0, 0.0);
    Cold := TRUE;
END_IF;

(* setup non-retain variables after a warm start *)
IF (Warm = False) THEN
    (* for each input clear the state and set the output to ON *)
    FOR pos := 1 TO ANY_TO_DINT(Input_Size) DO
        State[pos] := State_OK;
        Output[pos] := 1;
    END_FOR;

    ReturnStatus := Event_Log(State_Warm, 0, 0.0);
    Warm := TRUE;
END_IF;

Variables

NameTypeDirAttrRetained
ColdBoolVarR/WYes
WarmBoolVarR/WNo

Defined words (#define in C++)

Defined WordsValue
State_Unused0
State_OK1
State_HiHi2
State_Cold3
State_Warm4

No comments:

Post a Comment