• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Workspace类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Workspace的典型用法代码示例。如果您正苦于以下问题:C++ Workspace类的具体用法?C++ Workspace怎么用?C++ Workspace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Workspace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: TEST_F

TEST_F(EnergyPlusFixture,ForwardTranslatorTest_TranslateSiteGroundReflectance) {
  openstudio::model::Model model;
  openstudio::model::SiteGroundReflectance groundreflect = model.getUniqueModelObject<openstudio::model::SiteGroundReflectance>();

  groundreflect.setJanuaryGroundReflectance(0.11);
  groundreflect.setFebruaryGroundReflectance(0.12);
  groundreflect.setMarchGroundReflectance(0.13);
  groundreflect.setAprilGroundReflectance(0.14);
  groundreflect.setMayGroundReflectance(0.15);
  groundreflect.setJuneGroundReflectance(0.16);
  groundreflect.setJulyGroundReflectance(0.17);
  groundreflect.setAugustGroundReflectance(0.18);
  groundreflect.setSeptemberGroundReflectance(0.19);
  groundreflect.setOctoberGroundReflectance(0.20);
  groundreflect.setNovemberGroundReflectance(0.21);
  groundreflect.setDecemberGroundReflectance(0.22);

  ForwardTranslator trans;
  Workspace workspace = trans.translateModelObject(groundreflect);
  ASSERT_EQ(1u, workspace.numObjectsOfType(IddObjectType::Site_GroundReflectance));
    
  IdfObject groundreflectIdf = workspace.getObjectsByType(IddObjectType::Site_GroundReflectance)[0];
  EXPECT_EQ(unsigned(12), groundreflectIdf.numFields());

  EXPECT_EQ( 0.11, *(groundreflectIdf.getDouble(0)) );
  EXPECT_EQ( 0.12, *(groundreflectIdf.getDouble(1)) );
  EXPECT_EQ( 0.13, *(groundreflectIdf.getDouble(2)) );
  EXPECT_EQ( 0.14, *(groundreflectIdf.getDouble(3)) );
  EXPECT_EQ( 0.15, *(groundreflectIdf.getDouble(4)) );
  EXPECT_EQ( 0.16, *(groundreflectIdf.getDouble(5)) );
  EXPECT_EQ( 0.17, *(groundreflectIdf.getDouble(6)) );
  EXPECT_EQ( 0.18, *(groundreflectIdf.getDouble(7)) );
  EXPECT_EQ( 0.19, *(groundreflectIdf.getDouble(8)) );
  EXPECT_EQ( 0.20, *(groundreflectIdf.getDouble(9)) );
  EXPECT_EQ( 0.21, *(groundreflectIdf.getDouble(10)) );
  EXPECT_EQ( 0.22, *(groundreflectIdf.getDouble(11)) );
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:37,代码来源:ForwardTranslator_GTest.cpp


示例2: TEST_F

TEST_F(EnergyPlusFixture,ForwardTranslatorTest_TranslateSiteGroundTemperatureBuildingSurface) {
  openstudio::model::Model model;
  openstudio::model::SiteGroundTemperatureBuildingSurface groundtemp = model.getUniqueModelObject<openstudio::model::SiteGroundTemperatureBuildingSurface>();

  groundtemp.setJanuaryGroundTemperature(19.527);
  groundtemp.setFebruaryGroundTemperature(19.502);
  groundtemp.setMarchGroundTemperature(19.536);
  groundtemp.setAprilGroundTemperature(19.598);
  groundtemp.setMayGroundTemperature(20.002);
  groundtemp.setJuneGroundTemperature(21.64);
  groundtemp.setJulyGroundTemperature(22.225);
  groundtemp.setAugustGroundTemperature(22.375);
  groundtemp.setSeptemberGroundTemperature(21.449);
  groundtemp.setOctoberGroundTemperature(20.121);
  groundtemp.setNovemberGroundTemperature(19.802);
  groundtemp.setDecemberGroundTemperature(19.633);

  ForwardTranslator trans;
  Workspace workspace = trans.translateModelObject(groundtemp);
  ASSERT_EQ(1u, workspace.numObjectsOfType(IddObjectType::Site_GroundTemperature_BuildingSurface));
    
  IdfObject groundtempIdf = workspace.getObjectsByType(IddObjectType::Site_GroundTemperature_BuildingSurface)[0];
  EXPECT_EQ(unsigned(12), groundtempIdf.numFields());

  EXPECT_EQ( 19.527, *(groundtempIdf.getDouble(0)) );
  EXPECT_EQ( 19.502, *(groundtempIdf.getDouble(1)) );
  EXPECT_EQ( 19.536, *(groundtempIdf.getDouble(2)) );
  EXPECT_EQ( 19.598, *(groundtempIdf.getDouble(3)) );
  EXPECT_EQ( 20.002, *(groundtempIdf.getDouble(4)) );
  EXPECT_EQ( 21.64, *(groundtempIdf.getDouble(5)) );
  EXPECT_EQ( 22.225, *(groundtempIdf.getDouble(6)) );
  EXPECT_EQ( 22.375, *(groundtempIdf.getDouble(7)) );
  EXPECT_EQ( 21.449, *(groundtempIdf.getDouble(8)) );
  EXPECT_EQ( 20.121, *(groundtempIdf.getDouble(9)) );
  EXPECT_EQ( 19.802, *(groundtempIdf.getDouble(10)) );
  EXPECT_EQ( 19.633, *(groundtempIdf.getDouble(11)) );
}
开发者ID:ORNL-BTRIC,项目名称:OpenStudio,代码行数:37,代码来源:ForwardTranslator_GTest.cpp


示例3: TEST_F

TEST_F(EnergyPlusFixture, ForwardTranslator_AvailabilityManagerLowTemperatureTurnOff) {

  Model m;

  AvailabilityManagerLowTemperatureTurnOff avm(m);

  // Assign Sensor Node and Temperature
  Node n(m);
  EXPECT_TRUE(avm.setSensorNode(n));
  EXPECT_TRUE(avm.setTemperature(60.19));
  // Test Applicability Schedule
  ScheduleConstant sch(m);
  sch.setValue(50);
  EXPECT_TRUE(avm.setApplicabilitySchedule(sch));

  // Assign it to a plant loop
  PlantLoop p(m);
  p.setAvailabilityManager(avm);

  // ForwardTranslate
  ForwardTranslator forwardTranslator;
  Workspace workspace = forwardTranslator.translateModel(m);

  WorkspaceObjectVector idfObjs(workspace.getObjectsByType(IddObjectType::AvailabilityManager_LowTemperatureTurnOff));
  EXPECT_EQ(1u, idfObjs.size());
  WorkspaceObject idf_avm(idfObjs[0]);

  // Sensor Node Name
  ASSERT_EQ(n.name().get(), idf_avm.getString(AvailabilityManager_LowTemperatureTurnOffFields::SensorNodeName).get());

  // Temperature
  EXPECT_DOUBLE_EQ(avm.temperature(), idf_avm.getDouble(AvailabilityManager_LowTemperatureTurnOffFields::Temperature).get());

  // Applicability Schedule Name
  ASSERT_EQ(sch.name().get(), idf_avm.getString(AvailabilityManager_LowTemperatureTurnOffFields::ApplicabilityScheduleName).get());

}
开发者ID:NREL,项目名称:OpenStudio,代码行数:37,代码来源:AvailabilityManagerLowTemperatureTurnOff_GTest.cpp


示例4: TEST_F

TEST_F(EnergyPlusFixture, ForwardTranslator_ExternalInterfaceFunctionalMockupUnitExportToActuator) {
  Model model;

  Building building = model.getUniqueModelObject<Building>();

  // add fan
  Schedule s = model.alwaysOnDiscreteSchedule();
  FanConstantVolume fan(model, s);

  // add actuator
  std::string fanControlType = "Fan Pressure Rise";
  std::string ComponentType = "Fan";
  ExternalInterfaceFunctionalMockupUnitExportToActuator fanActuator(fan, ComponentType, fanControlType, "Fan FMU name", 10);

  ForwardTranslator forwardTranslator;
  Workspace workspace = forwardTranslator.translateModel(model);
  EXPECT_EQ(0u, forwardTranslator.errors().size());
  EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::ExternalInterface_FunctionalMockupUnitExport_To_Actuator).size());

  WorkspaceObject object = workspace.getObjectsByType(IddObjectType::ExternalInterface_FunctionalMockupUnitExport_To_Actuator)[0];

  ASSERT_TRUE(object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::Name, false));
  EXPECT_EQ("External Interface Functional Mockup Unit Export To Actuator 1", object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::Name, false).get());
  ASSERT_TRUE(object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::ActuatedComponentUniqueName, false));
  EXPECT_EQ(fan.nameString(), object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::ActuatedComponentUniqueName, false).get());
  ASSERT_TRUE(object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::ActuatedComponentType, false));
  EXPECT_EQ(ComponentType, object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::ActuatedComponentType, false).get());
  ASSERT_TRUE(object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::ActuatedComponentControlType, false));
  EXPECT_EQ(fanControlType, object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::ActuatedComponentControlType, false).get());
  ASSERT_TRUE(object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::FMUVariableName, false));
  EXPECT_EQ("Fan FMU name", object.getString(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::FMUVariableName, false).get());
  ASSERT_TRUE(object.getDouble(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::InitialValue, false));
  EXPECT_EQ(10.0, object.getDouble(ExternalInterface_FunctionalMockupUnitExport_To_ActuatorFields::InitialValue, false).get());

  model.save(toPath("./ExternalInterfaceFunctionalMockupUnitExportToActuator.osm"), true);
  workspace.save(toPath("./ExternalInterfaceFunctionalMockupUnitExportToActuator.idf"), true);
}
开发者ID:NREL,项目名称:OpenStudio,代码行数:37,代码来源:ExternalInterfaceFT_GTest.cpp


