示例#1
0
 def status(self):
     '''returs a string of the status of the Be lens system'''
     lensin = self.is_in()
     if lensin in (1, 2, 3):
         spots = self.spotsize(printsummary=False)
         if spots < 1.5e-6: colour = 'green'
         else: colour = 'yellow'
         str = estr("Lens stack %s is" % lensin,
                    color="black",
                    type="normal")
         str += estr(" IN. ", color="yellow", type="normal")
         str += estr("spotsize = %e " % spots, color=colour, type="bold")
         zpos = self.z.wm()
         str += estr("(z position : %e" % zpos,
                     color='black',
                     type="normal")
         str += estr("   FWHM at lens %e" % self._fwhm_unfocused,
                     color='black',
                     type='normal')
         str += estr(" transmission : %e" % self.transmission(False),
                     color='black',
                     type='normal')
     elif lensin == "OUT":
         str = estr("Be Lenses are: ", color="black", type="normal")
         str += estr("OUT.", color="green", type="normal")
     else:
         str = estr("Be Lenses are in: ", color="black", type="normal")
         str += estr("UNKNOWN position. ", color="red", type="normal")
     return str
示例#2
0
  def _format(self,step=None,desc=True):
    sl = []
    sl.append(estr(self.name +' Procedure'))
    if desc and self._obj['desc']:
      sl.append(fill(self._desc,width=self._width))
    tdasteps = []
    for stepNo,tstep in enumerate(self._steps):
      tdasteps.append(fill(tstep,width=self._width,
	initial_indent='('+str(stepNo+1)+') ',
	subsequent_indent=' '*4))
    if not step==None:
      dasteps = []
      if step>0:
	dasteps.append(tdasteps[step-1])
      dasteps.append(estr(tdasteps[step]))
      if len(tdasteps)>step+1:
	dasteps.append(tdasteps[step+1])
    else:
      dasteps = tdasteps
	
    sl.extend(dasteps)

    op = ('\n\n').join(sl)
    op = '\n'+op
    return op
示例#3
0
 def status(self):
     '''Prints the status of the shutter.'''
     statstr = self._name + ' is '
     if self.isopen():
         statstr += estr('open', color='yellow', type='normal')
     else:
         statstr += estr('closed', color='green', type='normal')
     return (statstr)
示例#4
0
 def status(self):
   s = "attenuator %s (%d um of %s) is in position: "%(self.PVbase, self.d(), self.material())
   if self.state() == Filter.IN:
     s += estr("IN",color="green",type="normal")
   elif self.state() == Filter.OUT:
     s += estr("OUT",color="green",type="normal")
   else:
     s += estr("Unknown",color="yellow",type="normal")
   return s
示例#5
0
    def status(self):
        homsstat = self.__desc + " is "
        if self.is_in():
            homsstat += estr("IN", color="yellow", type="normal")
            a_enc = self.get_angle_encoder()
            homsstat += " (angle encoder = " + str(a_enc) + ")"
        elif self.is_parked():
            homsstat += estr("PARKED", color="green", type="normal")
        else:
            homsstat += "in "
            homsstat += estr("UNKNOWN position", color="red", type="normal")

        return homsstat
示例#6
0
 def status(self):
     from blutil import estr
     if self._type == 'feeatt':
         s = "attenuator %s (%d um of %s) is in position: "%(self.PVbase, 
                 self._filter.d*1.e6, str(self._filter.material))
         if self.isin():
           s += estr("IN",color="green",type="normal")
         elif self.isout():
           s += estr("OUT",color="green",type="normal")
         else:
           s += estr("Unknown",color="yellow",type="normal")
         return s
     else:
         return self._filter.status()
示例#7
0
 def status(self):
   E=self.getE()
   E0=self.get_E0()
   leakage=self.get_leakage()
   wp=Pv.get(self.wp_pv)
   if self.shg:
     state=estr("400 nm",color='blue',type='normal')
   else:
     state=estr("800 nm",color='red',type='normal')
   str ="  %s: %4.4f\n" % (self.name,E)
   str +="      State: %s\n" % state
   str +="  Waveplate: %3.2f deg\n" % wp
   str +="         E0: %3.4f \n" % E0
   str +="    Leakage: %3.4f \n" % leakage
   return str
示例#8
0
 def status(self):
     volt = Pv.get(self.pv_Volt)
     onoff = Pv.get(self.pv_OnOff)
     if onoff == 0:
         sstatus = estr("On", color='green', type='bold')
     elif onoff == 1:
         sstatus = estr("Off", color='red', type='bold')
     else:
         sstatus = estr("Not Known", color='white', type='normal')
     str1 = "%s:" % self.name
     str2 = " %s\n" % sstatus
     str3 = "Level:"
     str4 = " %d%%" % (self.level() * 100)
     str = str1.rjust(10) + str2.ljust(5) + str3.rjust(10) + str4.ljust(5)
     return str
