Common interface for controlling devices.
More...
#include <IDeviceController.h>
Common interface for controlling devices.
IDeviceController is the central control hub for device management in the imtdev library. It provides comprehensive device lifecycle management including enumeration, opening/closing, state tracking, and access to device information.
The controller acts as a facade that coordinates multiple subsystems:
- Device Lifecycle:
- Devices managed by the controller go through several states:
- DS_NONE: Device is not available
- DS_CLOSED: Device is available but not actively processing
- DS_OPENED: Device is active and can execute commands
- Usage Pattern:
pController->EnumerateDevices();
QByteArray deviceId =
DeviceAccessorPtr pAccessor = pController->
OpenDevice(deviceId,
nullptr);
if (pAccessor)
{
pAccessor->ExecuteCommand(commandId, params);
}
Common interface for controlling devices.
virtual const imtbase::ICollectionInfo & GetDeviceInstanceList() const =0
Get the list of available device instances.
virtual DeviceInstancePtr GetDeviceInstance(const QByteArray &deviceId) const =0
Get device instance info for the given device ID.
virtual bool CloseDevice(const QByteArray &deviceId)=0
Close a device and stop its processing loop.
virtual DeviceAccessorPtr OpenDevice(const QByteArray &deviceId, const iprm::IParamsSet *paramsPtr)=0
Open a device and start its processing loop.
- Thread Safety:
- Implementations should provide thread-safe access to device lists and opened devices. The base implementation (CDeviceControllerCompBase) uses mutex protection for this purpose.
- See also
- IDeviceEnumerator
-
IDeviceAccessor
-
IDeviceStateProvider
-
IDeviceInstance
-
CDeviceControllerCompBase
Definition at line 83 of file IDeviceController.h.
◆ CloseDevice()
| virtual bool imtdev::IDeviceController::CloseDevice |
( |
const QByteArray & |
deviceId | ) |
|
|
pure virtual |
Close a device and stop its processing loop.
Transitions a device from DS_OPENED to DS_CLOSED state, releasing resources and stopping any active processing.
- Parameters
-
| deviceId | Unique identifier of the device to close |
- Returns
- true if device was closed successfully, false otherwise
- See also
- OpenDevice()
- Note
- The device must be in DS_OPENED state for this operation to succeed
◆ GetDeviceInstance()
| virtual DeviceInstancePtr imtdev::IDeviceController::GetDeviceInstance |
( |
const QByteArray & |
deviceId | ) |
const |
|
pure virtual |
Get device instance info for the given device ID.
Retrieves runtime information about a specific device instance, including identifiers, version information, and attributes.
- Note
- For some devices, instance information can only be obtained when the device is open (in DS_OPENED state).
- Parameters
-
| deviceId | Unique identifier of the device |
- Returns
- Shared pointer to device instance, or nullptr if not found
- See also
- IDeviceInstance
-
OpenDevice()
◆ GetDeviceInstanceList()
Get the list of available device instances.
Returns a collection containing information about all devices that have been discovered through enumeration. The collection supports iteration and provides change notifications when devices are added or removed.
- Returns
- Reference to collection info containing device instances
- See also
- EnumerateDevices()
-
imtbase::ICollectionInfo
◆ GetDeviceStateProvider()
Get provider of current device states.
Returns the state provider that tracks the current state (DS_NONE, DS_CLOSED, DS_OPENED) of all devices managed by this controller.
- Returns
- Reference to device state provider
- See also
- IDeviceStateProvider
◆ GetDeviceStaticInfo()
| virtual const IDeviceSpecification * imtdev::IDeviceController::GetDeviceStaticInfo |
( |
const QByteArray & |
deviceTypeId | ) |
const |
|
pure virtual |
Get device static info for the given device type ID.
Retrieves the device specification that describes static properties, capabilities, and supported commands for a specific device type.
- Parameters
-
| deviceTypeId | Unique identifier of the device type |
- Returns
- Pointer to device specification, or nullptr if device type is not supported
- See also
- IDeviceSpecification
-
GetSupportedDeviceTypeIds()
◆ GetSupportedDeviceTypeIds()
| virtual const QByteArrayList & imtdev::IDeviceController::GetSupportedDeviceTypeIds |
( |
| ) |
const |
|
pure virtual |
Get IDs of device types supported by the controller.
Returns a list of device type identifiers that this controller can manage. Each device type has associated static information (IDeviceSpecification) that describes its capabilities.
- Returns
- Reference to list of supported device type IDs
- See also
- GetDeviceStaticInfo()
◆ OpenDevice()
| virtual DeviceAccessorPtr imtdev::IDeviceController::OpenDevice |
( |
const QByteArray & |
deviceId, |
|
|
const iprm::IParamsSet * |
paramsPtr |
|
) |
| |
|
pure virtual |
Open a device and start its processing loop.
Transitions a device from DS_CLOSED to DS_OPENED state, making it ready for command execution. Returns a device accessor that can be used to interact with the device.
- Parameters
-
| deviceId | Unique identifier of the device to open |
| paramsPtr | Optional parameters for device initialization (can be nullptr) |
- Returns
- Device accessor for command execution, or nullptr if open failed
- See also
- CloseDevice()
-
IDeviceAccessor
- Note
- The device must be in DS_CLOSED state for this operation to succeed
◆ SetDeviceInstanceDescription()
| virtual bool imtdev::IDeviceController::SetDeviceInstanceDescription |
( |
const QByteArray & |
deviceId, |
|
|
const QString & |
description |
|
) |
| |
|
pure virtual |
Set custom description for a device instance.
Allows overriding the default device description with custom text. This description provides additional context about the device.
- Parameters
-
| deviceId | Unique identifier of the device |
| description | Custom description to assign to the device |
- Returns
- true if description was set successfully, false otherwise
- See also
- SetDeviceInstanceName()
◆ SetDeviceInstanceName()
| virtual bool imtdev::IDeviceController::SetDeviceInstanceName |
( |
const QByteArray & |
deviceId, |
|
|
const QString & |
name |
|
) |
| |
|
pure virtual |
Set custom name for a device instance.
Allows overriding the default device name with a user-friendly name. This name is typically displayed in user interfaces.
- Parameters
-
| deviceId | Unique identifier of the device |
| name | Custom name to assign to the device |
- Returns
- true if name was set successfully, false otherwise
- See also
- SetDeviceInstanceDescription()