Esempio n. 1
0
    def _handler_sync_clock(self, *args, **kwargs):
        """
        sync clock close to a second edge 
        @retval (next_state, (next_agent_state, result)) tuple, (None, (None, None)).
        @throws InstrumentTimeoutException if device respond correctly.
        @throws InstrumentProtocolException if command could not be built or misunderstood.
        """

        next_state = None
        next_agent_state = None
        result = None

        time_format = "%Y/%m/%d %H:%M:%S"
        str_val = get_timestamp_delayed(time_format)
        log.debug("Setting instrument clock to '%s'", str_val)
        self._do_cmd_resp(Command.STOP, expected_prompt=Prompt.STOPPED)
        try:
            self._do_cmd_resp(Command.SET_CLOCK,
                              str_val,
                              expected_prompt=Prompt.CR_NL)
        finally:
            # ensure that we try to start the instrument sampling again
            self._do_cmd_resp(Command.GO, expected_prompt=Prompt.GO)

        return (next_state, (next_agent_state, result))
Esempio n. 2
0
    def _sync_clock(self, date_time_param, prompts, timeout, delay=1):
        """
        Send the command to the instrument to syncronize the clock
        @param date_time_param: date time parameter that we want to set
        @param prompts: expected prompt
        @param timeout: command timeout
        @param delay: wakeup delay
        @return: true if the command is successful
        @raise: InstrumentProtocolException if command fails
        """
        prompt = self._wakeup(timeout=timeout, delay=delay)

        # lets clear out any past data so it doesnt confuse the command
        self._linebuf = ''
        self._promptbuf = ''

        str_val = self._param_dict.format(date_time_param, get_timestamp_delayed("%d %b %Y %H:%M:%S"))
        set_cmd = '%s=%s' % (date_time_param, str_val) + NEWLINE

        self._do_cmd_direct(set_cmd)
        (prompt, response) = self._get_response()

        if response != set_cmd + prompt:
            raise InstrumentProtocolException("_clock_sync - response != set_cmd")

        if prompt != prompt:
            raise InstrumentProtocolException("_clock_sync - prompt != Prompt.COMMAND")

        return True
Esempio n. 3
0
    def _sync_clock(self, *args, **kwargs):
        """
        sync clock close to a second edge
        @retval (next_state, (next_agent_state, result)) tuple, (None, (None, None)).
        @throws InstrumentTimeoutException if device respond correctly.
        @throws InstrumentProtocolException if command could not be built or misunderstood.
        """

        next_state = None
        next_agent_state = None
        result = None

        time_format = "%Y/%m/%d %H:%M:%S"
        str_val = get_timestamp_delayed(time_format)
        log.debug("Setting instrument clock to '%s'", str_val)

        self._do_cmd_resp(Command.SET_CLOCK, str_val, expected_prompt=Prompt.CR_NL)
Esempio n. 4
0
    def assert_set_clock(self, time_param, time_override=None, time_format = "%d %b %Y %H:%M:%S", tolerance=DEFAULT_CLOCK_DIFF):
        """
        Verify that we can set the clock
        @param time_param: driver parameter
        @param time_override: use this time instead of current time.
        @param time_format: date time format
        @param tolerance: how close to the set time should the get be?
        """
        # Some seabirds tick the clock the instant you set it.  So you set
        # time 1, the get would be time 2.  Others do it correctly and wait
        # for a second before ticking. Hence the default tolerance of 1.
        if(time_override == None):
            set_time = get_timestamp_delayed(time_format)
        else:
            set_time = time.strftime(time_format, time.localtime(time_override))

        self.assert_set(time_param, set_time, no_get=True, startup=True)
        self.assertTrue(self._is_time_set(time_param, set_time, time_format, tolerance))
