Filter.py aufgeräumt, modbus erweitert syncronisiert jetzt die zeit, pCahrger speichert zählerstand pro dose
This commit is contained in:
parent
4512f2b3dc
commit
6edf4bb90f
3 changed files with 12 additions and 5 deletions
|
|
@ -11,7 +11,6 @@ from Sym2Lib import Add2Adapter, get_DataFrameDict
|
|||
from datetime import datetime
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
from Queue import Queue
|
||||
from pandas import DataFrame
|
||||
from profile.database import Database
|
||||
|
||||
|
|
@ -32,7 +31,6 @@ class CANFilter(Thread):
|
|||
def __init__(self, conf):
|
||||
Thread.__init__(self)
|
||||
self.conf = conf
|
||||
self.queue = Queue()
|
||||
|
||||
### init DB ###
|
||||
self.db = Database()
|
||||
|
|
@ -60,9 +58,6 @@ class CANFilter(Thread):
|
|||
self.symList.append(get_DataFrameDict(sym))
|
||||
Add2Adapter(self.pcan, sym)
|
||||
|
||||
def mean(self, l):
|
||||
return float(sum(l))/len(l) if len(l) > 0 else 0
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
receiveMessageName = self.pcan.receiveMessage()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ Created on 05.12.2013
|
|||
'''
|
||||
from pymodbus.client.sync import ModbusTcpClient
|
||||
from datetime import datetime
|
||||
import time
|
||||
from profile.datasheet import Datasheet
|
||||
import struct
|
||||
|
||||
|
|
@ -24,6 +25,7 @@ def setup(conf):
|
|||
### CONNECT ###
|
||||
for PAC in PACS[1::]:
|
||||
PAC.connect()
|
||||
_set_time(PAC)
|
||||
|
||||
return PACS
|
||||
|
||||
|
|
@ -83,6 +85,12 @@ def _to_float(reg):
|
|||
s = struct.pack('=i', tmp)
|
||||
return struct.unpack('=f', s)[0]
|
||||
|
||||
def _set_time(PAC):
|
||||
stamp = time.time()
|
||||
high = int(int(stamp) >> 16)
|
||||
low = int(int(stamp) & int(0xFFFF))
|
||||
PAC.write_registers(797, (high, low))
|
||||
|
||||
def close(PACS):
|
||||
### CLOSE ###
|
||||
for PAC in PACS[1::]:
|
||||
|
|
|
|||
|
|
@ -127,5 +127,9 @@ for i in range(tmp.index[-1]+1):
|
|||
if cur[x['pillarID']][x['plug']] < x['meterreading']:
|
||||
cur[x['pillarID']][x['plug']] = x['meterreading']
|
||||
tmp.loc[i, 'global'] = sum(list(cur))
|
||||
for item in range(len(list(cur))):
|
||||
col = '%s_%s' % (cur.index.levels[0][cur.index.labels[0][item]], cur.index.levels[1][cur.index.labels[1][item]])
|
||||
tmp.loc[i, col] = list(cur)[item]
|
||||
pass
|
||||
|
||||
db.writeDatabase('pCharger', tmp, bClear = False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue