FUNCTION_BLOCK GetPondCalibrationParameters
lowLevelScalingParam := 0.0;
highLevelScalingParam := 0.0;
lowVolumeScalingParam := 0.0;
highVolumeScalingParam := 0.0;
success := FALSE;

maxCalIndex := FindNumberOfCalPoints(calibrationLevel);

IF maxCalIndex = 0 THEN
	success := FALSE;
ELSIF maxCalIndex = 1 THEN
	lowLevelScalingParam := 0.0;
	highLevelScalingParam := calibrationLevel[1];
	lowVolumeScalingParam := 0.0;
	highVolumeScalingParam := calibrationVolume[1];
	success := TRUE;
ELSE
	IF pondLevel <= calibrationLevel[1] THEN
		lowLevelScalingParam := 0.0;
		highLevelScalingParam := calibrationLevel[1];
		lowVolumeScalingParam := 0.0;
		highVolumeScalingParam := calibrationVolume[1];
		success := TRUE;
	ELSIF pondLevel >= calibrationLevel[maxCalIndex] THEN
		lowLevelScalingParam := calibrationLevel[maxCalIndex - 1];
		highLevelScalingParam := calibrationLevel[maxCalIndex];
		lowVolumeScalingParam := calibrationVolume[maxCalIndex - 1];
		highVolumeScalingParam := calibrationVolume[maxCalIndex];
		success := TRUE;
	ELSE
		FOR calIndex := 1 TO maxCalIndex - 1 DO
			IF pondLevel >= calibrationLevel[calIndex] AND pondLevel < calibrationLevel[calIndex + 1] THEN
				lowLevelScalingParam := calibrationLevel[calIndex];
				highLevelScalingParam := calibrationLevel[calIndex + 1];
				lowVolumeScalingParam := calibrationVolume[calIndex];
				highVolumeScalingParam := calibrationVolume[calIndex + 1];
				success := TRUE;
			END_IF;
		END_FOR;
	END_IF;
END_IF;
	
END_FUNCTION_BLOCK