C# Imager Scan Engine API
Collaboration diagram for C# Imager Scan Engine API:

Modules

 Enumerations
 
 Events related with Imager Scan Engine
 
 Exceptions thrown by Imager Scan Engine
 

Classes

class  DeepsyImagerScanEngineManager
 Deepsy Image Scan Engine Manager. Allows to manage the funtionality for scanning and configuring all Imager Scan Engines plugged in the Deepsy system More...
 

Detailed Description

To work with Deepsy imager scan engine service it is necessary to use DeepyImagerScanEngineManager located in GMV.ITS.HAL.DEEPSY.Ise.Facade for getting the initial ImagerScanEngineManager object.

DeepyImagerScanEngineManager imagerScanEngineManager = new DeepyImagerScanEngineManager("192.168.1.10");


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:

try
{
DeepyImagerScanEngineManager imagerScanEngineManager = new DeepyImagerScanEngineManager("192.168.1.10");
List<IImagerScanEngine> imagerScanEnginesList = imagerScanEngineManager.GetImagerScanEngines();
}
catch (NotAvailableException e)
{
Console.WriteLine(e.Message);
}
catch (LowLevelException e)
{
Console.WriteLine(e.Message);
}
  To work with Deepsy imager scan engine service it is necessary to use DeepsyImagerScanEngineManager located in GMV.ITS.HAL.DEEPSY.Ise for getting the initial ImagerScanEngineManager object.
List<IImagerScanEngine> imagerScanEnginesList = imagerScanEngineManager.GetImagerScanEngines();


DeepsyImagerScanEngineManager has an optional parameter indicating the ip address of remote service. For instance:

string deepsyServerIp = "192.168.0.144";
DeepsyImagerScanEngineManager imagerScanEngineManager = new DeepsyImagerScanEngineManager(deepsyServerIp);



DeepsyImagerScanEngineManager is an IDisposable interface. An object that may hold resources (such as file or socket handles) until it is closed. The Dispose() method of an IDisposable object is called automatically when exiting a try-with-resources block, or exiting a using clause where it was declared. This construction ensures prompt release, avoiding resource exhaustion exceptions and errors that may otherwise occur:

using(DeepyImagerScanEngineManager imagerScanEngineManager = new DeepyImagerScanEngineManager("192.168.1.10"))
{
}


If this object is not inside a try with resources block, it is recommended to call to Dispose() in order to finalize properly;

imagerScanEngineManager.Dispose();

Service availability

To detect service availability the DeepsyImagerScanEngineManager implements methods for getting availability and subscribing to availability events.

class ImagerScanEngineEventsApp{
static void Main(string[] args)
{
DeepsyImagerScanEngineManager imagerScanEngineManager = new DeepsyImagerScanEngineManager("192.168.0.144");
imagerScanEngineManager.ImagerScanEngineStatus += MyImagerScanEngineStatusObserver;
}
private static void MyImagerScanEngineStatusObserver(object sender, DEEPSY.Ise.Interface.Event.ImagerScanEngineStatusEvent e)
{
Console.WriteLine($"Status event received from Imager Id {e.ImageScanEngine.Id}. Event: {e.Status}");
}
}


