| 339 | /// @endcond |
| 340 | |
| 341 | bool isCompatible(const ScheduleTypeLimits& parentLimits, const ScheduleTypeLimits& candidate) { |
| 342 | if (candidate == parentLimits) { |
| 343 | return true; |
| 344 | } |
| 345 | |
| 346 | // check continuous/discrete |
| 347 | if (OptionalString numericType = parentLimits.numericType()) { |
| 348 | if (!candidate.numericType() || !istringEqual(candidate.numericType().get(), *numericType)) { |
| 349 | return false; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | // check unit type |
| 354 | std::string unitType = parentLimits.unitType(); |
| 355 | if (parentLimits.isUnitTypeDefaulted() || istringEqual("Dimensionless", unitType)) { |
| 356 | if (!(candidate.isUnitTypeDefaulted() || (istringEqual("Dimensionless", candidate.unitType())))) { |
| 357 | return false; |
| 358 | } |
| 359 | } else { |
| 360 | if (!istringEqual(candidate.unitType(), unitType)) { |
| 361 | return false; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | // check lower limit |
| 366 | if (parentLimits.lowerLimitValue()) { |
| 367 | if (!candidate.lowerLimitValue() || (candidate.lowerLimitValue().get() < parentLimits.lowerLimitValue().get())) { |
| 368 | return false; |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | // check upper limit |
| 373 | if (parentLimits.upperLimitValue()) { |
| 374 | if (!candidate.upperLimitValue() || (candidate.upperLimitValue().get() > parentLimits.upperLimitValue().get())) { |
| 375 | return false; |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | // passed all checks |
| 380 | return true; |
| 381 | } |
| 382 | |
| 383 | } // namespace model |
| 384 | } // namespace openstudio |