Added more components
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user