dev free_fall
This commit is contained in:
parent
5e2fbae6aa
commit
65d931b92d
|
|
@ -457,6 +457,34 @@ class TecnaMarpossProvasetT3(ModbusComponent):
|
|||
self.log.debug(str(spec))
|
||||
for register, value in spec.items():
|
||||
self.write(register, value)
|
||||
# Override PR-/PR+ handling for Free Fall (Blockage) to write ABSOLUTE pressures
|
||||
if is_free_fall:
|
||||
try:
|
||||
pmin = _s.get("pressure_min", None)
|
||||
pmax = _s.get("pressure_max", None)
|
||||
# Sanity checks and auto-correct
|
||||
if pmin is not None and pmax is not None:
|
||||
try:
|
||||
pmin_v = float(pmin)
|
||||
pmax_v = float(pmax)
|
||||
if pmin_v > pmax_v:
|
||||
self.log.warning(f"Free Fall: pressure_min ({pmin_v}) > pressure_max ({pmax_v}); swapping values to maintain consistency")
|
||||
pmin_v, pmax_v = pmax_v, pmin_v
|
||||
pmin, pmax = pmin_v, pmax_v
|
||||
except Exception:
|
||||
pass
|
||||
# Write absolute values using relative pressure low-res format (23) and no gain
|
||||
if pmin is not None:
|
||||
self.write("PR- - Min pressure tolerance %", pmin, formatting=23, gain=1)
|
||||
self.log.info(f"Free Fall: wrote PR- (min final pressure) = {pmin} mbar (format 23)")
|
||||
if pmax is not None:
|
||||
self.write("PR+ - Max pressure tolerance % (P+)", pmax, formatting=23, gain=1)
|
||||
self.log.info(f"Free Fall: wrote PR+ (max final pressure) = {pmax} mbar (format 23)")
|
||||
except Exception as e:
|
||||
try:
|
||||
self.log.exception(f"Free Fall: failed to write absolute PR-/PR+ values: {e}")
|
||||
except Exception:
|
||||
pass
|
||||
pass
|
||||
|
||||
@db.connection_context()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user