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
{
private User user;
private Prod prod;
private bool shutdown = false;
internal void doJob(int userId, long codeId)
{
user = findUser(userId);
if (!user.vaild())
return;
private LCDDisplay lcd;
private Input inp;
public Automat() {
lcd = Factory.getLCDDisplay();
inp = new Input();
}
internal void doJob(InputData input)
{
if (input.type == InputData.types.Card)
{
user = this.findUser(input.id);
if (!user.vaild())
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)

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