[contrib/haskell] move into binoculars-ng
[hkl.git] / hkl / hkl-engine-soleil-nanoscopium-robot.c
blob00910c5609c11cb7a90cb74aae8fc02036a9bbaa
1 /* This file is part of the hkl library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2003-2020 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
22 #include <gsl/gsl_sys.h> // for gsl_isnan
23 #include "hkl-factory-private.h" // for autodata_factories_, etc
24 #include "hkl-pseudoaxis-common-hkl-private.h"
26 #define RZ "rz"
27 #define RS "rs"
28 #define RX "rx"
29 #define R "r"
30 #define DELTA "delta"
31 #define GAMMA "gamma"
33 /********/
34 /* mode */
35 /********/
37 static HklMode *lifting_detector_rz()
39 static const char *axes_r[] = {RZ, RS, RX, R, DELTA, GAMMA};
40 static const char *axes_w[] = {RZ, DELTA, GAMMA};
41 static const HklFunction *functions[] = {&RUBh_minus_Q_func};
42 static const HklModeAutoInfo info = {
43 HKL_MODE_AUTO_INFO("lifting detector rz", axes_r, axes_w, functions),
46 return hkl_mode_auto_new(&info,
47 &hkl_full_mode_operations,
48 TRUE);
51 static HklMode *lifting_detector_rs()
53 static const char *axes_r[] = {RZ, RS, RX, R, DELTA, GAMMA};
54 static const char *axes_w[] = {RS, DELTA, GAMMA};
55 static const HklFunction *functions[] = {&RUBh_minus_Q_func};
56 static const HklModeAutoInfo info = {
57 HKL_MODE_AUTO_INFO("lifting detector rs", axes_r, axes_w, functions),
60 return hkl_mode_auto_new(&info,
61 &hkl_full_mode_operations,
62 TRUE);
65 static HklMode *lifting_detector_rx()
67 static const char *axes_r[] = {RZ, RS, RX, R, DELTA, GAMMA};
68 static const char *axes_w[] = {RX, DELTA, GAMMA};
69 static const HklFunction *functions[] = {&RUBh_minus_Q_func};
70 static const HklModeAutoInfo info = {
71 HKL_MODE_AUTO_INFO("lifting detector rx", axes_r, axes_w, functions),
74 return hkl_mode_auto_new(&info,
75 &hkl_full_mode_operations,
76 TRUE);
79 /**********************/
80 /* pseudo axis engine */
81 /**********************/
83 static HklEngine *hkl_engine_soleil_nanoscopium_robot_hkl_new(HklEngineList *engines)
85 HklEngine *self;
86 HklMode *default_mode;
88 self = hkl_engine_hkl_new(engines);
90 default_mode = lifting_detector_rz();
91 hkl_engine_add_mode(self, default_mode);
92 hkl_engine_mode_set(self, default_mode);
94 hkl_engine_add_mode(self, lifting_detector_rs());
95 hkl_engine_add_mode(self, lifting_detector_rx());
97 return self;
100 /****************************/
101 /* SOLEIL NANOSCOPIUM ROBOT */
102 /****************************/
104 #define HKL_GEOMETRY_TYPE_SOLEIL_NANOSCOPIUM_ROBOT_DESCRIPTION \
105 "+ xrays source fix allong the :math:`\\vec{x}` direction (1, 0, 0)\n" \
106 "+ 3 axes for the sample\n" \
107 "\n" \
108 " + **" RZ "** : rotation around the :math:`-\\vec{z}` direction (0, 0, -1)\n" \
109 " + **" RS "** : rotation around the :math:`\\vec{y}` direction (0, 1, 0)\n" \
110 " + **" RX "** : rotating around the :math:`-\\vec{x}` direction (-1, 0, 0)\n" \
111 "\n" \
112 "+ 3 axis for the detector\n" \
113 "\n" \
114 " + **" R "** : radius of the sphere\n" \
115 " + **" DELTA "** : rotation around the :math:`-\\vec{y}` direction (0, -1, 0)\n" \
116 " + **" GAMMA "** : rotation around the :math:`-\\vec{z}` direction (0, 0, -1)\n"
118 static const char* hkl_geometry_soleil_nanoscopium_robot_axes[] = {RZ, RS, RX, R, DELTA, GAMMA};
120 static HklGeometry *hkl_geometry_new_soleil_nanoscopium_robot(const HklFactory *factory)
122 HklGeometry *self = hkl_geometry_new(factory, &hkl_geometry_operations_defaults);
123 HklHolder *h;
125 h = hkl_geometry_add_holder(self);
126 hkl_holder_add_rotation(h, RZ, 0, 0, -1, &hkl_unit_angle_deg);
127 hkl_holder_add_rotation(h, RS, 0, 1, 0, &hkl_unit_angle_deg);
128 hkl_holder_add_rotation(h, RX, -1, 0, 0, &hkl_unit_angle_deg);
130 h = hkl_geometry_add_holder(self);
131 hkl_holder_add_parameter(h, R, &hkl_unit_length_meter);
132 hkl_holder_add_rotation(h, DELTA, 0, -1, 0, &hkl_unit_angle_deg);
133 hkl_holder_add_rotation(h, GAMMA, 0, 0, -1, &hkl_unit_angle_deg);
135 return self;
138 static HklEngineList *hkl_engine_list_new_soleil_nanoscopium_robot(const HklFactory *factory)
140 HklEngineList *self = hkl_engine_list_new();
142 hkl_engine_soleil_nanoscopium_robot_hkl_new(self);
144 return self;
147 REGISTER_DIFFRACTOMETER(soleil_nanoscopium_robot, "SOLEIL NANOSCOPIUM ROBOT", HKL_GEOMETRY_TYPE_SOLEIL_NANOSCOPIUM_ROBOT_DESCRIPTION);