Esempio n. 5
0
    def _sync_clock(self, command, date_time_param, timeout=TIMEOUT, delay=1, time_format="%d %b %Y %H:%M:%S"):
        """
        Send the command to the instrument to syncronize the clock
        @param command: command to set6 date time
        @param date_time_param: date time parameter that we want to set
        @param timeout: command timeout
        @param delay: wakeup delay
        @param time_format: time format string for set command
        @raise: InstrumentProtocolException if command fails
        """
        # lets clear out any past data so it doesnt confuse the command
        self._linebuf = ''
        self._promptbuf = ''

        log.debug("Set time format(%s) '%s''", time_format, date_time_param)
        str_val = get_timestamp_delayed(time_format)
        log.debug("Set time value == '%s'", str_val)
        self._do_cmd_resp(command, date_time_param, str_val)
Esempio n. 6
0
    def _sync_clock(self, command, date_time_param, timeout=TIMEOUT, delay=1, time_format="%d %b %Y %H:%M:%S"):
        """
        Send the command to the instrument to syncronize the clock
        @param command: command to set6 date time
        @param date_time_param: date time parameter that we want to set
        @param timeout: command timeout
        @param delay: wakeup delay
        @param time_format: time format string for set command
        @raise: InstrumentProtocolException if command fails
        """
        # lets clear out any past data so it doesnt confuse the command
        self._linebuf = ''
        self._promptbuf = ''

        log.debug("Set time format(%s) '%s''", time_format, date_time_param)
        str_val = get_timestamp_delayed(time_format)
        log.debug("Set time value == '%s'", str_val)
        self._do_cmd_resp(command, date_time_param, str_val)
Esempio n. 7
0
    def _sync_clock(self, date_time_param, prompts, timeout, delay=1, time_format="%d %b %Y %H:%M:%S"):
        """
        Send the command to the instrument to syncronize the clock
        @param date_time_param: date time parameter that we want to set
        @param prompts: expected prompt
        @param timeout: command timeout
        @param delay: wakeup delay
        @param time_format: time format string for set command
        @return: true if the command is successful
        @raise: InstrumentProtocolException if command fails
        """
        prompt = self._wakeup(timeout=timeout, delay=delay)

        # lets clear out any past data so it doesnt confuse the command
        self._linebuf = ''
        self._promptbuf = ''

        log.debug("Set time format(%s) '%s''", time_format, date_time_param)
        str_val = get_timestamp_delayed(time_format)
        log.debug("Set time value == '%s'", str_val)
        self._set_params({date_time_param: str_val}, True)

        return True
Esempio n. 8
0
    def assert_set_clock(self,
                         time_param,
                         time_override=None,
                         time_format="%d %b %Y %H:%M:%S",
                         tolerance=DEFAULT_CLOCK_DIFF):
        """
        Verify that we can set the clock
        @param time_param: driver parameter
        @param time_override: use this time instead of current time.
        @param time_format: date time format
        @param tolerance: how close to the set time should the get be?
        """
        # Some seabirds tick the clock the instant you set it.  So you set
        # time 1, the get would be time 2.  Others do it correctly and wait
        # for a second before ticking. Hence the default tolerance of 1.
        if (time_override == None):
            set_time = get_timestamp_delayed(time_format)
        else:
            set_time = time.strftime(time_format,
                                     time.localtime(time_override))

        self.assert_set(time_param, set_time, no_get=True, startup=True)
        self.assertTrue(
            self._is_time_set(time_param, set_time, time_format, tolerance))
