1 #ifndef _MotionProxyHelper_H_ 2 #define _MotionProxyHelper_H_ 18 #include <TangoExceptionsHelper.h> 19 #include <DeviceProxyHelper.h> 20 #include <yat/threading/Mutex.h> 32 const string sDescription,
33 Tango::DeviceImpl * _device)
34 throw (Tango::DevFailed) ;
38 const string sDescription,
39 const string sAttributePositionName ,
40 const string sCommandStateName,
41 const string sCommandStopName,
42 Tango::DeviceImpl * _device)
43 throw (Tango::DevFailed) ;
49 virtual void Move(
double)
50 throw (Tango::DevFailed);
53 virtual void Stop(
void)
54 throw (Tango::DevFailed);
57 virtual void Forward(
void)
58 throw (Tango::DevFailed);
61 virtual void Backward(
void)
62 throw (Tango::DevFailed);
65 virtual double Read(
void)
66 throw (Tango::DevFailed);
69 virtual double ReadW(
void)
70 throw (Tango::DevFailed);
74 throw (Tango::DevFailed);
78 throw (Tango::DevFailed);
81 virtual Tango::DevState State(
void)
82 throw (Tango::DevFailed);
86 throw (Tango::DevFailed);
88 void AllowMove(
const bool bAllowMove);
95 void Command(
const string & cmd)
96 throw (Tango::DevFailed);
100 void Command(
const string & cmd, T value)
101 throw (Tango::DevFailed);
104 template <
typename T>
105 void WriteAttribute(
const string & cmd, T value)
106 throw (Tango::DevFailed);
109 template <
typename T>
110 T ReadAttribute(
const string & cmd)
111 throw (Tango::DevFailed);
115 Tango::DeviceProxyHelper* _mProxy;
117 string _sDescription;
118 string _sAttributePositionName;
119 string _sAttributeBLSWName;
120 string _sAttributeFLSWName;
121 string _sCommandStateName;
122 string _sCommandStatusName;
123 string _sCommandStopName;
124 string _sCommandForwardName;
125 string _sCommandBackwardName;
135 template <
typename T>
136 void MotionProxyHelper::Command(
const string & cmd_name, T arg)
137 throw (Tango::DevFailed)
139 DEBUG_STREAM <<
"MotionProxyHelper::Command("<<cmd_name<<
","<<arg<<
") [ "<< _sDescription<<
" ] entering... " << endl;
143 _mProxy->command_in(cmd_name.c_str(),arg);
145 catch (Tango::DevFailed& e)
148 TangoSys_OMemStream o;
149 o <<
"Unable to execute command "<<cmd_name<<
" with arg "<<arg <<
" on the device " << _sDescription <<
" !" << endl;
150 Tango::Except::re_throw_exception
152 static_cast<const char*>(
"TANGO_DEVICE_ERROR"),
153 static_cast<const char*>(o.str().c_str()),
154 static_cast<const char*>(
"MotionProxyHelper::Command()")
160 TangoSys_OMemStream o;
161 o <<
"Unable to execute command "<<cmd_name<<
" with arg "<<arg <<
" on the device " << _sDescription <<
" !" << endl;
162 Tango::Except::throw_exception
164 static_cast<const char*>(
"UNKNOWN_ERROR"),
165 static_cast<const char*>(o.str().c_str()),
166 static_cast<const char*>(
"MotionProxyHelper::Command()")
174 template <
typename T>
175 void MotionProxyHelper::WriteAttribute(
const string & attr_name, T value)
176 throw (Tango::DevFailed)
178 DEBUG_STREAM <<
"MotionProxyHelper::WriteAttribute("<<attr_name<<
","<<value<<
") [ "<< _sDescription<<
" ] entering... " << endl;
182 _mProxy->write_attribute(attr_name.c_str(),value);
184 catch (Tango::DevFailed& e)
187 TangoSys_OMemStream o;
188 o <<
"Unable to write "<<value<<
" on "<<attr_name <<
"attribute of the device " << _sDescription <<
" !" << endl;
189 Tango::Except::re_throw_exception
191 static_cast<const char*>(
"TANGO_DEVICE_ERROR"),
192 static_cast<const char*>(o.str().c_str()),
193 static_cast<const char*>(
"MotionProxyHelper::WriteAttribute()")
199 TangoSys_OMemStream o;
200 o <<
"Unable to write "<<value<<
" on "<<attr_name <<
" attribute of the device " << _sDescription <<
" !" << endl;
201 Tango::Except::throw_exception
203 static_cast<const char*>(
"UNKNOWN_ERROR"),
204 static_cast<const char*>(o.str().c_str()),
205 static_cast<const char*>(
"MotionProxyHelper::WriteAttribute()")
213 template <
typename T>
214 T MotionProxyHelper::ReadAttribute(
const string & attr_name)
215 throw (Tango::DevFailed)
217 DEBUG_STREAM <<
"MotionProxyHelper::ReadAttribute("<<attr_name<<
") [ "<< _sDescription<<
" ] entering... " << endl;
222 _mProxy->read_attribute(attr_name.c_str(),value);
224 catch (Tango::DevFailed& e)
227 TangoSys_OMemStream o;
228 o <<
"Unable to read "<<attr_name <<
"attribute of the device " << _sDescription <<
" !" << endl;
229 Tango::Except::re_throw_exception
231 static_cast<const char*>(
"TANGO_DEVICE_ERROR"),
232 static_cast<const char*>(o.str().c_str()),
233 static_cast<const char*>(
"MotionProxyHelper::ReadAttribute()")
239 TangoSys_OMemStream o;
240 o <<
"Unable to read "<<attr_name <<
" attribute of the device " << _sDescription <<
" !" << endl;
241 Tango::Except::throw_exception
243 static_cast<const char*>(
"UNKNOWN_ERROR"),
244 static_cast<const char*>(o.str().c_str()),
245 static_cast<const char*>(
"MotionProxyHelper::ReadAttribute()")
254 #endif // _MotionProxyHelper_H_
Definition: MotionProxyHelper.h:26
Definition: MotionProxyHelper.cpp:18