Description
ReverseTranslator is checking for duplicate objects here: https://github.com/NatLabRockies/OpenStudio/blob/develop/src/energyplus/ReverseTranslator.cpp#L1079
This comparison not correctly detecting duplicate objects, this leads to duplicate IdfObjects in the untranslatedIdfObjects which makes it hard to use the output.
This may be related to: Possibly related to #55
Current Behavior
When importing an IdfFile, duplicate IdfObjects are returned in ReverseTranslator::untranslatedIdfObjects
Expected Behavior
ReverseTranslator::untranslatedIdfObjects should not include duplicate objects
Steps to reproduce
openstudio.exe reverseTranslate.rb 5ZoneCoolBeam.idf will return missed duplicate with equal fields for AirLoopHVAC, VAV Sys 1 and ScheduleTypeLimits, Any Number?
require 'openstudio'
OpenStudio::Logger.instance.standardOutLogger.setLogLevel(OpenStudio::Trace)
path = ARGV[0]
idf = OpenStudio::IdfFile::load(OpenStudio::Path.new(path), "EnergyPlus".to_IddFileType)
workspace = OpenStudio::Workspace.new(idf.get, "None".to_StrictnessLevel)
translator = OpenStudio::EnergyPlus::ReverseTranslator.new
model = translator.translateWorkspace(workspace)
untranslated_idf_objects = translator.untranslatedIdfObjects
(0...untranslated_idf_objects.size).each do |i|
(i+1...untranslated_idf_objects.size).each do |j|
if untranslated_idf_objects[i] == untranslated_idf_objects[j]
# this check doesn't work
puts "duplicate"
elsif untranslated_idf_objects[i].iddObject == untranslated_idf_objects[j].iddObject &&
untranslated_idf_objects[i].numFields == untranslated_idf_objects[j].numFields &&
untranslated_idf_objects[i].numFields > 0 &&
untranslated_idf_objects[i].dataFieldsEqual(untranslated_idf_objects[j])
puts "missed duplicate with equal fields:\n\n#{untranslated_idf_objects[i]}\n#{untranslated_idf_objects[j]}"
end
end
end
Possible Solution
Use a different method to detect duplicates in ReverseTranslator
Operating System affected
No response
Environment
N/A
Version of OpenStudio
3.11.0
Context
No response
Description
ReverseTranslator is checking for duplicate objects here: https://github.com/NatLabRockies/OpenStudio/blob/develop/src/energyplus/ReverseTranslator.cpp#L1079
This comparison not correctly detecting duplicate objects, this leads to duplicate IdfObjects in the untranslatedIdfObjects which makes it hard to use the output.
This may be related to: Possibly related to #55
Current Behavior
When importing an IdfFile, duplicate IdfObjects are returned in ReverseTranslator::untranslatedIdfObjects
Expected Behavior
ReverseTranslator::untranslatedIdfObjects should not include duplicate objects
Steps to reproduce
openstudio.exe reverseTranslate.rb 5ZoneCoolBeam.idfwill return missed duplicate with equal fields for AirLoopHVAC, VAV Sys 1 and ScheduleTypeLimits, Any Number?Possible Solution
Use a different method to detect duplicates in ReverseTranslator
Operating System affected
No response
Environment
N/A
Version of OpenStudio
3.11.0
Context
No response