* add the soleil pom.xml file
[diffractometer.git] / src / DiffractometerExtra.cpp
blob5b90135af09bd6951dc65b0ad9d8d48826d0cbfd
1 #include "Diffractometer.h"
2 #include "AxisAttrib.h"
3 #include "PseudoAxesAttrib.h"
4 #include "macros.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
12 << " k : " << k
13 << " l : " << l << std::endl;
15 if (!_hklAdapter->simulated) {
16 this->set_state(Tango::MOVING);
17 this->set_status("Diffractometer moving");
20 std::string status;
21 bool res = _hklAdapter->internal_compute_angles(h, k, l, status);
22 if(!res)
23 TANGO_EXCEPTION_THROW("Can not compute the hkl",
24 status.c_str());
27 void Diffractometer::refresh_crystal_parameters()
29 DEBUG_STREAM << "Diffractometer::refresh_crystal_parameters(): entering... !" << endl;
31 // Refresh Values
32 if(_hklAdapter)
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)
41 HklGeometryType type;
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;
53 else
54 type = HKL_GEOMETRY_EULERIAN4C_VERTICAL;
56 return type;
59 void Diffractometer::create_dynamic_attributes(void)
61 if(_hklAdapter)
62 _hklAdapter->add_dynamic_attributes_to_device();
65 void Diffractometer::remove_dynamic_attributes(void)
67 if(_hklAdapter)
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++) {
79 error += " ";
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;
88 try
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);
102 // reset flag
103 _write_attributes_hkl_together = false;
105 catch (Tango::DevFailed &)
107 // restore write part
108 attr_H_write = h;
109 attr_K_write = k;
110 attr_L_write = l;
111 // reset flag
112 _write_attributes_hkl_together = false;
114 } else {
115 //standard case i.e only 1 attribute
116 Device_3Impl::write_attributes_3(values);
119 } // namespace_ns