from lib.adq_mod import *
from lib.xml2dict import device, variables
from datetime import datetime
from tkinter.filedialog import askopenfilename
import msvcrt
import sys
import os
from lib.logger import get_all_caller, logger
from devices.powermeter1830c import powermeter1830c as pp

logger = logger(filelevel=20)

cwd = os.getcwd()
savedir = cwd + '\\' + str(datetime.now().date()) + '\\'
#names of the parameters
par = variables('Par')
fpar = variables('FPar')
data = variables('Data')
fifo = variables('Fifo')


def abort(filename):
    logger = logging.getLogger(get_all_caller())
    logger.critical('You quit!')
    header = "type,x-pos,y-pos,z-pos,first scan time" + ",time_%s" * (
        len(data[0, :]) - 5) % tuple(range((len(data[0, :]) - 5)))
    np.savetxt("%s%s_abort.txt" % (savedir, filename),
               data,
               fmt='%s',
               delimiter=",",
               header=header)
Exemplo n.º 2
0
    def __init__(self, MplAnimate, parent=None):
        #super(MplCanvas, self).__init__(self.imv)
        QtGui.QGraphicsObject.__init__(self)
        self.setParent(parent)
        self.parent = parent
        self.xdata = []
        self.ydata = []
        self.MplAnimate = MplAnimate

        self.fifo = variables('Fifo')
        self.par = variables('Par')
        if MplAnimate.option[0] == 'Monitor':
            self.adw = adq('lib/adbasic/monitor.T90')
            self.delay = 400 * 0.1e-3
            self.detector = [
                device(parent.main.Monitor_comboBox.currentText())
            ]
            self.fifo_name = '%s%i' % (
                self.detector[0].properties['Type'],
                self.detector[0].properties['Input']['Hardware']['PortID'])
            self.xlabel = "Time"
            self.xunit = ' s'
            self.ylabel = "%s" % parent.main.Monitor_comboBox.currentText()
            self.yunit = ' %s' % self.detector[0].properties['Input'][
                'Calibration']['Unit']
            self.adw.load()
            self.adw.start()

        else:
            self.adw = adq('lib/adbasic/adwin.T99')
            self.adw.load()
            if not self.parent.main.Scan_Dropdown.button.isEnabled():
                self.detector = [
                    device(
                        self.parent.main.Scan_Detector_comboBox.currentText())
                ]
            else:
                i = 0
                self.parent.main.Scan_Dropdown.model
                self.detector = []
                while self.parent.main.Scan_Dropdown.model.item(i):
                    if self.parent.main.Scan_Dropdown.model.item(
                            i).checkState():
                        self.detector.append(
                            device(
                                self.parent.main.Scan_Dropdown.model.item(
                                    i).text()))
                    i += 1
            self.direction_1 = self.parent.main.Scan_1st_comboBox.currentText()

            if self.parent.main.Scan_1st_comboBox.currentText() == 'Time':
                self.duration = self.parent.main.Scan_1st_Range.value()
                self.accuracy = self.parent.main.Scan_Delay_Range.value(
                ) / 1000
                self.delay = self.accuracy
                self.xlabel = "%s" % self.parent.main.Scan_1st_comboBox.currentText(
                )
                self.xunit = ' %s' % self.parent.main.Scan_1st_UnitLabel.text()
                self.ylabel = [
                    "%s" % self.detector[i].properties['Name']
                    for i in range(len(self.detector))
                ]
                self.yunit = [
                    ' %s' %
                    self.detector[i].properties['Input']['Calibration']['Unit']
                    for i in range(len(self.detector))
                ]

            else:
                self.devs = [
                    device(self.parent.main.Scan_1st_comboBox.currentText())
                ]
                self.center = [
                    self.parent.Controler[self.parent.main.Scan_1st_comboBox.
                                          currentText()]['PosBox'].value()
                ]
                self.dims = [self.parent.main.Scan_1st_Range.value()]
                self.accuracy = [self.parent.main.Scan_1st_Accuracy.value()]
                self.xlabel = "%s" % parent.main.Scan_1st_comboBox.currentText(
                )
                self.xunit = ' %s' % self.devs[0].properties['Output'][
                    'Calibration']['Unit']
                self.ylabel = [
                    "%s" % self.detector[i].properties['Name']
                    for i in range(len(self.detector))
                ]
                self.yunit = [
                    ' %s' %
                    self.detector[i].properties['Input']['Calibration']['Unit']
                    for i in range(len(self.detector))
                ]
                if not self.parent.main.Scan_2nd_comboBox.currentText(
                ) == 'None':
                    self.devs.append(
                        device(
                            self.parent.main.Scan_2nd_comboBox.currentText()))
                    self.center.append(self.parent.Controler[
                        self.parent.main.Scan_2nd_comboBox.currentText()]
                                       ['PosBox'].value())
                    self.dims.append(self.parent.main.Scan_2nd_Range.value())
                    self.accuracy.append(
                        self.parent.main.Scan_2nd_Accuracy.value())
                    self.ylabel = "%s" % parent.main.Scan_2nd_comboBox.currentText(
                    )
                    self.yunit = ' %s' % self.devs[1].properties['Output'][
                        'Calibration']['Unit']

                if not self.parent.main.Scan_3rd_comboBox.currentText(
                ) == 'None':
                    self.devs.append(
                        device(
                            self.parent.main.Scan_3rd_comboBox.currentText()))
                    self.center.append(self.parent.Controler[
                        self.parent.main.Scan_3rd_comboBox.currentText()]
                                       ['PosBox'].value())
                    self.dims.append(self.parent.main.Scan_3rd_Range.value())
                    self.accuracy.append(
                        self.parent.main.Scan_3rd_Accuracy.value())
                self.speed = self.parent.main.Scan_Delay_Range.value()
                self.delay = self.speed
            self.fifo_name = 'scan_data'