_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();]]> _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();]]> _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();]]> _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();]]> _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();]]> _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();]]> _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();]]>