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
29
30#include <RobotAPI/interface/units/OptoForceUnit.h>
31
32#include <opto.h>
33
34namespace armarx
35{
36 /**
37 * @class OptoForceUnitPropertyDefinitions
38 * @brief
39 */
41 {
42 public:
45 {
46 //defineRequiredProperty<std::string>("PropertyName", "Description");
48 "OptoForceTopicName", "OptoForceValues", "Name of the OptoForce Topic");
49 defineOptionalProperty<std::string>("CalibrationFilePath",
50 "RobotAPI/sensors/OptoForceCalibration.xml",
51 "Path of the Calibration File");
52 }
53 };
54
55 /**
56 * @defgroup Component-OptoForceUnit OptoForceUnit
57 * @ingroup RobotAPI-Components
58 * A description of the component OptoForceUnit.
59 *
60 * @class OptoForceUnit
61 * @ingroup Component-OptoForceUnit
62 * @brief Brief description of class OptoForceUnit.
63 *
64 * Detailed description of class OptoForceUnit.
65 */
66 class OptoForceUnit : virtual public OptoForceUnitInterface, virtual public armarx::Component
67 {
68 private:
69 class DaqWrapper
70 {
71 public:
72 DaqWrapper(const std::string& deviceName,
73 const std::string& serialNumber,
74 const RapidXmlReaderNode& daqNode);
75
76 OptoDAQ daq;
77 std::string deviceName;
78 std::string serialNumber;
79 std::vector<float> countsPerN;
80 std::vector<std::string> sensorNames;
81 std::vector<bool> enableFlags;
82 std::vector<std::array<float, 3>> offsets;
83
84 void printInfo();
85 void checkSensorCount();
86 };
87
88 using DaqWrapperPtr = std::shared_ptr<DaqWrapper>;
89
90 public:
92
93 /**
94 * @see armarx::ManagedIceObject::getDefaultName()
95 */
96 std::string
97 getDefaultName() const override
98 {
99 return "OptoForceUnit";
100 }
101
102 protected:
103 /**
104 * @see armarx::ManagedIceObject::onInitComponent()
105 */
106 void onInitComponent() override;
107
108 /**
109 * @see armarx::ManagedIceObject::onConnectComponent()
110 */
111 void onConnectComponent() override;
112
113 /**
114 * @see armarx::ManagedIceObject::onDisconnectComponent()
115 */
116 void onDisconnectComponent() override;
117
118 /**
119 * @see armarx::ManagedIceObject::onExitComponent()
120 */
121 void onExitComponent() override;
122
123 /**
124 * @see PropertyUser::createPropertyDefinitions()
125 */
127
128 private:
129 void run();
130
131 OptoForceUnitListenerPrx topicPrx;
132
133 OptoPorts ports;
134 //OptoDAQ daq;
135 std::vector<DaqWrapperPtr> daqList;
137
138 std::ofstream recordingFile;
139 bool isRecording;
140 bool stopRecordingFlag;
141
142
143 // OptoForceUnitInterface interface
144 public:
145 void startRecording(const std::string& filepath, const Ice::Current&) override;
146 void stopRecording(const Ice::Current&) override;
147 };
148} // namespace armarx
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
OptoForceUnitPropertyDefinitions(std::string prefix)
void onInitComponent() override
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
void startRecording(const std::string &filepath, const Ice::Current &) override
void stopRecording(const Ice::Current &) override
void onExitComponent() override
std::string getDefaultName() const override
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.