This commit is contained in:
BlubbFish 2011-11-08 18:18:41 +00:00
parent 9bfb6285aa
commit f46f43dce2
6 changed files with 49 additions and 25 deletions

View File

@ -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" +

View File

@ -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()

View File

@ -195,6 +195,8 @@ namespace Matomat
public void RequestStop()
{
_shouldStop = true;
if (this.serialPort.IsOpen)
this.serialPort.Close();
}
}
}

View File

@ -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()

View File

@ -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;

View File

@ -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;
}
}