16#include <peak/dll_interface/peak_dll_interface_util.hpp>
17#include <peak/generic/peak_t_callback_manager.hpp>
429 static void PEAK_CALL_CONV InformationChangedCallbackCWrapper(
432 friend ClassCreator<DeviceDescriptor>;
439 std::weak_ptr<Interface> m_parentInterface;
440 std::weak_ptr<Device> m_openedDevice;
443 TCallbackManager<PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE, InformationChangedCallback>>
444 m_informationChangedCallbackManager;
446 TTriggerCallbackManager<DeviceOpenedCallbackHandle, DeviceOpenedCallback> m_deviceOpenedCallbackManager;
464 std::string entryString;
468 entryString =
"ReadOnly";
472 entryString =
"Control";
476 entryString =
"Exclusive";
480 entryString =
"Custom";
488 std::string entryString;
496 entryString =
"VendorName";
500 entryString =
"ModelName";
504 entryString =
"TLType";
508 entryString =
"DisplayName";
512 entryString =
"AccessStatus";
516 entryString =
"UserDefinedName";
520 entryString =
"SerialNumber";
524 entryString =
"Version";
528 entryString =
"TimestampTickFrequency";
532 entryString =
"Custom";
540 : m_backendHandle(deviceDescriptorHandle)
541 , m_parentInterface(parentInterface)
542 , m_informationChangedCallbackManager()
543 , m_key(QueryStringFromCInterfaceFunction([&](char* key, size_t* keySize) {
547 m_informationChangedCallbackManager = std::make_unique<
548 TCallbackManager<PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE, InformationChangedCallback>>(
549 [&](
void* callbackContext) {
550 return QueryNumericFromCInterfaceFunction<PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE>(
552 deviceDescriptorChangedCallbackHandle) {
554 m_backendHandle, InformationChangedCallbackCWrapper, callbackContext,
555 deviceDescriptorChangedCallbackHandle);
559 CallAndCheckCInterfaceFunction([&] {
561 m_backendHandle, callbackHandle);
570 m_informationChangedCallbackManager->UnregisterAllCallbacks();
583 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer,
size_t* bufferSize) {
585 m_backendHandle, infoCommand, dataType, buffer, bufferSize);
591 return QueryStringFromCInterfaceFunctionWithBufferSize([&](
char* displayName,
size_t* displayNameSize) {
593 m_backendHandle, displayName, displayNameSize);
599 return QueryStringFromCInterfaceFunctionWithBufferSize([&](
char* vendorName,
size_t* vendorNameSize) {
606 return QueryStringFromCInterfaceFunctionWithBufferSize([&](
char* modelName,
size_t* modelNameSize) {
613 return QueryStringFromCInterfaceFunctionWithBufferSize([&](
char* version,
size_t* versionSize) {
620 return QueryStringFromCInterfaceFunctionWithBufferSize([&](
char* tlType,
size_t* tlTypeSize) {
627 return QueryStringFromCInterfaceFunctionWithBufferSize([&](
char* userDefinedName,
size_t* userDefinedNameSize) {
629 m_backendHandle, userDefinedName, userDefinedNameSize);
635 return QueryStringFromCInterfaceFunctionWithBufferSize([&](
char* serialNumber,
size_t* serialNumberSize) {
637 m_backendHandle, serialNumber, serialNumberSize);
643 return static_cast<DeviceAccessStatus>(QueryNumericFromCInterfaceFunction<PEAK_DEVICE_ACCESS_STATUS>(
651 return QueryNumericFromCInterfaceFunction<uint64_t>([&](uint64_t* timestampTickFrequency) {
653 m_backendHandle, timestampTickFrequency);
659 return LockOrThrow(m_parentInterface);
664 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isAccessTypeAvailable) {
672 auto deviceHandle = QueryNumericFromCInterfaceFunction<PEAK_DEVICE_HANDLE>(
678 auto device = std::make_shared<ClassCreator<Device>>(deviceHandle, m_parentInterface);
679 m_openedDevice = device;
680 m_deviceOpenedCallbackManager.TriggerCallbacks(device);
687 return LockOrThrowOpenedModule(m_openedDevice);
692 return !m_openedDevice.expired();
698 return m_deviceOpenedCallbackManager.RegisterCallback(callback);
703 return m_deviceOpenedCallbackManager.UnregisterCallback(callback);
708 return QueryNumericFromCInterfaceFunction<uint64_t>([&](uint64_t* monitoringUpdateInterval_ms) {
710 m_backendHandle, monitoringUpdateInterval_ms);
716 return CallAndCheckCInterfaceFunction([&] {
718 m_backendHandle, monitoringUpdateInterval_ms);
724 return QueryNumericFromCInterfaceFunction<PEAK_BOOL8>([&](
PEAK_BOOL8* isInformationRoleMonitored) {
732 return CallAndCheckCInterfaceFunction([&] {
740 return CallAndCheckCInterfaceFunction([&] {
750 m_informationChangedCallbackManager->RegisterCallback(callback));
755 m_informationChangedCallbackManager->UnregisterCallback(
759inline void PEAK_CALL_CONV DeviceDescriptor::InformationChangedCallbackCWrapper(
763 std::vector<DeviceInformationRole> changedRolesVec;
764 changedRolesVec.reserve(changedRolesSize);
765 for (
size_t i = 0; i < changedRolesSize; ++i)
769 callback->operator()(changedRolesVec);
774 auto moduleDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_DESCRIPTOR_HANDLE>(
777 m_backendHandle, _moduleDescriptorHandle);
780 return moduleDescriptorHandle;
PEAK_COMMON_NO_DISCARD std::string Key() const
Returns the unique key.
Definition peak_device_descriptor.hpp:576
DeviceDescriptor()=delete
PEAK_COMMON_NO_DISCARD std::string ModelName() const
Returns the model name.
Definition peak_device_descriptor.hpp:604
void UnregisterDeviceOpenedCallback(DeviceOpenedCallbackHandle callbackHandle)
Unregisters a device opened callback.
Definition peak_device_descriptor.hpp:701
std::function< void(const std::shared_ptr< core::Device > &openedDevice)> DeviceOpenedCallback
Definition peak_device_descriptor.hpp:110
PEAK_COMMON_NO_DISCARD std::string VendorName() const
Returns the vendor name.
Definition peak_device_descriptor.hpp:597
void RemoveInformationRoleFromMonitoring(DeviceInformationRole informationRole)
Removes the given information role from the monitoring.
Definition peak_device_descriptor.hpp:738
PEAK_COMMON_NO_DISCARD DeviceAccessStatus AccessStatus() const
Returns the access status.
Definition peak_device_descriptor.hpp:641
InformationChangedCallback * InformationChangedCallbackHandle
Definition peak_device_descriptor.hpp:108
~DeviceDescriptor() override
Definition peak_device_descriptor.hpp:566
DeviceDescriptor & operator=(const DeviceDescriptor &other)=delete
PEAK_COMMON_NO_DISCARD std::shared_ptr< Device > OpenDevice(DeviceAccessType accessType)
Opens the Device.
Definition peak_device_descriptor.hpp:670
std::function< void(const std::vector< DeviceInformationRole > &changedRoles)> InformationChangedCallback
Definition peak_device_descriptor.hpp:106
PEAK_COMMON_NO_DISCARD bool IsOpenable(DeviceAccessType accessType=DeviceAccessType::Exclusive) const
Checks whether the device can be opened with a specific access type.
Definition peak_device_descriptor.hpp:662
void AddInformationRoleToMonitoring(DeviceInformationRole informationRole)
Adds the given information role to the monitoring.
Definition peak_device_descriptor.hpp:730
DeviceOpenedCallbackHandle RegisterDeviceOpenedCallback(const DeviceOpenedCallback &callback)
Registers a callback for signaling when the Device is opened with this DeviceDescriptor.
Definition peak_device_descriptor.hpp:695
InformationChangedCallbackHandle RegisterInformationChangedCallback(const InformationChangedCallback &callback)
Registers a callback for signaling changed information.
Definition peak_device_descriptor.hpp:746
PEAK_COMMON_NO_DISCARD std::string DisplayName() const
Returns the display name.
Definition peak_device_descriptor.hpp:589
PEAK_COMMON_NO_DISCARD std::shared_ptr< Interface > ParentInterface() const
Returns the parent interface.
Definition peak_device_descriptor.hpp:657
DeviceDescriptor(DeviceDescriptor &&other)=delete
void UnregisterInformationChangedCallback(InformationChangedCallbackHandle callbackHandle)
Unregisters an information changed callback.
Definition peak_device_descriptor.hpp:753
PEAK_COMMON_NO_DISCARD std::string TLType() const
Returns the TL (transport layer) type.
Definition peak_device_descriptor.hpp:618
PEAK_COMMON_NO_DISCARD std::string Version() const
Returns the version.
Definition peak_device_descriptor.hpp:611
PEAK_COMMON_NO_DISCARD bool IsOpened() const
Returns whether the device is open.
Definition peak_device_descriptor.hpp:690
void SetMonitoringUpdateInterval(uint64_t monitoringUpdateInterval_ms)
Sets the monitoring update interval.
Definition peak_device_descriptor.hpp:714
PEAK_COMMON_NO_DISCARD uint64_t MonitoringUpdateInterval() const
Returns the monitoring update interval.
Definition peak_device_descriptor.hpp:706
DeviceOpenedCallback * DeviceOpenedCallbackHandle
Definition peak_device_descriptor.hpp:112
PEAK_COMMON_NO_DISCARD std::shared_ptr< Device > OpenedDevice() const
Returns the Device that was opened with this DeviceDescriptor.
Definition peak_device_descriptor.hpp:685
PEAK_COMMON_NO_DISCARD RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition peak_device_descriptor.hpp:581
PEAK_COMMON_NO_DISCARD uint64_t TimestampTickFrequency() const
Returns the timestamp tick frequency.
Definition peak_device_descriptor.hpp:649
PEAK_COMMON_NO_DISCARD std::string SerialNumber() const
Returns the serial number.
Definition peak_device_descriptor.hpp:633
friend class FirmwareUpdater
Definition peak_device_descriptor.hpp:450
PEAK_COMMON_NO_DISCARD bool IsInformationRoleMonitored(DeviceInformationRole informationRole) const
Checks whether the given information role is monitored.
Definition peak_device_descriptor.hpp:722
PEAK_COMMON_NO_DISCARD std::string UserDefinedName() const
Returns the user defined name.
Definition peak_device_descriptor.hpp:625
DeviceDescriptor(const DeviceDescriptor &other)=delete
DeviceDescriptor & operator=(DeviceDescriptor &&other)=delete
The base class for all exceptions thrown by the library.
Definition peak_exception.hpp:24
ModuleDescriptor()=default
virtual PEAK_MODULE_DESCRIPTOR_HANDLE ModuleDescriptorHandle() const =0
Implements versioning functionality.
Definition peak_version.hpp:33
@ Custom
Definition peak_buffer.hpp:54
DeviceAccessType
Different modes to open the device with.
Definition peak_device_descriptor.hpp:37
DeviceInformationRole
Different types of information about the device.
Definition peak_device_descriptor.hpp:52
DeviceAccessStatus
Current accessibility of the device.
Definition peak_common_device_enums.hpp:23
@ ReadOnly
Definition peak_device_descriptor.hpp:38
@ Exclusive
Definition peak_device_descriptor.hpp:40
@ Custom
Definition peak_device_descriptor.hpp:42
@ Control
Definition peak_device_descriptor.hpp:39
@ Version
Definition peak_device_descriptor.hpp:61
@ DisplayName
Definition peak_device_descriptor.hpp:57
@ TimestampTickFrequency
Definition peak_device_descriptor.hpp:62
@ ModelName
Definition peak_device_descriptor.hpp:55
@ AccessStatus
Definition peak_device_descriptor.hpp:58
@ TLType
Definition peak_device_descriptor.hpp:56
@ Custom
Definition peak_device_descriptor.hpp:64
@ SerialNumber
Definition peak_device_descriptor.hpp:60
@ ID
Definition peak_device_descriptor.hpp:53
@ VendorName
Definition peak_device_descriptor.hpp:54
@ UserDefinedName
Definition peak_device_descriptor.hpp:59
@ ReadOnly
Definition peak_common_device_enums.hpp:25
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:32
std::string ToString(BufferPayloadType entry)
Definition peak_buffer.hpp:635
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_buffer.hpp:29
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.
struct PEAK_MODULE_DESCRIPTOR * PEAK_MODULE_DESCRIPTOR_HANDLE
Definition peak_backend.h:415
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.
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.
PEAK_C_API PEAK_DeviceDescriptor_GetKey(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *key, size_t *keySize)
Asks the given device descriptor for its key.
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.
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.
PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK * PEAK_DEVICE_DESCRIPTOR_INFORMATION_CHANGED_CALLBACK_HANDLE
Definition peak_backend.h:587
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.
PEAK_C_API PEAK_DeviceDescriptor_GetTimestampTickFrequency(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, uint64_t *timestampTickFrequency)
Asks the given device descriptor for its timestamp tick frequency.
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.
PEAK_C_API PEAK_DeviceDescriptor_GetVersion(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *version, size_t *versionSize)
Asks the given device descriptor for its version.
int8_t PEAK_BOOL8
Definition peak_backend.h:41
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_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_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.
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_GetVendorName(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, char *vendorName, size_t *vendorNameSize)
Asks the given device descriptor for its vendor name.
int32_t PEAK_DEVICE_INFORMATION_ROLE
Definition peak_backend.h:161
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.
int32_t PEAK_DEVICE_ACCESS_TYPE
Definition peak_backend.h:143
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.
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.
struct PEAK_DEVICE_DESCRIPTOR * PEAK_DEVICE_DESCRIPTOR_HANDLE
Definition peak_backend.h:383
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.
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_ToModuleDescriptor(PEAK_DEVICE_DESCRIPTOR_HANDLE deviceDescriptorHandle, PEAK_MODULE_DESCRIPTOR_HANDLE *moduleDescriptorHandle)
Casts the given device descriptor to a module descriptor.
struct PEAK_DEVICE * PEAK_DEVICE_HANDLE
Definition peak_backend.h:387
int32_t PEAK_DEVICE_ACCESS_STATUS
Definition peak_backend.h:132
#define PEAK_COMMON_NO_DISCARD
Definition peak_common_defines.h:89
#define PEAK_C_ABI_PREFIX
Definition peak_dll_defines.h:13