Table of Contents

Class ScannerModule

Namespace
Loehnert.Lisrt.Scanner
Assembly
Loehnert.Lisrt.Scanner.dll

Represents a module for a barcode scanner.

public class ScannerModule : InitializableCompositeModule, ICompositeModule, IInitializable, INotifyPropertyChangedEx, IHasServiceView, IScanner, ILisrtModule, INotifyPropertyChanged, IHasDeviceLabel
Inheritance
PropertyChangedBase
ScannerModule
Implements
INotifyPropertyChangedEx
Inherited Members
PropertyChangedBase.Refresh()
PropertyChangedBase.IsNotifying
PropertyChangedBase.PropertyChanged
Extension Methods

Examples

This example shows how to use the ScannerModule with a serial port:

var serialPort = new SerialPortModule("RS232")
{
    Encoding = Encoding.ASCII,

    // The barcode scanner must be configured accordingly
    EndDelimiter = Encoding.ASCII.GetBytes("\r"),
};

new ScannerModule("Scanner", serialPort);

Constructors

ScannerModule(string, ICommunication)

Initializes a new instance of the ScannerModule class.

public ScannerModule(string name, ICommunication communication)

Parameters

name string

The name of the module.

communication ICommunication

The communication port.

Exceptions

ArgumentNullException

Thrown when communication is null or name is null, empty or whitespace.

Properties

DeviceLabel

Gets or sets the device label.

[Configuration("")]
public string DeviceLabel { get; set; }

Property Value

string

Icon

Gets an icon which is representative for the module.

public override Uri Icon { get; }

Property Value

Uri

InstanceID

Gets or sets the instance ID.

public int InstanceID { get; set; }

Property Value

int

Methods

Exit()

Deinitializes the module and its communication.

public override void Exit()

Initialize()

Initializes the module and its communication module.

public override void Initialize()

OnCommunicationDataReceived(object, DataReceivedEventArgs)

Executed on DataReceived event.

protected virtual void OnCommunicationDataReceived(object sender, DataReceivedEventArgs e)

Parameters

sender object

The ICommunication sender.

e DataReceivedEventArgs

The event args of the DataReceived event.

Remarks

Receives the string from ICommunication and invokes the CodeScanned event.

ShowServiceView()

Shows the service window.

public virtual void ShowServiceView()

WaitForCodeScanned(int)

Waits until a barcode is scanned.

public virtual string WaitForCodeScanned(int timeoutInMilliseconds)

Parameters

timeoutInMilliseconds int

Timeout in milliseconds. Use Infinite(-1) for a infinite timeout.

Returns

string

The scanned code.

Exceptions

NotInitializedException

Thrown when the module is not initialized.

ArgumentOutOfRangeException

Thrown when timeoutInMilliseconds is a negative number other than -1 milliseconds, which represents an infinite time-out. -or- The number of milliseconds in timeout is greater than MaxValue.

TimeoutException

Thrown when timeoutInMilliseconds has elapsed.

WaitForCodeScanned(CancellationToken, int)

Waits until a barcode is scanned.

public virtual string WaitForCodeScanned(CancellationToken cancellationToken, int timeoutInMilliseconds = -1)

Parameters

cancellationToken CancellationToken

Cancellation token to cancel the operation.

timeoutInMilliseconds int

Timeout in milliseconds. Use Infinite(-1) for an infinite timeout.

Returns

string

The scanned code.

Exceptions

NotInitializedException

Thrown when the module is not initialized.

ArgumentOutOfRangeException

Thrown when timeoutInMilliseconds is a negative number other than -1 milliseconds, which represents an infinite time-out. -or- The number of milliseconds in timeout is greater than MaxValue.

TimeoutException

Thrown when timeoutInMilliseconds has elapsed.

OperationCanceledException

Thrown when cancellationToken is canceled.

Events

CodeScanned

Occurs when a code is scanned.

public event EventHandler<string> CodeScanned

Event Type

EventHandler<string>