示例5: TEST_F

TEST_F(EnergyPlusFixture,ForwardTranslator_Building)
{
  Model model;
  Building building = model.getUniqueModelObject<Building>();
  building.setName("Building");
  EXPECT_TRUE(building.isNorthAxisDefaulted());

  ForwardTranslator forwardTranslator;
  Workspace workspace = forwardTranslator.translateModel(model);

  ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::Building).size());
  ASSERT_EQ(0u, workspace.getObjectsByType(IddObjectType::Site_Location).size());
  ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::SimulationControl).size());

  WorkspaceObject object = workspace.getObjectsByType(IddObjectType::Building)[0];
  ASSERT_TRUE(object.getString(BuildingFields::Name));
  EXPECT_EQ("Building", object.getString(BuildingFields::Name).get());
  EXPECT_TRUE(object.isEmpty(BuildingFields::NorthAxis));
  EXPECT_TRUE(object.isEmpty(BuildingFields::Terrain));
  EXPECT_TRUE(object.isEmpty(BuildingFields::LoadsConvergenceToleranceValue));
  EXPECT_TRUE(object.isEmpty(BuildingFields::TemperatureConvergenceToleranceValue));
  EXPECT_TRUE(object.isEmpty(BuildingFields::SolarDistribution));
  EXPECT_TRUE(object.isEmpty(BuildingFields::MaximumNumberofWarmupDays));
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:24,代码来源:Building_GTest.cpp


