1+ import copy
2+
13from iocbuilder import Device , AutoSubstitution
24from iocbuilder .arginfo import *
35
4- from iocbuilder .modules .areaDetector import AreaDetector , _NDPluginBase
6+ from iocbuilder .modules .asyn import Asyn , AsynPort
7+ from iocbuilder .modules .ADCore import ADCore , NDPluginBaseTemplate , includesTemplates , makeTemplateInstance
58
69class AdPython (Device ):
710 '''Library dependencies for adPython'''
8- Dependencies = (AreaDetector ,)
11+ Dependencies = (ADCore ,)
912 # Device attributes
1013 LibFileList = ['adPython' ]
1114 DbdFileList = ['adPythonPlugin' ]
1215 AutoInstantiate = True
1316
17+ @includesTemplates (NDPluginBaseTemplate )
1418class _adPythonBase (AutoSubstitution ):
1519 '''This plugin Works out the area and tip of a sample'''
1620 TemplateFile = "adPythonPlugin.template"
17-
18- class adPythonPlugin (_NDPluginBase ):
21+
22+ class adPythonPlugin (AsynPort ):
1923 """This plugin creates an adPython object"""
24+ # This tells xmlbuilder to use PORT instead of name as the row ID
25+ UniqueName = "PORT"
26+
2027 _SpecificTemplate = _adPythonBase
2128 Dependencies = (AdPython ,)
2229
23- def __init__ (self , classname , BUFFERS = 50 , MEMORY = 0 , ** args ):
24- # Init the superclass (_NDPluginBase)
25- self .__super .__init__ (** args )
30+ def __init__ (self , classname , PORT , NDARRAY_PORT , QUEUE = 5 , BLOCK = 0 , NDARRAY_ADDR = 0 , BUFFERS = 50 , MEMORY = 0 , ** args ):
31+ # Init the superclass (AsynPort)
32+ self .__super .__init__ (PORT )
33+ # Update the attributes of self from the commandline args
34+ self .__dict__ .update (locals ())
35+ # Make an instance of our template
36+ makeTemplateInstance (self ._SpecificTemplate , locals (), args )
2637 # Init the python classname specific class
2738 class _tmp (AutoSubstitution ):
2839 ModuleName = adPythonPlugin .ModuleName
2940 TrueName = "_adPython%s" % classname
3041 TemplateFile = "adPython%s.template" % classname
31- _tmp (** filter_dict (args , _tmp .ArgInfo .Names ()))
42+ _tmpargs = copy .deepcopy (args )
43+ _tmpargs ['PORT' ] = PORT
44+ _tmp (** filter_dict (_tmpargs , _tmp .ArgInfo .Names ()))
3245 # Store the args
3346 self .filename = "$(ADPYTHON)/adPythonApp/scripts/adPython%s.py" % classname
34- self .__dict__ . update ( locals ())
47+ self .Configure = 'adPythonPluginConfigure'
3548
3649 def Initialise (self ):
3750 print '# %(Configure)s(portName, filename, classname, queueSize, ' \
@@ -42,11 +55,16 @@ def Initialise(self):
4255 '%(MEMORY)d)' % self .__dict__
4356
4457 # __init__ arguments
45- ArgInfo = _NDPluginBase .ArgInfo + makeArgInfo (__init__ ,
58+ ArgInfo = _SpecificTemplate .ArgInfo + makeArgInfo (__init__ ,
4659 classname = Choice ('Predefined python class to use' , [
4760 "Morph" , "Focus" , "Template" , "BarCode" , "Transfer" , "Mitegen" ,
4861 "Circle" , "DataMatrix" , "Gaussian2DFitter" , "PowerMean" ,
4962 "MxSampleDetect" ]),
63+ PORT = Simple ('Port name for the plugin' , str ),
64+ QUEUE = Simple ('Input array queue size' , int ),
65+ BLOCK = Simple ('Blocking callbacks?' , int ),
66+ NDARRAY_PORT = Ident ('Input array port' , AsynPort ),
67+ NDARRAY_ADDR = Simple ('Input array port address' , int ),
5068 BUFFERS = Simple ('Maximum number of NDArray buffers to be created for '
5169 'plugin callbacks' , int ),
5270 MEMORY = Simple ('Max memory to allocate, should be maxw*maxh*nbuffer '
0 commit comments