forked from avirad/npbc-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnpbc_monitor_logger.py
44 lines (40 loc) · 1.66 KB
/
npbc_monitor_logger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
import os
import time
import multiprocessing
from multiprocessing.managers import BaseManager
import serialworker
import json
import sqlite3
import settings
import npbc_communication
def initializeDatabase():
dbconn = sqlite3.connect(settings.DATABASE)
dbconn.execute("CREATE TABLE IF NOT EXISTS [BurnerLogs] ( \
[Timestamp] DATETIME NOT NULL PRIMARY KEY, \
[SwVer] NVARCHAR NOT NULL, \
[Date] DATETIME NOT NULL, \
[Mode] INTEGER NOT NULL, \
[State] INTEGER NOT NULL, \
[Status] INTEGER NOT NULL, \
[IgnitionFail] TINYINT NOT NULL, \
[PelletJam] TINYINT NOT NULL, \
[Tset] INTEGER NOT NULL, \
[Tboiler] INTEGER NOT NULL, \
[Flame] INTEGER NOT NULL, \
[Heater] TINYINT NOT NULL, \
[CHPump] TINYINT NOT NULL, \
[BF] TINYINT NOT NULL, \
[FF] TINYINT NOT NULL, \
[Fan] INTEGER NOT NULL, \
[Power] INTEGER NOT NULL, \
[ThermostatStop] TINYINT NOT NULL, \
[FFWorkTime] INTEGER NOT NULL)")
dbconn.commit()
if __name__ == '__main__':
## Initialize database
initializeDatabase()
## start the serial worker in background (as a deamon)
sp = serialworker.SerialProcess()
#sp.daemon = True
sp.start()