Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto recover #80

Merged
merged 9 commits into from
Sep 2, 2021
Prev Previous commit
Next Next commit
DEV: AutoRecover is called from within the function block of the PIP …
…and the GCC. The timer is default but can be set from the user program. AutoOn pv is available through epics to switch this function off. The Autorecover is set to always run unless a value has been written to that persistent variable. Still to be tested.
  • Loading branch information
ghalym committed Aug 31, 2021
commit f24af157d869377a3a8b61a7ea63438c0e93fa0c
8 changes: 7 additions & 1 deletion L2SIVacuum/DUTs/Gauges/ST_VG.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ STRUCT
field: ONAM ON;
'}
xHV_SW: BOOL; // High Voltage Switch from epics

{attribute 'pytmc' := '
pv: Auto_On;
field: ZNAM FALSE;
field: ONAM TRUE;
io:i;
'}
xAutoOn : BOOL;
/// Controls and I/Os
{attribute 'pytmc' := '
pv: PRESS_AI;
Expand Down
33 changes: 19 additions & 14 deletions L2SIVacuum/L2SIVacuum.tmc

Large diffs are not rendered by default.

Binary file modified L2SIVacuum/LineIDs.dbg
Binary file not shown.
3 changes: 3 additions & 0 deletions L2SIVacuum/POUs/Functions/Gauges/FB_GaugeBase.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ VAR
// For Persistent Data
bRestorePersistentData : BOOL:=TRUE;
stateTimer:TON;
fbGetCurTaskIdx : GETCURTASKINDEX;
fbWritePersistentData : WritePersistentData;
tRecover: TON;
END_VAR
VAR PERSISTENT
rVAC_SP : REAL;
Expand Down
27 changes: 26 additions & 1 deletion L2SIVacuum/POUs/Functions/Gauges/FB_MKS422.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ END_VAR
VAR_INPUT
PG : ST_VG; // Pirani Gauge Structure used to Interlock the Cold Cathode
b937A :BOOL:=FALSE; // True if this gauge is connected to MKS937A controller, False if connected to MKS937B controller
tRecoverDelay:TIME:=T#600S; (*Delay Time after the first cycle to start the device. Default is 600S*)
END_VAR
VAR_OUTPUT
{attribute 'pytmc' := '
Expand All @@ -31,6 +32,8 @@ VAR CONSTANT
END_VAR
VAR PERSISTENT
bWasOn : BOOL;
bAutoRecover:BOOL;
bAutoRecoverWrite:BOOL;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[(* 937B Logarithmic Output Conversion *)
Expand Down Expand Up @@ -108,7 +111,8 @@ IO();
(*Load or save the persistent variables*)
ACT_Persistent();
timer(IN:= NOT IG.q_xHV_DIS, PT:= T#2s);

(*Run Auto Recovery*)
ACT_Recover();
]]></ST>
</Implementation>
<Action Name="ACT_Logger" Id="{81455e48-69be-44cd-8f73-e6a424a8f2a9}">
Expand Down Expand Up @@ -167,6 +171,9 @@ IF (SUPER^.bRestorePersistentData) THEN
IF ( rHYS_PR <> 0) THEN
IG.rHYS_PR := rHYS_PR;
END_IF;
IF ( bAutoRecoverWrite) THEN
IG.xAutoOn := bAutoRecover;
END_IF;
END_IF
(*Check if a new value has been written in the structure variable copy it to the persistent variable*)
IF NOT (IG.rVAC_SP = rVAC_SP) THEN
Expand All @@ -180,13 +187,31 @@ END_IF;
IF NOT (IG.rHYS_PR = rHYS_PR) THEN
rHYS_PR:= IG.rHYS_PR;
END_IF;

IF NOT(bAutoRecoverWrite) OR NOT (IG.xAutoOn = bAutoRecover) THEN
bAutoRecover := IG.xAutoOn;
bAutoRecoverWrite := TRUE;
END_IF;
stateTimer(PT:=T#10S);
IF (stateTimer.Q) THEN
bWasOn := (IG.eState >=Valid );
stateTimer.IN := FALSE;
fbWritePersistentData(NETID:='', PORT:=851, START:=TRUE, TMOUT:=T#1s );
END_IF;]]></ST>
</Implementation>
</Action>
<Action Name="ACT_Recover" Id="{3e6e3bcf-7780-45ff-9848-62b6d7bc4a60}">
<Implementation>
<ST><![CDATA[fbGetCurTaskIdx();
IF (_TaskInfo[fbGetCurTaskIdx.index].FirstCycle) THEN
tRecover.IN := TRUE;
END_IF
tRecover(IN:= , PT:=tRecoverDelay);
IF NOT(bAutoRecoverWrite) OR (tRecover.Q AND bAutoRecover ) THEN
This^.M_Recover();
END_IF]]></ST>
</Implementation>
</Action>
<Action Name="IO" Id="{745bf75f-6d68-4d34-a177-a78f14818649}">
<Implementation>
<ST><![CDATA[(*soft link inputs*)
Expand Down
27 changes: 26 additions & 1 deletion L2SIVacuum/POUs/Functions/Gauges/FB_MKS500.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ END_VAR
VAR_INPUT
PG : ST_VG;
bEP : BOOL :=FALSE; // Set to True if This Gauge is connected to EP BOX and not EL Terminals
tRecoverDelay:TIME:=T#600S; (*Delay Time after the first cycle to start the device. Default is 600S*)
END_VAR
VAR_OUTPUT
{attribute 'pytmc' := '
Expand Down Expand Up @@ -49,6 +50,8 @@ VAR CONSTANT
END_VAR
VAR PERSISTENT
bWasOn : BOOL;
bAutoRecover:BOOL;
bAutoRecoverWrite:BOOL;
END_VAR

]]></Declaration>
Expand Down Expand Up @@ -138,7 +141,8 @@ ACT_Logger();
IO();
(*Load or save the persistent variables*)
ACT_Persistent();
]]></ST>
(*Run Auto Recovery*)
ACT_Recover();]]></ST>
</Implementation>
<Action Name="ACT_Logger" Id="{b6ae699a-8cbc-41c3-94fc-93d1d486cd97}">
<Implementation>
Expand Down Expand Up @@ -196,6 +200,9 @@ IF (SUPER^.bRestorePersistentData) THEN
IF ( rHYS_PR <> 0) THEN
IG.rHYS_PR := rHYS_PR;
END_IF;
IF ( bAutoRecoverWrite) THEN
IG.xAutoOn := bAutoRecover;
END_IF;
END_IF
(*Check if a new value has been written in the structure variable copy it to the persistent variable*)
IF NOT (IG.rVAC_SP = rVAC_SP) THEN
Expand All @@ -209,13 +216,31 @@ END_IF;
IF NOT (IG.rHYS_PR = rHYS_PR) THEN
rHYS_PR:= IG.rHYS_PR;
END_IF;