Esempio n. 9
0
    def test_parameters(self):
        """
        Verify that we can set the parameters

        1. Cannot set read only parameters
        2. Can set read/write parameters
        3. Can set read/write parameters w/direct access only
        """
        self.assert_initialize_driver(ProtocolState.COMMAND)

        #test read/write parameter
        self.assert_set(Parameter.MEASUREMENTS_PER_REPORTED, 20)

        #test setting immutable parameters when startup
        #NOTE: this does not use the startup config because setting a combination of parameters from their default
        #values will cause the instrument to no longer break out of autosample mode.  This is a safe way to test
        #setting startup params without the risk of going into autosample mode.
        self.assert_set(Parameter.MEASUREMENTS_PER_PACKET,
                        18,
                        startup=True,
                        no_get=True)
        self.assert_get(Parameter.MEASUREMENTS_PER_PACKET, 18)

        self.assert_set(Parameter.PREDEFINED_OUTPUT_SEQ,
                        3,
                        startup=True,
                        no_get=True)
        self.assert_get(Parameter.PREDEFINED_OUTPUT_SEQ, 3)

        self.assert_set(Parameter.PACKETS_PER_SET,
                        10,
                        startup=True,
                        no_get=True)
        self.assert_get(Parameter.PACKETS_PER_SET, 10)

        self.assert_set(Parameter.RECORDING_MODE, 1, startup=True, no_get=True)
        self.assert_get(Parameter.RECORDING_MODE, 1)

        self.assert_set(Parameter.MANUAL_MODE, 1, startup=True, no_get=True)
        self.assert_get(Parameter.MANUAL_MODE, 1)

        self.assert_set(Parameter.RUN_WIPER_INTERVAL,
                        '05:00:23',
                        startup=True,
                        no_get=True)
        self.assert_get(Parameter.RUN_WIPER_INTERVAL, '05:00:23')

        self.assert_set(Parameter.RUN_CLOCK_SYNC_INTERVAL,
                        '12:00:00',
                        startup=True,
                        no_get=True)
        self.assert_get(Parameter.RUN_CLOCK_SYNC_INTERVAL, '12:00:00')

        self.assert_set(Parameter.RUN_ACQUIRE_STATUS_INTERVAL,
                        '00:00:30',
                        startup=True,
                        no_get=True)
        self.assert_get(Parameter.RUN_ACQUIRE_STATUS_INTERVAL, '00:00:30')

        #test read only parameter (includes immutable, when not startup)- should not be set, value should not change
        self.assert_set_exception(Parameter.SERIAL_NUM, '12.123.1234')
        self.assert_set_exception(Parameter.FIRMWARE_VERSION, 'VER123')
        self.assert_set_exception(Parameter.MEASUREMENTS_PER_PACKET, 16)
        self.assert_set_exception(Parameter.MEASUREMENT_1_DARK_COUNT, 10)
        self.assert_set_exception(Parameter.MEASUREMENT_2_DARK_COUNT, 20)
        self.assert_set_exception(Parameter.MEASUREMENT_3_DARK_COUNT, 30)
        self.assert_set_exception(Parameter.MEASUREMENT_1_SLOPE, 12.00)
        self.assert_set_exception(Parameter.MEASUREMENT_2_SLOPE, 13.00)
        self.assert_set_exception(Parameter.MEASUREMENT_3_SLOPE, 14.00)
        self.assert_set_exception(Parameter.PREDEFINED_OUTPUT_SEQ, 0)
        self.assert_set_exception(Parameter.BAUD_RATE, 2422)
        self.assert_set_exception(Parameter.PACKETS_PER_SET, 0)
        self.assert_set_exception(Parameter.RECORDING_MODE, 0)
        self.assert_set_exception(Parameter.MANUAL_MODE, 0)
        self.assert_set_exception(Parameter.SAMPLING_INTERVAL, "003000")
        self.assert_set_exception(Parameter.DATE,
                                  get_timestamp_delayed("%m/%d/%y"))
        self.assert_set_exception(Parameter.TIME,
                                  get_timestamp_delayed("%H:%M:%S"))
        self.assert_set_exception(Parameter.MANUAL_START_TIME, "15:10:45")
        self.assert_set_exception(Parameter.INTERNAL_MEMORY, 512)
        self.assert_set_exception(Parameter.RUN_WIPER_INTERVAL, "00:00:00")
        self.assert_set_exception(Parameter.RUN_CLOCK_SYNC_INTERVAL,
                                  "00:00:00")
        self.assert_set_exception(Parameter.RUN_ACQUIRE_STATUS_INTERVAL,
                                  "00:00:00")
