示例#1
0
    def __init__(self):
        PlotWindow.__init__(self)

        self.window_size = 500
        self.values = deque(
            maxlen=self.window_size)  #numpy.zeros((self.window_size))
        self.index = 0
        self.draw_counter = 0
        self.paused = False

        rospy.init_node('visualizer', anonymous=True)
        self.subscriber = rospy.Subscriber("sector_probabilities",
                                           SectorProbabilities,
                                           self.plotResults,
                                           queue_size=1)

        self.pauseButton.clicked.connect(self.pauseClicked)
        self.resetButton.clicked.connect(self.resetClicked)
示例#2
0
def setup_mag_group(log_drive, backup_drive, error_drive, webplot_drive):
    # Bartington Mag690-100 outputs 100 mV/uT = 0.01 V/mG so 100 mG/V, 100 uG/mV
    mag_x = logger.Channel(hard_port=101, chan_name='Mag X', conv_func=lambda v: v * 100)
    mag_y = logger.Channel(hard_port=102, chan_name='Mag Y', conv_func=lambda v: v * 100)
    mag_z = logger.Channel(hard_port=103, chan_name='Mag Z', conv_func=lambda v: v * 100)
    mag_group = logger.SaveGroup([mag_x, mag_y, mag_z], group_name='MagField', quiet=True,
                                 log_drive=Path(log_drive, 'MagField'),
                                 backup_drive=Path(backup_drive, 'MagField'),
                                 error_drive=error_drive,
                                 webplot_drive=webplot_drive)
    mag_loader = mag_group.make_loader()
    mag_plotter = PlotWindow(mag_loader, save_path=webplot_drive, ylabel='Magnetic Field',
                             units_label='(mG)', plot_mode='multiplot')
    return mag_group, mag_plotter
示例#3
0
def setup_temperature_group(log_drive, backup_drive, error_drive, webplot_drive):
    # Omega temperature converters readout 1 degree per mV.
    temp_exp_cloud = logger.Channel(hard_port=108, chan_name='Temp_exp_cloud', conv_func=lambda t: t,
                                    init_cmds_template=logger.Keithley.thrmstr_cmds)
    temp_exp_table = logger.Channel(hard_port=111, chan_name='Temp_exp_table', conv_func=lambda t: t,
                                    init_cmds_template=logger.Keithley.thrmstr_cmds)
    temp_laser_table = logger.Channel(hard_port=113, chan_name='Temp_laser_table', conv_func=lambda t: t,
                                    init_cmds_template=logger.Keithley.thrmstr_cmds)
    temp_group = logger.SaveGroup([temp_exp_cloud, temp_exp_table, temp_laser_table], group_name='LabTemp', quiet=True,
                                  log_drive=Path(log_drive, 'LabTemp'),
                                  backup_drive=Path(backup_drive, 'LabTemp'),
                                  error_drive=error_drive,
                                  webplot_drive=webplot_drive)
    temp_loader = temp_group.make_loader()
    temp_plotter = PlotWindow(temp_loader, save_path=webplot_drive, ylabel='Temperature', units_label=r'($^{\circ}C$)')
    return temp_group, temp_plotter
示例#4
0
def setup_ion_gauge_group(log_drive, backup_drive, error_drive, webplot_drive):
    """
    Terranova ion gauge controller reads out a pseudo-logarithmic voltage. It is 0.5 volts per decade and has
    an offset. The Terranova manual expresses this in a very confusing way that makes it difficult to determine
    the offset. There is a write up in onenote and on the server about it. The data saved here is Log10(P/P0).
    The actual pressures (1e-10 level) are too high of precision to be straightforwardly stored in the .csv.
    """
    ion_gauge = logger.Channel(hard_port=106, chan_name='IonGauge', conv_func=lambda v: (v - 5) / 0.5)
    ion_gauge_group = logger.SaveGroup([ion_gauge], group_name='IonGauge', quiet=True,
                                       log_drive=Path(log_drive, 'IonGauge'),
                                       backup_drive=Path(backup_drive, 'IonGauge'),
                                       error_drive=error_drive,
                                       webplot_drive=webplot_drive)
    ion_gauge_loader = ion_gauge_group.make_loader()
    ion_gauge_plotter = PlotWindow(ion_gauge_loader, save_path=webplot_drive, conv_func=(lambda x: 10 ** x),
                                   ylabel='Ion Gauge Pressure', units_label='(torr)', yscale='log')
    return ion_gauge_group, ion_gauge_plotter
