Skip to content

PosSharp.Core.UposDeviceBase

github-actions[bot] edited this page May 8, 2026 · 8 revisions

PosSharp v1.2.0 API Reference


UposDeviceBase Class

A generic base implementation of PosSharp.Abstractions.IUposDevice that manages state transitions via a modular mediator and lifecycle manager.

public abstract class UposDeviceBase : PosSharp.Abstractions.IUposDevice, System.IDisposable, PosSharp.Abstractions.IUposEventSink

Inheritance System.Object 🡒 UposDeviceBase

Implements PosSharp.Abstractions.IUposDevice, System.IDisposable, PosSharp.Abstractions.IUposEventSink

Constructors
UposDeviceBase() Initializes a new instance of the UposDeviceBase class with default mediator and handler.
UposDeviceBase(IUposMediator, IUposLifecycleHandler) Initializes a new instance of the UposDeviceBase class with provided mediator and handler.
Properties
AutoDisable Gets or sets a value indicating whether the device is automatically disabled after a data event is fired.
Capabilities Gets the frozen capabilities of the device.
CapPowerReporting Gets the power reporting capabilities of the device.
CheckHealthText Gets a text description of the results of the last PosSharp.Abstractions.IUposDevice.CheckHealthAsync(PosSharp.Abstractions.HealthCheckLevel,System.Threading.CancellationToken) call.
DataCount Gets the number of data events currently queued.
DataEventEnabled Gets a value indicating whether data event notification is enabled.
DataEventEnabledProperty Gets a value indicating whether data event notification is enabled (Reactive).
DataEvents Gets a stream of DataEvents.
DeviceDescription Gets a description of the physical device.
DeviceName Gets the name of the physical device.
DirectIoEvents Gets a stream of DirectIOEvents.
ErrorEvents Gets a stream of ErrorEvents.
IsBusy Gets a value indicating whether the device is currently processing an operation.
IsBusyValue Gets a value indicating whether the device is currently processing an operation (Synchronous).
IsClaimed Gets a value indicating whether the device is claimed.
IsEnabled Gets a value indicating whether the device is enabled.
IsFlushing Gets a value indicating whether buffered data events are currently being flushed.
IsOpen Gets a value indicating whether the device is open.
IsStateVerificationEnabled Gets or sets a value indicating whether state verification is enabled.
LastError Gets the result code of the last completed operation.
Lifecycle Gets the lifecycle manager that validates state transitions.
Mediator Gets the mediator that coordinates state and operations.
OutputCompleteEvents Gets a stream of OutputCompleteEvents.
PowerNotify Gets or sets the power notification mode.
PowerState Gets the current power state of the device.
ResultCodeExtended Gets the extended result code of the last completed operation.
ServiceObjectDescription Gets a description of the Service Object.
ServiceObjectVersion Gets the version of the Service Object.
State Gets the current logical state of the device.
StatusUpdateEvents Gets a stream of StatusUpdateEvents.
Methods
AddDisposable(IDisposable) Adds a disposable to the extension disposable bag.
AddDisposables(IDisposable[]) Adds multiple disposables to the extension disposable bag.
BeginOperation() Begins a device operation, setting the IsBusy property to true. Returns a disposable that automatically resets the busy state when disposed.
CheckHealthAsync(HealthCheckLevel, CancellationToken) Tests the health of the device.
ClaimAsync(int, CancellationToken) Claims exclusive access to the device.
ClearInputAsync(CancellationToken) Clears all pending input data.
ClearOutputAsync(CancellationToken) Clears all pending buffered output data.
CloseAsync(CancellationToken) Closes communication with the device.
DirectIOAsync(int, int, object, CancellationToken) Sends a direct command to the device.
Dispose() Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Dispose(bool) Releases unmanaged and - optionally - managed resources.
FlushDataEvents() Flushes buffered data events to subscribers.
InitializeCapabilities(IDictionary<string,object>) Initializes the device capabilities with a frozen collection.
OnCheckHealthAsync(HealthCheckLevel, CancellationToken) Called by CheckHealthAsync(HealthCheckLevel, CancellationToken) to perform health check logic.
OnClaimAsync(int, CancellationToken) Called by ClaimAsync(int, CancellationToken) to perform device-specific claim logic.
OnClearInputAsync(CancellationToken) Called by ClearInputAsync(CancellationToken) to clear input buffers.
OnClearOutputAsync(CancellationToken) Called by ClearOutputAsync(CancellationToken) to clear output buffers.
OnCloseAsync(CancellationToken) Called by CloseAsync(CancellationToken) to perform device-specific close logic.
OnDirectIOAsync(int, int, object, CancellationToken) Called by DirectIOAsync(int, int, object, CancellationToken) to perform device-specific command logic.
OnDisableAsync(CancellationToken) Called by SetEnabledAsync(bool, CancellationToken) when disabling the device.
OnEnableAsync(CancellationToken) Called by SetEnabledAsync(bool, CancellationToken) when enabling the device.
OnOpenAsync(CancellationToken) Called by OpenAsync(CancellationToken) to perform device-specific open logic.
OnReleaseAsync(CancellationToken) Called by ReleaseAsync(CancellationToken) to perform device-specific release logic.
OpenAsync(CancellationToken) Attempts to open the device for communication.
PrepareAsync(CancellationToken) Ensures the device is not disposed and the cancellation token is not cancelled.
PublishDataEvent(UposDataEventArgs) Publishes a DataEvent to subscribers or buffers it if notification is disabled.
PublishDirectIoEvent(UposDirectIoEventArgs) Publishes a DirectIOEvent to subscribers.
PublishErrorEvent(UposErrorEventArgs) Publishes an ErrorEvent to subscribers.
PublishOutputCompleteEvent(UposOutputCompleteEventArgs) Publishes an OutputCompleteEvent to subscribers.
PublishStatusUpdateEvent(UposStatusUpdateEventArgs) Publishes a StatusUpdateEvent to subscribers.
ReleaseAsync(CancellationToken) Releases exclusive access to the device.
SetEnabledAsync(bool, CancellationToken) Enables or disables the device.
ThrowIfDisposed() Throws an System.ObjectDisposedException if the device is disposed.
TryBeginFlushing() Tries to acquire the flushing lock atomically.
UpdatePowerState(PowerState) Updates the current power state and fires an event if notification is enabled.
VerifyState(ControlState[]) Verifies that the device is in one of the allowed states.

Clone this wiki locally