|
| 1 | +# Avalia alarmes de processo com base em PVs e SPs. |
| 2 | + |
| 3 | +for slave in ModbusPal.getModbusSlaves(): |
| 4 | + if slave is None: |
| 5 | + continue |
| 6 | + |
| 7 | + name = slave.getName() |
| 8 | + regs = slave.getHoldingRegisters() |
| 9 | + coils = slave.getCoils() |
| 10 | + inputs = slave.getDiscreteInputs() |
| 11 | + |
| 12 | + if name == "SubestacaoEletrica": |
| 13 | + pv_voltage = regs.getValue(0) |
| 14 | + sp_voltage = regs.getValue(1) |
| 15 | + pv_load = regs.getValue(5) |
| 16 | + sp_load = regs.getValue(6) |
| 17 | + |
| 18 | + high_v = 1 if pv_voltage > (sp_voltage + 12) else 0 |
| 19 | + low_v = 1 if pv_voltage < (sp_voltage - 12) else 0 |
| 20 | + overload = 1 if pv_load > sp_load else 0 |
| 21 | + alarm_active = 1 if (high_v or low_v or overload) else 0 |
| 22 | + |
| 23 | + coils.setValue(2, high_v) |
| 24 | + coils.setValue(3, low_v) |
| 25 | + coils.setValue(4, overload) |
| 26 | + inputs.setValue(1, alarm_active) |
| 27 | + |
| 28 | + elif name == "CentrifugaLinhaA": |
| 29 | + pv_vib = regs.getValue(2) |
| 30 | + sp_vib = regs.getValue(3) |
| 31 | + pv_temp = regs.getValue(4) |
| 32 | + sp_temp = regs.getValue(5) |
| 33 | + rpm = regs.getValue(0) |
| 34 | + sp_rpm = regs.getValue(1) |
| 35 | + |
| 36 | + vib_alarm = 1 if pv_vib > sp_vib else 0 |
| 37 | + temp_alarm = 1 if pv_temp > sp_temp else 0 |
| 38 | + rpm_alarm = 1 if abs(rpm - sp_rpm) > 250 else 0 |
| 39 | + alarm_active = 1 if (vib_alarm or temp_alarm or rpm_alarm) else 0 |
| 40 | + |
| 41 | + coils.setValue(2, vib_alarm) |
| 42 | + coils.setValue(3, temp_alarm) |
| 43 | + inputs.setValue(1, alarm_active) |
| 44 | + |
| 45 | + elif name == "DigestorPolpa": |
| 46 | + pv_temp = regs.getValue(0) |
| 47 | + sp_temp = regs.getValue(1) |
| 48 | + pv_press = regs.getValue(2) |
| 49 | + sp_press = regs.getValue(3) |
| 50 | + pv_level = regs.getValue(4) |
| 51 | + sp_level = regs.getValue(5) |
| 52 | + |
| 53 | + temp_alarm = 1 if abs(pv_temp - sp_temp) > 8 else 0 |
| 54 | + press_alarm = 1 if abs(pv_press - sp_press) > 2 else 0 |
| 55 | + level_alarm = 1 if abs(pv_level - sp_level) > 12 else 0 |
| 56 | + alarm_active = 1 if (temp_alarm or press_alarm or level_alarm) else 0 |
| 57 | + |
| 58 | + coils.setValue(2, temp_alarm) |
| 59 | + coils.setValue(3, press_alarm) |
| 60 | + inputs.setValue(1, alarm_active) |
0 commit comments