示例#5
0
def setup_ion_pump_group(log_drive, backup_drive, error_drive, webplot_drive):
    """
    Gamma ion pump controller outputs a logarithmic voltage which is related to either the measured pressure or
    current of the ion pump. Now it is configured to give a logarithmic reading of the current. The offset is
    adjustable and set to 10 volts. This means that a current 1 A would register as 10 volts and 1e-8 A (10 nA)
    would register as 2V. The data saved here is Log10(I/I0).
    """
    ion_pump = logger.Channel(hard_port=104, chan_name='IonPump', conv_func=lambda v: (v - 10))
    ion_pump_group = logger.SaveGroup([ion_pump], group_name='IonPump', quiet=True,
                                      log_drive=Path(log_drive, 'IonPump'),
                                      backup_drive=Path(backup_drive, 'IonPump'),
                                      error_drive=error_drive,
                                      webplot_drive=webplot_drive)
    ion_pump_loader = ion_pump_group.make_loader()

    def curr2press(curr):
        # formula given in ion pump controller to convert current (expressed in nA) to pressure (in torr)
        return 0.066 * curr * 10 ** -9 * 5600 / 7000 / 70
    ion_pump_plotter = PlotWindow(ion_pump_loader, save_path=webplot_drive, conv_func=(lambda x: 10 ** x * 1e9),
                                  ylabel='Ion Pump Current', units_label='(nA)',
                                  twinx_on=True, twinx_func=curr2press, twinx_label='Pressure (torr)')
    return ion_pump_group, ion_pump_plotter
示例#6
0
    def __init__(self, parent=None):
        super(ADSRDemo4C, self).__init__(parent)

        self.conf = config.get('adsrdemo.py')

        self.vlc = []

        self.plotw = PlotWindow(self)
        self.plotw.add_curve('Chan 1')
        self.plotw.add_curve('Chan 2')
        self.plotw.add_curve('Chan 3')
        self.plotw.add_curve('Chan 4')

        self.plotw.add_curve('ADSR1')
        self.plotw.add_curve('ADSR2')
        self.plotw.add_curve('ADSR3')
        self.plotw.add_curve('ADSR4')

        self.dx = diff()

        self.adsr = [adsr_vlc() for x in range(4)]

        # atributo adsr : [nombre ,                    min, max,  k,       kdisp,   default]
        self.params = {  'attackl':['Duracion Ataque', 0,   200,  1./10,   1./100,  150 ],
                         'sustl':['Duracion Sustain',  0,   900,  1,       1./10,   100 ],
                         'rell':['Duracion Release',   0,   300,  1,       1./10,   15  ],
                         'alfa_att':['alfa Ataque',    0,   1000, 1./1000, 1./1000, 300 ],
                         'alfa_sus':['alfa Sustain',   0,   1000, 1./1000, 1./1000, 850 ],
                         'alfa_rel':['alfa Release',   0,   1000, 1./1000, 1./1000, 850 ],
                         'umbral':['umbral deteccion', 0,   400,  1,       1,       100 ]
                       }


        self.main_frame = QWidget()
        lay = QGridLayout()
        vbox = QVBoxLayout()
        lay.addLayout(vbox, 0,0)
        lay.setColumnStretch(1,1)
        lay.addWidget(self.plotw,0,1)
        self.main_frame.setLayout(lay)
        self.setCentralWidget(self.main_frame)

        hb = QHBoxLayout()
        vbox.addLayout(hb)
        b = QPushButton('Guardar')
        b.clicked.connect(self.guardar)
        hb.addWidget(b)
        b = QPushButton('Cargar')
        b.clicked.connect(self.cargar)
        hb.addWidget(b)

        b = QPushButton('Conectar con vlc')
        b.clicked.connect(self.vlc_connect)
        vbox.addWidget(b)

        self.sliders = []
        for attr,params  in self.params.iteritems():
            (nom, xmin, xmax, k, kdisp, default) = params
            lbl = QLabel(nom)
            sld = QSlider(Qt.Horizontal)
            sld.setRange(xmin, xmax)
            sld.valueChanged[int].connect(self.set_param)
            sld.params = (nom, lbl, attr, k, kdisp)
            sld.setValue(default) 
            vbox.addWidget(lbl)
            vbox.addWidget(sld)
            self.sliders.append(sld)

        b = QPushButton('Resetear ADSR')
        b.clicked.connect(self.reset_adsr)
        vbox.addWidget(b)

        vbox.addStretch(1)

        self.setWindowTitle('Prueba ADSR')
