Class ScannerModule
Represents a module for a barcode scanner.
public class ScannerModule : InitializableCompositeModule, ICompositeModule, IInitializable, INotifyPropertyChangedEx, IHasServiceView, IScanner, ILisrtModule, INotifyPropertyChanged, IHasDeviceLabel
  - Inheritance
 - 
      
      PropertyChangedBaseScannerModule
 
- Implements
 - 
      
      
      INotifyPropertyChangedEx
 
- Inherited Members
 - 
    
    
    
    
    
    
    
    
    PropertyChangedBase.Refresh()PropertyChangedBase.IsNotifyingPropertyChangedBase.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
namestringThe name of the module.
communicationICommunicationThe communication port.
Exceptions
- ArgumentNullException
 Thrown when
communicationis null ornameis null, empty or whitespace.
Properties
DeviceLabel
Gets or sets the device label.
[Configuration("")]
public string DeviceLabel { get; set; }
  Property Value
Icon
Gets an icon which is representative for the module.
public override Uri Icon { get; }
  Property Value
InstanceID
Gets or sets the instance ID.
public int InstanceID { get; set; }
  Property Value
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
senderobjectThe ICommunication sender.
eDataReceivedEventArgsThe 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
Returns
- string
 The scanned code.
Exceptions
- NotInitializedException
 Thrown when the module is not initialized.
- ArgumentOutOfRangeException
 Thrown when
timeoutInMillisecondsis 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
timeoutInMillisecondshas elapsed.
WaitForCodeScanned(CancellationToken, int)
Waits until a barcode is scanned.
public virtual string WaitForCodeScanned(CancellationToken cancellationToken, int timeoutInMilliseconds = -1)
  Parameters
cancellationTokenCancellationTokenCancellation token to cancel the operation.
timeoutInMillisecondsintTimeout 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
timeoutInMillisecondsis 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
timeoutInMillisecondshas elapsed.- OperationCanceledException
 Thrown when
cancellationTokenis canceled.
Events
CodeScanned
Occurs when a code is scanned.
public event EventHandler<string> CodeScanned