bug fixes

This commit is contained in:
2020-06-12 15:37:03 -05:00
parent eb7da58d75
commit 714a872a08
9 changed files with 77 additions and 24 deletions

View File

@@ -33,7 +33,7 @@ def read_tag(addr, tag, plc_type="CLX"):
log.error("Data Error during readTag({}, {}): {}".format(addr, tag, err))
except CommError:
# err = c.get_status()
clx.close()
#clx.close()
log.error("Could not connect during readTag({}, {})".format(addr, tag))
except AttributeError as err:
clx.close()
@@ -87,7 +87,7 @@ def write_tag(addr, tag, val, plc_type="CLX"):
except CommError as err:
clx_err = clx.get_status()
log.error("--\nCommError during write_tag({}, {}, {}, plc_type={})\n{}\n--".format(addr, tag, val, plc_type, err))
clx.close()
#clx.close()
return False
@@ -123,17 +123,17 @@ class Channel(object):
elif self.value is None:
send_needed = True
send_reason = "no value"
elif (time.time() - self.last_send_time) > self.guarantee_sec:
send_needed = True
send_reason = "guarantee sec"
elif self.value != new_value:
if self.map_:
if not self.value == self.map_[new_value]:
if (not self.value == self.map_[new_value]) or force_send:
send_needed = True
send_reason = "value change"
else:
send_needed = True
send_reason = "value change"
elif (time.time() - self.last_send_time) > self.guarantee_sec:
send_needed = True
send_reason = "guarantee sec"
elif force_send:
send_needed = True
send_reason = "forced"

View File

@@ -4,9 +4,9 @@ from plcfreshwater import PLC_IP_ADDRESS
tags = [
PLCChannel(PLC_IP_ADDRESS, "scaled_flow_meter","Scaled_Flow_Meter","REAL", 3, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "scaled_pressure_transducer","Scaled_Pressure_Transducer","REAL", 3, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "raw_hand_input","Raw_Hand_Input","BOOL", 1, 7200, plc_type="Micro800", map_={0: "Off", 1: "On"}),
PLCChannel(PLC_IP_ADDRESS, "raw_auto_input","Raw_Auto_Input","BOOL", 1, 7200, plc_type="Micro800", map_={0: "Off", 1: "On"}),
PLCChannel(PLC_IP_ADDRESS, "raw_run_status","Raw_Run_Status","BOOL", 1, 3600, plc_type="Micro800", map_={0: "Stopped", 1: "Running"}),
PLCChannel(PLC_IP_ADDRESS, "raw_hand_input","Raw_Hand_Input","BOOL", 1, 7200, plc_type="Micro800", map_={0: "Off", 1: "On", None: "Error"}),
PLCChannel(PLC_IP_ADDRESS, "raw_auto_input","Raw_Auto_Input","BOOL", 1, 7200, plc_type="Micro800", map_={0: "Off", 1: "On", None: "Error"}),
PLCChannel(PLC_IP_ADDRESS, "raw_run_status","Raw_Run_Status","BOOL", 1, 3600, plc_type="Micro800", map_={0: "Stopped", 1: "Running", None: "Error"}),
PLCChannel(PLC_IP_ADDRESS, "raw_local_start","Raw_Local_Start","BOOL", 1, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "lifetime_flow_meter_gal","Lifetime_Flow_Meter_Gal","REAL", 1000, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_yesterday_gal","Totalizer_FM_Yesterday_Total_Gal","REAL", 50, 3600, plc_type="Micro800"),
@@ -18,6 +18,6 @@ tags = [
PLCChannel(PLC_IP_ADDRESS, "total_fm_last_month_bbls","Totalizer_FM_Last_Month_BBLs","REAL", 100, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_month_bbls","Totalizer_FM_Current_Month_BBLs","REAL", 50, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "lifetime_flow_meter_bbls","Lifetime_Flow_Meter_BBLS","REAL", 1000, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "spt_flow_meter_unit","SPT_Flow_Meter_Unit","BOOL", `0`, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "raw_overload_status", "Raw_Overload_Status", "BOOL", `0`, 3600, plc_type="Micro800", map_={0: "Good", 1: "Down on Overload Tripped"})
PLCChannel(PLC_IP_ADDRESS, "spt_flow_meter_unit","SPT_Flow_Meter_Unit","BOOL", 0, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "raw_overload_status", "Raw_Overload_Status", "BOOL", 0, 3600, plc_type="Micro800", map_={0: "Good", 1: "Down on Overload Tripped", None: "Error"})
]

View File

@@ -8,7 +8,7 @@
"file4": "Tags.py"
},
"deviceName": "plcfreshwater",
"releaseVersion": "9",
"releaseVersion": "10",
"driverFileName": "plcfreshwater.py",
"driverId": "0100"
}

View File

@@ -52,7 +52,7 @@ class start(threading.Thread, deviceBase):
mqtt=mqtt, Nodes=Nodes)
self.daemon = True
self.version = "9"
self.version = "10"
self.finished = threading.Event()
self.force_send = False
self.public_ip_address = ""