* remove the PseudoAxesNames attribut from the Diffractometer
[diffractometer.git] / src / Diffractometer / Diffractometer.cpp
blob5930724eec93d5614336a83147d7f5e2789552d0
1 static const char *RcsId = "$Header: /cvsroot/tango-ds/Instrumentation/Diffractometer/src/Diffractometer.cpp,v 1.5 2008/11/28 15:46:32 piccaf Exp $";
2 //+=============================================================================
3 //
4 // file : Diffractometer.cpp
5 //
6 // description : C++ source for the Diffractometer 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 // Diffractometer are implemented in this file.
12 // project : TANGO Device Server
14 // $Author: piccaf $
16 // $Revision: 1.5 $
18 // $Log: Diffractometer.cpp,v $
19 // Revision 1.5 2008/11/28 15:46:32 piccaf
20 // * close # mantis: 11051
22 // Revision 1.4 2008/10/16 10:16:55 piccaf
23 // * update to build on windows with vc8
24 // * add the Eulerian6C diffractometer.
25 // * add the dynamic attributes in the factory instead of the init device
27 // Revision 1.3 2008/09/22 16:20:35 vince_soleil
28 // Set first character of attribute name in minus
30 // Revision 1.2 2008/09/22 08:46:23 piccaf
31 // * add files from the new diffractometer Device
34 // copyleft : European Synchrotron Radiation Facility
35 // BP 220, Grenoble 38043
36 // FRANCE
38 //-=============================================================================
40 // This file is generated by POGO
41 // (Program Obviously used to Generate tango Object)
43 // (c) - Software Engineering Group - ESRF
44 //=============================================================================
48 //===================================================================
50 // The following table gives the correspondence
51 // between commands and method name.
53 // Command name | Method name
54 // ----------------------------------------
55 // State | dev_state()
56 // Status | dev_status()
57 // Abort | abort()
58 // AddNewCrystal | add_new_crystal()
59 // AddReflection | add_reflection()
60 // AffineCrystal | affine_crystal()
61 // ComputedAnglesClear | computed_angles_clear()
62 // ComputedAnglesHKLList | computed_angles_hkllist()
63 // ComputeU | compute_u()
64 // ConfigureCrystal | configure_crystal()
65 // CopyCurrentCrystalAs | copy_current_crystal_as()
66 // CopyReflectionTo | copy_reflection_to()
67 // DeleteCurrentCrystal | delete_current_crystal()
68 // GetAffinementIteration | get_affinement_iteration()
69 // GetAffinementList | get_affinement_list()
70 // GetAffinementMaxIteration | get_affinement_max_iteration()
71 // GetAxesNames | get_axes_names()
72 // GetCrystalNames | get_crystal_names()
73 // GetCrystalParameterValues | get_crystal_parameter_values()
74 // GetModeDescription | get_mode_description()
75 // GetModeParametersNames | get_mode_parameters_names()
76 // GetModeParametersValues | get_mode_parameters_values()
77 // GetModeParameterValue | get_mode_parameter_value()
78 // GetReflection | get_reflection()
79 // GetReflectionSize | get_reflection_size()
80 // GotoComputedAngles | goto_computed_angles()
81 // GotoReflection | goto_reflection()
82 // Load | load()
83 // RemoveReflection | remove_reflection()
84 // Save | save()
85 // SetAffinementMaxIteration | set_affinement_max_iteration()
86 // SetCrystalParameterValues | set_crystal_parameter_values()
87 // SetHKL | set_hkl()
88 // SetModeParametersValues | set_mode_parameters_values()
89 // SetReflection | set_reflection()
91 //===================================================================
94 #include <tango.h>
95 #include <Diffractometer.h>
96 #include <DiffractometerClass.h>
98 #include <time.h>
99 #include <sstream>
100 #include <algorithm>
101 #include <cctype>
102 #include <string>
104 #include "macros.h"
105 #include "AxisAttrib.h"
106 #include "TangoHKLAdapterFactory.h"
108 namespace Diffractometer_ns
111 //+----------------------------------------------------------------------------
113 // method : Diffractometer::Diffractometer(string &s)
115 // description : constructor for simulated Diffractometer
117 // in : - cl : Pointer to the DeviceClass object
118 // - s : Device name
120 //-----------------------------------------------------------------------------
121 Diffractometer::Diffractometer(Tango::DeviceClass *cl,string &s)
122 :Tango::Device_3Impl(cl,s.c_str())
124 init_device();
127 Diffractometer::Diffractometer(Tango::DeviceClass *cl,const char *s)
128 :Tango::Device_3Impl(cl,s)
130 init_device();
133 Diffractometer::Diffractometer(Tango::DeviceClass *cl,const char *s,const char *d)
134 :Tango::Device_3Impl(cl,s,d)
136 init_device();
138 //+----------------------------------------------------------------------------
140 // method : Diffractometer::delete_device()
142 // description : will be called at device destruction or at init command.
144 //-----------------------------------------------------------------------------
145 void Diffractometer::delete_device()
147 // Delete device's allocated object
148 this->save();
150 // Delete device's allocated object
151 DELETE_SCALAR_ATTRIBUTE(attr_H_read);
152 DELETE_SCALAR_ATTRIBUTE(attr_K_read);
153 DELETE_SCALAR_ATTRIBUTE(attr_L_read);
154 DELETE_SCALAR_ATTRIBUTE(attr_AnglesIdx_read);
155 DELETE_SCALAR_ATTRIBUTE(attr_WaveLength_read);
156 DELETE_SCALAR_ATTRIBUTE(attr_Simulated_read);
157 DELETE_SCALAR_ATTRIBUTE(attr_A_read);
158 DELETE_SCALAR_ATTRIBUTE(attr_B_read);
159 DELETE_SCALAR_ATTRIBUTE(attr_C_read);
160 DELETE_SCALAR_ATTRIBUTE(attr_Alpha_read);
161 DELETE_SCALAR_ATTRIBUTE(attr_Beta_read);
162 DELETE_SCALAR_ATTRIBUTE(attr_Gamma_read);
163 DELETE_SCALAR_ATTRIBUTE(attr_Ux_read);
164 DELETE_SCALAR_ATTRIBUTE(attr_Uy_read);
165 DELETE_SCALAR_ATTRIBUTE(attr_Uz_read);
166 DELETE_SCALAR_ATTRIBUTE(attr_AStar_read);
167 DELETE_SCALAR_ATTRIBUTE(attr_BStar_read);
168 DELETE_SCALAR_ATTRIBUTE(attr_CStar_read);
169 DELETE_SCALAR_ATTRIBUTE(attr_AlphaStar_read);
170 DELETE_SCALAR_ATTRIBUTE(attr_BetaStar_read);
171 DELETE_SCALAR_ATTRIBUTE(attr_GammaStar_read);
173 DELETE_DEVSTRING_ATTRIBUTE(attr_Mode_read);
174 DELETE_DEVSTRING_ATTRIBUTE(attr_Crystal_read);
176 if(attr_CrystalReflections_read) {
177 delete[] attr_CrystalReflections_read;
178 attr_CrystalReflections_read = NULL;
181 if(attr_UB_read) {
182 delete[] attr_UB_read;
183 attr_UB_read = NULL;
186 if(attr_ReflectionsAngles_read) {
187 delete [] attr_ReflectionsAngles_read;
188 attr_ReflectionsAngles_read = NULL;
191 if (attr_ComputedAngles_read) {
192 delete [] attr_ComputedAngles_read;
193 attr_ComputedAngles_read = NULL;
196 if(attr_Reflections_read){
197 delete[] attr_Reflections_read;
198 attr_Reflections_read = NULL;
201 this->remove_dynamic_attributes();
203 _hklAdapter->pseudo_axes_stop_and_remove_devices();
206 * Do not remove the diffractometer in the delete method
207 * of the Derived classes to avoid a segmentation fault
208 * during the save method call. Indeed the Derived class delete
209 * method is called before this delete method.
211 TangoHKLAdapterFactory::instance()->detach_diffractometer_device(this);
214 //+----------------------------------------------------------------------------
216 // method : Diffractometer::init_device()
218 // description : will be called at device initialization.
220 //-----------------------------------------------------------------------------
221 void Diffractometer::init_device()
223 INFO_STREAM << "Diffractometer::Diffractometer() create device " << device_name << endl;
225 // Initialise variables to default values
226 //--------------------------------------------
227 get_device_property();
229 CREATE_SCALAR_ATTRIBUTE(attr_H_read, 0.0);
230 CREATE_SCALAR_ATTRIBUTE(attr_K_read, 0.0);
231 CREATE_SCALAR_ATTRIBUTE(attr_L_read, 0.0);
232 CREATE_SCALAR_ATTRIBUTE(attr_AnglesIdx_read, (short)-1);
233 CREATE_SCALAR_ATTRIBUTE(attr_WaveLength_read, 0.0);
234 CREATE_SCALAR_ATTRIBUTE(attr_Simulated_read, true);
235 CREATE_SCALAR_ATTRIBUTE(attr_A_read, 0.0);
236 CREATE_SCALAR_ATTRIBUTE(attr_B_read, 0.0);
237 CREATE_SCALAR_ATTRIBUTE(attr_C_read, 0.0);
238 CREATE_SCALAR_ATTRIBUTE(attr_Alpha_read, 0.0);
239 CREATE_SCALAR_ATTRIBUTE(attr_Beta_read, 0.0);
240 CREATE_SCALAR_ATTRIBUTE(attr_Gamma_read, 0.0);
241 CREATE_SCALAR_ATTRIBUTE(attr_Ux_read, 0.0);
242 CREATE_SCALAR_ATTRIBUTE(attr_Uy_read, 0.0);
243 CREATE_SCALAR_ATTRIBUTE(attr_Uz_read, 0.0);
244 CREATE_SCALAR_ATTRIBUTE(attr_AStar_read);
245 CREATE_SCALAR_ATTRIBUTE(attr_BStar_read);
246 CREATE_SCALAR_ATTRIBUTE(attr_CStar_read);
247 CREATE_SCALAR_ATTRIBUTE(attr_AlphaStar_read);
248 CREATE_SCALAR_ATTRIBUTE(attr_BetaStar_read);
249 CREATE_SCALAR_ATTRIBUTE(attr_GammaStar_read);
251 CREATE_DEVSTRING_ATTRIBUTE(attr_Crystal_read, 1, "");
252 CREATE_DEVSTRING_ATTRIBUTE(attr_Mode_read, 1, "");
254 attr_CrystalReflections_read = NULL;
255 attr_UB_read = NULL;
256 attr_ReflectionsAngles_read = NULL;
257 attr_ComputedAngles_read = NULL;
258 attr_Reflections_read = NULL;
259 attr_AxesNames_read = NULL;
261 // get the write part of the hkl attributes
262 _att_h_w = &dev_attr->get_w_attr_by_name("h");
263 _att_k_w = &dev_attr->get_w_attr_by_name("k");
264 _att_l_w = &dev_attr->get_w_attr_by_name("l");
266 // Device is in FAULT state because it was not yet configured.
267 this->set_state(Tango::FAULT);
268 this->set_status("Configure Diffractometer: crystal, wavelength,etc ..");
270 _computedAngles_size = 0;
272 // Write values
273 attr_H_write = 0.0;
274 attr_K_write = 0.0;
275 attr_L_write = 0.0;
278 _type = this->get_type_from_property(diffractometerType);
281 * this method must be call after get_device_property() as
282 * TangoHKLAdapter create the axisbuffer from the
283 * realAxisProxies.
285 _hklAdapter = TangoHKLAdapterFactory::instance()->attach_diffractometer_device(this, _type);
286 if (!_hklAdapter) {
287 this->set_state(Tango::FAULT);
288 this->set_status("Fatal can not initialize the hkl library");
289 TANGO_EXCEPTION_THROW("Internal Fatal Error", "Device can't get an instance of TangoHKLAdapter");
290 } else {
291 // Restore the Diffractometer state from the last run.
292 this->load();
294 _hklAdapter->connect_all_proxies();
296 // create an start all the PseudoAxes devices.
297 _hklAdapter->pseudo_axes_create_and_start_devices();
300 _write_attributes_hkl_together = false;
304 //+----------------------------------------------------------------------------
306 // method : Diffractometer::get_device_property()
308 // description : Read the device properties from database.
310 //-----------------------------------------------------------------------------
311 void Diffractometer::get_device_property()
313 // Initialize your default values here (if not done with POGO).
314 //------------------------------------------------------------------
316 // Read device properties from database.(Automatic code generation)
317 //------------------------------------------------------------------
318 Tango::DbData dev_prop;
319 dev_prop.push_back(Tango::DbDatum("TauConstant"));
320 dev_prop.push_back(Tango::DbDatum("RealAxisProxies"));
321 dev_prop.push_back(Tango::DbDatum("LambdaAttributeProxy"));
322 dev_prop.push_back(Tango::DbDatum("DiffractometerType"));
324 // Call database and extract values
325 //--------------------------------------------
326 if (Tango::Util::instance()->_UseDb==true)
327 get_db_device()->get_property(dev_prop);
328 Tango::DbDatum def_prop, cl_prop;
329 DiffractometerClass *ds_class =
330 (static_cast<DiffractometerClass *>(get_device_class()));
331 int i = -1;
333 // Try to initialize TauConstant from class property
334 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
335 if (cl_prop.is_empty()==false) cl_prop >> tauConstant;
336 else {
337 // Try to initialize TauConstant from default device value
338 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
339 if (def_prop.is_empty()==false) def_prop >> tauConstant;
341 // And try to extract TauConstant value from database
342 if (dev_prop[i].is_empty()==false) dev_prop[i] >> tauConstant;
344 // Try to initialize RealAxisProxies from class property
345 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
346 if (cl_prop.is_empty()==false) cl_prop >> realAxisProxies;
347 else {
348 // Try to initialize RealAxisProxies from default device value
349 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
350 if (def_prop.is_empty()==false) def_prop >> realAxisProxies;
352 // And try to extract RealAxisProxies value from database
353 if (dev_prop[i].is_empty()==false) dev_prop[i] >> realAxisProxies;
355 // Try to initialize LambdaAttributeProxy from class property
356 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
357 if (cl_prop.is_empty()==false) cl_prop >> lambdaAttributeProxy;
358 else {
359 // Try to initialize LambdaAttributeProxy from default device value
360 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
361 if (def_prop.is_empty()==false) def_prop >> lambdaAttributeProxy;
363 // And try to extract LambdaAttributeProxy value from database
364 if (dev_prop[i].is_empty()==false) dev_prop[i] >> lambdaAttributeProxy;
366 // Try to initialize DiffractometerType from class property
367 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
368 if (cl_prop.is_empty()==false) cl_prop >> diffractometerType;
369 else {
370 // Try to initialize DiffractometerType from default device value
371 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
372 if (def_prop.is_empty()==false) def_prop >> diffractometerType;
374 // And try to extract DiffractometerType value from database
375 if (dev_prop[i].is_empty()==false) dev_prop[i] >> diffractometerType;
379 // End of Automatic code generation
380 //------------------------------------------------------------------
383 //+----------------------------------------------------------------------------
385 // method : Diffractometer::always_executed_hook()
387 // description : method always executed before any command is executed
389 //-----------------------------------------------------------------------------
390 void Diffractometer::always_executed_hook()
392 if (_hklAdapter)
393 _hklAdapter->connect_all_proxies();
395 //+----------------------------------------------------------------------------
397 // method : Diffractometer::read_attr_hardware
399 // description : Hardware acquisition for attributes.
401 //-----------------------------------------------------------------------------
402 void Diffractometer::read_attr_hardware(vector<long> &attr_list)
404 DEBUG_STREAM << "Diffractometer::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
405 // Add your own code here
406 if (!_hklAdapter)
407 return;
409 _hklAdapter->update();
411 // update the hkl attributes
414 HKLBuffer const & buffer = _hklAdapter->get_HKLBuffer();
415 *attr_H_read = buffer.h_r;
416 attr_H_write = buffer.h_w;
417 *attr_K_read = buffer.k_r;
418 attr_K_write = buffer.k_w;
419 *attr_L_read = buffer.l_r;
420 attr_L_write = buffer.l_w;
422 // set the write part of the hkl attributes
423 _att_h_w->set_write_value(buffer.h_w);
424 _att_k_w->set_write_value(buffer.k_w);
425 _att_l_w->set_write_value(buffer.l_w);
427 catch (Tango::DevFailed & e)
429 ERROR_STREAM << e <<endl;
432 _hklAdapter->get_sample_lattices(attr_A_read, attr_B_read, attr_C_read,
433 attr_Alpha_read, attr_Beta_read, attr_Gamma_read,
434 attr_AStar_read, attr_BStar_read, attr_CStar_read,
435 attr_AlphaStar_read, attr_BetaStar_read, attr_GammaStar_read);
437 //+----------------------------------------------------------------------------
439 // method : Diffractometer::read_pseudoAxesProxies
441 // description : Extract real attribute values for pseudoAxesProxies acquisition result.
443 //-----------------------------------------------------------------------------
444 void Diffractometer::read_pseudoAxesProxies(Tango::Attribute &attr)
446 DEBUG_STREAM << "Diffractometer::read_pseudoAxesProxies(Tango::Attribute &attr) entering... "<< endl;
447 if(_hklAdapter){
448 Matrix<char *> const & img = _hklAdapter->get_pseudo_axes_proxies();
449 attr.set_value(img.data, img.xdim);
453 //+----------------------------------------------------------------------------
455 // method : Diffractometer::read_AnglesIdx
457 // description : Extract real attribute values for AnglesIdx acquisition result.
459 //-----------------------------------------------------------------------------
460 void Diffractometer::read_AnglesIdx(Tango::Attribute &attr)
462 DEBUG_STREAM << "Diffractometer::read_AnglesIdx(Tango::Attribute &attr) entering... "<< endl;
464 if(_hklAdapter){
465 *attr_AnglesIdx_read = _hklAdapter->get_angles_idx();
466 attr.set_value(attr_AnglesIdx_read);
470 //+----------------------------------------------------------------------------
472 // method : Diffractometer::write_AnglesIdx
474 // description : Write AnglesIdx attribute values to hardware.
476 //-----------------------------------------------------------------------------
477 void Diffractometer::write_AnglesIdx(Tango::WAttribute &attr)
479 DEBUG_STREAM << "Diffractometer::write_AnglesIdx(Tango::WAttribute &attr) entering... "<< endl;
481 attr.get_write_value(attr_AnglesIdx_write);
482 if(_hklAdapter)
483 _hklAdapter->set_angles_idx(attr_AnglesIdx_write);
486 //+----------------------------------------------------------------------------
488 // method : Diffractometer::read_AxesNames
490 // description : Extract real attribute values for AxesNames acquisition result.
492 //-----------------------------------------------------------------------------
493 void Diffractometer::read_AxesNames(Tango::Attribute &attr)
495 if(_hklAdapter){
496 Matrix<char *> const & img = _hklAdapter->get_dynamic_attribute_axes_names();
497 attr.set_value(img.data, img.xdim);
501 //+----------------------------------------------------------------------------
503 // method : Diffractometer::read_Angles
505 // description : Extract real attribute values for Angles acquisition result.
507 //-----------------------------------------------------------------------------
508 void Diffractometer::read_Angles(Tango::Attribute &attr)
510 DEBUG_STREAM << "Diffractometer::read_Angles(Tango::Attribute &attr) entering... "<< endl;
511 if(_hklAdapter){
512 Matrix<double> const & img = _hklAdapter->get_angles();
513 attr.set_value(img.data, img.xdim, img.ydim);
517 //+----------------------------------------------------------------------------
519 // method : Diffractometer::read_AnglesDegenerated
521 // description : Extract real attribute values for AnglesDegenerated acquisition result.
523 //-----------------------------------------------------------------------------
524 void Diffractometer::read_AnglesDegenerated(Tango::Attribute &attr)
526 DEBUG_STREAM << "Diffractometer::read_AnglesDegenerated(Tango::Attribute &attr) entering... "<< endl;
529 //+----------------------------------------------------------------------------
531 // method : Diffractometer::read_AnglesRangeCheck
533 // description : Extract real attribute values for AnglesRangeCheck acquisition result.
535 //-----------------------------------------------------------------------------
536 void Diffractometer::read_AnglesRangeCheck(Tango::Attribute &attr)
538 DEBUG_STREAM << "Diffractometer::read_AnglesRangeCheck(Tango::Attribute &attr) entering... "<< endl;
541 //+----------------------------------------------------------------------------
543 // method : Diffractometer::read_Reflections
545 // description : Extract real attribute values for Reflections acquisition result.
547 //-----------------------------------------------------------------------------
548 void Diffractometer::read_Reflections(Tango::Attribute &attr)
550 DEBUG_STREAM << "Diffractometer::read_Reflections(Tango::Attribute &attr) entering... "<< endl;
551 if(_hklAdapter){
552 Matrix<double> const & img = _hklAdapter->get_sample_reflections();
553 attr.set_value(img.data, img.xdim, img.ydim);
557 //+----------------------------------------------------------------------------
559 // method : Diffractometer::write_Reflections
561 // description : Write Reflections attribute values to hardware.
563 //-----------------------------------------------------------------------------
564 void Diffractometer::write_Reflections(Tango::WAttribute &attr)
566 DEBUG_STREAM << "Diffractometer::write_Reflections(Tango::WAttribute &attr) entering... "<< endl;
568 attr.get_write_value(attr_Reflections_write);
570 Matrix<double> img;
571 img.attach_to_buffer(&attr_Reflections_write,
572 attr.get_w_dim_x(), attr.get_w_dim_y());
574 if(_hklAdapter)
575 _hklAdapter->set_sample_reflections(img);
578 //+----------------------------------------------------------------------------
580 // method : Diffractometer::read_ComputedAngles
582 // description : Extract real attribute values for ComputedAngles acquisition result.
584 //-----------------------------------------------------------------------------
585 void Diffractometer::read_ComputedAngles(Tango::Attribute &attr)
587 DEBUG_STREAM << "Diffractometer::read_ComputedAngles(Tango::Attribute &attr) entering... "<< endl;
589 if(_hklAdapter){
590 Matrix<double> const & img = _hklAdapter->get_angles();
591 attr.set_value(img.data, img.xdim, img.ydim);
595 //+----------------------------------------------------------------------------
597 // method : Diffractometer::read_ReflectionsAngles
599 // description : Extract real attribute values for ReflectionsAngles acquisition result.
601 //-----------------------------------------------------------------------------
602 void Diffractometer::read_ReflectionsAngles(Tango::Attribute &attr)
604 DEBUG_STREAM << "Diffractometer::read_ReflectionsAngles(Tango::Attribute &attr) entering... "<< endl;
606 if (_hklAdapter){
607 Matrix<double> const & img = _hklAdapter->get_reflections_angles();
608 attr.set_value(img.data, img.xdim, img.ydim);
612 //+----------------------------------------------------------------------------
614 // method : Diffractometer::read_AStar
616 // description : Extract real attribute values for AStar acquisition result.
618 //-----------------------------------------------------------------------------
619 void Diffractometer::read_AStar(Tango::Attribute &attr)
621 DEBUG_STREAM << "Diffractometer::read_AStar(Tango::Attribute &attr) entering... "<< endl;
622 attr.set_value(attr_AStar_read);
625 //+----------------------------------------------------------------------------
627 // method : Diffractometer::read_BStar
629 // description : Extract real attribute values for BStar acquisition result.
631 //-----------------------------------------------------------------------------
632 void Diffractometer::read_BStar(Tango::Attribute &attr)
634 DEBUG_STREAM << "Diffractometer::read_BStar(Tango::Attribute &attr) entering... "<< endl;
635 attr.set_value(attr_BStar_read);
638 //+----------------------------------------------------------------------------
640 // method : Diffractometer::read_CStar
642 // description : Extract real attribute values for CStar acquisition result.
644 //-----------------------------------------------------------------------------
645 void Diffractometer::read_CStar(Tango::Attribute &attr)
647 DEBUG_STREAM << "Diffractometer::read_CStar(Tango::Attribute &attr) entering... "<< endl;
648 attr.set_value(attr_CStar_read);
651 //+----------------------------------------------------------------------------
653 // method : Diffractometer::read_AlphaStar
655 // description : Extract real attribute values for AlphaStar acquisition result.
657 //-----------------------------------------------------------------------------
658 void Diffractometer::read_AlphaStar(Tango::Attribute &attr)
660 DEBUG_STREAM << "Diffractometer::read_AlphaStar(Tango::Attribute &attr) entering... "<< endl;
661 attr.set_value(attr_AlphaStar_read);
664 //+----------------------------------------------------------------------------
666 // method : Diffractometer::read_BetaStar
668 // description : Extract real attribute values for BetaStar acquisition result.
670 //-----------------------------------------------------------------------------
671 void Diffractometer::read_BetaStar(Tango::Attribute &attr)
673 DEBUG_STREAM << "Diffractometer::read_BetaStar(Tango::Attribute &attr) entering... "<< endl;
674 attr.set_value(attr_BetaStar_read);
677 //+----------------------------------------------------------------------------
679 // method : Diffractometer::read_GammaStar
681 // description : Extract real attribute values for GammaStar acquisition result.
683 //-----------------------------------------------------------------------------
684 void Diffractometer::read_GammaStar(Tango::Attribute &attr)
686 DEBUG_STREAM << "Diffractometer::read_GammaStar(Tango::Attribute &attr) entering... "<< endl;
687 attr.set_value(attr_GammaStar_read);
690 //+----------------------------------------------------------------------------
692 // method : Diffractometer::read_A
694 // description : Extract real attribute values for A acquisition result.
696 //-----------------------------------------------------------------------------
697 void Diffractometer::read_A(Tango::Attribute &attr)
699 DEBUG_STREAM << "Diffractometer::read_A(Tango::Attribute &attr) entering... "<< endl;
700 attr.set_value(attr_A_read);
703 //+----------------------------------------------------------------------------
705 // method : Diffractometer::read_B
707 // description : Extract real attribute values for B acquisition result.
709 //-----------------------------------------------------------------------------
710 void Diffractometer::read_B(Tango::Attribute &attr)
712 DEBUG_STREAM << "Diffractometer::read_B(Tango::Attribute &attr) entering... "<< endl;
713 attr.set_value(attr_B_read);
716 //+----------------------------------------------------------------------------
718 // method : Diffractometer::read_C
720 // description : Extract real attribute values for C acquisition result.
722 //-----------------------------------------------------------------------------
723 void Diffractometer::read_C(Tango::Attribute &attr)
725 DEBUG_STREAM << "Diffractometer::read_C(Tango::Attribute &attr) entering... "<< endl;
726 attr.set_value(attr_C_read);
729 //+----------------------------------------------------------------------------
731 // method : Diffractometer::read_Alpha
733 // description : Extract real attribute values for Alpha acquisition result.
735 //-----------------------------------------------------------------------------
736 void Diffractometer::read_Alpha(Tango::Attribute &attr)
738 DEBUG_STREAM << "Diffractometer::read_Alpha(Tango::Attribute &attr) entering... "<< endl;
739 attr.set_value(attr_Alpha_read);
742 //+----------------------------------------------------------------------------
744 // method : Diffractometer::read_Beta
746 // description : Extract real attribute values for Beta acquisition result.
748 //-----------------------------------------------------------------------------
749 void Diffractometer::read_Beta(Tango::Attribute &attr)
751 DEBUG_STREAM << "Diffractometer::read_Beta(Tango::Attribute &attr) entering... "<< endl;
752 attr.set_value(attr_Beta_read);
755 //+----------------------------------------------------------------------------
757 // method : Diffractometer::read_Gamma
759 // description : Extract real attribute values for Gamma acquisition result.
761 //-----------------------------------------------------------------------------
762 void Diffractometer::read_Gamma(Tango::Attribute &attr)
764 DEBUG_STREAM << "Diffractometer::read_Gamma(Tango::Attribute &attr) entering... "<< endl;
765 attr.set_value(attr_Gamma_read);
768 //+----------------------------------------------------------------------------
770 // method : Diffractometer::read_UB
772 // description : Extract real attribute values for UB acquisition result.
774 //-----------------------------------------------------------------------------
775 void Diffractometer::read_UB(Tango::Attribute &attr)
777 DEBUG_STREAM << "Diffractometer::read_UB(Tango::Attribute &attr) entering... "<< endl;
779 if(_hklAdapter){
780 Matrix<double> const & img = _hklAdapter->get_sample_ub();
781 attr.set_value(img.data, img.xdim, img.ydim);
785 //+----------------------------------------------------------------------------
787 // method : Diffractometer::read_Ux
789 // description : Extract real attribute values for Ux acquisition result.
791 //-----------------------------------------------------------------------------
792 void Diffractometer::read_Ux(Tango::Attribute &attr)
794 DEBUG_STREAM << "Diffractometer::read_Ux(Tango::Attribute &attr) entering... "<< endl;
796 if(_hklAdapter)
797 attr.set_value(&_hklAdapter->get_sample_Ux());
800 //+----------------------------------------------------------------------------
802 // method : Diffractometer::write_Ux
804 // description : Write Ux attribute values to hardware.
806 //-----------------------------------------------------------------------------
807 void Diffractometer::write_Ux(Tango::WAttribute &attr)
809 DEBUG_STREAM << "Diffractometer::write_Ux(Tango::WAttribute &attr) entering... "<< endl;
810 double Ux;
812 attr.get_write_value(Ux);
813 if (_hklAdapter){
814 _hklAdapter->set_sample_Ux(Ux);
815 attr_Ux_write = Ux;
819 //+----------------------------------------------------------------------------
821 // method : Diffractometer::read_Uy
823 // description : Extract real attribute values for Uy acquisition result.
825 //-----------------------------------------------------------------------------
826 void Diffractometer::read_Uy(Tango::Attribute &attr)
828 DEBUG_STREAM << "Diffractometer::read_Uy(Tango::Attribute &attr) entering... "<< endl;
829 if(_hklAdapter)
830 attr.set_value(&_hklAdapter->get_sample_Uy());
833 //+----------------------------------------------------------------------------
835 // method : Diffractometer::write_Uy
837 // description : Write Uy attribute values to hardware.
839 //-----------------------------------------------------------------------------
840 void Diffractometer::write_Uy(Tango::WAttribute &attr)
842 DEBUG_STREAM << "Diffractometer::write_Uy(Tango::WAttribute &attr) entering... "<< endl;
843 double Uy;
845 attr.get_write_value(Uy);
846 if (_hklAdapter){
847 _hklAdapter->set_sample_Uy(Uy);
848 attr_Uy_write = Uy;
852 //+----------------------------------------------------------------------------
854 // method : Diffractometer::read_Uz
856 // description : Extract real attribute values for Uz acquisition result.
858 //-----------------------------------------------------------------------------
859 void Diffractometer::read_Uz(Tango::Attribute &attr)
861 DEBUG_STREAM << "Diffractometer::read_Uz(Tango::Attribute &attr) entering... "<< endl;
862 if(_hklAdapter)
863 attr.set_value(&_hklAdapter->get_sample_Uz());
866 //+----------------------------------------------------------------------------
868 // method : Diffractometer::write_Uz
870 // description : Write Uz attribute values to hardware.
872 //-----------------------------------------------------------------------------
873 void Diffractometer::write_Uz(Tango::WAttribute &attr)
875 DEBUG_STREAM << "Diffractometer::write_Uz(Tango::WAttribute &attr) entering... "<< endl;
876 double Uz;
878 attr.get_write_value(Uz);
879 if (_hklAdapter){
880 _hklAdapter->set_sample_Uz(Uz);
881 attr_Uz_write = Uz;
886 //+----------------------------------------------------------------------------
888 // method : Diffractometer::read_Simulated
890 // description : Extract real attribute values for Simulated acquisition result.
892 //-----------------------------------------------------------------------------
893 void Diffractometer::read_Simulated(Tango::Attribute &attr)
895 DEBUG_STREAM << "Diffractometer::read_Simulated(Tango::Attribute &attr) entering... "<< endl;
897 if(_hklAdapter)
898 *attr_Simulated_read = _hklAdapter->simulated;
899 attr.set_value(attr_Simulated_read);
902 //+----------------------------------------------------------------------------
904 // method : Diffractometer::write_Simulated
906 // description : Write Simulated attribute values to hardware.
908 //-----------------------------------------------------------------------------
909 void Diffractometer::write_Simulated(Tango::WAttribute &attr)
911 DEBUG_STREAM << "Diffractometer::write_Simulated(Tango::WAttribute &attr) entering... "<< endl;
912 attr.get_write_value(attr_Simulated_write);
914 if (_hklAdapter)
915 _hklAdapter->set_simulated(attr_Simulated_write);
918 //+----------------------------------------------------------------------------
920 // method : Diffractometer::read_H
922 // description : Extract real attribute values for H acquisition result.
924 //-----------------------------------------------------------------------------
925 void Diffractometer::read_H(Tango::Attribute &attr)
927 DEBUG_STREAM << "Diffractometer::read_H(Tango::Attribute &attr) entering... "<< endl;
929 attr.set_value(attr_H_read);
932 //+----------------------------------------------------------------------------
934 // method : Diffractometer::write_H
936 // description : Write H attribute values to hardware.
938 //-----------------------------------------------------------------------------
939 void Diffractometer::write_H(Tango::WAttribute &attr)
941 DEBUG_STREAM << "Diffractometer::write_H(Tango::WAttribute &attr) entering... "<< endl;
943 double h;
944 attr.get_write_value(h);
946 // if not during a simultaneous write
947 if (!_write_attributes_hkl_together) {
948 this->compute_angles(h, attr_K_write, attr_L_write);
949 // If calculation OK then set write point
950 attr_H_write = h;
951 }else
952 attr_H_write = h;
955 //+----------------------------------------------------------------------------
957 // method : Diffractometer::read_K
959 // description : Extract real attribute values for K acquisition result.
961 //-----------------------------------------------------------------------------
962 void Diffractometer::read_K(Tango::Attribute &attr)
964 DEBUG_STREAM << "Diffractometer::read_K(Tango::Attribute &attr) entering... "<< endl;
966 attr.set_value(attr_K_read);
969 //+----------------------------------------------------------------------------
971 // method : Diffractometer::write_K
973 // description : Write K attribute values to hardware.
975 //-----------------------------------------------------------------------------
976 void Diffractometer::write_K(Tango::WAttribute &attr)
978 DEBUG_STREAM << "Diffractometer::write_K(Tango::WAttribute &attr) entering... "<< endl;
980 double k;
982 attr.get_write_value(k);
984 if (!_write_attributes_hkl_together) {
985 this->compute_angles(attr_H_write, k, attr_L_write);
986 //Now that attribute values are OK, set them
987 attr_K_write = k;
988 }else
989 attr_K_write = k;
992 //+----------------------------------------------------------------------------
994 // method : Diffractometer::read_L
996 // description : Extract real attribute values for L acquisition result.
998 //-----------------------------------------------------------------------------
999 void Diffractometer::read_L(Tango::Attribute &attr)
1001 DEBUG_STREAM << "Diffractometer::read_L(Tango::Attribute &attr) entering... "<< endl;
1003 attr.set_value(attr_L_read);
1006 //+----------------------------------------------------------------------------
1008 // method : Diffractometer::write_L
1010 // description : Write L attribute values to hardware.
1012 //-----------------------------------------------------------------------------
1013 void Diffractometer::write_L(Tango::WAttribute &attr)
1015 DEBUG_STREAM << "Diffractometer::write_L(Tango::WAttribute &attr) entering... "<< endl;
1017 double l;
1019 attr.get_write_value(l);
1021 if (!_write_attributes_hkl_together) {
1022 this->compute_angles(attr_H_write, attr_K_write, l);
1023 //Now that attribute values are OK, set them
1024 attr_L_write = l;
1025 }else
1026 attr_L_write = l;
1029 //+----------------------------------------------------------------------------
1031 // method : Diffractometer::read_Mode
1033 // description : Extract real attribute values for Mode acquisition result.
1035 //-----------------------------------------------------------------------------
1036 void Diffractometer::read_Mode(Tango::Attribute &attr)
1038 DEBUG_STREAM << "Diffractometer::read_Mode(Tango::Attribute &attr) entering... "<< endl;
1040 if(_hklAdapter){
1041 if(*attr_Mode_read) delete[] *attr_Mode_read;
1042 *attr_Mode_read = CORBA::string_dup(_hklAdapter->read_mode());
1044 attr.set_value(attr_Mode_read);
1047 //+----------------------------------------------------------------------------
1049 // method : Diffractometer::write_Mode
1051 // description : Write Mode attribute values to hardware.
1053 //-----------------------------------------------------------------------------
1054 void Diffractometer::write_Mode(Tango::WAttribute &attr)
1056 DEBUG_STREAM << "Diffractometer::write_Mode(Tango::WAttribute &attr) entering... "<< endl;
1058 attr.get_write_value(attr_Mode_write);
1059 if(_hklAdapter)
1060 _hklAdapter->write_mode(attr_Mode_write);
1063 //+----------------------------------------------------------------------------
1065 // method : Diffractometer::read_Crystal
1067 // description : Extract real attribute values for Crystal acquisition result.
1069 //-----------------------------------------------------------------------------
1070 void Diffractometer::read_Crystal(Tango::Attribute &attr)
1072 DEBUG_STREAM << "Diffractometer::read_Crystal(Tango::Attribute &attr) entering... "<< endl;
1074 if(*attr_Crystal_read) delete [] *attr_Crystal_read;
1076 if (_hklAdapter)
1077 *attr_Crystal_read = CORBA::string_dup(_hklAdapter->get_sample_name());
1078 else
1079 *attr_Crystal_read = CORBA::string_dup("");
1080 attr.set_value(attr_Crystal_read);
1083 //+----------------------------------------------------------------------------
1085 // method : Diffractometer::write_Crystal
1087 // description : Write Crystal attribute values to hardware.
1089 //-----------------------------------------------------------------------------
1090 void Diffractometer::write_Crystal(Tango::WAttribute &attr)
1092 DEBUG_STREAM << "Diffractometer::write_Crystal(Tango::WAttribute &attr) entering... "<< endl;
1094 attr.get_write_value(attr_Crystal_write);
1095 if(_hklAdapter)
1096 _hklAdapter->set_current_sample(attr_Crystal_write);
1099 //+----------------------------------------------------------------------------
1101 // method : Diffractometer::read_WaveLength
1103 // description : Extract real attribute values for WaveLength acquisition result.
1105 //-----------------------------------------------------------------------------
1106 void Diffractometer::read_WaveLength(Tango::Attribute &attr)
1108 DEBUG_STREAM << "Diffractometer::read_WaveLength(Tango::Attribute &attr) entering... "<< endl;
1110 if(_hklAdapter)
1111 attr.set_value(&_hklAdapter->get_lambda());
1114 //+----------------------------------------------------------------------------
1116 // method : Diffractometer::write_WaveLength
1118 // description : Write WaveLength attribute values to hardware.
1120 //-----------------------------------------------------------------------------
1121 void Diffractometer::write_WaveLength(Tango::WAttribute &attr)
1123 DEBUG_STREAM << "Diffractometer::write_WaveLength(Tango::WAttribute &attr) entering... "<< endl;
1125 attr.get_write_value(attr_WaveLength_write);
1127 if (_hklAdapter) {
1128 _hklAdapter->set_lambda(attr_WaveLength_write);
1129 if (_hklAdapter->simulated)
1130 *attr_WaveLength_read = attr_WaveLength_write;
1134 //+----------------------------------------------------------------------------
1136 // method : Diffractometer::read_ModeNames
1138 // description : Extract real attribute values for ModeNames acquisition result.
1140 //-----------------------------------------------------------------------------
1141 void Diffractometer::read_ModeNames(Tango::Attribute &attr)
1143 DEBUG_STREAM << "Diffractometer::read_ModeNames(Tango::Attribute &attr) entering... "<< endl;
1145 if(_hklAdapter){
1146 Matrix<char *> const & img = _hklAdapter->get_mode_names();
1147 attr.set_value(img.data, img.xdim);
1151 //+----------------------------------------------------------------------------
1153 // method : Diffractometer::read_CrystalNames
1155 // description : Extract real attribute values for CrystalNames acquisition result.
1157 //-----------------------------------------------------------------------------
1158 void Diffractometer::read_CrystalNames(Tango::Attribute &attr)
1160 DEBUG_STREAM << "Diffractometer::read_CrystalNames(Tango::Attribute &attr) entering... "<< endl;
1162 std::vector<std::string> names;
1164 if (_hklAdapter)
1165 names = _hklAdapter->get_samples_names();
1167 _crystal_names_dev_varstring_array << names;
1168 attr.set_value(_crystal_names_dev_varstring_array.get_buffer(),
1169 _crystal_names_dev_varstring_array.length());
1172 //+----------------------------------------------------------------------------
1174 // method : Diffractometer::read_CrystalReflections
1176 // description : Extract real attribute values for CrystalReflections acquisition result.
1178 //-----------------------------------------------------------------------------
1179 void Diffractometer::read_CrystalReflections(Tango::Attribute &attr)
1181 DEBUG_STREAM << "Diffractometer::read_CrystalReflections(Tango::Attribute &attr) entering... "<< endl;
1183 if(_hklAdapter){
1184 Matrix<double> const & img = _hklAdapter->get_sample_reflections();
1185 attr.set_value(img.data, img.xdim, img.ydim);
1189 //+------------------------------------------------------------------
1191 * method: Diffractometer::abort
1193 * description: method to execute "Abort"
1194 * Stops the movement of all axis driven by the Diffractometer
1198 //+------------------------------------------------------------------
1199 void Diffractometer::abort()
1201 DEBUG_STREAM << "Diffractometer::abort(): entering... !" << endl;
1203 // Add your own code to control device here
1206 _hklAdapter->stop_all_axis();
1208 catch (Tango::DevFailed& e )
1210 ERROR_STREAM << e ;
1214 //+------------------------------------------------------------------
1216 * method: Diffractometer::add_new_crystal
1218 * description: method to execute "AddNewCrystal"
1219 * Create a new crystal
1221 * @param argin Name of the new crystal
1224 //+------------------------------------------------------------------
1225 void Diffractometer::add_new_crystal(Tango::DevString argin)
1227 DEBUG_STREAM << "Diffractometer::add_new_crystal(): entering... !" << endl;
1229 // Add your own code to control device here
1231 /* POGO rename SampleNew */
1233 if (_hklAdapter){
1234 _hklAdapter->add_new_sample(argin);
1235 this->save();
1239 //+------------------------------------------------------------------
1241 * method: Diffractometer::add_reflection
1243 * description: method to execute "AddReflection"
1244 * This commands requires the definition of 1 reflection defined by (h,k,l ) coordinates.
1245 * This coodinates are associated with the current angles configuration.
1247 * TODO: d�taill� le commentaire
1248 * reflections i.e : h, k, l, relevance, enable/disable
1250 * @param argin reflections i.e : h, k, l, relevance, enable/disable
1253 //+------------------------------------------------------------------
1254 void Diffractometer::add_reflection(const Tango::DevVarDoubleArray *argin)
1256 DEBUG_STREAM << "Diffractometer::add_reflection(): entering... !" << endl;
1258 // Add your own code to control device here
1260 /* POGO rename SampleReflectionAdd */
1261 if (_hklAdapter){
1262 _hklAdapter->add_reflection();
1263 this->save();
1267 //+------------------------------------------------------------------
1269 * method: Diffractometer::affine_crystal
1271 * description: method to execute "AffineCrystal"
1272 * Compute affinement for the current crystal with available list of reflection.
1274 * @param argin name of the crystal to fit
1275 * @return the fitness of the crystal after the affinement.
1278 //+------------------------------------------------------------------
1279 Tango::DevDouble Diffractometer::affine_crystal(Tango::DevString argin)
1281 Tango::DevDouble argout ;
1282 DEBUG_STREAM << "Diffractometer::affine_crystal(): entering... !" << endl;
1284 // Add your own code to control device here
1286 /* POGO rename SampleAffinement */
1288 if(_hklAdapter){
1289 argout = _hklAdapter->affine_sample(argin);
1290 this->refresh_crystal_parameters();
1291 this->save();
1294 return argout;
1297 //+------------------------------------------------------------------
1299 * method: Diffractometer::configure_crystal
1301 * description: method to execute "ConfigureCrystal"
1302 * Defines crystal lattice parameters.
1303 * This information is mandatory for angles calculations.
1304 * Angles units are degrees
1306 * @param argin Crystal parameters : alpha,beta,gamma, A,B,C
1309 //+------------------------------------------------------------------
1310 void Diffractometer::configure_crystal(const Tango::DevVarDoubleArray *argin)
1312 DEBUG_STREAM << "Diffractometer::configure_crystal(): entering... !" << endl;
1314 // Add your own code to control device here
1316 /* POGO rename SampleConfiguration */
1318 if(_hklAdapter){
1319 _hklAdapter->set_lattice(argin);
1320 this->refresh_crystal_parameters();
1321 this->save();
1325 //+------------------------------------------------------------------
1327 * method: Diffractometer::copy_current_crystal_as
1329 * description: method to execute "CopyCurrentCrystalAs"
1330 * Copy the current crytal as another name
1332 * @param argin
1335 //+------------------------------------------------------------------
1336 void Diffractometer::copy_current_crystal_as(Tango::DevString argin)
1338 DEBUG_STREAM << "Diffractometer::copy_current_crystal_as(): entering... !" << endl;
1340 // Add your own code to control device here
1342 /* POGO rename SampleCopy */
1344 if(_hklAdapter){
1345 _hklAdapter->copy_sample_as(argin);
1346 this->refresh_crystal_parameters();
1347 this->save();
1351 //+------------------------------------------------------------------
1353 * method: Diffractometer::delete_current_crystal
1355 * description: method to execute "DeleteCurrentCrystal"
1356 * Delete the current from this device
1360 //+------------------------------------------------------------------
1361 void Diffractometer::delete_current_crystal()
1363 DEBUG_STREAM << "Diffractometer::delete_current_crystal(): entering... !" << endl;
1365 // Add your own code to control device here
1367 /* POGO rename SampleDelete */
1369 if(_hklAdapter){
1370 _hklAdapter->del_sample();
1371 this->refresh_crystal_parameters();
1372 this->save();
1376 //+------------------------------------------------------------------
1378 * method: Diffractometer::get_affinement_iteration
1380 * description: method to execute "GetAffinementIteration"
1381 * This commands redefine the maximum of iteration for an affinement.
1383 * Arg in :
1385 * Affinement Name
1387 * Arg out :
1389 * Iteration value of the last calculation
1391 * @param argin Affinement name
1392 * @return Iteration value of the last calculation
1395 //+------------------------------------------------------------------
1396 Tango::DevLong Diffractometer::get_affinement_iteration(Tango::DevString argin)
1398 Tango::DevLong argout ;
1399 DEBUG_STREAM << "Diffractometer::get_affinement_iteration(): entering... !" << endl;
1401 /* TO DELETE */
1403 return argout;
1406 //+------------------------------------------------------------------
1408 * method: Diffractometer::get_affinement_list
1410 * description: method to execute "GetAffinementList"
1411 * This commands returns the list of Affinement names.
1413 * @return List of Affinement names
1416 //+------------------------------------------------------------------
1417 Tango::DevVarStringArray *Diffractometer::get_affinement_list()
1419 // POGO has generated a method core with argout allocation.
1420 // If you would like to use a static reference without copying,
1421 // See "TANGO Device Server Programmer's Manual"
1422 // (chapter : Writing a TANGO DS / Exchanging data)
1423 //------------------------------------------------------------
1424 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();
1426 /* TO DELETE */
1428 return argout;
1431 //+------------------------------------------------------------------
1433 * method: Diffractometer::get_affinement_max_iteration
1435 * description: method to execute "GetAffinementMaxIteration"
1436 * This commands redefine the maximum of iteration for an affinement.
1438 * Arg in :
1440 * Affinement Name
1442 * Arg out :
1444 * Value of the maximum
1446 * @param argin Affinement name
1447 * @return Value of iteration max
1450 //+------------------------------------------------------------------
1451 Tango::DevLong Diffractometer::get_affinement_max_iteration(Tango::DevString argin)
1453 Tango::DevLong argout ;
1454 DEBUG_STREAM << "Diffractometer::get_affinement_max_iteration(): entering... !" << endl;
1456 // Add your own code to control device here
1458 /* TO DELETE */
1460 return argout;
1463 //+------------------------------------------------------------------
1465 * method: Diffractometer::get_crystal_names
1467 * description: method to execute "GetCrystalNames"
1468 * Return all crystals names registed into the device
1470 * @return all crystals names registed
1473 //+------------------------------------------------------------------
1474 Tango::DevVarStringArray *Diffractometer::get_crystal_names()
1476 // POGO has generated a method core with argout allocation.
1477 // If you would like to use a static reference without copying,
1478 // See "TANGO Device Server Programmer's Manual"
1479 // (chapter : Writing a TANGO DS / Exchanging data)
1480 //------------------------------------------------------------
1481 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();
1482 argout->length(1);
1483 (*argout)[0] = CORBA::string_dup("dummy");
1484 DEBUG_STREAM << "Diffractometer::get_crystal_names(): entering... !" << endl;
1486 /* POGO TO DELETE */
1487 if(_hklAdapter)
1488 *argout << _hklAdapter->get_samples_names();
1490 return argout;
1493 //+------------------------------------------------------------------
1495 * method: Diffractometer::get_mode_description
1497 * description: method to execute "GetModeDescription"
1499 * @param argin mode
1500 * @return description
1503 //+------------------------------------------------------------------
1504 Tango::DevString Diffractometer::get_mode_description(Tango::DevString argin)
1506 // POGO has generated a method core with argout allocation.
1507 // If you would like to use a static reference without copying,
1508 // See "TANGO Device Server Programmer's Manual"
1509 // (chapter : Writing a TANGO DS / Exchanging data)
1510 //------------------------------------------------------------
1511 Tango::DevString argout = NULL;
1512 DEBUG_STREAM << "Diffractometer::get_mode_description(): entering... !" << endl;
1514 // Add your own code to control device here
1516 /* POGO TO DELETE */
1517 argout = CORBA::string_dup("toto");
1519 return argout;
1522 //+------------------------------------------------------------------
1524 * method: Diffractometer::get_mode_parameters_names
1526 * description: method to execute "GetModeParametersNames"
1528 * @return Parameters names of the current mode
1531 //+------------------------------------------------------------------
1532 Tango::DevVarStringArray *Diffractometer::get_mode_parameters_names()
1534 // POGO has generated a method core with argout allocation.
1535 // If you would like to use a static reference without copying,
1536 // See "TANGO Device Server Programmer's Manual"
1537 // (chapter : Writing a TANGO DS / Exchanging data)
1538 //------------------------------------------------------------
1539 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();
1540 DEBUG_STREAM << "Diffractometer::get_mode_parameters_names(): entering... !" << endl;
1542 // Add your own code to control device here
1544 /* POGO TO DELETE */
1545 if(_hklAdapter){
1546 size_t i;
1547 Matrix<char *> & img = _hklAdapter->get_mode_parameters_names();
1548 argout->length(img.xdim);
1549 for(i=0; i<img.xdim; ++i)
1550 (*argout)[i] = CORBA::string_dup(img.data[i]);
1553 return argout;
1556 //+------------------------------------------------------------------
1558 * method: Diffractometer::get_mode_parameters_values
1560 * description: method to execute "GetModeParametersValues"
1561 * Double : values of parameters
1563 * @return String : Names of parameters ; Double : values of parameters
1566 //+------------------------------------------------------------------
1567 Tango::DevVarDoubleStringArray *Diffractometer::get_mode_parameters_values()
1569 // POGO has generated a method core with argout allocation.
1570 // If you would like to use a static reference without copying,
1571 // See "TANGO Device Server Programmer's Manual"
1572 // (chapter : Writing a TANGO DS / Exchanging data)
1573 //------------------------------------------------------------
1574 Tango::DevVarDoubleStringArray *argout = new Tango::DevVarDoubleStringArray();
1575 DEBUG_STREAM << "Diffractometer::get_mode_parameters_values(): entering... !" << endl;
1577 // Add your own code to control device here
1579 /* POGO TO DELETE */
1580 if(_hklAdapter)
1581 _hklAdapter->get_mode_parameters_values(argout);
1583 return argout;
1586 //+------------------------------------------------------------------
1588 * method: Diffractometer::get_mode_parameter_value
1590 * description: method to execute "GetModeParameterValue"
1592 * @param argin name of parameter
1593 * @return value of this parameter
1596 //+------------------------------------------------------------------
1597 Tango::DevDouble Diffractometer::get_mode_parameter_value(Tango::DevString argin)
1599 Tango::DevDouble argout ;
1600 DEBUG_STREAM << "Diffractometer::get_mode_parameter_value(): entering... !" << endl;
1602 // Add your own code to control device here
1604 /* POGO TO DELETE */
1606 return argout;
1609 //+------------------------------------------------------------------
1611 * method: Diffractometer::get_reflection
1613 * description: method to execute "GetReflection"
1615 * @param argin index of reflection
1616 * @return H, K, L, Relevance, Affinement Enabled
1619 //+------------------------------------------------------------------
1620 Tango::DevVarDoubleArray *Diffractometer::get_reflection(Tango::DevShort argin)
1622 // POGO has generated a method core with argout allocation.
1623 // If you would like to use a static reference without copying,
1624 // See "TANGO Device Server Programmer's Manual"
1625 // (chapter : Writing a TANGO DS / Exchanging data)
1626 //------------------------------------------------------------
1627 Tango::DevVarDoubleArray *argout = new Tango::DevVarDoubleArray();
1628 DEBUG_STREAM << "Diffractometer::get_reflection(): entering... !" << endl;
1630 // Add your own code to control device here
1632 /* POGO replace by a Reflections attribut read/write */
1633 if(_hklAdapter)
1634 _hklAdapter->get_sample_reflection(argin, argout);
1636 return argout;
1639 //+------------------------------------------------------------------
1641 * method: Diffractometer::get_reflection_size
1643 * description: method to execute "GetReflectionSize"
1644 * Return the number of reflection of the current crystal
1646 * @return Number of reflection in current crytal
1649 //+------------------------------------------------------------------
1650 Tango::DevUShort Diffractometer::get_reflection_size()
1652 Tango::DevUShort argout ;
1653 DEBUG_STREAM << "Diffractometer::get_reflection_size(): entering... !" << endl;
1655 // Add your own code to control device here
1657 /* POGO TO DELETE */
1659 return argout;
1662 //+------------------------------------------------------------------
1664 * method: Diffractometer::goto_reflection
1666 * description: method to execute "GotoReflection"
1667 * Go to axis values of the given reflection
1669 * @param argin reflection number
1672 //+------------------------------------------------------------------
1673 void Diffractometer::goto_reflection(Tango::DevShort argin)
1675 DEBUG_STREAM << "Diffractometer::goto_reflection(): entering... !" << endl;
1677 // Add your own code to control device here
1679 /* POGO replace by a SampleReflectionAxisGoTo */
1682 //+------------------------------------------------------------------
1684 * method: Diffractometer::load
1686 * description: method to execute "Load"
1687 * Load all crystals
1691 //+------------------------------------------------------------------
1692 void Diffractometer::load()
1694 DEBUG_STREAM << "Diffractometer::load(): entering... !" << endl;
1696 // Add your own code to control device here
1698 // POGO TO DELETE
1699 if(_hklAdapter)
1700 _hklAdapter->load();
1703 //+------------------------------------------------------------------
1705 * method: Diffractometer::remove_reflection
1707 * description: method to execute "RemoveReflection"
1708 * This commands removes reflection from the current cristal.
1710 * @param argin index of reflection to remove
1713 //+------------------------------------------------------------------
1714 void Diffractometer::remove_reflection(Tango::DevShort argin)
1716 DEBUG_STREAM << "Diffractometer::remove_reflection(): entering... !" << endl;
1718 // Add your own code to control device here
1720 /* POGO rename SampleReflectionDelete */
1721 if(_hklAdapter){
1722 _hklAdapter->del_reflection(argin);
1723 this->refresh_crystal_parameters();
1724 this->save();
1728 //+------------------------------------------------------------------
1730 * method: Diffractometer::save
1732 * description: method to execute "Save"
1733 * Save all crystals
1737 //+------------------------------------------------------------------
1738 void Diffractometer::save()
1740 DEBUG_STREAM << "Diffractometer::save(): entering... !" << endl;
1742 // Add your own code to control device here
1744 // POGO TO DELETE
1745 if(_hklAdapter)
1746 _hklAdapter->save();
1749 //+------------------------------------------------------------------
1751 * method: Diffractometer::set_affinement_max_iteration
1753 * description: method to execute "SetAffinementMaxIteration"
1754 * This commands redefine the maximum of iteration for an affinement.
1755 * index = index of reflection
1756 * h = h value
1757 * k = k value
1758 * l = l valuee
1759 * relevance = relevance value of this reflection
1760 * affinement enabled = if true this reflection is associated with Affinement calculation
1762 * @param argin Affinement name, Value of iteration max
1765 //+------------------------------------------------------------------
1766 void Diffractometer::set_affinement_max_iteration(const Tango::DevVarStringArray *argin)
1768 DEBUG_STREAM << "Diffractometer::set_affinement_max_iteration(): entering... !" << endl;
1770 // Add your own code to control device here
1772 /* POGO TO DELETE */
1775 //+------------------------------------------------------------------
1777 * method: Diffractometer::set_crystal_parameter_values
1779 * description: method to execute "SetCrystalParameterValues"
1780 * Double : min value, max value, affinement enable
1782 * @param argin String : Name of parameter ; Double : min value, max value, affinement enable
1785 //+------------------------------------------------------------------
1786 void Diffractometer::set_crystal_parameter_values(const Tango::DevVarDoubleStringArray *argin)
1788 DEBUG_STREAM << "Diffractometer::set_crystal_parameter_values(): entering... !" << endl;
1790 // Add your own code to control device here
1792 // check Parameters
1793 if(_hklAdapter)
1794 _hklAdapter->set_sample_parameter_values(argin);
1797 //+------------------------------------------------------------------
1799 * method: Diffractometer::set_hkl
1801 * description: method to execute "SetHKL"
1802 * This command will set the triplet (h,k,l
1804 * @param argin h,k,l values
1807 //+------------------------------------------------------------------
1808 void Diffractometer::set_hkl(const Tango::DevVarDoubleArray *argin)
1810 DEBUG_STREAM << "Diffractometer::set_hkl(): entering... !" << endl;
1812 // Add your own code to control device here
1814 if(argin->length() != 3)
1815 TANGO_EXCEPTION_THROW("DATA_OUT_OF_RANGE", "set_hkl did not receive the exact amount of parameters: h, k, l");
1817 // try to set up hkl.
1818 this->compute_angles((*argin)[0], (*argin)[1], (*argin)[2]);
1821 //+------------------------------------------------------------------
1823 * method: Diffractometer::set_mode_parameters_values
1825 * description: method to execute "SetModeParametersValues"
1826 * Double : value of parameter
1828 * @param argin String : name of parameter ; Double : value of parameter
1831 //+------------------------------------------------------------------
1832 void Diffractometer::set_mode_parameters_values(const Tango::DevVarDoubleStringArray *argin)
1834 DEBUG_STREAM << "Diffractometer::set_mode_parameters_values(): entering... !" << endl;
1836 // Add your own code to control device here
1838 // Check if argin is like (key,value)
1839 if(_hklAdapter)
1840 _hklAdapter->set_mode_parameters_values(argin);
1843 //+------------------------------------------------------------------
1845 * method: Diffractometer::set_reflection
1847 * description: method to execute "SetReflection"
1848 * This commands redefine the parameters of 1 reflection of the current cristal.
1849 * index = index of reflection
1850 * h = h value
1851 * k = k value
1852 * l = l valuee
1853 * relevance = relevance value of this reflection
1854 * affinement enabled = if true this reflection is associated with Affinement calculation
1856 * @param argin reflections i.e : index, h, k, l, relevance, affinement enabled
1859 //+------------------------------------------------------------------
1860 void Diffractometer::set_reflection(const Tango::DevVarDoubleArray *argin)
1862 DEBUG_STREAM << "Diffractometer::set_reflection(): entering... !" << endl;
1864 // Add your own code to control device here
1866 /* POGO TO DELETE */
1867 if(_hklAdapter)
1868 _hklAdapter->set_sample_reflection(argin);
1871 //+------------------------------------------------------------------
1873 * method: Diffractometer::copy_reflection_to
1875 * description: method to execute "CopyReflectionTo"
1876 * Copy one reflection from the current crystal to another crystal
1878 * @param argin Double: Reflection number of the current crystal String : Name of the crystal where copy this reflection
1881 //+------------------------------------------------------------------
1882 void Diffractometer::copy_reflection_to(const Tango::DevVarDoubleStringArray *argin)
1884 DEBUG_STREAM << "Diffractometer::copy_reflection_to(): entering... !" << endl;
1886 // Add your own code to control device here
1888 /* POGO TO DELETE */
1891 //+------------------------------------------------------------------
1893 * method: Diffractometer::dev_state
1895 * description: method to execute "State"
1896 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
1898 * @return State Code
1901 //+------------------------------------------------------------------
1902 Tango::DevState Diffractometer::dev_state()
1904 Tango::DevState argout = DeviceImpl::dev_state();
1905 DEBUG_STREAM << "Diffractometer::dev_state(): entering... !" << endl;
1907 // Add your own code to control device here
1909 std::string status;
1911 if (_hklAdapter)
1912 _hklAdapter->getDiffractometerStateAndStatus(argout, status);
1913 else {
1914 argout = Tango::FAULT;
1915 status = "Diffractometer core not yet initialized !!!!";
1917 this->set_status(status);
1918 this->set_state(argout);
1920 return argout;
1923 //+------------------------------------------------------------------
1925 * method: Diffractometer::get_crystal_parameter_values
1927 * description: method to execute "GetCrystalParameterValues"
1928 * Return all values of a parameter for the current crystal
1930 * @param argin Name of parameter (see getParametersNames for the complete list of parameters)
1931 * @return In the order : minimum value, maximum value, affinement enable
1934 //+------------------------------------------------------------------
1935 Tango::DevVarDoubleStringArray *Diffractometer::get_crystal_parameter_values(Tango::DevString argin)
1937 // POGO has generated a method core with argout allocation.
1938 // If you would like to use a static reference without copying,
1939 // See "TANGO Device Server Programmer's Manual"
1940 // (chapter : Writing a TANGO DS / Exchanging data)
1941 //------------------------------------------------------------
1942 Tango::DevVarDoubleStringArray *argout = new Tango::DevVarDoubleStringArray();
1943 argout->dvalue.length(3);
1944 argout->dvalue[0] = 0.0;
1945 argout->dvalue[1] = 0.0;
1946 argout->dvalue[2] = 0.0;
1947 argout->svalue.length(1);
1948 argout->svalue[0] = CORBA::string_dup(argin);
1949 DEBUG_STREAM << "Diffractometer::get_crystal_parameter_values(): entering... !" << endl;
1951 // Add your own code to control device here
1952 if(_hklAdapter)
1953 _hklAdapter->get_sample_parameter_values(argout);
1955 return argout;
1958 //+------------------------------------------------------------------
1960 * method: Diffractometer::compute_u
1962 * description: method to execute "ComputeU"
1963 * Compute Matrix U from two reflections
1965 * @param argin a two elements array with the index of reflection to use
1968 //+------------------------------------------------------------------
1969 void Diffractometer::compute_u(const Tango::DevVarLongArray *argin)
1971 DEBUG_STREAM << "Diffractometer::compute_u(): entering... !" << endl;
1973 // Add your own code to control device here
1974 if(_hklAdapter){
1975 _hklAdapter->compute_u(argin);
1976 this->save();
1980 //+------------------------------------------------------------------
1982 * method: Diffractometer::get_axes_names
1984 * description: method to execute "GetAxesNames"
1985 * this method return the names of the dynamic attributes created from the hkl axes names
1986 * kappa -> AxisKappa etc...
1988 * @return namers of the axes
1991 //+------------------------------------------------------------------
1992 Tango::DevVarStringArray *Diffractometer::get_axes_names()
1994 // POGO has generated a method core with argout allocation.
1995 // If you would like to use a static reference without copying,
1996 // See "TANGO Device Server Programmer's Manual"
1997 // (chapter : Writing a TANGO DS / Exchanging data)
1998 //------------------------------------------------------------
1999 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();
2000 DEBUG_STREAM << "Diffractometer::get_axes_names(): entering... !" << endl;
2002 if(_hklAdapter){
2003 size_t i;
2005 Matrix<char *> const & img = _hklAdapter->get_dynamic_attribute_axes_names();
2006 argout->length(img.xdim);
2007 for(i=0; i<img.xdim; ++i)
2008 (*argout)[i] = CORBA::string_dup(img.data[i]);
2010 return argout;
2013 //+------------------------------------------------------------------
2015 * method: Diffractometer::computed_angles_clear
2017 * description: method to execute "ComputedAnglesClear"
2018 * Clears the attribute ComputedAngles.
2019 * Useful to get a fresh view of calculations already made
2023 //+------------------------------------------------------------------
2024 void Diffractometer::computed_angles_clear()
2026 DEBUG_STREAM << "Diffractometer::computed_angles_clear(): entering... !" << endl;
2028 // Add your own code to control device here
2029 _computedAngles_size = 0;
2030 if(attr_ComputedAngles_read) {
2031 delete [] attr_ComputedAngles_read;
2032 attr_ComputedAngles_read = NULL;
2037 //+------------------------------------------------------------------
2039 * method: Diffractometer::computed_angles_hkllist
2041 * description: method to execute "ComputedAnglesHKLList"
2042 * this commande works only in simulated mode.
2043 * It computhe [-hmax: hmax] etc.. angles computations.
2045 * @param argin hmax, kmax, lmax
2048 //+------------------------------------------------------------------
2049 void Diffractometer::computed_angles_hkllist(const Tango::DevVarDoubleArray *argin)
2051 DEBUG_STREAM << "Diffractometer::computed_angles_hkllist(): entering... !" << endl;
2053 // Add your own code to control device here
2055 if((argin->length() != 3) && (argin->length() != 6))
2056 TANGO_EXCEPTION_THROW("DATA_OUT_OF_RANGE", "computed_angles_hkllist did not receive the exact amount of parameters: hmax, kmax, lmax");
2058 // Parameters are OK
2059 if (!_hklAdapter->simulated)
2060 return;
2062 double h, k, l;
2063 double hmax = fabs((*argin)[0]);
2064 double kmax = fabs((*argin)[1]);
2065 double lmax = fabs((*argin)[2]);
2066 double dh, dk, dl;
2067 if (argin->length() == 6) {
2068 dh = fabs((*argin)[3]);
2069 dk = fabs((*argin)[4]);
2070 dl = fabs((*argin)[5]);
2071 } else
2072 dh = dk = dl = 1.;
2073 h = -hmax;
2074 while(h <= hmax) {
2075 k = -kmax;
2076 while(k <= kmax) {
2077 l = -lmax;
2078 while(l <= lmax) {
2079 try {
2080 this->compute_angles(h, k, l);
2082 catch(...)
2084 l += dl;
2086 k += dk;
2088 h += dh;
2093 //+------------------------------------------------------------------
2095 * method: Diffractometer::goto_computed_angles
2097 * description: method to execute "GotoComputedAngles"
2099 * @param argin the idx of the computed angles
2102 //+------------------------------------------------------------------
2103 void Diffractometer::goto_computed_angles(Tango::DevShort argin)
2105 DEBUG_STREAM << "Diffractometer::goto_computed_angles(): entering... !" << endl;
2107 // Add your own code to control device here
2117 } // namespace