Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Control or inter-react with a device

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Control or inter-react with a device

    Hi Gurus

    I'm new in this forum and also it my first time to start create a device driver or control application.

    I've created a POS system now I'm trying to inter-react with the dispenser device so that it can listen to the commands from my application and perform the desired action. As I've said I'm new in this type of development and also I'm not a guru or master in java. I've used these codes as dispenser
     code.google.com/p/atm-using-java-dp-ref/source/browse/trunk/src/atm/CashDispenser.java?r=5
    So my question is that how can I get this to control the dispenser device so that it will start dispensing as per the client request after the validation of card, pin, etc. Any help, link, guideline, suggestion, sample will be appreciated.

    Thank you.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,132
    My Mood
    Mellow
    Thanks
    187
    Thanked 659 Times in 646 Posts

    Default Re: Control or inter-react with a device

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    What is the dispensing device? There should be a programmer's reference manual for the device that shows how to write code that interfaces with it - an API of sorts.

  3. #3
    Junior Member
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Control or inter-react with a device

    What I'm trying to do is create a POS which will work and support all the POS devices, now my problem is a way used to communicate or send commands direct to the device in java, I only need a method that let's software fire direct commands to a device such as
     openDoor()
    ,
    CloseDoor()
    to roll back in the cash tray on a counter,
    cashDispenser.dispense(amount);
    on ATM to dispense the amount chosen by customer after the account has been verified. In short I'm looking for a way of sending or communicating with devices direct as I've said I'm trying to create a POS system.

    Thank you

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,132
    My Mood
    Mellow
    Thanks
    187
    Thanked 659 Times in 646 Posts

    Default Re: Control or inter-react with a device

    What I'm trying to do is create a POS which will work and support all the POS devices
    I doubt that it's possible to create a program that will interface correctly with ALL POS devices.

    What you could do is is create method stubs that can be written later to interface correctly with a specific POS device but in the meantime simply describe what they'll do with print statements, like "Opening cash drawer," etc.

    OR, create a configuration file that contains the commands for the POS devices for which you can find APIs and refer to the configuration file in each of your methods that interface with the POS device, load the correct command for the attached device, and send that command to the device.

  5. #5
    Junior Member
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Control or inter-react with a device

    Quote Originally Posted by GregBrannon View Post
    I doubt that it's possible to create a program that will interface correctly with ALL POS devices.
    Well I'm not too sure and that is why I need let say a structure of how to normally do this. By referring to jpos I saw that they use a variable "LogicalDeviceName" but since I've never worked with device controlling before I'm having a problem on tracing the right files in jpos but I think jpos is capable of doing so, meaning of controlling any device because I think it first check the firmware of that particular device and assign its name to the variable "LogicalDeviceName" the structure for this in jpos if I will only look at BaseControl file goes as follows but I will only quote what looks like what I want in this file.
    // This is for a file named BaseJposControl
    public String getPhysicalDeviceName() throws JposException {
    // Make sure control is opened
    if(!bOpen)
    {
    throw new JposException(JposConst.JPOS_E_CLOSED, "Control not opened");
    }
    try
    {
    return service.getPhysicalDeviceName();
    }
    catch(JposException je)
    {
    throw je;
    }
    catch(Exception e)
    {
    throw new JposException(JposCosnt.JPOS_E_FAILURE, "Unhandled exception from Device Service", e);
    }
    }
     
    // Now the file BaseControl has the properties and methods which has implementation in BaseJposControl, I will look at the method directIO.
     
    // BaseControl
    public void directIO(int command, int[] data, Object object) throws JposException;
     
    // BaseJposControl
    public void directIO(int command, int[] data, Object object) throws JposException {
    // Make sure control is opened
    if(!bOpen)
    {
    throw new JposException(JposConst.JPOS_E_CLOSED, "Control not opened");
    }
    // Perform the operation
    try
    {
    service.directIO(command, data, object);
    }
    catch(JposException je)
    {
    throw je;
    }
    catch(Exception e)
    {
    throw new JposException(JposConst.JPOS_E_FAILURE, "Unhandled exception from Device Service", e);
    }
    }

    Now I did try to use the jpos but all the files which have service111 have error on their very first public line so I couldn't use it then but I tried to take the files like BaseControl, BaseJposControl, JposConst, etc. But the problem now is to use them in my own class I don't know how to because they have many files which need to be loaded so that they won't be any errors on a new project which I've used using the source found in the link on my very first post so that is why I was looking for a structure of communicating with the device so that I can be able to identify on these files the file that I can call or use in my class that will call the class to perform the desired task or send direct command to the device.

    Thank you.

Similar Threads

  1. GUI inter face
    By mrgregglles in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 9th, 2013, 10:36 AM
  2. KeyListener - how to make program react to the key that was pressed twice?
    By scorpas in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: November 28th, 2012, 07:19 AM
  3. How Should I React to Softpedia Using My Programs?
    By KevinWorkman in forum The Cafe
    Replies: 9
    Last Post: August 29th, 2012, 10:17 AM
  4. Inter-Servlet Communication
    By richip in forum Java Theory & Questions
    Replies: 1
    Last Post: June 4th, 2012, 03:30 AM

Tags for this Thread