IDS peak genericC++ v1.16.0
Loading...
Searching...
No Matches
peak::DeviceManager Class Referencefinal

The global DeviceManager (singleton) searches all installed producer libraries (*.cti) and enumerates the modules contained in them. More...

#include <peak/peak_device_manager.hpp>

Public Types

enum class  UpdatePolicy {
  ScanEnvironmentForProducerLibraries ,
  DontScanEnvironmentForProducerLibraries
}
 Enum holding the possible update policies. More...
enum class  ResetPolicy {
  ErrorOnOpenDevices ,
  IgnoreOpenDevices
}
 Enum holding the possible reset policies. More...
using SystemFoundCallback = std::function<void(const std::shared_ptr<const core::System>& foundSystem)>
using SystemFoundCallbackHandle = SystemFoundCallback*
using InterfaceFoundCallback = std::function<void(const std::shared_ptr<const core::Interface>& foundInterface)>
using InterfaceFoundCallbackHandle = InterfaceFoundCallback*
using InterfaceLostCallback = std::function<void(const std::string& lostInterfaceKey)>
using InterfaceLostCallbackHandle = InterfaceLostCallback*
using DeviceFoundCallback = std::function<void(const std::shared_ptr<core::DeviceDescriptor>& foundDevice)>
using DeviceFoundCallbackHandle = DeviceFoundCallback*
using DeviceLostCallback = std::function<void(const std::string& lostDeviceKey)>
using DeviceLostCallbackHandle = DeviceLostCallback*
using DeviceDisconnectedCallback
using DeviceDisconnectedCallbackHandle = DeviceDisconnectedCallback*
using DeviceReconnectedCallback
using DeviceReconnectedCallbackHandle = DeviceReconnectedCallback*
using DeviceListChangedCallback = std::function<void()>
using DeviceListChangedCallbackHandle = DeviceListChangedCallback*
using UpdateErrorCallback = std::function<void(const std::string& errorDescription)>

Public Member Functions

void AddProducerLibrary (const std::string &ctiPath)
 Adds the given producer library (CTI).
void AddProducerLibrary (const std::shared_ptr< core::ProducerLibrary > &library)
 Adds the given producer library (CTI).
void Update (UpdatePolicy updatePolicy=UpdatePolicy::ScanEnvironmentForProducerLibraries, const UpdateErrorCallback &errorCallback=UpdateErrorCallback())
 Starts an update.
void Reset (ResetPolicy resetPolicy=ResetPolicy::ErrorOnOpenDevices)
 Resets the DeviceManager.
core::Timeout InterfaceUpdateTimeout () const
 Returns the interface update timeout.
void SetInterfaceUpdateTimeout (core::Timeout timeout_ms)
 Sets the interface update timeout.
core::Timeout DeviceUpdateTimeout () const
 Returns the device update timeout.
void SetDeviceUpdateTimeout (core::Timeout timeout_ms)
 Sets the device update timeout.
std::vector< std::shared_ptr< const core::System > > Systems () const
 Returns the found and opened systems.
std::vector< std::shared_ptr< const core::Interface > > Interfaces () const
 Returns the found and opened interfaces.
std::vector< std::shared_ptr< core::DeviceDescriptor > > Devices () const
 Returns the found devices.
SystemFoundCallbackHandle RegisterSystemFoundCallback (const SystemFoundCallback &callback)
 Registers a callback for signaling a found system.
void UnregisterSystemFoundCallback (SystemFoundCallbackHandle callbackHandle)
 Unregisters a system found callback.
InterfaceFoundCallbackHandle RegisterInterfaceFoundCallback (const InterfaceFoundCallback &callback)
 Registers a callback for signaling a found interface.
void UnregisterInterfaceFoundCallback (InterfaceFoundCallbackHandle callbackHandle)
 Unregisters a interface found callback.
InterfaceLostCallbackHandle RegisterInterfaceLostCallback (const InterfaceLostCallback &callback)
 Registers a callback for signaling a lost interface.
void UnregisterInterfaceLostCallback (InterfaceLostCallbackHandle callbackHandle)
 Unregisters an interface lost callback.
DeviceFoundCallbackHandle RegisterDeviceFoundCallback (const DeviceFoundCallback &callback)
 Registers a callback for signaling a found device.
void UnregisterDeviceFoundCallback (DeviceFoundCallbackHandle callbackHandle)
 Unregisters a device found callback.
DeviceLostCallbackHandle RegisterDeviceLostCallback (const DeviceLostCallback &callback)
 Registers a callback for signaling a lost device.
