Merge branch 'maint' into next
[diffractometer.git] / src / Diffractometer / Diffractometer.cpp
blobd88e44810c265f8fd433689ce1e110978ea1ff8f
1 static const char *RcsId = "$Header: /cvsroot/tango-ds/Instrumentation/Diffractometer/src/Diffractometer.cpp,v 1.5 2008/11/28 15:46:32 piccaf Exp $";
2 //+=============================================================================
3 //
4 // file : Diffractometer.cpp
5 //
6 // description : C++ source for the Diffractometer and its commands.
7 // The class is derived from Device. It represents the
8 // CORBA servant object which will be accessed from the
9 // network. All commands which can be executed on the
10 // Diffractometer are implemented in this file.
12 // project : TANGO Device Server
14 // $Author: piccaf $
16 // $Revision: 1.5 $
18 // $Log: Diffractometer.cpp,v $
19 // Revision 1.5 2008/11/28 15:46:32 piccaf
20 // * close # mantis: 11051
22 // Revision 1.4 2008/10/16 10:16:55 piccaf
23 // * update to build on windows with vc8
24 // * add the Eulerian6C diffractometer.
25 // * add the dynamic attributes in the factory instead of the init device
27 // Revision 1.3 2008/09/22 16:20:35 vince_soleil
28 // Set first character of attribute name in minus
30 // Revision 1.2 2008/09/22 08:46:23 piccaf
31 // * add files from the new diffractometer Device
34 // copyleft : European Synchrotron Radiation Facility
35 // BP 220, Grenoble 38043
36 // FRANCE
38 //-=============================================================================
40 // This file is generated by POGO
41 // (Program Obviously used to Generate tango Object)
43 // (c) - Software Engineering Group - ESRF
44 //=============================================================================
48 //===================================================================
50 // The following table gives the correspondence
51 // between commands and method name.
53 // Command name | Method name
54 // ----------------------------------------
55 // State | dev_state()
56 // Status | dev_status()
57 // Abort | abort()
58 // AddNewCrystal | add_new_crystal()
59 // AddReflection | add_reflection()
60 // AffineCrystal | affine_crystal()
61 // 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()
67 // Load | load()
68 // RemoveReflection | remove_reflection()
69 // Save | save()
70 // SetCrystalParameterValues | set_crystal_parameter_values()
72 //===================================================================
75 #include <tango.h>
76 #include <Diffractometer.h>
77 #include <DiffractometerClass.h>
79 #include <time.h>
80 #include <sstream>
81 #include <algorithm>
82 #include <cctype>
83 #include <string>
85 #include "macros.h"
86 #include "AxisAttrib.h"
87 #include "TangoHKLAdapterFactory.h"
89 namespace Diffractometer_ns
92 //+----------------------------------------------------------------------------
94 // method : Diffractometer::Diffractometer(string &s)
95 //
96 // description : constructor for simulated Diffractometer
98 // in : - cl : Pointer to the DeviceClass object
99 // - s : Device name
101 //-----------------------------------------------------------------------------
102 Diffractometer::Diffractometer(Tango::DeviceClass *cl,string &s)
103 :Tango::Device_4Impl(cl,s.c_str())
105 init_device();
108 Diffractometer::Diffractometer(Tango::DeviceClass *cl,const char *s)
109 :Tango::Device_4Impl(cl,s)
111 init_device();
114 Diffractometer::Diffractometer(Tango::DeviceClass *cl,const char *s,const char *d)
115 :Tango::Device_4Impl(cl,s,d)
117 init_device();
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
129 this->save();
131 // Delete device's allocated object
132 DELETE_SCALAR_ATTRIBUTE(attr_AnglesIdx_read);
133 DELETE_SCALAR_ATTRIBUTE(attr_WaveLength_read);
134 DELETE_SCALAR_ATTRIBUTE(attr_AutoUpdateFromProxies_read);
135 DELETE_SCALAR_ATTRIBUTE(attr_Simulated_read);
136 DELETE_SCALAR_ATTRIBUTE(attr_A_read);
137 DELETE_SCALAR_ATTRIBUTE(attr_B_read);
138 DELETE_SCALAR_ATTRIBUTE(attr_C_read);
139 DELETE_SCALAR_ATTRIBUTE(attr_Alpha_read);
140 DELETE_SCALAR_ATTRIBUTE(attr_Beta_read);
141 DELETE_SCALAR_ATTRIBUTE(attr_Gamma_read);
142 DELETE_SCALAR_ATTRIBUTE(attr_Ux_read);
143 DELETE_SCALAR_ATTRIBUTE(attr_Uy_read);
144 DELETE_SCALAR_ATTRIBUTE(attr_Uz_read);
145 DELETE_SCALAR_ATTRIBUTE(attr_AStar_read);
146 DELETE_SCALAR_ATTRIBUTE(attr_BStar_read);
147 DELETE_SCALAR_ATTRIBUTE(attr_CStar_read);
148 DELETE_SCALAR_ATTRIBUTE(attr_AlphaStar_read);
149 DELETE_SCALAR_ATTRIBUTE(attr_BetaStar_read);
150 DELETE_SCALAR_ATTRIBUTE(attr_GammaStar_read);
151 DELETE_SCALAR_ATTRIBUTE(attr_AFit_read);
152 DELETE_SCALAR_ATTRIBUTE(attr_BFit_read);
153 DELETE_SCALAR_ATTRIBUTE(attr_CFit_read);
154 DELETE_SCALAR_ATTRIBUTE(attr_AlphaFit_read);
155 DELETE_SCALAR_ATTRIBUTE(attr_BetaFit_read);
156 DELETE_SCALAR_ATTRIBUTE(attr_GammaFit_read);
157 DELETE_SCALAR_ATTRIBUTE(attr_UxFit_read);
158 DELETE_SCALAR_ATTRIBUTE(attr_UyFit_read);
159 DELETE_SCALAR_ATTRIBUTE(attr_UzFit_read);
161 DELETE_DEVSTRING_ATTRIBUTE(attr_Crystal_read);
163 if(attr_UB_read) {
164 delete[] attr_UB_read;
165 attr_UB_read = NULL;
168 if(attr_Angles_read) {
169 delete[] attr_Angles_read;
170 attr_Angles_read = NULL;
173 if(attr_ReflectionsAngles_read) {
174 delete [] attr_ReflectionsAngles_read;
175 attr_ReflectionsAngles_read = NULL;
178 if(attr_Reflections_read){
179 delete[] attr_Reflections_read;
180 attr_Reflections_read = NULL;
183 this->remove_dynamic_attributes();
186 * Do not remove the diffractometer in the delete method
187 * of the Derived classes to avoid a segmentation fault
188 * during the save method call. Indeed the Derived class delete
189 * method is called before this delete method.
191 TangoHKLAdapterFactory::instance()->detach_diffractometer_device(this);
194 //+----------------------------------------------------------------------------
196 // method : Diffractometer::init_device()
198 // description : will be called at device initialization.
200 //-----------------------------------------------------------------------------
201 void Diffractometer::init_device()
203 INFO_STREAM << "Diffractometer::Diffractometer() create device " << device_name << endl;
205 // Initialise variables to default values
206 //--------------------------------------------
207 get_device_property();
209 CREATE_SCALAR_ATTRIBUTE(attr_AnglesIdx_read, (short)-1);
210 CREATE_SCALAR_ATTRIBUTE(attr_WaveLength_read, 0.0);
211 CREATE_SCALAR_ATTRIBUTE(attr_AutoUpdateFromProxies_read, false);
212 CREATE_SCALAR_ATTRIBUTE(attr_Simulated_read, true);
213 CREATE_SCALAR_ATTRIBUTE(attr_A_read, 0.0);
214 CREATE_SCALAR_ATTRIBUTE(attr_B_read, 0.0);
215 CREATE_SCALAR_ATTRIBUTE(attr_C_read, 0.0);
216 CREATE_SCALAR_ATTRIBUTE(attr_Alpha_read, 0.0);
217 CREATE_SCALAR_ATTRIBUTE(attr_Beta_read, 0.0);
218 CREATE_SCALAR_ATTRIBUTE(attr_Gamma_read, 0.0);
219 CREATE_SCALAR_ATTRIBUTE(attr_Ux_read, 0.0);
220 CREATE_SCALAR_ATTRIBUTE(attr_Uy_read, 0.0);
221 CREATE_SCALAR_ATTRIBUTE(attr_Uz_read, 0.0);
222 CREATE_SCALAR_ATTRIBUTE(attr_AStar_read);
223 CREATE_SCALAR_ATTRIBUTE(attr_BStar_read);
224 CREATE_SCALAR_ATTRIBUTE(attr_CStar_read);
225 CREATE_SCALAR_ATTRIBUTE(attr_AlphaStar_read);
226 CREATE_SCALAR_ATTRIBUTE(attr_BetaStar_read);
227 CREATE_SCALAR_ATTRIBUTE(attr_GammaStar_read);
228 CREATE_SCALAR_ATTRIBUTE(attr_AFit_read, false);
229 CREATE_SCALAR_ATTRIBUTE(attr_BFit_read, false);
230 CREATE_SCALAR_ATTRIBUTE(attr_CFit_read, false);
231 CREATE_SCALAR_ATTRIBUTE(attr_AlphaFit_read, false);
232 CREATE_SCALAR_ATTRIBUTE(attr_BetaFit_read, false);
233 CREATE_SCALAR_ATTRIBUTE(attr_GammaFit_read, false);
234 CREATE_SCALAR_ATTRIBUTE(attr_UxFit_read, false);
235 CREATE_SCALAR_ATTRIBUTE(attr_UyFit_read, false);
236 CREATE_SCALAR_ATTRIBUTE(attr_UzFit_read, false);
238 CREATE_DEVSTRING_ATTRIBUTE(attr_Crystal_read, 1, "");
240 attr_UB_read = NULL;
241 attr_Angles_read = NULL;
242 attr_ReflectionsAngles_read = NULL;
243 attr_Reflections_read = NULL;
244 attr_AxesNames_read = NULL;
246 // Device is in FAULT state because it was not yet configured.
247 _config.state = Tango::FAULT;
248 _config.status = "Configure Diffractometer: crystal, wavelength, etc...)";
250 if (this->get_type_from_property(diffractometerType, _type)){
251 _config.status = "The DiffractometerType property is not well defined \n"
252 "Please select one of the next values : "
253 AVAILABLE_DIFFRACTOMETER_TYPE;
254 }else{
256 * this method must be call after get_device_property() as
257 * TangoHKLAdapter create the axisbuffer from the
258 * realAxisProxies.
260 _hklAdapter = TangoHKLAdapterFactory::instance()->attach_diffractometer_device(this, _type);
261 if (!_hklAdapter) {
262 this->set_state(Tango::FAULT);
263 this->set_status("Fatal can not initialize the hkl library");
264 TANGO_EXCEPTION_THROW("Internal Fatal Error", "Device can't get an instance of TangoHKLAdapter");
265 } else {
266 // Restore the Diffractometer state from the last run.
267 this->load();
269 this->create_dynamic_attributes();
271 _hklAdapter->connect_all_proxies();
273 // create an start all the PseudoAxes devices.
274 _hklAdapter->pseudo_axes_create_and_start_devices();
280 //+----------------------------------------------------------------------------
282 // method : Diffractometer::get_device_property()
284 // description : Read the device properties from database.
286 //-----------------------------------------------------------------------------
287 void Diffractometer::get_device_property()
289 // Initialize your default values here (if not done with POGO).
290 //------------------------------------------------------------------
292 // Read device properties from database.(Automatic code generation)
293 //------------------------------------------------------------------
294 Tango::DbData dev_prop;
295 dev_prop.push_back(Tango::DbDatum("TauConstant"));
296 dev_prop.push_back(Tango::DbDatum("RealAxisProxies"));
297 dev_prop.push_back(Tango::DbDatum("LambdaAttributeProxy"));
298 dev_prop.push_back(Tango::DbDatum("DiffractometerType"));
299 dev_prop.push_back(Tango::DbDatum("ProtectReflectionAxes"));
301 // Call database and extract values
302 //--------------------------------------------
303 if (Tango::Util::instance()->_UseDb==true)
304 get_db_device()->get_property(dev_prop);
305 Tango::DbDatum def_prop, cl_prop;
306 DiffractometerClass *ds_class =
307 (static_cast<DiffractometerClass *>(get_device_class()));
308 int i = -1;
310 // Try to initialize TauConstant from class property
311 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
312 if (cl_prop.is_empty()==false) cl_prop >> tauConstant;
313 else {
314 // Try to initialize TauConstant from default device value
315 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
316 if (def_prop.is_empty()==false) def_prop >> tauConstant;
318 // And try to extract TauConstant value from database
319 if (dev_prop[i].is_empty()==false) dev_prop[i] >> tauConstant;
321 // Try to initialize RealAxisProxies from class property
322 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
323 if (cl_prop.is_empty()==false) cl_prop >> realAxisProxies;
324 else {
325 // Try to initialize RealAxisProxies from default device value
326 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
327 if (def_prop.is_empty()==false) def_prop >> realAxisProxies;
329 // And try to extract RealAxisProxies value from database
330 if (dev_prop[i].is_empty()==false) dev_prop[i] >> realAxisProxies;
332 // Try to initialize LambdaAttributeProxy from class property
333 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
334 if (cl_prop.is_empty()==false) cl_prop >> lambdaAttributeProxy;
335 else {
336 // Try to initialize LambdaAttributeProxy from default device value
337 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
338 if (def_prop.is_empty()==false) def_prop >> lambdaAttributeProxy;
340 // And try to extract LambdaAttributeProxy value from database
341 if (dev_prop[i].is_empty()==false) dev_prop[i] >> lambdaAttributeProxy;
343 // Try to initialize DiffractometerType from class property
344 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
345 if (cl_prop.is_empty()==false) cl_prop >> diffractometerType;
346 else {
347 // Try to initialize DiffractometerType from default device value
348 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
349 if (def_prop.is_empty()==false) def_prop >> diffractometerType;
351 // And try to extract DiffractometerType value from database
352 if (dev_prop[i].is_empty()==false) dev_prop[i] >> diffractometerType;
354 // Try to initialize ProtectReflectionAxes from class property
355 cl_prop = ds_class->get_class_property(dev_prop[++i].name);
356 if (cl_prop.is_empty()==false) cl_prop >> protectReflectionAxes;
357 else {
358 // Try to initialize ProtectReflectionAxes from default device value
359 def_prop = ds_class->get_default_device_property(dev_prop[i].name);
360 if (def_prop.is_empty()==false) def_prop >> protectReflectionAxes;
362 // And try to extract ProtectReflectionAxes value from database
363 if (dev_prop[i].is_empty()==false) dev_prop[i] >> protectReflectionAxes;
367 // End of Automatic code generation
368 //------------------------------------------------------------------
371 //+----------------------------------------------------------------------------
373 // method : Diffractometer::always_executed_hook()
375 // description : method always executed before any command is executed
377 //-----------------------------------------------------------------------------
378 void Diffractometer::always_executed_hook()
380 if (_hklAdapter)
381 _hklAdapter->connect_all_proxies();
383 //+----------------------------------------------------------------------------
385 // method : Diffractometer::read_attr_hardware
387 // description : Hardware acquisition for attributes.
389 //-----------------------------------------------------------------------------
390 void Diffractometer::read_attr_hardware(vector<long> &attr_list)
392 DEBUG_STREAM << "Diffractometer::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
393 // Add your own code here
394 if (!_hklAdapter)
395 return;
397 _hklAdapter->update();
398 _hklAdapter->get_diffractometer_config(_config);
399 _hklAdapter->get_sample_lattices(attr_A_read, attr_B_read, attr_C_read,
400 attr_Alpha_read, attr_Beta_read, attr_Gamma_read,
401 attr_AStar_read, attr_BStar_read, attr_CStar_read,
402 attr_AlphaStar_read, attr_BetaStar_read, attr_GammaStar_read);
403 _hklAdapter->get_sample_fit(attr_AFit_read, attr_BFit_read, attr_CFit_read,
404 attr_AlphaFit_read, attr_BetaFit_read, attr_GammaFit_read,
405 attr_UxFit_read, attr_UyFit_read, attr_UzFit_read);
407 //+----------------------------------------------------------------------------
409 // method : Diffractometer::read_AutoUpdateFromProxies
411 // description : Extract real attribute values for AutoUpdateFromProxies acquisition result.
413 //-----------------------------------------------------------------------------
414 void Diffractometer::read_AutoUpdateFromProxies(Tango::Attribute &attr)
416 DEBUG_STREAM << "Diffractometer::read_AutoUpdateFromProxies(Tango::Attribute &attr) entering... "<< endl;
418 if(_hklAdapter)
419 *attr_AutoUpdateFromProxies_read = _hklAdapter->get_auto_update_from_proxies();
420 attr.set_value(attr_AutoUpdateFromProxies_read);
423 //+----------------------------------------------------------------------------
425 // method : Diffractometer::write_AutoUpdateFromProxies
427 // description : Write AutoUpdateFromProxies attribute values to hardware.
429 //-----------------------------------------------------------------------------
430 void Diffractometer::write_AutoUpdateFromProxies(Tango::WAttribute &attr)
432 DEBUG_STREAM << "Diffractometer::write_AutoUpdateFromProxies(Tango::WAttribute &attr) entering... "<< endl;
434 attr.get_write_value(attr_AutoUpdateFromProxies_write);
436 if (_hklAdapter)
437 _hklAdapter->set_auto_update_from_proxies(attr_AutoUpdateFromProxies_write);
440 //+----------------------------------------------------------------------------
442 // method : Diffractometer::read_AFit
444 // description : Extract real attribute values for AFit acquisition result.
446 //-----------------------------------------------------------------------------
447 void Diffractometer::read_AFit(Tango::Attribute &attr)
449 DEBUG_STREAM << "Diffractometer::read_AFit(Tango::Attribute &attr) entering... "<< endl;
450 attr.set_value(attr_AFit_read);
453 //+----------------------------------------------------------------------------
455 // method : Diffractometer::write_AFit
457 // description : Write AFit attribute values to hardware.
459 //-----------------------------------------------------------------------------
460 void Diffractometer::write_AFit(Tango::WAttribute &attr)
462 DEBUG_STREAM << "Diffractometer::write_AFit(Tango::WAttribute &attr) entering... "<< endl;
463 bool fit;
465 attr.get_write_value(fit);
466 if (_hklAdapter){
467 _hklAdapter->set_sample_AFit(fit);
468 this->save();
469 attr_AFit_write = fit;
473 //+----------------------------------------------------------------------------
475 // method : Diffractometer::read_BFit
477 // description : Extract real attribute values for BFit acquisition result.
479 //-----------------------------------------------------------------------------
480 void Diffractometer::read_BFit(Tango::Attribute &attr)
482 DEBUG_STREAM << "Diffractometer::read_BFit(Tango::Attribute &attr) entering... "<< endl;
483 attr.set_value(attr_BFit_read);
486 //+----------------------------------------------------------------------------
488 // method : Diffractometer::write_BFit
490 // description : Write BFit attribute values to hardware.
492 //-----------------------------------------------------------------------------
493 void Diffractometer::write_BFit(Tango::WAttribute &attr)
495 DEBUG_STREAM << "Diffractometer::write_BFit(Tango::WAttribute &attr) entering... "<< endl;
496 bool fit;
498 attr.get_write_value(fit);
499 if (_hklAdapter){
500 _hklAdapter->set_sample_BFit(fit);
501 this->save();
502 attr_BFit_write = fit;
506 //+----------------------------------------------------------------------------
508 // method : Diffractometer::read_CFit
510 // description : Extract real attribute values for CFit acquisition result.
512 //-----------------------------------------------------------------------------
513 void Diffractometer::read_CFit(Tango::Attribute &attr)
515 DEBUG_STREAM << "Diffractometer::read_CFit(Tango::Attribute &attr) entering... "<< endl;
516 attr.set_value(attr_CFit_read);
519 //+----------------------------------------------------------------------------
521 // method : Diffractometer::write_CFit
523 // description : Write CFit attribute values to hardware.
525 //-----------------------------------------------------------------------------
526 void Diffractometer::write_CFit(Tango::WAttribute &attr)
528 DEBUG_STREAM << "Diffractometer::write_CFit(Tango::WAttribute &attr) entering... "<< endl;
529 bool fit;
531 attr.get_write_value(fit);
532 if (_hklAdapter){
533 _hklAdapter->set_sample_CFit(fit);
534 this->save();
535 attr_CFit_write = fit;
539 //+----------------------------------------------------------------------------
541 // method : Diffractometer::read_AlphaFit
543 // description : Extract real attribute values for AlphaFit acquisition result.
545 //-----------------------------------------------------------------------------
546 void Diffractometer::read_AlphaFit(Tango::Attribute &attr)
548 DEBUG_STREAM << "Diffractometer::read_AlphaFit(Tango::Attribute &attr) entering... "<< endl;
549 attr.set_value(attr_AlphaFit_read);
552 //+----------------------------------------------------------------------------
554 // method : Diffractometer::write_AlphaFit
556 // description : Write AlphaFit attribute values to hardware.
558 //-----------------------------------------------------------------------------
559 void Diffractometer::write_AlphaFit(Tango::WAttribute &attr)
561 DEBUG_STREAM << "Diffractometer::write_AlphaFit(Tango::WAttribute &attr) entering... "<< endl;
562 bool fit;
564 attr.get_write_value(fit);
565 if (_hklAdapter){
566 _hklAdapter->set_sample_AlphaFit(fit);
567 this->save();
568 attr_AlphaFit_write = fit;
572 //+----------------------------------------------------------------------------
574 // method : Diffractometer::read_BetaFit
576 // description : Extract real attribute values for BetaFit acquisition result.
578 //-----------------------------------------------------------------------------
579 void Diffractometer::read_BetaFit(Tango::Attribute &attr)
581 DEBUG_STREAM << "Diffractometer::read_BetaFit(Tango::Attribute &attr) entering... "<< endl;
582 attr.set_value(attr_BetaFit_read);
585 //+----------------------------------------------------------------------------
587 // method : Diffractometer::write_BetaFit
589 // description : Write BetaFit attribute values to hardware.
591 //-----------------------------------------------------------------------------
592 void Diffractometer::write_BetaFit(Tango::WAttribute &attr)
594 DEBUG_STREAM << "Diffractometer::write_BetaFit(Tango::WAttribute &attr) entering... "<< endl;
595 bool fit;
597 attr.get_write_value(fit);
598 if (_hklAdapter){
599 _hklAdapter->set_sample_BetaFit(fit);
600 this->save();
601 attr_BetaFit_write = fit;
605 //+----------------------------------------------------------------------------
607 // method : Diffractometer::read_GammaFit
609 // description : Extract real attribute values for GammaFit acquisition result.
611 //-----------------------------------------------------------------------------
612 void Diffractometer::read_GammaFit(Tango::Attribute &attr)
614 DEBUG_STREAM << "Diffractometer::read_GammaFit(Tango::Attribute &attr) entering... "<< endl;
615 attr.set_value(attr_GammaFit_read);
618 //+----------------------------------------------------------------------------
620 // method : Diffractometer::write_GammaFit
622 // description : Write GammaFit attribute values to hardware.
624 //-----------------------------------------------------------------------------
625 void Diffractometer::write_GammaFit(Tango::WAttribute &attr)
627 DEBUG_STREAM << "Diffractometer::write_GammaFit(Tango::WAttribute &attr) entering... "<< endl;
628 bool fit;
630 attr.get_write_value(fit);
631 if (_hklAdapter){
632 _hklAdapter->set_sample_GammaFit(fit);
633 this->save();
634 attr_GammaFit_write = fit;
638 //+----------------------------------------------------------------------------
640 // method : Diffractometer::read_UxFit
642 // description : Extract real attribute values for UxFit acquisition result.
644 //-----------------------------------------------------------------------------
645 void Diffractometer::read_UxFit(Tango::Attribute &attr)
647 DEBUG_STREAM << "Diffractometer::read_UxFit(Tango::Attribute &attr) entering... "<< endl;
648 attr.set_value(attr_UxFit_read);
651 //+----------------------------------------------------------------------------
653 // method : Diffractometer::write_UxFit
655 // description : Write UxFit attribute values to hardware.
657 //-----------------------------------------------------------------------------
658 void Diffractometer::write_UxFit(Tango::WAttribute &attr)
660 DEBUG_STREAM << "Diffractometer::write_UxFit(Tango::WAttribute &attr) entering... "<< endl;
661 bool fit;
663 attr.get_write_value(fit);
664 if (_hklAdapter){
665 _hklAdapter->set_sample_UxFit(fit);
666 this->save();
667 attr_UxFit_write = fit;
671 //+----------------------------------------------------------------------------
673 // method : Diffractometer::read_UyFit
675 // description : Extract real attribute values for UyFit acquisition result.
677 //-----------------------------------------------------------------------------
678 void Diffractometer::read_UyFit(Tango::Attribute &attr)
680 DEBUG_STREAM << "Diffractometer::read_UyFit(Tango::Attribute &attr) entering... "<< endl;
681 attr.set_value(attr_UyFit_read);
684 //+----------------------------------------------------------------------------
686 // method : Diffractometer::write_UyFit
688 // description : Write UyFit attribute values to hardware.
690 //-----------------------------------------------------------------------------
691 void Diffractometer::write_UyFit(Tango::WAttribute &attr)
693 DEBUG_STREAM << "Diffractometer::write_UyFit(Tango::WAttribute &attr) entering... "<< endl;
694 bool fit;
696 attr.get_write_value(fit);
697 if (_hklAdapter){
698 _hklAdapter->set_sample_UyFit(fit);
699 this->save();
700 attr_UyFit_write = fit;
704 //+----------------------------------------------------------------------------
706 // method : Diffractometer::read_UzFit
708 // description : Extract real attribute values for UzFit acquisition result.
710 //-----------------------------------------------------------------------------
711 void Diffractometer::read_UzFit(Tango::Attribute &attr)
713 DEBUG_STREAM << "Diffractometer::read_UzFit(Tango::Attribute &attr) entering... "<< endl;
714 attr.set_value(attr_UzFit_read);
717 //+----------------------------------------------------------------------------
719 // method : Diffractometer::write_UzFit
721 // description : Write UzFit attribute values to hardware.
723 //-----------------------------------------------------------------------------
724 void Diffractometer::write_UzFit(Tango::WAttribute &attr)
726 DEBUG_STREAM << "Diffractometer::write_UzFit(Tango::WAttribute &attr) entering... "<< endl;
727 bool fit;
729 attr.get_write_value(fit);
730 if (_hklAdapter){
731 _hklAdapter->set_sample_UzFit(fit);
732 this->save();
733 attr_UzFit_write = fit;
737 //+----------------------------------------------------------------------------
739 // method : Diffractometer::read_pseudoAxesProxies
741 // description : Extract real attribute values for pseudoAxesProxies acquisition result.
743 //-----------------------------------------------------------------------------
744 void Diffractometer::read_pseudoAxesProxies(Tango::Attribute &attr)
746 DEBUG_STREAM << "Diffractometer::read_pseudoAxesProxies(Tango::Attribute &attr) entering... "<< endl;
747 if(_hklAdapter){
748 Matrix<char *> const & img = _hklAdapter->get_pseudo_axes_proxies();
749 attr.set_value(img.data, img.xdim);
753 //+----------------------------------------------------------------------------
755 // method : Diffractometer::read_AnglesIdx
757 // description : Extract real attribute values for AnglesIdx acquisition result.
759 //-----------------------------------------------------------------------------
760 void Diffractometer::read_AnglesIdx(Tango::Attribute &attr)
762 DEBUG_STREAM << "Diffractometer::read_AnglesIdx(Tango::Attribute &attr) entering... "<< endl;
764 if(_hklAdapter){
765 *attr_AnglesIdx_read = _hklAdapter->get_angles_idx();
766 attr.set_value(attr_AnglesIdx_read);
770 //+----------------------------------------------------------------------------
772 // method : Diffractometer::write_AnglesIdx
774 // description : Write AnglesIdx attribute values to hardware.
776 //-----------------------------------------------------------------------------
777 void Diffractometer::write_AnglesIdx(Tango::WAttribute &attr)
779 DEBUG_STREAM << "Diffractometer::write_AnglesIdx(Tango::WAttribute &attr) entering... "<< endl;
781 attr.get_write_value(attr_AnglesIdx_write);
782 if(_hklAdapter)
783 _hklAdapter->set_angles_idx(attr_AnglesIdx_write);
786 //+----------------------------------------------------------------------------
788 // method : Diffractometer::read_AxesNames
790 // description : Extract real attribute values for AxesNames acquisition result.
792 //-----------------------------------------------------------------------------
793 void Diffractometer::read_AxesNames(Tango::Attribute &attr)
795 if(_hklAdapter){
796 Matrix<char *> const & img = _hklAdapter->get_dynamic_attribute_axes_names();
797 attr.set_value(img.data, img.xdim);
801 //+----------------------------------------------------------------------------
803 // method : Diffractometer::read_Angles
805 // description : Extract real attribute values for Angles acquisition result.
807 //-----------------------------------------------------------------------------
808 void Diffractometer::read_Angles(Tango::Attribute &attr)
810 DEBUG_STREAM << "Diffractometer::read_Angles(Tango::Attribute &attr) entering... "<< endl;
811 if(_hklAdapter){
812 Matrix<double> const & img = _hklAdapter->get_angles();
813 attr.set_value(img.data, img.xdim, img.ydim);
817 //+----------------------------------------------------------------------------
819 // method : Diffractometer::read_AnglesDegenerated
821 // description : Extract real attribute values for AnglesDegenerated acquisition result.
823 //-----------------------------------------------------------------------------
824 void Diffractometer::read_AnglesDegenerated(Tango::Attribute &attr)
826 DEBUG_STREAM << "Diffractometer::read_AnglesDegenerated(Tango::Attribute &attr) entering... "<< endl;
829 //+----------------------------------------------------------------------------
831 // method : Diffractometer::read_AnglesRangeCheck
833 // description : Extract real attribute values for AnglesRangeCheck acquisition result.
835 //-----------------------------------------------------------------------------
836 void Diffractometer::read_AnglesRangeCheck(Tango::Attribute &attr)
838 DEBUG_STREAM << "Diffractometer::read_AnglesRangeCheck(Tango::Attribute &attr) entering... "<< endl;
841 //+----------------------------------------------------------------------------
843 // method : Diffractometer::read_Reflections
845 // description : Extract real attribute values for Reflections acquisition result.
847 //-----------------------------------------------------------------------------
848 void Diffractometer::read_Reflections(Tango::Attribute &attr)
850 DEBUG_STREAM << "Diffractometer::read_Reflections(Tango::Attribute &attr) entering... "<< endl;
851 if(_hklAdapter){
852 Matrix<double> const & img = _hklAdapter->get_reflections();
853 attr.set_value(img.data, img.xdim, img.ydim);
857 //+----------------------------------------------------------------------------
859 // method : Diffractometer::write_Reflections
861 // description : Write Reflections attribute values to hardware.
863 //-----------------------------------------------------------------------------
864 void Diffractometer::write_Reflections(Tango::WAttribute &attr)
866 DEBUG_STREAM << "Diffractometer::write_Reflections(Tango::WAttribute &attr) entering... "<< endl;
868 const Tango::DevDouble *value;
869 attr.get_write_value(value);
871 Matrix<double> img;
872 img.attach_to_const_buffer(value,
873 attr.get_w_dim_x(), attr.get_w_dim_y());
875 if(_hklAdapter)
876 _hklAdapter->set_reflections(img);
879 //+----------------------------------------------------------------------------
881 // method : Diffractometer::read_ReflectionsAngles
883 // description : Extract real attribute values for ReflectionsAngles acquisition result.
885 //-----------------------------------------------------------------------------
886 void Diffractometer::read_ReflectionsAngles(Tango::Attribute &attr)
888 DEBUG_STREAM << "Diffractometer::read_ReflectionsAngles(Tango::Attribute &attr) entering... "<< endl;
890 if (_hklAdapter){
891 Matrix<double> const & img = _hklAdapter->get_reflections_angles();
892 attr.set_value(img.data, img.xdim, img.ydim);
896 //+----------------------------------------------------------------------------
898 // method : Diffractometer::read_AStar
900 // description : Extract real attribute values for AStar acquisition result.
902 //-----------------------------------------------------------------------------
903 void Diffractometer::read_AStar(Tango::Attribute &attr)
905 DEBUG_STREAM << "Diffractometer::read_AStar(Tango::Attribute &attr) entering... "<< endl;
906 attr.set_value(attr_AStar_read);
909 //+----------------------------------------------------------------------------
911 // method : Diffractometer::read_BStar
913 // description : Extract real attribute values for BStar acquisition result.
915 //-----------------------------------------------------------------------------
916 void Diffractometer::read_BStar(Tango::Attribute &attr)
918 DEBUG_STREAM << "Diffractometer::read_BStar(Tango::Attribute &attr) entering... "<< endl;
919 attr.set_value(attr_BStar_read);
922 //+----------------------------------------------------------------------------
924 // method : Diffractometer::read_CStar
926 // description : Extract real attribute values for CStar acquisition result.
928 //-----------------------------------------------------------------------------
929 void Diffractometer::read_CStar(Tango::Attribute &attr)
931 DEBUG_STREAM << "Diffractometer::read_CStar(Tango::Attribute &attr) entering... "<< endl;
932 attr.set_value(attr_CStar_read);
935 //+----------------------------------------------------------------------------
937 // method : Diffractometer::read_AlphaStar
939 // description : Extract real attribute values for AlphaStar acquisition result.
941 //-----------------------------------------------------------------------------
942 void Diffractometer::read_AlphaStar(Tango::Attribute &attr)
944 DEBUG_STREAM << "Diffractometer::read_AlphaStar(Tango::Attribute &attr) entering... "<< endl;
945 attr.set_value(attr_AlphaStar_read);
948 //+----------------------------------------------------------------------------
950 // method : Diffractometer::read_BetaStar
952 // description : Extract real attribute values for BetaStar acquisition result.
954 //-----------------------------------------------------------------------------
955 void Diffractometer::read_BetaStar(Tango::Attribute &attr)
957 DEBUG_STREAM << "Diffractometer::read_BetaStar(Tango::Attribute &attr) entering... "<< endl;
958 attr.set_value(attr_BetaStar_read);
961 //+----------------------------------------------------------------------------
963 // method : Diffractometer::read_GammaStar
965 // description : Extract real attribute values for GammaStar acquisition result.
967 //-----------------------------------------------------------------------------
968 void Diffractometer::read_GammaStar(Tango::Attribute &attr)
970 DEBUG_STREAM << "Diffractometer::read_GammaStar(Tango::Attribute &attr) entering... "<< endl;
971 attr.set_value(attr_GammaStar_read);
974 //+----------------------------------------------------------------------------
976 // method : Diffractometer::read_A
978 // description : Extract real attribute values for A acquisition result.
980 //-----------------------------------------------------------------------------
981 void Diffractometer::read_A(Tango::Attribute &attr)
983 DEBUG_STREAM << "Diffractometer::read_A(Tango::Attribute &attr) entering... "<< endl;
984 attr.set_value(attr_A_read);
987 //+----------------------------------------------------------------------------
989 // method : Diffractometer::read_B
991 // description : Extract real attribute values for B acquisition result.
993 //-----------------------------------------------------------------------------
994 void Diffractometer::read_B(Tango::Attribute &attr)
996 DEBUG_STREAM << "Diffractometer::read_B(Tango::Attribute &attr) entering... "<< endl;
997 attr.set_value(attr_B_read);
1000 //+----------------------------------------------------------------------------
1002 // method : Diffractometer::read_C
1004 // description : Extract real attribute values for C acquisition result.
1006 //-----------------------------------------------------------------------------
1007 void Diffractometer::read_C(Tango::Attribute &attr)
1009 DEBUG_STREAM << "Diffractometer::read_C(Tango::Attribute &attr) entering... "<< endl;
1010 attr.set_value(attr_C_read);
1013 //+----------------------------------------------------------------------------
1015 // method : Diffractometer::read_Alpha
1017 // description : Extract real attribute values for Alpha acquisition result.
1019 //-----------------------------------------------------------------------------
1020 void Diffractometer::read_Alpha(Tango::Attribute &attr)
1022 DEBUG_STREAM << "Diffractometer::read_Alpha(Tango::Attribute &attr) entering... "<< endl;
1023 attr.set_value(attr_Alpha_read);
1026 //+----------------------------------------------------------------------------
1028 // method : Diffractometer::read_Beta
1030 // description : Extract real attribute values for Beta acquisition result.
1032 //-----------------------------------------------------------------------------
1033 void Diffractometer::read_Beta(Tango::Attribute &attr)
1035 DEBUG_STREAM << "Diffractometer::read_Beta(Tango::Attribute &attr) entering... "<< endl;
1036 attr.set_value(attr_Beta_read);
1039 //+----------------------------------------------------------------------------
1041 // method : Diffractometer::read_Gamma
1043 // description : Extract real attribute values for Gamma acquisition result.
1045 //-----------------------------------------------------------------------------
1046 void Diffractometer::read_Gamma(Tango::Attribute &attr)
1048 DEBUG_STREAM << "Diffractometer::read_Gamma(Tango::Attribute &attr) entering... "<< endl;
1049 attr.set_value(attr_Gamma_read);
1052 //+----------------------------------------------------------------------------
1054 // method : Diffractometer::read_UB
1056 // description : Extract real attribute values for UB acquisition result.
1058 //-----------------------------------------------------------------------------
1059 void Diffractometer::read_UB(Tango::Attribute &attr)
1061 DEBUG_STREAM << "Diffractometer::read_UB(Tango::Attribute &attr) entering... "<< endl;
1063 if(_hklAdapter){
1064 Matrix<double> const & img = _hklAdapter->get_sample_ub();
1065 attr.set_value(img.data, img.xdim, img.ydim);
1069 //+----------------------------------------------------------------------------
1071 // method : Diffractometer::read_Ux
1073 // description : Extract real attribute values for Ux acquisition result.
1075 //-----------------------------------------------------------------------------
1076 void Diffractometer::read_Ux(Tango::Attribute &attr)
1078 DEBUG_STREAM << "Diffractometer::read_Ux(Tango::Attribute &attr) entering... "<< endl;
1080 if(_hklAdapter)
1081 attr.set_value(&_hklAdapter->get_sample_Ux());
1084 //+----------------------------------------------------------------------------
1086 // method : Diffractometer::write_Ux
1088 // description : Write Ux attribute values to hardware.
1090 //-----------------------------------------------------------------------------
1091 void Diffractometer::write_Ux(Tango::WAttribute &attr)
1093 DEBUG_STREAM << "Diffractometer::write_Ux(Tango::WAttribute &attr) entering... "<< endl;
1094 double Ux;
1096 attr.get_write_value(Ux);
1097 if (_hklAdapter){
1098 _hklAdapter->set_sample_Ux(Ux);
1099 attr_Ux_write = Ux;
1103 //+----------------------------------------------------------------------------
1105 // method : Diffractometer::read_Uy
1107 // description : Extract real attribute values for Uy acquisition result.
1109 //-----------------------------------------------------------------------------
1110 void Diffractometer::read_Uy(Tango::Attribute &attr)
1112 DEBUG_STREAM << "Diffractometer::read_Uy(Tango::Attribute &attr) entering... "<< endl;
1113 if(_hklAdapter)
1114 attr.set_value(&_hklAdapter->get_sample_Uy());
1117 //+----------------------------------------------------------------------------
1119 // method : Diffractometer::write_Uy
1121 // description : Write Uy attribute values to hardware.
1123 //-----------------------------------------------------------------------------
1124 void Diffractometer::write_Uy(Tango::WAttribute &attr)
1126 DEBUG_STREAM << "Diffractometer::write_Uy(Tango::WAttribute &attr) entering... "<< endl;
1127 double Uy;
1129 attr.get_write_value(Uy);
1130 if (_hklAdapter){
1131 _hklAdapter->set_sample_Uy(Uy);
1132 attr_Uy_write = Uy;
1136 //+----------------------------------------------------------------------------
1138 // method : Diffractometer::read_Uz
1140 // description : Extract real attribute values for Uz acquisition result.
1142 //-----------------------------------------------------------------------------
1143 void Diffractometer::read_Uz(Tango::Attribute &attr)
1145 DEBUG_STREAM << "Diffractometer::read_Uz(Tango::Attribute &attr) entering... "<< endl;
1146 if(_hklAdapter)
1147 attr.set_value(&_hklAdapter->get_sample_Uz());
1150 //+----------------------------------------------------------------------------
1152 // method : Diffractometer::write_Uz
1154 // description : Write Uz attribute values to hardware.
1156 //-----------------------------------------------------------------------------
1157 void Diffractometer::write_Uz(Tango::WAttribute &attr)
1159 DEBUG_STREAM << "Diffractometer::write_Uz(Tango::WAttribute &attr) entering... "<< endl;
1160 double Uz;
1162 attr.get_write_value(Uz);
1163 if (_hklAdapter){
1164 _hklAdapter->set_sample_Uz(Uz);
1165 attr_Uz_write = Uz;
1170 //+----------------------------------------------------------------------------
1172 // method : Diffractometer::read_Simulated
1174 // description : Extract real attribute values for Simulated acquisition result.
1176 //-----------------------------------------------------------------------------
1177 void Diffractometer::read_Simulated(Tango::Attribute &attr)
1179 DEBUG_STREAM << "Diffractometer::read_Simulated(Tango::Attribute &attr) entering... "<< endl;
1181 if(_hklAdapter)
1182 *attr_Simulated_read = !_hklAdapter->get_auto_update_from_proxies();
1183 attr.set_value(attr_Simulated_read);
1186 //+----------------------------------------------------------------------------
1188 // method : Diffractometer::write_Simulated
1190 // description : Write Simulated attribute values to hardware.
1192 //-----------------------------------------------------------------------------
1193 void Diffractometer::write_Simulated(Tango::WAttribute &attr)
1195 DEBUG_STREAM << "Diffractometer::write_Simulated(Tango::WAttribute &attr) entering... "<< endl;
1196 attr.get_write_value(attr_Simulated_write);
1198 if (_hklAdapter)
1199 _hklAdapter->set_auto_update_from_proxies(!attr_Simulated_write);
1202 //+----------------------------------------------------------------------------
1204 // method : Diffractometer::read_Crystal
1206 // description : Extract real attribute values for Crystal acquisition result.
1208 //-----------------------------------------------------------------------------
1209 void Diffractometer::read_Crystal(Tango::Attribute &attr)
1211 DEBUG_STREAM << "Diffractometer::read_Crystal(Tango::Attribute &attr) entering... "<< endl;
1213 if(*attr_Crystal_read) delete [] *attr_Crystal_read;
1215 if (_hklAdapter)
1216 *attr_Crystal_read = CORBA::string_dup(_hklAdapter->get_sample_name());
1217 else
1218 *attr_Crystal_read = CORBA::string_dup("");
1219 attr.set_value(attr_Crystal_read);
1222 //+----------------------------------------------------------------------------
1224 // method : Diffractometer::write_Crystal
1226 // description : Write Crystal attribute values to hardware.
1228 //-----------------------------------------------------------------------------
1229 void Diffractometer::write_Crystal(Tango::WAttribute &attr)
1231 DEBUG_STREAM << "Diffractometer::write_Crystal(Tango::WAttribute &attr) entering... "<< endl;
1233 attr.get_write_value(attr_Crystal_write);
1234 if(_hklAdapter)
1235 _hklAdapter->set_current_sample(attr_Crystal_write);
1238 //+----------------------------------------------------------------------------
1240 // method : Diffractometer::read_WaveLength
1242 // description : Extract real attribute values for WaveLength acquisition result.
1244 //-----------------------------------------------------------------------------
1245 void Diffractometer::read_WaveLength(Tango::Attribute &attr)
1247 DEBUG_STREAM << "Diffractometer::read_WaveLength(Tango::Attribute &attr) entering... "<< endl;
1249 if(_hklAdapter)
1250 attr.set_value(&_hklAdapter->get_lambda());
1253 //+----------------------------------------------------------------------------
1255 // method : Diffractometer::write_WaveLength
1257 // description : Write WaveLength attribute values to hardware.
1259 //-----------------------------------------------------------------------------
1260 void Diffractometer::write_WaveLength(Tango::WAttribute &attr)
1262 DEBUG_STREAM << "Diffractometer::write_WaveLength(Tango::WAttribute &attr) entering... "<< endl;
1264 attr.get_write_value(attr_WaveLength_write);
1266 if (_hklAdapter) {
1267 _hklAdapter->set_lambda(attr_WaveLength_write);
1268 if (!_hklAdapter->get_auto_update_from_proxies())
1269 *attr_WaveLength_read = attr_WaveLength_write;
1273 //+----------------------------------------------------------------------------
1275 // method : Diffractometer::read_CrystalNames
1277 // description : Extract real attribute values for CrystalNames acquisition result.
1279 //-----------------------------------------------------------------------------
1280 void Diffractometer::read_CrystalNames(Tango::Attribute &attr)
1282 DEBUG_STREAM << "Diffractometer::read_CrystalNames(Tango::Attribute &attr) entering... "<< endl;
1284 std::vector<std::string> names;
1286 if (_hklAdapter)
1287 names = _hklAdapter->get_samples_names();
1289 _crystal_names_dev_varstring_array << names;
1290 attr.set_value(_crystal_names_dev_varstring_array.get_buffer(),
1291 _crystal_names_dev_varstring_array.length());
1294 //+------------------------------------------------------------------
1296 * method: Diffractometer::abort
1298 * description: method to execute "Abort"
1299 * Stops the movement of all axis driven by the Diffractometer
1303 //+------------------------------------------------------------------
1304 void Diffractometer::abort()
1306 DEBUG_STREAM << "Diffractometer::abort(): entering... !" << endl;
1308 // Add your own code to control device here
1311 _hklAdapter->stop_all_axis();
1313 catch (Tango::DevFailed& e )
1315 ERROR_STREAM << e ;
1319 //+------------------------------------------------------------------
1321 * method: Diffractometer::add_new_crystal
1323 * description: method to execute "AddNewCrystal"
1324 * Create a new crystal
1326 * @param argin Name of the new crystal
1329 //+------------------------------------------------------------------
1330 void Diffractometer::add_new_crystal(Tango::DevString argin)
1332 DEBUG_STREAM << "Diffractometer::add_new_crystal(): entering... !" << endl;
1334 // Add your own code to control device here
1336 /* POGO rename SampleNew */
1338 if (_hklAdapter){
1339 _hklAdapter->add_new_sample(argin);
1340 this->save();
1344 //+------------------------------------------------------------------
1346 * method: Diffractometer::add_reflection
1348 * description: method to execute "AddReflection"
1349 * This commands requires the definition of 1 reflection defined by (h,k,l ) coordinates.
1350 * This coodinates are associated with the current angles configuration.
1352 * TODO: d�taill� le commentaire
1353 * reflections i.e : h, k, l, relevance, enable/disable
1355 * @param argin reflections i.e : h, k, l, relevance, enable/disable
1358 //+------------------------------------------------------------------
1359 void Diffractometer::add_reflection(const Tango::DevVarDoubleArray *argin)
1361 DEBUG_STREAM << "Diffractometer::add_reflection(): entering... !" << endl;
1363 // Add your own code to control device here
1365 if (_hklAdapter){
1366 _hklAdapter->add_reflection(argin);
1367 this->save();
1371 //+------------------------------------------------------------------
1373 * method: Diffractometer::affine_crystal
1375 * description: method to execute "AffineCrystal"
1376 * Compute affinement for the current crystal with available list of reflection.
1378 * @param argin name of the crystal to fit
1379 * @return the fitness of the crystal after the affinement.
1382 //+------------------------------------------------------------------
1383 Tango::DevDouble Diffractometer::affine_crystal(Tango::DevString argin)
1385 Tango::DevDouble argout ;
1386 DEBUG_STREAM << "Diffractometer::affine_crystal(): entering... !" << endl;
1388 // Add your own code to control device here
1390 /* POGO rename SampleAffinement */
1392 if(_hklAdapter){
1393 argout = _hklAdapter->affine_sample(argin);
1394 this->refresh_crystal_parameters();
1395 this->save();
1398 return argout;
1401 //+------------------------------------------------------------------
1403 * method: Diffractometer::configure_crystal
1405 * description: method to execute "ConfigureCrystal"
1406 * Defines crystal lattice parameters.
1407 * This information is mandatory for angles calculations.
1408 * Angles units are degrees
1410 * @param argin Crystal parameters : alpha,beta,gamma, A,B,C
1413 //+------------------------------------------------------------------
1414 void Diffractometer::configure_crystal(const Tango::DevVarDoubleArray *argin)
1416 DEBUG_STREAM << "Diffractometer::configure_crystal(): entering... !" << endl;
1418 // Add your own code to control device here
1420 /* POGO rename SampleConfiguration */
1422 if(_hklAdapter){
1423 _hklAdapter->set_lattice(argin);
1424 this->refresh_crystal_parameters();
1425 this->save();
1429 //+------------------------------------------------------------------
1431 * method: Diffractometer::copy_current_crystal_as
1433 * description: method to execute "CopyCurrentCrystalAs"
1434 * Copy the current crytal as another name
1436 * @param argin
1439 //+------------------------------------------------------------------
1440 void Diffractometer::copy_current_crystal_as(Tango::DevString argin)
1442 DEBUG_STREAM << "Diffractometer::copy_current_crystal_as(): entering... !" << endl;
1444 // Add your own code to control device here
1446 /* POGO rename SampleCopy */
1448 if(_hklAdapter){
1449 _hklAdapter->copy_sample_as(argin);
1450 this->refresh_crystal_parameters();
1451 this->save();
1455 //+------------------------------------------------------------------
1457 * method: Diffractometer::delete_current_crystal
1459 * description: method to execute "DeleteCurrentCrystal"
1460 * Delete the current from this device
1464 //+------------------------------------------------------------------
1465 void Diffractometer::delete_current_crystal()
1467 DEBUG_STREAM << "Diffractometer::delete_current_crystal(): entering... !" << endl;
1469 // Add your own code to control device here
1471 /* POGO rename SampleDelete */
1473 if(_hklAdapter){
1474 _hklAdapter->del_sample();
1475 this->refresh_crystal_parameters();
1476 this->save();
1480 //+------------------------------------------------------------------
1482 * method: Diffractometer::load
1484 * description: method to execute "Load"
1485 * Load all crystals
1489 //+------------------------------------------------------------------
1490 void Diffractometer::load()
1492 DEBUG_STREAM << "Diffractometer::load(): entering... !" << endl;
1494 // Add your own code to control device here
1496 // POGO TO DELETE
1497 if(_hklAdapter)
1498 _hklAdapter->load();
1501 //+------------------------------------------------------------------
1503 * method: Diffractometer::remove_reflection
1505 * description: method to execute "RemoveReflection"
1506 * This commands removes reflection from the current cristal.
1508 * @param argin index of reflection to remove
1511 //+------------------------------------------------------------------
1512 void Diffractometer::remove_reflection(Tango::DevShort argin)
1514 DEBUG_STREAM << "Diffractometer::remove_reflection(): entering... !" << endl;
1516 // Add your own code to control device here
1518 /* POGO rename SampleReflectionDelete */
1519 if(_hklAdapter){
1520 _hklAdapter->del_reflection(argin);
1521 this->refresh_crystal_parameters();
1522 this->save();
1526 //+------------------------------------------------------------------
1528 * method: Diffractometer::save
1530 * description: method to execute "Save"
1531 * Save all crystals
1535 //+------------------------------------------------------------------
1536 void Diffractometer::save()
1538 DEBUG_STREAM << "Diffractometer::save(): entering... !" << endl;
1540 // Add your own code to control device here
1542 // POGO TO DELETE
1543 if(_hklAdapter)
1544 _hklAdapter->save();
1547 //+------------------------------------------------------------------
1549 * method: Diffractometer::set_crystal_parameter_values
1551 * description: method to execute "SetCrystalParameterValues"
1552 * Double : min value, max value, affinement enable
1554 * @param argin String : Name of parameter ; Double : min value, max value, affinement enable
1557 //+------------------------------------------------------------------
1558 void Diffractometer::set_crystal_parameter_values(const Tango::DevVarDoubleStringArray *argin)
1560 DEBUG_STREAM << "Diffractometer::set_crystal_parameter_values(): entering... !" << endl;
1562 // Add your own code to control device here
1564 // check Parameters
1565 if(_hklAdapter)
1566 _hklAdapter->set_sample_parameter_values(argin);
1569 //+------------------------------------------------------------------
1571 * method: Diffractometer::copy_reflection_to
1573 * description: method to execute "CopyReflectionTo"
1574 * Copy one reflection from the current crystal to another crystal
1576 * @param argin Double: Reflection number of the current crystal String : Name of the crystal where copy this reflection
1579 //+------------------------------------------------------------------
1580 void Diffractometer::copy_reflection_to(const Tango::DevVarDoubleStringArray *argin)
1582 DEBUG_STREAM << "Diffractometer::copy_reflection_to(): entering... !" << endl;
1584 // Add your own code to control device here
1586 /* POGO TO DELETE */
1589 //+------------------------------------------------------------------
1591 * method: Diffractometer::dev_state
1593 * description: method to execute "State"
1594 * This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
1596 * @return State Code
1599 //+------------------------------------------------------------------
1600 Tango::DevState Diffractometer::dev_state()
1602 Tango::DevState argout;// = DeviceImpl::dev_state();
1603 DEBUG_STREAM << "Diffractometer::dev_state(): entering... !" << endl;
1605 // Add your own code to control device here
1607 argout = _config.state;
1608 this->set_state(argout);
1610 return argout;
1613 //+------------------------------------------------------------------
1615 * method: Diffractometer::get_crystal_parameter_values
1617 * description: method to execute "GetCrystalParameterValues"
1618 * Return all values of a parameter for the current crystal
1620 * @param argin Name of parameter (see getParametersNames for the complete list of parameters)
1621 * @return In the order : minimum value, maximum value, affinement enable
1624 //+------------------------------------------------------------------
1625 Tango::DevVarDoubleStringArray *Diffractometer::get_crystal_parameter_values(Tango::DevString argin)
1627 // POGO has generated a method core with argout allocation.
1628 // If you would like to use a static reference without copying,
1629 // See "TANGO Device Server Programmer's Manual"
1630 // (chapter : Writing a TANGO DS / Exchanging data)
1631 //------------------------------------------------------------
1632 Tango::DevVarDoubleStringArray *argout = new Tango::DevVarDoubleStringArray();
1633 argout->dvalue.length(3);
1634 argout->dvalue[0] = 0.0;
1635 argout->dvalue[1] = 0.0;
1636 argout->dvalue[2] = 0.0;
1637 argout->svalue.length(1);
1638 argout->svalue[0] = CORBA::string_dup(argin);
1639 DEBUG_STREAM << "Diffractometer::get_crystal_parameter_values(): entering... !" << endl;
1641 // Add your own code to control device here
1642 if(_hklAdapter)
1643 _hklAdapter->get_sample_parameter_values(argout);
1645 return argout;
1648 //+------------------------------------------------------------------
1650 * method: Diffractometer::compute_u
1652 * description: method to execute "ComputeU"
1653 * Compute Matrix U from two reflections
1655 * @param argin a two elements array with the index of reflection to use
1658 //+------------------------------------------------------------------
1659 void Diffractometer::compute_u(const Tango::DevVarLongArray *argin)
1661 DEBUG_STREAM << "Diffractometer::compute_u(): entering... !" << endl;
1663 // Add your own code to control device here
1664 if(_hklAdapter){
1665 _hklAdapter->compute_u(argin);
1666 this->save();
1670 //+------------------------------------------------------------------
1672 * method: Diffractometer::dev_status
1674 * description: method to execute "Status"
1675 * This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
1677 * @return Status description
1680 //+------------------------------------------------------------------
1681 Tango::ConstDevString Diffractometer::dev_status()
1683 //Tango::ConstDevString argout = DeviceImpl::dev_status();
1684 DEBUG_STREAM << "Diffractometer::dev_status(): entering... !" << endl;
1686 // Add your own code to control device here
1687 this->set_status(_config.status);
1688 return _config.status.c_str();
1695 } // namespace