modified to use events, hopefully will fix the crashing particle

This commit is contained in:
Martin Donnelly 2016-02-12 16:39:05 +00:00
parent b8e4a3229d
commit 4cbd586bc4

View File

@ -62,9 +62,7 @@ function insertTempReading(time, reading) {
logger.debug('Inserting reading:' + reading); logger.debug('Inserting reading:' + reading);
temp_db.run('BEGIN TRANSACTION'); temp_db.run('BEGIN TRANSACTION');
temp_db.run('INSERT into temp(date, reading) VALUES (?,?);', [time, reading]); temp_db.run('INSERT into temp(date, reading) VALUES (?,?);', [time, reading]);
temp_db.run('commit'); temp_db.run('commit');
} }
@ -127,13 +125,11 @@ router.post('/', function (req, res, next) {
if (data.hasOwnProperty('temp')) { if (data.hasOwnProperty('temp')) {
busEmitter.emit("saveTempData", {time: now.toJSON(), value: parseFloat(data.temp)}); busEmitter.emit("saveTempData", {time: now.toJSON(), value: parseFloat(data.temp)});
} }
else else {
{
logger.error('No temp data!'); logger.error('No temp data!');
} }
} }
else else {
{
logger.error('No data block!'); logger.error('No data block!');
} }
@ -165,8 +161,6 @@ router.get('/all', function (req, res, next) {
//closeDB(); //closeDB();
}); });
}); });
module.exports = router; module.exports = router;