Added more components
This commit is contained in:
@@ -1,22 +1,193 @@
|
||||
<?xml version="1.0"?>
|
||||
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4026.16">
|
||||
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4026.19">
|
||||
<DataTypes>
|
||||
<DataType>
|
||||
<Name GUID="{E1AAE90D-A058-4E83-848E-5E87CB5B885D}" PersistentType="true">AnalogOutput</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog output events]]></DisplayName>
|
||||
<EventId>
|
||||
<Name Id="1">ConfigError</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog output {0} config error]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<Hides>
|
||||
<Hide GUID="{3A888A1F-1D4B-4F09-B99F-FC14E1B58E30}"/>
|
||||
</Hides>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name GUID="{DCEFCA06-1F7E-4471-8DA7-9DC894FB4E99}" PersistentType="true">Valve</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Valve event class]]></DisplayName>
|
||||
<EventId>
|
||||
<Name Id="1">DidNotOpen</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Valve {0} did not open]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="2">DidNotClose</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Valve {0} did not close]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="3">AnalogFeedbackOC</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Valve {0} feedback open circuit]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="4">AnalogOutputOC</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Valve {0} setpoint open circuit]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="5">NotInRange</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Valve {0} not in range]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<Hides>
|
||||
<Hide GUID="{0005231C-EDC7-4377-B286-9A5105D3C2EB}"/>
|
||||
</Hides>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name GUID="{36A2600C-A308-4BDA-B005-55AC5B3C5895}" PersistentType="true">AnalogInput</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog input events]]></DisplayName>
|
||||
<EventId>
|
||||
<Name Id="8">ErrorHigh</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog Input {0}: Input Value above error limit ({1})]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="7">WarningHigh</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog Input {0}: Input Value above warning limit ({1})]]></DisplayName>
|
||||
<Severity>Warning</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="6">WarningLow</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog Input {0}: Input Value below warning limit ({1})]]></DisplayName>
|
||||
<Severity>Warning</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="5">ErrorLow</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog Input {0}: Input Value below error limit ({1})]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="4">AIConfigError</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog Input {0} configuration error]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="3">AIShortCircuit</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog Input {0} short circuit]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="2">AICardFailure</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Analog Input {0} card error]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="1">AIOpenCircuit</Name>
|
||||
<DisplayName TxtId=""><![CDATA[{0} input open circuit]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<Hides>
|
||||
<Hide GUID="{24D5EA81-BC3C-4499-A04F-81445682E4A9}"/>
|
||||
<Hide GUID="{B5E40FE5-E6ED-480E-B452-E5D673F2C9BD}"/>
|
||||
</Hides>
|
||||
</DataType>
|
||||
<DataType>
|
||||
<Name GUID="{E8D6DC43-53DC-463C-80A9-82E0F1A7529A}" PersistentType="true">Motor</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Motor events]]></DisplayName>
|
||||
<EventId>
|
||||
<Name Id="3">NotInTarget</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Motor {0} not in target]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="2">RepairSwitchOpen</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Motor {0} repair switch open]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<EventId>
|
||||
<Name Id="1">MCBTripped</Name>
|
||||
<DisplayName TxtId=""><![CDATA[Motor {0} MCB tripped]]></DisplayName>
|
||||
<Severity>Error</Severity>
|
||||
</EventId>
|
||||
<Hides>
|
||||
<Hide GUID="{FA5310CE-0B21-47A3-9FEE-D3DA374C397F}"/>
|
||||
</Hides>
|
||||
</DataType>
|
||||
</DataTypes>
|
||||
<Project ProjectGUID="{775BE4FD-89CE-48D5-8E68-5C84AF95981A}" TargetNetId="5.167.199.178.1.1" Target64Bit="true" ShowHideConfigurations="#x6">
|
||||
<System>
|
||||
<Settings MaxCpus="2"/>
|
||||
<Licenses>
|
||||
<Target>
|
||||
<LicenseDevice DongleHardwareId="2" DongleDevice="#x71010001" DongleLevel="40" DongleSystemId="{5097FB65-8A2A-EFB0-8273-38CF2A98119D}" DongleSerialNumber="000btjb7" DongleCacheLicense="false"/>
|
||||
</Target>
|
||||
</Licenses>
|
||||
<Tasks>
|
||||
<Task Id="3" Priority="20" CycleTime="100000" AmsPort="350" AdtTasks="true">
|
||||
<Name>PlcTask</Name>
|
||||
</Task>
|
||||
</Tasks>
|
||||
<TypeSystem>
|
||||
<AdditionalTmcFile Name="BaseComponents_Events" File="BaseComponents_Events.tmc"/>
|
||||
</TypeSystem>
|
||||
</System>
|
||||
<Plc>
|
||||
<Project GUID="{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}" Name="PLC" PrjFilePath="PLC\PLC.plcproj" TmcFilePath="PLC\PLC.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" CopyTmcToTarget="true" CopyTpyToTarget="false" SymbolicMapping="true">
|
||||
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{AC60CA8B-BF14-DCA6-B7D9-AA4A866C44DE}" TmcPath="PLC\PLC.tmc">
|
||||
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{14654FC1-00FC-CFEC-B890-75F0B5146731}" TmcPath="PLC\PLC.tmc">
|
||||
<Name>PLC Instance</Name>
|
||||
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
|
||||
<Vars VarGrpType="2" AreaNo="1">
|
||||
<Name>PlcTask Outputs</Name>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimeoutTestOpen._fbValveTimeout.xOpenValve</Name>
|
||||
<Comment><![CDATA[ Use xOpenValve for normally closed valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimeoutTestOpen._fbValveTimeout.xCloseValve</Name>
|
||||
<Comment><![CDATA[ Use xCloseValve for normally open valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimeoutTestClose._fbValveTimeout.xOpenValve</Name>
|
||||
<Comment><![CDATA[ Use xOpenValve for normally closed valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimeoutTestClose._fbValveTimeout.xCloseValve</Name>
|
||||
<Comment><![CDATA[ Use xCloseValve for normally open valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimoutTriggerOpen._fbValveTimeout.xOpenValve</Name>
|
||||
<Comment><![CDATA[ Use xOpenValve for normally closed valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimoutTriggerOpen._fbValveTimeout.xCloseValve</Name>
|
||||
<Comment><![CDATA[ Use xCloseValve for normally open valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimoutTriggerClose._fbValveTimeout.xOpenValve</Name>
|
||||
<Comment><![CDATA[ Use xOpenValve for normally closed valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimoutTriggerClose._fbValveTimeout.xCloseValve</Name>
|
||||
<Comment><![CDATA[ Use xCloseValve for normally open valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValveTestHMI._fbValveOC.xOpenValve</Name>
|
||||
<Comment><![CDATA[ Use xOpenValve for normally closed valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValveTestHMI._fbValveOC.xCloseValve</Name>
|
||||
<Comment><![CDATA[ Use xCloseValve for normally open valves]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
</Vars>
|
||||
<Vars VarGrpType="1">
|
||||
<Name>PlcTask Inputs</Name>
|
||||
<Var>
|
||||
@@ -271,6 +442,46 @@
|
||||
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimeoutTestOpen._fbValveTimeout.xOpenFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimeoutTestOpen._fbValveTimeout.xCloseFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimeoutTestClose._fbValveTimeout.xOpenFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimeoutTestClose._fbValveTimeout.xCloseFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimoutTriggerOpen._fbValveTimeout.xOpenFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimoutTriggerOpen._fbValveTimeout.xCloseFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimoutTriggerClose._fbValveTimeout.xOpenFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValve_TimoutTriggerClose._fbValveTimeout.xCloseFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValveTestHMI._fbValveOC.xOpenFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
<Var>
|
||||
<Name>PRG_MAIN._fbValveTestHMI._fbValveOC.xCloseFeedback</Name>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
</Vars>
|
||||
<Contexts>
|
||||
<Context>
|
||||
@@ -289,5 +500,8 @@
|
||||
</Instance>
|
||||
</Project>
|
||||
</Plc>
|
||||
<Io>
|
||||
<Device File="Gerät 1 (EtherCAT).xti" Id="1"/>
|
||||
</Io>
|
||||
</Project>
|
||||
</TcSmProject>
|
||||
|
||||
161
DOC01321154-0000_INVEOR_M EtherCAT.xml
Normal file
161
DOC01321154-0000_INVEOR_M EtherCAT.xml
Normal file
@@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EtherCATInfo Version="1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="EtherCATInfo.xsd">
|
||||
<Vendor>
|
||||
<Id>#x00000337</Id>
|
||||
<Name>Kostal Industrie Elektrik GmbH</Name>
|
||||
<ImageData16x14>424DE6000000000000007600000028000000100000000E000000010004000000000070000000000000000000000000000000000000000000000000008000008000000080800080000000800080008080000080808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0088888888888888888888888888888888FFF666FFFF6666F8FFF6877FF67876FFFFF7F77FFFF67FFFFFF7F768FF6FFFFFFFF7F78FF67FFFFFFFF7FFFF67FFFFFFFFF7F78FF67FFFFFFFF7F766FFF7FFFFFFF7F77F6FFF67FFFFF6877FF67876FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</ImageData16x14>
|
||||
</Vendor>
|
||||
<Descriptions>
|
||||
<Groups>
|
||||
<Group>
|
||||
<Type>drives</Type>
|
||||
<Name LcId="1033">drives</Name>
|
||||
<ImageData16x14>424DE6000000000000007600000028000000100000000E000000010004000000000070000000000000000000000000000000000000000000000000008000008000000080800080000000800080008080000080808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0088888888888888888888888888888888FFF666FFFF6666F8FFF6877FF67876FFFFF7F77FFFF67FFFFFF7F768FF6FFFFFFFF7F78FF67FFFFFFFF7FFFF67FFFFFFFFF7F78FF67FFFFFFFF7F766FFF7FFFFFFF7F77F6FFF67FFFFF6877FF67876FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</ImageData16x14>
|
||||
</Group>
|
||||
</Groups>
|
||||
<Devices>
|
||||
<Device Physics="YY">
|
||||
<Type ProductCode="#x00000003" RevisionNo="#x00000002" UseLrdLwr="1">INVEOR_M</Type>
|
||||
<Name LcId="1033"><![CDATA[INVEOR_M]]></Name>
|
||||
<URL><![CDATA[http://http://www.kostal.com/industrie/de]]></URL>
|
||||
<GroupType>drives</GroupType>
|
||||
<Fmmu>Outputs</Fmmu>
|
||||
<Fmmu>Inputs</Fmmu>
|
||||
<Fmmu>MBoxState</Fmmu>
|
||||
<Sm MinSize="128" MaxSize="128" DefaultSize="128" StartAddress="#x1000" ControlByte="#x36" Enable="1">MBoxOut</Sm>
|
||||
<Sm MinSize="128" MaxSize="128" DefaultSize="128" StartAddress="#x1080" ControlByte="#x32" Enable="1">MBoxIn</Sm>
|
||||
<Sm MinSize="0" MaxSize="256" DefaultSize="200" StartAddress="#x1100" ControlByte="#x74" Enable="1">Outputs</Sm>
|
||||
<Sm MinSize="0" MaxSize="256" DefaultSize="200" StartAddress="#x1400" ControlByte="#x30" Enable="1">Inputs</Sm>
|
||||
<RxPdo Sm="2">
|
||||
<Index>#x1600</Index>
|
||||
<Name>Outputs0</Name>
|
||||
<Entry>
|
||||
<Index>#x2000</Index>
|
||||
<SubIndex>1</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Steuerwort</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x2000</Index>
|
||||
<SubIndex>2</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Sollfrequenz</Name>
|
||||
<DataType>REAL</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x2000</Index>
|
||||
<SubIndex>3</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Digitalausgänge / Relais</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x2000</Index>
|
||||
<SubIndex>4</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Analogausgang 1</Name>
|
||||
<DataType>REAL</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x2000</Index>
|
||||
<SubIndex>5</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Kundenspez.SPS Eingangsgröße 1 (Digital 32Bit)</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x2000</Index>
|
||||
<SubIndex>6</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Kundenspez.SPS Eingangsgröße 1 (Digital 32Bit)</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
</RxPdo>
|
||||
<TxPdo Sm="3">
|
||||
<Index>#x1a00</Index>
|
||||
<Name>Inputs0</Name>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>1</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Statuswort</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>2</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Istfrequenz</Name>
|
||||
<DataType>REAL</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>3</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Motorspannung</Name>
|
||||
<DataType>REAL</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>4</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Motorstrom</Name>
|
||||
<DataType>REAL</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>5</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Netzspannung</Name>
|
||||
<DataType>REAL</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>6</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Frequenzsollwert</Name>
|
||||
<DataType>REAL</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>7</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Digitaleingänge bitcodiert</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>8</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Analogeingang 1</Name>
|
||||
<DataType>REAL</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>9</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Fehlerwort 1</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
<Entry>
|
||||
<Index>#x3000</Index>
|
||||
<SubIndex>10</SubIndex>
|
||||
<BitLen>32</BitLen>
|
||||
<Name>Fehlerwort 2</Name>
|
||||
<DataType>UDINT</DataType>
|
||||
</Entry>
|
||||
</TxPdo>
|
||||
<Mailbox>
|
||||
<CoE SdoInfo="1" PdoUpload="1" CompleteAccess="0"/>
|
||||
<FoE/>
|
||||
</Mailbox>
|
||||
<Eeprom>
|
||||
<ByteSize>65536</ByteSize>
|
||||
<ConfigData>06000188E8030000</ConfigData>
|
||||
</Eeprom>
|
||||
<ImageData16x14>424DE6000000000000007600000028000000100000000E000000010004000000000070000000000000000000000000000000000000000000000000008000008000000080800080000000800080008080000080808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0088888888888888888888888888888888FFF666FFFF6666F8FFF6877FF67876FFFFF7F77FFFF67FFFFFF7F768FF6FFFFFFFF7F78FF67FFFFFFFF7FFFF67FFFFFFFFF7F78FF67FFFFFFFF7F766FFF7FFFFFFF7F77F6FFF67FFFFF6877FF67876FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</ImageData16x14>
|
||||
</Device>
|
||||
</Devices>
|
||||
</Descriptions>
|
||||
</EtherCATInfo>
|
||||
175
PLC/PLC.plcproj
175
PLC/PLC.plcproj
@@ -17,7 +17,6 @@
|
||||
<Implicit_Jitter_Distribution>{173a046e-fc1b-4ea3-9ec8-0d52397c403c}</Implicit_Jitter_Distribution>
|
||||
<LibraryReferences>{c870d3c5-a637-481e-9586-ab8eaa6f8f36}</LibraryReferences>
|
||||
<Released>false</Released>
|
||||
<AllowChecksForLibrary>false</AllowChecksForLibrary>
|
||||
<POUsForPropertyAccessIncluded>false</POUsForPropertyAccessIncluded>
|
||||
<GlobalVersionStructureIncluded>false</GlobalVersionStructureIncluded>
|
||||
</PropertyGroup>
|
||||
@@ -25,31 +24,114 @@
|
||||
<Compile Include="PlcTask.TcTTO">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Analog\FB_AnalogInput.TcPOU">
|
||||
<Compile Include="POUs\Components\Analog\FB_AnalogInput.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Analog\FB_AnalogOutput.TcPOU">
|
||||
<Compile Include="POUs\Components\Analog\FB_AnalogOutput.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Analog\Types\ST_ANALOG_EW_CONFIG.TcDUT">
|
||||
<Compile Include="POUs\Components\Analog\Types\ST_ANALOG_EW_CONFIG.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Analog\Types\ST_ANALOG_EW_DELAYS.TcDUT">
|
||||
<Compile Include="POUs\Components\Analog\Types\ST_ANALOG_EW_DELAYS.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Analog\Types\ST_ANALOG_EW_LEVELS.TcDUT">
|
||||
<Compile Include="POUs\Components\Analog\Types\ST_ANALOG_EW_LEVELS.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Analog\Types\ST_ANALOG_IO_CONFIG.TcDUT">
|
||||
<Compile Include="POUs\Components\Analog\Types\ST_ANALOG_IO_CONFIG.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\EventListener\FB_EventListener.TcPOU">
|
||||
<Compile Include="POUs\Components\EventListener\FB_EventListener.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\EventListener\Types\E_EventType.TcDUT">
|
||||
<Compile Include="POUs\Components\EventListener\Types\E_EventType.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\EventListener\Types\ST_BufferEventEntry.TcDUT">
|
||||
<Compile Include="POUs\Components\EventListener\Types\ST_BufferEventEntry.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Motor\FB_MotorBecker.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Motor\Types\ST_MOTOR_BECKER_CONFIG.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Utilities\FB_AlarmMessage.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Utilities\FB_Blinker.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Utilities\FB_RampGenerator.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Utilities\FB_ReleaseSignal.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Utilities\FC_HashFNV1a_32Bit.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Valves\FB_Valve.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Valves\FB_ValveAnalog.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Valves\Types\ST_ValveAnalogConfig.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Components\Valves\Types\ST_ValveConfig.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Constants\GVL_TYPE_CONST.TcGVL">
|
||||
<SubType>Code</SubType>
|
||||
<LinkAlways>true</LinkAlways>
|
||||
</Compile>
|
||||
<Compile Include="POUs\GVL\GVL_CONFIGS.TcGVL">
|
||||
<SubType>Code</SubType>
|
||||
<LinkAlways>true</LinkAlways>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\ST_HMI_ANALOG_MOTOR_DATA.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\ST_HMI_ANALOG_VALUE.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\ST_HMI_ANALOG_VALVE_DATA.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\ST_HMI_CONTROL_BUTTON.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\ST_HMI_INTEGER_VALUE.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\ST_HMI_INTERLOCK.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\ST_HMI_ORP_SENSOR_DATA.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\ST_HMI_VALVE_DATA.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Datentypen\T_INTERLOCK.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Enum\E_HMI_ANALOG_VALUE_STATUS.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Enum\E_HMI_BUTTON_FEEDBACK.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Enum\E_HMI_MODE.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Enum\E_HMI_MOTOR_STATUS.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\HMI\Enum\E_HMI_VALVE_STATUS.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\PRG_MAIN.TcPOU">
|
||||
@@ -58,24 +140,79 @@
|
||||
<Compile Include="POUs\Unittests\AITests\FB_AnalogInputTest.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Utilities\FB_ReleaseSignal.TcPOU">
|
||||
<Compile Include="POUs\Unittests\AnalogValveTests\FB_ValveAnalog_Test.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\AOTests\FB_AnalogOutputTest.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\ReleaseSignalTests\FB_ReleaseSignalTest.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\UtilitiesTests\FB_BlinkerTest.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\UtilitiesTests\FB_HashFNV1a_32BitTest.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\UtilitiesTests\FB_PT1Test.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\UtilitiesTests\FB_RampGeneratorTest.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\ValveTests\FB_ValveTestHMI.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\ValveTests\FB_ValveTestTimoutClose.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\ValveTests\FB_ValveTestTimoutOpen.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\ValveTests\FB_ValveTestTriggerTimoutClose.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\ValveTests\FB_ValveTestTriggerTimoutOpen.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="POUs\Unittests\ValveTests\FB_Valve_Test.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="DUTs" />
|
||||
<Folder Include="GVLs" />
|
||||
<Folder Include="POUs\Analog" />
|
||||
<Folder Include="POUs\Analog\Types" />
|
||||
<Folder Include="POUs\EventListener" />
|
||||
<Folder Include="POUs\EventListener\Types" />
|
||||
<Folder Include="POUs\Components\Analog" />
|
||||
<Folder Include="POUs\Components\Analog\Types" />
|
||||
<Folder Include="POUs\Components\EventListener" />
|
||||
<Folder Include="POUs\Components\EventListener\Types" />
|
||||
<Folder Include="POUs\Components\Motor" />
|
||||
<Folder Include="POUs\Components\Motor\Types" />
|
||||
<Folder Include="POUs\Components\Utilities" />
|
||||
<Folder Include="POUs\Components\Valves" />
|
||||
<Folder Include="POUs\Components\Valves\Types" />
|
||||
<Folder Include="POUs\Constants" />
|
||||
<Folder Include="POUs\HMI" />
|
||||
<Folder Include="POUs\HMI\Datentypen" />
|
||||
<Folder Include="POUs\HMI\Enum" />
|
||||
<Folder Include="POUs\GVL" />
|
||||
<Folder Include="POUs\Components" />
|
||||
<Folder Include="POUs\Unittests\AnalogValveTests" />
|
||||
<Folder Include="POUs\Unittests\ReleaseSignalTests" />
|
||||
<Folder Include="POUs\Unittests\UtilitiesTests" />
|
||||
<Folder Include="POUs\Unittests\ValveTests" />
|
||||
<Folder Include="POUs\Unittests" />
|
||||
<Folder Include="POUs\Unittests\AITests" />
|
||||
<Folder Include="POUs\Utilities" />
|
||||
<Folder Include="POUs\Unittests\AOTests" />
|
||||
<Folder Include="VISUs" />
|
||||
<Folder Include="POUs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PlaceholderReference Include="Tc2_MC2">
|
||||
<DefaultResolution>Tc2_MC2, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc2_MC2</Namespace>
|
||||
</PlaceholderReference>
|
||||
<PlaceholderReference Include="Tc2_Standard">
|
||||
<DefaultResolution>Tc2_Standard, * (Beckhoff Automation GmbH)</DefaultResolution>
|
||||
<Namespace>Tc2_Standard</Namespace>
|
||||
@@ -2446,9 +2583,9 @@
|
||||
</d>
|
||||
<d n="Values" t="Hashtable" ckt="String">
|
||||
<v>MaxStaticAnalysisErrors</v>
|
||||
<v>500U</v>
|
||||
<v>100U</v>
|
||||
<v>MaxStaticAnalysisWarnings</v>
|
||||
<v>500U</v>
|
||||
<v>100U</v>
|
||||
<v>PerformStaticAnalyse</v>
|
||||
<v>true</v>
|
||||
<v>SuppressedKeywords</v>
|
||||
@@ -2461,7 +2598,7 @@
|
||||
<d n="SubKeys" t="Hashtable" />
|
||||
<d n="Values" t="Hashtable" ckt="String" cvt="String">
|
||||
<v>ActiveVisuProfile</v>
|
||||
<v>IR0whWr8bwfyBwAAaCbC8QAAAABVAgAA1xHl6QAAAAABAAAAAAAAAAEaUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwACTHsAZgA5ADUAYgBiADQAMgA2AC0ANQA1ADIANAAtADQAYgA0ADUALQA5ADQAMAAwAC0AZgBiADAAZgAyAGUANwA3AGUANQAxAGIAfQADCE4AYQBtAGUABDJUAHcAaQBuAEMAQQBUACAAMwAuADEAIABCAHUAaQBsAGQAIAA0ADAAMgA2AC4AMQA1AAUWUAByAG8AZgBpAGwAZQBEAGEAdABhAAZMewAxADYAZQA1ADUAYgA2ADAALQA3ADAANAAzAC0ANABhADYAMwAtAGIANgA1AGIALQA2ADEANAA3ADEAMwA4ADcAOABkADQAMgB9AAcSTABpAGIAcgBhAHIAaQBlAHMACEx7ADMAYgBmAGQANQA0ADUAOQAtAGIAMAA3AGYALQA0AGQANgBlAC0AYQBlADEAYQAtAGEAOAAzADMANQA2AGEANQA1ADEANAAyAH0ACUx7ADkAYwA5ADUAOAA5ADYAOAAtADIAYwA4ADUALQA0ADEAYgBiAC0AOAA4ADcAMQAtADgAOQA1AGYAZgAxAGYAZQBkAGUAMQBhAH0ACg5WAGUAcgBzAGkAbwBuAAsGaQBuAHQADApVAHMAYQBnAGUADQpUAGkAdABsAGUADhpWAGkAcwB1AEUAbABlAG0ATQBlAHQAZQByAA8OQwBvAG0AcABhAG4AeQAQDFMAeQBzAHQAZQBtABESVgBpAHMAdQBFAGwAZQBtAHMAEjBWAGkAcwB1AEUAbABlAG0AcwBTAHAAZQBjAGkAYQBsAEMAbwBuAHQAcgBvAGwAcwATKFYAaQBzAHUARQBsAGUAbQBzAFcAaQBuAEMAbwBuAHQAcgBvAGwAcwAUJFYAaQBzAHUARQBsAGUAbQBUAGUAeAB0AEUAZABpAHQAbwByABUiVgBpAHMAdQBOAGEAdABpAHYAZQBDAG8AbgB0AHIAbwBsABYUVgBpAHMAdQBJAG4AcAB1AHQAcwAXGFYAaQBzAHUARQBsAGUAbQBCAGEAcwBlABgmRABlAHYAUABsAGEAYwBlAGgAbwBsAGQAZQByAHMAVQBzAGUAZAAZCGIAbwBvAGwAGiJQAGwAdQBnAGkAbgBDAG8AbgBzAHQAcgBhAGkAbgB0AHMAG0x7ADQAMwBkADUAMgBiAGMAZQAtADkANAAyAGMALQA0ADQAZAA3AC0AOQBlADkANAAtADEAYgBmAGQAZgAzADEAMABlADYAMwBjAH0AHBxBAHQATABlAGEAcwB0AFYAZQByAHMAaQBvAG4AHRRQAGwAdQBnAGkAbgBHAHUAaQBkAB4WUwB5AHMAdABlAG0ALgBHAHUAaQBkAB9IYQBmAGMAZAA1ADQANAA2AC0ANAA5ADEANAAtADQAZgBlADcALQBiAGIANwA4AC0AOQBiAGYAZgBlAGIANwAwAGYAZAAxADcAIBRVAHAAZABhAHQAZQBJAG4AZgBvACFMewBiADAAMwAzADYANgBhADgALQBiADUAYwAwAC0ANABiADkAYQAtAGEAMAAwAGUALQBlAGIAOAA2ADAAMQAxADEAMAA0AGMAMwB9ACIOVQBwAGQAYQB0AGUAcwAjTHsAMQA4ADYAOABmAGYAYwA5AC0AZQA0AGYAYwAtADQANQAzADIALQBhAGMAMAA2AC0AMQBlADMAOQBiAGIANQA1ADcAYgA2ADkAfQAkTHsAYQA1AGIAZAA0ADgAYwAzAC0AMABkADEANwAtADQAMQBiADUALQBiADEANgA0AC0ANQBmAGMANgBhAGQAMgBiADkANgBiADcAfQAlFk8AYgBqAGUAYwB0AHMAVAB5AHAAZQAmVFUAcABkAGEAdABlAEwAYQBuAGcAdQBhAGcAZQBNAG8AZABlAGwARgBvAHIAQwBvAG4AdgBlAHIAdABpAGIAbABlAEwAaQBiAHIAYQByAGkAZQBzACcQTABpAGIAVABpAHQAbABlACgUTABpAGIAQwBvAG0AcABhAG4AeQApHlUAcABkAGEAdABlAFAAcgBvAHYAaQBkAGUAcgBzACo4UwB5AHMAdABlAG0ALgBDAG8AbABsAGUAYwB0AGkAbwBuAHMALgBIAGEAcwBoAHQAYQBiAGwAZQArEnYAaQBzAHUAZQBsAGUAbQBzACwMcwB5AHMAdABlAG0ALUg2AGMAYgAxAGMAZABlADEALQBkADUAZABjAC0ANABhADMAYgAtADkAMAA1ADQALQAyADEAZgBhADcANQA2AGEAMwBmAGEANAAuKEkAbgB0AGUAcgBmAGEAYwBlAFYAZQByAHMAaQBvAG4ASQBuAGYAbwAvTHsAYwA2ADEAMQBlADQAMAAwAC0ANwBmAGIAOQAtADQAYwAzADUALQBiADkAYQBjAC0ANABlADMAMQA0AGIANQA5ADkANgA0ADMAfQAwGE0AYQBqAG8AcgBWAGUAcgBzAGkAbwBuADEYTQBpAG4AbwByAFYAZQByAHMAaQBvAG4AMgxMAGUAZwBhAGMAeQAzMEwAYQBuAGcAdQBhAGcAZQBNAG8AZABlAGwAVgBlAHIAcwBpAG8AbgBJAG4AZgBvADQwTABvAGEAZABMAGkAYgByAGEAcgBpAGUAcwBJAG4AdABvAFAAcgBvAGoAZQBjAHQANRpDAG8AbQBwAGEAdABpAGIAaQBsAGkAdAB5ANAAAhoD0AMBLQTQBQYaB9AHCBoBRQcJCNAACRoERQoLBAQAAAAHAAAAAAAAAAAAAADQDAutAgAAANANAS0O0A8BLRDQAAkaBEUKCwQEAAAABwAAAAAAAAAAAAAA0AwLrQEAAADQDQEtEdAPAS0Q0AAJGgRFCgsEBAAAAAcAAAAAAAAAAAAAANAMC60CAAAA0A0BLRLQDwEtENAACRoERQoLBAQAAAAHAAAAAAAAAAAAAADQDAutAgAAANANAS0T0A8BLRDQAAkaBEUKCwQEAAAABwAAAAAAAAAAAAAA0AwLrQIAAADQDQEtFNAPAS0Q0AAJGgRFCgsEBAAAAAcAAAAAAAAAAAAAANAMC60CAAAA0A0BLRXQDwEtENAACRoERQoLBAQAAAAHAAAAAAAAAAAAAADQDAutAgAAANANAS0W0A8BLRDQAAkaBEUKCwQEAAAABwAAAAAAAAAAAAAA0AwLrQQAAADQDQEtF9APAS0Q0BgZrQFFGhsB0AAbGgJFHAsEBAAAAAIAAAAAAAAAAAAAANAdHi0f0CAhGgJFIiMC0AAkGgVFCgsEAwAAAAMAAAAAAAAACgAAANAlC60AAAAA0AMBLSbQJwEtEdAoAS0Q0AAkGgVFCgsEAwAAAAMAAAAAAAAACgAAANAlC60BAAAA0AMBLSbQJwEtEdAoAS0QmikqAUUAAQLQAAEtK9AAAS0s0AAeLS3QLi8aA9AwC60BAAAA0DELrSQAAADQMhmtANAzLxoD0DALrQIAAADQMQutBgAAANAyGa0A0DQZrQDQNRmtAA==</v>
|
||||
<v>IR0whWr8bwfyBwAAMxnWswAAAABVAgAADu3eawAAAAABAAAAAAAAAAEaUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwACTHsAZgA5ADUAYgBiADQAMgA2AC0ANQA1ADIANAAtADQAYgA0ADUALQA5ADQAMAAwAC0AZgBiADAAZgAyAGUANwA3AGUANQAxAGIAfQADCE4AYQBtAGUABDJUAHcAaQBuAEMAQQBUACAAMwAuADEAIABCAHUAaQBsAGQAIAA0ADAAMgA2AC4AMQA4AAUWUAByAG8AZgBpAGwAZQBEAGEAdABhAAZMewAxADYAZQA1ADUAYgA2ADAALQA3ADAANAAzAC0ANABhADYAMwAtAGIANgA1AGIALQA2ADEANAA3ADEAMwA4ADcAOABkADQAMgB9AAcSTABpAGIAcgBhAHIAaQBlAHMACEx7ADMAYgBmAGQANQA0ADUAOQAtAGIAMAA3AGYALQA0AGQANgBlAC0AYQBlADEAYQAtAGEAOAAzADMANQA2AGEANQA1ADEANAAyAH0ACUx7ADkAYwA5ADUAOAA5ADYAOAAtADIAYwA4ADUALQA0ADEAYgBiAC0AOAA4ADcAMQAtADgAOQA1AGYAZgAxAGYAZQBkAGUAMQBhAH0ACg5WAGUAcgBzAGkAbwBuAAsGaQBuAHQADApVAHMAYQBnAGUADQpUAGkAdABsAGUADhpWAGkAcwB1AEUAbABlAG0ATQBlAHQAZQByAA8OQwBvAG0AcABhAG4AeQAQDFMAeQBzAHQAZQBtABESVgBpAHMAdQBFAGwAZQBtAHMAEjBWAGkAcwB1AEUAbABlAG0AcwBTAHAAZQBjAGkAYQBsAEMAbwBuAHQAcgBvAGwAcwATKFYAaQBzAHUARQBsAGUAbQBzAFcAaQBuAEMAbwBuAHQAcgBvAGwAcwAUJFYAaQBzAHUARQBsAGUAbQBUAGUAeAB0AEUAZABpAHQAbwByABUiVgBpAHMAdQBOAGEAdABpAHYAZQBDAG8AbgB0AHIAbwBsABYUVgBpAHMAdQBJAG4AcAB1AHQAcwAXGFYAaQBzAHUARQBsAGUAbQBCAGEAcwBlABgmRABlAHYAUABsAGEAYwBlAGgAbwBsAGQAZQByAHMAVQBzAGUAZAAZCGIAbwBvAGwAGiJQAGwAdQBnAGkAbgBDAG8AbgBzAHQAcgBhAGkAbgB0AHMAG0x7ADQAMwBkADUAMgBiAGMAZQAtADkANAAyAGMALQA0ADQAZAA3AC0AOQBlADkANAAtADEAYgBmAGQAZgAzADEAMABlADYAMwBjAH0AHBxBAHQATABlAGEAcwB0AFYAZQByAHMAaQBvAG4AHRRQAGwAdQBnAGkAbgBHAHUAaQBkAB4WUwB5AHMAdABlAG0ALgBHAHUAaQBkAB9IYQBmAGMAZAA1ADQANAA2AC0ANAA5ADEANAAtADQAZgBlADcALQBiAGIANwA4AC0AOQBiAGYAZgBlAGIANwAwAGYAZAAxADcAIBRVAHAAZABhAHQAZQBJAG4AZgBvACFMewBiADAAMwAzADYANgBhADgALQBiADUAYwAwAC0ANABiADkAYQAtAGEAMAAwAGUALQBlAGIAOAA2ADAAMQAxADEAMAA0AGMAMwB9ACIOVQBwAGQAYQB0AGUAcwAjTHsAMQA4ADYAOABmAGYAYwA5AC0AZQA0AGYAYwAtADQANQAzADIALQBhAGMAMAA2AC0AMQBlADMAOQBiAGIANQA1ADcAYgA2ADkAfQAkTHsAYQA1AGIAZAA0ADgAYwAzAC0AMABkADEANwAtADQAMQBiADUALQBiADEANgA0AC0ANQBmAGMANgBhAGQAMgBiADkANgBiADcAfQAlFk8AYgBqAGUAYwB0AHMAVAB5AHAAZQAmVFUAcABkAGEAdABlAEwAYQBuAGcAdQBhAGcAZQBNAG8AZABlAGwARgBvAHIAQwBvAG4AdgBlAHIAdABpAGIAbABlAEwAaQBiAHIAYQByAGkAZQBzACcQTABpAGIAVABpAHQAbABlACgUTABpAGIAQwBvAG0AcABhAG4AeQApHlUAcABkAGEAdABlAFAAcgBvAHYAaQBkAGUAcgBzACo4UwB5AHMAdABlAG0ALgBDAG8AbABsAGUAYwB0AGkAbwBuAHMALgBIAGEAcwBoAHQAYQBiAGwAZQArEnYAaQBzAHUAZQBsAGUAbQBzACwMcwB5AHMAdABlAG0ALUg2AGMAYgAxAGMAZABlADEALQBkADUAZABjAC0ANABhADMAYgAtADkAMAA1ADQALQAyADEAZgBhADcANQA2AGEAMwBmAGEANAAuKEkAbgB0AGUAcgBmAGEAYwBlAFYAZQByAHMAaQBvAG4ASQBuAGYAbwAvTHsAYwA2ADEAMQBlADQAMAAwAC0ANwBmAGIAOQAtADQAYwAzADUALQBiADkAYQBjAC0ANABlADMAMQA0AGIANQA5ADkANgA0ADMAfQAwGE0AYQBqAG8AcgBWAGUAcgBzAGkAbwBuADEYTQBpAG4AbwByAFYAZQByAHMAaQBvAG4AMgxMAGUAZwBhAGMAeQAzMEwAYQBuAGcAdQBhAGcAZQBNAG8AZABlAGwAVgBlAHIAcwBpAG8AbgBJAG4AZgBvADQwTABvAGEAZABMAGkAYgByAGEAcgBpAGUAcwBJAG4AdABvAFAAcgBvAGoAZQBjAHQANRpDAG8AbQBwAGEAdABpAGIAaQBsAGkAdAB5ANAAAhoD0AMBLQTQBQYaB9AHCBoBRQcJCNAACRoERQoLBAQAAAAHAAAAAAAAAAAAAADQDAutAgAAANANAS0O0A8BLRDQAAkaBEUKCwQEAAAACAAAAAAAAAAAAAAA0AwLrQEAAADQDQEtEdAPAS0Q0AAJGgRFCgsEBAAAAAcAAAAAAAAAAAAAANAMC60CAAAA0A0BLRLQDwEtENAACRoERQoLBAQAAAAIAAAAAAAAAAAAAADQDAutAgAAANANAS0T0A8BLRDQAAkaBEUKCwQEAAAACAAAAAAAAAAAAAAA0AwLrQIAAADQDQEtFNAPAS0Q0AAJGgRFCgsEBAAAAAgAAAAAAAAAAAAAANAMC60CAAAA0A0BLRXQDwEtENAACRoERQoLBAQAAAAHAAAAAAAAAAAAAADQDAutAgAAANANAS0W0A8BLRDQAAkaBEUKCwQEAAAACAAAAAAAAAAAAAAA0AwLrQQAAADQDQEtF9APAS0Q0BgZrQFFGhsB0AAbGgJFHAsEBAAAAAIAAAAAAAAAAAAAANAdHi0f0CAhGgJFIiMC0AAkGgVFCgsEAwAAAAMAAAAAAAAACgAAANAlC60AAAAA0AMBLSbQJwEtEdAoAS0Q0AAkGgVFCgsEAwAAAAMAAAAAAAAACgAAANAlC60BAAAA0AMBLSbQJwEtEdAoAS0QmikqAUUAAQLQAAEtK9AAAS0s0AAeLS3QLi8aA9AwC60BAAAA0DELrSQAAADQMhmtANAzLxoD0DALrQIAAADQMQutBgAAANAyGa0A0DQZrQDQNRmtAA==</v>
|
||||
</d>
|
||||
</o>
|
||||
<v>{8A0FB252-96EB-4DCC-A5B4-B4804D05E2D6}</v>
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_AnalogOutput" Id="{5ea9527b-d363-4c01-ba95-f8c298545979}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_AnalogOutput
|
||||
VAR_INPUT
|
||||
// Setpoint
|
||||
rSetpoint : REAL;
|
||||
|
||||
// config data for analog output scaling
|
||||
stScalingConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// Global switch to dissable all errors
|
||||
xReleaseErrors : BOOL := TRUE;
|
||||
|
||||
// Enables or dissables hardware errors
|
||||
xReleaseHardwareErrors : BOOL := TRUE;
|
||||
|
||||
// Input to confirm all errors
|
||||
xConfirmAlarms : BOOL;
|
||||
|
||||
// Input to tell the fb thats ist used inside a unit test
|
||||
// Fb will not throw error messages
|
||||
{attribute 'hide'}
|
||||
xInUnitTestMode : BOOL := FALSE;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
iAnalogValue AT %Q* : INT;
|
||||
|
||||
// Error in function block
|
||||
xError : BOOL;
|
||||
END_VAR
|
||||
VAR
|
||||
// Setpoint
|
||||
_rSetpointInternal : REAL;
|
||||
|
||||
// Name of the function block
|
||||
_sName : STRING;
|
||||
|
||||
// Scaling factor for conversion
|
||||
_rConversionFactor : REAL;
|
||||
|
||||
// Base offset for scaling factor
|
||||
_rBaseOffset : REAL;
|
||||
|
||||
// Temporary calculated analog value
|
||||
_rTempAnalogValue : REAL;
|
||||
|
||||
// Config error
|
||||
_xConfigError : BOOL;
|
||||
|
||||
// Max process value
|
||||
_rPVMax : REAL;
|
||||
|
||||
// Min process value
|
||||
_rPVMin : REAL;
|
||||
|
||||
// Config error alarm
|
||||
_fbAlarmConfigError : FB_TcAlarm;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_AnalogInput" Id="{532e1013-5a2e-43c7-8863-3ad112d7d7e8}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_AnalogInput
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_AnalogInput
|
||||
VAR_INPUT
|
||||
// Analog input value
|
||||
iAnalogValue AT %I* : INT;
|
||||
@@ -86,27 +86,6 @@ VAR
|
||||
// Limits config error
|
||||
_xEWConfigError : BOOL := FALSE;
|
||||
|
||||
// Delayed Signal warning low
|
||||
_fbSignalDelayWarningLow : FB_ReleaseSignal;
|
||||
|
||||
// Delayed Signal warning high
|
||||
_fbSignalDelayWarningHigh : FB_ReleaseSignal;
|
||||
|
||||
// Delayed Signal error low
|
||||
_fbSignalDelayErrorLow : FB_ReleaseSignal;
|
||||
|
||||
// Delayed signal error high
|
||||
_fbSignalDelayErrorHigh : FB_ReleaseSignal;
|
||||
|
||||
// Delayed signal for underrange error
|
||||
_fbSignalDelayUnderrangeError : FB_ReleaseSignal;
|
||||
|
||||
// Delayed signal for overload error
|
||||
_fbSignalDelayOverloadError : FB_ReleaseSignal;
|
||||
|
||||
// Delayed signal for card error
|
||||
_fbSignalDelayCardError : FB_ReleaseSignal;
|
||||
|
||||
// Helper variables used in reset error flag
|
||||
_xAlarmsActive : BOOL;
|
||||
_xInputErrorsActive : BOOL;
|
||||
@@ -137,19 +116,61 @@ VAR
|
||||
_xError : BOOL;
|
||||
|
||||
// Alarm handlers
|
||||
_fbAlarmCardError : FB_TcAlarm;
|
||||
_fbAlarmUnderrange : FB_TcAlarm;
|
||||
_fbAlarmOverload : FB_TcAlarm;
|
||||
_fbAlarmConfigError : FB_TcAlarm;
|
||||
_fbAlarmCardError : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogInput.AICardFailure, xWithConfirmation := TRUE);
|
||||
_fbAlarmUnderrange : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogInput.AIOpenCircuit, xWithConfirmation := TRUE);
|
||||
_fbAlarmOverload : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogInput.AIShortCircuit, xWithConfirmation := TRUE);
|
||||
_fbAlarmConfigError : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogInput.AIConfigError, xWithConfirmation := FALSE);
|
||||
|
||||
_fbAlarmErrorLow : FB_TcAlarm;
|
||||
_fbAlarmWarningLow : FB_TcAlarm;
|
||||
_fbAlarmWarningHigh : FB_TcAlarm;
|
||||
_fbAlarmErrorHigh : FB_TcAlarm;
|
||||
_fbAlarmErrorLow : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogInput.ErrorLow, xWithConfirmation := TRUE);
|
||||
_fbAlarmWarningLow : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogInput.WarningLow, xWithConfirmation := TRUE);
|
||||
_fbAlarmWarningHigh : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogInput.WarningHigh, xWithConfirmation := TRUE);
|
||||
_fbAlarmErrorHigh : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogInput.ErrorHigh, xWithConfirmation := TRUE);
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// =========
|
||||
<ST><![CDATA[// ===============
|
||||
// Handle not used
|
||||
// ===============
|
||||
|
||||
IF (NOT stAnalogIOConfig.xUsed) THEN
|
||||
// Clear all pending alarms if there are any
|
||||
_fbAlarmCardError(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmUnderrange(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmOverload(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmCardError(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmErrorHigh(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmErrorLow(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmWarningHigh(xActive := FALSE, xRelease := FALSE);
|
||||
|
||||
|
||||
// Clear warning flags
|
||||
IF xWarning OR xWarningLow OR xWarningHigh THEN
|
||||
_xWarning := FALSE;
|
||||
_xWarningLow := FALSE;
|
||||
_xWarningHigh := FALSE;
|
||||
|
||||
xWarning := FALSE;
|
||||
xWarningLow := FALSE;
|
||||
xWarningHigh := FALSE;
|
||||
END_IF
|
||||
|
||||
// Clear error flags
|
||||
IF xError OR xErrorLow OR xErrorHigh THEN
|
||||
_xError := FALSE;
|
||||
_xErrorLow := FALSE;
|
||||
_xErrorHigh := FALSE;
|
||||
|
||||
xError := FALSE;
|
||||
xErrorLow := FALSE;
|
||||
xErrorHigh := FALSE;
|
||||
END_IF
|
||||
|
||||
// Dont execute anything anymore
|
||||
RETURN;
|
||||
END_IF
|
||||
|
||||
|
||||
// =========
|
||||
// Prechecks
|
||||
// =========
|
||||
|
||||
@@ -168,21 +189,16 @@ CheckEWLevels();
|
||||
// Config error alarm handling
|
||||
// ===========================
|
||||
|
||||
IF xReleaseErrors AND (_xConfigError OR (_xEWConfigError AND xReleaseLimitErrors)) THEN
|
||||
// Latch error
|
||||
_fbAlarmConfigError(
|
||||
xActive:= _xConfigError OR (_xEWConfigError AND xReleaseLimitErrors),
|
||||
xRelease:= xReleaseErrors,
|
||||
xAcknowledge:= ,
|
||||
timOnDelay:= ,
|
||||
timOffDelay:= ,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
IF _fbAlarmConfigError.Triggered THEN
|
||||
_xError := TRUE;
|
||||
|
||||
// Raise alarm
|
||||
IF (NOT xInUnitTestMode) AND (NOT _fbAlarmConfigError.bRaised) THEN
|
||||
_fbAlarmConfigError.Raise(0);
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
// Clear alarm and confirm
|
||||
// Auto confirm because error can only be cleared
|
||||
// throught user action
|
||||
IF (NOT _xConfigError) AND (NOT _xEWConfigError) AND _fbAlarmConfigError.bRaised THEN
|
||||
_fbAlarmConfigError.Clear(0, TRUE);
|
||||
END_IF
|
||||
|
||||
|
||||
@@ -202,65 +218,37 @@ _rScaledValue := _iClampedAnalogValue * _rConversionFactor + _rBaseOffset;
|
||||
// Underrange alarm handling
|
||||
// =========================
|
||||
|
||||
// Filter underrange error signal
|
||||
_fbSignalDelayUnderrangeError(
|
||||
xSignal:= xUnderrange,
|
||||
_fbAlarmUnderrange(
|
||||
xActive:= xUnderrange,
|
||||
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseHardwareErrors,
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOn,
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff);
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
// Latch error signal
|
||||
IF _fbSignalDelayUnderrangeError.xReleaseSignal THEN
|
||||
IF _fbAlarmUnderrange.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
// Raise alarm
|
||||
IF _fbSignalDelayUnderrangeError.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmUnderrange.bRaised) THEN
|
||||
_fbAlarmUnderrange.Raise(0);
|
||||
END_IF
|
||||
|
||||
// Clear alarm
|
||||
IF (NOT _fbSignalDelayUnderrangeError.xReleaseSignal) AND _fbAlarmUnderrange.bRaised THEN
|
||||
_fbAlarmUnderrange.Clear(0, FALSE);
|
||||
END_IF
|
||||
|
||||
// Confirm alarm
|
||||
IF xConfirmAlarms AND (_fbAlarmUnderrange.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||
_fbAlarmUnderrange.Confirm(0);
|
||||
END_IF
|
||||
|
||||
|
||||
// =========================
|
||||
// Overload alarm handling
|
||||
// =========================
|
||||
|
||||
// Filter overload error signal
|
||||
_fbSignalDelayOverloadError(
|
||||
xSignal:= xOverrange,
|
||||
_fbAlarmOverload(
|
||||
xActive:= xOverrange,
|
||||
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseHardwareErrors,
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOn,
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff);
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
// Latch error signal
|
||||
IF _fbSignalDelayOverloadError.xReleaseSignal THEN
|
||||
IF _fbAlarmOverload.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
// Raise alarm
|
||||
IF _fbSignalDelayOverloadError.xReleaseSignal AND (NOT xInUnitTestMode) AND (_fbAlarmOverload.bRaised) THEN
|
||||
_fbAlarmOverload.Raise(0);
|
||||
END_IF
|
||||
|
||||
// Clear alarm
|
||||
IF (NOT _fbSignalDelayOverloadError.xReleaseSignal) AND _fbAlarmOverload.bRaised THEN
|
||||
_fbAlarmOverload.Clear(0, FALSE);
|
||||
END_IF
|
||||
|
||||
// Confirm alarm
|
||||
IF xConfirmAlarms AND (_fbAlarmOverload.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||
_fbAlarmOverload.Confirm(0);
|
||||
END_IF
|
||||
|
||||
|
||||
// =========================
|
||||
// Card alarm handling
|
||||
@@ -269,153 +257,88 @@ END_IF
|
||||
// Filter overload error signal
|
||||
// EL30xx also sets this if an underrange or overrange error is present,
|
||||
// so we filter this out
|
||||
_fbSignalDelayCardError(
|
||||
xSignal:= xErrorCard AND (NOT xUnderrange) AND (NOT xOverrange),
|
||||
_fbAlarmCardError(
|
||||
xActive:= xErrorCard AND (NOT xUnderrange) AND (NOT xOverrange),
|
||||
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseHardwareErrors,
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOn,
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff);
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
// Latch error signal
|
||||
IF _fbSignalDelayCardError.xReleaseSignal THEN
|
||||
IF _fbAlarmCardError.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
// Raise alarm
|
||||
IF _fbSignalDelayCardError.xReleaseSignal AND (NOT xInUnitTestMode) AND (_fbAlarmCardError.bRaised) THEN
|
||||
_fbAlarmCardError.Raise(0);
|
||||
END_IF
|
||||
|
||||
// Clear alarm
|
||||
IF (NOT _fbSignalDelayCardError.xReleaseSignal) AND _fbAlarmCardError.bRaised THEN
|
||||
_fbAlarmCardError.Clear(0, FALSE);
|
||||
END_IF
|
||||
|
||||
// Confirm alarm
|
||||
IF xConfirmAlarms AND (_fbAlarmCardError.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||
_fbAlarmCardError.Confirm(0);
|
||||
END_IF
|
||||
|
||||
|
||||
// ===========================
|
||||
// Error high alarm handling
|
||||
// ===========================
|
||||
|
||||
_fbSignalDelayErrorHigh(
|
||||
xSignal:= (_rScaledValue >= _rMaxErrorLevel),
|
||||
_fbAlarmErrorHigh(
|
||||
xActive:= (_rScaledValue >= _rMaxErrorLevel),
|
||||
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stAnalogEWConfig.stDelays.timErrorHighOn,
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timErrorHighOff);
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timErrorHighOff,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
_xErrorHigh := _fbSignalDelayErrorHigh.xReleaseSignal;
|
||||
_xErrorHigh := _fbAlarmErrorHigh.Triggered;
|
||||
|
||||
// Latch error
|
||||
IF _xErrorHigh THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
// Raise alarm
|
||||
IF _fbSignalDelayErrorHigh.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmErrorHigh.bRaised) THEN
|
||||
_fbAlarmErrorHigh.Raise(0);
|
||||
END_IF
|
||||
|
||||
// Clear alarm
|
||||
IF (NOT _fbSignalDelayErrorHigh.xReleaseSignal) AND _fbAlarmErrorHigh.bRaised THEN
|
||||
_fbAlarmErrorHigh.Clear(0, FALSE);
|
||||
END_IF
|
||||
|
||||
// Confirm alarm
|
||||
IF xConfirmAlarms AND (_fbAlarmErrorHigh.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||
_fbAlarmErrorHigh.Confirm(0);
|
||||
END_IF
|
||||
|
||||
|
||||
// ===========================
|
||||
// Error low alarm handling
|
||||
// ===========================
|
||||
|
||||
_fbSignalDelayErrorLow(
|
||||
xSignal:= (_rScaledValue <= _rMinErrorLevel),
|
||||
_fbAlarmErrorLow(
|
||||
xActive:= (_rScaledValue <= _rMinErrorLevel),
|
||||
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stAnalogEWConfig.stDelays.timErrorLowOn,
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timErrorLowOff);
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timErrorLowOff,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
_xErrorLow := _fbSignalDelayErrorLow.xReleaseSignal;
|
||||
_xErrorLow := _fbAlarmErrorLow.Triggered;
|
||||
|
||||
// Latch error
|
||||
IF _xErrorLow THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
// Raise alarm
|
||||
IF _fbSignalDelayErrorLow.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmErrorLow.bRaised) THEN
|
||||
_fbAlarmErrorLow.Raise(0);
|
||||
END_IF
|
||||
|
||||
// Clear alarm
|
||||
IF (NOT _fbSignalDelayErrorLow.xReleaseSignal) AND _fbAlarmErrorLow.bRaised THEN
|
||||
_fbAlarmErrorLow.Clear(0, FALSE);
|
||||
END_IF
|
||||
|
||||
// Confirm alarm
|
||||
IF xConfirmAlarms AND (_fbAlarmErrorLow.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||
_fbAlarmErrorLow.Confirm(0);
|
||||
END_IF
|
||||
|
||||
|
||||
// ===========================
|
||||
// Warning high alarm handling
|
||||
// ===========================
|
||||
|
||||
_fbSignalDelayWarningHigh(
|
||||
xSignal:= (_rScaledValue >= _rMaxWarningLevel),
|
||||
_fbAlarmWarningHigh(
|
||||
xActive:= (_rScaledValue >= _rMaxWarningLevel),
|
||||
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stAnalogEWConfig.stDelays.timWarningHighOn,
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timWarningHighOff);
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timWarningHighOff,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
_xWarningHigh := _fbSignalDelayWarningHigh.xReleaseSignal;
|
||||
|
||||
// Raise alarm
|
||||
IF _fbSignalDelayWarningHigh.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmWarningHigh.bRaised) THEN
|
||||
_fbAlarmWarningHigh.Raise(0);
|
||||
END_IF
|
||||
|
||||
// Clear alarm
|
||||
IF (NOT _fbSignalDelayWarningHigh.xReleaseSignal) AND _fbAlarmWarningHigh.bRaised THEN
|
||||
_fbAlarmWarningHigh.Clear(0, FALSE);
|
||||
END_IF
|
||||
|
||||
// Confirm alarm
|
||||
IF xConfirmAlarms AND (_fbAlarmWarningHigh.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||
_fbAlarmWarningHigh.Confirm(0);
|
||||
END_IF
|
||||
_xWarningHigh := _fbAlarmWarningHigh.Triggered;
|
||||
|
||||
|
||||
// ===========================
|
||||
// Warning low alarm handling
|
||||
// ===========================
|
||||
|
||||
_fbSignalDelayWarningLow(
|
||||
xSignal:= (_rScaledValue <= _rMinWarningLevel),
|
||||
_fbAlarmWarningLow(
|
||||
xActive:= (_rScaledValue <= _rMinWarningLevel),
|
||||
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stAnalogEWConfig.stDelays.timWarningLowOn,
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timWarningLowOff);
|
||||
timOffDelay:= stAnalogEWConfig.stDelays.timWarningLowOff,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
_xWarningLow := _fbSignalDelayWarningLow.xReleaseSignal;
|
||||
|
||||
// Raise alarm
|
||||
IF _fbSignalDelayWarningLow.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmWarningLow.bRaised) THEN
|
||||
_fbAlarmWarningLow.Raise(0);
|
||||
END_IF
|
||||
|
||||
// Clear alarm
|
||||
IF (NOT _fbSignalDelayWarningLow.xReleaseSignal) AND _fbAlarmWarningLow.bRaised THEN
|
||||
_fbAlarmWarningLow.Clear(0, FALSE);
|
||||
END_IF
|
||||
|
||||
// Confirm alarm
|
||||
IF xConfirmAlarms AND (_fbAlarmWarningLow.eConfirmationState = TcEventConfirmationState.WaitForConfirmation) THEN
|
||||
_fbAlarmWarningLow.Confirm(0);
|
||||
END_IF
|
||||
_xWarningLow := _fbAlarmWarningLow.Triggered;
|
||||
|
||||
|
||||
// ============
|
||||
@@ -429,16 +352,16 @@ _xWarning := _xWarningLow OR _xWarningHigh;
|
||||
// Reset error flag
|
||||
// ================
|
||||
|
||||
_xAlarmsActive := _fbAlarmConfigError.bActive
|
||||
OR _fbAlarmUnderrange.bActive
|
||||
OR _fbAlarmOverload.bActive
|
||||
OR _fbAlarmCardError.bActive
|
||||
OR _fbAlarmErrorHigh.bActive
|
||||
OR _fbAlarmErrorLow.bActive;
|
||||
_xAlarmsActive := _fbAlarmConfigError.Active
|
||||
OR _fbAlarmUnderrange.Active
|
||||
OR _fbAlarmOverload.Active
|
||||
OR _fbAlarmCardError.Active
|
||||
OR _fbAlarmErrorHigh.Active
|
||||
OR _fbAlarmErrorLow.Active;
|
||||
|
||||
_xInputErrorsActive := _fbSignalDelayUnderrangeError.xReleaseSignal
|
||||
OR _fbSignalDelayOverloadError.xReleaseSignal
|
||||
OR _fbSignalDelayCardError.xReleaseSignal;
|
||||
_xInputErrorsActive := _fbAlarmUnderrange.Triggered
|
||||
OR _fbAlarmOverload.Triggered
|
||||
OR _fbAlarmCardError.Triggered;
|
||||
|
||||
IF xConfirmAlarms AND _xError AND (NOT _xAlarmsActive) AND (NOT _xInputErrorsActive) AND (NOT _xConfigError) THEN
|
||||
_xError := FALSE;
|
||||
@@ -562,10 +485,10 @@ _sTempErrorMax := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rErrorMax), _s
|
||||
|
||||
{analysis -46}
|
||||
// Inser message parameters
|
||||
_fbAlarmErrorLow.ipArguments.Clear().AddString(_sName).AddString(_sTempErrorMin);
|
||||
_fbAlarmWarningLow.ipArguments.Clear().AddString(_sName).AddString(_sTempWarningMin);
|
||||
_fbAlarmWarningHigh.ipArguments.Clear().AddString(_sName).AddString(_sTempWarningMax);
|
||||
_fbAlarmErrorHigh.ipArguments.Clear().AddString(_sName).AddString(_sTempErrorMax);
|
||||
_fbAlarmErrorLow.Arguments.Clear().AddString(_sName).AddString(_sTempErrorMin);
|
||||
_fbAlarmWarningLow.Arguments.Clear().AddString(_sName).AddString(_sTempWarningMin);
|
||||
_fbAlarmWarningHigh.Arguments.Clear().AddString(_sName).AddString(_sTempWarningMax);
|
||||
_fbAlarmErrorHigh.Arguments.Clear().AddString(_sName).AddString(_sTempErrorMax);
|
||||
{analysis +46}]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
@@ -576,10 +499,10 @@ END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[{analysis -46}
|
||||
_fbAlarmCardError.ipArguments.Clear().AddString(_sName);
|
||||
_fbAlarmUnderrange.ipArguments.Clear().AddString(_sName);
|
||||
_fbAlarmOverload.ipArguments.Clear().AddString(_sName);
|
||||
_fbAlarmConfigError.ipArguments.Clear().AddString(_sName);
|
||||
_fbAlarmCardError.Arguments.Clear().AddString(_sName);
|
||||
_fbAlarmUnderrange.Arguments.Clear().AddString(_sName);
|
||||
_fbAlarmOverload.Arguments.Clear().AddString(_sName);
|
||||
_fbAlarmConfigError.Arguments.Clear().AddString(_sName);
|
||||
{analysis +46}]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
@@ -623,7 +546,8 @@ END_VAR
|
||||
<ST><![CDATA[_sName := Name;
|
||||
|
||||
// After a name change, all error messages have to be changed
|
||||
CreateAlarmMSG();]]></ST>
|
||||
CreateAlarmMSG();
|
||||
CreateAlarmLimitsMSG();]]></ST>
|
||||
</Implementation>
|
||||
</Set>
|
||||
</Property>
|
||||
237
PLC/POUs/Components/Analog/FB_AnalogOutput.TcPOU
Normal file
237
PLC/POUs/Components/Analog/FB_AnalogOutput.TcPOU
Normal file
@@ -0,0 +1,237 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_AnalogOutput" Id="{5ea9527b-d363-4c01-ba95-f8c298545979}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_AnalogOutput
|
||||
VAR_INPUT
|
||||
// Setpoint
|
||||
rSetpoint : REAL;
|
||||
|
||||
// config data for analog output scaling
|
||||
stAnalogIOConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// Global switch to dissable all errors
|
||||
xReleaseErrors : BOOL := TRUE;
|
||||
|
||||
// Input to confirm all errors
|
||||
xConfirmAlarms : BOOL;
|
||||
|
||||
// Input to tell the fb thats ist used inside a unit test
|
||||
// Fb will not throw error messages
|
||||
{attribute 'hide'}
|
||||
xInUnitTestMode : BOOL := FALSE;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
iAnalogValue AT %Q* : INT;
|
||||
|
||||
// Error in function block
|
||||
xError : BOOL;
|
||||
END_VAR
|
||||
VAR_IN_OUT
|
||||
// HMI Interface
|
||||
stHMIInterface : ST_HMI_ANALOG_VALUE;
|
||||
END_VAR
|
||||
VAR
|
||||
// Setpoint
|
||||
_rSetpointInternal : REAL;
|
||||
|
||||
// Name of the function block
|
||||
_sName : STRING;
|
||||
|
||||
// Scaling factor for conversion
|
||||
_rConversionFactor : REAL;
|
||||
|
||||
// Base offset for scaling factor
|
||||
_rBaseOffset : REAL;
|
||||
|
||||
// Temporary calculated analog value
|
||||
_rTempAnalogValue : REAL;
|
||||
|
||||
// Config error
|
||||
_xConfigError : BOOL;
|
||||
|
||||
// Max process value
|
||||
_rPVMax : REAL;
|
||||
|
||||
// Min process value
|
||||
_rPVMin : REAL;
|
||||
|
||||
// Config error alarm
|
||||
_fbAlarmConfigError : FB_AlarmMessage(stEventEntry := TC_EVENTS.AnalogOutput.ConfigError, xWithConfirmation := FALSE);
|
||||
|
||||
// Internal error flag
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// ===============
|
||||
// Handle not used
|
||||
// ===============
|
||||
|
||||
IF (NOT stAnalogIOConfig.xUsed) THEN
|
||||
// Clear all pending alarms if there are any
|
||||
_fbAlarmConfigError(xActive := FALSE, xRelease := FALSE);
|
||||
|
||||
IF xError THEN
|
||||
_xError := FALSE;
|
||||
xError := FALSE;
|
||||
END_IF
|
||||
|
||||
// Dont execute anything anymore
|
||||
RETURN;
|
||||
END_IF
|
||||
|
||||
// =========
|
||||
// Prechecks
|
||||
// =========
|
||||
|
||||
// Calculate scaling factors,
|
||||
// scaling will be zero in case
|
||||
// of invalid scaling parameters.
|
||||
CalcScalingFactors();
|
||||
|
||||
|
||||
// ===========================
|
||||
// Config error alarm handling
|
||||
// ===========================
|
||||
|
||||
_fbAlarmConfigError(
|
||||
xActive:= _xConfigError,
|
||||
xRelease:= xReleaseErrors,
|
||||
xAcknowledge:= ,
|
||||
timOnDelay:= ,
|
||||
timOffDelay:= ,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
IF _fbAlarmConfigError.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ========================
|
||||
// Analog value calculation
|
||||
// ========================
|
||||
|
||||
// Clamp analogue input levels
|
||||
_rSetpointInternal := MAX(rSetpoint, _rPVMin);
|
||||
_rSetpointInternal := MIN(_rSetpointInternal, _rPVMax);
|
||||
|
||||
// Calc scaled value
|
||||
_rTempAnalogValue := _rSetpointInternal * _rConversionFactor + _rBaseOffset;
|
||||
iAnalogValue := REAL_TO_INT(_rTempAnalogValue);
|
||||
|
||||
|
||||
// ====================
|
||||
// Handle HMI interface
|
||||
// ====================
|
||||
|
||||
stHMIInterface.xUsed := stAnalogIOConfig.xUsed;
|
||||
stHMIInterface.sUnit := stAnalogIOConfig.sUnit;
|
||||
stHMIInterface.rMin := stAnalogIOConfig.rPVMin;
|
||||
stHMIInterface.rMax := stAnalogIOConfig.rPVMax;
|
||||
|
||||
IF _xError THEN
|
||||
stHMIInterface.iStatus := E_HMI_ANALOG_VALUE_STATUS.ERROR;
|
||||
ELSE
|
||||
stHMIInterface.iStatus := E_HMI_ANALOG_VALUE_STATUS.OK;
|
||||
END_IF
|
||||
|
||||
stHMIInterface.sName := _sName;
|
||||
|
||||
|
||||
// ================
|
||||
// Reset error flag
|
||||
// ================
|
||||
|
||||
IF _xError AND xConfirmAlarms AND (NOT _xConfigError) AND (NOT _fbAlarmConfigError.Triggered) THEN
|
||||
_xError := FALSE;
|
||||
END_IF
|
||||
|
||||
|
||||
// Copy internal signals to outputs
|
||||
xError := _xError;]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="CalcScalingFactors" Id="{7d8169fd-cf9b-4df6-b6f9-6740616693c1}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE CalcScalingFactors : BOOL
|
||||
VAR
|
||||
_rNum : REAL;
|
||||
_rDenom : REAL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// _lrConversionFactor := (udiAIMax - udiAIMin)/(rPVMax - rPVMin) + udiAIMin
|
||||
// Splitted in two calculations to catch division by zero
|
||||
_rNum := INT_TO_REAL(stAnalogIOConfig.iAIMax - stAnalogIOConfig.iAIMin);
|
||||
_rDenom := (stAnalogIOConfig.rPVMax - stAnalogIOConfig.rPVMin);
|
||||
|
||||
// Do not divide by 0 or a negative number
|
||||
IF _rDenom > 0.0 THEN
|
||||
_rConversionFactor := _rNum/_rDenom;
|
||||
_rBaseOffset := INT_TO_REAL(stAnalogIOConfig.iAIMin) - (_rConversionFactor * stAnalogIOConfig.rPVMin);
|
||||
_rPVMax := stAnalogIOConfig.rPVMax;
|
||||
_rPVMin := stAnalogIOConfig.rPVMin;
|
||||
_xConfigError := FALSE;
|
||||
ELSE
|
||||
// Division by zero happened
|
||||
// Or denom was negative
|
||||
// Set scaling to zero
|
||||
_rConversionFactor := 0.0;
|
||||
_rBaseOffset := 0.0;
|
||||
_rPVMax := 0.0;
|
||||
_rPVMin := 0.0;
|
||||
_xConfigError := TRUE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="CreateAlarmMSG" Id="{874f5254-0ec6-4c5e-a9a6-0292ac71a964}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE CreateAlarmMSG
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[{analysis -46}
|
||||
_fbAlarmConfigError.Arguments.Clear().AddString(_sName);
|
||||
{analysis +46}]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="FB_init" Id="{0b8b8fc1-2085-4a85-a9d5-deae06fafe01}">
|
||||
<Declaration><![CDATA[//FB_Init ist immer implizit verfügbar und wird primär für die Initialisierung verwendet.
|
||||
//Der Rückgabewert wird nicht ausgewertet. Für gezielte Einflussnahme können Sie
|
||||
//die Methoden explizit deklarieren und darin mit dem Standard-Initialisierungscode
|
||||
//zusätzlichen Code bereitstellen. Sie können den Rückgabewert auswerten.
|
||||
METHOD FB_Init: BOOL
|
||||
VAR_INPUT
|
||||
bInitRetains: BOOL; // TRUE: Die Retain-Variablen werden initialisiert (Reset warm / Reset kalt)
|
||||
bInCopyCode: BOOL; // TRUE: Die Instanz wird danach in den Kopiercode kopiert (Online-Change)
|
||||
|
||||
sName : STRING;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_sName := sName;
|
||||
|
||||
CreateAlarmMSG();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Property Name="Name" Id="{33bc699d-7760-4934-8e7d-cd24d62ae4d2}">
|
||||
<Declaration><![CDATA[PROPERTY Name : STRING(80)]]></Declaration>
|
||||
<Get Name="Get" Id="{21d4b695-16bc-443c-9b7e-27e6c5e1de73}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Name := _sName;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
<Set Name="Set" Id="{c423a761-157c-4651-9a9a-3e5b0e891e86}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_sName := Name;
|
||||
|
||||
// After a name change, all error messages have to be changed
|
||||
CreateAlarmMSG();]]></ST>
|
||||
</Implementation>
|
||||
</Set>
|
||||
</Property>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
497
PLC/POUs/Components/Motor/FB_MotorBecker.TcPOU
Normal file
497
PLC/POUs/Components/Motor/FB_MotorBecker.TcPOU
Normal file
@@ -0,0 +1,497 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_MotorBecker" Id="{6ad1d5ad-7633-46cc-9d09-24bf8179e070}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_MotorBecker
|
||||
VAR_INPUT
|
||||
// Start motor from automatic
|
||||
xAutomaticStart : BOOL;
|
||||
|
||||
// Automatic setpoint
|
||||
rSPAutomatic : REAL;
|
||||
|
||||
// Analog motor config data
|
||||
stMotorConfig : ST_MOTOR_BECKER_CONFIG;
|
||||
|
||||
// Inverter statusword
|
||||
udiStatusword AT %I* : UDINT;
|
||||
|
||||
// Motor speed process value
|
||||
rProcessValue AT %I* : REAL;
|
||||
|
||||
// Errorword 1
|
||||
udiErrorword1 AT %I* : UDINT;
|
||||
|
||||
// Errorword 2
|
||||
udiErrorword2 AT %I* : UDINT;
|
||||
|
||||
// Release or block change to manual mode
|
||||
xReleaseManualMode : BOOL;
|
||||
|
||||
// Process interlocks
|
||||
wProcessINTLK : T_INTERLOCK;
|
||||
|
||||
// Used process interlocks
|
||||
wProcessINTLKUsed: T_INTERLOCK;
|
||||
|
||||
// Safety interlocks
|
||||
wSafetyINTLK : T_INTERLOCK;
|
||||
|
||||
// Used safety interlocks
|
||||
wSafetyINTLKUsed: T_INTERLOCK;
|
||||
|
||||
// Motor circuit breaker ok
|
||||
xMCBOk AT %I* : BOOL;
|
||||
|
||||
// Repair switch ok
|
||||
xRepairSwitchOk AT %I* : BOOL;
|
||||
|
||||
// Global switch to dissable all errors
|
||||
xReleaseErrors : BOOL := TRUE;
|
||||
|
||||
// Input to confirm all errors
|
||||
xConfirmAlarms : BOOL;
|
||||
|
||||
// Input to tell the fb thats ist used inside a unit test
|
||||
// FB will not throw error messages
|
||||
{attribute 'hide'}
|
||||
xInUnitTestMode : BOOL := FALSE;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
// Controlword
|
||||
udiControlword AT %Q* : UDINT;
|
||||
|
||||
// Motor frequency setpoint
|
||||
rMotorFrequency AT %Q* : REAL;
|
||||
|
||||
// Motor in target speed
|
||||
xInTarget : BOOL;
|
||||
|
||||
// Warning output
|
||||
xWarning : BOOL;
|
||||
|
||||
// Error output
|
||||
xError : BOOL;
|
||||
END_VAR
|
||||
VAR_IN_OUT
|
||||
stHMIInterface : ST_HMI_ANALOG_MOTOR_DATA;
|
||||
END_VAR
|
||||
VAR
|
||||
// Internal command for manual mode start request
|
||||
_xManualStart : BOOL := FALSE;
|
||||
|
||||
// Manual mode active
|
||||
_xManualModeActive : BOOL := FALSE;
|
||||
|
||||
// Automatic mode active
|
||||
_xAutomaticModeActive : BOOL := TRUE;
|
||||
|
||||
// Internal start command
|
||||
_xStart : BOOL;
|
||||
|
||||
// Internal setpoint
|
||||
_rSetpoint : REAL;
|
||||
|
||||
// Setpoint from ramp generator in target range
|
||||
_xRampGenInTarget : BOOL;
|
||||
|
||||
// Calculated allowed window for process value
|
||||
_rPVTargetMax : REAL;
|
||||
_rPVTargetMin : REAL;
|
||||
|
||||
// Ramp generator for start and stop ramp
|
||||
_fbRamp : FB_RampGenerator;
|
||||
|
||||
// Motor MCB tripped
|
||||
_xMCBTripped : BOOL;
|
||||
|
||||
// Motor repair switch tripped
|
||||
_xRepairSwitchOpenLatched : BOOL;
|
||||
|
||||
// Sum of all activated process interlocks latched
|
||||
_xSafetyINTLKOk : BOOL;
|
||||
|
||||
// Sum of all activated process interlocks
|
||||
_xProcessINTLKOk : BOOL;
|
||||
|
||||
// Motor running internal state
|
||||
_xMotorRunning : BOOL;
|
||||
|
||||
// Motor stopped internal state
|
||||
_xMotorStopped : BOOL;
|
||||
|
||||
// Alarm handler for MCB tripped
|
||||
_fbAlarmMCBTripped : FB_TcAlarm;
|
||||
_fbMCBTrippedDelayedSignal : FB_ReleaseSignal;
|
||||
|
||||
// Alarm handler for repair switch not closed
|
||||
_fbAlarmRepairSwitchOpen : FB_TcAlarm;
|
||||
|
||||
// Error handlers
|
||||
_fbAlarmNotInTarget : FB_TcAlarm;
|
||||
_fbNotInRange : FB_ReleaseSignal;
|
||||
|
||||
// Helper for statusword
|
||||
_dwStatusword : DWORD;
|
||||
|
||||
// Helper for control word
|
||||
_dwControlword : DWORD;
|
||||
|
||||
// Motor error active
|
||||
_xError : BOOL;
|
||||
|
||||
// Name of the motor
|
||||
_sName : STRING;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// ===============
|
||||
// Handle not used
|
||||
// ===============
|
||||
|
||||
IF (NOT stMotorConfig.xUsed) THEN
|
||||
// Clear all pending alarms if there are any
|
||||
IF _fbAlarmMCBTripped.bRaised THEN
|
||||
_fbAlarmMCBTripped.Clear(0, TRUE);
|
||||
END_IF
|
||||
|
||||
IF _fbAlarmRepairSwitchOpen.bRaised THEN
|
||||
_fbAlarmRepairSwitchOpen.Clear(0, TRUE);
|
||||
END_IF
|
||||
|
||||
IF _fbAlarmNotInTarget.bRaised THEN
|
||||
_fbAlarmNotInTarget.Clear(0, TRUE);
|
||||
END_IF
|
||||
|
||||
RETURN;
|
||||
END_IF
|
||||
|
||||
// ===========================
|
||||
// Reset safetyinterlocks flag
|
||||
// ===========================
|
||||
|
||||
IF xConfirmAlarms AND (NOT _xSafetyINTLKOk) THEN
|
||||
_xSafetyINTLKOk := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// Check interlocks
|
||||
CheckInterlocks();
|
||||
|
||||
// =================
|
||||
// Handle HMI inputs
|
||||
// =================
|
||||
|
||||
HandleHMIInput();
|
||||
|
||||
|
||||
// ==============================
|
||||
// Check if all interlocks are ok
|
||||
// ==============================
|
||||
|
||||
// Only reset manual command if safetyinterlocks are not ok
|
||||
IF (NOT _xSafetyINTLKOk) AND _xManualStart THEN
|
||||
// Also reset manual open command if safetyinterlocks are set
|
||||
_xManualStart := FALSE;
|
||||
END_IF
|
||||
|
||||
|
||||
// =====================================
|
||||
// Handle starting and stopping of motor
|
||||
// =====================================
|
||||
|
||||
_xStart := _xProcessINTLKOk AND _xSafetyINTLKOk AND ((_xManualStart AND _xManualModeActive AND (NOT _xAutomaticModeActive)) OR ( xAutomaticStart AND _xAutomaticModeActive AND (NOT _xManualModeActive)));
|
||||
|
||||
IF _xStart THEN
|
||||
IF _xManualModeActive AND (NOT _xAutomaticModeActive) THEN
|
||||
_rSetpoint := stHMIInterface.stSetpoint.rValue;
|
||||
ELSIF _xAutomaticModeActive AND (NOT _xManualModeActive) THEN
|
||||
_rSetpoint := rSPAutomatic;
|
||||
ELSE
|
||||
_rSetpoint := 0.0;
|
||||
END_IF
|
||||
ELSE
|
||||
_rSetpoint := 0.0;
|
||||
END_IF
|
||||
|
||||
// Clamp setpoint
|
||||
_rSetpoint := MAX(stMotorConfig.rTargetMin, _rSetpoint);
|
||||
_rSetpoint := MIN(stMotorConfig.rTargetMax, _rSetpoint);
|
||||
|
||||
|
||||
// Start stop motor
|
||||
IF _xStart THEN
|
||||
// Enable 1
|
||||
_dwControlword.0 := 1;
|
||||
// Enable PWM (austrudeln)
|
||||
_dwControlword.1 := 1;
|
||||
// Disable fast stop
|
||||
_dwControlword.2 := 1;
|
||||
// Seems to be the same as bit 1 and 2
|
||||
_dwControlword.3 := 1;
|
||||
_dwControlword.4 := 1;
|
||||
// Release setpoint
|
||||
_dwControlword.6 := 1;
|
||||
// Control via ethercat
|
||||
_dwControlword.10 := 1;
|
||||
ELSE
|
||||
// Enable 1
|
||||
_dwControlword.0 := 0;
|
||||
// Enable PWM (austrudeln)
|
||||
_dwControlword.1 := 1;
|
||||
// Disable fast stop
|
||||
_dwControlword.2 := 1;
|
||||
// Seems to be the same as bit 1 and 2
|
||||
_dwControlword.3 := 1;
|
||||
_dwControlword.4 := 1;
|
||||
// Release setpoint
|
||||
_dwControlword.6 := 0;
|
||||
// Control via ethercat
|
||||
_dwControlword.10 := 1;
|
||||
END_IF
|
||||
|
||||
_dwStatusword := UDINT_TO_DWORD(udiControlword);
|
||||
|
||||
// Wait for frequency converter to be enabled when we should start the motor
|
||||
// before starting the ramp
|
||||
IF _dwStatusword.0 // Ready to switch on
|
||||
AND _dwStatusword.1 // Ready for operation
|
||||
AND _dwStatusword.2 // Operational
|
||||
AND _dwStatusword.4 // No off 2
|
||||
AND _dwStatusword.5 // No off 3
|
||||
AND (NOT _dwStatusword.6) // PWM blocked
|
||||
AND (NOT _dwStatusword.3) THEN // No error active
|
||||
|
||||
|
||||
END_IF
|
||||
|
||||
_fbRamp(
|
||||
rTarget:= _rSetpoint,
|
||||
rTargetMin:= stMotorConfig.rTargetMin,
|
||||
rTargetMax:= stMotorConfig.rTargetMax,
|
||||
timRampUp:= stMotorConfig.timRampUpTime,
|
||||
timRampDown:= stMotorConfig.timRampDownTime,
|
||||
rSetpoint=> _rSetpoint,
|
||||
xInTarget=> _xRampGenInTarget);
|
||||
|
||||
// Calculate target tolerance
|
||||
_rPVTargetMax := _rSetpoint + stMotorConfig.rTargetTolerance;
|
||||
_rPVTargetMin := _rSetpoint - stMotorConfig.rTargetTolerance;
|
||||
|
||||
|
||||
// =============
|
||||
// Handle alarms
|
||||
// =============
|
||||
|
||||
_fbMCBTrippedDelayedSignal(
|
||||
xSignal:= (NOT xMCBOk),
|
||||
xRelease:= stMotorConfig.xHasMCBFeedback AND xReleaseErrors,
|
||||
timOnDelay:= ,
|
||||
timOffDelay:= ,
|
||||
xReleaseSignal=> );
|
||||
|
||||
|
||||
// ================
|
||||
// Reset error flag
|
||||
// ================
|
||||
|
||||
|
||||
// ================================
|
||||
// Copy internal signals to outputs
|
||||
// ================================
|
||||
|
||||
udiControlword := DWORD_TO_UDINT(_dwControlword);
|
||||
xError := _xError;
|
||||
|
||||
// ==================
|
||||
// Handle HMI outputs
|
||||
// ==================]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="CheckInterlocks" Id="{df278299-6ae1-4de0-a0dd-2a6c6fe155af}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE FINAL CheckInterlocks
|
||||
VAR
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Set interlocks ok
|
||||
_xProcessINTLKOk := TRUE;
|
||||
|
||||
// Check if all active interlocks are ok
|
||||
IF ((wProcessINTLK AND wProcessINTLKUsed) XOR wProcessINTLKUsed) > 0 THEN
|
||||
_xProcessINTLKOk := FALSE;
|
||||
END_IF
|
||||
|
||||
// Check safety interlocks
|
||||
// Safety interlocks will not automatically reset
|
||||
// They need to be reset via the xConfirmAlarms input
|
||||
IF ((wSafetyINTLK AND wSafetyINTLKUsed) XOR wSafetyINTLKUsed) > 0 THEN
|
||||
_xSafetyINTLKOk := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="CreateAlarmMSG" Id="{51bd55f4-6ff2-43af-9b06-6b00c317590c}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE CreateAlarmMSG
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Reset MCB tripped parameter
|
||||
_fbAlarmMCBTripped.ipArguments.Clear().AddString(_sName);
|
||||
|
||||
// Reset Repair switch open parameter
|
||||
_fbAlarmRepairSwitchOpen.ipArguments.Clear().AddString(_sName);
|
||||
_fbAlarmNotInTarget.ipArguments.Clear().AddString(_sName);
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="FB_init" Id="{f631cde4-5e68-41ff-9cf4-981cfb26ac03}">
|
||||
<Declaration><![CDATA[METHOD FB_init : BOOL
|
||||
VAR_INPUT
|
||||
bInitRetains : BOOL; // if TRUE, the retain variables are initialized (warm start / cold start)
|
||||
bInCopyCode : BOOL; // if TRUE, the instance afterwards gets moved into the copy code (online change)
|
||||
|
||||
sName : STRING;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Name of the function block
|
||||
_sName := sName;
|
||||
|
||||
// Create MCB tripped error
|
||||
_fbAlarmMCBTripped.CreateEx(stEventEntry := TC_EVENTS.Motor.MCBTripped, TRUE, 0);
|
||||
|
||||
// Create repair switch error
|
||||
_fbAlarmRepairSwitchOpen.CreateEx(stEventEntry := TC_EVENTS.Motor.RepairSwitchOpen, TRUE, 0);
|
||||
|
||||
// Create not in target range alarm message
|
||||
_fbAlarmNotInTarget.CreateEx(stEventEntry := TC_EVENTS.Motor.NotInTarget, bWithConfirmation := TRUE, 0);
|
||||
|
||||
// Create alarm messages
|
||||
CreateAlarmMSG();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="HandleHMIInput" Id="{faa08927-4f54-4ff8-952d-185a586720f8}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE HandleHMIInput
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[{warning disable C0371}
|
||||
// Handle automatic mode request
|
||||
IF stHMIInterface.stAutomaticButton.xRequest AND (NOT _xAutomaticModeActive) THEN
|
||||
_xAutomaticModeActive := TRUE;
|
||||
_xManualModeActive := FALSE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stAutomaticButton.xRequest THEN
|
||||
stHMIInterface.stAutomaticButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle manual mode request
|
||||
IF stHMIInterface.stManualButton.xRequest AND (NOT _xManualModeActive) AND xReleaseManualMode THEN
|
||||
_xAutomaticModeActive := FALSE;
|
||||
_xManualModeActive := TRUE;
|
||||
|
||||
// Copy last requested valve state into manual
|
||||
_xManualStart := xAutomaticStart;
|
||||
stHMIInterface.stSetpoint.rValue := rSPautomatic;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stManualButton.xRequest THEN
|
||||
stHMIInterface.stManualButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle start request
|
||||
IF stHMIInterface.stStartButton.xRequest AND _xManualModeActive AND _xProcessINTLKOk AND _xSafetyINTLKOk THEN
|
||||
_xManualStart := TRUE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stStartButton.xRequest THEN
|
||||
stHMIInterface.stStartButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle stop request
|
||||
IF stHMIInterface.stStopButton.xRequest AND _xManualModeActive THEN
|
||||
_xManualStart := FALSE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stStopButton.xRequest THEN
|
||||
stHMIInterface.stStopButton.xRequest := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="HandleHMIOutputs" Id="{94e6a928-a0fe-415b-a749-82ef7bb664cb}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE HandleHMIOutputs
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Copy setpoint min max
|
||||
stHMIInterface.stSetpoint.rMin := stMotorConfig.rTargetMin;
|
||||
stHMIInterface.stSetpoint.rMax := stMotorConfig.rTargetMax;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Property Name="Name" Id="{df07aafd-aaef-4848-9ad0-67f926a1c07c}">
|
||||
<Declaration><![CDATA[{attribute 'analysis' := '-23'}
|
||||
PROPERTY Name : STRING]]></Declaration>
|
||||
<Get Name="Get" Id="{bad90e91-d5f6-49f1-bb66-233ae84af444}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Name := _sName;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
<Set Name="Set" Id="{995fbf14-9a6c-4644-8204-b1aafcfead5f}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_sName := Name;
|
||||
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Set>
|
||||
</Property>
|
||||
<Property Name="ProcessInterlocksOK" Id="{666a9de5-5207-4562-a6d4-843121e8555a}">
|
||||
<Declaration><![CDATA[PROPERTY ProcessInterlocksOK : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{b4c317e2-b02e-4348-87b1-407f40fbb27b}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[ProcessInterlocksOK := _xProcessINTLKOk;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Method Name="ReqAutomaticMode" Id="{7c1e32af-c936-48bc-92a2-a5719444ed8b}">
|
||||
<Declaration><![CDATA[METHOD ReqAutomaticMode
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_xAutomaticModeActive := TRUE;
|
||||
_xManualModeActive := FALSE;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="ReqManualMode" Id="{9b47097e-7518-44f6-8350-29161ed7891b}">
|
||||
<Declaration><![CDATA[METHOD ReqManualMode
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IF xReleaseManualMode THEN
|
||||
_xManualModeActive := TRUE;
|
||||
_xAutomaticModeActive := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Property Name="SafetyInterlocksOK" Id="{197ebc7f-6847-4ed2-abf6-761b78adf519}">
|
||||
<Declaration><![CDATA[{attribute 'analysis' := '-31'}
|
||||
PROPERTY SafetyInterlocksOK : BOOL]]></Declaration>
|
||||
<Get Name="Get" Id="{b8f43bb8-2d37-40c1-b6a0-879caa30f816}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[SafetyInterlocksOK := _xSafetyINTLKOk;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
50
PLC/POUs/Components/Motor/Types/ST_MOTOR_BECKER_CONFIG.TcDUT
Normal file
50
PLC/POUs/Components/Motor/Types/ST_MOTOR_BECKER_CONFIG.TcDUT
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_MOTOR_BECKER_CONFIG" Id="{4a385713-810a-4687-90a2-0bc7d0a40c62}">
|
||||
<Declaration><![CDATA[TYPE ST_MOTOR_BECKER_CONFIG :
|
||||
STRUCT
|
||||
// Minimum speed
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
rTargetMin : REAL := 0.0;
|
||||
|
||||
// Maximum speed
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
rTargetMax : REAL := 100.0;
|
||||
|
||||
// Maximum allowable difference between setpoint and process value
|
||||
// Defaults to +-5 units
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
rTargetTolerance : REAL := 5.0;
|
||||
|
||||
// Minimum process value when the motor should be seen as running
|
||||
// Defaults to 1 unit
|
||||
rPVMotorStopped : REAL := 1.0;
|
||||
|
||||
// Time for the valve to get to the requested setpoint
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
timNotInRange : TIME := T#30S;
|
||||
|
||||
// Startup time from 0% - 100%
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
timRampUpTime : TIME;
|
||||
|
||||
// Stop time from 100% - 0%
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
timRampDownTime : TIME;
|
||||
|
||||
// Has motor circuit breaker feedback signal
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xHasMCBFeedback : BOOL;
|
||||
|
||||
// Has repair switch feedback signal
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xHasRepairSwitchFeedback : BOOL;
|
||||
|
||||
// Motor is used
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
106
PLC/POUs/Components/Utilities/FB_AlarmMessage.TcPOU
Normal file
106
PLC/POUs/Components/Utilities/FB_AlarmMessage.TcPOU
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_AlarmMessage" Id="{4e628f13-10b9-47d9-8d26-ceb4bcb9bf43}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_AlarmMessage
|
||||
VAR_INPUT
|
||||
xActive : BOOL;
|
||||
xRelease : BOOL;
|
||||
xAcknowledge : BOOL;
|
||||
timOnDelay : TIME := T#0S;
|
||||
timOffDelay : TIME := T#0S;
|
||||
xInUnitTestMode : BOOL := FALSE;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
END_VAR
|
||||
VAR
|
||||
_fbReleaseAlarm : FB_ReleaseSignal;
|
||||
_fbAlarmMessage : FB_TcAlarm;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Filter alarm signal
|
||||
_fbReleaseAlarm(
|
||||
xSignal:= xActive,
|
||||
xRelease:= xRelease,
|
||||
timOnDelay:= timOnDelay,
|
||||
timOffDelay:= timOffDelay);
|
||||
|
||||
// Raise alarm
|
||||
IF _fbReleaseAlarm.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmMessage.bRaised) THEN
|
||||
_fbAlarmMessage.Raise(0);
|
||||
END_IF
|
||||
|
||||
// Clear alarm
|
||||
IF ((NOT _fbReleaseAlarm.xReleaseSignal) OR (NOT xRelease)) AND (_fbAlarmMessage.bRaised) THEN
|
||||
_fbAlarmMessage.Clear(0, FALSE);
|
||||
END_IF
|
||||
|
||||
// Confirm alarm
|
||||
IF _fbAlarmMessage.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND (xAcknowledge OR (NOT xRelease)) THEN
|
||||
_fbAlarmMessage.Confirm(0);
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
<Property Name="Active" Id="{4e7fa79e-e44f-42ff-ab45-0e14a9921a12}">
|
||||
<Declaration><![CDATA[PROPERTY Active : BOOL]]></Declaration>
|
||||
<Get Name="Get" Id="{70df159d-fc9d-44c5-ae42-7d731a5dae12}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Active := _fbAlarmMessage.bActive;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="Arguments" Id="{f40c819a-ad71-4e81-830e-67d02b4e9e2f}">
|
||||
<Declaration><![CDATA[PROPERTY PUBLIC Arguments : I_TcArguments]]></Declaration>
|
||||
<Get Name="Get" Id="{c1b8ca1b-cb6c-4841-8282-61423914cb4e}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Arguments := _fbAlarmMessage.ipArguments;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Method Name="FB_init" Id="{59e606ca-879e-463e-9089-6aa9e1011af6}">
|
||||
<Declaration><![CDATA[//FB_Init ist immer implizit verfügbar und wird primär für die Initialisierung verwendet.
|
||||
//Der Rückgabewert wird nicht ausgewertet. Für gezielte Einflussnahme können Sie
|
||||
//die Methoden explizit deklarieren und darin mit dem Standard-Initialisierungscode
|
||||
//zusätzlichen Code bereitstellen. Sie können den Rückgabewert auswerten.
|
||||
METHOD FB_Init: BOOL
|
||||
VAR_INPUT
|
||||
bInitRetains: BOOL; // TRUE: Die Retain-Variablen werden initialisiert (Reset warm / Reset kalt)
|
||||
bInCopyCode: BOOL; // TRUE: Die Instanz wird danach in den Kopiercode kopiert (Online-Change)
|
||||
|
||||
stEventEntry : TcEventEntry;
|
||||
xWithConfirmation : BOOL;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Create alarm
|
||||
_fbAlarmMessage.CreateEx(stEventEntry := stEventEntry, bWithConfirmation := xWithConfirmation);]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Property Name="Raised" Id="{6c8f10b8-0c5e-4665-b985-30ac574d84e9}">
|
||||
<Declaration><![CDATA[PROPERTY Raised : BOOL]]></Declaration>
|
||||
<Get Name="Get" Id="{0ef44270-1843-4da0-932f-31f831130a1d}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Raised := _fbAlarmMessage.bRaised;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="Triggered" Id="{84255a39-f5bd-41ec-9bb9-56c375350a5b}">
|
||||
<Declaration><![CDATA[PROPERTY Triggered : BOOL]]></Declaration>
|
||||
<Get Name="Get" Id="{1df049dd-1509-4300-b01e-e32eececdb86}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Triggered := _fbReleaseAlarm.xReleaseSignal;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
35
PLC/POUs/Components/Utilities/FB_Blinker.TcPOU
Normal file
35
PLC/POUs/Components/Utilities/FB_Blinker.TcPOU
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_Blinker" Id="{84dea953-e299-4743-83b2-332727c2009e}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[{attribute 'analysis' := '-56, -37'}
|
||||
FUNCTION_BLOCK FINAL FB_Blinker
|
||||
VAR_INPUT
|
||||
rFrequency : REAL;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
xOut : BOOL;
|
||||
END_VAR
|
||||
VAR
|
||||
_fbTON1 : TON;
|
||||
_fbTON2 : TON;
|
||||
|
||||
_timTime : TIME;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Calculate wait time
|
||||
IF rFrequency = 0.0 THEN
|
||||
rFrequency := 1.0;
|
||||
END_IF
|
||||
|
||||
_timTime := REAL_TO_TIME((1.0/rFrequency)*0.5*1000.0);
|
||||
|
||||
// Blinker base
|
||||
_fbTON1(IN := NOT _fbTON2.Q, PT := _timTime);
|
||||
_fbTON2(IN := _fbTON1.Q, PT := _timTime);
|
||||
|
||||
// Output
|
||||
xOut := _fbTON1.Q;]]></ST>
|
||||
</Implementation>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
132
PLC/POUs/Components/Utilities/FB_RampGenerator.TcPOU
Normal file
132
PLC/POUs/Components/Utilities/FB_RampGenerator.TcPOU
Normal file
@@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_RampGenerator" Id="{eab75824-fb3c-460a-af65-da2b006c5dc1}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[// Must only be called once per cycle!
|
||||
// Otherwise the Interpolation is wrong
|
||||
{attribute 'analysis' := '-56'}
|
||||
FUNCTION_BLOCK FB_RampGenerator
|
||||
VAR_INPUT
|
||||
// Current target value
|
||||
rTarget : REAL;
|
||||
|
||||
// Minimum target value
|
||||
rTargetMin : REAL;
|
||||
|
||||
// Maximum target value
|
||||
rTargetMax : REAL;
|
||||
|
||||
// Ramp up time (min to max)
|
||||
timRampUp : TIME;
|
||||
|
||||
// Ramp down time (max to min)
|
||||
timRampDown : TIME;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
rSetpoint : REAL := 0;
|
||||
|
||||
// Indicates that the target value has been reached
|
||||
xInTarget : BOOL;
|
||||
END_VAR
|
||||
VAR
|
||||
// Cycle time in ms
|
||||
_rCycleTime : REAL;
|
||||
|
||||
// Ramp up speed per cycle
|
||||
// Units per ms
|
||||
_rRampUpSpeed : REAL;
|
||||
|
||||
// Ramp down speed per cycle
|
||||
// Units per ms
|
||||
_rRampDownSpeed : REAL;
|
||||
|
||||
// Distance left to go
|
||||
_rDistanceToGo : REAL;
|
||||
|
||||
// First cycle
|
||||
_xFirstCycle : BOOL := TRUE;
|
||||
|
||||
_fbGetCurTaskIdx : GETCURTASKINDEX;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Get task cycle time during first cycle
|
||||
// Does not work in FB_init and also not with {attribute 'call_after_init'}
|
||||
IF _xFirstCycle THEN
|
||||
_xFirstCycle := FALSE;
|
||||
// Get current task cycle time
|
||||
_fbGetCurTaskIdx();
|
||||
// Convert 100ns to 1ms
|
||||
_rCycleTime := UDINT_TO_REAL(TwinCAT_SystemInfoVarList._TASKInfo[_fbGetCurTaskIdx.index].CycleTime) * 10E-5;
|
||||
END_IF
|
||||
|
||||
// Clamp setpoint to min max values
|
||||
{analysis -37}
|
||||
rTarget := MAX(rTarget, rTargetMin);
|
||||
rTarget := MIN(rTarget, rTargetMax);
|
||||
{analysis +37}
|
||||
|
||||
// Calculate change rates
|
||||
// TIME datatype is handled internally like a UDINT (32-bit). This leads to a resolution in milliseconds.
|
||||
// [_rRampUpSpeed] = units per cycle
|
||||
IF timRampUp <> T#0S THEN
|
||||
_rRampUpSpeed := (rTargetMax - rTargetMin) * (_rCycleTime / TIME_TO_REAL(timRampUp));
|
||||
ELSE
|
||||
_rRampUpSpeed := rTargetMax;
|
||||
END_IF
|
||||
IF timRampDown <> T#0S THEN
|
||||
_rRampDownSpeed := -(rTargetMax - rTargetMin) * (_rCycleTime / TIME_TO_REAL(timRampDown));
|
||||
ELSE
|
||||
_rRampDownSpeed := -rTargetMax;
|
||||
END_IF
|
||||
|
||||
|
||||
// Calculate distance left to go
|
||||
_rDistanceToGo := rTarget - rSetpoint;
|
||||
|
||||
// Calculate new setpoint
|
||||
IF (_rDistanceToGo > 0.0) THEN
|
||||
IF (_rDistanceToGo > _rRampUpSpeed) THEN
|
||||
rSetpoint := rSetpoint + _rRampUpSpeed;
|
||||
ELSE
|
||||
rSetpoint := rTarget;
|
||||
END_IF
|
||||
ELSIF (_rDistanceToGo < 0.0) THEN
|
||||
IF (_rDistanceToGo < _rRampDownSpeed) THEN
|
||||
rSetpoint := rSetpoint + _rRampDownSpeed;
|
||||
ELSE
|
||||
rSetpoint := rTarget;
|
||||
END_IF
|
||||
ELSE
|
||||
rSetpoint := rTarget;
|
||||
END_IF
|
||||
|
||||
// Check if we are in range of target range
|
||||
IF ABS(rSetpoint-rTarget) <= 0.001 THEN
|
||||
xInTarget := TRUE;
|
||||
ELSE
|
||||
xInTarget := FALSE;
|
||||
END_IF ]]></ST>
|
||||
</Implementation>
|
||||
<Property Name="CycleTime" Id="{12c00f80-a9cf-4d1b-ac68-3c3e59228015}">
|
||||
<Declaration><![CDATA[PROPERTY CycleTime : REAL]]></Declaration>
|
||||
<Get Name="Get" Id="{06853e5f-48e3-4643-ae4f-e23a07d71695}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[CycleTime := _rCycleTime;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Method Name="SetStart" Id="{06f2b416-7cfb-4f46-94e3-4002d92fc703}">
|
||||
<Declaration><![CDATA[METHOD SetStart
|
||||
VAR_INPUT
|
||||
rStartpoint : REAL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[rSetpoint := rStartpoint;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
34
PLC/POUs/Components/Utilities/FC_HashFNV1a_32Bit.TcPOU
Normal file
34
PLC/POUs/Components/Utilities/FC_HashFNV1a_32Bit.TcPOU
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FC_HashFNV1a_32Bit" Id="{59a77c23-437d-4f1e-ae71-d5303ce54b27}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION FC_HashFNV1a_32Bit : UDINT
|
||||
VAR_INPUT
|
||||
psKey : POINTER TO STRING;
|
||||
END_VAR
|
||||
VAR
|
||||
// FNV-1a Hash value, seeded with starting value
|
||||
_udiHash : UDINT := 16#811C9DC5;
|
||||
|
||||
_uiCounter : UINT;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// FNV-1a prime number for a 32bit hash
|
||||
udiPrime : UDINT := 16#01000193;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Version 1.2
|
||||
IF psKey = 0 THEN
|
||||
FC_HashFNV1a_32Bit := 0;
|
||||
RETURN;
|
||||
END_IF
|
||||
WHILE psKey^[_uiCounter] <> 0 DO
|
||||
_udiHash := (_udiHash XOR BYTE_TO_UDINT(psKey^[_uiCounter])) * udiPrime;
|
||||
_uiCounter := _uiCounter + 1;
|
||||
END_WHILE
|
||||
|
||||
// Return calculated Hash
|
||||
FC_HashFNV1a_32Bit := _udiHash;]]></ST>
|
||||
</Implementation>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
520
PLC/POUs/Components/Valves/FB_Valve.TcPOU
Normal file
520
PLC/POUs/Components/Valves/FB_Valve.TcPOU
Normal file
@@ -0,0 +1,520 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_Valve" Id="{658f8bac-5e87-43a2-9b4c-a425a60acda2}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_Valve
|
||||
VAR_INPUT
|
||||
xOpenFeedback AT %I* : BOOL;
|
||||
xCloseFeedback AT %I* : BOOL;
|
||||
|
||||
// Open and close the valve
|
||||
xAutomaticOpen : BOOL;
|
||||
|
||||
// Global switch to dissable all errors
|
||||
xReleaseErrors : BOOL := TRUE;
|
||||
|
||||
// Config input
|
||||
// Valve configuration parameters
|
||||
stValveConfig : ST_ValveConfig;
|
||||
|
||||
// Release or block change to manual mode
|
||||
xReleaseManualMode : BOOL;
|
||||
|
||||
// Process interlocks
|
||||
wProcessINTLK : T_INTERLOCK;
|
||||
wProcessINTLKUsed: T_INTERLOCK;
|
||||
|
||||
// Safety interlocks
|
||||
wSafetyINTLK : T_INTERLOCK;
|
||||
|
||||
// Used safety interlocks
|
||||
wSafetyINTLKUsed: T_INTERLOCK;
|
||||
|
||||
// Input to confirm all errors
|
||||
xConfirmAlarms : BOOL;
|
||||
|
||||
// Input to tell the fb thats ist used inside a unit test
|
||||
// FB will not throw error messages
|
||||
{attribute 'hide'}
|
||||
xInUnitTestMode : BOOL := FALSE;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
// Use xOpenValve for normally closed valves
|
||||
xOpenValve AT %Q* : BOOL := FALSE;
|
||||
|
||||
// Use xCloseValve for normally open valves
|
||||
xCloseValve AT %Q* : BOOL := TRUE;
|
||||
|
||||
// Error in valve active
|
||||
xError : BOOL;
|
||||
END_VAR
|
||||
VAR_IN_OUT
|
||||
// HMI interface
|
||||
stHMIInterface : ST_HMI_VALVE_DATA;
|
||||
END_VAR
|
||||
VAR
|
||||
// Internal command for manual mode open request
|
||||
_xManualOpen : BOOL := FALSE;
|
||||
|
||||
// Manual mode active
|
||||
_xManualModeActive : BOOL := FALSE;
|
||||
|
||||
// Automatic mode active
|
||||
_xAutomaticModeActive : BOOL := TRUE;
|
||||
|
||||
// Sum of all activated interlocks
|
||||
_xProcessINTLKOk : BOOL;
|
||||
|
||||
// Sum of all activated process interlocks
|
||||
_xSafetyINTLKOk : BOOL := TRUE;
|
||||
|
||||
// Internal open state of the valve
|
||||
_xIsOpen : BOOL;
|
||||
|
||||
// Internal closed state of the valve
|
||||
_xIsClosed : BOOL;
|
||||
|
||||
// Name of valve
|
||||
// Will be set in constructor and can be changed with the name property
|
||||
_sName : STRING;
|
||||
|
||||
// Alarm handler for valve did not open
|
||||
_fbAlarmDidNotOpen : FB_AlarmMessage(stEventEntry := TC_EVENTS.Valve.DidNotOpen, xWithConfirmation := TRUE);
|
||||
|
||||
// Alarm handler for valve did not close
|
||||
_fbAlarmDidNotClose : FB_AlarmMessage(stEventEntry := TC_EVENTS.Valve.DidNotClose, xWithConfirmation := TRUE);
|
||||
|
||||
// Internal open command
|
||||
_xOpenValve : BOOL;
|
||||
|
||||
// Helper variables used in reset error flag
|
||||
_xAlarmsActive : BOOL;
|
||||
_xInputErrorsActive : BOOL;
|
||||
|
||||
// Internal error flags
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// ===============
|
||||
// Handle not used
|
||||
// ===============
|
||||
|
||||
IF (NOT stValveConfig.xUsed) THEN
|
||||
// Clear all pending alarms if there are any
|
||||
_fbAlarmDidNotOpen(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmDidNotClose(xActive := FALSE, xRelease := FALSE);
|
||||
|
||||
_xError := FALSE;
|
||||
xError := FALSE;
|
||||
|
||||
RETURN;
|
||||
END_IF
|
||||
|
||||
|
||||
// ===========================
|
||||
// Reset safetyinterlocks flag
|
||||
// ===========================
|
||||
|
||||
IF xConfirmAlarms AND (NOT _xSafetyINTLKOk) THEN
|
||||
_xSafetyINTLKOk := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// =========
|
||||
// Prechecks
|
||||
// =========
|
||||
|
||||
CheckInterlocks();
|
||||
|
||||
|
||||
// =================
|
||||
// Handle HMI inputs
|
||||
// =================
|
||||
|
||||
HandleHMIInput();
|
||||
|
||||
|
||||
// ===================================
|
||||
// Handle opening and closing of valve
|
||||
// ===================================
|
||||
|
||||
_xOpenValve := ((_xManualOpen AND _xManualModeActive AND (NOT _xAutomaticModeActive))
|
||||
OR ( xAutomaticOpen AND _xAutomaticModeActive AND (NOT _xManualModeActive)));
|
||||
|
||||
// Check for interlocks
|
||||
// If not, use valve state from settings
|
||||
IF (NOT _xProcessINTLKOk) OR (NOT _xSafetyINTLKOk) THEN
|
||||
_xOpenValve := stValveConfig.xOpenWhenInterlocksActive;
|
||||
|
||||
// Also reset manual open command if safetyinterlocks are set
|
||||
IF (NOT _xSafetyINTLKOk) AND (_xManualOpen <> stValveConfig.xOpenWhenInterlocksActive) THEN
|
||||
_xManualOpen := stValveConfig.xOpenWhenInterlocksActive;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
// Handle open close feedback
|
||||
_xIsOpen := (stValveConfig.xHasOpenFeedback AND xOpenFeedback AND (NOT xCloseFeedback)) OR ((NOT stValveConfig.xHasOpenFeedback) AND _xOpenValve);
|
||||
_xIsClosed := (stValveConfig.xHasClosedFeedback AND xCloseFeedback AND (NOT xOpenFeedback)) OR ((NOT stValveConfig.xHasClosedFeedback) AND (NOT _xOpenValve));
|
||||
|
||||
|
||||
// ===========================
|
||||
// Valve did not open in time
|
||||
// ===========================
|
||||
|
||||
_fbAlarmDidNotOpen(
|
||||
xActive:= _xOpenValve AND (NOT _xIsOpen),
|
||||
xRelease:= xReleaseErrors,
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stValveConfig.timTimeoutOpen,
|
||||
timOffDelay:= T#0S,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
// Latch error signal
|
||||
IF _fbAlarmDidNotOpen.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ===========================
|
||||
// Valve did not close in time
|
||||
// ===========================
|
||||
|
||||
_fbAlarmDidNotClose(
|
||||
xActive:= (NOT _xOpenValve) AND (NOT _xIsClosed),
|
||||
xRelease:= xReleaseErrors,
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stValveConfig.timTimeoutClose,
|
||||
timOffDelay:= T#0S,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
// Latch error signal
|
||||
IF _fbAlarmDidNotClose.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ================
|
||||
// Reset error flag
|
||||
// ================
|
||||
|
||||
_xAlarmsActive := _fbAlarmDidNotOpen.Active OR _fbAlarmDidNotClose.Active;
|
||||
_xInputErrorsActive := _fbAlarmDidNotOpen.Triggered OR _fbAlarmDidNotClose.Triggered;
|
||||
|
||||
IF xConfirmAlarms AND _xError AND (NOT _xAlarmsActive) AND (NOT _xInputErrorsActive) THEN
|
||||
_xError := FALSE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ================================
|
||||
// Copy internal signals to outputs
|
||||
// ================================
|
||||
|
||||
xOpenValve := _xOpenValve;
|
||||
xCloseValve := (NOT _xOpenValve);
|
||||
|
||||
xError := _xError;
|
||||
|
||||
|
||||
// ==================
|
||||
// Handle HMI outputs
|
||||
// ==================
|
||||
|
||||
HandleHMIOutput();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="CheckInterlocks" Id="{30a74d3e-2b2c-4675-9a57-4f19eacc7578}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE FINAL CheckInterlocks
|
||||
VAR
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Set interlocks ok
|
||||
_xProcessINTLKOk := TRUE;
|
||||
|
||||
// Check if all active interlocks are ok
|
||||
IF ((wProcessINTLK AND wProcessINTLKUsed) XOR wProcessINTLKUsed) > 0 THEN
|
||||
_xProcessINTLKOk := FALSE;
|
||||
END_IF
|
||||
|
||||
// Check safety interlocks
|
||||
// Safety interlocks will not automatically reset
|
||||
// They need to be reset via the xConfirmAlarms input
|
||||
IF ((wSafetyINTLK AND wSafetyINTLKUsed) XOR wSafetyINTLKUsed) > 0 THEN
|
||||
_xSafetyINTLKOk := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="CreateAlarmMSG" Id="{afc73f4f-5060-43b3-9def-13568c293122}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE CreateAlarmMSG
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Create did not in open alarm
|
||||
_fbAlarmDidNotOpen.Arguments.Clear().AddString(_sName);
|
||||
|
||||
// Create did not close alarm
|
||||
_fbAlarmDidNotClose.Arguments.Clear().AddString(_sName);]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="FB_init" Id="{0feef5ff-7efd-4523-9e63-83898cab15b4}">
|
||||
<Declaration><![CDATA[//FB_Init ist immer implizit verfügbar und wird primär für die Initialisierung verwendet.
|
||||
//Der Rückgabewert wird nicht ausgewertet. Für gezielte Einflussnahme können Sie
|
||||
//die Methoden explizit deklarieren und darin mit dem Standard-Initialisierungscode
|
||||
//zusätzlichen Code bereitstellen. Sie können den Rückgabewert auswerten.
|
||||
METHOD FB_Init: BOOL
|
||||
VAR_INPUT
|
||||
bInitRetains: BOOL; // TRUE: Die Retain-Variablen werden initialisiert (Reset warm / Reset kalt)
|
||||
bInCopyCode: BOOL; // TRUE: Die Instanz wird danach in den Kopiercode kopiert (Online-Change)
|
||||
|
||||
sName : STRING(80);
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_sName := sName;
|
||||
|
||||
// Create alarm messages
|
||||
CreateAlarmMSG();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="HandleHMIInput" Id="{daeab2cd-6c5b-4055-97d1-f9300c25c2a5}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE HandleHMIInput
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[{warning disable C0371}
|
||||
// Handle automatic mode request
|
||||
IF stHMIInterface.stAutomaticButton.xRequest AND (NOT _xAutomaticModeActive) THEN
|
||||
_xAutomaticModeActive := TRUE;
|
||||
_xManualModeActive := FALSE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stAutomaticButton.xRequest THEN
|
||||
stHMIInterface.stAutomaticButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle manual mode request
|
||||
IF stHMIInterface.stManualButton.xRequest AND (NOT _xManualModeActive) AND xReleaseManualMode THEN
|
||||
_xAutomaticModeActive := FALSE;
|
||||
_xManualModeActive := TRUE;
|
||||
|
||||
// Copy last requested valve state into manual
|
||||
_xManualOpen := xAutomaticOpen;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stManualButton.xRequest THEN
|
||||
stHMIInterface.stManualButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle open request
|
||||
IF stHMIInterface.stOpenButton.xRequest AND _xManualModeActive AND _xProcessINTLKOk AND _xSafetyINTLKOk THEN
|
||||
_xManualOpen := TRUE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stOpenButton.xRequest THEN
|
||||
stHMIInterface.stOpenButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle close request
|
||||
IF stHMIInterface.stCloseButton.xRequest AND _xManualModeActive THEN
|
||||
_xManualOpen := FALSE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stCloseButton.xRequest THEN
|
||||
stHMIInterface.stCloseButton.xRequest := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="HandleHMIOutput" Id="{89ada59a-03b1-4917-880c-76f3bba59ef0}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE HandleHMIOutput : BOOL
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[{warning disable C0371}
|
||||
// Handle open closed feedbacks
|
||||
IF (NOT _xIsOpen) AND (NOT _xIsClosed) AND (NOT _xError) THEN
|
||||
stHMIInterface.iStatus := E_HMI_VALVE_STATUS.TRANSITIONING;
|
||||
END_IF
|
||||
|
||||
IF _xIsOpen AND (NOT _xIsClosed) AND (NOT _xError) THEN
|
||||
stHMIInterface.iStatus := E_HMI_VALVE_STATUS.OPENED;
|
||||
END_IF
|
||||
|
||||
IF _xIsClosed AND (NOT _xIsOpen) AND (NOT _xError) THEN
|
||||
stHMIInterface.iStatus := E_HMI_VALVE_STATUS.CLOSED;
|
||||
END_IF
|
||||
|
||||
IF _xError THEN
|
||||
stHMIInterface.iStatus := E_HMI_VALVE_STATUS.ERROR;
|
||||
END_IF
|
||||
|
||||
// Copy config data to hmi interface
|
||||
stHMIInterface.xUsed := stValveConfig.xUsed;
|
||||
stHMIInterface.sName := _sName;
|
||||
|
||||
// Handle mode button feedback
|
||||
IF _xManualModeActive THEN
|
||||
stHMIInterface.stManualButton.eFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
ELSE
|
||||
stHMIInterface.stManualButton.eFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
END_IF
|
||||
|
||||
IF _xAutomaticModeActive THEN
|
||||
stHMIInterface.stAutomaticButton.eFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
ELSE
|
||||
stHMIInterface.stAutomaticButton.eFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
END_IF
|
||||
|
||||
// Handle open close button feedback
|
||||
IF _xIsOpen THEN
|
||||
stHMIInterface.stOpenButton.eFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
ELSE
|
||||
stHMIInterface.stOpenButton.eFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
END_IF
|
||||
|
||||
IF _xIsClosed THEN
|
||||
stHMIInterface.stCloseButton.eFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
ELSE
|
||||
stHMIInterface.stCloseButton.eFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
END_IF
|
||||
|
||||
// Handle release button signals
|
||||
stHMIInterface.stManualButton.xRelease := xReleaseManualMode AND (NOT _xManualModeActive);
|
||||
stHMIInterface.stAutomaticButton.xRelease := (NOT _xAutomaticModeActive);
|
||||
|
||||
stHMIInterface.stOpenButton.xRelease := _xManualModeActive AND _xProcessINTLKOk AND _xSafetyINTLKOk;
|
||||
stHMIInterface.stCloseButton.xRelease := _xManualModeActive;
|
||||
|
||||
// Handle current mode
|
||||
IF _xManualModeActive AND (NOT _xAutomaticModeActive) THEN
|
||||
stHMIInterface.iCurrentMode := E_HMI_MODE.MANUAL;
|
||||
END_IF
|
||||
|
||||
IF _xAutomaticModeActive AND (NOT _xManualModeActive) THEN
|
||||
stHMIInterface.iCurrentMode := E_HMI_MODE.AUTOMATIC;
|
||||
END_IF
|
||||
|
||||
// Handle interlock status
|
||||
stHMIInterface.stInterlock.wProcessINTLKStatus := wProcessINTLK;
|
||||
stHMIInterface.stInterlock.wProcessINTLKUsed := wProcessINTLKUsed;
|
||||
stHMIInterface.stInterlock.xProcessINTLKOk := _xProcessINTLKOk;
|
||||
|
||||
stHMIInterface.stInterlock.wSafetyINTLKStatus := wSafetyINTLK;
|
||||
stHMIInterface.stInterlock.wSafetyINTLKUsed := wSafetyINTLKUsed;
|
||||
stHMIInterface.stInterlock.xSafetyINTLKOk := _xSafetyINTLKOk;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Property Name="IsClosed" Id="{1f4ebe6c-a98f-48b1-8a5f-f4c1debefa5c}">
|
||||
<Declaration><![CDATA[PROPERTY IsClosed : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{ef140b66-3db4-4eb7-87ae-680649452cd3}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IsClosed := _xIsClosed;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="IsInAutomaticMode" Id="{d767111f-e137-4db5-8520-de2e239783bd}">
|
||||
<Declaration><![CDATA[PROPERTY IsInAutomaticMode : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{203d88c3-1caf-4d92-8292-06e60d21d256}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IsInAutomaticMode := _xAutomaticModeActive AND (NOT _xManualModeActive);
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="IsInManualMode" Id="{ddd53775-56a5-419a-a26e-07865c412725}">
|
||||
<Declaration><![CDATA[PROPERTY IsInManualMode : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{93872f82-0dd1-4fc7-bfb1-ae593ff57248}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IsInManualMode := _xManualModeActive AND (NOT _xAutomaticModeActive);]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="IsOpen" Id="{6afdd2c7-3934-4136-a18f-ea14a935f5ef}">
|
||||
<Declaration><![CDATA[PROPERTY IsOpen : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{3d3206fd-7dcd-4c1d-a91d-4513ff154aa6}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IsOpen := _xIsOpen;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="Name" Id="{6475e552-32d7-4dcc-b692-9b5c114c6e55}">
|
||||
<Declaration><![CDATA[PROPERTY Name : STRING(80)]]></Declaration>
|
||||
<Get Name="Get" Id="{3c945911-435e-4362-80a0-23de08a8aa01}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Name := _sName;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
<Set Name="Set" Id="{e21a3263-d456-45aa-b72b-78833f59308c}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_sName := Name;
|
||||
|
||||
// Recreate alarm messages after name change
|
||||
CreateAlarmMSG();]]></ST>
|
||||
</Implementation>
|
||||
</Set>
|
||||
</Property>
|
||||
<Property Name="ProcessInterlocksOK" Id="{5304af5f-5f38-41ac-bae3-41072677ae5b}">
|
||||
<Declaration><![CDATA[PROPERTY ProcessInterlocksOK : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{c7a36fe9-16d1-4e6a-840a-95721198ae41}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[ProcessInterlocksOK := _xProcessINTLKOk;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Method Name="ReqAutomaticMode" Id="{8d7ea6da-e5b9-4d22-89bf-8b742e336da8}">
|
||||
<Declaration><![CDATA[METHOD ReqAutomaticMode
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_xAutomaticModeActive := TRUE;
|
||||
_xManualModeActive := FALSE;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="ReqManualMode" Id="{3b374714-1bdd-4b5e-a971-5605e320e287}">
|
||||
<Declaration><![CDATA[METHOD ReqManualMode
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IF xReleaseManualMode THEN
|
||||
_xManualModeActive := TRUE;
|
||||
_xAutomaticModeActive := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Property Name="SafetyInterlocksOK" Id="{cfa4b65a-d169-4f4b-ad4b-6e2d8e24ce3a}">
|
||||
<Declaration><![CDATA[{attribute 'analysis' := '-31'}
|
||||
PROPERTY SafetyInterlocksOK : BOOL]]></Declaration>
|
||||
<Get Name="Get" Id="{fa7d25b7-22e3-4e23-afcd-0ace84239f31}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[SafetyInterlocksOK := _xSafetyINTLKOk;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
689
PLC/POUs/Components/Valves/FB_ValveAnalog.TcPOU
Normal file
689
PLC/POUs/Components/Valves/FB_ValveAnalog.TcPOU
Normal file
@@ -0,0 +1,689 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveAnalog" Id="{54d19eca-c234-46d9-92a2-1587aba4973c}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[{attribute 'reflection'}
|
||||
FUNCTION_BLOCK FINAL FB_ValveAnalog
|
||||
VAR_INPUT
|
||||
rSPAutomatic : REAL;
|
||||
|
||||
iFeedbackValue AT %I* : INT;
|
||||
xFeedbackUnderrange AT %I* : BOOL;
|
||||
xFeedbackOverrange AT %I* : BOOL;
|
||||
xErrorCard AT %I* : BOOL;
|
||||
|
||||
xOpenFeedback AT %I* : BOOL;
|
||||
xCloseFeedback AT %I* : BOOL;
|
||||
|
||||
// Open and close the valve
|
||||
xAutomaticOpen : BOOL;
|
||||
|
||||
// Global switch to dissable all errors
|
||||
xReleaseErrors : BOOL := TRUE;
|
||||
|
||||
// Config input
|
||||
// Valve configuration parameters
|
||||
stValveConfig : ST_ValveAnalogConfig;
|
||||
|
||||
// Release or block change to manual mode
|
||||
xReleaseManualMode : BOOL;
|
||||
|
||||
// Process interlocks
|
||||
wProcessINTLK : T_INTERLOCK;
|
||||
wProcessINTLKUsed: T_INTERLOCK;
|
||||
|
||||
// Safety interlocks
|
||||
wSafetyINTLK : T_INTERLOCK;
|
||||
|
||||
// Used safety interlocks
|
||||
wSafetyINTLKUsed: T_INTERLOCK;
|
||||
|
||||
// Input to confirm all errors
|
||||
xConfirmAlarms : BOOL;
|
||||
|
||||
// Input to tell the fb thats ist used inside a unit test
|
||||
// FB will not throw error messages
|
||||
{attribute 'hide'}
|
||||
xInUnitTestMode : BOOL := FALSE;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
// Ouput setpoint
|
||||
iSetpoint AT %Q* : INT;
|
||||
|
||||
// Error in valve active
|
||||
xError : BOOL;
|
||||
END_VAR
|
||||
VAR_IN_OUT
|
||||
// HMI interface
|
||||
stHMIInterface : ST_HMI_ANALOG_VALVE_DATA;
|
||||
END_VAR
|
||||
VAR
|
||||
// Internal command for manual mode open request
|
||||
_xManualOpen : BOOL := FALSE;
|
||||
|
||||
// Manual mode active
|
||||
_xManualModeActive : BOOL := FALSE;
|
||||
|
||||
// Automatic mode active
|
||||
_xAutomaticModeActive : BOOL := TRUE;
|
||||
|
||||
// Sum of all activated interlocks
|
||||
_xProcessINTLKOk : BOOL;
|
||||
|
||||
// Sum of all activated process interlocks
|
||||
_xSafetyINTLKOk : BOOL := TRUE;
|
||||
|
||||
// Internal open state of the valve
|
||||
_xIsOpen : BOOL;
|
||||
|
||||
// Internal closed state of the valve
|
||||
_xIsClosed : BOOL;
|
||||
|
||||
// Name of valve
|
||||
// Will be set in constructor and can be changed with the name property
|
||||
_sName : STRING;
|
||||
|
||||
// Analog input
|
||||
{attribute 'hide'}
|
||||
_fbAnalogInput : FB_AnalogInput('');
|
||||
|
||||
// analog output
|
||||
{attribute 'hide'}
|
||||
_fbAnalogOutput : FB_AnalogOutput('');
|
||||
|
||||
// Internal setpoint
|
||||
_rSetpoint : REAL;
|
||||
|
||||
{attribute 'is_connected' := 'xFeedbackUnderrange'}
|
||||
_xHasUnderrangeFeedback : BOOL;
|
||||
|
||||
{attribute 'is_connected' := 'xFeedbackOverrange'}
|
||||
_xHasOverrangeFeedback : BOOL;
|
||||
|
||||
{attribute 'is_connected' := 'xErrorCard'}
|
||||
_xHasCardError : BOOL;
|
||||
|
||||
// Current valve position
|
||||
_rCurrentValvePosition : REAL;
|
||||
|
||||
// Alarm handler for valve did not open
|
||||
_fbAlarmDidNotOpen : FB_AlarmMessage(stEventEntry := TC_EVENTS.Valve.DidNotOpen, xWithConfirmation := TRUE);
|
||||
|
||||
// Alarm handler for valve did not close
|
||||
_fbAlarmDidNotClose : FB_AlarmMessage(stEventEntry := TC_EVENTS.Valve.DidNotClose, xWithConfirmation := TRUE);
|
||||
|
||||
// Alarm handler for not in range
|
||||
_fbAlarmNotInRange : FB_AlarmMessage(stEventEntry := TC_EVENTS.Valve.NotInRange, xWithConfirmation := TRUE);
|
||||
|
||||
// Analog input error
|
||||
_xAnalogInputError : BOOL;
|
||||
|
||||
// analog output error
|
||||
_xAnalogOutputError : BOOL;
|
||||
|
||||
// Analog input warning active
|
||||
_xWarningAnalogInput : BOOL;
|
||||
|
||||
// Calculated allowed window for process value
|
||||
_rPVTargetMax : REAL;
|
||||
_rPVTargetMin : REAL;
|
||||
|
||||
// Error for not beeing in range
|
||||
_xNotInRange : BOOL;
|
||||
|
||||
// Internal open command
|
||||
_xOpenValve : BOOL;
|
||||
|
||||
// Helper variables used in reset error flag
|
||||
_xAlarmsActive : BOOL;
|
||||
_xInputErrorsActive : BOOL;
|
||||
|
||||
// Internal error flags
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// ===============
|
||||
// Handle not used
|
||||
// ===============
|
||||
|
||||
IF (NOT stValveConfig.xUsed) THEN
|
||||
// Clear all pending alarms if there are any
|
||||
_fbAlarmDidNotOpen(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmDidNotClose(xActive := FALSE, xRelease := FALSE);
|
||||
_fbAlarmNotInRange(xActive := FALSE, xRelease := FALSE);
|
||||
|
||||
_xAnalogOutputError := FALSE;
|
||||
_xAnalogInputError := FALSE;
|
||||
|
||||
_xWarningAnalogInput := FALSE;
|
||||
|
||||
_xError := FALSE;
|
||||
xError := FALSE;
|
||||
|
||||
RETURN;
|
||||
END_IF
|
||||
|
||||
|
||||
// ===========================
|
||||
// Reset safetyinterlocks flag
|
||||
// ===========================
|
||||
|
||||
IF xConfirmAlarms AND (NOT _xSafetyINTLKOk) THEN
|
||||
_xSafetyINTLKOk := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// =========
|
||||
// Prechecks
|
||||
// =========
|
||||
|
||||
CheckInterlocks();
|
||||
|
||||
|
||||
// =================
|
||||
// Handle HMI inputs
|
||||
// =================
|
||||
|
||||
HandleHMIInput();
|
||||
|
||||
|
||||
// ==============================
|
||||
// Check if all interlocks are ok
|
||||
// ==============================
|
||||
|
||||
// Only reset manual command if safetyinterlocks are not ok
|
||||
IF (NOT _xSafetyINTLKOk) AND _xManualOpen THEN
|
||||
// Also reset manual open command if safetyinterlocks are set
|
||||
_xManualOpen := FALSE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ===================================
|
||||
// Handle opening and closing of valve
|
||||
// ===================================
|
||||
|
||||
_xOpenValve := _xProcessINTLKOk AND _xSafetyINTLKOk AND ((_xManualOpen AND _xManualModeActive AND (NOT _xAutomaticModeActive)) OR ( xAutomaticOpen AND _xAutomaticModeActive AND (NOT _xManualModeActive)));
|
||||
|
||||
IF _xOpenValve THEN
|
||||
IF _xManualModeActive AND (NOT _xAutomaticModeActive) THEN
|
||||
_rSetpoint := stHMIInterface.stSetpoint.rValue;
|
||||
ELSIF _xAutomaticModeActive AND (NOT _xManualModeActive) THEN
|
||||
_rSetpoint := rSPAutomatic;
|
||||
ELSE
|
||||
_rSetpoint := 0.0;
|
||||
END_IF
|
||||
ELSE
|
||||
IF (NOT _xProcessINTLKOk) OR (NOT _xSafetyINTLKOk) THEN
|
||||
_rSetpoint := stValveConfig.rSetpointWhenInterlocksActive;
|
||||
ELSE
|
||||
_rSetpoint := 0.0;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
|
||||
// ====================
|
||||
// Handle analog output
|
||||
// ====================
|
||||
|
||||
_fbAnalogOutput(
|
||||
rSetpoint:= _rSetpoint,
|
||||
stAnalogIOConfig:= stValveConfig.stAnalogOutputConfig,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
xInUnitTestMode := xInUnitTestMode,
|
||||
iAnalogValue=> iSetpoint,
|
||||
xError => _xAnalogOutputError,
|
||||
stHMIInterface:= stHMIInterface.stSetpoint);
|
||||
|
||||
IF _fbAnalogOutput.xError THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
// ===================
|
||||
// Handle analog input
|
||||
// ===================
|
||||
|
||||
IF stValveConfig.xHasAnalogFeedback THEN
|
||||
stValveConfig.stAnalogInputConfig.xUsed := TRUE;
|
||||
ELSE
|
||||
stValveConfig.stAnalogInputConfig.xUsed := FALSE;
|
||||
END_IF
|
||||
|
||||
_fbAnalogInput(
|
||||
iAnalogValue:= iFeedbackValue,
|
||||
xUnderrange:= _xHasUnderrangeFeedback AND xFeedbackUnderrange,
|
||||
xOverrange:= _xHasOverrangeFeedback AND xFeedbackOverrange,
|
||||
xErrorCard:= _xHasCardError AND xErrorCard,
|
||||
stAnalogIOConfig:= stValveConfig.stAnalogInputConfig,
|
||||
stAnalogEWConfig:= stValveConfig.stAnalogInputEWConfig,
|
||||
xReleaseErrors:= xReleaseErrors,
|
||||
xReleaseLimitErrors:= FALSE,
|
||||
xReleaseHardwareErrors:= TRUE,
|
||||
xInUnitTestMode := xInUnitTestMode,
|
||||
xConfirmAlarms:= xConfirmAlarms,
|
||||
rScaledValue=> _rCurrentValvePosition,
|
||||
xError=> _xAnalogInputError,
|
||||
xWarning=> _xWarningAnalogInput,
|
||||
xErrorLow=> ,
|
||||
xWarningLow=> ,
|
||||
xWarningHigh=> ,
|
||||
xErrorHigh=> );
|
||||
|
||||
IF _fbAnalogInput.xError THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
IF NOT stValveConfig.xHasAnalogFeedback THEN
|
||||
_rCurrentValvePosition := _rSetpoint;
|
||||
END_IF
|
||||
|
||||
|
||||
// Handle open close feedback
|
||||
_xIsOpen := (stValveConfig.xHasOpenFeedback AND xOpenFeedback AND (NOT xCloseFeedback)) OR ((NOT stValveConfig.xHasOpenFeedback) AND (_rCurrentValvePosition >= stValveConfig.rPVIsOpen));
|
||||
_xIsClosed := (stValveConfig.xHasClosedFeedback AND xCloseFeedback AND (NOT xOpenFeedback)) OR ((NOT stValveConfig.xHasClosedFeedback) AND (_rCurrentValvePosition <= stValveConfig.rPVIsOpen));
|
||||
|
||||
|
||||
// Calculate target tolerance
|
||||
_rPVTargetMax := _rSetpoint + stValveConfig.rTargetTolerance;
|
||||
_rPVTargetMin := _rSetpoint - stValveConfig.rTargetTolerance;
|
||||
|
||||
// Check if valve position is in target
|
||||
_xNotInRange := stValveConfig.xHasAnalogFeedback AND ((_rCurrentValvePosition < _rPVTargetMin) OR (_rCurrentValvePosition > _rPVTargetMax));
|
||||
|
||||
// ==================
|
||||
// Not in range alarm
|
||||
// ==================
|
||||
|
||||
_fbAlarmNotInRange(
|
||||
xActive:= _xNotInRange,
|
||||
xRelease:= xReleaseErrors,
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stValveConfig.timNotInRange,
|
||||
timOffDelay:= T#0S,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
// Latch error signal
|
||||
IF _fbAlarmNotInRange.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ===========================
|
||||
// Valve did not open in time
|
||||
// ===========================
|
||||
|
||||
_fbAlarmDidNotOpen(
|
||||
xActive:= _xOpenValve AND (NOT _xIsOpen),
|
||||
xRelease:= xReleaseErrors,
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stValveConfig.timTimeoutOpen,
|
||||
timOffDelay:= T#0S,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
// Latch error signal
|
||||
IF _fbAlarmDidNotOpen.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ===========================
|
||||
// Valve did not close in time
|
||||
// ===========================
|
||||
|
||||
_fbAlarmDidNotClose(
|
||||
xActive:= (NOT _xOpenValve) AND (NOT _xIsClosed),
|
||||
xRelease:= xReleaseErrors,
|
||||
xAcknowledge:= xConfirmAlarms,
|
||||
timOnDelay:= stValveConfig.timTimeoutClose,
|
||||
timOffDelay:= T#0S,
|
||||
xInUnitTestMode:= xInUnitTestMode);
|
||||
|
||||
// Latch error signal
|
||||
IF _fbAlarmDidNotClose.Triggered THEN
|
||||
_xError := TRUE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ================
|
||||
// Reset error flag
|
||||
// ================
|
||||
|
||||
_xAlarmsActive := _fbAlarmDidNotOpen.Active OR _fbAlarmDidNotClose.Active OR _fbAlarmNotInRange.Raised OR _xAnalogInputError OR _xAnalogOutputError;
|
||||
_xInputErrorsActive := _fbAlarmDidNotOpen.Triggered OR _fbAlarmDidNotClose.Triggered OR _fbAlarmNotInRange.Triggered;
|
||||
|
||||
IF xConfirmAlarms AND _xError AND (NOT _xAlarmsActive) AND (NOT _xInputErrorsActive) THEN
|
||||
_xError := FALSE;
|
||||
END_IF
|
||||
|
||||
|
||||
// ================================
|
||||
// Copy internal signals to outputs
|
||||
// ================================
|
||||
|
||||
xError := _xError;
|
||||
|
||||
|
||||
// ==================
|
||||
// Handle HMI outputs
|
||||
// ==================
|
||||
|
||||
HandleHMIOutput();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="CheckInterlocks" Id="{8b1816d5-ab17-471a-8a0b-10f53aacd0e5}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE FINAL CheckInterlocks
|
||||
VAR
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Set interlocks ok
|
||||
_xProcessINTLKOk := TRUE;
|
||||
|
||||
// Check if all active interlocks are ok
|
||||
IF ((wProcessINTLK AND wProcessINTLKUsed) XOR wProcessINTLKUsed) > 0 THEN
|
||||
_xProcessINTLKOk := FALSE;
|
||||
END_IF
|
||||
|
||||
// Check safety interlocks
|
||||
// Safety interlocks will not automatically reset
|
||||
// They need to be reset via the xConfirmAlarms input
|
||||
IF ((wSafetyINTLK AND wSafetyINTLKUsed) XOR wSafetyINTLKUsed) > 0 THEN
|
||||
_xSafetyINTLKOk := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="CreateAlarmMSG" Id="{c81e16aa-3869-4b2a-9f6c-7c975920c18f}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE CreateAlarmMSG
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Create did not in open alarm
|
||||
_fbAlarmDidNotOpen.Arguments.Clear().AddString(_sName);
|
||||
|
||||
// Create did not close alarm
|
||||
_fbAlarmDidNotClose.Arguments.Clear().AddString(_sName);
|
||||
|
||||
// Create did not in range alarm
|
||||
_fbAlarmNotInRange.Arguments.Clear().AddString(_sName);]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="FB_init" Id="{c1ee06ac-eaad-41e8-80a7-e09a4d61cbeb}">
|
||||
<Declaration><![CDATA[//FB_Init ist immer implizit verfügbar und wird primär für die Initialisierung verwendet.
|
||||
//Der Rückgabewert wird nicht ausgewertet. Für gezielte Einflussnahme können Sie
|
||||
//die Methoden explizit deklarieren und darin mit dem Standard-Initialisierungscode
|
||||
//zusätzlichen Code bereitstellen. Sie können den Rückgabewert auswerten.
|
||||
METHOD FB_Init: BOOL
|
||||
VAR_INPUT
|
||||
bInitRetains: BOOL; // TRUE: Die Retain-Variablen werden initialisiert (Reset warm / Reset kalt)
|
||||
bInCopyCode: BOOL; // TRUE: Die Instanz wird danach in den Kopiercode kopiert (Online-Change)
|
||||
|
||||
sName : STRING(80);
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_sName := sName;
|
||||
|
||||
// Name the analog input and output
|
||||
_fbAnalogInput.Name := CONCAT(_sName, '.AnalogInput');
|
||||
_fbAnalogOutput.Name := CONCAT(_sName, '.AnalogOutput');
|
||||
|
||||
// Create alarm messages
|
||||
CreateAlarmMSG();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="HandleHMIInput" Id="{5eccb8ad-99f3-45d0-9d3c-03af7601217d}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE HandleHMIInput
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[{warning disable C0371}
|
||||
// Handle automatic mode request
|
||||
IF stHMIInterface.stAutomaticButton.xRequest AND (NOT _xAutomaticModeActive) THEN
|
||||
_xAutomaticModeActive := TRUE;
|
||||
_xManualModeActive := FALSE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stAutomaticButton.xRequest THEN
|
||||
stHMIInterface.stAutomaticButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle manual mode request
|
||||
IF stHMIInterface.stManualButton.xRequest AND (NOT _xManualModeActive) AND xReleaseManualMode THEN
|
||||
_xAutomaticModeActive := FALSE;
|
||||
_xManualModeActive := TRUE;
|
||||
|
||||
// Copy last requested valve state into manual
|
||||
_xManualOpen := xAutomaticOpen;
|
||||
stHMIInterface.stSetpoint.rValue := rSPAutomatic;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stManualButton.xRequest THEN
|
||||
stHMIInterface.stManualButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle open request
|
||||
IF stHMIInterface.stOpenButton.xRequest AND _xManualModeActive AND _xProcessINTLKOk AND _xSafetyINTLKOk THEN
|
||||
_xManualOpen := TRUE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stOpenButton.xRequest THEN
|
||||
stHMIInterface.stOpenButton.xRequest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Handle close request
|
||||
IF stHMIInterface.stCloseButton.xRequest AND _xManualModeActive THEN
|
||||
_xManualOpen := FALSE;
|
||||
END_IF
|
||||
|
||||
IF stHMIInterface.stCloseButton.xRequest THEN
|
||||
stHMIInterface.stCloseButton.xRequest := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="HandleHMIOutput" Id="{78e41bf5-d7d4-4955-92e5-e51e67c4444d}">
|
||||
<Declaration><![CDATA[METHOD PRIVATE HandleHMIOutput : BOOL
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[{warning disable C0371}
|
||||
// Handle open closed feedbacks
|
||||
IF (NOT _xIsOpen) AND (NOT _xIsClosed) AND (NOT _xError) THEN
|
||||
stHMIInterface.iStatus := E_HMI_VALVE_STATUS.TRANSITIONING;
|
||||
END_IF
|
||||
|
||||
IF _xIsOpen AND (NOT _xIsClosed) AND (NOT _xError) THEN
|
||||
stHMIInterface.iStatus := E_HMI_VALVE_STATUS.OPENED;
|
||||
END_IF
|
||||
|
||||
IF _xIsClosed AND (NOT _xIsOpen) AND (NOT _xError) THEN
|
||||
stHMIInterface.iStatus := E_HMI_VALVE_STATUS.CLOSED;
|
||||
END_IF
|
||||
|
||||
IF _xError THEN
|
||||
stHMIInterface.iStatus := E_HMI_VALVE_STATUS.ERROR;
|
||||
END_IF
|
||||
|
||||
// Copy analog in_out data
|
||||
stHMIInterface.stProcessValue.sName := 'Actual position';
|
||||
stHMIInterface.stProcessValue.rValue := _rCurrentValvePosition;
|
||||
|
||||
stHMIInterface.stSetpoint.sName := 'Target position';
|
||||
stHMIInterface.stSetpoint.rMin := stHMIInterface.stProcessValue.rMin;
|
||||
stHMIInterface.stSetpoint.rMax := stHMIInterface.stProcessValue.rMax;
|
||||
stHMIInterface.stSetpoint.sUnit := stHMIInterface.stProcessValue.sUnit;
|
||||
|
||||
// Copy config data to hmi interface
|
||||
stHMIInterface.xUsed := stValveConfig.xUsed;
|
||||
stHMIInterface.sName := _sName;
|
||||
|
||||
// Handle mode button feedback
|
||||
IF _xManualModeActive THEN
|
||||
stHMIInterface.stManualButton.eFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
ELSE
|
||||
stHMIInterface.stManualButton.eFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
END_IF
|
||||
|
||||
IF _xAutomaticModeActive THEN
|
||||
stHMIInterface.stAutomaticButton.eFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
ELSE
|
||||
stHMIInterface.stAutomaticButton.eFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
END_IF
|
||||
|
||||
// Handle open close button feedback
|
||||
IF _xIsOpen THEN
|
||||
stHMIInterface.stOpenButton.eFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
ELSE
|
||||
stHMIInterface.stOpenButton.eFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
END_IF
|
||||
|
||||
IF _xIsClosed THEN
|
||||
stHMIInterface.stCloseButton.eFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
ELSE
|
||||
stHMIInterface.stCloseButton.eFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
END_IF
|
||||
|
||||
// Handle release button signals
|
||||
stHMIInterface.stManualButton.xRelease := xReleaseManualMode AND (NOT _xManualModeActive);
|
||||
stHMIInterface.stAutomaticButton.xRelease := (NOT _xAutomaticModeActive);
|
||||
|
||||
stHMIInterface.stOpenButton.xRelease := _xManualModeActive AND _xProcessINTLKOk AND _xSafetyINTLKOk;
|
||||
stHMIInterface.stCloseButton.xRelease := _xManualModeActive;
|
||||
|
||||
// Handle current mode
|
||||
IF _xManualModeActive AND (NOT _xAutomaticModeActive) THEN
|
||||
stHMIInterface.iCurrentMode := E_HMI_MODE.MANUAL;
|
||||
END_IF
|
||||
|
||||
IF _xAutomaticModeActive AND (NOT _xManualModeActive) THEN
|
||||
stHMIInterface.iCurrentMode := E_HMI_MODE.AUTOMATIC;
|
||||
END_IF
|
||||
|
||||
// Handle interlock status
|
||||
stHMIInterface.stInterlock.wProcessINTLKStatus := wProcessINTLK;
|
||||
stHMIInterface.stInterlock.wProcessINTLKUsed := wProcessINTLKUsed;
|
||||
stHMIInterface.stInterlock.xProcessINTLKOk := _xProcessINTLKOk;
|
||||
|
||||
stHMIInterface.stInterlock.wSafetyINTLKStatus := wSafetyINTLK;
|
||||
stHMIInterface.stInterlock.wSafetyINTLKUsed := wSafetyINTLKUsed;
|
||||
stHMIInterface.stInterlock.xSafetyINTLKOk := _xSafetyINTLKOk;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Property Name="IsClosed" Id="{b6c1710c-9aab-4569-b47e-788596401de5}">
|
||||
<Declaration><![CDATA[PROPERTY IsClosed : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{6a0b898d-b4dd-42f2-8af5-0cbc0b739a53}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IsClosed := _xIsClosed;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="IsInAutomaticMode" Id="{c23f1e57-d41d-447f-ba1b-ef6a2091e1ee}">
|
||||
<Declaration><![CDATA[PROPERTY IsInAutomaticMode : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{7da816e7-e04c-4f70-b8a6-974fe4187b1c}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IsInAutomaticMode := _xAutomaticModeActive AND (NOT _xManualModeActive);
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="IsInManualMode" Id="{cb02ea4c-34fb-4c1c-bc05-be290f13e9cc}">
|
||||
<Declaration><![CDATA[PROPERTY IsInManualMode : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{b9145693-63b3-4bde-b741-a96047fb952a}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IsInManualMode := _xManualModeActive AND (NOT _xAutomaticModeActive);]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="IsOpen" Id="{14c8ecb1-93c0-4640-a72a-37068aa931c0}">
|
||||
<Declaration><![CDATA[PROPERTY IsOpen : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{9f1a9fc3-9760-4f2d-977c-2b77a4848604}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IsOpen := _xIsOpen;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Property Name="Name" Id="{a9acd029-3ab7-4f0b-866d-4e5e120b76d7}">
|
||||
<Declaration><![CDATA[PROPERTY Name : STRING(80)]]></Declaration>
|
||||
<Get Name="Get" Id="{2a298056-2f0c-40dd-93f1-0193ef39b177}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Name := _sName;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
<Set Name="Set" Id="{4439378f-18e8-4038-8e1b-e9c4c0e99771}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_sName := Name;
|
||||
|
||||
// Rename the analog input and output
|
||||
_fbAnalogInput.Name := CONCAT(_sName, '.AnalogInput');
|
||||
_fbAnalogOutput.Name := CONCAT(_sName, '.AnalogOutput');
|
||||
|
||||
// Recreate alarm messages after name change
|
||||
CreateAlarmMSG();]]></ST>
|
||||
</Implementation>
|
||||
</Set>
|
||||
</Property>
|
||||
<Property Name="ProcessInterlocksOK" Id="{6eca8eb7-6785-41bf-a07d-24fa126ee630}">
|
||||
<Declaration><![CDATA[PROPERTY ProcessInterlocksOK : BOOL
|
||||
]]></Declaration>
|
||||
<Get Name="Get" Id="{063a0fc0-f2e2-4438-82b9-93ba2a524eb0}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[ProcessInterlocksOK := _xProcessINTLKOk;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
<Method Name="ReqAutomaticMode" Id="{dc5b5371-d320-47c3-9450-5d2ea8274952}">
|
||||
<Declaration><![CDATA[METHOD ReqAutomaticMode
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_xAutomaticModeActive := TRUE;
|
||||
_xManualModeActive := FALSE;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="ReqManualMode" Id="{e9adf596-9367-4445-83ca-794c5fdbc5db}">
|
||||
<Declaration><![CDATA[METHOD ReqManualMode
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[IF xReleaseManualMode THEN
|
||||
_xManualModeActive := TRUE;
|
||||
_xAutomaticModeActive := FALSE;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Property Name="SafetyInterlocksOK" Id="{4a127995-0516-47b5-bd54-a8856404b497}">
|
||||
<Declaration><![CDATA[{attribute 'analysis' := '-31'}
|
||||
PROPERTY SafetyInterlocksOK : BOOL]]></Declaration>
|
||||
<Get Name="Get" Id="{74eb6ffc-1090-4dcc-bb8f-03a5108315f7}">
|
||||
<Declaration><![CDATA[VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[SafetyInterlocksOK := _xSafetyINTLKOk;]]></ST>
|
||||
</Implementation>
|
||||
</Get>
|
||||
</Property>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
60
PLC/POUs/Components/Valves/Types/ST_ValveAnalogConfig.TcDUT
Normal file
60
PLC/POUs/Components/Valves/Types/ST_ValveAnalogConfig.TcDUT
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_ValveAnalogConfig" Id="{8ae10abc-4856-40f8-b7e0-08933552acd7}">
|
||||
<Declaration><![CDATA[TYPE ST_ValveAnalogConfig :
|
||||
STRUCT
|
||||
// Analog value when valve is considered open
|
||||
// defaults to >=5%
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
rPVIsOpen : REAL := 5.0;
|
||||
|
||||
// Maximum allowable difference between setpoint and process value
|
||||
// Defaults to +-5
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
rTargetTolerance : REAL := 5.0;
|
||||
|
||||
// Time for the valve to get to the requested setpoint
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
timNotInRange : TIME := T#30S;
|
||||
|
||||
// Config parameters for the analog input
|
||||
stAnalogInputConfig : ST_ANALOG_IO_CONFIG := (iAIMax := 32767, iAIMin := 0, rPVMax := 100, rPVMin := 0);
|
||||
stAnalogInputEWConfig : ST_ANALOG_EW_CONFIG;
|
||||
|
||||
// Config parameters for the analog output
|
||||
stAnalogOutputConfig : ST_ANALOG_IO_CONFIG := (iAIMax := 32767, iAIMin := 0, rPVMax := 100, rPVMin := 0);
|
||||
|
||||
// Timeout for the valve to open
|
||||
// 0 = deactivated
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
timTimeoutOpen : TIME := T#0S;
|
||||
|
||||
// Timeout for the valve to close
|
||||
// 0 = deactivated
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
timTimeoutClose : TIME := T#0S;
|
||||
|
||||
// Valve has open feedback signal
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xHasOpenFeedback : BOOL;
|
||||
|
||||
// Valve has close feedback signal
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xHasClosedFeedback : BOOL;
|
||||
|
||||
// Valve has analog feedback signal
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xHasAnalogFeedback : BOOL;
|
||||
|
||||
// Set setpoint to use if interlocks are active
|
||||
// defaults to 0
|
||||
rSetpointWhenInterlocksActive : REAL := 0;
|
||||
|
||||
// Valve is used
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
35
PLC/POUs/Components/Valves/Types/ST_ValveConfig.TcDUT
Normal file
35
PLC/POUs/Components/Valves/Types/ST_ValveConfig.TcDUT
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_ValveConfig" Id="{cfeab4f5-40b4-416d-92f9-378624bedcc4}">
|
||||
<Declaration><![CDATA[TYPE ST_ValveConfig :
|
||||
STRUCT
|
||||
// Timeout for the valve to open
|
||||
// 0 = deactivated
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
timTimeoutOpen : TIME := T#0S;
|
||||
|
||||
// Timeout for the valve to close
|
||||
// 0 = deactivated
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
timTimeoutClose : TIME := T#0S;
|
||||
|
||||
// Valve has open feedback signal
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xHasOpenFeedback : BOOL;
|
||||
|
||||
// Valve has close feedback signal
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xHasClosedFeedback : BOOL;
|
||||
|
||||
// Set to TRUE if valve should be open instead
|
||||
// of closed with activated interlocks
|
||||
xOpenWhenInterlocksActive : BOOL := FALSE;
|
||||
|
||||
// Valve is used
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
24
PLC/POUs/Constants/GVL_TYPE_CONST.TcGVL
Normal file
24
PLC/POUs/Constants/GVL_TYPE_CONST.TcGVL
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<GVL Name="GVL_TYPE_CONST" Id="{c6299c6b-5596-4bf2-8513-3e0970c2ce61}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
{attribute 'naming' := 'off'}
|
||||
{attribute 'analysis' := '-33'}
|
||||
VAR_GLOBAL CONSTANT
|
||||
INT_MIN : INT := -32768;
|
||||
INT_MAX : INT := 32767;
|
||||
|
||||
UINT_MAX : UINT := 65535;
|
||||
UINT_MIN : UINT := 0;
|
||||
|
||||
DINT_MAX : DINT := 2147483647;
|
||||
DINT_MIN : DINT := -2147483648;
|
||||
|
||||
UDINT_MAX : UDINT := 4294967295;
|
||||
UDINT_MIN : UDINT := 0;
|
||||
|
||||
REAL_MAX : REAL := 3.042823E+38;
|
||||
REAL_MIN : REAL := 1.0E-44;
|
||||
END_VAR]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
12
PLC/POUs/GVL/GVL_CONFIGS.TcGVL
Normal file
12
PLC/POUs/GVL/GVL_CONFIGS.TcGVL
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<GVL Name="GVL_CONFIGS" Id="{528b16e8-292d-49fa-9485-85d9ddf6c11a}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
VAR_GLOBAL CONSTANT
|
||||
// Maximum number OF different interlock conditions
|
||||
// Since an interlock is defined as a WORD (size 16 BIT),
|
||||
// we have 16 interlocks
|
||||
MAX_INTERLOCKS : USINT := 16;
|
||||
END_VAR]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
54
PLC/POUs/HMI/Datentypen/ST_HMI_ANALOG_MOTOR_DATA.TcDUT
Normal file
54
PLC/POUs/HMI/Datentypen/ST_HMI_ANALOG_MOTOR_DATA.TcDUT
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_HMI_ANALOG_MOTOR_DATA" Id="{e9412b33-412b-4fea-8801-2ed1d961ca65}">
|
||||
<Declaration><![CDATA[TYPE ST_HMI_ANALOG_MOTOR_DATA :
|
||||
STRUCT
|
||||
// Button to set the valve into Automatic mode
|
||||
stAutomaticButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Button to set the valve into manual mode
|
||||
stManualButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Buttons for opening and closing the button in manual mode
|
||||
stStartButton : ST_HMI_CONTROL_BUTTON;
|
||||
stStopButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Current setpoint
|
||||
stSetpoint : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// Current process value
|
||||
stProcessValue : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// Reflects the current status of the valve
|
||||
// 1 = Running; 2 = Starting/Stopping; 3 = Stopped; 4 = Error
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iStatus : INT;
|
||||
|
||||
// Reflects the current mode of the valve
|
||||
// 1 = Automatic mode; 2 = Manual mode
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iCurrentMode : INT;
|
||||
|
||||
// Interlocks for HMI
|
||||
stInterlock : ST_HMI_INTERLOCK;
|
||||
|
||||
// Instance name (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
sName : STRING(80);
|
||||
|
||||
// true = Object ist used by the program and can be actuated by the HMI
|
||||
// false = Object is NOT used by the program and should NOT be used by the HMI
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
46
PLC/POUs/HMI/Datentypen/ST_HMI_ANALOG_VALUE.TcDUT
Normal file
46
PLC/POUs/HMI/Datentypen/ST_HMI_ANALOG_VALUE.TcDUT
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_HMI_ANALOG_VALUE" Id="{3a54dc92-9517-488a-9951-d35ff2c8f85b}">
|
||||
<Declaration><![CDATA[TYPE ST_HMI_ANALOG_VALUE :
|
||||
STRUCT
|
||||
// Current value
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
rValue : REAL;
|
||||
|
||||
// Maxmimum value defined by configuration (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
rMin : REAL;
|
||||
|
||||
// Minimum value defined by configuration (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
rMax : REAL;
|
||||
|
||||
// Unit of measurement (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
sUnit : STRING(80);
|
||||
|
||||
// Instance name (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
sName : STRING(80);
|
||||
|
||||
// Reflects the current status of the analog input (read only)
|
||||
// 1 = Ok; 2 = Error
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iStatus : INT := 0;
|
||||
|
||||
// true = Object ist used by the program and can be actuated by the HMI
|
||||
// false = Object is NOT used by the program and should NOT be used by the HMI
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
54
PLC/POUs/HMI/Datentypen/ST_HMI_ANALOG_VALVE_DATA.TcDUT
Normal file
54
PLC/POUs/HMI/Datentypen/ST_HMI_ANALOG_VALVE_DATA.TcDUT
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_HMI_ANALOG_VALVE_DATA" Id="{8cf9206f-a80c-45c9-bb5c-178cbd098270}">
|
||||
<Declaration><![CDATA[TYPE ST_HMI_ANALOG_VALVE_DATA :
|
||||
STRUCT
|
||||
// Button to set the valve into Automatic mode
|
||||
stAutomaticButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Button to set the valve into manual mode
|
||||
stManualButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Buttons for opening and closing the button in manual mode
|
||||
stOpenButton : ST_HMI_CONTROL_BUTTON;
|
||||
stCloseButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Current setpoint
|
||||
stSetpoint : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// Current process value
|
||||
stProcessValue : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// Interlocks for HMI
|
||||
stInterlock : ST_HMI_INTERLOCK;
|
||||
|
||||
// Reflects the current status of the valve
|
||||
// 1 = Opened; 2 = Opening/Closing; 3 = Closed; 4 = Error
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iStatus : INT;
|
||||
|
||||
// Reflects the current mode of the valve
|
||||
// 1 = Automatic mode; 2 = Manual mode
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iCurrentMode : INT;
|
||||
|
||||
// Instance name (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
sName : STRING(80);
|
||||
|
||||
// true = Object ist used by the program and can be actuated by the HMI
|
||||
// false = Object is NOT used by the program and should NOT be used by the HMI
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
26
PLC/POUs/HMI/Datentypen/ST_HMI_CONTROL_BUTTON.TcDUT
Normal file
26
PLC/POUs/HMI/Datentypen/ST_HMI_CONTROL_BUTTON.TcDUT
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_HMI_CONTROL_BUTTON" Id="{5039d22d-b17a-4f01-942f-a3d08ba20cd7}">
|
||||
<Declaration><![CDATA[TYPE ST_HMI_CONTROL_BUTTON :
|
||||
STRUCT
|
||||
// HMI -> PLC
|
||||
// The HMI writes here to signal the plc
|
||||
// that it wants to command this button
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
xRequest : BOOL;
|
||||
|
||||
// Signals if the Button can be used by the HMI (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xRelease : BOOL;
|
||||
|
||||
// Current state of the button (read only)
|
||||
// 0 = none, 1 = active, 2 = pending, 3 = waring, 4 = error (Type int)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
eFeedback : E_HMI_BUTTON_FEEDBACK;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
46
PLC/POUs/HMI/Datentypen/ST_HMI_INTEGER_VALUE.TcDUT
Normal file
46
PLC/POUs/HMI/Datentypen/ST_HMI_INTEGER_VALUE.TcDUT
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_HMI_INTEGER_VALUE" Id="{257b8b79-4109-405a-aaf8-5fd1c6431eee}">
|
||||
<Declaration><![CDATA[TYPE ST_HMI_INTEGER_VALUE :
|
||||
STRUCT
|
||||
// Current value
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
iValue : INT;
|
||||
|
||||
// Maxmimum value defined by configuration (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iMin : INT;
|
||||
|
||||
// Minimum value defined by configuration (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iMax : INT;
|
||||
|
||||
// Unit of measurement (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
sUnit : STRING(80);
|
||||
|
||||
// Instance name (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
sName : STRING(80);
|
||||
|
||||
// Reflects the current status of the analog input (read only)
|
||||
// 1 = Ok; 2 = Error
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iStatus : INT := 0;
|
||||
|
||||
// true = Object ist used by the program and can be actuated by the HMI
|
||||
// false = Object is NOT used by the program and should NOT be used by the HMI
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
50
PLC/POUs/HMI/Datentypen/ST_HMI_INTERLOCK.TcDUT
Normal file
50
PLC/POUs/HMI/Datentypen/ST_HMI_INTERLOCK.TcDUT
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_HMI_INTERLOCK" Id="{7280bab4-f308-456f-81a8-d90e7dab2738}">
|
||||
<Declaration><![CDATA[TYPE ST_HMI_INTERLOCK :
|
||||
STRUCT
|
||||
// Each bit represents the current interlock status
|
||||
// TRUE = Interlock OK
|
||||
// FALSE = Interlock not OK
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
wProcessINTLKStatus : T_INTERLOCK;
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
wSafetyINTLKStatus : T_INTERLOCK;
|
||||
|
||||
// Each bit represents an interlock which is monitored
|
||||
// TRUE = Interlock bit is used
|
||||
// FALSE = Interlock bit is not used
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
wProcessINTLKUsed : T_INTERLOCK;
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
wSafetyINTLKUsed : T_INTERLOCK;
|
||||
|
||||
|
||||
// Descriptive name of each interlock
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
{attribute 'analysis' := '-33'}
|
||||
asProcessINTLKName : ARRAY [0..(GVL_CONFIGS.MAX_INTERLOCKS-1)] OF STRING(80);
|
||||
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
{attribute 'analysis' := '-33'}
|
||||
asSafetyINTLKName : ARRAY [0..(GVL_CONFIGS.MAX_INTERLOCKS-1)] OF STRING(80);
|
||||
|
||||
// Represents the combined process interlock status
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xProcessINTLKOk : BOOL;
|
||||
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xSafetyINTLKOk : BOOL;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
47
PLC/POUs/HMI/Datentypen/ST_HMI_ORP_SENSOR_DATA.TcDUT
Normal file
47
PLC/POUs/HMI/Datentypen/ST_HMI_ORP_SENSOR_DATA.TcDUT
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_HMI_ORP_SENSOR_DATA" Id="{5591496f-c48a-4039-866c-f9454b697632}">
|
||||
<Declaration><![CDATA[TYPE ST_HMI_ORP_SENSOR_DATA :
|
||||
STRUCT
|
||||
// PH sensor value
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
rValuePH : REAL;
|
||||
|
||||
// Temperature sensor value
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
rValueTemp : REAL;
|
||||
|
||||
// Redox potential sensor data
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
rValueORP : REAL;
|
||||
|
||||
// Sensor lifetime left
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
rValueDLI : REAL;
|
||||
|
||||
// Reflects the current status of the ORP input data (read only)
|
||||
// 1 = Ok; 2 = Error
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iStatus : INT := 0;
|
||||
|
||||
// Instance name (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
sName : STRING(80);
|
||||
|
||||
// true = Object ist used by the program and can be actuated by the HMI
|
||||
// false = Object is NOT used by the program and should NOT be used by the HMI
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
49
PLC/POUs/HMI/Datentypen/ST_HMI_VALVE_DATA.TcDUT
Normal file
49
PLC/POUs/HMI/Datentypen/ST_HMI_VALVE_DATA.TcDUT
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_HMI_VALVE_DATA" Id="{6751dac7-5b57-4a36-91da-fd2e723254c5}">
|
||||
<Declaration><![CDATA[TYPE ST_HMI_VALVE_DATA :
|
||||
STRUCT
|
||||
// Button to set the valve into Automatic mode
|
||||
stAutomaticButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Button to set the valve into manual mode
|
||||
stManualButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Buttons for opening and closing the button in manual mode
|
||||
stOpenButton : ST_HMI_CONTROL_BUTTON;
|
||||
stCloseButton : ST_HMI_CONTROL_BUTTON;
|
||||
|
||||
// Reflects the current status of the valve
|
||||
// 1 = Opened; 2 = Opening/Closing; 3 = Closed; 4 = Error
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iStatus : INT;
|
||||
|
||||
// Reflects the current mode of the valve
|
||||
// 1 = Automatic mode; 2 = Manual mode
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
iCurrentMode : INT;
|
||||
|
||||
// Interlocks for HMI
|
||||
stInterlock : ST_HMI_INTERLOCK;
|
||||
|
||||
// Instance name (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
sName : STRING(80);
|
||||
|
||||
// true = Object ist used by the program and can be actuated by the HMI
|
||||
// false = Object is NOT used by the program and should NOT be used by the HMI
|
||||
// (read only)
|
||||
{attribute 'OPC.UA.DA' := '1'}
|
||||
{attribute 'OPC.UA.DA.Access' := '1'}
|
||||
xUsed : BOOL := TRUE;
|
||||
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
7
PLC/POUs/HMI/Datentypen/T_INTERLOCK.TcDUT
Normal file
7
PLC/POUs/HMI/Datentypen/T_INTERLOCK.TcDUT
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="T_INTERLOCK" Id="{ec032632-1f17-4d00-bf8d-22bf3be720ca}">
|
||||
<Declaration><![CDATA[TYPE T_INTERLOCK : WORD; END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
14
PLC/POUs/HMI/Enum/E_HMI_ANALOG_VALUE_STATUS.TcDUT
Normal file
14
PLC/POUs/HMI/Enum/E_HMI_ANALOG_VALUE_STATUS.TcDUT
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="E_HMI_ANALOG_VALUE_STATUS" Id="{a3c070c3-4456-4cc5-87b7-d5db4abc287e}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
{attribute 'strict'}
|
||||
TYPE E_HMI_ANALOG_VALUE_STATUS :
|
||||
(
|
||||
OK := 1,
|
||||
ERROR := 2
|
||||
);
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
18
PLC/POUs/HMI/Enum/E_HMI_BUTTON_FEEDBACK.TcDUT
Normal file
18
PLC/POUs/HMI/Enum/E_HMI_BUTTON_FEEDBACK.TcDUT
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="E_HMI_BUTTON_FEEDBACK" Id="{dd7c6534-9dcb-4c09-86a7-742a590c8efa}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
{attribute 'strict'}
|
||||
{attribute 'analysis' := '-32'}
|
||||
TYPE E_HMI_BUTTON_FEEDBACK :
|
||||
(
|
||||
NONE := 0,
|
||||
ACTIVE := 1,
|
||||
PENDING := 2,
|
||||
WARNING := 3,
|
||||
ERROR := 4
|
||||
) INT := NONE;
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
14
PLC/POUs/HMI/Enum/E_HMI_MODE.TcDUT
Normal file
14
PLC/POUs/HMI/Enum/E_HMI_MODE.TcDUT
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="E_HMI_MODE" Id="{819c1a48-9d62-42a0-ace9-1d45c5e49819}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
{attribute 'strict'}
|
||||
TYPE E_HMI_MODE :
|
||||
(
|
||||
AUTOMATIC := 1,
|
||||
MANUAL := 2
|
||||
);
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
16
PLC/POUs/HMI/Enum/E_HMI_MOTOR_STATUS.TcDUT
Normal file
16
PLC/POUs/HMI/Enum/E_HMI_MOTOR_STATUS.TcDUT
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="E_HMI_MOTOR_STATUS" Id="{d99897af-6865-4ec7-a780-4ac4e69129e1}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
{attribute 'strict'}
|
||||
TYPE E_HMI_MOTOR_STATUS :
|
||||
(
|
||||
RUNNING := 1,
|
||||
TRANSITIONING := 2,
|
||||
STOPPED := 3,
|
||||
ERROR := 4
|
||||
);
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
16
PLC/POUs/HMI/Enum/E_HMI_VALVE_STATUS.TcDUT
Normal file
16
PLC/POUs/HMI/Enum/E_HMI_VALVE_STATUS.TcDUT
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="E_HMI_VALVE_STATUS" Id="{1997df70-e467-40ef-b432-9fb399b78557}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
{attribute 'strict'}
|
||||
TYPE E_HMI_VALVE_STATUS :
|
||||
(
|
||||
OPENED := 1,
|
||||
TRANSITIONING := 2,
|
||||
CLOSED := 3,
|
||||
ERROR := 4
|
||||
);
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -1,13 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="PRG_MAIN" Id="{f325d0cd-99c8-4d5b-980f-1fc96ab1417c}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[PROGRAM PRG_MAIN
|
||||
<Declaration><![CDATA[{attribute 'analysis' := '-33'}
|
||||
PROGRAM PRG_MAIN
|
||||
VAR
|
||||
{attribute 'analysis' := '-33'}
|
||||
// Analog I/O tests
|
||||
_fbAnalogInputTest : FB_AnalogInputTest;
|
||||
_fbAnalogOutputTest : FB_AnalogOutputTest;
|
||||
|
||||
_fbEventlistener : FB_EventListener(sHostName := '127.0.0.1', uiHostPort := 1883, sTopic := 'SlmMachine/Notifications/PLC/Detail');
|
||||
// Valve tests
|
||||
_fbValve_Test : FB_Valve_Test;
|
||||
_fbValve_TimeoutTestOpen : FB_ValveTestTimoutOpen;
|
||||
_fbValve_TimeoutTestClose : FB_ValveTestTimoutClose;
|
||||
_fbValve_TimoutTriggerOpen : FB_ValveTestTriggerTimoutOpen;
|
||||
_fbValve_TimoutTriggerClose : FB_ValveTestTriggerTimoutClose;
|
||||
|
||||
_fbValveAnalogTest : FB_ValveAnalog_Test;
|
||||
|
||||
_fbValveTestHMI : FB_ValveTestHMI;
|
||||
|
||||
// Release signal test
|
||||
_fbReleaseSignalTest : FB_ReleaseSignalTest;
|
||||
|
||||
// Utilities tests
|
||||
_fbBlinkerTest : FB_BlinkerTest;
|
||||
_fbRampGeneratorTest : FB_RampGeneratorTest;
|
||||
_fbHashFNV1a_32BitTest : FB_HashFNV1a_32BitTest;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
|
||||
469
PLC/POUs/Unittests/AOTests/FB_AnalogOutputTest.TcPOU
Normal file
469
PLC/POUs/Unittests/AOTests/FB_AnalogOutputTest.TcPOU
Normal file
@@ -0,0 +1,469 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_AnalogOutputTest" Id="{ebe472aa-270b-4ff7-b47b-01e41ab792c6}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_AnalogOutputTest EXTENDS TcUnit.FB_TestSuite
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
END_VAR
|
||||
VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// test invalid parameter
|
||||
TestConfigErrorDivisionByZero();
|
||||
TestConfigErrorNegativMaxMinusMin();
|
||||
|
||||
// test HMI
|
||||
TestHMIOutput();
|
||||
|
||||
// test functionality itself
|
||||
TestOutputScaling();
|
||||
|
||||
// test clamping
|
||||
TestSetpointUpperCap();
|
||||
TestSetpointLowerCap();
|
||||
|
||||
// test unused
|
||||
TestUnused();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestConfigErrorDivisionByZero" Id="{eb0c63a7-066d-4e01-b0f9-aedc1022b328}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestConfigErrorDivisionByZero
|
||||
VAR
|
||||
// analog output instance
|
||||
_fbAnalogOutput : FB_AnalogOutput('');
|
||||
|
||||
// analog output config
|
||||
_stAnalogOutputConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// analog output hmi data
|
||||
_stHMIInterface : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// conversion result
|
||||
_iAnalogOutput : INT;
|
||||
|
||||
// fb error
|
||||
_xError : BOOL;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestConfigErrorDivisionByZero');
|
||||
|
||||
// denom = udiAIMax - udiAIMin
|
||||
// Test if no crash occurs when denom equals zero
|
||||
_stAnalogOutputConfig.iAIMax := 4095;
|
||||
_stAnalogOutputConfig.iAIMin := 0;
|
||||
_stAnalogOutputConfig.rPVMax := 0;
|
||||
_stAnalogOutputConfig.rPVMin := 0;
|
||||
|
||||
// run analog scaling
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 100,
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// evaluate Error and result to zero
|
||||
AssertTrue(_xError, 'There should be an error when trying to divide by zero.');
|
||||
AssertEquals_INT(Expected := 0, Actual := _iAnalogOutput, 'Output is expected to be zero when trying to divide by zero');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestConfigErrorNegativMaxMinusMin" Id="{6f3e2737-a3ba-4909-b974-955bc0e635c3}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestConfigErrorNegativMaxMinusMin
|
||||
VAR
|
||||
// analog output instance
|
||||
_fbAnalogOutput : FB_AnalogOutput('');
|
||||
|
||||
// analog output config
|
||||
_stAnalogOutputConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// analog output hmi data
|
||||
_stHMIInterface : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// conversion result
|
||||
_iAnalogOutput : INT;
|
||||
|
||||
// fb error
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestConfigErrorNegativMaxMinusMin');
|
||||
|
||||
// denom = udiAIMax - udiAIMin
|
||||
// Test if no crash occurs when denom is smaller than zero
|
||||
_stAnalogOutputConfig.iAIMax := 4095;
|
||||
_stAnalogOutputConfig.iAIMin := 0;
|
||||
_stAnalogOutputConfig.rPVMax := 0;
|
||||
_stAnalogOutputConfig.rPVMin := 1;
|
||||
|
||||
|
||||
// run analog scaling
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 100,
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// evaluate Error and result to zero
|
||||
AssertTrue(_xError, 'There should be an error when trying to divide by zero.');
|
||||
AssertEquals_INT(Expected := 0, Actual := _iAnalogOutput, 'Output is expected to be zero when trying to divide by negative number.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestHMIOutput" Id="{6b0d589b-625b-471a-8f08-48db4bd05305}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestHMIOutput
|
||||
VAR
|
||||
// analog output instance
|
||||
_fbAnalogOutput : FB_AnalogOutput('Name');
|
||||
|
||||
// analog output config
|
||||
_stAnalogOutputConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// analog output hmi data
|
||||
_stHMIInterface : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// conversion result
|
||||
_iAnalogOutput : INT;
|
||||
|
||||
// fb error
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected hmi values
|
||||
sName : STRING := 'Name';
|
||||
sUnit : STRING := 'm/s';
|
||||
iOk : INT := 1;
|
||||
iError : INT := 2;
|
||||
|
||||
// delta for assertion
|
||||
rDelta : REAL := 0.01;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestHMIOutput');
|
||||
|
||||
// some example settings
|
||||
_stAnalogOutputConfig.iAIMax := 4095; //12 bit max
|
||||
_stAnalogOutputConfig.iAIMin := 0;
|
||||
_stAnalogOutputConfig.rPVMax := 100;
|
||||
_stAnalogOutputConfig.rPVMin := 50;
|
||||
_stAnalogOutputConfig.sUnit := sUnit;
|
||||
|
||||
// run analog scaling
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 60, //60 * 81,9 - 4095 = 819
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// due to only moving real, a delta of 0.01 should be sufficient.
|
||||
// testing all HMI values
|
||||
AssertEquals_REAL(Expected := _stAnalogOutputConfig.rPVMax, Actual := _stHMIInterface.rMax, Delta := rDelta,'rMax was not passed to HMI correctly.');
|
||||
AssertEquals_REAL(Expected := _stAnalogOutputConfig.rPVMin, Actual := _stHMIInterface.rMin, Delta := rDelta,'rMin was not passed to HMI correctly.');
|
||||
// rValue from HMI Interface functions as an Input to the FB. If the FB would write it back we would have a loop!
|
||||
{analysis -140}
|
||||
//AssertEquals_REAL(Expected := rExpected, Actual := stHMIInterface.rValue, Delta := rDelta,'rValue was not passed to HMI correctly.');
|
||||
{analysis +140}
|
||||
AssertEquals_STRING(Expected := sName, Actual := _stHMIInterface.sName, 'sName was not passed to HMI correctly.');
|
||||
AssertEquals_STRING(Expected := sUnit, Actual := _stHMIInterface.sUnit, 'sUnit was not passed to HMI correctly.');
|
||||
AssertTrue(_stHMIInterface.xUsed, 'xUsed is not passed to HMI correctly.');
|
||||
AssertEquals_INT(Expected := iOk, Actual := _stHMIInterface.iStatus, 'Status is Error when OK was expected.');
|
||||
|
||||
// testing error passtrough (div by zero)
|
||||
_stAnalogOutputConfig.rPVMax := 0;
|
||||
_stAnalogOutputConfig.rPVMin := 0;
|
||||
|
||||
// run analog scaling
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 0,
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError);
|
||||
|
||||
// reading error from HMI interface
|
||||
AssertEquals_INT(Expected := iError, Actual := _stHMIInterface.iStatus, 'Status is OK when Error was expected.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputScaling" Id="{60f43e92-2d83-42da-8c76-29a4e23f243d}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestOutputScaling
|
||||
VAR
|
||||
// analog output instance
|
||||
_fbAnalogOutput : FB_AnalogOutput('');
|
||||
|
||||
// analog output config
|
||||
_stAnalogOutputConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// analog output hmi data
|
||||
_stHMIInterface : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// conversion result
|
||||
_iAnalogOutput : INT;
|
||||
|
||||
// fb error
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected conversion results
|
||||
iExpected1 : INT := 819;
|
||||
iExpected2 : INT := 3071;
|
||||
iExpected3 : INT := 354;
|
||||
iExpected4 : INT := 4013;
|
||||
iExpected5 : INT := 2058;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputScaling');
|
||||
|
||||
// some example settings
|
||||
_stAnalogOutputConfig.iAIMax := 4095; //12 bit max
|
||||
_stAnalogOutputConfig.iAIMin := 0;
|
||||
_stAnalogOutputConfig.rPVMax := 100;
|
||||
_stAnalogOutputConfig.rPVMin := 50;
|
||||
|
||||
// run first value
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 60, //60 * 81,9 - 4095 = 819
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// and evaluate result
|
||||
AssertFalse(_xError, 'There should not be an error here.');
|
||||
AssertEquals_INT(Expected := iExpected1, Actual := _iAnalogOutput,'Result was not calculated correctly.');
|
||||
|
||||
// run second value
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 87.5, //87,5 * 81,9 - 4095 = 3071
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError);
|
||||
|
||||
// and evaluate result
|
||||
AssertFalse(_xError, 'There should not be an error here.');
|
||||
AssertEquals_INT(Expected := iExpected2, Actual := _iAnalogOutput,'Result was not calculated correctly.');
|
||||
|
||||
// run third value
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 54.321, //54,321 * 81,9 - 4095 = 354
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError);
|
||||
|
||||
// and evaluate result
|
||||
AssertFalse(_xError, 'There should not be an error here.');
|
||||
AssertEquals_INT(Expected := iExpected3, Actual := _iAnalogOutput,'Result was not calculated correctly.');
|
||||
|
||||
// run forth value
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 99, //99 * 81,9 - 4095 = 4013
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError);
|
||||
|
||||
// and evaluate result
|
||||
AssertFalse(_xError, 'There should not be an error here.');
|
||||
AssertEquals_INT(Expected := iExpected4, Actual := _iAnalogOutput,'Result was not calculated correctly.');
|
||||
|
||||
// run fifth value
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 75.12345, // 75,12345 * 81,9 - 4095 = 2058
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError);
|
||||
|
||||
// and evaluate result
|
||||
AssertFalse(_xError, 'There should not be an error here.');
|
||||
AssertEquals_INT(Expected := iExpected5, Actual := _iAnalogOutput,'Result was not calculated correctly.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestSetpointLowerCap" Id="{807912d5-bba1-425b-bbaa-8753f0659a61}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestSetpointLowerCap
|
||||
VAR
|
||||
// analog output instance
|
||||
_fbAnalogOutput : FB_AnalogOutput('');
|
||||
|
||||
// analog output config
|
||||
_stAnalogOutputConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// analog output hmi data
|
||||
_stHMIInterface : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// conversion result
|
||||
_iAnalogOutput : INT;
|
||||
|
||||
// fb error
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected lower cap result
|
||||
iExpected : INT := 0;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestSetpointLowerCap');
|
||||
|
||||
// some example settings
|
||||
_stAnalogOutputConfig.iAIMax := 4095; //12 bit max
|
||||
_stAnalogOutputConfig.iAIMin := 0;
|
||||
_stAnalogOutputConfig.rPVMax := 100;
|
||||
_stAnalogOutputConfig.rPVMin := 50;
|
||||
|
||||
// run with setpoint lower than lower cap
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 30,
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// evaluate wethere the result is the equivalent of lower cap or not
|
||||
AssertFalse(_xError, 'There should not be an error here.');
|
||||
AssertEquals_INT(Expected := iExpected, Actual := _iAnalogOutput,'Setpoint was expected to be capped.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestSetpointUpperCap" Id="{286c1c76-f998-4c94-9225-155b9dc5d782}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestSetpointUpperCap
|
||||
VAR
|
||||
// analog output instance
|
||||
_fbAnalogOutput : FB_AnalogOutput('');
|
||||
|
||||
// analog output config
|
||||
_stAnalogOutputConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// analog output hmi data
|
||||
_stHMIInterface : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// conversion result
|
||||
_iAnalogOutput : INT;
|
||||
|
||||
// fb error
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected upper cap result
|
||||
iExpected : INT := 4095;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestSetpointUpperCap');
|
||||
|
||||
// some example settings
|
||||
_stAnalogOutputConfig.iAIMax := 4095; //12 bit max
|
||||
_stAnalogOutputConfig.iAIMin := 0;
|
||||
_stAnalogOutputConfig.rPVMax := 100;
|
||||
_stAnalogOutputConfig.rPVMin := 50;
|
||||
|
||||
// run with setpoint higher than upper cap
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 110,
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// evaluate wethere the result is the equivalent of upper cap or not
|
||||
AssertFalse(_xError, 'There should not be an error here.');
|
||||
AssertEquals_INT(Expected := iExpected, Actual := _iAnalogOutput,'Setpoint was expected to be capped.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestUnused" Id="{5c9c0209-9c4b-4d43-90e6-a77c731cebf3}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestUnused
|
||||
VAR
|
||||
// analog output instance
|
||||
_fbAnalogOutput : FB_AnalogOutput('');
|
||||
|
||||
// analog output config
|
||||
_stAnalogOutputConfig : ST_ANALOG_IO_CONFIG;
|
||||
|
||||
// analog output hmi data
|
||||
_stHMIInterface : ST_HMI_ANALOG_VALUE;
|
||||
|
||||
// conversion result
|
||||
_iAnalogOutput : INT;
|
||||
|
||||
// fb error
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestUnused');
|
||||
|
||||
// some example settings
|
||||
_stAnalogOutputConfig.xUsed := FALSE;
|
||||
|
||||
// run analog output
|
||||
_fbAnalogOutput(
|
||||
rSetpoint := 100,
|
||||
stAnalogIOConfig := _stAnalogOutputConfig,
|
||||
xReleaseErrors := ,
|
||||
xConfirmAlarms := ,
|
||||
stHMIInterface := _stHMIInterface,
|
||||
iAnalogValue => _iAnalogOutput,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// test for error and output (should not be present and 0 when unused)
|
||||
AssertFalse(_xError, 'There should not be an error when unused.');
|
||||
AssertEquals_INT(Expected := 0, Actual := _iAnalogOutput, 'Output is expected to be zero when unused');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
547
PLC/POUs/Unittests/AnalogValveTests/FB_ValveAnalog_Test.TcPOU
Normal file
547
PLC/POUs/Unittests/AnalogValveTests/FB_ValveAnalog_Test.TcPOU
Normal file
@@ -0,0 +1,547 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveAnalog_Test" Id="{9dc8ec77-f523-463e-8c0f-b11bbdcadb17}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ValveAnalog_Test EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Automatic Mode
|
||||
SwitchToAutomaticMode();
|
||||
|
||||
// Manual Mode
|
||||
SwitchToManualMode();
|
||||
|
||||
// Test interlocks
|
||||
TestProcessInterlocks();
|
||||
TestProcessINTLKsInAutomaticMode();
|
||||
TestProcessINTLKsInManualMode();
|
||||
|
||||
// Check feedback signals
|
||||
CheckOpenCloseFeedbacks();
|
||||
|
||||
// Test Open/Close Valves
|
||||
OpenCloseValveInAutomaticMode();
|
||||
OpenCloseValveInManualMode();
|
||||
|
||||
// check range errors
|
||||
CheckNotInRangeError();
|
||||
CheckOverrange();
|
||||
CheckUnderrange();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="CheckNotInRangeError" Id="{f10fdc9b-52ba-49cf-9c89-aee87b8a1ee1}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD CheckNotInRangeError
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveAnalogConfig;
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve error output
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('CheckNotInRangeError');
|
||||
|
||||
// config valve to
|
||||
_stValveConfig.xHasAnalogFeedback := TRUE;
|
||||
_stValveConfig.rTargetTolerance := 5;
|
||||
_stValveConfig.timNotInRange := T#0S;
|
||||
_stValveConfig.stAnalogInputConfig.iAIMax :=4095;
|
||||
_stValveConfig.stAnalogInputConfig.iAIMin :=0;
|
||||
_stValveConfig.stAnalogInputConfig.rPVMax :=100;
|
||||
_stValveConfig.stAnalogInputConfig.rPVMin :=0;
|
||||
|
||||
// Set in automatic mode and open valve
|
||||
_fbValve.ReqAutomaticMode();
|
||||
_fbValve.rSPAutomatic := 100;
|
||||
|
||||
// needs one cycle to write values (scaled feedback ~75, tolerance 95 to 105)
|
||||
_fbValve(xAutomaticOpen := TRUE, stValveConfig := _stValveConfig, stHMIInterface := _stHMIValve, iFeedbackValue := 3000, xError => _xError, xInUnitTestMode := TRUE);
|
||||
|
||||
// assert result
|
||||
AssertTrue(_xError, 'Expected NotInRangeError, got no error.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="CheckOpenCloseFeedbacks" Id="{ce54a6cd-7831-4ab3-aa0c-464e9a0018d6}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD CheckOpenCloseFeedbacks
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveAnalogConfig;
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve feedback
|
||||
_xOpenFeedback : BOOL := FALSE;
|
||||
_xCloseFeedback : BOOL := FALSE;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('CheckOpenCloseFeedbacks');
|
||||
|
||||
// set open+close feedback to present, analog feedback to false
|
||||
_stValveConfig.xHasAnalogFeedback := FALSE;
|
||||
_stValveConfig.xHasOpenFeedback := TRUE;
|
||||
_stValveConfig.xHasClosedFeedback := TRUE;
|
||||
|
||||
// Test feedbacks in manual mode
|
||||
_xOpenFeedback := FALSE;
|
||||
_xCloseFeedback := FALSE;
|
||||
_fbValve.xReleaseManualMode := TRUE;
|
||||
_fbValve.ReqManualMode();
|
||||
_fbValve(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig, xInUnitTestMode := TRUE);
|
||||
|
||||
|
||||
// We should now be in manual mode
|
||||
AssertTrue(Condition := _fbValve.IsInManualMode, Message := 'Valve did not changed to manual mode');
|
||||
|
||||
|
||||
// Test closed
|
||||
_xOpenFeedback := FALSE;
|
||||
_xCloseFeedback := TRUE;
|
||||
_fbValve(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig, xInUnitTestMode := TRUE);
|
||||
AssertTrue(Condition := _fbValve.IsClosed, Message := 'Valve should be closed');
|
||||
AssertFalse(Condition := _fbValve.IsOpen, Message := 'Valve should not be open');
|
||||
|
||||
// Test opened
|
||||
_xOpenFeedback := TRUE;
|
||||
_xCloseFeedback := FALSE;
|
||||
_stHMIValve.stSetpoint.rValue := 100.0;
|
||||
_fbValve(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig, xInUnitTestMode := TRUE);
|
||||
AssertTrue(Condition := _fbValve.IsOpen, Message := 'Valve should be open');
|
||||
AssertFalse(Condition := _fbValve.IsClosed, Message := 'Valve should not be closed');
|
||||
|
||||
// Test open and close
|
||||
_xOpenFeedback := TRUE;
|
||||
_xCloseFeedback := TRUE;
|
||||
_fbValve(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig, xInUnitTestMode := TRUE);
|
||||
AssertFalse(Condition := _fbValve.IsClosed OR _fbValve.IsOpen, Message := 'Valve should not signal open or closed with both feedback signals high');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="CheckOverrange" Id="{6a8f595e-e480-42ad-a991-d9700b5e80d0}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD CheckOverrange
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveAnalogConfig;
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve error output
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('CheckOverrange');
|
||||
|
||||
// set delay to zero to make single cycle test possible (AnalogInput is tested individually)
|
||||
_stValveConfig.stAnalogInputEWConfig.stDelays.timHardwareSignalLevelOn := T#0S;
|
||||
_stValveConfig.xHasAnalogFeedback := TRUE;
|
||||
|
||||
// needs one cycle to write values, xOverrange must be connected.
|
||||
_fbValve(
|
||||
stValveConfig := _stValveConfig,
|
||||
stHMIInterface := _stHMIValve,
|
||||
xFeedbackOverrange := TRUE,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// assert result
|
||||
AssertTrue(_xError, 'Expected Overrange error, got no error.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="CheckUnderrange" Id="{4d7e06e3-a833-4b91-a285-8e2fb59100bd}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD CheckUnderrange
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveAnalogConfig;
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve error output
|
||||
_xError : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('CheckUnderrange');
|
||||
|
||||
// set delay to zero to make single cycle test possible (AnalogInput is tested individually)
|
||||
_stValveConfig.stAnalogInputEWConfig.stDelays.timHardwareSignalLevelOn := T#0S;
|
||||
_stValveConfig.xHasAnalogFeedback := TRUE;
|
||||
|
||||
// needs one cycle to write values, xUnderrange must be connected.
|
||||
_fbValve(
|
||||
stValveConfig := _stValveConfig,
|
||||
stHMIInterface := _stHMIValve,
|
||||
xFeedbackUnderrange := TRUE,
|
||||
xError => _xError,
|
||||
xInUnitTestMode := TRUE);
|
||||
|
||||
// assert result
|
||||
AssertTrue(_xError, 'Expected Underrange error, got no error.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="OpenCloseValveInAutomaticMode" Id="{fc3da46f-724a-400a-ab82-86cb17e3d842}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD OpenCloseValveInAutomaticMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('OpenCloseValveInAutomaticMode');
|
||||
|
||||
// Set in automatic mode
|
||||
_fbValve.ReqAutomaticMode();
|
||||
|
||||
// Open valve
|
||||
_fbValve.rSPAutomatic := 100;
|
||||
|
||||
// Needs one cycle to write outputs
|
||||
_fbValve(xAutomaticOpen := TRUE, stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// evaluate valve state
|
||||
_xResult := _fbValve.IsOpen AND NOT _fbValve.IsClosed;
|
||||
AssertTrue(_xResult, 'Valve did not open in Automatic Mode');
|
||||
|
||||
// Close valve
|
||||
_fbValve.rSPAutomatic := 0;
|
||||
|
||||
// Needs one cycle to write outputs
|
||||
_fbValve(xAutomaticOpen := FALSE, stHMIInterface := _stHMIValve);
|
||||
|
||||
// evaluate valve state
|
||||
_xResult := _fbValve.IsClosed AND NOT _fbValve.IsOpen;
|
||||
AssertTrue(_xResult, 'Valve did not close in Automatic Mode');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="OpenCloseValveInManualMode" Id="{1349619a-f843-4cf9-9143-1a752f089a58}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD OpenCloseValveInManualMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('OpenCloseValveInManualMode');
|
||||
|
||||
// release manual mode
|
||||
_fbValve.xReleaseManualMode := TRUE;
|
||||
|
||||
// Set in manual mode
|
||||
_fbValve.ReqManualMode();
|
||||
|
||||
// Open valve and call block
|
||||
_stHMIValve.stSetpoint.rValue := 100;
|
||||
_stHMIValve.stOpenButton.xRequest := TRUE;
|
||||
_fbValve(stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// evaluate valve state
|
||||
_xResult := _fbValve.IsOpen AND NOT _fbValve.IsClosed;
|
||||
AssertTrue(_xResult, 'Valve did not open in Manual Mode');
|
||||
|
||||
// Close valve and call block
|
||||
_stHMIValve.stCloseButton.xRequest := TRUE;
|
||||
_fbValve(stHMIInterface := _stHMIValve);
|
||||
|
||||
// evaluate valve state
|
||||
_xResult := _fbValve.IsClosed AND NOT _fbValve.IsOpen;
|
||||
AssertTrue(_xResult, 'Valve did not close in Manual Mode');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SwitchToAutomaticMode" Id="{7c51a185-7dd4-4b8d-9873-f1eaa22c97e6}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD SwitchToAutomaticMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('SwitchToAutomaticMode');
|
||||
|
||||
// request switch to automatic mode
|
||||
_fbValve.ReqAutomaticMode();
|
||||
|
||||
// call valve block
|
||||
_fbValve(stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// assert valve mode
|
||||
_xResult := _fbValve.IsInAutomaticMode;
|
||||
AssertTrue(_xResult, 'Valve did not change into Automatic Mode');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SwitchToManualMode" Id="{84f7ce91-9e5d-4bc0-8681-d7a35657e9a9}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD SwitchToManualMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('SwitchToManualMode');
|
||||
|
||||
// Test switch without xReleaseManualMode
|
||||
_fbValve.xReleaseManualMode := FALSE;
|
||||
_fbValve.ReqManualMode();
|
||||
_fbValve(stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
_xResult := NOT _fbValve.IsInManualMode;
|
||||
AssertTrue(_xResult, 'Valve changed to Manual Mode but this mode was not released');
|
||||
|
||||
// Test with xReleaseManualMode
|
||||
_fbValve.xReleaseManualMode := TRUE;
|
||||
_fbValve.ReqManualMode();
|
||||
_fbValve(stHMIInterface := _stHMIValve);
|
||||
_xResult := _fbValve.IsInManualMode;
|
||||
AssertTrue(_xResult, 'Valve did not changed to Manual Mode');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestProcessInterlocks" Id="{2152677d-8778-48f4-98dc-366509ac6287}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
{attribute 'analysis' := '-81'}
|
||||
METHOD TestProcessInterlocks
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
|
||||
// current interlock
|
||||
_usiCounter : USINT;
|
||||
|
||||
// Init all entries to TRUE
|
||||
_wInterlocks : T_INTERLOCK := 2#1111_1111_1111_1111;//[GVL_VALVE.MAX_INTERLOCKS(TRUE)];
|
||||
_wInterlocksUsed : T_INTERLOCK := 2#1111_1111_1111_1111;
|
||||
|
||||
// induvidual interlock test result
|
||||
_axInterlockTestResultFalse : ARRAY[0..GVL_CONFIGS.MAX_INTERLOCKS-1] OF BOOL;
|
||||
_axInterlockTestResultTrue : ARRAY[0..GVL_CONFIGS.MAX_INTERLOCKS-1] OF BOOL;
|
||||
|
||||
// comulated interlock test result
|
||||
_xInterlocksFalseOK : BOOL;
|
||||
_xInterlocksTrueOK : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// loop iterations for interlock test
|
||||
usiEndValue : USINT := GVL_CONFIGS.MAX_INTERLOCKS-1;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Test interlocks as reutrn value
|
||||
TEST('TestProcessInterlocks');
|
||||
|
||||
// call valve block and evaluate interlocks
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
_xResult := _fbValve.ProcessInterlocksOK;
|
||||
|
||||
AssertTrue(_xResult, 'Interlocks not Ok but should be');
|
||||
|
||||
// Test each interlock individually
|
||||
// Save the result in the two following variables
|
||||
_xInterlocksFalseOK := TRUE;
|
||||
_xInterlocksTrueOK := TRUE;
|
||||
|
||||
FOR _usiCounter := 0 TO usiEndValue DO
|
||||
|
||||
// Test one interlock for false and then disable it
|
||||
_wInterlocks := SHL(_wInterlocks, 1);
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Save result in an array for later debugging if necessary
|
||||
_axInterlockTestResultFalse[_usiCounter] := _fbValve.ProcessInterlocksOK;
|
||||
|
||||
// Save global result
|
||||
IF _fbValve.ProcessInterlocksOK THEN
|
||||
_xInterlocksFalseOK := FALSE;
|
||||
END_IF
|
||||
// Disable this interlock after testing it
|
||||
_wInterlocksUsed := SHL(_wInterlocksUsed, 1);
|
||||
|
||||
// Test if, after disabling the interlock, the interlocks are ok again
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Save result in an array for later debugging if necessary
|
||||
_axInterlockTestResultTrue[_usiCounter] := _fbValve.ProcessInterlocksOK;
|
||||
|
||||
// Save global result
|
||||
IF NOT _fbValve.ProcessInterlocksOK THEN
|
||||
_xInterlocksTrueOK := FALSE;
|
||||
END_IF
|
||||
END_FOR
|
||||
|
||||
// Test False interlocks result
|
||||
AssertTrue(_xInterlocksFalseOK, 'Interlock should not be ok but are');
|
||||
|
||||
// Test False interlocks result
|
||||
AssertTrue(_xInterlocksTrueOK, 'Interlock should be ok but are not');
|
||||
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestProcessINTLKsInAutomaticMode" Id="{468a3341-78b1-4d81-96e1-32c340664094}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestProcessINTLKsInAutomaticMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;
|
||||
|
||||
// valve analog config
|
||||
_stAnalogValveConfig : ST_ValveAnalogConfig;
|
||||
|
||||
// valve interlocks
|
||||
_wInterlocks : T_INTERLOCK;
|
||||
_wInterlocksUsed : T_INTERLOCK;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestProcessINTLKsInAutomaticMode');
|
||||
_wInterlocks.0 := 1;
|
||||
_wInterlocksUsed.0 := 1;
|
||||
|
||||
// Switch to automatic mode
|
||||
_fbValve.ReqAutomaticMode();
|
||||
_fbValve(wProcessINTLK := _wInterlocks, stValveConfig := _stAnalogValveConfig, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// Open valve in automatic mode
|
||||
_fbValve.rSPAutomatic := 100;
|
||||
_fbValve(xAutomaticOpen := TRUE, wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Test if valve is open, when not we have an intermediate error
|
||||
// which should have been found by another test
|
||||
IF _fbValve.IsOpen THEN
|
||||
// Activate an interlock
|
||||
_wInterlocks.0 := 0;
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Valve should now be closed
|
||||
AssertFalse(Condition := _fbValve.IsOpen, Message := 'Valve should not be open with active Interlock');
|
||||
AssertTrue(Condition := _fbValve.IsClosed, Message := 'Close output not active with active Interlock');
|
||||
AssertEquals_INT(Expected := 0, Actual := _fbValve.iSetpoint, Message := 'Analog output should be zero');
|
||||
ELSE
|
||||
AssertTrue(Condition := _fbValve.IsOpen, Message := 'Valve did not open before the test');
|
||||
END_IF
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestProcessINTLKsInManualMode" Id="{65a15a58-c0c0-4568-a4e1-3f436c3d6baa}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestProcessINTLKsInManualMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_ValveAnalog('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_ANALOG_VALVE_DATA;;
|
||||
|
||||
// valve interlocks
|
||||
_wInterlocks : T_INTERLOCK;
|
||||
_wInterlocksUsed : T_INTERLOCK;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestProcessINTLKsInManualMode');
|
||||
_wInterlocks.0 := 1;
|
||||
_wInterlocksUsed.0 := 1;
|
||||
|
||||
// Switch to manual mode
|
||||
_fbValve.xReleaseManualMode := TRUE;
|
||||
_fbValve.ReqManualMode();
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// Open valve in manual mode
|
||||
_stHMIValve.stSetpoint.rValue := 100.0;
|
||||
_stHMIValve.stOpenButton.xRequest := TRUE;
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Test if valve is open, when not we have an intermediate error
|
||||
// which should have been found by another test
|
||||
IF _fbValve.IsOpen THEN
|
||||
// Activate an interlock
|
||||
_wInterlocks.0 := 0;
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Valve should now be closed
|
||||
AssertFalse(Condition := _fbValve.IsOpen, Message := 'Valve should not be open with active Interlock');
|
||||
AssertTrue(Condition := _fbValve.IsClosed, Message := 'Close output not active with active Interlock');
|
||||
AssertEquals_INT(Expected := 0, Actual := _fbValve.iSetpoint, Message := 'Analog output should be zero');
|
||||
ELSE
|
||||
AssertTrue(Condition := _fbValve.IsOpen, Message := 'Valve did not open before the test');
|
||||
END_IF
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
188
PLC/POUs/Unittests/ReleaseSignalTests/FB_ReleaseSignalTest.TcPOU
Normal file
188
PLC/POUs/Unittests/ReleaseSignalTests/FB_ReleaseSignalTest.TcPOU
Normal file
@@ -0,0 +1,188 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ReleaseSignalTest" Id="{8b18b04a-432b-48e8-9173-e18ffc6e0a72}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ReleaseSignalTest EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// variables for onTimeTest
|
||||
_fbReleaseSignalWithOnTime : FB_ReleaseSignal;
|
||||
_fbOnTimer : TON;
|
||||
_xTestWithOnTimeFinished : BOOL := FALSE;
|
||||
|
||||
// variables for offTimeTest
|
||||
_fbReleaseSignalWithOffTime : FB_ReleaseSignal;
|
||||
_fbOffTimer : TON;
|
||||
_xTestWithOffTimeFinished : BOOL := FALSE;
|
||||
_xSignalForOffTest : BOOL := TRUE;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// run tests with different time behaviour
|
||||
TestWithoutTime();
|
||||
TestWithOnTime();
|
||||
TestWithOffTime();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestWithOffTime" Id="{59bccf19-8c18-4516-9bfc-d8ecab97a196}">
|
||||
<Declaration><![CDATA[METHOD TestWithOffTime
|
||||
VAR
|
||||
// result
|
||||
_xReturnValue : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// off timing
|
||||
timOffTime : TIME := T#100MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestWithOffTime');
|
||||
|
||||
// Test off time delay
|
||||
_fbReleaseSignalWithOffTime(
|
||||
xSignal:= _xSignalForOffTest,
|
||||
xRelease:= TRUE,
|
||||
timOnDelay:= T#0MS,
|
||||
timOffDelay:= timOffTime,
|
||||
xReleaseSignal=> _xReturnValue);
|
||||
|
||||
// Start timer after which the output of the Signal fb will be checked
|
||||
_fbOffTimer(IN := TRUE, PT := (timOffTime + T#50MS));
|
||||
|
||||
IF _xSignalForOffTest THEN
|
||||
_xSignalForOffTest := FALSE;
|
||||
END_IF
|
||||
|
||||
// Signal must be true at the start of the test
|
||||
// If not, abort the test
|
||||
IF _xSignalForOffTest AND (NOT _xReturnValue) THEN
|
||||
AssertTrue(Condition := _xReturnValue, Message := 'Signal not true at start of test');
|
||||
_xTestWithOffTimeFinished := TRUE;
|
||||
END_IF
|
||||
|
||||
// Check value after a time which is longer than the signal delay time
|
||||
IF NOT _fbOffTimer.Q THEN
|
||||
IF (NOT _xReturnValue) THEN
|
||||
AssertFalse(Condition := _xReturnValue, Message := 'Signal was false before the time was over');
|
||||
_fbOnTimer.IN := FALSE;
|
||||
_xTestWithOffTimeFinished := TRUE;
|
||||
END_IF
|
||||
ELSE
|
||||
AssertFalse(Condition := _xReturnValue, Message := 'Signal was not false after the time elapsed');
|
||||
_fbOnTimer.IN := FALSE;
|
||||
_xTestWithOffTimeFinished := TRUE;
|
||||
END_IF
|
||||
|
||||
IF _xTestWithOffTimeFinished THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestWithOnTime" Id="{adc27bca-ad94-40db-8c4a-cead392adedc}">
|
||||
<Declaration><![CDATA[METHOD TestWithOnTime
|
||||
VAR
|
||||
// result
|
||||
_xReturnValue : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// on timing
|
||||
timOnTime : TIME := T#100MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestWithOnTime');
|
||||
|
||||
// Test on time delay
|
||||
_fbReleaseSignalWithOnTime(
|
||||
xSignal:= TRUE,
|
||||
xRelease:= TRUE,
|
||||
timOnDelay:= timOnTime,
|
||||
timOffDelay:= T#0MS,
|
||||
xReleaseSignal=> _xReturnValue);
|
||||
|
||||
// Start timer after which the output of the Signal fb will be checked
|
||||
_fbOnTimer(IN := TRUE, PT := (timOnTime + T#50MS));
|
||||
|
||||
// Check value after a time which is longer than the signal delay time
|
||||
IF NOT _fbOnTimer.Q THEN
|
||||
IF _xReturnValue THEN
|
||||
AssertTrue(Condition := _xReturnValue, Message := 'Signal was true before the time was over');
|
||||
_fbOnTimer.IN := FALSE;
|
||||
_xTestWithOnTimeFinished := TRUE;
|
||||
END_IF
|
||||
ELSE
|
||||
AssertTrue(Condition := _xReturnValue, Message := 'Signal was not true after the time elapsed');
|
||||
_fbOnTimer.IN := FALSE;
|
||||
_xTestWithOnTimeFinished := TRUE;
|
||||
END_IF
|
||||
|
||||
IF _xTestWithOnTimeFinished THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestWithoutTime" Id="{394513b0-dc3f-4f97-9cfc-0254521f5ce3}">
|
||||
<Declaration><![CDATA[METHOD TestWithoutTime
|
||||
VAR
|
||||
// reslease signal instance
|
||||
_fbReleaseSignal : FB_ReleaseSignal;
|
||||
|
||||
// input signal
|
||||
_xSignal : BOOL;
|
||||
|
||||
// expected result
|
||||
_xExpected : BOOL;
|
||||
|
||||
// release result
|
||||
_xReturnValue : BOOL;
|
||||
|
||||
// release signal
|
||||
_xRelease : BOOL := TRUE;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestWithoutTime');
|
||||
|
||||
// Test with active release
|
||||
_xRelease := TRUE;
|
||||
|
||||
// Test low signal
|
||||
_xSignal := FALSE;
|
||||
_xExpected := FALSE;
|
||||
_fbReleaseSignal(
|
||||
xSignal:= _xSignal,
|
||||
xRelease:= _xRelease,
|
||||
timOnDelay:= T#0MS,
|
||||
timOffDelay:= T#0MS,
|
||||
xReleaseSignal=> _xReturnValue);
|
||||
|
||||
AssertEquals(Expected:= _xExpected, Actual:= _xReturnValue, Message:= 'Signal is not false');
|
||||
|
||||
|
||||
// Test high signal
|
||||
_xSignal := TRUE;
|
||||
_xExpected := TRUE;
|
||||
_fbReleaseSignal(
|
||||
xSignal:= _xSignal,
|
||||
xRelease:= _xRelease,
|
||||
timOnDelay:= T#0MS,
|
||||
timOffDelay:= T#0MS,
|
||||
xReleaseSignal=> _xReturnValue);
|
||||
|
||||
AssertEquals(Expected:= _xExpected, Actual:= _xReturnValue, Message:= 'Signal is not true');
|
||||
|
||||
// Test with inactive release
|
||||
_xRelease := FALSE;
|
||||
_xSignal := TRUE;
|
||||
_xExpected := FALSE;
|
||||
_fbReleaseSignal(
|
||||
xSignal:= _xSignal,
|
||||
xRelease:= _xRelease,
|
||||
timOnDelay:= T#0MS,
|
||||
timOffDelay:= T#0MS,
|
||||
xReleaseSignal=> _xReturnValue);
|
||||
|
||||
AssertEquals(Expected:= _xExpected, Actual:= _xReturnValue, Message:= 'Signal is not false with no active release');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
301
PLC/POUs/Unittests/UtilitiesTests/FB_BlinkerTest.TcPOU
Normal file
301
PLC/POUs/Unittests/UtilitiesTests/FB_BlinkerTest.TcPOU
Normal file
@@ -0,0 +1,301 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_BlinkerTest" Id="{93a2f3b8-14aa-41c9-9ba1-1c60e3f7d9e3}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[{attribute 'analysis' := '-31'}
|
||||
FUNCTION_BLOCK FB_BlinkerTest EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// variables for 50Hz test
|
||||
_fbBlinkerFreq50Hz : FB_Blinker;
|
||||
_fbDelayFreq50HzOnTimer : TON;
|
||||
_fbDelayFreq50HzOffTimer : TON;
|
||||
_fbRtrigFreq50Hz : R_TRIG;
|
||||
_iFreq50HzCounter : INT := 0;
|
||||
|
||||
// variables for 5Hz test
|
||||
_fbBlinkerFreq5Hz : FB_Blinker;
|
||||
_fbDelayFreq5HzOnTimer : TON;
|
||||
_fbDelayFreq5HzOffTimer : TON;
|
||||
_fbRtrigFreq5Hz : R_TRIG;
|
||||
_iFreq5HzCounter : INT := 0;
|
||||
|
||||
// variables for 2Hz test
|
||||
_fbBlinkerFreq2Hz : FB_Blinker;
|
||||
_fbDelayFreq2HzOnTimer : TON;
|
||||
_fbDelayFreq2HzOffTimer : TON;
|
||||
_fbRtrigFreq2Hz : R_TRIG;
|
||||
_iFreq2HzCounter : INT := 0;
|
||||
|
||||
// variables for 1Hz test
|
||||
_fbBlinkerFreq1Hz : FB_Blinker;
|
||||
_fbDelayFreq1HzOnTimer : TON;
|
||||
_fbDelayFreq1HzOffTimer : TON;
|
||||
_fbRtrigFreq1Hz : R_TRIG;
|
||||
_iFreq1HzCounter : INT := 0;
|
||||
|
||||
// variables for 0.5Hz test
|
||||
_fbBlinkerFreq0_5Hz : FB_Blinker;
|
||||
_fbDelayFreq0_5HzOnTimer : TON;
|
||||
_fbDelayFreq0_5HzOffTimer : TON;
|
||||
_fbRtrigFreq0_5Hz : R_TRIG;
|
||||
_iFreq0_5HzCounter : INT := 0;
|
||||
|
||||
// variables for 0.1Hz test
|
||||
_fbBlinkerFreq0_1Hz : FB_Blinker;
|
||||
_fbDelayFreq0_1HzOnTimer : TON;
|
||||
_fbDelayFreq0_1HzOffTimer : TON;
|
||||
_fbRtrigFreq0_1Hz : R_TRIG;
|
||||
_iFreq0_1HzCounter : INT := 0;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// test blinker for different frequencies
|
||||
TestOutputFrequency50Hz();
|
||||
TestOutputFrequency5Hz();
|
||||
TestOutputFrequency2Hz();
|
||||
TestOutputFrequency1Hz();
|
||||
TestOutputFrequency0_5Hz();
|
||||
{analysis -140}
|
||||
// TestOutputFrequency0_1Hz();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestOutputFrequency0_1Hz" Id="{c17bb511-c82a-42b8-a274-50330416d4e0}">
|
||||
<Declaration><![CDATA[METHOD TestOutputFrequency0_1Hz
|
||||
VAR
|
||||
// blinker output
|
||||
_xOut : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// delay for timer
|
||||
timDelay : TIME := T#5S;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputFrequency0_1Hz');
|
||||
|
||||
// alternating timers (0.1Hz blinking frequency)
|
||||
_fbDelayFreq0_1HzOnTimer(IN := NOT _fbDelayFreq0_1HzOffTimer.Q, PT := timDelay);
|
||||
_fbDelayFreq0_1HzOffTimer(IN := _fbDelayFreq0_1HzOnTimer.Q, PT := timDelay);
|
||||
_fbRtrigFreq0_1Hz(CLK := _fbDelayFreq0_1HzOnTimer.Q);
|
||||
|
||||
// run blinker
|
||||
_fbBlinkerFreq0_1Hz(rFrequency := 0.1, xOut => _xOut);
|
||||
|
||||
// check results for each cycle depending on alternating timers
|
||||
IF _fbDelayFreq0_1HzOnTimer.Q THEN
|
||||
AssertTrue(_xOut, 'xOut is supposed to be true but is false.');
|
||||
ELSE
|
||||
AssertFalse(_xOut, 'xOut is supposed to be false but is true.');
|
||||
END_IF
|
||||
|
||||
// increment counter when timer is done
|
||||
IF _fbRtrigFreq0_1Hz.Q THEN
|
||||
_iFreq0_1HzCounter := _iFreq0_1HzCounter + 1;
|
||||
END_IF
|
||||
|
||||
// finish test after 5 blinking cycles
|
||||
IF _iFreq0_1HzCounter > 5 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputFrequency0_5Hz" Id="{6ceaefc3-45ad-4025-9305-7cee18dd0ee3}">
|
||||
<Declaration><![CDATA[METHOD TestOutputFrequency0_5Hz
|
||||
VAR
|
||||
// blinker output
|
||||
_xOut : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// delay for timer
|
||||
timDelay : TIME := T#1S;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputFrequency0_5Hz');
|
||||
|
||||
// alternating timers (0.5Hz blinking frequency)
|
||||
_fbDelayFreq0_5HzOnTimer(IN := NOT _fbDelayFreq0_5HzOffTimer.Q, PT := timDelay);
|
||||
_fbDelayFreq0_5HzOffTimer(IN := _fbDelayFreq0_5HzOnTimer.Q, PT := timDelay);
|
||||
_fbRtrigFreq0_5Hz(CLK := _fbDelayFreq0_5HzOnTimer.Q);
|
||||
|
||||
// run blinker
|
||||
_fbBlinkerFreq0_5Hz(rFrequency := 0.5, xOut => _xOut);
|
||||
|
||||
// check results for each cycle depending on alternating timers
|
||||
IF _fbDelayFreq0_5HzOnTimer.Q THEN
|
||||
AssertTrue(_xOut, 'xOut is supposed to be true but is false.');
|
||||
ELSE
|
||||
AssertFalse(_xOut, 'xOut is supposed to be false but is true.');
|
||||
END_IF
|
||||
|
||||
// increment counter when timer is done
|
||||
IF _fbRtrigFreq0_5Hz.Q THEN
|
||||
_iFreq0_5HzCounter := _iFreq0_5HzCounter + 1;
|
||||
END_IF
|
||||
|
||||
// finish test after 5 blinking cycles
|
||||
IF _iFreq0_5HzCounter > 5 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputFrequency1Hz" Id="{d1f61e42-2489-495d-b533-6fba45f62c50}">
|
||||
<Declaration><![CDATA[METHOD TestOutputFrequency1Hz
|
||||
VAR
|
||||
// blinker output
|
||||
_xOut : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// delay for timer
|
||||
timDelay : TIME := T#500MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputFrequency1Hz');
|
||||
|
||||
// alternating timers (1Hz blinking frequency)
|
||||
_fbDelayFreq1HzOnTimer(IN := NOT _fbDelayFreq1HzOffTimer.Q, PT := timDelay);
|
||||
_fbDelayFreq1HzOffTimer(IN := _fbDelayFreq1HzOnTimer.Q, PT := timDelay);
|
||||
_fbRtrigFreq1Hz(CLK := _fbDelayFreq1HzOnTimer.Q);
|
||||
|
||||
// run blinker
|
||||
_fbBlinkerFreq1Hz(rFrequency := 1.0, xOut => _xOut);
|
||||
|
||||
// check results for each cycle depending on alternating timers
|
||||
IF _fbDelayFreq1HzOnTimer.Q THEN
|
||||
AssertTrue(_xOut, 'xOut is supposed to be true but is false.');
|
||||
ELSE
|
||||
AssertFalse(_xOut, 'xOut is supposed to be false but is true.');
|
||||
END_IF
|
||||
|
||||
// increment counter when timer is done
|
||||
IF _fbRtrigFreq1Hz.Q THEN
|
||||
_iFreq1HzCounter := _iFreq1HzCounter + 1;
|
||||
END_IF
|
||||
|
||||
// finish test after 5 blinking cycles
|
||||
IF _iFreq1HzCounter > 5 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputFrequency2Hz" Id="{1e5023d2-a4d9-4826-ac00-229fc3919936}">
|
||||
<Declaration><![CDATA[METHOD TestOutputFrequency2Hz
|
||||
VAR
|
||||
// blinker output
|
||||
_xOut : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// delay for timer
|
||||
timDelay : TIME := T#250MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputFrequency2Hz');
|
||||
|
||||
// alternating timers (2Hz blinking frequency)
|
||||
_fbDelayFreq2HzOnTimer(IN := NOT _fbDelayFreq2HzOffTimer.Q, PT := timDelay);
|
||||
_fbDelayFreq2HzOffTimer(IN := _fbDelayFreq2HzOnTimer.Q, PT := timDelay);
|
||||
_fbRtrigFreq2Hz(CLK := _fbDelayFreq2HzOnTimer.Q);
|
||||
|
||||
// run blinker
|
||||
_fbBlinkerFreq2Hz(rFrequency := 2.0, xOut => _xOut);
|
||||
|
||||
// check results for each cycle depending on alternating timers
|
||||
IF _fbDelayFreq2HzOnTimer.Q THEN
|
||||
AssertTrue(_xOut, 'xOut is supposed to be true but is false.');
|
||||
ELSE
|
||||
AssertFalse(_xOut, 'xOut is supposed to be false but is true.');
|
||||
END_IF
|
||||
|
||||
// increment counter when timer is done
|
||||
IF _fbRtrigFreq2Hz.Q THEN
|
||||
_iFreq2HzCounter := _iFreq2HzCounter + 1;
|
||||
END_IF
|
||||
|
||||
// finish test after 5 blinking cycles
|
||||
IF _iFreq2HzCounter > 5 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputFrequency50Hz" Id="{b4a8cd02-0a88-4b2c-9a24-0ee3a74bd6c1}">
|
||||
<Declaration><![CDATA[METHOD TestOutputFrequency50Hz
|
||||
VAR
|
||||
// blinker output
|
||||
_xOut : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// delay for timer
|
||||
timDelay : TIME := T#10MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputFrequency50Hz');
|
||||
|
||||
// alternating timers (50Hz blinking frequency)
|
||||
_fbDelayFreq50HzOnTimer(IN := NOT _fbDelayFreq50HzOffTimer.Q, PT := timDelay);
|
||||
_fbDelayFreq50HzOffTimer(IN := _fbDelayFreq50HzOnTimer.Q, PT := timDelay);
|
||||
_fbRtrigFreq50Hz(CLK := _fbDelayFreq50HzOnTimer.Q);
|
||||
|
||||
// run blinker
|
||||
_fbBlinkerFreq50Hz(rFrequency := 50.0, xOut => _xOut);
|
||||
|
||||
// check results for each cycle depending on alternating timers
|
||||
IF _fbDelayFreq50HzOnTimer.Q THEN
|
||||
AssertTrue(_xOut, 'xOut is supposed to be true but is false.');
|
||||
ELSE
|
||||
AssertFalse(_xOut, 'xOut is supposed to be false but is true.');
|
||||
END_IF
|
||||
|
||||
// increment counter when timer is done
|
||||
IF _fbRtrigFreq50Hz.Q THEN
|
||||
_iFreq50HzCounter := _iFreq50HzCounter + 1;
|
||||
END_IF
|
||||
|
||||
// finish test after 5 blinking cycles
|
||||
IF _iFreq50HzCounter > 5 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputFrequency5Hz" Id="{d93914de-f931-4cc2-adcc-04e3043464c9}">
|
||||
<Declaration><![CDATA[METHOD TestOutputFrequency5Hz
|
||||
VAR
|
||||
// blinker output
|
||||
_xOut : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// delay for timer
|
||||
timDelay : TIME := T#100MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputFrequency5Hz');
|
||||
|
||||
// alternating timers (5Hz blinking frequency)
|
||||
_fbDelayFreq5HzOnTimer(IN := NOT _fbDelayFreq5HzOffTimer.Q, PT := timDelay);
|
||||
_fbDelayFreq5HzOffTimer(IN := _fbDelayFreq5HzOnTimer.Q, PT := timDelay);
|
||||
_fbRtrigFreq5Hz(CLK := _fbDelayFreq5HzOnTimer.Q);
|
||||
|
||||
// run blinker
|
||||
_fbBlinkerFreq5Hz(rFrequency := 5.0, xOut => _xOut);
|
||||
|
||||
// check results for each cycle depending on alternating timers
|
||||
IF _fbDelayFreq5HzOnTimer.Q THEN
|
||||
AssertTrue(_xOut, 'xOut is supposed to be true but is false.');
|
||||
ELSE
|
||||
AssertFalse(_xOut, 'xOut is supposed to be false but is true.');
|
||||
END_IF
|
||||
|
||||
// increment counter when timer is done
|
||||
IF _fbRtrigFreq5Hz.Q THEN
|
||||
_iFreq5HzCounter := _iFreq5HzCounter + 1;
|
||||
END_IF
|
||||
|
||||
// finish test after 5 blinking cycles
|
||||
IF _iFreq5HzCounter > 5 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
178
PLC/POUs/Unittests/UtilitiesTests/FB_HashFNV1a_32BitTest.TcPOU
Normal file
178
PLC/POUs/Unittests/UtilitiesTests/FB_HashFNV1a_32BitTest.TcPOU
Normal file
@@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_HashFNV1a_32BitTest" Id="{584d6db4-3042-4682-bf3c-6924d5cfd45e}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[{attribute 'analysis' := '-31'}
|
||||
FUNCTION_BLOCK FB_HashFNV1a_32BitTest EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// run tests with different strings
|
||||
TestHashString1();
|
||||
TestHashString2();
|
||||
TestHashString3();
|
||||
TestHashString4();
|
||||
TestHashString5();
|
||||
|
||||
{analysis -140}
|
||||
// run test with special characters (not needed.)
|
||||
// TestSpecialCharacter();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestHashString1" Id="{6848e3d2-7c66-46db-96ed-dbbf60aafca3}">
|
||||
<Declaration><![CDATA[METHOD TestHashString1
|
||||
VAR
|
||||
// string input
|
||||
_sString : STRING := 'Hallo Welt!';
|
||||
|
||||
// hash result
|
||||
_udiActual : UDINT;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected hash
|
||||
udiExpected : UDINT := 16#83258870;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestHashString1');
|
||||
|
||||
// run hash function
|
||||
_udiActual := FC_HashFNV1a_32Bit(ADR(_sString));
|
||||
|
||||
// assert results
|
||||
AssertEquals_UDINT(udiExpected, _udiActual, 'Did not return expected hash result.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestHashString2" Id="{d1a187f2-69ef-4d7b-9820-3422b177f90e}">
|
||||
<Declaration><![CDATA[METHOD TestHashString2
|
||||
VAR
|
||||
// string input
|
||||
_sString : STRING := 'Ich schreibe ganz ganz viele Tests....';
|
||||
|
||||
// hash result
|
||||
_udiActual : UDINT;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected hash
|
||||
udiExpected : UDINT := 16#D732A024;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestHashString2');
|
||||
|
||||
// run hash function
|
||||
_udiActual := FC_HashFNV1a_32Bit(ADR(_sString));
|
||||
|
||||
// assert results
|
||||
AssertEquals_UDINT(udiExpected, _udiActual, 'Did not return expected hash result.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestHashString3" Id="{73b939c5-9983-42c2-965b-e966bace91db}">
|
||||
<Declaration><![CDATA[METHOD TestHashString3
|
||||
VAR
|
||||
// string input
|
||||
_sString : STRING(255) := 'Dies soll ein ganz langer String werden. Dieses Vorgehen ist sinnvoll, damit die Grenzen der Hashfunktion getestet werden koennen. Ausserdem ist es interessant, ob Sonderzeichen wie: , , , , und ... funktionieren. Leider funktionieren diese nicht...';
|
||||
|
||||
// hash result
|
||||
_udiActual : UDINT;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected hash
|
||||
udiExpected : UDINT := 16#BD4EBCD2;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestHashString3');
|
||||
|
||||
// run hash function
|
||||
_udiActual := FC_HashFNV1a_32Bit(ADR(_sString));
|
||||
|
||||
// assert results
|
||||
AssertEquals_UDINT(udiExpected, _udiActual, 'Did not return expected hash result.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestHashString4" Id="{889fd548-f653-4805-824c-e896f9bf9367}">
|
||||
<Declaration><![CDATA[METHOD TestHashString4
|
||||
VAR
|
||||
// string input
|
||||
_sString : STRING := 'Hallo Welt!';
|
||||
|
||||
// hash result
|
||||
_udiActual : UDINT;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected hash
|
||||
udiExpected : UDINT := 16#83258870;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestHashString4');
|
||||
|
||||
// run hash function
|
||||
_udiActual := FC_HashFNV1a_32Bit(ADR(_sString));
|
||||
|
||||
// assert results
|
||||
AssertEquals_UDINT(udiExpected, _udiActual, 'Did not return expected hash result.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestHashString5" Id="{a29b8c4b-5d3e-4229-941d-f616140007f0}">
|
||||
<Declaration><![CDATA[METHOD TestHashString5
|
||||
VAR
|
||||
// string input
|
||||
_sString : STRING := 'Matthias hat dieses Programm Leistungsoptimiert!';
|
||||
|
||||
// hash result
|
||||
_udiActual : UDINT;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected hash
|
||||
udiExpected : UDINT := 16#D442FBA9;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestHashString5');
|
||||
|
||||
// run hash function
|
||||
_udiActual := FC_HashFNV1a_32Bit(ADR(_sString));
|
||||
|
||||
// assert results
|
||||
AssertEquals_UDINT(udiExpected, _udiActual, 'Did not return expected hash result.');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestSpecialCharacter" Id="{80e59124-8e21-4287-a17c-f0f64d1dd87b}">
|
||||
<Declaration><![CDATA[METHOD TestSpecialCharacter
|
||||
VAR
|
||||
// string input
|
||||
_sString : STRING := 'äöüß';
|
||||
|
||||
// hash result
|
||||
_udiActual : UDINT;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected hash
|
||||
udiExpected : UDINT := 16#2891249a;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestSpecialCharacter');
|
||||
|
||||
// run hash function
|
||||
_udiActual := FC_HashFNV1a_32Bit(ADR(_sString));
|
||||
|
||||
// assert results
|
||||
AssertEquals_UDINT(udiExpected, _udiActual, 'Handling of special charater is not possible');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
276
PLC/POUs/Unittests/UtilitiesTests/FB_PT1Test.TcPOU
Normal file
276
PLC/POUs/Unittests/UtilitiesTests/FB_PT1Test.TcPOU
Normal file
@@ -0,0 +1,276 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_PT1Test" Id="{70928114-b90c-4509-80ef-931fbb32faf9}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_PT1Test EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// variables for test using T1 = 50 ms
|
||||
_fbPT1_StepPT1_50 : FB_PT1;
|
||||
_xInitStepPT1_50 : BOOL := FALSE;
|
||||
_alrExpectedValuesStepPT1_50 : ARRAY[1..20] OF LREAL;
|
||||
_iCounterStepPT1_50 : INT := 1;
|
||||
|
||||
// variables for test using T1 = 168 ms
|
||||
_fbPT1_StepPT1_168 : FB_PT1;
|
||||
_xInitStepPT1_168 : BOOL := FALSE;
|
||||
_alrExpectedValuesStepPT1_168 : ARRAY[1..20] OF LREAL;
|
||||
_iCounterStepPT1_168 : INT := 1;
|
||||
|
||||
// variables for test using T1 = 15 ms and a step of 2.345
|
||||
_fbPT1_StepPT1_15_2345 : FB_PT1;
|
||||
_xInitStepPT1_15_2345 : BOOL := FALSE;
|
||||
_alrExpectedValuesStepPT1_15_2345 : ARRAY[1..20] OF LREAL;
|
||||
_iCounterStepPT1_15_2345 : INT := 1;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// test readout of task cycle time
|
||||
TestCycleTimeReadout();
|
||||
|
||||
// test step responses for different time constants
|
||||
TestOutputStepResponseT1_50ms();
|
||||
TestOutputStepResponseT1_168ms();
|
||||
TestOutputStepResponseStep2dot345_T1_15ms();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestCycleTimeReadout" Id="{904f47d5-67b3-4556-aaef-cec669b6e988}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestCycleTimeReadout
|
||||
VAR
|
||||
// pt1 instance
|
||||
_fbPT1 : FB_PT1;
|
||||
|
||||
// task index instance
|
||||
_fbGetCurTaskIdx : GETCURTASKINDEX;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestCycleTimeReadout');
|
||||
|
||||
// read current cycle time and abort test in case of cycletime not 10 ms.
|
||||
_fbGetCurTaskIdx();
|
||||
IF ((UDINT_TO_REAL(TwinCAT_SystemInfoVarList._TASKInfo[_fbGetCurTaskIdx.index].CycleTime) * 10E-5) - 10.0) > 0.0001 THEN
|
||||
AssertTrue(FALSE, 'Project cycle time not set to 10ms!');
|
||||
ELSE
|
||||
_fbPT1(
|
||||
lrInput := 0,
|
||||
timT := T#10MS,
|
||||
lrOutput => );
|
||||
|
||||
// Project should be set to 10ms cycle time for this test to work
|
||||
AssertEquals_LREAL(Expected := 10.0, Actual := _fbPT1.CycleTime, Delta := 0.01, 'Cycle time is not equal to project cycle time (10ms)');
|
||||
END_IF
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputStepResponseStep2dot345_T1_15ms" Id="{6ad357cb-7b1c-47ef-888c-e7cf604e0662}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
{attribute 'analysis' := '-26'}
|
||||
METHOD TestOutputStepResponseStep2dot345_T1_15ms
|
||||
VAR
|
||||
// pt1 output
|
||||
_lrOutput : LREAL;
|
||||
|
||||
// error message
|
||||
_sMessage : STRING := 'Step ';
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// pt1 setpoint
|
||||
lrSetpoint : LREAL := 2.345;
|
||||
|
||||
// delta for assertion
|
||||
lrDelta : LREAL := 0.0001;
|
||||
|
||||
// T1
|
||||
timT : TIME := T#15MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputStepResponseStep2dot345_T1_15ms');
|
||||
|
||||
// init expected values for 20 cyclic calls
|
||||
IF NOT _xInitStepPT1_15_2345 THEN
|
||||
_xInitStepPT1_15_2345 := TRUE;
|
||||
_alrExpectedValuesStepPT1_15_2345[1] := 0.938;
|
||||
_alrExpectedValuesStepPT1_15_2345[2] := 1.5008;
|
||||
_alrExpectedValuesStepPT1_15_2345[3] := 1.83848;
|
||||
_alrExpectedValuesStepPT1_15_2345[4] := 2.041088;
|
||||
_alrExpectedValuesStepPT1_15_2345[5] := 2.1626528;
|
||||
_alrExpectedValuesStepPT1_15_2345[6] := 2.23559168;
|
||||
_alrExpectedValuesStepPT1_15_2345[7] := 2.279355008;
|
||||
_alrExpectedValuesStepPT1_15_2345[8] := 2.305613005;
|
||||
_alrExpectedValuesStepPT1_15_2345[9] := 2.321367803;
|
||||
_alrExpectedValuesStepPT1_15_2345[10] := 2.330820682;
|
||||
_alrExpectedValuesStepPT1_15_2345[11] := 2.336492409;
|
||||
_alrExpectedValuesStepPT1_15_2345[12] := 2.339895445;
|
||||
_alrExpectedValuesStepPT1_15_2345[13] := 2.341937267;
|
||||
_alrExpectedValuesStepPT1_15_2345[14] := 2.34316236;
|
||||
_alrExpectedValuesStepPT1_15_2345[15] := 2.343897416;
|
||||
_alrExpectedValuesStepPT1_15_2345[16] := 2.34433845;
|
||||
_alrExpectedValuesStepPT1_15_2345[17] := 2.34460307;
|
||||
_alrExpectedValuesStepPT1_15_2345[18] := 2.344761842;
|
||||
_alrExpectedValuesStepPT1_15_2345[19] := 2.344857105;
|
||||
_alrExpectedValuesStepPT1_15_2345[20] := 2.344914263;
|
||||
END_IF
|
||||
|
||||
// run PT1
|
||||
_fbPT1_StepPT1_15_2345(
|
||||
lrInput := lrSetpoint,
|
||||
timT := timT,
|
||||
lrOutput => _lrOutput);
|
||||
|
||||
// set error message according to current step
|
||||
_sMessage := CONCAT(_sMessage, TO_STRING(_iCounterStepPT1_15_2345));
|
||||
_sMessage := CONCAT(_sMessage, ' did not return expected value.');
|
||||
|
||||
// check values of current step
|
||||
AssertEquals_LREAL(Expected := _alrExpectedValuesStepPT1_15_2345[_iCounterStepPT1_15_2345], Actual := _lrOutput, Delta := lrDelta, _sMessage);
|
||||
_iCounterStepPT1_15_2345 := _iCounterStepPT1_15_2345 + 1;
|
||||
|
||||
// finish test after 20 cycles
|
||||
IF _iCounterStepPT1_15_2345 > 20 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputStepResponseT1_168ms" Id="{95beda9c-524a-46f3-bd27-507fc0dda2e0}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
{attribute 'analysis' := '-26'}
|
||||
METHOD TestOutputStepResponseT1_168ms
|
||||
VAR
|
||||
// pt1 output
|
||||
_lrOutput : LREAL;
|
||||
|
||||
// error message
|
||||
_sMessage : STRING := 'Step ';
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// pt1 setpoint
|
||||
lrSetpoint : LREAL := 1;
|
||||
|
||||
// delta for assertion
|
||||
lrDelta : LREAL := 0.0001;
|
||||
|
||||
// T1
|
||||
timT : TIME := T#168MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputStepResponseT1_168ms');
|
||||
|
||||
// init expected values for 20 cyclic calls
|
||||
IF NOT _xInitStepPT1_168 THEN
|
||||
_xInitStepPT1_168 := TRUE;
|
||||
_alrExpectedValuesStepPT1_168[1] := 0.056179775;
|
||||
_alrExpectedValuesStepPT1_168[2] := 0.109203383;
|
||||
_alrExpectedValuesStepPT1_168[3] := 0.159248137;
|
||||
_alrExpectedValuesStepPT1_168[4] := 0.206481388;
|
||||
_alrExpectedValuesStepPT1_168[5] := 0.251061085;
|
||||
_alrExpectedValuesStepPT1_168[6] := 0.293136305;
|
||||
_alrExpectedValuesStepPT1_168[7] := 0.332847749;
|
||||
_alrExpectedValuesStepPT1_168[8] := 0.370328212;
|
||||
_alrExpectedValuesStepPT1_168[9] := 0.405703032;
|
||||
_alrExpectedValuesStepPT1_168[10] := 0.439090502;
|
||||
_alrExpectedValuesStepPT1_168[11] := 0.470602271;
|
||||
_alrExpectedValuesStepPT1_168[12] := 0.500343717;
|
||||
_alrExpectedValuesStepPT1_168[13] := 0.528414295;
|
||||
_alrExpectedValuesStepPT1_168[14] := 0.554907874;
|
||||
_alrExpectedValuesStepPT1_168[15] := 0.579913049;
|
||||
_alrExpectedValuesStepPT1_168[16] := 0.60351344;
|
||||
_alrExpectedValuesStepPT1_168[17] := 0.625787966;
|
||||
_alrExpectedValuesStepPT1_168[18] := 0.646811114;
|
||||
_alrExpectedValuesStepPT1_168[19] := 0.666653186;
|
||||
_alrExpectedValuesStepPT1_168[20] := 0.685380535;
|
||||
END_IF
|
||||
|
||||
// run PT1
|
||||
_fbPT1_StepPT1_168(
|
||||
lrInput := lrSetpoint,
|
||||
timT := timT,
|
||||
lrOutput => _lrOutput);
|
||||
|
||||
// set error message according to current step
|
||||
_sMessage := CONCAT(_sMessage, TO_STRING(_iCounterStepPT1_168));
|
||||
_sMessage := CONCAT(_sMessage, ' did not return expected value.');
|
||||
|
||||
// check values of current step
|
||||
AssertEquals_LREAL(Expected := _alrExpectedValuesStepPT1_168[_iCounterStepPT1_168], Actual := _lrOutput, Delta := lrDelta, _sMessage);
|
||||
_iCounterStepPT1_168 := _iCounterStepPT1_168 + 1;
|
||||
|
||||
// finish test after 20 cycles
|
||||
IF _iCounterStepPT1_168 > 20 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestOutputStepResponseT1_50ms" Id="{13fc9847-7f4d-4bad-80e0-d8a65864a692}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
{attribute 'analysis' := '-26'}
|
||||
METHOD TestOutputStepResponseT1_50ms
|
||||
VAR
|
||||
// pt1 output
|
||||
_lrOutput : LREAL;
|
||||
|
||||
// error message
|
||||
_sMessage : STRING := 'Step ';
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// pt1 setpoint
|
||||
lrSetpoint : LREAL := 1;
|
||||
|
||||
// delta for assertion
|
||||
lrDelta : LREAL := 0.0001;
|
||||
|
||||
// T1
|
||||
timT : TIME := T#50MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOutputStepResponseT1_50ms');
|
||||
|
||||
// init expected values for 20 cyclic calls
|
||||
IF NOT _xInitStepPT1_50 THEN
|
||||
_xInitStepPT1_50 := TRUE;
|
||||
_alrExpectedValuesStepPT1_50[1] := 0.166666667;
|
||||
_alrExpectedValuesStepPT1_50[2] := 0.305555556;
|
||||
_alrExpectedValuesStepPT1_50[3] := 0.421296296;
|
||||
_alrExpectedValuesStepPT1_50[4] := 0.517746914;
|
||||
_alrExpectedValuesStepPT1_50[5] := 0.598122428;
|
||||
_alrExpectedValuesStepPT1_50[6] := 0.665102023;
|
||||
_alrExpectedValuesStepPT1_50[7] := 0.720918353;
|
||||
_alrExpectedValuesStepPT1_50[8] := 0.767431961;
|
||||
_alrExpectedValuesStepPT1_50[9] := 0.806193301;
|
||||
_alrExpectedValuesStepPT1_50[10] := 0.838494417;
|
||||
_alrExpectedValuesStepPT1_50[11] := 0.865412014;
|
||||
_alrExpectedValuesStepPT1_50[12] := 0.887843345;
|
||||
_alrExpectedValuesStepPT1_50[13] := 0.906536121;
|
||||
_alrExpectedValuesStepPT1_50[14] := 0.922113434;
|
||||
_alrExpectedValuesStepPT1_50[15] := 0.935094528;
|
||||
_alrExpectedValuesStepPT1_50[16] := 0.945912107;
|
||||
_alrExpectedValuesStepPT1_50[17] := 0.954926756;
|
||||
_alrExpectedValuesStepPT1_50[18] := 0.962438963;
|
||||
_alrExpectedValuesStepPT1_50[19] := 0.968699136;
|
||||
_alrExpectedValuesStepPT1_50[20] := 0.973915947;
|
||||
END_IF
|
||||
|
||||
// run PT1
|
||||
_fbPT1_StepPT1_50(
|
||||
lrInput := lrSetpoint,
|
||||
timT := timT,
|
||||
lrOutput => _lrOutput);
|
||||
|
||||
// set error message according to current step
|
||||
_sMessage := CONCAT(_sMessage, TO_STRING(_iCounterStepPT1_50));
|
||||
_sMessage := CONCAT(_sMessage, ' did not return expected value.');
|
||||
|
||||
// check values of current step
|
||||
AssertEquals_LREAL(Expected := _alrExpectedValuesStepPT1_50[_iCounterStepPT1_50], Actual := _lrOutput, Delta := lrDelta, _sMessage);
|
||||
_iCounterStepPT1_50 := _iCounterStepPT1_50 + 1;
|
||||
|
||||
// finish test after 20 cycles
|
||||
IF _iCounterStepPT1_50 > 20 THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
473
PLC/POUs/Unittests/UtilitiesTests/FB_RampGeneratorTest.TcPOU
Normal file
473
PLC/POUs/Unittests/UtilitiesTests/FB_RampGeneratorTest.TcPOU
Normal file
@@ -0,0 +1,473 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_RampGeneratorTest" Id="{883a6789-24bc-434e-bdcd-11047d9142bc}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_RampGeneratorTest EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// variables for max clamp test
|
||||
_fbRMPMaxClamp : FB_RampGenerator;
|
||||
_fbDelayMaxClamp : TON;
|
||||
_fbDelayMaxClampBuffer : TON;
|
||||
|
||||
// variables for min clamp test
|
||||
_fbRMPMinClamp : FB_RampGenerator;
|
||||
_fbDelayMinClamp : TON;
|
||||
_fbDelayMinClampBuffer : TON;
|
||||
_xInitMinClamp : BOOL := FALSE;
|
||||
|
||||
// variables for ramp down timing test
|
||||
_fbRMPRampDownTime : FB_RampGenerator;
|
||||
_fbDelayRampDownTime : TON;
|
||||
|
||||
// variables for ramp up timing test
|
||||
_fbRMPRampUpTime : FB_RampGenerator;
|
||||
_fbDelayRampUpTime : TON;
|
||||
|
||||
// variables for ramp down continuity test
|
||||
_fbRMPRampDownContinuity : FB_RampGenerator;
|
||||
_fbDelayRampDownContinuity : TON;
|
||||
_rNextExpectedDown : REAL := 0;
|
||||
|
||||
// variables for ramp up continuity test
|
||||
_fbRMPRampUpContinuity : FB_RampGenerator;
|
||||
_fbDelayRampUpContinuity : TON;
|
||||
_rNextExpectedUp : REAL := 0;
|
||||
|
||||
// variables for in target up test
|
||||
_fbRMPInTargetResultUp : FB_RampGenerator;
|
||||
_fbDelayInTargetResultUp : TON;
|
||||
|
||||
// variables for in target down test
|
||||
_fbRMPInTargetResultDown : FB_RampGenerator;
|
||||
_fbDelayInTargetResultDown : TON;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// test for correct cycle time and it's readout
|
||||
TestCycleTimeReadout();
|
||||
|
||||
// test clamping
|
||||
TestMaxClamping();
|
||||
TestMinClamping();
|
||||
|
||||
// test ramp up/down
|
||||
TestRampUpTime();
|
||||
TestRampUpContinuity();
|
||||
TestRampDownTime();
|
||||
TestRampDownContinuity();
|
||||
|
||||
// test inTarget
|
||||
TestInTargetResultUp();
|
||||
TestInTargetResultDown();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestCycleTimeReadout" Id="{adf8238e-e5ed-478c-ac22-37930b46e697}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestCycleTimeReadout
|
||||
VAR
|
||||
// ramp generator instance
|
||||
_fbRampGen : FB_RampGenerator;
|
||||
|
||||
// task index instance
|
||||
_fbGetCurTaskIdx : GETCURTASKINDEX;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestCycleTimeReadout');
|
||||
|
||||
// read current cycle time and abort test in case of cycletime not 10 ms.
|
||||
_fbGetCurTaskIdx();
|
||||
IF ((UDINT_TO_REAL(TwinCAT_SystemInfoVarList._TASKInfo[_fbGetCurTaskIdx.index].CycleTime) * 10E-5) - 10.0) > 0.001 THEN
|
||||
AssertTrue(FALSE, 'Project cycle time not set to 10ms!');
|
||||
ELSE
|
||||
_fbRampGen(
|
||||
rTarget:= 0.0,
|
||||
rTargetMin:= 0.0,
|
||||
rTargetMax:= 100.0,
|
||||
timRampUp:= T#5S,
|
||||
timRampDown:= T#5S,
|
||||
rSetpoint=> ,
|
||||
xInTarget=> );
|
||||
|
||||
// Project should be set to 10ms cycle time for this test to work
|
||||
AssertEquals_REAL(Expected := 10.0, Actual := _fbRampGen.CycleTime, Delta := 0.01, 'Cycle time is not equal to project cycle time (10ms)');
|
||||
END_IF
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestInTargetResultDown" Id="{d659dd70-b87c-48f4-9d7b-df95aaef8540}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestInTargetResultDown
|
||||
VAR
|
||||
// in target result
|
||||
_xInTarget : BOOL;
|
||||
|
||||
// current ramp setpoint
|
||||
_rSetpoint : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// delay until in target should be reached
|
||||
timDelay : TIME := T#990MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestInTargetResultDown');
|
||||
|
||||
// timer until InTarget is supposed to be reached
|
||||
_fbDelayInTargetResultDown(IN := TRUE, PT := timDelay);
|
||||
|
||||
// run RampGenerator
|
||||
_fbRMPInTargetResultDown(
|
||||
rTarget := -1,
|
||||
rTargetMin := -1,
|
||||
rTargetMax := 1,
|
||||
timRampUp := T#2S,
|
||||
timRampDown := T#2S,
|
||||
rSetpoint => _rSetpoint,
|
||||
xInTarget => _xInTarget);
|
||||
|
||||
// check for whether InTarget is reached at the specified time
|
||||
IF NOT _fbDelayInTargetResultDown.Q THEN
|
||||
AssertFalse(_xInTarget, 'InTarget reached earlier then expected.');
|
||||
ELSE
|
||||
AssertTrue(_xInTarget, 'InTarget not reached in time.');
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestInTargetResultUp" Id="{41467b7e-bd5d-4d30-abee-4fe231a34fce}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestInTargetResultUp
|
||||
VAR
|
||||
// in target result
|
||||
_xInTarget : BOOL;
|
||||
|
||||
// current ramp setpoint
|
||||
_rSetpoint : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// delay until in target should be reached
|
||||
timDelay : TIME := T#740MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestInTargetResultUp');
|
||||
|
||||
// timer until InTarget is supposed to be reached
|
||||
_fbDelayInTargetResultUp(IN := TRUE, PT := timDelay);
|
||||
|
||||
// run RampGenerator
|
||||
_fbRMPInTargetResultUp(
|
||||
rTarget := 1,
|
||||
rTargetMin := -1,
|
||||
rTargetMax := 1,
|
||||
timRampUp := T#1S500MS,
|
||||
timRampDown := T#1S500MS,
|
||||
rSetpoint => _rSetpoint,
|
||||
xInTarget => _xInTarget);
|
||||
|
||||
// check for whether InTarget is reached at the specified time
|
||||
IF NOT _fbDelayInTargetResultUp.Q THEN
|
||||
AssertFalse(_xInTarget, 'InTarget reached earlier then expected.');
|
||||
ELSE
|
||||
AssertTrue(_xInTarget, 'InTarget not reached in time.');
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestMaxClamping" Id="{65cd0699-a59f-4537-9fbd-e53ee8fb2124}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestMaxClamping
|
||||
VAR
|
||||
// current ramp setpoint
|
||||
_rSetpoint : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected clamped value
|
||||
rExpected : REAL := 5;
|
||||
|
||||
// delta for assertion
|
||||
rDelta : REAL := 0.0001;
|
||||
|
||||
// delay until clamping is reached
|
||||
timDelayRamp : TIME := T#500MS;
|
||||
|
||||
// delay to check for value changes after clamping
|
||||
timDelay : TIME := T#1S;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestMaxClamping');
|
||||
|
||||
// timer until until clamping is reach + timeBuffer afterwards to check whether is stays clamped or not
|
||||
_fbDelayMaxClamp(IN := TRUE, PT := timDelayRamp);
|
||||
_fbDelayMaxClampBuffer(IN := TRUE, PT := timDelay);
|
||||
|
||||
// run RampGenerator
|
||||
_fbRMPMaxClamp(
|
||||
rTarget := 10,
|
||||
rTargetMin := 0,
|
||||
rTargetMax := 5,
|
||||
timRampUp := T#500MS,
|
||||
timRampDown := T#500MS,
|
||||
rSetpoint => _rSetpoint,
|
||||
xInTarget =>);
|
||||
|
||||
// check for clamping
|
||||
IF NOT _fbDelayMaxClamp.Q THEN
|
||||
// too early
|
||||
AssertTrue(_rSetpoint < rExpected,'Clamped value reached before expected time');
|
||||
ELSE
|
||||
// after expected rampTime
|
||||
IF NOT _fbDelayMaxClampBuffer.Q THEN
|
||||
AssertEquals_REAL(Expected := rExpected, Actual := _rSetpoint, Delta := rDelta, 'Value did not stay on or did not reach MaxTarget');
|
||||
ELSE
|
||||
TEST_FINISHED();
|
||||
END_IF
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestMinClamping" Id="{e7c98271-509c-4227-870c-3cb3245da266}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestMinClamping
|
||||
VAR
|
||||
// current ramp setpoint
|
||||
_rSetpoint : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected clamped value
|
||||
rExpected : REAL := 5;
|
||||
|
||||
// delta for assertion
|
||||
rDelta : REAL := 0.0001;
|
||||
|
||||
// delay until clamping is reached
|
||||
timDelayRamp : TIME := T#500MS;
|
||||
|
||||
// delay to check for value changes after clamping
|
||||
timDelay : TIME := T#1S;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestMinClamping');
|
||||
|
||||
// init start at top cap
|
||||
IF NOT _xInitMinClamp THEN
|
||||
_fbRMPMinClamp.SetStart(10);
|
||||
_xInitMinClamp := TRUE;
|
||||
END_IF
|
||||
|
||||
// timer until until clamping is reach + timeBuffer afterwards to check whether is stays clamped or not
|
||||
_fbDelayMinClamp(IN := TRUE, PT := timDelayRamp);
|
||||
_fbDelayMinClampBuffer(IN := TRUE, PT := timDelay);
|
||||
|
||||
// run RampGenerator
|
||||
_fbRMPMinClamp(
|
||||
rTarget := 0,
|
||||
rTargetMin := 5,
|
||||
rTargetMax := 10,
|
||||
timRampUp := T#500MS,
|
||||
timRampDown := T#500MS,
|
||||
rSetpoint => _rSetpoint,
|
||||
xInTarget =>);
|
||||
|
||||
// check for clamping
|
||||
IF NOT _fbDelayMinClamp.Q THEN
|
||||
// too early
|
||||
AssertTrue(_rSetpoint >= (rExpected - rDelta), 'Clamped value reached before expected time');
|
||||
ELSE
|
||||
// after expected rampTime
|
||||
IF NOT _fbDelayMinClampBuffer.Q THEN
|
||||
AssertEquals_REAL(Expected := rExpected, Actual := _rSetpoint, Delta := rDelta, 'Value did not stay on or did not reach MinTarget');
|
||||
ELSE
|
||||
TEST_FINISHED();
|
||||
END_IF
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestRampDownContinuity" Id="{dcb7f0b0-2158-4cf1-af71-745bee5bf2bd}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestRampDownContinuity
|
||||
VAR
|
||||
// current ramp setpoint
|
||||
_rSetpoint : REAL;
|
||||
|
||||
// calculated ramp speed
|
||||
_rMyRampSpeed : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected final value
|
||||
rExpected : REAL := -9.4564;
|
||||
|
||||
// delta for assertion
|
||||
rDelta : REAL := 0.0001;
|
||||
|
||||
// delay until final value is reached
|
||||
timDelay : TIME := T#470MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestRampDownContinuity');
|
||||
|
||||
// ramp timer, calc speed & calc next expected ramp step
|
||||
_fbDelayRampDownContinuity(IN := TRUE, PT := timDelay);
|
||||
_rMyRampSpeed := 20 * (10 / TIME_TO_REAL(T#1S));
|
||||
_rNextExpectedDown := _rNextExpectedDown - _rMyRampSpeed;
|
||||
|
||||
// run RampGenerator
|
||||
_fbRMPRampDownContinuity(
|
||||
rTarget := -9.4564,
|
||||
rTargetMin := -10,
|
||||
rTargetMax := 10,
|
||||
timRampUp := T#1S,
|
||||
timRampDown := T#1S,
|
||||
rSetpoint => _rSetpoint,
|
||||
xInTarget =>);
|
||||
|
||||
// check for current expected value
|
||||
IF NOT _fbDelayRampDownContinuity.Q THEN
|
||||
AssertEquals_REAL(Expected := _rNextExpectedDown, Actual := _rSetpoint, Delta := rDelta, 'Expected current value was not achieved.');
|
||||
ELSE
|
||||
// check for final value
|
||||
AssertEquals_REAL(Expected := rExpected, Actual := _rSetpoint, Delta := rDelta, 'Value was not reached in time.');
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestRampDownTime" Id="{c4784967-e4fc-415b-8fa5-fb9ce6bb34f7}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestRampDownTime
|
||||
VAR
|
||||
// current ramp setpoint
|
||||
_rSetpoint : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected final value
|
||||
rExpected : REAL := -7.4367;
|
||||
|
||||
// delta for assertions
|
||||
rDelta : REAL := 0.0001;
|
||||
|
||||
// delay until final value is reached
|
||||
timDelay : TIME := T#74MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestRampDownTime');
|
||||
|
||||
// timer until bottom of ramp is supposed to be reached
|
||||
_fbDelayRampDownTime(IN := TRUE, PT := timDelay);
|
||||
|
||||
// run RampGenerator
|
||||
_fbRMPRampDownTime(
|
||||
rTarget := -7.4367,
|
||||
rTargetMin := -10,
|
||||
rTargetMax := 10,
|
||||
timRampUp := T#500MS,
|
||||
timRampDown := T#100MS,
|
||||
rSetpoint => _rSetpoint,
|
||||
xInTarget =>);
|
||||
|
||||
// check whether final value is reach on time or before
|
||||
IF NOT _fbDelayRampDownTime.Q THEN
|
||||
AssertTrue(_rSetpoint > (rExpected - rDelta),'Value reached before expected time.');
|
||||
ELSE
|
||||
AssertEquals_REAL(Expected := rExpected, Actual := _rSetpoint, Delta := rDelta, 'Value was not reached in time.');
|
||||
TEST_FINISHED();
|
||||
END_IF
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestRampUpContinuity" Id="{3771104c-32d2-4bae-b36b-27a109bac10f}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestRampUpContinuity
|
||||
VAR
|
||||
// current ramp setpoint
|
||||
_rSetpoint : REAL;
|
||||
|
||||
// calculated ramp speed
|
||||
_rMyRampSpeed : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected final value
|
||||
rExpected : REAL := 8.673;
|
||||
|
||||
// delta for assertions
|
||||
rDelta : REAL := 0.0001;
|
||||
|
||||
// delay until final value is reached
|
||||
timDelay : TIME := T#860MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestRampUpContinuity');
|
||||
|
||||
// ramp timer, calc speed & calc next expected ramp step
|
||||
_fbDelayRampUpContinuity(IN := TRUE, PT := timDelay);
|
||||
_rMyRampSpeed := 16.567 * (10 / TIME_TO_REAL(T#1S650MS));
|
||||
_rNextExpectedUp := _rNextExpectedUp + _rMyRampSpeed;
|
||||
|
||||
// run RampGenerator
|
||||
_fbRMPRampUpContinuity(
|
||||
rTarget := 8.673,
|
||||
rTargetMin := -7,
|
||||
rTargetMax := 9.567,
|
||||
timRampUp := T#1S650MS,
|
||||
timRampDown := T#1S,
|
||||
rSetpoint => _rSetpoint,
|
||||
xInTarget =>);
|
||||
|
||||
// check for current expected value
|
||||
IF NOT _fbDelayRampUpContinuity.Q THEN
|
||||
AssertEquals_REAL(Expected := _rNextExpectedUp, Actual := _rSetpoint, Delta := rDelta, 'Expected current value was not achieved.');
|
||||
ELSE
|
||||
// check for final value
|
||||
AssertEquals_REAL(Expected := rExpected, Actual := _rSetpoint, Delta := rDelta, 'Value was not reached in time.');
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestRampUpTime" Id="{79d093cd-b7fc-4c92-b138-2dee08eb11bc}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestRampUpTime
|
||||
VAR
|
||||
// current ramp setpoint
|
||||
_rSetpoint : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// expected final value
|
||||
rExpected : REAL := 8.3456;
|
||||
|
||||
// delta for assertions
|
||||
rDelta : REAL := 0.0001;
|
||||
|
||||
// delay until final value is reached
|
||||
timDelay : TIME := T#440MS;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestRampUpTime');
|
||||
|
||||
// timer until bottom of ramp is supposed to be reached
|
||||
_fbDelayRampUpTime(IN := TRUE, PT := timDelay);
|
||||
|
||||
// run RampGenerator
|
||||
_fbRMPRampUpTime(
|
||||
rTarget := 8.3456,
|
||||
rTargetMin := -10,
|
||||
rTargetMax := 10,
|
||||
timRampUp := T#1S70MS,
|
||||
timRampDown := T#100MS,
|
||||
rSetpoint => _rSetpoint,
|
||||
xInTarget =>);
|
||||
|
||||
// check whether final value is reach on time or before
|
||||
IF NOT _fbDelayRampUpTime.Q THEN
|
||||
AssertTrue(_rSetpoint < rExpected,'Value reached before expected time.');
|
||||
ELSE
|
||||
AssertEquals_REAL(Expected := rExpected, Actual := _rSetpoint, Delta := rDelta, 'Value was not reached in time.');
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
282
PLC/POUs/Unittests/ValveTests/FB_ValveTestHMI.TcPOU
Normal file
282
PLC/POUs/Unittests/ValveTests/FB_ValveTestHMI.TcPOU
Normal file
@@ -0,0 +1,282 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveTestHMI" Id="{78a34e73-74e3-480e-93ae-396774638baf}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ValveTestHMI EXTENDS TcUnit.FB_TestSuite
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
END_VAR
|
||||
VAR
|
||||
// valve instance for Open/Close-Test
|
||||
_fbValveOC : FB_Valve('');
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TestManualButtonRelease();
|
||||
TestManualButtonModeChange();
|
||||
TestManualModeButtonOpenClose();
|
||||
TestManualModeOpenRelease();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestManualButtonModeChange" Id="{4fa4418c-a1e9-4136-b912-1dfb82f3064a}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestManualButtonModeChange
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig;
|
||||
|
||||
// valve interlocks
|
||||
_wInterlocks : T_INTERLOCK;
|
||||
_wInterlocksUsed : T_INTERLOCK;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestManualButtonModeChange');
|
||||
|
||||
// set manual request button on HMI and call valve block
|
||||
_stHMIValve.stManualButton.xRequest := TRUE;
|
||||
_fbValve(
|
||||
xReleaseManualMode:= TRUE,
|
||||
wProcessINTLK:= _wInterlocks,
|
||||
wProcessINTLKUsed:= _wInterlocksUsed,
|
||||
stHMIInterface:= _stHMIValve,
|
||||
xError=> ,
|
||||
xOpenFeedback:= ,
|
||||
xCloseFeedback:= ,
|
||||
xReleaseErrors:= ,
|
||||
xConfirmAlarms:= ,
|
||||
stValveConfig:= _stValveConfig,
|
||||
xOpenValve=> ,
|
||||
xCloseValve=> );
|
||||
|
||||
// Valve should now be in manual mode and xRequest should have been reset
|
||||
AssertTrue(Condition := _fbValve.IsInManualMode, Message := 'Valve did not change to manual mode');
|
||||
AssertFalse(Condition := _stHMIValve.stManualButton.xRequest, Message := 'Valve did not reset the manual mode button request');
|
||||
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestManualButtonRelease" Id="{6966094d-e9b6-4f8b-a399-9dea4a3eee19}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestManualButtonRelease
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig;
|
||||
|
||||
// valve interlocks
|
||||
_wInterlocks : T_INTERLOCK;
|
||||
_wInterlocksUsed : T_INTERLOCK;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestManualButtonRelease');
|
||||
|
||||
// Test no release for HMI mode change
|
||||
_fbValve(
|
||||
xReleaseManualMode:= FALSE,
|
||||
wProcessINTLK:= _wInterlocks,
|
||||
wProcessINTLKUsed:= _wInterlocksUsed,
|
||||
stHMIInterface:= _stHMIValve,
|
||||
xError=> ,
|
||||
xOpenFeedback:= ,
|
||||
xCloseFeedback:= ,
|
||||
xReleaseErrors:= ,
|
||||
xConfirmAlarms:= ,
|
||||
stValveConfig:= _stValveConfig,
|
||||
xOpenValve=> ,
|
||||
xCloseValve=> );
|
||||
|
||||
AssertFalse(Condition := _stHMIValve.stManualButton.xRelease, Message := 'Manual mode button was released but should not have been');
|
||||
|
||||
|
||||
// Test release for HMI mode change
|
||||
_fbValve(
|
||||
xReleaseManualMode:= TRUE,
|
||||
wProcessINTLK:= _wInterlocks,
|
||||
wProcessINTLKUsed:= _wInterlocksUsed,
|
||||
stHMIInterface:= _stHMIValve,
|
||||
xError=> ,
|
||||
xOpenFeedback:= ,
|
||||
xCloseFeedback:= ,
|
||||
xReleaseErrors:= ,
|
||||
xConfirmAlarms:= ,
|
||||
stValveConfig:= ,
|
||||
xOpenValve=> ,
|
||||
xCloseValve=> );
|
||||
|
||||
AssertTrue(Condition := _stHMIValve.stManualButton.xRelease, Message := 'Manual mode button was not released but should have been');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestManualModeButtonOpenClose" Id="{5447550c-d5f0-42c9-bcfd-b2ef662685c8}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestManualModeButtonOpenClose
|
||||
VAR
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig;
|
||||
|
||||
// valve interlocks
|
||||
_wInterlocks : T_INTERLOCK;
|
||||
_wInterlocksUsed : T_INTERLOCK;
|
||||
|
||||
// hmi button feedback
|
||||
_eExpectedOpenButtonFeedback : E_HMI_BUTTON_FEEDBACK;
|
||||
_eExpectedCloseButtonFeedback : E_HMI_BUTTON_FEEDBACK;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestManualModeButtonOpenClose');
|
||||
|
||||
// set manual request button on HMI and call valve block
|
||||
_stHMIValve.stManualButton.xRequest := TRUE;
|
||||
_fbValveOC(
|
||||
xReleaseManualMode:= TRUE,
|
||||
wProcessINTLK:= _wInterlocks,
|
||||
wProcessINTLKUsed:= _wInterlocksUsed,
|
||||
stHMIInterface:= _stHMIValve,
|
||||
xError=> ,
|
||||
xOpenFeedback:= ,
|
||||
xCloseFeedback:= ,
|
||||
xReleaseErrors:= ,
|
||||
xConfirmAlarms:= ,
|
||||
stValveConfig:= _stValveConfig,
|
||||
xOpenValve=> ,
|
||||
xCloseValve=> );
|
||||
|
||||
// Valve should now be in manual mode
|
||||
AssertTrue(Condition := _fbValveOC.IsInManualMode, Message := 'Valve did not change to manual mode pre test');
|
||||
|
||||
// Request open from HMI and call valve block
|
||||
_stHMIValve.stOpenButton.xRequest := TRUE;
|
||||
_fbValveOC(
|
||||
xReleaseManualMode:= TRUE,
|
||||
wProcessINTLK:= _wInterlocks,
|
||||
wProcessINTLKUsed:= _wInterlocksUsed,
|
||||
stHMIInterface:= _stHMIValve,
|
||||
xError=> ,
|
||||
xOpenFeedback:= ,
|
||||
xCloseFeedback:= ,
|
||||
xReleaseErrors:= ,
|
||||
xConfirmAlarms:= ,
|
||||
stValveConfig:= ,
|
||||
xOpenValve=> ,
|
||||
xCloseValve=> );
|
||||
|
||||
// test for valve state and HMI feedback
|
||||
AssertTrue(Condition := _fbValveOC.xOpenValve, Message := 'Valve did not open as requested by hmi button');
|
||||
AssertFalse(Condition := _stHMIValve.stOpenButton.xRequest, Message := 'Valve did not reset open request');
|
||||
_eExpectedOpenButtonFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
_eExpectedCloseButtonFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
AssertEquals(Expected := _eExpectedOpenButtonFeedback, Actual := _stHMIValve.stOpenButton.eFeedback, Message := 'Valve did not send correct open button feedback signal while open');
|
||||
AssertEquals(Expected := _eExpectedCloseButtonFeedback, Actual := _stHMIValve.stCloseButton.eFeedback, Message := 'Valve did not send correct close button feedback signal while open');
|
||||
|
||||
// Request close from HMI and call valve block
|
||||
_stHMIValve.stCloseButton.xRequest := TRUE;
|
||||
_fbValveOC(
|
||||
xReleaseManualMode:= TRUE,
|
||||
wProcessINTLK:= _wInterlocks,
|
||||
wProcessINTLKUsed:= _wInterlocksUsed,
|
||||
stHMIInterface:= _stHMIValve,
|
||||
xError=> ,
|
||||
xOpenFeedback:= ,
|
||||
xCloseFeedback:= ,
|
||||
xReleaseErrors:= ,
|
||||
xConfirmAlarms:= ,
|
||||
stValveConfig:= ,
|
||||
xOpenValve=> ,
|
||||
xCloseValve=> );
|
||||
|
||||
// test for valve state and HMI feedback
|
||||
AssertTrue(Condition := _fbValveOC.xCloseValve, Message := 'Valve did not close as requested by hmi button');
|
||||
AssertFalse(Condition := _stHMIValve.stCloseButton.xRequest, Message := 'Valve did not reset close request');
|
||||
_eExpectedOpenButtonFeedback := E_HMI_BUTTON_FEEDBACK.NONE;
|
||||
_eExpectedCloseButtonFeedback := E_HMI_BUTTON_FEEDBACK.ACTIVE;
|
||||
AssertEquals(Expected := _eExpectedCloseButtonFeedback, Actual := _stHMIValve.stCloseButton.eFeedback, Message := 'Valve did not send correct close button feedback signal while closed');
|
||||
AssertEquals(Expected := _eExpectedOpenButtonFeedback, Actual := _stHMIValve.stOpenButton.eFeedback, Message := 'Valve did not send correct open button feedback signal while closed');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestManualModeOpenRelease" Id="{7b7870a1-a0b3-45c8-af76-55d8712c17bf}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestManualModeOpenRelease
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// valve interlocks
|
||||
wInterlocks : T_INTERLOCK := 0;
|
||||
wInterlocksUsed : T_INTERLOCK := 1;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestManualModeOpenRelease');
|
||||
|
||||
// set manual request button on HMI and call valve block
|
||||
_stHMIValve.stManualButton.xRequest := TRUE;
|
||||
_fbValve(
|
||||
xReleaseManualMode:= TRUE,
|
||||
wProcessINTLK:= wInterlocks,
|
||||
wProcessINTLKUsed:= wInterlocksUsed,
|
||||
stHMIInterface:= _stHMIValve,
|
||||
xError=> ,
|
||||
xOpenFeedback:= ,
|
||||
xCloseFeedback:= ,
|
||||
xReleaseErrors:= ,
|
||||
xConfirmAlarms:= ,
|
||||
stValveConfig:= _stValveConfig,
|
||||
xOpenValve=> ,
|
||||
xCloseValve=> );
|
||||
|
||||
// Valve should now be in manual mode
|
||||
AssertTrue(Condition := _fbValve.IsInManualMode, Message := 'Valve did not change to manual mode pre test');
|
||||
|
||||
// Valve should not realease open button with active interlock
|
||||
AssertFalse(Condition := _stHMIValve.stOpenButton.xRelease, Message := 'Valve did release open button but should not');
|
||||
|
||||
// Test if request is denied by valve with active interlocks
|
||||
_stHMIValve.stOpenButton.xRequest := TRUE;
|
||||
_fbValve(
|
||||
xReleaseManualMode:= TRUE,
|
||||
wProcessINTLK:= wInterlocks,
|
||||
wProcessINTLKUsed:= wInterlocksUsed,
|
||||
stHMIInterface:= _stHMIValve,
|
||||
xError=> ,
|
||||
xOpenFeedback:= ,
|
||||
xCloseFeedback:= ,
|
||||
xReleaseErrors:= ,
|
||||
xConfirmAlarms:= ,
|
||||
stValveConfig:= ,
|
||||
xOpenValve=> ,
|
||||
xCloseValve=> );
|
||||
|
||||
AssertFalse(Condition := _fbValve.xOpenValve, Message := 'Valve did not block manual open command with active interlock');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
77
PLC/POUs/Unittests/ValveTests/FB_ValveTestTimoutClose.TcPOU
Normal file
77
PLC/POUs/Unittests/ValveTests/FB_ValveTestTimoutClose.TcPOU
Normal file
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveTestTimoutClose" Id="{676995cc-e0f8-4711-82b2-410116e6831b}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ValveTestTimoutClose EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// feedback result
|
||||
_xOpenFeedback : BOOL := FALSE;
|
||||
_xCloseFeedback : BOOL := FALSE;
|
||||
|
||||
// valve instance
|
||||
_fbValveTimeout : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// test timings
|
||||
_fbTimeoutCloseTestTimer : TON := (PT := T#200MS);
|
||||
_fbDelayFeedbackSignalTimer : TON := (PT := T#50MS);
|
||||
|
||||
// test finished
|
||||
_xTestTimeoutFinished : BOOL;
|
||||
|
||||
// current test state
|
||||
_iState : INT;
|
||||
|
||||
// vlave config
|
||||
_stValveConfig : ST_ValveConfig := (timTimeoutOpen := t#0MS, timTimeoutClose := T#100MS);
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TestClose();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestClose" Id="{b2dc7638-d362-4caf-a205-a2aede6d9720}">
|
||||
<Declaration><![CDATA[METHOD TestClose
|
||||
VAR_INPUT
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestClose');
|
||||
|
||||
CASE _iState OF
|
||||
0:
|
||||
// request automatic close and start timers
|
||||
_fbValveTimeout(xAutomaticOpen := FALSE, stHMIInterface := _stHMIValve);
|
||||
_fbTimeoutCloseTestTimer.IN := TRUE;
|
||||
_fbDelayFeedbackSignalTimer.IN := TRUE;
|
||||
_iState := 10;
|
||||
|
||||
10:
|
||||
// set close feedback after 50ms and call valve block
|
||||
_xOpenFeedback := FALSE;
|
||||
_xCloseFeedback := _fbValveTimeout.xCloseValve AND _fbDelayFeedbackSignalTimer.Q;
|
||||
_fbValveTimeout(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig);
|
||||
|
||||
// test timeout after 200ms
|
||||
IF _fbTimeoutCloseTestTimer.Q THEN
|
||||
_iState := 20;
|
||||
_fbDelayFeedbackSignalTimer.IN := FALSE;
|
||||
_fbTimeoutCloseTestTimer.IN := FALSE;
|
||||
END_IF
|
||||
|
||||
20:
|
||||
// assert IsClosed and no error
|
||||
_xTestTimeoutFinished := TRUE;
|
||||
AssertTrue(Condition := _fbValveTimeout.IsClosed AND NOT _fbValveTimeout.xError, Message := 'Valve threw close timeout error');
|
||||
END_CASE
|
||||
|
||||
// call timer
|
||||
_fbTimeoutCloseTestTimer();
|
||||
_fbDelayFeedbackSignalTimer();
|
||||
|
||||
IF _xTestTimeoutFinished THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
78
PLC/POUs/Unittests/ValveTests/FB_ValveTestTimoutOpen.TcPOU
Normal file
78
PLC/POUs/Unittests/ValveTests/FB_ValveTestTimoutOpen.TcPOU
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveTestTimoutOpen" Id="{49e1a729-e622-4855-a7d7-67a9f99d1550}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ValveTestTimoutOpen EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// valve feedback
|
||||
_xOpenFeedback : BOOL := FALSE;
|
||||
_xCloseFeedback : BOOL := FALSE;
|
||||
|
||||
// valve instance
|
||||
_fbValveTimeout : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// test timings
|
||||
_fbTimeoutOpenTestTimer : TON := (PT := T#200MS);
|
||||
_fbDelayFeedbackSignalTimer : TON := (PT := T#50MS);
|
||||
|
||||
// test finished
|
||||
_xTestTimeoutFinished : BOOL;
|
||||
|
||||
// current test state
|
||||
_iState : INT;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig := (timTimeoutOpen := t#100MS, timTimeoutClose := T#0MS);
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TestOpen();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestOpen" Id="{4f96f391-c47b-4572-833e-9be45b3993f5}">
|
||||
<Declaration><![CDATA[METHOD TestOpen
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOpen');
|
||||
|
||||
CASE _iState OF
|
||||
0:
|
||||
// request automatic open and start timers
|
||||
_fbValveTimeout(xAutomaticOpen := TRUE, stHMIInterface := _stHMIValve);
|
||||
_fbTimeoutOpenTestTimer.IN := TRUE;
|
||||
_fbDelayFeedbackSignalTimer.IN := TRUE;
|
||||
_iState := 10;
|
||||
|
||||
10:
|
||||
// set open feedback after 50ms and call valve block
|
||||
_xOpenFeedback := _fbValveTimeout.xOpenValve AND _fbDelayFeedbackSignalTimer.Q;
|
||||
_xCloseFeedback := FALSE;
|
||||
_fbValveTimeout(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig);
|
||||
|
||||
// test timeout after 200ms
|
||||
IF _fbTimeoutOpenTestTimer.Q THEN
|
||||
_iState := 20;
|
||||
_fbDelayFeedbackSignalTimer.IN := FALSE;
|
||||
_fbTimeoutOpenTestTimer.IN := FALSE;
|
||||
END_IF
|
||||
|
||||
20:
|
||||
// assert IsOpen and no error
|
||||
_xTestTimeoutFinished := TRUE;
|
||||
AssertTrue(Condition := _fbValveTimeout.IsOpen AND NOT _fbValveTimeout.xError, Message := 'Valve threw open timeout error');
|
||||
END_CASE
|
||||
|
||||
// call timer
|
||||
_fbTimeoutOpenTestTimer();
|
||||
_fbDelayFeedbackSignalTimer();
|
||||
|
||||
IF _xTestTimeoutFinished THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveTestTriggerTimoutClose" Id="{492c2d14-a1aa-412e-b759-1e35a3301e66}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ValveTestTriggerTimoutClose EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// valve feedback
|
||||
_xOpenFeedback : BOOL := FALSE;
|
||||
_xCloseFeedback : BOOL := FALSE;
|
||||
|
||||
// valve instance
|
||||
_fbValveTimeout : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// test timings
|
||||
_fbTimeoutCloseTestTimer : TON := (PT := T#100MS);
|
||||
_fbDelayFeedbackSignalTimer : TON := (PT := T#200MS);
|
||||
|
||||
// test finished
|
||||
_xTestTimeoutFinished : BOOL;
|
||||
|
||||
// current test state
|
||||
_iState : INT;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig := (timTimeoutOpen := t#0MS, timTimeoutClose := T#100MS, xHasClosedFeedback := TRUE);
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TestTriggerTimeoutClose();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestTriggerTimeoutClose" Id="{cc9351d2-a43b-4e56-9e5b-6d2747045073}">
|
||||
<Declaration><![CDATA[METHOD TestTriggerTimeoutClose
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestTriggerTimeoutClose');
|
||||
|
||||
CASE _iState OF
|
||||
0:
|
||||
// request automatic close and start timers
|
||||
_fbValveTimeout(xAutomaticOpen := FALSE, stHMIInterface := _stHMIValve);
|
||||
_fbTimeoutCloseTestTimer.IN := TRUE;
|
||||
_fbDelayFeedbackSignalTimer.IN := TRUE;
|
||||
_iState := 10;
|
||||
|
||||
10:
|
||||
// both feedback false and call valve block
|
||||
_xOpenFeedback := FALSE;
|
||||
_xCloseFeedback := FALSE;
|
||||
_fbValveTimeout(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, xInUnitTestMode := TRUE, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig);
|
||||
|
||||
// test timeout after 200ms
|
||||
IF _fbTimeoutCloseTestTimer.Q THEN
|
||||
_iState := 20;
|
||||
_fbDelayFeedbackSignalTimer.IN := FALSE;
|
||||
_fbTimeoutCloseTestTimer.IN := FALSE;
|
||||
END_IF
|
||||
|
||||
20:
|
||||
// assert error
|
||||
_xTestTimeoutFinished := TRUE;
|
||||
AssertTrue(Condition := _fbValveTimeout.xError, Message := 'Valve did not throw an close timeout error');
|
||||
END_CASE
|
||||
|
||||
// call timer
|
||||
_fbTimeoutCloseTestTimer();
|
||||
_fbDelayFeedbackSignalTimer();
|
||||
|
||||
IF _xTestTimeoutFinished THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveTestTriggerTimoutOpen" Id="{3357d110-5f1d-4d49-b94c-6c4cc8f6b306}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ValveTestTriggerTimoutOpen EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// valve feedback
|
||||
_xOpenFeedback : BOOL := FALSE;
|
||||
_xCloseFeedback : BOOL := FALSE;
|
||||
|
||||
// valve instance
|
||||
_fbValveTimeout : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// test timings
|
||||
_fbTimeoutOpenTestTimer : TON := (PT := T#100MS);
|
||||
_fbDelayFeedbackSignalTimer : TON := (PT := T#200MS);
|
||||
|
||||
// test finished
|
||||
_xTestTimeoutFinished : BOOL;
|
||||
|
||||
// current test state
|
||||
_iState : INT;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig := (timTimeoutOpen := t#100MS, timTimeoutClose := T#0MS, xHasOpenFeedback := TRUE);
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TestTriggerTimeoutOpen();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestTriggerTimeoutOpen" Id="{2b990579-8e3f-4c9d-9f7f-cb96af520f83}">
|
||||
<Declaration><![CDATA[METHOD TestTriggerTimeoutOpen
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestTriggerTimeoutOpen');
|
||||
|
||||
CASE _iState OF
|
||||
0:
|
||||
// request automatic open and start timers
|
||||
_fbValveTimeout(xAutomaticOpen := TRUE, stHMIInterface := _stHMIValve);
|
||||
_fbTimeoutOpenTestTimer.IN := TRUE;
|
||||
_fbDelayFeedbackSignalTimer.IN := TRUE;
|
||||
_fbValveTimeout.xInUnitTestMode := TRUE;
|
||||
_iState := 10;
|
||||
|
||||
10:
|
||||
// both feedback false and call valve block
|
||||
_xOpenFeedback := FALSE;
|
||||
_xCloseFeedback := FALSE;
|
||||
_fbValveTimeout(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, xInUnitTestMode := TRUE, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig);
|
||||
|
||||
// test timeout after 200ms
|
||||
IF _fbTimeoutOpenTestTimer.Q THEN
|
||||
_iState := 20;
|
||||
_fbDelayFeedbackSignalTimer.IN := FALSE;
|
||||
_fbTimeoutOpenTestTimer.IN := FALSE;
|
||||
END_IF
|
||||
|
||||
20:
|
||||
// assert error
|
||||
_xTestTimeoutFinished := TRUE;
|
||||
AssertTrue(Condition := _fbValveTimeout.xError, Message := 'Valve did not throw an open timeout error');
|
||||
END_CASE
|
||||
|
||||
// call timer
|
||||
_fbTimeoutOpenTestTimer();
|
||||
_fbDelayFeedbackSignalTimer();
|
||||
|
||||
IF _xTestTimeoutFinished THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
427
PLC/POUs/Unittests/ValveTests/FB_Valve_Test.TcPOU
Normal file
427
PLC/POUs/Unittests/ValveTests/FB_Valve_Test.TcPOU
Normal file
@@ -0,0 +1,427 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_Valve_Test" Id="{1304864d-3fed-4e82-bcdb-9dc7e4b2a441}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_Valve_Test EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Automatic Mode
|
||||
SwitchToAutomaticMode();
|
||||
OpenValveInAutomaticMode();
|
||||
|
||||
// Manual Mode
|
||||
SwitchToManualMode();
|
||||
OpenValveInManualMode();
|
||||
|
||||
// Test interlocks
|
||||
TestProcessInterlocks();
|
||||
TestProcessINTLKsInAutomaticMode();
|
||||
TestProcessINTLKsInManualMode();
|
||||
|
||||
// Check feedback signals
|
||||
CheckOpenCloseFeedbacks();
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="CheckOpenCloseFeedbacks" Id="{a28ac9cc-3e5a-4aec-ae25-5e2418416c2e}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD CheckOpenCloseFeedbacks
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve config
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
_stValveConfig : ST_ValveConfig;
|
||||
|
||||
// valve feedback
|
||||
_xOpenFeedback : BOOL;
|
||||
_xCloseFeedback : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('CheckOpenCloseFeedbacks');
|
||||
|
||||
// set timeout to zero and open+close feedback present
|
||||
_stValveConfig.timTimeoutClose := T#0S;
|
||||
_stValveConfig.timTimeoutOpen := T#0S;
|
||||
_stValveConfig.xHasOpenFeedback := TRUE;
|
||||
_stValveConfig.xHasClosedFeedback := TRUE;
|
||||
|
||||
// Test feedbacks in manual mode
|
||||
_xOpenFeedback := FALSE;
|
||||
_xCloseFeedback := FALSE;
|
||||
_fbValve.xReleaseManualMode := TRUE;
|
||||
_fbValve.ReqManualMode();
|
||||
_fbValve(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig, xInUnitTestMode := TRUE);
|
||||
|
||||
// We should now be in manual mode
|
||||
AssertTrue(Condition := _fbValve.IsInManualMode, Message := 'Valve did not changed to manual mode');
|
||||
|
||||
|
||||
// Test not closed and not opened
|
||||
AssertFalse(Condition := _fbValve.IsClosed OR _fbValve.IsOpen, Message := 'Valve should not signal open or closed with no feedback signals');
|
||||
|
||||
// Test closed
|
||||
_xOpenFeedback := FALSE;
|
||||
_xCloseFeedback := TRUE;
|
||||
_fbValve(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback,stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig, xInUnitTestMode := TRUE);
|
||||
AssertTrue(Condition := _fbValve.IsClosed, Message := 'Valve should be closed');
|
||||
AssertFalse(Condition := _fbValve.IsOpen, Message := 'Valve should not be open');
|
||||
|
||||
// Test opened
|
||||
_xOpenFeedback := TRUE;
|
||||
_xCloseFeedback := FALSE;
|
||||
_stHMIValve.stOpenButton.xRequest := TRUE;
|
||||
_fbValve(stHMIInterface := _stHMIValve);
|
||||
_fbValve(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig, xInUnitTestMode := TRUE);
|
||||
AssertTrue(Condition := _fbValve.IsOpen, Message := 'Valve should be open');
|
||||
AssertFalse(Condition := _fbValve.IsClosed, Message := 'Valve should not be closed');
|
||||
|
||||
// Test open and close
|
||||
_xOpenFeedback := TRUE;
|
||||
_xCloseFeedback := TRUE;
|
||||
_fbValve(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig, xInUnitTestMode := TRUE);
|
||||
AssertFalse(Condition := _fbValve.IsClosed OR _fbValve.IsOpen, Message := 'Valve should not signal open or closed with both feedback signals high');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="OpenValveInAutomaticMode" Id="{0b9852fb-7e89-42e5-977d-75ac8ce8f431}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD OpenValveInAutomaticMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('OpenValveInAutomaticMode');
|
||||
|
||||
// Set in automatic mode
|
||||
_fbValve.ReqAutomaticMode();
|
||||
|
||||
// Open valve
|
||||
_fbValve(xAutomaticOpen := TRUE, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Needs one cycle to write outputs
|
||||
_fbValve(stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// evaluate valve state
|
||||
_xResult := _fbValve.IsOpen AND NOT _fbValve.IsClosed;
|
||||
AssertTrue(_xResult, 'Valve did not open in Automatic Mode');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="OpenValveInManualMode" Id="{ebd3a3ca-f259-4efb-b134-f4d858027ff8}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD OpenValveInManualMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('OpenValveInManualMode');
|
||||
|
||||
// Needs one cycle to write outputs
|
||||
_fbValve.xReleaseManualMode := TRUE;
|
||||
|
||||
// Set in manual mode
|
||||
_fbValve.ReqManualMode();
|
||||
|
||||
// Open valve
|
||||
_stHMIValve.stOpenButton.xRequest := TRUE;
|
||||
_fbValve(stHMIInterface := _stHMIValve);
|
||||
_fbValve(stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// evaluate valve state
|
||||
_xResult := _fbValve.IsOpen AND NOT _fbValve.IsClosed;
|
||||
AssertTrue(_xResult, 'Valve did not open in Manual Mode');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SwitchToAutomaticMode" Id="{f0347789-26a5-4296-ac7a-3320d7d68b7f}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD SwitchToAutomaticMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('SwitchToAutomaticMode');
|
||||
|
||||
// request switch to automatic modes
|
||||
_fbValve.ReqAutomaticMode();
|
||||
|
||||
// call valve and read values
|
||||
_fbValve(stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// set result
|
||||
_xResult := _fbValve.IsInAutomaticMode;
|
||||
|
||||
// assert result
|
||||
AssertTrue(_xResult, 'Valve did not change into Automatic Mode');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SwitchToManualMode" Id="{f3a6a0eb-d468-45b4-ae0e-31d573348f7d}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD SwitchToManualMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('SwitchToManualMode');
|
||||
|
||||
// Test switch without xReleaseManualMode
|
||||
_fbValve.xReleaseManualMode := FALSE;
|
||||
_fbValve.ReqManualMode();
|
||||
_fbValve(stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
_xResult := NOT _fbValve.IsInManualMode;
|
||||
AssertTrue(_xResult, 'Valve changed to Manual Mode but this mode was not released');
|
||||
|
||||
// Test with xReleaseManualMode
|
||||
_fbValve.xReleaseManualMode := TRUE;
|
||||
_fbValve.ReqManualMode();
|
||||
_fbValve(stHMIInterface := _stHMIValve);
|
||||
_xResult := _fbValve.IsInManualMode;
|
||||
AssertTrue( _xResult, 'Valve did not changed to Manual Mode');
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestProcessInterlocks" Id="{a963e3c3-4c6c-44cd-913b-cd94b66ce40c}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
{attribute 'analysis' := '-81'}
|
||||
METHOD TestProcessInterlocks
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve state
|
||||
_xResult : BOOL;
|
||||
|
||||
// current interlock
|
||||
_usiCounter : USINT;
|
||||
|
||||
// Init all entries to TRUE
|
||||
_wInterlocks : T_INTERLOCK := 2#1111_1111_1111_1111;//[GVL_VALVE.MAX_INTERLOCKS(TRUE)];
|
||||
_wInterlocksUsed : T_INTERLOCK := 2#1111_1111_1111_1111;
|
||||
|
||||
// interlock test result
|
||||
_axInterlockTestResultFalse : ARRAY[0..GVL_CONFIGS.MAX_INTERLOCKS-1] OF BOOL;
|
||||
_axInterlockTestResultTrue : ARRAY[0..GVL_CONFIGS.MAX_INTERLOCKS-1] OF BOOL;
|
||||
|
||||
// interlock comulated result
|
||||
_xInterlocksFalseOK : BOOL;
|
||||
_xInterlocksTrueOK : BOOL;
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
// loop iterations for interlock test
|
||||
usiEndValue : USINT := GVL_CONFIGS.MAX_INTERLOCKS-1;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Test interlocks as reutrn value
|
||||
TEST('TestProcessInterlocks');
|
||||
|
||||
// call valve with interlocks and evaluate result
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
_xResult := _fbValve.ProcessInterlocksOK;
|
||||
|
||||
AssertTrue(_xResult, 'Interlocks not Ok but should be');
|
||||
|
||||
// Test each interlock individually
|
||||
// Save the result in the two following variables
|
||||
_xInterlocksFalseOK := TRUE;
|
||||
_xInterlocksTrueOK := TRUE;
|
||||
|
||||
FOR _usiCounter := 0 TO usiEndValue DO
|
||||
|
||||
// Test one interlock for false and then disable it
|
||||
_wInterlocks := SHL(_wInterlocks, 1);
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Save result in an array for later debugging if necessary
|
||||
_axInterlockTestResultFalse[_usiCounter] := _fbValve.ProcessInterlocksOK;
|
||||
|
||||
// Save global result
|
||||
IF _fbValve.ProcessInterlocksOK THEN
|
||||
_xInterlocksFalseOK := FALSE;
|
||||
END_IF
|
||||
// Disable this interlock after testing it
|
||||
_wInterlocksUsed := SHL(_wInterlocksUsed, 1);
|
||||
|
||||
// Test if, after disabling the interlock, the interlocks are ok again
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Save result in an array for later debugging if necessary
|
||||
_axInterlockTestResultTrue[_usiCounter] := _fbValve.ProcessInterlocksOK;
|
||||
|
||||
// Save global result
|
||||
IF NOT _fbValve.ProcessInterlocksOK THEN
|
||||
_xInterlocksTrueOK := FALSE;
|
||||
END_IF
|
||||
END_FOR
|
||||
|
||||
// Test False interlocks result
|
||||
AssertTrue(_xInterlocksFalseOK, 'Interlock should not be ok but are');
|
||||
|
||||
// Test False interlocks result
|
||||
AssertTrue(_xInterlocksTrueOK, 'Interlock should be ok but are not');
|
||||
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestProcessINTLKsInAutomaticMode" Id="{d6681863-baa6-4f1c-bb6d-7d6ecd0c4518}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestProcessINTLKsInAutomaticMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve interlocks
|
||||
_wInterlocks : T_INTERLOCK;
|
||||
_wInterlocksUsed : T_INTERLOCK;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestProcessINTLKsInAutomaticMode');
|
||||
_wInterlocks.0 := 1;
|
||||
_wInterlocksUsed.0 := 1;
|
||||
|
||||
// Switch to automatic mode
|
||||
_fbValve.ReqAutomaticMode();
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// Open valve in automatic mode
|
||||
_fbValve(xAutomaticOpen := TRUE, stHMIInterface := _stHMIValve);
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Test if valve is open, when not we have an intermediate error
|
||||
// which should have been found by another test
|
||||
IF _fbValve.IsOpen THEN
|
||||
// Activate an interlock
|
||||
_wInterlocks.0 := 0;
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Valve should now be closed
|
||||
AssertFalse(Condition := _fbValve.xOpenValve, Message := 'Valve should not be open with active Interlock');
|
||||
AssertTrue(Condition := _fbValve.xCloseValve, Message := 'Close output not active with active Interlock');
|
||||
|
||||
// Test the same with open valve when interlock active
|
||||
_stValveConfig.xOpenWhenInterlocksActive := TRUE;
|
||||
_fbValve(stValveConfig := _stValveConfig, wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Valve should now be open
|
||||
AssertTrue(Condition := _fbValve.xOpenValve, Message := 'Valve should be open with active Interlock and inverted config');
|
||||
AssertFalse(Condition := _fbValve.xCloseValve, Message := 'Close output active with active Interlock and inverted config');
|
||||
ELSE
|
||||
AssertTrue(Condition := _fbValve.IsOpen, Message := 'Valve did not open before the test');
|
||||
END_IF
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="TestProcessINTLKsInManualMode" Id="{24ef6949-9116-427c-aa82-83ed6d197c5c}">
|
||||
<Declaration><![CDATA[{warning disable C0394}
|
||||
METHOD TestProcessINTLKsInManualMode
|
||||
VAR
|
||||
// valve instance
|
||||
_fbValve : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// valve interlocks
|
||||
_wInterlocks : T_INTERLOCK;
|
||||
_wInterlocksUsed : T_INTERLOCK;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestProcessINTLKsInManualMode');
|
||||
_wInterlocks.0 := 1;
|
||||
_wInterlocksUsed.0 := 1;
|
||||
|
||||
// Switch to manual mode
|
||||
_fbValve.xReleaseManualMode := TRUE;
|
||||
_fbValve.ReqManualMode();
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve, xInUnitTestMode := TRUE);
|
||||
|
||||
// Open valve in manual mode
|
||||
_stHMIValve.stOpenButton.xRequest := TRUE;
|
||||
_fbValve(stHMIInterface := _stHMIValve);
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Test if valve is open, when not we have an intermediate error
|
||||
// which should have been found by another test
|
||||
IF _fbValve.IsOpen THEN
|
||||
// Activate an interlock
|
||||
_wInterlocks.0 := 0;
|
||||
_fbValve(wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Valve should now be closed
|
||||
AssertFalse(Condition := _fbValve.xOpenValve, Message := 'Valve should not be open with active Interlock');
|
||||
AssertTrue(Condition := _fbValve.xCloseValve, Message := 'Close output not active with active Interlock');
|
||||
|
||||
// Test the same with open valve when interlock active
|
||||
_stValveConfig.xOpenWhenInterlocksActive := TRUE;
|
||||
_fbValve(stValveConfig := _stValveConfig, wProcessINTLK := _wInterlocks, wProcessINTLKUsed := _wInterlocksUsed, stHMIInterface := _stHMIValve);
|
||||
|
||||
// Valve should now be open
|
||||
AssertTrue(Condition := _fbValve.xOpenValve, Message := 'Valve should be open with active Interlock and inverted config');
|
||||
AssertFalse(Condition := _fbValve.xCloseValve, Message := 'Close output active with active Interlock and inverted config');
|
||||
AssertTrue(Condition := _stHMIValve.stOpenButton.eFeedback = E_HMI_BUTTON_FEEDBACK.ACTIVE, Message := 'Open button should be set active with active Interlock and inverted config');
|
||||
ELSE
|
||||
AssertTrue(Condition := _fbValve.IsOpen, Message := 'Valve did not open before the test');
|
||||
END_IF
|
||||
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
20
_Config/IO/Gerät 1 (EtherCAT).xti
Normal file
20
_Config/IO/Gerät 1 (EtherCAT).xti
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<TcSmItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4026.19" ClassName="CDevEtherCATDef" SubType="111">
|
||||
<Device Id="1" Disabled="true" DevType="111" DevFlags="#x0003" AmsPort="28673" AmsNetId="5.167.199.178.2.1" RemoteName="Gerät 1 (EtherCAT)" InfoImageId="2">
|
||||
<Name>__FILENAME__</Name>
|
||||
<AddressInfo>
|
||||
<Pnp>
|
||||
<DeviceDesc></DeviceDesc>
|
||||
<DeviceName></DeviceName>
|
||||
<DeviceData>000000000000</DeviceData>
|
||||
</Pnp>
|
||||
</AddressInfo>
|
||||
<Image Id="1" AddrType="9" ImageType="3">
|
||||
<Name>Prozessabbild</Name>
|
||||
</Image>
|
||||
<Box File="Box 1 (INVEOR_M).xti" Id="1">
|
||||
<EtherCAT PortABoxInfo="#x00ffffff"/>
|
||||
</Box>
|
||||
<EtherCAT/>
|
||||
</Device>
|
||||
</TcSmItem>
|
||||
71
_Config/IO/Gerät 1 (EtherCAT)/Box 1 (INVEOR_M).xti
Normal file
71
_Config/IO/Gerät 1 (EtherCAT)/Box 1 (INVEOR_M).xti
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0"?>
|
||||
<TcSmItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4026.19" ClassName="CFlbTermDef" SubType="9099">
|
||||
<ImageDatas>
|
||||
<ImageData Id="1000">424de6000000000000007600000028000000100000000e000000010004000000000070000000000000000000000000000000000000000000000000008000008000000080800080000000800080008080000080808000c0c0c0000000ff0000ff000000ffff00ff000000ff00ff00ffff0000ffffff0088888888888888888888888888888888fff666ffff6666f8fff6877ff67876fffff7f77ffff67ffffff7f768ff6ffffffff7f78ff67ffffffff7ffff67fffffffff7f78ff67ffffffff7f766fff7fffffff7f77f6fff67fffff6877ff67876ffffffffffffffffffffffffffffffffff</ImageData>
|
||||
</ImageDatas>
|
||||
<Box Id="1" BoxType="9099" BoxFlags="#x00000020">
|
||||
<Name>__FILENAME__</Name>
|
||||
<ImageId>1000</ImageId>
|
||||
<EtherCAT SlaveType="2" PdiType="#x0006" StateMBoxPolling="true" UseLrdLwrInsteadOfLrw="true" CycleMBoxPollingTime="0" CoeType="19" FoeType="1" VendorId="#x00000337" ProductCode="#x00000003" RevisionNo="#x00000002" InfoDataAddr="true" PortPhys="17" MaxSlotCount="256" MaxSlotGroupCount="1" SlotPdoIncrement="1" SlotIndexIncrement="16" Type="INVEOR_M" Desc="INVEOR_M">
|
||||
<SyncMan>001080003600010001000000800080008000001036010000</SyncMan>
|
||||
<SyncMan>801080003200010002000000800080008000801032010000</SyncMan>
|
||||
<SyncMan>00111800740001000300000000000001c800001174010000</SyncMan>
|
||||
<SyncMan>00142800300001000400000000000001c800001430010000</SyncMan>
|
||||
<Fmmu>0000000000000000001100020100000001000000000000000000000000000000</Fmmu>
|
||||
<Fmmu>0000000000000000001400010100000002000000000000000000000000000000</Fmmu>
|
||||
<Fmmu>00000000000000000d0800010100000003000000000000000000000000000000</Fmmu>
|
||||
<Pdo Name="Inputs0" Index="#x1a00" Flags="#x0000" SyncMan="3">
|
||||
<Entry Name="Statuswort" Index="#x3000" Sub="#x01">
|
||||
<Type>UDINT</Type>
|
||||
</Entry>
|
||||
<Entry Name="Istfrequenz" Index="#x3000" Sub="#x02">
|
||||
<Type>REAL</Type>
|
||||
</Entry>
|
||||
<Entry Name="Motorspannung" Index="#x3000" Sub="#x03">
|
||||
<Type>REAL</Type>
|
||||
</Entry>
|
||||
<Entry Name="Motorstrom" Index="#x3000" Sub="#x04">
|
||||
<Type>REAL</Type>
|
||||
</Entry>
|
||||
<Entry Name="Netzspannung" Index="#x3000" Sub="#x05">
|
||||
<Type>REAL</Type>
|
||||
</Entry>
|
||||
<Entry Name="Frequenzsollwert" Index="#x3000" Sub="#x06">
|
||||
<Type>REAL</Type>
|
||||
</Entry>
|
||||
<Entry Name="Digitaleingänge bitcodiert" Index="#x3000" Sub="#x07">
|
||||
<Type>UDINT</Type>
|
||||
</Entry>
|
||||
<Entry Name="Analogeingang 1" Index="#x3000" Sub="#x08">
|
||||
<Type>REAL</Type>
|
||||
</Entry>
|
||||
<Entry Name="Fehlerwort 1" Index="#x3000" Sub="#x09">
|
||||
<Type>UDINT</Type>
|
||||
</Entry>
|
||||
<Entry Name="Fehlerwort 2" Index="#x3000" Sub="#x0a">
|
||||
<Type>UDINT</Type>
|
||||
</Entry>
|
||||
</Pdo>
|
||||
<Pdo Name="Outputs0" Index="#x1600" InOut="1" Flags="#x0000" SyncMan="2">
|
||||
<Entry Name="Steuerwort" Index="#x2000" Sub="#x01">
|
||||
<Type>UDINT</Type>
|
||||
</Entry>
|
||||
<Entry Name="Sollfrequenz" Index="#x2000" Sub="#x02">
|
||||
<Type>REAL</Type>
|
||||
</Entry>
|
||||
<Entry Name="Digitalausgänge / Relais" Index="#x2000" Sub="#x03">
|
||||
<Type>UDINT</Type>
|
||||
</Entry>
|
||||
<Entry Name="Analogausgang 1" Index="#x2000" Sub="#x04">
|
||||
<Type>REAL</Type>
|
||||
</Entry>
|
||||
<Entry Name="Kundenspez.SPS Eingangsgröße 1 (Digital 32Bit)" Index="#x2000" Sub="#x05">
|
||||
<Type>UDINT</Type>
|
||||
</Entry>
|
||||
<Entry Name="Kundenspez.SPS Eingangsgröße 1 (Digital 32Bit)" Index="#x2000" Sub="#x06">
|
||||
<Type>UDINT</Type>
|
||||
</Entry>
|
||||
</Pdo>
|
||||
</EtherCAT>
|
||||
</Box>
|
||||
</TcSmItem>
|
||||
Reference in New Issue
Block a user