00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef AXES_COMPONENT_HPP
00029 #define AXES_COMPONENT_HPP
00030
00031 #include <rtt/dev/AxisInterface.hpp>
00032 #include <rtt/dev/DriveInterface.hpp>
00033 #include <rtt/dev/DigitalInput.hpp>
00034 #include <rtt/dev/DigitalOutput.hpp>
00035
00036 #include <map>
00037 #include <utility>
00038 #include <string>
00039 #include <boost/tuple/tuple.hpp>
00040 #include <rtt/Logger.hpp>
00041 #include <rtt/TaskContext.hpp>
00042 #include <rtt/DataPort.hpp>
00043 #include <rtt/Property.hpp>
00044 #include <rtt/Attribute.hpp>
00045 #include <rtt/RTT.hpp>
00046
00047 #include <ocl/OCL.hpp>
00048
00049 namespace OCL
00050 {
00060 class AxesComponent
00061 : public TaskContext
00062 {
00063 public:
00064 typedef std::vector<double> ChannelType;
00065
00071 AxesComponent( int max_axes = 1, const std::string& name = "AxesComponent" );
00072
00077 virtual bool startup();
00078
00082 virtual void update();
00083
00087 virtual void shutdown();
00088
00093 bool addAxis( const std::string& name, AxisInterface* axis_i );
00094
00106 bool addAxisOnChannel(const std::string& axis_name, const std::string& sensor_name, int virtual_channel );
00107
00114 void removeAxisFromChannel(const std::string& axis_name);
00115
00119 bool removeAxis( const std::string& name );
00120
00130 bool enableAxis( const std::string& name );
00131
00135 bool disableAxis( const std::string& name );
00136
00140 bool stopAxis( const std::string& name );
00141
00145 bool switchOn( const std::string& name );
00146
00150 bool switchOff( const std::string& name );
00151
00155 bool isEnabled( const std::string& name ) const;
00156
00160 bool isDriven( const std::string& name ) const;
00161
00165 bool isStopped( const std::string& name ) const;
00166
00170 bool isLocked( const std::string& name ) const;
00171
00175 double position( const std::string& name ) const;
00176
00181 bool isOn( const std::string& name ) const;
00182
00186 double readSensor( const std::string& name ) const;
00187
00191 int getAxes() const;
00205 bool calibrateSensor( const std::string& axis, const std::string& name );
00206
00210 bool resetSensor( const std::string& axis, const std::string& name );
00211
00215 bool isCalibrated( const std::string& axis, const std::string& name ) const;
00217 protected:
00218 struct AxisInfo;
00219
00220 AxisInfo* mhasAxis(const std::string& axis_name);
00221
00223 Property<int> max_channels;
00224
00225 typedef std::map<std::string, std::pair<SensorInterface<double>*, WriteDataPort<double>* > > SensorMap;
00226
00227 struct AxisInfo
00228 {
00229 AxisInfo(AxisInterface* a, const std::string& thename)
00230 : name(thename), axis(a),
00231 sensor(0), inport(0),
00232 channel(-1) {}
00233 std::string name;
00234 AxisInterface* axis;
00235 SensorInterface<double>* sensor;
00236 DataPort<double>* inport;
00237 int channel;
00238
00239
00240 SensorMap sensors;
00241 };
00242
00243
00244 ChannelType chan_meas;
00245 WriteDataPort<ChannelType> chan_sensor;
00246 ChannelType chan_out;
00247 ReadDataPort< ChannelType > chan_drive;
00248
00249 std::map<std::string, const DigitalInput* > d_in;
00250 std::map<std::string, DigitalOutput* > d_out;
00251
00252 typedef std::map<std::string, AxisInfo > AxisMap;
00253
00254 AxisMap axes;
00255
00256 Attribute<ChannelType> testData;
00257
00258 void to_axis(const AxisInfo& dd );
00259
00260 unsigned int usingChannels;
00261 };
00262 }
00263
00264 #endif
00265