def __apply_configuration__(self): #check the DB is self-consistent! from DAQSys.DecoderClass import validate validate(self.__db__()) #only override input locations (if I was asked to) self.overrideIfRequired(setup=True) #if I was asked to override the locations, I must also propagate this to the configurables, not just the db #so I must setup the configurables. If someone else wants different properties, #they should have edited the database, not edited the configurables directly, or they should #add a postConfigAction to do what they want to change #if ODIN is active, then configure the EventTimeDecoder from DAQSys.DecoderClass import decodersForBank if self.getProp("EvtClockBank") is not None and len( self.getProp("EvtClockBank")): SetEvtClock(self.getProp("EvtClockBank"), self.__db__()) if not self.isPropertySet("Sequencer") and not self.getProp( "DataOnDemand"): #then I'm not doing anything else return if self.isPropertySet("Sequencer") and self.getProp("DataOnDemand"): raise ValueError( "You asked me to do the DoD service *and* a sequencer, but it only make sense to do one of these" ) #if DoD, check that no active algs want to write to the same location... for k, v in self.__db__().items(): if not v.Active: continue thedecoder = v.setup() #either add to a sequence, respecting dependencies if self.isPropertySet("Sequencer"): if self.getProp("Sequencer").Members is None: self.getProp("Sequencer").Members = [] if thedecoder in self.getProp("Sequencer").Members: continue #add any requirements first! for alg in v.listRequired(): depdecoder = self.__db__()[alg].setup() if depdecoder not in self.getProp("Sequencer").Members: self.getProp("Sequencer").Members.append(depdecoder) self.getProp("Sequencer").Members.append(thedecoder) #or DoD if self.getProp("DataOnDemand"): if DataOnDemandSvc().AlgMap is None or type( DataOnDemandSvc().AlgMap) is not dict: DataOnDemandSvc().AlgMap = {} locs = v.listOutputs() for loc in locs: if loc in DataOnDemandSvc().AlgMap: testname = DataOnDemandSvc().AlgMap[loc] if type(testname) is not str: testname = testname.getFullName() #handle default names! if testname == v.FullName or ( testname.split("/")[0] == testname.split("/")[-1] and v.FullName.split("/")[0] == v.FullName.split("/")[-1] and testname.split("/")[0] == v.FullName.split("/")[0]): print "# WARNING: something else configured a decoder already, " + loc + " " + testname else: raise AttributeError( "At least two different active algs want to write to the same location. Check your DecoderDB! " + loc + ": " + testname + " & " + v.FullName) DataOnDemandSvc().AlgMap[loc] = thedecoder
publicTools=[thednames[3]], conf=test_db) d4 = Decoder(thednames[3], active=False, properties={"OutputLevel": 6}, inputs={"Members": ["Blah", "Blah"]}, conf=test_db) d5 = Decoder(thednames[4], active=True, properties={"OutputLevel": 6}, inputs={"Members": None}, conf=test_db) validate(test_db) #some simple checks! if d1.isInputSettable(): raise ValueError("Input is found to be settable! 1") if not d2.isInputSettable(): raise ValueError("Input not found to be settable! 2") if not d3.isInputSettable(): raise ValueError("Input not found to be settable! 3") if not d4.isInputSettable(): raise ValueError("Input not found to be settable! 45") if not d5.isInputSettable():
import DAQSys from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import validate validate(DecoderDB) for k, v in DecoderDB.items(): if v.Active: if len(v.listInputs()) == 0: raise ValueError("Decoder " + v.FullName + " input location unknown.") for l in v.listInputs(): if not len(l): raise ValueError("Zero length default for input " + v.FullName) if len(v.listOutputs()) == 0: raise ValueError("Decoder " + v.FullName + " output location unknown.") for l in v.listOutputs(): if not len(l): raise ValueError("Zero length default for output " + v.FullName) if len(v.Banks) == 0: raise ValueError("Decoder " + v.FullName + " banks unknown.") #check the setup for k, decoder in DecoderDB.items(): if decoder.Active: decoder.setup() #add an alg already into the DoD with the default name dec = None