Changeset 13767 for trunk/FACT++
- Timestamp:
- 05/17/12 20:21:30 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/drivectrl.cc
r13223 r13767 733 733 }; 734 734 735 string fDatabase; 736 735 737 typedef map<string,pair<double,double>> sources; 736 738 sources fSources; … … 945 947 946 948 T::Out() << name << "," << ra << "," << dec << endl; 949 } 950 return T::GetCurrentState(); 951 } 952 953 int ReloadSources() 954 { 955 try 956 { 957 ReadDatabase(); 958 } 959 catch (const exception &e) 960 { 961 T::Error("Reading sources from databse failed: "+string(e.what())); 947 962 } 948 963 return T::GetCurrentState(); … … 1140 1155 ("Print source list."); 1141 1156 1157 T::AddEvent("RELOAD_SOURCES") 1158 (bind(&StateMachineDrive::ReloadSources, this)) 1159 ("Reload sources from database."); 1160 1142 1161 fDrive.StartConnect(); 1143 1162 } … … 1148 1167 } 1149 1168 1150 void ReadDatabase( const string &database)1169 void ReadDatabase(bool print=true) 1151 1170 { 1152 1171 //static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))?"); … … 1159 1178 1160 1179 boost::smatch what; 1161 if (!boost::regex_match( database, what, expr, boost::match_extra))1162 throw runtime_error("Couldn't parse '"+ database+"'.");1180 if (!boost::regex_match(fDatabase, what, expr, boost::match_extra)) 1181 throw runtime_error("Couldn't parse '"+fDatabase+"'."); 1163 1182 1164 1183 if (what.size()!=10) 1165 throw runtime_error("Error parsing '"+ database+"'.");1184 throw runtime_error("Error parsing '"+fDatabase+"'."); 1166 1185 1167 1186 const string user = what[2]; … … 1200 1219 }*/ 1201 1220 1221 fSources.clear(); 1202 1222 for (vector<mysqlpp::Row>::const_iterator v=res.begin(); v<res.end(); v++) 1203 1223 { … … 1209 1229 fSources[name] = make_pair(ra, dec); 1210 1230 1211 ostringstream msg; 1212 msg << " " << name << setprecision(8) << ": Ra=" << ra << "h Dec=" << dec << "deg"; 1213 T::Message(msg); 1231 if (print) 1232 { 1233 ostringstream msg; 1234 msg << " " << name << setprecision(8) << ": Ra=" << ra << "h Dec=" << dec << "deg"; 1235 T::Message(msg); 1236 } 1214 1237 } 1215 1238 } … … 1255 1278 1256 1279 if (conf.Has("source-database")) 1257 ReadDatabase(conf.Get<string>("source-database")); 1280 { 1281 fDatabase = conf.Get<string>("source-database"); 1282 ReadDatabase(); 1283 } 1258 1284 1259 1285 // The possibility to connect should be last, so that
Note:
See TracChangeset
for help on using the changeset viewer.