Classes | |
enum | ConfigBrightness |
enum | ConfigDetectMode |
enum | ConfigIllumination |
enum | ConfigImageRotation |
enum | ConfigReadMode |
enum | ConfigSenseMode |
interface | ImagerScanEngine |
ImagerScanEngine. More... | |
interface | ImagerScanEngineEvent |
ImagerScanEngine event. More... | |
interface | ImagerScanEngineListEvent |
ImagerScanEngineListEvent Event. More... | |
interface | ImagerScanEngineListObserver |
Imager scan engine list observer. More... | |
class | ImagerScanEngineLowLevelException |
ImagerScanEngine low level exception. More... | |
interface | ImagerScanEngineManager |
ImagerScanEngine manager. More... | |
interface | ImagerScanEngineNewCodeEvent |
class | ImagerScanEngineNotAvailableException |
ImagerScanEngine not available exception. More... | |
interface | ImagerScanEngineObserver |
class | ImagerScanEngineStatusEvent |
ImagerScanEngine status change event. More... | |
Detailed Description
To work with Deepsy imager scan engine service it is necessary to use DeepsyImagerScanEngineManager located in com.gmv.its.deepsy.ise for getting the initial ImagerScanEngineManager object.
DeepsyImagerScanEngineManager.getInstance has an optional parameter indicating the ip address of remote service. For instance:
DeepsyImagerScanEngineManager is an AutoCloseable interface. An object that may hold resources (such as file or socket handles) until it is closed. The close() method of an AutoCloseable object is called automatically when exiting a try-with-resources block for which the object has been declared in the resource specification header. This construction ensures prompt release, avoiding resource exhaustion exceptions and errors that may otherwise occur. To obtain ImagerScanEngine objects:
If this object is not inside a try with resources block, it is recommended to call to imagerScanEngineManager.close() in order to finalize properly;
Service availability
To detect service availability the DeepsyImagerScanEngineManager implements Manager interface which provides methods for getting availability and subscribing to availability events.
Examples
-
Getting available imager scan engines
For getting available imager scan engines it is necessary to call to getImagerScanEngines method of ImagerScanEngineManager.import java.util.List;public class App {public static void main(String[] args) {try (DeepsyImagerScanEngineManager imagerScanEngineManager = DeepsyImagerScanEngineManager.getInstance("192.168.1.10")) {List<ImagerScanEngine> imagerScanEngineList = imagerScanEngineManager.getImagerScanEngines();} catch (ImagerScanEngineNotAvailableException e) {e.printStackTrace();} catch (ImagerScanEngineLowLevelException e) {e.printStackTrace();}}}
-
Set and Get Imager scan engine configuration
Getting configurations functionality is provided by getConfig methods.- ImagerScanEngine.getConfigBrightness
- ImagerScanEngine.getConfigIllumination
- ImagerScanEngine.getConfigImageRotation
- ImagerScanEngine.getConfigReadMode
-
Set imager scan engine configuration
Setting configurations functionality is provided by setConfig methods.- ImagerScanEngine.setConfigBrightness
- ImagerScanEngine.setConfigIllumination
- ImagerScanEngine.setConfigImageRotation
- ImagerScanEngine.setConfigReadMode
package com.gmv.its.dpyjavaexamples.ise;import java.util.List;public class setGetConfigurationApp {public static void main(String[] args) {try (DeepsyImagerScanEngineManager imagerScanEngineManager = DeepsyImagerScanEngineManager.getInstance("192.168.0.84")) {List<ImagerScanEngine> imagerScanEnginesList = imagerScanEngineManager.getImagerScanEngines();for (ImagerScanEngine scanner : imagerScanEnginesList) {scanner.setConfigBrightness(ConfigBrightness.STANDARD);scanner.setConfigIllumination(ConfigIllumination.ENABLE);scanner.setConfigImageRotation(ConfigImageRotation.NONE);scanner.setConfigReadMode(ConfigReadMode.AUTOTRIGGER);scanner.setConfigRereadTimeout(1000);}for (ImagerScanEngine scanner : imagerScanEnginesList) {System.out.println("Scanner configuration: ");System.out.println("Brightness: " + scanner.getConfigBrightness().name());System.out.println("Illumination: " + scanner.getConfigIllumination().name());System.out.println("ImageRotation: " + scanner.getConfigImageRotation().name());System.out.println("ReadMode: " + scanner.getConfigReadMode().name());System.out.println("RereadTimeout: " + scanner.getConfigRereadTimeout());}} catch (ImagerScanEngineNotAvailableException e) {e.printStackTrace();} catch (ImagerScanEngineLowLevelException e) {e.printStackTrace();}}}
-
Subscribe to events
There are 3 types of events in the imager scan engine system:- ImagerScanEngineListEvent : This event happens when a imagerScanEngine is added to or removed from the system. To receive this kind of events, it is necessary to subscribe to the ImagerScanEngineManager object with an object implementing interface ImagerScanEngineListObserver
- ImagerScanEngineStatusEvent : This event happens when a imagerScanEngine status changes. To receive this kind of events, it is necessary to subscribe to the ImagerScanEngine object with an object implementing interface ImagerScanEngineObserver
- ImagerScanEngineNewCodeEvent : This event happens when a imagerScanEngine scans a new code. To receive this kind of events, it is necessary to subscribe to the ImagerScanEngine object with an object implementing interface ImagerScanEngineObserver
This example subscribes to every event.
package com.gmv.its.dpyjavaexamples.ise;import java.util.List;class MyImagerScanEngineListObserver implements ImagerScanEngineListObserver {public void notify(ImagerScanEngineListEvent event) {System.out.println("Imager scan engine " + event.getAction().name());}}class MyImagerScanEngineObserver implements ImagerScanEngineObserver {public void notify(ImagerScanEngineEvent event) {if (event instanceof ImagerScanEngineNewCodeEvent) {System.out.println("New code: " + ((ImagerScanEngineNewCodeEvent) event).getCode());} else if (event instanceof ImagerScanEngineStatusEvent) {System.out.println("New Status: " + ((ImagerScanEngineStatusEvent) event).getStatus().name());}}}public class ImagerScanEngineEventsApp {public static void main(String[] args) {try (DeepsyImagerScanEngineManager imagerScanEngineManager = DeepsyImagerScanEngineManager.getInstance("192.168.0.144")) {imagerScanEngineManager.subscribe(new MyImagerScanEngineListObserver());List<ImagerScanEngine> imagerScanEnginesList = imagerScanEngineManager.getImagerScanEngines();for (ImagerScanEngine scanner : imagerScanEnginesList) {scanner.subscribe(new MyImagerScanEngineObserver());}Thread.sleep(10000);} catch (ImagerScanEngineNotAvailableException e) {e.printStackTrace();} catch (ImagerScanEngineLowLevelException e) {e.printStackTrace();} catch (CannotSubscribeException e) {e.printStackTrace();} catch (InterruptedException e) {e.printStackTrace();}}}