From 74f2be739d8f5758e754682ec8b2d0561494af89 Mon Sep 17 00:00:00 2001 From: MarieMih Date: Mon, 13 Nov 2023 21:25:16 +0300 Subject: [PATCH] Trial_hw3 --- {controls => equipment}/device.py | 3 +- equipment/turtle_device.py | 49 +++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) rename {controls => equipment}/device.py (97%) diff --git a/controls/device.py b/equipment/device.py similarity index 97% rename from controls/device.py rename to equipment/device.py index 33945c0..ffecccf 100644 --- a/controls/device.py +++ b/equipment/device.py @@ -1,9 +1,8 @@ from dataclasses import dataclass from typing import Optional, Collection, Any -from abc import abstractmethod +from abc import ABC, abstractmethod from enum import IntEnum -from abc import ABC, abstractmethod class DeviceLifecycleState(IntEnum): INIT = 0 diff --git a/equipment/turtle_device.py b/equipment/turtle_device.py index 3ba251f..4a11ada 100644 --- a/equipment/turtle_device.py +++ b/equipment/turtle_device.py @@ -1,8 +1,53 @@ from turtle import Turtle -from controls.device import SynchronyDevice +from device import SynchronyDevice +import inspect 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()) +