Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lbl-srg/modelica-buildings into i…
Browse files Browse the repository at this point in the history
…ssue4090_ctrlFlowAnnot
  • Loading branch information
AntoineGautier committed Jan 13, 2025
2 parents d75d239 + 97901a0 commit 7b5019d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 35 deletions.
Git LFS file not shown
Git LFS file not shown
2 changes: 1 addition & 1 deletion Buildings/Resources/Scripts/travis/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ test-openmodelica-spawn-spaces-failure:
"simulate(SpawnTest);\n" \
"getErrorString();" > openmod.mos )
@(cd $(TMP) && omc openmod.mos > /dev/null )
@cd $(TMP) && sudo grep -q "To use EnergyPlus, the Modelica Buildings Library must be installed in a directory that has no spaces." SpawnTest.log
@cd $(TMP) && sudo grep -q "To run a simulation with EnergyPlus coupling, the working directory must not have spaces." SpawnTest.log
@sudo rm -rf $(TMP)
@echo " Success."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,34 +543,6 @@ char* findSpawnExe(FMUBuilding* bui, const char* SEARCHPATH, const char* spawnEx
return spawnFullPath;
}


void terminateIfSpacesInInstallation(FMUBuilding* bui){
const char sep = '/';
char* libBaseName;
void (*SpawnFormatError)(const char *string, ...) = bui->SpawnFormatError;
size_t lasPosInd;

const char* ptr = strrchr(bui->buildingsLibraryRoot, sep);

if (ptr == NULL){
SpawnFormatError("Error. Expected separator '%c' in '%s'.", sep, bui->buildingsLibraryRoot);
}

/* Index of last position of the separator */
lasPosInd = (size_t)(ptr - bui->buildingsLibraryRoot);

mallocString(lasPosInd + 1, "Failed to allocate memory in terminateIfSpacesInInstallation().", &libBaseName, SpawnFormatError);
/* Copy the path except for the last part of the path, which is Buildings or Buildings 8.0.0 */
memcpy(libBaseName, bui->buildingsLibraryRoot, lasPosInd);
libBaseName[lasPosInd] = '\0';


if ( strchr(libBaseName, ' ') != NULL){
SpawnFormatError("To use EnergyPlus, the Modelica Buildings Library must be installed in a directory that has no spaces. (The Buildings directory can however have spaces such as in 'Buildings 9.0.0'.) Installing in '%s' is not supported.",
libBaseName);
}
}

void generateFMU(FMUBuilding* bui, const char* spawnFullPath, const char* modelicaBuildingsJsonFile){
/* Generate the FMU */
char* optionFlags;
Expand Down Expand Up @@ -962,7 +934,7 @@ void generateAndInstantiateBuilding(FMUBuilding* bui){
if (spawnFullPath == NULL){
SpawnFormatError("Failed to find spawn executable in Buildings Library installation, on SPAWNPATH and on PATH. See installation instructions at Buildings.ThermalZones.EnergyPlus_%s.UsersGuide.Installation", bui->idfVersion);
}
terminateIfSpacesInInstallation(bui);

/* Generate FMU using spawnFullPath */
generateFMU(bui, spawnFullPath, modelicaBuildingsJsonFile);
free(spawnFullPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,15 @@ void getSimulationTemporaryDirectory(
replaceChar(curDir, '\\', '/');
#endif

/* Ensure that there are no spaces in the current working directory.
See https://github.com/lbl-srg/modelica-buildings/issues/3993
*/
if(strchr(curDir, ' ') != NULL){
SpawnFormatError(
"To run a simulation with EnergyPlus coupling, the working directory must not have spaces. Working directory is '%s'.",
curDir);
}

/* Reduced the name of modelicaNameBuilding because Windows has limits on the length
of the file name.
*/
Expand Down
10 changes: 10 additions & 0 deletions Buildings/ThermalZones/EnergyPlus_24_2_0/UsersGuide.mo
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,16 @@ of the current EnergyPlus time step.<br/>
This will be addressed through
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/2000\">issue 2000</a>.
</p>
<h5>Running Spawn from a directory with spaces</h5>
<p>
Spawn stops with an error message if run from a directory that contains spaces (because loading the FMU would fail).
Therefore, make sure the working directory has no spaces.
The installation directory of the Buildings library however is allowed to have spaces.
</p>
<p>
This error check has been introduced in
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3993\">issue 3993</a>.
</p>
</html>"));
end KnownIssues;

Expand Down
5 changes: 4 additions & 1 deletion Buildings/UsersGuide/ReleaseNotes/Version_12_0_0.mo
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ to <b style=\"color:blue\">existing</b> libraries:
<td valign=\"top\">Updated the EnergyPlus coupling to use
EnergyPlus version 24.2.0.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3911\">#3911</a>.
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3911\">#3911</a>.<br/>
Improved the error reporting if a simulation is run from a working directory that has spaces in its name.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3993\">#3993</a>.
</td>
</tr>
</table>
Expand Down

0 comments on commit 7b5019d

Please sign in to comment.