Merge branch 'release/1.0'

This commit is contained in:
2026-01-21 07:55:09 +01:00
61 changed files with 12739 additions and 0 deletions

57
.gitignore vendored Normal file
View File

@@ -0,0 +1,57 @@
### TwinCAT3 ###
# website: https://www.beckhoff.com/twincat3/
# TwinCAT PLC
*.plcproj.bak
*.plcproj.orig
*.tpy
*.tclrs
#*.library
#*.compiled-library
*.compileinfo
*.asm
*.core
LineIDs.dbg
LineIDs.dbg.bak
# TwinCAT C++ and shared types
# ignoring the TMC file is only useful for plain PLC programming
# as soon as shared data types (via tmc), C++ or in general TcCom-Module are used, the TMC file has to be part of the repository
*.tmc
*.tmcRefac
# TwinCAT project files
*.tsproj.bak
*.tspproj.bak
*.tsproj.b?k
*.tsproj.orig
*.xti.bak
*.xti.bk?
*.xti.orig
*.xtv
*.xtv.bak
*.xtv.bk?
*.tnzip
# Multiuser specific
**/.TcGit/
# exclude not required folders
**/_Boot/
**/_CompileInfo/
**/_Libraries/
**/_ModuleInstall/
**/_Deployment/
**/_Repository/
# VS Shell project specific files and folders
**/.vs/
*.~u
*.project.~u
*.suo
# Own Ignores
commit.txt
*.txt
*.exe
*.xlsx

89
BaseComponents.sln Normal file
View File

