Przeglądaj źródła

changed the flow log database command from REPLACE to INSERT and fixed a error message

Sebastian 6 lat temu
rodzic
commit
454ebd2008
3 zmienionych plików z 5 dodań i 4 usunięć
  1. 1 1
      CoffeeCode/buildno
  2. 1 1
      CoffeeCode/database.cpp
  3. 3 2
      CoffeeCode/hal.cpp

+ 1 - 1
CoffeeCode/buildno

@@ -1 +1 @@
-273
+275

+ 1 - 1
CoffeeCode/database.cpp

@@ -211,7 +211,7 @@ int sqlSetConf(config_key_t id, uint64_t value) {
  */
 
 int sqlLogFlow(uint64_t sweep, uint64_t flow, uint64_t deltaT) {
-	int rc = sqlExecute(string_sprintf("REPLACE INTO flowLog (sweep, flow, timestamp) "
+	int rc = sqlExecute(string_sprintf("INSERT INTO flowLog (sweep, flow, timestamp) "
 			"VALUES (%lld, %lld, %lld);", sweep, flow, deltaT));
 	if (rc != SQLITE_OK)
 		return EXIT_FAILURE;

+ 3 - 2
CoffeeCode/hal.cpp

@@ -275,8 +275,9 @@ void halIntFlow(void) {
 	timespec deltaT;
 	clock_gettime(CLOCK_REALTIME, &flowTimestep[flowIndex]);
 	timespec_diff(&flowTimestep[((flowIndex + 1) % 2)], &flowTimestep[flowIndex], &deltaT);
-	if (sqlLogFlow(0, halGetFlow(), deltaT.tv_sec * 1000 + deltaT.tv_nsec/1000000)) {
-		logger_error("coffee.cpp: Couldn't write brewcounter to database");
+
+	if (sqlLogFlow(1, halGetFlow(), deltaT.tv_sec * 1000 + deltaT.tv_nsec/1000000)) {
+		logger_error("hal.cpp: could not log flow to database!");
 		return;
 	}
 	flowIndex = (flowIndex + 1) % 2;