diff --git a/Matomat/Automat.cs b/Matomat/Automat.cs index 98bfbad..a343dc4 100644 --- a/Matomat/Automat.cs +++ b/Matomat/Automat.cs @@ -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) diff --git a/Matomat/Input.cs b/Matomat/Input.cs new file mode 100644 index 0000000..672cad2 --- /dev/null +++ b/Matomat/Input.cs @@ -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(); + } + } +} diff --git a/Matomat/Prod.cs b/Matomat/Prod.cs new file mode 100644 index 0000000..72c2d14 --- /dev/null +++ b/Matomat/Prod.cs @@ -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(); + } + } +} diff --git a/Matomat/Worker.cs b/Matomat/Worker.cs index afd57c1..e391fdd 100644 --- a/Matomat/Worker.cs +++ b/Matomat/Worker.cs @@ -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."); }