com.epson.EpsonCom
Class EpsonComDevice

java.lang.Object
  extended by com.epson.EpsonCom.EpsonComDevice

public class EpsonComDevice
extends java.lang.Object

EpsonComDevice Class


Constructor Summary
EpsonComDevice()
          Constructor
 
Method Summary
 EpsonCom.ERROR_CODE activateASB(java.lang.Boolean drawer, java.lang.Boolean onoffline, java.lang.Boolean error, java.lang.Boolean paper, java.lang.Boolean slip, java.lang.Boolean panelbutton)
          activateASB activates the automatic status transmission.
 EpsonCom.ERROR_CODE cancelWaitForSlip()
          cancelWaitForSlip Closes and releases the port object
 EpsonCom.ERROR_CODE checkAndSetImageParameters(int checkOrCard)
          checkAndSetImageParameters checks the image parameters and if ok, sets them
 EpsonCom.ERROR_CODE closeDevice()
          closeDevice closes and releases the port object
 EpsonCom.ERROR_CODE cutPaper()
          cutPaper cuts the paper at the current position
 EpsonCom.ERROR_CODE deleteCropArea(int num)
          deleteCropArea deletes one crop area
 EpsonCom.ERROR_CODE ejectCheck()
          ejectCheck Ejects the check.
 EpsonCom.ERROR_CODE feedSlipToPrintStartPosition()
          feedSlipToPrintStartPosition feeds the slip to the print starting position according to the selected side
 EpsonComASBStatus getASB()
          getASB returns the most recently received ASB (Automatic Status Back)
 byte getDeviceStatus()
          getDeviceStatus Returns the previously requested real-time status
 java.util.Vector<java.lang.Byte> getImageData()
          getImageData returns the previously scanned image data from the image buffer
 byte[] getImageDataBytes()
          getImageDataBytes returns the previously scanned image data from the image buffer as a byte[]
 java.lang.String getMICRString()
          getMICRString returns the previously read MICR string from the MICR buffer
 java.util.Vector<java.lang.Byte> getReceivedData()
          getReceivedData Reads available data out of the receive buffer
 java.lang.Boolean isDeviceOpen()
          isDeviceOpen checks if the device is currently open and ready to receive data
 EpsonCom.ERROR_CODE openDevice()
          openDevice Creates and opens the port object.
 EpsonCom.ERROR_CODE printPage(int mode)
          printPage Finishes a page-mode page and prints it It also ejects any slip that was printed on even when this was not in page mode
 EpsonCom.ERROR_CODE printString(java.lang.String string, EpsonCom.FONT font, java.lang.Boolean bold, java.lang.Boolean underlined, java.lang.Boolean doubleHeight, java.lang.Boolean doubleWidth)
          printString Prints a one-line string with specific formatting
 EpsonCom.ERROR_CODE readMICR(EpsonCom.MICR_FONT font, java.lang.Boolean waitforanswer, int timeout)
          readMICR initiates the check (MICR) reading the result can be obtained by using the getMICR command
 EpsonCom.ERROR_CODE readMICRScanCheck(EpsonCom.MICR_FONT font, java.lang.Boolean waitforanswer, int timeout)
          readMICRScanCheck initiates check (MICR) reading followed by a check image scan if callback is registered, it will result in getting two callbacks, one for MICR and one for the image
 EpsonCom.ERROR_CODE registerCallback(CallbackInterface callback)
          registerCallback registers a callback function to be called when data arrives at the port
 EpsonCom.ERROR_CODE requestDeviceStatus(int type, java.lang.Boolean waitforanswer, int timeout)
          requestDeviceStatus requests the current real-time device status from the device the result can be obtained by using the command getDeviceStatus
 EpsonCom.ERROR_CODE resetDevice()
          resetDevice resets the printer
 EpsonCom.ERROR_CODE scanCheck(java.lang.Boolean waitforanswer, int timeout)
          scanCheck Initiates the check scanning (callback must be registered in order to receive the actual image data)
 EpsonCom.ERROR_CODE scanIDCard(java.lang.Boolean waitforanswer, int timeout)
          scanIDCard initiates the ID card scanning (callback must be registered in order to receive the actual image data)
 EpsonCom.ERROR_CODE selectAlignment(EpsonCom.ALIGNMENT alignment)
          selectAlignment selects the print alignment
 EpsonCom.ERROR_CODE selectImageFormat(EpsonCom.IMAGEFORMAT format)
          selectImageFormat selects the image format which will be used to return the image data after the next scan
 EpsonCom.ERROR_CODE selectPageMode()
          selectPageMode switches the printer into page mode.
 EpsonCom.ERROR_CODE selectPrintDirection(EpsonCom.PRINTDIRECTION direction)
          selectPrintDirection selects the print direction (for page mode only!)
 EpsonCom.ERROR_CODE selectReceiptPaper()
          selectReceiptPaper selects the paper type to print on
 EpsonCom.ERROR_CODE selectSlipPaper(EpsonCom.PAPERSIDE side)
          selectSlipPaper selects the slip as active paper and sets on which side to print on
 EpsonCom.ERROR_CODE sendCommand(java.lang.String command)
          sendCommand sends an ESC/POS command to the printer
 EpsonCom.ERROR_CODE sendData(java.util.Vector<java.lang.Byte> data)
          sendData sends binary data to the port
 EpsonCom.ERROR_CODE setCropArea(int num, int x1, int y1, int x2, int y2)
          setCropArea sets one crop area, defined by two diagonal coordinates
 EpsonCom.ERROR_CODE setDeviceParameters(EpsonComDeviceParameters params)
          setDeviceParameters Sets the device parameters.
 EpsonCom.ERROR_CODE setImageParameters(EpsonCom.BITDEPTH bitdepth, EpsonCom.IMAGEPROCESSING imageprocessing, int threshold)
          setImageParameters sets the parameters data tone, image processing and threshold
 EpsonCom.ERROR_CODE setScanArea(int x1, int y1, int x2, int y2)
          setScanArea sets the scan area, defined by two diagonal coordinates
 EpsonCom.ERROR_CODE unregisterCallback()
          unregisterCallback unregisters the callback function.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EpsonComDevice

