1 #include <fdet/FTelescopeListXMLManager.h>
3 #include <fwk/CentralConfig.h>
4 #include <utl/ErrorLogger.h>
5 #include <utl/Reader.h>
6 #include <fdet/FManagerRegister.h>
27 FTelescopeListXMLManager::GetTelescopeListData(T& returnData,
28 const string& componentProperty,
29 const string& componentName,
42 if (componentIndex.empty()) {
50 else if (componentIndex.size() == 1) {
51 return GetEyeData(returnData, componentProperty,
52 componentName, componentIndex);
54 else if (componentIndex.size() == 2) {
55 return GetTelescopeData(returnData, componentProperty,
56 componentName, componentIndex);
59 if (IsReportingErrors()) {
60 INFO(
string(
"More than three indices found; ") +
61 QueryInfoMessage(componentProperty, componentName, componentIndex));
74 FTelescopeListXMLManager::GetEyeData(T& returnData,
75 const string& componentProperty,
76 const string& componentName,
80 const IndexMap::const_iterator it = componentIndex.find(
"eyeId");
81 if (it == componentIndex.end()) {
82 INFO(
string(
"Only one index found and it is not 'eyeId'; ") +
83 QueryInfoMessage(componentProperty, componentName, componentIndex));
87 if (componentName !=
"eye"
88 && componentName !=
"virtualEye") {
91 const bool isVirtual = componentName ==
"virtualEye";
94 atts[
"id"] = it->second;
101 if (isVirtual && componentProperty ==
"parentEye")
105 if (componentProperty ==
"name")
106 eyeB = fBranch.
GetChild(
"virtualEye", atts);
126 FTelescopeListXMLManager::GetTelescopeData(T& returnData,
127 const string& componentProperty,
128 const string& componentName,
133 const IndexMap::const_iterator eIt = componentIndex.find(
"eyeId");
134 if (eIt == componentIndex.end()) {
135 INFO(
string(
"Two indices found, neither of them is 'eyeId'; ") +
136 QueryInfoMessage(componentProperty, componentName, componentIndex));
140 const IndexMap::const_iterator tIt = componentIndex.find(
"telescopeId");
141 if (tIt == componentIndex.end()) {
142 INFO(
string(
"Two indices found, neither of them is 'telescopeId'; ") +
143 QueryInfoMessage(componentProperty, componentName, componentIndex));
148 const bool isVirtual = componentName ==
"virtualTelescope";
149 if (componentName !=
"telescope" && !isVirtual) {
155 const string componentPropertyReal = (componentProperty ==
"pointing")
160 atts[
"id"] = eIt->second;
161 Branch eyeB = fBranch.
GetChild((isVirtual ?
"virtualEye" :
"eye"), atts);
167 && (componentProperty ==
"fromEye"
168 || componentProperty ==
"fromTelescope")) {
175 atts[
"id"] = tIt->second;
194 FTelescopeListXMLManager::GetFullEyeTelescopeList(list<int>& returnList,
195 const string& componentProperty,
196 const string& componentName,
204 if (componentProperty ==
"eyeList") {
208 if (cb.GetName() ==
"eye"
209 || cb.GetName() ==
"virtualEye") {
210 istringstream
is(cb.GetAttributes().find(
"id")->second);
213 returnList.push_back(
id);
218 else if (componentProperty ==
"telescopeList") {
221 if (componentIndex.size() != 1) {
222 INFO(
string(
"Invalid number of indices specified "
223 "in request for 'telescopeList'; ") +
224 QueryInfoMessage(componentProperty, componentName, componentIndex));
229 const IndexMap::const_iterator eIt = componentIndex.find(
"eyeId");
230 if (eIt == componentIndex.end()) {
231 INFO(
string(
"Invalid indices for retrieving 'telescopeList'; ") +
232 QueryInfoMessage(componentProperty, componentName, componentIndex));
239 eyeAtts[
"id"] = eIt->second;
243 eyeB = topB.
GetChild(
"virtualEye", eyeAtts);
247 info <<
"Could not find requested eye in XML file: " << eIt->second;
256 const IndexMap telescopeAtts = telescopeB.GetAttributes();
257 istringstream
is(telescopeAtts.find(
"id")->second);
260 returnList.push_back(telescopeId);
266 INFO(
string(
"Could not interpret the request with ") +
267 QueryInfoMessage(componentProperty, componentName, componentIndex));
277 FTelescopeListXMLManager::GetTelescopePointingData(std::map<std::string, double>& returnData,
278 const string& componentProperty,
279 const string& componentName,
283 if (componentIndex.size() != 2)
286 if (componentProperty !=
string(
"opticalAxisPhi")
287 && componentProperty != string(
"opticalAxisElevation")) {
292 const IndexMap::const_iterator eIt = componentIndex.find(
"eyeId");
294 if (eIt == componentIndex.end()) {
295 INFO(
string(
"No 'eyeId' in componentIndex; ") +
296 QueryInfoMessage(componentProperty, componentName, componentIndex));
301 atts[
"id"] = eIt->second;
307 const IndexMap::const_iterator tIt = componentIndex.find(
"telescopeId");
309 if (tIt == componentIndex.end()) {
310 INFO(
string(
"Two indices found, neither of them is 'telescopeId'; ") +
311 QueryInfoMessage(componentProperty, componentName, componentIndex));
315 atts[
"id"] = tIt->second;
325 const std::string pointingId = attrs.find(
string(
"id"))->second;
328 returnData[pointingId] = angle;
339 const std::string& componentProperty,
340 const std::string& componentName,
344 if (componentProperty ==
"relativeResponse") {
346 vector<double> wavelength;
348 GetTelescopeListData(wavelength,
"relativeResponseLambda",
349 componentName, componentIndex);
354 vector<double> value;
355 s = GetTelescopeListData(value,
"relativeResponseValue",
356 componentName, componentIndex);
363 return VManager::eFound;
365 }
else if (componentProperty ==
"MHzTimeCorrection") {
367 vector<double> correctionFactors;
369 GetTelescopeListData(correctionFactors,
"MHzCorrectionFactors",
370 componentName, componentIndex);
374 vector<double> months;
375 s = GetTelescopeListData(months,
"MHzCorrectionTimes",
376 componentName, componentIndex);
Class to hold collection (x,y) points and provide interpolation between them.
bool is(const double a, const double b)
std::map< std::string, std::string > AttributeMap
#define INFO(message)
Macro for logging informational messages.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
AttributeMap GetAttributes() const
Get a map<string, string> containing all the attributes of this Branch.
Branch GetNextSibling() const
Get next sibling of this branch.
Class representing a document branch.
Reads data from XML file(s) containing data unique to telescopes and eyes (eg. positions, orientations, commission times, and so forth).
void GetData(bool &b) const
Overloads of the GetData member template function.
#define REGISTER_F_MANAGER(_name_, _Type_)
std::map< std::string, std::string > IndexMap
Branch GetFirstChild() const
Get first child of this Branch.
Status
Specifies success or (eventually) various possible failure modes.