2 * This file is part of the hkl library.
4 * The hkl library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * The hkl library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) 2003-2014 Synchrotron SOLEIL
18 * L'Orme des Merisiers Saint-Aubin
19 * BP 48 91192 GIF-sur-YVETTE CEDEX
21 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
23 #include <stdio.h> // for fprintf, FILE
24 #include <stdlib.h> // for free
25 #include <string.h> // for NULL, strcmp
26 #include <sys/types.h> // for uint
27 #include "hkl-detector-private.h" // for hkl_detector_new_copy
28 #include "hkl-geometry-private.h" // for _HklGeometryList, etc
29 #include "hkl-macros-private.h" // for hkl_assert, HKL_MALLOC, etc
30 #include "hkl-parameter-private.h" // for hkl_parameter_list_fprintf, etc
31 #include "hkl-pseudoaxis-private.h" // for _HklEngine, _HklEngineList, etc
32 #include "hkl.h" // for HklEngine, HklEngineList, etc
33 #include "hkl/ccan/container_of/container_of.h" // for container_of
34 #include "hkl/ccan/darray/darray.h" // for darray_foreach, darray_init, etc
40 static inline HklParameter
*hkl_pseudo_axis_copy_real(const HklParameter
*base
)
42 HklPseudoAxis
*self
= container_of(base
, HklPseudoAxis
, parameter
);
43 HklPseudoAxis
*dup
= HKL_MALLOC(HklPseudoAxis
);
47 return &dup
->parameter
;
50 static inline void hkl_pseudo_axis_free_real(HklParameter
*self
)
52 HklPseudoAxis
*pseudo_axis
= container_of(self
, HklPseudoAxis
, parameter
);
57 static inline void hkl_pseudo_axis_fprintf_real(FILE *f
, const HklParameter
*self
)
59 HklPseudoAxis
*pseudo_axis
= container_of(self
, HklPseudoAxis
, parameter
);
61 hkl_parameter_fprintf_real(f
, self
);
62 fprintf(f
, " %p", pseudo_axis
->engine
);
65 static HklParameterOperations hkl_parameter_operations_pseudo_axis
= {
66 HKL_PARAMETER_OPERATIONS_DEFAULTS
,
67 .copy
= hkl_pseudo_axis_copy_real
,
68 .free
= hkl_pseudo_axis_free_real
,
69 .fprintf
= hkl_pseudo_axis_fprintf_real
,
72 HklParameter
*hkl_parameter_new_pseudo_axis(
73 const HklParameter
*parameter
,
78 self
= HKL_MALLOC(HklPseudoAxis
);
80 self
->parameter
= *parameter
;
81 self
->parameter
.ops
= &hkl_parameter_operations_pseudo_axis
;
82 self
->engine
= engine
;
84 return &self
->parameter
;
92 * hkl_mode_fprintf: (skip)
96 * print to a FILE the HklPSeudoAxisEngineMode members
98 void hkl_mode_fprintf(FILE *f
, const HklMode
*self
)
101 HklParameter
**parameter
;
103 fprintf(f
, "mode: \"%s\"\n", self
->info
->name
);
104 fprintf(f
, "initialize: %p\n", self
->ops
->init
);
105 fprintf(f
, "get: %p\n", self
->ops
->get
);
106 fprintf(f
, "set: %p\n", self
->ops
->set
);
108 darray_foreach(parameter
, self
->parameters
){
110 hkl_parameter_fprintf(f
, *parameter
);
113 if(self
->info
->axes
){
114 fprintf(f
, "axes names:");
115 for(i
=0; i
<self
->info
->n_axes
; ++i
)
116 fprintf(f
, " %s", self
->info
->axes
[i
]);
125 void hkl_engine_init(HklEngine
*self
,
126 const HklEngineInfo
*info
,
127 const HklEngineOperations
*ops
)
131 darray_init(self
->modes
);
132 darray_init(self
->pseudo_axes
);
133 darray_init(self
->pseudo_axes_names
);
134 darray_init(self
->mode_names
);
135 self
->geometry
= NULL
;
136 self
->detector
= NULL
;
140 void unregister_pseudo_axis(HklParameter
*pseudo_axis
)
142 hkl_parameter_free(pseudo_axis
);
145 HklParameter
*register_pseudo_axis(HklEngine
*self
,
146 const HklParameter
*conf
)
148 HklParameter
*parameter
;
150 parameter
= hkl_parameter_new_pseudo_axis(conf
, self
);
151 darray_append(self
->pseudo_axes
, parameter
);
152 darray_append(self
->pseudo_axes_names
, parameter
->name
);
157 static void hkl_engine_prepare_internal(HklEngine
*self
)
161 if(!self
|| !self
->engines
)
166 hkl_geometry_free(self
->geometry
);
167 self
->geometry
= hkl_geometry_new_copy(self
->engines
->geometry
);
170 hkl_detector_free(self
->detector
);
171 self
->detector
= hkl_detector_new_copy(self
->engines
->detector
);
174 hkl_sample_free(self
->sample
);
175 self
->sample
= hkl_sample_new_copy(self
->engines
->sample
);
177 /* fill the axes member from the function */
179 darray_free(self
->axes
);
180 darray_init(self
->axes
);
181 for(i
=0; i
<self
->mode
->info
->n_axes
; ++i
){
184 axis
= hkl_geometry_get_axis_by_name(self
->geometry
,
185 self
->mode
->info
->axes
[i
]);
187 darray_append(self
->axes
, axis
);
191 /* reset the geometries len */
192 hkl_geometry_list_reset(self
->engines
->geometries
);
196 * hkl_engine_name_get:
197 * @self: the this ptr
199 * Return value: the name of the HklEngine
201 const char *hkl_engine_name_get(const HklEngine
*self
)
203 return self
->info
->name
;
207 * hkl_engine_len: (skip)
208 * @self: the this ptr
210 * Return value: the len of the pseudo axes of the HklEngine
212 unsigned int hkl_engine_len(const HklEngine
*self
)
214 return self
->info
->n_pseudo_axes
;
218 * hkl_engine_pseudo_axes_names_get:
219 * @self: the this ptr
221 * Return value: (transfer none): the pseudo_axes managed by this HklEngine
223 const darray_string
*hkl_engine_pseudo_axes_names_get(HklEngine
*self
)
225 return &self
->pseudo_axes_names
;
229 * hkl_engine_pseudo_axes_values_get:
230 * @self: the this ptr
231 * @values: (array length=n_values): the values to get
232 * @n_values: the size of the values array.
233 * @unit_type: the unit type (default or user) of the returned value
235 * Get the engine pseudo axes values
237 void hkl_engine_pseudo_axes_values_get(HklEngine
*self
,
238 double values
[], size_t n_values
,
239 HklUnitEnum unit_type
)
241 hkl_assert(n_values
== self
->info
->n_pseudo_axes
);
243 for(size_t i
=0; i
<n_values
; ++i
)
244 values
[i
] = hkl_parameter_value_get(darray_item(self
->pseudo_axes
, i
),
249 * hkl_engine_pseudo_axes_values_set: (skip)
250 * @self: the this ptr
251 * @values: (array length=n_values): the values to set
252 * @n_values: the size of the values array.
253 * @unit_type: the unit type (default or user) of the returned value
254 * @error: return location for a GError, or NULL
256 * Set the engine pseudo axes values
259 * Returns: TRUE on success, FALSE if an error occurred
261 int hkl_engine_pseudo_axes_values_set(HklEngine
*self
,
262 double values
[], size_t n_values
,
263 HklUnitEnum unit_type
, GError
**error
)
265 g_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
267 if(n_values
!= self
->info
->n_pseudo_axes
){
270 HKL_ENGINE_ERROR_PSEUDO_AXES_VALUES_SET
,
271 "cannot set engine pseudo axes, wrong number of parameter (%d) given, (%d) expected\n",
272 n_values
, self
->info
->n_pseudo_axes
);
275 for(size_t i
=0; i
<n_values
; ++i
){
276 if(!hkl_parameter_value_set(darray_item(self
->pseudo_axes
, i
),
277 values
[i
], unit_type
, error
)){
278 g_assert (error
== NULL
|| *error
!= NULL
);
282 g_assert (error
== NULL
|| *error
== NULL
);
289 * hkl_engine_pseudo_axes_randomize: (skip)
290 * @self: the this ptr
292 * randomize all the parameters of the #HklEngine
294 void hkl_engine_pseudo_axes_randomize(HklEngine
*self
)
296 HklParameter
**parameter
;
298 darray_foreach(parameter
, self
->pseudo_axes
){
299 hkl_parameter_randomize(*parameter
);
304 * hkl_engine_pseudo_axis_get: (skip)
305 * @self: the this ptr
306 * @name: the name of the expected psudo_axis
307 * @error: return location for a GError, or NULL
309 * get the #HklParameter with the given @name.
311 * Returns: (allow-none): retun the parameter or NULL if the engine
312 * does not contain this pseudo_axis.
315 const HklParameter
*hkl_engine_pseudo_axis_get(const HklEngine
*self
,
319 HklParameter
**parameter
;
321 g_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
323 darray_foreach(parameter
, self
->pseudo_axes
)
324 if(!strcmp((*parameter
)->name
, name
))
329 HKL_ENGINE_ERROR_PSEUDO_AXIS_SET
,
330 "This pseudo axis doesn not contain this pseudo axis \"%s\"\n",
337 * hkl_engine_pseudo_axis_set: (skip)
338 * @self: the this ptr
339 * @name: the name of the pseudo_axis to set
340 * @parameter: the parameter to set.
341 * @error: return location for a GError, or NULL
343 * set a parameter of the #HklEngine
346 * return value: TRUE if succeded or FALSE otherwise.
348 int hkl_engine_pseudo_axis_set(HklEngine
*self
,
350 const HklParameter
*parameter
,
355 g_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
356 g_return_val_if_fail (strcmp(name
, parameter
->name
) == 0, FALSE
);
359 darray_foreach(p
, self
->pseudo_axes
)
360 if(!strcmp((*p
)->name
, parameter
->name
)){
361 hkl_parameter_init_copy(*p
, parameter
, NULL
);
367 HKL_ENGINE_ERROR_PSEUDO_AXIS_SET
,
368 "Can not find the pseudo axis \"%s\" in the \"%s\" engine\n",
369 parameter
->name
, self
->info
->name
);
375 * hkl_engine_mode_set: (skip)
376 * @self: the HklEngine
377 * @name: the mode to select
379 * This method also populate the self->axes from the mode->axes_names.
380 * this is to speed the computation of the numerical axes.
382 void hkl_engine_mode_set(HklEngine
*self
, HklMode
*mode
)
385 hkl_engine_prepare_internal(self
);
389 * hkl_engine_modes_names_get:
390 * @self: the this ptr
392 * Return value: (type gpointer): All the modes supported by the #HklEngine
394 const darray_string
*hkl_engine_modes_names_get(const HklEngine
*self
)
396 return &self
->mode_names
;
400 * hkl_engine_parameters_names_get:
401 * @self: the this ptr
403 * Return value: (type gpointer): All the parameters of #HklEngine.
405 const darray_string
*hkl_engine_parameters_names_get(const HklEngine
*self
)
407 return &self
->mode
->parameters_names
;
411 * hkl_engine_parameters_values_set: (skip)
412 * @self: the this ptr
413 * @values: (array length=n_values): the values to set
414 * @n_values: the size of the values array.
415 * @unit_type: the unit type (default or user) of the returned value
416 * @error: return location for a GError, or NULL
418 * Set the engine parameters values
420 * return value: TRUE if succeded or FALSE otherwise.
422 int hkl_engine_parameters_values_set(HklEngine
*self
,
423 double values
[], size_t n_values
,
424 HklUnitEnum unit_type
, GError
**error
)
426 g_return_val_if_fail (error
== NULL
|| *error
== NULL
&& n_values
== darray_size(self
->mode
->parameters
), FALSE
);
428 for(size_t i
=0; i
<n_values
; ++i
){
429 if(!hkl_parameter_value_set(darray_item(self
->mode
->parameters
, i
),
430 values
[i
], unit_type
, error
)){
431 g_assert (error
== NULL
|| *error
!= NULL
);
435 g_assert (error
== NULL
|| *error
== NULL
);
441 * hkl_engine_parameters_randomize: (skip)
442 * @self: the this ptr
444 * randomize all the parameters of the #HklEngine
446 void hkl_engine_parameters_randomize(HklEngine
*self
)
448 HklParameter
**parameter
;
450 darray_foreach(parameter
, self
->mode
->parameters
){
451 hkl_parameter_randomize(*parameter
);
456 * hkl_engine_parameter_get: (skip)
457 * @self: the this ptr
458 * @name: the name of the expected parameter
459 * @error: return location for a GError, or NULL
461 * get the #HklParameter with the given @name.
463 * Returns: (allow-none): return the parameter or NULL if the engine
464 * does not contain this parameter.
466 const HklParameter
*hkl_engine_parameter_get(const HklEngine
*self
,
470 HklParameter
**parameter
;
472 g_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
474 darray_foreach(parameter
, self
->mode
->parameters
)
475 if(!strcmp((*parameter
)->name
, name
))
480 HKL_ENGINE_ERROR_PARAMETER_GET
,
481 "this engine does not contain this parameter \"%s\"\n",
488 * hkl_engine_parameter_set: (skip)
489 * @self: the this ptr
490 * @name: the name of the parameter to set.
491 * @parameter: the parameter to set.
492 * @error: return location for a GError, or NULL
494 * set a parameter of the #HklEngine
497 * return value: TRUE if succeded or FALSE otherwise.
499 int hkl_engine_parameter_set(HklEngine
*self
,
501 const HklParameter
*parameter
,
506 g_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
507 g_return_val_if_fail (strcmp(name
, parameter
->name
) == 0, FALSE
);
509 darray_foreach(p
, self
->mode
->parameters
)
510 if(!strcmp((*p
)->name
, parameter
->name
)){
511 hkl_parameter_init_copy(*p
, parameter
, NULL
);
517 HKL_ENGINE_ERROR_PARAMETER_SET
,
518 "this engine does not contain this parameter \"%s\"\n",
525 * hkl_engine_engines_get:
526 * @self: the this ptr
528 * Return value: (transfer none): the HklEngineList which contain this HklEngine
530 HklEngineList
*hkl_engine_engines_get(HklEngine
*self
)
532 return self
->engines
;
536 * hkl_engine_select_mode:
537 * @self: the HklEngine
538 * @name: the mode to select
539 * @error: return location for a GError, or NULL
541 * This method also populate the self->axes from the mode->axes_names.
542 * this is to speed the computation of the numerical axes.
544 * return value: TRUE if succeded or FALSE otherwise.
546 int hkl_engine_select_mode(HklEngine
*self
, const char *name
,
551 g_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
553 darray_foreach(mode
, self
->modes
)
554 if(!strcmp((*mode
)->info
->name
, name
)){
555 hkl_engine_mode_set(self
, *mode
);
561 HKL_ENGINE_ERROR_SELECT_MODE
,
562 "this engine does not contain this mode \"%s\"\n",
569 * hkl_engine_initialize: (skip)
570 * @self: the HklEngine
571 * @error: return location for a GError, or NULL
573 * initialize the HklEngine
575 * return value: TRUE if succeded or FALSE otherwise.
577 int hkl_engine_initialize(HklEngine
*self
, GError
**error
)
579 hkl_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
581 if(!self
->geometry
|| !self
->detector
|| !self
->sample
585 HKL_ENGINE_ERROR_INITIALIZE
,
590 /* a NULL initialize method is valid */
591 if(self
->mode
->ops
->init
592 && !self
->mode
->ops
->init(self
->mode
,
594 self
->engines
->geometry
,
595 self
->engines
->detector
,
596 self
->engines
->sample
,
598 hkl_assert(error
== NULL
|| *error
!= NULL
);
602 hkl_assert(error
== NULL
|| *error
== NULL
);
608 * hkl_engine_set: (skip)
609 * @self: the HklEngine
610 * @error: return location for a GError, or NULL
612 * use the HklPseudoaxisEngine values to compute the real axes values.
614 * return value: TRUE if succeded or FALSE otherwise.
616 int hkl_engine_set(HklEngine
*self
, GError
**error
)
618 hkl_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
620 if(!self
->geometry
|| !self
->detector
|| !self
->sample
621 || !self
->mode
|| !self
->mode
->ops
->set
){
624 HKL_ENGINE_ERROR_SET
,
629 hkl_engine_prepare_internal(self
);
631 if (!self
->mode
->ops
->set(self
->mode
, self
,
636 hkl_assert(error
== NULL
|| *error
!= NULL
);
639 hkl_assert(error
== NULL
|| *error
== NULL
);
641 hkl_geometry_list_multiply(self
->engines
->geometries
);
642 hkl_geometry_list_multiply_from_range(self
->engines
->geometries
);
643 hkl_geometry_list_remove_invalid(self
->engines
->geometries
);
644 hkl_geometry_list_sort(self
->engines
->geometries
, self
->engines
->geometry
);
646 if(self
->engines
->geometries
->n_items
== 0){
649 HKL_ENGINE_ERROR_SET
,
650 "no remaining solutions");
658 * hkl_engine_get: (skip)
659 * @self: The HklEngine
660 * @error: return location for a GError, or NULL
662 * get the values of the pseudo-axes from the real-axes values
664 * return value: TRUE if succeded or FALSE otherwise.
666 int hkl_engine_get(HklEngine
*self
, GError
**error
)
668 hkl_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
670 if(!self
->engines
|| !self
->engines
->geometry
|| !self
->engines
->detector
671 || !self
->engines
->sample
|| !self
->mode
|| !self
->mode
->ops
->get
){
674 HKL_ENGINE_ERROR_GET
,
679 if (!self
->mode
->ops
->get(self
->mode
,
681 self
->engines
->geometry
,
682 self
->engines
->detector
,
683 self
->engines
->sample
,
685 hkl_assert(error
== NULL
|| *error
!= NULL
);
688 hkl_assert(error
== NULL
|| *error
== NULL
);
694 * hkl_engine_fprintf: (skip)
696 * @self: the HklEngine
698 * print to a FILE the HklEngine
700 void hkl_engine_fprintf(FILE *f
, const HklEngine
*self
)
702 HklParameter
**pseudo_axis
;
704 fprintf(f
, "\nPseudoAxesEngine : \"%s\"", self
->info
->name
);
708 fprintf(f
, " %s", self
->mode
->info
->name
);
709 for(uint i
=0; i
<darray_size(self
->mode
->parameters
); ++i
){
711 hkl_parameter_fprintf(
713 darray_item(self
->mode
->parameters
, i
));
718 /* the pseudoAxes part */
719 darray_foreach(pseudo_axis
, self
->pseudo_axes
){
721 hkl_parameter_fprintf(f
, *pseudo_axis
);
724 if(self
->engines
->geometries
->n_items
!= 0){
726 hkl_geometry_list_fprintf(f
, self
->engines
->geometries
);
736 * hkl_engine_list_new: (skip)
738 * default constructor
742 HklEngineList
*hkl_engine_list_new(void)
744 HklEngineList
*self
= NULL
;
746 self
= HKL_MALLOC(HklEngineList
);
750 self
->geometries
= hkl_geometry_list_new();
752 self
->geometry
= NULL
;
753 self
->detector
= NULL
;
760 * hkl_engine_list_new_copy: (skip)
763 * dummy copy constructor for the binding
765 * Returns: (transfer none): NULL all the time the structure is non-copyable
767 const HklEngineList
*hkl_engine_list_new_copy(const HklEngineList
*self
)
773 * hkl_engine_list_free: (skip)
774 * @self: the #HklEngineList to destroy
778 void hkl_engine_list_free(HklEngineList
*self
)
780 hkl_engine_list_clear(self
);
781 hkl_geometry_list_free(self
->geometries
);
786 * hkl_engine_list_add: (skip)
787 * @self: the engine list
788 * @engine: the engine to add
790 * add an #HklEngine to the #HklEngineList
792 * Returns: HKL_SUCCESS or HKL_FAIL
794 int hkl_engine_list_add(HklEngineList
*self
,
800 /* set the engines to access the Geometries list. */
801 engine
->engines
= self
;
803 darray_append(*self
, engine
);
809 * hkl_engine_list_engines_get: (skip)
810 * @self: the this ptr
812 * Return: a pointer on the engine array
814 darray_engine
*hkl_engine_list_engines_get(HklEngineList
*self
)
816 return (darray_engine
*)self
;
820 * hkl_engine_list_geometries_get:
821 * @self: the this ptr
823 * Return: a pointer on the engine array
825 const HklGeometryList
*hkl_engine_list_geometries_get(const HklEngineList
*self
)
827 return self
->geometries
;
831 * hkl_engine_list_geometry_get: (skip)
832 * @self: the this ptr
834 * Return: a pointer on the geometry member
836 HklGeometry
*hkl_engine_list_geometry_get(HklEngineList
*self
)
838 return self
->geometry
;
841 int hkl_engine_list_geometry_set(HklEngineList
*self
, const HklGeometry
*geometry
)
843 if(!hkl_geometry_set(self
->geometry
, geometry
))
846 hkl_engine_list_get(self
);
852 * hkl_engine_list_select_solution:
853 * @self: the this ptr
854 * @item: the #HklGeoemtryListItem selected.
856 * this method set the geometry member with the selected solution.
858 * return value: TRUE if succeded or FALSE otherwise.
860 int hkl_engine_list_select_solution(HklEngineList
*self
,
861 const HklGeometryListItem
*item
)
863 return hkl_geometry_init_geometry(self
->geometry
, item
->geometry
);
867 * hkl_engine_list_engine_get_by_name:
868 * @self: the this ptr
869 * @name: the name of the requested #HklPseudoAxisEngin
870 * @error: return location for a GError, or NULL
872 * get the #HklEngine by its name from the list.
874 * Returns: (transfer none) (allow-none): the requested engine
876 HklEngine
*hkl_engine_list_engine_get_by_name(HklEngineList
*self
,
882 g_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
884 darray_foreach(engine
, *self
){
885 if (!strcmp((*engine
)->info
->name
, name
))
890 HKL_ENGINE_LIST_ERROR
,
891 HKL_ENGINE_LIST_ERROR_ENGINE_GET_BY_NAME
,
892 "this engine list does not contain this engine \"%s\"",
899 * hkl_engine_list_pseudo_axis_get_by_name:
900 * @self: the engine list
901 * @name: the name of the requested #HklPseudoAxis
902 * @error: return location for a GError, or NULL
906 * Returns: (transfer none) (allow-none): the requested #HklPseudoAxis
908 HklParameter
*hkl_engine_list_pseudo_axis_get_by_name(
909 const HklEngineList
*self
, const char *name
,
913 HklParameter
**parameter
;
915 g_return_val_if_fail (error
== NULL
|| *error
== NULL
, FALSE
);
917 darray_foreach(engine
, *self
){
918 darray_foreach(parameter
, (*engine
)->pseudo_axes
){
919 if (!strcmp((*parameter
)->name
, name
))
925 HKL_ENGINE_LIST_ERROR
,
926 HKL_ENGINE_LIST_ERROR_ENGINE_GET_BY_NAME
,
927 "this engine list does not contain this pseudo axis \"%s\"",
934 * hkl_engine_list_clear: (skip)
935 * @self: the engine list to clear
937 * remove all engine from the engine list
939 void hkl_engine_list_clear(HklEngineList
*self
)
943 darray_foreach(engine
, *self
){
944 hkl_engine_free(*engine
);
950 * hkl_engine_list_init:
951 * @self: the engine list
952 * @geometry: the associated #HklGeometry
953 * @detector: the associated #HklDetector
954 * @sample: the associated #HklSample
956 * before using an engine list you must associate all engines to a
957 * Geometry, a detector and a sample.
959 void hkl_engine_list_init(HklEngineList
*self
,
960 HklGeometry
*geometry
,
961 HklDetector
*detector
,
966 self
->geometry
= geometry
;
967 self
->detector
= detector
;
968 self
->sample
= sample
;
970 darray_foreach(engine
, *self
){
971 hkl_engine_prepare_internal(*engine
);
976 * hkl_engine_list_get:
977 * @self: the list of #HklEngine
979 * apply the get method to all the #HklEngine of the list
980 * after this it is possible to retrive all the #HklPseudoAxis values.
982 * Returns: HKL_SUCCESS or HKL_FAIL if one of the #HklEngine
985 int hkl_engine_list_get(HklEngineList
*self
)
990 darray_foreach(engine
, *self
){
991 res
&= hkl_engine_get(*engine
, NULL
);
998 * hkl_engine_list_fprintf: (skip)
1002 * print to a FILE the #HklEngineList
1004 void hkl_engine_list_fprintf(FILE *f
,
1005 const HklEngineList
*self
)
1009 darray_foreach(engine
, *self
){
1010 hkl_engine_fprintf(f
, *engine
);