コード例 #1
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class EmailDirCommand():
    def __init__(self):
        self.regexp_str = "E-mail directory: " + Regexsimplefile
        self.label = "E-mail directory: DIRECTORY"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        dir_path = values[1]
        try:
            message = "Hi,\n\nat your request, here is the directory: " + os.path.normpath(
                os.path.abspath(
                    dir_path.encode('utf8').strip())) + "\n\n PyGMI"
            email_alert = Email_directory(
                directory=dir_path.encode('utf8').strip(),
                address=main.ui.email_address.text(),
                message=message,
                subject="Data directory from PyGMI",
                smtpadd=main.mainconf['smtpadd'],
                login=main.mainconf['login'],
                mdp=main.mainconf['mdp'],
                smtpport=main.mainconf['smtpport'])
            print "directory successfully sent by e-mail"
        except:
            print "Exception: directory could not be sent by e-mail"
        #go to next line of macro
        self.next_move = 1
        self.wait_time = 500
コード例 #2
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetPPMSFieldCommand():
    def __init__(self):
        self.regexp_str = "Set PPMS Field to " + Regexfloat + " Oe @ " + Regexfloat + " Oe/s (Linear|NoOvershoot|Oscillate)? (Persistent|Driven)?"
        self.label = "Set PPMS Field to X Oe @ X Oe/s (Linear|NoOvershoot|Oscillate) (Persistent|Driven)"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)
        self.waiting = False
        self.waiting_start = 0

    def run(self, main):
        values = self.regexp.capturedTexts()
        ##get the loop index and setpoint value
        setpoint = float(values[1])
        rate = float(values[2])
        #if an approach was also provided, go to this setpoint at this rate
        approach = 'Linear'
        mode = 'Persistent'
        if values[3] != '': approach = values[3]
        if values[4] != '': mode = values[4]
        with main.reserved_access_to_instr:
            main.ppms.set_field(setpoint, rate, approach, mode)

        #go to next line of macro after stdwtime (give some time to process other events)
        self.next_move = 1
        self.wait_time = 100
コード例 #3
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class AngleCommand():
    def __init__(self):
        #Text that will appear in the list of commands on the right side of the Macro editor
        self.label = "Set start|stop|step angle to FLOAT"
        #Regular expression which may or may not catch parameters
        self.regexp_str = "Set (start|stop|step) angle to " + Regexfloat
        #Add this to the beginning and end of the regular expression
        #so that whitespaces before and after will not prevent the regex from matching
        self.regexp_str = "^ *" + self.regexp_str + " *$"
        #instantiate regex
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        #what to do when the regex defined just above in __init__
        #has matched the current line of the Macro
        #get the captured parameters
        values = self.regexp.capturedTexts()
        #set the corresponding angle box
        if values[1] in ['stop', 'step', 'start']:
            anglebox = eval("main.ui.angle" + values[1])
            anglebox.setValue(float(values[2]))
        #Finally go to next line of macro...
        self.next_move = 1
        #...after 10 milliseconds
        self.wait_time = 10
コード例 #4
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class WaitForTPPMSStableCommand():
    def __init__(self):
        self.regexp_str = "Wait(?: at most " + Regexfloat + " secs)? for PPMS Temp to reach " + Regexfloat + " K"
        self.label = "Wait(at most X secs) for PPMS Temp to reach X K"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)
        self.waiting = False
        self.waiting_start = 0

    def run(self, main):
        values = self.regexp.capturedTexts()
        #Wait for the temperature measurement to be stable and
        #within 5% of specified temperature
        #(and lock only when accessing the instrument)
        with main.reserved_access_to_instr:
            Terror, T, status = main.ppms.get_temperature()
        if self.waiting == False:
            self.waiting = True
            self.waiting_start = time.clock()
        if status == 'Stable' and abs(T - float(values[2])) < abs(
                float(values[2]) * 0.05):
            #Temperature is stable, go to next line of macro
            self.waiting = False
            self.next_move = 1
            self.wait_time = 500
        elif values[1] != '' and time.clock() - self.waiting_start > float(
                values[1]):
            #time limit is reached, go to next line of macro
            self.waiting = False
            self.next_move = 1
            self.wait_time = 500
        else:
            #wait 10s and check again
            self.next_move = 0
            self.wait_time = 10000
