Merge branch 'master' of http://bitbucket.poconsole.net:7990/scm/poc/vfd_poc
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import types
|
||||
import traceback
|
||||
import binascii
|
||||
# import types
|
||||
# import traceback
|
||||
# import binascii
|
||||
import threading
|
||||
import time
|
||||
import thread
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
import serial
|
||||
import minimalmodbus
|
||||
# import thread
|
||||
# import os
|
||||
# import struct
|
||||
# import sys
|
||||
# import serial
|
||||
# import minimalmodbus
|
||||
import pickle
|
||||
from device_base import deviceBase
|
||||
# from datetime import datetime
|
||||
@@ -191,6 +191,7 @@ class Card():
|
||||
def readCard(self):
|
||||
self.card_id = readTag(plc_ip, "Card_Past[1].ID")[0]
|
||||
self.num_points = int(readTag(plc_ip, "Card_Past[1].Num_Points")[0])
|
||||
print("reading {} from card ID {}".format(self.num_points, self.card_id))
|
||||
for i in range(0, self.num_points):
|
||||
self.sc.append([round(float(readTag(plc_ip, 'Card_Past[1].Surface_Position[{}]'.format(i))[0]), 3), round(float(readTag(plc_ip, 'Card_Past[1].Surface_Load[{}]'.format(i))[0]), 3)])
|
||||
self.dc.append([round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Position[{}]'.format(i))[0]), 3), round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Load[{}]'.format(i))[0]), 3)])
|
||||
@@ -258,7 +259,8 @@ class start(threading.Thread, deviceBase):
|
||||
|
||||
def channelCheck(self, c, force):
|
||||
if c.read(force):
|
||||
self.sendtodbJSON(c.mesh_name, c.value, 0)
|
||||
self.sendtodbJSON(c.mesh_name, c.value, time.time())
|
||||
c.last_send_time = time.time()
|
||||
|
||||
def run(self):
|
||||
self.runLoopStatus = ""
|
||||
@@ -304,6 +306,16 @@ class start(threading.Thread, deviceBase):
|
||||
cstr = c.stringify()
|
||||
self.sendtodbJSON("sc", cstr[0], c.read_time)
|
||||
self.sendtodbJSON("dc", cstr[1], c.read_time)
|
||||
else:
|
||||
current_time = time.time()
|
||||
current_card = Card(current_time)
|
||||
self.sendtodbJSON("card_history", current_card.card_id, current_time)
|
||||
if (current_card.read_time - self.last_card_sent_time) > self.cardLoopTimer or self.forceSend:
|
||||
cards = current_card.stringify()
|
||||
self.sendtodbJSON("sc", cards[0], current_time)
|
||||
self.sendtodbJSON("dc", cards[1], current_time)
|
||||
current_card.sent = True
|
||||
self.card_storage.appendleft(current_card)
|
||||
runLoopStatus = "Complete"
|
||||
time.sleep(3)
|
||||
self.forceSend = False
|
||||
|
||||
Reference in New Issue
Block a user