opensurgsim
NimbleScaffold.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DEVICES_NIMBLE_NIMBLESCAFFOLD_H
17 #define SURGSIM_DEVICES_NIMBLE_NIMBLESCAFFOLD_H
18 
19 #include <memory>
20 
21 #include "SurgSim/DataStructures/DataGroup.h"
22 #include "SurgSim/Framework/BasicThread.h"
23 #include "SurgSim/Framework/Logger.h"
24 
25 namespace SurgSim
26 {
27 namespace Devices
28 {
29 
30 class NimbleDevice;
31 class NimbleThread;
32 
37 {
38 public:
41 
45  static std::shared_ptr<NimbleScaffold> getOrCreateSharedInstance();
46 
47 protected:
48  bool doInitialize() override;
49  bool doStartUp() override;
50  bool doUpdate(double dt) override;
51  void doBeforeStop() override;
52 
53 private:
55  struct StateData;
56 
57  friend class NimbleDevice;
58  friend class NimbleThread;
59 
62 
67  bool registerDevice(NimbleDevice* device);
68 
72  bool unregisterDevice(const NimbleDevice* device);
73 
75  void updateDeviceData();
76 
78  void resetDeviceData();
79 
81  static SurgSim::DataStructures::DataGroup buildDeviceInputData();
82 
84  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
86  std::unique_ptr<StateData> m_state;
87 
89  std::string m_serverIpAddress;
91  std::string m_serverPort;
93  bool m_serverSocketOpen;
94 
96  static std::array<std::pair<std::string, int>, 15> m_jointPoseNames;
97 };
98 
99 }; // namespace Devices
100 }; // namespace SurgSim
101 
102 #endif // SURGSIM_DEVICES_NIMBLE_NIMBLESCAFFOLD_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A class that manages Nimble devices.
Definition: NimbleScaffold.h:36
void doBeforeStop() override
Prepares the thread for its execution to be stopped.
Definition: NimbleScaffold.cpp:427
A class implementing the communication with the Nimble server.
Definition: NimbleDevice.h:57
A collection of NamedData objects.
Definition: DataGroup.h:68
bool doUpdate(double dt) override
Implementation of actual work function for this thread, this has a default implementation to handle d...
Definition: NimbleScaffold.cpp:389
Basic thread implementation, tries to maintain a constant rate, supplies startup an initialization...
Definition: BasicThread.h:48
~NimbleScaffold()
Destructor.
Definition: NimbleScaffold.cpp:288
Definition: NimbleScaffold.cpp:253
static std::shared_ptr< NimbleScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all NimbleDevice instances.
Definition: NimbleScaffold.cpp:482