void UnregisterDeviceLostCallback (DeviceLostCallbackHandle callbackHandle)
 Unregisters a device lost callback.
DeviceDisconnectedCallbackHandle RegisterDeviceDisconnectedCallback (const DeviceDisconnectedCallback &callback)
 Registers a callback for signaling a disconnected device.
void UnregisterDeviceDisconnectedCallback (DeviceDisconnectedCallbackHandle callbackHandle)
 Unregisters a device disconnected callback.
DeviceReconnectedCallbackHandle RegisterDeviceReconnectedCallback (const DeviceReconnectedCallback &callback)
 Registers a callback for signaling a reconnected device.
void UnregisterDeviceReconnectedCallback (DeviceReconnectedCallbackHandle callbackHandle)
 Unregisters a device reconnected callback.
DeviceListChangedCallbackHandle RegisterDeviceListChangedCallback (const DeviceListChangedCallback &callback)
 Registers a callback for signaling a change in the device list.
void UnregisterDeviceListChangedCallback (DeviceListChangedCallbackHandle callbackHandle)
 Unregisters a device list change callback.
 DeviceManager (const DeviceManager &other)=delete
DeviceManager & operator= (const DeviceManager &other)=delete

Static Public Member Functions

static DeviceManager & Instance ()
 Returns the global DeviceManager.

Friends

class Library

Detailed Description

The global DeviceManager (singleton) searches all installed producer libraries (*.cti) and enumerates the modules contained in them.

Retrieve the global DeviceManager with DeviceManager::Instance().

When Update() is called, it searches for all producer libraries contained in the directories found in the official GenICam GenTL environment variable GENICAM_GENTL{32/64}_PATH. It then openes all found ProducerLibraries, their Systems, their Interfaces, and lists all available DeviceDescriptors.

auto& deviceManager = peak::DeviceManager::Instance();
deviceManager.Update();
deviceDescriptors = deviceManager.Devices();
static DeviceManager & Instance()
Returns the global DeviceManager.
Definition peak_device_manager.hpp:844
Note
The found producer libraries depend on the architecture your application is compiled for. This means you are getting 32-bit producer libraries if your application is compiled for a 32-bit system and 64-bit producer libraries if your application is compiled for a 64-bit system.

The DeviceManager is a singleton. Therefore, after it was used, it stays active until program termination. That means the opened ProducerLibraries, Systems, and Interfaces stay open. To close them before and start from scratch during runtime, call Reset().

Member Typedef Documentation

◆ DeviceDisconnectedCallback

Initial value:
std::function<void(const std::shared_ptr<core::DeviceDescriptor>& disconnectedDevice)>

The type of device disconnect callbacks.

◆ DeviceDisconnectedCallbackHandle

The type of device disconnect callback handles.

◆ DeviceFoundCallback

using peak::DeviceManager::DeviceFoundCallback = std::function<void(const std::shared_ptr<core::DeviceDescriptor>& foundDevice)>

The type of device found callbacks.

◆ DeviceFoundCallbackHandle

The type of device found callback handles.

◆ DeviceListChangedCallback

using peak::DeviceManager::DeviceListChangedCallback = std::function<void()>

The type of device list changed callbacks.

◆ DeviceListChangedCallbackHandle

The type of device list changed callback handles.

◆ DeviceLostCallback

using peak::DeviceManager::DeviceLostCallback = std::function<void(const std::string& lostDeviceKey)>

The type of device lost callbacks.

◆ DeviceLostCallbackHandle

The type of device lost callback handles.

◆ DeviceReconnectedCallback

Initial value:
std::function<void(const std::shared_ptr<core::DeviceDescriptor>& reconnectedDevice,
core::DeviceReconnectInformation reconnectInformation)>
Definition reconnect_information.hpp:17

The type of device reconnect callbacks.

◆ DeviceReconnectedCallbackHandle

The type of device reconnect callback handles.

◆ InterfaceFoundCallback

using peak::DeviceManager::InterfaceFoundCallback = std::function<void(const std::shared_ptr<const core::Interface>& foundInterface)>

The type of interface found callbacks.

◆ InterfaceFoundCallbackHandle

The type of interface found callback handles.

◆ InterfaceLostCallback

using peak::DeviceManager::InterfaceLostCallback = std::function<void(const std::string& lostInterfaceKey)>

The type of interface lost callbacks.

◆ InterfaceLostCallbackHandle

The type of interface lost callback handles.

◆ SystemFoundCallback

using peak::DeviceManager::SystemFoundCallback = std::function<void(const std::shared_ptr<const core::System>& foundSystem)>

