--- trunk/tntnet/dynamic/critical.ecpp 2007/12/05 09:53:16 155 +++ trunk/tntnet/dynamic/critical.ecpp 2007/12/05 10:47:51 156 @@ -22,7 +22,7 @@ std::string query1; -query1 += "SELECT c.name, i.description, i.id "; +query1 += "SELECT c.name, i.description, i.id, i.commerror "; query1 += "FROM installation i INNER JOIN customer c "; query1 += "ON i.customerid = c.id"; @@ -31,14 +31,13 @@ std::string query2; -query2 += "SELECT commerror,temperature,flamedetector,conveyorerror,powerfailure "; +query2 += "SELECT temperature,flamedetector,conveyorerror,powerfailure "; query2 += "FROM logtable "; -query2 += "INNER JOIN installation "; -query2 += "ON logtable.installationnr = installation.id "; query2 += "WHERE installationnr = :v1 "; query2 += "ORDER BY messagenr DESC "; query2 += "LIMIT 1"; + tntdb::Statement st = conn.prepare(query2); std::ostream& out = reply.out(); @@ -53,38 +52,43 @@ st.setInt("v1", id); tntdb::Result res = st.select(); + bool commerror = inst_res[i].getBool(3); + int temperature = 50; + bool flameDetector = true; + bool conveyorError = false; + bool powerFailure = false; + if (res.size() > 0) { - bool commerror = res[0].getBool(0); - int temperature = res[0].getInt(1); - bool flameDetector = res[0].getBool(2); - bool conveyorError = res[0].getBool(3); - bool powerFailure = res[0].getBool(4); + temperature = res[0].getInt(0); + flameDetector = res[0].getBool(1); + conveyorError = res[0].getBool(2); + powerFailure = res[0].getBool(3); + } - if (commerror || temperature > 90 || flameDetector == false || conveyorError || powerFailure) - { - out << "" << inst_res[i].getString(0) << " : " << inst_res[i].getString(1) << "
\n"; - out << "\n"; - hasCritical = true; - } + hasCritical = true; } }