Next step to the moon

This commit is contained in:
BlubbFish 2011-09-21 15:57:00 +00:00
parent 59485950c2
commit 42e167bdef
4 changed files with 100 additions and 12 deletions

View File

@ -8,13 +8,53 @@ namespace Matomat
class Automat class Automat
{ {
private User user; private User user;
private Prod prod;
private bool shutdown = false; private bool shutdown = false;
internal void doJob(int userId, long codeId) private LCDDisplay lcd;
private Input inp;
public Automat() {
lcd = Factory.getLCDDisplay();
inp = new Input();
}
internal void doJob(InputData input)
{ {
user = findUser(userId); if (input.type == InputData.types.Card)
{
user = this.findUser(input.id);
if (!user.vaild()) if (!user.vaild())
return; return;
this.showUserInfo(user);
lcd.print("Bitte Produkt / Code über den Barcodeleser halten.");
InputData prodid = inp.getProdInput(20);
if (prodid.type == InputData.types.None)
return;
prod = this.findProd(prodid.id);
if(!prod.vaild())
return;
}
else if (input.type == InputData.types.Prod)
{
prod = this.findProd(input.id);
if (!prod.vaild())
return;
this.showProdInfo(prod);
}
}
private void showProdInfo(Prod prod)
{
throw new NotImplementedException();
}
private Prod findProd(int p)
{
throw new NotImplementedException();
}
private void showUserInfo(User user)
{
throw new NotImplementedException();
} }
private User findUser(int userId) private User findUser(int userId)

31
Matomat/Input.cs Normal file
View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Matomat
{
class InputData
{
public enum types
{
Card,
Prod,
None
}
public types type { get; set; }
public int id { get; set; }
}
class Input
{
internal InputData getAnyInput(int timeout)
{
throw new NotImplementedException();
}
internal InputData getProdInput(int timeout)
{
throw new NotImplementedException();
}
}
}

15
Matomat/Prod.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Matomat
{
class Prod
{
internal bool vaild()
{
throw new NotImplementedException();
}
}
}

View File

@ -12,24 +12,26 @@ namespace Matomat
private BarcodeReader barcode; private BarcodeReader barcode;
private Automat automat; private Automat automat;
private LCDDisplay lcd; private LCDDisplay lcd;
private Input inp;
public Worker() public Worker()
{ {
rfid = new RFIDReader(); rfid = new RFIDReader();
barcode = new BarcodeReader(); barcode = new BarcodeReader();
automat = new Automat(); automat = new Automat();
lcd = Factory.getLCDDisplay(); lcd = Factory.getLCDDisplay();
inp = new Input();
} }
public void DoWork() public void DoWork()
{ {
while (!_shouldStop) while (!_shouldStop)
{ {
lcd.print("Bitte Sudierendenausweis über den RFID Leser halten."); InputData input = inp.getAnyInput(0);
int userId = rfid.getCardID();
lcd.print("Bitte Produkt / Code über den Barcodeleser halten."); /*int userId = rfid.getCardID();
long codeId = barcode.getCodeID();
automat.doJob(userId, codeId); * lcd.print("Bitte Sudierendenausweis über den RFID Leser halten.");
if (automat.die()) long codeId = barcode.getCodeID();*/
RequestStop(); automat.doJob(input);
} }
Console.WriteLine("worker thread: terminating gracefully."); Console.WriteLine("worker thread: terminating gracefully.");
} }