ImagingTools Core SDK
Public Types | Public Member Functions | List of all members
imtdev::IDeviceStateProviderabstract

Interface for tracking device connection states. More...

#include <IDeviceStateProvider.h>

Inheritance diagram for imtdev::IDeviceStateProvider:
imtdev::CDeviceStateProviderAdapterComp

Public Types

enum  DeviceState { DS_NONE , DS_CLOSED , DS_OPENED }
 Runtime state of a device. More...
 
enum  ChangeFlags { CF_STATE_CHANGED = istd::IChangeable::ChangeFlags::CF_NO_UNDO + 7171 }
 Change notification flags. More...
 

Public Member Functions

virtual DeviceState GetDeviceState (const QByteArray &deviceId) const =0
 Get the current state of a device.
 

Detailed Description

Interface for tracking device connection states.

IDeviceStateProvider monitors and reports the current runtime state of devices managed by a device controller. It provides change notifications when device states transition between unavailable, closed, and opened states.

This interface extends istd::IChangeable to support observer pattern, allowing clients to register for notifications when device states change.

Device States:
Devices managed by the system can be in one of three states:
  • DS_NONE: Device is not available or not connected
  • DS_CLOSED: Device is available but not actively processing
  • DS_OPENED: Device is active and can execute commands
State Transitions:
[DS_NONE] <--> [DS_CLOSED] <--> [DS_OPENED]
^ ^
| |
+------------------------------+
(Communication loss or device removal)
@ DS_NONE
Device is not available.
@ DS_CLOSED
Device is available but not running.
@ DS_OPENED
Processing loop of the device is running.
Usage Example:
const IDeviceStateProvider& stateProvider = pController->GetDeviceStateProvider();
// Check current device state
IDeviceStateProvider::DeviceState state = stateProvider.GetDeviceState(deviceId);
switch (state)
{
// Device not available
break;
// Device available, can be opened
pController->OpenDevice(deviceId, nullptr);
break;
// Device is active, can execute commands
break;
}
// Register for state change notifications
class StateObserver : public imod::CSingleModelObserverBase
{
protected:
void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override
{
int changeFlags = changeSet.GetFlags();
if (changeFlags & IDeviceStateProvider::CF_STATE_CHANGED)
{
// Device state changed - update UI
}
}
};
Interface for tracking device connection states.
DeviceState
Runtime state of a device.
virtual DeviceState GetDeviceState(const QByteArray &deviceId) const =0
Get the current state of a device.
See also
IDeviceController
IDeviceEnumerator
CDeviceStateProviderAdapterComp

Definition at line 79 of file IDeviceStateProvider.h.

Member Enumeration Documentation

◆ ChangeFlags

Change notification flags.

Flags used with istd::IChangeable to indicate what type of change occurred.

Enumerator
CF_STATE_CHANGED 

Device state has changed Offset value (7171) ensures no collision with base class change flags

Definition at line 121 of file IDeviceStateProvider.h.

◆ DeviceState

Runtime state of a device.

Enumeration of possible device states in the system lifecycle.

Enumerator
DS_NONE 

Device is not available.

The device is not connected, not discovered, or has been removed from the system.

DS_CLOSED 

Device is available but not running.

The device has been discovered and is available for use, but its processing loop is not active. The device can be opened to transition to DS_OPENED state.

DS_OPENED 

Processing loop of the device is running.

The device is active and its processing loop is running. In this state the device can execute commands via IDeviceAccessor.

Definition at line 88 of file IDeviceStateProvider.h.

Member Function Documentation

◆ GetDeviceState()

virtual DeviceState imtdev::IDeviceStateProvider::GetDeviceState ( const QByteArray &  deviceId) const
pure virtual

Get the current state of a device.

Queries the current runtime state of the specified device.

Parameters
deviceIdUnique identifier of the device
Returns
Current state of the device (DS_NONE, DS_CLOSED, or DS_OPENED)
See also
DeviceState