<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
  <POU Name="FB_UnitMockup" Id="{a1155b26-00e6-4710-a8e4-140d6d5cd082}" SpecialFunc="None">
    <Declaration><![CDATA[FUNCTION_BLOCK FB_UnitMockup
VAR_INPUT
	stUnitError : REFERENCE TO ST_UNIT_ERROR;
END_VAR
VAR_OUTPUT
END_VAR
VAR
	// Valves posolyt
	_fbPosolytValveTankOutlet : FB_ValveMockup;
	
	// Valves negolyt
	_fbNegolytValveTankOutlet : FB_ValveMockup;

	// Pumps posolyt
	_fbPosolytPumpInlet : FB_MotorMockup;
	
	// Pumps negolyt
	_fbNegolytPumpInlet : FB_MotorMockup;

	// Pressure sensors posolyt
	_fbPressurePosolytSegmentInlet : FB_AnalogSensorMockup;
	_fbPressurePosolytTankInlet : FB_AnalogSensorMockup;
	
	// Pressure sensors negolyt
	_fbPressureNegolytSegmentInlet : FB_AnalogSensorMockup;
	_fbPressureNegolytTankInlet : FB_AnalogSensorMockup;
	
	// Temperature sensors
	_fbTemperatureSensorPosolyt : FB_AnalogSensorMockup;
	_fbTemperatureSensorNegolyt : FB_AnalogSensorMockup;
	
	// Segment Voltage
	_fbVoltageSegment : FB_AnalogSensorMockup;
	
	// Helping variables
	_xFlowThroughtSegmentPosolyt : BOOL;
	_xFlowThroughtBypassPosolyt : BOOL;
	
	_xFlowThroughtSegmentNegolyt : BOOL;
	_xFlowThroughtBypassNegolyt : BOOL;
END_VAR
]]></Declaration>
    <Implementation>
      <ST><![CDATA[// ===============================
// Valves posolyt
// ===============================
_fbPosolytValveTankOutlet(xErrorOpen := stUnitError.xErrorOpenValvePosolyt, xErrorClose := stUnitError.xErrorCloseValvePosolyt);


// ===============================
// Valves negolyt
// ===============================
_fbNegolytValveTankOutlet(xErrorOpen := stUnitError.xErrorOpenValveNegolyt, xErrorClose := stUnitError.xErrorCloseValveNegolyt);


// ===============================
// Pumps posolyt
// ===============================
_fbPosolytPumpInlet();


// ===============================
// Pumps negolyt
// ===============================
_fbNegolytPumpInlet();


// ===============================
// Simulate flow posolyt
// ===============================
_xFlowThroughtSegmentPosolyt := _fbPosolytPumpInlet.xEnable AND _fbPosolytValveTankOutlet.xOpenFeedback;
_xFlowThroughtBypassPosolyt := _fbPosolytPumpInlet.xEnable AND NOT _fbPosolytValveTankOutlet.xOpenFeedback;

_xFlowThroughtSegmentNegolyt := _fbNegolytPumpInlet.xEnable AND _fbNegolytValveTankOutlet.xOpenFeedback;
_xFlowThroughtBypassNegolyt := _fbNegolytPumpInlet.xEnable AND NOT _fbNegolytValveTankOutlet.xOpenFeedback ;


// ===============================
// Pressure sensors posolyt
// ===============================
_fbPressurePosolytSegmentInlet(
	xEnable:= _xFlowThroughtSegmentPosolyt,
	xErrorHigh := stUnitError.xErrorHighPressurePosolytSegmentInlet,
	xErrorLow := stUnitError.xErrorLowPressurePosolytSegmentInlet,
	stAnalogScaling := GVL_CONFIG.stPressureSensorConfig,
	rOnValue:= 487, 
	rOffValue:= 0.0,
	rErrorHighValue := 750,
	rErrorLowValue := 0.0,
	rNoise:= 0.002);
	
_fbPressurePosolytTankInlet(
	xEnable:= _xFlowThroughtSegmentPosolyt,
	xErrorHigh := stUnitError.xErrorHighPressurePosolytTankInlet,
	xErrorLow := stUnitError.xErrorLowPressurePosolytTankInlet,
	stAnalogScaling := GVL_CONFIG.stPressureSensorConfig,
	rOnValue:= 42.9, 
	rOffValue:= 0.0,
	rErrorHighValue := 150,
	rErrorLowValue := -110,
	rNoise:= 0.002);

	
// ===============================
// Pressure sensors negolyt
// ===============================
_fbPressureNegolytSegmentInlet(
	xEnable:= _xFlowThroughtSegmentNegolyt,
	xErrorHigh := stUnitError.xErrorHighPressureNegolytSegmentInlet,
	xErrorLow := stUnitError.xErrorLowPressureNegolytSegmentInlet,
	stAnalogScaling := GVL_CONFIG.stPressureSensorConfig,
	rOnValue:= 487, 
	rOffValue:= 0.0,
	rErrorHighValue := 750,
	rErrorLowValue := 0.0,
	rNoise:= 0.002);

_fbPressureNegolytTankInlet(
	xEnable:= _xFlowThroughtSegmentNegolyt,
	xErrorHigh := stUnitError.xErrorHighPressureNegolytTankInlet,
	xErrorLow := stUnitError.xErrorLowPressureNegolytTankInlet,
	stAnalogScaling := GVL_CONFIG.stPressureSensorConfig,
	rOnValue:= 42.9, 
	rOffValue:= 0.0,
	rErrorHighValue := 150,
	rErrorLowValue := -110,
	rNoise:= 0.002);

	
// ===============================
// Temperatur sensors
// ===============================
_fbTemperatureSensorPosolyt(
	xEnable:= _xFlowThroughtSegmentPosolyt,
	xErrorHigh := stUnitError.xErrorHighTempPosolyt,
	xErrorLow := stUnitError.xErrorLowTempPosolyt,
	stAnalogScaling := GVL_CONFIG.stTempSensorConfig,
	rOnValue:= 40.0,
	rOffValue:= 21.0,
	rErrorHighValue := 65.0,
	rErrorLowValue := -15.0);

_fbTemperatureSensorNegolyt(
	xEnable:= _xFlowThroughtSegmentNegolyt,
	xErrorHigh := stUnitError.xErrorHighTempNegolyt,
	xErrorLow := stUnitError.xErrorLowTempNegolyt,
	stAnalogScaling := GVL_CONFIG.stTempSensorConfig,
	rOnValue:= 40.0, 
	rOffValue:= 21.0,
	rErrorHighValue := 65.0,
	rErrorLowValue := -15.0);
	
	
// ===============================
// Voltage sensor
// ===============================
_fbVoltageSegment(
	xEnable:= _xFlowThroughtSegmentPosolyt AND _xFlowThroughtSegmentNegolyt, 
	xErrorHigh:= stUnitError.xErrorHighVoltageSegment, 
	xErrorLow:= stUnitError.xErrorLowVoltageSegment, 
	rOnValue:= 64.3, 
	rOffValue:= 0.0, 
	rErrorLowValue:= 35.0, 
	rErrorHighValue:= 80.0, 
	rNoise:= 0.05, 
	stAnalogScaling:= GVL_CONFIG.stVoltageSensorconfig);]]></ST>
    </Implementation>
    <LineIds Name="FB_UnitMockup">
      <LineId Id="812" Count="0" />
      <LineId Id="482" Count="0" />
      <LineId Id="813" Count="0" />
      <LineId Id="483" Count="0" />
      <LineId Id="822" Count="0" />
      <LineId Id="814" Count="0" />
      <LineId Id="486" Count="1" />
      <LineId Id="815" Count="0" />
      <LineId Id="488" Count="0" />
      <LineId Id="823" Count="0" />
      <LineId Id="816" Count="0" />
      <LineId Id="491" Count="1" />
      <LineId Id="817" Count="0" />
      <LineId Id="493" Count="0" />
      <LineId Id="824" Count="0" />
      <LineId Id="818" Count="0" />
      <LineId Id="495" Count="1" />
      <LineId Id="819" Count="0" />
      <LineId Id="497" Count="0" />
      <LineId Id="825" Count="0" />
      <LineId Id="820" Count="0" />
      <LineId Id="499" Count="1" />
      <LineId Id="821" Count="0" />
      <LineId Id="501" Count="0" />
      <LineId Id="695" Count="3" />
      <LineId Id="826" Count="0" />
      <LineId Id="810" Count="0" />
      <LineId Id="502" Count="1" />
      <LineId Id="811" Count="0" />
      <LineId Id="504" Count="1" />
      <LineId Id="804" Count="1" />
      <LineId Id="788" Count="0" />
      <LineId Id="506" Count="1" />
      <LineId Id="864" Count="0" />
      <LineId Id="882" Count="0" />
      <LineId Id="510" Count="0" />
      <LineId Id="519" Count="2" />
      <LineId Id="806" Count="1" />
      <LineId Id="789" Count="0" />
      <LineId Id="522" Count="1" />
      <LineId Id="866" Count="0" />
      <LineId Id="881" Count="0" />
      <LineId Id="524" Count="0" />
      <LineId Id="899" Count="0" />
      <LineId Id="809" Count="0" />
      <LineId Id="568" Count="1" />
      <LineId Id="808" Count="0" />
      <LineId Id="570" Count="1" />
      <LineId Id="830" Count="1" />
      <LineId Id="790" Count="0" />
      <LineId Id="699" Count="1" />
      <LineId Id="868" Count="0" />
      <LineId Id="880" Count="0" />
      <LineId Id="576" Count="0" />
      <LineId Id="585" Count="2" />
      <LineId Id="845" Count="1" />
      <LineId Id="791" Count="0" />
      <LineId Id="588" Count="1" />
      <LineId Id="879" Count="0" />
      <LineId Id="870" Count="0" />
      <LineId Id="592" Count="0" />
      <LineId Id="829" Count="0" />
      <LineId Id="827" Count="0" />
      <LineId Id="769" Count="1" />
      <LineId Id="828" Count="0" />
      <LineId Id="856" Count="2" />
      <LineId Id="863" Count="0" />
      <LineId Id="860" Count="1" />
      <LineId Id="855" Count="0" />
      <LineId Id="874" Count="0" />
      <LineId Id="878" Count="0" />
      <LineId Id="862" Count="0" />
      <LineId Id="772" Count="1" />
      <LineId Id="851" Count="1" />
      <LineId Id="792" Count="0" />
      <LineId Id="774" Count="1" />
      <LineId Id="877" Count="0" />
      <LineId Id="875" Count="0" />
      <LineId Id="779" Count="0" />
      <LineId Id="898" Count="0" />
      <LineId Id="896" Count="1" />
      <LineId Id="784" Count="0" />
      <LineId Id="886" Count="9" />
    </LineIds>
  </POU>
</TcPlcObject>