コード例 #1
0
ファイル: settingscontainer.cpp プロジェクト: vilkov/qfm
void Container::load()
{
	QFile file(m_storage);

	if (file.open(QFile::ReadOnly))
	{
		QXmlStreamReader stream(&file);

		if (readNextStartElement(stream) && stream.name() == QString::fromLatin1("QFM"))
			load(stream);
		else
			loadDefault();
	}
	else
		loadDefault();
}
コード例 #2
0
void ProgramData::changeBattery(int direction)
{
    battery.type+=direction;
    if(battery.type>=LAST_BATTERY_TYPE)
        battery.type=Unknown;
    loadDefault();
}
コード例 #3
0
void loadSaves(){
	std::stringstream filename;
	filename << directory<< "GenPool.dino";

	std::ifstream is;
	is.open(filename.str(),std::ios::in | std::ios::binary);

	if(!is.good()){
		is.close();
		MessageBox(NULL, "Error 404: Savefile not found\nDefault values will be used instead", TEXT("Failed to load saves"), MB_OK | MB_ICONERROR);
		loadDefault();
		return;
	}

	int noCreatures;
	is.read((char*)&noCreatures, sizeof(int));

	for(int i=0;i<noCreatures;i++){
		save* tmpCreature =new save();

		//read name
		int nameLength;
		is.read((char*)&nameLength, sizeof(int));
		tmpCreature->name.resize(nameLength);
		is.read((char*)&tmpCreature->name[0], sizeof(char)*nameLength);

		//read dna
		int sizeOfDna;
		is.read((char*)&sizeOfDna, sizeof(int));
		tmpCreature->dna.resize(sizeOfDna);
		is.read((char*)&tmpCreature->dna[0], sizeof(int)*sizeOfDna);

		//read fitness
		is.read((char*)&tmpCreature->fitness, sizeof(float));
		saves.push_back(tmpCreature);
	}
	if(!is.good()){
		MessageBox(NULL, "the loading failed and a default value will be read", TEXT("Failed to load saves"), MB_OK | MB_ICONERROR);
		loadDefault();
	}
	is.close();
}
コード例 #4
0
ファイル: XmlLanguage.cpp プロジェクト: dreamsxin/rainbrurpg
/** The default constructor
  *
  */
RainbruRPG::Options::xmlLanguage::xmlLanguage()
  :doc(NULL), 
   root(NULL), 
   lastUsed(""),
   defaultLang(""),
   mNbMessages(0)
{

  LOGI("xmlLanguage creation");

  Network::GlobalURI gu;
  this->filename=gu.getUserDirFile("languages.xml");
  refresh();

  languageList=new tLanguageList();

  if (loadDocument()){
    loadLastUsed();
    loadDefault();
    loadNbMessages();
    
    GTS_LIT(str1);
    // TRANSLATORS: The parameter is a language name.
    sprintf(str1, _("Last used language found : '%s'"), lastUsed);
    LOGI(str1);

    GTS_LIT(str2);
    // TRANSLATORS: The parameter is a language name.
    sprintf(str2, _("Default language found : '%s'"), defaultLang);
    LOGI(str2);

    treatAllLanguages();

    GTS_TIN(str3);
    // TRANSLATORS: The parameter is an integer (the list size).
    sprintf(str3, _("Language list size is '%d'"), languageList->size());
    LOGI(str3);

  }
  else{
    LOGE(_("Cannot load languages.xml"));

    GTS_LIT(str4);
    // TRANSLATORS: The parameter is an absolute file name (i.e. with paths).
    sprintf(str4,_("languages.xml absolute filename : '%s'"),filename.c_str());
    LOGE(str4)

    GTS_BIG(str5);
    // TRANSLATORS: The parameter is an error string
    sprintf(str5,_("TinyXml error description '%s'"),doc->ErrorDesc());
    LOGE(str5)
  }

}
コード例 #5
0
ファイル: Settings.cpp プロジェクト: gitter-badger/xournalpp
Settings::Settings(String filename)
{
	XOJ_INIT_TYPE(Settings);

	this->filename = filename;
	this->timeoutId = 0;
	this->saved = true;

	loadDefault();

	checkCanXInput();
}
コード例 #6
0
ファイル: comm.c プロジェクト: changkyuya/corvusm3
/* doComm - if one line is complete do Command ------------------------------*/
void doComm()
{
	// do byte commands first char
	switch (line[0])
	{
		// command
		case 'c':
			docComm();
			break;
		// debug level
		case 'd':
			dodComm();
			break;
		// set parameter
		case 's':
			dosComm();
			break;
		// set and store in FLASH
		case 'f':
			dofComm();
			break;
		// print parameter
		case 'p':
			dopComm();
			break;
		// read from flash parameter
		case 'r':
			dorComm();
			break;
		// laod default parameter
		case '#':
			loadDefault();
			break;
		// flash all parameter
		case '*':
			flashAllParameter();
			break;
		// RC signal from Tool
		case '~':
			doRCComm();
			break;
		default:
			send(HELP);
	}
	
	// clear line
	l = 0;
	// send info to user
	//char message [] = "OK\r\n";
}
コード例 #7
0
ファイル: nvram_daemon.c プロジェクト: WiseMan787/ralink_sdk
/*
 * gpio interrupt handler -
 *   SIGUSR1 - notify goAhead to start WPS (by sending SIGUSR1)
 *   SIGUSR2 - restore default value
 */
