Beispiel #1
0
 def got_data(self, data):
     """
     Callback for receiving new data from the device.
     """
     if self.get_current_state() == ProtocolStates.DIRECT_ACCESS:
         # direct access mode
         if len(data) > 0:
             log.debug("mavs4InstrumentProtocol.got_data(): <" + data + ">") 
             if self._driver_event:
                 self._driver_event(DriverAsyncEvent.DIRECT_ACCESS, data)
                 # TODO: what about logging this as an event?
         return
     
     if len(data)>0:
         # Call the superclass to update line and prompt buffers.
         MenuInstrumentProtocol.got_data(self, data)
 
         # If in streaming mode, process the buffer for samples to publish.
         cur_state = self.get_current_state()
         if cur_state == ProtocolStates.AUTOSAMPLE:
             if INSTRUMENT_NEWLINE in self._linebuf:
                 lines = self._linebuf.split(INSTRUMENT_NEWLINE)
                 self._linebuf = lines[-1]
                 for line in lines:
                     self._extract_sample(line)  
    def got_data(self, data):
        """
        Callback for receiving new data from the device.
        """
        #if self.get_current_state() == State.DIRECT_ACCESS:
        #    # direct access mode
        #    if len(data) > 0:
        #        #mi_logger.debug("ooicoreInstrumentProtocol.got_data(): <" + data + ">")
        #        # check for echoed commands from instrument (TODO: this should only be done for telnet?)
        #        if len(self._sent_cmds) > 0:
        #            # there are sent commands that need to have there echoes filtered out
        #            oldest_sent_cmd = self._sent_cmds[0]
        #            if string.count(data, oldest_sent_cmd) > 0:
        #                # found a command echo, so remove it from data and delete the command form list
        #                data = string.replace(data, oldest_sent_cmd, "", 1)
        #                self._sent_cmds.pop(0)
        #        if len(data) > 0 and self._driver_event:
        #            self._driver_event(DriverAsyncEvent.DIRECT_ACCESS, data)
        #            # TODO: what about logging this as an event?
        #    return

        if len(data) > 0:
            # Call the superclass to update line and prompt buffers.
            MenuInstrumentProtocol.got_data(self, data)