1636 lines
48 KiB
XML
1636 lines
48 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<TcPlcObject Version="1.1.0.1">
|
|
<POU Name="FB_AnalogInputTest" Id="{32b84560-3c63-4a9b-83f5-f484fc52c86a}" SpecialFunc="None">
|
|
<Declaration><![CDATA[FUNCTION_BLOCK FB_AnalogInputTest EXTENDS TcUnit.FB_TestSuite
|
|
VAR
|
|
// On delay error low
|
|
_fbAIErrorLowOn : FB_AnalogInput('');
|
|
_fbErrorLowOnTimer : TON;
|
|
_xErrorLowOnTestFinished : BOOL := FALSE;
|
|
|
|
// on delay warning low
|
|
_fbAIWarningLowOn : FB_AnalogInput('');
|
|
_fbWarningLowOnTimer : TON;
|
|
_xWarningLowOnTestFinished : BOOL := FALSE;
|
|
|
|
// on delay warning high
|
|
_fbAIWarningHighOn : FB_AnalogInput('');
|
|
_fbWarningHighOnTimer : TON;
|
|
_xWarningHighOnTestFinished : BOOL := FALSE;
|
|
|
|
// on delay error high
|
|
_fbAIErrorHighOn : FB_AnalogInput('');
|
|
_fbErrorHighOnTimer : TON;
|
|
_xErrorHighOnTestFinished : BOOL := FALSE;
|
|
|
|
// on delay overrange
|
|
_fbAIOverrangeOn : FB_AnalogInput('');
|
|
_fbOverrangeOnTimer : TON;
|
|
|
|
// on delay underrange
|
|
_fbAIUnderrangeOn : FB_AnalogInput('');
|
|
_fbUnderrangeOnTimer : TON;
|
|
|
|
// off delay error low
|
|
_fbAIErrorLowOff : FB_AnalogInput('');
|
|
_xErrorLowOffInitDone : BOOL := FALSE;
|
|
_fbErrorLowOffTimer : TON;
|
|
_xErrorLowOffTestFinished : BOOL := FALSE;
|
|
|
|
// off delay warning low
|
|
_fbAIWarningLowOff : FB_AnalogInput('');
|
|
_xWarningLowOffInitDone : BOOL := FALSE;
|
|
_fbWarningLowOffTimer : TON;
|
|
_xWarningLowOffTestFinished : BOOL := FALSE;
|
|
|
|
// off delay warning high
|
|
_fbAIWarningHighOff : FB_AnalogInput('');
|
|
_xWarningHighOffInitDone : BOOL := FALSE;
|
|
_fbWarningHighOffTimer : TON;
|
|
_xWarningHighOffTestFinished : BOOL := FALSE;
|
|
|
|
// off delay error high
|
|
_fbAIErrorHighOff : FB_AnalogInput('');
|
|
_xErrorHighOffInitDone : BOOL := FALSE;
|
|
_fbErrorHighOffTimer : TON;
|
|
_xErrorHighOffTestFinished : BOOL := FALSE;
|
|
|
|
// off delay underrange
|
|
_fbAIUnderrangeOff : FB_AnalogInput('');
|
|
_xUnderrangeOffInitDone : BOOL := FALSE;
|
|
_fbUnderrangeOffTimer : TON;
|
|
|
|
// off delay overrange
|
|
_fbAIOverrangeOff : FB_AnalogInput('');
|
|
_xOverrangeOffInitDone : BOOL := FALSE;
|
|
_fbOverrangeOffTimer : TON;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[// Check config error
|
|
CheckConfigErrorMin();
|
|
CheckConfigErrorMax();
|
|
|
|
// Check scalings
|
|
CheckInputScaling();
|
|
CheckDivisionByZero();
|
|
|
|
// Check error and alarm outputs without time delays
|
|
CheckErrorLow();
|
|
CheckWarningLow();
|
|
CheckWarningHigh();
|
|
CheckErrorHigh();
|
|
|
|
// Check over- and underrange error
|
|
CheckOverrange();
|
|
CheckUnderrange();
|
|
CheckOverrangeWithOffDelay();
|
|
CheckUnderrangeWithOffDelay();
|
|
CheckOverrangeWithOnDelay();
|
|
CheckUnderrangeWithOnDelay();
|
|
|
|
// Check error and alarm outputs with time delays
|
|
CheckErrorLowWithOnDelay();
|
|
CheckWarningLowWithOnDelay();
|
|
CheckWarningHighWithOnDelay();
|
|
CheckErrorHighWithOnDelay();
|
|
|
|
CheckErrorLowWithOffDelay();
|
|
CheckWarningLowWithOffDelay();
|
|
CheckWarningHighWithOffDelay();
|
|
CheckErrorHighWithOffDelay();]]></ST>
|
|
</Implementation>
|
|
<Method Name="CheckConfigErrorMax" Id="{0773e14d-514c-41ce-8fce-b439761b534d}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckConfigErrorMax
|
|
VAR
|
|
// analog input instance
|
|
_fbAnalogInput : FB_AnalogInput('');
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := -10, rWarningMin := 0, rWarningMax := 20, rErrorMax := 10);
|
|
|
|
// error output
|
|
_xError : BOOL;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckConfigErrorMax');
|
|
|
|
// prevent scaling config error
|
|
_stAnalogInputConfig.iAIMax := 4095;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 120;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// run analog input
|
|
_fbAnalogInput(
|
|
iAnalogValue := 1234,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xReleaseLimitErrors := TRUE,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xInUnitTestMode := TRUE,
|
|
xError=> _xError,
|
|
rScaledValue=> );
|
|
|
|
// assert results
|
|
AssertTrue(Condition := _xError, Message:= 'No error thrown at warning max > error max');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckConfigErrorMin" Id="{57503141-9382-4985-92a1-4c12abbd81c7}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckConfigErrorMin
|
|
VAR
|
|
// analog input instance
|
|
_fbAnalogInput : FB_AnalogInput('');
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := -10, rWarningMin := -11, rWarningMax := 0, rErrorMax := 10);
|
|
|
|
// error output
|
|
_xError : BOOL;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckConfigErrorMin');
|
|
|
|
// prevent scaling config error
|
|
_stAnalogInputConfig.iAIMax := 4095;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 120;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// run analog input
|
|
_fbAnalogInput(
|
|
iAnalogValue:= 1234,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xReleaseLimitErrors := TRUE,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xInUnitTestMode := TRUE,
|
|
xError=> _xError,
|
|
rScaledValue=> );
|
|
|
|
// assert result
|
|
AssertTrue(Condition := _xError, Message:= 'No error thrown at warning min < error min');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckDivisionByZero" Id="{a058cdc8-5f03-429e-9654-ae95350c74e2}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckDivisionByZero
|
|
VAR
|
|
// analog input instance
|
|
_fbAnalogInput : FB_AnalogInput('');
|
|
|
|
// analog input config and nested configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
|
|
// analog input outputs
|
|
_xError : BOOL;
|
|
_rResult : REAL;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckDivisionByZero');
|
|
|
|
// denom = udiAIMax - udiAIMin
|
|
// Test if no crash occurs when denom equals zero
|
|
_stAnalogInputConfig.iAIMax := 0;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 120;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// run analog input
|
|
_fbAnalogInput(
|
|
iAnalogValue:= 1234,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xInUnitTestMode := TRUE,
|
|
xError=> _xError,
|
|
rScaledValue=> _rResult);
|
|
|
|
// assert results
|
|
AssertTrue(_xError,'Expected error when trying to devide by zero');
|
|
AssertEquals_REAL(Expected:= 0.0, Actual:= _rResult, Delta:= 0.0, Message:= 'Division by zero not correcty handled');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckErrorHigh" Id="{2d8f5601-8d4a-49fb-8af4-2ebbca163bcf}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckErrorHigh
|
|
VAR
|
|
// analog input instance
|
|
_fbAI : FB_AnalogInput('');
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS := (timWarningLowOff := T#100MS);
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckErrorHigh');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// Check with active release signal
|
|
_fbAI(
|
|
iAnalogValue:= 95,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
|
|
// assert results
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is active');
|
|
AssertFalse(Condition:= _xResultWarningLow, Message:= 'Warning low is active');
|
|
AssertTrue(Condition:= _xResultWarningHigh, Message:= 'Warning high is not active');
|
|
AssertTrue(Condition:= _xResultErrorHigh, Message:= 'Error high is not active');
|
|
|
|
// Check without active release signal
|
|
_fbAI(
|
|
iAnalogValue:= 95,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= FALSE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
|
|
// assert results
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is active without active release signal');
|
|
AssertFalse(Condition:= _xResultWarningLow, Message:= 'Warning low is active without active release signal');
|
|
AssertFalse(Condition:= _xResultWarningHigh, Message:= 'Warning high is active without active release signal');
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is active without active release signal');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckErrorHighWithOffDelay" Id="{7beb7746-046c-4e22-a7c2-608265dd1ea3}">
|
|
<Declaration><![CDATA[METHOD CheckErrorHighWithOffDelay
|
|
VAR
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// off delay
|
|
timOffTime : TIME := T#100MS;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckErrorHighWithOffDelay');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
// configure delay
|
|
_stDelayConfig.timErrorHighOff := timOffTime;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// Activate an error in the first cycle
|
|
IF NOT _xErrorHighOffInitDone THEN
|
|
_xErrorHighOffInitDone := TRUE;
|
|
_fbAIErrorHighOff(
|
|
iAnalogValue:= 95,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
ELSE
|
|
_fbErrorHighOffTimer(IN := TRUE, PT := timOffTime);
|
|
_fbAIErrorHighOff(
|
|
iAnalogValue:= 50,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
END_IF
|
|
|
|
// Wait for the delay time to be finished and check the signal level
|
|
// Should be high until the delay time has passed
|
|
IF _fbErrorHighOffTimer.Q THEN
|
|
_xErrorHighOffTestFinished := TRUE;
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is still active after the delay time');
|
|
ELSE
|
|
AssertTrue(Condition:= _xResultErrorHigh, Message:= 'Error high is not active before the delay time elapsed');
|
|
IF NOT _xResultErrorHigh THEN
|
|
_xErrorHighOffTestFinished := TRUE;
|
|
END_IF
|
|
END_IF
|
|
|
|
IF _xErrorHighOffTestFinished THEN
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckErrorHighWithOnDelay" Id="{8173453c-d757-4c7c-be34-471e707174d1}">
|
|
<Declaration><![CDATA[METHOD CheckErrorHighWithOnDelay
|
|
VAR
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input error outputs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// on delay
|
|
timOnTime : TIME := T#100MS;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckErrorHighWithOnDelay');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
// configure delay
|
|
_stDelayConfig.timErrorHighOn := timOnTime;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// start/call timer
|
|
_fbErrorHighOnTimer(IN := TRUE, PT := timOnTime);
|
|
|
|
// Check with active release signal
|
|
_fbAIErrorHighOn(
|
|
iAnalogValue:= 95,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
|
|
// assert results
|
|
IF NOT _fbErrorHighOnTimer.Q THEN
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is active before the time');
|
|
_fbErrorLowOnTimer.IN := FALSE;
|
|
ELSE
|
|
_xErrorHighOnTestFinished := TRUE;
|
|
AssertTrue(Condition:= _xResultErrorHigh, Message:= 'Error high is not active after the delay time');
|
|
END_IF
|
|
|
|
IF _xErrorHighOnTestFinished THEN
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckErrorLow" Id="{2b4b6408-f41f-42aa-873f-add9ff4ebb22}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckErrorLow
|
|
VAR
|
|
// analog input instance
|
|
_fbAI : FB_AnalogInput('');
|
|
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckErrorLow');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// Error low with release
|
|
_fbAI(
|
|
iAnalogValue:= 0,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh
|
|
);
|
|
|
|
// assert results
|
|
AssertTrue(Condition:= _xResultErrorLow, Message:= 'Error low is not active');
|
|
AssertTrue(Condition:= _xResultWarningLow, Message:= 'Warning low is not active');
|
|
AssertFalse(Condition:= _xResultWarningHigh, Message:= 'Warning high is active');
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is active');
|
|
|
|
// Error low without release
|
|
_fbAI(
|
|
iAnalogValue:= 0,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= FALSE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh
|
|
);
|
|
|
|
// assert results
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is active with no active release signal');
|
|
AssertFalse(Condition:= _xResultWarningLow, Message:= 'Warning low is active with no active release signal');
|
|
AssertFalse(Condition:= _xResultWarningHigh, Message:= 'Warning high is active with no active release signal');
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is active with no active release signal');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckErrorLowWithOffDelay" Id="{92a2d7f0-095f-45d3-8aa6-035cc350ed41}">
|
|
<Declaration><![CDATA[METHOD CheckErrorLowWithOffDelay
|
|
VAR
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS := (timErrorLowOff := T#100MS);
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// off delay
|
|
timOffTime : TIME := T#100MS;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckErrorLowWithOffDelay');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
|
|
// Activate an error in the first cycle
|
|
IF NOT _xErrorLowOffInitDone THEN
|
|
_xErrorLowOffInitDone := TRUE;
|
|
_fbAIErrorLowOff(
|
|
iAnalogValue:= 5,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
ELSE
|
|
_fbErrorLowOffTimer(IN := TRUE, PT := timOffTime);
|
|
_fbAIErrorLowOff(
|
|
iAnalogValue:= 50,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
END_IF
|
|
|
|
// Wait for the delay time to be finished and check the signal level
|
|
// Should be high until the delay time has passed
|
|
IF _fbErrorLowOffTimer.Q THEN
|
|
_xErrorLowOffTestFinished := TRUE;
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is still active after the delay time');
|
|
ELSE
|
|
AssertTrue(Condition:= _xResultErrorLow, Message:= 'Error low is not active before the delay time elapsed');
|
|
IF NOT _xResultErrorLow THEN
|
|
_xErrorLowOffTestFinished := TRUE;
|
|
END_IF
|
|
END_IF
|
|
|
|
IF _xErrorLowOffTestFinished THEN
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckErrorLowWithOnDelay" Id="{5c559675-3f9d-410c-942d-744cff739663}">
|
|
<Declaration><![CDATA[METHOD CheckErrorLowWithOnDelay
|
|
VAR
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS := (timErrorLowOn := T#100MS);
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// on delay
|
|
timOnTime : TIME := T#100MS;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckErrorLowWithOnDelay');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// start/call timer
|
|
_fbErrorLowOnTimer(IN := TRUE, PT := timOnTime);
|
|
|
|
// Check with active release signal
|
|
_fbAIErrorLowOn(
|
|
iAnalogValue:= 5,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
|
|
// assert results
|
|
IF NOT _fbErrorLowOnTimer.Q THEN
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is active before the time');
|
|
_fbErrorLowOnTimer.IN := FALSE;
|
|
ELSE
|
|
_xErrorLowOnTestFinished := TRUE;
|
|
AssertTrue(Condition:= _xResultErrorLow, Message:= 'Error low is not active after the delay time');
|
|
AssertTrue(Condition:= _xResultWarningLow, Message:= 'Warning low is not active after the delay time');
|
|
END_IF
|
|
|
|
IF _xErrorLowOnTestFinished THEN
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckInputScaling" Id="{909c1d67-78c4-4d44-9973-ca3ea195582c}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckInputScaling
|
|
VAR
|
|
// analog input instance
|
|
_fbAnalogInput : FB_AnalogInput('');
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
|
|
// analog input output
|
|
_rResult : REAL;
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// expected result
|
|
rExpected : REAL := 72.5;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckInputScaling');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := -10;
|
|
_stAnalogInputConfig.iAIMax := 4095; // 12 bit max
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// run analog input
|
|
_fbAnalogInput(
|
|
iAnalogValue:= 3071, // 0,75 * 4095 = 3071,25
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xError=> ,
|
|
xInUnitTestMode := TRUE,
|
|
rScaledValue=> _rResult);
|
|
|
|
// Value should be between 72.49 und 72.52 -> Delta = 0,03
|
|
AssertEquals_REAL(
|
|
Expected := rExpected,
|
|
Actual := _rResult,
|
|
Delta := 0.03,
|
|
Message := 'Analog value not correct');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckOverrange" Id="{7ca2cc67-9461-44fb-9fa9-b3ecfc8a3ae2}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckOverrange
|
|
VAR
|
|
// analog input instance
|
|
_fbAI : FB_AnalogInput('');
|
|
|
|
// analog input error output
|
|
_xResultError : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckOverrange');
|
|
|
|
// instant overrange passthrough
|
|
_stDelayConfig.timHardwareSignalLevelOn := T#0S;
|
|
|
|
// prevent scaling config error
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// run AI to check for overrange error
|
|
_fbAI(
|
|
iAnalogValue:= 50,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= TRUE,
|
|
xErrorCard:= ,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> ,
|
|
xWarningLow=> ,
|
|
xWarningHigh=> ,
|
|
xErrorHigh=> );
|
|
|
|
// assert result
|
|
AssertTrue(_xResultError, 'Expected overrange error');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckOverrangeWithOffDelay" Id="{5bc88d95-29cd-4ad1-a843-9107fd960c07}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckOverrangeWithOffDelay
|
|
VAR
|
|
// analog input error output
|
|
_xResultError : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckOverrangeWithOffDelay');
|
|
|
|
// instant overrange passthrough, off delay of 100ms
|
|
_stDelayConfig.timHardwareSignalLevelOn := T#0S;
|
|
_stDelayConfig.timHardwareSignalLevelOff := T#100MS;
|
|
|
|
// prevent scaling config error
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// call timer
|
|
_fbOverrangeOffTimer(IN := TRUE, PT := T#100MS);
|
|
|
|
// init with overrange error
|
|
IF NOT _xOverrangeOffInitDone THEN
|
|
_xOverrangeOffInitDone := TRUE;
|
|
// run AI to check for overrange error
|
|
_fbAIOverrangeOff(
|
|
iAnalogValue:= 50,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= TRUE,
|
|
xErrorCard:= ,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> ,
|
|
xWarningLow=> ,
|
|
xWarningHigh=> ,
|
|
xErrorHigh=> );
|
|
END_IF
|
|
|
|
// run AI cyclically until overrange error is supposed to be off
|
|
_fbAIOverrangeOff(
|
|
iAnalogValue:= 50,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= ,
|
|
xReleaseErrors := TRUE,
|
|
xReleaseHardwareErrors := TRUE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xConfirmAlarms := TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> ,
|
|
xWarningLow=> ,
|
|
xWarningHigh=> ,
|
|
xErrorHigh=> );
|
|
|
|
// assert result depending on timer
|
|
IF NOT _fbOverrangeOffTimer.Q THEN
|
|
AssertTrue(_xResultError, 'Overrange error is reset before expected time');
|
|
ELSE
|
|
AssertFalse(_xResultError, 'Overrange error not reset on time');
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckOverrangeWithOnDelay" Id="{da98ed11-b872-4f91-9db7-05fc4c9d85fe}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckOverrangeWithOnDelay
|
|
VAR
|
|
// analog input error output
|
|
_xResultError : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckOverrangeWithOnDelay');
|
|
|
|
// overrange error after delay of 100ms
|
|
_stDelayConfig.timHardwareSignalLevelOn := T#100MS;
|
|
|
|
// prevent scaling config error
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// call timer
|
|
_fbOverrangeOnTimer(IN := TRUE, PT := T#100MS);
|
|
|
|
// run AI to check for overrange error
|
|
_fbAIOverrangeOn(
|
|
iAnalogValue:= 50,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= TRUE,
|
|
xErrorCard:= ,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> ,
|
|
xWarningLow=> ,
|
|
xWarningHigh=> ,
|
|
xErrorHigh=> );
|
|
|
|
// assert result depending on timer
|
|
IF NOT _fbOverrangeOnTimer.Q THEN
|
|
AssertFalse(_xResultError, 'Overrange error set before expected time');
|
|
ELSE
|
|
AssertTrue(_xResultError, 'Overrange error not set on time');
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckUnderrange" Id="{cd2c34a1-8090-4e23-bf4f-6b92573abd3b}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckUnderrange
|
|
VAR
|
|
// analog input instance
|
|
_fbAI : FB_AnalogInput('');
|
|
|
|
// analog input error output
|
|
_xResultError : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckUnderrange');
|
|
|
|
// instant underrange passthrough
|
|
_stDelayConfig.timHardwareSignalLevelOn := T#0S;
|
|
|
|
// prevent scaling config error
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// run AI to check for underrange error
|
|
_fbAI(
|
|
iAnalogValue:= 50,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= TRUE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= ,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> ,
|
|
xWarningLow=> ,
|
|
xWarningHigh=> ,
|
|
xErrorHigh=> );
|
|
|
|
// assert result
|
|
AssertTrue(_xResultError, 'Expected underrange error');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckUnderrangeWithOffDelay" Id="{eb199422-03e1-4175-8e5c-0c29a93f1f8c}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckUnderrangeWithOffDelay
|
|
VAR
|
|
// analog input error output
|
|
_xResultError : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckUnderrangeWithOffDelay');
|
|
|
|
// instant underrange passthrough, off delay of 100ms
|
|
_stDelayConfig.timHardwareSignalLevelOn := T#0S;
|
|
_stDelayConfig.timHardwareSignalLevelOff := T#100MS;
|
|
|
|
// prevent scaling config error
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// call timer
|
|
_fbUnderrangeOffTimer(IN := TRUE, PT := T#100MS);
|
|
|
|
// init with underrange error
|
|
IF NOT _xUnderrangeOffInitDone THEN
|
|
_xUnderrangeOffInitDone := TRUE;
|
|
// run AI to check for underrange error
|
|
_fbAIUnderrangeOff(
|
|
iAnalogValue:= 50,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= TRUE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= ,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> ,
|
|
xWarningLow=> ,
|
|
xWarningHigh=> ,
|
|
xErrorHigh=> );
|
|
END_IF
|
|
|
|
// run AI cyclically until underrange error is supposed to be off
|
|
_fbAIUnderrangeOff(
|
|
iAnalogValue:= 0,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= ,
|
|
xReleaseErrors := TRUE,
|
|
xReleaseHardwareErrors := TRUE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xConfirmAlarms := TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> ,
|
|
xWarningLow=> ,
|
|
xWarningHigh=> ,
|
|
xErrorHigh=> );
|
|
|
|
// assert result depending on timer
|
|
IF NOT _fbUnderrangeOffTimer.Q THEN
|
|
AssertTrue(_xResultError, 'Underrange error is reset before expected time');
|
|
ELSE
|
|
AssertFalse(_xResultError, 'Underrange error not reset on time');
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckUnderrangeWithOnDelay" Id="{a371a59a-0275-4e65-8bb6-887c9b6af884}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckUnderrangeWithOnDelay
|
|
VAR
|
|
// analog input error output
|
|
_xResultError : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckUnderrangeWithOnDelay');
|
|
|
|
// underrange error after delay of 100ms
|
|
_stDelayConfig.timHardwareSignalLevelOn := T#100MS;
|
|
|
|
// prevent scaling config error
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// call timer
|
|
_fbUnderrangeOnTimer(IN := TRUE, PT := T#100MS);
|
|
|
|
// run AI to check for underrange error
|
|
_fbAIUnderrangeOn(
|
|
iAnalogValue:= 50,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= TRUE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= ,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> ,
|
|
xWarningLow=> ,
|
|
xWarningHigh=> ,
|
|
xErrorHigh=> );
|
|
|
|
// assert result depending on timer
|
|
IF NOT _fbUnderrangeOnTimer.Q THEN
|
|
AssertFalse(_xResultError, 'Underrange error set before expected time');
|
|
ELSE
|
|
AssertTrue(_xResultError, 'Underrange error not set on time');
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckWarningHigh" Id="{08c1bee3-6f8a-405f-b22f-ca09f2929da8}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckWarningHigh
|
|
VAR
|
|
// analog input instance
|
|
_fbAI : FB_AnalogInput('');
|
|
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckWarningHigh');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// Check with active release signal
|
|
_fbAI(
|
|
iAnalogValue:= 85,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh
|
|
);
|
|
|
|
// assert results
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is active');
|
|
AssertFalse(Condition:= _xResultWarningLow, Message:= 'Warning low is active');
|
|
AssertTrue(Condition:= _xResultWarningHigh, Message:= 'Warning high is not active');
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is active');
|
|
|
|
// Check without active release signal
|
|
_fbAI(
|
|
iAnalogValue:= 85,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= FALSE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh
|
|
);
|
|
// assert results
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is active without active release signal');
|
|
AssertFalse(Condition:= _xResultWarningLow, Message:= 'Warning low is active without active release signal');
|
|
AssertFalse(Condition:= _xResultWarningHigh, Message:= 'Warning high is active without active release signal');
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is active without active release signal');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckWarningHighWithOffDelay" Id="{0dd3dffb-b3e7-44fb-b901-3168d1605c8e}">
|
|
<Declaration><![CDATA[METHOD CheckWarningHighWithOffDelay
|
|
VAR
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS := (timWarningHighOff := T#100MS);
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// off delay
|
|
timOffTime : TIME := T#100MS;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckWarningHighWithOffDelay');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// Activate an error in the first cycle
|
|
IF NOT _xWarningHighOffInitDone THEN
|
|
_xWarningHighOffInitDone := TRUE;
|
|
_fbAIWarningHighOff(
|
|
iAnalogValue:= 85,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
ELSE
|
|
_fbWarningHighOffTimer(IN := TRUE, PT := timOffTime);
|
|
_fbAIWarningHighOff(
|
|
iAnalogValue:= 50,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
END_IF
|
|
|
|
// Wait for the delay time to be finished and check the signal level
|
|
// Should be high until the delay time has passed
|
|
IF _fbWarningHighOffTimer.Q THEN
|
|
_xWarningHighOffTestFinished := TRUE;
|
|
AssertFalse(Condition:= _xResultWarningHigh, Message:= 'Warning high is still active after the delay time');
|
|
ELSE
|
|
AssertTrue(Condition:= _xResultWarningHigh, Message:= 'Warning high is not active before the delay time elapsed');
|
|
IF NOT _xResultWarningHigh THEN
|
|
_xWarningHighOffTestFinished := TRUE;
|
|
END_IF
|
|
END_IF
|
|
|
|
IF _xWarningHighOffTestFinished THEN
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckWarningHighWithOnDelay" Id="{b450cc57-1223-412e-aaf2-f492e00c32e1}">
|
|
<Declaration><![CDATA[METHOD CheckWarningHighWithOnDelay
|
|
VAR
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS := (timWarningHighOn := T#100MS);
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// on delay
|
|
timOnTime : TIME := T#100MS;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckWarningHighWithOnDelay');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// start/call timer
|
|
_fbWarningHighOnTimer(IN := TRUE, PT := timOnTime);
|
|
|
|
// Check with active release signal
|
|
_fbAIWarningHighOn(
|
|
iAnalogValue:= 85,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
|
|
// assert results
|
|
IF NOT _fbWarningHighOnTimer.Q THEN
|
|
AssertFalse(Condition:= _xResultWarningHigh, Message:= 'Warning high is active before the time');
|
|
_fbErrorLowOnTimer.IN := FALSE;
|
|
ELSE
|
|
_xWarningHighOnTestFinished := TRUE;
|
|
AssertTrue(Condition:= _xResultWarningHigh, Message:= 'Warning high is not active after the delay time');
|
|
END_IF
|
|
|
|
IF _xWarningHighOnTestFinished THEN
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckWarningLow" Id="{4d87cfda-2d33-4211-a3f0-4be2d739b59a}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckWarningLow
|
|
VAR
|
|
// analog input instance
|
|
_fbAI : FB_AnalogInput('');
|
|
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS;
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckWarningLow');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// Warning low with release
|
|
_fbAI(
|
|
iAnalogValue:= 15,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh
|
|
);
|
|
|
|
// assert results
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is active');
|
|
AssertTrue(Condition:= _xResultWarningLow, Message:= 'Warning low is not active');
|
|
AssertFalse(Condition:= _xResultWarningHigh, Message:= 'Warning high is active');
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is active');
|
|
|
|
// Warning low without release
|
|
_fbAI(
|
|
iAnalogValue:= 15,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= FALSE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh
|
|
);
|
|
|
|
// assert results
|
|
AssertFalse(Condition:= _xResultErrorLow, Message:= 'Error low is active without active release');
|
|
AssertFalse(Condition:= _xResultWarningLow, Message:= 'Warning low is active without active release');
|
|
AssertFalse(Condition:= _xResultWarningHigh, Message:= 'Warning high is active without active release');
|
|
AssertFalse(Condition:= _xResultErrorHigh, Message:= 'Error high is active without active release');
|
|
|
|
TEST_FINISHED();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckWarningLowWithOffDelay" Id="{dc07ff37-03f7-4787-9a3b-9b053f32e2ff}">
|
|
<Declaration><![CDATA[METHOD CheckWarningLowWithOffDelay
|
|
VAR
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS := (timWarningLowOff := T#100MS);
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// off delay
|
|
timOffTime : TIME := T#100MS;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckWarningLowWithOffDelay');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
// Activate an error in the first cycle
|
|
IF NOT _xWarningLowOffInitDone THEN
|
|
_xWarningLowOffInitDone := TRUE;
|
|
_fbAIWarningLowOff(
|
|
iAnalogValue:= 15,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
ELSE
|
|
_fbWarningLowOffTimer(IN := TRUE, PT := timOffTime);
|
|
_fbAIWarningLowOff(
|
|
iAnalogValue:= 50,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
END_IF
|
|
|
|
// Wait for the delay time to be finished and check the signal level
|
|
// Should be high until the delay time has passed
|
|
IF _fbWarningLowOffTimer.Q THEN
|
|
_xWarningLowOffTestFinished := TRUE;
|
|
AssertFalse(Condition:= _xResultWarningLow, Message:= 'Warning low is still active after the delay time');
|
|
ELSE
|
|
AssertTrue(Condition:= _xResultWarningLow, Message:= 'Warning low is not active before the delay time elapsed');
|
|
IF NOT _xResultWarningLow THEN
|
|
_xWarningLowOffTestFinished := TRUE;
|
|
END_IF
|
|
END_IF
|
|
|
|
IF _xWarningLowOffTestFinished THEN
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="CheckWarningLowWithOnDelay" Id="{17bdf3f1-d764-4efc-bcdf-cdb70fe56bb2}">
|
|
<Declaration><![CDATA[{warning disable C0394}
|
|
METHOD CheckWarningLowWithOnDelay
|
|
VAR
|
|
// analog input error outputs
|
|
_xResultError : BOOL;
|
|
_xResultErrorLow : BOOL;
|
|
_xResultWarningLow : BOOL;
|
|
_xResultWarningHigh : BOOL;
|
|
_xResultErrorHigh : BOOL;
|
|
|
|
// analog input configs
|
|
_stAnalogInputConfig : ST_ANALOG_IO_CONFIG;
|
|
_stAnalogEWConfig : ST_ANALOG_EW_CONFIG;
|
|
_stDelayConfig : ST_ANALOG_EW_DELAYS := (timWarningLowOn := T#100MS);
|
|
_stEWConfig : ST_ANALOG_EW_LEVELS := (rErrorMin := 10, rWarningMin := 20, rWarningMax := 80, rErrorMax := 90);
|
|
END_VAR
|
|
|
|
VAR CONSTANT
|
|
// on delay
|
|
timOnTime : TIME := T#100MS;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[TEST('CheckWarningLowWithOnDelay');
|
|
|
|
// configure analog input
|
|
_stAnalogInputConfig.rPVMax := 100;
|
|
_stAnalogInputConfig.rPVMin := 0;
|
|
_stAnalogInputConfig.iAIMax := 100;
|
|
_stAnalogInputConfig.iAIMin := 0;
|
|
|
|
_stAnalogEWConfig.stLevels := _stEWConfig;
|
|
_stAnalogEWConfig.stDelays := _stDelayConfig;
|
|
|
|
_fbWarningLowOnTimer(IN := TRUE, PT := timOnTime);
|
|
|
|
// Check with active release signal
|
|
_fbAIWarningLowOn(
|
|
iAnalogValue:= 15,
|
|
stAnalogIOConfig := _stAnalogInputConfig,
|
|
stAnalogEWConfig := _stAnalogEWConfig,
|
|
xUnderrange:= FALSE,
|
|
xOverrange:= FALSE,
|
|
xErrorCard:= FALSE,
|
|
xReleaseLimitErrors:= TRUE,
|
|
xError=> _xResultError,
|
|
rScaledValue=> ,
|
|
xInUnitTestMode := TRUE,
|
|
xErrorLow=> _xResultErrorLow,
|
|
xWarningLow=> _xResultWarningLow,
|
|
xWarningHigh=> _xResultWarningHigh,
|
|
xErrorHigh=> _xResultErrorHigh);
|
|
|
|
// assert results
|
|
IF NOT _fbWarningLowOnTimer.Q THEN
|
|
AssertFalse(Condition:= _xResultWarningLow, Message:= 'Warning low is active before the time');
|
|
_fbErrorLowOnTimer.IN := FALSE;
|
|
ELSE
|
|
_xWarningLowOnTestFinished := TRUE;
|
|
AssertTrue(Condition:= _xResultWarningLow, Message:= 'Warning low is not active after the delay time');
|
|
END_IF
|
|
|
|
IF _xWarningLowOnTestFinished THEN
|
|
TEST_FINISHED();
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
</POU>
|
|
</TcPlcObject> |