# HG changeset patch # User David Douard # Date 1204220123 -3600 # Node ID 6ecb0fd8c129d5e2405a588b42bf4bbf9ca3c3c7 # Parent 5297b87070964c43ce02c1f31ba587bf9959cd0e cleanup: removed useless commandregister (and fix some missing import) diff -r 5297b8707096 -r 6ecb0fd8c129 pygpibtoolkit/HP3562A/HP356X.py --- 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) diff -r 5297b8707096 -r 6ecb0fd8c129 pygpibtoolkit/gpibcontroller.py --- 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): diff -r 5297b8707096 -r 6ecb0fd8c129 pygpibtoolkit/pygpib.py --- 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