Skip to content

Commit

Permalink
added support for relative changes in position
Browse files Browse the repository at this point in the history
  • Loading branch information
pcruzparri committed Nov 14, 2023
1 parent 00f4daf commit f7c6446
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion yaqd_watchdog/_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def check(self) -> float:
self._remaining = self.timeout
self._last = time.time()
else:
self._remaining = max(0, self.timeout + (self._last - time.time()))
self._remaining = max(0.0, self.timeout + (self._last - time.time()))
return self._remaining


Expand Down Expand Up @@ -101,6 +101,20 @@ def trigger(self, checks: dict):
pass


@dataclass
class SetRelativeAction:
host: str
port: int
distance: float

def trigger(self, checks: dict):
try:
c = yaqc.Client(host=self.host, port=self.port)
c.set_relative(self.distance)
except:
pass


@dataclass
class SetIdentifierAction:
host: str
Expand Down
12 changes: 12 additions & 0 deletions yaqd_watchdog/watchdog.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ fields = [{"name"="host", "type"="string", "default"="localhost"},
{"name"="port", "type"="int"},
{"name"="position", "type"="float"}]

[[types]]
type = "record"
name = "set_relative"
fields = [{"name"="host", "type"="string", "default"="localhost"},
{"name"="port", "type"="int"},
{"name"="distance", "type"="float"}]

[[types]]
type = "record"
name = "set_identifier"
Expand Down Expand Up @@ -71,6 +78,11 @@ type = "map"
values = "set_position"
default = {}

[config.set_relative_actions]
type = "map"
values = "set_relative"
default = {}

[config.set_identifier_actions]
type = "map"
values = "set_identifier"
Expand Down

0 comments on commit f7c6446

Please sign in to comment.