void DsnConfigurationWindow::RetrieveSslParameters(config::Configuration& cfg) const
                {
                    std::string sslModeStr;
                    std::string sslKeyStr;
                    std::string sslCertStr;
                    std::string sslCaStr;

                    sslModeComboBox->GetText(sslModeStr);
                    sslKeyFileEdit->GetText(sslKeyStr);
                    sslCertFileEdit->GetText(sslCertStr);
                    sslCaFileEdit->GetText(sslCaStr);

                    LOG_MSG("Retrieving arguments:");
                    LOG_MSG("SSL Mode:           " << sslModeStr);
                    LOG_MSG("SSL Key:            " << sslKeyStr);
                    LOG_MSG("SSL Certificate:    " << sslCertStr);
                    LOG_MSG("SSL CA:             " << sslCaStr);

                    ssl::SslMode::Type sslMode = ssl::SslMode::FromString(sslModeStr, ssl::SslMode::DISABLE);

                    cfg.SetSslMode(sslMode);
                    cfg.SetSslKeyFile(sslKeyStr);
                    cfg.SetSslCertFile(sslCertStr);
                    cfg.SetSslCaFile(sslCaStr);
                }
                void DsnConfigurationWindow::RetrieveAuthParameters(config::Configuration& cfg) const
                {
                    std::string user;
                    std::string password;

                    userEdit->GetText(user);
                    passwordEdit->GetText(password);

                    cfg.SetUser(user);
                    cfg.SetPassword(password);
                }
                void DsnConfigurationWindow::RetrieveConnectionParameters(config::Configuration& cfg) const
                {
                    std::string dsnStr;
                    std::string addressStr;
                    std::string schemaStr;
                    std::string versionStr;

                    nameEdit->GetText(dsnStr);
                    addressEdit->GetText(addressStr);
                    schemaEdit->GetText(schemaStr);
                    protocolVersionComboBox->GetText(versionStr);

                    common::StripSurroundingWhitespaces(addressStr);
                    common::StripSurroundingWhitespaces(dsnStr);
                    // Stripping of whitespaces off the schema skipped intentionally

                    LOG_MSG("Retrieving arguments:");
                    LOG_MSG("DSN:                " << dsnStr);
                    LOG_MSG("Address:            " << addressStr);
                    LOG_MSG("Schema:             " << schemaStr);
                    LOG_MSG("Protocol version:   " << versionStr);

                    if (dsnStr.empty())
                        throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "DSN name can not be empty.");

                    diagnostic::DiagnosticRecordStorage diag;

                    std::vector<EndPoint> addresses;

                    config::ParseAddress(addressStr, addresses, &diag);

                    if (diag.GetStatusRecordsNumber() > 0)
                    {
                        throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
                            diag.GetStatusRecord(1).GetMessageText().c_str());
                    }

                    ProtocolVersion version = ProtocolVersion::FromString(versionStr);

                    if (!version.IsSupported())
                        throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "Protocol version is not supported.");

                    cfg.SetDsn(dsnStr);
                    cfg.SetAddresses(addresses);
                    cfg.SetSchema(schemaStr);
                    cfg.SetProtocolVersion(version);
                }
Example #4
0
    void configure(simulator::Simulation& simulation, const config::Configuration& config) override
    {
        const float px = 0.3;
        const auto filepath = config.buildFilePath(config.get("filename"));

        // SVG image
        NSVGimage* image = nsvgParseFromFile(filepath.string().c_str(), "px", 96);

        if (!image)
            throw RuntimeException("Cannot parse SVG");

        auto obstacle = simulation.buildObject("obstacle.Polygon");
        auto& shapes = obstacle->getMutableShapes();

        const auto size = Vector<float>(image->width, image->height);

        // Coordinate scale
        const auto scale = simulation.getWorldSize() / size;
        const auto offset = size * 0.5;

        // Foreach shapes
        for (NSVGshape* shape = image->shapes; shape != nullptr; shape = shape->next)
        {
            ShapeEdges oShape;

            // Foreach paths
            for (NSVGpath* path = shape->paths; path != nullptr; path = path->next)
            {
                storePath([&oShape, &offset, &scale] (Vector<float> vec) {
                    const auto v = (vec - offset) * scale * Vector<float>(1, -1);
                    if (oShape.edges.empty() ||
                        oShape.edges.back().distanceSquared(v).value() > 0.05)
                    {
                        oShape.edges.push_back(v);
                        Log::debug(v.getX(), "; ", v.getY());
                    }
                }, path, px * 1.5);
            }

            shapes.push_back(std::move(oShape));
        }

        obstacle->initShapes();
    }
Example #5
0
void DMFT::configure(config::Configuration& configuration) {
    m_configuration = &configuration;
    try {
        m_U = configuration.getDouble("DMFT.U");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_mu = configuration.getDouble("DMFT.mu");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_T = configuration.getDouble("DMFT.temperature");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_delta = configuration.getDouble("DMFT.delta");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_scaling = configuration.getDouble("DMFT.scaling");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_tolerance = configuration.getDouble("DMFT.tolerance");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_maxIterations = configuration.getInteger("DMFT.maxIterations");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_startWithDelta = configuration.getBool("DMFT.startWithDelta");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        std::string initialD = configuration.getString("DMFT.initialD");
        math::CFunction D;
        D.readBinary(initialD);
        setHybridizationFunction(D);
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        std::string initialS = configuration.getString("DMFT.initialS");
        math::CFunction S;
        S.readBinary(initialS);
        setSelfEnergy(S);
        double scaling = -S.getArgument(0);
        setScaling(scaling);
    } catch( libconfig::SettingNotFoundException& e ) {}
}
Example #6
0
void Program::loadConfig(simulator::Simulation& simulation, const config::Configuration& config)
{
    if (config.has("filename"))
    {
        m_source.initFile(config.get("filename"));
    }
    else
    {
        m_source.initSource(config.getContent());
    }

    // Store function pointer
    m_call = m_source.getFunction("__call__");

    // Fallback
    if (!m_call)
        m_call = m_source.getFunction("call");

    if (!m_call)
        throw InvalidArgumentException("Python program doesn't have '__call__' or 'call' function");
}
Example #7
0
        SqlResult Connection::InternalEstablish(const config::Configuration cfg)
        {
            config = cfg;

            if (connected)
            {
                AddStatusRecord(SQL_STATE_08002_ALREADY_CONNECTED, "Already connected.");

                return SQL_RESULT_ERROR;
            }

            connected = socket.Connect(cfg.GetHost().c_str(), cfg.GetTcpPort());

            if (!connected)
            {
                AddStatusRecord(SQL_STATE_08001_CANNOT_CONNECT, "Failed to establish connection with the host.");

                return SQL_RESULT_ERROR;
            }

            return MakeRequestHandshake();
        }
Example #8
0
void Module::loadConfig(simulator::Simulation& simulation, const config::Configuration& config)
{
    // Configure parent
    module::Module::loadConfig(simulation, config);

    simulation.getWorld().SetContactListener(this);

    for (auto&& c_bond : config.getConfigurations("bond"))
    {
        m_bonds.push_back(Bond{
            c_bond.get<RealType>("association-constant"),
            c_bond.get<RealType>("disassociation-constant"),
            c_bond.get("ligand"),
            c_bond.get("receptor")
        });
    }
}
                void DsnConfigurationWindow::RetrieveAdditionalParameters(config::Configuration& cfg) const
                {
                    std::string pageSizeStr;

                    pageSizeEdit->GetText(pageSizeStr);

                    int32_t pageSize = common::LexicalCast<int32_t>(pageSizeStr);

                    if (pageSize <= 0)
                        pageSize = config.GetPageSize();

                    std::string nestedTxModeStr;

                    nestedTxModeComboBox->GetText(nestedTxModeStr);

                    NestedTxMode::Type mode = NestedTxMode::FromString(nestedTxModeStr, config.GetNestedTxMode());

                    bool distributedJoins = distributedJoinsCheckBox->IsChecked();
                    bool enforceJoinOrder = enforceJoinOrderCheckBox->IsChecked();
                    bool replicatedOnly = replicatedOnlyCheckBox->IsChecked();
                    bool collocated = collocatedCheckBox->IsChecked();
                    bool lazy = lazyCheckBox->IsChecked();
                    bool skipReducerOnUpdate = skipReducerOnUpdateCheckBox->IsChecked();

                    LOG_MSG("Retrieving arguments:");
                    LOG_MSG("Page size:              " << pageSize);
                    LOG_MSG("Nested TX Mode:         " << NestedTxMode::ToString(mode));
                    LOG_MSG("Distributed Joins:      " << (distributedJoins ? "true" : "false"));
                    LOG_MSG("Enforce Join Order:     " << (enforceJoinOrder ? "true" : "false"));
                    LOG_MSG("Replicated only:        " << (replicatedOnly ? "true" : "false"));
                    LOG_MSG("Collocated:             " << (collocated ? "true" : "false"));
                    LOG_MSG("Lazy:                   " << (lazy ? "true" : "false"));
                    LOG_MSG("Skip reducer on update: " << (skipReducerOnUpdate ? "true" : "false"));

                    cfg.SetPageSize(pageSize);
                    cfg.SetNestedTxMode(mode);
                    cfg.SetDistributedJoins(distributedJoins);
                    cfg.SetEnforceJoinOrder(enforceJoinOrder);
                    cfg.SetReplicatedOnly(replicatedOnly);
                    cfg.SetCollocated(collocated);
                    cfg.SetLazy(lazy);
                    cfg.SetSkipReducerOnUpdate(skipReducerOnUpdate);
                }
Example #10
0
    utils::Parallel::setGlobalCommunicator(utils::Parallel::getCommunicatorWorld());
    reset();
  }
};



BOOST_AUTO_TEST_SUITE(PreciceTests)
BOOST_FIXTURE_TEST_SUITE(Parallel, ParallelTestFixture)


