本文整理汇总了Python中mi.core.instrument.instrument_fsm.InstrumentFSM.get_current_state方法的典型用法代码示例。如果您正苦于以下问题:Python InstrumentFSM.get_current_state方法的具体用法?Python InstrumentFSM.get_current_state怎么用?Python InstrumentFSM.get_current_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.core.instrument.instrument_fsm.InstrumentFSM
的用法示例。
在下文中一共展示了InstrumentFSM.get_current_state方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Protocol
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
########################################################################
# Unknown handlers.
########################################################################
def _handler_unknown_enter(self, *args, **kwargs):
"""
Enter unknown state.
"""
# Tell driver superclass to send a state change event.
# Superclass will query the state.
self._driver_event(DriverAsyncEvent.STATE_CHANGE)
def _handler_unknown_exit(self, *args, **kwargs):
"""
Exit unknown state.
"""
pass
def _handler_unknown_discover(self, *args, **kwargs):
"""
Discover current state; can be COMMAND or AUTOSAMPLE.
@retval (next_state, result), (ProtocolState.COMMAND or
State.AUTOSAMPLE, None) if successful.
@throws InstrumentTimeoutException if the device cannot be woken.
@throws InstrumentStateException if the device response does not correspond to
an expected state.
"""
timeout = kwargs.get('timeout', TIMEOUT)
next_state = None
result = None
current_state = self._protocol_fsm.get_current_state()
log.debug("///////////////////// in handler_unknown_discover: current state is ",current_state)
if current_state == ProtocolState.AUTOSAMPLE:
result = ResourceAgentState.STREAMING
elif current_state == ProtocolState.COMMAND:
result = ResourceAgentState.IDLE
elif current_state == ProtocolState.UNKNOWN:
# Wakeup the device with timeout if passed.
delay = 0.5
log.debug("############## TIMEOUT = " + str(timeout))
prompt = self._wakeup(timeout=timeout, delay=delay)
prompt = self._wakeup(timeout)
logging = self._is_logging(timeout=timeout)
if logging == True:
next_state = ProtocolState.AUTOSAMPLE
result = ResourceAgentState.STREAMING
elif logging == False:
next_state = ProtocolState.COMMAND
result = ResourceAgentState.IDLE
else:
raise InstrumentStateException('Unknown state.')
print "//////////////////// on exit from handler_unknown_discover: next_state is ",next_state
return (next_state, result)
示例2: SingleConnectionInstrumentDriver
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
@param timeout=timeout Optional command timeout.
@retval Current device state.
@raises InstrumentTimeoutException if could not wake device.
@raises InstrumentStateException if command not allowed in current state or if
device state not recognized.
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.DISCOVER, DriverEvent.DISCOVER, *args, **kwargs)
def get_resource_capabilities(self, current_state=True, *args, **kwargs):
"""
Return driver commands and parameters.
@param current_state True to retrieve commands available in current
state, otherwise reutrn all commands.
@retval list of AgentCapability objects representing the drivers
capabilities.
@raises NotImplementedException if not implemented by subclass.
"""
if self._protocol:
return self._protocol.get_resource_capabilities(current_state)
else:
return [[], []]
def get_resource_state(self, *args, **kwargs):
"""
Return the current state of the driver.
@retval str current driver state.
@raises NotImplementedException if not implemented by subclass.
"""
connection_state = self._connection_fsm.get_current_state()
if connection_state == DriverConnectionState.CONNECTED:
return self._protocol.get_current_state()
else:
return connection_state
def get_resource(self, *args, **kwargs):
"""
Retrieve device parameters.
@param args[0] DriverParameter.ALL or a list of parameters to retrive.
@retval parameter : value dict.
@raises InstrumentParameterException if missing or invalid get parameters.
@raises InstrumentStateException if command not allowed in current state
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.GET, DriverEvent.GET, *args, **kwargs)
def set_resource(self, *args, **kwargs):
"""
Set device parameters.
@param args[0] parameter : value dict of parameters to set.
@param timeout=timeout Optional command timeout.
@raises InstrumentParameterException if missing or invalid set parameters.
@raises InstrumentTimeoutException if could not wake device or no response.
@raises InstrumentProtocolException if set command not recognized.
@raises InstrumentStateException if command not allowed in current state.
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.SET, DriverEvent.SET, *args, **kwargs)
def execute_resource(self, resource_cmd, *args, **kwargs):
示例3: SatlanticPARInstrumentProtocol
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
###################################################################
# Helpers
###################################################################
def _wakeup(self, timeout):
"""There is no wakeup sequence for this instrument"""
pass
def _update_params(self, *args, **kwargs):
"""Fetch the parameters from the device, and update the param dict.
@param args Unused
@param kwargs Takes timeout value
@throws InstrumentProtocolException
@throws InstrumentTimeoutException
"""
mi_logger.debug("Updating parameter dict")
old_config = self._param_dict.get_config()
self.get_config()
new_config = self._param_dict.get_config()
if (new_config != old_config) and (None not in old_config.values()):
self._driver_event(DriverAsyncEvent.CONFIG_CHANGE)
def _send_reset(self, timeout=10):
"""Send a reset command out to the device
@throw InstrumentTimeoutException
@throw InstrumentProtocolException
@todo handle errors correctly here, deal with repeats at high sample rate
"""
write_delay = 0.2
mi_logger.debug("Sending reset chars")
if self._protocol_fsm.get_current_state() == PARProtocolState.COMMAND_MODE:
return InstErrorCode.OK
while True:
self._do_cmd_no_resp(Command.RESET, timeout=timeout,
write_delay=write_delay)
time.sleep(RESET_DELAY)
if self._confirm_autosample_mode():
break
def _send_stop(self, timeout=10):
"""Send a stop command out to the device
@retval return InstErrorCode.OK for success or no-op, error code on
failure
@throw InstrumentTimeoutException
@throw InstrumentProtocolException
@todo handle errors correctly here, deal with repeats at high sample rate
"""
write_delay = 0.2
mi_logger.debug("Sending stop chars")
if self._protocol_fsm.get_current_state() == PARProtocolState.COMMAND_MODE:
return InstErrorCode.OK
while True:
self._do_cmd_no_resp(Command.STOP, timeout=timeout,
write_delay=write_delay)
if self._confirm_poll_mode():
return
def _send_break(self, timeout=10):
示例4: VadcpProtocol
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
self._protocol_fsm = InstrumentFSM(ProtocolState, ProtocolEvent,
None, None)
# UNKNOWN
self._protocol_fsm.add_handler(ProtocolState.UNKNOWN,
ProtocolEvent.INITIALIZE,
self._handler_initialize)
# COMMAND_MODE
self._protocol_fsm.add_handler(ProtocolState.COMMAND_MODE,
ProtocolEvent.GET_LAST_ENSEMBLE,
self._handler_command_get_latest_sample)
self._protocol_fsm.add_handler(ProtocolState.COMMAND_MODE,
ProtocolEvent.GET_METADATA,
self._handler_command_get_metadata)
self._protocol_fsm.add_handler(ProtocolState.COMMAND_MODE,
ProtocolEvent.RUN_RECORDER_TESTS,
self._handler_command_run_recorder_tests)
self._protocol_fsm.add_handler(ProtocolState.COMMAND_MODE,
ProtocolEvent.RUN_ALL_TESTS,
self._handler_command_run_all_tests)
self._protocol_fsm.add_handler(ProtocolState.COMMAND_MODE,
ProtocolEvent.START_AUTOSAMPLE,
self._handler_command_autosample)
# AUTOSAMPLE_MODE
self._protocol_fsm.add_handler(ProtocolState.AUTOSAMPLE_MODE,
ProtocolEvent.STOP_AUTOSAMPLE,
self._handler_autosample_stop)
self._protocol_fsm.start(ProtocolState.UNKNOWN)
def execute_init_protocol(self, *args, **kwargs):
"""
"""
return self._protocol_fsm.on_event(ProtocolEvent.INITIALIZE,
*args, **kwargs)
def execute_get_latest_sample(self, *args, **kwargs):
"""
"""
return self._protocol_fsm.on_event(ProtocolEvent.GET_LAST_ENSEMBLE,
*args, **kwargs)
def execute_get_metadata(self, *args, **kwargs):
"""
"""
return self._protocol_fsm.on_event(ProtocolEvent.GET_METADATA,
*args, **kwargs)
def execute_run_recorder_tests(self, *args, **kwargs):
"""
"""
return self._protocol_fsm.on_event(ProtocolEvent.RUN_RECORDER_TESTS,
*args, **kwargs)
def execute_run_all_tests(self, *args, **kwargs):
"""
"""
return self._protocol_fsm.on_event(ProtocolEvent.RUN_ALL_TESTS,
*args, **kwargs)
################
# State handlers
################
def _handler_initialize(self, *args, **kwargs):
"""
Determines initial protocol state according to instrument's state
"""
next_state = None
result = None
# TODO determine the state. For now, assume command mode
self._driver_event(DriverAsyncEvent.STATE_CHANGE)
next_state = ProtocolState.COMMAND_MODE
return (next_state, result)
def _handler_command_get_latest_sample(self, *args, **kwargs):
"""
"""
if log.isEnabledFor(logging.DEBUG):
log.debug("args=%s kwargs=%s" % (str(args), str(kwargs)))
next_state = self._protocol_fsm.get_current_state()
result = None
timeout = kwargs.get('timeout', self._timeout)
try:
result = self._connection.get_latest_sample(timeout)
except TimeoutException, e:
raise InstrumentTimeoutException(msg=str(e))
except ClientException, e:
log.warn("ClientException while get_latest_sample: %s" %
str(e))
raise InstrumentException('ClientException: %s' % str(e))
示例5: SBE37Protocol
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
events_out = [x for x in events if SBE37Capability.has(x)]
return events_out
########################################################################
# Unknown handlers.
########################################################################
def _handler_unknown_enter(self, *args, **kwargs):
"""
Enter unknown state.
"""
# Tell driver superclass to send a state change event.
# Superclass will query the state.
self._driver_event(DriverAsyncEvent.STATE_CHANGE)
def _handler_unknown_exit(self, *args, **kwargs):
"""
Exit unknown state.
"""
pass
def _handler_unknown_discover(self, *args, **kwargs):
"""
Discover current state; can be COMMAND or AUTOSAMPLE.
@retval (next_state, result), (SBE37ProtocolState.COMMAND or
SBE37State.AUTOSAMPLE, None) if successful.
@throws InstrumentTimeoutException if the device cannot be woken.
@throws InstrumentStateException if the device response does not correspond to
an expected state.
"""
next_state = None
result = None
current_state = self._protocol_fsm.get_current_state()
# Driver can only be started in streaming, command or unknown.
if current_state == SBE37ProtocolState.AUTOSAMPLE:
result = ResourceAgentState.STREAMING
elif current_state == SBE37ProtocolState.COMMAND:
result = ResourceAgentState.IDLE
elif current_state == SBE37ProtocolState.UNKNOWN:
# Wakeup the device with timeout if passed.
timeout = kwargs.get('timeout', SBE37_TIMEOUT)
prompt = self._wakeup(timeout)
prompt = self._wakeup(timeout)
# Set the state to change.
# Raise if the prompt returned does not match command or autosample.
if prompt.strip() == SBE37Prompt.COMMAND:
next_state = SBE37ProtocolState.COMMAND
result = ResourceAgentState.IDLE
elif prompt.strip() == SBE37Prompt.AUTOSAMPLE:
next_state = SBE37ProtocolState.AUTOSAMPLE
result = ResourceAgentState.STREAMING
else:
raise InstrumentStateException('Unknown state.')
return (next_state, result)
########################################################################
# Command handlers.
########################################################################
示例6: SingleConnectionInstrumentDriver
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
@param timeout=timeout Optional command timeout.
@retval Current device state.
@raises InstrumentTimeoutException if could not wake device.
@raises InstrumentStateException if command not allowed in current state or if
device state not recognized.
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.DISCOVER, DriverEvent.DISCOVER, *args, **kwargs)
def get_resource_capabilities(self, current_state=True, *args, **kwargs):
"""
Return driver commands and parameters.
@param current_state True to retrieve commands available in current
state, otherwise reutrn all commands.
@retval list of AgentCapability objects representing the drivers
capabilities.
@raises NotImplementedException if not implemented by subclass.
"""
if self._protocol:
return self._protocol.get_resource_capabilities(current_state)
else:
return [[], []]
def get_resource_state(self, *args, **kwargs):
"""
Return the current state of the driver.
@retval str current driver state.
@raises NotImplementedException if not implemented by subclass.
"""
connection_state = self._connection_fsm.get_current_state()
if connection_state == DriverConnectionState.CONNECTED:
return self._protocol.get_current_state()
else:
return connection_state
def get_resource(self, *args, **kwargs):
"""
Retrieve device parameters.
@param args[0] DriverParameter.ALL or a list of parameters to retrive.
@retval parameter : value dict.
@raises InstrumentParameterException if missing or invalid get parameters.
@raises InstrumentStateException if command not allowed in current state
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.GET, DriverEvent.GET, *args, **kwargs)
def set_resource(self, *args, **kwargs):
"""
Set device parameters.
@param args[0] parameter : value dict of parameters to set.
@param timeout=timeout Optional command timeout.
@raises InstrumentParameterException if missing or invalid set parameters.
@raises InstrumentTimeoutException if could not wake device or no response.
@raises InstrumentProtocolException if set command not recognized.
@raises InstrumentStateException if command not allowed in current state.
@raises NotImplementedException if not implemented by subclass.
"""
# Forward event and argument to the protocol FSM.
return self._connection_fsm.on_event(DriverEvent.SET, DriverEvent.SET, *args, **kwargs)
def execute_resource(self, resource_cmd, *args, **kwargs):
示例7: Protocol
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
driver arrives. That is accomplished using the chunker mechanism. This
method would normally collet any data fragments that are then search by
the get_response method in the context of a synchronous command sent
from the observatory. However, because so much data arrives here that
is not applicable, the add_to_buffer method has been overridden to do
nothing.
@param data: bytes to add to the buffer
"""
# Update the line and prompt buffers; first acquire mutex.
promptbuf_mutex.acquire()
self._linebuf += data
self._promptbuf += data
promptbuf_mutex.release()
self._last_data_timestamp = time.time()
def _got_chunk(self, chunk, timestamp):
"""
The base class got_data has gotten a chunk from the chunker. Invoke
this driver's _my_add_to_buffer, or pass it to extract_sample
with the appropriate particle objects and REGEXes. We need to invoke
_my_add_to_buffer, because we've overridden the base class
add_to_buffer that is called from got_data(). The reason is explained
in comments in _my_add_to_buffer.
"""
log.debug("_got_chunk_: %s", chunk)
"""
If we're in leveling mode, use a different got_chunk
"""
if (self._protocol_fsm.get_current_state() == ProtocolState.LEVELING):
log.error("~~~~~~~~~~~~~~~~~~~~~~~~~ YAHOOO!!!! LEVELING CHUNK: %s", chunk)
if (self.leveling_regex.match(chunk)):
self._protocol_fsm.on_event(ProtocolEvent.LEVELING_COMPLETE)
return
else:
log.error("!!!!!!!!!!!!!!!!!!!! NOOOO!!")
if (self.cmd_rsp_regex.match(chunk) \
#or self.signon_regex.match(chunk) \ # currently not using the signon chunk
or self.status_01_regex.match(chunk) \
or self.status_02_regex.match(chunk)):
self._my_add_to_buffer(chunk)
log.error("++++++++++++++++++++++++ Adding CHUNK: %s to buffer", chunk)
else:
if not self._extract_sample(LILYDataParticle,
self.data_regex,
chunk, timestamp):
raise InstrumentProtocolException("Unhandled chunk")
def _build_command(self, cmd, *args, **kwargs):
command = cmd + NEWLINE
log.debug("_build_command: command is: %s", command)
return command
def _parse_data_on_off_resp(self, response, prompt):
log.debug("_parse_data_on_off_resp: response: %r; prompt: %s", response, prompt)
return response.lily_command_response
def _parse_status_01_resp(self, response, prompt):
log.debug("_parse_status_01_resp: response: %r; prompt: %s", response, prompt)
return response.lily_status_response
示例8: SingleConnectionInstrumentDriver
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
def execute_start_direct_access(self, *args, **kwargs):
"""
Switch to direct access mode.
@raises TimeoutError if could not wake device or no response.
@raises StateError if command not allowed in current state.
@raises NotImplementedError if not implemented by subclass.
"""
return self._connection_fsm.on_event(DriverEvent.START_DIRECT, DriverEvent.START_DIRECT, *args, **kwargs)
def execute_direct_access(self, *args, **kwargs):
"""
output direct access data to device.
@raises TimeoutError if could not wake device or no response.
@raises StateError if command not allowed in current state.
@raises NotImplementedError if not implemented by subclass.
"""
return self._connection_fsm.on_event(DriverEvent.EXECUTE_DIRECT, DriverEvent.EXECUTE_DIRECT, *args, **kwargs)
def execute_stop_direct_access(self, *args, **kwargs):
"""
Leave direct access mode.
@raises TimeoutError if could not wake device or no response.
@raises ProtocolError if stop command not recognized.
@raises StateError if command not allowed in current state.
@raises NotImplementedError if not implemented by subclass.
"""
return self._connection_fsm.on_event(DriverEvent.STOP_DIRECT, DriverEvent.STOP_DIRECT, *args, **kwargs)
########################################################################
# Resource query interface.
########################################################################
def get_current_state(self):
"""
Return current device state. For single connection devices, return
a single connection state if not connected, and protocol state if connected.
"""
connection_state = self._connection_fsm.get_current_state()
if connection_state == DriverConnectionState.CONNECTED:
return self._protocol.get_current_state()
else:
return connection_state
########################################################################
# Unconfigured handlers.
########################################################################
def _handler_unconfigured_enter(self, *args, **kwargs):
"""
Enter unconfigured state.
"""
# Send state change event to agent.
self._driver_event(DriverAsyncEvent.STATE_CHANGE)
def _handler_unconfigured_exit(self, *args, **kwargs):
"""
Exit unconfigured state.
"""
pass
def _handler_unconfigured_initialize(self, *args, **kwargs):
"""
Initialize handler. We are already in unconfigured state, do nothing.
@retval (next_state, result) tuple, (None, None).
"""
示例9: SatlanticPARInstrumentProtocol
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
###################################################################
# Helpers
###################################################################
def _wakeup(self, timeout):
"""There is no wakeup sequence for this instrument"""
pass
def _update_params(self, *args, **kwargs):
"""Fetch the parameters from the device, and update the param dict.
@param args Unused
@param kwargs Takes timeout value
@throws InstrumentProtocolException
@throws InstrumentTimeoutException
"""
log.debug("Updating parameter dict")
old_config = self._param_dict.get_config()
self.get_config()
new_config = self._param_dict.get_config()
if new_config != old_config:
self._driver_event(DriverAsyncEvent.CONFIG_CHANGE)
def _send_reset(self, timeout=10):
"""Send a reset command out to the device
@throw InstrumentTimeoutException
@throw InstrumentProtocolException
@todo handle errors correctly here, deal with repeats at high sample rate
"""
write_delay = 0.2
log.debug("Sending reset chars")
if self._protocol_fsm.get_current_state() == PARProtocolState.COMMAND:
return InstErrorCode.OK
# TODO: infinite loop bad idea
while True:
self._do_cmd_no_resp(Command.RESET, timeout=timeout, write_delay=write_delay)
time.sleep(RESET_DELAY)
if self._confirm_autosample_mode():
break
def _switch_to_poll(self, timeout=10):
"""Send a switch_to_poll command out to the device
@retval return InstErrorCode.OK for success or no-op, error code on
failure
@throw InstrumentTimeoutException
@throw InstrumentProtocolException
@todo handle errors correctly here, deal with repeats at high sample rate
"""
write_delay = 0.2
log.debug("Sending switch_to_poll char")
counter = 0
while counter < 10:
self._do_cmd_no_resp(Command.SWITCH_TO_POLL, timeout=0, write_delay=write_delay)
time.sleep(0.5) # wait a little for samples to stop coming out
if self._confirm_poll_mode():
return True
counter = counter + 1
return False
def _send_break(self, timeout=10):
示例10: SBE16Protocol
# 需要导入模块: from mi.core.instrument.instrument_fsm import InstrumentFSM [as 别名]
# 或者: from mi.core.instrument.instrument_fsm.InstrumentFSM import get_current_state [as 别名]
#.........这里部分代码省略.........
events_out = [x for x in events if Capability.has(x)]
return events_out
########################################################################
# Unknown handlers.
########################################################################
def _handler_unknown_enter(self, *args, **kwargs):
"""
Enter unknown state.
"""
# Tell driver superclass to send a state change event.
# Superclass will query the state.
self._driver_event(DriverAsyncEvent.STATE_CHANGE)
def _handler_unknown_exit(self, *args, **kwargs):
"""
Exit unknown state.
"""
pass
def _handler_unknown_discover(self, *args, **kwargs):
"""
Discover current state; can be COMMAND or AUTOSAMPLE.
@retval (next_state, next_agent_state), (SBE16ProtocolState.COMMAND or
SBE16State.AUTOSAMPLE, next_agent_state) if successful.
@throws InstrumentTimeoutException if the device cannot be woken.
@throws InstrumentProtocolException if the device response does not correspond to
an expected state.
"""
next_state = None
next_agent_state = None
current_state = self._protocol_fsm.get_current_state()
# Driver can only be started in streaming, command or unknown.
if current_state == SBE16ProtocolState.AUTOSAMPLE:
next_agent_state = ResourceAgentState.STREAMING
elif current_state == SBE16ProtocolState.COMMAND:
next_agent_state = ResourceAgentState.IDLE
elif current_state == SBE16ProtocolState.UNKNOWN:
# Wakeup the device with timeout if passed.
timeout = kwargs.get('timeout', SBE16_TIMEOUT)
prompt = self._wakeup(timeout)
prompt = self._wakeup(timeout)
# Set the state to change.
# Raise if the prompt returned does not match command or autosample.
if prompt in [SBE16Prompt.COMMAND, SBE16Prompt.EXECUTED]:
next_state = SBE16ProtocolState.COMMAND
next_agent_state = ResourceAgentState.IDLE
elif prompt == SBE16Prompt.AUTOSAMPLE:
next_state = SBE16ProtocolState.AUTOSAMPLE
next_agent_state = ResourceAgentState.STREAMING
else:
errorString = 'Failure to recognize device prompt: ' + prompt
raise InstrumentProtocolException(errorString)
return (next_state, next_agent_state)
def _handler_unknown_force_state(self, *args, **kwargs):
"""
Force driver into a given state for the purposes of unit testing
@param state=desired_state Required desired state to transition to.