Skip to content

Commit

Permalink
work in progress; not in a working state
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Meisrimel authored and Peter Meisrimel committed Jul 18, 2024
1 parent 0d497d9 commit 7ef257e
Show file tree
Hide file tree
Showing 15 changed files with 1,053 additions and 576 deletions.
5 changes: 5 additions & 0 deletions Config.cmake/fmixml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,16 @@ set(FMIXMLHEADERS
include/FMI3/fmi3_xml_model_structure.h
src/FMI3/fmi3_xml_model_structure_impl.h
include/FMI3/fmi3_xml_terminals_and_icons.h
## TODO: Sort these a bit
src/FMI3/fmi3_xml_terminals_and_icons_impl.h
src/FMI3/fmi3_xml_model_description_parser.h
src/FMI3/fmi3_xml_terminals_and_icons_parser.h
src/FMI3/fmi3_xml_parser_lists.h
src/FMI3/fmi3_xml_parser_util.h
src/FMI3/fmi3_xml_parser.h
src/FMI3/fmi3_xml_parser_handler.h
src/FMI3/fmi3_xml_type_struct_defs.h
src/FMI3/fmi3_xml_unit_struct_defs.h
include/FMI3/fmi3_xml_type.h
src/FMI3/fmi3_xml_type_impl.h
include/FMI3/fmi3_xml_unit.h
Expand Down
1 change: 1 addition & 0 deletions src/XML/include/FMI3/fmi3_xml_terminals_and_icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <JM/jm_callbacks.h>
#include <JM/jm_named_ptr.h>
#include <FMI/fmi_xml_context.h>
// #include "fmi3_xml_terminals_and_icons_impl.h"

#ifdef __cplusplus
extern "C" {
Expand Down
20 changes: 10 additions & 10 deletions src/XML/include/FMI3/fmi3_xml_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ fmi3_xml_type_definition_list_t* fmi3_xml_get_type_definitions(fmi3_xml_model_de

unsigned int fmi3_xml_get_type_definition_list_size(fmi3_xml_type_definition_list_t* td);

fmi3_xml_variable_typedef_t* fmi3_xml_get_typedef(fmi3_xml_type_definition_list_t* td, unsigned int index);
fmi3_xml_variable_typedef_t* fmi3_xml_get_typedef(fmi3_xml_type_definition_list_t* td, unsigned int index);

const char* fmi3_xml_get_type_name(fmi3_xml_variable_typedef_t*);
const char* fmi3_xml_get_type_name(fmi3_xml_variable_typedef_t* td);

/* Note that NULL pointer is returned if the attribute is not present in the XML.*/
const char* fmi3_xml_get_type_description(fmi3_xml_variable_typedef_t*);
const char* fmi3_xml_get_type_description(fmi3_xml_variable_typedef_t* td);

fmi3_base_type_enu_t fmi3_xml_get_base_type(fmi3_xml_variable_typedef_t*);
fmi3_base_type_enu_t fmi3_xml_get_base_type(fmi3_xml_variable_typedef_t* td);

/* Boolean and String has no extra attributes -> not needed*/

fmi3_xml_float_typedef_t* fmi3_xml_get_type_as_float(fmi3_xml_variable_typedef_t* t);
fmi3_xml_int_typedef_t* fmi3_xml_get_type_as_int(fmi3_xml_variable_typedef_t*);
fmi3_xml_enumeration_typedef_t* fmi3_xml_get_type_as_enum(fmi3_xml_variable_typedef_t*);
fmi3_xml_binary_typedef_t* fmi3_xml_get_type_as_binary(fmi3_xml_variable_typedef_t*);
fmi3_xml_clock_typedef_t* fmi3_xml_get_type_as_clock(fmi3_xml_variable_typedef_t*);
fmi3_xml_float_typedef_t* fmi3_xml_get_type_as_float(fmi3_xml_variable_typedef_t* td);
fmi3_xml_int_typedef_t* fmi3_xml_get_type_as_int(fmi3_xml_variable_typedef_t* td);
fmi3_xml_enumeration_typedef_t* fmi3_xml_get_type_as_enum(fmi3_xml_variable_typedef_t* td);
fmi3_xml_binary_typedef_t* fmi3_xml_get_type_as_binary(fmi3_xml_variable_typedef_t* td);
fmi3_xml_clock_typedef_t* fmi3_xml_get_type_as_clock(fmi3_xml_variable_typedef_t* td);

/* Note that NULL-pointer is always returned for strings and booleans */
const char* fmi3_xml_get_type_quantity(fmi3_xml_variable_typedef_t*);
const char* fmi3_xml_get_type_quantity(fmi3_xml_variable_typedef_t* td);

int fmi3_xml_get_float64_type_is_relative_quantity(fmi3_xml_float_typedef_t*);
int fmi3_xml_get_float64_type_is_unbounded(fmi3_xml_float_typedef_t*);
Expand Down
15 changes: 11 additions & 4 deletions src/XML/src/FMI3/fmi3_xml_model_description_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,25 @@
#include <JM/jm_vector.h>
#include <JM/jm_named_ptr.h>
#include <JM/jm_string_set.h>
#include <FMI3/fmi3_xml_model_description.h>
// #include <FMI3/fmi3_xml_model_description.h>

#include "fmi3_xml_unit_impl.h"
#include "fmi3_xml_type_impl.h"
#include "fmi3_xml_variable_impl.h"
// #include "fmi3_xml_unit_impl.h"
// #include "fmi3_xml_type_impl.h"
// #include "fmi3_xml_variable_impl.h"
#include "fmi3_xml_type_struct_defs.h"
#include "fmi3_xml_unit_struct_defs.h"
#include "fmi3_xml_model_structure_impl.h"

#ifdef __cplusplus
extern "C" {
#endif

#define FMI3_DEFAULT_EXPERIMENT_TOLERANCE 1e-4
#define FMI3_DEFAULT_EXPERIMENT_STEPSIZE 1e-2

typedef struct fmi3_xml_type_definition_list_t fmi3_xml_type_definition_list_t;


typedef struct fmi3_xml_default_experiment {
double startTime;
int startTimeDefined;
Expand Down
56 changes: 29 additions & 27 deletions src/XML/src/FMI3/fmi3_xml_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
#define snprintf _snprintf
#endif

#include "fmi3_xml_model_description_impl.h"
#include "fmi3_xml_terminals_and_icons_impl.h"
// #include "fmi3_xml_model_description_impl.h"
// #include "fmi3_xml_terminals_and_icons_impl.h"
#include "fmi3_xml_parser.h"
#include "JM/jm_portability.h"
#include "fmi3_xml_parser_util.h"
#include "fmi3_xml_parser_handler.h"

static const char* module = "FMI3XML";

Expand Down Expand Up @@ -203,31 +205,31 @@ void fmi3_xml_parse_free_context(fmi3_xml_parser_context_t* context) {
context->callbacks->free(context);
}

void fmi3_xml_parse_fatal(fmi3_xml_parser_context_t* context, const char* fmt, ...) {
va_list args;
va_start (args, fmt);
jm_log_fatal_v(context->callbacks, module, fmt, args);
va_end (args);
XML_StopParser(context->parser,0);
}

void fmi3_xml_parse_error(fmi3_xml_parser_context_t* context, const char* fmt, ...) {
va_list args;
va_start (args, fmt);
if (context->parser)
jm_log_info(context->callbacks, module, "[Line:%u] Detected during parsing:", XML_GetCurrentLineNumber(context->parser));
jm_log_error_v(context->callbacks, module, fmt, args);
va_end (args);
}

void fmi3_xml_parse_warning(fmi3_xml_parser_context_t* context, const char* fmt, ...) {
va_list args;
va_start (args, fmt);
if (context->parser)
jm_log_info(context->callbacks, module, "[Line:%u] Detected during parsing:", XML_GetCurrentLineNumber(context->parser));
jm_log_warning_v(context->callbacks, module, fmt, args);
va_end (args);
}
// void fmi3_xml_parse_fatal(fmi3_xml_parser_context_t* context, const char* fmt, ...) {
// va_list args;
// va_start (args, fmt);
// jm_log_fatal_v(context->callbacks, module, fmt, args);
// va_end (args);
// XML_StopParser(context->parser,0);
// }

// void fmi3_xml_parse_error(fmi3_xml_parser_context_t* context, const char* fmt, ...) {
// va_list args;
// va_start (args, fmt);
// if (context->parser)
// jm_log_info(context->callbacks, module, "[Line:%u] Detected during parsing:", XML_GetCurrentLineNumber(context->parser));
// jm_log_error_v(context->callbacks, module, fmt, args);
// va_end (args);
// }

// void fmi3_xml_parse_warning(fmi3_xml_parser_context_t* context, const char* fmt, ...) {
// va_list args;
// va_start (args, fmt);
// if (context->parser)
// jm_log_info(context->callbacks, module, "[Line:%u] Detected during parsing:", XML_GetCurrentLineNumber(context->parser));
// jm_log_warning_v(context->callbacks, module, fmt, args);
// va_end (args);
// }

/**
* Raises a generic parse error for the given attribute.
Expand Down
Loading

0 comments on commit 7ef257e

Please sign in to comment.