The type of system found callbacks.

◆ SystemFoundCallbackHandle

The type of system found callback handles.

◆ UpdateErrorCallback

using peak::DeviceManager::UpdateErrorCallback = std::function<void(const std::string& errorDescription)>

The type of update error callbacks.

Member Enumeration Documentation

◆ ResetPolicy

Enum holding the possible reset policies.

Enumerator
ErrorOnOpenDevices 

Check and throw an exception if an opened device is found

IgnoreOpenDevices 

Ignore opened device and close them

◆ UpdatePolicy

Enum holding the possible update policies.

Enumerator
ScanEnvironmentForProducerLibraries 

Scan env variable and add newly found producer libraries on DeviceManager::Update() call

DontScanEnvironmentForProducerLibraries 

Don't scan env variable and add newly found producer libraries on DeviceManager::Update() call

Constructor & Destructor Documentation

◆ DeviceManager()

peak::DeviceManager::DeviceManager ( const DeviceManager & other)
delete

Member Function Documentation

◆ AddProducerLibrary() [1/2]

void peak::DeviceManager::AddProducerLibrary ( const std::shared_ptr< core::ProducerLibrary > & library)
inline

Adds the given producer library (CTI).

This function can be used to add already opened producer libraries manually. This is useful when the desired producer library is not registered at the GenTL environment variable. If the producer library is already present, this call does nothing.

Parameters
[in]libraryThe library instance
Since
1.7
Exceptions
core::BadAccessExceptionAccess denied
core::InternalErrorExceptionAn internal error has occurred.
Note
Changes only take effect when they are applied before calling Update(). Calling the function while an update is running will block the call.
If the system of the producer library is not open, it will be opened immediately.
Will trigger the SystemFound callback if the system is added to the internal list.

◆ AddProducerLibrary() [2/2]

void peak::DeviceManager::AddProducerLibrary ( const std::string & ctiPath)
inline

Adds the given producer library (CTI).

This function can be used to add producer libraries manually. This is useful when the desired producer library is not registered at the GenTL environment variable.

Parameters
[in]ctiPathThe path to the producer library (CTI) to add
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.
Note
Changes only take effect when they are applied before calling Update(). Changes applied during a running update only take effect with the next call to Update().

◆ Devices()

std::vector< std::shared_ptr< core::DeviceDescriptor > > peak::DeviceManager::Devices ( ) const
inline

Returns the found devices.

Returns
Found devices
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ DeviceUpdateTimeout()

core::Timeout peak::DeviceManager::DeviceUpdateTimeout ( ) const
inline

Returns the device update timeout.

Returns
Device update timeout in milliseconds
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ Instance()

DeviceManager & peak::DeviceManager::Instance ( )
inlinestatic

Returns the global DeviceManager.

Since
1.0

◆ Interfaces()

std::vector< std::shared_ptr< const core::Interface > > peak::DeviceManager::Interfaces ( ) const
inline

Returns the found and opened interfaces.

Returns
Found and opened interfaces
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ InterfaceUpdateTimeout()

core::Timeout peak::DeviceManager::InterfaceUpdateTimeout ( ) const
inline

Returns the interface update timeout.

Returns
Interface update timeout in milliseconds
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ operator=()

DeviceManager & peak::DeviceManager::operator= ( const DeviceManager & other)
delete

◆ RegisterDeviceDisconnectedCallback()

DeviceManager::DeviceDisconnectedCallbackHandle peak::DeviceManager::RegisterDeviceDisconnectedCallback ( const DeviceDisconnectedCallback & callback)
inline

Registers a callback for signaling a disconnected device.

This function registers a callback which gets called every time a device is disconnected. Pass the callback handle returned by this function to UnregisterDeviceDisconnectCallback() to unregister the callback.

Parameters
[in]callbackThe callback to call if a device is disconnected.
Returns
Callback handle
Since
1.7
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ RegisterDeviceFoundCallback()

DeviceManager::DeviceFoundCallbackHandle peak::DeviceManager::RegisterDeviceFoundCallback ( const DeviceFoundCallback & callback)
inline

Registers a callback for signaling a found device.

This function registers a callback which gets called every time a new device is found. Pass the callback handle returned by this function to UnregisterDeviceFoundCallback() to unregister the callback.

Parameters
[in]callbackThe callback to call if a new device is found.
Returns
Callback handle
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.
Note
The registered callback is executed in the thread calling Update().

◆ RegisterDeviceListChangedCallback()

