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()
46 //===================================================================
50 #include <PseudoAxes.h>
51 #include <PseudoAxesClass.h>
53 #include "TangoHKLAdapterFactory.h"
55 namespace PseudoAxes_ns
58 //+----------------------------------------------------------------------------
60 // method : PseudoAxes::PseudoAxes(string &s)
62 // description : constructor for simulated PseudoAxes
64 // in : - cl : Pointer to the DeviceClass object
67 //-----------------------------------------------------------------------------
68 PseudoAxes::PseudoAxes(Tango::DeviceClass
*cl
,string
&s
)
69 :Tango::Device_4Impl(cl
,s
.c_str())
74 PseudoAxes::PseudoAxes(Tango::DeviceClass
*cl
,const char *s
)
75 :Tango::Device_4Impl(cl
,s
)
80 PseudoAxes::PseudoAxes(Tango::DeviceClass
*cl
,const char *s
,const char *d
)
81 :Tango::Device_4Impl(cl
,s
,d
)
85 //+----------------------------------------------------------------------------
87 // method : PseudoAxes::delete_device()
89 // description : will be called at device destruction or at init command.
91 //-----------------------------------------------------------------------------
92 void PseudoAxes::delete_device()
94 // Delete device's allocated object
98 _adapter
->remove_dynamic_attributes();
104 //+----------------------------------------------------------------------------
106 // method : PseudoAxes::init_device()
108 // description : will be called at device initialization.
110 //-----------------------------------------------------------------------------
111 void PseudoAxes::init_device()
113 INFO_STREAM
<< "PseudoAxes::PseudoAxes() create device " << device_name
<< endl
;
115 // Initialise variables to default values
116 //--------------------------------------------
117 get_device_property();
122 config
.state
= Tango::FAULT
;
123 config
.status
= "Not yet initialized";
124 config
.initialized
= false;
127 // we can get the Diffractometer device adapter in the init as this one start all PseudoAxes
129 _hklAdapter
= Diffractometer_ns::TangoHKLAdapterFactory::instance()->get_diffractometer_adapter(diffractometerProxy
);
131 if(_hklAdapter
&& !_adapter
){
132 _adapter
= _hklAdapter
->pseudo_axes_adapter_get_by_name(engineName
);
134 _adapter
->set_device(this);
135 _adapter
->add_dynamic_attributes();
142 //+----------------------------------------------------------------------------
144 // method : PseudoAxes::get_device_property()
146 // description : Read the device properties from database.
148 //-----------------------------------------------------------------------------
149 void PseudoAxes::get_device_property()
151 // Initialize your default values here (if not done with POGO).
152 //------------------------------------------------------------------
154 // Read device properties from database.(Automatic code generation)
155 //------------------------------------------------------------------
156 Tango::DbData dev_prop
;
157 dev_prop
.push_back(Tango::DbDatum("DiffractometerProxy"));
158 dev_prop
.push_back(Tango::DbDatum("EngineName"));
160 // Call database and extract values
161 //--------------------------------------------
162 if (Tango::Util::instance()->_UseDb
==true)
163 get_db_device()->get_property(dev_prop
);
164 Tango::DbDatum def_prop
, cl_prop
;
165 PseudoAxesClass
*ds_class
=
166 (static_cast<PseudoAxesClass
*>(get_device_class()));
169 // Try to initialize DiffractometerProxy from class property
170 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
171 if (cl_prop
.is_empty()==false) cl_prop
>> diffractometerProxy
;
173 // Try to initialize DiffractometerProxy from default device value
174 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
175 if (def_prop
.is_empty()==false) def_prop
>> diffractometerProxy
;
177 // And try to extract DiffractometerProxy value from database
178 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> diffractometerProxy
;
180 // Try to initialize EngineName from class property
181 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
182 if (cl_prop
.is_empty()==false) cl_prop
>> engineName
;
184 // Try to initialize EngineName from default device value
185 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
186 if (def_prop
.is_empty()==false) def_prop
>> engineName
;
188 // And try to extract EngineName value from database
189 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> engineName
;
193 // End of Automatic code generation
194 //------------------------------------------------------------------
197 //+----------------------------------------------------------------------------
199 // method : PseudoAxes::always_executed_hook()
201 // description : method always executed before any command is executed
203 //-----------------------------------------------------------------------------
204 void PseudoAxes::always_executed_hook()
207 _hklAdapter
= Diffractometer_ns::TangoHKLAdapterFactory::instance()->get_diffractometer_adapter(diffractometerProxy
);
209 if(_hklAdapter
&& !_adapter
)
210 _adapter
= _hklAdapter
->pseudo_axes_adapter_get_by_name(engineName
);
213 //+----------------------------------------------------------------------------
215 // method : PseudoAxes::read_attr_hardware
217 // description : Hardware acquisition for attributes.
219 //-----------------------------------------------------------------------------
220 void PseudoAxes::read_attr_hardware(vector
<long> &attr_list
)
222 DEBUG_STREAM
<< "PseudoAxes::read_attr_hardware(vector<long> &attr_list) entering... "<< endl
;
223 // Add your own code here
225 config
= _adapter
->get_config();
227 //+----------------------------------------------------------------------------
229 // method : PseudoAxes::read_initialized
231 // description : Extract real attribute values for initialized acquisition result.
233 //-----------------------------------------------------------------------------
234 void PseudoAxes::read_initialized(Tango::Attribute
&attr
)
236 DEBUG_STREAM
<< "PseudoAxes::read_initialized(Tango::Attribute &attr) entering... "<< endl
;
238 attr
.set_value(&config
.initialized
);
241 //+----------------------------------------------------------------------------
243 // method : PseudoAxes::write_initialized
245 // description : Write initialized attribute values to hardware.
247 //-----------------------------------------------------------------------------
248 void PseudoAxes::write_initialized(Tango::WAttribute
&attr
)
250 DEBUG_STREAM
<< "PseudoAxes::write_initialized(Tango::WAttribute &attr) entering... "<< endl
;
253 Tango::DevBoolean initialized
;
254 attr
.get_write_value(initialized
);
255 _adapter
->set_initialized(initialized
);
259 //+----------------------------------------------------------------------------
261 // method : PseudoAxes::read_parameters
263 // description : Extract real attribute values for parameters acquisition result.
265 //-----------------------------------------------------------------------------
266 void PseudoAxes::read_parameters(Tango::Attribute
&attr
)
268 DEBUG_STREAM
<< "PseudoAxes::read_parameters(Tango::Attribute &attr) entering... "<< endl
;
271 Matrix
<double> const & img
= config
.parameters
;
272 attr
.set_value(img
.data
, img
.xdim
);
276 //+----------------------------------------------------------------------------
278 // method : PseudoAxes::write_parameters
280 // description : Write parameters attribute values to hardware.
282 //-----------------------------------------------------------------------------
283 void PseudoAxes::write_parameters(Tango::WAttribute
&attr
)
285 DEBUG_STREAM
<< "PseudoAxes::write_parameters(Tango::WAttribute &attr) entering... "<< endl
;
288 const Tango::DevDouble
*values
;
289 attr
.get_write_value(values
);
291 img
.attach_to_const_buffer(values
,
292 attr
.get_w_dim_x(), attr
.get_w_dim_y());
294 _adapter
->set_parameters(img
);
298 //+----------------------------------------------------------------------------
300 // method : PseudoAxes::read_pseudoAxisNames
302 // description : Extract real attribute values for pseudoAxisNames acquisition result.
304 //-----------------------------------------------------------------------------
305 void PseudoAxes::read_pseudoAxisNames(Tango::Attribute
&attr
)
307 DEBUG_STREAM
<< "PseudoAxes::read_pseudoAxisNames(Tango::Attribute &attr) entering... "<< endl
;
309 Matrix
<char *> const & img
= config
.pseudo_axes_names
;
310 attr
.set_value(img
.data
, img
.xdim
);
315 //+----------------------------------------------------------------------------
317 // method : PseudoAxes::read_mode
319 // description : Extract real attribute values for mode acquisition result.
321 //-----------------------------------------------------------------------------
322 void PseudoAxes::read_mode(Tango::Attribute
&attr
)
324 DEBUG_STREAM
<< "PseudoAxes::read_mode(Tango::Attribute &attr) entering... "<< endl
;
326 attr
.set_value(&config
.mode
);
329 //+----------------------------------------------------------------------------
331 // method : PseudoAxes::write_mode
333 // description : Write mode attribute values to hardware.
335 //-----------------------------------------------------------------------------
336 void PseudoAxes::write_mode(Tango::WAttribute
&attr
)
338 DEBUG_STREAM
<< "PseudoAxes::write_mode(Tango::WAttribute &attr) entering... "<< endl
;
339 attr
.get_write_value(attr_mode_write
);
341 _adapter
->set_mode(attr_mode_write
);
344 //+----------------------------------------------------------------------------
346 // method : PseudoAxes::read_modeNames
348 // description : Extract real attribute values for modeNames acquisition result.
350 //-----------------------------------------------------------------------------
351 void PseudoAxes::read_modeNames(Tango::Attribute
&attr
)
353 DEBUG_STREAM
<< "PseudoAxes::read_modeNames(Tango::Attribute &attr) entering... "<< endl
;
355 Matrix
<char *> const & img
= config
.mode_names
;
356 attr
.set_value(img
.data
, img
.xdim
);
360 //+----------------------------------------------------------------------------
362 // method : PseudoAxes::read_parametersNames
364 // description : Extract real attribute values for parametersNames acquisition result.
366 //-----------------------------------------------------------------------------
367 void PseudoAxes::read_parametersNames(Tango::Attribute
&attr
)
369 DEBUG_STREAM
<< "PseudoAxes::read_parametersNames(Tango::Attribute &attr) entering... "<< endl
;
371 Matrix
<char *> const & img
= config
.parameters_names
;
372 attr
.set_value(img
.data
, img
.xdim
);
376 //+------------------------------------------------------------------
378 * method: PseudoAxes::axis_init
380 * description: method to execute "AxisInit"
381 * Initialize the pseudoAxes (exemple the psi pseudo axis)
385 //+------------------------------------------------------------------
386 void PseudoAxes::axis_init()
388 DEBUG_STREAM
<< "PseudoAxes::axis_init(): entering... !" << endl
;
390 // Add your own code to control device here
396 //+------------------------------------------------------------------
398 * method: PseudoAxes::dev_state
400 * description: method to execute "State"
401 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
406 //+------------------------------------------------------------------
407 Tango::DevState
PseudoAxes::dev_state()
409 Tango::DevState argout
= DeviceImpl::dev_state();
410 DEBUG_STREAM
<< "PseudoAxes::dev_state(): entering... !" << endl
;
412 // Add your own code to control device here
415 this->set_state(config
.state
);
417 return this->device_state
;
420 //+------------------------------------------------------------------
422 * method: PseudoAxes::dev_status
424 * description: method to execute "Status"
425 * This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
427 * @return Status description
430 //+------------------------------------------------------------------
431 Tango::ConstDevString
PseudoAxes::dev_status()
433 Tango::ConstDevString argout
= DeviceImpl::dev_status();
434 DEBUG_STREAM
<< "PseudoAxes::dev_status(): entering... !" << endl
;
436 // Add your own code to control device here
439 this->set_status(config
.status
);
441 return this->device_status
.c_str();
446 //+------------------------------------------------------------------
448 * method: PseudoAxes::apply
450 * description: method to execute "Apply"
451 * Apply the values of the pseudo axes and write them on the diffractometer device.
455 //+------------------------------------------------------------------
456 void PseudoAxes::apply()
458 DEBUG_STREAM
<< "PseudoAxes::apply(): entering... !" << endl
;
460 // Add your own code to control device here