コード例 #5
0
class AngleCommand():
    def __init__(self):
        #Text that will appear in the list of commands on the right side of the Macro editor
        self.label="Set start|stop|step angle to FLOAT"
        #Regular expression which may or may not catch parameters
        self.regexp_str="Set (start|stop|step) angle to "+Regexfloat
        #Add this to the beginning and end of the regular expression
        #so that whitespaces before and after will not prevent the regex from matching
        self.regexp_str="^ *"+self.regexp_str+" *$"
        #instantiate regex
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        #what to do when the regex defined just above in __init__
        #has matched the current line of the Macro
        #get the captured parameters
        values=self.regexp.capturedTexts()
        #set the corresponding angle box
        if values[1] in ['stop','step','start']:
            anglebox=eval("main.ui.angle"+values[1])
            anglebox.setValue(float(values[2]))           
        #Finally go to next line of macro...
        self.next_move=1
        #...after 10 milliseconds
        self.wait_time=10 
コード例 #6
0
class WaitForHStableCommand():
    def __init__(self):
        self.regexp_str="Wait(?: at most "+Regexfloat+" secs)? for magnet (X|Y|Z) to finish ramping"
        self.label="Wait (at most X secs) for magnet (X|Y|Z) to finish ramping"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
        self.waiting=False
        self.waiting_start=0
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #wait for field to stabilize (and lock only when accessing the instrument)
        with main.reserved_access_to_instr:
            magnet=eval("main.magnet_"+values[2])
            stat=magnet.query_status()
        if self.waiting==False:
            self.waiting=True
            self.waiting_start=time.clock()
        if not(stat=='RAMPING to programmed current/field') or (values[1]!='' and time.clock()-self.waiting_start>float(values[1])):
            #ramping is finished or time limit is reached, go to next line of macro
            self.waiting=False
            self.next_move=1
            self.wait_time=500
        else:
            #wait 5s and check again
            self.next_move=0
            self.wait_time=5000       
コード例 #7
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetTempVTICommand():
    def __init__(self):
        self.regexp_str = "Set VTI Loop (\d+) to " + Regexfloat + " K(?: @ " + Regexfloat + " K/min)?"
        self.label = "Set VTI Loop X to X K (@ X K/min)"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)
        self.waiting = False
        self.waiting_start = 0

    def run(self, main):
        values = self.regexp.capturedTexts()
        ##get the loop index and setpoint value
        loop = float(values[1])
        setpoint = float(values[2])
        #if a ramp rate was also provided, go to this setpoint at this rate
        VTI = main.instr_9
        if values[3] != '':
            rate = float(values[3])
            with main.reserved_access_to_instr:
                VTI.conf_ramp(loop, rate, 'on')
                VTI.set_setpoint(loop, setpoint)
        else:
            with main.reserved_access_to_instr:
                VTI.switch_ramp(loop, 'off')
                VTI.set_setpoint(loop, setpoint)
        #go to next line of macro after stdwtime (give some time to process other events)
        self.next_move = 1
        self.wait_time = 500
コード例 #8
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class WaitForMeasureCommand():
    def __init__(self):
        self.regexp_str = "Wait(?: at most " + Regexfloat + " secs)? for measurements completion"
        self.label = "Wait(at most X secs) for measurements completion"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)
        self.waiting = False
        self.waiting_start = 0

    def run(self, main):
        values = self.regexp.capturedTexts()
        if self.waiting == False:
            self.waiting = True
            self.waiting_start = time.clock()
        if not (main.measurements_thread.isAlive()) or (
                values[1] != ''
                and time.clock() - self.waiting_start > float(values[1])):
            #Measurements are complete or time limit was reached, go to next line of macro
            self.waiting = False
            self.next_move = 1
            self.wait_time = 500
        else:
            #wait 1s and check again if measurements are complete
            self.next_move = 0
            self.wait_time = 1000
コード例 #9
0
class SetTempVTICommand():
    def __init__(self):
        self.regexp_str="Set VTI Loop (\d+) to "+Regexfloat+" K(?: @ "+Regexfloat+" K/min)?"
        self.label="Set VTI Loop X to X K (@ X K/min)"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
        self.waiting=False
        self.waiting_start=0
        
    def run(self,main):
        values=self.regexp.capturedTexts()
        ##get the loop index and setpoint value
        loop=float(values[1])
        setpoint=float(values[2])
        #if a ramp rate was also provided, go to this setpoint at this rate
        VTI=main.instr_9
        if values[3]!='':
            rate=float(values[3])
            with main.reserved_access_to_instr:
                VTI.conf_ramp(loop,rate,'on')
                VTI.set_setpoint(loop,setpoint)
        else:        
            with main.reserved_access_to_instr:            
                VTI.switch_ramp(loop,'off')
                VTI.set_setpoint(loop,setpoint)
        #go to next line of macro after stdwtime (give some time to process other events)
        self.next_move=1
        self.wait_time=500
