Skip to content

Commit

Permalink
fixup update_time and state init
Browse files Browse the repository at this point in the history
  • Loading branch information
falkecarlsen committed Aug 14, 2024
1 parent 09633b3 commit c18bd6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions py_driver/driver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import threading
from dataclasses import dataclass, field
from dataclasses import dataclass
from datetime import timedelta, datetime
from time import sleep, time
from typing import Optional
Expand Down Expand Up @@ -64,7 +64,7 @@ class ClaireState:
Stream_inflow_duty: Optional[int] = None
Stream_outflow_duty: Optional[int] = None
dynamic: Optional[bool] = None
last_update: datetime = datetime.now()
last_update: datetime = datetime.now() - timedelta(hours=1)

def __init__(self, state):
self.dynamic = None
Expand Down Expand Up @@ -130,10 +130,9 @@ class ClaireDevice:
"""

def __init__(self, port):
self.state = None
self.device = port
self.heartbeat = time() # last time device was alive
self.busy = True # initially unknown, therefore busy
self.state = ClaireState()
# read timeout in secs, 1 should be sufficient

# exclusive only available on posix-like systems, assumes mac-env is posix-like
Expand Down Expand Up @@ -163,6 +162,7 @@ def __init__(self, port):
self.check_version()

print(f'{TAG} Device initialized. Getting initial state...')
self.heartbeat = time() # last time device was alive
self.update_state()

def alive(self):
Expand Down

0 comments on commit c18bd6a

Please sign in to comment.