remove all spaces and add a new one
| 158 | |
| 159 | // remove all spaces and add a new one |
| 160 | virtual bool run(Model& model, OSRunner& runner, const std::map<std::string, OSArgument>& user_arguments) const override { |
| 161 | ModelMeasure::run(model, runner, user_arguments); // initializes runner |
| 162 | |
| 163 | // calls runner.registerAttribute for 'lights_definition' and 'multiplier' |
| 164 | if (!runner.validateUserArguments(arguments(model), user_arguments)) { |
| 165 | return false; |
| 166 | } |
| 167 | |
| 168 | // lights_definition argument value will be object handle |
| 169 | Handle h = toUUID(runner.getStringArgumentValue("lights_definition", user_arguments)); |
| 170 | |
| 171 | OptionalWorkspaceObject wo = model.getObject(h); |
| 172 | if (!wo) { |
| 173 | std::stringstream ss; |
| 174 | ss << "Object " << toString(h) << " not found in model."; |
| 175 | runner.registerError(ss.str()); |
| 176 | return false; |
| 177 | } |
| 178 | |
| 179 | OptionalLightsDefinition lightsDef = wo->optionalCast<LightsDefinition>(); |
| 180 | if (!lightsDef) { |
| 181 | std::stringstream ss; |
| 182 | ss << wo->briefDescription() << " is not a LightsDefinition."; |
| 183 | runner.registerError(ss.str()); |
| 184 | return false; |
| 185 | } |
| 186 | // save name of lights definition |
| 187 | runner.registerValue("lights_definition_name", lightsDef->name().get()); |
| 188 | |
| 189 | if (!(lightsDef->designLevelCalculationMethod() == "Watts/Area")) { |
| 190 | std::stringstream ss; |
| 191 | ss << "This measure only applies to lights definitions that are in units of Watts/Area. "; |
| 192 | ss << lightsDef->briefDescription() << " is in units of "; |
| 193 | ss << lightsDef->designLevelCalculationMethod() << "."; |
| 194 | runner.registerAsNotApplicable(ss.str()); |
| 195 | return true; |
| 196 | } |
| 197 | |
| 198 | double multiplier = runner.getDoubleArgumentValue("multiplier", user_arguments); |
| 199 | |
| 200 | if (multiplier < 0.0) { |
| 201 | std::stringstream ss; |
| 202 | ss << "The lighting power density multiplier must be greater than or equal to 0. "; |
| 203 | ss << "Instead, it is " << toString(multiplier) << "."; |
| 204 | runner.registerError(ss.str()); |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | double originalValue = lightsDef->wattsperSpaceFloorArea().get(); |
| 209 | double newValue = multiplier * originalValue; |
| 210 | |
| 211 | lightsDef->setWattsperSpaceFloorArea(newValue); |
| 212 | |
| 213 | // register effects of this measure |
| 214 | |
| 215 | // human-readable |
| 216 | std::stringstream ss; |
| 217 | ss << "The lighting power density of " << lightsDef->briefDescription(); |
nothing calls this directly
no test coverage detected