1 #ifndef __TANGOHKLADAPTER_H__
2 #define __TANGOHKLADAPTER_H__
11 #include <hkl/hkl-geometry-factory.h>
12 #include <hkl/hkl-pseudoaxis-factory.h>
14 #include "AxisAdapter.h"
15 //#include "PseudoAxisAdapter.h"
18 #if ( _MSC_VER && _MSC_VER <= 1200 )
19 // Ce pragma ne devrait pas être dans ce fichier car le warning ne s'affiche
20 // que si l'on compile une version DEBUG de la librairie.
21 // Il faut utiliser l'option de compilation \wd4786 mais elle n'est présente
22 // qu'à partir de VC++7
23 # pragma warning (disable : 4786)
26 #define NO_SOFTWARE_LIMITS -999999
28 namespace DiffractometerDevice_ns
{
30 // forward declaration
31 class DiffractometerDevice
;
33 struct HklDiffractometer
{
34 HklGeometry
*geometry_r
;
35 HklGeometry
*geometry_w
;
37 HklSampleList
*samples
;
38 HklPseudoAxisEngineList
*engines_r
;
39 HklPseudoAxisEngineList
*engines_w
;
42 struct PseudoAxisAdapter
{
43 std::string _devicename
;
45 HklPseudoAxis
*_pseudo_r
;
46 HklPseudoAxis
*_pseudo_w
;
49 std::vector
<AxisAdapter
*> _axes
;
50 Tango::DevState _state
;
55 double h_r
; // read part of position value
56 double h_w
; // write part of position value
57 double k_r
; // read part of position value
58 double k_w
; // write part of position value
59 double l_r
; // read part of position value
60 double l_w
; // write part of position value
65 * Class which associates a Diffractometer with the PseudoAxis
73 TangoHKLAdapter(DiffractometerDevice
*_device
, HklGeometryType type
);
75 virtual ~TangoHKLAdapter(void);
77 // Diffractometer Part
78 virtual HklDiffractometer
*diffractometer(void);
80 HKLBuffer
const & get_HKLBuffer(void) const;
82 void getDiffractometerStateAndStatus(Tango::DevState
& the_state
,
83 std::string
& the_status
);
85 bool internal_compute_angles(double h
, double k
,
86 double l
, std::string
& status
);
88 void goto_reflection(short reflection_number
);
90 void set_simulated(bool simulated
);
92 void connect_all_proxies(void);
100 double & get_lambda(void) {return _lambda
;}
102 void set_lambda(double lambda
);
108 Matrix
<double> & get_angles(void) {omni_mutex_lock
lock(_lock
); return _angles
;}
110 short & get_angles_idx(void);
112 void set_angles_idx(short idx
);
118 char const *get_sample_name(void);
120 void set_current_sample(char const * name
);
122 void get_sample_lattices(double * a
, double * b
, double * c
,
123 double * alpha
, double * beta
, double * gamma
,
124 double * a_star
, double * b_star
, double * c_star
,
125 double * alpha_star
, double * beta_star
, double * gamma_star
);
127 Matrix
<double> & get_sample_ub(void) {omni_mutex_lock
lock(_lock
); return _ub
;}
129 double & get_sample_Ux(void) {return _ux
;}
131 void set_sample_Ux(double ux
);
133 double & get_sample_Uy(void) {return _uy
;}
135 void set_sample_Uy(double uy
);
137 double & get_sample_Uz(void) {return _uz
;}
139 void set_sample_Uz(double uz
);
141 void add_new_sample(std::string
const & name
);
143 void copy_sample_as(Tango::DevString copy_name
);
145 void del_sample(void);
147 void set_lattice(const Tango::DevVarDoubleArray
*argin
);
149 void add_reflection(void);
151 void del_reflection(Tango::DevShort argin
);
153 // to remove in favour of get_sample_reflections
154 void get_sample_reflection(int idx
, Tango::DevVarDoubleArray
*argout
);
156 // to remove in favour of set_sample_reflections
157 void set_sample_reflection(const Tango::DevVarDoubleArray
*argin
);
159 Matrix
<double> & get_sample_reflections(void) {omni_mutex_lock
lock(_lock
); return _sample_reflections
;}
161 void set_sample_reflections(Matrix
<double> const & img
);
163 double affine_sample(std::string name
);
165 std::vector
<std::string
> get_samples_names(void);
167 void get_sample_parameter_values(Tango::DevVarDoubleStringArray
*argout
);
169 void set_sample_parameter_values(Tango::DevVarDoubleStringArray
const *argin
);
171 void compute_u(const Tango::DevVarLongArray
*argin
);
173 Matrix
<double> & get_reflections_angles(void) {omni_mutex_lock
lock(_lock
); return _reflections_angles
;}
179 char const *read_mode(void);
181 void write_mode(Tango::DevString argin
);
183 Matrix
<char *> & get_mode_names(void) {omni_mutex_lock
lock(_lock
); return _mode_names
;}
185 Matrix
<char *> & get_mode_parameters_names(void){omni_mutex_lock
lock(_lock
); return _mode_parameters_names
;}
187 void get_mode_parameters_values(Tango::DevVarDoubleStringArray
*argout
);
189 void set_mode_parameters_values(const Tango::DevVarDoubleStringArray
*argin
);
195 const std::vector
<AxisAdapter
> & get_axes(void) const {return _axes
;}
197 std::vector
<AxisAdapter
> & get_axes(void) {return _axes
;}
199 void read_axis(int idx
, double & read
, double & write
);
201 void write_axis(int idx
, double value
);
203 void stop_all_axis(void);
205 /*******************/
206 /* PseudoAxes Part */
207 /*******************/
209 std::vector
<std::string
> pseudo_axis_get_names(void);
211 void pseudo_axis_init(PseudoAxisAdapter
*buffer
, bool init
);
213 PseudoAxisAdapter
*pseudo_axis_buffer_new(char const *name
);
215 void pseudo_axis_write(PseudoAxisAdapter
*buffer
, double value
);
220 HklDiffractometer
*_diffractometer
;
221 std::vector
<AxisAdapter
> _axes
;
222 std::vector
<PseudoAxisAdapter
*> _pseudoAxes
;
223 HKLBuffer _hklBuffer
;
224 Tango::Group
*_proxies
;
225 Tango::AttributeProxy
*_lambdaAttributeProxy
;
226 bool _wrong_nb_of_axis_proxies
;
228 void update_lambda(void);
230 void update_angles(void);
232 void update_reflections_angles(void);
234 void update_sample_reflections(void);
236 void update_ub(void);
238 void update_ux_uy_uz(void);
240 void update_mode_names(void);
242 void update_mode_parameters_names(void);
244 void update_axisBuffers_from_library(void);
246 void update_axisBuffers_from_proxies(void);
248 void update_HKLBuffer_from_library(void);
250 void update_pseudo_axis_buffers_from_library(void);
252 void update_library_from_axisBuffers(void);
254 void update_proxies_from_axisBuffers(void);
256 void update_proxies_from_pseudoAxesBuffer(PseudoAxisAdapter
*buffer
);
260 DiffractometerDevice
*_device
;
261 HklGeometryType _type
;
264 Matrix
<double> _angles
;
265 Matrix
<char *> _mode_names
;
266 Matrix
<char *> _mode_parameters_names
;
270 Matrix
<double> _reflections_angles
;
271 Matrix
<double> _sample_reflections
;
277 void pseudo_axis_related_axes_update(PseudoAxisAdapter
*buffer
);
282 // given the state compute the new state using the axe state.
283 extern void compose_state(Tango::DevState
& state
, Tango::DevState
const & axe_state
);
284 //extern std::string hkl_axes_consign_as_string(HklAxis const **axes, size_t axes_len);
286 #endif// _TangoHKLAdapter_H