Changeset 13809
- Timestamp:
- 05/22/12 07:53:28 (12 years ago)
- Location:
- fact/tools/PyDimCtrl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/PyDimCtrl/factdimserver.py
r13808 r13809 58 58 *returns* numeric state code, parsed from return of self.state() 59 59 """ 60 if hasattr(self, 'state'): 61 s = self.state()[0] 62 return int(s[ s.find('[')+1 : s.find(']') ]) 60 if hasattr(self, 'stn'): 61 return self.stn 63 62 else: 64 63 raise TypeError(self.name+' has no CMD called STATE') … … 72 71 """ 73 72 74 if not hasattr(self, 'st ate'):73 if not hasattr(self, 'stn'): 75 74 raise TypeError(self.name+' has no CMD called STATE') 76 75 if timeout == None: … … 79 78 timeout = float(timeout) 80 79 start = time.time() 81 while not self ()== state_num:80 while not self.stn == state_num: 82 81 time.sleep(0.1) 83 82 if time.time() >= start+timeout: … … 316 315 globals()[server_name.lower()] = new_instance 317 316 del new_instance 318 317 del i 319 318 ############################################################################## 320 319 # class for colored printing -
fact/tools/PyDimCtrl/pyfactctrl.py
r13808 r13809 1 1 #!/usr/bin/python -tti 2 from fpydim import * 3 4 2 from factdimserver import * 5 3 6 4 def IsReadyForDataTaking( verbose = True ): … … 14 12 15 13 ok = True 16 if not drive ()== 7:17 msg.warn( drive.state()[0]+ " NOT ok")14 if not drive.stn == 7: 15 msg.warn(drive.name + ':' + drive.sts + " NOT ok") 18 16 ok = False 19 if not feedback() == 12: 20 msg.warn( feedback.state()[0] + " NOT ok") 17 else: 18 msg.ok(drive.name + ':' + drive.sts + " OK") 19 20 if not feedback.stn == 12: 21 msg.warn(feedback.name +':'+ feedback.sts + " NOT ok") 21 22 ok = False 22 if not bias() == 9: 23 msg.warn( bias.state()[0] + " NOT ok") 23 else: 24 msg.ok(feedback.name +':'+ feedback.sts + " OK") 25 26 if not bias.stn == 9: 27 msg.warn(bias.name +':'+ bias.sts + " NOT ok") 24 28 ok = False 25 if not fad() == 4: 26 msg.warn( fad.state()[0] + " NOT ok") 29 else: 30 msg.ok(bias.name +':'+ bias.sts + " OK") 31 32 if not fad.stn == 4: 33 msg.warn(fad.name +':'+ fad.sts + " NOT ok") 27 34 ok = False 35 else: 36 msg.ok(fad.name +':'+ fad.sts + " ok") 37 28 38 29 39 if ok: … … 67 77 def TrackSource( Shift=0.6, Angle=50, SrcName='Crab', verbose=True): 68 78 drive = drive_control 69 70 msg = MSG() 71 msg.output = verbose 72 73 if not drive.wait(5, 10): 74 msg.warn("drive not ready after 10sec") 75 msg.warn( drive.state()[0].rstrip('\x00') ) 76 return False 77 79 msg = MSG( verbose ) 78 80 SrcName += '\0' 81 82 timeout = 3 83 starttime = time.time() 84 while not drive.stn == 5: 85 if time.time() - starttime > timeout: 86 msg.fail('Did not get DRIVE into Armed state') 87 return False 88 89 if drive.stn < 5: 90 msg.fail('DRIVE in state'+drive.sts+" I don't what to do.") 91 if drive.stn >= 256: 92 msg.fail('DRIVE in state'+drive.sts+" I don't what to do.") 93 94 if drive.stn in [6,7]: 95 drive.stop() 96 time.sleep(0.5) 97 79 98 drive.track_source( Shift, Angle, SrcName) 80 81 99 return True 82 100 83 101 def WaitForTracking( CalmDownTime = 30, verbose = True): 84 102 drive = drive_control 85 86 msg = MSG() 87 msg.output = verbose 88 89 if not drive.wait(6, 10): 90 msg.warn("drive not in state moving after 10sec") 91 return False 92 93 if not drive.wait(7, 10): 94 msg.warn("drive not in state Tracking after 10sec") 95 return False 96 97 msg("waiting "+str(CalmDownTime)\ 98 +"sec for drive to calm down and tracking to be stable") 103 msg = MSG(verbose) 104 105 starttime = time.time() 106 time_out = 10 107 108 while not drive.stn == 7: #Tracking 109 if time.time() - starttime > time_out: 110 msg.fail("DRIVE not in Tracking after Timeout") 111 return False 112 113 msg.ok("Drive is Tracking, waiting to calm down...") 99 114 time.sleep(CalmDownTime) 100 115 return True 116 101 117 def TakePedestalOnRun( verbose = True ): 102 118 msg = MSG() … … 144 160 145 161 def Take( time=0, events=0, runtype='drs-pedestal', verbose=True): 146 msg = MSG() 147 msg.output = verbose 162 msg = MSG( verbose ) 148 163 fad = fad_control 149 164 runtype += '\0' … … 163 178 return True 164 179 180 def Take1218( verbose = True): 181 182 TrackSource( Shift=0.6, Angle=-5, SrcName='1ES 1218+304') 183 WaitForTracking( CalmDownTime = 45, verbose = True) 184 185 TakeDrsAmplitudeCalibration( roi=1024 ) 186 TakeDrsTimeCalibration( mode='upshifted' ) 187 TakeDrsAmplitudeCalibration( roi=300 ) 188 189 VoltageOn( mode='current' ) 190 for i in range(4): 191 msg("Taking Data Run "+str(i+1)+" of 4") 192 TakeDataRun() 193 VoltageOff() 194 195 TrackSource( Shift=0.6, Angle=175, SrcName='1ES 1218+304') 196 WaitForTracking( CalmDownTime = 45, verbose = True) 197 198 VoltageOn( mode='current' ) 199 for i in range(4): 200 msg("Taking Data Run "+str(i+1)+" of 4") 201 TakeDataRun() 202 VoltageOff() 203 204 drive_control.stop() 165 205 166 206 def BlinkenLights(verbose = True): … … 277 317 else: 278 318 # there might be a problem with one of the boards 279 conns = map( ord, fad.connections()[0] )280 problems = {}281 for fad,conn in enumerate(conns):282 if conn < 255:283 print "FAD:", fad, "has a problem"284 if not fad/10 in problems:285 problems[fad/10] = []286 else:287 problems[fad/10].append( fad%10 )319 conns = map( ord, fad.connections()[0] ) 320 problems = {} 321 for fad,conn in enumerate(conns): 322 if conn < 255: 323 print "FAD:", fad, "has a problem" 324 if not fad/10 in problems: 325 problems[fad/10] = [] 326 else: 327 problems[fad/10].append( fad%10 ) 288 328 289 for fad in range(10): 329 for fad in range(10): 330 for crate in problems.keys(): 331 fad.disconnect(crate*10+fad) 332 ftm.toggle_ftu(crate*10+fad) 290 333 for crate in problems.keys(): 291 fad.disconnect(crate*10+fad) 292 ftm.toggle_ftu(crate*10+fad) 293 for crate in problems.keys(): 294 time.sleep(1) 295 ftm.reset_crate(crate) 334 time.sleep(1) 335 ftm.reset_crate(crate) 296 336 297 for fad in range(10):298 for crate in problems.keys():299 time.sleep(3.5)300 fad.connect(crate*10+fad)301 ftm.toggle_ftu(crate*10+fad)337 for fad in range(10): 338 for crate in problems.keys(): 339 time.sleep(3.5) 340 fad.connect(crate*10+fad) 341 ftm.toggle_ftu(crate*10+fad) 302 342 303 343 elif fad.stn == 5: # Configuring1 … … 508 548 raise ValueError("mode must be 'temperature', 'current' or 'feedback'") 509 549 510 feedback.start(..... blaaaaa .....)511 hier muss noch ne menge passieren512 550 513 551 bias.set_global_dac(1) … … 526 564 return True 527 565 528 # standard watchdog s:566 # standard watchdog: 529 567 def std_bias_watchdog( state, verbose=True ): 530 568 msg = MSG(verbose)
Note:
See TracChangeset
for help on using the changeset viewer.