示例6: cleanAll

void cleanAll() {
	utils::rm("./build", true, true);
	utils::mkdir("./build");
	utils::rm(".busy", true, true);
	std::cout << "clean all done" << std::endl;

	// ignore exceptions
	try {
		Workspace ws;
		auto validPackages = ws.getPackages();
		auto allDepPackages = validPackages.begin()->getAllDependendPackages();
		std::vector<Package const*> noDepPackage;
		for (auto const& p : validPackages) {
			auto iter = std::find_if(allDepPackages.begin(), allDepPackages.end(), [&](Package const* p2) {
				return p.getName() == p2->getName();
			});
			if (iter == allDepPackages.end()) {
				noDepPackage.push_back(&p);
			}
		}

		if (noDepPackage.size() > 0) {
			std::cout << "\n" << TERM_RED << "Packages is not used or referenced:\n" << TERM_RESET;
			std::string paths;
			for (auto p : noDepPackage) {
				std::cout << " - " << p->getName() << "\n";
				paths += " " + p->getPath();
			}
			std::cout << "you might want to run\n";
			std::cout << TERM_GREEN"  rm -rf " << paths << TERM_RESET"\n";
		}

	} catch (...) {}


}
开发者ID:SGSSGene,项目名称:busy,代码行数:36,代码来源:cleanAll.cpp


示例7: averagePos

void MainFrame::OnMoveClick(wxRibbonButtonBarEvent& event)
{
    Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
    if(workspace) {
        auto elementList = workspace->GetAllElements();
        // Calculate the average position of selected elements.
        wxPoint2DDouble averagePos(0, 0);
        int numSelElements = 0;
        for(auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
            Element* element = *it;
            if(element->IsSelected()) {
                averagePos += element->GetPosition();
                numSelElements++;
            }
        }
        averagePos = wxPoint2DDouble(averagePos.m_x / double(numSelElements), averagePos.m_y / double(numSelElements));
        // Set the move position to the average of selected elements.
        for(auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
            Element* element = *it;
            if(element->IsSelected()) { element->StartMove(averagePos); }
        }
        workspace->SetWorkspaceMode(Workspace::MODE_MOVE_ELEMENT);
    }
}
开发者ID:Thales1330,项目名称:PSP,代码行数:24,代码来源:MainFrame.cpp


示例8: chromagramOfBufferedAudio

 void KeyFinder::chromagramOfBufferedAudio(
   Workspace& workspace,
   const Parameters& params
 ) {
   if (workspace.getFftAdapter() == NULL)
     workspace.setFftAdapter(new FftAdapter(params.getFftFrameSize()));
   SpectrumAnalyser sa(workspace.buffer.getFrameRate(), params, ctFactory);
   Chromagram* c = sa.chromagramOfWholeFrames(workspace.buffer, workspace.getFftAdapter());
   // deal with tuning if necessary
   if (c->getBandsPerSemitone() > 1) {
     if (params.getTuningMethod() == TUNING_BAND_ADAPTIVE) {
       c->tuningBandAdaptive(params.getDetunedBandWeight());
     } else if (params.getTuningMethod() == TUNING_HARTE) {
       c->tuningHarte();
     }
   }
   workspace.buffer.discardFramesFromFront(params.getHopSize() * c->getHops());
   if (workspace.chroma == NULL) {
     workspace.chroma = c;
   } else {
     workspace.chroma->append(*c);
     delete c;
   }
 }
开发者ID:tism,项目名称:libKeyFinder,代码行数:24,代码来源:keyfinder.cpp


示例9: TEST_F

TEST_F(IdfFixture,ValidityReport_WithCustomIdd) 
{
  Workspace workspace;
  EXPECT_EQ(IddFileType::OpenStudio, workspace.iddFileType().value());
  EXPECT_TRUE(workspace.isValid(StrictnessLevel::Draft));
  workspace.addObject(IdfObject(IddObjectType::OS_Building));
  EXPECT_TRUE(workspace.isValid(StrictnessLevel::Draft));

  std::stringstream ss;
  workspace.iddFile().print(ss);
  boost::optional<IddFile> iddFile = IddFile::load(ss);
  ASSERT_TRUE(iddFile);

  Workspace workspace2(*iddFile, StrictnessLevel::None);
  EXPECT_EQ(IddFileType::UserCustom, workspace2.iddFileType().value());
  workspace2.addObjects(workspace.toIdfFile().objects());
  EXPECT_EQ(workspace.objects().size(), workspace2.objects().size());
  EXPECT_TRUE(workspace2.isValid(StrictnessLevel::Draft));
  ValidityReport report = workspace2.validityReport(StrictnessLevel::Draft);
  LOG(Debug,"Validity report for workspace2: " << std::endl << report);
}
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:21,代码来源:Validity_GTest.cpp