示例#9
0
    def status(self):
        #get clostest position in y
        #deltas = self.y._presetDelta()
        status = ''
        status += 'Pulse picker -- '
        isopen = Pv.get(self._PVname('DF')) == 0
        if isopen:
            status += blutil.estr('open', color='green') + '\n'
        else:
            status += blutil.estr('closed', color='red') + '\n'
        #status += '\t%g from %s' %(deltas[0][1],deltas[0][0])
        #status += '\n'
        #status += self.trigger.status()

        return status
示例#10
0
 def status(self, num):
     '''Returns the status of the solenoid.'''
     if num >= 0 and num < 9: statstr = self._name + ' is '
     else:
         print "Solenoid number must be between 1-8"
         return
     if Pv.get(self._basepv + ':' + num + ':OUT') == 1:
         statstr += estr('out', color='green', type='normal')
     elif Pv.get(self._basepv + ':' + num + ':IN') == 1:
         statstr += estr('in', color='red', type='normal')
     else:
         statstr += estr('neither out nor in - perhaps moving?',
                         color='yellow',
                         type='fault')
     return (statstr)
示例#11
0
 def status(self):
   pos = self.m.wm()
   if self.isin():
     pos_str =  estr("IN",color="red",type="normal")
   elif self.isout():
     pos_str =  estr("OUT",color="green",type="normal")
   else:
     pos_str = estr("UNKOWN",color="red")
   str = "Ref laser position is : %s (stage at %.3f mm)" % (pos_str,pos)
   if hasattr(self, 'x') or hasattr(self, 'y') or hasattr(self, 'rx') or hasattr(self, 'ry'):
     str+='\npico motors positions: \n'
     if hasattr(self, 'x'): str+='x = %+.4f\n' % self.x.wm()
     if hasattr(self, 'y'): str+='y = %+.4f\n' % self.y.wm()
     if hasattr(self, 'rx'): str+='rx = %+.4f\n' % self.rx.wm()
     if hasattr(self, 'ry'): str+='ry = %+.4f\n' % self.ry.wm()
   return str
示例#12
0
 def status(self):
     '''return a string that formats the delay and t0 '''
     retstr = 'Nanosecond laser : '
     delay = self.delay()
     if not (-5e-9 < delay < 50e-9):
         color = 'red'
         type = 'bold'
     else:
         color = 'black'
         type = 'normal'
     retstr += estr('Delay = ' + str(delay) + '\n', color=color, type=type)
     retstr += estr('                   T0 = ' + str(self.get_offset()) +
                    '\n',
                    color=color,
                    type=type)
     return retstr
示例#13
0
 def setDelay(self,value):
   if abs(value)>0.1:
     warnString=blutil.estr('This function is expecting seconds, you likely forgot a e-12. \n The current %s:FS_TGT_TIME is %g"%(self.PVbase,self._PVtarg.value)',color='red',type='bold')
     print warnString
   self.wait()
   self._newtarget = value*1e9
   self._lastmovetime = time()
   return self._PVtarg.put(self._newtarget)
示例#14
0
 def status(self):
     """
 Returns the detailed status of a valve
 NB: If valve is neither open OR closed,
 or both open AND closed,
 status will be reported as 'NOT KNOWN'
 """
     op = self.isopen()
     cl = self.isclosed()
     if ((op and cl) or (not op and not cl)):
         vstatus = estr("NOT KNOWN", color='red', type='normal')
     elif op:
         vstatus = estr("OPEN", color='green', type='normal')
     elif cl:
         vstatus = estr("CLOSED", color='orange', type='normal')
     str1 = "%s:" % self.name
     str2 = " %s" % vstatus
     str = str1.rjust(9) + str2.ljust(13)
     return str
示例#15
0
 def status(self):
     str = estr("%s " % self.__desc, color="black", type="bold")
     pos = self.y.wm()
     if (abs(pos - self.__screen_in_pos) < 5e-3):
         str += "screen is %s\n" % estr("IN", type="normal")
     elif (abs(pos - self.__diode_in_pos) < 5e-3):
         str += "diode is %s\n" % estr("IN", type="normal")
     elif (abs(pos - self.__all_out_pos) < 5e-3):
         str += "all elements are %s\n" % estr(
             "OUT", color="green", type="normal")
     else:
         str += "%s\n" % estr("UNKOWN position", type="normal")
     str += " zoom %.1f%%\n" % self.zoom.wm()
     if (self.focus is not None):
         str += " focus %.1f%%\n" % self.focus.wm()
     if (self.__led is not None):
         str += " light level %s%%\n" % self.__getlight()
     if (self.__det is not None):
         str += " %s" % self.__det.status()
     return str