public EpsonComDevice()
Constructor

Method Detail

setDeviceParameters

public EpsonCom.ERROR_CODE setDeviceParameters(EpsonComDeviceParameters params)
setDeviceParameters Sets the device parameters. This is needed before a device is opened with the openDevice command.

Parameters:
params - DeviceParameters object
Returns:
SUCCESS or INVALID_PORT_TYPE, INVALID_PORT_NAME, INVALID_PORT_NUMBER or INVALID_IP_ADDRESS

openDevice

public EpsonCom.ERROR_CODE openDevice()
openDevice Creates and opens the port object. Any parameter needs to be set before this call using the setDeviceParameters method.

Returns:
SUCCESS or FAILED or any other of the port parameter errors

closeDevice

public EpsonCom.ERROR_CODE closeDevice()
closeDevice closes and releases the port object

Returns:
SUCCESS or FAILED

isDeviceOpen

public java.lang.Boolean isDeviceOpen()
isDeviceOpen checks if the device is currently open and ready to receive data

Returns:
rue = device is currently open false = device is currently not open

sendData

public EpsonCom.ERROR_CODE sendData(java.util.Vector<java.lang.Byte> data)
sendData sends binary data to the port

Parameters:
data - the binary data to be sent
Returns:
SUCCESS or FAILED

sendCommand

public EpsonCom.ERROR_CODE sendCommand(java.lang.String command)
sendCommand sends an ESC/POS command to the printer

Parameters:
command - String with the command, this can be any ESC/POS command, consisting of values separated by a space. Values can be single characters, strings in quotes, decimal or hex numbers. Examples: "Hello Printer" LF GS I 67
Returns:
SUCCESS or FAILED

getReceivedData

public java.util.Vector<java.lang.Byte> getReceivedData()
getReceivedData Reads available data out of the receive buffer

Returns:
Vector with the received data or null if no valid Port object

requestDeviceStatus

public EpsonCom.ERROR_CODE requestDeviceStatus(int type,
                                               java.lang.Boolean waitforanswer,
                                               int timeout)
requestDeviceStatus requests the current real-time device status from the device the result can be obtained by using the command getDeviceStatus

Parameters:
type - type of status: - 0=cut sheet, - 1=printer, - 2=offline cause, - 3=error cause, - 4=roll paper sensor, - 5=slip, - 6=MICR, - 7=card image scanner
waitforanswer - true if this function shall wait until the device status has arrived from the printer
timeout - if waitForAnswer==true, this specifies the timeout period in seconds
Returns:
>=0 = status or FAILED, TIMEOUT

getDeviceStatus

public byte getDeviceStatus()
getDeviceStatus Returns the previously requested real-time status

Returns:
one byte with the one-byte real-time status, or -1 if error

activateASB

public EpsonCom.ERROR_CODE activateASB(java.lang.Boolean drawer,
                                       java.lang.Boolean onoffline,
                                       java.lang.Boolean error,
                                       java.lang.Boolean paper,
                                       java.lang.Boolean slip,
                                       java.lang.Boolean panelbutton)
activateASB activates the automatic status transmission. The printer will now send ASB messages whenever it's status changes

Parameters:
drawer - true to activate ASB for this status
onoffline - true to activate ASB for this status
error - true to activate ASB for this status
paper - true to activate ASB for this status
slip - true to activate ASB for this status
panelbutton - true to activate ASB for this status
Returns:
SUCCESS or FAILED

