Changeset 13818 for fact/tools/PyDimCtrl/pyfactctrl.py
- Timestamp:
- 05/23/12 02:59:43 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/PyDimCtrl/pyfactctrl.py
r13814 r13818 1 1 #!/usr/bin/python -tti 2 2 from factdimserver import * 3 4 3 5 4 6 # List of Wobble Positions … … 33 35 34 36 VoltageOn( mode='current' ) 35 for i in range(4): 36 msg("Taking Data Run "+str(i+1)+" of 4") 37 TakeDataRun() 37 TakeData() #Ped | ExtLP | 4x Data 38 38 VoltageOff() 39 39 … … 223 223 In all other cases, the method will perform the needed steps to switch 224 224 on the bias voltage, the way the user requested 225 226 raises NotImplementedError in case of 'feedback' 225 227 """ 226 228 msg = MSG( verbose ) … … 234 236 fb_target = 10 #TempControl 235 237 elif mode == 'feedback': 236 fb_target = 11 # FeedbackControl 238 #fb_target = 11 # FeedbackControl 239 raise NotImplementedError('The author of this script did not know how to start this mode') 237 240 elif mode == 'current': 238 241 fb_target = 12 #CurrentControl … … 242 245 starttime = time.time() 243 246 244 while not ((bias.stn == bias_target) and (fb.stn == fb_target)): 247 long_enough = (time.time() - bias.last_st_change > 2) and (time.time() - fb.last_st_change > 2) 248 while not ((bias.stn == bias_target) and (fb.stn == fb_target) and long_enough): 249 245 250 if time.time() - starttime > timeout: 246 251 msg.fail("VoltageOn did not succeed after "+str(timeout)+' seconds') 247 252 return False 248 253 249 254 elif fb.stn == fb_target-3: # everything fine, but output disabled 250 255 fb.enable_output(1) 251 bias.set_global_dac(1)256 252 257 253 258 elif fb.stn == fb_target and bias.stn == 5: # feedback ok, but we are Ramping 254 259 # lets try to wait 255 260 time.sleep(0.5) 261 262 elif fb.stn == 6: #Connected 263 if mode == 'temperature': 264 fb.start_temp_control(0.0) 265 elif mode == 'current': 266 fb.start_current_control(0.0) 267 elif mode == 'feedback': 268 raise NotImplementedError('The author of this script did not know how to start this mode') 256 269 257 270 elif bias.stn == 1: #Disconnected 258 271 bias.reconnect() 272 # makes no sense to be quick in this case 273 time.sleep(2) 259 274 260 275 elif bias.stn == 6: # Overcurrent … … 279 294 # if nothing was done. sleep a while 280 295 time.sleep(0.5) 281 282 296 297 long_enough = (time.time() - bias.last_st_change > 2) and (time.time() - fb.last_st_change > 2) 283 298 284 285 msg("waiting 45sec...") 286 time.sleep(45) 287 return True 288 299 300 msg.ok("Voltage is On") 301 if mode == 'current': 302 msg("Waiting 45sec, so we get at least 3 current readings") 303 time.sleep(45) 304 305 return True 306 307 def VoltageOff( timeout = 10, verbose = True): 308 """ High Level Method for switching off the bias Voltage 309 """ 310 msg = MSG( verbose ) 311 bias = bias_control 312 313 bias.set_zero_voltage() 314 315 starttime = time.time() 316 while not bias.stn == 7: # VoltageOff 317 if time.time() - starttime > timeout: 318 msg.fail("VoltageOff did not succeed after "+str(timeout)+' seconds') 319 return False 320 time.sleep(1) 321 322 msg.ok("Voltage is Off") 323 return True 289 324 290 325 … … 305 340 306 341 307 def IsReadyForDataTaking( verbose = True ): 342 #============================================================================== 343 def IsReadyForDataTaking( TrackingNeeded = True, verbose = True ): 308 344 drive = drive_control 309 345 bias = bias_control … … 315 351 316 352 ok = True 317 if not drive.stn == 7: 318 msg.warn(drive.name + ':' + drive.sts + " NOT ok") 319 ok = False 320 else: 321 msg.ok(drive.name + ':' + drive.sts + " OK") 353 if TrackingNeeded: 354 if not drive.stn == 7: 355 msg.warn(drive.name + ':' + drive.sts + " NOT ok") 356 ok = False 357 else: 358 msg.ok(drive.name + ':' + drive.sts + " OK") 322 359 323 360 if not feedback.stn == 12: … … 347 384 def TakeDataRun( verbose = True ): 348 385 fad = fad_control 349 msg = MSG( )350 msg.output = verbose 386 msg = MSG(verbose) 387 351 388 if not IsReadyForDataTaking( verbose=False ): 352 389 msg.fail("System not Ready for DataTaking") … … 364 401 365 402 def TakePedestalOnRun( verbose = True ): 366 msg = MSG( )367 msg.output = verbose 368 if not IsReadyForDataTaking( verbose=False ):403 msg = MSG(verbose) 404 405 if not IsReadyForDataTaking( TrackingNeeded=False, verbose=False ): 369 406 msg.fail("System not Ready for DataTaking") 370 407 IsReadyForDataTaking( verbose=True ) … … 381 418 382 419 def TakeExtLpRun( verbose = True ): 383 msg = MSG() 384 msg.output = verbose 385 if not IsReadyForDataTaking( verbose=False ): 420 msg = MSG(verbose) 421 if not IsReadyForDataTaking( TrackingNeeded=False, verbose=False ): 386 422 msg.fail("System not Ready for DataTaking") 387 423 IsReadyForDataTaking( verbose=True ) … … 398 434 399 435 def TakeData( verbose = True): 400 msg = MSG() 401 msg.output = verbose 436 msg = MSG(verbose) 402 437 TakePedestalOnRun() 403 438 TakeExtLpRun() … … 696 731 697 732 #============================================================================== 698 # standard watchdog:699 def std_bias_watchdog( state, verbose=True ):700 msg = MSG(verbose)701 if state == 1: #Disconnected702 msg.warn("BIAS just DISCONNECTED .. trying to reconnect")703 msg.warn("current runnumber:"+fad_control.runnumber() )704 bias.reconnect()705 time.sleep(1)706 bias.set_zero_voltage()707 # TODO: This should work, but it is stupid.708 bias.reset_over_current_status()709 bias.reset_over_current_status()710 bias.set_zero_voltage()711 bias.reset_over_current_status()712 bias.set_global_dac(1)713 714 733 # create introduction: 715 734 class INTRO(object): … … 721 740 print "welcome to PyDimCtrl V0.1:" 722 741 print "--------------------------" 723 print "If the hardware is ON but not all the software is connected try:"724 print " Connect()"725 742 print "If all the programs are already up and running, you might want to" 726 743 print " TakeDrsAmplitudeCalibration(roi=1024) or " … … 736 753 print "Switch off with:" 737 754 print " VoltageOff()" 755 print "In case you would like to simply take Data of a certain source try:" 756 print " TakeFullSet(source = 'Crab')" 738 757 print "" 739 print "In case you would like a Watchdog to check, if the Voltage is up" 740 print "and the BiasCrate is not disconnected, then try:" 741 print " VoltageOn( mode='--see above--', Watchdog=True )" 742 print "PLEASE NOTE: The Watchdog will monitor the State of BIAS_CONTROL" 743 print "and in case of a connection loss, it will: " 744 print " * print a warning" 745 print " * issue a the RECONNECT command" 746 print " * issue SET_ZERO_VOLTAGE - since this is the only way to get referenced" 747 print " * Ramp up again, using the same settings as before" 748 print " * possible OverCurrent situation will be treated as usual" 749 print "The Watchdog will not react on any other state change, like OverCurrent or VoltageOff" 758 print "look at the 'source_list' to get an overview, of the " 759 print "current sources available:" 760 print " pprint(source_list)" 761 print "" 762 print "" 750 763 print "" 751 764 print ""
Note:
See TracChangeset
for help on using the changeset viewer.