static void nvramIrqHandler(int signum)
{
	if (signum == SIGUSR1) {
#ifdef CONFIG_RALINK_RT2880
		int gopid;
		FILE *fp = fopen("/var/run/goahead.pid", "r");

		if (NULL == fp) {
			printf("nvram: goAhead is not running\n");
			return;
		}
		fscanf(fp, "%d", &gopid);
		if (gopid < 2) {
			printf("nvram: goAhead pid(%d) <= 1\n", gopid);
			return;
		}

		//send SIGUSR1 signal to goAhead for WPSPBCStart();
		printf("notify goahead to start WPS PBC..\n");
		kill(gopid, SIGUSR1);
		fclose(fp);
#else
		//RT2883, RT3052, RT3883 use a different gpio number for WPS,
		//which will be registered in goahead instead
#endif
	} else if (signum == SIGUSR2) {
		printf("load default and reboot..\n");
		loadDefault(2860);
#if defined (CONFIG_RTDEV) || \
    defined (CONFIG_RTDEV_PLC)
		loadDefault(2880);
#elif defined (CONFIG_RT2561_AP) || defined (CONFIG_RT2561_AP_MODULE)
		loadDefault(2561);
#endif
		system("reboot");
	}
}
コード例 #8
0
ファイル: CurveInput.cpp プロジェクト: mjvogelsong/Heater
// Master function for obtaining the information needed
//  	to define the reflow curve
//  	choice: 0 - default
//  	        1 - user-defined
void CurveInput::loadCurve( boolean choice )
{
	if ( !choice ) // Default
	{
		loadDefault(); // get the default times and temps
		initLCD(&col, &row);
		lcd.print("Loaded Default");
	}
	else
	{
		loadUserCurve(); // get the user's times and temps
		initLCD(&col, &row);
		lcd.print("Loaded User");
	}
}
コード例 #9
0
ファイル: config.cpp プロジェクト: asavonic/moldynam
void IConfig::loadFromStream(std::istream& is)
{
    loadDefault();
    std::string entry_name;
    bool read = true;
    while (read) {
        while (char c = is.get()) {
            if (!is.good()) {
                read = false;
                break;
            }

            // trim spaces at the beginning
            if (c == ' ' || c == '\n' || c == '\r') {
                continue;
            }

            // skip comment line
            if (c == '#') {
                is.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
                continue;
            }

            // next config header, finish parsing
            if (c == '[') {
                read = false;
            }

            is.unget();
            break;
        }

        if (!read) {
            break;
        }

        is >> entry_name;

        if (m_strEntryMap.count(entry_name)) {
            m_strEntryMap[entry_name]->readValueFromStream(is);
        } else {
            throw ConfigError("Unrecognized config entry: " + entry_name);
        }
    }

    onLoad();
}
コード例 #10
0
ファイル: parameter.c プロジェクト: changkyuya/corvusm3
/* load Parameter from virtual EEPROM ---------------------------------------*/
void loadParameter()
{
	u16 val;
	u16 i;

	// test if flash is clear
	EE_ReadVariable(401, &val);
	if (val != 99)
	{
		loadDefault();
	}
	EE_WriteVariable(401, 99);
	
	for (i = 0;i <= USED_PARAMETER; i++)
	{
		EE_ReadVariable(VirtAddVarTab[i], &val);
		parameter[i] = val;
		// for test
		print_para(i);
		Delay(2); // prevent txbuffer overvlow
	}
}
コード例 #11
0
ファイル: calibration_v0.cpp プロジェクト: ana-GT/golems
/**
 * @function setKinematics
 */
