RealSenseContext.cpp
Go to the documentation of this file.
1 #include "RealSenseContext.h"
2 #include "PCH.h"
3 
4 URealSenseContext::URealSenseContext(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
5 {
6  REALSENSE_TRACE(TEXT("+URealSenseContext_%p"), this);
7 }
8 
10 {
11  REALSENSE_TRACE(TEXT("~URealSenseContext_%p"), this);
12 }
13 
15 {
16  RsContext = Handle; // rs2_context is managed by FRealSensePlugin, just keep a pointer
17 }
18 
20 {
21  return RsContext;
22 }
23 
25 {
27 }
28 
30 {
31  auto Device = NewNamedObject<URealSenseDevice>(this, Name);
32  Device->SetHandle(Handle);
33  return Device;
34 }
35 
37 {
38  REALSENSE_TRACE(TEXT("URealSenseContext_%p::QueryDevices"), this);
39 
40  FScopeLock Lock(&DevicesMx);
41 
42  Devices.Empty();
43 
46  if (List)
47  {
48  const int Count = rs2_get_device_count(List, &e);
49  for (int i = 0; i < Count; i++)
50  {
51  rs2_device* RsDevice = rs2_create_device(List, i, &e);
52  if (RsDevice)
53  {
54  Devices.Add(NewDevice(RsDevice, TEXT("RealSenseDevice")));
55  }
56  }
57 
59  }
60 
61  for (auto* Device : Devices)
62  {
63  Device->QueryData();
64  }
65 }
66 
68 {
69  FScopeLock Lock(&DevicesMx);
70 
71  return (Id < 0 || Id >= Devices.Num()) ? nullptr : Devices[Id];
72 }
73 
75 {
76  FScopeLock Lock(&DevicesMx);
77 
78  for (auto* Device : Devices)
79  {
80  if (Device->Serial.Equals(Serial))
81  {
82  return Device;
83  }
84  }
85 
86  return nullptr;
87 }
class URealSenseDevice * GetDeviceById(int Id)
rs2_device_list * rs2_query_devices(const rs2_context *context, rs2_error **error)
Definition: rs.cpp:208
static IRealSensePlugin & Get()
virtual class URealSenseContext * GetContext()=0
rs2_device * rs2_create_device(const rs2_device_list *info_list, int index, rs2_error **error)
Definition: rs.cpp:289
static URealSenseContext * GetRealSense()
e
Definition: rmse.py:177
virtual ~URealSenseContext()
struct rs2_context * RsContext
Definition: api.h:28
FCriticalSection DevicesMx
void SetHandle(struct rs2_context *Handle)
TArray< class URealSenseDevice * > Devices
#define REALSENSE_TRACE(Format,...)
Definition: Shared.h:21
class URealSenseDevice * FindDeviceBySerial(FString Serial)
int i
void rs2_delete_device_list(rs2_device_list *info_list)
Definition: rs.cpp:275
int rs2_get_device_count(const rs2_device_list *info_list, rs2_error **error)
Definition: rs.cpp:259
void SetHandle(struct rs2_device *Handle)
struct rs2_context * GetHandle()
class URealSenseDevice * NewDevice(struct rs2_device *Handle, const TCHAR *Name)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:39