FUNCTION_BLOCK Input

status.active := (rawValue >= 9830.0) OR (config.simValue <> 0.0) ; (* 9830.0 raw = 3.0 mA *)

if config.simValue = 0.0 THEN
	status.scaledValue := LinearScale(
		config.scalingConfig.rawMin,
		config.scalingConfig.rawMax,
		config.scalingConfig.euMin,
		config.scalingConfig.euMax,
		rawValue
	);
ELSE
	status.scaledValue := config.simValue;
end_if;

IF config.isPondLevel THEN
	status.scaledValue := status.scaledValue + config.pondOffset;
	GetPondCalibrationParameters_1(scaledValue, status.calibrationLevel, status.calibrationVolume);

	IF GetPondCalibrationParameters_1.success THEN
		status.pondVolume := LinearScale(
			GetPondCalibrationParameters_1.lowLevelScalingParam, 
			GetPondCalibrationParameters_1.highLevelScalingParam, 
			GetPondCalibrationParameters_1.lowVolumeScalingParam,
			GetPondCalibrationParameters_1.highVolumeScalingParam,
			status.scaledValue
		);
	END_IF;
	
	IF commands.cmdInsertCalPoint AND NOT status.insertSuccess THEN 
	insertInstruction(commands.inpCalLevel, commands.inpCalVolume, status.calibrationLevel, status.calibrationVolume);
		IF insertInstruction.success THEN
			status.calibrationLevel := insertInstruction.outLevelArr;
			status.calibrationVolume := insertInstruction.outVolumeArr;
			status.insertSuccess := TRUE;
		END_IF;
	END_IF;
	
	IF NOT commands.cmdInsertCalPoint THEN
		status.insertSuccess := FALSE;
	END_IF;

	IF commands.cmdDeleteCalPoint AND NOT status.deleteSuccess THEN
		deleteInstruction(commands.inpDeleteIndex, status.calibrationLevel, status.calibrationVolume);
		IF deleteInstruction.success THEN
			status.calibrationLevel := deleteInstruction.outLevelArr;
			status.calibrationVolume := deleteInstruction.outVolumeArr;
			status.deleteSuccess := TRUE;
		END_IF;
	END_IF;
	
	IF NOT commands.cmdDeleteCalPoint THEN
		status.deleteSuccess := FALSE;
	END_IF;

ELSE
	status.pondVolume := 0.0;
END_IF;


	

END_FUNCTION_BLOCK