FUNCTION AddCalibrationPoint
shiftStartIndex := 0;

(* Make sure pond number is between 1 and 4 *)
IF 0 > linpPondNumber OR linpPondNumber < 4 THEN
	AddCalibrationPoint := FALSE;
END_IF;

IF linpPondNumber = 1 THEN 
	calMaxIndex := FindNumberOfCalPoints(1);
	IF calMaxIndex = 0 THEN
		(* theres no existing calibration data *)
		pond1CalibrationHeight[1] := linpHeight;
		pond1CalibrationVolume[1] := linpVolume;
		AddCalibrationPoint := TRUE;
		
	ELSIF linpHeight < pond1CalibrationHeight[1] THEN
		(* less than the first point *)
		shiftStartIndex := 1;
	
	ELSIF linpHeight > pond1CalibrationHeight[calMaxIndex] THEN
		(* Greater than the last point *)
		IF calMaxIndex < 10 THEN
			pond1CalibrationHeight[calMaxIndex + 1] := linpHeight;
			pond1CalibrationVolume[calMaxIndex + 1] := linpVolume;
			AddCalibrationPoint := TRUE;
		END_IF;
		
	ELSE
		(* Somewhere in the middle *)
		FOR calIndex := 1 TO calMaxIndex - 1 DO
			IF pond1CalibrationHeight[calIndex] < linpHeight AND pond1CalibrationHeight[calIndex + 1] > linpHeight THEN
				shiftStartIndex := calIndex + 1;
			END_IF;
		END_FOR;
	END_IF;
	
	IF shiftStartIndex > 0 THEN 
		FOR shiftIndex := 9 TO shiftStartIndex BY -1 DO
			pond1CalibrationHeight[shiftIndex + 1] := pond1CalibrationHeight[shiftIndex];
			pond1CalibrationVolume[shiftIndex + 1] := pond1CalibrationVolume[shiftIndex];
		END_FOR;
		
		pond1CalibrationHeight[shiftStartIndex] := linpHeight;
		pond1CalibrationVolume[shiftStartIndex] := linpVolume;
		AddCalibrationPoint := TRUE;
	END_IF;

ELSIF linpPondNumber = 2 THEN 
	calMaxIndex := FindNumberOfCalPoints(2);
	IF calMaxIndex = 0 THEN
		(* theres no existing calibration data *)
		pond2CalibrationHeight[1] := linpHeight;
		pond2CalibrationVolume[1] := linpVolume;
		AddCalibrationPoint := TRUE;
		
	ELSIF linpHeight < pond2CalibrationHeight[1] THEN
		(* less than the first point *)
		shiftStartIndex := 1;
	
	ELSIF linpHeight > pond2CalibrationHeight[calMaxIndex] THEN
		(* Greater than the last point *)
		IF calMaxIndex < 10 THEN
			pond2CalibrationHeight[calMaxIndex + 1] := linpHeight;
			pond2CalibrationVolume[calMaxIndex + 1] := linpVolume;
			AddCalibrationPoint := TRUE;
		END_IF;
		
	ELSE
		(* Somewhere in the middle *)
		FOR calIndex := 1 TO calMaxIndex - 1 DO
			IF pond2CalibrationHeight[calIndex] < linpHeight AND pond2CalibrationHeight[calIndex + 1] > linpHeight THEN
				shiftStartIndex := calIndex + 1;
			END_IF;
		END_FOR;
	END_IF;
	
	IF shiftStartIndex > 0 THEN 
		FOR shiftIndex := 9 TO shiftStartIndex BY -1 DO
			pond2CalibrationHeight[shiftIndex + 1] := pond2CalibrationHeight[shiftIndex];
			pond2CalibrationVolume[shiftIndex + 1] := pond2CalibrationVolume[shiftIndex];
		END_FOR;
		
		pond2CalibrationHeight[shiftStartIndex] := linpHeight;
		pond2CalibrationVolume[shiftStartIndex] := linpVolume;
		AddCalibrationPoint := TRUE;
	END_IF;