readMICR

public EpsonCom.ERROR_CODE readMICR(EpsonCom.MICR_FONT font,
                                    java.lang.Boolean waitforanswer,
                                    int timeout)
readMICR initiates the check (MICR) reading the result can be obtained by using the getMICR command

Parameters:
font - E13B, CMC7
waitforanswer - true if this function shall wait until the MICR string has arrived from the printer
timeout - if waitForAnswer==true, this specifies the timeout period in seconds
Returns:
SUCCESS, FAILED or INVALID_FONT

getASB

public EpsonComASBStatus getASB()
getASB returns the most recently received ASB (Automatic Status Back)

Returns:
ASBStatus object with the most recently received ASB status

getMICRString

public java.lang.String getMICRString()
getMICRString returns the previously read MICR string from the MICR buffer

Returns:
String with the MICR string or null if no MICR is available

getImageData

public java.util.Vector<java.lang.Byte> getImageData()
getImageData returns the previously scanned image data from the image buffer

Returns:
Vector with the image data or null if no data is available

getImageDataBytes

public byte[] getImageDataBytes()
getImageDataBytes returns the previously scanned image data from the image buffer as a byte[]

Returns:
byte[] with the image data or null if no data is available

setImageParameters

public EpsonCom.ERROR_CODE setImageParameters(EpsonCom.BITDEPTH bitdepth,
                                              EpsonCom.IMAGEPROCESSING imageprocessing,
                                              int threshold)
setImageParameters sets the parameters data tone, image processing and threshold

Parameters:
bitdepth -
imageprocessing -
threshold - -128..+127, standard value = 0
Returns:
SUCCESS, FAILED, INVALID_BIT_DEPTH, INVALID_IMAGE_PROCESSING or INVALID_THRESHOLD.

setScanArea

public EpsonCom.ERROR_CODE setScanArea(int x1,
                                       int y1,
                                       int x2,
                                       int y2)
setScanArea sets the scan area, defined by two diagonal coordinates

Parameters:
x1 - upper left corner
y1 - upper left corner
x2 - lower right corner
y2 - lower right corner
Returns:
SUCCESS, FAILED or INVALID_SCAN_AREA

setCropArea

public EpsonCom.ERROR_CODE setCropArea(int num,
                                       int x1,
                                       int y1,
                                       int x2,
                                       int y2)
setCropArea sets one crop area, defined by two diagonal coordinates

Parameters:
num - index of the crop area 1..10
x1 - upper left corner
y1 - upper left corner
x2 - lower right corner
y2 - lower right corner
Returns:
SUCCESS, FAILED, INVALID_CROP_AREA_INDEX or INVALID_CROP_AREA

deleteCropArea

public EpsonCom.ERROR_CODE deleteCropArea(int num)
deleteCropArea deletes one crop area

Parameters:
num - index of the crop area 1..10 to be deleted
Returns:
SUCCESS, FAILED or INVALID_CROP_AREA_INDEX

selectImageFormat

public EpsonCom.ERROR_CODE selectImageFormat(EpsonCom.IMAGEFORMAT format)
selectImageFormat selects the image format which will be used to return the image data after the next scan

Parameters:
format - image format: - RAW, raw data, no header, uncompressed - BMP, BMP uncompressed - TIFF, TIFF uncompressed (gray-scale only) - TIFF_COMP, TIFF with CCITT Grp4 compression (b/w only) - JPEG_HIGH, JPEG with high compression rate (gray-scale only) - JPEG_MED, JPEG with standard compression rate (gray-scale only) - JPEG_LOW JPEG with low compression rate (gray-scale only)
Returns:
SUCCESS, FAILED or INVALID_IMAGE_FORMAT

selectReceiptPaper

public EpsonCom.ERROR_CODE selectReceiptPaper()
selectReceiptPaper selects the paper type to print on

Returns:
SUCCESS or FAILED

selectSlipPaper

public EpsonCom.ERROR_CODE selectSlipPaper(EpsonCom.PAPERSIDE side)
selectSlipPaper selects the slip as active paper and sets on which side to print on

Parameters:
side - side to print on: FRONT or BACK
Returns:
SUCCESS or FAILED or INVALID_PAPER_SIDE

selectAlignment

public EpsonCom.ERROR_CODE selectAlignment(EpsonCom.ALIGNMENT alignment)
selectAlignment selects the print alignment

Parameters:
alignment - LEFT, CENTER, RIGHT
Returns:
SUCCESS, FAILED or INVALID_JUSTIFICATION

selectPageMode

public EpsonCom.ERROR_CODE selectPageMode()
selectPageMode switches the printer into page mode. To print, call printPage.

Returns:
SUCCESS or FAILED

selectPrintDirection

public EpsonCom.ERROR_CODE selectPrintDirection(EpsonCom.PRINTDIRECTION direction)
selectPrintDirection selects the print direction (for page mode only!)

