From bd0f7def246fe33a28e03aad27f7f35875d78c52 Mon Sep 17 00:00:00 2001 From: Nico Melone Date: Wed, 26 Feb 2020 17:03:56 -0600 Subject: [PATCH] made mappings for channels reporting a number that needed to be mapped --- dual_flowmeter/Tags.py | 8 +- dual_flowmeter/config.txt | 2 +- dual_flowmeter/dual_flowmeter.py | 4 +- dualactuator/Tags.py | 4 +- dualactuator/config.txt | 2 +- dualactuator/dualactuator.py | 2 +- flow-monitor/config.txt | 2 +- flow-monitor/flow-monitor.py | 20 +++-- ipp/config.txt | 2 +- ipp/ipp.py | 6 +- ipp/maps.py | 5 ++ multisensor/config.txt | 2 +- multisensor/multisensor.py | 16 ++-- piflow/Channel.py | 141 ++++++++++++++++++++++++++++++- piflow/PiFlow.py | 2 +- piflow/Tags.py | 18 ++-- piflow/config.txt | 2 +- piflow/utilities.py | 7 +- plcfreshwater/Tags.py | 10 +-- plcfreshwater/config.txt | 2 +- plcfreshwater/plcfreshwater.py | 2 +- 21 files changed, 203 insertions(+), 56 deletions(-) diff --git a/dual_flowmeter/Tags.py b/dual_flowmeter/Tags.py index 2428b91..30ed23a 100644 --- a/dual_flowmeter/Tags.py +++ b/dual_flowmeter/Tags.py @@ -3,19 +3,19 @@ from dual_flowmeter import PLC_IP_ADDRESS tags = [ PLCChannel(PLC_IP_ADDRESS, "pump_1_daily_total","Pump_1_Daily_Flow_Rate_Total","REAL", 10, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "pump_1_run_status","Pump_1_Run_Status","BOOL", 0, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "pump_1_run_status","Pump_1_Run_Status","BOOL", 0, 3600, plc_type="Micro800", map_={0: "Off", 1: "On"}), PLCChannel(PLC_IP_ADDRESS, "pump_1_flowrate","Pump_1_SCL_Flow_Meter","REAL", 250, 600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "pump_1_yesterdays_total","Pump_1_Yesterdays_Total","REAL", 10, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "pump_1_power","Pump_1_Power","BOOL", 0, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "pump_1_power","Pump_1_Power","BOOL", 0, 3600, plc_type="Micro800", map_={0: "Off", 1: "On"}), PLCChannel(PLC_IP_ADDRESS, "pump_1_prevmonth_total","Pump_1_PrevMonth_Total","REAL", 10, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "pump_1_month_total","Pump_1_Current_Month_Total","REAL", 10, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "pump_1_lifetime_total","Pump_1_Lifetime_Flow","REAL", 10, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "pump_1_suction","Suction_PSI_TP1_Scaled","REAL", 10, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "pump_2_daily_total","Pump_2_Daily_Flow_Rate_Total","REAL", 10, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "pump_2_run_status","Pump_2_Run_Status","BOOL", 0, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "pump_2_run_status","Pump_2_Run_Status","BOOL", 0, 3600, plc_type="Micro800", map_={0: "Off", 1: "On"}), PLCChannel(PLC_IP_ADDRESS, "pump_2_flowrate","Pump_2_SCL_Flow_Meter","REAL", 250, 600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "pump_2_yesterdays_total","Pump_2_Yesterdays_Total","REAL", 10, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "pump_2_power","Pump_2_Power","BOOL", 0, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "pump_2_power","Pump_2_Power","BOOL", 0, 3600, plc_type="Micro800", map_={0: "Off", 1: "On"}), PLCChannel(PLC_IP_ADDRESS, "pump_2_prevmonth_total","Pump_2_PrevMonth_Total","REAL", 100, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "pump_2_month_total","Pump_2_Current_Month_Total","REAL", 50, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "pump_2_lifetime_total","Pump_2_Lifetime_Flow","REAL", 10, 3600, plc_type="Micro800"), diff --git a/dual_flowmeter/config.txt b/dual_flowmeter/config.txt index 65b4028..c4b56f5 100644 --- a/dual_flowmeter/config.txt +++ b/dual_flowmeter/config.txt @@ -8,7 +8,7 @@ "file4": "Tags.py" }, "deviceName": "dual_flowmeter", - "releaseVersion": "4", + "releaseVersion": "5", "driverFileName": "dual_flowmeter.py", "driverId": "0100" } \ No newline at end of file diff --git a/dual_flowmeter/dual_flowmeter.py b/dual_flowmeter/dual_flowmeter.py index b62835f..e3cba4d 100644 --- a/dual_flowmeter/dual_flowmeter.py +++ b/dual_flowmeter/dual_flowmeter.py @@ -18,7 +18,7 @@ _ = None log.info("dual_flowmeter startup") # GLOBAL VARIABLES -WAIT_FOR_CONNECTION_SECONDS = 60 +WAIT_FOR_CONNECTION_SECONDS = 20 IP_CHECK_PERIOD = 60 WATCHDOG_ENABLE = False WATCHDOG_CHECK_PERIOD = 60 @@ -42,7 +42,7 @@ class start(threading.Thread, deviceBase): mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "4" + self.version = "5" self.finished = threading.Event() self.force_send = False self.public_ip_address = "" diff --git a/dualactuator/Tags.py b/dualactuator/Tags.py index c3b75d2..ce06f14 100644 --- a/dualactuator/Tags.py +++ b/dualactuator/Tags.py @@ -3,9 +3,9 @@ from dualactuator import PLC_IP_ADDRESS tags = [ PLCChannel(PLC_IP_ADDRESS, "open_cmd","Open_Cmd","BOOL", 1, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "v1_open_fbk","V1_Open_FBK","BOOL", 1, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "v1_open_fbk","V1_Open_FBK","BOOL", 1, 3600, plc_type="Micro800", map_={0: "Closed", 1: "Open"}), PLCChannel(PLC_IP_ADDRESS, "v1_closed_fbk","V1_Closed_FBK","BOOL", 1, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "v2_open_fbk","V2_Open_FBK","BOOL", 1, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "v2_open_fbk","V2_Open_FBK","BOOL", 1, 3600, plc_type="Micro800", map_={0: "Closed", 1: "Open"}), PLCChannel(PLC_IP_ADDRESS, "v2_closed_fbk","V2_Closed_FBK","BOOL", 1, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "sep_valve_cmd","sep_valve_cmd","BOOL", 1, 3600, plc_type="Micro800"), PLCChannel(PLC_IP_ADDRESS, "v1_open_cmd","V1_Open_Cmd","BOOL", 1, 3600, plc_type="Micro800"), diff --git a/dualactuator/config.txt b/dualactuator/config.txt index 1706b9f..b69662b 100644 --- a/dualactuator/config.txt +++ b/dualactuator/config.txt @@ -8,7 +8,7 @@ "file4": "Tags.py" }, "deviceName": "dualactuator", - "releaseVersion": "3", + "releaseVersion": "4", "driverFileName": "dualactuator.py", "driverId": "0100" } \ No newline at end of file diff --git a/dualactuator/dualactuator.py b/dualactuator/dualactuator.py index 888848d..b75c866 100644 --- a/dualactuator/dualactuator.py +++ b/dualactuator/dualactuator.py @@ -40,7 +40,7 @@ class start(threading.Thread, deviceBase): mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "3" + self.version = "4" self.finished = threading.Event() self.force_send = False self.public_ip_address = "" diff --git a/flow-monitor/config.txt b/flow-monitor/config.txt index 2d3211e..3bb4431 100644 --- a/flow-monitor/config.txt +++ b/flow-monitor/config.txt @@ -6,6 +6,6 @@ }, "deviceName": "flowmonitor", "driverId": "0140", - "releaseVersion": "18", + "releaseVersion": "19", "driverFileName": "flow-monitor.py" } \ No newline at end of file diff --git a/flow-monitor/flow-monitor.py b/flow-monitor/flow-monitor.py index 0f584c7..3c00ec1 100644 --- a/flow-monitor/flow-monitor.py +++ b/flow-monitor/flow-monitor.py @@ -113,7 +113,11 @@ class ChannelSimple(object): """Check to see if the value needs to be pushed.""" if self.last_sent_value is None or self.last_sent_timestamp == 0: return True - + if type(value) == str: + if value != self.last_sent_value: + return True + else: + return False if abs(value - self.last_sent_value) > self.senddelta_value: return True @@ -180,7 +184,7 @@ class start(threading.Thread, deviceBase): self.force_send = False self.daemon = True - self.version = "18" + self.version = "19" self.finished = threading.Event() threading.Thread.start(self) @@ -370,17 +374,17 @@ class start(threading.Thread, deviceBase): bpd_val = 0 #Determine run status - runstatus = 0 + runstatus = "undefined" if din1_val == 0 and gpm_val == 0: - runstatus = 0 #Stopped + runstatus = "Stopped" #Stopped elif din1_val == 0 and gpm_val > 10: - runstatus = 1 #Assumed running might not have run indication + runstatus = "Running" #Assumed running might not have run indication elif din1_val == 1 and gpm_val == 0: - runstatus = 3 #no flow warning + runstatus = "Running: No Flow" #no flow warning elif din1_val == 1 and gpm_val < self.lowflow: - runstatus = 4 #low flow warning + runstatus = "Running: Low Flow" #low flow warning elif din1_val == 1 and gpm_val >= self.lowflow: - runstatus = 1 #running normally + runstatus = "Running" #running normally now = time.time() time_diff = now - last_measured_timestamp diff --git a/ipp/config.txt b/ipp/config.txt index 2debc15..5c157f5 100644 --- a/ipp/config.txt +++ b/ipp/config.txt @@ -7,6 +7,6 @@ }, "deviceName": "ipp", "driverId": "0090", - "releaseVersion": "9", + "releaseVersion": "10", "driverFileName": "ipp.py" } diff --git a/ipp/ipp.py b/ipp/ipp.py index 37e9db0..ab46a08 100644 --- a/ipp/ipp.py +++ b/ipp/ipp.py @@ -186,7 +186,7 @@ CHANNELS = [ PLCChannel(PLC_IP_ADDRESS, 'rptemperature', 'RP_Temperature', 'REAL', 0.0, 3600, plc_type='Micro800'), PLCChannel(PLC_IP_ADDRESS, 'rptrip', 'RP_Trip', 'REAL', 0.0, 3600, plc_type='Micro800'), PLCChannel(PLC_IP_ADDRESS, 'rptubingpressure', 'RP_TubingPressure', 'REAL', 0.0, 3600, plc_type='Micro800'), - PLCChannel(PLC_IP_ADDRESS, 'runpermissive', 'Run_Permissive', 'REAL', 0.0, 3600, plc_type='Micro800'), + PLCChannel(PLC_IP_ADDRESS, 'runpermissive', 'Run_Permissive', 'REAL', 0.0, 3600, plc_type='Micro800', map_=map_permissive), PLCChannel(PLC_IP_ADDRESS, 'spmode', 'SP_Mode', 'REAL', 0.0, 3600, plc_type='Micro800'), PLCChannel(PLC_IP_ADDRESS, 'sppressure', 'SP_Pressure', 'REAL', 0.0, 3600, plc_type='Micro800'), PLCChannel(PLC_IP_ADDRESS, 'sptemperature', 'SP_Temperature', 'REAL', 0.0, 3600, plc_type='Micro800'), @@ -194,7 +194,7 @@ CHANNELS = [ PLCChannel(PLC_IP_ADDRESS, 'spvoltage', 'SP_Voltage', 'REAL', 0.0, 3600, plc_type='Micro800'), PLCChannel(PLC_IP_ADDRESS, 'startbutton', 'Start_Button', 'REAL', 0.0, 3600, plc_type='Micro800'), PLCChannel(PLC_IP_ADDRESS, 'startcommand', 'Start_Command', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True), - PLCChannel(PLC_IP_ADDRESS, 'startpermissive', 'Start_Permissive', 'REAL', 0.0, 3600, plc_type='Micro800'), + PLCChannel(PLC_IP_ADDRESS, 'startpermissive', 'Start_Permissive', 'REAL', 0.0, 3600, plc_type='Micro800',map_=map_permissive), PLCChannel(PLC_IP_ADDRESS, 'stopcommand', 'Stop_Command', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True), PLCChannel(PLC_IP_ADDRESS, 'tempshutdown', 'Temp_Shutdown', 'REAL', 1.0, 3600, plc_type='Micro800', write_enabled=True), PLCChannel(PLC_IP_ADDRESS, 'tempshutdownenabled', 'Temp_Shutdown_Enabled', 'REAL', 0.0, 3600, plc_type='Micro800', write_enabled=True), @@ -259,7 +259,7 @@ class start(threading.Thread, deviceBase): deviceBase.__init__(self, name=name, number=number, mac=mac, Q=Q, mcu=mcu, companyId=companyId, offset=offset, mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "9" + self.version = "10" self.finished = threading.Event() self.forceSend = False threading.Thread.start(self) diff --git a/ipp/maps.py b/ipp/maps.py index d5a7502..caa5bb0 100644 --- a/ipp/maps.py +++ b/ipp/maps.py @@ -75,3 +75,8 @@ map_device_status = { 10: "User stopped", 11: "Waiting to start (Timer Mode)" } + +map_permissive = { + 0: "Not Ready", + 1: "OK" +} diff --git a/multisensor/config.txt b/multisensor/config.txt index 0a1f6e8..4109dad 100644 --- a/multisensor/config.txt +++ b/multisensor/config.txt @@ -2,7 +2,7 @@ "driverFileName": "multisensor.py", "deviceName": "multisensor", "driverId": "0240", - "releaseVersion": "5", + "releaseVersion": "6", "files": { "file1": "multisensor.py", "file2": "utilities.py", diff --git a/multisensor/multisensor.py b/multisensor/multisensor.py index cc61ccf..a7c6875 100644 --- a/multisensor/multisensor.py +++ b/multisensor/multisensor.py @@ -78,7 +78,7 @@ class start(threading.Thread, deviceBase): mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "5" + self.version = "6" self.finished = threading.Event() self.force_send = False self.public_ip_address = "" @@ -120,15 +120,15 @@ class start(threading.Thread, deviceBase): if "active" in chan.plc_tag: PERSIST[chan.mesh_name] = val persistence.store(PERSIST,'persist.json') - if "scaledValue" in chan.plc_tag: - if val <= PERSIST[chan.mesh_name[:3]+"low"] and PERSIST[chan.mesh_name[:3]+"active"] == 1: - self.sendtodbDev(1, chan.mesh_name[:3]+"alarm", "LOW", 0, 'multisensor') - elif val >= PERSIST[chan.mesh_name[:3]+"high"] and PERSIST[chan.mesh_name[:3]+"active"] == 1: - self.sendtodbDev(1, chan.mesh_name[:3]+"alarm", "HIGH", 0, 'multisensor') - else: - self.sendtodbDev(1, chan.mesh_name[:3]+"alarm", "OK", 0, 'multisensor') if chan.check(val, self.force_send): self.sendtodbDev(1, chan.mesh_name, chan.value, 0, 'multisensor') + if "scaledValue" in chan.plc_tag: + if val <= PERSIST[chan.mesh_name[:3]+"low"] and PERSIST[chan.mesh_name[:3]+"active"] == 1: + self.sendtodbDev(1, chan.mesh_name[:3]+"alarm", "LOW", 0, 'multisensor') + elif val >= PERSIST[chan.mesh_name[:3]+"high"] and PERSIST[chan.mesh_name[:3]+"active"] == 1: + self.sendtodbDev(1, chan.mesh_name[:3]+"alarm", "HIGH", 0, 'multisensor') + else: + self.sendtodbDev(1, chan.mesh_name[:3]+"alarm", "OK", 0, 'multisensor') #time.sleep(5) diff --git a/piflow/Channel.py b/piflow/Channel.py index f25da24..48961c8 100644 --- a/piflow/Channel.py +++ b/piflow/Channel.py @@ -111,7 +111,7 @@ class Channel(object): """Check to see if the new_value needs to be stored.""" send_needed = False send_reason = "" - if self.data_type == 'BOOL' or self.data_type == 'STRING': + if self.data_type == 'BOOL' or self.data_type == 'STRING' or type(new_value) == str: if self.last_send_time == 0: send_needed = True send_reason = "no send time" @@ -171,6 +171,145 @@ def identity(sent): """Return exactly what was sent to it.""" return sent +def volume_units(vunit): + units = { + 0: "cm cubed/s", + 1: "cm cubed/min", + 2: "cm cubed/h", + 3: "cm cubed/d", + 4: "dm cubed/s", + 5: "dm cubed/min", + 6: "dm cubed/h", + 7: "dm cubed/d", + 8: "m cubed/s", + 9: "m cubed/min", + 10: "m cubed/h", + 11: "m cubed/d", + 12: "ml/s", + 13: "ml/min", + 14: "ml/h", + 15: "ml/d", + 16: "l/s", + 17: "l/min", + 18: "l/h (+)", + 19: "l/d", + 20: "hl/s", + 21: "hl/min", + 22: "hl/h", + 23: "hl/d", + 24: "Ml/s", + 25: "Ml/min", + 26: "Ml/h", + 27: "Ml/d", + 32: "af/s", + 33: "af/min", + 34: "af/h", + 35: "af/d", + 36: "ft cubed/s", + 37: "ft cubed/min", + 38: "ft cubed/h", + 39: "ft cubed/d", + 40: "fl oz/s (us)", + 41: "fl oz/min (us)", + 42: "fl oz/h (us)", + 43: "fl oz/d (us)", + 44: "gal/s (us)", + 45: "gal/min (us)", + 46: "gal/h (us)", + 47: "gal/d (us)", + 48: "Mgal/s (us)", + 49: "Mgal/min (us)", + 50: "Mgal/h (us)", + 51: "Mgal/d (us)", + 52: "bbl/s (us;liq.)", + 53: "bbl/min (us;liq.)", + 54: "bbl/h (us;liq.)", + 55: "bbl/d (us;liq.)", + 56: "bbl/s (us;beer)", + 57: "bbl/min (us;beer)", + 58: "bbl/h (us;beer)", + 59: "bbl/d (us;beer)", + 60: "bbl/s (us;oil)", + 61: "bbl/min (us;oil)", + 62: "bbl/h (us;oil)", + 63: "bbl/d (us;oil)", + 64: "bbl/s (us;tank)", + 65: "bbl/min (us;tank)", + 66: "bbl/h (us;tank)", + 67: "bbl/d (us;tank)", + 68: "gal/s (imp)", + 69: "gal/min (imp)", + 70: "gal/h (imp)", + 71: "gal/d (imp)", + 72: "Mgal/s (imp)", + 73: "Mgal/min (imp)", + 74: "Mgal/h (imp)", + 75: "Mgal/d (imp)", + 76: "bbl/s (imp;beer)", + 77: "bbl/min (imp;beer)", + 78: "bbl/h (imp;beer)", + 79: "bbl/d (imp;beer)", + 80: "bbl/s (imp;oil)", + 81: "bbl/min (imp;oil)", + 82: "bbl/h (imp;oil)", + 83: "bbl/d (imp;oil)", + 88: "kgal/s (us)", + 89: "kgal/min (us)", + 90: "kgal/h (us)", + 91: "kgal/d (us)", + 92: "MMft cubed/s", + 93: "MMft cubed/min", + 94: "MMft cubed/h", + 96: "Mft cubed/d" + } + return units[vunit] + +def totalizer_units(tunit): + + units = { + 0: "cm cubed", + 1: "dm cubed", + 2: "m cubed", + 3: "ml", + 4: "l", + 5: "hl", + 6: "Ml Mega", + 8: "af", + 9: "ft cubed", + 10: "fl oz (us)", + 11: "gal (us)", + 12: "Mgal (us)", + 13: "bbl (us;liq.)", + 14: "bbl (us;beer)", + 15: "bbl (us;oil)", + 16: "bbl (us;tank)", + 17: "gal (imp)", + 18: "Mgal (imp)", + 19: "bbl (imp;beer)", + 20: "bbl (imp;oil)", + 22: "kgal (us)", + 23: "Mft cubed", + 50: "g", + 51: "kg", + 52: "t", + 53: "oz", + 54: "lb", + 55: "STon", + 100: "Nl", + 101: "Nm cubed", + 102: "Sm cubed", + 103: "Sft cubed", + 104: "Sl", + 105: "Sgal (us)", + 106: "Sbbl (us;liq.)", + 107: "Sgal (imp)", + 108: "Sbbl (us;oil)", + 109: "MMSft cubed", + 110: "Nhl", + 251: "None" + } + return units[tunit] + def int_to_bits(n,x): return pad_to_x([int(digit) for digit in bin(n)[2:]],x) # [2:] to chop off the "0b" part diff --git a/piflow/PiFlow.py b/piflow/PiFlow.py index 7d84d89..faff57c 100644 --- a/piflow/PiFlow.py +++ b/piflow/PiFlow.py @@ -45,7 +45,7 @@ class start(threading.Thread, deviceBase): mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "18" + self.version = "19" self.finished = threading.Event() self.force_send = False self.public_ip_address = "" diff --git a/piflow/Tags.py b/piflow/Tags.py index 1a7b8f3..aeb6d4d 100644 --- a/piflow/Tags.py +++ b/piflow/Tags.py @@ -1,4 +1,4 @@ -from Channel import PLCChannel,Channel, ModbusChannel, status_codes, fault_code_a, fault_code_b +from Channel import PLCChannel,Channel, ModbusChannel, status_codes, fault_code_a, fault_code_b, volume_units, totalizer_units import persistence data = persistence.load('persist.json') @@ -14,10 +14,10 @@ if drive_enabled: ModbusChannel('totalizer_1', 2609, 'FLOAT', 10,600,channel_size=2, unit_number=flowmeter_unit_number), ModbusChannel('totalizer_2', 2809, 'FLOAT', 10,600,channel_size=2, unit_number=flowmeter_unit_number), ModbusChannel('totalizer_3', 3009, 'FLOAT', 10,600,channel_size=2, unit_number=flowmeter_unit_number), - ModbusChannel('volume_flow_units', 2102, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number), - ModbusChannel('totalizer_1_units', 4603, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number), - ModbusChannel('totalizer_2_units', 4604, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number), - ModbusChannel('totalizer_3_units', 4605, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number), + ModbusChannel('volume_flow_units', 2102, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number, transform_fn=volume_units), + ModbusChannel('totalizer_1_units', 4603, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number, transform_fn=totalizer_units), + ModbusChannel('totalizer_2_units', 4604, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number, transform_fn=totalizer_units), + ModbusChannel('totalizer_3_units', 4605, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number, transform_fn=totalizer_units), ModbusChannel('run_status', 13, 'STRING', 0, 3600, channel_size=1, unit_number=drive_unit_number, transform_fn=status_codes), ModbusChannel('frequency', 9, 'INTEGER', 0.5, 600, channel_size=2, unit_number=drive_unit_number,scaling=2 ), ModbusChannel('current', 8, 'INTEGER', 0.5, 600, channel_size=2, unit_number=drive_unit_number,scaling=1 ), @@ -34,10 +34,10 @@ else: ModbusChannel('totalizer_1', 2609, 'FLOAT', 10,600,channel_size=2, unit_number=flowmeter_unit_number), ModbusChannel('totalizer_2', 2809, 'FLOAT', 10,600,channel_size=2, unit_number=flowmeter_unit_number), ModbusChannel('totalizer_3', 3009, 'FLOAT', 10,600,channel_size=2, unit_number=flowmeter_unit_number), - ModbusChannel('volume_flow_units', 2102, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number), - ModbusChannel('totalizer_1_units', 4603, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number), - ModbusChannel('totalizer_2_units', 4604, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number), - ModbusChannel('totalizer_3_units', 4605, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number) + ModbusChannel('volume_flow_units', 2102, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number, transform_fn=volume_units), + ModbusChannel('totalizer_1_units', 4603, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number, transform_fn=totalizer_units), + ModbusChannel('totalizer_2_units', 4604, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number, transform_fn=totalizer_units), + ModbusChannel('totalizer_3_units', 4605, 'INTEGER', 1,3600,channel_size=1, unit_number=flowmeter_unit_number, transform_fn=totalizer_units) ] diff --git a/piflow/config.txt b/piflow/config.txt index b4f288f..9142d24 100644 --- a/piflow/config.txt +++ b/piflow/config.txt @@ -3,7 +3,7 @@ "driverFileName":"PiFlow.py", "deviceName":"piflow", "driverId":"0280", -"releaseVersion":"18", +"releaseVersion":"19", "files": { "file1":"PiFlow.py", "file2":"Channel.py", diff --git a/piflow/utilities.py b/piflow/utilities.py index 4cca34a..f9b2081 100644 --- a/piflow/utilities.py +++ b/piflow/utilities.py @@ -5,13 +5,14 @@ import urllib import contextlib def get_private_ip_address(): """Find the private IP Address of the host device.""" - sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.connect(("8.8.8.8", 80)) + ip_address = sock.getsockname()[0] + sock.close() except Exception as e: return e - ip_address = sock.getsockname()[0] - sock.close() + return ip_address def get_public_ip_address(): diff --git a/plcfreshwater/Tags.py b/plcfreshwater/Tags.py index 3c69cd3..a9a08ca 100644 --- a/plcfreshwater/Tags.py +++ b/plcfreshwater/Tags.py @@ -4,12 +4,10 @@ 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", 0, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "raw_auto_input","Raw_Auto_Input","BOOL", 0, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "raw_run_status","Raw_Run_Status","BOOL", 0, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "raw_run_indication","Raw_Run_Indication","BOOL", 0, 3600, plc_type="Micro800"), + PLCChannel(PLC_IP_ADDRESS, "raw_hand_input","Raw_Hand_Input","BOOL", 0, 3600, plc_type="Micro800", map_={0: "Off", 1: "On"}), + PLCChannel(PLC_IP_ADDRESS, "raw_auto_input","Raw_Auto_Input","BOOL", 0, 3600, plc_type="Micro800", map_={0: "Off", 1: "On"}), + PLCChannel(PLC_IP_ADDRESS, "raw_run_status","Raw_Run_Status","BOOL", 0, 3600, plc_type="Micro800", map_={0: "Stopped", 1: "Running"}), PLCChannel(PLC_IP_ADDRESS, "raw_local_start","Raw_Local_Start","BOOL", 0, 3600, plc_type="Micro800"), - PLCChannel(PLC_IP_ADDRESS, "cmd_cloud_control","CMD_Cloud_Control","BOOL", 0, 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"), PLCChannel(PLC_IP_ADDRESS, "total_fm_day_gal","Totalizer_FM_Current_Day_Total_Gal","REAL", 50, 3600, plc_type="Micro800"), @@ -21,5 +19,5 @@ tags = [ 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") + PLCChannel(PLC_IP_ADDRESS, "raw_overload_status", "Raw_Overload_Status", "BOOL", 0, 3600, plc_type="Micro800", map_={0: "Good", 1: "Down on Overload Tripped"}) ] \ No newline at end of file diff --git a/plcfreshwater/config.txt b/plcfreshwater/config.txt index 4df87d6..f35989e 100644 --- a/plcfreshwater/config.txt +++ b/plcfreshwater/config.txt @@ -8,7 +8,7 @@ "file4": "Tags.py" }, "deviceName": "plcfreshwater", - "releaseVersion": "7", + "releaseVersion": "8", "driverFileName": "plcfreshwater.py", "driverId": "0100" } \ No newline at end of file diff --git a/plcfreshwater/plcfreshwater.py b/plcfreshwater/plcfreshwater.py index 1b9d21d..c494d19 100644 --- a/plcfreshwater/plcfreshwater.py +++ b/plcfreshwater/plcfreshwater.py @@ -52,7 +52,7 @@ class start(threading.Thread, deviceBase): mqtt=mqtt, Nodes=Nodes) self.daemon = True - self.version = "7" + self.version = "8" self.finished = threading.Event() self.force_send = False self.public_ip_address = ""