updates 2024-07-31
This commit is contained in:
BIN
abbflow/.DS_Store
vendored
BIN
abbflow/.DS_Store
vendored
Binary file not shown.
BIN
advvfdipp/.DS_Store
vendored
BIN
advvfdipp/.DS_Store
vendored
Binary file not shown.
BIN
dualactuator/.DS_Store
vendored
BIN
dualactuator/.DS_Store
vendored
Binary file not shown.
@@ -6,8 +6,15 @@ address = 123
|
||||
|
||||
instrument = minimalmodbus.Instrument('/dev/ttyS0', address) #device, modbus slave address
|
||||
instrument.debug = True
|
||||
try:
|
||||
value = instrument.read_float(599) #register -1 for float
|
||||
print("Value: {}".format(value))
|
||||
except Exception as e:
|
||||
for _ in range(3):
|
||||
try:
|
||||
value = instrument.read_float(3873) #register -1 for float
|
||||
print("Flow Rate from Flow Meter: {}".format(value))
|
||||
except Exception as e:
|
||||
print("Error: {}".format(e))
|
||||
|
||||
try:
|
||||
value = instrument.read_float(784) #register -1 for float
|
||||
print("Frequency from Drive: {}".format(value))
|
||||
except Exception as e:
|
||||
print("Error: {}".format(e))
|
||||
|
||||
BIN
plcfreshwater/.DS_Store
vendored
BIN
plcfreshwater/.DS_Store
vendored
Binary file not shown.
@@ -2,32 +2,41 @@ from Channel import PLCChannel, ModbusChannel
|
||||
from plcfreshwater import PLC_IP_ADDRESS
|
||||
|
||||
tags = [
|
||||
PLCChannel(PLC_IP_ADDRESS, "scaled_flow_meter","Scaled_Flow_Meter","REAL", 10, 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", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_auto_input","Raw_Auto_Input","BOOL", 1, 7200, plc_type="Micro800", map_={0: "Off", 1: "On", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_run_status","Raw_Run_Status","BOOL", 1, 3600, plc_type="Micro800", map_={0: "Stopped", 1: "Running", None: "N/A"}),
|
||||
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, "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: "N/A"})
|
||||
PLCChannel(PLC_IP_ADDRESS, "scaled_flow_meter",
|
||||
"Scaled_Flow_Meter", "REAL", 10, 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", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_auto_input", "Raw_Auto_Input", "BOOL",
|
||||
1, 7200, plc_type="Micro800", map_={0: "Off", 1: "On", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_run_status", "Raw_Run_Status", "BOOL", 1,
|
||||
3600, plc_type="Micro800", map_={0: "Stopped", 1: "Running", None: "N/A"}),
|
||||
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, "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: "N/A"})
|
||||
]
|
||||
|
||||
tags_totalizer = [
|
||||
PLCChannel(PLC_IP_ADDRESS, "scaled_flow_meter","Scaled_Flow_Meter","REAL", 10, 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", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_auto_input","Raw_Auto_Input","BOOL", 1, 7200, plc_type="Micro800", map_={0: "Off", 1: "On", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_run_status","Raw_Run_Status","BOOL", 1, 3600, plc_type="Micro800", map_={0: "Stopped", 1: "Running", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_local_start","Raw_Local_Start","BOOL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_yesterday_gal","Totalizer_FM_Yesterday_Total_Gal","REAL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_day_gal","Totalizer_FM_Current_Day_Total_Gal","REAL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_last_month_gal","Totalizer_FM_Last_Month_Gal","REAL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_month_gal","Totalizer_FM_Current_Month_Gal","REAL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_yesterday_bbls","Totalizer_FM_Yesterday_Total_BBLs","REAL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_day_bbls","Totalizer_FM_Current_Day_Total_BBLs","REAL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_last_month_bbls","Totalizer_FM_Last_Month_BBLs","REAL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_month_bbls","Totalizer_FM_Current_Month_BBLs","REAL", 1, 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", None: "N/A"})
|
||||
PLCChannel(PLC_IP_ADDRESS, "scaled_flow_meter","Scaled_Flow_Meter", "REAL", 10, 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", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_auto_input", "Raw_Auto_Input", "BOOL",1, 7200, plc_type="Micro800", map_={0: "Off", 1: "On", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_run_status", "Raw_Run_Status", "BOOL", 1,3600, plc_type="Micro800", map_={0: "Stopped", 1: "Running", None: "N/A"}),
|
||||
PLCChannel(PLC_IP_ADDRESS, "raw_local_start", "Raw_Local_Start","BOOL", 1, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_yesterday_gal","Totalizer_FM_Yesterday_Total_Gal", "REAL", 500, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_day_gal","Totalizer_FM_Current_Day_Total_Gal", "REAL", 500, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_last_month_gal","Totalizer_FM_Last_Month_Gal", "REAL", 500, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_month_gal","Totalizer_FM_Current_Month_Gal", "REAL", 500, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_yesterday_bbls","Totalizer_FM_Yesterday_Total_BBLs", "REAL", 100, 3600, plc_type="Micro800"),
|
||||
PLCChannel(PLC_IP_ADDRESS, "total_fm_day_bbls","Totalizer_FM_Current_Day_Total_BBLs", "REAL", 100, 3600, plc_type="Micro800"),
|
||||
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", 100, 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", None: "N/A"})
|
||||
]
|
||||
@@ -120,6 +120,7 @@ class start(threading.Thread, deviceBase):
|
||||
from Tags import tags, tags_totalizer
|
||||
if PERSIST["Totalizers"]:
|
||||
CHANNELS = tags_totalizer
|
||||
self.totalizing = True
|
||||
else:
|
||||
CHANNELS = tags
|
||||
while True:
|
||||
|
||||
173
plcfreshwater/reset lifetime/update_values.py
Normal file
173
plcfreshwater/reset lifetime/update_values.py
Normal file
@@ -0,0 +1,173 @@
|
||||
from pycomm.ab_comm.clx import Driver as ClxDriver
|
||||
from pycomm.cip.cip_base import CommError, DataError
|
||||
import time
|
||||
import sys
|
||||
import json
|
||||
TAG_DATAERROR_SLEEPTIME = 5
|
||||
|
||||
|
||||
def read_tag(addr, tag, plc_type="CLX"):
|
||||
#Read a tag from the PLC.
|
||||
direct = plc_type == "Micro800"
|
||||
clx = ClxDriver()
|
||||
try:
|
||||
if clx.open(addr, direct_connection=direct):
|
||||
try:
|
||||
val = clx.read_tag(tag)
|
||||
clx.close()
|
||||
return val
|
||||
except DataError as err:
|
||||
clx.close()
|
||||
time.sleep(TAG_DATAERROR_SLEEPTIME)
|
||||
print("Data Error during readTag({}, {}): {}".format(addr, tag, err))
|
||||
except CommError:
|
||||
# err = c.get_status()
|
||||
#clx.close()
|
||||
print("Could not connect during readTag({}, {})".format(addr, tag))
|
||||
except AttributeError as err:
|
||||
clx.close()
|
||||
print("AttributeError during readTag({}, {}): \n{}".format(addr, tag, err))
|
||||
clx.close()
|
||||
return False
|
||||
|
||||
|
||||
def write_tag(addr, tag, val, plc_type="CLX"):
|
||||
#Write a tag value to the PLC.
|
||||
direct = plc_type == "Micro800"
|
||||
clx = ClxDriver()
|
||||
try:
|
||||
if clx.open(addr, direct_connection=direct):
|
||||
try:
|
||||
initial_val = clx.read_tag(tag)
|
||||
write_status = clx.write_tag(tag, val, initial_val[1])
|
||||
clx.close()
|
||||
return write_status
|
||||
except DataError as err:
|
||||
clx_err = clx.get_status()
|
||||
clx.close()
|
||||
print("--\nDataError during writeTag({}, {}, {}, plc_type={}) -- {}\n{}\n".format(addr, tag, val, plc_type, err, clx_err))
|
||||
except CommError as err:
|
||||
clx_err = clx.get_status()
|
||||
print("--\nCommError during write_tag({}, {}, {}, plc_type={})\n{}\n--".format(addr, tag, val, plc_type, err))
|
||||
#clx.close()
|
||||
return False
|
||||
|
||||
ips = {
|
||||
"000001000016": "192.168.1.216",
|
||||
"000001000005": "192.168.1.205",
|
||||
"000001000004": "192.168.1.204",
|
||||
"000001000007": "192.168.1.207",
|
||||
"000001000006": "192.168.1.206",
|
||||
"000001000001": "192.168.1.201",
|
||||
"000001000003": "192.168.1.203",
|
||||
"000001000002": "192.168.1.202",
|
||||
"000001000012": "192.168.1.212",
|
||||
"000001000013": "192.168.1.213",
|
||||
"000001000010": "192.168.1.210",
|
||||
"000001000011": "192.168.1.211",
|
||||
"000001000009": "192.168.1.209",
|
||||
"000001000008": "192.168.1.208",
|
||||
"000001000014": "192.168.1.214",
|
||||
"000001000015": "192.168.1.215",
|
||||
"000006000001": "192.168.1.217",
|
||||
"000006000002": "192.168.1.218",
|
||||
"000006000003": "192.168.1.219",
|
||||
"000006000004": "192.168.1.221",
|
||||
"000006000005": "192.168.1.220",
|
||||
"000001000023": "192.168.1.223",
|
||||
"000001000024": "192.168.1.224",
|
||||
"000001000025": "192.168.1.225"
|
||||
}
|
||||
totals_to_fix = [
|
||||
{
|
||||
"total_fm_last_month_gal": 585526.8125,
|
||||
"total_fm_last_month_bbls": 13941.114583333334,
|
||||
"name": "Windham 108-1",
|
||||
"mac": "000001000005"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 432819.125,
|
||||
"total_fm_last_month_bbls": 10305.217261904761,
|
||||
"name": "Windham 108-6",
|
||||
"mac": "000001000002"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 569190.8111801123,
|
||||
"total_fm_last_month_bbls": 13552.162170955055,
|
||||
"name": "Windham 108-5",
|
||||
"mac": "000001000003"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 349503.8125,
|
||||
"total_fm_last_month_bbls": 8321.519345238095,
|
||||
"name": "Windham 107-1",
|
||||
"mac": "000001000004"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 835251.983612061,
|
||||
"total_fm_last_month_bbls": 19886.95199076336,
|
||||
"name": "Windham 107-2",
|
||||
"mac": "000001000008"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 455446.20678711,
|
||||
"total_fm_last_month_bbls": 10843.957304455,
|
||||
"name": "Windham 108-8",
|
||||
"mac": "000001000009"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 589450.9773197174,
|
||||
"total_fm_last_month_bbls": 14034.54707904089,
|
||||
"name": "Windham 108-10",
|
||||
"mac": "000001000010"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 1272923.0,
|
||||
"total_fm_last_month_bbls": 30307.690476190477,
|
||||
"name": "Windham 108-2",
|
||||
"mac": "000001000011"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 642752.0,
|
||||
"total_fm_last_month_bbls": 15303.619047619048,
|
||||
"name": "Caden WW #3",
|
||||
"mac": "000000000006"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 3431191.5,
|
||||
"total_fm_last_month_bbls": 81695.03571428571,
|
||||
"name": "Kate A2",
|
||||
"mac": "000001000015"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 1197581.8099999998,
|
||||
"total_fm_last_month_bbls": 28513.852619047615,
|
||||
"name": "Barnett 24-1 PLC Fresh Water",
|
||||
"mac": "000000000031"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 603957.6875,
|
||||
"total_fm_last_month_bbls": 14379.94494047619,
|
||||
"name": "Kelly #1 PLC Fresh Water",
|
||||
"mac": "000001000023"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 1089152.125,
|
||||
"total_fm_last_month_bbls": 25932.193452380954,
|
||||
"name": "Kelly #2 PLC Fresh Water",
|
||||
"mac": "000001000024"
|
||||
},
|
||||
{
|
||||
"total_fm_last_month_gal": 493207.21875,
|
||||
"total_fm_last_month_bbls": 11743.029017857143,
|
||||
"name": "Kelly #3 PLC Fresh Water",
|
||||
"mac": "000001000025"
|
||||
}
|
||||
]
|
||||
for x in totals_to_fix:
|
||||
addr = ips.get(x['mac'], None)
|
||||
if addr:
|
||||
write_gal = write_tag(addr, "Totalizer_FM_Last_Month_Gal", x["total_fm_last_month_gal"], "Micro800" )
|
||||
write_bbl = write_tag(addr, "Totalizer_FM_Last_Month_BBLs", x["total_fm_last_month_bbls"], "Micro800" )
|
||||
print(x["name"], write_gal, write_bbl)
|
||||
|
||||
Reference in New Issue
Block a user