示例10:

const Workspace& Ide::IdeWorkspace() const
{
	static Workspace wspc;
	static String _main;
	if(main != _main || wspc.GetCount() == 0) {
		wspc.Scan(main);
		_main = main;
	}
	else {
		for(int i = 0; i < wspc.GetCount(); i++)
			if(wspc.GetPackage(i).time != FileGetTime(PackagePath(wspc[i]))) {
				wspc.Scan(main);
				break;
			}
	}
	return wspc;
}
开发者ID:kolyden,项目名称:mirror,代码行数:17,代码来源:ide.cpp


示例11: TEST_F

/**
 * Tests only the controlType of the ForwardTranslator which I exposed after the fact
 **/
TEST_F(EnergyPlusFixture,ForwardTranslator_AirLoopHVACUnitarySystem_ControlType)
{
  Model m;

  AirLoopHVAC airLoop(m);
  AirLoopHVACUnitarySystem unitary(m);

  Node supplyOutletNode = airLoop.supplyOutletNode();
  unitary.addToNode(supplyOutletNode);

  // test if Setpoint
  unitary.setControlType("Setpoint");

  ForwardTranslator ft;
  Workspace workspace = ft.translateModel(m);

  EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem).size());
  EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::AirLoopHVAC).size());

  IdfObject idf_unitary = workspace.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)[0];

  ASSERT_EQ("Setpoint",
            idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::ControlType).get() );

  // test if load (make sure nothing is hardcoded)
  unitary.setControlType("Load");

  workspace = ft.translateModel(m);

  EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem).size());
  EXPECT_EQ(1u, workspace.getObjectsByType(IddObjectType::AirLoopHVAC).size());

  idf_unitary = workspace.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)[0];

  ASSERT_EQ("Load",
            idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::ControlType).get() );


}
开发者ID:NREL,项目名称:OpenStudio,代码行数:42,代码来源:AirLoopHVACUnitarySystem_GTest.cpp


示例12: makeChoiceArgumentOfWorkspaceObjects

OSArgument makeChoiceArgumentOfWorkspaceObjects(const std::string& name,
                                                const IddObjectType& iddObjectType,
                                                const Workspace& workspace,
                                                bool required)
{
  std::vector< std::pair<std::string, std::string> > intermediate;

  std::vector<WorkspaceObject> objects = workspace.getObjectsByType(iddObjectType);
  for (const WorkspaceObject& object : objects){
    std::string objectName;
    if (object.name()) {
      objectName = object.name().get();
    }
    else {
      objectName = object.iddObject().type().valueName();
    }
    intermediate.push_back(std::pair<std::string,std::string>(toString(object.handle()),
                                                              objectName));
  }

  std::sort(intermediate.begin(),
            intermediate.end(),
            SecondOfPairLess< std::pair<std::string,std::string> >());

  int n = intermediate.size();
  StringVector choices(n), displayNames(n);
  for (int i = 0; i < n; ++i) {
    choices[i] = intermediate[i].first;
    displayNames[i] = intermediate[i].second;
  }

  return OSArgument::makeChoiceArgument(name,
                                        choices,
                                        displayNames,
                                        required);
}
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:36,代码来源:OSArgument.cpp


示例13: OnSaveClick

void MainFrame::OnSaveClick(wxRibbonButtonBarEvent& event)
{
    Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
    if(workspace) {
        FileHanding fileHandling(workspace);

        if(workspace->GetSavedPath().IsOk()) {
            fileHandling.SaveProject(workspace->GetSavedPath());
        } else {
            wxFileDialog saveFileDialog(this, _("Save PSP file"), "", "", "PSP files (*.psp)|*.psp",
                                        wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
            if(saveFileDialog.ShowModal() == wxID_CANCEL) return;

            fileHandling.SaveProject(saveFileDialog.GetPath());
            wxFileName fileName(saveFileDialog.GetPath());
            workspace->SetName(fileName.GetName());
            m_auiNotebook->SetPageText(m_auiNotebook->GetPageIndex(workspace), workspace->GetName());
            workspace->SetSavedPath(fileName);
        }
    }
}
开发者ID:Thales1330,项目名称:PSP,代码行数:21,代码来源:MainFrame.cpp


示例14: Workspace

void MainFrame::OnImportClick(wxRibbonButtonBarEvent& event)
{
    // Create a new workspace to import
    Workspace* impWorkspace = new Workspace(this, _("Imported project"), this->GetStatusBar(), m_sharedGLContext);
    ImportForm importForm(this, impWorkspace);
    if(importForm.ShowModal() == wxID_OK) {
        // Import file(s)
        EnableCurrentProjectRibbon();

        if(!m_sharedGLContext) m_sharedGLContext = impWorkspace->GetOpenGLContext();
        m_workspaceList.push_back(impWorkspace);

        m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_DISABLESOL, true);
        m_ribbonButtonBarContinuous->ToggleButton(ID_RIBBON_ENABLESOL, false);

        m_auiNotebook->AddPage(impWorkspace, impWorkspace->GetName(), true);
        m_auiNotebook->Layout();
        impWorkspace->Redraw();
        impWorkspace->SetJustOpened(true);
        impWorkspace->Fit();
        m_projectNumber++;
    }
}
开发者ID:Thales1330,项目名称:PSP,代码行数:23,代码来源:MainFrame.cpp


