You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2006/12/24 17:45:57 UTC

svn commit: r490040 - in /incubator/ofbiz/trunk/specialpurpose/pos: config/ src/org/ofbiz/pos/adaptor/ src/org/ofbiz/pos/device/impl/

Author: jleroux
Date: Sun Dec 24 08:45:57 2006
New Revision: 490040

URL: http://svn.apache.org/viewvc?view=rev&rev=490040
Log:
This fix closes "Character buffer is out of synch with enter key..." (https://issues.apache.org/jira/browse/OFBIZ-259). More explanations in the Jira issue.

Added:
    incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.properties   (with props)
Modified:
    incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties
    incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_es.properties
    incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties
    incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_it.properties
    incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_zh.properties
    incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.xml
    incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/adaptor/KeyboardAdaptor.java
    incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Scanner.java

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties?view=diff&rev=490040&r1=490039&r2=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties Sun Dec 24 08:45:57 2006
@@ -1,6 +1,7 @@
-####
+#####################################################################
 #
 # OFBiz XUI Properties file used for the XUI interface of the POS module (cf. XUI documentation)
+#
 # Copyright 2001-2006 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -16,6 +17,7 @@
 # under the License.
 #####################################################################
 Add=Add
+AmountInOut=Amount
 CASH=CASH
 CASH_DRAWER_COMMUNICATION_ERROR=CASH DRAWER COMMUNICATION ERROR
 CASH_DRAWER_IS_OPEN=CASH DRAWER IS OPEN
@@ -60,6 +62,7 @@
 RECEIPT_PRINTER_COMMUNICATION_ERROR=RECEIPT PRINTER COMMUNICATION ERROR
 REPRINT=REPRINT
 RESET_XUI=RESET XUI
+ReasonInOut=Reason
 Replace=Replace
 ReplaceAndDelete=<html><center>Replace and<br>delete
 SALE_DISC=SALE DISC
@@ -84,5 +87,3 @@
 problems_reading_card=PROBLEMS READING SWIPED CARD
 product_not_found=PRODUCT NOT FOUND
 promo_page=This will be the promo page!
-AmountInOut=Amount
-ReasonInOut=Reason
\ No newline at end of file

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_es.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_es.properties?view=diff&rev=490040&r1=490039&r2=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_es.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_es.properties Sun Dec 24 08:45:57 2006
@@ -1,4 +1,7 @@
 #####################################################################
+#
+# OFBiz XUI Properties file used for the XUI interface of the POS module (cf. XUI documentation)
+#
 # Copyright 2001-2006 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may not

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties?view=diff&rev=490040&r1=490039&r2=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties Sun Dec 24 08:45:57 2006
@@ -1,4 +1,4 @@
-####
+#####################################################################
 #
 # OFBiz XUI Properties file used for the XUI interface of the POS module (cf. XUI documentation)
 #
@@ -17,6 +17,7 @@
 # under the License.
 #####################################################################
 Add=Ajouter
+AmountInOut=Montant
 CASH=Esp\u00E8ces
 CASH_DRAWER_COMMUNICATION_ERROR=Erreur lors de la communication avec le tiroir caisse
 CASH_DRAWER_IS_OPEN=Le tiroir caisse est ouvert
@@ -61,6 +62,7 @@
 RECEIPT_PRINTER_COMMUNICATION_ERROR=Erreur lors de la communication avec l'imprimante de caisse
 REPRINT=R\u00E9afficher
 RESET_XUI=R\u00E9initialiser
+ReasonInOut=Raison
 Replace=Remplacer
 ReplaceAndDelete=<html><center>Remplacer et<br>supprimer
 SALE_DISC=Remise sur la vente
@@ -85,5 +87,3 @@
 problems_reading_card=Probl\u00E8me lors de la lecture de la carte
 product_not_found=Produit inconnu !
 promo_page=Ce sera la page des promotions...
-AmountInOut=Montant
-ReasonInOut=Raison
\ No newline at end of file

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_it.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_it.properties?view=diff&rev=490040&r1=490039&r2=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_it.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_it.properties Sun Dec 24 08:45:57 2006
@@ -1,5 +1,7 @@
 #####################################################################
 #
+# OFBiz XUI Properties file used for the XUI interface of the POS module (cf. XUI documentation)
+#
 # Copyright 2001-2006 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may not

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_zh.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_zh.properties?view=diff&rev=490040&r1=490039&r2=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_zh.properties (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_zh.properties Sun Dec 24 08:45:57 2006
@@ -1,4 +1,4 @@
-####
+#####################################################################
 #
 # OFBiz XUI Properties file used for the XUI interface of the POS module (cf. XUI documentation)
 #

Added: incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.properties?view=auto&rev=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.properties (added)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.properties Sun Dec 24 08:45:57 2006
@@ -0,0 +1,25 @@
+#####################################################################
+#
+# File used for the some specific parameters of JavaPOS implementation 
+#
+# Copyright 2001-2006 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#####################################################################
+
+# Defines if many bar codes may be sent in one message alone or only the 1st bar code keeped
+MultiBarCodesAllowed=Y
+# Defines the max waiting time between 2 bar code scanner messages sent  
+MaxWaitScanner=100
+# Defines the max waiting time between 2 key pressed
+MaxWaitKeyboard=10
\ No newline at end of file

Propchange: incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.properties
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.xml?view=diff&rev=490040&r1=490039&r2=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.xml (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/config/jpos.xml Sun Dec 24 08:45:57 2006
@@ -72,6 +72,21 @@
         <prop name="CodeType:UPCE" type="String" value="C"/>
         <prop name="CodeType:EAN13" type="String" value="E"/>
         <prop name="CodeType:EAN8" type="String" value="D"/>
+        
+        <!--Zebex predefined barcode identifiers (not implemented, should no be needed else see readCodeMap>
+        <prop name="BarcodeTypePosition" type="String" value="Prefix"/>        
+        <prop name="CodeType:CODE39" type="String" value="M"/>
+        <prop name="CodeType:ITF2OF5" type="String" value="I"/>
+        <prop name="CodeType:CHINESEPOSTCODE" type="String" value="H"/>
+        <prop name="CodeType:UPCE" type="String" value="E"/>                                    
+        <prop name="CodeType:UPCA" type="String" value="A"/>
+        <prop name="CodeType:EAN13" type="String" value="F"/>
+        <prop name="CodeType:EAN8" type="String" value="FF"/>        
+        <prop name="CodeType:CODABAR" type="String" value="N"/>
+        <prop name="CodeType:CODE128" type="String" value="K"/>
+        <prop name="CodeType:CODE93" type="String" value="L"/>
+        <prop name="CodeType:MSI" type="String" value="P"/>
+        <prop name="CodeType:MATRIX25" type="String" value="G"/-->                
     </JposEntry>
 
     <!-- Generic Keyboard Wedge MSR Device (included w/ OFBiz) -->
@@ -171,12 +186,12 @@
         <prop name="cashDrawer1" type="Boolean" value="true"/>
         <prop name="drawerClosedOnSignalLow" type="Boolean" value="false"/>
     </JposEntry>
-	
+
     <!-- Epson TM-T88III POSPrinter (requires epsonJposService180.jar, epsonJposServiceCommon.jar 
         in component://pos/lib (classpath references not needed)
-		 and JavaComm installed (javax.comm package). See http://www.javapos.com/devint.html about this point...
-		 pos-containers.xml must contains a reference to the logicalName : <property name="Receipt" value="TM-T88III"/>
-		 -->
+         and JavaComm installed (javax.comm package). See http://www.javapos.com/devint.html about this point...
+         pos-containers.xml must contains a reference to the logicalName : <property name="Receipt" value="TM-T88III"/>
+         -->
     <JposEntry logicalName="TM-T88III">
         <creation factoryClass="jp.co.epson.jpos180.util.EpsonJposServiceInstanceFactory" serviceClass="jp.co.epson.jpos180.ptr.T88III"/>
         <vendor name="SEIKO EPSON" url="http://www.epson.co.jp"/>
@@ -220,5 +235,5 @@
         <prop name="ServiceVersion" type="String" value="1.80"/>
         <prop name="flowControl" type="String" value="None"/>
         <prop name="FlowControl" type="String" value="1"/>
-	</JposEntry>
+    </JposEntry>
 </JposEntries>

Modified: incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/adaptor/KeyboardAdaptor.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/adaptor/KeyboardAdaptor.java?view=diff&rev=490040&r1=490039&r2=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/adaptor/KeyboardAdaptor.java (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/adaptor/KeyboardAdaptor.java Sun Dec 24 08:45:57 2006
@@ -25,6 +25,8 @@
 import java.util.Map;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
 
 import org.apache.commons.collections.map.LinkedMap;
 
@@ -114,7 +116,11 @@
 
     private class KeyboardListener extends Thread {
 
-        private static final long MAX_WAIT = 100;
+        public final Long MAX_WAIT_SCANNER = new Long(Long.parseLong(UtilProperties.getPropertyValue("jpos.properties", "MaxWaitScanner", "100")));
+        public final Long MAX_WAIT_KEYBOARD = new Long(Long.parseLong(UtilProperties.getPropertyValue("jpos.properties", "MaxWaitKeyboard", "10")));
+        // By default keyboard entry (login & password 1st)
+        public Long MAX_WAIT = MAX_WAIT_KEYBOARD;
+
         private List keyCodeData = new LinkedList();
         private List keyCharData = new LinkedList();
         private long lastKey = -1;
@@ -146,6 +152,9 @@
 
         protected synchronized void receiveChar(char keychar) {
             keyCharData.add(new Character(keychar));
+            if (keychar == '\2') {
+                MAX_WAIT = MAX_WAIT_SCANNER;
+            }
         }
 
         protected synchronized void sendData() {
@@ -177,6 +186,7 @@
                     keyCharData = new LinkedList();
                     keyCodeData = new LinkedList();
                     lastKey = -1;
+                    MAX_WAIT = MAX_WAIT_KEYBOARD;
                 }
             } else {
                 Debug.logWarning("No receivers configured for key input", module);
@@ -211,7 +221,7 @@
         public void run() {
             while (running) {
                 long now = System.currentTimeMillis();
-                if ((lastKey > -1) && (now - lastKey) >= MAX_WAIT) {
+                if ((lastKey > -1) && (now - lastKey) >= MAX_WAIT.intValue()) {
                     this.sendData();
                 }
 
@@ -219,7 +229,7 @@
                     break;
                 } else {
                     try {
-                        Thread.sleep(MAX_WAIT);
+                        Thread.sleep(MAX_WAIT.intValue());
                     } catch (InterruptedException e) {
                     }
                 }

Modified: incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Scanner.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Scanner.java?view=diff&rev=490040&r1=490039&r2=490040
==============================================================================
--- incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Scanner.java (original)
+++ incubator/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/device/impl/Scanner.java Sun Dec 24 08:45:57 2006
@@ -19,6 +19,7 @@
 import jpos.ScannerConst;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.pos.adaptor.DataEventAdaptor;
 import org.ofbiz.pos.device.GenericDevice;
 import org.ofbiz.pos.screen.PosScreen;
@@ -30,6 +31,7 @@
 
     protected String deviceName = null;
     protected int timeout = -1;
+    private static final boolean MULTI_BARCODES_ALLOWED = UtilProperties.propertyValueEqualsIgnoreCase("jpos.properties", "MultiBarCodesAllowed", "Y");
 
     public Scanner(String deviceName, int timeout) {
         super(deviceName, timeout);
@@ -80,13 +82,31 @@
                 Debug.logWarning("Scanner type checking problems - check scanner driver", module);
             }
 
-            // stuff the data to the Input component
-            PosScreen.currentScreen.getInput().clearInput();
-            PosScreen.currentScreen.getInput().appendString(new String(data));
-
-            // call the ENTER event
-            //this.callEnter();
-            MenuEvents.addItem(PosScreen.currentScreen, null);
+            // This deals with multi Bar Codes in one event alone. 
+            // For the moment it works only with barcode id  of 1 char (see ScannerKybService).
+            // I thought that javapos AutoDisable option should be the way but does not seem to work.
+            // At least with my Zebex handheld and seem also not implemented though present
+            // in Msr, Kbd ans Scanner services (see autoDisable, getAutoDisable, setAutoDisable).
+            // I also tried to use setDataEventEnabled around getScanDataLabel/Type without success
+            // Perhaps I'm missing something here, but have no more time to search...
+            // I saw in JavaPOS Doc somehting about supplemental barcode. I think it's ok
+            // because it seems that in this case the scanner is able to deliver only one label.
+            String toInput = new String(data) + "\n  "; 
+            while (toInput.indexOf("\n") > -1) {
+                int posCR = toInput.indexOf("\n");            
+                // stuff the data to the Input component                
+                PosScreen.currentScreen.getInput().clearInput();
+                PosScreen.currentScreen.getInput().appendString(toInput.substring(0, posCR));
+                
+                // At least one product recognized
+                MenuEvents.addItem(PosScreen.currentScreen, null);
+        
+                if (!MULTI_BARCODES_ALLOWED) {
+                    break;
+                }
+                // More products to add
+                toInput = toInput.substring(posCR+3);
+            }
         }
     }
 }