Esempio n. 10
0
    def test_parameters(self):
        """
        Verify that we can set the parameters

        1. Cannot set read only parameters
        2. Can set read/write parameters
        3. Can set read/write parameters w/direct access only
        """
        self.assert_initialize_driver(ProtocolState.COMMAND)

        #test read/write parameter
        self.assert_set(Parameter.MEASUREMENTS_PER_REPORTED, 20)

        #test setting immutable parameters when startup
        #NOTE: this does not use the startup config because setting a combination of parameters from their default
        #values will cause the instrument to no longer break out of autosample mode.  This is a safe way to test
        #setting startup params without the risk of going into autosample mode.
        self.assert_set(Parameter.MEASUREMENTS_PER_PACKET, 18, startup=True, no_get=True)
        self.assert_get(Parameter.MEASUREMENTS_PER_PACKET, 18)

        self.assert_set(Parameter.PREDEFINED_OUTPUT_SEQ, 3, startup=True, no_get=True)
        self.assert_get(Parameter.PREDEFINED_OUTPUT_SEQ, 3)

        self.assert_set(Parameter.PACKETS_PER_SET, 10, startup=True, no_get=True)
        self.assert_get(Parameter.PACKETS_PER_SET, 10)

        self.assert_set(Parameter.RECORDING_MODE, 1, startup=True, no_get=True)
        self.assert_get(Parameter.RECORDING_MODE, 1)

        self.assert_set(Parameter.MANUAL_MODE, 1, startup=True, no_get=True)
        self.assert_get(Parameter.MANUAL_MODE, 1)

        self.assert_set(Parameter.RUN_WIPER_INTERVAL, '05:00:23', startup=True, no_get=True)
        self.assert_get(Parameter.RUN_WIPER_INTERVAL, '05:00:23')

        self.assert_set(Parameter.RUN_CLOCK_SYNC_INTERVAL, '12:00:00', startup=True, no_get=True)
        self.assert_get(Parameter.RUN_CLOCK_SYNC_INTERVAL, '12:00:00')

        self.assert_set(Parameter.RUN_ACQUIRE_STATUS_INTERVAL, '00:00:30', startup=True, no_get=True)
        self.assert_get(Parameter.RUN_ACQUIRE_STATUS_INTERVAL, '00:00:30')

        #test read only parameter (includes immutable, when not startup)- should not be set, value should not change
        self.assert_set_exception(Parameter.SERIAL_NUM, '12.123.1234')
        self.assert_set_exception(Parameter.FIRMWARE_VERSION, 'VER123')
        self.assert_set_exception(Parameter.MEASUREMENTS_PER_PACKET, 16)
        self.assert_set_exception(Parameter.MEASUREMENT_1_DARK_COUNT, 10)
        self.assert_set_exception(Parameter.MEASUREMENT_2_DARK_COUNT, 20)
        self.assert_set_exception(Parameter.MEASUREMENT_3_DARK_COUNT, 30)
        self.assert_set_exception(Parameter.MEASUREMENT_1_SLOPE, 12.00)
        self.assert_set_exception(Parameter.MEASUREMENT_2_SLOPE, 13.00)
        self.assert_set_exception(Parameter.MEASUREMENT_3_SLOPE, 14.00)
        self.assert_set_exception(Parameter.PREDEFINED_OUTPUT_SEQ, 0)
        self.assert_set_exception(Parameter.BAUD_RATE, 2422)
        self.assert_set_exception(Parameter.PACKETS_PER_SET, 0)
        self.assert_set_exception(Parameter.RECORDING_MODE, 0)
        self.assert_set_exception(Parameter.MANUAL_MODE, 0)
        self.assert_set_exception(Parameter.SAMPLING_INTERVAL, "003000")
        self.assert_set_exception(Parameter.DATE, get_timestamp_delayed("%m/%d/%y"))
        self.assert_set_exception(Parameter.TIME, get_timestamp_delayed("%H:%M:%S"))
        self.assert_set_exception(Parameter.MANUAL_START_TIME, "15:10:45")
        self.assert_set_exception(Parameter.INTERNAL_MEMORY, 512)
        self.assert_set_exception(Parameter.RUN_WIPER_INTERVAL, "00:00:00")
        self.assert_set_exception(Parameter.RUN_CLOCK_SYNC_INTERVAL, "00:00:00")
        self.assert_set_exception(Parameter.RUN_ACQUIRE_STATUS_INTERVAL, "00:00:00")