multiple updates to various drivers
This commit is contained in:
10
Pub_Sub/piflow/thingsboard/drive_measures.csv
Normal file
10
Pub_Sub/piflow/thingsboard/drive_measures.csv
Normal file
@@ -0,0 +1,10 @@
|
||||
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
|
||||
frequency,drive,default,periodic,,INT,,0,,,4X0785,,,ro,,,zoom,,,,,0.01,0.0,,,,,,2,,0,0,,,,,,,
|
||||
current,drive,default,periodic,,INT,,0,,,4X0784,,,ro,,,zoom,,,,,0.1,0.0,,,,,,2,,0,0,,,,,,,
|
||||
pid_ref,drive,default,periodic,,INT,,0,,,4X0792,,,ro,,,zoom,,,,,0.1,0.0,,,,,,2,,0,0,,,,,,,
|
||||
pid_feedback,drive,default,periodic,,INT,,0,,,4X0793,,,ro,,,zoom,,,,,0.1,0.0,,,,,,2,,0,0,,,,,,,
|
||||
motor_rated_current,drive,default,periodic,,INT,,0,,,4X4897,,,ro,,,zoom,,,,,0.1,0.0,,,,,,2,,0,0,,,,,,,
|
||||
sleep_delay,drive,default,periodic,,INT,,0,,,4X4925,,,ro,,,zoom,,,,,0.1,0.0,,,,,,2,,0,0,,,,,,,
|
||||
run_status,drive,default,periodic,,INT,,0,,,4X0773,,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
fault_a,drive,default,periodic,,INT,,0,,,4X0816,,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
fault_b,drive,default,periodic,,INT,,0,,,4X0817,,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
|
13
Pub_Sub/piflow/thingsboard/flowmeter_measures.csv
Normal file
13
Pub_Sub/piflow/thingsboard/flowmeter_measures.csv
Normal file
@@ -0,0 +1,13 @@
|
||||
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
|
||||
volume_flow,flowmeter,default,periodic,,FLOAT,,,,,4X3874,2,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
totalizer_1,flowmeter,default,periodic,,FLOAT,,,,,4X2610,2,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
totalizer_2,flowmeter,default,periodic,,FLOAT,,,,,4X2810,2,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
totalizer_3,flowmeter,default,periodic,,FLOAT,,,,,4X3010,2,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
flow_unit,flowmeter,default,periodic,,INT,,0,,,4X2103,,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
totalizer_1_units,flowmeter,default,periodic,,INT,,0,,,4X4604,,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
totalizer_2_units,flowmeter,default,periodic,,INT,,0,,,4X4605,,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
totalizer_3_units,flowmeter,default,periodic,,INT,,0,,,4X4606,,,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
reset_totalizers,flowmeter,,never,,INT,,0,,,4X2609,,,rw,,,none,,,,,,,,,,,,,,0,,,,,,,,
|
||||
byte_order,flowmeter,default,onChange,0,INT,,0,,,4X4915,,,rw,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
device_name,flowmeter,default,onChange,,STRING,,,,,4X7238,,14,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
serial_number,flowmeter,default,onChange,,STRING,,,,,4X7003,,12,ro,,,none,,,,,,,,,,,,,,0,0,,,,,,,
|
||||
|
615
Pub_Sub/piflow/thingsboard/piflow.cfg
Normal file
615
Pub_Sub/piflow/thingsboard/piflow.cfg
Normal file
File diff suppressed because one or more lines are too long
@@ -98,8 +98,14 @@ def sendData(message):
|
||||
payload["values"]["month_" + measure["name"]], monthReset = totalizeMonth(measure["value"], measure["name"])
|
||||
payload["values"]["week_" + measure["name"]], weekReset = totalizeWeek(measure["value"], measure["name"])
|
||||
payload["values"]["today_" + measure["name"]], dayReset = totalizeDay(measure["value"], measure["name"])
|
||||
elif measure["name"] in ["totalizer_1_units", "totalizer_2_units", "totalizer_3_units", "flow_unit", "run_status", "fault_a", "fault_b"]:
|
||||
elif measure["name"] in ["totalizer_1_units", "totalizer_2_units", "totalizer_3_units", "flow_unit"]:
|
||||
payload["values"][measure["name"]] = convert_int(measure["name"], measure["value"])
|
||||
elif measure["name"] in ["run_status"]:
|
||||
payload["values"][measure["name"]] = status_codes(measure["value"])
|
||||
elif measure["name"] in [ "fault_a"]:
|
||||
payload["values"][measure["name"]] = fault_code_a(measure["value"])
|
||||
elif measure["name"] in ["fault_b"]:
|
||||
payload["values"][measure["name"]] = fault_code_b(measure["value"])
|
||||
else:
|
||||
payload["values"][measure["name"]] = measure["value"]
|
||||
except Exception as e:
|
||||
@@ -293,34 +299,154 @@ def totalizeYear(lifetime, totalizer, max_retries=3, retry_delay=2):
|
||||
logger.error("All attempts to save totalizers failed.")
|
||||
return (None, False)
|
||||
|
||||
def decode_status(value):
|
||||
drive_status_codes = {
|
||||
15: "Reversed",
|
||||
14: "REM. Freq",
|
||||
13: "REM. R/S",
|
||||
12: "Reverse operation command",
|
||||
11: "Forward operation command",
|
||||
10: "Brake release signal",
|
||||
9: "-(Not used)",
|
||||
8: "Drive stopped.",
|
||||
7: "DC Braking",
|
||||
6: "Speed reached",
|
||||
5: "Decelerating",
|
||||
4: "Accelerating",
|
||||
3: "Fault trip",
|
||||
2: "Operating in reverse direction",
|
||||
1: "Operating in forward direction",
|
||||
0: "Stopped",
|
||||
|
||||
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
|
||||
|
||||
def pad_to_x(n,x):
|
||||
while len(n) < x:
|
||||
n = [0] + n
|
||||
return n
|
||||
|
||||
def status_codes(n):
|
||||
|
||||
status_array = int_to_bits(n,16)
|
||||
status_low = {
|
||||
0: "Stopped;",
|
||||
1: "Operating in Forward;",
|
||||
2: "Operating in Reverse;",
|
||||
3: "DC operating;"
|
||||
}
|
||||
# List to collect the active bits' descriptions
|
||||
active_bits = []
|
||||
|
||||
# Iterate through each bit
|
||||
for bit, description in drive_status_codes.items():
|
||||
if value & (1 << bit): # Check if the bit is set
|
||||
active_bits.append(description)
|
||||
|
||||
return ", ".join(active_bits)
|
||||
status_mid = {
|
||||
0: "",
|
||||
1: "Speed searching;",
|
||||
2: "Accelerating;",
|
||||
3: "At constant speed;",
|
||||
4: "Decelerating;",
|
||||
5: "Decelerating to stop;",
|
||||
6: "H/W OCS;",
|
||||
7: "S/W OCS;",
|
||||
8: "Dwell operating;"
|
||||
}
|
||||
status_high = {
|
||||
0: "Normal state",
|
||||
4: "Warning occurred",
|
||||
8: "Fault occurred"
|
||||
}
|
||||
values = {
|
||||
0: 8,
|
||||
1: 4,
|
||||
2: 2,
|
||||
3: 1
|
||||
}
|
||||
|
||||
stats_low = status_array[12:]
|
||||
stats_mid = status_array[8:12]
|
||||
stats_high = status_array[:4]
|
||||
low = 0
|
||||
mid = 0
|
||||
high = 0
|
||||
for x in range(4):
|
||||
if stats_low[x] == 1:
|
||||
low = low + values[x]
|
||||
if stats_mid[x] == 1:
|
||||
mid = mid + values[x]
|
||||
if stats_high[x] == 1:
|
||||
high = high + values[x]
|
||||
|
||||
return status_low[low] + " " + status_mid[mid] + ' ' + status_high[high]
|
||||
|
||||
def fault_code_a(n):
|
||||
|
||||
fault_code_array = int_to_bits(n,16)
|
||||
|
||||
""" fault = {
|
||||
0: "OCT",
|
||||
1: "OVT",
|
||||
2: "EXT-A",
|
||||
3: "EST",
|
||||
4: "COL",
|
||||
5: "GFT",
|
||||
6: "OHT",
|
||||
7: "ETH",
|
||||
8: "OLT",
|
||||
9: "Reserved",
|
||||
10: "EXT-B",
|
||||
11: "EEP",
|
||||
12: "FAN",
|
||||
13: "POT",
|
||||
14: "IOLT",
|
||||
15: "LVT"
|
||||
} """
|
||||
fault = {
|
||||
0: "Overload Trip",
|
||||
1: "Underload Trip",
|
||||
2: "Inverter Overload Trip",
|
||||
3: "E-Thermal Trip",
|
||||
4: "Ground Fault Trip",
|
||||
5: "Output Image Trip",
|
||||
6: "Inmput Imaging Trip",
|
||||
7: "Reserved",
|
||||
8: "Reserved",
|
||||
9: "NTC Trip",
|
||||
10: "Overcurrent Trip",
|
||||
11: "Overvoltage Trip",
|
||||
12: "External Trip",
|
||||
13: "Arm Short",
|
||||
14: "Over Heat Trip",
|
||||
15: "Fuse Open Trip"
|
||||
}
|
||||
|
||||
faults = []
|
||||
counter = 15
|
||||
for x in range(16):
|
||||
if fault_code_array[x] == 1:
|
||||
faults = [fault[counter]] + faults
|
||||
counter = counter - 1
|
||||
return ' '.join(faults)
|
||||
|
||||
def fault_code_b(n):
|
||||
|
||||
fault_code_array = int_to_bits(n,8)
|
||||
|
||||
""" fault = {
|
||||
0: "COM",
|
||||
1: "Reserved",
|
||||
2: "NTC",
|
||||
3: "REEP",
|
||||
4: "OC2",
|
||||
5: "NBR",
|
||||
6: "SAFA",
|
||||
7: "SAFB"
|
||||
} """
|
||||
fault = {
|
||||
0: "Reserved",
|
||||
1: "Reserved",
|
||||
2: "Reserved",
|
||||
3: "FAN Trip",
|
||||
4: "Reserved",
|
||||
5: "Reserved",
|
||||
6: "Pre PID Fail",
|
||||
7: "Bad contact at basic I/O board",
|
||||
8: "External Brake Trip",
|
||||
9: "No Motor Trip",
|
||||
10: "Bad Option Card",
|
||||
11: "Reserved",
|
||||
12: "Reserved",
|
||||
13: "Reserved",
|
||||
14: "Pre Over Heat Trip",
|
||||
15: "Reserved"
|
||||
}
|
||||
|
||||
faults = []
|
||||
counter = 7
|
||||
for x in range(8):
|
||||
if fault_code_array[x] == 1:
|
||||
faults = [fault[counter]] + faults
|
||||
counter = counter - 1
|
||||
return ' '.join(faults)
|
||||
|
||||
|
||||
|
||||
def convert_int(measure, value):
|
||||
|
||||
@@ -458,42 +584,6 @@ def convert_int(measure, value):
|
||||
96: "Mft cubed/d"
|
||||
}
|
||||
|
||||
drive_fault_a_codes = {
|
||||
0: "Overload Trip",
|
||||
1: "Underload Trip",
|
||||
2: "Inverter Overload Trip",
|
||||
3: "E-Thermal Trip",
|
||||
4: "Ground Fault Trip",
|
||||
5: "Output Image Trip",
|
||||
6: "Inmput Imaging Trip",
|
||||
7: "Reserved",
|
||||
8: "Reserved",
|
||||
9: "NTC Trip",
|
||||
10: "Overcurrent Trip",
|
||||
11: "Overvoltage Trip",
|
||||
12: "External Trip",
|
||||
13: "Arm Short",
|
||||
14: "Over Heat Trip",
|
||||
15: "Fuse Open Trip"
|
||||
}
|
||||
drive_fault_b_codes = {
|
||||
0: "Reserved",
|
||||
1: "Reserved",
|
||||
2: "Reserved",
|
||||
3: "FAN Trip",
|
||||
4: "Reserved",
|
||||
5: "Reserved",
|
||||
6: "Pre PID Fail",
|
||||
7: "Bad contact at basic I/O board",
|
||||
8: "External Brake Trip",
|
||||
9: "No Motor Trip",
|
||||
10: "Bad Option Card",
|
||||
11: "Reserved",
|
||||
12: "Reserved",
|
||||
13: "Reserved",
|
||||
14: "Pre Over Heat Trip",
|
||||
15: "Reserved"
|
||||
}
|
||||
|
||||
|
||||
piflow = {
|
||||
@@ -501,9 +591,6 @@ def convert_int(measure, value):
|
||||
"totalizer_2_units": totalizer_codes.get(value, "Invalid Code"),
|
||||
"totalizer_3_units": totalizer_codes.get(value, "Invalid Code"),
|
||||
"flow_unit": flow_codes.get(value, "Invalid Code"),
|
||||
"fault_a": drive_fault_a_codes.get(value, "Invalid Code"),
|
||||
"fault_b": drive_fault_b_codes.get(value, "Invalid Code"),
|
||||
"run_status": decode_status(value)
|
||||
}
|
||||
|
||||
return piflow.get(measure, "Invalid Tag")
|
||||
|
||||
Reference in New Issue
Block a user