当前位置: 首页>>代码示例>>C++>>正文


C++ Generator::getInputPin方法代码示例

本文整理汇总了C++中Generator::getInputPin方法的典型用法代码示例。如果您正苦于以下问题:C++ Generator::getInputPin方法的具体用法?C++ Generator::getInputPin怎么用?C++ Generator::getInputPin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Generator的用法示例。


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

示例1: main

int main(int argc, char *argv[])
{
    const Resource::Type LIQUID_STATE = 1;
    const Resource::Type SOLID_STATE = 2;
    const Resource::Type GAS_STATE = 3;
    const Resource::Type PLASMA_STATE = 4;

    Resource::Info fuelInfo(Resource::INVALID_RESOURCE, LIQUID_STATE);
    Resource::Info energyInfo(Resource::INVALID_RESOURCE, PLASMA_STATE);
    Resource::Info waterInfo(Resource::INVALID_RESOURCE, LIQUID_STATE);
    Resource::Info oxygenInfo(Resource::INVALID_RESOURCE, GAS_STATE);

    SimSys::System system;
    Registrar registrar;

    registrar.registerResource("fuel", fuelInfo);
    registrar.registerResource("energy", energyInfo);
    registrar.registerResource("water", waterInfo);
    registrar.registerResource("oxygen", oxygenInfo);

    /*
    ResourceTank *fuelTank = new ResourceTank(1000, registrar.getInfo("fuel"), registrar);
    ResourceTank *waterTank = new ResourceTank(1000, registrar.getInfo("water"), registrar);
    ResourceTank *capacitor = new ResourceTank(500, registrar.getInfo("energy"), registrar);
    ResourceTank *oxygenTank = new ResourceTank(500, registrar.getInfo("oxygen"), registrar);
    Generator *generator = new Generator(registrar);
    LifeSupport *lifeSupport = new LifeSupport(registrar);
    Ventilation *ventilation = new Ventilation(registrar);

    Pipe *fuelToGenerator = new Pipe(generator->getInput("fuel-in"), Generator::FUEL_PER_GENERATION * 2, Generator::FUEL_PER_GENERATION / 2);
    fuelTank->getOutput("out-port")->connect(fuelToGenerator);
    Pipe *energyToCapacitor = new Pipe(capacitor->getInput("in-port"), Generator::ENERGY_PER_GENERATION * 2, Generator::FUEL_PER_GENERATION / 2);
    generator->getOutput("energy-out")->connect(energyToCapacitor);
    Pipe *capacitorToLifeSupport = new Pipe(lifeSupport->getInput("energy-in"), LifeSupport::ENERGY_NEEDED * 2, LifeSupport::ENERGY_NEEDED / 2);
    capacitor->getOutput("out-port")->connect(capacitorToLifeSupport);
    Pipe *waterToLifeSupport = new Pipe(lifeSupport->getInput("water-in"), LifeSupport::WATER_NEEDED * 2, LifeSupport::WATER_NEEDED / 2);
    waterTank->getOutput("out-port")->connect(waterToLifeSupport);
    Pipe *lifeSupportToOxygen = new Pipe(oxygenTank->getInput("in-port"), LifeSupport::OXYGEN_GENERATED * 2, LifeSupport::OXYGEN_GENERATED / 2);
    lifeSupport->getOutput("oxygen-out")->connect(lifeSupportToOxygen);
    Pipe *oxygenToVentilation = new Pipe(ventilation->getInput("oxygen-in"), Ventilation::OXYGEN_NEEDED * 2, Ventilation::OXYGEN_NEEDED / 2);
    oxygenTank->getOutput("out-port")->connect(oxygenToVentilation);

    fuelTank->getInput("in-port")->sink(registrar.getResource("fuel", 1000));
    waterTank->getInput("in-port")->sink(registrar.getResource("water", 1000));

    system.add(fuelTank);
    system.add(waterTank);
    system.add(capacitor);
    system.add(oxygenTank);
    system.add(generator);
    system.add(lifeSupport);
    system.add(ventilation);

    system.add(fuelToGenerator);
    system.add(energyToCapacitor);
    system.add(capacitorToLifeSupport);
    system.add(waterToLifeSupport);
    system.add(lifeSupportToOxygen);
    system.add(oxygenToVentilation);
    */

    /*
    Builtin::DigitalInput *inputOne = new Builtin::DigitalInput(true);
    Builtin::DigitalInput *inputTwo = new Builtin::DigitalInput(false);

    Builtin::XorGate2 *xorGate = new Builtin::XorGate2();
    Builtin::OrGate2 *orGate = new Builtin::OrGate2();

    Builtin::DigitalProbe *outputProbe = new PrintProbe("xor gate");

    inputOne->getOutput("digital-out")->connectTo(xorGate->getInput("A"));
    inputTwo->getOutput("digital-out")->connectTo(orGate->getInput("A"));
    xorGate->getOutput("Q")->connectTo(outputProbe->getInput("digital-in"));
    xorGate->getOutput("Q")->connectTo(orGate->getInput("B"));
    orGate->getOutput("Q")->connectTo(xorGate->getInput("B"));

    system.add(inputOne);
    system.add(inputTwo);
    system.add(xorGate);
    system.add(orGate);
    system.add(outputProbe);
    */


    // resource layer
    Generator *generator = new Generator(registrar);
    Capacitor *capacitor = new Capacitor(registrar);
    // control layer
    HysterisisController *controller = new HysterisisController(0.75f, 0.99f);
    Builtin::DigitalProbe *probe = new PrintProbe("controller");
    // create pipes
    Pipe *generatorToCapacitor = new Pipe(capacitor->getInput("energy-in"), Testing::Generator::ENERGY_PER_GENERATION * 2, Testing::Generator::ENERGY_PER_GENERATION);
    // connect pipes
    generator->getOutput("energy-out")->connect(generatorToCapacitor);
    // connect controls
    capacitor->getOutputPin("readout")->connectTo(controller->getInputPin("value"));
    controller->getOutputPin("control")->connectTo(generator->getInputPin("enable"));
    controller->getOutputPin("control")->connectTo(probe->getInputPin("digital-in"));
    // add to system
    system.add(generator);
//.........这里部分代码省略.........
开发者ID:omaskery,项目名称:SimulationSystem,代码行数:101,代码来源:main.cpp


注:本文中的Generator::getInputPin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。