Fixed more SolarData stuff
This commit is contained in:
@@ -19,11 +19,13 @@ import tuxeip
|
||||
from tuxeip import TuxEIP, LGX, LGX_REAL
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
db = MySQLdb.connect(host="127.0.0.1",user="website",passwd="henrypump",db="SolarData")
|
||||
db = MySQLdb.connect(host="127.0.0.1",user="website",passwd="henrypump",db="TagData")
|
||||
cur = db.cursor()
|
||||
query = "SELECT * FROM SolarData.tags WHERE deleted = 0;"
|
||||
query = "SELECT * FROM TagData.tags WHERE deleted = 0;"
|
||||
cur.execute(query)
|
||||
tags = cur.fetchall()
|
||||
# ((1L, 'DC_Bus_Voltage', datetime.datetime(2015, 12, 8, 16, 2, 32), 'V', 0L), (2L, 'Output_Frequency', datetime.datetime(2015, 12, 8, 16, 31, 12), 'Hz', 0L))
|
||||
@@ -31,6 +33,7 @@ def main():
|
||||
db.close()
|
||||
|
||||
PLC_IP_ADDRESS = "192.168.1.10" # MAKE THIS A db VALUE
|
||||
scan_rate = 10
|
||||
|
||||
tagList = [];
|
||||
if len(tags) > 0:
|
||||
@@ -48,9 +51,9 @@ def main():
|
||||
r["val"] = tux.ReadLGXDataAsFloat(sess, conn, r['name'], 1)[0]
|
||||
print("{0} - {1}".format(r["name"], r["val"]))
|
||||
if not r["val"] == r["lastVal"]:
|
||||
db = MySQLdb.connect(host="127.0.0.1",user="website",passwd="henrypump",db="SolarData")
|
||||
db = MySQLdb.connect(host="127.0.0.1",user="website",passwd="henrypump",db="TagData")
|
||||
cur = db.cursor()
|
||||
aQuery = """INSERT INTO SolarData.values (tagID, val) VALUES ('%d', '%f');"""%(r["id"], float(r["val"]))
|
||||
aQuery = """INSERT INTO TagData.values (tagID, val) VALUES ('%d', '%f');"""%(r["id"], float(r["val"]))
|
||||
print(aQuery)
|
||||
storeVal = cur.execute(aQuery)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user