def _handler_disconnected_connect(self, *args, **kwargs): """ @throw InstrumentTimeoutException on timeout """ next_state = None result = None try: InstrumentProtocol.connect(self, *args, **kwargs) timeout = kwargs.get('timeout', 10) prompt = self._wakeup(timeout) if prompt == SBE37Prompt.COMMAND: next_state = SBE37State.COMMAND elif prompt == SBE37Prompt.AUTOSAMPLE: next_state = SBE37State.AUTOSAMPLE except InstrumentConnectionException: # Connection failed, fail and stay here. next_state = None result = InstErrorCode.DRIVER_CONNECT_FAILED except InstrumentTimeoutException: # Timeout connecting or waking device. Stay disconnected. InstrumentProtocol.disconnect(self, *args, **kwargs) next_state = None result = InstErrorCode.DRIVER_CONNECT_FAILED return (next_state, result)
def _handler_command_disconnect(self, *args, **kwargs): """ """ next_state = None result = None try: mi_logger.info('DISCONNECTING') InstrumentProtocol.disconnect(self, *args, **kwargs) mi_logger.info('DONE DISCONNECTING') next_state = SBE37State.DISCONNECTED except InstrumentConnectionException: # Disconnect failed. Fail and stay here. next_state = None result = InstErrorCode.DISCONNECT_FAILED else: next_state = SBE37State.DISCONNECTED result = InstErrorCode.OK return (next_state, result)