Trial_hw3

This commit is contained in:
MarieMih 2023-11-13 21:25:16 +03:00
parent 8200022240
commit 74f2be739d
2 changed files with 48 additions and 4 deletions

View File

@ -1,9 +1,8 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import Optional, Collection, Any from typing import Optional, Collection, Any
from abc import abstractmethod from abc import ABC, abstractmethod
from enum import IntEnum from enum import IntEnum
from abc import ABC, abstractmethod
class DeviceLifecycleState(IntEnum): class DeviceLifecycleState(IntEnum):
INIT = 0 INIT = 0

View File

@ -1,8 +1,53 @@
from turtle import Turtle from turtle import Turtle
from controls.device import SynchronyDevice from device import SynchronyDevice
import inspect
class TurtleDevice(SynchronyDevice): class TurtleDevice(SynchronyDevice):
pass # TODO(Homework #3)
def open():
super().open()
return Turtle()
def close (self):
super().close()
del(self)
@property
def trait_descriptors(self):
print("This is all class attributes: ", l)
for i in dir(Turtle):
if not i.startswith("__") and inspect.ismethod(Turtle.i)==False:
print(i, '\n')
@property
def action_descriptors(self):
print("This is all class methods: \n")
for i in dir(Turtle):
if not i.startswith("__") and inspect.ismethod(Turtle.i)==True:
sig = inspect.signature(Turtle.i)
print(i, str(sig), '\n')
def execute(self, action_name: str, *args, **kwargs):
"""Execute action `action_name`, using `args` and `kwargs` as action argument."""
pass
def read(self, trait_name: str):
"""Read physical state of trait `trait_name` from device."""
pass
def write(self, trait_name: str, value: Any) -> bool:
"""Pass `value` to trait `trait_name` of device."""
pass
def invalidate(self, trait_name: str):
"""Invalidate logical state of trait `trait_name`"""
pass
print(TurtleDevice.action_descriptors())