def _calib_w_float(self, block, index, value): cmd = SPINDIRx1Cmd.find('cw') value_bytes = Encode.float(value, '<') self._transact(cmd, (block, index), value_bytes) time.sleep(cmd.execution_time)
def _calib_w_unsigned_long(self, block, index, value): cmd = SPINDIRt1f1Cmd.find('cw') value_bytes = Encode.unsigned_long(value, '<') self._transact(cmd, (block, index), value_bytes) time.sleep(cmd.execution_time)
def record_raw(self, deferral, interval, count): try: self.obtain_lock() # start recording... deferral_bytes = Encode.unsigned_int(deferral, '<') interval_bytes = Encode.unsigned_int(interval, '<') count_bytes = Encode.unsigned_int(count, '<') param_bytes = [] param_bytes.extend(deferral_bytes) param_bytes.extend(interval_bytes) param_bytes.extend(count_bytes) cmd = SPINDIRt1f1Cmd.find('rs') self._transact(cmd, param_bytes) # wait... lamp_period = self._calib_r_unsigned_int( 0, NDIRCalib.INDEX_LAMP_PERIOD) execution_time = (lamp_period + deferral + (interval * count)) / 1000 time.sleep(execution_time) # playback... cmd = SPINDIRt1f1Cmd.find('rp') cmd.return_count = count * 10 response = self._transact(cmd) values = [] for i in range(0, cmd.return_count, 10): timestamp = Decode.unsigned_int(response[i:i + 2], '<') pile_ref = Decode.long(response[i + 2:i + 6], '<') pile_act = Decode.long(response[i + 6:i + 10], '<') values.append((timestamp, pile_ref, pile_act)) return values finally: self.release_lock()
def record_raw(self, deferral, interval, count): try: self.obtain_lock() # start recording... deferral_bytes = Encode.unsigned_int(deferral, '<') interval_bytes = Encode.unsigned_int(interval, '<') count_bytes = Encode.unsigned_int(count, '<') param_bytes = [] param_bytes.extend(deferral_bytes) param_bytes.extend(interval_bytes) param_bytes.extend(count_bytes) cmd = SPINDIRx1Cmd.find('rs') self._transact(cmd, param_bytes) # wait... execution_time = cmd.execution_time + (( (interval * count) + deferral) / 1000) # print("execution time: %s" % execution_time, file=sys.stderr) time.sleep(execution_time) # playback... cmd = SPINDIRx1Cmd.find('rp') cmd.return_count = count * 10 response = self._transact(cmd) values = [] for i in range(0, cmd.return_count, 10): timestamp = Decode.unsigned_int(response[i:i + 2], '<') pile_ref = Decode.long(response[i + 2:i + 6], '<') pile_act = Decode.long(response[i + 6:i + 10], '<') values.append((timestamp, pile_ref, pile_act)) return values finally: self.release_lock()
def lamp_level(self, voltage): try: self.obtain_lock() voltage_bytes = Encode.float(voltage, '<') cmd = SPINDIRx1Cmd.find('ll') self._transact(cmd, voltage_bytes) finally: self.release_lock()
def cleaning_interval(self, interval): values = Encode.unsigned_long(interval, '>') self.__write(self.__CMD_AUTO_CLEANING_INTERVAL, self.__POST_WRITE_DELAY, *values)