Hi All,
I'm a newbie to the POS system. so please mind if my questions are stupid.
I have an epson TM-U200 printer with USB connection and cash drawer connected to printer with RJ 11 cable.
I tried to create a service object for my printer and suceeds.(It shows on test app as a POS Printer)
this is my code for that.
-
[HardwareId(@"USB\Vid_0525&Pid_a700",@"USB\Vid_0525&Pid_a700")]
-
[ServiceObject(DeviceType.PosPrinter,"PrinterTemplate","Printer Class",1,9)]
-
public class MyPrinter : PosPrinterBase
-
{ private string MyHealthText;
-
-
public MyPrinter()
-
{
-
// Initialize device capability properties.
-
MyHealthText = "";
-
}
-
-
~MyPrinter()
-
{
-
Dispose(false);
-
}
-
-
// Release any resources managed by this object.
-
protected override void Dispose(bool disposing)
-
{
-
try
-
{
-
// Your code here.
-
}
-
finally
-
{
-
// Must call base class Dispose.
-
base.Dispose(disposing);
-
}
-
}
-
#region PosCommon overrides
-
// Returns the result of the last call to CheckHealth().
-
public override string CheckHealthText
-
{
-
get
-
{
-
// MsrBasic.VerifyState(mustBeClaimed,
-
// mustBeEnabled). This may throw an exception.
-
VerifyState(false, false);
-
-
return MyHealthText;
-
}
-
}
-
-
public override string CheckHealth(
-
HealthCheckLevel level)
-
{
-
// Verify that device is open, claimed, and enabled.
-
VerifyState(true, true);
-
-
// Your code here:
-
// check the health of the device and return a
-
// descriptive string.
-
-
// Cache result in the CheckHealthText property.
-
MyHealthText = "Ok";
-
return MyHealthText;
-
}
-
-
public override DirectIOData DirectIO(
-
int command,
-
int data,
-
object obj)
-
{
-
// Verify that device is open.
-
VerifyState(false, false);
-
-
return new DirectIOData(data, obj);
-
}
-
#endregion // PosCommon overrides
-
protected override PrintResults PrintNormalImpl(PrinterStation station, PrinterState printerState, string data)
-
{
-
throw new Exception("The method or operation is not implemented.");
-
}
-
protected override void ValidateDataImpl(PrinterStation station, string data)
-
{
-
throw new Exception("The method or operation is not implemented.");
-
}
-
-
}
-
I register this with posdm in the name "Printer"
This is my application.
-
PosExplorer ex = new PosExplorer();
-
DeviceInfo d = ex.GetDevice(DeviceType.PosPrinter, "Printer");
-
PosPrinter printer = (PosPrinter)ex.CreateInstance(d);
-
printer.Open();
-
printer.Claim(1000);
-
printer.DeviceEnabled = true;
-
//printer.PrintNormal(PrinterStation.Receipt, "SSSSSS");
-
-
printer.Release();
-
printer.Close();
-
this PrintNormal method giving me an error saying "The receipt station is not present". I cannot figure it out. Please help me on this.
and if I want to open the cash drawer, can I use the printnormal method for that. something like "printer.PrintNormal(PrinterStation.Receipt, "ESC /27,112,0,25,250");"
I'm really confused.