DeviceManager::DeviceListChangedCallbackHandle peak::DeviceManager::RegisterDeviceListChangedCallback ( const DeviceListChangedCallback & callback)
inline

Registers a callback for signaling a change in the device list.

This function registers a callback which gets called every time the device list changes. Pass the callback handle returned by this function to UnregisterDeviceListChangedCallback() to unregister the callback.

Parameters
[in]callbackThe callback to call if the device list has changed.
Returns
Callback handle
Since
1.7
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ RegisterDeviceLostCallback()

DeviceManager::DeviceLostCallbackHandle peak::DeviceManager::RegisterDeviceLostCallback ( const DeviceLostCallback & callback)
inline

Registers a callback for signaling a lost device.

This function registers a callback which gets called every time a device is lost. Pass the callback handle returned by this function to UnregisterDeviceLostCallback() to unregister the callback.

Parameters
[in]callbackThe callback to call if a device is lost.
Returns
Callback handle
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.
Note
The registered callback is executed in the thread calling Update().

◆ RegisterDeviceReconnectedCallback()

DeviceManager::DeviceReconnectedCallbackHandle peak::DeviceManager::RegisterDeviceReconnectedCallback ( const DeviceReconnectedCallback & callback)
inline

Registers a callback for signaling a reconnected device.

This function registers a callback which gets called every time a device is reconnected. Pass the callback handle returned by this function to UnregisterDeviceReconnectedCallback() to unregister the callback.

Parameters
[in]callbackThe callback to call if a device is reconnected.
Returns
Callback handle
Since
1.7
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ RegisterInterfaceFoundCallback()

DeviceManager::InterfaceFoundCallbackHandle peak::DeviceManager::RegisterInterfaceFoundCallback ( const InterfaceFoundCallback & callback)
inline

Registers a callback for signaling a found interface.

This function registers a callback which gets called every time a new interface is found. Pass the callback handle returned by this function to UnregisterInterfaceFoundCallback() to unregister the callback.

Parameters
[in]callbackThe callback to call if a new interface is found.
Returns
Callback handle
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.
Note
The registered callback is executed in the thread calling Update().

◆ RegisterInterfaceLostCallback()

DeviceManager::InterfaceLostCallbackHandle peak::DeviceManager::RegisterInterfaceLostCallback ( const InterfaceLostCallback & callback)
inline

Registers a callback for signaling a lost interface.

This function registers a callback which gets called every time an interface is lost. Pass the callback handle returned by this function to UnregisterInterfaceLostCallback() to unregister the callback.

Parameters
[in]callbackThe callback to call if an interface is lost.
Returns
Callback handle
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.
Note
The registered callback is executed in the thread calling Update().

◆ RegisterSystemFoundCallback()

DeviceManager::SystemFoundCallbackHandle peak::DeviceManager::RegisterSystemFoundCallback ( const SystemFoundCallback & callback)
inline

Registers a callback for signaling a found system.

This function registers a callback which gets called every time a new system is found. Pass the callback handle returned by this function to UnregisterSystemFoundCallback() to unregister the callback.

Parameters
[in]callbackThe callback to call if a new system is found.
Returns
Callback handle
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.
Note
The registered callback is executed in the thread calling Update().

◆ Reset()

void peak::DeviceManager::Reset ( ResetPolicy resetPolicy = ResetPolicy::ErrorOnOpenDevices)
inline

Resets the DeviceManager.

All Interfaces and Systems are closed, additional ProducerLibraries (added via AddProducerLibrary()) are cleared. Any registered callbacks stay active and the DeviceLostCallback and InterfaceLostCallback are called for all devices / interfaces.

Note
Can't reset the DeviceManager while there are open Devices. Close all devices before calling this method. Otherwise, a core::InternalErrorException is thrown.
Parameters
[in]resetPolicyWith the default ResetPolicy::ErrorOnOpenDevices, an exception is thrown if there are any open devices managed by the DeviceManager. With ResetPolicy::IgnoreOpenDevices, no such exception is thrown.
Since
1.0
Exceptions
core::InternalErrorExceptionIf there are open devices (with ResetPolicy::ErrorOnOpenDevices).

◆ SetDeviceUpdateTimeout()

void peak::DeviceManager::SetDeviceUpdateTimeout ( core::Timeout timeout_ms)
inline

Sets the device update timeout.

Parameters
[in]timeout_msThe time to wait for new devices in milliseconds.
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.
Note
Changes only take effect when they are applied before calling Update(). Changes applied during a running update only take effect with the next call to Update().

◆ SetInterfaceUpdateTimeout()

