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 // we can get the Diffractometer device adapter in the init as this one start all PseudoAxes
123 _hklAdapter
= Diffractometer_ns::TangoHKLAdapterFactory::instance()->get_diffractometer_adapter(diffractometerProxy
);
125 if(_hklAdapter
&& !_adapter
){
126 _adapter
= _hklAdapter
->pseudo_axes_adapter_get_by_name(engineName
);
128 _adapter
->set_device(this);
129 _adapter
->add_dynamic_attributes();
136 //+----------------------------------------------------------------------------
138 // method : PseudoAxes::get_device_property()
140 // description : Read the device properties from database.
142 //-----------------------------------------------------------------------------
143 void PseudoAxes::get_device_property()
145 // Initialize your default values here (if not done with POGO).
146 //------------------------------------------------------------------
148 // Read device properties from database.(Automatic code generation)
149 //------------------------------------------------------------------
150 Tango::DbData dev_prop
;
151 dev_prop
.push_back(Tango::DbDatum("DiffractometerProxy"));
152 dev_prop
.push_back(Tango::DbDatum("EngineName"));
154 // Call database and extract values
155 //--------------------------------------------
156 if (Tango::Util::instance()->_UseDb
==true)
157 get_db_device()->get_property(dev_prop
);
158 Tango::DbDatum def_prop
, cl_prop
;
159 PseudoAxesClass
*ds_class
=
160 (static_cast<PseudoAxesClass
*>(get_device_class()));
163 // Try to initialize DiffractometerProxy from class property
164 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
165 if (cl_prop
.is_empty()==false) cl_prop
>> diffractometerProxy
;
167 // Try to initialize DiffractometerProxy from default device value
168 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
169 if (def_prop
.is_empty()==false) def_prop
>> diffractometerProxy
;
171 // And try to extract DiffractometerProxy value from database
172 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> diffractometerProxy
;
174 // Try to initialize EngineName from class property
175 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
176 if (cl_prop
.is_empty()==false) cl_prop
>> engineName
;
178 // Try to initialize EngineName from default device value
179 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
180 if (def_prop
.is_empty()==false) def_prop
>> engineName
;
182 // And try to extract EngineName value from database
183 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> engineName
;
187 // End of Automatic code generation
188 //------------------------------------------------------------------
191 //+----------------------------------------------------------------------------
193 // method : PseudoAxes::always_executed_hook()
195 // description : method always executed before any command is executed
197 //-----------------------------------------------------------------------------
198 void PseudoAxes::always_executed_hook()
201 _hklAdapter
= Diffractometer_ns::TangoHKLAdapterFactory::instance()->get_diffractometer_adapter(diffractometerProxy
);
203 if(_hklAdapter
&& !_adapter
)
204 _adapter
= _hklAdapter
->pseudo_axes_adapter_get_by_name(engineName
);
207 //+----------------------------------------------------------------------------
209 // method : PseudoAxes::read_attr_hardware
211 // description : Hardware acquisition for attributes.
213 //-----------------------------------------------------------------------------
214 void PseudoAxes::read_attr_hardware(vector
<long> &attr_list
)
216 DEBUG_STREAM
<< "PseudoAxes::read_attr_hardware(vector<long> &attr_list) entering... "<< endl
;
217 // Add your own code here
219 _hklAdapter
->update();
221 //+----------------------------------------------------------------------------
223 // method : PseudoAxes::read_parameters
225 // description : Extract real attribute values for parameters acquisition result.
227 //-----------------------------------------------------------------------------
228 void PseudoAxes::read_parameters(Tango::Attribute
&attr
)
230 DEBUG_STREAM
<< "PseudoAxes::read_parameters(Tango::Attribute &attr) entering... "<< endl
;
233 Matrix
<double> const & img
= _adapter
->get_mode_parameters();
234 attr
.set_value(img
.data
, img
.xdim
);
238 //+----------------------------------------------------------------------------
240 // method : PseudoAxes::write_parameters
242 // description : Write parameters attribute values to hardware.
244 //-----------------------------------------------------------------------------
245 void PseudoAxes::write_parameters(Tango::WAttribute
&attr
)
247 DEBUG_STREAM
<< "PseudoAxes::write_parameters(Tango::WAttribute &attr) entering... "<< endl
;
250 const Tango::DevDouble
*values
;
251 attr
.get_write_value(values
);
253 img
.attach_to_const_buffer(values
,
254 attr
.get_w_dim_x(), attr
.get_w_dim_y());
256 _adapter
->set_mode_parameters(img
);
260 //+----------------------------------------------------------------------------
262 // method : PseudoAxes::read_pseudoAxisNames
264 // description : Extract real attribute values for pseudoAxisNames acquisition result.
266 //-----------------------------------------------------------------------------
267 void PseudoAxes::read_pseudoAxisNames(Tango::Attribute
&attr
)
269 DEBUG_STREAM
<< "PseudoAxes::read_pseudoAxisNames(Tango::Attribute &attr) entering... "<< endl
;
271 Matrix
<char *> const & img
= _adapter
->get_pseudo_axis_names();
272 attr
.set_value(img
.data
, img
.xdim
);
277 //+----------------------------------------------------------------------------
279 // method : PseudoAxes::read_mode
281 // description : Extract real attribute values for mode acquisition result.
283 //-----------------------------------------------------------------------------
284 void PseudoAxes::read_mode(Tango::Attribute
&attr
)
286 DEBUG_STREAM
<< "PseudoAxes::read_mode(Tango::Attribute &attr) entering... "<< endl
;
288 attr
.set_value(_adapter
->get_mode());
291 //+----------------------------------------------------------------------------
293 // method : PseudoAxes::write_mode
295 // description : Write mode attribute values to hardware.
297 //-----------------------------------------------------------------------------
298 void PseudoAxes::write_mode(Tango::WAttribute
&attr
)
300 DEBUG_STREAM
<< "PseudoAxes::write_mode(Tango::WAttribute &attr) entering... "<< endl
;
301 attr
.get_write_value(attr_mode_write
);
303 _adapter
->set_mode(attr_mode_write
);
306 //+----------------------------------------------------------------------------
308 // method : PseudoAxes::read_modeNames
310 // description : Extract real attribute values for modeNames acquisition result.
312 //-----------------------------------------------------------------------------
313 void PseudoAxes::read_modeNames(Tango::Attribute
&attr
)
315 DEBUG_STREAM
<< "PseudoAxes::read_modeNames(Tango::Attribute &attr) entering... "<< endl
;
317 Matrix
<char *> const & img
= _adapter
->get_mode_names();
318 attr
.set_value(img
.data
, img
.xdim
);
322 //+----------------------------------------------------------------------------
324 // method : PseudoAxes::read_parametersNames
326 // description : Extract real attribute values for parametersNames acquisition result.
328 //-----------------------------------------------------------------------------
329 void PseudoAxes::read_parametersNames(Tango::Attribute
&attr
)
331 DEBUG_STREAM
<< "PseudoAxes::read_parametersNames(Tango::Attribute &attr) entering... "<< endl
;
333 Matrix
<char *> const & img
= _adapter
->get_mode_parameters_names();
334 attr
.set_value(img
.data
, img
.xdim
);
338 //+------------------------------------------------------------------
340 * method: PseudoAxes::axis_init
342 * description: method to execute "AxisInit"
343 * Initialize the pseudoAxes (exemple the psi pseudo axis)
347 //+------------------------------------------------------------------
348 void PseudoAxes::axis_init()
350 DEBUG_STREAM
<< "PseudoAxes::axis_init(): entering... !" << endl
;
352 // Add your own code to control device here
358 //+------------------------------------------------------------------
360 * method: PseudoAxes::dev_state
362 * description: method to execute "State"
363 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
368 //+------------------------------------------------------------------
369 Tango::DevState
PseudoAxes::dev_state()
371 Tango::DevState argout
= DeviceImpl::dev_state();
372 DEBUG_STREAM
<< "PseudoAxes::dev_state(): entering... !" << endl
;
374 // Add your own code to control device here
377 argout
= _adapter
->get_state();
383 //+------------------------------------------------------------------
385 * method: PseudoAxes::dev_status
387 * description: method to execute "Status"
388 * This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
390 * @return Status description
393 //+------------------------------------------------------------------
394 Tango::ConstDevString
PseudoAxes::dev_status()
396 Tango::ConstDevString argout
= DeviceImpl::dev_status();
397 DEBUG_STREAM
<< "PseudoAxes::dev_status(): entering... !" << endl
;
399 // Add your own code to control device here
402 argout
= _adapter
->get_status().c_str();