There is an error, to claim the printer in the context, a
user has this one left linked and no other it can use it to
print .
My solution is not use el method claim until it goes away
to print and just after finishing to liberate it.
CODE :
In com.globalretailtech.pos.hardware.BaseDevice add
this method :
/**
* Release the device
*/
public void release(jpos.BaseControl c) {
control = c;
try {
if (isOpen())
control.release();
} catch (jpos.JposException e) {
logger.warn("Control not released");
}
}
And in com.globalretailtech.pos.hardware.POSPrinter,
add
private void open(){
if ( isOpen() ){
try {
logger.debug("before claim Printer");
control.claim(5000);
logger.debug("before setDeviceEnabled");
control.setDeviceEnabled(true);
logger.debug("device
claimed:"+control.getClaimed());
logger.debug("device
enabled:"+control.getDeviceEnabled());
} catch (JposException e) {
logger.error("Can't claim PosPrinter");
}
}
// some additional properties
if (isOpen()) {
logger.debug("init PosPrinter");
try {
//TODO parametrize quality
control.setRecLetterQuality(false);
} catch (JposException e) {
logger.error("Can't init PosPrinter", e);
}
}
}
and
/**
* Prints Ej as a receipt
**/
public void printReceipt(Ej ej) throws JposException {
if (!isOpen())
return;
// PATCHED - BEGIN
open();
// PATCHED - END
...................Printing.....
// PATCHED - BEGIN
release(control);
// PATCHED - END
}
And rewrite the contructor methods of POSPrinter an
Printer to:
public Printer(jpos.POSPrinter c, String devicename) {
super((jpos.BaseControl) c, devicename);
}
------------------------------------
public PosPrinter(
jpos.POSPrinter c,
String devicename,
PosContext context) {
super(c, devicename);
setContext(context);
control = c;
}