]> gerrit.simantics Code Review - simantics/fmil.git/blob - org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI2/fmi2_import_unit.h
Switch to full JavaSE-11+ compatibility
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / Import / include / FMI2 / fmi2_import_unit.h
1 /*
2     Copyright (C) 2012 Modelon AB
3
4     This program is free software: you can redistribute it and/or modify
5     it under the terms of the BSD style license.
6
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.
11
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>.
14 */
15
16 /** \file fmi2_import_unit.h
17 *  \brief Public interface to the FMI import C-library. Handling of variable units.
18 */
19
20 #ifndef FMI2_IMPORT_UNIT_H_
21 #define FMI2_IMPORT_UNIT_H_
22 \r
23 #include <fmilib_config.h>\r
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29                 /**
30         \addtogroup fmi2_import
31         @{
32         \addtogroup fmi2_import_units Functions for handling unit definitions.
33         @}
34         \addtogroup fmi2_import_units Functions for handling unit definitions.
35         @{
36         */
37
38 /**\name Structures encapsulating unit information */\r
39 /**@{ */\r
40 /** \brief A variable unit defined with a unit defition */\r
41 typedef struct fmi2_xml_unit_t fmi2_import_unit_t;\r
42 /** \brief A display unit. */\r
43 typedef struct fmi2_xml_display_unit_t fmi2_import_display_unit_t;\r
44 /** \brief The list of all the unit definitions in the model */\r
45 typedef struct fmi2_xml_unit_definitions_t fmi2_import_unit_definitions_t;\r
46 /**@} */\r
47
48 /** \brief Get the number of unit definitions. */
49 FMILIB_EXPORT unsigned int  fmi2_import_get_unit_definitions_number(fmi2_import_unit_definitions_t*);
50
51 /** \brief Get a unit definition */
52 FMILIB_EXPORT fmi2_import_unit_t* fmi2_import_get_unit(fmi2_import_unit_definitions_t*, unsigned int  index);
53
54 /** \brief Get a unit name */
55 FMILIB_EXPORT const char* fmi2_import_get_unit_name(fmi2_import_unit_t*);
56
57 /** \brief Get the number of display units associated with this unit */
58 FMILIB_EXPORT unsigned int fmi2_import_get_unit_display_unit_number(fmi2_import_unit_t*);
59
60 /**
61         \brief Get fmi2_SI_base_units_Num SI base units exponents associated with the unit.
62 */
63 FMILIB_EXPORT const int* fmi2_import_get_SI_unit_exponents(fmi2_import_unit_t*);
64
65 /**
66         \brief Get factor to the corresponding SI base units.
67 */
68 FMILIB_EXPORT double fmi2_import_get_SI_unit_factor(fmi2_import_unit_t*);
69
70 /**
71         \brief Get offset to the corresponding SI base units.
72 */
73 FMILIB_EXPORT double fmi2_import_get_SI_unit_offset(fmi2_import_unit_t*);
74
75 /**
76         \brief Convert a value with respect to the unit to the
77         value with respect to the SI base unit.
78 */
79 FMILIB_EXPORT double fmi2_import_convert_to_SI_base_unit(double, fmi2_import_unit_t*);
80
81 /**
82         \brief Convert a value with respect to the SI base unit to the
83         value with respect to the unit.
84 */
85 FMILIB_EXPORT double fmi2_import_convert_from_SI_base_unit(double, fmi2_import_unit_t*);
86
87 /** \brief Get a display unit object by index.
88         @param index The index of display unit to be returned. Must be less than the number returned by fmi2_import_get_unit_display_unit_number()
89 */
90 FMILIB_EXPORT fmi2_import_display_unit_t* fmi2_import_get_unit_display_unit(fmi2_import_unit_t*, size_t index);
91
92 /**
93         \brief Get unit defition for a display unit.
94 */
95 FMILIB_EXPORT fmi2_import_unit_t* fmi2_import_get_base_unit(fmi2_import_display_unit_t*);
96 /**
97         \brief Get display unit name
98 */
99 FMILIB_EXPORT const char* fmi2_import_get_display_unit_name(fmi2_import_display_unit_t*);
100
101 /**
102         \brief Get the "factor" associated with the display unit.
103 */
104 FMILIB_EXPORT fmi2_real_t fmi2_import_get_display_unit_factor(fmi2_import_display_unit_t*);
105 /**
106         \brief Get the "offset" associated with the display unit.
107 */
108 FMILIB_EXPORT fmi2_real_t fmi2_import_get_display_unit_offset(fmi2_import_display_unit_t*);
109
110 /**
111         \brief Convert a value measured in "units" to a value measured with "display units"
112         @param value The value to be converted.
113         @param du The display unit object
114         @param isRelativeQuantity specifies if "offset" should be incorporated into conversion
115 */
116 FMILIB_EXPORT fmi2_real_t fmi2_import_convert_to_display_unit(fmi2_real_t value , fmi2_import_display_unit_t* du, int isRelativeQuantity);
117
118
119 /**
120         \brief Convert a value measured in "display units" to a value measured with "units"
121         @param value The value to be converted.
122         @param du The display unit object
123         @param isRelativeQuantity specifies if "offset" should be incorporated into conversion
124 */
125 FMILIB_EXPORT fmi2_real_t fmi2_import_convert_from_display_unit(fmi2_real_t value, fmi2_import_display_unit_t* du, int isRelativeQuantity);
126 /** @} */
127 #ifdef __cplusplus
128 }
129 #endif
130 #endif