예제 #1
0
    def set_to_angle(self, theta=(0,0)):
        """ Set mirrors to angle theta_x and theta_y
        :param theta: tuple (theta_x, theta_y)
        :param theta: tuple (theta_x, theta_y)
        :return: True if succesful
        """
        try:
            task_x.clear_task()
            task_y.clear_task()
        except:
            pass


        if abs(theta[0]) > 0.393 or abs(theta[1]) > 0.393:
            print("angle to big")
            return False

        theta_x = np.array([-theta[0], -theta[0]], dtype=np.float64)
        theta_y = np.array([theta[1], theta[1]], dtype=np.float64)

        task_x = DAQTask.DAQTask(self.daq_task_x_name)
        task_x.generate(theta_x,clear_task=True)

        task_y = DAQTask.DAQTask(self.daq_task_y_name)
        task_y.generate(theta_y, clear_task=True)
        return True
예제 #2
0
 def measure_one(self, plot=False, save=False):
     """ Measurement at one point
     :return: measured data
     """
     task = self.combobox_canal_measure.currentText()
     t = DAQTask.DAQTask(task)
     t.acquire()
     data = t.data
     logger.info(str(data))
     if plot:
         f, (ax1, ax2) = plt.subplots(1, 2)
         ax1.plot(data[0])
         ax2.plot(data[1])
         plt.show()
     if save:
         file_path = self.lineedit_folder_measurement.text()
         file_name = self.lineedit_file_name.text()
         file = file_path + "\\" + file_name
         if file_name == '' or os.path.isfile(file):
             file = QtGui.QFileDialog.getOpenFileName(
                 self,
                 "Save File",
                 "",
             )
     logger.info("plot shown")
     return data
예제 #3
0
 def test_force(self):
     """
     Test force measurement
     :return:
     """
     # clear task
     try:
         task.clear_task()
     except:
         pass
     # create task
     task = DAQTask.DAQTask("velocity_force")
     # get data
     task.acquire()
     logger.info(task.data)
     plt.plot(task.data[1])
     plt.show()
     #open file
     # write data
     try:
         task.clear_task()
     except:
         pass
예제 #4
0
    def inject_properties(self, properties):
        """Get fresh arguments to the function before starting the measurement."""
        self.type = properties['excitation_type']
        self.task = DAQTask.DAQTask(properties['task_name'])
        self.sampling_rate = self.task.sample_rate
        self.task_info.send(self.sampling_rate)
        self.channel_list = self.task.channel_list
        self.samples_per_channel = self.task.samples_per_ch
        self.number_of_channels = self.task.number_of_ch
        self.exc_channel = properties['exc_channel']
        self.trigger_level = properties['trigger_level']
        self.pre_trigger_samples = properties['pre_trigger_samples']
        if properties['samples_per_channel'] is 'auto':
            self.samples_per_channel = self.task.samples_per_ch
        else:
            self.samples_per_channel = properties['samples_per_channel']
        self.samples_left_to_acquire = self.samples_per_channel

        # Reinitialize pipe always -- it is closed when measurement is stopped.
        self.measured_data = properties['measured_data_pipe']
        self.random_chunk = properties['random_chunk_pipe']

        self.ring_buffer = RingBuffer.RingBuffer(self.number_of_channels,
                                                 self.samples_per_channel)
예제 #5
0
        def load_task(reset=False):
            if 'refresh  ' in self.device_task.currentText():
                self._refresh_tasks_list()
            else:
                try:
                    # TODO: Check for required buffer size and availible buffer.
                    # i = dq.DAQTask(self.device_task.currentText().encode())
                    i = dq.DAQTask(self.device_task.currentText().encode())

                    channel_list = list(map(bytes.decode, i.channel_list))

                    i.clear_task(wait_until_done=False)

                    # if i.sample_rate < 2000:
                    #     task_status.setText('<span style="color: orange;"><b>Sampling rate should be at least 2 kHz.</b></span>')
                    #     table.setDisabled(True)
                    #     self.save.setDisabled(True)
                    # else:

                    combos = [
                        QtWidgets.QComboBox() for channel in channel_list
                    ]
                    labels = [
                        QtWidgets.QLabel(channel) for channel in channel_list
                    ]

                    # task_status.setText("""<span style="color: green;">Sampling rate: <b>{0:.0f} S/s</b>, """
                    #                     """Samples to read: <b>{1:.0f} S</b><br />"""
                    #                     """Nr. of channels: <b>{2:.0f}</b></span>""".format(i.sample_rate,
                    #                                                                 i.samples_per_ch, len(channel_list)))

                    task_status.setText(
                        """<span style="color: green;">Sampling rate: <b>{0:.0f} S/s</b>, """
                        """Nr. of channels: <b>{1:.0f}</b></span>""".format(
                            i.sample_rate, len(channel_list)))

                    # Reset settings on task change except when opening up saved state.
                    if 'task_name' in self.settings:
                        if self.settings[
                                'task_name'] == self.device_task.currentText(
                                ).encode():
                            pass
                        else:
                            self.win_length.setValue(i.samples_per_ch)
                    else:
                        self.win_length.setValue(i.samples_per_ch)

                    self.channel_nr = len(channel_list)
                    refresh_table(channel_list)
                    self.save.setEnabled(True)
                    self.button_testrun.setEnabled(True)

                    # Run measurement thread.
                    # self.measure_test_run_process_start()

                    # table.setEnabled(True)

                except dq.DAQError:
                    task_status.setText(
                        '<span style="color: orange;"><b>Device malfunction.</b></span>'
                    )
                    table.setDisabled(True)
                    # table.setDisabled(True)
                    self.save.setDisabled(True)