19 #include <peak/dll_interface/peak_dll_interface_util.hpp> 20 #include <peak/generic/peak_t_callback_manager.hpp> 122 std::string Key()
const;
171 std::string
TLType()
const;
227 std::shared_ptr<Interface> ParentInterface()
const;
279 std::shared_ptr<Device> OpenedDevice()
const;
323 uint64_t MonitoringUpdateInterval()
const;
333 void SetMonitoringUpdateInterval(uint64_t monitoringUpdateInterval_ms);
400 friend ClassCreator<DeviceDescriptor>;
407 std::weak_ptr<Interface> m_parentInterface;
408 std::weak_ptr<Device> m_openedDevice;
411 TCallbackManager<PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE, InformationChangedCallback>>
412 m_informationChangedCallbackManager;
414 TTriggerCallbackManager<DeviceOpenedCallbackHandle, DeviceOpenedCallback> m_deviceOpenedCallbackManager;
432 std::string entryString;
436 entryString =
"ReadOnly";
440 entryString =
"Control";
444 entryString =
"Exclusive";
448 entryString =
"Custom";
456 std::string entryString;
464 entryString =
"VendorName";
468 entryString =
"ModelName";
472 entryString =
"TLType";
476 entryString =
"DisplayName";
480 entryString =
"AccessStatus";
484 entryString =
"UserDefinedName";
488 entryString =
"SerialNumber";
492 entryString =
"Version";
496 entryString =
"TimestampTickFrequency";
500 entryString =
"Custom";
508 : m_backendHandle(deviceDescriptorHandle)
509 , m_parentInterface(parentInterface)
510 , m_informationChangedCallbackManager()
511 , m_key(QueryStringFromCInterfaceFunction([&](
char* key,
size_t* keySize) {
515 m_informationChangedCallbackManager = std::make_unique<
516 TCallbackManager<PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE, InformationChangedCallback>>(
517 [&](
void* callbackContext) {
518 return QueryNumericFromCInterfaceFunction<PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE>(
520 deviceDescriptorChangedCallbackHandle) {
522 m_backendHandle, InformationChangedCallbackCWrapper, callbackContext,
523 deviceDescriptorChangedCallbackHandle);
527 CallAndCheckCInterfaceFunction([&] {
529 m_backendHandle, callbackHandle);
538 m_informationChangedCallbackManager->UnregisterAllCallbacks();
551 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer,
size_t* bufferSize) {
553 m_backendHandle, infoCommand, dataType, buffer, bufferSize);
559 return QueryStringFromCInterfaceFunction([&](
char* displayName,
size_t* displayNameSize) {
561 m_backendHandle, displayName, displayNameSize);
567 return QueryStringFromCInterfaceFunction([&](
char* vendorName,
size_t* vendorNameSize) {
574 return QueryStringFromCInterfaceFunction([&](
char* modelName,
size_t* modelNameSize) {
581 return QueryStringFromCInterfaceFunction([&](
char* version,
size_t* versionSize) {
588 return QueryStringFromCInterfaceFunction([&](
char* tlType,
size_t* tlTypeSize) {
595 return QueryStringFromCInterfaceFunction([&](
char* userDefinedName,
size_t* userDefinedNameSize) {
597 m_backendHandle, userDefinedName, userDefinedNameSize);
603 return QueryStringFromCInterfaceFunction([&](
char* serialNumber,
size_t* serialNumberSize) {
605 m_backendHandle, serialNumber, serialNumberSize);
611 return static_cast<DeviceAccessStatus>(QueryNumericFromCInterfaceFunction<PEAK_DEVICE_ACCESS_STATUS>(
619 return QueryNumericFromCInterfaceFunction<uint64_t>([&](uint64_t* timestampTickFrequency) {
621 m_backendHandle, timestampTickFrequency);
627 return LockOrThrow(m_parentInterface);
632 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isAccessTypeAvailable) {
634 m_backendHandle, static_cast<PEAK_DEVICE_ACCESS_TYPE>(accessType), isAccessTypeAvailable);
640 auto deviceHandle = QueryNumericFromCInterfaceFunction<PEAK_DEVICE_HANDLE>(
643 m_backendHandle, static_cast<PEAK_DEVICE_ACCESS_TYPE>(accessType), _deviceHandle);
646 auto device = std::make_shared<ClassCreator<Device>>(deviceHandle, m_parentInterface);
647 m_openedDevice = device;
648 m_deviceOpenedCallbackManager.TriggerCallbacks(device);
655 return LockOrThrowOpenedModule(m_openedDevice);
661 return m_deviceOpenedCallbackManager.RegisterCallback(callback);
666 return m_deviceOpenedCallbackManager.UnregisterCallback(callback);
671 return QueryNumericFromCInterfaceFunction<uint64_t>([&](uint64_t* monitoringUpdateInterval_ms) {
673 m_backendHandle, monitoringUpdateInterval_ms);
679 return CallAndCheckCInterfaceFunction([&] {
681 m_backendHandle, monitoringUpdateInterval_ms);
687 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isInformationRoleMonitored) {
689 m_backendHandle, static_cast<PEAK_DEVICE_INFORMATION_ROLE>(informationRole), isInformationRoleMonitored);
695 return CallAndCheckCInterfaceFunction([&] {
697 m_backendHandle, static_cast<PEAK_DEVICE_INFORMATION_ROLE>(informationRole));
703 return CallAndCheckCInterfaceFunction([&] {
705 m_backendHandle, static_cast<PEAK_DEVICE_INFORMATION_ROLE>(informationRole));
713 m_informationChangedCallbackManager->RegisterCallback(callback));
718 m_informationChangedCallbackManager->UnregisterCallback(
719 reinterpret_cast<PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE>(callbackHandle));
722 inline void PEAK_CALL_CONV DeviceDescriptor::InformationChangedCallbackCWrapper(
726 std::vector<DeviceInformationRole> changedRolesVec;
727 changedRolesVec.reserve(changedRolesSize);
728 for (
size_t i = 0; i < changedRolesSize; ++i)
730 changedRolesVec.emplace_back(static_cast<DeviceInformationRole>(*(changedRoles + i)));
732 callback->operator()(changedRolesVec);
737 auto moduleDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_DESCRIPTOR_HANDLE>(
740 m_backendHandle, _moduleDescriptorHandle);
743 return moduleDescriptorHandle;
std::string Key() const
Returns the unique key.
Definition: peak_device_descriptor.hpp:544
std::function< void(const std::shared_ptr< core::Device > &openedDevice)> DeviceOpenedCallback
Definition: peak_device_descriptor.hpp:110
Encapsulates the GenTL functions associated with a GenTL Device module's ID.
Definition: peak_device_descriptor.hpp:102
PEAK_C_API PEAK_DeviceDescriptor_GetVendorName(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *vendorName, size_t *vendorNameSize)
Asks the given device descriptor for its vendor name.
int8_t PEAK_BOOL8
Definition: peak_backend.h:26
PEAK_C_API PEAK_DeviceDescriptor_OpenDevice(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_DEVICE_ACCESS_TYPE accessType, PEAK_DEVICE_HANDLE *deviceHandle)
Opens the device being associated with the given interface descriptor for the given access type...
int32_t PEAK_DEVICE_INFORMATION_ROLE
Definition: peak_backend.h:146
PEAK_C_API PEAK_DeviceDescriptor_IsInformationRoleMonitored(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_DEVICE_INFORMATION_ROLE informationRole, PEAK_BOOL8 *isInformationRoleMonitored)
Asks the given device descriptor whether the given information role is monitored. ...
PEAK_C_API PEAK_DeviceDescriptor_GetAccessStatus(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_DEVICE_ACCESS_STATUS *accessStatus)
Asks the given device descriptor for its access status.
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition: peak_dynamic_loader.h:32
void UnregisterDeviceOpenedCallback(DeviceOpenedCallbackHandle callbackHandle)
Unregisters a device opened callback.
Definition: peak_device_descriptor.hpp:664
std::string ToString(BufferPayloadType entry)
Definition: peak_buffer.hpp:472
std::string VendorName() const
Returns the vendor name.
Definition: peak_device_descriptor.hpp:565
PEAK_C_API PEAK_DeviceDescriptor_GetVersion(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *version, size_t *versionSize)
Asks the given device descriptor for its version.
PEAK_C_API PEAK_DeviceDescriptor_GetTLType(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *tlType, size_t *tlTypeSize)
Asks the given device descriptor for its TL type.
std::function< void(const std::vector< DeviceInformationRole > &changedRoles)> InformationChangedCallback
Definition: peak_device_descriptor.hpp:106
bool IsOpenable(DeviceAccessType accessType=DeviceAccessType::Exclusive) const
Checks whether the device can be opened with a specific access type.
Definition: peak_device_descriptor.hpp:630
DeviceAccessStatus
Current accessibility of the device.
Definition: peak_common_device_enums.hpp:24
DeviceInformationRole
Different types of information about the device.
Definition: peak_device_descriptor.hpp:52
void AddInformationRoleToMonitoring(DeviceInformationRole informationRole)
Adds the given information role to the monitoring.
Definition: peak_device_descriptor.hpp:693
bool IsInformationRoleMonitored(DeviceInformationRole informationRole) const
Checks whether the given information role is monitored.
Definition: peak_device_descriptor.hpp:685
DeviceOpenedCallbackHandle RegisterDeviceOpenedCallback(const DeviceOpenedCallback &callback)
Registers a callback for signaling when the Device is opened with this DeviceDescriptor.
Definition: peak_device_descriptor.hpp:658
Allows to update the firmware of a device.
Definition: peak_firmware_updater.hpp:45
Represents a GenTL Interface module.
Definition: peak_interface.hpp:45
InformationChangedCallback * InformationChangedCallbackHandle
Definition: peak_device_descriptor.hpp:108
std::string TLType() const
Returns the TL (transport layer) type.
Definition: peak_device_descriptor.hpp:586
std::shared_ptr< Interface > ParentInterface() const
Returns the parent interface.
Definition: peak_device_descriptor.hpp:625
std::string Version() const
Returns the version.
Definition: peak_device_descriptor.hpp:579
struct PEAK_MODULE_DESCRIPTOR * PEAK_MODULE_DESCRIPTOR_HANDLE
Definition: peak_backend.h:397
PEAK_C_API PEAK_DeviceDescriptor_ToModuleDescriptor(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_MODULE_DESCRIPTOR_HANDLE *moduleDescriptorHandle)
Casts the given device descriptor to a module descriptor.
PEAK_C_API PEAK_DeviceDescriptor_GetModelName(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *modelName, size_t *modelNameSize)
Asks the given device descriptor for its model name.
PEAK_C_API PEAK_DeviceDescriptor_AddInformationRoleToMonitoring(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_DEVICE_INFORMATION_ROLE informationRole)
Tells the given device descriptor to add the given information role to the monitoring.
PEAK_C_API PEAK_DeviceDescriptor_GetDisplayName(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *displayName, size_t *displayNameSize)
Asks the given device descriptor for its display name.
std::string DisplayName() const
Returns the display name.
Definition: peak_device_descriptor.hpp:557
PEAK_C_API PEAK_DeviceDescriptor_RegisterInformationChangedCallback(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK callback, void *callbackContext, PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE *callbackHandle)
Registers a callback signaling changed information at the given device descriptor.
std::shared_ptr< Device > OpenDevice(DeviceAccessType accessType)
Opens the Device.
Definition: peak_device_descriptor.hpp:638
PEAK_C_API PEAK_DeviceDescriptor_GetSerialNumber(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *serialNumber, size_t *serialNumberSize)
Asks the given device descriptor for its serial number.
DeviceDescriptor()=delete
RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition: peak_device_descriptor.hpp:549
The base class for all openable modules.
Definition: peak_module_descriptor.hpp:30
std::string SerialNumber() const
Returns the serial number.
Definition: peak_device_descriptor.hpp:601
The base class for all exceptions thrown by the library.
Definition: peak_exception.hpp:25
PEAK_C_API PEAK_DeviceDescriptor_GetIsOpenable(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_DEVICE_ACCESS_TYPE accessType, PEAK_BOOL8 *isOpenable)
Asks the given device descriptor whether the device can be opened with this specific access type...
PEAK_C_API PEAK_DeviceDescriptor_GetTimestampTickFrequency(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, uint64_t *timestampTickFrequency)
Asks the given device descriptor for its timestamp tick frequency.
uint64_t TimestampTickFrequency() const
Returns the timestamp tick frequency.
Definition: peak_device_descriptor.hpp:617
PEAK_C_API PEAK_DeviceDescriptor_GetInfo(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, int32_t infoCommand, int32_t *infoDataType, uint8_t *info, size_t *infoSize)
Asks the given device descriptor for an information based on a specific command.
PEAK_C_API PEAK_DeviceDescriptor_UnregisterInformationChangedCallback(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE callbackHandle)
Unregisters the information changed callback with the given handle from the given device descriptor...
struct PEAK_DEVICE_DESCRIPTOR * PEAK_DEVICE_DESCRIPTOR_HANDLE
Definition: peak_backend.h:365
DeviceOpenedCallback * DeviceOpenedCallbackHandle
Definition: peak_device_descriptor.hpp:112
#define PEAK_CALL_CONV
Definition: peak_dynamic_loader.h:29
#define PEAK_C_ABI_PREFIX
Definition: peak_dll_defines.h:16
PEAK_C_API PEAK_DeviceDescriptor_RemoveInformationRoleFromMonitoring(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_DEVICE_INFORMATION_ROLE informationRole)
Tells the given device descriptor to remove the given information role from the monitoring.
PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK * PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE
Definition: peak_backend.h:515
std::string UserDefinedName() const
Returns the user defined name.
Definition: peak_device_descriptor.hpp:593
InformationChangedCallbackHandle RegisterInformationChangedCallback(const InformationChangedCallback &callback)
Registers a callback for signaling changed information.
Definition: peak_device_descriptor.hpp:709
int32_t PEAK_DEVICE_ACCESS_STATUS
Definition: peak_backend.h:117
uint64_t MonitoringUpdateInterval() const
Returns the monitoring update interval.
Definition: peak_device_descriptor.hpp:669
PEAK_C_API PEAK_DeviceDescriptor_GetUserDefinedName(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *userDefinedName, size_t *userDefinedNameSize)
Asks the given device descriptor for its user-defined name.
DeviceAccessStatus AccessStatus() const
Returns the access status.
Definition: peak_device_descriptor.hpp:609
PEAK_C_API PEAK_DeviceDescriptor_SetMonitoringUpdateInterval(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, uint64_t monitoringUpdateInterval_ms)
Tells the given device descriptor to set the given monitoring update interval.
void RemoveInformationRoleFromMonitoring(DeviceInformationRole informationRole)
Removes the given information role from the monitoring.
Definition: peak_device_descriptor.hpp:701
void SetMonitoringUpdateInterval(uint64_t monitoringUpdateInterval_ms)
Sets the monitoring update interval.
Definition: peak_device_descriptor.hpp:677
std::shared_ptr< Device > OpenedDevice() const
Returns the Device that was opened with this DeviceDescriptor.
Definition: peak_device_descriptor.hpp:653
PEAK_C_API PEAK_DeviceDescriptor_GetMonitoringUpdateInterval(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, uint64_t *monitoringUpdateInterval_ms)
Asks the given device descriptor for its monitoring update interval.
struct PEAK_DEVICE * PEAK_DEVICE_HANDLE
Definition: peak_backend.h:369
~DeviceDescriptor() override
Definition: peak_device_descriptor.hpp:534
std::string ModelName() const
Returns the model name.
Definition: peak_device_descriptor.hpp:572
PEAK_C_API PEAK_DeviceDescriptor_GetKey(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *key, size_t *keySize)
Asks the given device descriptor for its key.
DeviceAccessType
Different modes to open the device with.
Definition: peak_device_descriptor.hpp:38
void UnregisterInformationChangedCallback(InformationChangedCallbackHandle callbackHandle)
Unregisters an information changed callback.
Definition: peak_device_descriptor.hpp:716