Пример #1
0
  // remove all spaces and add a new one
  virtual bool run(Model& model,
                   OSRunner& runner,
                   const std::map<std::string, OSArgument>& user_arguments) const
  {
    ModelUserScript::run(model,runner,user_arguments);

    // no arguments, so do not bother validating them

    std::stringstream ss;

    // remove old spaces
    int count(0);
    for (openstudio::model::Space space : model.getModelObjects<openstudio::model::Space>()) {
      space.remove();
      ++count;
    }
    ss << "Initial model had " << count << " spaces.";
    runner.registerInitialCondition(ss.str()); ss.str("");

    // add a new one
    openstudio::model::Space space(model);

    ss << "Removed the " << count << " original spaces, and added one new one named '" << space.name().get() << "'.";
    runner.registerFinalCondition(ss.str());

    // success
    return true;
  }
Пример #2
0
bool ModelUserScript::run(openstudio::model::Model& model,
                          OSRunner& runner,
                          const std::map<std::string, OSArgument>& user_arguments) const
{
  runner.prepareForUserScriptRun(*this);
  return true;
}
bool WorkspaceUserScript::run(openstudio::Workspace& workspace,
                              OSRunner& runner,
                              const std::map<std::string, OSArgument>& user_arguments) const
{
  runner.prepareForUserScriptRun(*this);
  return true;
}
Пример #4
0
TEST_F(RulesetFixture, RegisterValueNames) {
  OSRunner runner;
  runner.registerValue("value", 0);
  runner.registerValue("ValueTwo", 1);
  runner.registerValue("VALUETHREE", 2);
  runner.registerValue("4ValueFour", 3);
  runner.registerValue("Value<Five>", 4);
  runner.registerValue("#V|a@l#u$e%F^i&v*e(V)a{l}u_e[F]i;v:e'V\"a,l<u.e>F\\i/v?e+V=", 5);
  runner.registerValue("Value&$@$Six", 6);
  runner.registerValue("Value____Seven", 7);
  std::vector<Attribute> attributes = runner.result().attributes();
  ASSERT_EQ(8u, attributes.size());
  EXPECT_EQ("value", attributes[0].name());
  EXPECT_EQ("value_two", attributes[1].name());
  EXPECT_EQ("valuethree", attributes[2].name());
  EXPECT_EQ("_4_value_four", attributes[3].name());
  EXPECT_EQ("value_five", attributes[4].name());
  EXPECT_EQ("v_a_l_u_e_f_i_v_e_v_a_l_u_e_f_i_v_e_v_a_l_u_e_f_i_v_e_v", attributes[5].name());
  EXPECT_EQ("value_six", attributes[6].name());
  EXPECT_EQ("value_seven", attributes[7].name());
}
Пример #5
0
  // remove all spaces and add a new one
  virtual bool run(Model& model,
                   OSRunner& runner,
                   const std::map<std::string, OSArgument>& user_arguments) const
  {
    ModelUserScript::run(model,runner,user_arguments); // initializes runner

    // calls runner.registerAttribute for 'lights_definition' and 'multiplier'
    if (!runner.validateUserArguments(arguments(model),user_arguments)) {
      return false;
    }

    // lights_definition argument value will be object handle
    Handle h = toUUID(runner.getStringArgumentValue("lights_definition",user_arguments));

    OptionalWorkspaceObject wo = model.getObject(h);
    if (!wo) {
      std::stringstream ss;
      ss << "Object " << toString(h) << " not found in model.";
      runner.registerError(ss.str());
      return false;
    }

    OptionalLightsDefinition lightsDef = wo->optionalCast<LightsDefinition>();
    if (!lightsDef) {
      std::stringstream ss;
      ss << wo->briefDescription() << " is not a LightsDefinition.";
      runner.registerError(ss.str());
      return false;
    }
    // save name of lights definition
    runner.registerValue("lights_definition_name",lightsDef->name().get());

    if (!(lightsDef->designLevelCalculationMethod() == "Watts/Area")) {
      std::stringstream ss;
      ss << "This measure only applies to lights definitions that are in units of Watts/Area. ";
      ss << lightsDef->briefDescription() << " is in units of ";
      ss << lightsDef->designLevelCalculationMethod() << ".";
      runner.registerAsNotApplicable(ss.str());
      return true;
    }

    double multiplier = runner.getDoubleArgumentValue("multiplier",user_arguments);

    if (multiplier < 0.0) {
      std::stringstream ss;
      ss << "The lighting power density multiplier must be greater than or equal to 0. ";
      ss << "Instead, it is " << toString(multiplier) << ".";
      runner.registerError(ss.str());
      return false;
    }

    double originalValue = lightsDef->wattsperSpaceFloorArea().get();
    double newValue = multiplier * originalValue;

    lightsDef->setWattsperSpaceFloorArea(newValue);

    // register effects of this measure

    // human-readable
    std::stringstream ss;
    ss << "The lighting power density of " << lightsDef->briefDescription();
    ss << ", which is used by " << lightsDef->quantity() << " instances covering ";
    ss << lightsDef->floorArea() << " m^2 of floor area, was " << originalValue << ".";
    runner.registerInitialCondition(ss.str()); ss.str("");
    ss << "The lighting power density of " << lightsDef->briefDescription();
    ss << " has been changed to " << newValue << ".";
    runner.registerFinalCondition(ss.str()); ss.str("");

    // machine-readable
    runner.registerValue("lpd_in","Input Lighting Power Density",originalValue,"W/m^2");
    runner.registerValue("lpd_out","Output Lighting Power Density",newValue,"W/m^2");
    runner.registerValue("lights_definition_num_instances",lightsDef->quantity());
    runner.registerValue("lights_definition_floor_area",
                         "Floor Area using this Lights Definition (SI)",
                         lightsDef->floorArea(),
                         "m^2");
    runner.registerValue("lights_definition_floor_area_ip",
                         "Floor Area using this Lights Definition (IP)",
                         convert(lightsDef->floorArea(),"m^2","ft^2").get(),
                         "ft^2");

    return true;
  }
Пример #6
0
bool ReportingMeasure::run(OSRunner& runner,
                           const std::map<std::string, OSArgument>& user_arguments) const
{
  runner.prepareForMeasureRun(*this);
  return true;
}
Пример #7
0
bool UtilityUserScript::run(OSRunner& runner,
                            const std::map<std::string, OSArgument>& user_arguments) const
{
  runner.prepareForUserScriptRun(*this);
  return true;
}