Skip to content

Commit

Permalink
Fixed a bug in tsv unused variable handling. Added test cases for unu…
Browse files Browse the repository at this point in the history
…sed variable situation.
  • Loading branch information
ghorwin committed Jan 7, 2025
1 parent 2d7a954 commit 056f87f
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 9 deletions.
2 changes: 1 addition & 1 deletion MasterSim/src/MSIM_Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const char * const RELEASE_DATE = "December 31st, 2024";

const unsigned int KEYWORD_INDENTATION = 0;

const unsigned int KEYWORD_WIDTH = 24;
const unsigned int KEYWORD_WIDTH = 32;


} // namespace MASTER_SIM
Expand Down
14 changes: 6 additions & 8 deletions MasterSim/src/MSIM_MasterSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ void MasterSim::composeVariableVector() {
colIndex = fileReaderSlave->m_doubleVarNames.size()-1;
fileReaderSlave->m_doubleOutputs.resize(fileReaderSlave->m_doubleVarNames.size());
IBK::IBK_Message(IBK::FormatString(" Variable '%1' from csv slave is assigned type 'Real'\n")
.arg(edge.m_outputVariableRef), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_STANDARD);
.arg(edge.m_outputVariableRef), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_INFO);
}
break;

Expand Down Expand Up @@ -995,7 +995,7 @@ void MasterSim::composeVariableVector() {
colIndex = fileReaderSlave->m_intVarNames.size()-1;
fileReaderSlave->m_intOutputs.resize(fileReaderSlave->m_intVarNames.size());
IBK::IBK_Message(IBK::FormatString(" Variable '%1' from csv slave is assigned type 'Integer'\n")
.arg(edge.m_outputVariableRef), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_STANDARD);
.arg(edge.m_outputVariableRef), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_INFO);
}
break;

Expand Down Expand Up @@ -1028,7 +1028,7 @@ void MasterSim::composeVariableVector() {
colIndex = fileReaderSlave->m_boolVarNames.size()-1;
fileReaderSlave->m_boolOutputs.resize(fileReaderSlave->m_boolVarNames.size());
IBK::IBK_Message(IBK::FormatString(" Variable '%1' from csv slave is assigned type 'Boolean'\n")
.arg(edge.m_outputVariableRef), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_STANDARD);
.arg(edge.m_outputVariableRef), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_INFO);
}
break;

Expand Down Expand Up @@ -1061,7 +1061,7 @@ void MasterSim::composeVariableVector() {
colIndex = fileReaderSlave->m_stringVarNames.size()-1;
fileReaderSlave->m_stringOutputs.resize(fileReaderSlave->m_stringVarNames.size());
IBK::IBK_Message(IBK::FormatString(" Variable '%1' from csv slave is assigned type 'String'\n")
.arg(edge.m_outputVariableRef), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_STANDARD);
.arg(edge.m_outputVariableRef), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_INFO);
}
break;
case MASTER_SIM::FMIVariable::NUM_VT : IBK_ASSERT(false); // must not ever happen, only to make compiler happy
Expand Down Expand Up @@ -1115,11 +1115,9 @@ void MasterSim::composeVariableVector() {
fileReaderSlave->m_doubleVarNames.push_back(varName);
fileReaderSlave->m_doubleVarUnits.push_back(fileReaderSlave->m_typelessVarUnits[colIndex]);

// adjust colIndex to point to the newly registered double variable
colIndex = fileReaderSlave->m_doubleVarNames.size()-1;
fileReaderSlave->m_doubleOutputs.resize(fileReaderSlave->m_doubleVarNames.size());
IBK::IBK_Message(IBK::FormatString("Unconnected variable '%1' from csv slave '%2' is assigned type 'Real'\n")
.arg(varName).arg(fileReaderSlave->m_name), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_STANDARD);
IBK::IBK_Message(IBK::FormatString("Assuming type 'Real' for unconnected variable '%1' from file reader slave '%2'\n")
.arg(varName).arg(fileReaderSlave->m_name), IBK::MSG_PROGRESS, FUNC_ID, IBK::VL_INFO);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions data/tests/linux64/FileReaderSlave/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/LV_Richardson_PredatorFromFile_noiter/
/LV_Richardson_PredatorFromFile_noiter_excelcsv/
/FileReaderSeveralVars/
/FileReaderUnusedVars/
/FileReaderUnusedVarsWriteAll/
29 changes: 29 additions & 0 deletions data/tests/linux64/FileReaderSlave/FileReaderUnusedVars.msim
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Created: Di. Jan. 7 08:53:10 2025
# LastModified: Di. Jan. 7 08:53:10 2025

tStart 0 a
tEnd 6 h
hMax 10 min
hMin 1e-05 s
hFallBackLimit 0.001 s
hStart 10 min
hOutputMin 1 h
outputTimeUnit h
adjustStepSize no
preventOversteppingOfEndTime yes
absTol 1e-06
relTol 1e-05
MasterMode GAUSS_SEIDEL
ErrorControlMode NONE
maxIterations 1
writeInternalVariables yes
writeUnconnectedFileReaderVars no

simulator 0 0 FileReader #4682b4 "SixRealValues.tsv"
simulator 1 0 RealInputVars #6a5acd "fmus/IBK/FourRealInputVars.fmu"

graph FileReader.Var1 RealInputVars.V1
graph FileReader.Var2 RealInputVars.V2
graph FileReader.Var3 RealInputVars.V3
graph FileReader.Var4 RealInputVars.V4

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Created: Di. Jan. 7 08:53:10 2025
# LastModified: Di. Jan. 7 08:53:10 2025

tStart 0 a
tEnd 6 h
hMax 10 min
hMin 1e-05 s
hFallBackLimit 0.001 s
hStart 10 min
hOutputMin 1 h
outputTimeUnit h
adjustStepSize no
preventOversteppingOfEndTime yes
absTol 1e-06
relTol 1e-05
MasterMode GAUSS_SEIDEL
ErrorControlMode NONE
maxIterations 1
writeInternalVariables yes
writeUnconnectedFileReaderVars yes

simulator 0 0 FileReader #4682b4 "SixRealValues.tsv"
simulator 1 0 RealInputVars #6a5acd "fmus/IBK/FourRealInputVars.fmu"

graph FileReader.Var1 RealInputVars.V1
graph FileReader.Var2 RealInputVars.V2
graph FileReader.Var3 RealInputVars.V3
graph FileReader.Var4 RealInputVars.V4

8 changes: 8 additions & 0 deletions data/tests/linux64/FileReaderSlave/SixRealValues.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Time [h] Var3 [-] Var2 [-] Var6 [-] Var1 [-] Var5 [-] Var4 [-]
0 1 8 6 2 5 9
1 2 2 3 4 2 8
2 2 3 3 9 9 7
3 9 2 4 4 4 4
4 3 4 5 5 8 5
5 0 6 4 6 5 2
6 7 3 7 7 9 1

0 comments on commit 056f87f

Please sign in to comment.