20 #include <peak/dll_interface/peak_dll_interface_util.hpp> 54 ,
public std::enable_shared_from_this<Device>
65 std::string
Key()
const;
71 std::string
ID()
const;
86 std::string
TLType()
const;
112 std::shared_ptr<class RemoteDevice>
RemoteDevice()
const;
123 std::vector<std::shared_ptr<DataStreamDescriptor>>
DataStreams()
const;
139 return m_backendHandle;
146 friend ClassCreator<Device>;
150 std::weak_ptr<Interface> m_parentInterface;
152 void Initialize()
const override;
153 mutable std::vector<std::shared_ptr<DataStreamDescriptor>> m_dataStreams;
154 mutable std::shared_ptr<class RemoteDevice> m_remoteDevice;
169 : m_backendHandle(deviceHandle)
170 , m_parentInterface(parentInterface)
171 , m_key(QueryStringFromCInterfaceFunction([&](
char* key,
size_t* keySize) {
188 return QueryRawInformationFromCInterfaceFunction([&](int32_t* dataType, uint8_t* buffer,
size_t* bufferSize) {
195 return QueryStringFromCInterfaceFunction([&](
char*
id,
size_t* idSize) {
202 return QueryStringFromCInterfaceFunction([&](
char* displayName,
size_t* displayNameSize) {
209 return QueryStringFromCInterfaceFunction([&](
char* vendorName,
size_t* vendorNameSize) {
216 return QueryStringFromCInterfaceFunction([&](
char* modelName,
size_t* modelNameSize) {
223 return QueryStringFromCInterfaceFunction([&](
char* version,
size_t* versionSize) {
230 return QueryStringFromCInterfaceFunction([&](
char* tlType,
size_t* tlTypeSize) {
237 return QueryStringFromCInterfaceFunction([&](
char* userDefinedName,
size_t* userDefinedNameSize) {
239 m_backendHandle, userDefinedName, userDefinedNameSize);
245 return QueryStringFromCInterfaceFunction([&](
char* serialNumber,
size_t* serialNumberSize) {
252 return static_cast<DeviceAccessStatus>(QueryNumericFromCInterfaceFunction<PEAK_DEVICE_ACCESS_STATUS>(
260 return QueryNumericFromCInterfaceFunction<uint64_t>([&](uint64_t* timestampTickFrequency) {
267 InitializeIfNecessary();
269 return m_remoteDevice;
274 InitializeIfNecessary();
276 return m_dataStreams;
281 return LockOrThrow(m_parentInterface);
286 auto moduleHandle = QueryNumericFromCInterfaceFunction<PEAK_MODULE_HANDLE>(
296 auto eventSupportingModuleHandle = QueryNumericFromCInterfaceFunction<PEAK_EVENT_SUPPORTING_MODULE_HANDLE>(
299 m_backendHandle, _eventSupportingModuleHandle);
302 return eventSupportingModuleHandle;
305 inline void Device::Initialize()
const 307 EventSupportingModule::Initialize();
310 auto numDataStreams = QueryNumericFromCInterfaceFunction<size_t>([&](
size_t* _numDataStreams) {
314 std::vector<std::shared_ptr<DataStreamDescriptor>> dataStreams;
315 for (
size_t x = 0; x < numDataStreams; ++x)
317 auto dataStreamDescriptorHandle = QueryNumericFromCInterfaceFunction<PEAK_DATA_STREAM_DESCRIPTOR_HANDLE>(
320 m_backendHandle, x, _dataStreamDescriptorHandle);
323 dataStreams.emplace_back(std::make_shared<ClassCreator<DataStreamDescriptor>>(
324 dataStreamDescriptorHandle, std::const_pointer_cast<Device>(shared_from_this())));
327 m_dataStreams = dataStreams;
330 auto remoteDeviceHandle = QueryNumericFromCInterfaceFunction<PEAK_REMOTE_DEVICE_HANDLE>(
335 m_remoteDevice = std::make_shared<ClassCreator<peak::core::RemoteDevice>>(
336 remoteDeviceHandle, std::const_pointer_cast<
Device>(shared_from_this()));
PEAK_C_API PEAK_Device_GetDisplayName(PEAK_DEVICE_HANDLE deviceHandle, char *displayName, size_t *displayNameSize)
Asks the given device for its display name.
PEAK_C_API PEAK_Device_GetAccessStatus(PEAK_DEVICE_HANDLE deviceHandle, PEAK_DEVICE_ACCESS_STATUS *accessStatus)
Asks the given device for its access status.
PEAK_C_API PEAK_Device_ToModule(PEAK_DEVICE_HANDLE deviceHandle, PEAK_MODULE_HANDLE *moduleHandle)
Casts the given device to a module.
PEAK_C_API PEAK_Device_GetModelName(PEAK_DEVICE_HANDLE deviceHandle, char *modelName, size_t *modelNameSize)
Asks the given device for its model name.
std::string UserDefinedName() const
Returns the user defined name.
Definition: peak_device.hpp:235
std::string ModelName() const
Returns the model name.
Definition: peak_device.hpp:214
PEAK_C_API PEAK_Device_GetKey(PEAK_DEVICE_HANDLE deviceHandle, char *key, size_t *keySize)
Asks the given device for its key.
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition: peak_dynamic_loader.h:32
struct PEAK_EVENT_SUPPORTING_MODULE * PEAK_EVENT_SUPPORTING_MODULE_HANDLE
Definition: peak_backend.h:459
DeviceAccessStatus AccessStatus() const
Returns the access status.
Definition: peak_device.hpp:250
PEAK_C_API PEAK_Device_GetInfo(PEAK_DEVICE_HANDLE deviceHandle, int32_t infoCommand, int32_t *infoDataType, uint8_t *info, size_t *infoSize)
Asks the given device for an information based on a specific command.
PEAK_C_API PEAK_Device_GetUserDefinedName(PEAK_DEVICE_HANDLE deviceHandle, char *userDefinedName, size_t *userDefinedNameSize)
Asks the given device for its user-defined name.
DeviceAccessStatus
Current accessibility of the device.
Definition: peak_common_device_enums.hpp:24
~Device() override
Definition: peak_device.hpp:176
PEAK_C_API PEAK_Device_GetVersion(PEAK_DEVICE_HANDLE deviceHandle, char *version, size_t *versionSize)
Asks the given device for its version.
std::string ID() const
Returns the ID.
Definition: peak_device.hpp:193
std::string Key() const
Returns the unique key.
Definition: peak_device.hpp:181
Represents a GenTL Device module, i.e. a local virtual Device proxy for the actual hardware RemoteDev...
Definition: peak_device.hpp:52
PEAK_C_API PEAK_Device_GetRemoteDevice(PEAK_DEVICE_HANDLE deviceHandle, PEAK_REMOTE_DEVICE_HANDLE *remoteDeviceHandle)
Asks the given device for its remote device.
std::string Version() const
Returns the version.
Definition: peak_device.hpp:221
struct PEAK_REMOTE_DEVICE * PEAK_REMOTE_DEVICE_HANDLE
Definition: peak_backend.h:375
PEAK_C_API PEAK_Device_Destruct(PEAK_DEVICE_HANDLE deviceHandle)
Delete the given device.
std::string DisplayName() const
Returns the display name.
Definition: peak_device.hpp:200
PEAK_C_API PEAK_Device_GetID(PEAK_DEVICE_HANDLE deviceHandle, char *id, size_t *idSize)
Asks the given device for its ID.
PEAK_C_API PEAK_Device_GetNumDataStreams(PEAK_DEVICE_HANDLE deviceHandle, size_t *numDataStreams)
Asks the given device for its number of data streams.
std::string TLType() const
Returns the TL (transport layer) type.
Definition: peak_device.hpp:228
PEAK_C_API PEAK_Device_GetSerialNumber(PEAK_DEVICE_HANDLE deviceHandle, char *serialNumber, size_t *serialNumberSize)
Asks the given device for its serial number.
PEAK_C_API PEAK_Device_GetTimestampTickFrequency(PEAK_DEVICE_HANDLE deviceHandle, uint64_t *timestampTickFrequency)
Asks the given device for its timestamp tick frequency.
std::string SerialNumber() const
Returns the serial number.
Definition: peak_device.hpp:243
std::shared_ptr< class RemoteDevice > RemoteDevice() const
Returns the remote device of the device.
Definition: peak_device.hpp:265
std::shared_ptr< Interface > ParentInterface() const
Returns the parent interface.
Definition: peak_device.hpp:279
#define PEAK_C_ABI_PREFIX
Definition: peak_dll_defines.h:16
std::string VendorName() const
Returns the vendor name.
Definition: peak_device.hpp:207
int32_t PEAK_DEVICE_ACCESS_STATUS
Definition: peak_backend.h:117
uint64_t TimestampTickFrequency() const
Returns the timestamp tick frequency.
Definition: peak_device.hpp:258
PEAK_C_API PEAK_Device_ToEventSupportingModule(PEAK_DEVICE_HANDLE deviceHandle, PEAK_EVENT_SUPPORTING_MODULE_HANDLE *eventSupportingModuleHandle)
Casts the given device to an event-supporting module.
PEAK_C_API PEAK_Device_GetTLType(PEAK_DEVICE_HANDLE deviceHandle, char *tlType, size_t *tlTypeSize)
Asks the given device for its TL type.
PEAK_DEVICE_HANDLE Handle() const
Get the backend handle.
Definition: peak_device.hpp:137
std::vector< std::shared_ptr< DataStreamDescriptor > > DataStreams() const
Returns the data stream list of the device.
Definition: peak_device.hpp:272
struct PEAK_MODULE * PEAK_MODULE_HANDLE
Definition: peak_backend.h:403
PEAK_C_API PEAK_Device_GetDataStream(PEAK_DEVICE_HANDLE deviceHandle, size_t index, PEAK_DATA_STREAM_DESCRIPTOR_HANDLE *dataStreamDescriptorHandle)
Asks the given device for the data stream descriptor with the given index.
struct PEAK_DEVICE * PEAK_DEVICE_HANDLE
Definition: peak_backend.h:371
PEAK_C_API PEAK_Device_GetVendorName(PEAK_DEVICE_HANDLE deviceHandle, char *vendorName, size_t *vendorNameSize)
Asks the given device for its vendor name.
struct PEAK_DATA_STREAM_DESCRIPTOR * PEAK_DATA_STREAM_DESCRIPTOR_HANDLE
Definition: peak_backend.h:379
RawInformation Info(int32_t infoCommand) const
Delivers information based on the given GenTL info command.
Definition: peak_device.hpp:186
The base class for all modules being able to raise events.
Definition: peak_event_supporting_module.hpp:33
Device & operator=(const Device &other)=delete