简体   繁体   中英

Is it possible to interact with JavaPOS device using PHP POS in a simplistic manner?

We have a POS written in PHP which needs to interact with a POS printer. The printer support JavaPOS. The state of PHP POS is that it generates a bill and waits for a user to select a printer.

The issue now is, the JavaPOS printer doesn't show up. I am able to interact with using test Java code which has the necessary drivers & jpos.xml. I wish to 'install' this.

From my understanding for past four days going through JavaPOS manuals from different manufactures [EPSON, Starmicronics, Diebold Nixdorfag ], it is not possible. JavaPOS is meant for POS system written in Java [JavaFX to Spring].

But I find it very odd to believe this. I believe this shouldn't be the case because if this true, it would make very hard for POS not written in Java or .Net to interact with plethora of POS devices and terminal out there.

Hence, is it possible to interact with non Java & non .Net POS to send print command to JavaPOS device?

Please note, simply installing the device and sending a print command doesn't fix the issue. Say, if I want to add a logo to the receipt along with dynamic data in the footer of the receipt, Java code will be required for .Net to make it 'rich'. Now, where does this Java code specifically sit? Is it some virtual device which runs in the background and pretends to be a printer and shows up in the print dialog in a, say PHP POS?

Sample Java code written to interact with JavaPOS with jpos.xml file as reference.

public static void main(String[] args) {
    File f = new File(PrintFTest.class.getClassLoader().getResource("jpos.xml").getPath());

    System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, f.getAbsolutePath());
    //System.getProperties().list(System.out);
    FiscalPrinter fiscalPrinter = new FiscalPrinter();

    // Get Access to it
    try {
        fiscalPrinter.open("printf");
        fiscalPrinter.claim(1000);
        fiscalPrinter.setDeviceEnabled(true);
    } catch (JposException e) {
        System.out.println("Exception at Access");
        e.printStackTrace();
    }

    // Print 
    try {
        fiscalPrinter.resetPrinter();
        fiscalPrinter.beginFiscalReceipt(true);
        fiscalPrinter.printRecItem("Salame", 40000, 0, 0, 0, "");
        fiscalPrinter.printRecTotal(40000, 40000, "CONTANTI");
        fiscalPrinter.endFiscalReceipt(false);
    } catch (JposException e) {
        System.out.println("Exception at Print");
    }

    try {
        System.out.println("1FP - Fiscal Printer disabling");
        fiscalPrinter.setDeviceEnabled(false);
        System.out.println("2FP - Fiscal Printer releasing");
        fiscalPrinter.release();
        System.out.println("2FP - Fiscal Printer closing");
        fiscalPrinter.close();
    } catch (JposException e) {
        System.out.println("Exception at Close");
    }

}

}

It should contain the installation/setup/configuration method in the JavaPOS provided by each printer vendor and its user's manual.

Please install and configure equipment and software accordingly.

However, in general, JavaPOS printers are rarely recognized as standard printer devices for their respective operating systems.

For example, there is such an article.
Getting started with Java POS development
JavaPOS Working Group

Next, it is recommended that you use these programs to operate and verify the printer only in the Java environment.
emigonza/POStest
ntsggr/JavaPOS-POStest-2

There are several ways to use Java from PHP as follows.
PHP/Java Integration
Using PHP-Java Bridges with WebLogic Server
What is the PHP/Java Bridge?
How it works
Java Bridge
How to call custom java methods from PHP?

There is no problem if it can be solved by the above method, but I recommend the following method.

  • Combine the Java program and JavaPOS to create a program that runs standalone.
  • The program provides functions similar to POS processing units such as "receipt printing".
  • This program communicates with PHP's POS in a simple and light way such as a bare TCP/IP socket, so that request issuance, completion notification or completion confirmation can be performed asynchronously.

In Addition:

The following is an example of a POS application that is entirely made in Java.
Since these are open source, it seems to be a reference for programming.
However, it is unknown whether JavaPOS control is used or not.

Openbravo Java POS
Floreant POS

The following is an example of an open source POS application written in PHP.
Probably JavaPOS will not be used.

OpenSourcePOS
WallacePOS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM