updated leak detection
This commit is contained in:
@@ -12,6 +12,14 @@ class RuntimeStats:
|
||||
self.currentRun = 0
|
||||
self.today = ""
|
||||
self.todayString = ""
|
||||
self.filePath = "/var/user/files/runtimestats.json"
|
||||
|
||||
def __init__(self, filePath:str):
|
||||
self.runs = {}
|
||||
self.currentRun = 0
|
||||
self.today = ""
|
||||
self.todayString = ""
|
||||
self.filePath = filePath
|
||||
|
||||
def manageTime(self):
|
||||
if self.todayString != dt.strftime(dt.today(), "%Y-%m-%d"):
|
||||
@@ -136,7 +144,7 @@ class RuntimeStats:
|
||||
raise Exception("Day can not be None")
|
||||
logger.debug("removing day {}".format(day))
|
||||
del self.runs[day]
|
||||
self.saveDataToFile()
|
||||
self.saveDataToFile(filePath=self.filePath)
|
||||
|
||||
def convertSecondstoHours(self, seconds):
|
||||
return round(seconds / (60*60),2)
|
||||
@@ -145,7 +153,7 @@ class RuntimeStats:
|
||||
logger.debug("clearing database")
|
||||
try:
|
||||
for day in list(self.runs.keys()):
|
||||
self.removeDay(day=day)
|
||||
self.removeDay(day=day, filePath=self.filePath)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
return False
|
||||
@@ -193,9 +201,15 @@ class RuntimeStats:
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
rts = RuntimeStats()
|
||||
rts.loadDataFromFile()
|
||||
rts.saveDataToFile()
|
||||
p001_path = "/var/user/files/runtimestats_p001.json"
|
||||
rts1 = RuntimeStats("/var/user/files/runtimestats_p001.json")
|
||||
rts1.loadDataFromFile(p001_path)
|
||||
rts1.saveDataToFile(p001_path)
|
||||
|
||||
p002_path = "/var/user/files/runtimestats_p002.json"
|
||||
rts2 = RuntimeStats("/var/user/files/runtimestats_p002.json")
|
||||
rts2.loadDataFromFile(p002_path)
|
||||
rts2.saveDataToFile(p002_path)
|
||||
|
||||
def reboot():
|
||||
# basic = Basic()
|
||||
@@ -389,10 +403,11 @@ def controlName(name):
|
||||
|
||||
def sendData(message):
|
||||
# logger.info(message)
|
||||
rts.loadDataFromFile()
|
||||
rts1.loadDataFromFile()
|
||||
rts2.loadDataFromFile()
|
||||
grouped_data = {}
|
||||
grouped_attributes = {}
|
||||
now = (round(dt.timestamp(dt.now())/600)*600)*1000
|
||||
now = (round(dt.timestamp(dt.now())/60)*60)*1000
|
||||
payload = {"ts": now, "values": {}}
|
||||
attributes_payload = {}
|
||||
logger.debug(message)
|
||||
@@ -423,18 +438,29 @@ def sendData(message):
|
||||
if health:
|
||||
if "_spt" in name:
|
||||
grouped_attributes[ctrlName][name] = value
|
||||
if name in ["p001_run"]:
|
||||
rts.manageTime()
|
||||
if value == 1 and not rts.runs[rts.todayString]["run_" + str(rts.currentRun)]["start"]:
|
||||
rts.startRun()
|
||||
rts.saveDataToFile()
|
||||
elif value == 0 and rts.runs[rts.todayString]["run_" + str(rts.currentRun)]["start"] and not rts.runs[rts.todayString]["run_" + str(rts.currentRun)]["end"]:
|
||||
rts.endRun()
|
||||
rts.saveDataToFile()
|
||||
grouped_data[ctrlName][name + "_today_running_hours"] = rts.calculateRunTimeDay()
|
||||
grouped_data[ctrlName][name + "_month_running_hours"] = rts.calculateRunTimeMultiDay(numDays=dt.today().day)
|
||||
else:
|
||||
grouped_data[ctrlName][name] = value
|
||||
if name in ["p001_run"]:
|
||||
rts1.manageTime()
|
||||
if value == 1 and not rts1.runs[rts1.todayString]["run_" + str(rts1.currentRun)]["start"]:
|
||||
rts1.startRun()
|
||||
rts1.saveDataToFile(p001_path)
|
||||
elif value == 0 and rts1.runs[rts1.todayString]["run_" + str(rts1.currentRun)]["start"] and not rts1.runs[rts1.todayString]["run_" + str(rts1.currentRun)]["end"]:
|
||||
rts1.endRun()
|
||||
rts1.saveDataToFile()
|
||||
grouped_data[ctrlName][name + "_today_running_hours"] = rts1.calculateRunTimeDay()
|
||||
grouped_data[ctrlName][name + "_month_running_hours"] = rts1.calculateRunTimeMultiDay(numDays=dt.today().day)
|
||||
if name in ["p002_run"]:
|
||||
rts2.manageTime()
|
||||
if value == 1 and not rts2.runs[rts2.todayString]["run_" + str(rts2.currentRun)]["start"]:
|
||||
rts2.startRun()
|
||||
rts2.saveDataToFile(p002_path)
|
||||
elif value == 0 and rts2.runs[rts2.todayString]["run_" + str(rts2.currentRun)]["start"] and not rts2.runs[rts2.todayString]["run_" + str(rts2.currentRun)]["end"]:
|
||||
rts2.endRun()
|
||||
rts2.saveDataToFile()
|
||||
grouped_data[ctrlName][name + "_today_running_hours"] = rts2.calculateRunTimeDay()
|
||||
grouped_data[ctrlName][name + "_month_running_hours"] = rts2.calculateRunTimeMultiDay(numDays=dt.today().day)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
@@ -460,7 +486,7 @@ def sendData(message):
|
||||
time.sleep(2)
|
||||
|
||||
attributes_payload["latestReportTime"] = (
|
||||
round(dt.timestamp(dt.now())/600)*600)*1000
|
||||
round(dt.timestamp(dt.now())/60)*60)*1000
|
||||
for chunk in chunk_payload(payload=attributes_payload):
|
||||
publish("v1/devices/me/attributes", json.dumps(chunk), __qos__)
|
||||
time.sleep(2)
|
||||
|
||||
2392
Pub_Sub/fk_leak_detection/thingsboard/tag_dump_2025_December_02.json
Normal file
2392
Pub_Sub/fk_leak_detection/thingsboard/tag_dump_2025_December_02.json
Normal file
File diff suppressed because it is too large
Load Diff
36
Pub_Sub/fk_overflow_pump/thingsboard/measure.csv
Normal file
36
Pub_Sub/fk_overflow_pump/thingsboard/measure.csv
Normal file
@@ -0,0 +1,36 @@
|
||||
MeasuringPointName,ControllerName,GroupName,UploadType,DeadZonePercent,DataType,ArrayIndex,EnableBit,BitIndex,reverseBit,Address,Decimal,Len,ReadWrite,Unit,Description,Transform Type,MaxValue,MinValue,MaxScale,MinScale,Gain,Offset,startBit,endBit,Pt,Ct,Mapping_table,TransDecimal,bitMap,msecSample,storageLwTSDB,DataEndianReverse,ReadOffset,ReadLength,WriteOffset,WriteLength,DataParseMethod,BitId
|
||||
discharge_out,overflow_pump,default,periodic,,FLOAT,,,,,DisPSI_Out,2,,ro,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
fit_rate,overflow_pump,default,periodic,,FLOAT,,,,,FIT_Rate,2,,ro,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
level_override_cmd,overflow_pump,default,periodic,,BIT,,,,0,Level_Override ,,,rw,,"1= runs regardless of level, 0= runs based on start/stop levels",none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pond_1_hi_alm,overflow_pump,default,periodic,,BIT,,,,0,Pond_1_Hi_Alarm,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pond_1_hi_clr_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Hi_Clr_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_hi_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Hi_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_level,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Lev,2,,ro,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_lo_alm,overflow_pump,default,periodic,,BIT,,,,0,Pond_1_Lo_Alarm,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pond_1_lo_clr_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Lo_Clr_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_lo_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Lo_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_total_bbls,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Total_Barrels,2,,ro,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_2_hi_alm,overflow_pump,default,periodic,,BIT,,,,0,Pond_2_Hi_Alarm,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pond_2_hi_clr_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_2_Hi_Clr_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_2_hi_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_2_Hi_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_2_level,overflow_pump,default,periodic,,FLOAT,,,,,Pond_2_Lev,2,,ro,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_2_lo_alm,overflow_pump,default,periodic,,BIT,,,,0,Pond_2_Lo_Alarm,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pond_2_lo_clr_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_2_Lo_Clr_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_2_lo_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_2_Lo_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_2_total_bbls,overflow_pump,default,periodic,,FLOAT,,,,,Pond_2_Total_Barrels,2,,ro,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pump_1_auto,overflow_pump,default,periodic,,BIT,,,,0,P001_AUTO_FBK,,,ro,, HOA auto status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_hand,overflow_pump,default,periodic,,BIT,,,,0,P001_HAND_FBK,,,ro,, HOA hand status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_local_start,overflow_pump,default,periodic,,BIT,,,,0,P001_START_BTN_FBK,,,ro,,Local start status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_overload_status,overflow_pump,default,periodic,,BIT,,,,0,P001_OVERLOAD_FBK,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_run_fail_alm,overflow_pump,default,periodic,,BIT,,,,0,P001_RUN_FAIL_ALARM,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_run_status,overflow_pump,default,periodic,,BIT,,,,0,P001_RUN_FBK,,,ro,, Pump running status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_auto,overflow_pump,default,periodic,,BIT,,,,0,P002_AUTO_FBK,,,ro,, HOA auto status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_hand,overflow_pump,default,periodic,,BIT,,,,0,P002_HAND_FBK,,,ro,, HOA hand status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_local_start,overflow_pump,default,periodic,,BIT,,,,0,P002_START_BTN_FBK,,,ro,,Local start status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_overload_status,overflow_pump,default,periodic,,BIT,,,,0,P002_OVERLOAD_FBK,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_run_fail_alm,overflow_pump,default,periodic,,BIT,,,,0,P002_RUN_FAIL_ALARM,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_run_status,overflow_pump,default,periodic,,BIT,,,,0,P002_RUN_FBK,,,ro,, Pump running status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
run_level_perm,overflow_pump,default,periodic,,BIT,,,,0,Run_Level_Perm,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
start_level_spt,overflow_pump,default,periodic,,FLOAT,,,,,Start_Level_spt ,2,,rw,, start level input,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
start_stop_cmd,overflow_pump,default,periodic,,BIT,,,,0,CMD_Cloud_Control,,,rw,, Pump Start Stop,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
stop_level_spt,overflow_pump,default,periodic,,FLOAT,,,,,Stop_Level_spt ,2,,rw,, stop level input,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
|
25
Pub_Sub/fk_overflow_pump/thingsboard/measure_no_pond2.csv
Normal file
25
Pub_Sub/fk_overflow_pump/thingsboard/measure_no_pond2.csv
Normal file
@@ -0,0 +1,25 @@
|
||||
MeasuringPointName,ControllerName,GroupName,UploadType,DeadZonePercent,DataType,ArrayIndex,EnableBit,BitIndex,reverseBit,Address,Decimal,Len,ReadWrite,Unit,Description,Transform Type,MaxValue,MinValue,MaxScale,MinScale,Gain,Offset,startBit,endBit,Pt,Ct,Mapping_table,TransDecimal,bitMap,msecSample,storageLwTSDB,DataEndianReverse,ReadOffset,ReadLength,WriteOffset,WriteLength,DataParseMethod,BitId
|
||||
level_override_spt,overflow_pump,default,periodic,,BIT,,,,0,Level_Override ,,,rw,,"1= runs regardless of level, 0= runs based on start/stop levels",none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pond_1_hi_alm,overflow_pump,default,periodic,,BIT,,,,0,Pond_1_Hi_Alarm,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pond_1_hi_clr_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Hi_Clr_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_hi_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Hi_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_level,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Lev,2,,ro,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_lo_alm,overflow_pump,default,periodic,,BIT,,,,0,Pond_1_Lo_Alarm,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pond_1_lo_clr_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Lo_Clr_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_lo_spt,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Lo_Setpoint,2,,rw,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pond_1_total_bbls,overflow_pump,default,periodic,,FLOAT,,,,,Pond_1_Total_Barrels,2,,ro,,,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
pump_1_auto,overflow_pump,default,periodic,,BIT,,,,0,P001_AUTO_FBK,,,ro,, HOA auto status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_hand,overflow_pump,default,periodic,,BIT,,,,0,P001_HAND_FBK,,,ro,, HOA hand status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_local_start,overflow_pump,default,periodic,,BIT,,,,0,P001_START_BTN_FBK,,,ro,,Local start status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_overload_status,overflow_pump,default,periodic,,BIT,,,,0,P001_OVERLOAD_FBK,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_run_fail_alm,overflow_pump,default,periodic,,BIT,,,,0,P001_RUN_FAIL_ALARM,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_1_run_status,overflow_pump,default,periodic,,BIT,,,,0,P001_RUN_FBK,,,ro,, Pump running status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_auto,overflow_pump,default,periodic,,BIT,,,,0,P002_AUTO_FBK,,,ro,, HOA auto status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_hand,overflow_pump,default,periodic,,BIT,,,,0,P002_HAND_FBK,,,ro,, HOA hand status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_local_start,overflow_pump,default,periodic,,BIT,,,,0,P002_START_BTN_FBK,,,ro,,Local start status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_overload_status,overflow_pump,default,periodic,,BIT,,,,0,P002_OVERLOAD_FBK,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_run_fail_alm,overflow_pump,default,periodic,,BIT,,,,0,P002_RUN_FAIL_ALARM,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
pump_2_run_status,overflow_pump,default,periodic,,BIT,,,,0,P002_RUN_FBK,,,ro,, Pump running status,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
run_level_perm,overflow_pump,default,periodic,,BIT,,,,0,Run_Level_Perm,,,ro,,,none,,,,,,,,,,,,,0,,1,,,,,,,
|
||||
start_level_spt,overflow_pump,default,periodic,,FLOAT,,,,,Start_Level_spt ,2,,rw,, start level input,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
stop_level_spt,overflow_pump,default,periodic,,FLOAT,,,,,Stop_Level_spt ,2,,rw,, stop level input,none,,,,,,,,,,,,,,,1,,,,,,,
|
||||
|
@@ -1,8 +0,0 @@
|
||||
MeasuringPointName,ControllerName,GroupName,UploadType,DataType,EnableBit,BitIndex,reverseBit,Address,Decimal,Len,ReadWrite,Unit,Description,Transform Type,MaxValue,MinValue,MaxScale,MinScale,Gain,Offset,startBit,endBit,Pt,Ct,Mapping_table,TransDecimal,bitMap,msecSample,DataEndianReverse,ReadOffset,ReadLength,DataParseMethod,BitId,storageLwTSDB
|
||||
start_level_spt,overflow_pump,default,periodic,FLOAT,,,,Start_Level_spt ,2,,ro,, start level input,none,,,,,,,,,,,,,,,,,,,,1
|
||||
stop_level_spt,overflow_pump,default,periodic,FLOAT,,,,Stop_Level_spt ,2,,ro,, stop level input,none,,,,,,,,,,,,,,,,,,,,1
|
||||
auto,overflow_pump,default,periodic,BIT,,,0,Raw_Auto_Input ,,,ro,, HOA auto status,none,,,,,,,,,,,,,0,,,,,,,1
|
||||
hand,overflow_pump,default,periodic,BIT,,,0,Raw_Hand_Input ,,,ro,, HOA hand status,none,,,,,,,,,,,,,0,,,,,,,1
|
||||
run_status,overflow_pump,default,periodic,BIT,,,0,Raw_Run_Status ,,,ro,, Pump running status,none,,,,,,,,,,,,,0,,,,,,,1
|
||||
level_override,overflow_pump,default,periodic,BIT,,,0,Level_Override ,,,ro,,"1= runs regardless of level, 0= runs based on start/stop levels",none,,,,,,,,,,,,,0,,,,,,,1
|
||||
overload_status,overflow_pump,default,periodic,BIT,,,0,Raw_Overload_Status , ,,ro,,,none,,,,,,,,,,,,,0,,,,,,,1
|
||||
|
1433
Pub_Sub/fk_overflow_pump/thingsboard/tag_dump_2025_October_23.json
Normal file
1433
Pub_Sub/fk_overflow_pump/thingsboard/tag_dump_2025_October_23.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
MeasuringPointName,ControllerName,GroupName,UploadType,DeadZoneType,DeadZonePercent,DataType,ArrayIndex,EnableBit,BitIndex,reverseBit,Address,Decimal,Len,CodeType,ReadWrite,Unit,Description,Transform Type,MaxValue,MinValue,MaxScale,MinScale,Gain,Offset,startBit,endBit,Pt,Ct,Mapping_table,TransDecimal,bitMap,msecSample,storageLwTSDB,DataEndianReverse,ReadOffset,ReadLength,WriteOffset,WriteLength,DataParseMethod,BitId,pollCycle,EnableRequestCount,RequestCount,byteOrder
|
||||
flowrate,flowmeter,default,periodic,,,FLOAT,,,,,4X3874,2,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,cdab
|
||||
totalizer_1,flowmeter,default,periodic,,,FLOAT,,,,,4X2610,2,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,cdab
|
||||
totalizer_2,flowmeter,default,periodic,,,FLOAT,,,,,4X2810,2,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,cdab
|
||||
totalizer_3,flowmeter,default,periodic,,,FLOAT,,,,,4X3010,2,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,cdab
|
||||
flow_unit,flowmeter,default,onChange,0,0,INT,,0,,,4X2103,,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,ab
|
||||
totalizer_1_unit,flowmeter,default,onChange,0,0,INT,,0,,,4X4604,,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,ab
|
||||
totalizer_2_unit,flowmeter,default,onChange,0,0,INT,,0,,,4X4605,,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,ab
|
||||
totalizer_3_unit,flowmeter,default,periodic,,,INT,,0,,,4X4606,,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,ab
|
||||
reset_totalizers,flowmeter,,never,,,INT,,0,,,4X2609,,,,rw,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,ab
|
||||
byte_order,flowmeter,default,onChange,0,0,INT,,0,,,4X4915,,,,rw,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,ab
|
||||
device_name,flowmeter,default,onChange,,,STRING,,,,,4X7238,,14,UTF-8,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,
|
||||
serial_number,flowmeter,default,onChange,,,STRING,,,,,4X7003,,12,UTF-8,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,
|
||||
totalizer_1_rollover,flowmeter,default,periodic,,,FLOAT,,,,,4X2612,2,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,cdab
|
||||
empty_pipe,flowmeter,default,periodic,,,FLOAT,,,,,4X2298,2,,,ro,,,none,,,,,,,,,,,,,,0,1,,,,,,,,0,0,,cdab
|
||||
|
631
Pub_Sub/flowmeterskid/thingsboard/flowmeterskid_tb_v6.cfg
Normal file
631
Pub_Sub/flowmeterskid/thingsboard/flowmeterskid_tb_v6.cfg
Normal file
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -10,25 +10,25 @@
|
||||
"import json, pprint\n",
|
||||
"from datetime import datetime as dt\n",
|
||||
"import csv\n",
|
||||
"import re\n"
|
||||
"import re, time\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ip_address = \"107.84.248.206\"# \"ngrok.iot.inhandnetworks.com:3054\" # \"166.141.90.208\"\n",
|
||||
"device_type = \"dane_water\"\n",
|
||||
"ip_address = \"166.193.23.21\"# \"ngrok.iot.inhandnetworks.com:3054\" # \"166.141.90.208\"\n",
|
||||
"device_type = \"fk_overflow_pump\"\n",
|
||||
"today = dt.now().strftime(\"%Y_%B_%d\")\n",
|
||||
"filename = f\"tag_dump_{today}_Station_3.json\"\n",
|
||||
"filename = f\"tag_dump_{today}.json\"\n",
|
||||
"path = f'/Users/nico/Documents/GitHub/HP_InHand_IG502/Pub_Sub/{device_type}/thingsboard/' # code snippets/tag_dump.json'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -43,7 +43,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -78,19 +78,11 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"CSV file created: /Users/nico/Documents/GitHub/HP_InHand_IG502/Pub_Sub/dane_water/thingsboard/Station_3.csv\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"controller_name = \"Station_3\"\n",
|
||||
"controller_name = \"leak_detection\"\n",
|
||||
"filename = f\"{controller_name}.csv\"\n",
|
||||
"header = [\n",
|
||||
" \"MeasuringPointName\",\"ControllerName\",\"GroupName\",\"UploadType\",\"DeadZoneType\",\"DeadZonePercent\",\n",
|
||||
@@ -169,11 +161,100 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Alarm_Enable\n",
|
||||
"Level_Override\n",
|
||||
"P001_AUTO_FBK\n",
|
||||
"P001_HAND_FBK\n",
|
||||
"P001_OVERLOAD_ALARM\n",
|
||||
"P001_OVERLOAD_FBK\n",
|
||||
"P001_RUN_CMD\n",
|
||||
"P001_RUN_FAIL_ALARM\n",
|
||||
"P001_RUN_FBK\n",
|
||||
"P001_START_BTN_FBK\n",
|
||||
"P002_AUTO_FBK\n",
|
||||
"P002_HAND_FBK\n",
|
||||
"P002_OVERLOAD_ALARM\n",
|
||||
"P002_OVERLOAD_FBK\n",
|
||||
"P002_RUN_CMD\n",
|
||||
"P002_RUN_FAIL_ALARM\n",
|
||||
"P002_RUN_FBK\n",
|
||||
"P002_START_BTN_FBK\n",
|
||||
"Pond_1_CU_Ft\n",
|
||||
"Pond_1_Cubic_Feet_To_Barrels\n",
|
||||
"Pond_1_Dim_A\n",
|
||||
"Pond_1_Dim_B\n",
|
||||
"Pond_1_Dim_C\n",
|
||||
"Pond_1_Dim_D\n",
|
||||
"Pond_1_EU_Max\n",
|
||||
"Pond_1_EU_Min\n",
|
||||
"Pond_1_Hi_Alarm\n",
|
||||
"Pond_1_Hi_Alarm_Enable\n",
|
||||
"Pond_1_Hi_Alarm_Enabled\n",
|
||||
"Pond_1_Hi_Clr_Setpoint\n",
|
||||
"Pond_1_Hi_Reset\n",
|
||||
"Pond_1_Hi_Set\n",
|
||||
"Pond_1_Hi_Setpoint\n",
|
||||
"Pond_1_Input_Max\n",
|
||||
"Pond_1_Input_Min\n",
|
||||
"Pond_1_Lev\n",
|
||||
"Pond_1_Lev_Temp\n",
|
||||
"Pond_1_Lo_Alarm\n",
|
||||
"Pond_1_Lo_Clr_Setpoint\n",
|
||||
"Pond_1_Lo_Reset\n",
|
||||
"Pond_1_Lo_Set\n",
|
||||
"Pond_1_Lo_Setpoint\n",
|
||||
"Pond_1_ScaledMax\n",
|
||||
"Pond_1_ScaledMin\n",
|
||||
"Pond_1_Tot_Bbls_Temp\n",
|
||||
"Pond_1_Total_Barrels\n",
|
||||
"Run_Level_Perm\n",
|
||||
"Start_Level_spt\n",
|
||||
"Stop_Level_spt\n",
|
||||
"_IO_EM_AI_00\n",
|
||||
"_IO_EM_AI_01\n",
|
||||
"_IO_EM_AI_02\n",
|
||||
"_IO_EM_AI_03\n",
|
||||
"_IO_EM_AO_00\n",
|
||||
"_IO_EM_DI_00\n",
|
||||
"_IO_EM_DI_01\n",
|
||||
"_IO_EM_DI_02\n",
|
||||
"_IO_EM_DI_03\n",
|
||||
"_IO_EM_DI_04\n",
|
||||
"_IO_EM_DI_05\n",
|
||||
"_IO_EM_DI_06\n",
|
||||
"_IO_EM_DI_07\n",
|
||||
"_IO_EM_DI_08\n",
|
||||
"_IO_EM_DI_09\n",
|
||||
"_IO_EM_DI_10\n",
|
||||
"_IO_EM_DI_11\n",
|
||||
"_IO_EM_DO_00\n",
|
||||
"_IO_EM_DO_01\n",
|
||||
"_IO_EM_DO_02\n",
|
||||
"_IO_EM_DO_03\n",
|
||||
"_IO_EM_DO_04\n",
|
||||
"_IO_EM_DO_05\n",
|
||||
"_IO_EM_DO_06\n",
|
||||
"_IO_P1_AI_00\n",
|
||||
"_IO_P1_AI_01\n",
|
||||
"_IO_P1_AI_02\n",
|
||||
"_IO_P1_AI_03\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(plctags)"
|
||||
"tags = []\n",
|
||||
"for x in plctags:\n",
|
||||
" tags.append(x[\"tag_name\"])\n",
|
||||
"tags.sort()\n",
|
||||
"for x in tags:\n",
|
||||
" print(x)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -187,12 +268,20 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 16,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Pond_1_Total_Barrels, nan, REAL, None\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"with LogixDriver(ip_address) as plc:\n",
|
||||
" print(plc.read(\"Pond_1_Lev\"))"
|
||||
" print(plc.read(\"Pond_1_Total_Barrels\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -202,23 +291,13 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"readtags = [\n",
|
||||
" \"Lact_01_Monthly_Total\",\n",
|
||||
" \"Lact_01_Prev_Month_Total\",\n",
|
||||
" \"Lact_01_Today_Total\",\n",
|
||||
" \"Lact_01_Yesterday_Total\",\n",
|
||||
" \"Lact_02_Monthly_Total\",\n",
|
||||
" \"Lact_02_Prev_Month_Total\",\n",
|
||||
" \"Lact_02_Today_Total\",\n",
|
||||
" \"Lact_02_Yesterday_Total\",\n",
|
||||
" \"XferPump_01_Daily_Totalizer.Total\",\n",
|
||||
" \"XferPump_01_Daily_Totalizer.OldTotal\",\n",
|
||||
" \"XferPump_02_Monthly_Totalizer.Total\",\n",
|
||||
" \"XferPump_02_Monthly_Totalizer.OldTotal\",\n",
|
||||
" \"Val_Water_Xfer_Current_Day\",\n",
|
||||
" \"Val_Water_Xfer_Prev_Day\"\n",
|
||||
" \"P001_RUN_FBK\",\n",
|
||||
" \"Leak_1_Lev\"\n",
|
||||
"]\n",
|
||||
"with LogixDriver('63.40.227.154') as plc:\n",
|
||||
"with LogixDriver(ip_address) as plc:\n",
|
||||
" while(True):\n",
|
||||
" print(*plc.read(*readtags), sep=\"\\n\")\n",
|
||||
" time.sleep(30)\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
|
||||
221
code snippets/parseIncomingIPs.ipynb
Normal file
221
code snippets/parseIncomingIPs.ipynb
Normal file
@@ -0,0 +1,221 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "c3d3179a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import re\n",
|
||||
"from pathlib import Path\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "bf7cab93",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"LOG_FILE = Path('/Users/nico/Downloads/history(1).log') # change to your real filename\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "3fb97df3",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Regular expressions\n",
|
||||
"# 1. find lines that mention ACCEPTIN or DROPIN\n",
|
||||
"# 2. extract the SRC=… and DPT=… fields\n",
|
||||
"rx_match = re.compile(r'\\b(?:ACCEPTIN|DROPIN)\\b')\n",
|
||||
"rx_src = re.compile(r'SRC=(\\S+)')\n",
|
||||
"rx_dpt = re.compile(r'DPT=(\\S+)')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "80bda503",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"src_set = set()\n",
|
||||
"dpt_set = set()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "2c65a8a8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for line in LOG_FILE.read_text().splitlines():\n",
|
||||
" if rx_match.search(line):\n",
|
||||
" src = rx_src.search(line)\n",
|
||||
" dpt = rx_dpt.search(line)\n",
|
||||
" if src:\n",
|
||||
" src_set.add(src.group(1))\n",
|
||||
" if dpt:\n",
|
||||
" dpt_set.add(dpt.group(1))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "ee8d993a",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"SRC addresses (unique):\n",
|
||||
"101.109.1.155\n",
|
||||
"101.126.65.104\n",
|
||||
"103.167.90.33\n",
|
||||
"129.212.181.192\n",
|
||||
"139.19.117.131\n",
|
||||
"143.244.143.105\n",
|
||||
"146.88.240.102\n",
|
||||
"149.100.11.243\n",
|
||||
"157.230.88.176\n",
|
||||
"159.203.22.30\n",
|
||||
"161.35.89.149\n",
|
||||
"162.199.59.89\n",
|
||||
"162.243.92.131\n",
|
||||
"164.52.0.92\n",
|
||||
"164.92.186.91\n",
|
||||
"165.227.34.24\n",
|
||||
"178.20.210.151\n",
|
||||
"178.20.210.152\n",
|
||||
"185.226.197.20\n",
|
||||
"185.243.98.11\n",
|
||||
"185.244.104.2\n",
|
||||
"185.44.76.10\n",
|
||||
"192.155.81.124\n",
|
||||
"193.142.147.209\n",
|
||||
"193.163.125.168\n",
|
||||
"193.163.125.172\n",
|
||||
"193.32.162.146\n",
|
||||
"193.34.213.150\n",
|
||||
"194.0.234.20\n",
|
||||
"194.180.48.63\n",
|
||||
"196.251.100.49\n",
|
||||
"196.251.100.74\n",
|
||||
"198.23.193.70\n",
|
||||
"198.235.24.220\n",
|
||||
"198.235.24.255\n",
|
||||
"199.30.231.6\n",
|
||||
"205.210.31.254\n",
|
||||
"209.38.80.186\n",
|
||||
"211.197.158.113\n",
|
||||
"217.119.139.38\n",
|
||||
"222.186.13.133\n",
|
||||
"40.118.131.195\n",
|
||||
"40.124.80.250\n",
|
||||
"45.140.140.15\n",
|
||||
"45.58.127.135\n",
|
||||
"51.158.205.47\n",
|
||||
"51.159.195.137\n",
|
||||
"52.177.127.126\n",
|
||||
"62.60.131.204\n",
|
||||
"64.31.56.53\n",
|
||||
"64.62.156.14\n",
|
||||
"64.62.197.37\n",
|
||||
"64.62.197.80\n",
|
||||
"66.175.215.158\n",
|
||||
"71.6.134.230\n",
|
||||
"77.90.185.43\n",
|
||||
"78.130.40.117\n",
|
||||
"78.159.130.8\n",
|
||||
"80.94.92.166\n",
|
||||
"81.22.193.93\n",
|
||||
"85.235.74.21\n",
|
||||
"88.218.193.185\n",
|
||||
"89.42.231.77\n",
|
||||
"91.199.163.52\n",
|
||||
"91.224.92.54\n",
|
||||
"91.224.92.94\n",
|
||||
"91.232.238.112\n",
|
||||
"94.100.26.36\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(\"SRC addresses (unique):\")\n",
|
||||
"for addr in sorted(src_set):\n",
|
||||
" print(addr)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "238c0796",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"68"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(src_set)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "8c5730a3",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"DPT ports (unique):\n",
|
||||
"22\n",
|
||||
"443\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(\"\\nDPT ports (unique):\")\n",
|
||||
"for port in sorted(dpt_set):\n",
|
||||
" print(port)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user