def main(): #This is used to test the module reporter = Reporter() def checkControls(): curs = db.cursor() curs.execute("SELECT ALL channel,value FROM control") conts = curs.fetchall() curs.close() if conts == []: return idNo, data = conts[0] print("Test Acknowledge Control {} = 0x{}".format( Reporter.num_str(idNo, 10, 2), data)) curs = db.cursor() curs.execute("DELETE FROM control WHERE channel=(?);", (idNo, )) db.commit() curs.close() global logging logging = True global db import createBubNetTables db = createBubNetTables.getdb() print("Testing Module executeBSM.py") print("The following output should be generated by the program") print(""" ========================= This has to be put in yet ========================= """) bsma = BSM("test", "/home/barney/Desktop/bubblNet/installation/test.bsm", db, reporter) bsmb = BSM("testfire", "/home/barney/Desktop/bubblNet/installation/testfire.bsm", db, reporter) while True: checkControls() bsma.runEvent() bsmb.runEvent() time.sleep(0.5)
#!/usr/bin/python3 import time import sys import RPi.GPIO as GPIO import sqlite3 import createBubNetTables import executeBSM from executeBSM import BSM import nrf24l01 from nrf24l01 import tx, rx, initRF import hd44780u_i2c from hd44780u_i2c import lcd_init, lcd_num, lcd_mess, num_str db = createBubNetTables.getdb() bsmdb = createBubNetTables.getbsmdb() config = {} with open( "/home/pi/BUBBLnetConfig.bub", "r", ) as conf: for line in conf: if line[0:4] == "cfg(": cp = line.index(",") key = line[4:cp] config[key] = line[cp + 1:-2] rfChannel = int(config["RFchannel"]) serialNo = int(config["serial"]) period = int(config["period"]) scriptPath = config["scriptPath"]