示例15: switch

void MainFrame::OnAddElementsClick(wxCommandEvent& event)
{
    Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());

    if(workspace) {
        if(workspace->GetWorkspaceMode() != Workspace::MODE_INSERT) {
            auto elementList = workspace->GetElementList();
            wxString statusBarText = "";
            bool newElement = false;

            switch(event.GetId()) {
                case ID_ADDMENU_BUS: {
                    Bus* newBus = new Bus(wxPoint2DDouble(0, 0),
                                          wxString::Format(_("Bus %d"), workspace->GetElementNumber(ID_BUS)));
                    workspace->IncrementElementNumber(ID_BUS);
                    elementList.push_back(newBus);
                    statusBarText = _("Insert Bus: Click to insert, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_LINE: {
                    Line* newLine = new Line(wxString::Format(_("Line %d"), workspace->GetElementNumber(ID_LINE)));
                    elementList.push_back(newLine);
                    workspace->IncrementElementNumber(ID_LINE);
                    statusBarText = _("Insert Line: Click on two buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_TRANSFORMER: {
                    Transformer* newTransformer = new Transformer(
                        wxString::Format(_("Transformer %d"), workspace->GetElementNumber(ID_TRANSFORMER)));
                    workspace->IncrementElementNumber(ID_TRANSFORMER);
                    elementList.push_back(newTransformer);
                    statusBarText = _("Insert Transformer: Click on two buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_GENERATOR: {
                    SyncGenerator* newGenerator = new SyncGenerator(
                        wxString::Format(_("Generator %d"), workspace->GetElementNumber(ID_SYNCGENERATOR)));
                    workspace->IncrementElementNumber(ID_SYNCGENERATOR);
                    elementList.push_back(newGenerator);
                    statusBarText = _("Insert Generator: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_LOAD: {
                    Load* newLoad = new Load(wxString::Format(_("Load %d"), workspace->GetElementNumber(ID_LOAD)));
                    workspace->IncrementElementNumber(ID_LOAD);
                    elementList.push_back(newLoad);
                    statusBarText = _("Insert Load: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_CAPACITOR: {
                    Capacitor* newCapacitor =
                        new Capacitor(wxString::Format(_("Capacitor %d"), workspace->GetElementNumber(ID_CAPACITOR)));
                    workspace->IncrementElementNumber(ID_CAPACITOR);
                    elementList.push_back(newCapacitor);
                    statusBarText = _("Insert Capacitor: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_INDUCTOR: {
                    Inductor* newInductor =
                        new Inductor(wxString::Format(_("Inductor %d"), workspace->GetElementNumber(ID_INDUCTOR)));
                    workspace->IncrementElementNumber(ID_INDUCTOR);
                    elementList.push_back(newInductor);
                    statusBarText = _("Insert Inductor: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_INDMOTOR: {
                    IndMotor* newIndMotor = new IndMotor(
                        wxString::Format(_("Induction motor %d"), workspace->GetElementNumber(ID_INDMOTOR)));
                    workspace->IncrementElementNumber(ID_INDMOTOR);
                    elementList.push_back(newIndMotor);
                    statusBarText = _("Insert Induction Motor: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
                case ID_ADDMENU_SYNCCOMP: {
                    SyncMotor* newSyncCondenser = new SyncMotor(
                        wxString::Format(_("Synchronous condenser %d"), workspace->GetElementNumber(ID_SYNCMOTOR)));
                    workspace->IncrementElementNumber(ID_SYNCMOTOR);
                    elementList.push_back(newSyncCondenser);
                    statusBarText = _("Insert Synchronous Condenser: Click on a buses, ESC to cancel.");
                    newElement = true;
                } break;
            }
            if(newElement) {
                workspace->SetElementList(elementList);
                workspace->SetWorkspaceMode(Workspace::MODE_INSERT);
                workspace->SetStatusBarText(statusBarText);
                workspace->Redraw();
            }
        }
    }
}
开发者ID:Thales1330,项目名称:PSP,代码行数:91,代码来源:MainFrame.cpp


示例16: OnSCPowerClick

void MainFrame::OnSCPowerClick(wxRibbonButtonBarEvent& event)
{
    Workspace* workspace = static_cast<Workspace*>(m_auiNotebook->GetCurrentPage());
    if(workspace) { workspace->RunSCPower(); }
}
开发者ID:Thales1330,项目名称:PSP,代码行数:5,代码来源:MainFrame.cpp


示例17: TEST_F

/* Ensures that the nodes that translated correctly
 * that means correct node names in the CentralHeatPumpSystem but also
 * on the Branches
 */
TEST_F(EnergyPlusFixture,ForwardTranslatorCentralHeatPumpSystem_Nodes) {

  boost::optional<WorkspaceObject> _wo;
  ForwardTranslator ft;

  Model m;

  CentralHeatPumpSystem central_hp(m);
  ASSERT_TRUE(central_hp.setAncillaryPower(0.7));
  EXPECT_FALSE(central_hp.ancillaryOperationSchedule());
  Schedule schedule = m.alwaysOnDiscreteSchedule();

  // Return type: bool
  ASSERT_TRUE(central_hp.setAncillaryOperationSchedule(schedule));
  EXPECT_TRUE(central_hp.ancillaryOperationSchedule());

  // First module has one
  CentralHeatPumpSystemModule central_hp_module(m);
  central_hp.addModule(central_hp_module);
  EXPECT_EQ(1, central_hp_module.numberofChillerHeaterModules());

  // Second has 2
  CentralHeatPumpSystemModule central_hp_module2(m);
  central_hp.addModule(central_hp_module2);
  ASSERT_TRUE(central_hp_module2.setNumberofChillerHeaterModules(2));


  ASSERT_EQ( (unsigned)2, central_hp.modules().size() );


  // Connect the CentralHP to three plant loops
  // CoolingLoop: on the supply side
  PlantLoop coolingPlant(m);
  EXPECT_TRUE(coolingPlant.addSupplyBranchForComponent(central_hp));

  // SourceLoop: on the demand side
  PlantLoop sourcePlant(m);
  EXPECT_TRUE(sourcePlant.addDemandBranchForComponent(central_hp));
  // Also add a CT to the sourcePlant
  CoolingTowerSingleSpeed ct(m);
  sourcePlant.addSupplyBranchForComponent(ct);

  // HeatingLoop: on the supply side
  PlantLoop heatingPlant(m);
  // Workaround to be able to use addToTertiaryNode directly
  // (addSupplyBranchForComponent should work directly, but this is tested in model GTest, so here we just make sure we call
  // addToTertiaryNode directly)
  BoilerHotWater temp_b(m);
  EXPECT_TRUE(heatingPlant.addSupplyBranchForComponent(temp_b));

  ASSERT_TRUE(temp_b.inletModelObject());
  auto node = temp_b.inletModelObject().get().cast<Node>();
  EXPECT_TRUE(central_hp.addToTertiaryNode(node));
  temp_b.remove();


  // Translate
  Workspace w = ft.translateModel(m);

  EXPECT_EQ(0u, ft.errors().size());
  EXPECT_EQ(1u, w.getObjectsByType(IddObjectType::CentralHeatPumpSystem).size());

  IdfObject i_central_hp = w.getObjectsByType(IddObjectType::CentralHeatPumpSystem)[0];

  // supply = Cooling
  ASSERT_EQ(i_central_hp.getString(CentralHeatPumpSystemFields::CoolingLoopInletNodeName).get(),
            central_hp.supplyInletModelObject().get().name());

  ASSERT_EQ(i_central_hp.getString(CentralHeatPumpSystemFields::CoolingLoopOutletNodeName).get(),
            central_hp.supplyOutletModelObject().get().name());

  // demand = Source
  ASSERT_EQ(i_central_hp.getString(CentralHeatPumpSystemFields::SourceLoopInletNodeName).get(),
            central_hp.demandInletModelObject().get().name());

  ASSERT_EQ(i_central_hp.getString(CentralHeatPumpSystemFields::SourceLoopOutletNodeName).get(),
            central_hp.demandOutletModelObject().get().name());

  // tertiary = Heating
  ASSERT_EQ(i_central_hp.getString(CentralHeatPumpSystemFields::HeatingLoopInletNodeName).get(),
            central_hp.tertiaryInletModelObject().get().name());

  ASSERT_EQ(i_central_hp.getString(CentralHeatPumpSystemFields::HeatingLoopOutletNodeName).get(),
            central_hp.tertiaryOutletModelObject().get().name());


  // Check node names on supply/demand branches
  // Checks that the special case implemented in ForwardTranslatePlantLoop::populateBranch does the right job

  // supply = Cooling (on supply)
  {
    _wo = w.getObjectByTypeAndName(IddObjectType::PlantLoop, coolingPlant.name().get());
    ASSERT_TRUE(_wo.is_initialized());
    WorkspaceObject idf_plant = _wo.get();
    WorkspaceObject idf_brlist = idf_plant.getTarget(PlantLoopFields::PlantSideBranchListName).get();

//.........这里部分代码省略.........
开发者ID:NREL,项目名称:OpenStudio,代码行数:101,代码来源:CentralHeatPumpSystem_GTest.cpp


示例18: onEnabled

bool DuplicateViewCommand::onEnabled(Context* context)
{
  Workspace* workspace = App::instance()->workspace();
  WorkspaceView* view = workspace->activeView();
  return (view != nullptr);
}
开发者ID:4144,项目名称:aseprite,代码行数:6,代码来源:cmd_duplicate_view.cpp


示例19: Build

bool MakeBuild::Build(const Workspace& wspc, String mainparam, String outfile, bool clear_console)
{
	String hfile = outfile + ".xxx";
	SaveFile(hfile, "");
	FileTime start_time = GetFileTime(hfile); // Defensive way to get correct filetime of start
	DeleteFile(hfile);
	
	ClearErrorEditor();
	BeginBuilding(true, clear_console);
	bool ok = true;
	if(wspc.GetCount()) {
		for(int i = 0; i < wspc.GetCount(); i++) {
			const Package& pk = wspc.package[i];
			for(int j = 0; j < pk.GetCount(); j++)
				if(pk[j] == "main.conf") {
					String pn = wspc[i];
					String p = SourcePath(pn, "main.conf");
					main_conf << "// " << pn << "\r\n" << LoadFile(p) << "\r\n";
					PutConsole("Found " + p);
				}
		}

		if(main_conf.GetCount()) {
			VectorMap<String, String> bm = GetMethodVars(method);
			One<Host> host = CreateHost(false);
			One<Builder> b = CreateBuilder(~host);
			if(b) {
				Index<String> mcfg = PackageConfig(wspc, 0, bm, mainparam, *host, *b, NULL);
				String outdir = OutDir(mcfg, wspc[0], bm, false);
				String path = AppendFileName(outdir, "main.conf.h");
				RealizePath(path);
				SaveChangedFile(path, main_conf);
				PutConsole("Saving " + path);
				add_includes << outdir << ';';
			}
		}

		Vector<int> build_order;
		if(GetTargetMode().linkmode != 2) {
			for(int i = 1; i < wspc.GetCount(); i++)
				build_order.Add(i);
		}
		else {
			Index<int> remaining;
			for(int i = 1; i < wspc.GetCount(); i++)
				remaining.Add(i);
			while(!remaining.IsEmpty()) {
				int t;
				for(t = 0; t < remaining.GetCount(); t++) {
					const Package& pk = wspc.package[remaining[t]];
					bool delay = false;
					for(int u = 0; u < pk.uses.GetCount(); u++)
						if(remaining.Find(wspc.package.Find(pk.uses[u].text)) >= 0) {
							delay = true;
							break;
						}
					if(!delay)
						break;
				}
				if(t >= remaining.GetCount())
					t = 0;
				build_order.Add(remaining[t]);
				remaining.Remove(t);
			}
		}

		String mainpackage = wspc[0];
		Vector<String> linkfile;
		String linkopt = GetMethodVars(method).Get(targetmode ? "RELEASE_LINK" : "DEBUG_LINK", Null);
		if(linkopt.GetCount())
			linkopt << ' ';
		ok = true;
		int ms = msecs();
		for(int i = 0; i < build_order.GetCount() && (ok || !stoponerrors); i++) {
			int px = build_order[i];
			ok = BuildPackage(wspc, px, i, build_order.GetCount() + 1,
				              mainparam, Null, linkfile, linkopt) && ok;
			if(msecs() - ms >= 200) {
				DoProcessEvents();
				ms = msecs();
			}
		}
		if(ok || !stoponerrors) {
			ok = BuildPackage(wspc, 0, build_order.GetCount(), build_order.GetCount() + 1,
			                  mainparam, outfile, linkfile, linkopt, ok) && ok;
			// Set the time of target to start-time, so that if any file changes during
			// compilation, it is recompiled during next build
			SetFileTime(target, start_time); 
		}
	}
	EndBuilding(ok);
	ReQualifyCodeBase();
	SetErrorEditor();
	return ok;
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:95,代码来源:Build.cpp


示例20: TEST_F

TEST_F(EnergyPlusFixture, ForwardTranslator_ScheduleVariableInterval_500_Shifted)
{
  // The vector of time deltas, randomly generated
  long numbers[500] = { 86313, 48668, 46739, 86313, 86313, 35939, 28787, 81175, 41086, 60467, 71308, 36332,
    75050, 44913, 86313, 36150, 86313, 86313, 86313, 86313, 49633, 23793, 86313, 86313, 86313, 78168, 72707,
    56754, 35868, 29986, 25413, 40812, 62829, 31364, 77455, 76379, 86313, 50167, 34835, 70623, 86313, 70817,
    48215, 52955, 59462, 27876, 27334, 52308, 32575, 86313, 86313, 53883, 57044, 86313, 45829, 38304, 42861,
    86313, 86313, 29215, 35662, 86313, 86313, 63866, 73697, 58074, 80833, 85161, 60866, 85214, 38748, 86313,
    86313, 36676, 33285, 86313, 38269, 86313, 67373, 56445, 86313, 85745, 54775, 51067, 86313, 23644, 34226,
    86313, 71364, 64214, 45392, 86313, 49499, 71086, 50232, 86313, 86313, 75456, 62390, 78586, 67472, 66497,
    51741, 76133, 86313, 52833, 72670, 65395, 86313, 86180, 67179, 86313, 86313, 86313, 33630, 48006, 42881,
    69935, 39664, 63806, 41471, 35258, 31512, 83115, 86313, 73282, 86313, 86313, 53505, 47981, 61876, 86313,
    31543, 86313, 37030, 66163, 47482, 58352, 86313, 73380, 86313, 46900, 59984, 57889, 41704, 42690, 86313,
    86313, 51497, 71154, 42596, 73589, 27242, 61291, 43573, 86313, 65535, 86313, 58071, 86313, 79620, 86313,
    26578, 32739, 86313, 34133, 70385, 27867, 81956, 72324, 38580, 29633, 33298, 59005, 27369, 32838, 61259,
    35188, 77004, 86313, 60872, 86313, 49717, 43171, 27070, 35573, 30796, 86313, 86313, 86313, 86313, 63163,
    77254, 45155, 86313, 86313, 57614, 59737, 48050, 86313, 86313, 72316, 52488, 60663, 50962, 35766, 81130,
    70904, 34878, 76407, 68502, 82977, 86313, 55383, 33518, 86313, 29334, 28864, 44800, 64615, 86313, 78882,
    66482, 50578, 78395, 66541, 68202, 83235, 61364, 81762, 86313, 47870, 34782, 46302, 50788, 49417, 44120,
    74002, 25114, 86313, 24457, 53465, 26107, 33636, 86313, 80121, 64977, 30723, 40309, 86313, 86313, 76107,
    86313, 33956, 52007, 62567, 86313, 58138, 41487, 31619, 33507, 62906, 35965, 86313, 43492, 86313, 24031,
    83944, 86313, 86313, 71510, 86284, 56508, 28345, 39127, 86313, 37952, 54719, 79620, 36024, 86313, 86313,
    86313, 86313, 30591, 83941, 64038, 74265, 75851, 56856, 44849, 27458, 30350, 24754, 31329, 56821, 55979,
    39576, 50515, 52438, 84957, 85891, 51660, 86313, 49117, 86313, 63442, 24063, 77802, 29621, 37905, 53515,
    72884, 81821, 86313, 86313, 86313, 86313, 84048, 86313, 76408, 70785, 55767, 86313, 41679, 83722, 85612,
    86313, 86313, 29925, 86313, 52021, 86313, 78981, 86313, 86313, 50598, 74333, 67904, 86313, 31582, 86313,
    70034, 86313, 35070, 74448, 45073, 86313, 86313, 71613, 35444, 63476, 53592, 84978, 26717, 58140, 61863,
    84549, 58604, 34180, 62200, 36225, 83922, 33905, 83064, 24935, 51077, 86313, 49476, 61010, 41624, 65246,
    30697, 86313, 26883, 86313, 75916, 48961, 86313, 53663, 86313, 38177, 51527, 79510, 86313, 26712, 74984,
    64740, 86313, 49378, 86313, 86313, 47440, 32930, 25094, 76695, 68608, 35416, 86313, 86313, 26731, 86313,
    65665, 57451, 86313, 64561, 47067, 76935, 31435, 72573, 86313, 38846, 72254, 42634, 86313, 86313, 71265,
    86313, 56154, 86313, 66939, 86313, 30369, 36409, 67475, 86313, 86313, 86313, 86313, 38236, 86313, 57408,
    66435, 29802, 72062, 86313, 43899, 86313, 47590, 64377, 53064, 68569, 37843, 86313, 86313, 86313, 86313,
    69253, 54914, 33398, 26446, 49428, 59356, 86313, 86313, 86313, 78915, 44437, 61977, 75481, 86313, 86313,
    47774, 71126, 86313, 84201, 86313, 66183, 44427, 59010, 24018, 34729, 86313, 32745, 86313, 48847, 61975,
    76417, 86313, 86313, 66541, 51775, 86313, 86129, 36853, 86313, 70306, 46162, 86313, 86313, 29768, 46103,
    24318, 26234, 59933, 43230, 65930, 86313, 86313, 54580 };

  // The vector of values
  Vector values = linspace(1, 500, 500);

  // Create the vector of seconds from start
  std::vector<long> seconds(500);
  seconds[0] = numbers[0];
  for (unsigned i = 1; i<500; i++) {
    seconds[i] = numbers[i] + seconds[i - 1];
  }

  // Create a time series starting 12/31 00:00:-86313 with irregular interval
  TimeSeries timeseries(DateTime(Date(MonthOfYear::Jan, 1)), seconds, values, "");

  Model model;

  // Create a schedule and make sure it worked
  boost::optional<ScheduleInterval> scheduleInterval = ScheduleInterval::fromTimeSeries(timeseries, model);
  ASSERT_TRUE(scheduleInterval);
  ASSERT_TRUE(scheduleInterval->optionalCast<ScheduleVariableInterval>());

  // Forward translate the schedule
  ForwardTranslator ft;
  Workspace workspace = ft.translateModel(model);

  std::vector<WorkspaceObject> objects = workspace.getObjectsByType(IddObjectType::Schedule_Compact);
  ASSERT_EQ(1u, objects.size());

  boost::regex throughRegex("^Through:\\s*(.*)/\\s*(.*)\\s*");
  boost::regex untilRegex("^Until:\\s*(.*):(.*)\\s*");

  // Write out the schedule - keep this around for now
  //workspace.save(toPath("./ForwardTranslator_ScheduleVariableInterval_500_Shifted.idf"), true);

  // Check the contents of the output
  unsigned N = objects[0].numFields();
  boost::optional<Date> lastDateThrough;
  bool until24Found = false;
  bool nextValueShouldBeLast = false;
  unsigned numUntils = 0;

  for (unsigned i = 0; i < N; ++i) {
    boost::optional<std::string> field = objects[0].getString(i, true, false);
    ASSERT_TRUE(field);

    if (nextValueShouldBeLast) {
      double value = boost::lexical_cast<double>(* 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Workspace2D_sptr类代码示例发布时间:2022-05-31
下一篇:
C++ WorkingSetMember类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap