Skip to content

Commit

Permalink
Merge pull request #21 from ghalym/JF
Browse files Browse the repository at this point in the history
FIX: Tranmission Calc
  • Loading branch information
ghalym authored Apr 9, 2024
2 parents ac83734 + 3f85a82 commit 2bf4e9f
Show file tree
Hide file tree
Showing 7 changed files with 49,435 additions and 775 deletions.
6 changes: 3 additions & 3 deletions Arbiter/KFEArbiter/GVLs/GVL.TcGVL
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ END_VAR
VAR_GLOBAL CONSTANT
MAX_FAST_FAULTS : UINT := 100;
//Judgement factor constants (administrative mode)
nBeamIntensity : INT :=5;//mj
MaxDuration : REAL :=12;
//Judgement factor constants (administrative mode)
nBeamIntensity : INT :=5;//mj
MaxDuration : REAL :=12;
END_VAR]]></Declaration>
</GVL>
Expand Down
2 changes: 1 addition & 1 deletion Arbiter/KFEArbiter/KFEArbiter.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<Resolution>LCLS General, 2.8.2 (SLAC)</Resolution>
</PlaceholderResolution>
<PlaceholderResolution Include="PMPS">
<Resolution>PMPS, 3.0.14 (SLAC - LCLS)</Resolution>
<Resolution>PMPS, 3.2.1 (SLAC - LCLS)</Resolution>
</PlaceholderResolution>
<PlaceholderResolution Include="SysDir">
<Resolution>SysDir, 3.5.8.0 (System)</Resolution>
Expand Down
49,638 changes: 49,160 additions & 478 deletions Arbiter/KFEArbiter/KFEArbiter.tmc

Large diffs are not rendered by default.

