/[H9]/trunk/tntnet/dynamic/critical.ecpp
ViewVC logotype

Diff of /trunk/tntnet/dynamic/critical.ecpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 155 by torben, Tue Dec 4 13:29:21 2007 UTC revision 156 by torben, Wed Dec 5 10:47:51 2007 UTC
# Line 22  tntdb::Connection conn = tntdb::connect( Line 22  tntdb::Connection conn = tntdb::connect(
22    
23    
24  std::string query1;  std::string query1;
25  query1 += "SELECT c.name, i.description, i.id ";  query1 += "SELECT c.name, i.description, i.id, i.commerror ";
26  query1 += "FROM installation i INNER JOIN customer c ";  query1 += "FROM installation i INNER JOIN customer c ";
27  query1 += "ON i.customerid = c.id";  query1 += "ON i.customerid = c.id";
28    
# Line 31  tntdb::Result inst_res = conn.select(que Line 31  tntdb::Result inst_res = conn.select(que
31    
32    
33  std::string query2;  std::string query2;
34  query2 += "SELECT commerror,temperature,flamedetector,conveyorerror,powerfailure ";  query2 += "SELECT temperature,flamedetector,conveyorerror,powerfailure ";
35  query2 += "FROM logtable ";  query2 += "FROM logtable ";
 query2 += "INNER JOIN installation ";  
 query2 += "ON logtable.installationnr = installation.id ";  
36  query2 += "WHERE installationnr = :v1 ";  query2 += "WHERE installationnr = :v1 ";
37  query2 += "ORDER BY messagenr DESC ";  query2 += "ORDER BY messagenr DESC ";
38  query2 += "LIMIT 1";  query2 += "LIMIT 1";
39    
40    
41  tntdb::Statement st = conn.prepare(query2);  tntdb::Statement st = conn.prepare(query2);
42    
43  std::ostream& out = reply.out();  std::ostream& out = reply.out();
# Line 53  for (unsigned i=0; i<inst_res.size(); i+ Line 52  for (unsigned i=0; i<inst_res.size(); i+
52          st.setInt("v1", id);          st.setInt("v1", id);
53          tntdb::Result res = st.select();          tntdb::Result res = st.select();
54    
55            bool commerror = inst_res[i].getBool(3);
56            int temperature = 50;
57            bool flameDetector = true;
58            bool conveyorError = false;
59            bool powerFailure = false;
60    
61          if (res.size() > 0)          if (res.size() > 0)
62          {          {
63                  bool commerror = res[0].getBool(0);                  temperature = res[0].getInt(0);
64                  int temperature = res[0].getInt(1);                  flameDetector = res[0].getBool(1);
65                  bool flameDetector = res[0].getBool(2);                  conveyorError = res[0].getBool(2);
66                  bool conveyorError = res[0].getBool(3);                  powerFailure = res[0].getBool(3);
67                  bool powerFailure = res[0].getBool(4);          }
68    
69                  if (commerror || temperature > 90 || flameDetector == false || conveyorError || powerFailure)          if (commerror || temperature > 90 || flameDetector == false || conveyorError || powerFailure)
70                  {          {
71                          out << "<a href='installationdetails?id=" << id << "'><b>" << inst_res[i].getString(0) << "</b> : " << inst_res[i].getString(1) << "<br></a>\n";                  out << "<a href='installationdetails?id=" << id << "'><b>" << inst_res[i].getString(0) << "</b> : " << inst_res[i].getString(1) << "<br></a>\n";
72                          out << "<ul>";                  out << "<ul>";
73    
74                          if (temperature > 90)                  if (temperature > 90)
75                                  out << "<li>High temperature</li>\n";                          out << "<li>High temperature</li>\n";
76    
77                          if (commerror)                  if (commerror)
78                                  out << "<li>Communication error</li>\n";                          out << "<li>Communication error</li>\n";
79    
80                          if (flameDetector == false)                  if (flameDetector == false)
81                                  out << "<li>No flames</li>\n";                          out << "<li>No flames</li>\n";
82    
83                          if (conveyorError)                  if (conveyorError)
84                                  out << "<li>Conveyor error</li>\n";                          out << "<li>Conveyor error</li>\n";
85    
86                          if (powerFailure)                  if (powerFailure)
87                                  out << "<li>Power failure</li>\n";                          out << "<li>Power failure</li>\n";
88    
89                          out << "</ul>\n";                  out << "</ul>\n";
90    
91                          hasCritical = true;                  hasCritical = true;
                 }  
92          }          }
93  }  }
94    

Legend:
Removed from v.155  
changed lines
  Added in v.156

  ViewVC Help
Powered by ViewVC 1.1.20