BOOST_AUTO_TEST_CASE(TestMasterSlaveSetup, * testing::OnSize(4))
{
  SolverInterface interface ( "SolverOne", utils::Parallel::getProcessRank(), 4 );
  std::string configFilename = _pathToTests + "config1.xml";
  config::Configuration config;
  xml::configure(config.getXMLTag(), configFilename);
  interface._impl->configure(config.getSolverInterfaceConfiguration());

  BOOST_TEST ( interface.getDimensions() == 3 );

  if(utils::Parallel::getProcessRank()==0){
    BOOST_TEST(utils::MasterSlave::_masterMode == true);
    BOOST_TEST(utils::MasterSlave::_slaveMode == false);
  }
  else {
    BOOST_TEST(utils::MasterSlave::_masterMode == false);
    BOOST_TEST(utils::MasterSlave::_slaveMode == true);
  }

  BOOST_TEST(utils::MasterSlave::_rank == utils::Parallel::getProcessRank());
Example #11
0
void Simulation::configure(const config::Configuration& config)
{
    // Resize world
    {
        auto size = config.get<SizeVector>("world-size");

        if (size.getWidth() == Zero || size.getHeight() == Zero)
            throw config::Exception("Width or height is zero!");

        setWorldSize(size);
    }

    // Time step
    setTimeStep(config.get<units::Time>("dt"));

    if (config.has("length-coefficient"))
    {
        m_converter.setLengthCoefficient(config.get<RealType>("length-coefficient"));
    }

    // Set gravity
    setGravity(config.get("gravity", getGravity()));

    // Number of iterations
    setIterations(config.get("iterations", getIterations()));

    // Background color
    setBackgroundColor(config.get("background", getBackgroundColor()));

#if CONFIG_RENDER_TEXT_ENABLE
    setFontColor(config.get("text-color", getBackgroundColor().inverted()));
#endif

#if CONFIG_RENDER_TEXT_ENABLE
    setFontSize(config.get("text-size", getFontSize()));
#endif

#if CONFIG_RENDER_TEXT_ENABLE
    setSimulationTimeRender(config.get("show-simulation-time", isSimulationTimeRender()));
#endif

#ifdef CECE_ENABLE_RENDER
    setVisualized(config.get("visualized", isVisualized()));
#endif

    // Parse plugins
    for (auto&& pluginConfig : config.getConfigurations("plugin"))
    {
        // Returns valid pointer or throws an exception
        requirePlugin(pluginConfig.get("name"))->configure(*this, pluginConfig);
    }

    // Parse parameters
    for (auto&& parameterConfig : config.getConfigurations("parameter"))
    {
        setParameter(parameterConfig.get("name"), units::parse(parameterConfig.get("value")));
    }

    // Register user types
    for (auto&& typeConfig : config.getConfigurations("type"))
    {
        addObjectType({
            typeConfig.get("name"),
            typeConfig.get("base"),
            typeConfig.toMemory()
        });
    }

    // Parse init
    for (auto&& initConfig : config.getConfigurations("init"))
    {
        const String typeName = initConfig.has("language")
            ? initConfig.get("language")
            : initConfig.get("type");

        auto initializer = getPluginContext().createInitializer(typeName);

        if (initializer)
        {
            // Configure initializer
            initializer->loadConfig(*this, initConfig);

            // Register initializer
            addInitializer(std::move(initializer));
        }
    }

    // Parse modules
    for (auto&& moduleConfig : config.getConfigurations("module"))
    {
        // Get name
        auto name = moduleConfig.get("name");

        if (hasModule(name))
            continue;

        const String typeName = moduleConfig.has("language")
            ? moduleConfig.get("language")
            : moduleConfig.has("type")
                ? moduleConfig.get("type")
                : name
        ;

        auto module = getPluginContext().createModule(typeName, *this);

        if (module)
        {
            module->loadConfig(*this, moduleConfig);

            addModule(std::move(name), std::move(module));
        }
    }

    // Parse programs
    for (auto&& programConfig : config.getConfigurations("program"))
    {
        const String typeName = programConfig.has("language")
            ? programConfig.get("language")
            : programConfig.get("type");

        auto program = getPluginContext().createProgram(typeName);

        if (program)
        {
            // Configure program
            program->loadConfig(*this, programConfig);

            // Register program
            addProgram(programConfig.get("name"), std::move(program));
        }
    }

    // Parse objects
    for (auto&& objectConfig : config.getConfigurations("object"))
    {
        // Create object
        auto object = buildObject(
            objectConfig.get("class"),
            objectConfig.get("type", object::Object::Type::Dynamic)
        );

        if (object)
            object->configure(objectConfig, *this);
    }

    if (config.has("data-out-objects-filename"))
    {
        m_dataOutObjects = makeUnique<OutFileStream>(config.get("data-out-objects-filename"));
        *m_dataOutObjects << "iteration;totalTime;id;typeName;posX;posY;velX;velY\n";
    }
}