FACT++  1.0
void ConnectionLid::ProcessAnswer ( )
inlineprivate

Definition at line 103 of file lidctrl.cc.

References i, ConnectionLid::Lid::Print(), ConnectionLid::Lid::Set(), and ConnectionLid::Lid::status.

104  {
105  if (fIsVerbose)
106  {
107  Out() << "------------------------------------------------------" << endl;
108  Out() << fRdfData << endl;
109  Out() << "------------------------------------------------------" << endl;
110  }
111 
112  fRdfData.insert(0, "<?xml version=\"1.0\"?>\n");
113 
114  QDomDocument doc;
115  if (!doc.setContent(QString(fRdfData.c_str()), false))
116  {
117  Warn("Parsing of html failed.");
118  return;
119  }
120 
121  if (fIsVerbose)
122  {
123  Out() << "Parsed:\n-------\n" << doc.toString().toStdString() << endl;
124  Out() << "------------------------------------------------------" << endl;
125  }
126 
127  const QDomNodeList imageElems = doc.elementsByTagName("span"); // "input"
128 
129  /*
130  // elementById
131  for (unsigned int i=0; i<imageElems.length(); i++)
132  {
133  QDomElement e = imageElems.item(i).toElement();
134  Out() << "<" << e.tagName().toStdString() << " ";
135 
136  QDomNamedNodeMap att = e.attributes();
137 
138  for (int j=0; j<att.size(); j++)
139  {
140  Out() << att.item(j).nodeName().toStdString() << "=";
141  Out() << att.item(j).nodeValue().toStdString() << " ";
142  }
143  Out() << "> " << e.text().toStdString() << endl;
144  }*/
145 
146  for (unsigned int i=0; i<imageElems.length(); i++)
147  {
148  const QDomElement e = imageElems.item(i).toElement();
149 
150  const QDomNamedNodeMap att = e.attributes();
151 
152  fLid1.Set(att);
153  fLid2.Set(att);
154  }
155 
156  if (fIsVerbose)
157  {
158  fLid1.Print(Out());
159  fLid2.Print(Out());
160  Out() << "------------------------------------------------------" << endl;
161  }
162 
163  Update(fLid1, fLid2);
164 
165  fRdfData = "";
166 
167  if ((fLid1.status!="Open" && fLid1.status!="Closed" && fLid1.status!="Power Problem" && fLid1.status!="Unknown" && fLid1.status!="Overcurrent") ||
168  (fLid2.status!="Open" && fLid2.status!="Closed" && fLid2.status!="Power Problem" && fLid2.status!="Unknown" && fLid1.status!="Overcurrent"))
169  Warn("Lid reported status unknown by lidctrl ("+fLid1.status+"/"+fLid2.status+")");
170 
171  fLastReport = Time();
172  }
void Print(ostream &out)
Definition: lidctrl.cc:74
Time fLastReport
Definition: lidctrl.cc:93
string fRdfData
Definition: lidctrl.cc:87
int i
Definition: db_dim_client.c:21
bool Set(const QDomNamedNodeMap &map)
Definition: lidctrl.cc:43
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
virtual void Update(const Lid &, const Lid &)
Definition: lidctrl.cc:98
std::ostream & Out()
Definition: Connection.h:51
bool fIsVerbose
Definition: lidctrl.cc:84
int Warn(const std::string &str)
Definition: MessageImp.h:48

+ Here is the call graph for this function: