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()
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()) # Don't do it because is done in __init__ # # 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()
from Acssim.Servants.Representations.Dynamic import Dynamic from Acssim.Goodies import addComponent class MockComponent(object): def __init__(self, name): self.name = name def _get_name(self): return self.name def activateOffShoot(self, os): return os addComponent("TEST_RPS_1", MockComponent("TEST_RPS_1")) addComponent("HELLOWORLD1", MockComponent("HELLOWORLD1")) addComponent("BADCOMPONENT", MockComponent("BADCOMPONENT")) if __name__ == "__main__": print "--TEST_RPS_1--" dyn = Dynamic("TEST_RPS_1", "IDL:alma/RampedPS/RampedPowerSupply:1.0") #from RampedPowerSupply print "dyn.getMethod('startRamping'):", dyn.getMethod('startRamping') #from PowerSuppy print "dyn.getMethod('_get_readback'):", dyn.getMethod('_get_readback') print print "--HELLOWORLD1--" dyn = Dynamic("HELLOWORLD1", "IDL:alma/acsexmplHelloWorld/HelloWorld:1.0")
# @(#) $Id$ #------------------------------------------------------------------------------ __revision__ = "@(#) $Id$" ''' Tests Dynamic ''' import CORBA from Acssim.Servants.Representations.Dynamic import Dynamic from Acssim.Goodies import addComponent class MockComponent: def __init__(self, name): self.name = name def _get_name(self): return self.name def activateOffShoot(self, os): return os addComponent("TEST_RPS_1", MockComponent("TEST_RPS_1")) addComponent("HELLOWORLD1", MockComponent("HELLOWORLD1")) addComponent("BADCOMPONENT", MockComponent("BADCOMPONENT")) if __name__=="__main__": print "--TEST_RPS_1--" dyn = Dynamic("TEST_RPS_1", "IDL:alma/RampedPS/RampedPowerSupply:1.0") #from RampedPowerSupply print "dyn.getMethod('startRamping'):", dyn.getMethod('startRamping') #from PowerSuppy print "dyn.getMethod('_get_readback'):", dyn.getMethod('_get_readback') print print "--HELLOWORLD1--" dyn = Dynamic("HELLOWORLD1", "IDL:alma/acsexmplHelloWorld/HelloWorld:1.0")
''' from Acssim.Servants.Representations.BehaviorProxy import BehaviorProxy from Acssim.Goodies import addComponent import CORBA class MockComponent(object): def __init__(self, name): self.name = name def _get_name(self): return self.name def activateOffShoot(self, os): return os if __name__=="__main__": bp = BehaviorProxy("TEST_RPS_1") print "dir(TEST_RPS_1):", dir(bp) print addComponent("TEST_RPS_1", MockComponent("TEST_RPS_1")) try: print "bp.getMethod('on'):", bp.getMethod('on') print "Good!" except: print "Bad...cannot get 'on' method after a MockComponent has been created" print try: print "bp.getMethod('nonexistentMethod'):", bp.getMethod('nonexistentMethod') print "Bad!" except CORBA.NO_RESOURCES, temp_ex: print "Good...got a NO_RESOURCES exception for a nonexistent method" print try: