Processing Screens

This commit is contained in:
BlubbFish 2011-10-14 07:57:53 +00:00
parent c9d6696600
commit 9f628c93bc
8 changed files with 173 additions and 20 deletions

View File

@ -32,6 +32,13 @@ namespace Matomat
prod = this.findProd(prodid.id); prod = this.findProd(prodid.id);
if(!prod.vaild()) if(!prod.vaild())
return; return;
this.showProdInfo(prod);
if (prod.GetProdType() == Prod.ProdType.product)
{
this.sell(prod, user);
}
} }
else if (input.type == InputData.types.Prod) else if (input.type == InputData.types.Prod)
{ {
@ -42,22 +49,51 @@ namespace Matomat
} }
} }
private void showProdInfo(Prod prod) private void sell(Prod prod, User user)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
private Prod findProd(int p) private void showProdInfo(Prod prod)
{ {
throw new NotImplementedException(); if (prod.GetProdType() == Prod.ProdType.product)
{
long id = prod.GetProdId();
double price = prod.GetProdPrice();
string name = prod.GetProdName();
this.lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
"² Produkt: " + name.PadRight(27, ' ') + " ²" +
"² Preis: " + price.ToString(2).PadLeft(6, ' ') + "€ EAN13: " + id.ToString().PadRight(14, ' ') + " ²" +
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", 5);
}
if (prod.GetProdType() == Prod.ProdType.instruction)
{
string name = prod.GetFunctName();
this.lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
"² Instruktion: " + name.PadRight(23, ' ') + " ²" +
"² AdminCard + Instruction + TargetCard ²" +
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", 5);
}
}
private Prod findProd(long prodid)
{
return new Prod(prodid);
} }
private void showUserInfo(User user) private void showUserInfo(User user)
{ {
lcd.print("User x",5); string name = user.GetUserName();
int konto = user.GetUserKonto();
long id = user.GetUserId();
int all = user.GetUserAll();
lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²" +
"² User: " + name.PadRight(8, ' ') + " Betrag: " + (konto.ToString() + " €").PadRight(7, ' ') + " ²" +
"² UserID: " + id.ToString().PadRight(12, ' ') + " Gesamt: " + (all.ToString() + " €").PadRight(7, ' ') + " ²" +
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", 5);
} }
private User findUser(int userId) private User findUser(long userId)
{ {
return new User(userId); return new User(userId);
} }

View File

@ -9,8 +9,7 @@ namespace Matomat
{ {
internal long getCodeID() internal long getCodeID()
{ {
Console.ReadKey(); return 4029764001807;
return 1234567890123;
} }
} }
} }

View File

@ -51,5 +51,12 @@ namespace Matomat
return b.Substring(start, b.Length); return b.Substring(start, b.Length);
} }
} }
public static class Double
{
public static string ToString(this double d, int f)
{
return "1.00";
}
}
} }

View File

@ -20,7 +20,7 @@ namespace Matomat
None None
} }
public types type { get; set; } public types type { get; set; }
public int id { get; set; } public long id { get; set; }
} }
class Input class Input
{ {
@ -40,18 +40,24 @@ namespace Matomat
static List<instance> instances; static List<instance> instances;
private InputData data; private InputData data;
private RFIDReader rfid; private RFIDReader rfid;
private BarcodeReader code;
public Input() public Input()
{ {
rfid = new RFIDReader(); rfid = new RFIDReader();
code = new BarcodeReader();
} }
private void doWorkCard() private void doWorkCard()
{ {
while (true) while (true)
{ {
Thread.Sleep(1); Thread.Sleep(1);
char k = 'r';
if (k == 'r')
{
data.id = rfid.getCardID(); data.id = rfid.getCardID();
data.type = InputData.types.Card; data.type = InputData.types.Card;
} }
}
} }
private void doWorkCode() private void doWorkCode()
@ -59,6 +65,13 @@ namespace Matomat
while (true) while (true)
{ {
Thread.Sleep(1); Thread.Sleep(1);
char k = Console.ReadKey(false).KeyChar;
Console.WriteLine();
if (k == 'b')
{
data.id = code.getCodeID();
data.type = InputData.types.Prod;
}
} }
} }
internal InputData getAnyInput(int timeout) internal InputData getAnyInput(int timeout)

View File