コード例 #10
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class WaitForHStableCommand():
    def __init__(self):
        self.regexp_str = "Wait(?: at most " + Regexfloat + " secs)? for magnet (X|Y|Z) to finish ramping"
        self.label = "Wait (at most X secs) for magnet (X|Y|Z) to finish ramping"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)
        self.waiting = False
        self.waiting_start = 0

    def run(self, main):
        values = self.regexp.capturedTexts()
        #wait for field to stabilize (and lock only when accessing the instrument)
        with main.reserved_access_to_instr:
            magnet = eval("main.magnet_" + values[2])
            stat = magnet.query_status()
        if self.waiting == False:
            self.waiting = True
            self.waiting_start = time.clock()
        if not (stat == 'RAMPING to programmed current/field') or (
                values[1] != ''
                and time.clock() - self.waiting_start > float(values[1])):
            #ramping is finished or time limit is reached, go to next line of macro
            self.waiting = False
            self.next_move = 1
            self.wait_time = 500
        else:
            #wait 5s and check again
            self.next_move = 0
            self.wait_time = 5000
コード例 #11
0
class SetPPMSFieldCommand():
    def __init__(self):
        self.regexp_str="Set PPMS Field to "+Regexfloat+" Oe @ "+Regexfloat+" Oe/s (Linear|NoOvershoot|Oscillate)? (Persistent|Driven)?"
        self.label="Set PPMS Field to X Oe @ X Oe/s (Linear|NoOvershoot|Oscillate) (Persistent|Driven)"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
        self.waiting=False
        self.waiting_start=0
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        ##get the loop index and setpoint value
        setpoint=float(values[1])
        rate=float(values[2])
        #if an approach was also provided, go to this setpoint at this rate
        approach = 'Linear'
        mode = 'Persistent'
        if values[3]!='':approach = values[3]
        if values[4]!='':mode = values[4]
        with main.reserved_access_to_instr:
            main.ppms.set_field(setpoint,rate,approach,mode)
        
        #go to next line of macro after stdwtime (give some time to process other events)
        self.next_move=1
        self.wait_time=100
コード例 #12
0
class WaitForTPPMSStableCommand():
    def __init__(self):
        self.regexp_str="Wait(?: at most "+Regexfloat+" secs)? for PPMS Temp to reach "+Regexfloat+" K"
        self.label="Wait(at most X secs) for PPMS Temp to reach X K"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
        self.waiting=False
        self.waiting_start=0
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #Wait for the temperature measurement to be stable and
        #within 5% of specified temperature
        #(and lock only when accessing the instrument)
        with main.reserved_access_to_instr:
            Terror, T, status = main.ppms.get_temperature()
        if self.waiting==False:
            self.waiting=True
            self.waiting_start=time.clock()
        if status == 'Stable' and abs(T-float(values[2]))<abs(float(values[2])*0.05):
            #Temperature is stable, go to next line of macro
            self.waiting=False
            self.next_move=1
            self.wait_time=500
        elif values[1]!='' and time.clock()-self.waiting_start>float(values[1]):
            #time limit is reached, go to next line of macro
            self.waiting=False
            self.next_move=1
            self.wait_time=500
        else:
            #wait 10s and check again
            self.next_move=0
            self.wait_time=10000 
コード例 #13
0
ファイル: browsers.py プロジェクト: karstenv/manageR
 def getData(self, error):
     if error:
         self.html = self.http.errorString()
     else:
         self.html = self.http.readAll()
     # the following is a hack to handle redirects...
     regexp = QRegExp(r'Redirect\sto\s\<a\shref=\"(.*)\">')
     if regexp.indexIn(QString(self.html)) > -1:
         self.setSource(QUrl(regexp.capturedTexts()[1]))
コード例 #14
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetSaveFileCommand():
    def __init__(self):
        self.regexp_str = "Set Save file to " + Regexsimplefile + ""
        self.label = "Set Save file to X"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        main.ui.savefile_txt_input.setText(values[1])
        #new file name is set, go to next line of macro
        self.next_move = 1
        self.wait_time = 500
コード例 #15
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class WaitCommand():
    def __init__(self):
        self.regexp_str = "Wait " + Regexfloat + " secs"
        self.label = "Wait X secs"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        #self.values[1]!=''
        #go to next line of macro after 'values[1]' seconds
        self.next_move = 1
        self.wait_time = float(values[1]) * 1000
コード例 #16
0
class SetSaveFileCommand():
    def __init__(self):
        self.regexp_str="Set Save file to "+Regexsimplefile+""
        self.label="Set Save file to X"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        main.ui.savefile_txt_input.setText(values[1])
        #new file name is set, go to next line of macro
        self.next_move=1
        self.wait_time=500                                     
