openDAQ
Open data acquisition platform
GenericDevicePtr< InterfaceType > Class Template Reference

Represents an openDAQ device. The device contains a list of signals and physical channels. Some devices support adding function blocks, or connecting to devices. The list of available function blocks/devices can be obtained via the getAvailable functions, and added via the add functions. More...

Detailed Description

template<typename InterfaceType>
class GenericDevicePtr< InterfaceType >

Represents an openDAQ device. The device contains a list of signals and physical channels. Some devices support adding function blocks, or connecting to devices. The list of available function blocks/devices can be obtained via the getAvailable functions, and added via the add functions.

Devices can be split up into three different types, with each devices supporting one or more:

  1. Physical devices Physical devices provide access to physical channels. They measure real-world data and send it via packets through output signals of channels. The list of channels can be obtained via getChannels as a flat list.
  2. Client devices Client devices can connect to other devices via their supported connection protocol. openDAQ natively supports connecting to TMS devices via its openDAQ OpcUa Client Module. A list of available devices a client device can connect to can be obtained via getAvailableDevices. The addDevice is used to connect to/add a device.
  3. Function block devices Function block devices provide a dictionary of available function block types that can be added to them and configured. The calculation of function blocks is done on the device itself. The dictionary of available function block types can be obtained via getAvailableFunctionBlockTypes. They can then be added via addFunctionBlock.

All devices also provide access to their Device information, containing metadata such as the device's serial number, location... They can also be queried for their current domain values (time) through its device domain.

As each device is a property object, a device has access to all Property object methods, allowing each device to expose a list of custom properties such as sample rate, scaling factor and many others. By default, openDAQ devices have the UserName and Location string Properties.

Public Member Functions

daq::DeviceInfoPtr getInfo () const
 Gets the device info. It contains data about the device such as the device's serial number, location, and connection string. More...
 
daq::DeviceDomainPtr getDomain () const
 Gets the device's domain data. It allows for querying the device for its domain (time) values. More...
 
daq::GenericFolderPtr< daq::IFolder > getInputsOutputsFolder () const
 Gets a folder containing channels. More...
 
daq::ListPtr< daq::IComponent > getCustomComponents () const
 Gets a list of all components/folders in a device that are not titled 'IO', 'Sig', 'Dev', 'Synchronization' or 'FB'. More...
 
daq::ListPtr< daq::ISignal > getSignals (const daq::SearchFilterPtr &searchFilter=nullptr) const
 Gets a list of the device's signals. More...
 
daq::ListPtr< daq::ISignal > getSignalsRecursive (const daq::SearchFilterPtr &searchFilter=nullptr) const
 Gets a list of the signals that belong to the device. More...
 
daq::ListPtr< daq::IChannel > getChannels (const daq::SearchFilterPtr &searchFilter=nullptr) const
 Gets a flat list of the device's physical channels. More...
 
daq::ListPtr< daq::IChannel > getChannelsRecursive (const daq::SearchFilterPtr &searchFilter=nullptr) const
 Gets a flat list of the device's physical channels. Also finds all visible channels of visible child devices. More...
 
daq::ListPtr< daq::IDevice > getDevices (const daq::SearchFilterPtr &searchFilter=nullptr) const
 Gets a list of child devices that the device is connected to. More...
 
daq::ListPtr< daq::IDeviceInfo > getAvailableDevices () const
 Gets a list of available devices, containing their Device Info. More...
 
daq::DictPtr< daq::IString, daq::IDeviceType > getAvailableDeviceTypes () const
 Get a dictionary of available device types as <IString, IDeviceType> pairs. More...
 
daq::GenericDevicePtr< daq::IDevice > addDevice (const daq::StringPtr &connectionString, const daq::PropertyObjectPtr &config=nullptr) const
 Connects to a device at the given connection string and returns it. More...
 
void removeDevice (const daq::GenericDevicePtr< daq::IDevice > &device) const
 Disconnects from the device provided as argument and removes it from the internal list of devices. More...
 
daq::ListPtr< daq::IFunctionBlock > getFunctionBlocks (const daq::SearchFilterPtr &searchFilter=nullptr) const
 Gets the list of added function blocks. More...
 
daq::DictPtr< daq::IString, daq::IFunctionBlockType > getAvailableFunctionBlockTypes () const
 Gets all function block types that are supported by the device, containing their description. More...
 