@ -55,11 +55,19 @@ namespace Matomat
private Queue<Message> messages; private Queue<Message> messages;
private volatile bool _shouldStop; private volatile bool _shouldStop;
private SerialPort serialPort; private SerialPort serialPort;
private bool disable = false;
public LCDDisplay(Comport port) public LCDDisplay(Comport port)
{ {
this.serialPort = new SerialPort(port.port, port.bautrate, port.parity, port.databits, port.stopbits); this.serialPort = new SerialPort(port.port, port.bautrate, port.parity, port.databits, port.stopbits);
try
{
this.serialPort.Open(); this.serialPort.Open();
}
catch (Exception)
{
this.disable = true;
}
messages = new Queue<Message>(); messages = new Queue<Message>();
Thread workerThread = new Thread(this.DoWork); Thread workerThread = new Thread(this.DoWork);
workerThread.Start(); workerThread.Start();
@ -87,9 +95,18 @@ namespace Matomat
private void display(string text, Status status) private void display(string text, Status status)
{ {
if (status == Status.Warn)
{
Console.Beep();
}
if (status == Status.Error)
{
Console.Beep();
Console.Beep();
}
Console.WriteLine(text); Console.WriteLine(text);
this.displayClear(); this.displayClear();
byte[] btext = text.ToCharArray("ÄÖÜäöüß²", new byte[] { 0xE1, 0xEF, 0xF5, 0xE1, 0xEF, 0xF5, 0xE2, 0xFF }); byte[] btext = text.ToCharArray("ÄÖÜäöüß²", new byte[] { 0xE1, 0xEF, 0xF5, 0xE1, 0xEF, 0xF5, 0xE2, 0xFF, 0xFF});
byte[] upper; byte[] upper;
byte[] lower; byte[] lower;
if (text.Length > 80) if (text.Length > 80)
@ -118,14 +135,20 @@ namespace Matomat
} }
private void displayCode(byte[] p) private void displayCode(byte[] p)
{
if (!disable)
{ {
this.serialPort.Write(p, 0, p.Length); this.serialPort.Write(p, 0, p.Length);
} }
}
private void displayEscCode(string code) private void displayEscCode(string code)
{ {
this.displayCode(new byte[] { 0x1b }); this.displayCode(new byte[] { 0x1b });
if (!disable)
{
this.serialPort.Write(code); this.serialPort.Write(code);
}
this.displayCode(new byte[] { 0x0d }); this.displayCode(new byte[] { 0x0d });
} }
public enum Status public enum Status

View File

@ -7,9 +7,65 @@ namespace Matomat
{ {
class Prod class Prod
{ {
private long prodId;
private bool found;
private ProdType type;
public enum ProdType
{
product,
instruction
}
public Prod(long prodId)
{
this.prodId = prodId;
this.load();
}
private void load()
{
if (true)
this.found = true;
this.type = ProdType.instruction;
}
internal bool vaild() internal bool vaild()
{ {
throw new NotImplementedException(); LCDDisplay lcd = Factory.getLCDDisplay();
if (!found)
{
lcd.print("²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²"+
"² Produkt wurde nich gefunden ²"+
"² EAN13: "+(this.GetProdId().ToString()+" unbekannt").PadRight(29,' ')+" ²"+
"²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²", LCDDisplay.Status.Error, 5);
return false;
}
return true;
}
internal ProdType GetProdType()
{
return this.type;
}
internal long GetProdId()
{
return this.prodId;
}
internal double GetProdPrice()
{
return 1.0;
}
internal string GetProdName()
{
return "Mate-Cola";
}
internal string GetFunctName()
{
return "aufladen(10);";
} }
} }
} }

View File

@ -7,10 +7,9 @@ namespace Matomat
{ {
class RFIDReader class RFIDReader
{ {
internal int getCardID() internal long getCardID()
{ {
Console.ReadKey(); return 0xFFFFFFFF;
return 0x1234;
} }
} }
} }

View File

@ -7,10 +7,10 @@ namespace Matomat
{ {
class User class User
{ {
private int userId; private long userId;
private bool found; private bool found;
public User(int userId) public User(long userId)
{ {
// TODO: Complete member initialization // TODO: Complete member initialization
this.userId = userId; this.userId = userId;
@ -34,5 +34,25 @@ namespace Matomat
return true; return true;
} }
internal string GetUserName()
{
return "pschel2s";
}
internal int GetUserKonto()
{
return 15;
}
internal long GetUserId()
{
return this.userId;
}
internal int GetUserAll()
{
return 35;
}
} }
} }