From e38b9058276a8d6e627994c0d1a9cafa9e17854d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez-Gallego?= Date: Thu, 31 Aug 2023 17:30:25 +0000 Subject: [PATCH] Do not always set UNKNOWN if flag is empty --- python/lvmecp/dome.py | 3 +++ python/lvmecp/module.py | 3 --- python/lvmecp/safety.py | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/python/lvmecp/dome.py b/python/lvmecp/dome.py index 1f80177..7c725de 100644 --- a/python/lvmecp/dome.py +++ b/python/lvmecp/dome.py @@ -65,6 +65,9 @@ async def _update_internal(self): else: new_status |= self.flag.POSITION_UNKNOWN + if new_status.value == 0: + new_status = self.flag.__unknown__ + return new_status async def set_direction(self, open: bool): diff --git a/python/lvmecp/module.py b/python/lvmecp/module.py index 7252db6..8473248 100644 --- a/python/lvmecp/module.py +++ b/python/lvmecp/module.py @@ -87,9 +87,6 @@ async def update(self): log.warning(f"{self.name}: failed updating status: {err}") new_status = self.flag(self.flag.__unknown__) - if new_status.value == 0: - new_status = self.flag(self.flag.__unknown__) - # Only notify if the status has changed. if new_status != self.status: await self.notify_status(new_status) diff --git a/python/lvmecp/safety.py b/python/lvmecp/safety.py index 39c096c..351264d 100644 --- a/python/lvmecp/safety.py +++ b/python/lvmecp/safety.py @@ -38,6 +38,9 @@ async def _update_internal(self): if safety_status.local: new_status |= self.flag.LOCAL + if new_status.value == 0: + new_status = self.flag.__unknown__ + return new_status async def is_remote(self):