daq::FunctionBlockPtr addFunctionBlock (const daq::StringPtr &typeId, const daq::PropertyObjectPtr &config=nullptr) const
 Creates and adds a function block to the device with the provided unique ID and returns it. More...
 
void removeFunctionBlock (const daq::FunctionBlockPtr &functionBlock) const
 Removes the function block provided as argument, disconnecting its signals and input ports. More...
 
daq::StringPtr saveConfiguration () const
 Saves the configuration of the device to string. More...
 
void loadConfiguration (const daq::StringPtr &configuration, const daq::UpdateParametersPtr &config=nullptr) const
 Loads the configuration of the device from string. More...
 
daq::UInt getTicksSinceOrigin () const
 Gets the number of ticks passed since the device's absolute origin. More...
 
daq::StreamingPtr addStreaming (const daq::StringPtr &connectionString, const daq::PropertyObjectPtr &config=nullptr) const
 Connects to a streaming at the given connection string, adds it as a streaming source of device and returns created streaming object. More...
 
daq::PropertyObjectPtr createDefaultAddDeviceConfig () const
 Creates config object that can be used when adding a device. Contains Device and Streaming default configuration for all available Device/Streaming types. Also contains general add-device configuration settings. More...
 
daq::SyncComponentPtr getSyncComponent () const
 Gets the sync component of the device. More...
 
daq::ServerPtr addServer (const daq::StringPtr &typeId, const daq::PropertyObjectPtr &config) const
 Creates and adds to the device a server with the provided unique type ID and returns it. More...
 
void removeServer (const daq::ServerPtr &server) const
 Removes the server provided as argument. More...
 
daq::ListPtr< daq::IServer > getServers () const
 Get list of added servers. More...
 
void lock () const
 Lock a device with a session user. Once locked, no properties of the device can be changed via the protocol layer. Only the same user who locked the device can unlock it. If no user was specified when the device was locked, any user will be able to unlock it.
 
void unlock () const
 Unlock a device with a session user. A device can only be unlocked by the same user who locked it. If no user was specified when the device was locked, any user will be able to unlock it.
 
daq::Bool isLocked () const
 Returns truee if device is locked. Once locked, no properties of the device can be changed via the protocol layer. More...
 
daq::ListPtr< daq::ILogFileInfo > getLogFileInfos () const
 Gets a list of available log files. More...
 
daq::StringPtr getLog (const daq::StringPtr &id, daq::Int size=-1, daq::Int offset=0) const
 Retrieves a chunk of the log file with the provided ID. This function extracts a specified portion (or the entire content) of the log file, starting at the given offset. If the size and offset are not specified, it will attempt to return the entire log file by default. More...
 

Member Function Documentation

◆ addDevice()

daq::GenericDevicePtr<daq::IDevice> addDevice ( const daq::StringPtr &  connectionString,
const daq::PropertyObjectPtr &  config = nullptr 
) const
inline

Connects to a device at the given connection string and returns it.

Returns
The added device.
Parameters
connectionStringThe connection string containing the address of the device. In example an IPv4/IPv6 address. The connection string can be found in the Device Info objects returned by getAvailableDevices.
configA config object to configure a client device. This object can contain properties like max sample rate, port to use for 3rd party communication, number of channels to generate, or other device specific settings. Can be created from its corresponding Device type object. In case of a null value, it will use the default configuration.

◆ addFunctionBlock()

daq::FunctionBlockPtr addFunctionBlock ( const daq::StringPtr &  typeId,
const daq::PropertyObjectPtr &  config = nullptr 
) const
inline

Creates and adds a function block to the device with the provided unique ID and returns it.

Returns
The added function block.
Parameters
typeIdThe unique ID of the function block. Can be obtained from its corresponding Function Block Info object.
configA config object to configure a function block with custom settings specific to that function block type.

◆ addServer()

daq::ServerPtr addServer ( const daq::StringPtr &  typeId,
const daq::PropertyObjectPtr &  config 
) const
inline

Creates and adds to the device a server with the provided unique type ID and returns it.

Returns
The added server.
Parameters
typeIdThe unique type ID of the server. Can be obtained from its corresponding Server type object.
configA config object to configure a server with custom settings specific to that server type.

◆ addStreaming()

