def initialize(self): ''' Overriden from baseclass. ''' #we can finally access the IR location and call BaseSimulator's #constructor...dynamically changing this object's inheritance BaseSimulator.__init__(self, self.ir, self._get_name()) # # hook to call the initialize method from the Simulation Server # simServer = getSimProxy(self._get_name(), self.ir).server_handler # print 'Getting initialize method from server' # initMethodDict = simServer.getMethod('initialize2') # if initMethodDict != None: # print 'executing initialize method: ' + str(initMethodDict['Value']) # _executeDict(initMethodDict, [self], getCompLocalNS(self._get_name())) #add myself to the global lis addComponent(self._get_name(), self) # Create a BehaviorProxy, passing the interface repository id to the # constructor. proxy = getSimProxy(self._get_name(), self.ir) #possible for developers to configure an initialize method #for the simulated component. ns = getCompLocalNS(self._get_name()) ns['SELF'] = self _execute(self._get_name(), "initialize", [self], ns) #create the object used to dispatch events automatically self.event_dispatcher = EventDispatcher(self) #handle attributes that should NOT be generically simulated self.__setupSpecialCases()
EVENT_COUNTER[ifr_id] = EVENT_COUNTER[ifr_id] + 1 if __name__ == "__main__": ec_cons = Consumer("ALMA_EVENT_CHANNEL") ec_cons.addSubscription("temperatureDataBlockEvent", eventHandler) ec_cons.addSubscription("XmlEntityStruct", eventHandler) ec_cons.consumerReady() erc_cons = Consumer("ALMA_EVENT_RESPONSE_CHANNEL") erc_cons.addSubscription("Duration", eventHandler) erc_cons.consumerReady() #create the event dispatcher ed = EventDispatcher(FAKE_MS) #sleep for awhile giving consumers a chance to process a few #events sleep(60) ec_cons.disconnect() erc_cons.disconnect() ed.destroy() if EVENT_COUNTER["IDL:alma/FRIDGE/temperatureDataBlockEvent:1.0"] > 10: print "Good...enough temperatureDataBlockEvent's" else: print "Bad...not enough temperatureDataBlockEvent's" if EVENT_COUNTER["IDL:alma/xmlentity/XmlEntityStruct:1.0"] > 4: