Skip to content

Commit

Permalink
Improve and fix call signatures.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjsr committed Feb 12, 2025
1 parent 73e0355 commit 54cea26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TimingDevices/TimingDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def begin_reading( self ) -> TimingDeviceCommand:
self.send_command(startDeviceCommand)
return startDeviceCommand

async def get_status( self, onStatusCallback: Callable[[DecoderStatusMessage], None] | None = None ) -> TimingDeviceCommand:
async def get_status( self, onStatusCallback: Callable[[DecoderStatusMessage], None] | None = None ) -> TimingDeviceCommand[DecoderStatusMessage]:
getStatusCommand = self.create_command(TimingDeviceCommand.COMMAND_STATUS)
self.send_command(getStatusCommand)
return getStatusCommand
Expand Down
14 changes: 10 additions & 4 deletions TimingDevices/UltraTimingDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import datetime
import socket
import time
from typing import cast
from typing import cast, Callable

from Log import getLogger
from LogQueue import LogQueue
Expand Down Expand Up @@ -85,9 +85,9 @@ async def on_connect(self, msg: UltraConnectConfirmationMessage) -> bool:

if self.__on_connect_action_start_if_stopped:
getStatusResult = await self.get_status()
if getStatusResult.response is not None:
if getStatusResult.response.isStopped():
self.begin_reading()
response: UltraDecoderStatusMessage = getStatusResult.response
if response is not None and response.readStatus == False:
self.begin_reading()


except Exception as e:
Expand Down Expand Up @@ -137,6 +137,12 @@ def setTime(self) -> bool:
return False
return True

async def get_status( self, onStatusCallback: Callable[[UltraDecoderStatusMessage], None] | None = None ) -> UltraGetStatusCommand:
getStatusCommand = super().get_status(onStatusCallback)
ultraStatusCommand = cast(UltraGetStatusCommand, getStatusCommand)
return ultraStatusCommand


def process_messages(self) -> bool:
message: DecoderMessage | None = self.peek_last_message()
if message is None:
Expand Down

0 comments on commit 54cea26

Please sign in to comment.