MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / getOrCreateScheduleTypeLimits

Method getOrCreateScheduleTypeLimits

src/model/ScheduleTypeRegistry.cpp:48–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 }
47
48 ScheduleTypeLimits ScheduleTypeRegistry::getOrCreateScheduleTypeLimits(const ScheduleType& scheduleType, Model& model) const {
49 std::string defaultName = getDefaultName(scheduleType);
50
51 // DLM: I do not understand why both upper and lower limit have to be set to reuse this?
52 //// if fully specified, try to retrieve
53 //if (scheduleType.lowerLimitValue && scheduleType.upperLimitValue) {
54 ScheduleTypeLimitsVector candidates = model.getConcreteModelObjectsByName<ScheduleTypeLimits>(defaultName);
55 for (const ScheduleTypeLimits& candidate : candidates) {
56 // Pass isStringent = true, so we don't return for eg a Dimensionless schedule with limits [0.5, 0.7] when our object accepts any number
57 if (isCompatible(scheduleType, candidate, true)) {
58 return candidate;
59 }
60 }
61 //}
62
63 // otherwise, or if not there, create and return
64 ScheduleTypeLimits scheduleTypeLimits(model);
65
66 scheduleTypeLimits.setName(defaultName);
67
68 if (scheduleType.lowerLimitValue) {
69 scheduleTypeLimits.setLowerLimitValue(scheduleType.lowerLimitValue.get());
70 }
71 if (scheduleType.upperLimitValue) {
72 scheduleTypeLimits.setUpperLimitValue(scheduleType.upperLimitValue.get());
73 }
74 if (scheduleType.isContinuous) {
75 scheduleTypeLimits.setNumericType("Continuous");
76 } else {
77 scheduleTypeLimits.setNumericType("Discrete");
78 }
79 if (!scheduleType.unitType.empty()) {
80 scheduleTypeLimits.setUnitType(scheduleType.unitType);
81 }
82
83 return scheduleTypeLimits;
84 }
85
86 ScheduleTypeRegistry& ScheduleTypeRegistry::instance() {
87 static ScheduleTypeRegistry instance;

Callers 2

TEST_FFunction · 0.80

Calls 8

setLowerLimitValueMethod · 0.80
setUpperLimitValueMethod · 0.80
setNumericTypeMethod · 0.80
isCompatibleFunction · 0.70
setNameMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45
setUnitTypeMethod · 0.45

Tested by 1

TEST_FFunction · 0.64