Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add FMI3.0 prototype for cosimulation #1414

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdParty
14 changes: 14 additions & 0 deletions include/OMSimulator/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ typedef enum {
typedef enum {
oms_component_none,
oms_component_fmu, ///< FMU
oms_component_fmu3, ///< FMU3
oms_component_table, ///< lookup table
oms_component_external ///< external model
} oms_component_enu_t;
Expand All @@ -113,6 +114,19 @@ typedef enum {
oms_signal_type_bus
} oms_signal_type_enu_t;

typedef enum {
oms_signal_numeric_type_FLOAT32, // Represents fmi3Float32
oms_signal_numeric_type_FLOAT64, // Represents fmi3Float64
oms_signal_numeric_type_INT8, // Represents fmi3Int8
oms_signal_numeric_type_UINT8, // Represents fmi3UInt8
oms_signal_numeric_type_INT16, // Represents fmi3Int16
oms_signal_numeric_type_UINT16, // Represents fmi3UInt16
oms_signal_numeric_type_INT32, // Represents fmi3Int32
oms_signal_numeric_type_UINT32, // Represents fmi3UInt32
oms_signal_numeric_type_INT64, // Represents fmi3Int64
oms_signal_numeric_type_UINT64 // Represents fmi3UInt64
} oms_signal_numeric_type_enu_t;

/**
* \brief Connection type
*/
Expand Down
1 change: 1 addition & 0 deletions src/OMSimulatorLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(OMSIMULATORLIB_SOURCES
Clocks.cpp
Component.cpp
ComponentFMUCS.cpp
ComponentFMU3CS.cpp
ComponentFMUME.cpp
ComponentTable.cpp
ComRef.cpp
Expand Down
33 changes: 33 additions & 0 deletions src/OMSimulatorLib/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ void oms::fmi2logger(fmi2ComponentEnvironment env, fmi2String instanceName, fmi2
}
}

void oms::fmi3logger(fmi3InstanceEnvironment env, fmi3Status status, fmi3String category, fmi3String message)
{
if (status == fmi3OK && !logDebugEnabled())
{
// When frequently called for debug logging during simulation, avoid costly formatting.
return;
}

std::string msg = message; // Directly use the message as a string.

switch (status)
{
case fmi3OK:
logDebug("[fmi3OK] " + std::string(category) + ": " + msg);
break;
case fmi3Warning:
logWarning("[fmi3Warning] " + std::string(category) + ": " + msg);
break;
case fmi3Discard:
logError("[fmi3Discard] " + std::string(category) + ": " + msg);
break;
case fmi3Error:
logError("[fmi3Error] " + std::string(category) + ": " + msg);
break;
case fmi3Fatal:
logError("[fmi3Fatal] " + std::string(category) + ": " + msg);
break;
default:
logError("[unknown] " + std::string(category) + ": " + msg);
break;
}
}

oms::Component::Component(const ComRef& cref, oms_component_enu_t type, System* parentSystem, const std::string& path)
: element(oms_element_component, cref), cref(cref), type(type), parentSystem(parentSystem), path(path)
{
Expand Down
2 changes: 1 addition & 1 deletion src/OMSimulatorLib/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace oms
class Variable;

void fmi2logger(fmi2ComponentEnvironment env, fmi2String instanceName, fmi2Status status, fmi2String category, fmi2String message, ...);

void fmi3logger(fmi3InstanceEnvironment env, fmi3Status status, fmi3String category, fmi3String message);
class Component
{
public:
Expand Down
Loading