OptoForceUnit.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::ArmarXObjects::OptoForceUnit
17  * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 
28 #include <RobotAPI/interface/units/OptoForceUnit.h>
29 #include <opto.h>
31 
32 namespace armarx
33 {
34  /**
35  * @class OptoForceUnitPropertyDefinitions
36  * @brief
37  */
40  {
41  public:
44  {
45  //defineRequiredProperty<std::string>("PropertyName", "Description");
46  defineOptionalProperty<std::string>("OptoForceTopicName", "OptoForceValues", "Name of the OptoForce Topic");
47  defineOptionalProperty<std::string>("CalibrationFilePath", "RobotAPI/sensors/OptoForceCalibration.xml", "Path of the Calibration File");
48  }
49  };
50 
51  /**
52  * @defgroup Component-OptoForceUnit OptoForceUnit
53  * @ingroup RobotAPI-Components
54  * A description of the component OptoForceUnit.
55  *
56  * @class OptoForceUnit
57  * @ingroup Component-OptoForceUnit
58  * @brief Brief description of class OptoForceUnit.
59  *
60  * Detailed description of class OptoForceUnit.
61  */
62  class OptoForceUnit :
63  virtual public OptoForceUnitInterface,
64  virtual public armarx::Component
65  {
66  private:
67  class DaqWrapper
68  {
69  public:
70  DaqWrapper(const std::string& deviceName, const std::string& serialNumber, const RapidXmlReaderNode& daqNode);
71 
72  OptoDAQ daq;
73  std::string deviceName;
74  std::string serialNumber;
75  std::vector<float> countsPerN;
76  std::vector<std::string> sensorNames;
77  std::vector<bool> enableFlags;
78  std::vector<std::array<float, 3>> offsets;
79 
80  void printInfo();
81  void checkSensorCount();
82  };
83  using DaqWrapperPtr = std::shared_ptr<DaqWrapper>;
84 
85  public:
86  OptoForceUnit();
87 
88  /**
89  * @see armarx::ManagedIceObject::getDefaultName()
90  */
91  std::string getDefaultName() const override
92  {
93  return "OptoForceUnit";
94  }
95 
96  protected:
97  /**
98  * @see armarx::ManagedIceObject::onInitComponent()
99  */
100  void onInitComponent() override;
101 
102  /**
103  * @see armarx::ManagedIceObject::onConnectComponent()
104  */
105  void onConnectComponent() override;
106 
107  /**
108  * @see armarx::ManagedIceObject::onDisconnectComponent()
109  */
110  void onDisconnectComponent() override;
111 
112  /**
113  * @see armarx::ManagedIceObject::onExitComponent()
114  */
115  void onExitComponent() override;
116 
117  /**
118  * @see PropertyUser::createPropertyDefinitions()
119  */
121 
122  private:
123  void run();
124 
125  OptoForceUnitListenerPrx topicPrx;
126 
127  OptoPorts ports;
128  //OptoDAQ daq;
129  std::vector<DaqWrapperPtr> daqList;
131 
132  std::ofstream recordingFile;
133  bool isRecording;
134  bool stopRecordingFlag;
135 
136 
137 
138  // OptoForceUnitInterface interface
139  public:
140  void startRecording(const std::string& filepath, const Ice::Current&) override;
141  void stopRecording(const Ice::Current&) override;
142  };
143 }
144 
armarx::OptoForceUnit::OptoForceUnit
OptoForceUnit()
Definition: OptoForceUnit.cpp:32
armarx::OptoForceUnit::onExitComponent
void onExitComponent() override
Definition: OptoForceUnit.cpp:210
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::OptoForceUnit::onConnectComponent
void onConnectComponent() override
Definition: OptoForceUnit.cpp:100
armarx::OptoForceUnit::onDisconnectComponent
void onDisconnectComponent() override
Definition: OptoForceUnit.cpp:204
RunningTask.h
armarx::OptoForceUnit::stopRecording
void stopRecording(const Ice::Current &) override
Definition: OptoForceUnit.cpp:276
armarx::OptoForceUnit::getDefaultName
std::string getDefaultName() const override
Definition: OptoForceUnit.h:91
armarx::OptoForceUnit::onInitComponent
void onInitComponent() override
Definition: OptoForceUnit.cpp:38
armarx::OptoForceUnit::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: OptoForceUnit.cpp:215
armarx::RapidXmlReaderNode
Definition: RapidXmlReader.h:68
armarx::OptoForceUnitPropertyDefinitions::OptoForceUnitPropertyDefinitions
OptoForceUnitPropertyDefinitions(std::string prefix)
Definition: OptoForceUnit.h:42
armarx::OptoForceUnitPropertyDefinitions
Definition: OptoForceUnit.h:38
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::OptoForceUnit
Brief description of class OptoForceUnit.
Definition: OptoForceUnit.h:62
RapidXmlReader.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::OptoForceUnit::startRecording
void startRecording(const std::string &filepath, const Ice::Current &) override
Definition: OptoForceUnit.cpp:269