Newer
Older
for (unsigned long i=1 ; i<=devlist_ptr->length() ; i++)
{
// Add dynamic attributes if any
DataImporter *dev = static_cast<DataImporter *>(device_list[device_list.size()-i]);
dev->add_dynamic_attributes();
// Check before if database used.
if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false))
export_device(dev);
else
export_device(dev, dev->get_name().c_str());
}
/*----- PROTECTED REGION ID(DataImporterClass::device_factory_after) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataImporterClass::device_factory_after
}
//--------------------------------------------------------
/**
* Method : DataImporterClass::attribute_factory()
* Description : Create the attribute object(s)
* and store them in the attribute list
*/
//--------------------------------------------------------
void DataImporterClass::attribute_factory(vector<Tango::Attr *> &att_list)
{
/*----- PROTECTED REGION ID(DataImporterClass::attribute_factory_before) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataImporterClass::attribute_factory_before
// Create a list of static attributes
create_static_attribute_list(get_class_attr()->get_attr_list());
/*----- PROTECTED REGION ID(DataImporterClass::attribute_factory_after) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataImporterClass::attribute_factory_after
}
//--------------------------------------------------------
/**
* Method : DataImporterClass::command_factory()
* Description : Create the command object(s)
* and store them in the command list
*/
//--------------------------------------------------------
void DataImporterClass::command_factory()
{
/*----- PROTECTED REGION ID(DataImporterClass::command_factory_before) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataImporterClass::command_factory_before
// Command On
OnClass *pOnCmd =
new OnClass("On",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR);
command_list.push_back(pOnCmd);
// Command Off
OffClass *pOffCmd =
new OffClass("Off",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR);
command_list.push_back(pOffCmd);
/*----- PROTECTED REGION ID(DataImporterClass::command_factory_after) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataImporterClass::command_factory_after
}
//===================================================================
// Dynamic attributes related methods
//===================================================================
//--------------------------------------------------------
/**
* method : DataImporterClass::create_static_attribute_list
* description : Create the a list of static attributes
*
* @param att_list the ceated attribute list
*/
//--------------------------------------------------------
void DataImporterClass::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(DataImporterClass::create_static_att_list) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataImporterClass::create_static_att_list
}
//--------------------------------------------------------
/**
* method : DataImporterClass::erase_dynamic_attributes
* description : delete the dynamic attributes if any.
*
* @param devlist_ptr the device list pointer
* @param list of all attributes
*/
//--------------------------------------------------------
void DataImporterClass::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());
DataImporter *dev = static_cast<DataImporter *> (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(DataImporterClass::erase_dynamic_attributes) ENABLED START -----*/
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
/*----- PROTECTED REGION END -----*/ // DataImporterClass::erase_dynamic_attributes
}
//--------------------------------------------------------
/**
* Method : DataImporterClass::get_attr_by_name()
* Description : returns Tango::Attr * object found by name
*/
//--------------------------------------------------------
Tango::Attr *DataImporterClass::get_attr_object_by_name(vector<Tango::Attr *> &att_list, string attname)
{
vector<Tango::Attr *>::iterator it;
for (it=att_list.begin() ; it<att_list.end() ; it++)
if ((*it)->get_name()==attname)
return (*it);
// Attr does not exist
return NULL;
}
/*----- PROTECTED REGION ID(DataImporterClass::Additional Methods) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataImporterClass::Additional Methods
} // namespace