示例#16
0
 def info(self):
     """ Returns the ion pump information """
     current = Pv.get(self.__imon)
     voltage = Pv.get(self.__vmon)
     controller = Pv.get(self.__vpcname)
     pumpsize = Pv.get(self.__pumpsize)
     statemon = Pv.get(self.__statemon)
     if (statemon == 0):
         state = estr("Off", color='red', type='normal')
     elif (statemon == 1):
         state = "On"
     else:
         state = estr("Unknown", color='white', type='normal')
     str = "   %s\n" % (self.status())
     str += "   Current: %.2e Amps\n" % current
     str += "   Voltage: %4.0f Volts\n" % voltage
     str += "     State: %s\n" % state
     str += "      Size: %s l/s\n" % pumpsize
     str += "Controller: %s\n" % controller
     print str
示例#17
0
 def status(self):
     str = estr("**LADM Status**\n ", color="white", type="bold")
     str += "\t%10s\t%10s\t%10s\n" % ("Motor", "User", "Dial")
     str += "\t%10s\t%+10.4f\t%+10.4s\n" % ("theta", self.theta.wm(), "-")
     str += "\t%10s\t%+10.4f\t%+10.4s\n" % ("XT", self.XT.wm(), "-")
     keys = self.motors.keys()
     keys.sort()
     for key in keys:
         m = self.motors[key]
         str += "\t%10s\t%+10.4f\t%+10.4f\n" % (key, m.wm(), m.wm_dial())
     return str
示例#18
0
 def status(self):
     str = estr("%s " % self.__desc, color="black", type="bold")
     state = self.pim.state()
     if state == "YAG":
         str += "screen is %s\n" % estr("IN", type="normal")
     elif state == "DIODE":
         str += "diode is %s\n" % estr("IN", type="normal")
     elif state == "OUT":
         str += "all elements are %s\n" % estr(
             "OUT", color="green", type="normal")
     else:
         str += "%s\n" % estr("UNKOWN position", type="normal")
     if self.zoom:
         str += " zoom %.1f%%\n" % self.zoom.wm()
     if self.focus:
         str += " focus %.1f%%\n" % self.focus.wm()
     if self.__led:
         str += " light level %s%%\n" % self.__getlight()
     if self.__det:
         str += " %s" % self.__det.status()
     return str
示例#19
0
 def status(self, show_dets=None):
     str = estr(self.__desc, color="black", type="bold")
     if self.dx and self.dy:
         str += ", diode @ (dx,dy) = ({0:.4f},{1:.4f})".format(
             self.dx.wm(), self.dy.wm())
     str += ", diode {0}".format(self.diode.state())
     if self.ty:
         str += ", target @ ty = {0:.4f}".format(self.ty.wm())
     str += ", target {0}\n".format(self.target.state())
     if show_dets is None:
         show_dets = self.__show_dets
     if self.__det and show_dets:
         str += " {0}".format(self.__det.status())
     return str
示例#20
0
 def status(self):
     """ Returns the ion pump pressure reading """
     p_on = Pv.get(self.__statemon)
     if (p_on == 0):
         pstatus = estr("Ion Pump Off", color='white', type='normal')
     else:
         pressure = Pv.get(self.__pmon)
         if pressure < 5e-8:
             pstatus = estr("%.2e Torr" % pressure,
                            color='green',
                            type='normal')
         elif pressure < 1e-6:
             pstatus = estr("%.2e Torr" % pressure,
                            color='orange',
                            type='normal')
         else:
             pstatus = estr("%.2e Torr" % pressure,
                            color='red',
                            type='normal')
     str1 = "%s:" % self.name
     str2 = " %s" % pstatus
     str = str1.rjust(8) + str2.ljust(16)
     return str
示例#21
0
 def status(self):
     """ Returns the gauge reading """
     g_on = Pv.get(self.__statusmon)
     if (g_on != 0):
         gstatus = estr("Gauge Off", color='white', type='normal')
         str = "%s: %s" % (self.name, gstatus)
     else:
         pressure = Pv.get(self.__pmon)
         if pressure < 5e-8:
             gstatus = estr("%.1e Torr" % pressure,
                            color='green',
                            type='normal')
         elif pressure < 1e-6:
             gstatus = estr("%.1e Torr" % pressure,
                            color='orange',
                            type='normal')
         else:
             gstatus = estr("%.1e Torr" % pressure,
                            color='red',
                            type='normal')
     str1 = "%s:" % self.name
     str2 = " %s" % gstatus
     str = str1.rjust(12) + str2.ljust(13)
     return str
