本文整理汇总了C++中Workspace::getObjectsByName方法的典型用法代码示例。如果您正苦于以下问题:C++ Workspace::getObjectsByName方法的具体用法?C++ Workspace::getObjectsByName怎么用?C++ Workspace::getObjectsByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workspace
的用法示例。
在下文中一共展示了Workspace::getObjectsByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: translateEnergyManagementSystemConstructionIndexVariable
OptionalModelObject ReverseTranslator::translateEnergyManagementSystemConstructionIndexVariable(const WorkspaceObject & workspaceObject)
{
if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ConstructionIndexVariable) {
LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_ConstructionIndexVariable");
return boost::none;
}
OptionalString s1 = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::Name);
if(!s1){
LOG(Error, "WorkspaceObject EnergyManagementSystem_ConstructionIndexVariable has no Name");
return boost::none;
}
OptionalString s = workspaceObject.getString(EnergyManagementSystem_ConstructionIndexVariableFields::ConstructionObjectName);
if (!s) {
LOG(Error, workspaceObject.nameString() + ": has no ConstructionObjectName");
return boost::none;
}
Workspace workspace = workspaceObject.workspace();
if (s) {
//std::vector<WorkspaceObject> wsObjects = workspace.getObjectsByTypeAndName(IddObjectType::Construction, *s);
std::vector<WorkspaceObject> wsObjects = workspace.getObjectsByName(*s);
if (wsObjects.size() > 1) {
LOG(Error, workspaceObject.nameString() + ": Construction is not unique. More than 1 object with that name.");
return boost::none;
}
if (wsObjects.size() == 0) {
LOG(Error, workspaceObject.nameString() + ": Construction not found.");
return boost::none;
} else {
boost::optional<model::ModelObject> modelObject = translateAndMapWorkspaceObject(wsObjects[0]);
if (modelObject) {
openstudio::model::EnergyManagementSystemConstructionIndexVariable emsConstructionIndexVariable(m_model);
emsConstructionIndexVariable.setName(*s1);
emsConstructionIndexVariable.setConstructionObject(modelObject.get());
return emsConstructionIndexVariable;
}
}
}
return boost::none;
}
开发者ID:chlimit,项目名称:OpenStudio,代码行数:43,代码来源:ReverseTranslateEnergyManagementSystemConstructionIndexVariable.cpp
示例2: translateEnergyManagementSystemOutputVariable
OptionalModelObject ReverseTranslator::translateEnergyManagementSystemOutputVariable(const WorkspaceObject & workspaceObject)
{
if (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_OutputVariable) {
LOG(Error, "WorkspaceObject is not IddObjectType: EnergyManagementSystem_OutputVariable");
return boost::none;
}
//make sure all other objects are translated first except below
for (const WorkspaceObject& workspaceObject : m_workspace.objects()) {
if ((workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Program)
&& (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_Subroutine)
&& (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_ProgramCallingManager)
&& (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_MeteredOutputVariable)
&& (workspaceObject.iddObject().type() != IddObjectType::EnergyManagementSystem_OutputVariable)) {
translateAndMapWorkspaceObject(workspaceObject);
}
}
OptionalString s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::Name);
if (!s) {
LOG(Error, "EnergyManagementSystem_OutputVariable has no Name");
return boost::none;
}
openstudio::model::EnergyManagementSystemOutputVariable emsOutputVariable(m_model);
emsOutputVariable.setName(*s);
s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::EMSVariableName);
if (!s) {
LOG(Error, emsOutputVariable.nameString() + ": EMSVariableName not set");
return boost::none;
} else {
Workspace workspace = workspaceObject.workspace();
//look for GlobalVariables, translate and check if there is a name match since GV's dont have name field.
boost::optional<WorkspaceObject> wsObject = workspace.getObjectByTypeAndName(IddObjectType::EnergyManagementSystem_GlobalVariable, *s);
//for (WorkspaceObject& wsObject : workspace.getObjectsByType(IddObjectType::EnergyManagementSystem_GlobalVariable)) {
if (wsObject) {
boost::optional<model::ModelObject> modelObject = translateAndMapWorkspaceObject(wsObject.get());
if (modelObject) {
if (modelObject.get().cast<EnergyManagementSystemGlobalVariable>().name() == s) {
emsOutputVariable.setEMSVariableName(*s);
}
}
}
//look for name match on other (EMS) objects.
for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) {
boost::optional<model::ModelObject> modelObject = translateAndMapWorkspaceObject(wsObject);
if (modelObject) {
emsOutputVariable.setEMSVariableName(*s);
break;
}
}
}
s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::UpdateFrequency);
if (!s) {
LOG(Error, emsOutputVariable.nameString() + ": UpdateFrequency not set");
return boost::none;
} else {
emsOutputVariable.setUpdateFrequency(*s);
}
s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::TypeofDatainVariable);
if (!s) {
LOG(Error, emsOutputVariable.nameString() + ": TypeofDatainVariable not set");
return boost::none;
} else {
emsOutputVariable.setTypeOfDataInVariable(*s);
}
s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::Units);
if (s) {
emsOutputVariable.setUnits(*s);
}
s = workspaceObject.getString(EnergyManagementSystem_OutputVariableFields::EMSProgramorSubroutineName);
if (s) {
Workspace workspace = workspaceObject.workspace();
for (WorkspaceObject& wsObject : workspace.getObjectsByName(*s)) {
boost::optional<model::ModelObject> modelObject = translateAndMapWorkspaceObject(wsObject);
if (modelObject) {
if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Program) {
emsOutputVariable.setEMSProgramOrSubroutineName(modelObject.get().cast<EnergyManagementSystemProgram>());
} else if (modelObject.get().iddObjectType() == IddObjectType::OS_EnergyManagementSystem_Subroutine) {
emsOutputVariable.setEMSProgramOrSubroutineName(modelObject.get().cast<EnergyManagementSystemSubroutine>());
}
return emsOutputVariable;
}
}
}
return emsOutputVariable;
}