From 8200022240fdbb980b51773384ceecd777c57f8e Mon Sep 17 00:00:00 2001 From: MarieMih Date: Thu, 26 Oct 2023 19:34:03 +0300 Subject: [PATCH] commit_new --- .gitignore | 3 +++ controls/device.py | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9874c37..f06ca8c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ __pycache__/ *.py[cod] *$py.class +#visual studio +.vs/ + # C extensions *.so diff --git a/controls/device.py b/controls/device.py index d126692..33945c0 100644 --- a/controls/device.py +++ b/controls/device.py @@ -2,8 +2,13 @@ from dataclasses import dataclass from typing import Optional, Collection, Any from abc import abstractmethod -class DeviceLifecycleState: - pass # TODO(Homework #3) +from enum import IntEnum +from abc import ABC, abstractmethod + +class DeviceLifecycleState(IntEnum): + INIT = 0 + OPEN = 1 + CLOSE = 2 class DevaceError(Exception): @@ -33,8 +38,8 @@ class ActionDescriptor: info: Optional[str] = None -class Device: - # TODO(Homework #3) +class Device(ABC): + _state = DeviceLifecycleState.INIT @property @@ -43,10 +48,14 @@ class Device: def close(self): self._state = DeviceLifecycleState.CLOSE - + + @property + @abstractmethod def trait_descriptors(self) -> Collection[TraitDescriptor]: pass - + + @property + @abstractmethod def action_descriptors(self) -> Collection[ActionDescriptor]: pass