Skip to content

Commit

Permalink
Merge pull request #67 from C0bit/eps
Browse files Browse the repository at this point in the history
ENH: Add EPS structure for displaying interlock information and logic
  • Loading branch information
ZLLentz authored Mar 1, 2023
2 parents dfc543d + 9b10a87 commit c3ba6eb
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
40 changes: 40 additions & 0 deletions LCLSGeneral/LCLSGeneral/DUTs/DUT_EPS.TcDUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<DUT Name="DUT_EPS" Id="{0134451e-57c2-478a-9365-5d6570cca7b2}">
<Declaration><![CDATA[TYPE DUT_EPS :
STRUCT
// Contains EPS flags
{attribute 'pytmc' := '
pv: nFlags
io: i
field: DESC Contains EPS flags
'}
nFlags: UDINT := 16#FFFFFFFF;
// Desciption of values nFlags contains
{attribute 'pytmc' := '
pv: sFlagDesc
io: i
field: DESC of nFlag variable, using ';' seperated list.
'}
sFlagDesc: STRING;
// Name to use for log messages.
{attribute 'pytmc' := '
pv: sMessage
io: i
field: DESC Message from EPS to usr
'}
sMessage: STRING;
// Keep Track if nFlags are all true
{atribute 'pytmc' := '
pv: bEPS_OK
io: i
field: DESC check if nFlags are all true;
'}
bEPS_OK : BOOL := TRUE;
END_STRUCT
END_TYPE]]></Declaration>
</DUT>
</TcPlcObject>
65 changes: 65 additions & 0 deletions LCLSGeneral/LCLSGeneral/POUs/EPS/FB_EPS.TcPOU
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_EPS" Id="{0c78cf58-96ea-4c52-b0ca-64b7290d1ef9}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_EPS
VAR_IN_OUT
eps : DUT_EPS;
END_VAR
VAR_OUTPUT
END_VAR
VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
<Method Name="setBit" Id="{243035d2-b889-46d7-b89e-610b76586068}">
<Declaration><![CDATA[METHOD setBit : BOOL
VAR_INPUT
nBits : BYTE;
bValue : BOOL;
END_VAR
VAR
nMask : UDINT := 1;
nBitValue : UDINT := 0;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[nMask := SHL(nMask, nBits);
nBitValue := SHR((nMask AND eps.nFlags), nBits);
IF (TO_BOOL(nBitValue)) <> bValue THEN
eps.nFlags := eps.nFlags XOR nMask;
END_IF
// Check if all values are true
IF eps.nFlags = 16#FFFFFFFF THEN
eps.bEPS_OK := TRUE;
ELSE
eps.bEPS_OK := FALSE;
END_IF
]]></ST>
</Implementation>
</Method>
<Method Name="setDescription" Id="{84797ad0-c375-4675-8998-ec2e912fbbdd}">
<Declaration><![CDATA[METHOD setDescription : BOOL
VAR_INPUT
desciption : STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[eps.sFlagDesc := desciption;]]></ST>
</Implementation>
</Method>
<Method Name="setMessage" Id="{50553b5a-8e8e-441f-8a78-c5cb5c67e718}">
<Declaration><![CDATA[METHOD setMessage : BOOL
VAR_INPUT
message : STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[eps.sMessage := message;]]></ST>
</Implementation>
</Method>
</POU>
</TcPlcObject>

0 comments on commit c3ba6eb

Please sign in to comment.