本文整理汇总了C++中OSArgument::setDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:C++ OSArgument::setDefaultValue方法的具体用法?C++ OSArgument::setDefaultValue怎么用?C++ OSArgument::setDefaultValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSArgument
的用法示例。
在下文中一共展示了OSArgument::setDefaultValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: perturbation
TEST_F(AnalysisFixture, RubyPerturbation_FreeStandingUserScript) {
// construct
openstudio::path scriptPath = toPath("myUserScript.rb");
RubyPerturbation perturbation(scriptPath,
FileReferenceType::IDF,
FileReferenceType::IDF,
true);
EXPECT_EQ(FileReferenceType(FileReferenceType::IDF),perturbation.inputFileType());
EXPECT_EQ(FileReferenceType(FileReferenceType::IDF),perturbation.outputFileType());
EXPECT_FALSE(perturbation.usesBCLMeasure());
EXPECT_ANY_THROW(perturbation.measure());
EXPECT_ANY_THROW(perturbation.measureDirectory());
EXPECT_ANY_THROW(perturbation.measureUUID());
EXPECT_ANY_THROW(perturbation.measureVersionUUID());
FileReference scriptReference = perturbation.perturbationScript();
EXPECT_EQ(scriptPath,scriptReference.path().filename());
EXPECT_EQ(boost::filesystem::system_complete(scriptPath),scriptReference.path());
EXPECT_EQ(FileReferenceType(FileReferenceType::RB),scriptReference.fileType());
EXPECT_TRUE(perturbation.arguments().empty());
EXPECT_TRUE(perturbation.isUserScript());
EXPECT_FALSE(perturbation.hasIncompleteArguments());
// add arguments to fill in
OSArgument numBoilers = OSArgument::makeIntegerArgument("numBoilers");
OSArgument numChillers = OSArgument::makeIntegerArgument("numChillers");
StringVector choices;
choices.push_back("parallel");
choices.push_back("series");
OSArgument topology = OSArgument::makeChoiceArgument("topology",choices);
EXPECT_TRUE(topology.setDefaultValue("parallel"));
perturbation.setArgument(numBoilers);
perturbation.setArgument(numChillers);
perturbation.setArgument(topology);
// verify that arguments are incomplete
EXPECT_EQ(3u,perturbation.arguments().size());
EXPECT_EQ(2u,perturbation.incompleteArguments().size());
EXPECT_TRUE(perturbation.hasIncompleteArguments());
// set to different script and verify that arguments cleared
scriptPath = toPath("myOtherUserScript.rb");
perturbation.setPerturbationScript(scriptPath,
FileReferenceType::OSM,
FileReferenceType::OSM,
true);
EXPECT_EQ(FileReferenceType(FileReferenceType::OSM),perturbation.inputFileType());
EXPECT_EQ(FileReferenceType(FileReferenceType::OSM),perturbation.outputFileType());
scriptReference = perturbation.perturbationScript();
EXPECT_EQ(scriptPath,scriptReference.path().filename());
EXPECT_TRUE(perturbation.arguments().empty());
EXPECT_TRUE(perturbation.isUserScript());
EXPECT_FALSE(perturbation.hasIncompleteArguments());
}
示例2: arguments
virtual std::vector<OSArgument> arguments(const Model& model) const
{
std::vector<OSArgument> result;
OSArgument arg = makeChoiceArgumentOfWorkspaceObjects(
"lights_definition",
IddObjectType::OS_Lights_Definition,
model);
result.push_back(arg);
arg = OSArgument::makeDoubleArgument("multiplier",false);
arg.setDefaultValue(0.8);
result.push_back(arg);
return result;
}
示例3: problem
TEST_F(ProjectFixture, RubyMeasureRecord_BCLMeasure) {
// Construct problem with RubyMeasure that points to BCLMeasure
Problem problem("Problem",VariableVector(),runmanager::Workflow());
MeasureGroup dvar("Variable",MeasureVector());
problem.push(dvar);
openstudio::path measuresPath = resourcesPath() / toPath("/utilities/BCL/Measures");
openstudio::path dir = measuresPath / toPath("SetWindowToWallRatioByFacade");
BCLMeasure measure = BCLMeasure::load(dir).get();
RubyMeasure rpert(measure);
dvar.push(rpert);
OSArgument arg = OSArgument::makeDoubleArgument("wwr");
arg.setValue(0.4);
rpert.setArgument(arg);
arg = OSArgument::makeIntegerArgument("typo_arg");
arg.setDefaultValue(1);
rpert.setArgument(arg);
// Serialize to database
{
ProjectDatabase database = getCleanDatabase("RubyMeasureRecord_BCLMeasure");
bool didStartTransaction = database.startTransaction();
EXPECT_TRUE(didStartTransaction);
// Problem Record
ProblemRecord problemRecord = ProblemRecord::factoryFromProblem(problem,database);
database.save();
if (didStartTransaction) {
EXPECT_TRUE(database.commitTransaction());
}
}
// Re-open database, de-serialize, verify that RubyMeasure is intact.
openstudio::path tempDir1 = measuresPath / toPath(toString(createUUID()));
{
ProjectDatabase database = getExistingDatabase("RubyMeasureRecord_BCLMeasure");
ASSERT_EQ(1u,ProblemRecord::getProblemRecords(database).size());
ASSERT_EQ(1u,MeasureGroupRecord::getMeasureGroupRecords(database).size());
EXPECT_EQ(1u,RubyMeasureRecord::getRubyMeasureRecords(database).size());
MeasureRecordVector dprs = MeasureGroupRecord::getMeasureGroupRecords(database)[0].measureRecords(false);
ASSERT_EQ(1u,dprs.size());
ASSERT_TRUE(dprs[0].optionalCast<RubyMeasureRecord>());
RubyMeasureRecord rpr = dprs[0].cast<RubyMeasureRecord>();
RubyMeasure rp = rpr.rubyMeasure();
EXPECT_TRUE(rp.usesBCLMeasure());
EXPECT_TRUE(rp.measure());
EXPECT_EQ(dir,rp.measureDirectory());
EXPECT_EQ(measure.uuid(),rp.measureUUID());
EXPECT_EQ(measure.versionUUID(),rp.measureVersionUUID());
EXPECT_ANY_THROW(rp.perturbationScript());
EXPECT_EQ(2u,rp.arguments().size());
EXPECT_FALSE(rp.hasIncompleteArguments());
// Update measure and save
BCLMeasure newVersion = measure.clone(tempDir1).get();
newVersion.setDescription("Window to wall ratio with sill height configurable.");
newVersion.save();
EXPECT_NE(measure.versionUUID(),newVersion.versionUUID());
OSArgumentVector args;
args.push_back(OSArgument::makeDoubleArgument("wwr"));
args.push_back(OSArgument::makeDoubleArgument("sillHeight"));
Problem problemCopy = ProblemRecord::getProblemRecords(database)[0].problem();
problemCopy.updateMeasure(newVersion,args,false);
bool didStartTransaction = database.startTransaction();
EXPECT_TRUE(didStartTransaction);
// Problem Record
ProblemRecord problemRecord = ProblemRecord::factoryFromProblem(problemCopy,database);
database.save();
if (didStartTransaction) {
EXPECT_TRUE(database.commitTransaction());
}
}
// Re-open database, check that old argument records are gone, check that de-serialized object ok
openstudio::path tempDir2 = measuresPath / toPath(toString(createUUID()));
{
ProjectDatabase database = getExistingDatabase("RubyMeasureRecord_BCLMeasure");
ASSERT_EQ(1u,ProblemRecord::getProblemRecords(database).size());
EXPECT_EQ(1u,MeasureGroupRecord::getMeasureGroupRecords(database).size());
EXPECT_EQ(1u,RubyMeasureRecord::getRubyMeasureRecords(database).size());
EXPECT_EQ(1u,FileReferenceRecord::getFileReferenceRecords(database).size());
EXPECT_EQ(2u,OSArgumentRecord::getOSArgumentRecords(database).size());
Problem problemCopy = ProblemRecord::getProblemRecords(database)[0].problem();
InputVariableVector vars = problemCopy.variables();
ASSERT_FALSE(vars.empty());
ASSERT_TRUE(vars[0].optionalCast<MeasureGroup>());
MeasureVector dps = vars[0].cast<MeasureGroup>().measures(false);
ASSERT_FALSE(dps.empty());
ASSERT_TRUE(dps[0].optionalCast<RubyMeasure>());
RubyMeasure rp = dps[0].cast<RubyMeasure>();
EXPECT_TRUE(rp.usesBCLMeasure());
EXPECT_TRUE(rp.measure());
EXPECT_EQ(tempDir1,rp.measureDirectory());
//.........这里部分代码省略.........