from turtle import Turtle from typing import Any from equipment.device import SynchronyDevice import inspect import types class TurtleDevice(SynchronyDevice): def open(self): super().open() return Turtle() @staticmethod def close (exam): super().close() del exam @property def trait_descriptors(self): l = list() for i in inspect.getmembers(TurtleDevice): if not (i[0].startswith("__") or i[0].startswith("_")) and not inspect.isfunction(i[1]): l.append(i[0]) return l @property def action_descriptors(self): l = list() #print(inspect.getmembers(TurtleDevice)) #for i in dir(TurtleDevice): # # print(type(getattr(TurtleDevice(), i))=='method') # # if not i.startswith("__") and type(getattr(TurtleDevice(), i)) == types.MethodType: # if not i.startswith("__") and inspect.isroutine(inspect.getattr_static(TurtleDevice, i)): # sig = inspect.signature(getattr(TurtleDevice, i)) # l.append(i + " " + str(sig)) #return l for i in inspect.getmembers(TurtleDevice): # print(type(getattr(TurtleDevice, i))) # print(type(getattr(TurtleDevice(), i))=='method') if not (i[0].startswith("__") or i[0].startswith("_")) and inspect.isfunction(i[1]): sig = inspect.signature(getattr(TurtleDevice, i[0])) l.append(i[0]+str(sig)) return l 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 #t = TurtleDevice() #print(t.trait_descriptors)