Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated orphaned ScheduleRule when making a new profile based on existing one #298

Open
rwadhwa910 opened this issue Jan 14, 2021 · 7 comments

Comments

@rwadhwa910
Copy link

I have imported a schedule from a library which has 12 different schedules within it. After getting imported each schedule creates a copy of its own schedule as shown in the image below.

OS APP 1.1.0
Windows 10
1

@rwadhwa910 rwadhwa910 added the Triage Issue needs to be assessed and labeled, further information on reported might be needed label Jan 14, 2021
@macumber
Copy link
Collaborator

Can you attach the original OSM you imported @rwadhwa910 ? By import, do you mean you loaded the OSM as a library and dragged the schedule into your model from the library?

@jmarrec
Copy link
Collaborator

jmarrec commented Feb 10, 2021

@rwadhwa910 ping.

@rwadhwa910
Copy link
Author

@macumber I imported the osm file as a library and then drag the schedules that were there in the osm file.I am not sure whether I have that osm file with me as I was working on NREL computer at that time.

@macumber
Copy link
Collaborator

I'm not seeing this same behavior but I am seeing orphan schedule day objects created when you "Make a new profile based on" another schedule.

@macumber macumber added this to the OpenStudio Application 1.3.0 milestone May 29, 2021
@jmarrec
Copy link
Collaborator

jmarrec commented Jun 1, 2021

I can't see the duplicated stuff. I suspect user tried to load the same OSM as a library, and while editing the OSM tried to import from that "library".

As far as orphaned... There's a double clone happening between the OSApp and the SDK.

void SchedulesTabController::addRule(model::ScheduleRuleset& scheduleRuleset, UUID scheduleDayHandle) {
boost::optional<model::ScheduleRule> rule;
if (!scheduleDayHandle.isNull()) {
boost::optional<model::ScheduleDay> scheduleDayToCopy = scheduleRuleset.model().getModelObject<model::ScheduleDay>(scheduleDayHandle);
if (scheduleDayToCopy) {
rule = model::ScheduleRule(scheduleRuleset, scheduleDayToCopy->clone().cast<model::ScheduleDay>());
}
}
if (!rule) {
rule = model::ScheduleRule(scheduleRuleset);
rule->daySchedule().addValue(Time(1, 0), defaultStartingValue(rule->daySchedule()));
}
OS_ASSERT(rule);
}

It's perhaps confusing but the SDK ctor ScheduleRule::ScheduleRule(ScheduleRuleset& scheduleRuleset, const ScheduleDay& daySchedule) actually clones daySchedule already internally...

https://github.com/NREL/OpenStudio/blob/92a416c03a98b44b67668e5b3d6d3c89be729afa/src/model/ScheduleRule.cpp#L600-L617

@jmarrec jmarrec added component - Backend and removed Triage Issue needs to be assessed and labeled, further information on reported might be needed labels Jun 1, 2021
@jmarrec jmarrec changed the title Multiple Copies of Schedules getting created Duplicated orphaned ScheduleRule when making a new profile based on existing one Jun 1, 2021
@jmarrec
Copy link
Collaborator

jmarrec commented Jun 1, 2021

For the record, the same applies to Summer/Winter/holiday profiles... ScheduleRuleset::setXXXDesignDaySchedule ALSO clones the schedule day it's passed (which is confusing).

https://github.com/NREL/OpenStudio/blob/92a416c03a98b44b67668e5b3d6d3c89be729afa/src/model/ScheduleRuleset.cpp#L281-L307

@jmarrec
Copy link
Collaborator

jmarrec commented Jun 3, 2022

Is there really an action item for us here? Seems like this is the default behavior of the OS SDK (which clones the schedule days), or am I misreading the situation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants