Updated to latest version

This commit is contained in:
2020-01-16 15:49:18 -06:00
parent f840c6fd7f
commit 04080eebd2
5 changed files with 40 additions and 27 deletions

View File

@@ -20,5 +20,6 @@ tags = [
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"),
PLCChannel(PLC_IP_ADDRESS, "pump_2_suction","Suction_PSI_TP2_Scaled","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "pump_charge_psi_tp1", "Charge_PSI_TP1_Scaled", "REAL", 10, 3600, plc_type="Micro800")
PLCChannel(PLC_IP_ADDRESS, "pump_charge_psi_tp1", "Charge_PSI_TP1_Scaled", "REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "pond_1_height", "Pond_level_tp1_scaled", "REAL", 2, 3600, plc_type="Micro800")
]

View File

@@ -4,22 +4,22 @@ 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, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "raw_auto_input","Raw_Auto_Input","BOOL", 1, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "raw_run_status","Raw_Run_Status","BOOL", 1, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "raw_run_indication","Raw_Run_Indication","BOOL", 1, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "raw_local_start","Raw_Local_Start","BOOL", 1, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "cmd_cloud_control","CMD_Cloud_Control","BOOL", 1, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "lifetime_flow_meter_gal","Lifetime_Flow_Meter_Gal","REAL", 3, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_yesterday_gal","Totalizer_FM_Yesterday_Total_Gal","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_day_gal","Totalizer_FM_Current_Day_Total_Gal","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_last_month_gal","Totalizer_FM_Last_Month_Gal","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_month_gal","Totalizer_FM_Current_Month_Gal","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_yesterday_bbls","Totalizer_FM_Yesterday_Total_BBLs","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_day_bbls","Totalizer_FM_CUrrent_Day_Total_BBLs","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_last_month_bbls","Totalizer_FM_Last_Month_BBLs","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_month_bbls","Totalizer_FM_Current_Month_BBLs","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "lifetime_flow_meter_bbls","Lifetime_Flow_Meter_BBLS","REAL", 10, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "spt_flow_meter_unit","SPT_Flow_Meter_Unit","BOOL", 1, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "raw_overload_status", "Raw_Overload_Status", "BOOL", 1, 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_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"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_last_month_gal","Totalizer_FM_Last_Month_Gal","REAL", 100, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_month_gal","Totalizer_FM_Current_Month_Gal","REAL", 50, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_yesterday_bbls","Totalizer_FM_Yesterday_Total_BBLs","REAL", 50, 3600, plc_type="Micro800"),
PLCChannel(PLC_IP_ADDRESS, "total_fm_day_bbls","Totalizer_FM_CUrrent_Day_Total_BBLs","REAL", 50, 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", 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")
]

View File

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

View File

@@ -11,7 +11,7 @@ from utilities import get_public_ip_address, get_private_ip_address
_ = None
# GLOBAL VARIABLES
WAIT_FOR_CONNECTION_SECONDS = 60
WAIT_FOR_CONNECTION_SECONDS = 10
IP_CHECK_PERIOD = 60
PLC_IP_ADDRESS = ""
TOPIC_MAC = ""
@@ -24,10 +24,10 @@ if not IP_TABLE:
"000000000001":"192.168.1.201",
"000000000002":"192.168.1.202",
"000000000003":"192.168.1.203",
"000000000004":"192.168.1.204",
"000000000005":"192.168.1.205",
"000000000006":"192.168.1.206",
"000000000007":"192.168.1.207",
"000000000004":"192.168.1.211",
"000000000005":"192.168.1.210",
"000000000006":"192.168.1.208",
"000000000007":"192.168.1.209",
"000000000008":"192.168.1.208",
"000000000009":"192.168.1.209",
"000000000010":"192.168.1.210",
@@ -52,7 +52,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 = ""
@@ -60,6 +60,7 @@ class start(threading.Thread, deviceBase):
self.private_ip_address = ""
self.plcip = ""
self.ping_counter = 0
self.plc_ping_status = 'Comms Error to PLC'
threading.Thread.start(self)
# this is a required function for all drivers, its goal is to upload some piece of data
@@ -109,6 +110,16 @@ class start(threading.Thread, deviceBase):
#time.sleep(TAG_DATAERROR_SLEEPTIME) # sleep to allow Micro800 to handle ENET requests
# print("plcfreshwater driver still alive...")
plc_ping = os.system("ping -c 1 " + IP_TABLE[self.mac])
if plc_ping == 0:
if self.plc_ping_status == "Comms Error to PLC":
self.sendtodbDev(1, "plc_ping","OK", 0, 'plcfreshwater')
self.plc_ping_status = "OK"
else:
if self.plc_ping_status == "OK":
self.sendtodbDev(1, 'plc_ping', "Comms Error to PLC",0, 'plcfreshwater')
self.plc_ping_status = 'Comms Error to PLC'
time.sleep(10)
if self.force_send:
if send_loops > 2:
log.warning("Turning off force_send")
@@ -166,3 +177,4 @@ class start(threading.Thread, deviceBase):
if write_res is None:
write_res = "Error writing to PLC..."
return write_res

View File

@@ -240,7 +240,7 @@ class start(threading.Thread, deviceBase):
new_val = json.loads(str(value).replace("'", '"'))
tag_n = str(new_val['tag']) # "cmd_Start"
val_n = new_val['val']
w = write_tag(str(PLC_IP_ADDRESS), tag_n, val_n)
w = write_tag(str(PLC_IP_ADDRESS), tag_n, val_n, plc_type="Micro800")
logger.info("Result of plcpond_writeplctag(self, {}, {}) = {}".format(name, value, w))
if w is None:
w = "Error writing to PLC..."