2 Copyright (C) 2012 Modelon AB
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the BSD style license.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 FMILIB_License.txt file for more details.
12 You should have received a copy of the FMILIB_License.txt file
13 along with this program. If not, contact Modelon AB <http://www.modelon.com>.
16 #ifndef FMI2_XML_VARIABLEIMPL_H
17 #define FMI2_XML_VARIABLEIMPL_H
19 #include <JM/jm_vector.h>
21 #include <FMI2/fmi2_xml_model_description.h>
23 #include "fmi2_xml_type_impl.h"
29 /* General variable type is convenien to unify all the variable list operations */
30 struct fmi2_xml_variable_t {
31 fmi2_xml_variable_type_base_t* typeBase; /** \brief Type information of the variable */
33 const char* description; /** \brief Associate description */
35 size_t originalIndex; /** \brief Index in the model description */
37 /* NB: before parsing of <ModelVariables> has finished,
38 derivativeOf and previous are stored as integer indices cast to pointers,
39 until they can be looked up */
40 fmi2_xml_variable_t *derivativeOf; /** \brief Only for continuous Real variables. If non-NULL, the variable that this is the derivative of. */
41 fmi2_xml_variable_t *previous; /** \brief If non-NULL, the variable that holds the value of this variable at the previous super-dense time instant. */
43 fmi2_value_reference_t vr; /** \brief Value reference */
48 char reinit; /** \brief Only for continuous Real variables */
49 char canHandleMultipleSetPerTimeInstant;
54 static int fmi2_xml_compare_vr (const void* first, const void* second) {
55 fmi2_xml_variable_t* a = *(fmi2_xml_variable_t**)first;
56 fmi2_xml_variable_t* b = *(fmi2_xml_variable_t**)second;
57 fmi2_base_type_enu_t at = fmi2_xml_get_variable_base_type(a);
58 fmi2_base_type_enu_t bt = fmi2_xml_get_variable_base_type(b);
59 if(at == fmi2_base_type_enum) at = fmi2_base_type_int;
60 if(bt == fmi2_base_type_enum) bt = fmi2_base_type_int;
61 if(at!=bt) return at - bt;
62 if(a->vr < b->vr) return -1;
63 if(a->vr > b->vr) return 1;
64 return ((int)a->aliasKind - (int)b->aliasKind);
71 #endif /* FMI2_XML_VARIABLEIMPL_H */