示例#1
0
文件: Consumer.py 项目: tstaig/ACS
    def push_structured_event(self, event):
        '''
        CORBA method that is invoked by suppliers. If a correct handler function
        has been provided via the addSubscription method, this is used to do
        something useful with the event. Furthermore, if the user-defined handler
        function raises an exception, this is caught and the processEvent
        method is also invoked. Otherwise, its up to the developer to subclass
        Consumer and override the processEvent method.

        Parameters: event is a CosNotification.StructuredEvent
        
        Returns: Nothing

        Raises: Nothing
        '''
        #For HLA/ITS - to be removed later!
        comp_name = "Unknown"
        if get_integration_logs(self.channelName) == 1:
            try:
                comp_name = self.component.getName()
            except:
                pass

            self.logger.logNotice(
                "Receiver:" + comp_name + ", Event Type:" +
                event.header.fixed_header.event_type.type_name)

        if self.__buffer.qsize() >= self.__buffer_max_size / 2:
            log = LOG_NC_ReceiverTooSlow()
            log.setClientName(comp_name)
            log.setEventName(event.header.fixed_header.event_type.type_name)
            log.setChannelName(self.channelName)
            if self.__buffer.full():
                log.setNumEventsDiscarded(1)
                self.__buffer.get(block=False)
            log.log()

        self.__buffer.put(event, block=False)
示例#2
0
    def push_structured_event (self, event):
        '''
        CORBA method that is invoked by suppliers. If a correct handler function
        has been provided via the addSubscription method, this is used to do
        something useful with the event. Furthermore, if the user-defined handler
        function raises an exception, this is caught and the processEvent
        method is also invoked. Otherwise, its up to the developer to subclass
        Consumer and override the processEvent method.

        Parameters: event is a CosNotification.StructuredEvent
        
        Returns: Nothing

        Raises: Nothing
        '''
        #For HLA/ITS - to be removed later!
        comp_name = "Unknown"
        if get_integration_logs(self.channelName)==1:
            try:
                comp_name = self.component.getName()
            except:
                pass
                
            self.logger.logNotice("Receiver:" + comp_name +
                                  ", Event Type:" + event.header.fixed_header.event_type.type_name)

        if self.__buffer.qsize() >= self.__buffer_max_size / 2:
            log = LOG_NC_ReceiverTooSlow()
            log.setClientName(comp_name)
            log.setEventName(event.header.fixed_header.event_type.type_name)
            log.setChannelName(self.channelName)
            if self.__buffer.full():
                log.setNumEventsDiscarded(1);
                self.__buffer.get(block=False)
            log.log()
        
        self.__buffer.put(event, block=False)
示例#3
0
        event_descrip = CORBA.Any(CORBA.TypeCode(CORBA.id(event_descrip)),
                                  event_descrip)

        # create the structured event
        se = CosNotification.StructuredEvent(header,
                                             new_list,
                                             event_descrip)
        
        # publish the event
        try:
            self.sppc.push_structured_event(se)
            if event_callback != None:
                event_callback.eventSent(simple_data)

            #For HLA/ITS - to be removed later!
            if get_integration_logs(self.channelName)==1:
                try:
                    comp_name = self.component.getName()
                except:
                    comp_name = "Unknown"
                    
                self.logger.logNotice("Publisher:" + comp_name +
                                      ", Event Type:" + type_name)
            
            self.count = self.count + 1
        except (CORBA.COMM_FAILURE, CORBA.TRANSIENT):
            #Notify Service is down
            if event_callback != None:
                event_callback.eventDropped(simple_data)

        except (CORBA.OBJECT_NOT_EXIST, CORBA.BAD_OPERATION) as e:
示例#4
0
                                               long(time_stamp.value),
                                               long(self.count))
        event_descrip = CORBA.Any(CORBA.TypeCode(CORBA.id(event_descrip)),
                                  event_descrip)

        # create the structured event
        se = CosNotification.StructuredEvent(header, new_list, event_descrip)

        # publish the event
        try:
            self.sppc.push_structured_event(se)
            if event_callback != None:
                event_calback.eventSent(simple_data)

            #For HLA/ITS - to be removed later!
            if get_integration_logs(self.channelName) == 1:
                try:
                    comp_name = self.component.getName()
                except:
                    comp_name = "Unknown"

                self.logger.logNotice("Publisher:" + comp_name +
                                      ", Event Type:" + type_name)

            self.count = self.count + 1
        except (CORBA.COMM_FAILURE, CORBA.TRANSIENT):
            #Notify Service is down
            if event_callback != None:
                event_calback.eventDropped(simple_data)

        except Exception, e: