コード例 #1
0
ファイル: Simulator.py プロジェクト: tstaig/ACS
    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()
コード例 #2
0
ファイル: Simulator.py プロジェクト: tstaig/ACS
    def cleanUp(self):
        '''
        Overriden from baseclass.
        '''
        BaseSimulator.cleanUp(self)
        self.event_dispatcher.destroy()

        #possible for developers to configure cleanUp method
        #for the simulated component.
        _execute(self._get_name(), "cleanUp", [self],
                 getCompLocalNS(self._get_name()))

        ComponentLifecycle.cleanUp(self)
        removeComponent(self._get_name())
コード例 #3
0
ファイル: Simulator.py プロジェクト: ACS-Community/ACS
 def cleanUp(self):
     '''
     Overriden from baseclass.
     '''
     BaseSimulator.cleanUp(self)
     self.event_dispatcher.destroy()
     
     #possible for developers to configure cleanUp method
     #for the simulated component.
     _execute(self._get_name(),
              "cleanUp",
              [self],
              getCompLocalNS(self._get_name()))
     
     ComponentLifecycle.cleanUp(self)
     removeComponent(self._get_name())
コード例 #4
0
ファイル: Simulator.py プロジェクト: ACS-Community/ACS
    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()
コード例 #5
0
ファイル: Simulator.py プロジェクト: ydc92546169/ACS
    def invoke(self, args, moreargs):
        '''
        This method has all calls to CORBA operations forwarded to it.  Definitly
        needs to be overriden in subclasses.

        Parameters:
        - args is a tuple of arguments...args[0] is the calling methods name and
        everything that follows were parameters to the calling method.
        - moreargs is a dictionary of yet more arguments

        Returns: Anything

        Raises: Anything
        '''
        if _DEBUG == 1:
            print self.__name, " - DynamicImplementation.invoke(", args, moreargs, ")"

        #simulate doing something with callbacks...
        tryCallbackParams(args[1:], self)
        
        meth_name = args[0]

        if len(args)>1:
            #create the list of args
            args = list(args[1:])
            #append the component reference
            args.append(self)
            new_args = args
            
        else:
            new_args = [self]
        self.recorder.record(meth_name, new_args[:-1])
        
        local_namespace = getCompLocalNS(self._get_name())
        local_namespace['SELF'] = self    
        return _execute(self._get_name(),
                        meth_name,
                        new_args,
                        local_namespace)