diff --git a/include/OMSimulator/Types.h b/include/OMSimulator/Types.h index 458643eea..3759975f8 100644 --- a/include/OMSimulator/Types.h +++ b/include/OMSimulator/Types.h @@ -321,7 +321,7 @@ typedef struct { char* conA; ///< Name of connector A char* conB; ///< Name of connector B ssd_connection_geometry_t* geometry; ///< Geometry information of the connection - bool suppressUnitConversion; ///< boolean to specify automatic unit coversion between connections + bool suppressUnitConversion; ///< Boolean to specify if automatic unit conversion between connections should be suppressed } oms_connection_t; /** diff --git a/src/OMSimulatorLib/DirectedGraph.cpp b/src/OMSimulatorLib/DirectedGraph.cpp index 5ff5484ad..5cb743cf8 100644 --- a/src/OMSimulatorLib/DirectedGraph.cpp +++ b/src/OMSimulatorLib/DirectedGraph.cpp @@ -271,7 +271,10 @@ void oms::DirectedGraph::calculateSortedConnections() scc.component_names.insert(conB.getOwner()); // check for factor in connector units if (nodes[edges.connections[components[i][j]].first].connectorUnits.empty() || nodes[edges.connections[components[i][j]].second].connectorUnits.empty()) + { scc.factor = 1.0; + scc.suppressUnitConversion = true; + } else { double factorA = 1.0; diff --git a/src/OMSimulatorLib/SystemSC.cpp b/src/OMSimulatorLib/SystemSC.cpp index f706f0f5a..a0ea3597b 100644 --- a/src/OMSimulatorLib/SystemSC.cpp +++ b/src/OMSimulatorLib/SystemSC.cpp @@ -980,9 +980,9 @@ oms_status_enu_t oms::SystemSC::updateInputs(DirectedGraph& graph) { double value = 0.0; if (oms_status_ok != getReal(graph.getNodes()[output].getName(), value)) return oms_status_error; - /* check for unit conversion and suppressUnitConversion and set the value multiplied by factor, - * by default, factor = 1.0, (e.g) mm to m will be (factor*value) => (10^-3 * value) - */ + + // Check for unit conversion and suppressUnitConversion. Set the value multiplied by factor. + // By default, factor = 1.0. For example, mm to m will be (factor * value) => (1e-3 * value). if (sortedConnections[i].suppressUnitConversion) value = value; else diff --git a/src/OMSimulatorLib/SystemWC.cpp b/src/OMSimulatorLib/SystemWC.cpp index b7e2f169f..820e67819 100644 --- a/src/OMSimulatorLib/SystemWC.cpp +++ b/src/OMSimulatorLib/SystemWC.cpp @@ -1034,20 +1034,20 @@ oms_status_enu_t oms::SystemWC::updateInputs(oms::DirectedGraph& graph) const std::vector& sortedConnections = graph.getSortedConnections(); updateAlgebraicLoops(sortedConnections, graph); - for(int i=0; i < sortedConnections.size(); i++) + for(size_t i=0; i < sortedConnections.size(); i++) { if (!sortedConnections[i].thisIsALoop) { - int output = sortedConnections[i].connections[0].first; - int input = sortedConnections[i].connections[0].second; + size_t output = sortedConnections[i].connections[0].first; + size_t input = sortedConnections[i].connections[0].second; if (graph.getNodes()[input].getType() == oms_signal_type_real) { double value = 0.0; if (oms_status_ok != getReal(graph.getNodes()[output].getName(), value)) return oms_status_error; - /* check for unit conversion and suppressUnitConversion and set the value multiplied by factor, - * by default, factor = 1.0, (e.g) mm to m will be (factor*value) => (10^-3 * value) - */ + + // Check for unit conversion and suppressUnitConversion. Set the value multiplied by factor. + // By default, factor = 1.0. For example, mm to m will be (factor * value) => (10^-3 * value). if (sortedConnections[i].suppressUnitConversion) value = value; else diff --git a/testsuite/simulation/renameValues2.lua b/testsuite/simulation/renameValues2.lua index d82e75b42..26c0aa0b4 100644 --- a/testsuite/simulation/renameValues2.lua +++ b/testsuite/simulation/renameValues2.lua @@ -4,6 +4,7 @@ -- ucrt64: yes -- win: yes -- mac: no +-- asan: yes oms_setCommandLineOption("--suppressPath=true") oms_setTempDirectory("./renameValues2_lua/")