Skip to content

Commit

Permalink
Merge branch 'develop' into coil-thermal-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-robertson committed Jan 16, 2024
2 parents 5543a5e + ecdc636 commit 2340337
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildCSharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: buildCSharpSDK

on:
push:
branches: [ master, develop, CSharp ]
branches: [ master, CSharp ]
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python_bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Python Bindings

on:
push:
branches: [ master, develop, actions_pypi ]
branches: [ master, actions_pypi ]
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
Expand Down
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ set(ENERGYPLUS_BUILD_SHA "7636e6b3e9")

# ENERGYPLUS_RELEASE_NAME is used to locate the E+ download
# from the github releases
set(ENERGYPLUS_RELEASE_NAME "v23.2.0")
set(ENERGYPLUS_RELEASE_NAME "v23.2.0-WithMacStaticLibs")

set(ENERGYPLUS_REPO "NREL")
set(ENERGYPLUS_REPO "jmarrec") # TODO: temp

# Radiance
set(RADIANCE_VERSION "5.0.a.12")
Expand Down Expand Up @@ -625,10 +625,10 @@ endif()
if(UNIX)
if(APPLE)
if (ARCH MATCHES "arm64")
set(ENERGYPLUS_EXPECTED_HASH 918a4544793aafc32df5910c83f05f1a)
set(ENERGYPLUS_EXPECTED_HASH 72948a3f884ce9fe44145210eceb8259)
set(ENERGYPLUS_PLATFORM "Darwin-macOS12.1-arm64")
else()
set(ENERGYPLUS_EXPECTED_HASH b8c1ee3fe45318a4575078de07cc5656)
set(ENERGYPLUS_EXPECTED_HASH 219c1a5cfec7b6fd6bd8507c043b82ab)
set(ENERGYPLUS_PLATFORM "Darwin-macOS10.15-x86_64")
endif()
elseif(LSB_RELEASE_ID_SHORT MATCHES "CentOS")
Expand Down Expand Up @@ -1089,8 +1089,7 @@ mark_as_advanced(MAXIMIZE_CPU_USAGE)
# Doxygen
if(BUILD_DOCUMENTATION)
# need doxygen
find_package(Doxygen REQUIRED)

find_package(Doxygen 1.8.7...<1.8.9 REQUIRED)
# if have dot you have more options
#if(DOXYGEN_DOT_FOUND)

Expand Down
10 changes: 7 additions & 3 deletions ruby/bindings/InitRubyBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,13 @@ class RubyMeasureInfoBinding < OpenStudio::Measure::MeasureInfoBinding
readme_out_path = File.join(File.dirname(readme_in_path), File.basename(readme_in_path, File.extname(readme_in_path)))
readme_in = File.read(readme_in_path)
renderer = ERB.new(readme_in)
readme_out = renderer.result(get_binding())
rescue
info = OpenStudio::Measure::OSMeasureInfo.new(e.message)
b = get_binding()
readme_out = renderer.result(b)
rescue => e
exception_msg = "Failed to Render ERB file: #{e.class}: #{e.message}\nTraceback:\n"
exception_msg += e.backtrace.join("\n")
STDERR.puts exception_msg
# info = OpenStudio::Measure::OSMeasureInfo.new(exception_msg)
return false # @info
end
# write README.md file
Expand Down
24 changes: 23 additions & 1 deletion src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,17 @@ if(BUILD_TESTING)

