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;
126 // we can get the Diffractometer device adapter in the init as this one start all PseudoAxes
128 _hklAdapter
= Diffractometer_ns::TangoHKLAdapterFactory::instance()->get_diffractometer_adapter(diffractometerProxy
);
130 if(_hklAdapter
&& !_adapter
){
131 _adapter
= _hklAdapter
->pseudo_axes_adapter_get_by_name(engineName
);
133 _adapter
->set_device(this);
134 _adapter
->add_dynamic_attributes();
141 //+----------------------------------------------------------------------------
143 // method : PseudoAxes::get_device_property()
145 // description : Read the device properties from database.
147 //-----------------------------------------------------------------------------
148 void PseudoAxes::get_device_property()
150 // Initialize your default values here (if not done with POGO).
151 //------------------------------------------------------------------
153 // Read device properties from database.(Automatic code generation)
154 //------------------------------------------------------------------
155 Tango::DbData dev_prop
;
156 dev_prop
.push_back(Tango::DbDatum("DiffractometerProxy"));
157 dev_prop
.push_back(Tango::DbDatum("EngineName"));
159 // Call database and extract values
160 //--------------------------------------------
161 if (Tango::Util::instance()->_UseDb
==true)
162 get_db_device()->get_property(dev_prop
);
163 Tango::DbDatum def_prop
, cl_prop
;
164 PseudoAxesClass
*ds_class
=
165 (static_cast<PseudoAxesClass
*>(get_device_class()));
168 // Try to initialize DiffractometerProxy from class property
169 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
170 if (cl_prop
.is_empty()==false) cl_prop
>> diffractometerProxy
;
172 // Try to initialize DiffractometerProxy from default device value
173 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
174 if (def_prop
.is_empty()==false) def_prop
>> diffractometerProxy
;
176 // And try to extract DiffractometerProxy value from database
177 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> diffractometerProxy
;
179 // Try to initialize EngineName from class property
180 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
181 if (cl_prop
.is_empty()==false) cl_prop
>> engineName
;
183 // Try to initialize EngineName from default device value
184 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
185 if (def_prop
.is_empty()==false) def_prop
>> engineName
;
187 // And try to extract EngineName value from database
188 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> engineName
;
192 // End of Automatic code generation
193 //------------------------------------------------------------------
196 //+----------------------------------------------------------------------------
198 // method : PseudoAxes::always_executed_hook()
200 // description : method always executed before any command is executed
202 //-----------------------------------------------------------------------------
203 void PseudoAxes::always_executed_hook()
206 _hklAdapter
= Diffractometer_ns::TangoHKLAdapterFactory::instance()->get_diffractometer_adapter(diffractometerProxy
);
208 if(_hklAdapter
&& !_adapter
)
209 _adapter
= _hklAdapter
->pseudo_axes_adapter_get_by_name(engineName
);
212 //+----------------------------------------------------------------------------
214 // method : PseudoAxes::read_attr_hardware
216 // description : Hardware acquisition for attributes.
218 //-----------------------------------------------------------------------------
219 void PseudoAxes::read_attr_hardware(vector
<long> &attr_list
)
221 DEBUG_STREAM
<< "PseudoAxes::read_attr_hardware(vector<long> &attr_list) entering... "<< endl
;
222 // Add your own code here
224 config
= _adapter
->get_config();
226 //+----------------------------------------------------------------------------
228 // method : PseudoAxes::read_initialized
230 // description : Extract real attribute values for initialized acquisition result.
232 //-----------------------------------------------------------------------------
233 void PseudoAxes::read_initialized(Tango::Attribute
&attr
)
235 DEBUG_STREAM
<< "PseudoAxes::read_initialized(Tango::Attribute &attr) entering... "<< endl
;
237 attr
.set_value(&config
.initialized
);
240 //+----------------------------------------------------------------------------
242 // method : PseudoAxes::write_initialized
244 // description : Write initialized attribute values to hardware.
246 //-----------------------------------------------------------------------------
247 void PseudoAxes::write_initialized(Tango::WAttribute
&attr
)
249 DEBUG_STREAM
<< "PseudoAxes::write_initialized(Tango::WAttribute &attr) entering... "<< endl
;
252 Tango::DevBoolean initialized
;
253 attr
.get_write_value(initialized
);
254 _adapter
->set_initialized(initialized
);
258 //+----------------------------------------------------------------------------
260 // method : PseudoAxes::read_parameters
262 // description : Extract real attribute values for parameters acquisition result.
264 //-----------------------------------------------------------------------------
265 void PseudoAxes::read_parameters(Tango::Attribute
&attr
)
267 DEBUG_STREAM
<< "PseudoAxes::read_parameters(Tango::Attribute &attr) entering... "<< endl
;
270 Matrix
<double> const & img
= config
.parameters
;
271 attr
.set_value(img
.data
, img
.xdim
);
275 //+----------------------------------------------------------------------------
277 // method : PseudoAxes::write_parameters
279 // description : Write parameters attribute values to hardware.
281 //-----------------------------------------------------------------------------
282 void PseudoAxes::write_parameters(Tango::WAttribute
&attr
)
284 DEBUG_STREAM
<< "PseudoAxes::write_parameters(Tango::WAttribute &attr) entering... "<< endl
;
287 const Tango::DevDouble
*values
;
288 attr
.get_write_value(values
);
290 img
.attach_to_const_buffer(values
,
291 attr
.get_w_dim_x(), attr
.get_w_dim_y());
293 _adapter
->set_parameters(img
);
297 //+----------------------------------------------------------------------------
299 // method : PseudoAxes::read_pseudoAxisNames
301 // description : Extract real attribute values for pseudoAxisNames acquisition result.
303 //-----------------------------------------------------------------------------
304 void PseudoAxes::read_pseudoAxisNames(Tango::Attribute
&attr
)
306 DEBUG_STREAM
<< "PseudoAxes::read_pseudoAxisNames(Tango::Attribute &attr) entering... "<< endl
;
308 Matrix
<char *> const & img
= config
.pseudo_axes_names
;
309 attr
.set_value(img
.data
, img
.xdim
);
314 //+----------------------------------------------------------------------------
316 // method : PseudoAxes::read_mode
318 // description : Extract real attribute values for mode acquisition result.
320 //-----------------------------------------------------------------------------
321 void PseudoAxes::read_mode(Tango::Attribute
&attr
)
323 DEBUG_STREAM
<< "PseudoAxes::read_mode(Tango::Attribute &attr) entering... "<< endl
;
325 attr
.set_value(&config
.mode
);
328 //+----------------------------------------------------------------------------
330 // method : PseudoAxes::write_mode
332 // description : Write mode attribute values to hardware.
334 //-----------------------------------------------------------------------------
335 void PseudoAxes::write_mode(Tango::WAttribute
&attr
)
337 DEBUG_STREAM
<< "PseudoAxes::write_mode(Tango::WAttribute &attr) entering... "<< endl
;
338 attr
.get_write_value(attr_mode_write
);
340 _adapter
->set_mode(attr_mode_write
);
343 //+----------------------------------------------------------------------------
345 // method : PseudoAxes::read_modeNames
347 // description : Extract real attribute values for modeNames acquisition result.
349 //-----------------------------------------------------------------------------
350 void PseudoAxes::read_modeNames(Tango::Attribute
&attr
)
352 DEBUG_STREAM
<< "PseudoAxes::read_modeNames(Tango::Attribute &attr) entering... "<< endl
;
354 Matrix
<char *> const & img
= config
.mode_names
;
355 attr
.set_value(img
.data
, img
.xdim
);
359 //+----------------------------------------------------------------------------
361 // method : PseudoAxes::read_parametersNames
363 // description : Extract real attribute values for parametersNames acquisition result.
365 //-----------------------------------------------------------------------------
366 void PseudoAxes::read_parametersNames(Tango::Attribute
&attr
)
368 DEBUG_STREAM
<< "PseudoAxes::read_parametersNames(Tango::Attribute &attr) entering... "<< endl
;
370 Matrix
<char *> const & img
= config
.parameters_names
;
371 attr
.set_value(img
.data
, img
.xdim
);
375 //+------------------------------------------------------------------
377 * method: PseudoAxes::axis_init
379 * description: method to execute "AxisInit"
380 * Initialize the pseudoAxes (exemple the psi pseudo axis)
384 //+------------------------------------------------------------------
385 void PseudoAxes::axis_init()
387 DEBUG_STREAM
<< "PseudoAxes::axis_init(): entering... !" << endl
;
389 // Add your own code to control device here
395 //+------------------------------------------------------------------
397 * method: PseudoAxes::dev_state
399 * description: method to execute "State"
400 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
405 //+------------------------------------------------------------------
406 Tango::DevState
PseudoAxes::dev_state()
408 Tango::DevState argout
= DeviceImpl::dev_state();
409 DEBUG_STREAM
<< "PseudoAxes::dev_state(): entering... !" << endl
;
411 // Add your own code to control device here
414 this->set_state(config
.state
);
416 return this->device_state
;
419 //+------------------------------------------------------------------
421 * method: PseudoAxes::dev_status
423 * description: method to execute "Status"
424 * This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
426 * @return Status description
429 //+------------------------------------------------------------------
430 Tango::ConstDevString
PseudoAxes::dev_status()
432 Tango::ConstDevString argout
= DeviceImpl::dev_status();
433 DEBUG_STREAM
<< "PseudoAxes::dev_status(): entering... !" << endl
;
435 // Add your own code to control device here
438 this->set_status(config
.status
);
440 return this->device_status
.c_str();