コード例 #17
0
class WaitCommand():
    def __init__(self):
        self.regexp_str="Wait "+Regexfloat+" secs"
        self.label="Wait X secs"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #self.values[1]!=''
        #go to next line of macro after 'values[1]' seconds
        self.next_move=1
        self.wait_time=float(values[1])*1000      
コード例 #18
0
class SetVTIHeaterCommand():
    def __init__(self):
        self.regexp_str="Set VTI heater range to (\d)"
        self.label="Set VTI heater range to DIGIT"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #set the heater range
        with main.reserved_access_to_instr:
            main.instr_9.set_heater_range(int(values[1]))                     
        #go to next line of macro
        self.next_move=1
        self.wait_time=500         
コード例 #19
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetVTIHeaterCommand():
    def __init__(self):
        self.regexp_str = "Set VTI heater range to (\d)"
        self.label = "Set VTI heater range to DIGIT"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        #set the heater range
        with main.reserved_access_to_instr:
            main.instr_9.set_heater_range(int(values[1]))
        #go to next line of macro
        self.next_move = 1
        self.wait_time = 500
コード例 #20
0
class SetUICommand():
    def __init__(self,main):
#        print "|".join(dir(main.ui))
        self.regexp_str="Set UI ("+"|".join(dir(main.ui))+") to "+Regexfloat
        self.label="Set UI PROPERTY to FLOAT"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #set the property
        prop = eval("main.ui."+values[1])
        prop.setValue(float(values[2]))
        #go to next line of macro
        self.next_move=1
        self.wait_time=10
コード例 #21
0
class StartMeasureCommand():
    def __init__(self):
        #type name_of_program() to start it
        self.regexp_str="Start "+Regexprogramfile+"\((.*)\)"
        self.label="Start PROGRAM()"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        main.ui.measMode.setCurrentIndex(main.ui.measMode.findText(values[1]))
        #start measurements
        main.start_measurements()
        #go to next line of macro
        self.next_move=1
        self.wait_time=500                      
コード例 #22
0
class WaitForEpoch():
    def __init__(self):
        self.regexp_str="Wait for Epoch \+ "+Regexfloat+" secs"
        self.label="Wait for Epoch + X secs"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #test if the current time is greater than the time provided in the macro (in Epoch seconds)
        if float(values[1])>time.time():
            self.next_move=0
            self.wait_time=5000
        else:
            self.next_move=1
            self.wait_time=100
コード例 #23
0
class SetVCommand():
    def __init__(self):
        self.regexp_str="Set voltage (\d) to "+Regexfloat+" V"
        self.label="Set voltage DIGIT to FLOAT V"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #set the voltage
        if values[1] in ['1','2','3']:
            V_source_setpoint=eval("main.ui.V_setpoint_"+values[1])
            V_source_setpoint.setValue(float(values[2]))
        #go to next line of macro
        self.next_move=1
        self.wait_time=500
コード例 #24
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetVCommand():
    def __init__(self):
        self.regexp_str = "Set voltage (\d) to " + Regexfloat + " V"
        self.label = "Set voltage DIGIT to FLOAT V"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        #set the voltage
        if values[1] in ['1', '2', '3']:
            V_source_setpoint = eval("main.ui.V_setpoint_" + values[1])
            V_source_setpoint.setValue(float(values[2]))
        #go to next line of macro
        self.next_move = 1
        self.wait_time = 500
コード例 #25
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class WaitForEpoch():
    def __init__(self):
        self.regexp_str = "Wait for Epoch \+ " + Regexfloat + " secs"
        self.label = "Wait for Epoch + X secs"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        #test if the current time is greater than the time provided in the macro (in Epoch seconds)
        if float(values[1]) > time.time():
            self.next_move = 0
            self.wait_time = 5000
        else:
            self.next_move = 1
            self.wait_time = 100
コード例 #26
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class StartMeasureCommand():
    def __init__(self):
        #type name_of_program() to start it
        self.regexp_str = "Start " + Regexprogramfile + "\((.*)\)"
        self.label = "Start PROGRAM()"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        main.ui.measMode.setCurrentIndex(main.ui.measMode.findText(values[1]))
        #start measurements
        main.start_measurements()
        #go to next line of macro
        self.next_move = 1
        self.wait_time = 500
コード例 #27
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetUICommand():
    def __init__(self, main):
        #        print "|".join(dir(main.ui))
        self.regexp_str = "Set UI (" + "|".join(dir(
            main.ui)) + ") to " + Regexfloat
        self.label = "Set UI PROPERTY to FLOAT"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        #set the property
        prop = eval("main.ui." + values[1])
        prop.setValue(float(values[2]))
        #go to next line of macro
        self.next_move = 1
        self.wait_time = 10
