Added more components
This commit is contained in:
77
PLC/POUs/Unittests/ValveTests/FB_ValveTestTimoutClose.TcPOU
Normal file
77
PLC/POUs/Unittests/ValveTests/FB_ValveTestTimoutClose.TcPOU
Normal file
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_ValveTestTimoutClose" Id="{676995cc-e0f8-4711-82b2-410116e6831b}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_ValveTestTimoutClose EXTENDS TcUnit.FB_TestSuite
|
||||
VAR
|
||||
// feedback result
|
||||
_xOpenFeedback : BOOL := FALSE;
|
||||
_xCloseFeedback : BOOL := FALSE;
|
||||
|
||||
// valve instance
|
||||
_fbValveTimeout : FB_Valve('');
|
||||
|
||||
// valve hmi data
|
||||
_stHMIValve : ST_HMI_VALVE_DATA;
|
||||
|
||||
// test timings
|
||||
_fbTimeoutCloseTestTimer : TON := (PT := T#200MS);
|
||||
_fbDelayFeedbackSignalTimer : TON := (PT := T#50MS);
|
||||
|
||||
// test finished
|
||||
_xTestTimeoutFinished : BOOL;
|
||||
|
||||
// current test state
|
||||
_iState : INT;
|
||||
|
||||
// vlave config
|
||||
_stValveConfig : ST_ValveConfig := (timTimeoutOpen := t#0MS, timTimeoutClose := T#100MS);
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TestClose();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="TestClose" Id="{b2dc7638-d362-4caf-a205-a2aede6d9720}">
|
||||
<Declaration><![CDATA[METHOD TestClose
|
||||
VAR_INPUT
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('TestClose');
|
||||
|
||||
CASE _iState OF
|
||||
0:
|
||||
// request automatic close and start timers
|
||||
_fbValveTimeout(xAutomaticOpen := FALSE, stHMIInterface := _stHMIValve);
|
||||
_fbTimeoutCloseTestTimer.IN := TRUE;
|
||||
_fbDelayFeedbackSignalTimer.IN := TRUE;
|
||||
_iState := 10;
|
||||
|
||||
10:
|
||||
// set close feedback after 50ms and call valve block
|
||||
_xOpenFeedback := FALSE;
|
||||
_xCloseFeedback := _fbValveTimeout.xCloseValve AND _fbDelayFeedbackSignalTimer.Q;
|
||||
_fbValveTimeout(xOpenFeedback := _xOpenFeedback, xCloseFeedback := _xCloseFeedback, stHMIInterface := _stHMIValve, stValveConfig := _stValveConfig);
|
||||
|
||||
// test timeout after 200ms
|
||||
IF _fbTimeoutCloseTestTimer.Q THEN
|
||||
_iState := 20;
|
||||
_fbDelayFeedbackSignalTimer.IN := FALSE;
|
||||
_fbTimeoutCloseTestTimer.IN := FALSE;
|
||||
END_IF
|
||||
|
||||
20:
|
||||
// assert IsClosed and no error
|
||||
_xTestTimeoutFinished := TRUE;
|
||||
AssertTrue(Condition := _fbValveTimeout.IsClosed AND NOT _fbValveTimeout.xError, Message := 'Valve threw close timeout error');
|
||||
END_CASE
|
||||
|
||||
// call timer
|
||||
_fbTimeoutCloseTestTimer();
|
||||
_fbDelayFeedbackSignalTimer();
|
||||
|
||||
IF _xTestTimeoutFinished THEN
|
||||
TEST_FINISHED();
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
Reference in New Issue
Block a user