示例#1
0
//设置参数
void MainWidget::on_serPort_write_SP_PsBtn_clicked()
{
    pSPTYPE   pSPTYPE_Temp =NULL;
    if((pSPTYPE_Temp=(pSPTYPE)calloc(1,sizeof(SPTYPE)))==NULL)
    {
        free(pSPTYPE_Temp);
        pSPTYPE_Temp=NULL;
        return ;
    }

    pSPTYPE_Temp->SAMDOT = atof(ui->serPort_SP_TabWidget->item(0,1)->text().toLatin1().data());
    strcpy((char *)pSPTYPE_Temp->PRODUCT, ui->serPort_SP_TabWidget->item(0,3)->text().toStdString().c_str());
    //qDebug("dddd%s",pSPTYPE_Temp->PRODUCT);
    pSPTYPE_Temp->VOLTAGERANGE = atof(ui->serPort_SP_TabWidget->item(2,1)->text().toLatin1().data());
    pSPTYPE_Temp->CURRENTRANGE = atof(ui->serPort_SP_TabWidget->item(2,3)->text().toLatin1().data());

    pSPTYPE_Temp->METERCONST  = atof(ui->serPort_SP_TabWidget->item(3,1)->text().toLatin1().data());
    pSPTYPE_Temp->CONST1      = atof(ui->serPort_SP_TabWidget->item(3,3)->text().toLatin1().data());
    pSPTYPE_Temp->PRICE       = ui->serPort_SP_TabWidget->item(4,1)->text().toFloat(0);

    //qDebug("xxx=%f",pSPTYPE_Temp->PRICE);
    pSPTYPE_Temp->CHARGETYPE  =  SP_chargeType_cbbox->currentIndex();
    pSPTYPE_Temp->LOADTYPE    =  SP_loadType_cbbox->currentIndex();
    pSPTYPE_Temp->MEASURETYPE =  SP_measureType_cbbox->currentIndex();


    if(timeThreadTimer.setSP(pSPTYPE_Temp)==false )
    {
        show_MsBox(QString::fromUtf8("设置失败"),3000);
        return ;
    }

    show_MsBox(QString::fromUtf8("设置成功"),3000);

    write_ini("SP/SAMRATE",ui->serPort_SP_TabWidget->item(0,1)->text());
    write_ini("SP/PRODUCT",ui->serPort_SP_TabWidget->item(0,3)->text());

    write_ini("SP/VOLTAGERANGE",ui->serPort_SP_TabWidget->item(2,1)->text());
    write_ini("SP/CURRENTRANGE",ui->serPort_SP_TabWidget->item(2,3)->text());

    write_ini("SP/METERCONST",ui->serPort_SP_TabWidget->item(3,1)->text());
    write_ini("SP/CONST",ui->serPort_SP_TabWidget->item(3,3)->text());
    write_ini("SP/PRICE",ui->serPort_SP_TabWidget->item(4,1)->text());

    write_ini("SP/CHARGETYPE",QString::number(SP_chargeType_cbbox->currentIndex()));
    write_ini("SP/LOADTYPE",QString::number(SP_loadType_cbbox->currentIndex()));
    write_ini("SP/MEASURETYPE",QString::number(SP_measureType_cbbox->currentIndex()));
}
示例#2
0
void save_config()
{
	out_config_file.open(abs_file_name.c_str(), fstream::out);
	write_ini(out_config_file, config_pt);
	out_config_file.flush();
	out_config_file.close();
}
示例#3
0
void robot_config_t::to_file(const std::string& filename) const
{
	ini_t ini;

	for(key_t::const_iterator iter=keys_m.begin();iter!=keys_m.end();++iter)
		ini[iter->first]=to_lower(iter->second);

	write_ini(filename,ini);
}
void AsiftKeypoints::iniwriteSiftParameters(std::string name,siftPar par){

	ptree pt;
	
	iniwriteSiftParameters(pt,par);

	write_ini(name,pt);

}
示例#5
0
文件: Admin.cpp 项目: PoopikPele/VoIP
bool admin_change_type (short int type, char* pass)
{
	if (type == 2 && !admin_change_pass (pass, 1) )
	{
		ptree pt;
		boost::property_tree::ini_parser::read_ini("conf.ini", pt);
		pt.put("server_type", type);
		write_ini("conf.ini", pt);
		return true;
	}
	else if (type == 2)
		return false;
	else
	{
		ptree pt;
		boost::property_tree::ini_parser::read_ini("conf.ini", pt);
		pt.put("server_type", type);
		pt.put("server_pass", "\0");
		write_ini("conf.ini", pt);
		return true;
	}
}
示例#6
0
void CMisc::saveManager(string saveFileName, string dataName, int value, string dataName2, int value2)
{
	namespace propertyTree = boost::property_tree;

	propertyTree::ptree pt;

	pt.put(dataName, value);
	pt.put(dataName2, value2);


	write_ini(saveFileName, pt);

}
示例#7
0
void REPLAY::StartRecording(
	const std::string & newcartype,
	const std::string & newcarpaint,
	const MATHVECTOR<float, 3> & newcarcolor,
	const PTree & carconfig,
	const std::string & trackname,
	std::ostream & error_log)
{
	track = trackname;
	cartype = newcartype;
	carpaint = newcarpaint;
	carcolor = newcarcolor;

	GetReadyToRecord();

	std::stringstream carstream;
	write_ini(carconfig, carstream);
	carfile = carstream.str();
}
示例#8
0
文件: Admin.cpp 项目: PoopikPele/VoIP
short int admin_change_pass (char* pass, bool force)
{
	ptree pt;
	short int type;
	boost::property_tree::ini_parser::read_ini ("conf.ini", pt);
	type = pt.get<short int>("server_type");
	if (type == 2 || force)
	{
		if ( strlen(pass) > 16 || strlen(pass) < 5 )
			return 2;
		else
		{
			pt.put("server_pass", pass);
			write_ini("conf.ini", pt);
			return 0;
		}
	}
	else
		return 1;
}
示例#9
0
static void write_ini(const PTree & p, std::ostream & out, std::string key_name)
{
	for (PTree::const_iterator i = p.begin(), e = p.end(); i != e; ++i)
	{
		if (i->second.size() == 0)
		{
			out << i->first << " = " << i->second.value() << "\n";
		}
	}
	out << "\n";

	for (PTree::const_iterator i = p.begin(), e = p.end(); i != e; ++i)
	{
		if (i->second.size() > 0)
		{
			out << "[" << key_name + i->first << "]\n";
			write_ini(i->second, out, key_name + i->first + ".");
		}
	}
}
string OAuthClient::access(){
	string url = serverUrl + access_token_url;
	cout << "accessing" << endl;
	string queryString = getQuery(url);

	url = url + questionMark + queryString;
	cout << " url " + url<< endl;

	string response = httpClient.get(url, true);
	cout << "response " + response << endl;

	Token response_token = Token::extract(response);

	init = initClient(response_token.key(), response_token.secret());
	authenticated = authenticate();
	puserConfig.put("user.oauth_key", response_token.key());
	puserConfig.put("user.oauth_secret", response_token.secret());
	write_ini(uConfig, puserConfig);

	return response;
}
string OAuthClient::logout(){

	cout << "ERASE" << endl;
	puserConfig.clear();
	puserConfig.put("user.oauth_key" , "");
	puserConfig.put("user.oauth_secret" , "");
	write_ini(uConfig, puserConfig);

	if(!init) return "";

	string url = serverUrl + logout_url;
	cout << "logout" << endl;
	string queryString = getQuery(url, true);
	url = url + questionMark + queryString;

	string response = httpClient.get(url);
	cout << "response " + response << endl;

	authenticated = false;
	init = false;

	return response;
}
示例#12
0
G_MODULE_EXPORT void on_properties1_activate(GtkWidget *wiggy, gpointer data)
{
	GtkWidget	*dialog;
	GtkWidget	*w;

	dialog=GTK_WIDGET(gtk_builder_get_object (builder, "PreferencesDialog"));

	/* Put in the current values */
	w=GTK_WIDGET(gtk_builder_get_object (builder, "eEditTextFile"));
	gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.edit_text_file);
	w=GTK_WIDGET(gtk_builder_get_object (builder, "eViewTextFile"));
	gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_text_file);
	w=GTK_WIDGET(gtk_builder_get_object (builder, "eViewStdout"));
	gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_stdout);
	w=GTK_WIDGET(gtk_builder_get_object (builder, "eViewCtrlAFile"));
	gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_ctrla_file);
	w=GTK_WIDGET(gtk_builder_get_object (builder, "eViewHTMLFile"));
	gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_html_file);

	switch(gtk_dialog_run(GTK_DIALOG(dialog))) {
		case GTK_RESPONSE_OK:
			/* Read out the new values */
			w=GTK_WIDGET(gtk_builder_get_object (builder, "eEditTextFile"));
			strcpy(gtkm_conf.edit_text_file,gtk_entry_get_text(GTK_ENTRY(w)));
			w=GTK_WIDGET(gtk_builder_get_object (builder, "eViewTextFile"));
			strcpy(gtkm_conf.view_text_file,gtk_entry_get_text(GTK_ENTRY(w)));
			w=GTK_WIDGET(gtk_builder_get_object (builder, "eViewStdout"));
			strcpy(gtkm_conf.view_stdout,gtk_entry_get_text(GTK_ENTRY(w)));
			w=GTK_WIDGET(gtk_builder_get_object (builder, "eViewCtrlAFile"));
			strcpy(gtkm_conf.view_ctrla_file,gtk_entry_get_text(GTK_ENTRY(w)));
			w=GTK_WIDGET(gtk_builder_get_object (builder, "eViewHTMLFile"));
			strcpy(gtkm_conf.view_html_file,gtk_entry_get_text(GTK_ENTRY(w)));
			write_ini();
	}
	gtk_widget_hide_on_delete(dialog);
}
示例#13
0
void write_ini(const PTree & p, std::ostream & out)
{
	write_ini(p, out, std::string());
}
示例#14
0
int state0() 
/* Do what needs to be done in state 0.

   pre: The global variable 'paramfile' contains the name of the
        parameter file specified on the commandline.
        The global variable 'alpha' contains the number of indiviuals
        you need to generate for the initial population.
                
   post: Optionally read parameter specific for the module.
         Optionally do some initialization.
         Initial population created.
         Information about initial population written to the ini file
         using write_ini().
         Return value == 0 if successful,
                      == 1 if unspecified errors happened,
                      == 2 if file reading failed.
*/
{
     /**********| added for DTLZ |**************/
     int i;
     /**********| addition for DTLZ end |*******/

     
     int result; /* stores return values of called functions */
     int *initial_population; /* storing the IDs of the individuals */
     initial_population = (int *) malloc(alpha * sizeof(int)); 
     if (initial_population == NULL)
     {
          log_to_file(log_file, __FILE__, __LINE__, "variator out of memory");
          return (1);
     }

     /**********| added for DTLZ |**************/
     result = read_local_parameters();
     
     if (result != 0)
     { 
          log_to_file(log_file, __FILE__, __LINE__,
                      "couldn't read local parameters");
          return (1);
     }

     /* initializing the first alpha individuals */
     for(i = 0; i < alpha; i++)
     {
 	 individual *ind = new_individual();
	 eval(ind);
	 initial_population[i] = add_individual(ind);
         if(initial_population[i] == -1)
            return(1);
     } 

     gen = 1;
     
     /**********| addition for DTLZ end |*******/

     result = write_ini(initial_population);
     if (result != 0)
     { 
          log_to_file(log_file, __FILE__, __LINE__,
                      "couldn't write ini");
          free(initial_population);
          return (1);
     }

     free(initial_population);
     return (0);
}