コード例 #28
0
class EmailCommand():
    def __init__(self):
        self.regexp_str="E-mail message: "+Regexsimplefile
        self.label="E-mail message: MESSAGE"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        msg=values[1]
        try:
            email_alert=Email_alert(message=msg.encode('utf8'),address=main.ui.email_address.text(),subject="Message from PyGMI",smtpadd=main.mainconf['smtpadd'],login=main.mainconf['login'],mdp=main.mainconf['mdp'],smtpport=main.mainconf['smtpport'])
            print "message successfully sent by e-mail"
        except:
            print "Exception: message could not be sent by e-mail"
        #go to next line of macro
        self.next_move=1
        self.wait_time=500   
コード例 #29
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetICommand():
    def __init__(self):
        self.regexp_str = "Set current (\d) to " + Regexfloat + " A"
        self.label = "Set current DIGIT to FLOAT A"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        #set the current
        if values[1] == '1':
            main.ui.I_source_setpoint.setValue(float(values[2]) * 1e6)
        elif values[1] in ['2', '3']:
            I_source_setpoint = eval("main.ui.I_source_setpoint_" + values[1])
            I_source_setpoint.setValue(float(values[2]) * 1e6)
        #go to next line of macro
        self.next_move = 1
        self.wait_time = 10
コード例 #30
0
class SetICommand():
    def __init__(self):
        self.regexp_str="Set current (\d) to "+Regexfloat+" A"
        self.label="Set current DIGIT to FLOAT A"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #set the current
        if values[1]=='1':
            main.ui.I_source_setpoint.setValue(float(values[2])*1e6)
        elif values[1] in ['2','3']:
            I_source_setpoint=eval("main.ui.I_source_setpoint_"+values[1])
            I_source_setpoint.setValue(float(values[2])*1e6)
        #go to next line of macro
        self.next_move=1
        self.wait_time=10
コード例 #31
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class WaitForTStableCommand():
    def __init__(self):
        self.regexp_str = "Wait(?: at most " + Regexfloat + " secs)? for channel (\w) to reach " + Regexfloat + " \+/\- " + Regexfloat + " K"
        self.label = "Wait(at most X secs) for channel X to reach X +/- X K"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)
        self.waiting = False
        self.waiting_start = 0

    def run(self, main):
        values = self.regexp.capturedTexts()
        #wait for temperature to stabilize (and lock only when accessing the instrument)
        with main.reserved_access_to_instr:
            T = main.temp_controller.query_temp(values[2])
        if self.waiting == False:
            self.waitTcounter = 0
            self.waiting = True
            self.waiting_start = time.clock()
        if values[1] != '' and time.clock() - self.waiting_start > float(
                values[1]):
            #time limit is reached, go to next line of macro
            self.waiting = False
            self.next_move = 1
            self.wait_time = 500
        elif abs(T - float(values[3])) < float(values[4]):
            #Wait for the temperature measurement to be ten times
            #within the specified limits, in a row, to consider it stable
            if self.waitTcounter < 10:
                #count one, wait 0.5 secs and measure T again
                self.waitTcounter += 1
                self.next_move = 0
                self.wait_time = 500
            else:
                #Temperature is stable, go to next line of macro
                self.waitTcounter = 0
                self.waiting = False
                self.next_move = 1
                self.wait_time = 500
        else:
            #wait 10s and check again, but reset the stable temperature counter
            self.waitTcounter = 0
            self.next_move = 0
            self.wait_time = 10000
コード例 #32
0
class EmailDirCommand():
    def __init__(self):
        self.regexp_str="E-mail directory: "+Regexsimplefile
        self.label="E-mail directory: DIRECTORY"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        dir_path=values[1]
        try:
            message="Hi,\n\nat your request, here is the directory: "+os.path.normpath(os.path.abspath(dir_path.encode('utf8').strip()))+"\n\n PyGMI"
            email_alert=Email_directory(directory=dir_path.encode('utf8').strip(),address=main.ui.email_address.text(),message=message,subject="Data directory from PyGMI",smtpadd=main.mainconf['smtpadd'],login=main.mainconf['login'],mdp=main.mainconf['mdp'],smtpport=main.mainconf['smtpport'])
            print  "directory successfully sent by e-mail"
        except:
            print "Exception: directory could not be sent by e-mail"
        #go to next line of macro
        self.next_move=1
        self.wait_time=500   
