HW4_second_com

This commit is contained in:
MarieMih 2023-11-16 23:56:44 +03:00
parent 7ec82f80d1
commit 1fbdae751c
3 changed files with 9 additions and 5 deletions

View File

@ -58,7 +58,7 @@ class Device(ABC):
def action_descriptors(self) -> Collection[ActionDescriptor]: def action_descriptors(self) -> Collection[ActionDescriptor]:
pass pass
@abstractmethod #@abstractmethod
def __getitem__(self, trait_name: str) -> Optional[Any]: def __getitem__(self, trait_name: str) -> Optional[Any]:
"""Return logical state of trait `trait_name`.""" """Return logical state of trait `trait_name`."""
pass pass

View File

@ -1,10 +1,11 @@
from turtle import Turtle from turtle import Turtle
from device import SynchronyDevice from typing import Any
from equipment.device import SynchronyDevice
import inspect import inspect
class TurtleDevice(SynchronyDevice): class TurtleDevice(SynchronyDevice):
def open(): def open(self):
super().open() super().open()
return Turtle() return Turtle()
@ -46,7 +47,7 @@ class TurtleDevice(SynchronyDevice):
pass pass
print(TurtleDevice.action_descriptors()) #print(TurtleDevice.action_descriptors())

View File

@ -2,6 +2,7 @@ import cmd
import threading import threading
from threading import Thread from threading import Thread
from threading import Event from threading import Event
import time
from queue import Queue from queue import Queue
@ -16,11 +17,12 @@ class TurtleDeviceThread(threading.Thread):
new_message = self.queue.get() new_message = self.queue.get()
print("Name and args of action are {}".format(new_message)) print("Name and args of action are {}".format(new_message))
#self.device. #self.device.
#time.sleep(30)
self.queue.task_done() self.queue.task_done()
if self.event.is_set(): if self.event.is_set():
break break
def __message_thread__(self): def __message_thread__(self):
thread = Thread(target = __message_processing__, daemon=True) thread = Thread(target = self.__message_processing__, daemon=True)
thread.start() thread.start()
# TODO(Homework 4) \end # TODO(Homework 4) \end
@ -38,6 +40,7 @@ class NoBlockingTurtleShell(cmd.Cmd):
def __init__(self, turtle_thread: TurtleDeviceThread): def __init__(self, turtle_thread: TurtleDeviceThread):
# TODO(Homework 4) \begin # TODO(Homework 4) \begin
super(NoBlockingTurtleShell, self).__init__()
turtle_thread.__message_thread__() turtle_thread.__message_thread__()
# TODO(Homework 4) \end # TODO(Homework 4) \end