ELSIF linpPondNumber = 3 THEN 
	calMaxIndex := FindNumberOfCalPoints(3);
	IF calMaxIndex = 0 THEN
		(* theres no existing calibration data *)
		pond3CalibrationHeight[1] := linpHeight;
		pond3CalibrationVolume[1] := linpVolume;
		AddCalibrationPoint := TRUE;
		
	ELSIF linpHeight < pond3CalibrationHeight[1] THEN
		(* less than the first point *)
		shiftStartIndex := 1;
	
	ELSIF linpHeight > pond3CalibrationHeight[calMaxIndex] THEN
		(* Greater than the last point *)
		IF calMaxIndex < 10 THEN
			pond3CalibrationHeight[calMaxIndex + 1] := linpHeight;
			pond3CalibrationVolume[calMaxIndex + 1] := linpVolume;
			AddCalibrationPoint := TRUE;
		END_IF;
		
	ELSE
		(* Somewhere in the middle *)
		FOR calIndex := 1 TO calMaxIndex - 1 DO
			IF pond3CalibrationHeight[calIndex] < linpHeight AND pond3CalibrationHeight[calIndex + 1] > linpHeight THEN
				shiftStartIndex := calIndex + 1;
			END_IF;
		END_FOR;
	END_IF;
	
	IF shiftStartIndex > 0 THEN 
		FOR shiftIndex := 9 TO shiftStartIndex BY -1 DO
			pond3CalibrationHeight[shiftIndex + 1] := pond3CalibrationHeight[shiftIndex];
			pond3CalibrationVolume[shiftIndex + 1] := pond3CalibrationVolume[shiftIndex];
		END_FOR;
		
		pond3CalibrationHeight[shiftStartIndex] := linpHeight;
		pond3CalibrationVolume[shiftStartIndex] := linpVolume;
		AddCalibrationPoint := TRUE;
	END_IF;

ELSIF linpPondNumber = 4 THEN 
	calMaxIndex := FindNumberOfCalPoints(4);
	IF calMaxIndex = 0 THEN
		(* theres no existing calibration data *)
		pond4CalibrationHeight[1] := linpHeight;
		pond4CalibrationVolume[1] := linpVolume;
		AddCalibrationPoint := TRUE;
		
	ELSIF linpHeight < pond4CalibrationHeight[1] THEN
		(* less than the first point *)
		shiftStartIndex := 1;
	
	ELSIF linpHeight > pond4CalibrationHeight[calMaxIndex] THEN
		(* Greater than the last point *)
		IF calMaxIndex < 10 THEN
			pond4CalibrationHeight[calMaxIndex + 1] := linpHeight;
			pond4CalibrationVolume[calMaxIndex + 1] := linpVolume;
			AddCalibrationPoint := TRUE;
		END_IF;
		
	ELSE
		(* Somewhere in the middle *)
		FOR calIndex := 1 TO calMaxIndex - 1 DO
			IF pond4CalibrationHeight[calIndex] < linpHeight AND pond4CalibrationHeight[calIndex + 1] > linpHeight THEN
				shiftStartIndex := calIndex + 1;
			END_IF;
		END_FOR;
	END_IF;
	
	IF shiftStartIndex > 0 THEN 
		FOR shiftIndex := 9 TO shiftStartIndex BY -1 DO
			pond4CalibrationHeight[shiftIndex + 1] := pond4CalibrationHeight[shiftIndex];
			pond4CalibrationVolume[shiftIndex + 1] := pond4CalibrationVolume[shiftIndex];
		END_FOR;
		
		pond4CalibrationHeight[shiftStartIndex] := linpHeight;
		pond4CalibrationVolume[shiftStartIndex] := linpVolume;
		AddCalibrationPoint := TRUE;
	END_IF;

END_IF;



END_FUNCTION