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

Common interface for accessing an open device. More...

#include <IDeviceAccessor.h>

Inherits istd::IPolymorphic.

Public Types

typedef QSharedPointer< istd::IChangeable > CommandResultPtr
 Shared pointer type for command results.
 

Public Member Functions

virtual bool IsValid () const =0
 Get device accessor validity status.
 
virtual QByteArray GetDeviceId () const =0
 Get the device ID associated with this accessor.
 
virtual const iprm::IOptionsList & GetSubDeviceList () const =0
 Get the list of sub-devices.
 
virtual DeviceAccessorPtr GetSubDevice (const QByteArray &deviceId) const =0
 Access a sub-device.
 
virtual CommandResultPtr ExecuteCommand (const QByteArray &commandId, const iprm::IParamsSet *commandParamsPtr=nullptr)=0
 Execute a command on the device.
 

Detailed Description

Common interface for accessing an open device.

IDeviceAccessor provides the mechanism to interact with an opened device, enabling command execution and navigation of hierarchical device structures.

An accessor is obtained by opening a device via IDeviceController::OpenDevice() and remains valid as long as the device stays open and communication is maintained. The accessor becomes invalid if communication with the device is lost.

Key Features:
  • Command Execution: Execute device-specific commands with parameters
  • Sub-Device Access: Navigate and access sub-devices in composite configurations
  • Validity Checking: Monitor connection status and accessor validity
  • Device Identification: Track which device this accessor controls
Usage Example:
// Open device and get accessor
DeviceAccessorPtr pAccessor = pController->OpenDevice(deviceId, nullptr);
if (pAccessor && pAccessor->IsValid())
{
// Execute a command
pAccessor->ExecuteCommand("READ_DATA", paramsPtr);
// Access sub-devices if available
const iprm::IOptionsList& subDevices = pAccessor->GetSubDeviceList();
if (!subDevices.IsEmpty())
{
QByteArray subDeviceId = subDevices.GetOption(0).GetId();
DeviceAccessorPtr pSubAccessor = pAccessor->GetSubDevice(subDeviceId);
// Execute command on sub-device
pSubAccessor->ExecuteCommand("SUB_COMMAND", nullptr);
}
}
QSharedPointer< istd::IChangeable > CommandResultPtr
Shared pointer type for command results.
Lifetime:
The accessor is valid from successful OpenDevice() until CloseDevice() is called or communication is lost. Always check IsValid() before executing commands.
See also
IDeviceController
IDeviceInstance
ICompositeDeviceInstance

Definition at line 84 of file IDeviceAccessor.h.

Member Typedef Documentation

◆ CommandResultPtr

typedef QSharedPointer<istd::IChangeable> imtdev::IDeviceAccessor::CommandResultPtr

Shared pointer type for command results.

Command execution results are returned as changeable objects wrapped in shared pointers for proper lifetime management.

Definition at line 93 of file IDeviceAccessor.h.

Member Function Documentation

◆ ExecuteCommand()

virtual CommandResultPtr imtdev::IDeviceAccessor::ExecuteCommand ( const QByteArray &  commandId,
const iprm::IParamsSet *  commandParamsPtr = nullptr 
)
pure virtual

Execute a command on the device.

Executes a device-specific command with optional parameters. The command must be in the list of supported commands defined by IDeviceSpecification.

Parameters
commandIdUnique identifier of the command to execute
commandParamsPtrOptional parameters for the command (can be nullptr)
Returns
Shared pointer to command result object, or empty pointer if accessor is invalid
See also
IDeviceSpecification::GetSupportedCommands()
Note
Returns empty pointer if accessor is not valid - always check IsValid() first

◆ GetDeviceId()

virtual QByteArray imtdev::IDeviceAccessor::GetDeviceId ( ) const
pure virtual

Get the device ID associated with this accessor.

Returns the unique identifier of the device that this accessor controls.

Returns
Device identifier as a byte array
See also
IDeviceController::OpenDevice()

◆ GetSubDevice()

virtual DeviceAccessorPtr imtdev::IDeviceAccessor::GetSubDevice ( const QByteArray &  deviceId) const
pure virtual

Access a sub-device.

Creates an accessor for a specific sub-device within a composite device. The sub-device must be in the list returned by GetSubDeviceList().

Parameters
deviceIdUnique identifier of the sub-device to access
Returns
Accessor for the sub-device, or nullptr if sub-device not found
See also
GetSubDeviceList()

◆ GetSubDeviceList()

virtual const iprm::IOptionsList & imtdev::IDeviceAccessor::GetSubDeviceList ( ) const
pure virtual

Get the list of sub-devices.

For composite devices, returns a list of available sub-devices that can be accessed through this accessor. For simple devices, returns an empty list.

Returns
Reference to options list containing sub-device information
See also
GetSubDevice()
ICompositeDeviceInstance

◆ IsValid()

virtual bool imtdev::IDeviceAccessor::IsValid ( ) const
pure virtual

Get device accessor validity status.

Checks if the accessor is valid and can be used to perform operations. An accessor becomes invalid when communication with the device is lost or the device is closed.

Returns
true if accessor is valid and can execute commands, false otherwise
Note
Always check validity before executing commands to avoid errors