Added more components
This commit is contained in:
78
PLC/POUs/Unittests/ValveTests/FB_ValveTestTimoutOpen.TcPOU
Normal file
78
PLC/POUs/Unittests/ValveTests/FB_ValveTestTimoutOpen.TcPOU
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveTestTimoutOpen" Id="{49e1a729-e622-4855-a7d7-67a9f99d1550}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ValveTestTimoutOpen EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// valve feedback
|
||||
_xOpenFeedback : BOOL := FALSE;
|
||||
_xCloseFeedback : BOOL := FALSE;
|
||||
|
||||
// valve instance
|
||||
_fbValveTimeout : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// test timings
|
||||
_fbTimeoutOpenTestTimer : TON := (PT := T#200MS);
|
||||
_fbDelayFeedbackSignalTimer : TON := (PT := T#50MS);
|
||||
|
||||
// test finished
|
||||
_xTestTimeoutFinished : BOOL;
|
||||
|
||||
// current test state
|
||||
_iState : INT;
|
||||
|
||||
// valve config
|
||||
_stValveConfig : ST_ValveConfig := (timTimeoutOpen := t#100MS, timTimeoutClose := T#0MS);
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TestOpen();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestOpen" Id="{4f96f391-c47b-4572-833e-9be45b3993f5}">
|
||||
<Declaration><![CDATA[METHOD TestOpen
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestOpen');
|
||||
|
||||
CASE _iState OF
|
||||
0:
|
||||
// request automatic open and start timers
|
||||
_fbValveTimeout(xAutomaticOpen := TRUE, stHMIInterface := _stHMIValve);
|
||||
_fbTimeoutOpenTestTimer.IN := TRUE;
|
||||
_fbDelayFeedbackSignalTimer.IN := TRUE;
|
||||
_iState := 10;
|
||||
|
||||
10:
|
||||
// set open feedback after 50ms and call valve block
|
||||
_xOpenFeedback := _fbValveTimeout.xOpenValve AND _fbDelayFeedbackSignalTimer.Q;
|
||||
_xCloseFeedback := FALSE;
|
||||
_fbValveTimeout(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig);
|
||||
|
||||
// test timeout after 200ms
|
||||
IF _fbTimeoutOpenTestTimer.Q THEN
|
||||
_iState := 20;
|
||||
_fbDelayFeedbackSignalTimer.IN := FALSE;
|
||||
_fbTimeoutOpenTestTimer.IN := FALSE;
|
||||
END_IF
|
||||
|
||||
20:
|
||||
// assert IsOpen and no error
|
||||
_xTestTimeoutFinished := TRUE;
|
||||
AssertTrue(Condition := _fbValveTimeout.IsOpen AND NOT _fbValveTimeout.xError, Message := 'Valve threw open timeout error');
|
||||
END_CASE
|
||||
|
||||
// call timer
|
||||
_fbTimeoutOpenTestTimer();
|
||||
_fbDelayFeedbackSignalTimer();
|
||||
|
||||
IF _xTestTimeoutFinished THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
Reference in New Issue
Block a user