Examples

  • Getting available imager scan engines
    For getting available imager scan engines it is necessary to call to GetImagerScanEngines method of DeepsyImagerScanEngineManager.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    namespace GMV.ITS.HAL.DEEPSY.Examples.Ise
    {
    public class GetImagerScanEngineListApp
    {
    public static int Main(string[] args)
    {
    try
    {
    Console.WriteLine($"Imager Scan Engine. Get Imager Scan engine list");
    string deepsyServerIp = args.Length == 0 ? "192.168.0.144" : args[0];
    DeepsyImagerScanEngineManager imagerScanEngineManager = new DeepsyImagerScanEngineManager(deepsyServerIp);
    IEnumerable<IImagerScanEngine> imagerScanEnginesList = imagerScanEngineManager.ImagerScanEngines;
    Console.WriteLine($"There are {imagerScanEnginesList?.ToList().Count} imager scan engines.");
    return imagerScanEnginesList.ToList().Count;
    }
    catch (NotAvailableException ex)
    {
    Console.WriteLine($"Error NotAvailableException {ex.Message}");
    }
    catch (HalException deepsyEx)
    {
    Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");
    }
    catch (Exception ex)
    {
    Console.WriteLine($"Error Not Handled exception {ex.Message}");
    }
    return -1;
    }
    }
    }

  • 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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    namespace GMV.ITS.HAL.DEEPSY.Examples.Ise
    {
    class SetGetConfigurationApp
    {
    static void Main(string[] args)
    {
    try
    {
    Console.WriteLine($"Imager Scan Engine. Set-Get Configuration example");
    string deepsyServerIp = args.Length == 0 ? "192.168.0.144" : args[0];
    DeepsyImagerScanEngineManager imagerScanEngineManager = new DeepsyImagerScanEngineManager(deepsyServerIp);
    IEnumerable<IImagerScanEngine> imagerScanEnginesList = imagerScanEngineManager.GetImagerScanEngines();
    Console.WriteLine($"There are {imagerScanEnginesList?.ToList().Count} imager scan engines.");
    // Setting intial configuration
    foreach(IImagerScanEngine scanner in imagerScanEnginesList)
    {
    Console.WriteLine($"Set scanner configuration for Imager Scan Engine {scanner.Id}:");
    scanner.SetConfigBrightness(DEEPSY.Ise.Interface.Enum.ConfigBrightness.STANDARD);
    scanner.SetConfigIllumination(DEEPSY.Ise.Interface.Enum.ConfigIllumination.ENABLE);
    scanner.SetConfigImageRotation(DEEPSY.Ise.Interface.Enum.ConfigImageRotation.NONE);
    scanner.SetConfigReadMode(DEEPSY.Ise.Interface.Enum.ConfigReadMode.AUTOTRIGGER);
    scanner.SetConfigRereadTimeout(10);
    }
    //Read configuration for each imager
    foreach (IImagerScanEngine scanner in imagerScanEnginesList)
    {
    Console.WriteLine($"Get Scanner configuration for Imager Scan Engine {scanner.Id}:");
    Console.WriteLine($"Brightness: {scanner.GetConfigBrightness()}");
    Console.WriteLine($"Illumination: {scanner.GetConfigIllumination()}");
    Console.WriteLine($"ImageRotation: {scanner.GetConfigImageRotation()}");
    Console.WriteLine($"ReadMode: {scanner.GetConfigReadMode()}");
    Console.WriteLine($"RereadTimeout: {scanner.GetConfigRereadTimeout()}");
    }
    //Change the configuration and then check that it was modified
    foreach (IImagerScanEngine scanner in imagerScanEnginesList)
    {
    Console.WriteLine($"Set Scanner configuration for Imager Scan Engine {scanner.Id}:");
    scanner.SetConfigIllumination(DEEPSY.Ise.Interface.Enum.ConfigIllumination.BLINK);
    scanner.SetConfigRereadTimeout(20);
    }
    //Change the configuration and then check that it was modified
    foreach (IImagerScanEngine scanner in imagerScanEnginesList)
    {
    Console.WriteLine($"Get Scanner configuration for Imager Scan Engine {scanner.Id}:");
    Console.WriteLine($"Illumination: {scanner.GetConfigIllumination()}");
    Console.WriteLine($"RereadTimeout: {scanner.GetConfigRereadTimeout()}");
    }
    }
    catch (NotAvailableException ex)
    {
    Console.WriteLine($"Error NotAvailableException {ex.Message}");
    }
    catch (HalException deepsyEx)
    {
    Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");
    }
    catch (Exception ex)
    {
    Console.WriteLine($"Error Not Handled exception {ex.Message}");
    }
    }
    private static void MyImagerScanEngineNewCodeObserver(object sender, DEEPSY.Ise.Interface.Event.ImagerScanEngineNewCodeEvent e)
    {
    Console.WriteLine($"New code event received from Imager Id {e.ImageScanEngine.Id}. New code scanned: {e.Code}");
    }
    private static void MyImagerScanEngineStatusObserver(object sender, DEEPSY.Ise.Interface.Event.ImagerScanEngineStatusEvent e)
    {
    Console.WriteLine($"Status event received from Imager Id {e.ImageScanEngine.Id}. Event: {e.Status}");
    }
    private static void MyImagerScanEngineListObserver(object sender, DEEPSY.Ise.Interface.Event.ImagerScanEngineListEvent e)
    {
    Console.WriteLine($"Imager event received. Imager Id {e.ImageScanEngine.Id}. Action: {e.Action}");
    }
    }
    }

  • Subscribe to events
    There are 3 types of events in the imager scan engine system:

    • ImagerScanEngineList : 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 ImagerScanEngineListEvent
    • ImagerScanEngineStatus : 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 ImagerScanEngineStatusEvent
    • ImageScanEngineNewCode : 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 ImagerScanEngineNewCodeEvent

    This example subscribes to every event.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    namespace GMV.ITS.HAL.DEEPSY.Examples.Ise
    {
    class ImagerScanEngineEventsApp
    {
    static void Main(string[] args)
    {
    try
    {
    string deepsyServerIp = args.Length == 0 ? "192.168.0.144" : args[0];
    DeepsyImagerScanEngineManager imagerScanEngineManager = new DeepsyImagerScanEngineManager(deepsyServerIp);
    imagerScanEngineManager.ImagerScanEngineList += MyImagerScanEngineListObserver;
    IEnumerable<IImagerScanEngine> imagerScanEnginesList = imagerScanEngineManager.ImagerScanEngines;
    foreach(IImagerScanEngine imagerScanEngine in imagerScanEnginesList)
    {
    imagerScanEngine.ImagerScanEngineStatus += MyImagerScanEngineStatusObserver;
    imagerScanEngine.ImageScanEngineNewCode += MyImagerScanEngineNewCodeObserver;
    }
    Console.WriteLine($"There are {imagerScanEnginesList?.ToList().Count} imager scan engines.");
    Console.WriteLine("Press ESC for exit");
    while (Console.ReadKey().Key != ConsoleKey.Escape){
    }
    }
    catch(NotAvailableException ex)
    {
    Console.WriteLine($"Error NotAvailableException {ex.Message}");
    }
    catch (HalException deepsyEx)
    {
    Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");
    }
    catch (Exception ex)
    {
    Console.WriteLine($"Error Not Handled exception {ex.Message}");
    }
    }
    private static void MyImagerScanEngineNewCodeObserver(object sender, DEEPSY.Ise.Interface.Event.ImagerScanEngineNewCodeEvent e)
    {
    Console.WriteLine($"New code event received from Imager Id {e.ImageScanEngine.Id}. New code scanned: {e.Code}");
    }
    private static void MyImagerScanEngineStatusObserver(object sender, DEEPSY.Ise.Interface.Event.ImagerScanEngineStatusEvent e)
    {
    Console.WriteLine($"Status event received from Imager Id {e.ImageScanEngine.Id}. Event: {e.Status}");
    }
    private static void MyImagerScanEngineListObserver(object sender, DEEPSY.Ise.Interface.Event.ImagerScanEngineListEvent e)
    {
    Console.WriteLine($"Imager event received. Imager Id {e.ImageScanEngine.Id}. Action: {e.Action}");
    }
    }
    }