1 #include "Diffractometer.h"
2 #include "AxisAttrib.h"
3 #include "PseudoAxesAttrib.h"
6 namespace Diffractometer_ns
8 void Diffractometer::compute_angles(double h
, double k
,double l
)
10 DEBUG_STREAM
<< "Diffractometer::compute_angles(): entering... !" << endl
;
11 DEBUG_STREAM
<< " h : " << h
13 << " l : " << l
<< std::endl
;
15 if (!_hklAdapter
->simulated
) {
16 this->set_state(Tango::MOVING
);
17 this->set_status("Diffractometer moving");
21 bool res
= _hklAdapter
->internal_compute_angles(h
, k
, l
, status
);
23 TANGO_EXCEPTION_THROW("Can not compute the hkl",
27 void Diffractometer::refresh_crystal_parameters()
29 DEBUG_STREAM
<< "Diffractometer::refresh_crystal_parameters(): entering... !" << endl
;
33 _hklAdapter
->get_sample_lattices(attr_A_read
, attr_B_read
, attr_C_read
,
34 attr_Alpha_read
, attr_Beta_read
, attr_Gamma_read
,
35 attr_AStar_read
, attr_BStar_read
, attr_CStar_read
,
36 attr_AlphaStar_read
, attr_BetaStar_read
, attr_GammaStar_read
);
39 HklGeometryType
Diffractometer::get_type_from_property(std::string
const & name
)
43 if (!strcasecmp(name
.c_str(), "2CV"))
44 type
= HKL_GEOMETRY_TWOC_VERTICAL
;
45 else if (!strcasecmp(name
.c_str(), "E4CV"))
46 type
= HKL_GEOMETRY_EULERIAN4C_VERTICAL
;
47 else if (!strcasecmp(name
.c_str(), "K4CV"))
48 type
= HKL_GEOMETRY_KAPPA4C_VERTICAL
;
49 else if (!strcasecmp(name
.c_str(), "K6C"))
50 type
= HKL_GEOMETRY_KAPPA6C
;
51 else if (!strcasecmp(name
.c_str(), "E6C"))
52 type
= HKL_GEOMETRY_EULERIAN6C
;
54 type
= HKL_GEOMETRY_EULERIAN4C_VERTICAL
;
59 void Diffractometer::create_dynamic_attributes(void)
62 _hklAdapter
->add_dynamic_attributes_to_device();
65 void Diffractometer::remove_dynamic_attributes(void)
68 _hklAdapter
->delete_dynamic_attributes();
71 void Diffractometer::write_attributes_3(const Tango::AttributeValueList
& values
) throw (CORBA::SystemException
, Tango::DevFailed
, Tango::MultiDevFailed
)
73 DEBUG_STREAM
<< "Diffractometer::write_attributes_3: entering... !" << std::endl
;
74 // TODO check if it's really H,K and L
75 // If we received 2 or 3 values , assume they are h,k,l
77 std::string error
= "Diffractometer::write_attributes_3:";
78 for (unsigned int i
= 0; i
< values
.length(); i
++) {
80 error
+= values
[i
].name
;
82 DEBUG_STREAM
<< error
<< std::endl
;
84 if (values
.length() == 3 || values
.length() == 2) {
85 double h
= attr_H_write
;
86 double k
= attr_K_write
;
87 double l
= attr_L_write
;
90 // set flag value to avoid direct write on hardware of each single attribute
91 _write_attributes_hkl_together
= true;
93 // Initialise defaut h,k,l setpoint values
94 attr_H_write
= *attr_H_read
;
95 attr_K_write
= *attr_K_read
;
96 attr_L_write
= *attr_L_read
;
97 // do standard treatement to set the hkl coordinates from the user.
98 Device_3Impl::write_attributes_3(values
);
99 // do the final hkl, write with values which have been stored in xCoordinate_temp members
100 this->compute_angles(attr_H_write
, attr_K_write
, attr_L_write
);
103 _write_attributes_hkl_together
= false;
105 catch (Tango::DevFailed
&)
107 // restore write part
112 _write_attributes_hkl_together
= false;
115 //standard case i.e only 1 attribute
116 Device_3Impl::write_attributes_3(values
);