Class ScanSystem
A complete system of ScanHeads.
Namespace: JoeScan.Pinchot
Assembly: JoeScan.Pinchot.dll
Syntax
public class ScanSystem : IDisposable
Remarks
This class represents a complete scan system. It contains a collection of ScanHead objects, and provides properties and methods for adding ScanHeads, accessing the ScanHeads, connecting/disconnecting to/from the ScanHeads, and starting/stopping scanning on the ScanHeads.
Constructors
| Improve this Doc View SourceScanSystem(ScanSystemUnits)
Initializes a new instance of the scan system class.
Declaration
public ScanSystem(ScanSystemUnits units)
Parameters
Type | Name | Description |
---|---|---|
ScanSystemUnits | units | The units that this scan system and all associated ScanHeads will use. |
Properties
| Improve this Doc View SourceIsConfigured
Obtains the configuration state of the scan system. If true
, the system's configuration has
already been sent to the scan head via PreSendConfiguration().
If false
, the configuration will be sent when StartScanning(UInt32, DataFormat, ScanningMode) is called and there
will be a time penalty before receiving profiles.
Declaration
public bool IsConfigured { get; }
Property Value
Type | Description |
---|---|
Boolean | A |
IsConnected
Gets a value indicating whether all ScanHeads have established network connection.
Declaration
public bool IsConnected { get; }
Property Value
Type | Description |
---|---|
Boolean | A value indicating whether all ScanHeads have established network connection. |
IsScanning
Gets a value indicating whether the scan system is actively scanning.
Declaration
public bool IsScanning { get; }
Property Value
Type | Description |
---|---|
Boolean | A value indicating whether the scan system is actively scanning. |
ScanHeads
Gets a read-only collection of ScanHeads belonging to the scan system.
Declaration
public IReadOnlyCollection<ScanHead> ScanHeads { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<ScanHead> | A |
Units
Gets the units that this scan system and all associated ScanHeads will use for configuration and returned data. Can only be set when a scan system is created.
Declaration
public ScanSystemUnits Units { get; }
Property Value
Type | Description |
---|---|
ScanSystemUnits | The units of the scan system. |
Methods
| Improve this Doc View SourceAddPhase()
Adds an empty phase to the end of the phase table. Elements can be added to this newly created phase by calling AddPhaseElement(UInt32, Camera) or AddPhaseElement(UInt32, Laser) after this function has been called.
Declaration
public void AddPhase()
AddPhaseElement(UInt32, Camera)
Adds a camera
from the ScanHead with id
to the current phase.
Declaration
public void AddPhaseElement(uint id, Camera camera)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | The ScanHead ID. |
Camera | camera | The Camera that should expose. |
AddPhaseElement(UInt32, Camera, ScanHeadConfiguration)
Adds a camera
from the ScanHead with id
to the current phase.
Overwrites the ScanHeadConfiguration that was applied with Configure(ScanHeadConfiguration)
with configuration
instead.
Declaration
public void AddPhaseElement(uint id, Camera camera, ScanHeadConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | The ScanHead ID. |
Camera | camera | The Camera that should expose. |
ScanHeadConfiguration | configuration | The ScanHeadConfiguration that will be applied to the element for current phase. |
Remarks
Only the MaxLaserOnTimeUs, DefaultLaserOnTimeUs, and MinLaserOnTimeUs are overwritten.
AddPhaseElement(UInt32, Laser)
Adds a laser
from the ScanHead with id
to the current phase.
Declaration
public void AddPhaseElement(uint id, Laser laser)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | The ScanHead ID. |
Laser | laser | The Laser that should be on during exposure. |
AddPhaseElement(UInt32, Laser, ScanHeadConfiguration)
Adds a laser
from the ScanHead with id
to the current phase.
Overwrites the ScanHeadConfiguration that was applied with Configure(ScanHeadConfiguration)
with configuration
instead.
Declaration
public void AddPhaseElement(uint id, Laser laser, ScanHeadConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | The ScanHead ID. |
Laser | laser | The Laser that should be on during exposure. |
ScanHeadConfiguration | configuration | The ScanHeadConfiguration that will be applied to the element for current phase. |
Remarks
Only the MaxLaserOnTimeUs, DefaultLaserOnTimeUs, and MinLaserOnTimeUs are overwritten.
ClearFrames()
Empties the internal client side software buffers used to store frames.
Under normal scanning conditions where the application consumes frames as they become available, this function will not be needed. Its use is to be found in cases where the application fails to consume frames after some time and the number of buffered frames becomes more than the application can consume and only the most recent scan data is desired.
When operating in profile scanning mode, use ClearProfiles() instead.
Declaration
public void ClearFrames()
Remarks
Frames are automatically cleared when StartScanning(UInt32, DataFormat, ScanningMode) is called.
ClearPhaseTable()
Clears all phases and elements added to the phase table.
Declaration
public void ClearPhaseTable()
Connect(TimeSpan)
Attempts to connect to all ScanHeadss.
Declaration
public IReadOnlyCollection<ScanHead> Connect(TimeSpan connectTimeout)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | connectTimeout | The connection timeout period. |
Returns
Type | Description |
---|---|
IReadOnlyCollection<ScanHead> | A |
Exceptions
Type | Condition |
---|---|
VersionCompatibilityException | A scan head has a firmware version that is incompatible with the API. |
CreateScanHead(UInt32, UInt32)
Declaration
public ScanHead CreateScanHead(uint serialNumber, uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | serialNumber | The serial number of the scan head. |
UInt32 | id | The ID to associate with the ScanHead. |
Returns
Type | Description |
---|---|
ScanHead | The created ScanHead. |
Remarks
scan system must not be connected. Verify IsConnected
is false
and/or call Disconnect() before calling ths method.
Disconnect()
Disconnects from all ScanHeadss.
Declaration
public void Disconnect()
DiscoverDevices()
Performs a network discovery to determine what scan heads are on the network.
Declaration
public Dictionary<uint, DiscoveredDevice> DiscoverDevices()
Returns
Type | Description |
---|---|
Dictionary<UInt32, DiscoveredDevice> | A dictionary of all discovered scan heads where the key is the serial number. |
DiscoverDevicesAsync()
Performs a network discovery to determine what scan heads are on the network.
Declaration
public async Task<Dictionary<uint, DiscoveredDevice>> DiscoverDevicesAsync()
Returns
Type | Description |
---|---|
Task<Dictionary<UInt32, DiscoveredDevice>> | A dictionary of all discovered scan heads where the key is the serial number. |
Dispose()
Releases the managed and unmanaged resources used by the scan system.
Declaration
public void Dispose()
Dispose(Boolean)
Releases the unmanaged resources used by the scan system and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | Whether being disposed explicitly (true) or due to a finalizer (false). |
Finalize()
Declaration
protected void Finalize()
GetMinScanPeriod()
Gets the minimum scan period allowed by the scan system in microseconds.
Declaration
public uint GetMinScanPeriod()
Returns
Type | Description |
---|---|
UInt32 | The minimum scan period allowed by the scan system in microseconds. |
GetScanHeadByID(UInt32)
Gets a ScanHead by ID.
Declaration
public ScanHead GetScanHeadByID(uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | The ID of the desired ScanHead. |
Returns
Type | Description |
---|---|
ScanHead | The ScanHead. |
GetScanHeadBySerialNumber(UInt32)
Gets a ScanHead by serial number.
Declaration
public ScanHead GetScanHeadBySerialNumber(uint serialNumber)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | serialNumber | The serial number of the desired ScanHead. |
Returns
Type | Description |
---|---|
ScanHead | The ScanHead. |
PreSendConfiguration()
Prepares the scan system to begin scanning. If connected, this function will send all of the necessary configuration data to all of the scan heads. Provided that no changes are made to any of the scan heads associated with the scan system, the API will skip sending this data to the scan heads when calling StartScanning(UInt32, DataFormat, ScanningMode) and allow scanning to start faster.
Declaration
public void PreSendConfiguration()
Remarks
- This method is invoked automatically when Connect(TimeSpan) is successful.
- If not manually called between a successful connection and scanning, it will be called automatically in StartScanning(UInt32, DataFormat, ScanningMode).
See Also
| Improve this Doc View SourceStartScanning(UInt32, DataFormat, ScanningMode)
Starts scanning on all ScanHeads.
Declaration
public void StartScanning(uint periodUs, DataFormat dataFormat, ScanningMode mode = ScanningMode.Profile)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | periodUs | The scan period in microseconds. |
DataFormat | dataFormat | The DataFormat. |
ScanningMode | mode | The ScanningMode. |
Remarks
scan system must be connected. Verify IsConnected
is true
and/or call Connect(TimeSpan) before calling ths method.
All existing IProfiles will be cleared from all ScanHeads
when calling this method. Ensure that all data from the previous scan that is desired
is read out before calling this method.
The periodUs
is the period in which each individual scan head will
generate profiles.
StopScanning()
Stops scanning on all ScanHeads.
Declaration
public void StopScanning()
Remarks
Physical scan heads will take approximately 0.5-1.0 seconds to stop scanning after StopScanning() is called. IProfiles will remain in the profile buffers until they are either consumed or StartScanning(UInt32, DataFormat, ScanningMode) is called.
TakeAnyProfile(out IProfile, CancellationToken)
Tries to take an IProfile from any profile queue in ScanHeads, blocking if all the queues are empty.
Declaration
public bool TakeAnyProfile(out IProfile profile, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
IProfile | profile | The dequeued IProfile. |
CancellationToken | token | Token to observe. |
Returns
Type | Description |
---|---|
Boolean | true if a profile was taken else false. |
Remarks
The profile queues are not guarenteed to be taken from equally or in any order.
TakeFrame(CancellationToken)
Tries to take an IFrame, blocking if one isn't ready.
Declaration
public IFrame TakeFrame(CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The |
Returns
Type | Description |
---|---|
IFrame | The dequeued IFrame. |
TryTakeAnyProfile(out IProfile, TimeSpan, CancellationToken)
Declaration
public bool TryTakeAnyProfile(out IProfile profile, TimeSpan timeout = null, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
IProfile | profile | The dequeued IProfile. |
TimeSpan | timeout | The time to wait for a profile when all the queues are empty. |
CancellationToken | token | Token to observe. |
Returns
Type | Description |
---|---|
Boolean | true if a profile was taken else false. |
Remarks
The profile queues are not guarenteed to be taken from equally or in any order.
TryTakeFrame(out IFrame, TimeSpan, CancellationToken)
Tries to take an IFrame.
Declaration
public bool TryTakeFrame(out IFrame frame, TimeSpan timeout = null, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
IFrame | frame | The dequeued IFrame or null. |
TimeSpan | timeout | Time to wait for an IFrame to be taken. |
CancellationToken | token | The |
Returns
Type | Description |
---|---|
Boolean | true if an IFrame was successfully taken,
otherwise false if |
Events
| Improve this Doc View SourceScanSyncUpdateEvent
This event can be used to listen for ScanSync updates for diagnostic purposes. It will be raised for every 1000 ScanSync updates or roughly once every second.
Declaration
public event EventHandler<ScanSyncUpdateEvent> ScanSyncUpdateEvent
Event Type
Type | Description |
---|---|
EventHandler<ScanSyncUpdateEvent> |