* PseudoAxis is no more a friend of PseudoAxisAdapter.
[diffractometer.git] / src / DiffractometerDevice.cpp
blob601f6ad5ddc8906b56d7a1c636166295c272c6d3
1 static const char *RcsId = "$Header: /cvsroot/tango-ds/Instrumentation/Diffractometer/src/DiffractometerDevice.cpp,v 1.5 2008/11/28 15:46:32 piccaf Exp $";
2 //+=============================================================================
3 //
4 // file : DiffractometerDevice.cpp
5 //
6 // description : C++ source for the DiffractometerDevice 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 // DiffractometerDevice are implemented in this file.
12 // project : TANGO Device Server
14 // $Author: piccaf $
16 // $Revision: 1.5 $
18 // $Log: DiffractometerDevice.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 <DiffractometerDevice.h>
96 #include <DiffractometerDeviceClass.h>
98 #include <time.h>
99 #include <sstream>
100 #include <algorithm>
101 #include <cctype>
102 #include <string>
104 #include "macros.h"
105 #include "DynamicAttrAxis.h"
106 #include "TangoHKLAdapterFactory.h"
108 namespace DiffractometerDevice_ns
111 //+----------------------------------------------------------------------------
113 // method : DiffractometerDevice::DiffractometerDevice(string &s)
115 // description : constructor for simulated DiffractometerDevice
117 // in : - cl : Pointer to the DeviceClass object
118 // - s : Device name
120 //-----------------------------------------------------------------------------
121 DiffractometerDevice::DiffractometerDevice(Tango::DeviceClass *cl,string &s)
122 :Tango::Device_3Impl(cl,s.c_str())
124 init_device();
127 DiffractometerDevice::DiffractometerDevice(Tango::DeviceClass *cl,const char *s)
128 :Tango::Device_3Impl(cl,s)
130 init_device();
133 DiffractometerDevice::DiffractometerDevice(Tango::DeviceClass *cl,const char *s,const char *d)
134 :Tango::Device_3Impl(cl,s,d)
136 init_device();
138 //+----------------------------------------------------------------------------
140 // method : DiffractometerDevice::delete_device()
142 // description : will be called at device destruction or at init command.
144 //-----------------------------------------------------------------------------
145 void DiffractometerDevice::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();
204 * Do not remove the diffractometer in the delete method
205 * of the Derived classes to avoid a segmentation fault
206 * during the save method call. Indeed the Derived class delete
207 * method is called before this delete method.
209 TangoHKLAdapterFactory::instance()->detach_device(this);
212 //+----------------------------------------------------------------------------
214 // method : DiffractometerDevice::init_device()
216 // description : will be called at device initialization.
218 //-----------------------------------------------------------------------------
219 void DiffractometerDevice::init_device()
221 INFO_STREAM << "DiffractometerDevice::DiffractometerDevice() create device " << device_name << endl;
223 // Initialise variables to default values
224 //--------------------------------------------
225 get_device_property();
227 CREATE_SCALAR_ATTRIBUTE(attr_H_read, 0.0);
228 CREATE_SCALAR_ATTRIBUTE(attr_K_read, 0.0);
229 CREATE_SCALAR_ATTRIBUTE(attr_L_read, 0.0);
230 CREATE_SCALAR_ATTRIBUTE(attr_AnglesIdx_read, (short)-1);
231 CREATE_SCALAR_ATTRIBUTE(attr_WaveLength_read, 0.0);
232 CREATE_SCALAR_ATTRIBUTE(attr_Simulated_read, true);
233 CREATE_SCALAR_ATTRIBUTE(attr_A_read, 0.0);
234 CREATE_SCALAR_ATTRIBUTE(attr_B_read, 0.0);
235 CREATE_SCALAR_ATTRIBUTE(attr_C_read, 0.0);
236 CREATE_SCALAR_ATTRIBUTE(attr_Alpha_read, 0.0);
237 CREATE_SCALAR_ATTRIBUTE(attr_Beta_read, 0.0);
238 CREATE_SCALAR_ATTRIBUTE(attr_Gamma_read, 0.0);
239 CREATE_SCALAR_ATTRIBUTE(attr_Ux_read, 0.0);
240 CREATE_SCALAR_ATTRIBUTE(attr_Uy_read, 0.0);
241 CREATE_SCALAR_ATTRIBUTE(attr_Uz_read, 0.0);
242 CREATE_SCALAR_ATTRIBUTE(attr_AStar_read);
243 CREATE_SCALAR_ATTRIBUTE(attr_BStar_read);
244 CREATE_SCALAR_ATTRIBUTE(attr_CStar_read);
245 CREATE_SCALAR_ATTRIBUTE(attr_AlphaStar_read);
246 CREATE_SCALAR_ATTRIBUTE(attr_BetaStar_read);
247 CREATE_SCALAR_ATTRIBUTE(attr_GammaStar_read);
249 CREATE_DEVSTRING_ATTRIBUTE(attr_Crystal_read, 1, "");
250 CREATE_DEVSTRING_ATTRIBUTE(attr_Mode_read, 1, "");
252 attr_CrystalReflections_read = NULL;
253 attr_UB_read = NULL;
254 attr_ReflectionsAngles_read = NULL;
255 attr_ComputedAngles_read = NULL;
256 attr_Reflections_read = NULL;
257 attr_AxesNames_read = NULL;
259 // get the write part of the hkl attributes
260 _att_h_w = &dev_attr->get_w_attr_by_name("h");
261 _att_k_w = &dev_attr->get_w_attr_by_name("k");
262 _att_l_w = &dev_attr->get_w_attr_by_name("l");
264 // Device is in FAULT state because it was not yet configured.
265 this->set_state(Tango::FAULT);
266 this->set_status("Configure Diffractometer: crystal, wavelength,etc ..");
268 _computedAngles_size = 0;
270 // Write values
271 attr_H_write = 0.0;
272 attr_K_write = 0.0;
273 attr_L_write = 0.0;
276 _type = this->get_type_from_property(diffractometerType);
279 * this method must be call after get_device_property() as
280 * TangoHKLAdapter create the axisbuffer from the
281 * realAxisProxies.
283 _hklAdapter = TangoHKLAdapterFactory::instance()->attach_device(this, _type);
284 if (!_hklAdapter) {
285 this->set_state(Tango::FAULT);
286 this->set_status("Fatal can not initialize the hkl library");
287 TANGO_EXCEPTION_THROW("Internal Fatal Error", "Device can't get an instance of TangoHKLAdapter");
288 } else {
289 // Restore the Diffractometer state from the last run.
290 this->load();
292 _hklAdapter->connect_all_proxies();
295 _write_attributes_hkl_together = false;
299 //+----------------------------------------------------------------------------
301 // method : DiffractometerDevice::get_device_property()
303 // description : Read the device properties from database.
305 //-----------------------------------------------------------------------------
306 void DiffractometerDevice::get_device_property()
308 // Initialize your default values here (if not done with POGO).
309 //------------------------------------------------------------------
311 // Read device properties from database.(Automatic code generation)
312 //------------------------------------------------------------------
313 Tango::DbData dev_prop;
314 dev_prop.push_back(Tango::DbDatum("TauConstant"));
315 dev_prop.push_back(Tango::DbDatum("RealAxisProxies"));
316 dev_prop.push_back(Tango::DbDatum("LambdaAttributeProxy"));
317 dev_prop.push_back(Tango::DbDatum("DiffractometerType"));
319 // Call database and extract values
320 //--------------------------------------------
321 if (Tango::Util::instance()->_UseDb==true)
322 get_db_device()->get_property(dev_prop);
323 Tango::DbDatum def_prop, cl_prop;
324 DiffractometerDeviceClass *ds_class =
325 (static_cast<DiffractometerDeviceClass *>(get_device_class()));
326 int i = -1;
328 // Try to initialize TauConstant from class property
329 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
330 if (cl_prop.is_empty()==false) cl_prop >> tauConstant;
331 else {
332 // Try to initialize TauConstant from default device value
333 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
334 if (def_prop.is_empty()==false) def_prop >> tauConstant;
336 // And try to extract TauConstant value from database
337 if (dev_prop[i].is_empty()==false) dev_prop[i] >> tauConstant;
339 // Try to initialize RealAxisProxies from class property
340 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
341 if (cl_prop.is_empty()==false) cl_prop >> realAxisProxies;
342 else {
343 // Try to initialize RealAxisProxies from default device value
344 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
345 if (def_prop.is_empty()==false) def_prop >> realAxisProxies;
347 // And try to extract RealAxisProxies value from database
348 if (dev_prop[i].is_empty()==false) dev_prop[i] >> realAxisProxies;
350 // Try to initialize LambdaAttributeProxy from class property
351 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
352 if (cl_prop.is_empty()==false) cl_prop >> lambdaAttributeProxy;
353 else {
354 // Try to initialize LambdaAttributeProxy from default device value
355 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
356 if (def_prop.is_empty()==false) def_prop >> lambdaAttributeProxy;
358 // And try to extract LambdaAttributeProxy value from database
359 if (dev_prop[i].is_empty()==false) dev_prop[i] >> lambdaAttributeProxy;
361 // Try to initialize DiffractometerType from class property
362 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
363 if (cl_prop.is_empty()==false) cl_prop >> diffractometerType;
364 else {
365 // Try to initialize DiffractometerType from default device value
366 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
367 if (def_prop.is_empty()==false) def_prop >> diffractometerType;
369 // And try to extract DiffractometerType value from database
370 if (dev_prop[i].is_empty()==false) dev_prop[i] >> diffractometerType;
374 // End of Automatic code generation
375 //------------------------------------------------------------------
378 //+----------------------------------------------------------------------------
380 // method : DiffractometerDevice::always_executed_hook()
382 // description : method always executed before any command is executed
384 //-----------------------------------------------------------------------------
385 void DiffractometerDevice::always_executed_hook()
387 if (_hklAdapter)
388 _hklAdapter->connect_all_proxies();
390 //+----------------------------------------------------------------------------
392 // method : DiffractometerDevice::read_attr_hardware
394 // description : Hardware acquisition for attributes.
396 //-----------------------------------------------------------------------------
397 void DiffractometerDevice::read_attr_hardware(vector<long> &attr_list)
399 DEBUG_STREAM << "DiffractometerDevice::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
400 // Add your own code here
401 if (!_hklAdapter)
402 return;
404 _hklAdapter->update();
406 // update the hkl attributes
409 HKLBuffer const & buffer = _hklAdapter->get_HKLBuffer();
410 *attr_H_read = buffer.h_r;
411 attr_H_write = buffer.h_w;
412 *attr_K_read = buffer.k_r;
413 attr_K_write = buffer.k_w;
414 *attr_L_read = buffer.l_r;
415 attr_L_write = buffer.l_w;
417 // set the write part of the hkl attributes
418 _att_h_w->set_write_value(buffer.h_w);
419 _att_k_w->set_write_value(buffer.k_w);
420 _att_l_w->set_write_value(buffer.l_w);
422 catch (Tango::DevFailed & e)
424 ERROR_STREAM << e <<endl;
427 _hklAdapter->get_sample_lattices(attr_A_read, attr_B_read, attr_C_read,
428 attr_Alpha_read, attr_Beta_read, attr_Gamma_read,
429 attr_AStar_read, attr_BStar_read, attr_CStar_read,
430 attr_AlphaStar_read, attr_BetaStar_read, attr_GammaStar_read);
432 //+----------------------------------------------------------------------------
434 // method : DiffractometerDevice::read_AnglesIdx
436 // description : Extract real attribute values for AnglesIdx acquisition result.
438 //-----------------------------------------------------------------------------
439 void DiffractometerDevice::read_AnglesIdx(Tango::Attribute &attr)
441 DEBUG_STREAM << "DiffractometerDevice::read_AnglesIdx(Tango::Attribute &attr) entering... "<< endl;
443 if(_hklAdapter){
444 *attr_AnglesIdx_read = _hklAdapter->get_angles_idx();
445 attr.set_value(attr_AnglesIdx_read);
449 //+----------------------------------------------------------------------------
451 // method : DiffractometerDevice::write_AnglesIdx
453 // description : Write AnglesIdx attribute values to hardware.
455 //-----------------------------------------------------------------------------
456 void DiffractometerDevice::write_AnglesIdx(Tango::WAttribute &attr)
458 DEBUG_STREAM << "DiffractometerDevice::write_AnglesIdx(Tango::WAttribute &attr) entering... "<< endl;
460 attr.get_write_value(attr_AnglesIdx_write);
461 if(_hklAdapter)
462 _hklAdapter->set_angles_idx(attr_AnglesIdx_write);
465 //+----------------------------------------------------------------------------
467 // method : DiffractometerDevice::read_AxesNames
469 // description : Extract real attribute values for AxesNames acquisition result.
471 //-----------------------------------------------------------------------------
472 void DiffractometerDevice::read_AxesNames(Tango::Attribute &attr)
474 attr.set_value(_dynamic_axes_names_char, _dynamic_axes_names.size());
477 //+----------------------------------------------------------------------------
479 // method : DiffractometerDevice::read_Angles
481 // description : Extract real attribute values for Angles acquisition result.
483 //-----------------------------------------------------------------------------
484 void DiffractometerDevice::read_Angles(Tango::Attribute &attr)
486 DEBUG_STREAM << "DiffractometerDevice::read_Angles(Tango::Attribute &attr) entering... "<< endl;
487 if(_hklAdapter){
488 Matrix<double> const & img = _hklAdapter->get_angles();
489 attr.set_value(img.data, img.xdim, img.ydim);
493 //+----------------------------------------------------------------------------
495 // method : DiffractometerDevice::read_AnglesDegenerated
497 // description : Extract real attribute values for AnglesDegenerated acquisition result.
499 //-----------------------------------------------------------------------------
500 void DiffractometerDevice::read_AnglesDegenerated(Tango::Attribute &attr)
502 DEBUG_STREAM << "DiffractometerDevice::read_AnglesDegenerated(Tango::Attribute &attr) entering... "<< endl;
505 //+----------------------------------------------------------------------------
507 // method : DiffractometerDevice::read_AnglesRangeCheck
509 // description : Extract real attribute values for AnglesRangeCheck acquisition result.
511 //-----------------------------------------------------------------------------
512 void DiffractometerDevice::read_AnglesRangeCheck(Tango::Attribute &attr)
514 DEBUG_STREAM << "DiffractometerDevice::read_AnglesRangeCheck(Tango::Attribute &attr) entering... "<< endl;
517 //+----------------------------------------------------------------------------
519 // method : DiffractometerDevice::read_Reflections
521 // description : Extract real attribute values for Reflections acquisition result.
523 //-----------------------------------------------------------------------------
524 void DiffractometerDevice::read_Reflections(Tango::Attribute &attr)
526 DEBUG_STREAM << "DiffractometerDevice::read_Reflections(Tango::Attribute &attr) entering... "<< endl;
527 if(_hklAdapter){
528 Matrix<double> const & img = _hklAdapter->get_sample_reflections();
529 attr.set_value(img.data, img.xdim, img.ydim);
533 //+----------------------------------------------------------------------------
535 // method : DiffractometerDevice::write_Reflections
537 // description : Write Reflections attribute values to hardware.
539 //-----------------------------------------------------------------------------
540 void DiffractometerDevice::write_Reflections(Tango::WAttribute &attr)
542 DEBUG_STREAM << "DiffractometerDevice::write_Reflections(Tango::WAttribute &attr) entering... "<< endl;
544 attr.get_write_value(attr_Reflections_write);
546 Matrix<double> img;
547 img.attach_to_buffer(&attr_Reflections_write,
548 attr.get_w_dim_x(), attr.get_w_dim_y());
550 if(_hklAdapter)
551 _hklAdapter->set_sample_reflections(img);
554 //+----------------------------------------------------------------------------
556 // method : DiffractometerDevice::read_ComputedAngles
558 // description : Extract real attribute values for ComputedAngles acquisition result.
560 //-----------------------------------------------------------------------------
561 void DiffractometerDevice::read_ComputedAngles(Tango::Attribute &attr)
563 DEBUG_STREAM << "DiffractometerDevice::read_ComputedAngles(Tango::Attribute &attr) entering... "<< endl;
565 if(_hklAdapter){
566 Matrix<double> const & img = _hklAdapter->get_angles();
567 attr.set_value(img.data, img.xdim, img.ydim);
571 //+----------------------------------------------------------------------------
573 // method : DiffractometerDevice::read_ReflectionsAngles
575 // description : Extract real attribute values for ReflectionsAngles acquisition result.
577 //-----------------------------------------------------------------------------
578 void DiffractometerDevice::read_ReflectionsAngles(Tango::Attribute &attr)
580 DEBUG_STREAM << "DiffractometerDevice::read_ReflectionsAngles(Tango::Attribute &attr) entering... "<< endl;
582 if (_hklAdapter){
583 Matrix<double> const & img = _hklAdapter->get_reflections_angles();
584 attr.set_value(img.data, img.xdim, img.ydim);
588 //+----------------------------------------------------------------------------
590 // method : DiffractometerDevice::read_AStar
592 // description : Extract real attribute values for AStar acquisition result.
594 //-----------------------------------------------------------------------------
595 void DiffractometerDevice::read_AStar(Tango::Attribute &attr)
597 DEBUG_STREAM << "DiffractometerDevice::read_AStar(Tango::Attribute &attr) entering... "<< endl;
598 attr.set_value(attr_AStar_read);
601 //+----------------------------------------------------------------------------
603 // method : DiffractometerDevice::read_BStar
605 // description : Extract real attribute values for BStar acquisition result.
607 //-----------------------------------------------------------------------------
608 void DiffractometerDevice::read_BStar(Tango::Attribute &attr)
610 DEBUG_STREAM << "DiffractometerDevice::read_BStar(Tango::Attribute &attr) entering... "<< endl;
611 attr.set_value(attr_BStar_read);
614 //+----------------------------------------------------------------------------
616 // method : DiffractometerDevice::read_CStar
618 // description : Extract real attribute values for CStar acquisition result.
620 //-----------------------------------------------------------------------------
621 void DiffractometerDevice::read_CStar(Tango::Attribute &attr)
623 DEBUG_STREAM << "DiffractometerDevice::read_CStar(Tango::Attribute &attr) entering... "<< endl;
624 attr.set_value(attr_CStar_read);
627 //+----------------------------------------------------------------------------
629 // method : DiffractometerDevice::read_AlphaStar
631 // description : Extract real attribute values for AlphaStar acquisition result.
633 //-----------------------------------------------------------------------------
634 void DiffractometerDevice::read_AlphaStar(Tango::Attribute &attr)
636 DEBUG_STREAM << "DiffractometerDevice::read_AlphaStar(Tango::Attribute &attr) entering... "<< endl;
637 attr.set_value(attr_AlphaStar_read);
640 //+----------------------------------------------------------------------------
642 // method : DiffractometerDevice::read_BetaStar
644 // description : Extract real attribute values for BetaStar acquisition result.
646 //-----------------------------------------------------------------------------
647 void DiffractometerDevice::read_BetaStar(Tango::Attribute &attr)
649 DEBUG_STREAM << "DiffractometerDevice::read_BetaStar(Tango::Attribute &attr) entering... "<< endl;
650 attr.set_value(attr_BetaStar_read);
653 //+----------------------------------------------------------------------------
655 // method : DiffractometerDevice::read_GammaStar
657 // description : Extract real attribute values for GammaStar acquisition result.
659 //-----------------------------------------------------------------------------
660 void DiffractometerDevice::read_GammaStar(Tango::Attribute &attr)
662 DEBUG_STREAM << "DiffractometerDevice::read_GammaStar(Tango::Attribute &attr) entering... "<< endl;
663 attr.set_value(attr_GammaStar_read);
666 //+----------------------------------------------------------------------------
668 // method : DiffractometerDevice::read_A
670 // description : Extract real attribute values for A acquisition result.
672 //-----------------------------------------------------------------------------
673 void DiffractometerDevice::read_A(Tango::Attribute &attr)
675 DEBUG_STREAM << "DiffractometerDevice::read_A(Tango::Attribute &attr) entering... "<< endl;
676 attr.set_value(attr_A_read);
679 //+----------------------------------------------------------------------------
681 // method : DiffractometerDevice::read_B
683 // description : Extract real attribute values for B acquisition result.
685 //-----------------------------------------------------------------------------
686 void DiffractometerDevice::read_B(Tango::Attribute &attr)
688 DEBUG_STREAM << "DiffractometerDevice::read_B(Tango::Attribute &attr) entering... "<< endl;
689 attr.set_value(attr_B_read);
692 //+----------------------------------------------------------------------------
694 // method : DiffractometerDevice::read_C
696 // description : Extract real attribute values for C acquisition result.
698 //-----------------------------------------------------------------------------
699 void DiffractometerDevice::read_C(Tango::Attribute &attr)
701 DEBUG_STREAM << "DiffractometerDevice::read_C(Tango::Attribute &attr) entering... "<< endl;
702 attr.set_value(attr_C_read);
705 //+----------------------------------------------------------------------------
707 // method : DiffractometerDevice::read_Alpha
709 // description : Extract real attribute values for Alpha acquisition result.
711 //-----------------------------------------------------------------------------
712 void DiffractometerDevice::read_Alpha(Tango::Attribute &attr)
714 DEBUG_STREAM << "DiffractometerDevice::read_Alpha(Tango::Attribute &attr) entering... "<< endl;
715 attr.set_value(attr_Alpha_read);
718 //+----------------------------------------------------------------------------
720 // method : DiffractometerDevice::read_Beta
722 // description : Extract real attribute values for Beta acquisition result.
724 //-----------------------------------------------------------------------------
725 void DiffractometerDevice::read_Beta(Tango::Attribute &attr)
727 DEBUG_STREAM << "DiffractometerDevice::read_Beta(Tango::Attribute &attr) entering... "<< endl;
728 attr.set_value(attr_Beta_read);
731 //+----------------------------------------------------------------------------
733 // method : DiffractometerDevice::read_Gamma
735 // description : Extract real attribute values for Gamma acquisition result.
737 //-----------------------------------------------------------------------------
738 void DiffractometerDevice::read_Gamma(Tango::Attribute &attr)
740 DEBUG_STREAM << "DiffractometerDevice::read_Gamma(Tango::Attribute &attr) entering... "<< endl;
741 attr.set_value(attr_Gamma_read);
744 //+----------------------------------------------------------------------------
746 // method : DiffractometerDevice::read_UB
748 // description : Extract real attribute values for UB acquisition result.
750 //-----------------------------------------------------------------------------
751 void DiffractometerDevice::read_UB(Tango::Attribute &attr)
753 DEBUG_STREAM << "DiffractometerDevice::read_UB(Tango::Attribute &attr) entering... "<< endl;
755 if(_hklAdapter){
756 Matrix<double> const & img = _hklAdapter->get_sample_ub();
757 attr.set_value(img.data, img.xdim, img.ydim);
761 //+----------------------------------------------------------------------------
763 // method : DiffractometerDevice::read_Ux
765 // description : Extract real attribute values for Ux acquisition result.
767 //-----------------------------------------------------------------------------
768 void DiffractometerDevice::read_Ux(Tango::Attribute &attr)
770 DEBUG_STREAM << "DiffractometerDevice::read_Ux(Tango::Attribute &attr) entering... "<< endl;
772 if(_hklAdapter)
773 attr.set_value(&_hklAdapter->get_sample_Ux());
776 //+----------------------------------------------------------------------------
778 // method : DiffractometerDevice::write_Ux
780 // description : Write Ux attribute values to hardware.
782 //-----------------------------------------------------------------------------
783 void DiffractometerDevice::write_Ux(Tango::WAttribute &attr)
785 DEBUG_STREAM << "DiffractometerDevice::write_Ux(Tango::WAttribute &attr) entering... "<< endl;
786 double Ux;
788 attr.get_write_value(Ux);
789 if (_hklAdapter){
790 _hklAdapter->set_sample_Ux(Ux);
791 attr_Ux_write = Ux;
795 //+----------------------------------------------------------------------------
797 // method : DiffractometerDevice::read_Uy
799 // description : Extract real attribute values for Uy acquisition result.
801 //-----------------------------------------------------------------------------
802 void DiffractometerDevice::read_Uy(Tango::Attribute &attr)
804 DEBUG_STREAM << "DiffractometerDevice::read_Uy(Tango::Attribute &attr) entering... "<< endl;
805 if(_hklAdapter)
806 attr.set_value(&_hklAdapter->get_sample_Uy());
809 //+----------------------------------------------------------------------------
811 // method : DiffractometerDevice::write_Uy
813 // description : Write Uy attribute values to hardware.
815 //-----------------------------------------------------------------------------
816 void DiffractometerDevice::write_Uy(Tango::WAttribute &attr)
818 DEBUG_STREAM << "DiffractometerDevice::write_Uy(Tango::WAttribute &attr) entering... "<< endl;
819 double Uy;
821 attr.get_write_value(Uy);
822 if (_hklAdapter){
823 _hklAdapter->set_sample_Uy(Uy);
824 attr_Uy_write = Uy;
828 //+----------------------------------------------------------------------------
830 // method : DiffractometerDevice::read_Uz
832 // description : Extract real attribute values for Uz acquisition result.
834 //-----------------------------------------------------------------------------
835 void DiffractometerDevice::read_Uz(Tango::Attribute &attr)
837 DEBUG_STREAM << "DiffractometerDevice::read_Uz(Tango::Attribute &attr) entering... "<< endl;
838 if(_hklAdapter)
839 attr.set_value(&_hklAdapter->get_sample_Uz());
842 //+----------------------------------------------------------------------------
844 // method : DiffractometerDevice::write_Uz
846 // description : Write Uz attribute values to hardware.
848 //-----------------------------------------------------------------------------
849 void DiffractometerDevice::write_Uz(Tango::WAttribute &attr)
851 DEBUG_STREAM << "DiffractometerDevice::write_Uz(Tango::WAttribute &attr) entering... "<< endl;
852 double Uz;
854 attr.get_write_value(Uz);
855 if (_hklAdapter){
856 _hklAdapter->set_sample_Uz(Uz);
857 attr_Uz_write = Uz;
862 //+----------------------------------------------------------------------------
864 // method : DiffractometerDevice::read_Simulated
866 // description : Extract real attribute values for Simulated acquisition result.
868 //-----------------------------------------------------------------------------
869 void DiffractometerDevice::read_Simulated(Tango::Attribute &attr)
871 DEBUG_STREAM << "DiffractometerDevice::read_Simulated(Tango::Attribute &attr) entering... "<< endl;
873 if(_hklAdapter)
874 *attr_Simulated_read = _hklAdapter->simulated;
875 attr.set_value(attr_Simulated_read);
878 //+----------------------------------------------------------------------------
880 // method : DiffractometerDevice::write_Simulated
882 // description : Write Simulated attribute values to hardware.
884 //-----------------------------------------------------------------------------
885 void DiffractometerDevice::write_Simulated(Tango::WAttribute &attr)
887 DEBUG_STREAM << "DiffractometerDevice::write_Simulated(Tango::WAttribute &attr) entering... "<< endl;
888 attr.get_write_value(attr_Simulated_write);
890 if (_hklAdapter)
891 _hklAdapter->set_simulated(attr_Simulated_write);
894 //+----------------------------------------------------------------------------
896 // method : DiffractometerDevice::read_H
898 // description : Extract real attribute values for H acquisition result.
900 //-----------------------------------------------------------------------------
901 void DiffractometerDevice::read_H(Tango::Attribute &attr)
903 DEBUG_STREAM << "DiffractometerDevice::read_H(Tango::Attribute &attr) entering... "<< endl;
905 attr.set_value(attr_H_read);
908 //+----------------------------------------------------------------------------
910 // method : DiffractometerDevice::write_H
912 // description : Write H attribute values to hardware.
914 //-----------------------------------------------------------------------------
915 void DiffractometerDevice::write_H(Tango::WAttribute &attr)
917 DEBUG_STREAM << "DiffractometerDevice::write_H(Tango::WAttribute &attr) entering... "<< endl;
919 double h;
920 attr.get_write_value(h);
922 // if not during a simultaneous write
923 if (!_write_attributes_hkl_together) {
924 this->compute_angles(h, attr_K_write, attr_L_write);
925 // If calculation OK then set write point
926 attr_H_write = h;
927 }else
928 attr_H_write = h;
931 //+----------------------------------------------------------------------------
933 // method : DiffractometerDevice::read_K
935 // description : Extract real attribute values for K acquisition result.
937 //-----------------------------------------------------------------------------
938 void DiffractometerDevice::read_K(Tango::Attribute &attr)
940 DEBUG_STREAM << "DiffractometerDevice::read_K(Tango::Attribute &attr) entering... "<< endl;
942 attr.set_value(attr_K_read);
945 //+----------------------------------------------------------------------------
947 // method : DiffractometerDevice::write_K
949 // description : Write K attribute values to hardware.
951 //-----------------------------------------------------------------------------
952 void DiffractometerDevice::write_K(Tango::WAttribute &attr)
954 DEBUG_STREAM << "DiffractometerDevice::write_K(Tango::WAttribute &attr) entering... "<< endl;
956 double k;
958 attr.get_write_value(k);
960 if (!_write_attributes_hkl_together) {
961 this->compute_angles(attr_H_write, k, attr_L_write);
962 //Now that attribute values are OK, set them
963 attr_K_write = k;
964 }else
965 attr_K_write = k;
968 //+----------------------------------------------------------------------------
970 // method : DiffractometerDevice::read_L
972 // description : Extract real attribute values for L acquisition result.
974 //-----------------------------------------------------------------------------
975 void DiffractometerDevice::read_L(Tango::Attribute &attr)
977 DEBUG_STREAM << "DiffractometerDevice::read_L(Tango::Attribute &attr) entering... "<< endl;
979 attr.set_value(attr_L_read);
982 //+----------------------------------------------------------------------------
984 // method : DiffractometerDevice::write_L
986 // description : Write L attribute values to hardware.
988 //-----------------------------------------------------------------------------
989 void DiffractometerDevice::write_L(Tango::WAttribute &attr)
991 DEBUG_STREAM << "DiffractometerDevice::write_L(Tango::WAttribute &attr) entering... "<< endl;
993 double l;
995 attr.get_write_value(l);
997 if (!_write_attributes_hkl_together) {
998 this->compute_angles(attr_H_write, attr_K_write, l);
999 //Now that attribute values are OK, set them
1000 attr_L_write = l;
1001 }else
1002 attr_L_write = l;
1005 //+----------------------------------------------------------------------------
1007 // method : DiffractometerDevice::read_Mode
1009 // description : Extract real attribute values for Mode acquisition result.
1011 //-----------------------------------------------------------------------------
1012 void DiffractometerDevice::read_Mode(Tango::Attribute &attr)
1014 DEBUG_STREAM << "DiffractometerDevice::read_Mode(Tango::Attribute &attr) entering... "<< endl;
1016 if(_hklAdapter){
1017 if(*attr_Mode_read) delete[] *attr_Mode_read;
1018 *attr_Mode_read = CORBA::string_dup(_hklAdapter->read_mode());
1020 attr.set_value(attr_Mode_read);
1023 //+----------------------------------------------------------------------------
1025 // method : DiffractometerDevice::write_Mode
1027 // description : Write Mode attribute values to hardware.
1029 //-----------------------------------------------------------------------------
1030 void DiffractometerDevice::write_Mode(Tango::WAttribute &attr)
1032 DEBUG_STREAM << "DiffractometerDevice::write_Mode(Tango::WAttribute &attr) entering... "<< endl;
1034 attr.get_write_value(attr_Mode_write);
1035 if(_hklAdapter)
1036 _hklAdapter->write_mode(attr_Mode_write);
1039 //+----------------------------------------------------------------------------
1041 // method : DiffractometerDevice::read_Crystal
1043 // description : Extract real attribute values for Crystal acquisition result.
1045 //-----------------------------------------------------------------------------
1046 void DiffractometerDevice::read_Crystal(Tango::Attribute &attr)
1048 DEBUG_STREAM << "DiffractometerDevice::read_Crystal(Tango::Attribute &attr) entering... "<< endl;
1050 if(*attr_Crystal_read) delete [] *attr_Crystal_read;
1052 if (_hklAdapter)
1053 *attr_Crystal_read = CORBA::string_dup(_hklAdapter->get_sample_name());
1054 else
1055 *attr_Crystal_read = CORBA::string_dup("");
1056 attr.set_value(attr_Crystal_read);
1059 //+----------------------------------------------------------------------------
1061 // method : DiffractometerDevice::write_Crystal
1063 // description : Write Crystal attribute values to hardware.
1065 //-----------------------------------------------------------------------------
1066 void DiffractometerDevice::write_Crystal(Tango::WAttribute &attr)
1068 DEBUG_STREAM << "DiffractometerDevice::write_Crystal(Tango::WAttribute &attr) entering... "<< endl;
1070 attr.get_write_value(attr_Crystal_write);
1071 if(_hklAdapter)
1072 _hklAdapter->set_current_sample(attr_Crystal_write);
1075 //+----------------------------------------------------------------------------
1077 // method : DiffractometerDevice::read_WaveLength
1079 // description : Extract real attribute values for WaveLength acquisition result.
1081 //-----------------------------------------------------------------------------
1082 void DiffractometerDevice::read_WaveLength(Tango::Attribute &attr)
1084 DEBUG_STREAM << "DiffractometerDevice::read_WaveLength(Tango::Attribute &attr) entering... "<< endl;
1086 if(_hklAdapter)
1087 attr.set_value(&_hklAdapter->get_lambda());
1090 //+----------------------------------------------------------------------------
1092 // method : DiffractometerDevice::write_WaveLength
1094 // description : Write WaveLength attribute values to hardware.
1096 //-----------------------------------------------------------------------------
1097 void DiffractometerDevice::write_WaveLength(Tango::WAttribute &attr)
1099 DEBUG_STREAM << "DiffractometerDevice::write_WaveLength(Tango::WAttribute &attr) entering... "<< endl;
1101 attr.get_write_value(attr_WaveLength_write);
1103 if (_hklAdapter) {
1104 _hklAdapter->set_lambda(attr_WaveLength_write);
1105 if (_hklAdapter->simulated)
1106 *attr_WaveLength_read = attr_WaveLength_write;
1110 //+----------------------------------------------------------------------------
1112 // method : DiffractometerDevice::read_ModeNames
1114 // description : Extract real attribute values for ModeNames acquisition result.
1116 //-----------------------------------------------------------------------------
1117 void DiffractometerDevice::read_ModeNames(Tango::Attribute &attr)
1119 DEBUG_STREAM << "DiffractometerDevice::read_ModeNames(Tango::Attribute &attr) entering... "<< endl;
1121 if(_hklAdapter){
1122 Matrix<char *> const & img = _hklAdapter->get_mode_names();
1123 attr.set_value(img.data, img.xdim);
1127 //+----------------------------------------------------------------------------
1129 // method : DiffractometerDevice::read_CrystalNames
1131 // description : Extract real attribute values for CrystalNames acquisition result.
1133 //-----------------------------------------------------------------------------
1134 void DiffractometerDevice::read_CrystalNames(Tango::Attribute &attr)
1136 DEBUG_STREAM << "DiffractometerDevice::read_CrystalNames(Tango::Attribute &attr) entering... "<< endl;
1138 std::vector<std::string> names;
1140 if (_hklAdapter)
1141 names = _hklAdapter->get_samples_names();
1143 _crystal_names_dev_varstring_array << names;
1144 attr.set_value(_crystal_names_dev_varstring_array.get_buffer(),
1145 _crystal_names_dev_varstring_array.length());
1148 //+----------------------------------------------------------------------------
1150 // method : DiffractometerDevice::read_CrystalReflections
1152 // description : Extract real attribute values for CrystalReflections acquisition result.
1154 //-----------------------------------------------------------------------------
1155 void DiffractometerDevice::read_CrystalReflections(Tango::Attribute &attr)
1157 DEBUG_STREAM << "DiffractometerDevice::read_CrystalReflections(Tango::Attribute &attr) entering... "<< endl;
1159 if(_hklAdapter){
1160 Matrix<double> const & img = _hklAdapter->get_sample_reflections();
1161 attr.set_value(img.data, img.xdim, img.ydim);
1165 //+------------------------------------------------------------------
1167 * method: DiffractometerDevice::abort
1169 * description: method to execute "Abort"
1170 * Stops the movement of all axis driven by the Diffractometer
1174 //+------------------------------------------------------------------
1175 void DiffractometerDevice::abort()
1177 DEBUG_STREAM << "DiffractometerDevice::abort(): entering... !" << endl;
1179 // Add your own code to control device here
1182 _hklAdapter->stop_all_axis();
1184 catch (Tango::DevFailed& e )
1186 ERROR_STREAM << e ;
1190 //+------------------------------------------------------------------
1192 * method: DiffractometerDevice::add_new_crystal
1194 * description: method to execute "AddNewCrystal"
1195 * Create a new crystal
1197 * @param argin Name of the new crystal
1200 //+------------------------------------------------------------------
1201 void DiffractometerDevice::add_new_crystal(Tango::DevString argin)
1203 DEBUG_STREAM << "DiffractometerDevice::add_new_crystal(): entering... !" << endl;
1205 // Add your own code to control device here
1207 /* POGO rename SampleNew */
1209 if (_hklAdapter){
1210 _hklAdapter->add_new_sample(argin);
1211 this->save();
1215 //+------------------------------------------------------------------
1217 * method: DiffractometerDevice::add_reflection
1219 * description: method to execute "AddReflection"
1220 * This commands requires the definition of 1 reflection defined by (h,k,l ) coordinates.
1221 * This coodinates are associated with the current angles configuration.
1223 * TODO: d�taill� le commentaire
1224 * reflections i.e : h, k, l, relevance, enable/disable
1226 * @param argin reflections i.e : h, k, l, relevance, enable/disable
1229 //+------------------------------------------------------------------
1230 void DiffractometerDevice::add_reflection(const Tango::DevVarDoubleArray *argin)
1232 DEBUG_STREAM << "DiffractometerDevice::add_reflection(): entering... !" << endl;
1234 // Add your own code to control device here
1236 /* POGO rename SampleReflectionAdd */
1237 if (_hklAdapter){
1238 _hklAdapter->add_reflection();
1239 this->save();
1243 //+------------------------------------------------------------------
1245 * method: DiffractometerDevice::affine_crystal
1247 * description: method to execute "AffineCrystal"
1248 * Compute affinement for the current crystal with available list of reflection.
1250 * @param argin name of the crystal to fit
1251 * @return the fitness of the crystal after the affinement.
1254 //+------------------------------------------------------------------
1255 Tango::DevDouble DiffractometerDevice::affine_crystal(Tango::DevString argin)
1257 Tango::DevDouble argout ;
1258 DEBUG_STREAM << "DiffractometerDevice::affine_crystal(): entering... !" << endl;
1260 // Add your own code to control device here
1262 /* POGO rename SampleAffinement */
1264 if(_hklAdapter){
1265 argout = _hklAdapter->affine_sample(argin);
1266 this->refresh_crystal_parameters();
1267 this->save();
1270 return argout;
1273 //+------------------------------------------------------------------
1275 * method: DiffractometerDevice::configure_crystal
1277 * description: method to execute "ConfigureCrystal"
1278 * Defines crystal lattice parameters.
1279 * This information is mandatory for angles calculations.
1280 * Angles units are degrees
1282 * @param argin Crystal parameters : alpha,beta,gamma, A,B,C
1285 //+------------------------------------------------------------------
1286 void DiffractometerDevice::configure_crystal(const Tango::DevVarDoubleArray *argin)
1288 DEBUG_STREAM << "DiffractometerDevice::configure_crystal(): entering... !" << endl;
1290 // Add your own code to control device here
1292 /* POGO rename SampleConfiguration */
1294 if(_hklAdapter){
1295 _hklAdapter->set_lattice(argin);
1296 this->refresh_crystal_parameters();
1297 this->save();
1301 //+------------------------------------------------------------------
1303 * method: DiffractometerDevice::copy_current_crystal_as
1305 * description: method to execute "CopyCurrentCrystalAs"
1306 * Copy the current crytal as another name
1308 * @param argin
1311 //+------------------------------------------------------------------
1312 void DiffractometerDevice::copy_current_crystal_as(Tango::DevString argin)
1314 DEBUG_STREAM << "DiffractometerDevice::copy_current_crystal_as(): entering... !" << endl;
1316 // Add your own code to control device here
1318 /* POGO rename SampleCopy */
1320 if(_hklAdapter){
1321 _hklAdapter->copy_sample_as(argin);
1322 this->refresh_crystal_parameters();
1323 this->save();
1327 //+------------------------------------------------------------------
1329 * method: DiffractometerDevice::delete_current_crystal
1331 * description: method to execute "DeleteCurrentCrystal"
1332 * Delete the current from this device
1336 //+------------------------------------------------------------------
1337 void DiffractometerDevice::delete_current_crystal()
1339 DEBUG_STREAM << "DiffractometerDevice::delete_current_crystal(): entering... !" << endl;
1341 // Add your own code to control device here
1343 /* POGO rename SampleDelete */
1345 if(_hklAdapter){
1346 _hklAdapter->del_sample();
1347 this->refresh_crystal_parameters();
1348 this->save();
1352 //+------------------------------------------------------------------
1354 * method: DiffractometerDevice::get_affinement_iteration
1356 * description: method to execute "GetAffinementIteration"
1357 * This commands redefine the maximum of iteration for an affinement.
1359 * Arg in :
1361 * Affinement Name
1363 * Arg out :
1365 * Iteration value of the last calculation
1367 * @param argin Affinement name
1368 * @return Iteration value of the last calculation
1371 //+------------------------------------------------------------------
1372 Tango::DevLong DiffractometerDevice::get_affinement_iteration(Tango::DevString argin)
1374 Tango::DevLong argout ;
1375 DEBUG_STREAM << "DiffractometerDevice::get_affinement_iteration(): entering... !" << endl;
1377 /* TO DELETE */
1379 return argout;
1382 //+------------------------------------------------------------------
1384 * method: DiffractometerDevice::get_affinement_list
1386 * description: method to execute "GetAffinementList"
1387 * This commands returns the list of Affinement names.
1389 * @return List of Affinement names
1392 //+------------------------------------------------------------------
1393 Tango::DevVarStringArray *DiffractometerDevice::get_affinement_list()
1395 // POGO has generated a method core with argout allocation.
1396 // If you would like to use a static reference without copying,
1397 // See "TANGO Device Server Programmer's Manual"
1398 // (chapter : Writing a TANGO DS / Exchanging data)
1399 //------------------------------------------------------------
1400 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();
1402 /* TO DELETE */
1404 return argout;
1407 //+------------------------------------------------------------------
1409 * method: DiffractometerDevice::get_affinement_max_iteration
1411 * description: method to execute "GetAffinementMaxIteration"
1412 * This commands redefine the maximum of iteration for an affinement.
1414 * Arg in :
1416 * Affinement Name
1418 * Arg out :
1420 * Value of the maximum
1422 * @param argin Affinement name
1423 * @return Value of iteration max
1426 //+------------------------------------------------------------------
1427 Tango::DevLong DiffractometerDevice::get_affinement_max_iteration(Tango::DevString argin)
1429 Tango::DevLong argout ;
1430 DEBUG_STREAM << "DiffractometerDevice::get_affinement_max_iteration(): entering... !" << endl;
1432 // Add your own code to control device here
1434 /* TO DELETE */
1436 return argout;
1439 //+------------------------------------------------------------------
1441 * method: DiffractometerDevice::get_crystal_names
1443 * description: method to execute "GetCrystalNames"
1444 * Return all crystals names registed into the device
1446 * @return all crystals names registed
1449 //+------------------------------------------------------------------
1450 Tango::DevVarStringArray *DiffractometerDevice::get_crystal_names()
1452 // POGO has generated a method core with argout allocation.
1453 // If you would like to use a static reference without copying,
1454 // See "TANGO Device Server Programmer's Manual"
1455 // (chapter : Writing a TANGO DS / Exchanging data)
1456 //------------------------------------------------------------
1457 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();
1458 argout->length(1);
1459 (*argout)[0] = CORBA::string_dup("dummy");
1460 DEBUG_STREAM << "DiffractometerDevice::get_crystal_names(): entering... !" << endl;
1462 /* POGO TO DELETE */
1463 if(_hklAdapter)
1464 *argout << _hklAdapter->get_samples_names();
1466 return argout;
1469 //+------------------------------------------------------------------
1471 * method: DiffractometerDevice::get_mode_description
1473 * description: method to execute "GetModeDescription"
1475 * @param argin mode
1476 * @return description
1479 //+------------------------------------------------------------------
1480 Tango::DevString DiffractometerDevice::get_mode_description(Tango::DevString argin)
1482 // POGO has generated a method core with argout allocation.
1483 // If you would like to use a static reference without copying,
1484 // See "TANGO Device Server Programmer's Manual"
1485 // (chapter : Writing a TANGO DS / Exchanging data)
1486 //------------------------------------------------------------
1487 Tango::DevString argout = NULL;
1488 DEBUG_STREAM << "DiffractometerDevice::get_mode_description(): entering... !" << endl;
1490 // Add your own code to control device here
1492 /* POGO TO DELETE */
1493 argout = CORBA::string_dup("toto");
1495 return argout;
1498 //+------------------------------------------------------------------
1500 * method: DiffractometerDevice::get_mode_parameters_names
1502 * description: method to execute "GetModeParametersNames"
1504 * @return Parameters names of the current mode
1507 //+------------------------------------------------------------------
1508 Tango::DevVarStringArray *DiffractometerDevice::get_mode_parameters_names()
1510 // POGO has generated a method core with argout allocation.
1511 // If you would like to use a static reference without copying,
1512 // See "TANGO Device Server Programmer's Manual"
1513 // (chapter : Writing a TANGO DS / Exchanging data)
1514 //------------------------------------------------------------
1515 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();
1516 DEBUG_STREAM << "DiffractometerDevice::get_mode_parameters_names(): entering... !" << endl;
1518 // Add your own code to control device here
1520 /* POGO TO DELETE */
1521 if(_hklAdapter){
1522 size_t i;
1523 Matrix<char *> & img = _hklAdapter->get_mode_parameters_names();
1524 argout->length(img.xdim);
1525 for(i=0; i<img.xdim; ++i)
1526 (*argout)[i] = CORBA::string_dup(img.data[i]);
1529 return argout;
1532 //+------------------------------------------------------------------
1534 * method: DiffractometerDevice::get_mode_parameters_values
1536 * description: method to execute "GetModeParametersValues"
1537 * Double : values of parameters
1539 * @return String : Names of parameters ; Double : values of parameters
1542 //+------------------------------------------------------------------
1543 Tango::DevVarDoubleStringArray *DiffractometerDevice::get_mode_parameters_values()
1545 // POGO has generated a method core with argout allocation.
1546 // If you would like to use a static reference without copying,
1547 // See "TANGO Device Server Programmer's Manual"
1548 // (chapter : Writing a TANGO DS / Exchanging data)
1549 //------------------------------------------------------------
1550 Tango::DevVarDoubleStringArray *argout = new Tango::DevVarDoubleStringArray();
1551 DEBUG_STREAM << "DiffractometerDevice::get_mode_parameters_values(): entering... !" << endl;
1553 // Add your own code to control device here
1555 /* POGO TO DELETE */
1556 if(_hklAdapter)
1557 _hklAdapter->get_mode_parameters_values(argout);
1559 return argout;
1562 //+------------------------------------------------------------------
1564 * method: DiffractometerDevice::get_mode_parameter_value
1566 * description: method to execute "GetModeParameterValue"
1568 * @param argin name of parameter
1569 * @return value of this parameter
1572 //+------------------------------------------------------------------
1573 Tango::DevDouble DiffractometerDevice::get_mode_parameter_value(Tango::DevString argin)
1575 Tango::DevDouble argout ;
1576 DEBUG_STREAM << "DiffractometerDevice::get_mode_parameter_value(): entering... !" << endl;
1578 // Add your own code to control device here
1580 /* POGO TO DELETE */
1582 return argout;
1585 //+------------------------------------------------------------------
1587 * method: DiffractometerDevice::get_reflection
1589 * description: method to execute "GetReflection"
1591 * @param argin index of reflection
1592 * @return H, K, L, Relevance, Affinement Enabled
1595 //+------------------------------------------------------------------
1596 Tango::DevVarDoubleArray *DiffractometerDevice::get_reflection(Tango::DevShort argin)
1598 // POGO has generated a method core with argout allocation.
1599 // If you would like to use a static reference without copying,
1600 // See "TANGO Device Server Programmer's Manual"
1601 // (chapter : Writing a TANGO DS / Exchanging data)
1602 //------------------------------------------------------------
1603 Tango::DevVarDoubleArray *argout = new Tango::DevVarDoubleArray();
1604 DEBUG_STREAM << "DiffractometerDevice::get_reflection(): entering... !" << endl;
1606 // Add your own code to control device here
1608 /* POGO replace by a Reflections attribut read/write */
1609 if(_hklAdapter)
1610 _hklAdapter->get_sample_reflection(argin, argout);
1612 return argout;
1615 //+------------------------------------------------------------------
1617 * method: DiffractometerDevice::get_reflection_size
1619 * description: method to execute "GetReflectionSize"
1620 * Return the number of reflection of the current crystal
1622 * @return Number of reflection in current crytal
1625 //+------------------------------------------------------------------
1626 Tango::DevUShort DiffractometerDevice::get_reflection_size()
1628 Tango::DevUShort argout ;
1629 DEBUG_STREAM << "DiffractometerDevice::get_reflection_size(): entering... !" << endl;
1631 // Add your own code to control device here
1633 /* POGO TO DELETE */
1635 return argout;
1638 //+------------------------------------------------------------------
1640 * method: DiffractometerDevice::goto_reflection
1642 * description: method to execute "GotoReflection"
1643 * Go to axis values of the given reflection
1645 * @param argin reflection number
1648 //+------------------------------------------------------------------
1649 void DiffractometerDevice::goto_reflection(Tango::DevShort argin)
1651 DEBUG_STREAM << "DiffractometerDevice::goto_reflection(): entering... !" << endl;
1653 // Add your own code to control device here
1655 /* POGO replace by a SampleReflectionAxisGoTo */
1658 //+------------------------------------------------------------------
1660 * method: DiffractometerDevice::load
1662 * description: method to execute "Load"
1663 * Load all crystals
1667 //+------------------------------------------------------------------
1668 void DiffractometerDevice::load()
1670 DEBUG_STREAM << "DiffractometerDevice::load(): entering... !" << endl;
1672 // Add your own code to control device here
1674 /* TODO MOVE to the DiffractometerDeviceExtra */
1675 /* POGO remove the command */
1678 // Get the Crystal Attributes properties.
1679 Tango::DbData properties;
1680 properties.push_back(Tango::DbDatum("CurrentCrystal"));
1681 this->get_db_device()->get_attribute_property(properties);
1683 // Get the number of properties
1684 unsigned long nb_crystal = 0;
1685 properties[0] >> nb_crystal;
1687 if (nb_crystal > 0) {
1688 _diffractometer->samples().clear();
1689 unsigned long i, j;
1691 for(i=1; i<=nb_crystal; i++) {
1692 // The name of the property name is the name of a crystal.
1693 const std::string & name = properties[i].name;
1694 hkl::Sample * sample;
1695 sample = _diffractometer->samples().add(name, hkl::SAMPLE_MONOCRYSTAL);
1696 if (sample)
1697 _diffractometer->samples().set_current(name);
1699 // Extract the lines store in the property
1700 std::vector<std::string> lines;
1701 properties[i] >> lines;
1703 for(j=0; j<lines.size(); j++) {
1704 char *line = strdup(lines[j].c_str());
1705 char *last;
1706 char *key = strtok_r(line, "=", &last);
1708 if(!strcmp(key,"wavelength")) {
1709 double lambda = atof(strtok_r(NULL, ";", &last));
1710 if(lambda <= 0.0)
1711 lambda = 1.54;
1712 _diffractometer->geometry()->get_source().setWaveLength(lambda);
1713 } else if (!strcmp(key,"lattice")) {
1714 double a = atof(strtok_r(NULL, ";", &last));
1715 double b = atof(strtok_r(NULL, ";", &last));
1716 double c = atof(strtok_r(NULL, ";", &last));
1717 double alpha = atof(strtok_r(NULL, ";", &last)) * HKL_DEGTORAD;
1718 double beta = atof(strtok_r(NULL, ";", &last)) * HKL_DEGTORAD;
1719 double gamma = atof(strtok_r(NULL, ";", &last)) * HKL_DEGTORAD;
1721 hkl::Lattice & lattice = sample->lattice();
1722 lattice.a().set_current(a);
1723 lattice.b().set_current(b);
1724 lattice.c().set_current(c);
1725 lattice.alpha().set_current(alpha);
1726 lattice.beta().set_current(beta);
1727 lattice.gamma().set_current(gamma);
1728 } else if (!strcmp(key,"reflection")) {
1729 unsigned int idx = 0;
1730 hkl::AxeList const & axes = _diffractometer->geometry()->get_axes();
1732 double h = atof(strtok_r(NULL, ";", &last));
1733 double k = atof(strtok_r(NULL, ";", &last));
1734 double l = atof(strtok_r(NULL, ";", &last));
1735 // int relevance = values.nextIntToken();
1736 // no more need of this relevance but extract never the less
1737 strtok_r(NULL, ";", &last);
1738 bool flag = atoi(strtok_r(NULL, ";", &last)) > 0;
1739 while(key = strtok_r(NULL, ";", &last))
1740 axes[idx++]->set_current(atof(key) * HKL_DEGTORAD);
1742 // Create reflection
1743 hkl::Reflection & reflection = sample->reflections().add(hkl::svector(h, k, l));
1744 reflection.flag() = flag;
1746 free(line);
1747 // End of key research
1748 }// End for each parameters
1749 }// End for each property
1751 this->refresh_crystal_parameters();
1756 //+------------------------------------------------------------------
1758 * method: DiffractometerDevice::remove_reflection
1760 * description: method to execute "RemoveReflection"
1761 * This commands removes reflection from the current cristal.
1763 * @param argin index of reflection to remove
1766 //+------------------------------------------------------------------
1767 void DiffractometerDevice::remove_reflection(Tango::DevShort argin)
1769 DEBUG_STREAM << "DiffractometerDevice::remove_reflection(): entering... !" << endl;
1771 // Add your own code to control device here
1773 /* POGO rename SampleReflectionDelete */
1774 if(_hklAdapter){
1775 _hklAdapter->del_reflection(argin);
1776 this->refresh_crystal_parameters();
1777 this->save();
1781 //+------------------------------------------------------------------
1783 * method: DiffractometerDevice::save
1785 * description: method to execute "Save"
1786 * Save all crystals
1790 //+------------------------------------------------------------------
1791 void DiffractometerDevice::save()
1793 DEBUG_STREAM << "DiffractometerDevice::save(): entering... !" << endl;
1795 // Add your own code to control device here
1798 // Step 1 : clean all properties
1799 // FP Le mieux serait sans doute de ne pas effacer les propriétés d'attribut
1800 // avant d'avoir crée correctement un data_put.
1801 Tango::DbData current_crystal_prop;
1802 current_crystal_prop.push_back(Tango::DbDatum("CurrentCrystal"));
1803 this->get_db_device()->get_attribute_property(current_crystal_prop);
1804 long number_of_prop = 0;
1805 current_crystal_prop[0] >> number_of_prop ;
1806 if( number_of_prop > 0)
1807 this->get_db_device()->delete_attribute_property(current_crystal_prop);
1809 // Step 2 : get the Crystal properties
1810 Tango::DbData data_put;
1811 Tango::DbDatum attribute("CurrentCrystal");
1812 // Put number of properties (= nb of samples)
1813 attribute << (long)_diffractometer->samples().size();
1814 data_put.push_back(attribute);
1815 // Create each property
1816 hkl::SampleList::iterator it = _diffractometer->samples().begin();
1817 hkl::SampleList::iterator end = _diffractometer->samples().end();
1818 while (it != end) {
1819 hkl::Sample * sample = *it;
1820 std::vector<std::string> lines;
1821 char line[256];
1823 // Get Wavelength
1824 double wavelength = _diffractometer->geometry()->get_source().get_waveLength().get_value();
1825 snprintf(line, 255, "wavelength=%f", wavelength);
1826 lines.push_back(line);
1828 // get its lattices values
1829 hkl::Lattice & lattice = sample->lattice();
1830 double a = lattice.a().get_current().get_value();
1831 double b = lattice.b().get_current().get_value();
1832 double c = lattice.c().get_current().get_value();
1833 double alpha = lattice.alpha().get_current().get_value() * HKL_RADTODEG;
1834 double beta = lattice.beta().get_current().get_value() * HKL_RADTODEG;
1835 double gamma = lattice.gamma().get_current().get_value() * HKL_RADTODEG;
1837 snprintf(line, 255, "lattice=%f;%f;%f;%f;%f;%f",
1838 a, b, c, alpha, beta, gamma);
1839 lines.push_back(line);
1841 // get reflection
1842 unsigned int i, j;
1843 hkl::ReflectionList & reflections = sample->reflections();
1844 for(i=0; i<reflections.size(); i++) {
1845 hkl::Reflection * reflection = reflections[i];
1846 hkl::svector const & hkl = reflection->get_hkl();
1847 hkl::AxeList const & axes = reflection->get_geometry().get_axes();
1848 snprintf(line, 255, "reflection=%f;%f;%f;%d;%d",
1849 hkl.x(), hkl.y(), hkl.z(),
1850 1, reflection->flag());
1851 // Extract values of each axes
1852 for(j=0; j<axes.size(); j++) {
1853 char pos[256];
1854 double rad = axes[j]->get_current().get_value() * HKL_RADTODEG;
1855 snprintf(pos, 255, ";%f", rad);
1856 strncat(line, pos, 255);
1859 lines.push_back(line);
1862 // Try to create property
1863 // Get crystal name
1864 Tango::DbDatum property((*it)->get_name());
1865 property << lines;
1866 data_put.push_back(property);
1867 ++it;
1870 //update database for this property
1871 this->get_db_device()->put_attribute_property(data_put);
1875 //+------------------------------------------------------------------
1877 * method: DiffractometerDevice::set_affinement_max_iteration
1879 * description: method to execute "SetAffinementMaxIteration"
1880 * This commands redefine the maximum of iteration for an affinement.
1881 * index = index of reflection
1882 * h = h value
1883 * k = k value
1884 * l = l valuee
1885 * relevance = relevance value of this reflection
1886 * affinement enabled = if true this reflection is associated with Affinement calculation
1888 * @param argin Affinement name, Value of iteration max
1891 //+------------------------------------------------------------------
1892 void DiffractometerDevice::set_affinement_max_iteration(const Tango::DevVarStringArray *argin)
1894 DEBUG_STREAM << "DiffractometerDevice::set_affinement_max_iteration(): entering... !" << endl;
1896 // Add your own code to control device here
1898 /* POGO TO DELETE */
1901 //+------------------------------------------------------------------
1903 * method: DiffractometerDevice::set_crystal_parameter_values
1905 * description: method to execute "SetCrystalParameterValues"
1906 * Double : min value, max value, affinement enable
1908 * @param argin String : Name of parameter ; Double : min value, max value, affinement enable
1911 //+------------------------------------------------------------------
1912 void DiffractometerDevice::set_crystal_parameter_values(const Tango::DevVarDoubleStringArray *argin)
1914 DEBUG_STREAM << "DiffractometerDevice::set_crystal_parameter_values(): entering... !" << endl;
1916 // Add your own code to control device here
1918 // check Parameters
1919 if(_hklAdapter)
1920 _hklAdapter->set_sample_parameter_values(argin);
1923 //+------------------------------------------------------------------
1925 * method: DiffractometerDevice::set_hkl
1927 * description: method to execute "SetHKL"
1928 * This command will set the triplet (h,k,l
1930 * @param argin h,k,l values
1933 //+------------------------------------------------------------------
1934 void DiffractometerDevice::set_hkl(const Tango::DevVarDoubleArray *argin)
1936 DEBUG_STREAM << "DiffractometerDevice::set_hkl(): entering... !" << endl;
1938 // Add your own code to control device here
1940 if(argin->length() != 3)
1941 TANGO_EXCEPTION_THROW("DATA_OUT_OF_RANGE", "set_hkl did not receive the exact amount of parameters: h, k, l");
1943 // try to set up hkl.
1944 this->compute_angles((*argin)[0], (*argin)[1], (*argin)[2]);
1947 //+------------------------------------------------------------------
1949 * method: DiffractometerDevice::set_mode_parameters_values
1951 * description: method to execute "SetModeParametersValues"
1952 * Double : value of parameter
1954 * @param argin String : name of parameter ; Double : value of parameter
1957 //+------------------------------------------------------------------
1958 void DiffractometerDevice::set_mode_parameters_values(const Tango::DevVarDoubleStringArray *argin)
1960 DEBUG_STREAM << "DiffractometerDevice::set_mode_parameters_values(): entering... !" << endl;
1962 // Add your own code to control device here
1964 // Check if argin is like (key,value)
1965 if(_hklAdapter)
1966 _hklAdapter->set_mode_parameters_values(argin);
1969 //+------------------------------------------------------------------
1971 * method: DiffractometerDevice::set_reflection
1973 * description: method to execute "SetReflection"
1974 * This commands redefine the parameters of 1 reflection of the current cristal.
1975 * index = index of reflection
1976 * h = h value
1977 * k = k value
1978 * l = l valuee
1979 * relevance = relevance value of this reflection
1980 * affinement enabled = if true this reflection is associated with Affinement calculation
1982 * @param argin reflections i.e : index, h, k, l, relevance, affinement enabled
1985 //+------------------------------------------------------------------
1986 void DiffractometerDevice::set_reflection(const Tango::DevVarDoubleArray *argin)
1988 DEBUG_STREAM << "DiffractometerDevice::set_reflection(): entering... !" << endl;
1990 // Add your own code to control device here
1992 /* POGO TO DELETE */
1993 if(_hklAdapter)
1994 _hklAdapter->set_sample_reflection(argin);
1997 //+------------------------------------------------------------------
1999 * method: DiffractometerDevice::copy_reflection_to
2001 * description: method to execute "CopyReflectionTo"
2002 * Copy one reflection from the current crystal to another crystal
2004 * @param argin Double: Reflection number of the current crystal String : Name of the crystal where copy this reflection
2007 //+------------------------------------------------------------------
2008 void DiffractometerDevice::copy_reflection_to(const Tango::DevVarDoubleStringArray *argin)
2010 DEBUG_STREAM << "DiffractometerDevice::copy_reflection_to(): entering... !" << endl;
2012 // Add your own code to control device here
2014 /* POGO TO DELETE */
2017 //+------------------------------------------------------------------
2019 * method: DiffractometerDevice::dev_state
2021 * description: method to execute "State"
2022 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
2024 * @return State Code
2027 //+------------------------------------------------------------------
2028 Tango::DevState DiffractometerDevice::dev_state()
2030 Tango::DevState argout = DeviceImpl::dev_state();
2031 DEBUG_STREAM << "DiffractometerDevice::dev_state(): entering... !" << endl;
2033 // Add your own code to control device here
2035 std::string status;
2037 if (_hklAdapter)
2038 _hklAdapter->getDiffractometerStateAndStatus(argout, status);
2039 else {
2040 argout = Tango::FAULT;
2041 status = "Diffractometer core not yet initialized !!!!";
2043 this->set_status(status);
2044 this->set_state(argout);
2046 return argout;
2049 //+------------------------------------------------------------------
2051 * method: DiffractometerDevice::get_crystal_parameter_values
2053 * description: method to execute "GetCrystalParameterValues"
2054 * Return all values of a parameter for the current crystal
2056 * @param argin Name of parameter (see getParametersNames for the complete list of parameters)
2057 * @return In the order : minimum value, maximum value, affinement enable
2060 //+------------------------------------------------------------------
2061 Tango::DevVarDoubleStringArray *DiffractometerDevice::get_crystal_parameter_values(Tango::DevString argin)
2063 // POGO has generated a method core with argout allocation.
2064 // If you would like to use a static reference without copying,
2065 // See "TANGO Device Server Programmer's Manual"
2066 // (chapter : Writing a TANGO DS / Exchanging data)
2067 //------------------------------------------------------------
2068 Tango::DevVarDoubleStringArray *argout = new Tango::DevVarDoubleStringArray();
2069 argout->dvalue.length(3);
2070 argout->dvalue[0] = 0.0;
2071 argout->dvalue[1] = 0.0;
2072 argout->dvalue[2] = 0.0;
2073 argout->svalue.length(1);
2074 argout->svalue[0] = CORBA::string_dup(argin);
2075 DEBUG_STREAM << "DiffractometerDevice::get_crystal_parameter_values(): entering... !" << endl;
2077 // Add your own code to control device here
2078 if(_hklAdapter)
2079 _hklAdapter->get_sample_parameter_values(argout);
2081 return argout;
2084 //+------------------------------------------------------------------
2086 * method: DiffractometerDevice::compute_u
2088 * description: method to execute "ComputeU"
2089 * Compute Matrix U from two reflections
2091 * @param argin a two elements array with the index of reflection to use
2094 //+------------------------------------------------------------------
2095 void DiffractometerDevice::compute_u(const Tango::DevVarLongArray *argin)
2097 DEBUG_STREAM << "DiffractometerDevice::compute_u(): entering... !" << endl;
2099 // Add your own code to control device here
2100 if(_hklAdapter){
2101 _hklAdapter->compute_u(argin);
2102 this->save();
2106 //+------------------------------------------------------------------
2108 * method: DiffractometerDevice::get_axes_names
2110 * description: method to execute "GetAxesNames"
2111 * this method return the names of the dynamic attributes created from the hkl axes names
2112 * kappa -> AxisKappa etc...
2114 * @return namers of the axes
2117 //+------------------------------------------------------------------
2118 Tango::DevVarStringArray *DiffractometerDevice::get_axes_names()
2120 // POGO has generated a method core with argout allocation.
2121 // If you would like to use a static reference without copying,
2122 // See "TANGO Device Server Programmer's Manual"
2123 // (chapter : Writing a TANGO DS / Exchanging data)
2124 //------------------------------------------------------------
2125 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();
2126 unsigned int len = _dynamic_attributes.size();
2127 argout->length(len);
2128 DEBUG_STREAM << "DiffractometerDevice::get_axes_names(): entering... !" << endl;
2130 // Add your own code to control device here
2131 for(unsigned int i=0; i<len; ++i)
2132 (*argout)[i] = CORBA::string_dup(_dynamic_attributes[i]->get_name().c_str());
2133 return argout;
2136 //+------------------------------------------------------------------
2138 * method: DiffractometerDevice::computed_angles_clear
2140 * description: method to execute "ComputedAnglesClear"
2141 * Clears the attribute ComputedAngles.
2142 * Useful to get a fresh view of calculations already made
2146 //+------------------------------------------------------------------
2147 void DiffractometerDevice::computed_angles_clear()
2149 DEBUG_STREAM << "DiffractometerDevice::computed_angles_clear(): entering... !" << endl;
2151 // Add your own code to control device here
2152 _computedAngles_size = 0;
2153 if(attr_ComputedAngles_read) {
2154 delete [] attr_ComputedAngles_read;
2155 attr_ComputedAngles_read = NULL;
2160 //+------------------------------------------------------------------
2162 * method: DiffractometerDevice::computed_angles_hkllist
2164 * description: method to execute "ComputedAnglesHKLList"
2165 * this commande works only in simulated mode.
2166 * It computhe [-hmax: hmax] etc.. angles computations.
2168 * @param argin hmax, kmax, lmax
2171 //+------------------------------------------------------------------
2172 void DiffractometerDevice::computed_angles_hkllist(const Tango::DevVarDoubleArray *argin)
2174 DEBUG_STREAM << "DiffractometerDevice::computed_angles_hkllist(): entering... !" << endl;
2176 // Add your own code to control device here
2178 if((argin->length() != 3) && (argin->length() != 6))
2179 TANGO_EXCEPTION_THROW("DATA_OUT_OF_RANGE", "computed_angles_hkllist did not receive the exact amount of parameters: hmax, kmax, lmax");
2181 // Parameters are OK
2182 if (!_hklAdapter->simulated)
2183 return;
2185 double h, k, l;
2186 double hmax = fabs((*argin)[0]);
2187 double kmax = fabs((*argin)[1]);
2188 double lmax = fabs((*argin)[2]);
2189 double dh, dk, dl;
2190 if (argin->length() == 6) {
2191 dh = fabs((*argin)[3]);
2192 dk = fabs((*argin)[4]);
2193 dl = fabs((*argin)[5]);
2194 } else
2195 dh = dk = dl = 1.;
2196 h = -hmax;
2197 while(h <= hmax) {
2198 k = -kmax;
2199 while(k <= kmax) {
2200 l = -lmax;
2201 while(l <= lmax) {
2202 try {
2203 this->compute_angles(h, k, l);
2205 catch(...)
2207 l += dl;
2209 k += dk;
2211 h += dh;
2216 //+------------------------------------------------------------------
2218 * method: DiffractometerDevice::goto_computed_angles
2220 * description: method to execute "GotoComputedAngles"
2222 * @param argin the idx of the computed angles
2225 //+------------------------------------------------------------------
2226 void DiffractometerDevice::goto_computed_angles(Tango::DevShort argin)
2228 DEBUG_STREAM << "DiffractometerDevice::goto_computed_angles(): entering... !" << endl;
2230 // Add your own code to control device here
2236 } // namespace