@@ -0,0 +1,89 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# TcXaeShell Solution File, Format Version 11.00
VisualStudioVersion = 17.10.35827.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{B1E792BE-AA5F-4E3C-8C82-674BF9C0715B}") = "BaseComponents", "BaseComponents.tsproj", "{775BE4FD-89CE-48D5-8E68-5C84AF95981A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|TwinCAT OS (ARMV7-A) = Debug|TwinCAT OS (ARMV7-A)
Debug|TwinCAT OS (ARMV7-M) = Debug|TwinCAT OS (ARMV7-M)
Debug|TwinCAT OS (ARMV8-A) = Debug|TwinCAT OS (ARMV8-A)
Debug|TwinCAT OS (x64) = Debug|TwinCAT OS (x64)
Debug|TwinCAT OS (x64-E) = Debug|TwinCAT OS (x64-E)
Debug|TwinCAT RT (x64) = Debug|TwinCAT RT (x64)
Debug|TwinCAT RT (x86) = Debug|TwinCAT RT (x86)
Release|TwinCAT OS (ARMV7-A) = Release|TwinCAT OS (ARMV7-A)
Release|TwinCAT OS (ARMV7-M) = Release|TwinCAT OS (ARMV7-M)
Release|TwinCAT OS (ARMV8-A) = Release|TwinCAT OS (ARMV8-A)
Release|TwinCAT OS (x64) = Release|TwinCAT OS (x64)
Release|TwinCAT OS (x64-E) = Release|TwinCAT OS (x64-E)
Release|TwinCAT RT (x64) = Release|TwinCAT RT (x64)
Release|TwinCAT RT (x86) = Release|TwinCAT RT (x86)
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (ARMV7-A).ActiveCfg = Debug|TwinCAT OS (ARMV7-A)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (ARMV7-A).Build.0 = Debug|TwinCAT OS (ARMV7-A)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (ARMV7-M).ActiveCfg = Debug|TwinCAT OS (ARMV7-M)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (ARMV7-M).Build.0 = Debug|TwinCAT OS (ARMV7-M)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (ARMV8-A).ActiveCfg = Debug|TwinCAT OS (ARMV8-A)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (ARMV8-A).Build.0 = Debug|TwinCAT OS (ARMV8-A)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (x64).ActiveCfg = Debug|TwinCAT OS (x64)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (x64).Build.0 = Debug|TwinCAT OS (x64)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (x64-E).ActiveCfg = Debug|TwinCAT OS (x64-E)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT OS (x64-E).Build.0 = Debug|TwinCAT OS (x64-E)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT RT (x64).ActiveCfg = Debug|TwinCAT RT (x64)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT RT (x64).Build.0 = Debug|TwinCAT RT (x64)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT RT (x86).ActiveCfg = Debug|TwinCAT RT (x86)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Debug|TwinCAT RT (x86).Build.0 = Debug|TwinCAT RT (x86)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (ARMV7-A).ActiveCfg = Release|TwinCAT OS (ARMV7-A)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (ARMV7-A).Build.0 = Release|TwinCAT OS (ARMV7-A)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (ARMV7-M).ActiveCfg = Release|TwinCAT OS (ARMV7-M)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (ARMV7-M).Build.0 = Release|TwinCAT OS (ARMV7-M)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (ARMV8-A).ActiveCfg = Release|TwinCAT OS (ARMV8-A)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (ARMV8-A).Build.0 = Release|TwinCAT OS (ARMV8-A)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (x64).ActiveCfg = Release|TwinCAT OS (x64)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (x64).Build.0 = Release|TwinCAT OS (x64)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (x64-E).ActiveCfg = Release|TwinCAT OS (x64-E)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT OS (x64-E).Build.0 = Release|TwinCAT OS (x64-E)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT RT (x64).ActiveCfg = Release|TwinCAT RT (x64)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT RT (x64).Build.0 = Release|TwinCAT RT (x64)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT RT (x86).ActiveCfg = Release|TwinCAT RT (x86)
{775BE4FD-89CE-48D5-8E68-5C84AF95981A}.Release|TwinCAT RT (x86).Build.0 = Release|TwinCAT RT (x86)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (ARMV7-A).ActiveCfg = Debug|TwinCAT OS (ARMV7-A)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (ARMV7-A).Build.0 = Debug|TwinCAT OS (ARMV7-A)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (ARMV7-M).ActiveCfg = Debug|TwinCAT OS (ARMV7-M)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (ARMV7-M).Build.0 = Debug|TwinCAT OS (ARMV7-M)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (ARMV8-A).ActiveCfg = Debug|TwinCAT OS (ARMV8-A)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (ARMV8-A).Build.0 = Debug|TwinCAT OS (ARMV8-A)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (x64).ActiveCfg = Debug|TwinCAT OS (x64)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (x64).Build.0 = Debug|TwinCAT OS (x64)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (x64-E).ActiveCfg = Debug|TwinCAT OS (x64-E)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT OS (x64-E).Build.0 = Debug|TwinCAT OS (x64-E)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT RT (x64).ActiveCfg = Debug|TwinCAT RT (x64)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT RT (x64).Build.0 = Debug|TwinCAT RT (x64)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT RT (x86).ActiveCfg = Debug|TwinCAT RT (x86)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Debug|TwinCAT RT (x86).Build.0 = Debug|TwinCAT RT (x86)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (ARMV7-A).ActiveCfg = Release|TwinCAT OS (ARMV7-A)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (ARMV7-A).Build.0 = Release|TwinCAT OS (ARMV7-A)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (ARMV7-M).ActiveCfg = Release|TwinCAT OS (ARMV7-M)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (ARMV7-M).Build.0 = Release|TwinCAT OS (ARMV7-M)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (ARMV8-A).ActiveCfg = Release|TwinCAT OS (ARMV8-A)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (ARMV8-A).Build.0 = Release|TwinCAT OS (ARMV8-A)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (x64).ActiveCfg = Release|TwinCAT OS (x64)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (x64).Build.0 = Release|TwinCAT OS (x64)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (x64-E).ActiveCfg = Release|TwinCAT OS (x64-E)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT OS (x64-E).Build.0 = Release|TwinCAT OS (x64-E)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT RT (x64).ActiveCfg = Release|TwinCAT RT (x64)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT RT (x64).Build.0 = Release|TwinCAT RT (x64)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT RT (x86).ActiveCfg = Release|TwinCAT RT (x86)
{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}.Release|TwinCAT RT (x86).Build.0 = Release|TwinCAT RT (x86)
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {774463EE-2F3E-4F1B-B601-3BD67A7A2115}
EndGlobalSection
EndGlobal

508
BaseComponents.tsproj Normal file
View File

@@ -0,0 +1,508 @@
<?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.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}" Target64Bit="true" ShowHideConfigurations="#x6">
<System>
<Settings MaxCpus="2"/>
<Licenses>
<Target>
<ManualSelect>{9FD32FC8-0CF9-4C5B-95FB-F35423496A77}</ManualSelect>
<LicenseDevice DongleHardwareId="2" DongleDevice="#x71010002" DongleLevel="92" DongleSystemId="{F4D452BD-01EA-8CE8-F538-CCB335BD88CC}" 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" File="BaseComponents.tmc"/>
</TypeSystem>
</System>
<Plc>
<Project GUID="{4E62D9E7-436C-457D-8DC4-82D2FEF91C96}" Name="BasicComponents" PrjFilePath="BasicComponents\BasicComponents.plcproj" TmcFilePath="BasicComponents\BasicComponents.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" CopyTmcToTarget="true" CopyTpyToTarget="false" SymbolicMapping="true">
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcHash="{BC065F54-D783-3F62-2B3C-EC8392B01342}" TmcPath="PLC\PLC.tmc">
<Name>BasicComponents 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>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorLowOn.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorLowOn.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorLowOn.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorLowOn.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningLowOn.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningLowOn.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningLowOn.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningLowOn.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningHighOn.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningHighOn.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningHighOn.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningHighOn.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorHighOn.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorHighOn.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorHighOn.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorHighOn.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIOverrangeOn.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIOverrangeOn.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIOverrangeOn.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIOverrangeOn.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIUnderrangeOn.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIUnderrangeOn.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIUnderrangeOn.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIUnderrangeOn.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorLowOff.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorLowOff.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorLowOff.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorLowOff.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningLowOff.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningLowOff.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningLowOff.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningLowOff.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningHighOff.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningHighOff.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningHighOff.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIWarningHighOff.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorHighOff.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorHighOff.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorHighOff.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIErrorHighOff.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIUnderrangeOff.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIUnderrangeOff.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIUnderrangeOff.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIUnderrangeOff.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
EL30xx also sets this if an underrange or overrange error is present]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIOverrangeOff.iAnalogValue</Name>
<Comment><![CDATA[ Analog input value]]></Comment>
<Type>INT</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIOverrangeOff.xUnderrange</Name>
<Comment><![CDATA[ Card has detected an open circuit]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIOverrangeOff.xOverrange</Name>
<Comment><![CDATA[ Input is overloaded]]></Comment>
<Type>BOOL</Type>
</Var>
<Var>
<Name>PRG_MAIN._fbAnalogInputTest._fbAIOverrangeOff.xErrorCard</Name>
<Comment><![CDATA[ Input card has error
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>
<Id>0</Id>
<Name>PlcTask</Name>
<ManualConfig>
<OTCID>#x02010030</OTCID>
</ManualConfig>
<Priority>20</Priority>
<CycleTime>10000000</CycleTime>
</Context>
</Contexts>
<TaskPouOids>
<TaskPouOid Prio="20" OTCID="#x08502001"/>
</TaskPouOids>
</Instance>
</Project>
</Plc>
</Project>
</TcSmProject>

BIN
BasicComponents.library Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,584 @@
<?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 FINAL FB_AnalogInput
VAR_INPUT
// Analog input value
iAnalogValue AT %I* : INT;
// Card has detected an open circuit
xUnderrange AT%I* : BOOL;
// Input is overloaded
xOverrange AT %I* : BOOL;
// Input card has error
// EL30xx also sets this if an underrange or overrange error is present
xErrorCard AT %I* : BOOL;
// IO config data
stAnalogIOConfig : ST_ANALOG_IO_CONFIG;
// Error and warning config data
stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
// Global switch to dissable all errors
xReleaseErrors : BOOL := TRUE;
// Enables or dissables errors from min max values
xReleaseLimitErrors : BOOL := FALSE;
// 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
// Optional HMI interface
stHMIInterface : ST_HMI_ANALOG_VALUE;
// Scaled output value
rScaledValue : REAL;
// Error in function block
xError : BOOL;
// Warning active
xWarning : BOOL;
// Low level error
xErrorLow : BOOL;
// Low level warning
xWarningLow : BOOL;
// High level warning
xWarningHigh : BOOL;
//High level error
xErrorHigh : BOOL;
END_VAR
VAR
// Scaling factor for conversion
_rConversionFactor : REAL;
// Base offset for scaling factor
_rBaseOffset : REAL;
// Min warning level
_rMinWarningLevel : REAL;
// Max warning level
_rMaxWarningLevel : REAL;
// Min error level
_rMinErrorLevel : REAL;
// Max error level
_rMaxErrorLevel : REAL;
// Scaling config error
_xConfigError : BOOL := FALSE;
// Limits config error
_xEWConfigError : BOOL := FALSE;
// Helper variables used in reset error flag
_xAlarmsActive : BOOL;
_xInputErrorsActive : BOOL;
// Max process value
_iAIMax : INT;
// Min process value
_iAIMin : INT;
// Clamped analog value
_iClampedAnalogValue : INT;
// Internal scaled value
_rScaledValue : REAL;
// Name of the function block
_sName : STRING;
// Internal warning flags
_xWarningLow : BOOL;
_xWarningHigh : BOOL;
_xWarning : BOOL;
// Internal error flag
_xErrorLow : BOOL;
_xErrorHigh : BOOL;
_xError : BOOL;
// Alarm handlers
_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_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[// ===============
// 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
// =========
// Calculate scaling factors,
// scaling will be zero in case
// of invalid scaling parameters.
// Also checks if reference to config data is valid.
CalcScalingFactors();
// Check error and warning levels config
// Will later raise alarms if config is wrong
CheckEWLevels();
// ===========================
// Config error alarm handling
// ===========================
_fbAlarmConfigError(
xActive:= _xConfigError OR (_xEWConfigError AND xReleaseLimitErrors),
xRelease:= xReleaseErrors,
xAcknowledge:= ,
timOnDelay:= ,
timOffDelay:= ,
xInUnitTestMode:= xInUnitTestMode);
IF _fbAlarmConfigError.Triggered THEN
_xError := TRUE;
END_IF
// ========================
// Analog value calculation
// ========================
// Clamp analogue input levels
_iClampedAnalogValue := MAX(_iAIMin, iAnalogValue);
_iClampedAnalogValue := MIN(_iAIMax, _iClampedAnalogValue);
// Calc scaled value
_rScaledValue := _iClampedAnalogValue * _rConversionFactor + _rBaseOffset;
// =========================
// Underrange alarm handling
// =========================
_fbAlarmUnderrange(
xActive:= xUnderrange,
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseHardwareErrors,
xAcknowledge:= xConfirmAlarms,
timOnDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOn,
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff,
xInUnitTestMode:= xInUnitTestMode);
// Latch error signal
IF _fbAlarmUnderrange.Triggered THEN
_xError := TRUE;
END_IF
// =========================
// Overload alarm handling
// =========================
_fbAlarmOverload(
xActive:= xOverrange,
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseHardwareErrors,
xAcknowledge:= xConfirmAlarms,
timOnDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOn,
timOffDelay:= stAnalogEWConfig.stDelays.timHardwareSignalLevelOff,
xInUnitTestMode:= xInUnitTestMode);
// Latch error signal
IF _fbAlarmOverload.Triggered THEN
_xError := TRUE;
END_IF
// =========================
// Card alarm handling
// =========================
// Filter overload error signal
// EL30xx also sets this if an underrange or overrange error is present,
// so we filter this out
_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,
xInUnitTestMode:= xInUnitTestMode);
// Latch error signal
IF _fbAlarmCardError.Triggered THEN
_xError := TRUE;
END_IF
// ===========================
// Error high alarm handling
// ===========================
_fbAlarmErrorHigh(
xActive:= (_rScaledValue >= _rMaxErrorLevel),
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
xAcknowledge:= xConfirmAlarms,
timOnDelay:= stAnalogEWConfig.stDelays.timErrorHighOn,
timOffDelay:= stAnalogEWConfig.stDelays.timErrorHighOff,
xInUnitTestMode:= xInUnitTestMode);
_xErrorHigh := _fbAlarmErrorHigh.Triggered;
// Latch error
IF _xErrorHigh THEN
_xError := TRUE;
END_IF
// ===========================
// Error low alarm handling
// ===========================
_fbAlarmErrorLow(
xActive:= (_rScaledValue <= _rMinErrorLevel),
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
xAcknowledge:= xConfirmAlarms,
timOnDelay:= stAnalogEWConfig.stDelays.timErrorLowOn,
timOffDelay:= stAnalogEWConfig.stDelays.timErrorLowOff,
xInUnitTestMode:= xInUnitTestMode);
_xErrorLow := _fbAlarmErrorLow.Triggered;
// Latch error
IF _xErrorLow THEN
_xError := TRUE;
END_IF
// ===========================
// Warning high alarm handling
// ===========================
_fbAlarmWarningHigh(
xActive:= (_rScaledValue >= _rMaxWarningLevel),
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
xAcknowledge:= xConfirmAlarms,
timOnDelay:= stAnalogEWConfig.stDelays.timWarningHighOn,
timOffDelay:= stAnalogEWConfig.stDelays.timWarningHighOff,
xInUnitTestMode:= xInUnitTestMode);
_xWarningHigh := _fbAlarmWarningHigh.Triggered;
// ===========================
// Warning low alarm handling
// ===========================
_fbAlarmWarningLow(
xActive:= (_rScaledValue <= _rMinWarningLevel),
xRelease:= stAnalogIOConfig.xUsed AND xReleaseErrors AND xReleaseLimitErrors AND (NOT _xEWConfigError),
xAcknowledge:= xConfirmAlarms,
timOnDelay:= stAnalogEWConfig.stDelays.timWarningLowOn,
timOffDelay:= stAnalogEWConfig.stDelays.timWarningLowOff,
xInUnitTestMode:= xInUnitTestMode);
_xWarningLow := _fbAlarmWarningLow.Triggered;
// ============
// Warning flag
// ============
_xWarning := _xWarningLow OR _xWarningHigh;
// ================
// Reset error flag
// ================
_xAlarmsActive := _fbAlarmConfigError.Active
OR _fbAlarmUnderrange.Active
OR _fbAlarmOverload.Active
OR _fbAlarmCardError.Active
OR _fbAlarmErrorHigh.Active
OR _fbAlarmErrorLow.Active;
_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;
END_IF
// ====================
// Handle HMI interface
// ====================
HandleHMIOutput();
// Copy internal signals to outputs
xWarningLow := _xWarningLow;
xWarningHigh := _xWarningHigh;
xWarning := _xWarning;
xErrorLow := _xErrorLow;
xErrorHigh := _xErrorHigh;
xError := _xError;
rScaledValue := _rScaledValue;]]></ST>
</Implementation>
<Method Name="CalcScalingFactors" Id="{e88dfbcd-1a0d-45a0-9d50-5ad8be2479c9}">
<Declaration><![CDATA[{attribute 'analysis' := '-56'}
METHOD PRIVATE CalcScalingFactors
VAR
_rNum : REAL;
_rDenom : REAL;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// _lrConversionFactor := (lrPVMax - lrPVMin)/(udiAIMax - udiAIMin) + (rPVMin - ((lrPVMax - lrPVMin)/(udiAIMax - udiAIMin)*udiAIMin))
// Splitted in two calculations to catch division by zero
_rNum := (stAnalogIOConfig.rPVMax - stAnalogIOConfig.rPVMin);
_rDenom := INT_TO_REAL(stAnalogIOConfig.iAIMax - stAnalogIOConfig.iAIMin);
// Do not divide by 0 or a negative number
IF _rDenom > 0.0 THEN
_rConversionFactor := _rNum/_rDenom;
_rBaseOffset := stAnalogIOConfig.rPVMin - (_rConversionFactor * INT_TO_REAL(stAnalogIOConfig.iAIMin));
_iAIMax := stAnalogIOConfig.iAIMax;
_iAIMin := stAnalogIOConfig.iAIMin;
_xConfigError := FALSE;
ELSE
// Division by zero happened
// Or denom was negative
// Set scaling to zero
_rConversionFactor := 0.0;
_rBaseOffset := 0.0;
_iAIMax := 0;
_iAIMin := 0;
_xConfigError := TRUE;
END_IF]]></ST>
</Implementation>
</Method>
<Method Name="CheckEWLevels" Id="{6fcb5a6d-e37d-4efd-ad76-02026f476863}">
<Declaration><![CDATA[METHOD PRIVATE CheckEWLevels
VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Reset (E)rror (W)arning config error
_xEWConfigError := FALSE;
// Check for EW config error
IF stAnalogEWConfig.stLevels.rWarningMin <= stAnalogEWConfig.stLevels.rErrorMin THEN
_xEWConfigError := TRUE;
END_IF
IF stAnalogEWConfig.stLevels.rWarningMax >= stAnalogEWConfig.stLevels.rErrorMax THEN
_xEWConfigError := TRUE;
END_IF
IF stAnalogEWConfig.stLevels.rWarningMin >= stAnalogEWConfig.stLevels.rWarningMax THEN
_xEWConfigError := TRUE;
END_IF
// Only write error and warning levels when there was no config error
IF (NOT _xEWConfigError) THEN
// Recreate alarm messages with the newly set limits
// if values have been changed
{analysis -54}
IF (_rMinErrorLevel <> stAnalogEWConfig.stLevels.rErrorMin)
OR (_rMinWarningLevel <> stAnalogEWConfig.stLevels.rWarningMin)
OR (_rMaxWarningLevel <> stAnalogEWConfig.stLevels.rWarningMax)
OR (_rMaxErrorLevel <> stAnalogEWConfig.stLevels.rErrorMax) THEN
{analysis +54}
CreateAlarmLimitsMSG();
END_IF
// Set new values
_rMinErrorLevel := stAnalogEWConfig.stLevels.rErrorMin;
_rMinWarningLevel := stAnalogEWConfig.stLevels.rWarningMin;
_rMaxWarningLevel := stAnalogEWConfig.stLevels.rWarningMax;
_rMaxErrorLevel := stAnalogEWConfig.stLevels.rErrorMax;
END_IF
]]></ST>
</Implementation>
</Method>
<Method Name="CreateAlarmLimitsMSG" Id="{d38eb5a5-80eb-4ab2-8c50-97431707ca20}">
<Declaration><![CDATA[{attribute 'analysis' := '-26'}
METHOD PRIVATE CreateAlarmLimitsMSG
VAR_INPUT
END_VAR
VAR
_sTempUnit : STRING;
_sTempErrorMin : STRING;
_sTempWarningMin : STRING;
_sTempWarningMax : STRING;
_sTempErrorMax : STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Check if analog value has unit
IF stAnalogIOConfig.sUnit <> '' THEN
_sTempUnit := CONCAT(' ', stAnalogIOConfig.sUnit);
ELSE
_sTempUnit := '';
END_IF
// Create message parameter strings
_sTempErrorMin := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rErrorMin), _sTempUnit);
_sTempWarningMin := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rWarningMin), _sTempUnit);
_sTempWarningMax := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rWarningMax), _sTempUnit);
_sTempErrorMax := CONCAT(REAL_TO_STRING(stAnalogEWConfig.stLevels.rErrorMax), _sTempUnit);
{analysis -46}
// Inser message parameters
_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>
<Method Name="CreateAlarmMSG" Id="{e4d0fc74-1711-410b-9ec3-4af08afbc236}">
<Declaration><![CDATA[METHOD PRIVATE CreateAlarmMSG
VAR_INPUT
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[{analysis -46}
_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>
<Method Name="FB_init" Id="{27512538-cc2f-4100-8046-022de49f067a}">
<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)
// Name of analogue io
sName : STRING(80);
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[// Save io name
_sName := sName;
// Create alarm messages
CreateAlarmMSG();
CreateAlarmLimitsMSG();]]></ST>
</Implementation>
</Method>
<Method Name="HandleHMIOutput" Id="{1667ccb9-efb6-43f9-9a11-5c208475143f}">
<Declaration><![CDATA[METHOD PRIVATE HandleHMIOutput
VAR_INPUT
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[stHMIInterface.xUsed := stAnalogIOConfig.xUsed;
stHMIInterface.sUnit := stAnalogIOConfig.sUnit;
stHMIInterface.sName := _sName;
stHMIInterface.rValue := _rScaledValue;
stHMIInterface.rMin := stAnalogIOConfig.rPVMin;
stHMIInterface.rMax := stAnalogIOConfig.rPVMax;
IF _xError THEN
stHMIInterface.iStatus := 2;
ELSE
stHMIInterface.iStatus := 1;
END_IF]]></ST>
</Implementation>
</Method>
<Property Name="Name" Id="{103c7177-ef49-4a4b-98b1-06578d5fce31}">
<Declaration><![CDATA[PROPERTY Name : STRING(80)]]></Declaration>
<Get Name="Get" Id="{02e85b3f-9933-4282-a9d2-1ab27eb22499}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[Name := _sName;]]></ST>
</Implementation>
</Get>
<Set Name="Set" Id="{4215abec-259f-45d7-a31e-437036d4e241}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_sName := Name;
// After a name change, all error messages have to be changed
CreateAlarmMSG();
CreateAlarmLimitsMSG();]]></ST>
</Implementation>
</Set>
</Property>
</POU>
</TcPlcObject>