void peak::DeviceManager::SetInterfaceUpdateTimeout ( core::Timeout timeout_ms)
inline

Sets the interface update timeout.

Parameters
[in]timeout_msThe time to wait for new interfaces in milliseconds.
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.
Note
Changes only take effect when they are applied before calling Update(). Changes applied during a running update only take effect with the next call to Update().

◆ Systems()

std::vector< std::shared_ptr< const core::System > > peak::DeviceManager::Systems ( ) const
inline

Returns the found and opened systems.

Returns
Found and opened systems
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ UnregisterDeviceDisconnectedCallback()

void peak::DeviceManager::UnregisterDeviceDisconnectedCallback ( DeviceManager::DeviceDisconnectedCallbackHandle callbackHandle)
inline

Unregisters a device disconnected callback.

This function unregisters a device disconnected callback by taking its handle.

Parameters
[in]callbackHandleThe handle of the callback to unregister.
Since
1.7
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ UnregisterDeviceFoundCallback()

void peak::DeviceManager::UnregisterDeviceFoundCallback ( DeviceManager::DeviceFoundCallbackHandle callbackHandle)
inline

Unregisters a device found callback.

This function unregisters a device found callback by taking its handle.

Parameters
[in]callbackHandleThe handle of the callback to unregister.
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ UnregisterDeviceListChangedCallback()

void peak::DeviceManager::UnregisterDeviceListChangedCallback ( DeviceManager::DeviceListChangedCallbackHandle callbackHandle)
inline

Unregisters a device list change callback.

This function unregisters a device lost callback by taking its handle.

Parameters
[in]callbackHandleThe handle of the callback to unregister.
Since
1.7
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ UnregisterDeviceLostCallback()

void peak::DeviceManager::UnregisterDeviceLostCallback ( DeviceManager::DeviceLostCallbackHandle callbackHandle)
inline

Unregisters a device lost callback.

This function unregisters a device lost callback by taking its handle.

Parameters
[in]callbackHandleThe handle of the callback to unregister.
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ UnregisterDeviceReconnectedCallback()

void peak::DeviceManager::UnregisterDeviceReconnectedCallback ( DeviceManager::DeviceReconnectedCallbackHandle callbackHandle)
inline

Unregisters a device reconnected callback.

This function unregisters a device reconnected callback by taking its handle.

Parameters
[in]callbackHandleThe handle of the callback to unregister.
Since
1.7
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ UnregisterInterfaceFoundCallback()

void peak::DeviceManager::UnregisterInterfaceFoundCallback ( DeviceManager::InterfaceFoundCallbackHandle callbackHandle)
inline

Unregisters a interface found callback.

This function unregisters a interface found callback by taking its handle.

Parameters
[in]callbackHandleThe handle of the callback to unregister.
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ UnregisterInterfaceLostCallback()

void peak::DeviceManager::UnregisterInterfaceLostCallback ( DeviceManager::InterfaceLostCallbackHandle callbackHandle)
inline

Unregisters an interface lost callback.

This function unregisters an interface lost callback by taking its handle.

Parameters
[in]callbackHandleThe handle of the callback to unregister.
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ UnregisterSystemFoundCallback()

void peak::DeviceManager::UnregisterSystemFoundCallback ( DeviceManager::SystemFoundCallbackHandle callbackHandle)
inline

Unregisters a system found callback.

This function unregisters a system found callback by taking its handle.

Parameters
[in]callbackHandleThe handle of the callback to unregister.
Since
1.0
Exceptions
core::InternalErrorExceptionAn internal error has occurred.

◆ Update()

void peak::DeviceManager::Update ( UpdatePolicy updatePolicy = UpdatePolicy::ScanEnvironmentForProducerLibraries,
const UpdateErrorCallback & errorCallback = UpdateErrorCallback() )
inline

Starts an update.

If there is already an update in progress, it waits for the previous update to finish before starting the new update.

Parameters
[in]updatePolicyThe update policy to use.
[in]errorCallbackA thread-safe callback getting called for each error occurring during the update.
Since
1.0
Exceptions
core::NotInitializedExceptionThe library was not initialized before use.
core::InternalErrorExceptionAn internal error has occurred.
core::NotFoundExceptionThe environment variable GENICAM_GENTL32_PATH / GENICAM_GENTL64_PATH was not found or was empty when scanning for environment ProducerLibraries.
core::CTILoadingExceptionA error has occurred when loading a CTI from the environment variable GENICAM_GENTL32_PATH / GENICAM_GENTL64_PATH.

◆ Library

friend class Library
friend

The documentation for this class was generated from the following file: