Beispiel #1
0
    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)
Beispiel #2
0
 def _handler_unconfigured_enter(self, *args, **kwargs):
     """
     """
     
     mi_logger.info('channel %s entered state %s', SBE37Channel.CTD,
                        SBE37State.UNCONFIGURED)
     self._publish_state_change(SBE37State.UNCONFIGURED)
     
     # Initialize throws no exceptions.
     InstrumentProtocol.initialize(self, *args, **kwargs)
Beispiel #3
0
    def _handler_disconnected_configure(self, *args, **kwargs):
        """
        """
        next_state = None
        result = None
        
        try:
            InstrumentProtocol.configure(self, *args, **kwargs)
                
        except (TypeError, KeyError, InstrumentConnectionException, IndexError):
            result = InstErrorCode.INVALID_PARAMETER
            next_state = SBE37State.UNCONFIGURED

        return (next_state, result)
    def __init__(self, channel, params, evt_callback=None):
        """
        @param channel identifies the particular protocol instance.
        @param params the particular parameters for this channel.
        """
        InstrumentProtocol.__init__(self, evt_callback)
        self._channel = channel

        # initialize values for the params:
        MyProtocol.next_base_value += 1000
        next_value = MyProtocol.next_base_value
        self._values = {}
        for param in params:
            next_value += 1
            self._values[param] = next_value
Beispiel #5
0
    def __init__(self, evt_callback=None):
        """
        Creates and initializes a protocol object to the UNCOFIGURED state.
        """
        InstrumentProtocol.__init__(self, evt_callback)

        self.trhph_client = None

        self._host = None
        self._port = None

        self._state = DriverState.UNCONFIGURED

        # TODO probably promote this convenience to super-class?
        self._timeout = 30
        """Default timeout value for operations accepting an optional timeout
Beispiel #6
0
 def _handler_unconfigured_configure(self, *args, **kwargs):
     """
     """
     next_state = None
     result = None
     
     try:
         InstrumentProtocol.configure(self, *args, **kwargs)
             
     except (TypeError, KeyError, InstrumentConnectionException, IndexError):
         result = InstErrorCode.INVALID_PARAMETER
         next_state = None
             
     # Everything worked, set next state.
     else:
         next_state = SBE37State.DISCONNECTED
             
     return (next_state, result)
Beispiel #7
0
    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)