示例#22
0
 def getInOut(self):
   s_title = "filter# |"
   s_in    = " IN     |"
   s_out   = " OUT    |"
   for i, filt in enumerate(self.filters):
     status = filt.state()
     stuck = filt.stuck()
     s_title += "%d|" % i
     if status==Filter.IN:
       if stuck==Filter.NOT_STUCK:
         s_in += estr("X",color="green",type="normal")+"|"
       else:
         s_in += estr("S",color="red",type="normal")+"|"
       s_out+=" |"
     elif status==Filter.OUT:
       if stuck==Filter.NOT_STUCK:
         s_out += estr("X",color="green",type="normal")+"|"
       else:
         s_out += estr("S",color="red",type="normal")+"|"
       s_in+=" |"
     else:
       s_in += estr("?",color="yellow",type="normal")+"|"
       s_out+= estr("?",color="yellow",type="normal")+"|"
   return s_title, s_in, s_out
示例#23
0
def check_missing_PVs(motors,
                      daqepicsfile=None,
                      addfile=None,
                      updatelabel='missing_motors'):
    if daqepicsfile == None:
        daqepicsfile = '/reg/g/pcds/dist/pds/%s/misc/epicsArch.txt' % guessBeamline(
        )
    if addfile == None:
        bl = guessBeamline()
        blu = bl.upper()
        addfile = '/reg/g/pcds/dist/pds/%s/misc/epicsArch_%s_%spython.txt' % (
            bl, blu, bl)
    includedPVs = rdEpicsArchiveDaq(daqepicsfile, ignore_labels=True)
    try:
        includedPVs.pop(updatelabel)
    except:
        pass
    usedPVs = getMotorPvList(motors)
    update = dict()
    for lab, PV in zip(usedPVs.keys(), usedPVs.values()):
        isin = False
        for group in includedPVs:
            if PV in includedPVs[group].values():
                isin = True
        if not isin:
            update[lab] = PV
    pvs = []
    for PV in update.values():
        pvs.append(Pv.Pv(PV))
        pvs[-1].connect()
    sleep(1)
    isavailable = []
    for pv in pvs:
        isavailable.append(pv._Pv__connection_sem.isSet())

    print "Following motor PVs are not in the DAQ archiver, red=not available\n"
    labs = update.keys()
    PVs = update.values()
    labslen = max([len(lab) for lab in labs])
    PVslen = max([len(PV) for PV in PVs])
    for av, lab in zip(isavailable, labs):
        tstr = '   ' + ljust(lab, labslen, ' ') + ':  ' + update[lab]
        if not av:
            tstr = estr(tstr, color='red')
        print tstr
    print 'Would you like to write these to '
    print '%s ?' % addfile
    print 'y(es) / n(o) / o(nly available PVs) '
    inp = raw_input()
    if inp == 'y':
        writegroup = dict()
        writegroup[updatelabel] = update
        writeEpicsArchiveDaq(daqepicsfile, writegroup)
    elif inp == 'o':
        writegroup = dict()
        avupdate = dict()
        for ia, lab in zip(isavailable, labs):
            if ia:
                avupdate[lab] = update[lab]
        writegroup[updatelabel] = avupdate
        return writeEpicsArchiveDaq(daqepicsfile, writegroup)
示例#24
0
def warning(text):
    """Print text to screen in BOLD RED lettering."""
    print(estr(text, color="red", type="bold"))
示例#25
0
 def status(self):
     str = estr("%s" % self.__desc, color="black", type="bold")
     str += " %s" % self.getConfigpars()
     str += " %s" % self.getFEXpars()
     return str
示例#26
0
from blutil import config, estr, errorlogger
from blutil.update_checker import start_update_checker

# Allow exec/empty * import
__all__ = []

hutch = "cxi"

# Print starttime
dtstart = datetime.datetime.now()
print "{0}python start: {1}".format(hutch, dtstart.strftime("%Y%h%d-%H:%M:%S"))
sys.stdout.flush()

# Render title
pf = Figlet(font="speed")
print estr(pf.renderText("{0}python".format(hutch.title())), color=hutch)

# Define base directory early to allow error logging
config.HOME_DIR = "/reg/neh/operator/{0}opr/".format(hutch)
config.BASE_DIR = config.HOME_DIR + "{0}python_files/".format(hutch)

# Start error logging early to catch startup errors
logging_dir = "/reg/g/pcds/pds/{}/logfiles/".format(hutch)
errorlogger.IPythonErrLog(logging_dir +
                          "{1:04}/{2:02}/{3:02}_{0}python_errors.log".format(
                              hutch, dtstart.year, dtstart.month, dtstart.day))

# Start update checker early to catch updates during startup
start_update_checker()

# Load Elog early to get expname