NatLabRockies / NatLabRockies/OpenStudio

BCLXML doesn't handle AttributeVector

Open
#5,364 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component - Measures
Dominant language
C++
Stars
646
Forks
237
Avg merge
3d 11h
Merged PRs (30d)
10

Description

Issue overview

OpenStudio::Attribute has an AttributeVector value type, but it is not supported by BCLXML.

Current Behavior

No warning is issued, but it is not serialized in saving. Nor would it be read.

https://github.com/NREL/OpenStudio/blob/4303dda75d9f59da5e4bd51974410263444bb5a5/src/utilities/bcl/BCLXML.cpp#L687-L690

Expected Behavior

We should implement support for it, or warn when you try to add an AttributeVector in BCLXML::addAttribute.

Steps to Reproduce

bclXML = OpenStudio::BCLXML.new('measure.xml')

consideration1 = OpenStudio::Attribute.new("consideration", "Check transformer capacity when installing a heat pump.")
consideration2 = OpenStudio::Attribute.new("consideration", "Verify wiring compliance with local electrical codes before installation.")
implementation_considerations = OpenStudio::Attribute.new("implementation_considerations", [consideration1, consideration2])

n = bclXML.attributes.size

# The bclXML has the new attribute, but it will NOT be serialized to measure.xml when you save, nor in puts
bclXML.addAttribute(implementation_considerations)
raise unless bclXML.attributes.size == n + 1
puts bclXML
  <attributes>
    <attribute>
      <name>Measure Type</name>
      <value>ModelMeasure</value>
      <datatype>string</datatype>
    </attribute>
    <attribute>
      <name>Measure Language</name>
      <value>Ruby</value>
      <datatype>string</datatype>
    </attribute>
-   <attribute>
-      <name>string_attribute</name>
-      <datatype>AttributeVector<datatype>
-         <value>
-            <attributes>...</attributes>
-         </value>
-    </attribute>
  </attributes>

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): All
  • Version of OpenStudio (if using an intermediate build, include SHA): 3.10.0-alpha
Context

Just realized this after trying to add nested attributes in measure.xml

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/utilities/bcl/BCLXML.cpp around lines 687-690 and inspect BCLXML::addAttribute, using the Ruby reproduction with measure.xml as the first check. Trace how existing attribute types are serialized and read. Done means AttributeVector is handled consistently, or addAttribute clearly warns when it is unsupported, with the reproduction no longer silently losing the attribute.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, ruby
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.