コード例 #33
0
class SetPersistFieldCommand():
    def __init__(self):
        self.regexp_str="Set persistent field in magnet (X|Y|Z) to "+Regexfloat+" T"
        self.label="Set persistent field in magnet X|Y|Z to x T"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
            
    def run(self,main):
        values=self.regexp.capturedTexts()
        ##set the loop index and setpoint value
        magnet_setpoint=eval("main.ui.B_"+values[1]+"_setpoint")
        magnet_setpoint.setValue(float(values[2]))
        time.sleep(1)
        main.ui.measMode.setCurrentIndex(main.ui.measMode.findText("Change_persistent_"+values[1]+"_field"))
        #start measurements
        main.start_measurements()     
        #go to next line of macro after stdwtime (give some time to process other events)
        self.next_move=1
        self.wait_time=500
コード例 #34
0
class WaitForTStableCommand():
    def __init__(self):
        self.regexp_str="Wait(?: at most "+Regexfloat+" secs)? for channel (\w) to reach "+Regexfloat+" \+/\- "+Regexfloat+" K"
        self.label="Wait(at most X secs) for channel X to reach X +/- X K"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
        self.waiting=False
        self.waiting_start=0
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        #wait for temperature to stabilize (and lock only when accessing the instrument)
        with main.reserved_access_to_instr:
            T=main.temp_controller.query_temp(values[2])
        if self.waiting==False:
            self.waitTcounter=0
            self.waiting=True
            self.waiting_start=time.clock()
        if values[1]!='' and time.clock()-self.waiting_start>float(values[1]):
            #time limit is reached, go to next line of macro
            self.waiting=False
            self.next_move=1
            self.wait_time=500
        elif abs(T-float(values[3]))<float(values[4]):
            #Wait for the temperature measurement to be ten times
            #within the specified limits, in a row, to consider it stable
            if self.waitTcounter<10:
                #count one, wait 0.5 secs and measure T again
                self.waitTcounter+=1
                self.next_move=0
                self.wait_time=500
            else:
                #Temperature is stable, go to next line of macro
                self.waitTcounter=0
                self.waiting=False
                self.next_move=1
                self.wait_time=500                
        else:
            #wait 10s and check again, but reset the stable temperature counter
            self.waitTcounter=0
            self.next_move=0
            self.wait_time=10000 
コード例 #35
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetFieldCommand():
    def __init__(self):
        self.regexp_str = "Set Field of magnet (X|Y|Z) to " + Regexfloat + " G(?: @ " + Regexfloat + " G/s)?"
        self.label = "Set Field of magnet X|Y|Z to X G (@ X G/s)"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        with main.reserved_access_to_instr:
            magnet = eval("main.magnet_" + values[1])
            if values[3] != '':
                #if a ramp rate was also provided, go to this setpoint at this rate
                magnet.program_ramp_rate_in_Gauss_per_second(float(values[3]))
            #print "Setting Field to ",
            magnet.program_field_in_kG(float(values[2]) * 1e-3)
            magnet.ramp_to_programmed_field()
        #go to next line of macro
        self.next_move = 1
        self.wait_time = 500
コード例 #36
0
class SetFieldCommand():
    def __init__(self):
        self.regexp_str="Set Field of magnet (X|Y|Z) to "+Regexfloat+" G(?: @ "+Regexfloat+" G/s)?"
        self.label="Set Field of magnet X|Y|Z to X G (@ X G/s)"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        with main.reserved_access_to_instr:
            magnet=eval("main.magnet_"+values[1])
            if values[3]!='':
                #if a ramp rate was also provided, go to this setpoint at this rate
                magnet.program_ramp_rate_in_Gauss_per_second(float(values[3]))    
            #print "Setting Field to ",
            magnet.program_field_in_kG(float(values[2])*1e-3)
            magnet.ramp_to_programmed_field()
        #go to next line of macro
        self.next_move=1
        self.wait_time=500  
コード例 #37
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetPersistFieldCommand():
    def __init__(self):
        self.regexp_str = "Set persistent field in magnet (X|Y|Z) to " + Regexfloat + " T"
        self.label = "Set persistent field in magnet X|Y|Z to x T"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        ##set the loop index and setpoint value
        magnet_setpoint = eval("main.ui.B_" + values[1] + "_setpoint")
        magnet_setpoint.setValue(float(values[2]))
        time.sleep(1)
        main.ui.measMode.setCurrentIndex(
            main.ui.measMode.findText("Change_persistent_" + values[1] +
                                      "_field"))
        #start measurements
        main.start_measurements()
        #go to next line of macro after stdwtime (give some time to process other events)
        self.next_move = 1
        self.wait_time = 500
