Automat
This commit is contained in:
parent
9bfb6285aa
commit
f46f43dce2
@ -13,6 +13,10 @@ namespace Matomat
|
||||
private LCDDisplay lcd;
|
||||
private Input inp;
|
||||
|
||||
public delegate void stopEvent(bool stop);
|
||||
|
||||
public event stopEvent stopThread;
|
||||
|
||||
public Automat() {
|
||||
lcd = Factory.getLCDDisplay();
|
||||
inp = Factory.getInput();
|
||||
@ -37,6 +41,19 @@ namespace Matomat
|
||||
{
|
||||
this.sell(prod, user);
|
||||
}
|
||||
if (prod.GetProdType() == Prod.ProdType.instruction)
|
||||
{
|
||||
switch (prod.GetFunctName())
|
||||
{
|
||||
case "exit();": this.stopThread(true); break;
|
||||
case "aufladen(10);": this.InsAufladen(10); break;
|
||||
case "aufladen(20);": this.InsAufladen(20); break;
|
||||
case "aufladen(5);": this.InsAufladen(5); break;
|
||||
case "addUser();": this.InsAddUser(); break;
|
||||
case "delUser();": this.InsDelUser(); break;
|
||||
case "showStats();": this.InsShowStats(); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -56,7 +73,8 @@ namespace Matomat
|
||||
this.lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
|
||||
"² Du hast zu viel Geld auf dem Konto ²" +
|
||||
"² BITTE bezahlen! | Grenze 20€ ²" +
|
||||
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", LCDDisplay.Status.Error, 5);
|
||||
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²",
|
||||
LCDDisplay.Status.Error, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,11 +122,6 @@ namespace Matomat
|
||||
return new User(userId);
|
||||
}
|
||||
|
||||
internal bool die()
|
||||
{
|
||||
return shutdown;
|
||||
}
|
||||
|
||||
internal void GetInitStatus()
|
||||
{
|
||||
lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²abcdef 321" +
|
||||
|
@ -36,6 +36,8 @@ namespace Matomat
|
||||
public override void query(string sql)
|
||||
{
|
||||
this.err = null;
|
||||
if (this.data is MySqlDataReader && !this.data.IsClosed)
|
||||
this.data.Close();
|
||||
this.data = null;
|
||||
this.data_b = true;
|
||||
if (sql.ToUpper().Substring(0, 6) == "SELECT")
|
||||
@ -191,6 +193,7 @@ namespace Matomat
|
||||
}
|
||||
return row;
|
||||
}
|
||||
this.data.Close();
|
||||
return null;
|
||||
}
|
||||
public override Exception getError()
|
||||
|
@ -195,6 +195,8 @@ namespace Matomat
|
||||
public void RequestStop()
|
||||
{
|
||||
_shouldStop = true;
|
||||
if (this.serialPort.IsOpen)
|
||||
this.serialPort.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ namespace Matomat
|
||||
if (t == null)
|
||||
{
|
||||
this.found = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
this.found = true;
|
||||
if (t.iscommand)
|
||||
{
|
||||
@ -40,7 +40,7 @@ namespace Matomat
|
||||
{
|
||||
this.type = ProdType.product;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal bool vaild()
|
||||
|
@ -12,7 +12,6 @@ namespace Matomat
|
||||
|
||||
public User(long userId)
|
||||
{
|
||||
// TODO: Complete member initialization
|
||||
this.userId = userId;
|
||||
load();
|
||||
}
|
||||
@ -20,8 +19,11 @@ namespace Matomat
|
||||
private void load()
|
||||
{
|
||||
TUser u = new Tables().getUserTable(this.userId);
|
||||
|
||||
if (true)
|
||||
if (u == null)
|
||||
{
|
||||
this.found = false;
|
||||
return;
|
||||
}
|
||||
this.found = true;
|
||||
}
|
||||
|
||||
@ -31,6 +33,7 @@ namespace Matomat
|
||||
if (!found)
|
||||
{
|
||||
lcd.print("User wurde nich gefunden",LCDDisplay.Status.Error,5);
|
||||
System.Threading.Thread.Sleep(4500);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -18,8 +18,10 @@ namespace Matomat
|
||||
rfid = new RFIDReader();
|
||||
barcode = new BarcodeReader();
|
||||
automat = new Automat();
|
||||
automat.stopThread += new Automat.stopEvent(RequestStop);
|
||||
lcd = Factory.getLCDDisplay();
|
||||
inp = Factory.getInput();
|
||||
_shouldStop = false;
|
||||
}
|
||||
public void DoWork()
|
||||
{
|
||||
@ -29,11 +31,12 @@ namespace Matomat
|
||||
InputData input = inp.getAnyInput(0);
|
||||
automat.doJob(input);
|
||||
}
|
||||
Console.WriteLine("worker thread: terminating gracefully.");
|
||||
lcd.print("Matomat Beendet!");
|
||||
lcd.RequestStop();
|
||||
}
|
||||
public void RequestStop()
|
||||
private void RequestStop(bool stop)
|
||||
{
|
||||
_shouldStop = true;
|
||||
_shouldStop = stop;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user