cleanup: removed useless commandregister (and fix some missing import)

Thu, 28 Feb 2008 18:35:23 +0100

author
David Douard <david.douard@logilab.fr>
date
Thu, 28 Feb 2008 18:35:23 +0100
changeset 61
6ecb0fd8c129
parent 60
5297b8707096
child 62
486a480d196b

cleanup: removed useless commandregister (and fix some missing import)

pygpibtoolkit/HP3562A/HP356X.py file | annotate | diff | comparison | revisions
pygpibtoolkit/gpibcontroller.py file | annotate | diff | comparison | revisions
pygpibtoolkit/pygpib.py file | annotate | diff | comparison | revisions
--- a/pygpibtoolkit/HP3562A/HP356X.py	Thu Feb 28 18:16:52 2008 +0100
+++ b/pygpibtoolkit/HP3562A/HP356X.py	Thu Feb 28 18:35:23 2008 +0100
@@ -1,20 +1,13 @@
 #
-from pygpibtoolkit.pygpib import CommandRegister, Constants, Command
+from pygpibtoolkit.pygpib import Constants, Command
 from pygpibtoolkit.pygpib import BoolValue, IntValue, FloatValue
 from pygpibtoolkit.pygpib import PercentageValue, FrequencyValue, DurationValue
+from pygpibtoolkit.pygpib import VoltageValue
 from pygpibtoolkit.pygpib import EnumValue, StringValue
-from pygpibtoolkit.pygpib import Mode, ModeCommand
+from pygpibtoolkit.pygpib import Mode, ModeCommand, Flag
 
 from pygpibtoolkit.gpibcontroller import AbstractGPIBDevice, deviceRegister
 
-class Register(CommandRegister):
-    """
-    Register class for every HPIB commands for the HP356X devices
-    """
-# we must instanciate the singleton for registering mechanism to work
-Register()     
-
-
 #####################
 # HP3562A constants and command set
 # **VERY INCOMPLETE**
@@ -249,10 +242,7 @@
 class HP356XDevice(AbstractGPIBDevice):
     _accepts = ["HP3562A", "HP3563A"]
     _idn = "ID?"
-    _cmd_register = Register
     def manage_srq(self, statusbyte):
         print "Managing SRQ", statusbyte
         
-    
-    
 deviceRegister.register_manager(HP356XDevice)
--- a/pygpibtoolkit/gpibcontroller.py	Thu Feb 28 18:16:52 2008 +0100
+++ b/pygpibtoolkit/gpibcontroller.py	Thu Feb 28 18:35:23 2008 +0100
@@ -31,7 +31,6 @@
 class AbstractGPIBDevice(object):
     __metaclass__ = AbstractGPIBDeviceMetaclass
     _accepts = []
-    _cmd_register = None # to be defined in son classes
 
     @classmethod
     def accepts(cls, idn):
--- a/pygpibtoolkit/pygpib.py	Thu Feb 28 18:16:52 2008 +0100
+++ b/pygpibtoolkit/pygpib.py	Thu Feb 28 18:35:23 2008 +0100
@@ -42,57 +42,6 @@
         self.name = name
         self.description = description
         self.condition = condition
-
-class CommandRegister(object):
-    _instances = {}
-    _registered_type = None #Command
-    def __new__(cls):
-        # implements a singleton *per class*
-        if cls.__name__ not in cls._instances:
-            if cls._registered_type is None:
-                cls._registered_type = Command
-            instance = super(CommandRegister, cls).__new__(cls)
-            instance.registry = {}
-            cls._instances[cls.__name__] = instance
-        return cls._instances[cls.__name__]
-
-    @classmethod
-    def add(cls, registered_cls):
-        for registry in cls._instances.values():
-            if registry.__module__ == registered_cls.__module__:
-                break
-        else:
-            return
-        
-        assert issubclass(registered_cls, registry._registered_type)
-        if registered_cls is registry._registered_type:
-            return
-
-        name = registered_cls.__name__
-        if name not in registry:
-            registry.registry[name] = registered_cls
-            
-    def __contains__(self, key):
-        return key in self.registry
-    def keys(self):
-        return self.registry.keys()
-    def items(self):
-        return self.registry.items()
-    def values(self):
-        return self.registry.values()
-    def __getitem__(self, key):
-        return self.registry[key]
-
-class MetaCommand(type):
-    """
-    Metaclass for HPIB command. Used to register all commands.
-    """
-    _commands = {}
-    def __init__(cls, name, bases, dct):
-        # called at class creation
-        super(MetaCommand, cls).__init__(name, bases, dct)
-        if name not in [ "AbstractCommand","Command"]:
-            CommandRegister().add(cls)
     
 class AbstractCommand(object):
     """
@@ -101,7 +50,6 @@
     This is actually a attribute descriptor, which should have
     AbstractGPIBDevice derived classes as owner.
     """
-    __metaclass__ = MetaCommand
     _readonly = True
     _init_value = None
     
@@ -255,6 +203,7 @@
 class Mode(AbstractValue):
     pass
 
+
 # TODO
 # class STATUS_BYTE(Constants):
 #     # IEEE 488.2 Status Byte constants

mercurial