Skip to content

Commit

Permalink
Merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec committed Dec 13, 2019
2 parents 6af6bc8 + dca0ee7 commit 9e53f52
Show file tree
Hide file tree
Showing 59 changed files with 1,321 additions and 123 deletions.
40 changes: 38 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -1,3 +1,39 @@
## OpenStudio Pull Request Template
Pull request overview
---------------------

Please read [OpenStudio Pull Requests](https://github.com/NREL/OpenStudio/wiki/OpenStudio-Pull-Requests) to better understand the OpenStrudio Pull Request protocol.
- Fixes #ISSUENUMBERHERE (IF THIS IS A DEFECT)
- DESCRIBE PURPOSE OF THIS PULL REQUEST

Please read [OpenStudio Pull Requests](https://github.com/NREL/OpenStudio/wiki/OpenStudio-Pull-Requests) to better understand the OpenStudio Pull Request protocol.

### Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

- [ ] Model API Changes / Additions
- [ ] Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
- [ ] Model API methods are tested (in `src/model/test`)
- [ ] EnergyPlus ForwardTranslator Tests (in `src/energyplus/Test`)
- [ ] If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
- [ ] If needed, added VersionTranslation rules for the objects (`src/osversion/VersionTranslator.cpp`)
- [ ] Checked behavior in OpenStudioApplication, adjusted policies as needed (`src/openstudio_lib/library/OpenStudioPolicy.xml`)
- [ ] Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
- [ ] All new and existing tests passes
- [ ] If methods have been deprecated, update rest of code to use the new methods

**Labels:**

- [ ] If change to an IDD file, add the label `IDDChange`
- [ ] If breaking existing API, add the label `APIChange`
- [ ] If deemed ready, add label `Pull Request - Ready for CI` so that CI builds your PR

### Review Checklist

This will not be exhaustively relevant to every PR.
- [ ] Perform a Code Review on GitHub
- [ ] Code Style, strip trailing whitespace, etc.
- [ ] All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
- [ ] Labeling is ok
- [ ] If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
- [ ] If feature, test running new feature, try creative ways to break it
- [ ] CI status: all green or justified
10 changes: 10 additions & 0 deletions Jenkinsfile_develop_format
@@ -0,0 +1,10 @@
//Jenkins pipelines are stored in shared libaries. Please see: https://github.com/tijcolem/nrel_cbci_jenkins_libs

@Library('cbci_shared_libs@develop') _

// Build for PR to develop branch only.
if ((env.CHANGE_ID) && (env.CHANGE_TARGET) ) {

openstudio_format_develop()

}
9 changes: 8 additions & 1 deletion OpenStudio.in
@@ -1,6 +1,9 @@
#ifndef OPENSTUDIO_HXX
#define OPENSTUDIO_HXX

// Support for Ninja on Windows (Ninja isn't multi-configuration while MSVC is)
#cmakedefine NINJA

inline std::string openStudioVersion()
{
return "${OPENSTUDIO_VERSION}";
Expand Down Expand Up @@ -44,7 +47,11 @@ inline std::string rubyLibDir()
inline std::string rubyOpenStudioDir()
{
#ifdef WIN32
return "${PROJECT_BINARY_DIR}/ruby/" + std::string(CMAKE_INTDIR) + "/";
#ifdef NINJA
return "${PROJECT_BINARY_DIR}/ruby/";
#else
return "${PROJECT_BINARY_DIR}/ruby/" + std::string(CMAKE_INTDIR) + "/";
#endif
#else
return "${PROJECT_BINARY_DIR}/ruby/";
#endif
Expand Down
48 changes: 48 additions & 0 deletions ci/clang-format.sh
@@ -0,0 +1,48 @@
#!/bin/bash

# This script compares two branches (eg. pr-bugfix - <> develop )
# and finds files of types cpp, hpp, c, h
# that have changed between branches and processes each of these files using clang-format.
# The default behavior of clang-format is to auto change the file and format according to the style guide (.clang-format). If these files change the CI will alert fail and alert the user to correct the changes. The user should run this script locally and accept the auto changes proposed by clang-format.

display_usage() {
echo -e "\nUsage:\ PR_BRANCH_NAME TARGET_BRANCH_NAME \n"
}

if [ $# -le 1 ]
then
display_usage
exit 1
fi

PR_BRANCH_NAME=$1
TARGET_BRANCH_NAME=$2

# first find if any files changed
num=$(git diff $PR_BRANCH_NAME $TARGET_BRANCH_NAME --name-only | grep '.*\.\(cpp\|c\|hpp\|h\)$' | wc -l | tr -d '[:space:]')

if [ $num -eq 0 ]
then
echo "No files of type (cpp, c, hpp, h) changed. Skipping clang-formatting"
exit 0
fi

git diff $PR_BRANCH_NAME $TARGET_BRANCH_NAME --name-only | grep '.*\.\(cpp\|c\|hpp\|h\)$' | xargs clang-format -style=file -i -fallback-style=none

# clang-format will auto correct files so prepare the diff and use this as artifact
git diff > clang_format.patch

# Delete if nothhing otherwise exit 1 to indicate a failed job
if [ ! -s clang_format.patch ]
then
rm clang_format.patch
exit 0
else
echo "clang-format auto corrected files:"
git diff --name-only
echo -e "\nPlease correct these files. You can run ci/clang-format.sh locally and commit changes"
exit 1
fi

exit 0

8 changes: 7 additions & 1 deletion csharp/CMakeLists.txt
Expand Up @@ -71,11 +71,17 @@ if(MSVC)

# the main OpenStudio dll
set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/$(ConfigurationName)/OpenStudio.dll")
set(CONFIG_ARGS "/p:Configuration=$(ConfigurationName)")

if(NINJA)
set(CONFIG_ARGS "/p:Configuration=${CMAKE_BUILD_TYPE}")
set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/OpenStudio.dll")
endif()

# custom command to make OPENSTUDIO_CSHARP_DLL
add_custom_command(
OUTPUT ${OPENSTUDIO_CSHARP_DLL}
COMMAND "MSBuild" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj" "/p:Configuration=$(ConfigurationName)"
COMMAND "MSBuild" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj" "${CONFIG_ARGS}"
DEPENDS ${ALL_CSHARP_WRAPPER_TARGETS} ${ALL_CSHARP_WRAPPER_FILES}
)

Expand Down
2 changes: 2 additions & 0 deletions developer/ruby/.gitignore
@@ -0,0 +1,2 @@
*.bak
deprecated_methods.md
163 changes: 163 additions & 0 deletions developer/ruby/DeprecatedMethods.rb
@@ -0,0 +1,163 @@
# This script aims to facilitate the reporting of deprecated methods
# An amount of manual work will be necessary to add relevant information in the
# resulting deprecated_methods.csv:
# * Fill the 'Replace With' with any relevant method that supersedes it
# * Add the 'Commit SHA' to the commit that deprecated the method in question

require 'fileutils'
require 'csv'

ROOT_DIR = File.absolute_path(File.join(File.dirname(__FILE__), "../../"))
DEPRECATED_CSV_PATH = File.join(File.dirname(__FILE__), 'deprecated_methods.csv')
DEPRECATED_MD_PATH = File.join(File.dirname(__FILE__), 'deprecated_methods.md')

# Parse the CMakeLists.txt for the current version
# It greps for 'project(OpenStudio VERSION X.Y.Z)
# It will raise if something goes wrong
#
# @param cmake_path [String] The path to openstudiocore CMakeLists.txt
# @return [String] the resulting version, eg "2.8.0".
def parse_version_from_cmakelist(cmake_path)
version_line = nil
File.open(cmake_path) do |f|
version_line = f.grep(/project\(OpenStudio VERSION/)
end

if version_line.nil?
raise "Couldn't find 'project(OpenStudio VERSION' in #{cmake_path}"
elsif !((version_line.class == Array) && (version_line.size == 1))
raise "Expected to find only one version in #{cmake_path}, found: #{version_line}"
end
os_version_str = version_line[0].match(/VERSION\s+(\d+\.\d+\.\d+)/).captures[0]
return os_version_str
end

# Parse the hpp files for newly added OS_DEPRECATED.
# Checks if already present in known_deprecated in which case it won't add it
# to the return new_deprecated for the current version, but wil add it to
# old_deprecated.
#
# @param known_deprecated [Array] The Array of Hash from CSV deprecated_methods.csv
# @return [Hash] keys are 'new' and 'old', each have a value that is an
# Array of hash of newly-added / known deprecated
def parse_new_deprecated(known_deprecated, os_version_str)
new_deprecated = []
old_deprecated = []
Dir.glob( File.join(ROOT_DIR, "openstudiocore/src/**/*.hpp") ) do |p|

class_name = File.basename(p).sub('.hpp', '')
content = File.read(p)
deprecated_signatures = content.scan(/OS_DEPRECATED.* (\w+)\(.*\).*;/).flatten
next if deprecated_signatures.empty?
deprecated_signatures.each do |method|
found = known_deprecated.select{|h| (h['Class Name'] == class_name) && (h['Method'] == method)}
if found
old_deprecated << found[0]
next
end

puts "Found new OS_DEPRECATED #{class_name}::#{method}"
row = {
'Namespace' => p.split('src/')[1].split('/')[0],
'Class Name' => class_name,
'Method' => method,
# has to be right now since it's new
'Deprecated Since' => os_version_str,
'Commit SHA' => nil,
'Replace With' => nil,
'Removed In' => nil,
}
new_deprecated << row
end
end

return {'new' => new_deprecated,
'old' => old_deprecated}
end

# Any stuff that is in know_deprecated but NOT in old_deprecated was recently
# removed, so we update the "Removed In" field if not already present
#
# @param known_deprecated [Array] The Array of Hash from CSV deprecated_methods.csv
# @param old_deprecated [Array] The Array of Hash of the ones we did find
#
# @return None: know_deprecated is mutated with 'Removed In'
def update_removed_deprecated(known_deprecated, old_deprecated, os_version_str)
(known_deprecated - old_deprecated).each do |h|
next if !h['Removed In'].nil?
h['Removed In'] = os_version_str
end
end

# Save to CSV (and make a copy of old CSV)
def output_to_csv(new_table)
# Create a copy of the old CSV
FileUtils.cp('deprecated_methods.csv', 'deprecated_methods.csv.bak')

CSV.open(DEPRECATED_CSV_PATH, "wb") do |csv|
csv << new_table.first.keys # adds the header
new_table.each do |hash|
csv << hash.values
end
end

puts "Saved CSV to disk to #{DEPRECATED_CSV_PATH} (backed up old to deprecated_methods.csv.bak)"

end


def add_link_to_sha(h)
dep = h['Deprecated Since']
sha = h['Commit SHA']
if dep.nil?
return ''
elsif sha.nil?
return dep
else
return "[#{dep}](https://github.com/NREL/OpenStudio/commit/#{sha})"
end
end

# Format output as a Markdown table
def output_to_markdown(new_table)

File.open(DEPRECATED_MD_PATH, 'w') do |f|

headers = ["Namespace", "Class Name", "Method", "Deprecated Since", "Replace With", "Removed In"]
f.puts headers.join(' | ')
f.puts headers.map{'---'}.join(' | ')

new_table.each do |h|
toprint = [
h['Namespace'], h['Class Name'], h['Method'], add_link_to_sha(h), h['Replace With'], h['Removed In']
]
f.puts toprint.join(' | ')
end
end
puts "Saved Markdown Table to disk to #{DEPRECATED_MD_PATH}"

end

cmake_path = File.join(ROOT_DIR, 'openstudiocore/CMakeLists.txt')
os_version_str = parse_version_from_cmakelist(cmake_path)


# Load Deprecated methods
raw_data = CSV.table(DEPRECATED_CSV_PATH, {:header_converters => nil})
known_deprecated = raw_data.map { |row| row.to_hash }

x = parse_new_deprecated(known_deprecated, os_version_str)
new_deprecated = x['new']
old_deprecated = x['old']
update_removed_deprecated(known_deprecated, old_deprecated, os_version_str)

new_table = known_deprecated + new_deprecated
output_to_csv(new_table)
output_to_markdown(new_table)







27 changes: 27 additions & 0 deletions developer/ruby/deprecated_methods.csv
@@ -0,0 +1,27 @@
Namespace,Class Name,Method,Deprecated Since,Commit SHA,Replace With,Removed In
measure,OSMeasure,registerWithSketchUp,,,None,
measure,OSMeasure,registerWithApplication,,,None,
model,AvailabilityManagerNightCycle,controlThermalZone,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b7,controlThermalZones,
model,AvailabilityManagerNightCycle,setControlThermalZone,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b8,setControlThermalZones,
model,AvailabilityManagerNightCycle,resetControlThermalZone,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b9,resetControlThermalZones,
model,AirLoopHVAC,availabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b10,availabilityManagers,
model,AirLoopHVAC,setAvailabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b11,"addAvailabilityManager, setAvailabilityManagers",
model,AirLoopHVAC,resetAvailabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b12,resetAvailabilityManagers,
model,PlantLoop,availabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b13,availabilityManagers,
model,PlantLoop,setAvailabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b14,"addAvailabilityManager, setAvailabilityManagers",
model,PlantLoop,resetAvailabilityManager,2.3.1,3578590b7e63a68bedb7e43bef21f50552e0c6b15,resetAvailabilityManagers,
model,Node,addSetpointManager,1.13.0,40c19546076be456f110ca542cd70ce711541961,SetpointManagerXXX::addToNode,
model,Node,addSetpointManagerWarmest,1.13.0,40c19546076be456f110ca542cd70ce711541962,SetpointManagerWarmest::addToNode,
model,Node,getSetpointManagerSingleZoneReheat,1.13.0,40c19546076be456f110ca542cd70ce711541963,Node::setpointManagers,
model,Node,getSetpointManagerMixedAir,1.13.0,40c19546076be456f110ca542cd70ce711541964,Node::setpointManagers,
model,Node,setpointManagerScheduled,1.13.0,40c19546076be456f110ca542cd70ce711541965,Node::setpointManagers,
model,Node,setpointManagerFollowOutdoorAirTemperature,1.13.0,40c19546076be456f110ca542cd70ce711541966,Node::setpointManagers,
model,Node,setpointManagerOutdoorAirReset,1.13.0,40c19546076be456f110ca542cd70ce711541967,Node::setpointManagers,
model,Node,setpointManagerWarmest,1.13.0,40c19546076be456f110ca542cd70ce711541968,Node::setpointManagers,
model,Node,removeSetpointManagerSingleZoneReheat,1.13.0,40c19546076be456f110ca542cd70ce711541969,SetpointManagerSingleZoneReheat::remove,
model,Node,removeSetpointManagerWarmest,1.13.0,40c19546076be456f110ca542cd70ce711541970,SetpointManagerWarmest::remove,
model,Node,removeSetpointManagerOutdoorAirReset,1.13.0,40c19546076be456f110ca542cd70ce711541971,SetpointManagerOutdoorAirReset::remove,
model,Node,removeSetpointManagerFollowOutdoorAirTemperature,1.13.0,40c19546076be456f110ca542cd70ce711541972,SetpointManagerFollowOutdoorAirTemperature::remove,
model,Node,removeSetpointManagerScheduled,1.13.0,40c19546076be456f110ca542cd70ce711541973,SetpointManagerScheduled::remove,
model,Node,removeSetpointManagerMixedAir,1.13.0,40c19546076be456f110ca542cd70ce711541974,SetpointManagerMixedAir::remove,
model,ZoneVentilationDesignFlowRate,setDesignFlowRateCalculationMethod,2.3.1,9ee9be2d0da3ed954a1e98cc3ab39ec7debffa92,"Done when calling setDesignFlowRate, setFlowRateperZoneFloorArea, setAirChangesperHour",
8 changes: 8 additions & 0 deletions embedded/CMakeLists.txt
Expand Up @@ -7,3 +7,11 @@ add_executable(CreateEmbeddedSource

target_link_libraries(CreateEmbeddedSource CONAN_PKG::zlib)

# Add a specific manifest for CreateEmbeddedSource that will include the LongPathAware attribute, which,
# in conjunction with the regkey LongPathsEnabled=1 will make it work with paths that are longer than MAX_PATH (win10 only)
if( WIN32 )
add_custom_command(TARGET CreateEmbeddedSource
POST_BUILD
COMMAND mt -nologo -manifest "${CMAKE_CURRENT_SOURCE_DIR}/CreateEmbeddedSource.manifest.xml" -outputresource:$<TARGET_FILE:CreateEmbeddedSource>
)
endif()
8 changes: 8 additions & 0 deletions embedded/CreateEmbeddedSource.manifest.xml
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
</windowsSettings>
</application>
</assembly>
2 changes: 1 addition & 1 deletion pat/CMakeLists.txt
@@ -1,4 +1,4 @@
set(PAT_SHA 3c20e076f7813e7b9bc406a40314d50e0929157b)
set(PAT_SHA a3b5518bde747f0387ee9a226884e3314c5df46c)

find_program(NPM_COMMAND npm)

Expand Down
8 changes: 6 additions & 2 deletions resources/energyplus/ProposedEnergy+.idd
Expand Up @@ -40252,10 +40252,10 @@ SolarCollector:FlatPlate:Water,
A1 , \field Name
\required-field
\type alpha
\reference-class-name validPlantEquipmentTypes ! remove?
\reference validPlantEquipmentNames ! remove?
\reference-class-name validBranchEquipmentTypes
\reference validBranchEquipmentNames
\reference-class-name validPlantEquipmentTypes ! Need to be able to place it on PlantEquipmentList
\reference validPlantEquipmentNames ! Need to be able to place it on PlantEquipmentList
A2 , \field SolarCollectorPerformance Name
\required-field
\type object-list
Expand Down Expand Up @@ -40284,6 +40284,8 @@ SolarCollector:FlatPlate:PhotovoltaicThermal,
\reference validOASysEquipmentNames
\reference-class-name validBranchEquipmentTypes
\reference validBranchEquipmentNames
\reference-class-name validPlantEquipmentTypes ! Need to be able to place it on PlantEquipmentList
\reference validPlantEquipmentNames ! Need to be able to place it on PlantEquipmentList
A2 , \field Surface Name
\required-field
\type object-list
Expand Down Expand Up @@ -40351,6 +40353,8 @@ SolarCollector:IntegralCollectorStorage,
\type alpha
\reference-class-name validBranchEquipmentTypes
\reference validBranchEquipmentNames
\reference-class-name validPlantEquipmentTypes ! Need to be able to place it on PlantEquipmentList
\reference validPlantEquipmentNames ! Need to be able to place it on PlantEquipmentList
A2 , \field IntegralCollectorStorageParameters Name
\required-field
\type object-list
Expand Down

0 comments on commit 9e53f52

Please sign in to comment.