svn commit: r427496 - /incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/jpos/service/NullPosPrinter.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r427496 - /incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/jpos/service/NullPosPrinter.java

jleroux@apache.org
Author: jleroux
Date: Tue Aug  1 02:14:02 2006
New Revision: 427496

URL: http://svn.apache.org/viewvc?rev=427496&view=rev
Log:
A patch from Ray Barlow to improve and ease reading of NullPosPrinter writing in the log.
Simply groups the printer commands (for example receipt) together so that they will dump to the logs in one go which makes it a lot easier to see the receipt formatting when developing and making changes. WIthout this patch all the lines of a print get broken across different log messages and it's very hard to see and check formatting.
Not actually used for production deployments were real printers are attached.

Modified:
    incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/jpos/service/NullPosPrinter.java

Modified: incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/jpos/service/NullPosPrinter.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/jpos/service/NullPosPrinter.java?rev=427496&r1=427495&r2=427496&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/jpos/service/NullPosPrinter.java (original)
+++ incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/jpos/service/NullPosPrinter.java Tue Aug  1 02:14:02 2006
@@ -27,6 +27,11 @@
  */
 public class NullPosPrinter extends BaseService implements jpos.services.POSPrinterService12 {
 
+    protected static final String ESC = ((char) 0x1b) + "";
+    protected static final String PAPER_CUT = ESC + "|100fP";
+
+    private StringBuffer printerBuffer = new StringBuffer();
+
     public int getDeviceServiceVersion() throws JposException {
         return 1002000;
     }
@@ -476,24 +481,32 @@
     public void endRemoval() throws JposException {
     }
 
+    private void printALine(String s) {
+        printerBuffer = printerBuffer.append(s);
+        if ( s.indexOf(NullPosPrinter.PAPER_CUT) > 0 ) {
+            Debug.log(printerBuffer.toString(), module);
+            printerBuffer = new StringBuffer();
+        }
+    }
+
     public void printBarCode(int i, String s, int i1, int i2, int i3, int i4, int i5) throws JposException {
-        Debug.log("Barcode:\n" + s + "\n", module);
+        printALine("Barcode:" + s + "\n");
     }
 
     public void printBitmap(int i, String s, int i1, int i2) throws JposException {
-        Debug.log("Bitmap:\n" + s + "\n", module);
+        printALine("Bitmap:" + s + "\n");
     }
 
     public void printImmediate(int i, String s) throws JposException {
-        Debug.log("Immediate:\n" + s + "\n", module);
+        printALine("Immediate:" + s + "\n");
     }
 
     public void printNormal(int i, String s) throws JposException {
-        Debug.log("Normal:\n" + s + "\n", module);
+        printALine("Normal:" + s + "\n");
     }
 
     public void printTwoNormal(int i, String s, String s1) throws JposException {
-        Debug.log("2Normal:\n" + s + "\n", module);
+        printALine("2Normal:" + s + "\n");
     }
 
     public void rotatePrint(int i, int i1) throws JposException {
@@ -506,8 +519,9 @@
     }
 
     public void transactionPrint(int i, int i1) throws JposException {
+      Debug.log("transactionPrint:\n\n", module);
     }
 
     public void validateData(int i, String s) throws JposException {
     }
-}
\ No newline at end of file
+}