]> gerrit.simantics Code Review - simantics/fmil.git/blobdiff - org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI2/fmi2_import_unit.h
Add FMILibrary-2.0.3 to org.simantics.fmil.core\native.
[simantics/fmil.git] / org.simantics.fmil.core / native / FMILibrary / src / Import / include / FMI2 / fmi2_import_unit.h
diff --git a/org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI2/fmi2_import_unit.h b/org.simantics.fmil.core/native/FMILibrary/src/Import/include/FMI2/fmi2_import_unit.h
new file mode 100644 (file)
index 0000000..6ab809c
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+    Copyright (C) 2012 Modelon AB
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the BSD style license.
+
+     This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    FMILIB_License.txt file for more details.
+
+    You should have received a copy of the FMILIB_License.txt file
+    along with this program. If not, contact Modelon AB <http://www.modelon.com>.
+*/
+
+/** \file fmi2_import_unit.h
+*  \brief Public interface to the FMI import C-library. Handling of variable units.
+*/
+
+#ifndef FMI2_IMPORT_UNIT_H_
+#define FMI2_IMPORT_UNIT_H_
+\r
+#include <fmilib_config.h>\r
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+               /**
+       \addtogroup fmi2_import
+       @{
+       \addtogroup fmi2_import_units Functions for handling unit definitions.
+       @}
+       \addtogroup fmi2_import_units Functions for handling unit definitions.
+       @{
+       */
+
+/**\name Structures encapsulating unit information */\r
+/**@{ */\r
+/** \brief A variable unit defined with a unit defition */\r
+typedef struct fmi2_xml_unit_t fmi2_import_unit_t;\r
+/** \brief A display unit. */\r
+typedef struct fmi2_xml_display_unit_t fmi2_import_display_unit_t;\r
+/** \brief The list of all the unit definitions in the model */\r
+typedef struct fmi2_xml_unit_definitions_t fmi2_import_unit_definitions_t;\r
+/**@} */\r
+
+/** \brief Get the number of unit definitions. */
+FMILIB_EXPORT unsigned int  fmi2_import_get_unit_definitions_number(fmi2_import_unit_definitions_t*);
+
+/** \brief Get a unit definition */
+FMILIB_EXPORT fmi2_import_unit_t* fmi2_import_get_unit(fmi2_import_unit_definitions_t*, unsigned int  index);
+
+/** \brief Get a unit name */
+FMILIB_EXPORT const char* fmi2_import_get_unit_name(fmi2_import_unit_t*);
+
+/** \brief Get the number of display units associated with this unit */
+FMILIB_EXPORT unsigned int fmi2_import_get_unit_display_unit_number(fmi2_import_unit_t*);
+
+/**
+       \brief Get fmi2_SI_base_units_Num SI base units exponents associated with the unit.
+*/
+FMILIB_EXPORT const int* fmi2_import_get_SI_unit_exponents(fmi2_import_unit_t*);
+
+/**
+       \brief Get factor to the corresponding SI base units.
+*/
+FMILIB_EXPORT double fmi2_import_get_SI_unit_factor(fmi2_import_unit_t*);
+
+/**
+       \brief Get offset to the corresponding SI base units.
+*/
+FMILIB_EXPORT double fmi2_import_get_SI_unit_offset(fmi2_import_unit_t*);
+
+/**
+       \brief Convert a value with respect to the unit to the
+       value with respect to the SI base unit.
+*/
+FMILIB_EXPORT double fmi2_import_convert_to_SI_base_unit(double, fmi2_import_unit_t*);
+
+/**
+       \brief Convert a value with respect to the SI base unit to the
+       value with respect to the unit.
+*/
+FMILIB_EXPORT double fmi2_import_convert_from_SI_base_unit(double, fmi2_import_unit_t*);
+
+/** \brief Get a display unit object by index.
+       @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()
+*/
+FMILIB_EXPORT fmi2_import_display_unit_t* fmi2_import_get_unit_display_unit(fmi2_import_unit_t*, size_t index);
+
+/**
+       \brief Get unit defition for a display unit.
+*/
+FMILIB_EXPORT fmi2_import_unit_t* fmi2_import_get_base_unit(fmi2_import_display_unit_t*);
+/**
+       \brief Get display unit name
+*/
+FMILIB_EXPORT const char* fmi2_import_get_display_unit_name(fmi2_import_display_unit_t*);
+
+/**
+       \brief Get the "factor" associated with the display unit.
+*/
+FMILIB_EXPORT fmi2_real_t fmi2_import_get_display_unit_factor(fmi2_import_display_unit_t*);
+/**
+       \brief Get the "offset" associated with the display unit.
+*/
+FMILIB_EXPORT fmi2_real_t fmi2_import_get_display_unit_offset(fmi2_import_display_unit_t*);
+
+/**
+       \brief Convert a value measured in "units" to a value measured with "display units"
+       @param value The value to be converted.
+       @param du The display unit object
+       @param isRelativeQuantity specifies if "offset" should be incorporated into conversion
+*/
+FMILIB_EXPORT fmi2_real_t fmi2_import_convert_to_display_unit(fmi2_real_t value , fmi2_import_display_unit_t* du, int isRelativeQuantity);
+
+
+/**
+       \brief Convert a value measured in "display units" to a value measured with "units"
+       @param value The value to be converted.
+       @param du The display unit object
+       @param isRelativeQuantity specifies if "offset" should be incorporated into conversion
+*/
+FMILIB_EXPORT fmi2_real_t fmi2_import_convert_from_display_unit(fmi2_real_t value, fmi2_import_display_unit_t* du, int isRelativeQuantity);
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+#endif