本文整理汇总了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)
示例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)
示例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)
示例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)
示例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
示例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))