bool setKinematics() {

  // Always set this first
  setHardCodedStructures();

  std::string path_world("/home/ana/Research/commonData/scenes/benchmark_tests/test0_followBall.urdf");
  
  // Load known knowledge
  loadDefault();
  
  // Load world
  dart::utils::DartLoader dl;
  mWorld = dl.parseWorld( path_world );
  
  if( !mWorld ) {
    printf("\t [ERROR] Was not able to load world \n");
    return false;
  }
  
  setSubject( mS, mWorld, LWA4_ROBOT );
  return true;
}
コード例 #12
0
ファイル: app.cpp プロジェクト: hplh/SoVStereo
App::App(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	centralWidget = new QWidget;
	centralLayout = new QVBoxLayout;

	contentWidget = new QWidget;
	contentLayout = new QGridLayout;

	elapsedTimeLabel = new QLabel("Elapsed time: 0 s");
	elapsedTimeLabel->setFixedSize(300, 15);

	sourceLabel = new QLabel;
	sourceLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	sourceLabel->setScaledContents(true);
	contentLayout->addWidget(sourceLabel, 0, 0);

	maskLabel = new QLabel;
	maskLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	maskLabel->setScaledContents(true);
	contentLayout->addWidget(maskLabel, 0, 1);

	v_disparityLabel = new QLabel;
	v_disparityLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	v_disparityLabel->setScaledContents(true);
	contentLayout->addWidget(v_disparityLabel, 0, 2);

	v_disparity_N_Label = new QLabel;
	v_disparity_N_Label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	v_disparity_N_Label->setScaledContents(true);
	contentLayout->addWidget(v_disparity_N_Label, 2, 2);

	u_disparityLabel = new QLabel;
	u_disparityLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	u_disparityLabel->setScaledContents(true);
	contentLayout->addWidget(u_disparityLabel, 2, 1);

	resultLabel = new QLabel;
	resultLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	resultLabel->setScaledContents(true);
	contentLayout->addWidget(resultLabel, 2, 0);

	contentWidget->setLayout(contentLayout);

	centralLayout->addWidget(elapsedTimeLabel);
	centralLayout->addWidget(contentWidget);
	centralWidget->setLayout(centralLayout);

	setCentralWidget(centralWidget);

	connect(ui.action_Load_default, SIGNAL(triggered()), this, SLOT(loadDefault()));
	connect(ui.action_Load_source, SIGNAL(triggered()), this, SLOT(loadSource()));
	connect(ui.action_Load_mask, SIGNAL(triggered()), this, SLOT(loadMask()));
	connect(ui.action_Remove_mask, SIGNAL(triggered()), this, SLOT(removeMask()));
	connect(ui.action_Save, SIGNAL(triggered()), this, SLOT(saveResult()));
	connect(ui.actionV_Disparity, SIGNAL(triggered()), this, SLOT(v_disparityCall()));
	connect(ui.actionU_Disparity, SIGNAL(triggered()), this, SLOT(u_disparityCall()));
	connect(ui.actionHoughLineV_Disp, SIGNAL(triggered()), this, SLOT(houghLinesV_DispCall()));
	connect(ui.actionPHoughLineV_Disp, SIGNAL(triggered()), this, SLOT(probabilisticHoughLinesV_DispCall()));
	connect(ui.actionCudaHoughLineV_Disp, SIGNAL(triggered()), this, SLOT(cudaHoughLinesV_DispCall()));
	connect(ui.actionCudaPHoughLineV_Disp, SIGNAL(triggered()), this, SLOT(cudaProbabilisticHoughLinesV_DispCall()));
}
コード例 #13
0
ファイル: esdasettings.cpp プロジェクト: lexchou/esda
ESDASettings::ESDASettings()
{
    //load settings
    loadDefault();
}
コード例 #14
0
ファイル: DeviceInfo.cpp プロジェクト: jsli/code-snippet
DeviceInfo::DeviceInfo() {
	// TODO Auto-generated constructor stub
//	load();
	loadDefault();
}
コード例 #15
0
ファイル: kscopeconfig.cpp プロジェクト: choueric/kscope-4
/**
 * Class constructor.
 */
KScopeConfig::KScopeConfig() : m_bFontsChanged(false)
{
    // TODO:
    loadDefault();
}
コード例 #16
0
ファイル: settings.cpp プロジェクト: nonametr/mls
void Settings::checkIntegrity()
{
	map<string, string> integrity_check = {
            {"custom_rtmp_channel", 	CHECK_CUSTOM_RTMP_CHANNEL_TABLE_INTEGRITY_V1},
	};

	QSqlQuery query(db);
	for(auto it = integrity_check.begin(); it != integrity_check.end(); ++it)
	{
		query.exec(it->second.c_str());
		query.next();
		QSqlRecord result = query.record();
        ASSERT_WITH_CODE(result.field("is_correct").value().toBool(), "Custom RTMP channel plugin configuration SQL database integrity check error!", traceerr("Table \'%s\' corrupted or not exist. Restoring default configuration!", it->first.c_str()); loadDefault(); return;);
	}