示例#1
0
Field::Field(const TCHAR* Name, const TCHAR* Value, int _config, const bool duplicateValue):
	lazy(false)
{
	CND_PRECONDITION(Name != NULL, "Name cannot be NULL");
	CND_PRECONDITION(Value != NULL, "value cannot be NULL");
	CND_PRECONDITION(_tcslen(Value)>0 && _tcslen(Name)>0, "name and value cannot both be empty");

	/*
	if (_config & INDEX_NO && _config & STORE_NO)
		_CLTHROWA(CL_ERR_IllegalArgument,"it doesn't make sense to have a field that is neither indexed nor stored");
	if (_config & INDEX_NO && _config & TERMVECTOR_YES)
		_CLTHROWA(CL_ERR_IllegalArgument,"cannot store term vector information for a field that is not indexed");
	*/

	_name        = CLStringIntern::intern( Name );
	if (duplicateValue)
		fieldsData = stringDuplicate( Value );
	else
		fieldsData = (void*)Value;
	valueType = VALUE_STRING;

	boost=1.0f;

	//config = INDEX_TOKENIZED; // default Field is tokenized and indexed

	setConfig(_config);
}
示例#2
0
/*--------------------------------------------------------------------------*/
void engine::start ( int argc , char **argv,bool sg){
  int P,p,q;

  config.getCmdLine(argc,argv);
  P =config.P;
  p =config.p;
  q =config.q;
  time_out = config.to;
  printf("Engine start, pure-mpi=%d\n",config.pure_mpi);

  ProcessGrid *_PG = new ProcessGrid(P,p,q);
  ProcessGrid &PG=*_PG;

  DataHostPolicy      *hpData    = new DataHostPolicy    (DataHostPolicy::BLOCK_CYCLIC         , PG );
  TaskHostPolicy      *hpTask    = new TaskHostPolicy    (TaskHostPolicy::WRITE_DATA_OWNER     , PG );
  ContextHostPolicy   *hpContext = new ContextHostPolicy (ContextHostPolicy::ALL_ENTER         , PG );
  TaskReadPolicy      *hpTaskRead= new TaskReadPolicy    (TaskReadPolicy::ALL_READ_ALL         , PG );
  TaskAddPolicy       *hpTaskAdd = new TaskAddPolicy     (TaskAddPolicy::WRITE_DATA_OWNER      , PG );


  glbCtx.setPolicies(hpData,hpTask,hpContext,hpTaskRead,hpTaskAdd);
  glbCtx.setConfiguration(&config);
  if ( config.pure_mpi )
    sg = true;
  else
    sg= false;
  setConfig(&config,sg);
  doProcess();
}
示例#3
0
bool EglHwcomposerBackend::initBufferConfigs()
{
    const EGLint config_attribs[] = {
        EGL_RED_SIZE,             8,
        EGL_GREEN_SIZE,           8,
        EGL_BLUE_SIZE,            8,
        EGL_ALPHA_SIZE,           8,
        EGL_RENDERABLE_TYPE,      EGL_OPENGL_ES2_BIT,
        EGL_NONE,
    };

    EGLint count;
    EGLConfig configs[1024];
    if (eglChooseConfig(eglDisplay(), config_attribs, configs, 1, &count) == EGL_FALSE) {
        qCCritical(KWIN_HWCOMPOSER) << "choose config failed";
        return false;
    }
    if (count != 1) {
        qCCritical(KWIN_HWCOMPOSER) << "choose config did not return a config" << count;
        return false;
    }
    setConfig(configs[0]);

    return true;
}
void ConfigSubscriptions::buttonClicked (Button* buttonThatWasClicked)
{
    //[UserbuttonClicked_Pre]
    //[/UserbuttonClicked_Pre]

    if (buttonThatWasClicked == subscribeButton)
    {
        //[UserButtonCode_subscribeButton] -- add your button handler code here..
        //[/UserButtonCode_subscribeButton]
    }
    else if (buttonThatWasClicked == ignoreButton)
    {
        //[UserButtonCode_ignoreButton] -- add your button handler code here..
        //[/UserButtonCode_ignoreButton]
    }

    //[UserbuttonClicked_Post]

  bool should_subscribe = this->subscribeButton->getToggleState() ;
  bool should_ignore    = this->ignoreButton->getToggleState() ;
  int  subscribe_mode   = (should_ignore)   ? NJClient::SUBSCRIBE_DENY :
                          (should_subscribe)? NJClient::SUBSCRIBE_ALL  :
                                              NJClient::SUBSCRIBE_NONE ;

  setConfig(CONFIG::SUBSCRIBE_MODE_KEY , var(subscribe_mode)) ;

    //[/UserbuttonClicked_Post]
}
示例#5
0
void CBankInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const
{
    //logGlobal->debugStream() << "Seed used to configure bank is " << rng.nextInt();

    auto bank = dynamic_cast<CBank*>(object);

    bank->resetDuration = bankResetDuration;

    si32 totalChance = 0;
    for (auto & node : levels)
        totalChance += node["chance"].Float();

    assert(totalChance != 0);

    si32 selectedChance = rng.nextInt(totalChance - 1);
    //logGlobal->debugStream() << "Selected chance for bank config is " << selectedChance;

    for (auto & node : levels)
    {
        if (selectedChance < node["chance"].Float())
        {
            bank->setConfig(generateConfig(node, rng));
        }
        else
        {
            selectedChance -= node["chance"].Float();
        }

    }
}
示例#6
0
MachineConfigObject::MachineConfigObject(QObject *parent, MachineConfig *config)
 : QObject(parent)
    , myConfig(0)
{
    setConfig(config);
    connect(config, SIGNAL(optionChanged(QString, QString, QString, QVariant)),this,SLOT(configChanged(QString, QString, QString, QVariant)));
}
示例#7
0
//__________________________________________________________________________
void Speller::Aspell::Suggest::init(const std::string& lang,
				    const std::string& jargon,
				    const std::string& encoding)
	throw( std::invalid_argument, std::runtime_error )
{
	// Save aspell configuration values
	flang = lang;
	fjargon = jargon;
	fencoding = encoding;

	fconfig = new_aspell_config();
	try
	{
		setConfig();
	}
	catch( const std::invalid_argument& err )
	{
		throw err;
	}

	AspellCanHaveError* ret = new_aspell_speller( fconfig );
	delete_aspell_config( fconfig );
	if( aspell_error_number( ret ) != 0 )
	{
		delete_aspell_can_have_error( ret );
		throw std::runtime_error( "(Aspell::Speller::Suggest::init"
					  "): Error in creating speller." );
	}
	else
	{
		fspeller = to_aspell_speller( ret );
		fconfig = aspell_speller_config( fspeller );
	}
}
示例#8
0
文件: Task.cpp 项目: FreddyFox/dune
      //! Initialize resources.
      void
      onResourceInitialization(void)
      {
        if (!getConstantParameters())
          throw RestartNeeded(DTR("failed to get constant parameters"), c_restart_delay);

        setConfig();

        std::map<std::string, LED*>::iterator itr = m_led_by_name.begin();
        for (unsigned i = 0; i < c_led_count; ++i)
          setBrightness(itr->second, 0);

        if (!m_args.led_patterns.empty())
        {
          uint8_t count = m_args.led_patterns.size();

          UCTK::Frame frame;
          frame.setId(PKT_ID_LED_PATTERN);
          frame.setPayloadSize(1 + (count * 2));
          frame.set(count, 0);
          for (size_t i = 0; i < count; ++i)
            frame.set<uint16_t>(m_args.led_patterns[i], 1 + i * 2);
          if (!m_ctl->sendFrame(frame))
            throw RestartNeeded(DTR("failed to set LED patterns"), c_restart_delay);
        }

        m_wdog.reset();
        setEntityState(IMC::EntityState::ESTA_NORMAL, Status::CODE_ACTIVE);
      }
