1 static const char *RcsId
= "$Header: $";
2 //+=============================================================================
4 // file : PseudoAxes.cpp
6 // description : C++ source for the PseudoAxes and its commands.
7 // The class is derived from Device. It represents the
8 // CORBA servant object which will be accessed from the
9 // network. All commands which can be executed on the
10 // PseudoAxes are implemented in this file.
12 // project : TANGO Device Server
20 // copyleft : European Synchrotron Radiation Facility
21 // BP 220, Grenoble 38043
24 //-=============================================================================
26 // This file is generated by POGO
27 // (Program Obviously used to Generate tango Object)
29 // (c) - Software Engineering Group - ESRF
30 //=============================================================================
34 //===================================================================
36 // The following table gives the correspondence
37 // between commands and method name.
39 // Command name| Method name
40 // ----------------------------------------
41 // State | dev_state()
42 // Status | dev_status()
43 // AxisInit | axis_init()
45 //===================================================================
49 #include <PseudoAxes.h>
50 #include <PseudoAxesClass.h>
52 #include "TangoHKLAdapterFactory.h"
54 namespace PseudoAxes_ns
57 //+----------------------------------------------------------------------------
59 // method : PseudoAxes::PseudoAxes(string &s)
61 // description : constructor for simulated PseudoAxes
63 // in : - cl : Pointer to the DeviceClass object
66 //-----------------------------------------------------------------------------
67 PseudoAxes::PseudoAxes(Tango::DeviceClass
*cl
,string
&s
)
68 :Tango::Device_3Impl(cl
,s
.c_str())
73 PseudoAxes::PseudoAxes(Tango::DeviceClass
*cl
,const char *s
)
74 :Tango::Device_3Impl(cl
,s
)
79 PseudoAxes::PseudoAxes(Tango::DeviceClass
*cl
,const char *s
,const char *d
)
80 :Tango::Device_3Impl(cl
,s
,d
)
84 //+----------------------------------------------------------------------------
86 // method : PseudoAxes::delete_device()
88 // description : will be called at device destruction or at init command.
90 //-----------------------------------------------------------------------------
91 void PseudoAxes::delete_device()
93 // Delete device's allocated object
97 _adapter
->remove_dynamic_attributes();
103 //+----------------------------------------------------------------------------
105 // method : PseudoAxes::init_device()
107 // description : will be called at device initialization.
109 //-----------------------------------------------------------------------------
110 void PseudoAxes::init_device()
112 INFO_STREAM
<< "PseudoAxes::PseudoAxes() create device " << device_name
<< endl
;
114 // Initialise variables to default values
115 //--------------------------------------------
116 get_device_property();
121 _config
.state
= Tango::FAULT
;
122 _config
.status
= "Not yet initialized";
123 _config
.initialized
= false;
125 // we can get the Diffractometer device adapter in the init as this one start all PseudoAxes
127 _hklAdapter
= Diffractometer_ns::TangoHKLAdapterFactory::instance()->get_diffractometer_adapter(diffractometerProxy
);
129 if(_hklAdapter
&& !_adapter
){
130 _adapter
= _hklAdapter
->pseudo_axes_adapter_get_by_name(engineName
);
132 _adapter
->set_device(this);
133 _adapter
->add_dynamic_attributes();
140 //+----------------------------------------------------------------------------
142 // method : PseudoAxes::get_device_property()
144 // description : Read the device properties from database.
146 //-----------------------------------------------------------------------------
147 void PseudoAxes::get_device_property()
149 // Initialize your default values here (if not done with POGO).
150 //------------------------------------------------------------------
152 // Read device properties from database.(Automatic code generation)
153 //------------------------------------------------------------------
154 Tango::DbData dev_prop
;
155 dev_prop
.push_back(Tango::DbDatum("DiffractometerProxy"));
156 dev_prop
.push_back(Tango::DbDatum("EngineName"));
158 // Call database and extract values
159 //--------------------------------------------
160 if (Tango::Util::instance()->_UseDb
==true)
161 get_db_device()->get_property(dev_prop
);
162 Tango::DbDatum def_prop
, cl_prop
;
163 PseudoAxesClass
*ds_class
=
164 (static_cast<PseudoAxesClass
*>(get_device_class()));
167 // Try to initialize DiffractometerProxy from class property
168 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
169 if (cl_prop
.is_empty()==false) cl_prop
>> diffractometerProxy
;
171 // Try to initialize DiffractometerProxy from default device value
172 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
173 if (def_prop
.is_empty()==false) def_prop
>> diffractometerProxy
;
175 // And try to extract DiffractometerProxy value from database
176 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> diffractometerProxy
;
178 // Try to initialize EngineName from class property
179 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
180 if (cl_prop
.is_empty()==false) cl_prop
>> engineName
;
182 // Try to initialize EngineName from default device value
183 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
184 if (def_prop
.is_empty()==false) def_prop
>> engineName
;
186 // And try to extract EngineName value from database
187 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> engineName
;
191 // End of Automatic code generation
192 //------------------------------------------------------------------
195 //+----------------------------------------------------------------------------
197 // method : PseudoAxes::always_executed_hook()
199 // description : method always executed before any command is executed
201 //-----------------------------------------------------------------------------
202 void PseudoAxes::always_executed_hook()
205 _hklAdapter
= Diffractometer_ns::TangoHKLAdapterFactory::instance()->get_diffractometer_adapter(diffractometerProxy
);
207 if(_hklAdapter
&& !_adapter
)
208 _adapter
= _hklAdapter
->pseudo_axes_adapter_get_by_name(engineName
);
211 //+----------------------------------------------------------------------------
213 // method : PseudoAxes::read_attr_hardware
215 // description : Hardware acquisition for attributes.
217 //-----------------------------------------------------------------------------
218 void PseudoAxes::read_attr_hardware(vector
<long> &attr_list
)
220 DEBUG_STREAM
<< "PseudoAxes::read_attr_hardware(vector<long> &attr_list) entering... "<< endl
;
221 // Add your own code here
223 _config
= _adapter
->get_config();
225 //+----------------------------------------------------------------------------
227 // method : PseudoAxes::read_initialized
229 // description : Extract real attribute values for initialized acquisition result.
231 //-----------------------------------------------------------------------------
232 void PseudoAxes::read_initialized(Tango::Attribute
&attr
)
234 DEBUG_STREAM
<< "PseudoAxes::read_initialized(Tango::Attribute &attr) entering... "<< endl
;
236 attr
.set_value(&_config
.initialized
);
239 //+----------------------------------------------------------------------------
241 // method : PseudoAxes::write_initialized
243 // description : Write initialized attribute values to hardware.
245 //-----------------------------------------------------------------------------
246 void PseudoAxes::write_initialized(Tango::WAttribute
&attr
)
248 DEBUG_STREAM
<< "PseudoAxes::write_initialized(Tango::WAttribute &attr) entering... "<< endl
;
251 Tango::DevBoolean initialized
;
252 attr
.get_write_value(initialized
);
253 _adapter
->set_initialized(initialized
);
257 //+----------------------------------------------------------------------------
259 // method : PseudoAxes::read_parameters
261 // description : Extract real attribute values for parameters acquisition result.
263 //-----------------------------------------------------------------------------
264 void PseudoAxes::read_parameters(Tango::Attribute
&attr
)
266 DEBUG_STREAM
<< "PseudoAxes::read_parameters(Tango::Attribute &attr) entering... "<< endl
;
269 Matrix
<double> const & img
= _adapter
->get_mode_parameters();
270 attr
.set_value(img
.data
, img
.xdim
);
274 //+----------------------------------------------------------------------------
276 // method : PseudoAxes::write_parameters
278 // description : Write parameters attribute values to hardware.
280 //-----------------------------------------------------------------------------
281 void PseudoAxes::write_parameters(Tango::WAttribute
&attr
)
283 DEBUG_STREAM
<< "PseudoAxes::write_parameters(Tango::WAttribute &attr) entering... "<< endl
;
286 const Tango::DevDouble
*values
;
287 attr
.get_write_value(values
);
289 img
.attach_to_const_buffer(values
,
290 attr
.get_w_dim_x(), attr
.get_w_dim_y());
292 _adapter
->set_mode_parameters(img
);
296 //+----------------------------------------------------------------------------
298 // method : PseudoAxes::read_pseudoAxisNames
300 // description : Extract real attribute values for pseudoAxisNames acquisition result.
302 //-----------------------------------------------------------------------------
303 void PseudoAxes::read_pseudoAxisNames(Tango::Attribute
&attr
)
305 DEBUG_STREAM
<< "PseudoAxes::read_pseudoAxisNames(Tango::Attribute &attr) entering... "<< endl
;
307 Matrix
<char *> const & img
= _adapter
->get_pseudo_axis_names();
308 attr
.set_value(img
.data
, img
.xdim
);
313 //+----------------------------------------------------------------------------
315 // method : PseudoAxes::read_mode
317 // description : Extract real attribute values for mode acquisition result.
319 //-----------------------------------------------------------------------------
320 void PseudoAxes::read_mode(Tango::Attribute
&attr
)
322 DEBUG_STREAM
<< "PseudoAxes::read_mode(Tango::Attribute &attr) entering... "<< endl
;
324 attr
.set_value(_adapter
->get_mode());
327 //+----------------------------------------------------------------------------
329 // method : PseudoAxes::write_mode
331 // description : Write mode attribute values to hardware.
333 //-----------------------------------------------------------------------------
334 void PseudoAxes::write_mode(Tango::WAttribute
&attr
)
336 DEBUG_STREAM
<< "PseudoAxes::write_mode(Tango::WAttribute &attr) entering... "<< endl
;
337 attr
.get_write_value(attr_mode_write
);
339 _adapter
->set_mode(attr_mode_write
);
342 //+----------------------------------------------------------------------------
344 // method : PseudoAxes::read_modeNames
346 // description : Extract real attribute values for modeNames acquisition result.
348 //-----------------------------------------------------------------------------
349 void PseudoAxes::read_modeNames(Tango::Attribute
&attr
)
351 DEBUG_STREAM
<< "PseudoAxes::read_modeNames(Tango::Attribute &attr) entering... "<< endl
;
353 Matrix
<char *> const & img
= _adapter
->get_mode_names();
354 attr
.set_value(img
.data
, img
.xdim
);
358 //+----------------------------------------------------------------------------
360 // method : PseudoAxes::read_parametersNames
362 // description : Extract real attribute values for parametersNames acquisition result.
364 //-----------------------------------------------------------------------------
365 void PseudoAxes::read_parametersNames(Tango::Attribute
&attr
)
367 DEBUG_STREAM
<< "PseudoAxes::read_parametersNames(Tango::Attribute &attr) entering... "<< endl
;
369 Matrix
<char *> const & img
= _adapter
->get_mode_parameters_names();
370 attr
.set_value(img
.data
, img
.xdim
);
374 //+------------------------------------------------------------------
376 * method: PseudoAxes::axis_init
378 * description: method to execute "AxisInit"
379 * Initialize the pseudoAxes (exemple the psi pseudo axis)
383 //+------------------------------------------------------------------
384 void PseudoAxes::axis_init()
386 DEBUG_STREAM
<< "PseudoAxes::axis_init(): entering... !" << endl
;
388 // Add your own code to control device here
394 //+------------------------------------------------------------------
396 * method: PseudoAxes::dev_state
398 * description: method to execute "State"
399 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
404 //+------------------------------------------------------------------
405 Tango::DevState
PseudoAxes::dev_state()
407 Tango::DevState argout
= DeviceImpl::dev_state();
408 DEBUG_STREAM
<< "PseudoAxes::dev_state(): entering... !" << endl
;
410 // Add your own code to control device here
413 this->set_state(_config
.state
);
415 return this->device_state
;
418 //+------------------------------------------------------------------
420 * method: PseudoAxes::dev_status
422 * description: method to execute "Status"
423 * This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
425 * @return Status description
428 //+------------------------------------------------------------------
429 Tango::ConstDevString
PseudoAxes::dev_status()
431 Tango::ConstDevString argout
= DeviceImpl::dev_status();
432 DEBUG_STREAM
<< "PseudoAxes::dev_status(): entering... !" << endl
;
434 // Add your own code to control device here
437 this->set_status(_config
.status
);
439 return this->device_status
.c_str();