|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Übungen_LF6_WinFormanwendung
|
|
|
|
|
{
|
|
|
|
|
public partial class Aufzug : Form
|
|
|
|
|
{
|
|
|
|
|
public enum zustand
|
|
|
|
|
{
|
|
|
|
|
EG,
|
|
|
|
|
Stockwerk1,
|
|
|
|
|
Stockwerk2,
|
|
|
|
|
FahreAuf,
|
|
|
|
|
FahreAb
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zustand aufzugZustand;
|
|
|
|
|
List<string> ziel = new List<string>();
|
|
|
|
|
bool fahrtBeendet = true;
|
|
|
|
|
AufzugKabine Kabine = new AufzugKabine();
|
|
|
|
|
|
|
|
|
|
public Aufzug()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
Kabine = new AufzugKabine(80, SensorEG.Location.X + 120, SensorEG.Location.Y ,"Aufzug");
|
|
|
|
|
this.Controls.Add(Kabine);
|
|
|
|
|
|
|
|
|
|
aufzugZustand = zustand.EG;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
int index = 0;
|
|
|
|
|
switch (aufzugZustand)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
case zustand.FahreAuf:
|
|
|
|
|
Kabine.Top -= 1;
|
|
|
|
|
|
|
|
|
|
foreach (string aktuellesZiel in ziel)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
switch (aktuellesZiel)
|
|
|
|
|
{
|
|
|
|
|
case "Etage1":
|
|
|
|
|
if (Kabine.Top == Sensor1.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.Stockwerk1;
|
|
|
|
|
ziel.Remove(aktuellesZiel);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Etage2":
|
|
|
|
|
if (Kabine.Top == Sensor2.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.Stockwerk2;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case zustand.FahreAb:
|
|
|
|
|
Kabine.Top += 1;
|
|
|
|
|
|
|
|
|
|
foreach (string aktuellesZiel in ziel)
|
|
|
|
|
{
|
|
|
|
|
index++;
|
|
|
|
|
switch (aktuellesZiel)
|
|
|
|
|
{
|
|
|
|
|
case "EG":
|
|
|
|
|
if (Kabine.Top == SensorEG.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.EG;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Etage1":
|
|
|
|
|
if (Kabine.Top == Sensor1.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.Stockwerk1;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Etage2":
|
|
|
|
|
if (Kabine.Top == Sensor2.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.Stockwerk2;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case zustand.EG:
|
|
|
|
|
|
|
|
|
|
foreach (string aktuellesZiel in ziel)
|
|
|
|
|
{
|
|
|
|
|
index++;
|
|
|
|
|
switch (aktuellesZiel)
|
|
|
|
|
{
|
|
|
|
|
case "EG":
|
|
|
|
|
if (Kabine.Top == SensorEG.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.EG;
|
|
|
|
|
ziel.Remove(aktuellesZiel);
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Etage1":
|
|
|
|
|
|
|
|
|
|
case "Etage2":
|
|
|
|
|
aufzugZustand = zustand.FahreAuf;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fahrtBeendet = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case zustand.Stockwerk1:
|
|
|
|
|
foreach (string aktuellesZiel in ziel)
|
|
|
|
|
{
|
|
|
|
|
switch (aktuellesZiel)
|
|
|
|
|
{
|
|
|
|
|
case "EG":
|
|
|
|
|
if (Kabine.Top == SensorEG.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.EG;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Etage1":
|
|
|
|
|
if (Kabine.Top == Sensor1.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.Stockwerk1;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Etage2":
|
|
|
|
|
if (Kabine.Top == Sensor2.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.Stockwerk2;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fahrtBeendet = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if (ziel.Count == 0)
|
|
|
|
|
fahrtBeendet = true;
|
|
|
|
|
break;
|
|
|
|
|
case zustand.Stockwerk2:
|
|
|
|
|
foreach (string aktuellesZiel in ziel)
|
|
|
|
|
{
|
|
|
|
|
switch (aktuellesZiel)
|
|
|
|
|
{
|
|
|
|
|
case "EG":
|
|
|
|
|
if (Kabine.Top == SensorEG.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.EG;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Etage1":
|
|
|
|
|
if (Kabine.Top == Sensor1.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.Stockwerk1;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case "Etage2":
|
|
|
|
|
if (Kabine.Top == Sensor2.Top)
|
|
|
|
|
{
|
|
|
|
|
aufzugZustand = zustand.Stockwerk2;
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fahrtBeendet = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!fahrtBeendet &&(aufzugZustand == zustand.EG ||
|
|
|
|
|
aufzugZustand == zustand.Stockwerk1 ||
|
|
|
|
|
aufzugZustand == zustand.Stockwerk2))
|
|
|
|
|
{
|
|
|
|
|
fahrtBeendet = true;
|
|
|
|
|
//update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
while (!fahrtBeendet);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button_ende_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonEG_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ziel.Add("EG");
|
|
|
|
|
if (fahrtBeendet)
|
|
|
|
|
{
|
|
|
|
|
fahrtBeendet = false;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ziel.Add("Etage1");
|
|
|
|
|
if (fahrtBeendet)
|
|
|
|
|
{
|
|
|
|
|
fahrtBeendet = false;
|
|
|
|
|
update();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Button2_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ziel.Add("Etage2");
|
|
|
|
|
if (fahrtBeendet)
|
|
|
|
|
{
|
|
|
|
|
fahrtBeendet = false;
|
|
|
|
|
update();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|