コード例 #38
0
class WaitForMeasureCommand():
    def __init__(self):
        self.regexp_str="Wait(?: at most "+Regexfloat+" secs)? for measurements completion"
        self.label="Wait(at most X secs) for measurements completion"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
        self.waiting=False
        self.waiting_start=0
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        if self.waiting==False:
            self.waiting=True
            self.waiting_start=time.clock()
        if not(main.measurements_thread.isAlive()) or (values[1]!='' and time.clock()-self.waiting_start>float(values[1])):
            #Measurements are complete or time limit was reached, go to next line of macro
            self.waiting=False
            self.next_move=1
            self.wait_time=500
        else:
            #wait 1s and check again if measurements are complete
            self.next_move=0
            self.wait_time=1000
コード例 #39
0
class SetPPMSTempCommand():
    def __init__(self):
        self.regexp_str="Set PPMS Temperature to "+Regexfloat+" K @ "+Regexfloat+" K/min (FastSettle|NoOvershoot)?"
        self.label="Set PPMS Temperature to X K @ X K/min (FastSettle/NoOvershoot)"
        self.regexp_str="^ *"+self.regexp_str+" *$" #so that the same string with heading and trailing whitespaces also matches
        self.regexp=QRegExp(self.regexp_str)
        self.waiting=False
        self.waiting_start=0
    
    def run(self,main):
        values=self.regexp.capturedTexts()
        ##get the loop index and setpoint value
        setpoint=float(values[1])
        rate=float(values[2])
        #if an approach was also provided, go to this setpoint at this rate
        approach = 'FastSettle'      
        if values[3]!='':approach = values[3]
        with main.reserved_access_to_instr:
            main.ppms.set_temperature(setpoint,rate,approach)
        
        #go to next line of macro after stdwtime (give some time to process other events)
        self.next_move=1
        self.wait_time=100
コード例 #40
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class SetPPMSTempCommand():
    def __init__(self):
        self.regexp_str = "Set PPMS Temperature to " + Regexfloat + " K @ " + Regexfloat + " K/min (FastSettle|NoOvershoot)?"
        self.label = "Set PPMS Temperature to X K @ X K/min (FastSettle/NoOvershoot)"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)
        self.waiting = False
        self.waiting_start = 0

    def run(self, main):
        values = self.regexp.capturedTexts()
        ##get the loop index and setpoint value
        setpoint = float(values[1])
        rate = float(values[2])
        #if an approach was also provided, go to this setpoint at this rate
        approach = 'FastSettle'
        if values[3] != '': approach = values[3]
        with main.reserved_access_to_instr:
            main.ppms.set_temperature(setpoint, rate, approach)

        #go to next line of macro after stdwtime (give some time to process other events)
        self.next_move = 1
        self.wait_time = 100
コード例 #41
0
ファイル: Macro_editor.py プロジェクト: vbanos/PyGMI
class EmailCommand():
    def __init__(self):
        self.regexp_str = "E-mail message: " + Regexsimplefile
        self.label = "E-mail message: MESSAGE"
        self.regexp_str = "^ *" + self.regexp_str + " *$"  #so that the same string with heading and trailing whitespaces also matches
        self.regexp = QRegExp(self.regexp_str)

    def run(self, main):
        values = self.regexp.capturedTexts()
        msg = values[1]
        try:
            email_alert = Email_alert(message=msg.encode('utf8'),
                                      address=main.ui.email_address.text(),
                                      subject="Message from PyGMI",
                                      smtpadd=main.mainconf['smtpadd'],
                                      login=main.mainconf['login'],
                                      mdp=main.mainconf['mdp'],
                                      smtpport=main.mainconf['smtpport'])
            print "message successfully sent by e-mail"
        except:
            print "Exception: message could not be sent by e-mail"
        #go to next line of macro
        self.next_move = 1
        self.wait_time = 500
コード例 #42
0
ファイル: pqPages.py プロジェクト: tallforasmurf/PPQT
    MW.setCentralWidget(widj)
    MW.setWinModStatus = setWinModStatus
    MW.show()
    fn = QFileDialog.getOpenFileName(None,"Select a Test Book")
    print(fn)
    fh = QFile(fn)
    if not fh.open(QFile.ReadOnly):
        raise IOError, unicode(fh.errorString())
    stream = QTextStream(fh)
    stream.setCodec("UTF-8")
    IMC.editWidget.setPlainText(stream.readAll()) # load the editor doc
    widj.docWillChange()
    # Code from pqEdit to parse a doc by lines and extract page seps.
    reLineSep = QRegExp(u'-----File: ([^\\.]+)\\.png---((\\\\[^\\\\]*)+)\\\\-*',Qt.CaseSensitive)
    qtb = IMC.editWidget.document().begin() # first text block
    IMC.pageTable.clear()
    while qtb != IMC.editWidget.document().end(): # up to end of document
        qsLine = qtb.text() # text of line as qstring
        if reLineSep.exactMatch(qsLine): # a page separator
            qsfilenum = reLineSep.capturedTexts()[1]
            qsproofers = reLineSep.capturedTexts()[2]
            # proofer names can contain spaces, replace with en-space char
            qsproofers.replace(QChar(" "),QChar(0x2002))
            tcursor = QTextCursor(IMC.editWidget.document())
            tcursor.setPosition(qtb.position())
            IMC.pageTable.loadPsep(tcursor, qsfilenum, qsproofers)
        # ignore non-seps
        qtb = qtb.next()
    widj.docHasChanged()
    app.exec_()