Binary file modified Arbiter/KFEArbiter/LineIDs.dbg
Binary file not shown.
2 changes: 1 addition & 1 deletion Arbiter/KFEArbiter/POUs/PMPS_Arbiter.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fbPhotonEnergyWatcher(i_stCurrentBeamParams := PMPS_GVL.stCurrentBeamParameters,
fbBeamClassWatcher(i_stCurrentBeamParams := PMPS_GVL.stCurrentBeamParameters,
i_stRequestedBeamParams := PMPS_GVL.stRequestedBeamParameters,
io_fbFFHWO:= GVL.g_FastFaultOutput1,
i_xReset := GVL.AttemptReset);
i_xAutoReset := TRUE);
// Evaluate fast fault vetos
Expand Down
77 changes: 41 additions & 36 deletions Arbiter/KFEArbiter/POUs/P_AT1K0_SL1K0.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -43,71 +43,76 @@ VAR
i_Desc := 'EtherCAT interface watcher, for connection to KFE Gas Att. systems for Transmission requests. Very rare. Make a note, and if it can be reset, go ahead.',
i_TypeCode := 16#5);
bSimApt: BOOL;
// Administrative mode for beam intensity
{attribute 'pytmc' := '
pv: @(PREFIX)IntensityJF
{attribute 'pytmc' := '
pv: @(PREFIX)IntensityJF
'}
nBeamIntensityJF: REAL :=GVL.nBeamIntensity;
{attribute 'pytmc' := '
pv: @(PREFIX)ApplyJF
nBeamIntensityJF: REAL :=GVL.nBeamIntensity;
{attribute 'pytmc' := '
pv: @(PREFIX)ApplyJF
'}
bApplyJF: BOOL:=FALSE;
{attribute 'pytmc' := '
pv: @(PREFIX)CancelJF
bApplyJF: BOOL:=FALSE;
{attribute 'pytmc' := '
pv: @(PREFIX)CancelJF
'}
bCancelJF: BOOL:=FALSE;
{attribute 'pytmc' := '
pv: @(PREFIX)DurationJF
bCancelJF: BOOL:=FALSE;
{attribute 'pytmc' := '
pv: @(PREFIX)DurationJF
'}
rDurationJF: REAL:=GVL.MaxDuration;//hours
{attribute 'pytmc' := '
pv: @(PREFIX)TimeRemainJF
rDurationJF: REAL:=GVL.MaxDuration;//hours
{attribute 'pytmc' := '
pv: @(PREFIX)TimeRemainJF
'}
rTimeRemainJF: REAL:=GVL.MaxDuration;//hours
tDuration:TIME;
tonDuration:TON;
rTimeRemainJF: REAL:=GVL.MaxDuration;//hours
tDuration:TIME;
tonDuration:TON;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[
//Beam intensity factor implemenation
// No diff by zero
IF (nBeamIntensityJF =0) THEN nBeamIntensityJF:=GVL.nBeamIntensity; END_IF
IF (nBeamIntensityJF =0) OR (nBeamIntensityJF > GVL.nBeamIntensity ) THEN nBeamIntensityJF:=GVL.nBeamIntensity; END_IF
//Check it it has expired or is cancelled and reset to defaults
IF(tonDuration.Q OR bCancelJF)
THEN
nBeamIntensityJF:=GVL.nBeamIntensity;
bCancelJF := FALSE;
bApplyJF := FALSE;
THEN
nBeamIntensityJF:=GVL.nBeamIntensity;
bCancelJF := FALSE;
bApplyJF := FALSE;
END_IF
// Maximum duration is 12 hours
rDurationJF := LIMIT(0,rDurationJF,MaxDuration);
//check if it is applied
tDuration:= TO_TIME(rDurationJF*60*60*1000);//to msec
tonDuration(IN:=bApplyJF,PT:=tDuration,ET=>);
rTimeRemainJF:= rDurationJF - (TO_REAL(tonDuration.ET)/60/60/1000);//to hours
//Calculate the new requested transmission
PMPS_GVL.stRequestedBeamParameters.nTran := LIMIT(0,(GVL.nBeamIntensity/nBeamIntensityJF)* PMPS_GVL.stRequestedBeamParameters.nTran,1);
// If interface with plc-kfe-gatt OK carry out exchange
IF i_bWcStateOut_AT1K0 = 0 AND i_bWcStateIn_AT1K0 = 0 AND i_nState_AT1K0 = 8 THEN
// Send request from this arbiter to the gas attenuator
q_nTranToAT1K0Req.nTran := PMPS_GVL.stRequestedBeamParameters.nTran*PMPS_GVL.TRANS_SCALING_FACTOR;
IF (bApplyJF) THEN
q_nTranToAT1K0Req.nTran := LIMIT(0,(GVL.nBeamIntensity/nBeamIntensityJF)*PMPS_GVL.stRequestedBeamParameters.nTran*PMPS_GVL.TRANS_SCALING_FACTOR,1);
ELSE
q_nTranToAT1K0Req.nTran := PMPS_GVL.stRequestedBeamParameters.nTran*PMPS_GVL.TRANS_SCALING_FACTOR;
END_IF
q_nTranToAT1K0Req.xAttOK := 16#FF;
//Update with judgement factor
PMPS_GVL.stCurrentBeamParameters.nTran := i_nTranToAT1K0Stat.nTran *(nBeamIntensityJF/GVL.nBeamIntensity);//REAL_TO_UINT(UINT_TO_REAL(i_nTranToAT1K0Stat.nTran)*0.01);
//Calculate the new requested transmission
IF (bApplyJF) THEN
PMPS_GVL.stCurrentBeamParameters.nTran := i_nTranToAT1K0Stat.nTran *(nBeamIntensityJF/GVL.nBeamIntensity);//REAL_TO_UINT(UINT_TO_REAL(i_nTranToAT1K0Stat.nTran)*0.01);
ELSE
PMPS_GVL.stCurrentBeamParameters.nTran := i_nTranToAT1K0Stat.nTran;//REAL_TO_UINT(UINT_TO_REAL(i_nTranToAT1K0Stat.nTran)*0.01);
END_IF
ffKFEGattConnection.i_xOK := TRUE;
ELSE
Expand Down
Loading

0 comments on commit 2bf4e9f

Please sign in to comment.