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 //+=============================================================================
4 // file : Diffractometer.cpp
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
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
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()
58 // AddNewCrystal | add_new_crystal()
59 // AddReflection | add_reflection()
60 // AffineCrystal | affine_crystal()
61 // ComputeU | compute_u()
62 // ConfigureCrystal | configure_crystal()
63 // CopyCurrentCrystalAs | copy_current_crystal_as()
64 // CopyReflectionTo | copy_reflection_to()
65 // DeleteCurrentCrystal | delete_current_crystal()
66 // GetCrystalParameterValues | get_crystal_parameter_values()
68 // RemoveReflection | remove_reflection()
70 // SetCrystalParameterValues | set_crystal_parameter_values()
72 //===================================================================
76 #include <Diffractometer.h>
77 #include <DiffractometerClass.h>
86 #include "AxisAttrib.h"
87 #include "TangoHKLAdapterFactory.h"
89 namespace Diffractometer_ns
92 //+----------------------------------------------------------------------------
94 // method : Diffractometer::Diffractometer(string &s)
96 // description : constructor for simulated Diffractometer
98 // in : - cl : Pointer to the DeviceClass object
101 //-----------------------------------------------------------------------------
102 Diffractometer::Diffractometer(Tango::DeviceClass
*cl
,string
&s
)
103 :Tango::Device_3Impl(cl
,s
.c_str())
108 Diffractometer::Diffractometer(Tango::DeviceClass
*cl
,const char *s
)
109 :Tango::Device_3Impl(cl
,s
)
114 Diffractometer::Diffractometer(Tango::DeviceClass
*cl
,const char *s
,const char *d
)
115 :Tango::Device_3Impl(cl
,s
,d
)
119 //+----------------------------------------------------------------------------
121 // method : Diffractometer::delete_device()
123 // description : will be called at device destruction or at init command.
125 //-----------------------------------------------------------------------------
126 void Diffractometer::delete_device()
128 // Delete device's allocated object
131 // Delete device's allocated object
132 DELETE_SCALAR_ATTRIBUTE(attr_H_read
);
133 DELETE_SCALAR_ATTRIBUTE(attr_K_read
);
134 DELETE_SCALAR_ATTRIBUTE(attr_L_read
);
135 DELETE_SCALAR_ATTRIBUTE(attr_AnglesIdx_read
);
136 DELETE_SCALAR_ATTRIBUTE(attr_WaveLength_read
);
137 DELETE_SCALAR_ATTRIBUTE(attr_Simulated_read
);
138 DELETE_SCALAR_ATTRIBUTE(attr_A_read
);
139 DELETE_SCALAR_ATTRIBUTE(attr_B_read
);
140 DELETE_SCALAR_ATTRIBUTE(attr_C_read
);
141 DELETE_SCALAR_ATTRIBUTE(attr_Alpha_read
);
142 DELETE_SCALAR_ATTRIBUTE(attr_Beta_read
);
143 DELETE_SCALAR_ATTRIBUTE(attr_Gamma_read
);
144 DELETE_SCALAR_ATTRIBUTE(attr_Ux_read
);
145 DELETE_SCALAR_ATTRIBUTE(attr_Uy_read
);
146 DELETE_SCALAR_ATTRIBUTE(attr_Uz_read
);
147 DELETE_SCALAR_ATTRIBUTE(attr_AStar_read
);
148 DELETE_SCALAR_ATTRIBUTE(attr_BStar_read
);
149 DELETE_SCALAR_ATTRIBUTE(attr_CStar_read
);
150 DELETE_SCALAR_ATTRIBUTE(attr_AlphaStar_read
);
151 DELETE_SCALAR_ATTRIBUTE(attr_BetaStar_read
);
152 DELETE_SCALAR_ATTRIBUTE(attr_GammaStar_read
);
154 DELETE_DEVSTRING_ATTRIBUTE(attr_Mode_read
);
155 DELETE_DEVSTRING_ATTRIBUTE(attr_Crystal_read
);
157 if(attr_CrystalReflections_read
) {
158 delete[] attr_CrystalReflections_read
;
159 attr_CrystalReflections_read
= NULL
;
163 delete[] attr_UB_read
;
167 if(attr_ReflectionsAngles_read
) {
168 delete [] attr_ReflectionsAngles_read
;
169 attr_ReflectionsAngles_read
= NULL
;
172 if (attr_ComputedAngles_read
) {
173 delete [] attr_ComputedAngles_read
;
174 attr_ComputedAngles_read
= NULL
;
177 if(attr_Reflections_read
){
178 delete[] attr_Reflections_read
;
179 attr_Reflections_read
= NULL
;
182 this->remove_dynamic_attributes();
185 * Do not remove the diffractometer in the delete method
186 * of the Derived classes to avoid a segmentation fault
187 * during the save method call. Indeed the Derived class delete
188 * method is called before this delete method.
190 TangoHKLAdapterFactory::instance()->detach_diffractometer_device(this);
193 //+----------------------------------------------------------------------------
195 // method : Diffractometer::init_device()
197 // description : will be called at device initialization.
199 //-----------------------------------------------------------------------------
200 void Diffractometer::init_device()
202 INFO_STREAM
<< "Diffractometer::Diffractometer() create device " << device_name
<< endl
;
204 // Initialise variables to default values
205 //--------------------------------------------
206 get_device_property();
208 CREATE_SCALAR_ATTRIBUTE(attr_H_read
, 0.0);
209 CREATE_SCALAR_ATTRIBUTE(attr_K_read
, 0.0);
210 CREATE_SCALAR_ATTRIBUTE(attr_L_read
, 0.0);
211 CREATE_SCALAR_ATTRIBUTE(attr_AnglesIdx_read
, (short)-1);
212 CREATE_SCALAR_ATTRIBUTE(attr_WaveLength_read
, 0.0);
213 CREATE_SCALAR_ATTRIBUTE(attr_Simulated_read
, true);
214 CREATE_SCALAR_ATTRIBUTE(attr_A_read
, 0.0);
215 CREATE_SCALAR_ATTRIBUTE(attr_B_read
, 0.0);
216 CREATE_SCALAR_ATTRIBUTE(attr_C_read
, 0.0);
217 CREATE_SCALAR_ATTRIBUTE(attr_Alpha_read
, 0.0);
218 CREATE_SCALAR_ATTRIBUTE(attr_Beta_read
, 0.0);
219 CREATE_SCALAR_ATTRIBUTE(attr_Gamma_read
, 0.0);
220 CREATE_SCALAR_ATTRIBUTE(attr_Ux_read
, 0.0);
221 CREATE_SCALAR_ATTRIBUTE(attr_Uy_read
, 0.0);
222 CREATE_SCALAR_ATTRIBUTE(attr_Uz_read
, 0.0);
223 CREATE_SCALAR_ATTRIBUTE(attr_AStar_read
);
224 CREATE_SCALAR_ATTRIBUTE(attr_BStar_read
);
225 CREATE_SCALAR_ATTRIBUTE(attr_CStar_read
);
226 CREATE_SCALAR_ATTRIBUTE(attr_AlphaStar_read
);
227 CREATE_SCALAR_ATTRIBUTE(attr_BetaStar_read
);
228 CREATE_SCALAR_ATTRIBUTE(attr_GammaStar_read
);
230 CREATE_DEVSTRING_ATTRIBUTE(attr_Crystal_read
, 1, "");
231 CREATE_DEVSTRING_ATTRIBUTE(attr_Mode_read
, 1, "");
233 attr_CrystalReflections_read
= NULL
;
235 attr_ReflectionsAngles_read
= NULL
;
236 attr_ComputedAngles_read
= NULL
;
237 attr_Reflections_read
= NULL
;
238 attr_AxesNames_read
= NULL
;
240 // get the write part of the hkl attributes
241 _att_h_w
= &dev_attr
->get_w_attr_by_name("h");
242 _att_k_w
= &dev_attr
->get_w_attr_by_name("k");
243 _att_l_w
= &dev_attr
->get_w_attr_by_name("l");
245 // Device is in FAULT state because it was not yet configured.
246 this->set_state(Tango::FAULT
);
247 this->set_status("Configure Diffractometer: crystal, wavelength,etc ..");
249 _computedAngles_size
= 0;
257 _type
= this->get_type_from_property(diffractometerType
);
260 * this method must be call after get_device_property() as
261 * TangoHKLAdapter create the axisbuffer from the
264 _hklAdapter
= TangoHKLAdapterFactory::instance()->attach_diffractometer_device(this, _type
);
266 this->set_state(Tango::FAULT
);
267 this->set_status("Fatal can not initialize the hkl library");
268 TANGO_EXCEPTION_THROW("Internal Fatal Error", "Device can't get an instance of TangoHKLAdapter");
270 // Restore the Diffractometer state from the last run.
273 _hklAdapter
->connect_all_proxies();
275 // create an start all the PseudoAxes devices.
276 _hklAdapter
->pseudo_axes_create_and_start_devices();
279 _write_attributes_hkl_together
= false;
283 //+----------------------------------------------------------------------------
285 // method : Diffractometer::get_device_property()
287 // description : Read the device properties from database.
289 //-----------------------------------------------------------------------------
290 void Diffractometer::get_device_property()
292 // Initialize your default values here (if not done with POGO).
293 //------------------------------------------------------------------
295 // Read device properties from database.(Automatic code generation)
296 //------------------------------------------------------------------
297 Tango::DbData dev_prop
;
298 dev_prop
.push_back(Tango::DbDatum("TauConstant"));
299 dev_prop
.push_back(Tango::DbDatum("RealAxisProxies"));
300 dev_prop
.push_back(Tango::DbDatum("LambdaAttributeProxy"));
301 dev_prop
.push_back(Tango::DbDatum("DiffractometerType"));
303 // Call database and extract values
304 //--------------------------------------------
305 if (Tango::Util::instance()->_UseDb
==true)
306 get_db_device()->get_property(dev_prop
);
307 Tango::DbDatum def_prop
, cl_prop
;
308 DiffractometerClass
*ds_class
=
309 (static_cast<DiffractometerClass
*>(get_device_class()));
312 // Try to initialize TauConstant from class property
313 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
314 if (cl_prop
.is_empty()==false) cl_prop
>> tauConstant
;
316 // Try to initialize TauConstant from default device value
317 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
318 if (def_prop
.is_empty()==false) def_prop
>> tauConstant
;
320 // And try to extract TauConstant value from database
321 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> tauConstant
;
323 // Try to initialize RealAxisProxies from class property
324 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
325 if (cl_prop
.is_empty()==false) cl_prop
>> realAxisProxies
;
327 // Try to initialize RealAxisProxies from default device value
328 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
329 if (def_prop
.is_empty()==false) def_prop
>> realAxisProxies
;
331 // And try to extract RealAxisProxies value from database
332 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> realAxisProxies
;
334 // Try to initialize LambdaAttributeProxy from class property
335 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
336 if (cl_prop
.is_empty()==false) cl_prop
>> lambdaAttributeProxy
;
338 // Try to initialize LambdaAttributeProxy from default device value
339 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
340 if (def_prop
.is_empty()==false) def_prop
>> lambdaAttributeProxy
;
342 // And try to extract LambdaAttributeProxy value from database
343 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> lambdaAttributeProxy
;
345 // Try to initialize DiffractometerType from class property
346 cl_prop
= ds_class
->get_class_property(dev_prop
[++i
].name
);
347 if (cl_prop
.is_empty()==false) cl_prop
>> diffractometerType
;
349 // Try to initialize DiffractometerType from default device value
350 def_prop
= ds_class
->get_default_device_property(dev_prop
[i
].name
);
351 if (def_prop
.is_empty()==false) def_prop
>> diffractometerType
;
353 // And try to extract DiffractometerType value from database
354 if (dev_prop
[i
].is_empty()==false) dev_prop
[i
] >> diffractometerType
;
358 // End of Automatic code generation
359 //------------------------------------------------------------------
362 //+----------------------------------------------------------------------------
364 // method : Diffractometer::always_executed_hook()
366 // description : method always executed before any command is executed
368 //-----------------------------------------------------------------------------
369 void Diffractometer::always_executed_hook()
372 _hklAdapter
->connect_all_proxies();
374 //+----------------------------------------------------------------------------
376 // method : Diffractometer::read_attr_hardware
378 // description : Hardware acquisition for attributes.
380 //-----------------------------------------------------------------------------
381 void Diffractometer::read_attr_hardware(vector
<long> &attr_list
)
383 DEBUG_STREAM
<< "Diffractometer::read_attr_hardware(vector<long> &attr_list) entering... "<< endl
;
384 // Add your own code here
388 _hklAdapter
->update();
389 _hklAdapter
->get_diffractometer_config(_config
);
391 // update the hkl attributes
394 HKLBuffer
const & buffer
= _hklAdapter
->get_HKLBuffer();
395 *attr_H_read
= buffer
.h_r
;
396 attr_H_write
= buffer
.h_w
;
397 *attr_K_read
= buffer
.k_r
;
398 attr_K_write
= buffer
.k_w
;
399 *attr_L_read
= buffer
.l_r
;
400 attr_L_write
= buffer
.l_w
;
402 // set the write part of the hkl attributes
403 _att_h_w
->set_write_value(buffer
.h_w
);
404 _att_k_w
->set_write_value(buffer
.k_w
);
405 _att_l_w
->set_write_value(buffer
.l_w
);
407 catch (Tango::DevFailed
& e
)
409 ERROR_STREAM
<< e
<<endl
;
412 _hklAdapter
->get_sample_lattices(attr_A_read
, attr_B_read
, attr_C_read
,
413 attr_Alpha_read
, attr_Beta_read
, attr_Gamma_read
,
414 attr_AStar_read
, attr_BStar_read
, attr_CStar_read
,
415 attr_AlphaStar_read
, attr_BetaStar_read
, attr_GammaStar_read
);
417 //+----------------------------------------------------------------------------
419 // method : Diffractometer::read_pseudoAxesProxies
421 // description : Extract real attribute values for pseudoAxesProxies acquisition result.
423 //-----------------------------------------------------------------------------
424 void Diffractometer::read_pseudoAxesProxies(Tango::Attribute
&attr
)
426 DEBUG_STREAM
<< "Diffractometer::read_pseudoAxesProxies(Tango::Attribute &attr) entering... "<< endl
;
428 Matrix
<char *> const & img
= _hklAdapter
->get_pseudo_axes_proxies();
429 attr
.set_value(img
.data
, img
.xdim
);
433 //+----------------------------------------------------------------------------
435 // method : Diffractometer::read_AnglesIdx
437 // description : Extract real attribute values for AnglesIdx acquisition result.
439 //-----------------------------------------------------------------------------
440 void Diffractometer::read_AnglesIdx(Tango::Attribute
&attr
)
442 DEBUG_STREAM
<< "Diffractometer::read_AnglesIdx(Tango::Attribute &attr) entering... "<< endl
;
445 *attr_AnglesIdx_read
= _hklAdapter
->get_angles_idx();
446 attr
.set_value(attr_AnglesIdx_read
);
450 //+----------------------------------------------------------------------------
452 // method : Diffractometer::write_AnglesIdx
454 // description : Write AnglesIdx attribute values to hardware.
456 //-----------------------------------------------------------------------------
457 void Diffractometer::write_AnglesIdx(Tango::WAttribute
&attr
)
459 DEBUG_STREAM
<< "Diffractometer::write_AnglesIdx(Tango::WAttribute &attr) entering... "<< endl
;
461 attr
.get_write_value(attr_AnglesIdx_write
);
463 _hklAdapter
->set_angles_idx(attr_AnglesIdx_write
);
466 //+----------------------------------------------------------------------------
468 // method : Diffractometer::read_AxesNames
470 // description : Extract real attribute values for AxesNames acquisition result.
472 //-----------------------------------------------------------------------------
473 void Diffractometer::read_AxesNames(Tango::Attribute
&attr
)
476 Matrix
<char *> const & img
= _hklAdapter
->get_dynamic_attribute_axes_names();
477 attr
.set_value(img
.data
, img
.xdim
);
481 //+----------------------------------------------------------------------------
483 // method : Diffractometer::read_Angles
485 // description : Extract real attribute values for Angles acquisition result.
487 //-----------------------------------------------------------------------------
488 void Diffractometer::read_Angles(Tango::Attribute
&attr
)
490 DEBUG_STREAM
<< "Diffractometer::read_Angles(Tango::Attribute &attr) entering... "<< endl
;
492 Matrix
<double> const & img
= _hklAdapter
->get_angles();
493 attr
.set_value(img
.data
, img
.xdim
, img
.ydim
);
497 //+----------------------------------------------------------------------------
499 // method : Diffractometer::read_AnglesDegenerated
501 // description : Extract real attribute values for AnglesDegenerated acquisition result.
503 //-----------------------------------------------------------------------------
504 void Diffractometer::read_AnglesDegenerated(Tango::Attribute
&attr
)
506 DEBUG_STREAM
<< "Diffractometer::read_AnglesDegenerated(Tango::Attribute &attr) entering... "<< endl
;
509 //+----------------------------------------------------------------------------
511 // method : Diffractometer::read_AnglesRangeCheck
513 // description : Extract real attribute values for AnglesRangeCheck acquisition result.
515 //-----------------------------------------------------------------------------
516 void Diffractometer::read_AnglesRangeCheck(Tango::Attribute
&attr
)
518 DEBUG_STREAM
<< "Diffractometer::read_AnglesRangeCheck(Tango::Attribute &attr) entering... "<< endl
;
521 //+----------------------------------------------------------------------------
523 // method : Diffractometer::read_Reflections
525 // description : Extract real attribute values for Reflections acquisition result.
527 //-----------------------------------------------------------------------------
528 void Diffractometer::read_Reflections(Tango::Attribute
&attr
)
530 DEBUG_STREAM
<< "Diffractometer::read_Reflections(Tango::Attribute &attr) entering... "<< endl
;
532 Matrix
<double> const & img
= _hklAdapter
->get_sample_reflections();
533 attr
.set_value(img
.data
, img
.xdim
, img
.ydim
);
537 //+----------------------------------------------------------------------------
539 // method : Diffractometer::write_Reflections
541 // description : Write Reflections attribute values to hardware.
543 //-----------------------------------------------------------------------------
544 void Diffractometer::write_Reflections(Tango::WAttribute
&attr
)
546 DEBUG_STREAM
<< "Diffractometer::write_Reflections(Tango::WAttribute &attr) entering... "<< endl
;
548 attr
.get_write_value(attr_Reflections_write
);
551 img
.attach_to_buffer(&attr_Reflections_write
,
552 attr
.get_w_dim_x(), attr
.get_w_dim_y());
555 _hklAdapter
->set_sample_reflections(img
);
558 //+----------------------------------------------------------------------------
560 // method : Diffractometer::read_ComputedAngles
562 // description : Extract real attribute values for ComputedAngles acquisition result.
564 //-----------------------------------------------------------------------------
565 void Diffractometer::read_ComputedAngles(Tango::Attribute
&attr
)
567 DEBUG_STREAM
<< "Diffractometer::read_ComputedAngles(Tango::Attribute &attr) entering... "<< endl
;
570 Matrix
<double> const & img
= _hklAdapter
->get_computed_angles();
571 attr
.set_value(img
.data
, img
.xdim
, img
.ydim
);
575 //+----------------------------------------------------------------------------
577 // method : Diffractometer::read_ReflectionsAngles
579 // description : Extract real attribute values for ReflectionsAngles acquisition result.
581 //-----------------------------------------------------------------------------
582 void Diffractometer::read_ReflectionsAngles(Tango::Attribute
&attr
)
584 DEBUG_STREAM
<< "Diffractometer::read_ReflectionsAngles(Tango::Attribute &attr) entering... "<< endl
;
587 Matrix
<double> const & img
= _hklAdapter
->get_reflections_angles();
588 attr
.set_value(img
.data
, img
.xdim
, img
.ydim
);
592 //+----------------------------------------------------------------------------
594 // method : Diffractometer::read_AStar
596 // description : Extract real attribute values for AStar acquisition result.
598 //-----------------------------------------------------------------------------
599 void Diffractometer::read_AStar(Tango::Attribute
&attr
)
601 DEBUG_STREAM
<< "Diffractometer::read_AStar(Tango::Attribute &attr) entering... "<< endl
;
602 attr
.set_value(attr_AStar_read
);
605 //+----------------------------------------------------------------------------
607 // method : Diffractometer::read_BStar
609 // description : Extract real attribute values for BStar acquisition result.
611 //-----------------------------------------------------------------------------
612 void Diffractometer::read_BStar(Tango::Attribute
&attr
)
614 DEBUG_STREAM
<< "Diffractometer::read_BStar(Tango::Attribute &attr) entering... "<< endl
;
615 attr
.set_value(attr_BStar_read
);
618 //+----------------------------------------------------------------------------
620 // method : Diffractometer::read_CStar
622 // description : Extract real attribute values for CStar acquisition result.
624 //-----------------------------------------------------------------------------
625 void Diffractometer::read_CStar(Tango::Attribute
&attr
)
627 DEBUG_STREAM
<< "Diffractometer::read_CStar(Tango::Attribute &attr) entering... "<< endl
;
628 attr
.set_value(attr_CStar_read
);
631 //+----------------------------------------------------------------------------
633 // method : Diffractometer::read_AlphaStar
635 // description : Extract real attribute values for AlphaStar acquisition result.
637 //-----------------------------------------------------------------------------
638 void Diffractometer::read_AlphaStar(Tango::Attribute
&attr
)
640 DEBUG_STREAM
<< "Diffractometer::read_AlphaStar(Tango::Attribute &attr) entering... "<< endl
;
641 attr
.set_value(attr_AlphaStar_read
);
644 //+----------------------------------------------------------------------------
646 // method : Diffractometer::read_BetaStar
648 // description : Extract real attribute values for BetaStar acquisition result.
650 //-----------------------------------------------------------------------------
651 void Diffractometer::read_BetaStar(Tango::Attribute
&attr
)
653 DEBUG_STREAM
<< "Diffractometer::read_BetaStar(Tango::Attribute &attr) entering... "<< endl
;
654 attr
.set_value(attr_BetaStar_read
);
657 //+----------------------------------------------------------------------------
659 // method : Diffractometer::read_GammaStar
661 // description : Extract real attribute values for GammaStar acquisition result.
663 //-----------------------------------------------------------------------------
664 void Diffractometer::read_GammaStar(Tango::Attribute
&attr
)
666 DEBUG_STREAM
<< "Diffractometer::read_GammaStar(Tango::Attribute &attr) entering... "<< endl
;
667 attr
.set_value(attr_GammaStar_read
);
670 //+----------------------------------------------------------------------------
672 // method : Diffractometer::read_A
674 // description : Extract real attribute values for A acquisition result.
676 //-----------------------------------------------------------------------------
677 void Diffractometer::read_A(Tango::Attribute
&attr
)
679 DEBUG_STREAM
<< "Diffractometer::read_A(Tango::Attribute &attr) entering... "<< endl
;
680 attr
.set_value(attr_A_read
);
683 //+----------------------------------------------------------------------------
685 // method : Diffractometer::read_B
687 // description : Extract real attribute values for B acquisition result.
689 //-----------------------------------------------------------------------------
690 void Diffractometer::read_B(Tango::Attribute
&attr
)
692 DEBUG_STREAM
<< "Diffractometer::read_B(Tango::Attribute &attr) entering... "<< endl
;
693 attr
.set_value(attr_B_read
);
696 //+----------------------------------------------------------------------------
698 // method : Diffractometer::read_C
700 // description : Extract real attribute values for C acquisition result.
702 //-----------------------------------------------------------------------------
703 void Diffractometer::read_C(Tango::Attribute
&attr
)
705 DEBUG_STREAM
<< "Diffractometer::read_C(Tango::Attribute &attr) entering... "<< endl
;
706 attr
.set_value(attr_C_read
);
709 //+----------------------------------------------------------------------------
711 // method : Diffractometer::read_Alpha
713 // description : Extract real attribute values for Alpha acquisition result.
715 //-----------------------------------------------------------------------------
716 void Diffractometer::read_Alpha(Tango::Attribute
&attr
)
718 DEBUG_STREAM
<< "Diffractometer::read_Alpha(Tango::Attribute &attr) entering... "<< endl
;
719 attr
.set_value(attr_Alpha_read
);
722 //+----------------------------------------------------------------------------
724 // method : Diffractometer::read_Beta
726 // description : Extract real attribute values for Beta acquisition result.
728 //-----------------------------------------------------------------------------
729 void Diffractometer::read_Beta(Tango::Attribute
&attr
)
731 DEBUG_STREAM
<< "Diffractometer::read_Beta(Tango::Attribute &attr) entering... "<< endl
;
732 attr
.set_value(attr_Beta_read
);
735 //+----------------------------------------------------------------------------
737 // method : Diffractometer::read_Gamma
739 // description : Extract real attribute values for Gamma acquisition result.
741 //-----------------------------------------------------------------------------
742 void Diffractometer::read_Gamma(Tango::Attribute
&attr
)
744 DEBUG_STREAM
<< "Diffractometer::read_Gamma(Tango::Attribute &attr) entering... "<< endl
;
745 attr
.set_value(attr_Gamma_read
);
748 //+----------------------------------------------------------------------------
750 // method : Diffractometer::read_UB
752 // description : Extract real attribute values for UB acquisition result.
754 //-----------------------------------------------------------------------------
755 void Diffractometer::read_UB(Tango::Attribute
&attr
)
757 DEBUG_STREAM
<< "Diffractometer::read_UB(Tango::Attribute &attr) entering... "<< endl
;
760 Matrix
<double> const & img
= _hklAdapter
->get_sample_ub();
761 attr
.set_value(img
.data
, img
.xdim
, img
.ydim
);
765 //+----------------------------------------------------------------------------
767 // method : Diffractometer::read_Ux
769 // description : Extract real attribute values for Ux acquisition result.
771 //-----------------------------------------------------------------------------
772 void Diffractometer::read_Ux(Tango::Attribute
&attr
)
774 DEBUG_STREAM
<< "Diffractometer::read_Ux(Tango::Attribute &attr) entering... "<< endl
;
777 attr
.set_value(&_hklAdapter
->get_sample_Ux());
780 //+----------------------------------------------------------------------------
782 // method : Diffractometer::write_Ux
784 // description : Write Ux attribute values to hardware.
786 //-----------------------------------------------------------------------------
787 void Diffractometer::write_Ux(Tango::WAttribute
&attr
)
789 DEBUG_STREAM
<< "Diffractometer::write_Ux(Tango::WAttribute &attr) entering... "<< endl
;
792 attr
.get_write_value(Ux
);
794 _hklAdapter
->set_sample_Ux(Ux
);
799 //+----------------------------------------------------------------------------
801 // method : Diffractometer::read_Uy
803 // description : Extract real attribute values for Uy acquisition result.
805 //-----------------------------------------------------------------------------
806 void Diffractometer::read_Uy(Tango::Attribute
&attr
)
808 DEBUG_STREAM
<< "Diffractometer::read_Uy(Tango::Attribute &attr) entering... "<< endl
;
810 attr
.set_value(&_hklAdapter
->get_sample_Uy());
813 //+----------------------------------------------------------------------------
815 // method : Diffractometer::write_Uy
817 // description : Write Uy attribute values to hardware.
819 //-----------------------------------------------------------------------------
820 void Diffractometer::write_Uy(Tango::WAttribute
&attr
)
822 DEBUG_STREAM
<< "Diffractometer::write_Uy(Tango::WAttribute &attr) entering... "<< endl
;
825 attr
.get_write_value(Uy
);
827 _hklAdapter
->set_sample_Uy(Uy
);
832 //+----------------------------------------------------------------------------
834 // method : Diffractometer::read_Uz
836 // description : Extract real attribute values for Uz acquisition result.
838 //-----------------------------------------------------------------------------
839 void Diffractometer::read_Uz(Tango::Attribute
&attr
)
841 DEBUG_STREAM
<< "Diffractometer::read_Uz(Tango::Attribute &attr) entering... "<< endl
;
843 attr
.set_value(&_hklAdapter
->get_sample_Uz());
846 //+----------------------------------------------------------------------------
848 // method : Diffractometer::write_Uz
850 // description : Write Uz attribute values to hardware.
852 //-----------------------------------------------------------------------------
853 void Diffractometer::write_Uz(Tango::WAttribute
&attr
)
855 DEBUG_STREAM
<< "Diffractometer::write_Uz(Tango::WAttribute &attr) entering... "<< endl
;
858 attr
.get_write_value(Uz
);
860 _hklAdapter
->set_sample_Uz(Uz
);
866 //+----------------------------------------------------------------------------
868 // method : Diffractometer::read_Simulated
870 // description : Extract real attribute values for Simulated acquisition result.
872 //-----------------------------------------------------------------------------
873 void Diffractometer::read_Simulated(Tango::Attribute
&attr
)
875 DEBUG_STREAM
<< "Diffractometer::read_Simulated(Tango::Attribute &attr) entering... "<< endl
;
878 *attr_Simulated_read
= _hklAdapter
->simulated
;
879 attr
.set_value(attr_Simulated_read
);
882 //+----------------------------------------------------------------------------
884 // method : Diffractometer::write_Simulated
886 // description : Write Simulated attribute values to hardware.
888 //-----------------------------------------------------------------------------
889 void Diffractometer::write_Simulated(Tango::WAttribute
&attr
)
891 DEBUG_STREAM
<< "Diffractometer::write_Simulated(Tango::WAttribute &attr) entering... "<< endl
;
892 attr
.get_write_value(attr_Simulated_write
);
895 _hklAdapter
->set_simulated(attr_Simulated_write
);
898 //+----------------------------------------------------------------------------
900 // method : Diffractometer::read_H
902 // description : Extract real attribute values for H acquisition result.
904 //-----------------------------------------------------------------------------
905 void Diffractometer::read_H(Tango::Attribute
&attr
)
907 DEBUG_STREAM
<< "Diffractometer::read_H(Tango::Attribute &attr) entering... "<< endl
;
909 attr
.set_value(attr_H_read
);
912 //+----------------------------------------------------------------------------
914 // method : Diffractometer::write_H
916 // description : Write H attribute values to hardware.
918 //-----------------------------------------------------------------------------
919 void Diffractometer::write_H(Tango::WAttribute
&attr
)
921 DEBUG_STREAM
<< "Diffractometer::write_H(Tango::WAttribute &attr) entering... "<< endl
;
924 attr
.get_write_value(h
);
926 // if not during a simultaneous write
927 if (!_write_attributes_hkl_together
) {
928 this->compute_angles(h
, attr_K_write
, attr_L_write
);
929 // If calculation OK then set write point
935 //+----------------------------------------------------------------------------
937 // method : Diffractometer::read_K
939 // description : Extract real attribute values for K acquisition result.
941 //-----------------------------------------------------------------------------
942 void Diffractometer::read_K(Tango::Attribute
&attr
)
944 DEBUG_STREAM
<< "Diffractometer::read_K(Tango::Attribute &attr) entering... "<< endl
;
946 attr
.set_value(attr_K_read
);
949 //+----------------------------------------------------------------------------
951 // method : Diffractometer::write_K
953 // description : Write K attribute values to hardware.
955 //-----------------------------------------------------------------------------
956 void Diffractometer::write_K(Tango::WAttribute
&attr
)
958 DEBUG_STREAM
<< "Diffractometer::write_K(Tango::WAttribute &attr) entering... "<< endl
;
962 attr
.get_write_value(k
);
964 if (!_write_attributes_hkl_together
) {
965 this->compute_angles(attr_H_write
, k
, attr_L_write
);
966 //Now that attribute values are OK, set them
972 //+----------------------------------------------------------------------------
974 // method : Diffractometer::read_L
976 // description : Extract real attribute values for L acquisition result.
978 //-----------------------------------------------------------------------------
979 void Diffractometer::read_L(Tango::Attribute
&attr
)
981 DEBUG_STREAM
<< "Diffractometer::read_L(Tango::Attribute &attr) entering... "<< endl
;
983 attr
.set_value(attr_L_read
);
986 //+----------------------------------------------------------------------------
988 // method : Diffractometer::write_L
990 // description : Write L attribute values to hardware.
992 //-----------------------------------------------------------------------------
993 void Diffractometer::write_L(Tango::WAttribute
&attr
)
995 DEBUG_STREAM
<< "Diffractometer::write_L(Tango::WAttribute &attr) entering... "<< endl
;
999 attr
.get_write_value(l
);
1001 if (!_write_attributes_hkl_together
) {
1002 this->compute_angles(attr_H_write
, attr_K_write
, l
);
1003 //Now that attribute values are OK, set them
1009 //+----------------------------------------------------------------------------
1011 // method : Diffractometer::read_Mode
1013 // description : Extract real attribute values for Mode acquisition result.
1015 //-----------------------------------------------------------------------------
1016 void Diffractometer::read_Mode(Tango::Attribute
&attr
)
1018 DEBUG_STREAM
<< "Diffractometer::read_Mode(Tango::Attribute &attr) entering... "<< endl
;
1021 if(*attr_Mode_read
) delete[] *attr_Mode_read
;
1022 *attr_Mode_read
= CORBA::string_dup(_hklAdapter
->read_mode());
1024 attr
.set_value(attr_Mode_read
);
1027 //+----------------------------------------------------------------------------
1029 // method : Diffractometer::write_Mode
1031 // description : Write Mode attribute values to hardware.
1033 //-----------------------------------------------------------------------------
1034 void Diffractometer::write_Mode(Tango::WAttribute
&attr
)
1036 DEBUG_STREAM
<< "Diffractometer::write_Mode(Tango::WAttribute &attr) entering... "<< endl
;
1038 attr
.get_write_value(attr_Mode_write
);
1040 _hklAdapter
->write_mode(attr_Mode_write
);
1043 //+----------------------------------------------------------------------------
1045 // method : Diffractometer::read_Crystal
1047 // description : Extract real attribute values for Crystal acquisition result.
1049 //-----------------------------------------------------------------------------
1050 void Diffractometer::read_Crystal(Tango::Attribute
&attr
)
1052 DEBUG_STREAM
<< "Diffractometer::read_Crystal(Tango::Attribute &attr) entering... "<< endl
;
1054 if(*attr_Crystal_read
) delete [] *attr_Crystal_read
;
1057 *attr_Crystal_read
= CORBA::string_dup(_hklAdapter
->get_sample_name());
1059 *attr_Crystal_read
= CORBA::string_dup("");
1060 attr
.set_value(attr_Crystal_read
);
1063 //+----------------------------------------------------------------------------
1065 // method : Diffractometer::write_Crystal
1067 // description : Write Crystal attribute values to hardware.
1069 //-----------------------------------------------------------------------------
1070 void Diffractometer::write_Crystal(Tango::WAttribute
&attr
)
1072 DEBUG_STREAM
<< "Diffractometer::write_Crystal(Tango::WAttribute &attr) entering... "<< endl
;
1074 attr
.get_write_value(attr_Crystal_write
);
1076 _hklAdapter
->set_current_sample(attr_Crystal_write
);
1079 //+----------------------------------------------------------------------------
1081 // method : Diffractometer::read_WaveLength
1083 // description : Extract real attribute values for WaveLength acquisition result.
1085 //-----------------------------------------------------------------------------
1086 void Diffractometer::read_WaveLength(Tango::Attribute
&attr
)
1088 DEBUG_STREAM
<< "Diffractometer::read_WaveLength(Tango::Attribute &attr) entering... "<< endl
;
1091 attr
.set_value(&_hklAdapter
->get_lambda());
1094 //+----------------------------------------------------------------------------
1096 // method : Diffractometer::write_WaveLength
1098 // description : Write WaveLength attribute values to hardware.
1100 //-----------------------------------------------------------------------------
1101 void Diffractometer::write_WaveLength(Tango::WAttribute
&attr
)
1103 DEBUG_STREAM
<< "Diffractometer::write_WaveLength(Tango::WAttribute &attr) entering... "<< endl
;
1105 attr
.get_write_value(attr_WaveLength_write
);
1108 _hklAdapter
->set_lambda(attr_WaveLength_write
);
1109 if (_hklAdapter
->simulated
)
1110 *attr_WaveLength_read
= attr_WaveLength_write
;
1114 //+----------------------------------------------------------------------------
1116 // method : Diffractometer::read_ModeNames
1118 // description : Extract real attribute values for ModeNames acquisition result.
1120 //-----------------------------------------------------------------------------
1121 void Diffractometer::read_ModeNames(Tango::Attribute
&attr
)
1123 DEBUG_STREAM
<< "Diffractometer::read_ModeNames(Tango::Attribute &attr) entering... "<< endl
;
1126 Matrix
<char *> const & img
= _hklAdapter
->get_mode_names();
1127 attr
.set_value(img
.data
, img
.xdim
);
1131 //+----------------------------------------------------------------------------
1133 // method : Diffractometer::read_CrystalNames
1135 // description : Extract real attribute values for CrystalNames acquisition result.
1137 //-----------------------------------------------------------------------------
1138 void Diffractometer::read_CrystalNames(Tango::Attribute
&attr
)
1140 DEBUG_STREAM
<< "Diffractometer::read_CrystalNames(Tango::Attribute &attr) entering... "<< endl
;
1142 std::vector
<std::string
> names
;
1145 names
= _hklAdapter
->get_samples_names();
1147 _crystal_names_dev_varstring_array
<< names
;
1148 attr
.set_value(_crystal_names_dev_varstring_array
.get_buffer(),
1149 _crystal_names_dev_varstring_array
.length());
1152 //+----------------------------------------------------------------------------
1154 // method : Diffractometer::read_CrystalReflections
1156 // description : Extract real attribute values for CrystalReflections acquisition result.
1158 //-----------------------------------------------------------------------------
1159 void Diffractometer::read_CrystalReflections(Tango::Attribute
&attr
)
1161 DEBUG_STREAM
<< "Diffractometer::read_CrystalReflections(Tango::Attribute &attr) entering... "<< endl
;
1164 Matrix
<double> const & img
= _hklAdapter
->get_sample_reflections();
1165 attr
.set_value(img
.data
, img
.xdim
, img
.ydim
);
1169 //+------------------------------------------------------------------
1171 * method: Diffractometer::abort
1173 * description: method to execute "Abort"
1174 * Stops the movement of all axis driven by the Diffractometer
1178 //+------------------------------------------------------------------
1179 void Diffractometer::abort()
1181 DEBUG_STREAM
<< "Diffractometer::abort(): entering... !" << endl
;
1183 // Add your own code to control device here
1186 _hklAdapter
->stop_all_axis();
1188 catch (Tango::DevFailed
& e
)
1194 //+------------------------------------------------------------------
1196 * method: Diffractometer::add_new_crystal
1198 * description: method to execute "AddNewCrystal"
1199 * Create a new crystal
1201 * @param argin Name of the new crystal
1204 //+------------------------------------------------------------------
1205 void Diffractometer::add_new_crystal(Tango::DevString argin
)
1207 DEBUG_STREAM
<< "Diffractometer::add_new_crystal(): entering... !" << endl
;
1209 // Add your own code to control device here
1211 /* POGO rename SampleNew */
1214 _hklAdapter
->add_new_sample(argin
);
1219 //+------------------------------------------------------------------
1221 * method: Diffractometer::add_reflection
1223 * description: method to execute "AddReflection"
1224 * This commands requires the definition of 1 reflection defined by (h,k,l ) coordinates.
1225 * This coodinates are associated with the current angles configuration.
1227 * TODO: d�taill� le commentaire
1228 * reflections i.e : h, k, l, relevance, enable/disable
1230 * @param argin reflections i.e : h, k, l, relevance, enable/disable
1233 //+------------------------------------------------------------------
1234 void Diffractometer::add_reflection(const Tango::DevVarDoubleArray
*argin
)
1236 DEBUG_STREAM
<< "Diffractometer::add_reflection(): entering... !" << endl
;
1238 // Add your own code to control device here
1240 /* POGO rename SampleReflectionAdd */
1242 _hklAdapter
->add_reflection();
1247 //+------------------------------------------------------------------
1249 * method: Diffractometer::affine_crystal
1251 * description: method to execute "AffineCrystal"
1252 * Compute affinement for the current crystal with available list of reflection.
1254 * @param argin name of the crystal to fit
1255 * @return the fitness of the crystal after the affinement.
1258 //+------------------------------------------------------------------
1259 Tango::DevDouble
Diffractometer::affine_crystal(Tango::DevString argin
)
1261 Tango::DevDouble argout
;
1262 DEBUG_STREAM
<< "Diffractometer::affine_crystal(): entering... !" << endl
;
1264 // Add your own code to control device here
1266 /* POGO rename SampleAffinement */
1269 argout
= _hklAdapter
->affine_sample(argin
);
1270 this->refresh_crystal_parameters();
1277 //+------------------------------------------------------------------
1279 * method: Diffractometer::configure_crystal
1281 * description: method to execute "ConfigureCrystal"
1282 * Defines crystal lattice parameters.
1283 * This information is mandatory for angles calculations.
1284 * Angles units are degrees
1286 * @param argin Crystal parameters : alpha,beta,gamma, A,B,C
1289 //+------------------------------------------------------------------
1290 void Diffractometer::configure_crystal(const Tango::DevVarDoubleArray
*argin
)
1292 DEBUG_STREAM
<< "Diffractometer::configure_crystal(): entering... !" << endl
;
1294 // Add your own code to control device here
1296 /* POGO rename SampleConfiguration */
1299 _hklAdapter
->set_lattice(argin
);
1300 this->refresh_crystal_parameters();
1305 //+------------------------------------------------------------------
1307 * method: Diffractometer::copy_current_crystal_as
1309 * description: method to execute "CopyCurrentCrystalAs"
1310 * Copy the current crytal as another name
1315 //+------------------------------------------------------------------
1316 void Diffractometer::copy_current_crystal_as(Tango::DevString argin
)
1318 DEBUG_STREAM
<< "Diffractometer::copy_current_crystal_as(): entering... !" << endl
;
1320 // Add your own code to control device here
1322 /* POGO rename SampleCopy */
1325 _hklAdapter
->copy_sample_as(argin
);
1326 this->refresh_crystal_parameters();
1331 //+------------------------------------------------------------------
1333 * method: Diffractometer::delete_current_crystal
1335 * description: method to execute "DeleteCurrentCrystal"
1336 * Delete the current from this device
1340 //+------------------------------------------------------------------
1341 void Diffractometer::delete_current_crystal()
1343 DEBUG_STREAM
<< "Diffractometer::delete_current_crystal(): entering... !" << endl
;
1345 // Add your own code to control device here
1347 /* POGO rename SampleDelete */
1350 _hklAdapter
->del_sample();
1351 this->refresh_crystal_parameters();
1356 //+------------------------------------------------------------------
1358 * method: Diffractometer::get_affinement_iteration
1360 * description: method to execute "GetAffinementIteration"
1361 * This commands redefine the maximum of iteration for an affinement.
1369 * Iteration value of the last calculation
1371 * @param argin Affinement name
1372 * @return Iteration value of the last calculation
1375 //+------------------------------------------------------------------
1376 Tango::DevLong
Diffractometer::get_affinement_iteration(Tango::DevString argin
)
1378 Tango::DevLong argout
;
1379 DEBUG_STREAM
<< "Diffractometer::get_affinement_iteration(): entering... !" << endl
;
1386 //+------------------------------------------------------------------
1388 * method: Diffractometer::get_affinement_list
1390 * description: method to execute "GetAffinementList"
1391 * This commands returns the list of Affinement names.
1393 * @return List of Affinement names
1396 //+------------------------------------------------------------------
1397 Tango::DevVarStringArray
*Diffractometer::get_affinement_list()
1399 // POGO has generated a method core with argout allocation.
1400 // If you would like to use a static reference without copying,
1401 // See "TANGO Device Server Programmer's Manual"
1402 // (chapter : Writing a TANGO DS / Exchanging data)
1403 //------------------------------------------------------------
1404 Tango::DevVarStringArray
*argout
= new Tango::DevVarStringArray();
1411 //+------------------------------------------------------------------
1413 * method: Diffractometer::get_affinement_max_iteration
1415 * description: method to execute "GetAffinementMaxIteration"
1416 * This commands redefine the maximum of iteration for an affinement.
1424 * Value of the maximum
1426 * @param argin Affinement name
1427 * @return Value of iteration max
1430 //+------------------------------------------------------------------
1431 Tango::DevLong
Diffractometer::get_affinement_max_iteration(Tango::DevString argin
)
1433 Tango::DevLong argout
;
1434 DEBUG_STREAM
<< "Diffractometer::get_affinement_max_iteration(): entering... !" << endl
;
1436 // Add your own code to control device here
1443 //+------------------------------------------------------------------
1445 * method: Diffractometer::get_crystal_names
1447 * description: method to execute "GetCrystalNames"
1448 * Return all crystals names registed into the device
1450 * @return all crystals names registed
1453 //+------------------------------------------------------------------
1454 Tango::DevVarStringArray
*Diffractometer::get_crystal_names()
1456 // POGO has generated a method core with argout allocation.
1457 // If you would like to use a static reference without copying,
1458 // See "TANGO Device Server Programmer's Manual"
1459 // (chapter : Writing a TANGO DS / Exchanging data)
1460 //------------------------------------------------------------
1461 Tango::DevVarStringArray
*argout
= new Tango::DevVarStringArray();
1463 (*argout
)[0] = CORBA::string_dup("dummy");
1464 DEBUG_STREAM
<< "Diffractometer::get_crystal_names(): entering... !" << endl
;
1466 /* POGO TO DELETE */
1468 *argout
<< _hklAdapter
->get_samples_names();
1473 //+------------------------------------------------------------------
1475 * method: Diffractometer::get_mode_description
1477 * description: method to execute "GetModeDescription"
1480 * @return description
1483 //+------------------------------------------------------------------
1484 Tango::DevString
Diffractometer::get_mode_description(Tango::DevString argin
)
1486 // POGO has generated a method core with argout allocation.
1487 // If you would like to use a static reference without copying,
1488 // See "TANGO Device Server Programmer's Manual"
1489 // (chapter : Writing a TANGO DS / Exchanging data)
1490 //------------------------------------------------------------
1491 Tango::DevString argout
= NULL
;
1492 DEBUG_STREAM
<< "Diffractometer::get_mode_description(): entering... !" << endl
;
1494 // Add your own code to control device here
1496 /* POGO TO DELETE */
1497 argout
= CORBA::string_dup("toto");
1502 //+------------------------------------------------------------------
1504 * method: Diffractometer::get_mode_parameters_names
1506 * description: method to execute "GetModeParametersNames"
1508 * @return Parameters names of the current mode
1511 //+------------------------------------------------------------------
1512 Tango::DevVarStringArray
*Diffractometer::get_mode_parameters_names()
1514 // POGO has generated a method core with argout allocation.
1515 // If you would like to use a static reference without copying,
1516 // See "TANGO Device Server Programmer's Manual"
1517 // (chapter : Writing a TANGO DS / Exchanging data)
1518 //------------------------------------------------------------
1519 Tango::DevVarStringArray
*argout
= new Tango::DevVarStringArray();
1520 DEBUG_STREAM
<< "Diffractometer::get_mode_parameters_names(): entering... !" << endl
;
1522 // Add your own code to control device here
1524 /* POGO TO DELETE */
1527 Matrix
<char *> & img
= _hklAdapter
->get_mode_parameters_names();
1528 argout
->length(img
.xdim
);
1529 for(i
=0; i
<img
.xdim
; ++i
)
1530 (*argout
)[i
] = CORBA::string_dup(img
.data
[i
]);
1536 //+------------------------------------------------------------------
1538 * method: Diffractometer::get_mode_parameters_values
1540 * description: method to execute "GetModeParametersValues"
1541 * Double : values of parameters
1543 * @return String : Names of parameters ; Double : values of parameters
1546 //+------------------------------------------------------------------
1547 Tango::DevVarDoubleStringArray
*Diffractometer::get_mode_parameters_values()
1549 // POGO has generated a method core with argout allocation.
1550 // If you would like to use a static reference without copying,
1551 // See "TANGO Device Server Programmer's Manual"
1552 // (chapter : Writing a TANGO DS / Exchanging data)
1553 //------------------------------------------------------------
1554 Tango::DevVarDoubleStringArray
*argout
= new Tango::DevVarDoubleStringArray();
1555 DEBUG_STREAM
<< "Diffractometer::get_mode_parameters_values(): entering... !" << endl
;
1557 // Add your own code to control device here
1559 /* POGO TO DELETE */
1561 _hklAdapter
->get_mode_parameters_values(argout
);
1566 //+------------------------------------------------------------------
1568 * method: Diffractometer::get_mode_parameter_value
1570 * description: method to execute "GetModeParameterValue"
1572 * @param argin name of parameter
1573 * @return value of this parameter
1576 //+------------------------------------------------------------------
1577 Tango::DevDouble
Diffractometer::get_mode_parameter_value(Tango::DevString argin
)
1579 Tango::DevDouble argout
;
1580 DEBUG_STREAM
<< "Diffractometer::get_mode_parameter_value(): entering... !" << endl
;
1582 // Add your own code to control device here
1584 /* POGO TO DELETE */
1589 //+------------------------------------------------------------------
1591 * method: Diffractometer::get_reflection
1593 * description: method to execute "GetReflection"
1595 * @param argin index of reflection
1596 * @return H, K, L, Relevance, Affinement Enabled
1599 //+------------------------------------------------------------------
1600 Tango::DevVarDoubleArray
*Diffractometer::get_reflection(Tango::DevShort argin
)
1602 // POGO has generated a method core with argout allocation.
1603 // If you would like to use a static reference without copying,
1604 // See "TANGO Device Server Programmer's Manual"
1605 // (chapter : Writing a TANGO DS / Exchanging data)
1606 //------------------------------------------------------------
1607 Tango::DevVarDoubleArray
*argout
= new Tango::DevVarDoubleArray();
1608 DEBUG_STREAM
<< "Diffractometer::get_reflection(): entering... !" << endl
;
1610 // Add your own code to control device here
1612 /* POGO replace by a Reflections attribut read/write */
1614 _hklAdapter
->get_sample_reflection(argin
, argout
);
1619 //+------------------------------------------------------------------
1621 * method: Diffractometer::get_reflection_size
1623 * description: method to execute "GetReflectionSize"
1624 * Return the number of reflection of the current crystal
1626 * @return Number of reflection in current crytal
1629 //+------------------------------------------------------------------
1630 Tango::DevUShort
Diffractometer::get_reflection_size()
1632 Tango::DevUShort argout
;
1633 DEBUG_STREAM
<< "Diffractometer::get_reflection_size(): entering... !" << endl
;
1635 // Add your own code to control device here
1637 /* POGO TO DELETE */
1639 argout
= _hklAdapter
->get_sample_reflections().ydim
;
1644 //+------------------------------------------------------------------
1646 * method: Diffractometer::goto_reflection
1648 * description: method to execute "GotoReflection"
1649 * Go to axis values of the given reflection
1651 * @param argin reflection number
1654 //+------------------------------------------------------------------
1655 void Diffractometer::goto_reflection(Tango::DevShort argin
)
1657 DEBUG_STREAM
<< "Diffractometer::goto_reflection(): entering... !" << endl
;
1659 // Add your own code to control device here
1661 /* POGO replace by a SampleReflectionAxisGoTo */
1664 //+------------------------------------------------------------------
1666 * method: Diffractometer::load
1668 * description: method to execute "Load"
1673 //+------------------------------------------------------------------
1674 void Diffractometer::load()
1676 DEBUG_STREAM
<< "Diffractometer::load(): entering... !" << endl
;
1678 // Add your own code to control device here
1682 _hklAdapter
->load();
1685 //+------------------------------------------------------------------
1687 * method: Diffractometer::remove_reflection
1689 * description: method to execute "RemoveReflection"
1690 * This commands removes reflection from the current cristal.
1692 * @param argin index of reflection to remove
1695 //+------------------------------------------------------------------
1696 void Diffractometer::remove_reflection(Tango::DevShort argin
)
1698 DEBUG_STREAM
<< "Diffractometer::remove_reflection(): entering... !" << endl
;
1700 // Add your own code to control device here
1702 /* POGO rename SampleReflectionDelete */
1704 _hklAdapter
->del_reflection(argin
);
1705 this->refresh_crystal_parameters();
1710 //+------------------------------------------------------------------
1712 * method: Diffractometer::save
1714 * description: method to execute "Save"
1719 //+------------------------------------------------------------------
1720 void Diffractometer::save()
1722 DEBUG_STREAM
<< "Diffractometer::save(): entering... !" << endl
;
1724 // Add your own code to control device here
1728 _hklAdapter
->save();
1731 //+------------------------------------------------------------------
1733 * method: Diffractometer::set_affinement_max_iteration
1735 * description: method to execute "SetAffinementMaxIteration"
1736 * This commands redefine the maximum of iteration for an affinement.
1737 * index = index of reflection
1741 * relevance = relevance value of this reflection
1742 * affinement enabled = if true this reflection is associated with Affinement calculation
1744 * @param argin Affinement name, Value of iteration max
1747 //+------------------------------------------------------------------
1748 void Diffractometer::set_affinement_max_iteration(const Tango::DevVarStringArray
*argin
)
1750 DEBUG_STREAM
<< "Diffractometer::set_affinement_max_iteration(): entering... !" << endl
;
1752 // Add your own code to control device here
1754 /* POGO TO DELETE */
1757 //+------------------------------------------------------------------
1759 * method: Diffractometer::set_crystal_parameter_values
1761 * description: method to execute "SetCrystalParameterValues"
1762 * Double : min value, max value, affinement enable
1764 * @param argin String : Name of parameter ; Double : min value, max value, affinement enable
1767 //+------------------------------------------------------------------
1768 void Diffractometer::set_crystal_parameter_values(const Tango::DevVarDoubleStringArray
*argin
)
1770 DEBUG_STREAM
<< "Diffractometer::set_crystal_parameter_values(): entering... !" << endl
;
1772 // Add your own code to control device here
1776 _hklAdapter
->set_sample_parameter_values(argin
);
1779 //+------------------------------------------------------------------
1781 * method: Diffractometer::set_hkl
1783 * description: method to execute "SetHKL"
1784 * This command will set the triplet (h,k,l
1786 * @param argin h,k,l values
1789 //+------------------------------------------------------------------
1790 void Diffractometer::set_hkl(const Tango::DevVarDoubleArray
*argin
)
1792 DEBUG_STREAM
<< "Diffractometer::set_hkl(): entering... !" << endl
;
1794 // Add your own code to control device here
1796 if(argin
->length() != 3)
1797 TANGO_EXCEPTION_THROW("DATA_OUT_OF_RANGE", "set_hkl did not receive the exact amount of parameters: h, k, l");
1799 // try to set up hkl.
1800 this->compute_angles((*argin
)[0], (*argin
)[1], (*argin
)[2]);
1803 //+------------------------------------------------------------------
1805 * method: Diffractometer::set_mode_parameters_values
1807 * description: method to execute "SetModeParametersValues"
1808 * Double : value of parameter
1810 * @param argin String : name of parameter ; Double : value of parameter
1813 //+------------------------------------------------------------------
1814 void Diffractometer::set_mode_parameters_values(const Tango::DevVarDoubleStringArray
*argin
)
1816 DEBUG_STREAM
<< "Diffractometer::set_mode_parameters_values(): entering... !" << endl
;
1818 // Add your own code to control device here
1820 // Check if argin is like (key,value)
1822 _hklAdapter
->set_mode_parameters_values(argin
);
1825 //+------------------------------------------------------------------
1827 * method: Diffractometer::set_reflection
1829 * description: method to execute "SetReflection"
1830 * This commands redefine the parameters of 1 reflection of the current cristal.
1831 * index = index of reflection
1835 * relevance = relevance value of this reflection
1836 * affinement enabled = if true this reflection is associated with Affinement calculation
1838 * @param argin reflections i.e : index, h, k, l, relevance, affinement enabled
1841 //+------------------------------------------------------------------
1842 void Diffractometer::set_reflection(const Tango::DevVarDoubleArray
*argin
)
1844 DEBUG_STREAM
<< "Diffractometer::set_reflection(): entering... !" << endl
;
1846 // Add your own code to control device here
1848 /* POGO TO DELETE */
1850 _hklAdapter
->set_sample_reflection(argin
);
1853 //+------------------------------------------------------------------
1855 * method: Diffractometer::copy_reflection_to
1857 * description: method to execute "CopyReflectionTo"
1858 * Copy one reflection from the current crystal to another crystal
1860 * @param argin Double: Reflection number of the current crystal String : Name of the crystal where copy this reflection
1863 //+------------------------------------------------------------------
1864 void Diffractometer::copy_reflection_to(const Tango::DevVarDoubleStringArray
*argin
)
1866 DEBUG_STREAM
<< "Diffractometer::copy_reflection_to(): entering... !" << endl
;
1868 // Add your own code to control device here
1870 /* POGO TO DELETE */
1873 //+------------------------------------------------------------------
1875 * method: Diffractometer::dev_state
1877 * description: method to execute "State"
1878 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
1880 * @return State Code
1883 //+------------------------------------------------------------------
1884 Tango::DevState
Diffractometer::dev_state()
1886 Tango::DevState argout
= DeviceImpl::dev_state();
1887 DEBUG_STREAM
<< "Diffractometer::dev_state(): entering... !" << endl
;
1889 // Add your own code to control device here
1891 argout
= _config
.state
;
1892 this->set_state(argout
);
1897 //+------------------------------------------------------------------
1899 * method: Diffractometer::get_crystal_parameter_values
1901 * description: method to execute "GetCrystalParameterValues"
1902 * Return all values of a parameter for the current crystal
1904 * @param argin Name of parameter (see getParametersNames for the complete list of parameters)
1905 * @return In the order : minimum value, maximum value, affinement enable
1908 //+------------------------------------------------------------------
1909 Tango::DevVarDoubleStringArray
*Diffractometer::get_crystal_parameter_values(Tango::DevString argin
)
1911 // POGO has generated a method core with argout allocation.
1912 // If you would like to use a static reference without copying,
1913 // See "TANGO Device Server Programmer's Manual"
1914 // (chapter : Writing a TANGO DS / Exchanging data)
1915 //------------------------------------------------------------
1916 Tango::DevVarDoubleStringArray
*argout
= new Tango::DevVarDoubleStringArray();
1917 argout
->dvalue
.length(3);
1918 argout
->dvalue
[0] = 0.0;
1919 argout
->dvalue
[1] = 0.0;
1920 argout
->dvalue
[2] = 0.0;
1921 argout
->svalue
.length(1);
1922 argout
->svalue
[0] = CORBA::string_dup(argin
);
1923 DEBUG_STREAM
<< "Diffractometer::get_crystal_parameter_values(): entering... !" << endl
;
1925 // Add your own code to control device here
1927 _hklAdapter
->get_sample_parameter_values(argout
);
1932 //+------------------------------------------------------------------
1934 * method: Diffractometer::compute_u
1936 * description: method to execute "ComputeU"
1937 * Compute Matrix U from two reflections
1939 * @param argin a two elements array with the index of reflection to use
1942 //+------------------------------------------------------------------
1943 void Diffractometer::compute_u(const Tango::DevVarLongArray
*argin
)
1945 DEBUG_STREAM
<< "Diffractometer::compute_u(): entering... !" << endl
;
1947 // Add your own code to control device here
1949 _hklAdapter
->compute_u(argin
);
1954 //+------------------------------------------------------------------
1956 * method: Diffractometer::get_axes_names
1958 * description: method to execute "GetAxesNames"
1959 * this method return the names of the dynamic attributes created from the hkl axes names
1960 * kappa -> AxisKappa etc...
1962 * @return namers of the axes
1965 //+------------------------------------------------------------------
1966 Tango::DevVarStringArray
*Diffractometer::get_axes_names()
1968 // POGO has generated a method core with argout allocation.
1969 // If you would like to use a static reference without copying,
1970 // See "TANGO Device Server Programmer's Manual"
1971 // (chapter : Writing a TANGO DS / Exchanging data)
1972 //------------------------------------------------------------
1973 Tango::DevVarStringArray
*argout
= new Tango::DevVarStringArray();
1974 DEBUG_STREAM
<< "Diffractometer::get_axes_names(): entering... !" << endl
;
1979 Matrix
<char *> const & img
= _hklAdapter
->get_dynamic_attribute_axes_names();
1980 argout
->length(img
.xdim
);
1981 for(i
=0; i
<img
.xdim
; ++i
)
1982 (*argout
)[i
] = CORBA::string_dup(img
.data
[i
]);
1987 //+------------------------------------------------------------------
1989 * method: Diffractometer::computed_angles_clear
1991 * description: method to execute "ComputedAnglesClear"
1992 * Clears the attribute ComputedAngles.
1993 * Useful to get a fresh view of calculations already made
1997 //+------------------------------------------------------------------
1998 void Diffractometer::computed_angles_clear()
2000 DEBUG_STREAM
<< "Diffractometer::computed_angles_clear(): entering... !" << endl
;
2002 // Add your own code to control device here
2004 /* POGO TO DELETE */
2005 _computedAngles_size
= 0;
2006 if(attr_ComputedAngles_read
) {
2007 delete [] attr_ComputedAngles_read
;
2008 attr_ComputedAngles_read
= NULL
;
2013 //+------------------------------------------------------------------
2015 * method: Diffractometer::computed_angles_hkllist
2017 * description: method to execute "ComputedAnglesHKLList"
2018 * this commande works only in simulated mode.
2019 * It computhe [-hmax: hmax] etc.. angles computations.
2021 * @param argin hmax, kmax, lmax
2024 //+------------------------------------------------------------------
2025 void Diffractometer::computed_angles_hkllist(const Tango::DevVarDoubleArray
*argin
)
2027 DEBUG_STREAM
<< "Diffractometer::computed_angles_hkllist(): entering... !" << endl
;
2029 // Add your own code to control device here
2031 if((argin
->length() != 3) && (argin
->length() != 6))
2032 TANGO_EXCEPTION_THROW("DATA_OUT_OF_RANGE", "computed_angles_hkllist did not receive the exact amount of parameters: hmax, kmax, lmax");
2034 // Parameters are OK
2035 if (!_hklAdapter
->simulated
)
2039 double hmax
= fabs((*argin
)[0]);
2040 double kmax
= fabs((*argin
)[1]);
2041 double lmax
= fabs((*argin
)[2]);
2043 if (argin
->length() == 6) {
2044 dh
= fabs((*argin
)[3]);
2045 dk
= fabs((*argin
)[4]);
2046 dl
= fabs((*argin
)[5]);
2056 this->compute_angles(h
, k
, l
);
2069 //+------------------------------------------------------------------
2071 * method: Diffractometer::goto_computed_angles
2073 * description: method to execute "GotoComputedAngles"
2075 * @param argin the idx of the computed angles
2078 //+------------------------------------------------------------------
2079 void Diffractometer::goto_computed_angles(Tango::DevShort argin
)
2081 DEBUG_STREAM
<< "Diffractometer::goto_computed_angles(): entering... !" << endl
;
2083 // Add your own code to control device here
2087 //+------------------------------------------------------------------
2089 * method: Diffractometer::dev_status
2091 * description: method to execute "Status"
2092 * This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
2094 * @return Status description
2097 //+------------------------------------------------------------------
2098 Tango::ConstDevString
Diffractometer::dev_status()
2100 Tango::ConstDevString argout
= DeviceImpl::dev_status();
2101 DEBUG_STREAM
<< "Diffractometer::dev_status(): entering... !" << endl
;
2103 // Add your own code to control device here
2104 this->set_status(_config
.status
);
2105 return _config
.status
.c_str();