当前位置: 首页>>代码示例>>Python>>正文


Python CommandResponseInstrumentProtocol.got_data方法代码示例

本文整理汇总了Python中mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol.got_data方法的典型用法代码示例。如果您正苦于以下问题:Python CommandResponseInstrumentProtocol.got_data方法的具体用法?Python CommandResponseInstrumentProtocol.got_data怎么用?Python CommandResponseInstrumentProtocol.got_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol的用法示例。


在下文中一共展示了CommandResponseInstrumentProtocol.got_data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: got_data

# 需要导入模块: from mi.core.instrument.instrument_protocol import CommandResponseInstrumentProtocol [as 别名]
# 或者: from mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol import got_data [as 别名]
 def got_data(self, data):
     """
     Callback for receiving new data from the device.
     """
     if self.get_current_state() == SBE37ProtocolState.DIRECT_ACCESS:
         # direct access mode
         if len(data) > 0:
             #mi_logger.debug("SBE37Protocol._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.
         CommandResponseInstrumentProtocol.got_data(self, data)
 
         # If in streaming mode, process the buffer for samples to publish.
         cur_state = self.get_current_state()
         if cur_state == SBE37ProtocolState.AUTOSAMPLE:
             if SBE37_NEWLINE in self._linebuf:
                 lines = self._linebuf.split(SBE37_NEWLINE)
                 self._linebuf = lines[-1]
                 for line in lines:
                     self._extract_sample(line)                    
开发者ID:newbrough,项目名称:marine-integrations,代码行数:35,代码来源:driver.py

示例2: got_data

# 需要导入模块: from mi.core.instrument.instrument_protocol import CommandResponseInstrumentProtocol [as 别名]
# 或者: from mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol import got_data [as 别名]
 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.
         CommandResponseInstrumentProtocol.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)                    
开发者ID:newbrough,项目名称:marine-integrations,代码行数:27,代码来源:driver.py

示例3: got_data

# 需要导入模块: from mi.core.instrument.instrument_protocol import CommandResponseInstrumentProtocol [as 别名]
# 或者: from mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol import got_data [as 别名]
    def got_data(self, data):
        """
        Callback for receiving new data from the device.
        """
        # Call the superclass to update line and promp buffers.
        CommandResponseInstrumentProtocol.got_data(self, data)

        # If in streaming mode, process the buffer for samples to publish.
        cur_state = self.get_current_state()
        if cur_state == SBE16ProtocolState.AUTOSAMPLE:
            if SBE16_NEWLINE in self._linebuf:
                lines = self._linebuf.split(SBE16_NEWLINE)
                self._linebuf = lines[-1]
                for line in lines:
                    self._extract_sample(line)                    
开发者ID:tgiguere,项目名称:marine-integrations,代码行数:17,代码来源:driver.py

示例4: got_data

# 需要导入模块: from mi.core.instrument.instrument_protocol import CommandResponseInstrumentProtocol [as 别名]
# 或者: from mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol import got_data [as 别名]
    def got_data(self, paPacket):
        """
        Callback for receiving new data from the device.
        """
        length = paPacket.get_data_size()
        data = paPacket.get_data()
        tempLength = len(data)

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

            # If in streaming mode, process the buffer for samples to publish.
            cur_state = self.get_current_state()
            if cur_state == SBE16ProtocolState.AUTOSAMPLE:
                if SBE16_NEWLINE in self._linebuf:
                    lines = self._linebuf.split(SBE16_NEWLINE)
                    self._linebuf = lines[-1]
                    for line in lines:
                        sample = self._extract_sample(SBE16DataParticle, SAMPLE_REGEX,
                                             line)
开发者ID:swarbhanu,项目名称:marine-integrations,代码行数:24,代码来源:driver.py

示例5: got_data

# 需要导入模块: from mi.core.instrument.instrument_protocol import CommandResponseInstrumentProtocol [as 别名]
# 或者: from mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol import got_data [as 别名]
    def got_data(self, paPacket):
        """ 
        Callback for receiving new data from the device.
        The port agent object fires this when data is received
        @param paPacket The packet of data that was received
        """
        paLength = paPacket.get_data_size()
        paData = paPacket.get_data()

        if self.get_current_state() == PARProtocolState.DIRECT_ACCESS:
            # direct access mode
            if paLength > 0:
                log.debug("SatlanticPARInstrumentProtocol.got_data(): <" + paData + ">")
                if self._driver_event:
                    self._driver_event(DriverAsyncEvent.DIRECT_ACCESS, paData)
                    # TODO: what about logging this as an event?
            return

        if paLength > 0:
            CommandResponseInstrumentProtocol.got_data(self, paData)

            # If we are streaming, process the line buffer for samples, but it
            # could have header stuff come out if you just got a break!
            if (
                self._protocol_fsm.get_current_state() == PARProtocolState.AUTOSAMPLE
                or self._protocol_fsm.get_current_state() == PARProtocolState.POLL
            ):
                if self.eoln in self._linebuf:
                    lines = self._linebuf.split(self.eoln)
                    for line in lines:
                        if SAMPLE_REGEX.match(line):
                            self._last_data_timestamp = time.time()

                            # construct and publish data particles
                            self._extract_sample(SatlanticPARDataParticle, SAMPLE_REGEX, line)

                            self._linebuf = self._linebuf.replace(line + self.eoln, "")  # been processed
开发者ID:swarbhanu,项目名称:marine-integrations,代码行数:39,代码来源:driver.py

示例6: got_data

# 需要导入模块: from mi.core.instrument.instrument_protocol import CommandResponseInstrumentProtocol [as 别名]
# 或者: from mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol import got_data [as 别名]
 def got_data(self, data):
     CommandResponseInstrumentProtocol.got_data(self, data)
     log.info("!!!!!!!!!!!!!!!!!!!got_data: data = %s" % str(data))
开发者ID:newbrough,项目名称:marine-integrations,代码行数:5,代码来源:driver.py


注:本文中的mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol.got_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。