Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
// Add your own code
/*----- 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 -----*/
// Add your own code
/*----- 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 -----*/
// Add your own code
/*----- 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 -----*/
// Add your own code
/*----- 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);
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
/*----- PROTECTED REGION ID(DataImporterClass::command_factory_after) ENABLED START -----*/
// Add your own code
/*----- 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 -----*/
/*----- 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