Пример #1
0
Quantity dot(OSQuantityVector lVector, const OSQuantityVector& rVector) {
  Unit lUnits(lVector.units()), rUnits(rVector.units());
  OptionalTemperatureUnit ltu = lUnits.optionalCast<TemperatureUnit>();
  OptionalTemperatureUnit rtu = rUnits.optionalCast<TemperatureUnit>();
  Unit resultUnits;
  if (ltu && rtu) {
    resultUnits = ltu.get() * rtu.get();
  }
  else {
    resultUnits = lUnits * rUnits;
  }
  ScaleOpReturnType resultScale = lVector.scale() * rVector.scale();
  lVector *= resultScale.second;
  DoubleVector lValues(lVector.values()), rValues(rVector.values());
  double resultValue = dot(createVector(lValues),createVector(rValues));
  return Quantity(resultValue,resultUnits);
}
Пример #2
0
OSQuantityVector convert(const OSQuantityVector& original, const Unit& targetUnits) {
  OSQuantityVector result;
  Quantity testQuantity(0.0,original.units());
  OptionalQuantity offset = convert(testQuantity,targetUnits);
  if (!offset) {
    return result;
  }
  testQuantity.setValue(1.0);
  OptionalQuantity factorPlusOffset = convert(testQuantity,targetUnits);
  OS_ASSERT(factorPlusOffset);
  OS_ASSERT(offset->units() == factorPlusOffset->units());
  result = OSQuantityVector(offset->units(),original.values());
  result = result * (factorPlusOffset->value() - offset->value()) + offset.get();
  return result;
}
Пример #3
0
TEST_F(ModelFixture,People_Schedule_Quantities) {
  Model model;
  PeopleDefinition definition(model);
  definition.setNumberofPeople(Quantity(100.0,createSIPeople()));

  People people(definition);
  ScheduleRuleset activityLevelSchedule(model);
  EXPECT_TRUE(checkOrAssignScheduleTypeLimits("People","Activity Level",activityLevelSchedule));
  ScheduleDay defaultSchedule = activityLevelSchedule.defaultDaySchedule();
  defaultSchedule.addValue(Time(0,24,0,0),Quantity(150.0,createSIPower()/createSIPeople()));
  EXPECT_TRUE(people.setActivityLevelSchedule(activityLevelSchedule));
  OSQuantityVector ipValues = defaultSchedule.getValues(true);
  EXPECT_EQ("W/person",ipValues.units().prettyString());
  EXPECT_DOUBLE_EQ(150.0,ipValues.values()[0]);
}
Пример #4
0
OSQuantityVector::OSQuantityVector(const OSQuantityVector& other)
  : m_units(other.units()), m_values(other.values())
{}
Пример #5
0
bool operator==(const OSQuantityVector& lVector,const OSQuantityVector& rVector) {
  return (&lVector == &rVector) || ((lVector.units() == rVector.units()) && (lVector.values() == rVector.values()));
}