From 65d931b92d7a504364da85a5952d9e3ef0d09d3f Mon Sep 17 00:00:00 2001 From: edo-neo Date: Wed, 15 Oct 2025 15:38:05 +0200 Subject: [PATCH] dev free_fall --- src/components/tecna_marposs_provaset_t3.py | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/components/tecna_marposs_provaset_t3.py b/src/components/tecna_marposs_provaset_t3.py index 6e2deb3..75b780c 100644 --- a/src/components/tecna_marposs_provaset_t3.py +++ b/src/components/tecna_marposs_provaset_t3.py @@ -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()