Parameters:
direction - LEFTTORIGHT, BOTTOMTOTOP, RIGHTTOLEFT, TOPTOBOTTOM
Returns:
SUCCESS, FAILED or INVALID_PRINT_DIRECTION

feedSlipToPrintStartPosition

public EpsonCom.ERROR_CODE feedSlipToPrintStartPosition()
feedSlipToPrintStartPosition feeds the slip to the print starting position according to the selected side

Returns:
SUCCESS or FAILED

ejectCheck

public EpsonCom.ERROR_CODE ejectCheck()
ejectCheck Ejects the check. This is necessary after a MICR read operation.

Returns:
SUCCESS or FAILED

cancelWaitForSlip

public EpsonCom.ERROR_CODE cancelWaitForSlip()
cancelWaitForSlip Closes and releases the port object

Returns:
SUCCESS or FAILED

printString

public EpsonCom.ERROR_CODE printString(java.lang.String string,
                                       EpsonCom.FONT font,
                                       java.lang.Boolean bold,
                                       java.lang.Boolean underlined,
                                       java.lang.Boolean doubleHeight,
                                       java.lang.Boolean doubleWidth)
printString Prints a one-line string with specific formatting

Parameters:
string - string to be printed
font - FONT_A, FONT_B
bold - true=bold, false=normal
underlined - true=underlined, false=not underlined
doubleHeight - true=double height, false=single height
doubleWidth - true=double width, false=single width
Returns:
SUCCESS, FAILED or INVALID_FONT

printPage

public EpsonCom.ERROR_CODE printPage(int mode)
printPage Finishes a page-mode page and prints it It also ejects any slip that was printed on even when this was not in page mode

Parameters:
mode - - 0 = print current page and exit page mode - 1 = print current page and stay in page mode
Returns:
SUCCESS, FAILED or INVALID_PRINT_PAGE_MODE

cutPaper

public EpsonCom.ERROR_CODE cutPaper()
cutPaper cuts the paper at the current position

Returns:
SUCCESS or FAILED

scanCheck

public EpsonCom.ERROR_CODE scanCheck(java.lang.Boolean waitforanswer,
                                     int timeout)
scanCheck Initiates the check scanning (callback must be registered in order to receive the actual image data)

Parameters:
waitforanswer - true if this function shall wait until the image data has arrived from the printer
timeout - if waitForAnswer==true, this specifies the timeout period in seconds
Returns:
SUCCESS, FAILED, INVALID_PARAMETER_COMBINATION or TIMEOUT

readMICRScanCheck

public EpsonCom.ERROR_CODE readMICRScanCheck(EpsonCom.MICR_FONT font,
                                             java.lang.Boolean waitforanswer,
                                             int timeout)
readMICRScanCheck initiates check (MICR) reading followed by a check image scan if callback is registered, it will result in getting two callbacks, one for MICR and one for the image

Parameters:
font - E13B or CMC7
waitforanswer - true if this function shall wait until the MICR string and the image data has arrived from the printer
timeout - if waitForAnswer==true, this specifies the timeout period in seconds
Returns:
SUCCESS, FAILED, INVALID_FONT or INVALID_PARAMETER_COMBINATION

scanIDCard

public EpsonCom.ERROR_CODE scanIDCard(java.lang.Boolean waitforanswer,
                                      int timeout)
scanIDCard initiates the ID card scanning (callback must be registered in order to receive the actual image data)

Parameters:
waitforanswer - true if this function shall wait until the image data has arrived from the printer
timeout - if waitForAnswer==true, this specifies the timeout period in seconds
Returns:
SUCCESS, FAILED, INVALID_PARAMETER_COMBINATION or INVALID_PARAMETER_FOR_CARDSCAN

resetDevice

public EpsonCom.ERROR_CODE resetDevice()
resetDevice resets the printer

Returns:
SUCCESS or FAILED

registerCallback

public EpsonCom.ERROR_CODE registerCallback(CallbackInterface callback)
registerCallback registers a callback function to be called when data arrives at the port

Parameters:
callback - object of a class that implements the CallbackInterface interface
Returns:
SUCCESS or INVALID_CALLBACK_OBJECT

unregisterCallback

public EpsonCom.ERROR_CODE unregisterCallback()
unregisterCallback unregisters the callback function.

Returns:

checkAndSetImageParameters

public EpsonCom.ERROR_CODE checkAndSetImageParameters(int checkOrCard)
checkAndSetImageParameters checks the image parameters and if ok, sets them

Parameters:
checkOrCard - 0=check, 1=card
Returns:
SUCCESS, FAILED, INVALID_IMAGE_FORMAT, INVALID_PARAMETER_COMBINATION or INVALID_PARAMETER_FOR_CARDSCAN