示例#7
0
class ADSRDemo4C(QMainWindow):
    name = 'Prueba cuatro canales'

    def __init__(self, parent=None):
        super(ADSRDemo4C, self).__init__(parent)

        self.conf = config.get('adsrdemo.py')

        self.vlc = []

        self.plotw = PlotWindow(self)
        self.plotw.add_curve('Chan 1')
        self.plotw.add_curve('Chan 2')
        self.plotw.add_curve('Chan 3')
        self.plotw.add_curve('Chan 4')

        self.plotw.add_curve('ADSR1')
        self.plotw.add_curve('ADSR2')
        self.plotw.add_curve('ADSR3')
        self.plotw.add_curve('ADSR4')

        self.dx = diff()

        self.adsr = [adsr_vlc() for x in range(4)]

        # atributo adsr : [nombre ,                    min, max,  k,       kdisp,   default]
        self.params = {  'attackl':['Duracion Ataque', 0,   200,  1./10,   1./100,  150 ],
                         'sustl':['Duracion Sustain',  0,   900,  1,       1./10,   100 ],
                         'rell':['Duracion Release',   0,   300,  1,       1./10,   15  ],
                         'alfa_att':['alfa Ataque',    0,   1000, 1./1000, 1./1000, 300 ],
                         'alfa_sus':['alfa Sustain',   0,   1000, 1./1000, 1./1000, 850 ],
                         'alfa_rel':['alfa Release',   0,   1000, 1./1000, 1./1000, 850 ],
                         'umbral':['umbral deteccion', 0,   400,  1,       1,       100 ]
                       }


        self.main_frame = QWidget()
        lay = QGridLayout()
        vbox = QVBoxLayout()
        lay.addLayout(vbox, 0,0)
        lay.setColumnStretch(1,1)
        lay.addWidget(self.plotw,0,1)
        self.main_frame.setLayout(lay)
        self.setCentralWidget(self.main_frame)

        hb = QHBoxLayout()
        vbox.addLayout(hb)
        b = QPushButton('Guardar')
        b.clicked.connect(self.guardar)
        hb.addWidget(b)
        b = QPushButton('Cargar')
        b.clicked.connect(self.cargar)
        hb.addWidget(b)

        b = QPushButton('Conectar con vlc')
        b.clicked.connect(self.vlc_connect)
        vbox.addWidget(b)

        self.sliders = []
        for attr,params  in self.params.iteritems():
            (nom, xmin, xmax, k, kdisp, default) = params
            lbl = QLabel(nom)
            sld = QSlider(Qt.Horizontal)
            sld.setRange(xmin, xmax)
            sld.valueChanged[int].connect(self.set_param)
            sld.params = (nom, lbl, attr, k, kdisp)
            sld.setValue(default) 
            vbox.addWidget(lbl)
            vbox.addWidget(sld)
            self.sliders.append(sld)

        b = QPushButton('Resetear ADSR')
        b.clicked.connect(self.reset_adsr)
        vbox.addWidget(b)

        vbox.addStretch(1)

        self.setWindowTitle('Prueba ADSR')

    def reset_adsr(self):
        for ad in self.adsr:
            ad.reset()


    def guardar(self):
        for sld in self.sliders:
            (nom, lbl, attr, k, kdisp) = sld.params
            self.conf[attr] = sld.value()

    def cargar(self):
        for sld in self.sliders:
            (nom, lbl, attr, k, kdisp) = sld.params
            if attr in self.conf:
                sld.setValue(self.conf[attr])

    def set_param(self, value):
        (nom, lbl, attr, k, kdisp) = self.sender().params
        val = k*value
        if attr in ['attackl','sustl', 'rell']:
            val = int(val)
        lbl.setText(nom + ': %.3f'%(value*kdisp) )
        for adsr in self.adsr:
            setattr(adsr, attr, val) 

    def new_data(self, data, *args, **kwargs):
        for item in data:
            res = item[1][:]
            for idx,x in enumerate( item[1]):
                res.append(self.adsr[idx](x))
                
            self.plotw.add_datapoint(item[0], *res)
 
    def start(self):
        self.show()

    def stop(self):
        self.hide()

    def destroy(self):
        self.close()

    def vlc_connect(self):
        self.vlc = []
        try:
            for idx in range(4):
                vlc = VLC(port=4210+idx)
                self.adsr[idx].vlc = vlc

        except:
            print 'error conexion vlc'
            for adsr in self.adsr:
                adsr.vlc = None
from PyQt5 import QtCore, QtWidgets
from loader import Loader
from plotwindow import PlotWindow
from ui_plottermanagerwindow import PlotterManagerWindow
from pathlib import Path
import sys

app = QtWidgets.QApplication(sys.argv)
keithley_logger_temp_path = Path('C:/', 'Users', 'Justin', 'Desktop', 'Working', 'Code', 'Keithley Logger Work')
work_dir = Path('C:/', 'Users', 'Justin', 'Desktop', 'Working', 'Code', 'Keithley Logger Work', 'MagField',
                'MagField')
log_drive = Path(keithley_logger_temp_path, 'Log Drive', 'Fake Data')
log_drive_2 = Path(keithley_logger_temp_path, 'Log Drive', 'Mag Data Fake')
file_prefix = 'Fake Data'
fake_data_loader = Loader(log_drive, file_prefix, quiet=True)
mag_data_fake_loader = Loader(log_drive_2, 'Mag Data Fake', quiet=True)
mag_data_loader = Loader(work_dir, 'MagField', quiet=True)
plotter1 = PlotWindow(fake_data_loader)
plotter2 = PlotWindow(mag_data_fake_loader)
plotter3 = PlotWindow(mag_data_loader)

ui = PlotterManagerWindow([plotter1, plotter2, plotter3])
ui.show()
sys.exit(app.exec_())