daq::StreamingPtr addStreaming ( const daq::StringPtr &  connectionString,
const daq::PropertyObjectPtr &  config = nullptr 
) const
inline

Connects to a streaming at the given connection string, adds it as a streaming source of device and returns created streaming object.

Returns
The added streaming source.
Parameters
connectionStringThe connection string containing the address of the streaming. In example an IPv4/IPv6 address. The connection string can be found in the Server Capability objects returned by getInfo().getServerCapabilities().
configA config object to configure a streaming connection. This object can contain properties like various connection timeouts or other streaming protocol specific settings. Can be created from its corresponding Streaming type object. In case of a null value, it will use the default configuration.

◆ createDefaultAddDeviceConfig()

daq::PropertyObjectPtr createDefaultAddDeviceConfig ( ) const
inline

Creates config object that can be used when adding a device. Contains Device and Streaming default configuration for all available Device/Streaming types. Also contains general add-device configuration settings.

Returns
The configuration object containing default settings for adding a device.

The default config object is organized to always have 3 object-type properties:

  • "General" Contains general properties such as "AutomaticallyConnectStreaming"
  • "Device": Contains a child object-type property for each available device type, with the key of each property being the ID of the device type. These can be configured to customize the addDevice call when using connecting to the selected device type (eg. via the native or OPC UA protocols).
  • "Streaming": Same as device, but used to configure each individual streaming connection established when calling addDevice.

◆ getAvailableDevices()

daq::ListPtr<daq::IDeviceInfo> getAvailableDevices ( ) const
inline

Gets a list of available devices, containing their Device Info.

Returns
The list of available devices.

The getAvailableDevices most often runs a discovery client, querying for available devices that a device module can connect to. The replies are formed into Device Info objects and inserted to the list of available devices.

◆ getAvailableDeviceTypes()

daq::DictPtr<daq::IString, daq::IDeviceType> getAvailableDeviceTypes ( ) const
inline

Get a dictionary of available device types as <IString, IDeviceType> pairs.

Returns
The dictionary of available device types.

◆ getAvailableFunctionBlockTypes()

daq::DictPtr<daq::IString, daq::IFunctionBlockType> getAvailableFunctionBlockTypes ( ) const
inline

Gets all function block types that are supported by the device, containing their description.

Returns
A dictionary of available function block types.

◆ getChannels()

daq::ListPtr<daq::IChannel> getChannels ( const daq::SearchFilterPtr &  searchFilter = nullptr) const
inline

Gets a flat list of the device's physical channels.

Parameters
searchFilterProvides an optional filter that filters out unwanted components and allows for recursion.
Returns
The flat list of channels.

If searchFilter is not provided, the returned list contains only visible channels and does not include those of child devices.

◆ getChannelsRecursive()

daq::ListPtr<daq::IChannel> getChannelsRecursive ( const daq::SearchFilterPtr &  searchFilter = nullptr) const
inline

Gets a flat list of the device's physical channels. Also finds all visible channels of visible child devices.

Parameters
searchFilterProvides an optional filter that filters out unwanted components and allows for recursion.
Returns
The flat list of channels.

◆ getCustomComponents()

daq::ListPtr<daq::IComponent> getCustomComponents ( ) const
inline

Gets a list of all components/folders in a device that are not titled 'IO', 'Sig', 'Dev', 'Synchronization' or 'FB'.

Returns
The list of custom components.

◆ getDevices()

daq::ListPtr<daq::IDevice> getDevices ( const daq::SearchFilterPtr &  searchFilter = nullptr) const
inline

Gets a list of child devices that the device is connected to.

Parameters
searchFilterProvides an optional filter that filters out unwanted components and allows for recursion.
Returns
The list of devices.

If searchFilter is not provided, the returned list contains only visible devices and does not include those of child devices.

◆ getDomain()

daq::DeviceDomainPtr getDomain ( ) const
inline

Gets the device's domain data. It allows for querying the device for its domain (time) values.

Returns
The device domain.

◆ getFunctionBlocks()

daq::ListPtr<daq::IFunctionBlock> getFunctionBlocks ( const daq::SearchFilterPtr &  searchFilter = nullptr) const
inline

Gets the list of added function blocks.

Parameters
searchFilterProvides an optional filter that filters out unwanted components and allows for recursion.
Returns
The list of added function blocks.

