def run(self): print "ExecutionThread: starting loop" while True: # Waiting to run print "Waiting to run." while self.experimentControlBackground.running == False: time.sleep(0.5) # In A Run Cycle # Setting up print "Settting Up" try: self.experimentControlBackground.updateGlobalExperimentFeedBackSettingUp() listeners = startExperiment( self.experimentControlBackground.filename, self.experimentControlBackground.runName, self.experimentControlBackground.serialImu, self.experimentControlBackground.serialAnt, self.experimentControlBackground.serialAr, self.experimentControlBackground.serialArduino, imuPort=self.experimentControlBackground.imuPort, imuHost=self.experimentControlBackground.imuHost, recordVideo=self.experimentControlBackground.components.recordVideo.checked, ) i = ITERATIONS_SETTING_UP while i > 0: time.sleep(1) i -= 1 print "." except Exception as ex: print "ERROR SETTING UP:{0}".format(str(ex)) self.experimentControlBackground.updateGlobalExperimentFeedBackErrorSettingUp() print "Running" try: self.experimentControlBackground.updateGlobalExperimentFeedBackRunning() while self.experimentControlBackground.running == True: syncListeners(listeners) time.sleep(0.25) except Exception as ex: print "ERROR RUNNING:{0}".format(str(ex)) self.experimentControlBackground.updateGlobalExperimentFeedBackErrorRunning() # Tearing Down print "Tear down" try: self.experimentControlBackground.updateGlobalExperimentFeedBackTearingDown() i = ITERATIONS_TEARING_DOWN while i > 0: time.sleep(1) i -= 1 print "." print "Stopped" shutDownExperiment(listeners) self.experimentControlBackground.updateStartButtonStart() self.experimentControlBackground.updateGlobalExperimentFeedBackInactive() # Clean Up listeners = [] except Exception as ex: print "ERROR RUNNING:{0}:\n{1}".format(str(ex), traceback.print_exc()) self.experimentControlBackground.updateGlobalExperimentFeedBackErrorTearingDown() time.sleep(2) self.experimentControlBackground.setRunning(False) self.experimentControlBackground.updateStartButtonStart() self.experimentControlBackground.updateGlobalExperimentFeedBackInactive()
print "\n\n-------------------------------\n" print "Specify the rest run name (--runname 01CornerTestRun) " print "\n\n-------------------------------\n" exit() currentRuns = SofiePyTableAccess.getRunsInTheFile(options.outfile, options.runname) if currentRuns: print "\n\n-------------------------------\n" print "The run '{0}' is already in the file '{1}':\n\nCurrent Runs:\n{2}".\ format(options.runname,options.outfile,currentRuns) print "\n\n-------------------------------\n" exit() listeners = \ startExperiment(options.outfile, options.runname, options.serialimu,options.serialant,options.serialar, imuPort=options.imuport,imuHost=options.imuhost, arHighRes=options.highres,arMarkerSize=options.bigmarker) print "\n\n-------------------------------\n" print "LOGGING SETUP: CALLIBRATION STILL PERIOD STARTS" print "\n\n-------------------------------\n" i=8; weBeenInterrupted = False try: while i>0: sleep(1) i -= 1 print '.' except KeyboardInterrupt: weBeenInterrupted = True; print "\n\n-------------------------------\n"
def run (self): print "ExecutionThread: starting loop" while True: #Waiting to run print 'Waiting to run.' while self.experimentControlBackground.running == False: time.sleep(0.5) #In A Run Cycle #Setting up print 'Settting Up' try: self.experimentControlBackground.\ updateGlobalExperimentFeedBackSettingUp() listeners = \ startExperiment(self.experimentControlBackground.filename, self.experimentControlBackground.runName, self.experimentControlBackground.serialImu, self.experimentControlBackground.serialAnt, self.experimentControlBackground.serialAr, self.experimentControlBackground.serialArduino, imuPort=self.experimentControlBackground.imuPort, imuHost=self.experimentControlBackground.imuHost, recordVideo=self.experimentControlBackground.components.recordVideo.checked ) i=ITERATIONS_SETTING_UP; while i>0: time.sleep(1) i -= 1 print '.' except Exception as ex: print 'ERROR SETTING UP:{0}'.format(str(ex)) self.experimentControlBackground.\ updateGlobalExperimentFeedBackErrorSettingUp() print 'Running' try: self.experimentControlBackground.\ updateGlobalExperimentFeedBackRunning() while self.experimentControlBackground.running == True: syncListeners(listeners) time.sleep(0.25) except Exception as ex: print 'ERROR RUNNING:{0}'.format(str(ex)) self.experimentControlBackground.updateGlobalExperimentFeedBackErrorRunning() #Tearing Down print 'Tear down' try: self.experimentControlBackground.\ updateGlobalExperimentFeedBackTearingDown() i=ITERATIONS_TEARING_DOWN; while i>0: time.sleep(1) i -= 1 print '.' print 'Stopped' shutDownExperiment(listeners) self.experimentControlBackground.updateStartButtonStart() self.experimentControlBackground.\ updateGlobalExperimentFeedBackInactive() #Clean Up listeners = [] except Exception as ex: print 'ERROR RUNNING:{0}:\n{1}'.format(str(ex),traceback.print_exc()) self.experimentControlBackground.\ updateGlobalExperimentFeedBackErrorTearingDown() time.sleep(2) self.experimentControlBackground.setRunning(False) self.experimentControlBackground.updateStartButtonStart() self.experimentControlBackground.\ updateGlobalExperimentFeedBackInactive()