fix: Use consistent Modbus register addresses
- Fixed random register generation in signals endpoint - Each pump now gets consistent register blocks (40011-40014, 40021-40024, etc.) - Addresses now follow logical pattern for industrial SCADA systems
This commit is contained in:
parent
c33f970b1c
commit
769f64ad40
|
|
@ -571,11 +571,15 @@ async def get_signals():
|
||||||
])
|
])
|
||||||
|
|
||||||
# Modbus signals for this pump
|
# Modbus signals for this pump
|
||||||
|
# Use consistent register addresses for each pump type
|
||||||
|
pump_num = int(pump_id.split('_')[1]) # Extract pump number from PUMP_001, PUMP_002, etc.
|
||||||
|
base_register = 40000 + (pump_num * 10) # Each pump gets 10 registers starting at 40001, 40011, etc.
|
||||||
|
|
||||||
signals.extend([
|
signals.extend([
|
||||||
{
|
{
|
||||||
"name": f"Station_{station_id}_Pump_{pump_id}_Setpoint",
|
"name": f"Station_{station_id}_Pump_{pump_id}_Setpoint",
|
||||||
"protocol": "modbus",
|
"protocol": "modbus",
|
||||||
"address": f"400{random.randint(1, 99)}",
|
"address": f"{base_register + 1}",
|
||||||
"data_type": "Integer",
|
"data_type": "Integer",
|
||||||
"current_value": f"{random.randint(0, 500)} Hz (x10)",
|
"current_value": f"{random.randint(0, 500)} Hz (x10)",
|
||||||
"quality": "Good",
|
"quality": "Good",
|
||||||
|
|
@ -584,7 +588,7 @@ async def get_signals():
|
||||||
{
|
{
|
||||||
"name": f"Station_{station_id}_Pump_{pump_id}_ActualSpeed",
|
"name": f"Station_{station_id}_Pump_{pump_id}_ActualSpeed",
|
||||||
"protocol": "modbus",
|
"protocol": "modbus",
|
||||||
"address": f"400{random.randint(1, 99)}",
|
"address": f"{base_register + 2}",
|
||||||
"data_type": "Integer",
|
"data_type": "Integer",
|
||||||
"current_value": f"{random.randint(0, 500)} Hz (x10)",
|
"current_value": f"{random.randint(0, 500)} Hz (x10)",
|
||||||
"quality": "Good",
|
"quality": "Good",
|
||||||
|
|
@ -593,7 +597,7 @@ async def get_signals():
|
||||||
{
|
{
|
||||||
"name": f"Station_{station_id}_Pump_{pump_id}_Power",
|
"name": f"Station_{station_id}_Pump_{pump_id}_Power",
|
||||||
"protocol": "modbus",
|
"protocol": "modbus",
|
||||||
"address": f"400{random.randint(1, 99)}",
|
"address": f"{base_register + 3}",
|
||||||
"data_type": "Integer",
|
"data_type": "Integer",
|
||||||
"current_value": f"{random.randint(0, 750)} kW (x10)",
|
"current_value": f"{random.randint(0, 750)} kW (x10)",
|
||||||
"quality": "Good",
|
"quality": "Good",
|
||||||
|
|
@ -602,7 +606,7 @@ async def get_signals():
|
||||||
{
|
{
|
||||||
"name": f"Station_{station_id}_Pump_{pump_id}_Temperature",
|
"name": f"Station_{station_id}_Pump_{pump_id}_Temperature",
|
||||||
"protocol": "modbus",
|
"protocol": "modbus",
|
||||||
"address": f"400{random.randint(1, 99)}",
|
"address": f"{base_register + 4}",
|
||||||
"data_type": "Integer",
|
"data_type": "Integer",
|
||||||
"current_value": f"{random.randint(20, 35)} °C",
|
"current_value": f"{random.randint(20, 35)} °C",
|
||||||
"quality": "Good",
|
"quality": "Good",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue