Пример #1
0
    # opens Avasoft
    def OpenAvasoft(self):
        self.logger.info('Avasoft is launched with help of a button.')
        subprocess.Popen(r"C:\Program Files (x86)\Avasoft8\Avasoft8.exe")

    # opens the software of the LED
    def OpenLEDDriver(self):
        self.logger.info('LED software is launched with help of a button.')
        subprocess.Popen(
            r"C:\Program Files (x86)\Mightex LEDDriver\LEDDriver.exe")

    def MakeDropdown(self):
        listOfNames = []
        self.cursor.execute("SELECT Catalysts.catalyst FROM Catalysts")
        rows = self.cursor.fetchall()

        for i in range(len(rows)):
            listOfNames.append(rows[i][0])

        return listOfNames


if __name__ == '__main__':
    logger = logging.getLogger('AutosamplerLog')
    logging.basicConfig(filename='AutosamplerLog.txt',
                        level=logging.DEBUG,
                        format='%(asctime)s - %(levelname)s - %(message)s')
    par = ImportparAuto()
    gui1 = AutomationInterface1(par)
    gui1.root.mainloop()
        self.logger.info('Reset the working directory and the standard output before GUI2 gets destroyed')

        self.root.quit()
        self.root.destroy()

    @staticmethod
    def waitingThread(pauzetime):
        time.sleep(pauzetime)
        pass

 class TextRedirector(object):
    def __init__(self, widget, tag="stdout"):
        self.widget = widget
        self.tag = tag

    def write(self, str):
        self.widget.configure(state="normal")
        self.widget.insert("end", str, (self.tag,))
        self.widget.configure(state=DISABLED)

    def flush(self):
        pass

if __name__ == '__main__':
    logger = logging.getLogger('AutosamplerLog')
    logging.basicConfig(filename='AutosamplerLog.txt', level=logging.DEBUG,
                        format='%(asctime)s - %(levelname)s - %(message)s')
    par = ImportparAuto()
    par.time101 = 1000
    gui2 = AutomationInterface2(par, 'hi', 'durp', 'thing')
    gui2.root.mainloop()
        # checks if given names are duplicates of one another and gives them a sequential number if so.
        for i in range(len(self.par.namesExperiments) - 1):
            b = 1
            for j in range(i + 1, len(self.par.namesExperiments)):
                if (self.par.namesExperiments[i] ==
                        self.par.namesExperiments[j]):
                    self.par.namesExperiments[j] = "{}_{}".format(
                        self.par.namesExperiments[i], str(b))
                    b += 1
                else:
                    pass


if __name__ == '__main__':
    logger = logging.getLogger('AutosamplerLog')
    logging.basicConfig(filename='AutosamplerLog.txt',
                        level=logging.DEBUG,
                        format='%(asctime)s - %(levelname)s - %(message)s')
    par = ImportparAuto()
    par.experimentNumber = 5
    par.namesExperiments = [None] * par.experimentNumber
    for i in range(len(par.namesExperiments)):
        letter = int(i / 8) + 65
        position = (i % 8) + 1
        par.namesExperiments[i] = '{}{}'.format(chr(letter), str(position))

    gui2 = NamingGUI(par)
    gui2.root.mainloop()

    for i in range(len(par.namesExperiments)):
        print(par.namesExperiments[i])
def MainRunAutosampler():
    # create main logger for Autosampler experiment
    logger = logging.getLogger('AutosamplerLog')
    logging.basicConfig(filename='AutosamplerLog.txt', level=logging.DEBUG,
                        format='%(asctime)s - %(levelname)s - %(message)s')

    logger.info('Start experiment')

    # import all the standard / pre-determined parameters
    par = ImportparAuto()
    par.mainRunParcing = True

    # create and make connection with the devices
    autosampler = Autosampler(comnumber=7, name='Autosampler')
    solventPump = HPLCPumpSmartline(comnumber=6, baudrate=115200, name='Solvent_Pump')
    catPump = HPLCPumpSmartline(comnumber=5, baudrate=115200, name='Catalyst_Pump')  # 4 = purple / 10 = green / 5 = orange

    # start solvent pump
    par.time101 = time.time()
    solventPump.SetFlowrate(par.flowRateSolvent)

    # create GUI1
    gui1 = AutomationInterface1(par)
    gui1.root.mainloop()
    par = gui1.par

    # tell the autosampler how many samples there are
    autosampler.SetExperiments(par.experimentNumber)

    # launch the naming GUI if checkbox was checked
    if par.selfNaming:
        namingWindow = NamingGUI(par)
        namingWindow.root.mainloop()
        par = namingWindow.par

        for name in par.namesExperiments:
            logger.debug('The name on index {0} is {1}'.format(par.namesExperiments.index(name), name))

    # start the second GUI
    gui2 = AutomationInterface2(par, autosampler, solventPump, catPump)
    gui2.root.mainloop()
    par = gui2.par

    # calculate data and make graphs
    ParceData(par)

    # send a email that the experiment is finished
    ST.SendEmail(par)

    # remove the fast overview pdf if self naming occurred
    if par.selfNaming:
        try:
            os.remove(os.path.join(par.workingDir, 'fast_overview.pdf'))
        except Exception as e:
            logger.error('redundant fast overview pdf could not be removed: {}'.format(e))
            pass

    # if overnight was checked, shut the pc down
    if par.overNight:
        ST.OverNightCommand(par)

    logger.info('Code has finished')
    # read your existing PDF
    existingFile = open(originalPDF, 'rb')
    existing_pdf = PdfFileReader(existingFile)
    output = PdfFileWriter()
    # add the "watermark" (which is the new pdf) on the existing page
    page = existing_pdf.getPage(0)
    output.addPage(page)
    output.addPage(new_pdf.getPage(0))
    # finally, write "output" to a real file
    outputStream = open("overview and legend.pdf", "wb")
    output.write(outputStream)
    outputStream.close()


if __name__ == '__main__':
    par = ImportparAuto()
    par.name = "KK-20180228-1"
    par.nameFileAvasoft = "{}{}".format(par.name, '.txt')
    par.dataStartTime = 144.951
    par.dataStartIntensity = 1587804.3769
    par.experimentNumber = 6

    par.mainRunParcing = False
    par.selfNaming = False
    par.databaseName = "Database_Automation.db"

    curTime = datetime.datetime.now()
    par.date = curTime.strftime('%Y/%m/%d')
    par.catalystName = '4CzIPN'

    par.scriptDir = os.getcwd()