View 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>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_ANALOG_EW_CONFIG" Id="{6f3ed88d-28a0-4a7f-a26a-6b822e47799e}">
<Declaration><![CDATA[TYPE ST_ANALOG_EW_CONFIG :
STRUCT
stLevels : ST_ANALOG_EW_LEVELS;
stDelays : ST_ANALOG_EW_DELAYS;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_ANALOG_EW_DELAYS" Id="{8b5ae408-253c-4618-ab64-5d8c4935716b}">
<Declaration><![CDATA[TYPE ST_ANALOG_EW_DELAYS :
STRUCT
{attribute 'OPC.UA.DA' := '1'}
timHardwareSignalLevelOn : TIME;
{attribute 'OPC.UA.DA' := '1'}
timHardwareSignalLevelOff : TIME;
{attribute 'OPC.UA.DA' := '1'}
timErrorLowOn : TIME;
{attribute 'OPC.UA.DA' := '1'}
timErrorLowOff : TIME;
{attribute 'OPC.UA.DA' := '1'}
timWarningLowOn : TIME;
{attribute 'OPC.UA.DA' := '1'}
timWarningLowOff : TIME;
{attribute 'OPC.UA.DA' := '1'}
timWarningHighOn : TIME;
{attribute 'OPC.UA.DA' := '1'}
timWarningHighOff : TIME;
{attribute 'OPC.UA.DA' := '1'}
timErrorHighOn : TIME;
{attribute 'OPC.UA.DA' := '1'}
timErrorHighOff : TIME;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_ANALOG_EW_LEVELS" Id="{40734543-a4f6-4336-bcfe-ac65f034a277}">
<Declaration><![CDATA[TYPE ST_ANALOG_EW_LEVELS :
STRUCT
{attribute 'OPC.UA.DA' := '1'}
rErrorMin : REAL;
{attribute 'OPC.UA.DA' := '1'}
rWarningMin : REAL;
{attribute 'OPC.UA.DA' := '1'}
rWarningMax : REAL;
{attribute 'OPC.UA.DA' := '1'}
rErrorMax : REAL;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_ANALOG_IO_CONFIG" Id="{ee57b40d-d65d-438f-80f9-912bc67bff84}">
<Declaration><![CDATA[TYPE ST_ANALOG_IO_CONFIG :
STRUCT
// Maximum analog value
{attribute 'OPC.UA.DA' := '1'}
iAIMax : INT;
// Minimum analog value
{attribute 'OPC.UA.DA' := '1'}
iAIMin : INT;
// Maximum process value
{attribute 'OPC.UA.DA' := '1'}
rPVMax : REAL;
// Minimum process value
{attribute 'OPC.UA.DA' := '1'}
rPVMin : REAL;
// Process unit (V, A, P, U/min, %, rpm etc)
{attribute 'OPC.UA.DA' := '1'}
sUnit : STRING;
// Analog IO is used
{attribute 'OPC.UA.DA' := '1'}
xUsed : BOOL := TRUE;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View File

@@ -0,0 +1,334 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="FB_EventListener" Id="{f2b95750-ccda-4cd6-a03a-c64e3d2c4751}" SpecialFunc="None">
<Declaration><![CDATA[{attribute 'no_assign'}
FUNCTION_BLOCK FB_EventListener EXTENDS FB_ListenerBase2
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
_fbEventLogger : FB_TcEventLogger;
_fbEventFilter : FB_TcEventFilter;
_fbMqttClient : FB_IotMqtt5Client;
_fbBuffer : FB_MemRingBuffer;
_abAlarmBuffer : ARRAY[0..1000] OF BYTE;
_fbJson : FB_JsonSaxWriter;
_sTopic : STRING(255);
_stBufferEventEntryToBuffer : ST_BufferEventEntry;
_stBufferEventEntryFromBuffer : ST_BufferEventEntry;
{attribute 'TcEncoding':='UTF-8'}
_sLastMessageText : STRING;
_udiCurrentEntries : UDINT;
_uiState : UINT := 0;
// Result from read buffer head
_xSuccess : BOOL;
// Results from read event message
_xGetTextDone : BOOL;
_xGetTextError : BOOL;
// Internal signal to connect to mqtt broker
_xConnect : BOOL := TRUE;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Needs to be called to get alarms and events
SUPER^.Execute();
// Call mqtt client
_fbMqttClient.Execute(bConnect := _xConnect);
// Check if we have alarms to send
IF _udiCurrentEntries > 0 THEN
{analysis -19}
_fbBuffer.A_RemoveHead(pRead:= ADR(_stBufferEventEntryFromBuffer),
cbRead:= SIZEOF(_stBufferEventEntryFromBuffer),
pBuffer:= ADR(_abAlarmBuffer),
cbBuffer:= SIZEOF(_abAlarmBuffer),
bOk=> _xSuccess,
nCount => _udiCurrentEntries);
{analysis +19}
IF _xSuccess THEN
_uiState := 10;
END_IF
END_IF
CASE _uiState OF
0: // Idle
10: // Get alarm text
_xGetTextDone := _stBufferEventEntryFromBuffer.fbAlarm.RequestEventText(
nLangId := 1033,
sResult := _sLastMessageText,
nResultSize := SIZEOF(_sLastMessageText),
bError => _xGetTextError);
IF _xGetTextError THEN
_sLastMessageText := '';
_uiState := 20;
ELSIF _xGetTextDone THEN
_uiState := 20;
END_IF
20: // Create mqtt message
CreateMessage();
_uiState := 0;
ELSE
// Do nothing
;
END_CASE]]></ST>
</Implementation>
<Method Name="AddAlarmToQueue" Id="{21a4a6af-4b8a-455f-b344-9cb0224cbfab}">
<Declaration><![CDATA[METHOD PRIVATE AddAlarmToQueue : BOOL
VAR_INPUT
END_VAR
VAR
_xOk : BOOL;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[{analysis -19}
_fbBuffer.A_AddTail( pWrite:= ADR( _stBufferEventEntryToBuffer ),
cbWrite:= SIZEOF( _stBufferEventEntryToBuffer ),
pBuffer:= ADR( _abAlarmBuffer ),
cbBuffer:= SIZEOF( _abAlarmBuffer ),
bOk=> _xOk,
nCount => _udiCurrentEntries);
{analysis +19}
AddAlarmToQueue := _xOk;
]]></ST>
</Implementation>
</Method>
<Method Name="CreateMessage" Id="{d6f40ec8-01e1-47a8-a5b0-10322e1b0d10}">
<Declaration><![CDATA[METHOD PRIVATE CreateMessage
VAR_INPUT
END_VAR
VAR
_sTemp : STRING;
_sJsonDocument : STRING(255);
_fbArguments : I_TcArguments;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_fbJson.ResetDocument();
_fbJson.StartObject();
// id todo test hashing
_fbJson.AddKey('id');
_fbJson.AddUdint(_stBufferEventEntryFromBuffer.fbAlarm.nUniqueId);
// Skip parent
// ack
_fbJson.AddKey('ack');
CASE _stBufferEventEntryFromBuffer.fbAlarm.eConfirmationState OF
TcEventConfirmationState.WaitForConfirmation:
_fbJson.AddUdint(1);
TcEventConfirmationState.Confirmed:
_fbJson.AddUdint(2);
ELSE
_fbJson.AddUdint(0);
END_CASE
// state
_fbJson.AddKey('state');
IF _stBufferEventEntryFromBuffer.fbAlarm.bActive THEN
_fbJson.AddUdint(1);
ELSE
_fbJson.AddUdint(0);
END_IF
// t0
_fbJson.AddKey('t0');
// In case of a reraise this will be updated!!!
_fbJson.AddUlint(_stBufferEventEntryFromBuffer.fbAlarm.nTimeRaised);
// t1
_fbJson.AddKey('t1');
CASE _stBufferEventEntryFromBuffer.eEventType OF
E_EventType.RAISED:
_fbJson.AddUlint(_stBufferEventEntryFromBuffer.fbAlarm.nTimeRaised);
E_EventType.CLEARED:
_fbJson.AddUlint(_stBufferEventEntryFromBuffer.fbAlarm.nTimeCleared);
E_EventType.CONFIRMED:
_fbJson.AddUlint(_stBufferEventEntryFromBuffer.fbAlarm.nTimeConfirmed);
ELSE
_fbJson.AddUlint(0);
END_CASE
// Skipp access rights
// Skipp origin id use origin name instead
// origin
_fbJson.AddKey('origin');
{analysis -46}
_sTemp := _stBufferEventEntryFromBuffer.fbAlarm.ipSourceInfo.sName;
{analysis +46}
_fbJson.AddString(_sTemp);
// Skipp message id because there is no catalogue
// msg
_fbJson.AddKey('msg');
_fbJson.AddString(_sLastMessageText);
// s
_fbJson.AddKey('s');
CASE _stBufferEventEntryFromBuffer.fbAlarm.eSeverity OF
TcEventSeverity.Info:
_fbJson.AddUdint(96);
TcEventSeverity.Warning:
_fbJson.AddUdint(160);
TcEventSeverity.Error:
_fbJson.AddUdint(224);
TcEventSeverity.Critical:
_fbJson.AddUdint(255);
ELSE
_fbJson.AddUdint(32);
END_CASE
// Skip message parameters
_fbArguments := _stBufferEventEntryFromBuffer.fbAlarm.ipArguments;
_fbJson.EndObject();
{analysis -26}
_fbJson.CopyDocument(_sJsonDocument, SIZEOF(_sJsonDocument));
{analysis +26}
// Send topic
_fbMqttClient.Publish(
sTopic:= 'SlmMachine/Notifications/NAMESPACE/Detail',
pPayload:= ADR(_sTemp),
nPayloadSize:= LEN2(ADR(_sTemp))+1,
eQoS:= TcIotMqttQos.AtLeastOnceDelivery,
bRetain:= FALSE,
bQueue:= FALSE);]]></ST>
</Implementation>
</Method>
<Method Name="FB_Init" Id="{a946d52f-a0e6-4aac-9d4c-5dd8aba5f5d2}">
<Declaration><![CDATA[//FB_Init is always available implicitly and it is used primarily for initialization.
//The return value is not evaluated. For a specific influence, you can also declare the
//methods explicitly and provide additional code there with the standard initialization
//code. You can evaluate the return value.
METHOD FB_Init: BOOL
VAR_INPUT
bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold)
bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change)
sHostName : STRING := 'localhost';
uiHostPort : UINT := 1883;
sTopic : STRING(255);
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[// Register alarms and messages
_fbEventFilter.Clear().IsAlarm().OR_OP().IsMessage();
Subscribe2(ipEventFilter := _fbEventFilter);
// Setup mqtt client parameters
_fbMqttClient.sHostName := sHostName;
_fbMqttClient.nHostPort := uiHostPort;
_sTopic := sTopic;
// Reset buffer
_fbBuffer.A_Reset();]]></ST>
</Implementation>
</Method>
<Method Name="OnAlarmCleared" Id="{00aefa2e-a70c-4880-b7a7-760d0051e0ee}">
<Declaration><![CDATA[METHOD OnAlarmCleared : Tc3_EventLogger.HRESULT
VAR_INPUT
{attribute 'naming' := 'off'}
fbEvent : REFERENCE TO Tc3_EventLogger.FB_TcEvent;
{attribute 'naming' := 'on'}
END_VAR
VAR
_xSuccess : BOOL;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[IF __ISVALIDREF(fbEvent) THEN
_fbEventLogger.GetAlarmEx(stEventEntry := fbEvent.stEventEntry, ipSourceInfo := fbEvent.ipSourceInfo, fbAlarm := _stBufferEventEntryToBuffer.fbAlarm);
_stBufferEventEntryToBuffer.eEventType := E_EventType.CLEARED;
_xSuccess := AddAlarmToQueue();
END_IF
]]></ST>
</Implementation>
</Method>
<Method Name="OnAlarmConfirmed" Id="{4f33c838-6809-4051-9524-d88e2cf6713c}">
<Declaration><![CDATA[METHOD OnAlarmConfirmed : Tc3_EventLogger.HRESULT
VAR_INPUT
{attribute 'naming' := 'off'}
fbEvent : REFERENCE TO Tc3_EventLogger.FB_TcEvent;
{attribute 'naming' := 'on'}
END_VAR
VAR
_xSuccess : BOOL;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[IF __ISVALIDREF(fbEvent) THEN
_fbEventLogger.GetAlarmEx(stEventEntry := fbEvent.stEventEntry, ipSourceInfo := fbEvent.ipSourceInfo, fbAlarm := _stBufferEventEntryToBuffer.fbAlarm);
_stBufferEventEntryToBuffer.eEventType := E_EventType.CONFIRMED;
_xSuccess := AddAlarmToQueue();
END_IF]]></ST>
</Implementation>
</Method>
<Method Name="OnAlarmRaised" Id="{2454a94e-91c5-4b90-9762-eaee63119c3b}">
<Declaration><![CDATA[METHOD OnAlarmRaised : Tc3_EventLogger.HRESULT
VAR_INPUT
{attribute 'naming' := 'off'}
fbEvent : REFERENCE TO Tc3_EventLogger.FB_TcEvent;
{attribute 'naming' := 'on'}
END_VAR
VAR
_xSuccess : BOOL;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[IF __ISVALIDREF(fbEvent) THEN
_fbEventLogger.GetAlarmEx(stEventEntry := fbEvent.stEventEntry, ipSourceInfo := fbEvent.ipSourceInfo, fbAlarm := _stBufferEventEntryToBuffer.fbAlarm);
_stBufferEventEntryToBuffer.eEventType := E_EventType.RAISED;
_xSuccess := AddAlarmToQueue();
END_IF
]]></ST>
</Implementation>
</Method>
<Method Name="OnMessageSent" Id="{13d5d489-4166-4664-bd09-265b3b8bc14f}">
<Declaration><![CDATA[METHOD OnMessageSent : Tc3_EventLogger.HRESULT
VAR_INPUT
{attribute 'naming' := 'off'}
fbEvent : REFERENCE TO Tc3_EventLogger.FB_TcEvent;
{attribute 'naming' := 'on'}
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
</Method>
</POU>
</TcPlcObject>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="E_EventType" Id="{c41c8e8d-56af-4514-8482-2c521e403b96}">
<Declaration><![CDATA[{attribute 'qualified_only'}
{attribute 'strict'}
{attribute 'to_string'}
TYPE E_EventType :
(
RAISED := 0,
CLEARED,
CONFIRMED,
MESSAGE
);
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<DUT Name="ST_BufferEventEntry" Id="{95daccce-6c97-4afa-b8a3-fb60fb3847c5}">
<Declaration><![CDATA[TYPE ST_BufferEventEntry :
STRUCT
fbAlarm : FB_TcAlarm;
eEventType : E_EventType;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View 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>

View 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>

View File

@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="FB_AlarmMessage" Id="{00b96800-3427-0356-3ac6-5d6b32218bad}" 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;
{attribute 'hide'}
xInUnitTestMode : BOOL := FALSE;
END_VAR
VAR_OUTPUT
END_VAR
VAR
_fbReleaseAlarm : FB_ReleaseSignal;
_fbAlarmMessage : FB_TcAlarm;
_fbSourceInfo : FB_TcSourceInfo;
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="{00a4408d-c0d1-0670-1ca5-9dcb270a2efc}">
<Declaration><![CDATA[PROPERTY Active : BOOL]]></Declaration>
<Get Name="Get" Id="{3e04f28e-d803-004a-19a2-eeac94c59afc}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[Active := _fbAlarmMessage.bActive;]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="Arguments" Id="{bad76689-89ef-0a0e-34ee-f40fa5d6aac1}">
<Declaration><![CDATA[PROPERTY PUBLIC Arguments : I_TcArguments]]></Declaration>
<Get Name="Get" Id="{8f632d08-eff2-0cce-3562-f29db78cffa0}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[Arguments := _fbAlarmMessage.ipArguments;]]></ST>
</Implementation>
</Get>
</Property>
<Method Name="FB_init" Id="{173de1d9-a300-02b1-2769-f9766f992e18}">
<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
VAR
_sTmp : STRING;
_sLeft : STRING;
_sRight : STRING;
_udiI : UDINT;
_udiPosition : UDINT;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[// Edit source info name, so that we get the parent as a source
// and not this fb
_sTmp := _fbSourceInfo.sName;
FindAndSplitChar(
sSeparatorChar:= '.',
pSrcString:= ADR(_sTmp),
pLeftString:= ADR(_sLeft),
nLeftSize:= SIZEOF(_sLeft),
pRightString:= ADR(_sRight),
nRightSize:= SIZEOF(_sRight),
bSearchFromRight:= TRUE);
_fbSourceInfo.sName := _sLeft;
// Create alarm
_fbAlarmMessage.CreateEx(stEventEntry := stEventEntry, bWithConfirmation := xWithConfirmation);]]></ST>
</Implementation>
</Method>
<Property Name="Raised" Id="{2254f7ab-28c0-02ea-0e65-a373d9d5b007}">
<Declaration><![CDATA[PROPERTY Raised : BOOL]]></Declaration>
<Get Name="Get" Id="{402fa563-3cdd-092f-24cf-a227bf8b3ef3}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[Raised := _fbAlarmMessage.bRaised;]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="Triggered" Id="{cafebd2a-d123-0563-2c59-c51cfbad3eb5}">
<Declaration><![CDATA[PROPERTY Triggered : BOOL]]></Declaration>
<Get Name="Get" Id="{532baece-3197-078f-07fe-70f16274ef68}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[Triggered := _fbReleaseAlarm.xReleaseSignal;]]></ST>
</Implementation>
</Get>
</Property>
</POU>
</TcPlcObject>

View 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>

View 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>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="FB_ReleaseSignal" Id="{95131698-43c9-4438-8f9f-0d910656ef66}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_ReleaseSignal
VAR_INPUT
// Signal to filter
xSignal : BOOL := FALSE;
// Release signal output
xRelease : BOOL := TRUE;
// Time for xSignal to be true before setting xReleaseSignal to true
timOnDelay : TIME := T#0MS;
// Time for xSignal to be false before setting xReleaseSignal to false
timOffDelay : TIME := T#0MS;
END_VAR
VAR_OUTPUT
// Filtered signal
xReleaseSignal : BOOL;
END_VAR
VAR
// Timer for on filtering
_fbOnDelayTimer : TON;
// Timer for off filtering
_fbOffDelayTimer : TON;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Delay on signal if signal is released
_fbOnDelayTimer(IN:= xSignal AND xRelease, PT:= timOnDelay);
IF _fbOnDelayTimer.Q THEN
xReleaseSignal := TRUE;
END_IF
// Delay off signal, return false even if off timer is still active
_fbOffDelayTimer(IN:= (NOT xSignal), PT:= timOffDelay);
IF _fbOffDelayTimer.Q OR (NOT xRelease) THEN
xReleaseSignal := FALSE;
END_IF]]></ST>
</Implementation>
</POU>
</TcPlcObject>

View 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>

View 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.xNormallyOpen;
// Also reset manual open command if safetyinterlocks are set
IF (NOT _xSafetyINTLKOk) AND (_xManualOpen <> stValveConfig.xNormallyOpen) THEN
_xManualOpen := stValveConfig.xNormallyOpen;
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>

View 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(80);
// 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>

View 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>

View 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
xNormallyOpen : BOOL := FALSE;
// Valve is used
{attribute 'OPC.UA.DA' := '1'}
xUsed : BOOL := TRUE;
END_STRUCT
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View File

@@ -0,0 +1,35 @@
<?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[{attribute 'analysis' := '-33'}
PROGRAM PRG_MAIN
VAR
// Analog I/O tests
_fbAnalogInputTest : FB_AnalogInputTest;
_fbAnalogOutputTest : FB_AnalogOutputTest;
// 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>
<ST><![CDATA[TcUnit.RUN();]]></ST>
</Implementation>
</POU>
</TcPlcObject>

File diff suppressed because it is too large Load Diff

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View File

@@ -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>

View File

@@ -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>

View 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.xNormallyOpen := 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.xNormallyOpen := 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>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<Task Name="PlcTask" Id="{739c9490-40b0-4fe2-b19c-ac870a301f9d}">
<!--CycleTime in micro seconds.-->
<CycleTime>10000</CycleTime>
<Priority>20</Priority>
<PouCall>
<Name>PRG_MAIN</Name>
</PouCall>
<TaskFBGuid>{a83be5e0-d5cf-4aec-b38e-29e42c090d19}</TaskFBGuid>
<Fb_init>{4deed5d2-49a0-440e-8d82-d09251814781}</Fb_init>
<Fb_exit>{fec05c77-54d5-4195-ac02-ecdaaad52f09}</Fb_exit>
<CycleUpdate>{7536800f-d7c6-464d-a9c4-0b4ee7a1d592}</CycleUpdate>
<PostCycleUpdate>{6dbfee29-f644-435d-b6e8-122b6f086f52}</PostCycleUpdate>
</Task>
</TcPlcObject>

View 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>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<LibraryCategories xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LibraryCategories.xsd">
<LibraryCategory>
<Id>3d49e892-ba18-4f02-888a-850f97d52db7</Id>
<Version>1.0.0.0</Version>
<DefaultName>Heisig GmbH</DefaultName>
</LibraryCategory>
<LibraryCategory>
<Id>eb1097e9-64c5-43a2-8e69-a580a5ac7866</Id>
<Version>1.0.0.0</Version>
<ParentCategory>
<Id>3d49e892-ba18-4f02-888a-850f97d52db7</Id>
</ParentCategory>
<DefaultName>Standard Libraries</DefaultName>
</LibraryCategory>
</LibraryCategories>

View 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>

View 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>