/** * jMICR - Java Device Driver for the Magtek Micro Check Scanner * http://www.magtek.com/products/check_reading/micrimage/micrimage.asp * * Copyright (C) 2004-2005 Caughey Consulting, Inc. * (www.caughey.com) * * Licensed under the terms of the GNU Lesser General Public License * (http://www.opensource.org/licenses/lgpl-license.php) * * For further information go to http://sourceforge.net/projects/jmicr/ * or contact michael@caughey.com. * * Test.java:Base Class used to test and demonstrate the function of the driver * Future Tests should be done by using JUnit * * Authors: * Michael J Caughey (michael@caughey.com) * * Versions: * 1.0.0 Initial Sourceforge Release * */ package com.sourceforge.jmicr.test; import com.sourceforge.jmicr.comm.*; import com.sourceforge.jmicr.magtek.*; import com.sourceforge.jmicr.magtek.micrimage.*; import com.sourceforge.jmicr.magtek.micrimage.types.*; public class Test { public Test() {} public static void pause(int seconds) { try { Thread.sleep(seconds * 1000); } catch (InterruptedException ex) { } } public static void main(String[] args) { MicrImageDevice micr = (MicrImageDevice) MagTekDeviceFactory.getInstance(). create(MagTekDeviceFactory. KEY_MICRIMAGE); try { // // Version // if (false) { System.out.println(micr.getVersion()); pause(1); } // // Serial Number // if (false) { System.out.println(micr.getSerialNumber()); pause(1); } // // Blink the light // if (false) { micr.setLED(160, 5); pause(1); } // // Set Disable Image // if (false) { micr.disableImage(); pause(5); } // // Set Enable image // if (false) { micr.enableImage(); pause(1); } // // Erase All Images // System.out.println("Erase All Images"); MemoryStatus ms = null; if (false) { ms = micr.eraseAllMemory(); System.out.println(""); pause(1); } // // Read the Check // System.out.println("Read the Check"); CheckInfo ci = null; if (true) { ci = micr.readCheck(); System.out.println("Routing Number = " + ci.routingNumber); System.out.println("Account Number = " + ci.accountNumber); System.out.println("Check Number = " + ci.checkNumber); System.out.println(""); pause(1); } // // Store the image // System.out.println("Store the image"); if (false) { ms = micr.storeImage(); System.out.println("Next Image = " + ms.nextImage); System.out.println("Stored Images = " + ms.storedImages); System.out.println("Bytes Available = " + ms.bytesRemaining); System.out.println(""); pause(1); } // // Get Image Status // System.out.println("Get Image Status"); ImageStatus is = null; if (true) { is = micr.getImageStatus(); System.out.println("Status = " + is.imageStatus); System.out.println("Compression = " + is.compression); System.out.println("ImageType = " + is.imageType); System.out.println("Size = " + is.size); System.out.println("Filename = " + is.filename); System.out.println(""); pause(1); } // // Check the Memory // System.out.println("Check the Memory"); if (false) { ms = micr.currentMemory(); System.out.println("Next Image = " + ms.nextImage); System.out.println("Stored Images = " + ms.storedImages); System.out.println("Bytes Available = " + ms.bytesRemaining); System.out.println(""); pause(1); } // // Get The Image // System.out.println("Get The Image"); if (true) { CheckImage checkImage = micr.readImage(is.size); pause(1); } } catch (CommPortException ex) { System.out.println(ex.getMessage()); } } }