示例#9
0
/******************************************************************************
Configures the device by setting it into the configured state.

Parameters:
  cfgnum - configuration number to set
******************************************************************************/
static void runtimeSetConfiguration(uint8_t cfgnum)
{
  // Set & save the desired configuration
  setConfig(cfgnum);
  // Acknowledge the request
  txZLP();
}
示例#10
0
Field::Field(const TCHAR* Name, Reader* reader, bool store, bool index, bool token, const bool storeTermVector)
{
//Func - Constructor
//Pre  - Name != NULL and contains the name of the field
//       reader != NULL and contains a Reader
//       store indicates if the field must be stored
//       index indicates if the field must be indexed
//       token indicates if the field must be tokenized
//Post - The instance has been created

    CND_PRECONDITION(Name != NULL, "Name is NULL");
    CND_PRECONDITION(reader != NULL, "reader is NULL");

    _name        = LStringIntern::intern( Name  CL_FILELINE);
    _stringValue = NULL;
    _readerValue = reader;
    _streamValue = NULL;
    boost=1.0f;
    omitNorms = false;

    int cfg = 0;
    if ( store )
        cfg |= STORE_YES;
    if ( index && token )
        cfg |= INDEX_TOKENIZED;
    else if ( index && !token )
        cfg |= INDEX_UNTOKENIZED;

    if ( storeTermVector )
        _CLTHROWA(CL_ERR_IllegalArgument,"Stored term vector is deprecated with using this constructor");

    setConfig(cfg);
}
RabbitMQService::RabbitMQService (Glib::KeyFile &confFile) : Service (confFile)
{
  sigset_t mask;
  std::string address;
  int port;

  try {
    address = confFile.get_string (RABBITMQ_GROUP, RABBITMQ_SERVER_ADDRESS);
  } catch (const Glib::KeyFileError &err) {
    GST_WARNING ("Setting default address %s to media server",
                 RABBITMQ_SERVER_ADDRESS_DEFAULT);
    address = RABBITMQ_SERVER_ADDRESS_DEFAULT;
  }

  try {
    port = confFile.get_integer (RABBITMQ_GROUP, RABBITMQ_SERVER_PORT);
    check_port (port);
  } catch (const Glib::KeyFileError &err) {
    GST_WARNING ("Setting default port %d to media server",
                 RABBITMQ_SERVER_PORT_DEFAULT);
    port = RABBITMQ_SERVER_PORT_DEFAULT;
  }

  this->address = address;
  this->port = port;

  setConfig (address, port);
  this->confFile.load_from_data (confFile.to_data() );

  sigemptyset (&mask);
  sigaddset (&mask, SIGCHLD);
  signalHandler = std::shared_ptr <SignalHandler> (new SignalHandler (mask,
                  std::bind (&RabbitMQService::childSignal, this, std::placeholders::_1) ) );
}
示例#12
0
文件: Musec.cpp 项目: Mystler/Musec
void Musec::loadLanguage(const QString& lang)
{
    qApp->removeTranslator(fTranslator);
    fTranslator->load(QLocale(lang), "musec", "_", ":/locales");
    setConfig("lang", lang);
    qApp->installTranslator(fTranslator);
}
    MockReplicaSet::MockReplicaSet(const string& setName, size_t nodes):
            _setName(setName) {
        ReplConfigMap replConfig;

        for (size_t n = 0; n < nodes; n++) {
            std::stringstream str;
            str << "$" << setName << n << ":27017";
            const string hostName(str.str());

            if (n == 0) {
                _primaryHost = hostName;
            }

            MockRemoteDBServer* mockServer = new MockRemoteDBServer(hostName);
            _nodeMap[hostName] = mockServer;

            MockConnRegistry::get()->addServer(mockServer);

            ReplSetConfig::MemberCfg config;
            config.h = HostAndPort(hostName);
            replConfig.insert(std::make_pair(hostName, config));
        }

        setConfig(replConfig);
    }