If searchFilter is not provided, the returned list contains only visible function blocks and does not include those of child function blocks, devices, or channels.

◆ getInfo()

daq::DeviceInfoPtr getInfo ( ) const
inline

Gets the device info. It contains data about the device such as the device's serial number, location, and connection string.

Returns
The device info.

◆ getInputsOutputsFolder()

daq::GenericFolderPtr<daq::IFolder> getInputsOutputsFolder ( ) const
inline

Gets a folder containing channels.

Returns
The folder that contains channels.

The InputsOutputs folder can contain other folders that themselves contain channels.

◆ getLog()

daq::StringPtr getLog ( const daq::StringPtr &  id,
daq::Int  size = -1,
daq::Int  offset = 0 
) const
inline

Retrieves a chunk of the log file with the provided ID. This function extracts a specified portion (or the entire content) of the log file, starting at the given offset. If the size and offset are not specified, it will attempt to return the entire log file by default.

Returns
A string which stores requested log chunk.
Parameters
idRhe ID of the log file to retrieve.
sizeThe size of the log chunk to retrieve in bytes. Defaults to -1, which means it will return all remaining bytes from the offset.
offsetThe offset, in bytes, from where the log chunk should be read. Defaults to 0 (start of the file). If size is set to -1, and offset is 0, the entire log file will be returned.

◆ getLogFileInfos()

daq::ListPtr<daq::ILogFileInfo> getLogFileInfos ( ) const
inline

Gets a list of available log files.

Returns
The list of available log files.

◆ getServers()

daq::ListPtr<daq::IServer> getServers ( ) const
inline

Get list of added servers.

Returns
List of added servers.

◆ getSignals()

daq::ListPtr<daq::ISignal> getSignals ( const daq::SearchFilterPtr &  searchFilter = nullptr) const
inline

Gets a list of the device's signals.

Parameters
searchFilterProvides an optional filter that filters out unwanted components and allows for recursion.
Returns
The flat list of signals.

If searchFilter is not provided, the returned list contains only visible signals and does not include those of child function blocks, devices, or channels.

Device signals are most often domain signals shared by other signals that belong to channels and/or function blocks.

◆ getSignalsRecursive()

daq::ListPtr<daq::ISignal> getSignalsRecursive ( const daq::SearchFilterPtr &  searchFilter = nullptr) const
inline

Gets a list of the signals that belong to the device.

Parameters
searchFilterProvides an optional filter that filters out unwanted components and allows for recursion.
Returns
The flat list of signals.

The list includes visible signals that belong to visible channels, function blocks, or sub devices of the device.

◆ getSyncComponent()

daq::SyncComponentPtr getSyncComponent ( ) const
inline

Gets the sync component of the device.

Returns
The sync component.

◆ getTicksSinceOrigin()

daq::UInt getTicksSinceOrigin ( ) const
inline

Gets the number of ticks passed since the device's absolute origin.

Returns
The number of ticks.

To scale the ticks into a domain unit, the Device's Domain should be used.

◆ isLocked()

daq::Bool isLocked ( ) const
inline

Returns truee if device is locked. Once locked, no properties of the device can be changed via the protocol layer.

Returns
True if device is locked.

◆ loadConfiguration()

void loadConfiguration ( const daq::StringPtr &  configuration,
const daq::UpdateParametersPtr &  config = nullptr 
) const
inline

Loads the configuration of the device from string.

Parameters
configurationSerialized configuration of the device.

◆ removeDevice()

void removeDevice ( const daq::GenericDevicePtr< daq::IDevice > &  device) const
inline

Disconnects from the device provided as argument and removes it from the internal list of devices.

Parameters
deviceThe device to be removed.

◆ removeFunctionBlock()

void removeFunctionBlock ( const daq::FunctionBlockPtr &  functionBlock) const
inline

Removes the function block provided as argument, disconnecting its signals and input ports.

Parameters
functionBlockThe function block to be removed.

◆ removeServer()

void removeServer ( const daq::ServerPtr &  server) const
inline

Removes the server provided as argument.

Parameters
serverThe server to be removed.

◆ saveConfiguration()

daq::StringPtr saveConfiguration ( ) const
inline

Saves the configuration of the device to string.

Returns
Serialized configuration of the device.