
PROGRAM _INIT
	
	Liftgate := 0;
	RTInfo_0(enable:=1);
	 
END_PROGRAM

PROGRAM _CYCLIC
	
	CASE Liftgate_oeffnen OF

		0:
		IF gTaster_Liftgate_oeffnen = TRUE THEN
			gMerker_Liftgate_Leuchte_Rot := TRUE;
			gTaster_Liftgate_Leuchte_Gruen := FALSE;
			gMerker_Stop_an_Kurve2 := TRUE;
			Liftgate_oeffnen := 10;
		END_IF

		10: lWarten_Liftgate := lWarten_Liftgate + (RTInfo_0.cycle_time/1000);
		IF gKurve_3.Inputs.Vor_Stopper = FALSE AND lWarten_Liftgate >= 2000 AND Kurve_2 = 0 THEN
			gMerker_Liftgate_entriegelt := TRUE;
			Rot_blinken := 0;
			gMerker_Liftgate_Leuchte_Rot := FALSE;
			gTaster_Liftgate_Leuchte_Rot := TRUE;
			Liftgate_oeffnen := 0;
		ELSIF gKurve_3.Inputs.Vor_Stopper = TRUE THEN
				gKurve_2.Cmd.Stopper := KMD_AUSFAHREN;
				lWarten_Liftgate := 0;
				Liftgate_oeffnen := 10;
//		ELSIF gKurve_2.Inputs.Vor_Stopper = TRUE THEN
//				lWarten_Liftgate := 0;
		END_IF
		
	END_CASE

	CASE Rot_blinken OF
	
		0: lWarten_Blinken := lWarten_Blinken + (RTInfo_0.cycle_time/1000);
		IF gMerker_Liftgate_Leuchte_Rot = TRUE AND lWarten_Blinken >= 500 THEN
			gTaster_Liftgate_Leuchte_Rot := TRUE;
			lWarten_Blinken := 0;
			Rot_blinken := 10;
		END_IF
	
		10: lWarten_Blinken := lWarten_Blinken + (RTInfo_0.cycle_time/1000);
		IF lWarten_Blinken >= 500 THEN
			gTaster_Liftgate_Leuchte_Rot := FALSE;
			lWarten_Blinken := 0;
			Rot_blinken := 0;
		END_IF
	 
	END_CASE

	IF gTaster_Liftgate_verriegeln = TRUE THEN
		Liftgate_oeffnen := 0;
		gTaster_Liftgate_Leuchte_Rot := FALSE;
		gMerker_Liftgate_Leuchte_Rot := FALSE;
		gTaster_Liftgate_Leuchte_Gruen := TRUE;
		gMerker_Liftgate_entriegelt := FALSE;
		gMerker_Stop_an_Kurve2 := FALSE;
	END_IF		

END_PROGRAM

PROGRAM _EXIT
	(* Insert code here *)
	 
END_PROGRAM

