From 1fbdae751cfc7f1ad2acc36239ad10f46e745928 Mon Sep 17 00:00:00 2001 From: MarieMih Date: Thu, 16 Nov 2023 23:56:44 +0300 Subject: [PATCH] HW4_second_com --- equipment/device.py | 2 +- equipment/turtle_device.py | 7 ++++--- noblocking_turtle_shell.py | 5 ++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/equipment/device.py b/equipment/device.py index ffecccf..ea4739a 100644 --- a/equipment/device.py +++ b/equipment/device.py @@ -58,7 +58,7 @@ class Device(ABC): def action_descriptors(self) -> Collection[ActionDescriptor]: pass - @abstractmethod + #@abstractmethod def __getitem__(self, trait_name: str) -> Optional[Any]: """Return logical state of trait `trait_name`.""" pass diff --git a/equipment/turtle_device.py b/equipment/turtle_device.py index 4a11ada..a8f8c7b 100644 --- a/equipment/turtle_device.py +++ b/equipment/turtle_device.py @@ -1,10 +1,11 @@ from turtle import Turtle -from device import SynchronyDevice +from typing import Any +from equipment.device import SynchronyDevice import inspect class TurtleDevice(SynchronyDevice): - def open(): + def open(self): super().open() return Turtle() @@ -46,7 +47,7 @@ class TurtleDevice(SynchronyDevice): pass -print(TurtleDevice.action_descriptors()) +#print(TurtleDevice.action_descriptors()) diff --git a/noblocking_turtle_shell.py b/noblocking_turtle_shell.py index e71021a..34e2302 100644 --- a/noblocking_turtle_shell.py +++ b/noblocking_turtle_shell.py @@ -2,6 +2,7 @@ import cmd import threading from threading import Thread from threading import Event +import time from queue import Queue @@ -16,11 +17,12 @@ class TurtleDeviceThread(threading.Thread): new_message = self.queue.get() print("Name and args of action are {}".format(new_message)) #self.device. + #time.sleep(30) self.queue.task_done() if self.event.is_set(): break def __message_thread__(self): - thread = Thread(target = __message_processing__, daemon=True) + thread = Thread(target = self.__message_processing__, daemon=True) thread.start() # TODO(Homework 4) \end @@ -38,6 +40,7 @@ class NoBlockingTurtleShell(cmd.Cmd): def __init__(self, turtle_thread: TurtleDeviceThread): # TODO(Homework 4) \begin + super(NoBlockingTurtleShell, self).__init__() turtle_thread.__message_thread__() # TODO(Homework 4) \end