IF NOT(bAutoRecoverWrite) OR NOT (bAutoRecover = IG.xAutoOn) THEN
bAutoRecover := IG.xAutoOn;
bAutoRecoverWrite := TRUE;
END_IF;
stateTimer(PT:=T#10S);
IF (stateTimer.Q) THEN
bWasOn := (IG.eState >=Valid );
stateTimer.IN := FALSE;
fbWritePersistentData(NETID:='', PORT:=851, START:=TRUE, TMOUT:=T#1s );
END_IF;]]></ST>
</Implementation>
</Action>
<Action Name="ACT_Recover" Id="{ac0dd076-6f0a-4fff-a772-7158a547a40b}">
<Implementation>
<ST><![CDATA[fbGetCurTaskIdx();
IF (_TaskInfo[fbGetCurTaskIdx.index].FirstCycle) THEN
tRecover.IN := TRUE;
END_IF
tRecover(IN:= , PT:=tRecoverDelay);
IF NOT(bAutoRecoverWrite) OR (tRecover.Q AND bAutoRecover ) THEN
This^.M_Recover();
END_IF]]></ST>
</Implementation>
</Action>
<Action Name="IO" Id="{8ad71ac6-f961-40c8-a3be-ad3367f81f67}">
<Implementation>
<ST><![CDATA[(*soft link inputs*)
Expand Down
34 changes: 30 additions & 4 deletions L2SIVacuum/POUs/Functions/Pumps/FB_PIP_Gamma.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FUNCTION_BLOCK FB_PIP_Gamma Extends FB_Pump
VAR_INPUT
i_stGauge : ST_VG; //Ion or Pirani gauge for pump interlock
i_xOverrideMode : BOOL; (*To be linked to global override bit. This Overrides Vacuum interlock logic*)
tRecoverDelay:TIME:=T#900S; (*Delay Time after the first cycle to start the device. Default is 900S*)
END_VAR
VAR_OUTPUT
{attribute 'pytmc' := '
Expand Down Expand Up @@ -43,13 +44,18 @@ stateTimer:TON;
{attribute 'instance-path'}
{attribute 'noinit'}
sPath: STRING;
fbGetCurTaskIdx : GETCURTASKINDEX;
fbWritePersistentData : WritePersistentData;
tRecover: TON;
END_VAR
VAR CONSTANT
rDefaultHVEna_SP : REAL :=1E-4; // Default protection setpoint as per the gamma QPCe manual
END_VAR
VAR PERSISTENT
rHVEna_SP : REAL;
bWasOn : BOOL;
bAutoRecover:BOOL;
bAutoRecoverWrite:BOOL;
END_VAR

]]></Declaration>
Expand All @@ -66,9 +72,7 @@ END_IF

(* Enable HV *)
IF i_stGauge.rPRESS <= stPump.rHVEna_SP AND i_stGauge.xPRESS_OK THEN
IF (stPump.xAutoOn) AND NOT (stPump.q_xHVEna_DO) THEN stPump.q_xHVEna_DO := TRUE;
ELSE stPump.q_xHVEna_DO := stPump.xHVEna_SW OR ((tonOvrd.Q AND i_xOverrideMode));
END_IF
stPump.q_xHVEna_DO := stPump.xHVEna_SW OR ((tonOvrd.Q AND i_xOverrideMode));
stPump.xILKOk:= TRUE;
ELSIF stPump.q_xHVEna_DO (*AND timer.Q*) THEN
IF q_IG.rPRESS > (stPump.rHVEna_SP + stPump.rHYS_PR) THEN // Ion pumps when running switches off based on their own pressure readings
Expand Down Expand Up @@ -124,7 +128,9 @@ ACT_IlkOverride();
// Log States and triggers
ACT_Logger();
(*Load or save the persistent variables*)
ACT_Persistent();]]></ST>
ACT_Persistent();
(*Run Auto Recovery*)
ACT_Recover();]]></ST>
</Implementation>
<Action Name="ACT_IlkOverride" Id="{bcee683f-3211-4a69-9559-1cb72724e991}">
<Implementation>
Expand Down Expand Up @@ -199,18 +205,38 @@ IF (SUPER^.bRestorePersistentData) THEN
IF (rHVEna_SP <> 0) THEN
stPump.rHVEna_SP := rHVEna_SP;
END_IF;
IF ( bAutoRecoverWrite) THEN
stPump.xAutoOn := bAutoRecover;
END_IF;
END_IF
(*Check if a new value has been written in the structure variable copy it to the persistent variable*)
IF NOT (stPump.rHVEna_SP = rHVEna_SP) THEN
rHVEna_SP := stPump.rHVEna_SP;
END_IF;
IF NOT(bAutoRecoverWrite) OR NOT (stPump.xAutoOn = bAutoRecover) THEN
bAutoRecover := stPump.xAutoOn;
bAutoRecoverWrite := TRUE;
END_IF;
stateTimer(PT:=T#10S);
IF (stateTimer.Q) THEN
bWasOn := (stPump.eState = pumpRUNNING);
stateTimer.IN := FALSE;
fbWritePersistentData(NETID:='', PORT:=851, START:=TRUE, TMOUT:=T#1s );
END_IF;]]></ST>
</Implementation>
</Action>
<Action Name="ACT_Recover" Id="{db71f277-6b1a-4048-ba14-ee322ccfb42c}">
<Implementation>
<ST><![CDATA[fbGetCurTaskIdx();
IF (_TaskInfo[fbGetCurTaskIdx.index].FirstCycle) THEN
tRecover.IN := TRUE;
END_IF
tRecover(IN:= , PT:=tRecoverDelay);
IF NOT(bAutoRecoverWrite) OR (tRecover.Q AND bAutoRecover ) THEN
This^.M_Recover();
END_IF]]></ST>
</Implementation>
</Action>
<Action Name="ACT_SetGauge" Id="{7f72f23c-b05a-4919-b11f-c886c11a10b4}">
<Implementation>
<ST><![CDATA[(*MG*)
Expand Down