コード例 #43
0
ファイル: 2669.py プロジェクト: jlg234bob/PPQT
    MW.show()
    fn = QFileDialog.getOpenFileName(None, "Select a Test Book")
    print(fn)
    fh = QFile(fn)
    if not fh.open(QFile.ReadOnly):
        raise IOError, unicode(fh.errorString())
    stream = QTextStream(fh)
    stream.setCodec("UTF-8")
    IMC.editWidget.setPlainText(stream.readAll())  # load the editor doc
    widj.docWillChange()
    # Code from pqEdit to parse a doc by lines and extract page seps.
    reLineSep = QRegExp(
        u'-----File: ([^\\.]+)\\.png---((\\\\[^\\\\]*)+)\\\\-*',
        Qt.CaseSensitive)
    qtb = IMC.editWidget.document().begin()  # first text block
    IMC.pageTable.clear()
    while qtb != IMC.editWidget.document().end():  # up to end of document
        qsLine = qtb.text()  # text of line as qstring
        if reLineSep.exactMatch(qsLine):  # a page separator
            qsfilenum = reLineSep.capturedTexts()[1]
            qsproofers = reLineSep.capturedTexts()[2]
            # proofer names can contain spaces, replace with en-space char
            qsproofers.replace(QChar(" "), QChar(0x2002))
            tcursor = QTextCursor(IMC.editWidget.document())
            tcursor.setPosition(qtb.position())
            IMC.pageTable.loadPsep(tcursor, qsfilenum, qsproofers)
        # ignore non-seps
        qtb = qtb.next()
    widj.docHasChanged()
    app.exec_()
コード例 #44
0
ファイル: highlighter.py プロジェクト: papablopo07/pireal
class Highlighter(QSyntaxHighlighter):
    """ Syntax Highlighting

    This class defines rules, a rule consists of a QRegExp pattern and a
    QTextCharFormat instance.
    """

    # Keywords
    KEYWORDS = [
        "select",
        "project",
        "rename",
        "product",
        "njoin",
        "difference",
        "intersect",
        "union",
        "and",
        "or"
    ]

    def __init__(self, editor):
        super(Highlighter, self).__init__(editor)
        # Keywords format
        keyword_format = QTextCharFormat()
        keyword_format.setForeground(Qt.darkBlue)
        keyword_format.setFontWeight(QFont.Bold)

        # Rules
        self._rules = [(QRegExp("\\b" + pattern + "\\b"), keyword_format)
                       for pattern in Highlighter.KEYWORDS]

        # Number format
        number_format = QTextCharFormat()
        number_pattern = QRegExp(r"\b([A-Z0-9]+)(?:[ _-](\d+))?\b")
        number_pattern.setMinimal(True)
        number_format.setForeground(Qt.darkCyan)
        self._rules.append((number_pattern, number_format))

        # String format
        string_format = QTextCharFormat()
        string_pattern = QRegExp("\".*\"|\'.*\'")
        string_pattern.setMinimal(True)
        string_format.setForeground(Qt.darkMagenta)
        self._rules.append((string_pattern, string_format))

        # Comment format
        comment_format = QTextCharFormat()
        comment_pattern = QRegExp("--[^\n]*")
        comment_format.setForeground(Qt.darkGreen)
        self._rules.append((comment_pattern, comment_format))

        # Paren
        self.paren = QRegExp('\(|\)')

    def highlightBlock(self, text):
        """ Reimplementation """

        block_data = TextBlockData()
        # Paren
        index = self.paren.indexIn(text, 0)
        while index >= 0:
            matched_paren = str(self.paren.capturedTexts()[0])
            info = ParenInfo(matched_paren, index)
            block_data.insert_paren_info(info)
            index = self.paren.indexIn(text, index + 1)

        self.setCurrentBlockUserData(block_data)

        for pattern, _format in self._rules:
            expression = QRegExp(pattern)
            index = expression.indexIn(text)
            while index >= 0:
                length = expression.matchedLength()
                self.setFormat(index, length, _format)
                index = expression.indexIn(text, index + length)

        self.setCurrentBlockState(0)