def __init__(self, compname, supported_interfaces): ''' Constructor. Paramters: - compname is the name of the component being simulated - supported_interfaces is an optional list of IDL interfaces which this particular component supports. Returns: Nothing Raises: ??? ''' #superclass constructor BaseRepresentation.__init__(self, compname) #setup the logger self.__logger = getLogger(str(CDB) + "(" + compname + ")") #bool value showing whether the CDB entry exists or not self.exists = 0 #determine if this simulated component allows inheritence allows_inheritence = self.handleCDB(compname) if allows_inheritence: #look at all supported IDL interfaces first self.handleInterfaces(supported_interfaces) #add this individual component one more time to override #anything defined in the subinterfaces. this is necessary if #the component is of type IDL:alma/x/y:1.0 and this entry #exists in the CDB self.handleCDB(compname)
def __init__ (self, compname, supported_interfaces): ''' Constructor. Paramters: - compname is the name of the component being simulated - supported_interfaces is an optional list of IDL interfaces which this particular component supports. Returns: Nothing Raises: ??? ''' #superclass constructor BaseRepresentation.__init__(self, compname) #setup the logger self.__logger = getLogger(str(CDB) + "(" + compname + ")") #bool value showing whether the CDB entry exists or not self.exists=0 #determine if this simulated component allows inheritence allows_inheritence = self.handleCDB(compname) if allows_inheritence: #look at all supported IDL interfaces first self.handleInterfaces(supported_interfaces) #add this individual component one more time to override #anything defined in the subinterfaces. this is necessary if #the component is of type IDL:alma/x/y:1.0 and this entry #exists in the CDB self.handleCDB(compname)
def __init__(self, compname, comp_type): BaseRepresentation.__init__(self, compname) self.comp_type = comp_type self.simulator = None self.client = PySimpleClient() self.simulator = None try: self.simulator = self.client.getDefaultComponent("IDL:alma/ACSSim/Simulator:1.0") except NoDefaultComponentEx, ex: # fine, no Simulator Server component defined in the CDB pass
def __init__(self, compname): ''' Constructor. Parameters: - compname is the name of the component to be simulated Returns: Nothing Raises: Nothing ''' BaseRepresentation.__init__(self, compname)
def __init__(self, compname, comp_type): BaseRepresentation.__init__(self, compname) self.comp_type = comp_type self.simulator = None self.client = PySimpleClient() self.simulator = None try: self.simulator = self.client.getDefaultComponent( "IDL:alma/ACSSim/Simulator:1.0") except NoDefaultComponentEx, ex: # fine, no Simulator Server component defined in the CDB pass
def getMethod(self, method_name): ''' Overriden from baseclass. ''' #sanity check self._BaseRepresentation__checkCompRef() if BaseRepresentation.getMethod(self, method_name)!=None: return BaseRepresentation.getMethod(self, method_name) #list of return values return_list = [] #create the temporary dictionary that will be returned later ret_val = { 'Value':[ "None" ], 'Timeout': getStandardTimeout()} #Check the method's name to see if it's really a RW attribute #This will be true if the method name starts with "_set_". If this #happens to be the case, just return if method_name.rfind("_set_") == 0: self.__logger.logDebug("Write attribute:" + method_name) return ret_val #Check to see if the method's name begins with "_get_". If this is #true, this is a special case because we do not have to worry #about inout and out parameters. elif method_name.rfind("_get_") == 0: self.__handleReadAttribute(method_name, return_list) #Since we've gotten this far, we must now examine the IFR to determine #which return values (if any) and exceptions this method can #return/throw. else: self.__handleNormalMethod(method_name, return_list) #convert the list of typecodes to a list of real implementations of #those types #if the methodname was not found... if len(return_list) == 0: self.__logger.logWarning("Failed to dynamically generate '" + method_name + "' because the IFR" + " was missing information on the method!") raise CORBA.NO_RESOURCES() ret_val['Value'] = self.__typecodesToObjects(return_list) self.__logger.logDebug("retVal looks like:" + method_name + " " + str(ret_val)) return ret_val
def getMethod(self, method_name): mdict = BaseRepresentation.getMethod(self, method_name) if mdict != None: return mdict if self.simulator == None: return None try: mdict = {} method_info = self.simulator.getMethod(self.compname, method_name) mdict['Timeout'] = method_info.timeout mdict['Value'] = method_info.code return mdict except NoSuchMethodEx: pass try: mdict = {} method_info = self.simulator.getMethodIF(self.comp_type, method_name) mdict['Timeout'] = method_info.timeout mdict['Value'] = method_info.code return mdict except NoSuchMethodEx: return None
def getMethod(self, method_name): ''' Overriden from baseclass. ''' #sanity check self._BaseRepresentation__checkCompRef() if BaseRepresentation.getMethod(self, method_name) != None: return BaseRepresentation.getMethod(self, method_name) #list of return values return_list = [] #create the temporary dictionary that will be returned later ret_val = {'Value': ["None"], 'Timeout': getStandardTimeout()} #Check the method's name to see if it's really a RW attribute #This will be true if the method name starts with "_set_". If this #happens to be the case, just return if method_name.rfind("_set_") == 0: self.__logger.logDebug("Write attribute:" + method_name) return ret_val #Check to see if the method's name begins with "_get_". If this is #true, this is a special case because we do not have to worry #about inout and out parameters. elif method_name.rfind("_get_") == 0: self.__handleReadAttribute(method_name, return_list) #Since we've gotten this far, we must now examine the IFR to determine #which return values (if any) and exceptions this method can #return/throw. else: self.__handleNormalMethod(method_name, return_list) #convert the list of typecodes to a list of real implementations of #those types #if the methodname was not found... if len(return_list) == 0: self.__logger.logWarning("Failed to dynamically generate '" + method_name + "' because the IFR" + " was missing information on the method!") raise CORBA.NO_RESOURCES() ret_val['Value'] = self.__typecodesToObjects(return_list) self.__logger.logDebug("retVal looks like:" + method_name + " " + str(ret_val)) return ret_val
def __init__ (self, compname, comptype): ''' Constructor ''' #superclass constructor BaseRepresentation.__init__(self, compname) self.__logger = getLogger(str(Dynamic) + "(" + compname + ")") #--------------------------------------------------------------------- def __initialize(args): ''' Fake lifecycle method. ''' self.__logger.logDebug("Simulated lifecyle method") return def __cleanUp(args): ''' Fake lifecycle method. ''' self.__logger.logDebug("Simulated lifecyle method") return self.setMethod('initialize', {'Timeout' : 0.0, 'Value' : __initialize} ) self.setMethod('cleanUp', {'Timeout' : 0.0, 'Value' : __cleanUp} ) #save the IDL type self.comp_type = comptype self.__interf = IR.lookup_id(comptype) try: self.__interf = self.__interf._narrow(CORBA.InterfaceDef) self.__interf = self.__interf.describe_interface() except Exception, ex: self.__logger.logCritical("Cannot find a definition for '" + self.comp_type + "' components!") raise CORBA.NO_RESOURCES()
def __init__(self, compname, comptype): ''' Constructor ''' #superclass constructor BaseRepresentation.__init__(self, compname) self.__logger = getLogger(str(Dynamic) + "(" + compname + ")") #--------------------------------------------------------------------- def __initialize(args): ''' Fake lifecycle method. ''' self.__logger.logDebug("Simulated lifecyle method") return def __cleanUp(args): ''' Fake lifecycle method. ''' self.__logger.logDebug("Simulated lifecyle method") return self.setMethod('initialize', {'Timeout': 0.0, 'Value': __initialize}) self.setMethod('cleanUp', {'Timeout': 0.0, 'Value': __cleanUp}) #save the IDL type self.comp_type = comptype self.__interf = IR.lookup_id(comptype) try: self.__interf = self.__interf._narrow(CORBA.InterfaceDef) self.__interf = self.__interf.describe_interface() except Exception, ex: self.__logger.logCritical("Cannot find a definition for '" + self.comp_type + "' components!") raise CORBA.NO_RESOURCES()
def __init__(self): BaseRepresentation.__init__(self, "HELLOWORLD1") self.setMethod("displayMessage", {"nonempty": "constructor"})
def __init__(self): BaseRepresentation.__init__(self, "HELLOWORLD1") self.setMethod("displayMessage", { "nonempty" : "constructor"})