예제 #1
0
//--------------------------------------------------------
void WebSocketDSClass::erase_dynamic_attributes(const Tango::DevVarStringArray *devlist_ptr, vector<Tango::Attr *> &att_list)
{
	Tango::Util *tg = Tango::Util::instance();

	for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
	{
		Tango::DeviceImpl *dev_impl = tg->get_device_by_name(((string)(*devlist_ptr)[i]).c_str());
		WebSocketDS *dev = static_cast<WebSocketDS *> (dev_impl);

		vector<Tango::Attribute *> &dev_att_list = dev->get_device_attr()->get_attribute_list();
		vector<Tango::Attribute *>::iterator ite_att;
		for (ite_att=dev_att_list.begin() ; ite_att != dev_att_list.end() ; ++ite_att)
		{
			string att_name((*ite_att)->get_name_lower());
			if ((att_name == "state") || (att_name == "status"))
				continue;
			vector<string>::iterator ite_str = find(defaultAttList.begin(), defaultAttList.end(), att_name);
			if (ite_str == defaultAttList.end())
			{
				cout2 << att_name << " is a UNWANTED dynamic attribute for device " << (*devlist_ptr)[i] << endl;
				Tango::Attribute &att = dev->get_device_attr()->get_attr_by_name(att_name.c_str());
				dev->remove_attribute(att_list[att.get_attr_idx()], true, false);
				--ite_att;
			}
		}
	}
	/*----- PROTECTED REGION ID(WebSocketDSClass::erase_dynamic_attributes) ENABLED START -----*/
    
    /*----- PROTECTED REGION END -----*/	//	WebSocketDSClass::erase_dynamic_attributes
}
예제 #2
0
void attribute(int sinc[])
{
    int att_pro[CONJ]={COD_STRING};
    int attname_sig[CONJ]={COD_DOSPUNTOS};
    checkinput(att_pro,sinc);
    switch(t_actual.compLex)
    {
        case COD_STRING:
            printf("<");
            att_name(attname_sig);//llama a la funcion que va a imprimir el nombre del tag
            printf(">");
            match(COD_DOSPUNTOS);
            att_value(sinc);
            break;
        default:
            error("Se esperaba STRING");
            break;
    }
    checkinput(sinc,att_pro);
    printf("</");
    auxiliar = lex[k];//se guarda el nombre de tag que corresponda
    printf("%s",sin_comilla(auxiliar.lexema));//se imprime nombre de tag de cierre
    k--;//se posiciona en el proximo nombre de tag
    printf(">");
}
예제 #3
0
void ConstantSet::read_from_netcdf(NcFile &nc, std::string const &vname)
{
	NcVar *ncvar = giss::get_var_safe(nc, vname.c_str(), true);
	if (!ncvar) {
		fprintf(stderr, "ConstantSet::read_from_netcdf() cannot find variable %s\n", vname.c_str());
		throw std::exception();
	}
	int n = ncvar->num_atts();

	// Read through the attributes, getting units and names separately
	std::map<std::string, std::string> units;
	std::map<std::string, double> consts;
	std::map<std::string, std::string> descriptions;
	for (int i=0; i<n; ++i) {
		auto att = giss::get_att(ncvar, i);
		std::string att_name(att->name());
		if (giss::ends_with(att_name, "_description")) {
			descriptions.insert(std::make_pair(
				att_name.substr(0, att_name.size() - std::strlen("_description")),
				std::string(att->as_string(0))));
		} else if (giss::ends_with(att_name, "_units")) {
			units.insert(std::make_pair(
				att_name.substr(0, att_name.size() - std::strlen("_units")),
				std::string(att->as_string(0))));
		} else {
			consts.insert(std::make_pair(
				att_name, att->as_double(0)));
		}
	}

	// Now go through them again, matching up constants and units
	for (auto ii = consts.begin(); ii != consts.end(); ++ii) {
		std::string const &name = ii->first;
		double const val = ii->second;

		auto ui = units.find(name);
		if (ui == units.end()) {
			fprintf(stderr, "Could not find _units attribute for %s\n", name.c_str());
		}

		auto di = descriptions.find(name);
		if (di == descriptions.end()) {
			fprintf(stderr, "Could not find _description attribute for %s\n", name.c_str());
		}

		std::string const &u = units.find(name)->second;
		std::string const &d = descriptions.find(name)->second;

		set(name, val, u, d);
	}
}
예제 #4
0
//--------------------------------------------------------
void WebSocketDSClass::create_static_attribute_list(vector<Tango::Attr *> &att_list)
{
	for (unsigned long i=0 ; i<att_list.size() ; i++)
	{
		string att_name(att_list[i]->get_name());
		transform(att_name.begin(), att_name.end(), att_name.begin(), ::tolower);
		defaultAttList.push_back(att_name);
	}

	cout2 << defaultAttList.size() << " attributes in default list" << endl;

	/*----- PROTECTED REGION ID(WebSocketDSClass::create_static_att_list) ENABLED START -----*/
    
    /*----- PROTECTED REGION END -----*/	//	WebSocketDSClass::create_static_att_list
}