# Test via optparse and check file exists
# Historical CLI versions
add_test(NAME OpenStudioCLI.Classic.execute_ruby_script.forward_flags.optparse.path_forwardslash
add_test(NAME OpenStudioCLI.Classic.execute_ruby_script.forward_flags.optparse.path_forwardslash
COMMAND $<TARGET_FILE:openstudio> classic execute_ruby_script execute_ruby_script_optparse_path.rb -x "./test_folder/hello.xml"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test/"
)
add_test(NAME OpenStudioCLI.Classic.execute_ruby_script.forward_flags.forward_help
COMMAND $<TARGET_FILE:openstudio> classic execute_ruby_script ${CMAKE_CURRENT_SOURCE_DIR}/test/execute_ruby_script_optparse_path.rb --help
)
set_tests_properties(OpenStudioCLI.Classic.execute_ruby_script.forward_flags.forward_help PROPERTIES
PASS_REGULAR_EXPRESSION "The Ruby help description."
)

if (WIN32)
# Posix paths don't understand a backward slash anyways
add_test(NAME OpenStudioCLI.Classic.execute_ruby_script.forward_flags.optparse.path_backwardslash
Expand All @@ -313,6 +320,21 @@ if(BUILD_TESTING)
COMMAND $<TARGET_FILE:openstudio> execute_ruby_script execute_ruby_script_optparse_path.rb -x "./test_folder/hello.xml"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test/"
)

add_test(NAME OpenStudioCLI.execute_ruby_script.forward_flags.forward_help
COMMAND $<TARGET_FILE:openstudio> execute_ruby_script ${CMAKE_CURRENT_SOURCE_DIR}/test/execute_ruby_script_optparse_path.rb --help
)
set_tests_properties(OpenStudioCLI.execute_ruby_script.forward_flags.forward_help PROPERTIES
PASS_REGULAR_EXPRESSION "The Ruby help description."
)

add_test(NAME OpenStudioCLI.execute_python_script.forward_flags.forward_help
COMMAND $<TARGET_FILE:openstudio> execute_python_script ${CMAKE_CURRENT_SOURCE_DIR}/test/execute_python_script_argparse_path.py --help
)
set_tests_properties(OpenStudioCLI.execute_python_script.forward_flags.forward_help PROPERTIES
PASS_REGULAR_EXPRESSION "The Python help description."
)

if (WIN32)
add_test(NAME OpenStudioCLI.execute_ruby_script.forward_flags.optparse.path_backwardslash
COMMAND $<TARGET_FILE:openstudio> execute_ruby_script execute_ruby_script_optparse_path.rb -x ".\\test_folder\\hello.xml"
Expand Down
6 changes: 5 additions & 1 deletion src/cli/MeasureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,12 @@ openstudio::measure::OSMeasureInfo MeasureManager::getMeasureInfo(const openstud

// TODO: for ruby at least, need to try the arity... model was added later, at 3.0.0
const int numArgs = (*thisEngine)->numberOfArguments(measureScriptObject, "arguments");
fmt::print("numArgs={}\n", numArgs);
// fmt::print("numArgs={}\n", numArgs);
if (numArgs == 0) {
auto msg = fmt::format("Reporting Measure at '{}' is using the old format where the 'arguments' method does not take model. "
" Please consider updating this to `def arguments(model)`.",
scriptPath_->generic_string());
fmt::print("{}\n", msg);
if (measureLanguage == MeasureLanguage::Ruby) {
auto patchArgumentsCmd = fmt::format(R"ruby(
module {0}Extensions
Expand Down
2 changes: 2 additions & 0 deletions src/cli/UpdateCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ namespace cli {
cmd += fmt::format(R"(
begin
require '{}'
rescue SystemExit
# puts "help was called"
rescue Exception => e
puts
puts "Error: #{{e.message}}"
Expand Down
40 changes: 21 additions & 19 deletions src/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,30 +244,32 @@ int main(int argc, char* argv[]) {
// {
auto* execute_ruby_scriptCommand = app.add_subcommand("execute_ruby_script", "Executes a ruby file");
openstudio::filesystem::path rubyScriptPath;
execute_ruby_scriptCommand->add_option("path", rubyScriptPath, "Path to ruby file")->required(true)->check(CLI::ExistingFile);
// We can't do this because that means we can't pass extra **flags**
// std::vector<std::string> executeRubyScriptCommandArgs;
// execute_ruby_scriptCommand->add_option("arguments", executeRubyScriptCommandArgs, "Arguments to pass to the ruby file")
// ->required(false)
// ->option_text("args");
execute_ruby_scriptCommand->allow_extras(true);
execute_ruby_scriptCommand->footer("You can pass extra arguments after the ruby file, they will be forwarded.");

execute_ruby_scriptCommand->callback([&rubyScriptPath, &rubyEngine, &execute_ruby_scriptCommand] {
openstudio::cli::executeRubyScriptCommand(rubyScriptPath, rubyEngine, execute_ruby_scriptCommand->remaining());
});
std::vector<std::string> ruby_fwd_args;
execute_ruby_scriptCommand->add_option("path", rubyScriptPath, "Path to Ruby file")
->option_text("RUBY_SCRIPT")
->required(true)
->check(CLI::ExistingFile);
execute_ruby_scriptCommand->add_option("args", ruby_fwd_args, "Extra Arguments forwarded to the Ruby script")->option_text("ARG ...");
execute_ruby_scriptCommand->positionals_at_end(true);
execute_ruby_scriptCommand->footer("Any additional arguments passed after the Ruby file are forwarded");
execute_ruby_scriptCommand->callback(
[&rubyScriptPath, &rubyEngine, &ruby_fwd_args] { openstudio::cli::executeRubyScriptCommand(rubyScriptPath, rubyEngine, ruby_fwd_args); });
// }

// {
auto* execute_python_scriptCommand = app.add_subcommand("execute_python_script", "Executes a python file");
openstudio::filesystem::path pythonScriptPath;
execute_python_scriptCommand->add_option("path", pythonScriptPath, "Path to python file")->required(true)->check(CLI::ExistingFile);

execute_python_scriptCommand->allow_extras(true);
execute_python_scriptCommand->footer("You can pass extra arguments after the python file, they will be forwarded.");

execute_python_scriptCommand->callback([&pythonScriptPath, &pythonEngine, &execute_python_scriptCommand] {
openstudio::cli::executePythonScriptCommand(pythonScriptPath, pythonEngine, execute_python_scriptCommand->remaining());
std::vector<std::string> python_fwd_args;
execute_python_scriptCommand->add_option("path", pythonScriptPath, "Path to Python file")
->option_text("PYTHON_SCRIPT")
->required(true)
->check(CLI::ExistingFile);
execute_python_scriptCommand->add_option("args", python_fwd_args, "Extra Arguments forwarded to the Python script")->option_text("ARG ...");
execute_python_scriptCommand->positionals_at_end(true);
execute_python_scriptCommand->footer("You can pass extra arguments after the Python file, they will be forwarded.");

execute_python_scriptCommand->callback([&pythonScriptPath, &pythonEngine, &python_fwd_args] {
openstudio::cli::executePythonScriptCommand(pythonScriptPath, pythonEngine, python_fwd_args);
});
// }

Expand Down
21 changes: 21 additions & 0 deletions src/cli/test/execute_python_script_argparse_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import argparse
from pathlib import Path


def validate_file(arg):
if (filepath := Path(arg)).is_file():
return filepath
else:
raise FileNotFoundError(arg)

def validate_xml_file(arg):
filepath = validate_file(arg)
if (filepath.suffix != '.xml'):
raise FileNotFoundError(f"{arg} is not a .xml file")
return filepath

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="The Python help description.")
parser.add_argument("-x,--xml", metavar='FILE', required=True, type=validate_xml_file, help="HPXML file")
args = parser.parse_args()
print(args)
1 change: 1 addition & 0 deletions src/cli/test/execute_ruby_script_optparse_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(__FILE__)} -x building.xml"
opts.banner += "\n\nThe Ruby help description.\n\n"

opts.on('-x', '--xml <FILE>', 'HPXML file') do |t|
options[:hpxml] = t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ namespace energyplus {
idfObject.setDouble(AirConditioner_VariableRefrigerantFlowFields::RatioofCompressorSizetoTotalCompressorCapacity, value.get());
}

// MaximumOutdoorDrybulbTemperatureforCrankcaseHeater
// MaximumOutdoorDryBulbTemperatureforCrankcaseHeater

if ((value = modelObject.maximumOutdoorDrybulbTemperatureforCrankcaseHeater())) {
idfObject.setDouble(AirConditioner_VariableRefrigerantFlowFields::MaximumOutdoorDryBulbTemperatureforCrankcaseHeater, value.get());
Expand Down Expand Up @@ -550,7 +550,7 @@ namespace energyplus {

// MaximumCondenserInletNodeTemperatureinHeatRecoveryMode

if ((value = modelObject.maximumOutdoorTemperatureinHeatingMode())) {
if ((value = modelObject.maximumOutdoorTemperatureinHeatRecoveryMode())) {
idfObject.setDouble(AirConditioner_VariableRefrigerantFlowFields::MaximumCondenserInletNodeTemperatureinHeatRecoveryMode, value.get());
}

Expand All @@ -564,7 +564,7 @@ namespace energyplus {

// InitialHeatRecoveryCoolingCapacityFraction

if ((value = modelObject.initialHeatRecoveryCoolingEnergyFraction())) {
if ((value = modelObject.initialHeatRecoveryCoolingCapacityFraction())) {
idfObject.setDouble(AirConditioner_VariableRefrigerantFlowFields::InitialHeatRecoveryCoolingCapacityFraction, value.get());
}

Expand Down
Loading

0 comments on commit 2340337

Please sign in to comment.