示例#14
0
/**************************************************
* Configure the Pi / touchIt
**************************************************/
void setup()
{
	unsigned char len = 0;
	unsigned char dir = IN;
	static const char dir_str[] = "in\0out";

	signal (SIGINT, exitHandler);

	// Open the I2C bus (enable file access)
	char *filename = (char *)"/dev/i2c-1";
	if((file_i2c = open(filename, O_RDWR)) < 0)
	{
		printf("setup(): Failed to open the i2c bus\n");
		return;
	}

	if(ioctl(file_i2c, I2C_SLAVE, TCHADD1) < 0)
	{
		printf("Failed to acquire bus access and/or talk to slave\n");
		return;
	}

	// Enable GPIO to read touchIt 'int' pin
	if((file_gpio = open("/sys/class/gpio/export", O_WRONLY)) < 0)
	{
		printf("setup(): Failed to open export for writing\n");
		return;
	}
	else
	{
		len = snprintf(buffer, BUFMAX, "%d", intPin);
		write(file_gpio, buffer, len);
		close(file_gpio);
	}

	// Configure GPIO Direction as input
	snprintf(buffer, DIRMAX, "/sys/class/gpio/gpio%d/direction", intPin);
	if((file_gpio = open(buffer, O_WRONLY)) < 0)
	{
		printf("setup(): Failed to open gpio direction for writing\n");
		return;
	}
	else
	{
		write(file_gpio, &dir_str[IN == dir ? 0:3], IN  == dir ? 2:3);
		close(file_gpio);
	}

	// Open gpio file for reading
	snprintf(buffer, DIRMAX, "/sys/class/gpio/gpio%d/value", intPin);
	if((file_gpio = open(buffer, O_RDONLY)) < 0)
	{
		printf("gpioRead(): failed to open gpio value for reading\n");
		return;
	}

	getVersion();

	setConfig(XMOVE | YMOVE);
}
示例#15
0
ImageProcessor::ImageProcessor(SkinCamConfig aConfig)
	:mouseClickNbhrd(7), cannyHighThresh(127), cannyLowThresh(127), cannyImage(0), medianKernel(7),
	  autoSelectCannyImage(false), lastSharpestBand(0),
	  distLowEnd(aConfig.distanceLowEnd), distHighEnd(aConfig.distanceHighEnd)
{
	setConfig(aConfig);
}
示例#16
0
TICC1100::TICC1100(std::shared_ptr<BaseLib::Systems::PhysicalInterfaceSettings> settings) : IPhysicalInterface(GD::bl, settings)
{
	try
	{
		_out.init(GD::bl);
		_out.setPrefix(GD::out.getPrefix() + "TI CC110X \"" + settings->id + "\": ");

		if(settings->listenThreadPriority == -1)
		{
			settings->listenThreadPriority = 45;
			settings->listenThreadPolicy = SCHED_FIFO;
		}
		if(settings->oscillatorFrequency < 0) settings->oscillatorFrequency = 26000000;
		if(settings->txPowerSetting < 0) settings->txPowerSetting = 0xC0;

		_transfer =  { (uint64_t)0, (uint64_t)0, (uint32_t)0, (uint32_t)4000000, (uint16_t)0, (uint8_t)8, (uint8_t)0, (uint32_t)0 };

		setConfig();
	}
    catch(const std::exception& ex)
    {
    	_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
    	_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
    	_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
示例#17
0
Kiptables::Kiptables(const char *name,KIptablesConfig *config) : KTMainWindow(name)
{
	setConfig(config);
	initView();
	initActions();
	createGUI();
}
示例#18
0
bool CDVRPTRV3Controller::openModem()
{
	bool ret = false;

	switch (m_connection) {
		case CT_USB:
			ret = m_usb->open();
			break;
		case CT_NETWORK:
			ret = m_network->open();
			break;
		default:
			wxLogError(wxT("Invalid connection type: %d"), int(m_connection));
			break;
	}

	if (!ret)
		return false;

	ret = readSerial();
	if (!ret) {
		closeModem();
		return false;
	}

	ret = setConfig();
	if (!ret) {
		closeModem();
		return false;
	}

	return true;
}
示例#19
0
void plDynamicTextMap::Create(unsigned int width, unsigned int height,
                              bool hasAlpha, unsigned int extraWidth,
                              unsigned int extraHeight) {
    setConfig(kRGB8888);
    fVisWidth = width;
    fVisHeight = height;
    fHasAlpha = hasAlpha;
    fWidth = 1;
    if (width + extraWidth > 1) {
        while (fWidth < (width + extraWidth))
            fWidth *= 2;
    }
    fHeight = 1;
    if (height + extraHeight > 1) {
        while (fHeight < (height + extraHeight))
            fHeight *= 2;
    }

    fHasBeenCreated = true;
    /*fFlags |= kDontThrowAwayImage;*/
    fStride = fWidth * 4;
    fLevelData.resize(1);
    fCompressionType = kUncompressed;
    fUncompressedInfo.fType = kRGB8888;
}
示例#20
0
//__________________________________________________________________________
void Speller::Aspell::Suggest::resetConfig()
	throw( std::invalid_argument, std::runtime_error )
{
	delete_aspell_config( fconfig );
	fconfig = new_aspell_config();
	try
	{
		setConfig();
	}
	catch( const std::invalid_argument& err )
	{
		throw err;
	}

	AspellCanHaveError* ret = new_aspell_speller( fconfig );
	if( aspell_error_number( ret ) != 0 )
	{
		delete_aspell_can_have_error( ret );
		throw std::runtime_error( "(Aspell::Speller::Suggest::Reset"
					  "Config): Error in creating "
					  "speller." );
	}
	else
	{
		// Following statement causes a crash, hence commented out
		//delete_aspell_speller( fspeller );
		fspeller = to_aspell_speller( ret );
		delete_aspell_config( fconfig );
		fconfig = aspell_speller_config( fspeller );
	}
}
示例#21
0
/**
 * Inicializa o mecanismo de log
 */
void initializeLog() {

	// Desabilita o log
	debugEnabled = 0;

	// Obtem recurso para ativar log
	enabledLog = getProperty(PROPERTY_LOG_ENABLED);

	// Verifica se deve ativar o log
	if (enabledLog != NULL && strcmp(enabledLog, "true") == 0) {

		fileLogName = getProperty(PROPERTY_LOG_FILE);
		if (fileLogName == NULL) {
			fileLogName = LOG_FILE;
		}

		// Obtem output
		output = getProperty(PROPERTY_LOG_OUTPUT);

		// Ativa o log
		debugEnabled = 1;

		if (output != NULL) {

			setConfig(atoi(output));

		}

	}

}
void ConfigDialogImpl::displayDialog()
{
    ui = new Configdialog(0L, "configure", true);
    connect(ui->buttonCancel, SIGNAL(clicked()), SLOT(slotCancel()));
    connect(ui->buttonOk, SIGNAL(clicked()), SLOT(slotOk()));
    setConfig();
    ui->show();
}
示例#23
0
void MediaCenter::setCoverSize(int coverSize)
{
    if (m_coverSize != coverSize) {
        m_coverSize = coverSize;
        setConfig(GUI_COVER_SIZE, m_coverSize);
        emit coverSizeChanged(m_coverSize);
    }
}
示例#24
0
void MediaCenter::setFullScreen(bool showFullScreen)
{
    if (m_showFullScreen != showFullScreen) {
        m_showFullScreen = showFullScreen;
        setConfig(GUI_SHOW_FULLSCREEN, showFullScreen);
        show();
        emit fullScreenChanged();
    }
}
示例#25
0
uint8_t HDC1000::begin(uint8_t reset, uint8_t mode, uint8_t resolution, uint8_t heater){
	Wire.begin();

	uint8_t config = mode|resolution|heater|reset;

	setConfig(config);

	return config;
}
示例#26
0
Converter::Converter(const char * config)
{
    if (!initialized)
        initialize();

    handle = NULL;
    m_loaded = false;
    setConfig(config);
}
示例#27
0
RobotConfig::RobotConfig(RobotWeakPtr robot, const std::string &name, const std::vector< Configuration > &configs)
	: name(name),
	robot(robot)
{
	THROW_VR_EXCEPTION_IF(!robot.lock(),"NULL robot in RobotConfig");
	for (std::vector< Configuration >::const_iterator i=configs.begin(); i!=configs.end(); i++ )
	{
		setConfig((*i));
	}
}
示例#28
0
RobotConfig::RobotConfig(RobotWeakPtr robot, const std::string &name, const std::map< RobotNodePtr, float > &configs)
	: name(name),
	robot(robot)
{
	THROW_VR_EXCEPTION_IF(!robot.lock(),"NULL robot in RobotConfig");
	for (std::map< RobotNodePtr, float >::const_iterator i=configs.begin(); i!=configs.end(); i++ )
	{
		setConfig(i->first,i->second);
	}
}
示例#29
0
FavoriteAppsModel::FavoriteAppsModel(QObject *parent)
: QAbstractListModel(parent)
{
    QHash<int, QByteArray> roles;
    roles.insert(Qt::DisplayRole, "label");
    roles.insert(Qt::DecorationRole, "icon");
    roles.insert(FavoriteIdRole, "favoriteId");
    setRoleNames(roles);
    setConfig(KSharedConfig::openConfig("salrc"));
}
示例#30
0
void MainWindow::ClickSetting(){

    Setting *setting = new Setting();
    setting->exec();
    setConfig();
    delete setting;



}