7 #include "imstkHaplyDeviceManager.h" 8 #include "imstkHaplyDeviceClient.h" 9 #include "imstkLogger.h" 11 #include <HardwareAPI.h> 12 #include <DeviceDetection.h> 18 std::vector<std::string>
19 HaplyDeviceManager::getInverse3PortNames()
22 std::string portNames[10];
23 const int portCount = Devices::DeviceDetection::AutoDetectInverse3(portNames);
25 std::cout << std::endl;
27 std::vector<std::string> results;
28 for (
int i = 0; i < portCount; i++)
30 results.push_back(portNames[i]);
35 std::vector<std::string>
36 HaplyDeviceManager::getHandlePortNames()
39 std::string portNames[10];
40 const int portCount = Devices::DeviceDetection::AutoDetectHandle(portNames);
42 std::vector<std::string> results;
43 for (
int i = 0; i < portCount; i++)
45 results.push_back(portNames[i]);
50 std::shared_ptr<DeviceClient>
51 HaplyDeviceManager::makeDeviceClient(std::string portName =
"", std::string handlePortName =
"")
56 std::vector<std::string> portNames = getInverse3PortNames();
57 CHECK(portNames.size() > 0) <<
"No Haply Inverse3 devices found";
58 portName = portNames[0];
61 if (handlePortName ==
"")
63 std::vector<std::string> portNames = getHandlePortNames();
64 if (portNames.size() > 0)
66 handlePortName = portNames[0];
70 auto deviceClient = std::shared_ptr<HaplyDeviceClient>(
new HaplyDeviceClient(portName, handlePortName));
71 m_deviceClients.push_back(deviceClient);
76 HaplyDeviceManager::isDevicePresent()
78 std::vector<std::string> portNames = HaplyDeviceManager::getInverse3PortNames();
80 for (
const auto& portName : portNames)
91 HaplyDeviceManager::initModule()
96 LOG(INFO) <<
"Haply HardwareAPI version " << GetLibraryVersion();
98 std::vector<std::string> portNames = HaplyDeviceManager::getInverse3PortNames();
100 for (
const auto& portName : portNames)
102 LOG(INFO) <<
"Inverse3 device available with name: " << portName;
106 portNames = HaplyDeviceManager::getHandlePortNames();
107 for (
const auto& portName : portNames)
109 LOG(INFO) <<
"Haply Handle device available with name: " << portName;
111 if (portNames.size() == 0)
113 LOG(INFO) <<
"No Haply Handle device available.";
116 for (
const auto& client : m_deviceClients)
118 client->initialize();
124 LOG(WARNING) <<
"HaplyDeviceManager already initialized. Reinitialization not implemented.";
130 HaplyDeviceManager::updateModule()
132 for (
const auto& client : m_deviceClients)
139 HaplyDeviceManager::uninitModule()
143 for (
const auto& client : m_deviceClients)
Subclass of DeviceClient for haply, currently implemented only for the Inverse3. Warning: This code i...