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()
Пример #2
0
    print "\n\n-------------------------------\n"
    
    try:
        while weBeenInterrupted==False:

            command=raw_input('HIT ENTER TO SEND SYNC SIGNALS:')
            logging.debug("raw_input = {0}".format(command));
            syncListeners(listeners)
            print 'SYNC SIGNAL SENT'
    except KeyboardInterrupt:
        pass;
    print "\n\n-------------------------------\n"
    print "EXPERIMENT STOPPED: STILL PERIOD AT END STARTING"
    print "\n\n-------------------------------\n"
    i=5;
    try:
        while i>0:
            sleep(1)
            i -= 1
            print '.'
    except KeyboardInterrupt:
        print 'END STILL PERIOD INTERRUPTED'
    print "\n\n-------------------------------------------------------"
    print "-------------------------------------------------------"
    print "-------------------------------------------------------"
    print "SHUTTING DOWN"
    print "\n\n-------------------------------\n"
    shutDownExperiment(listeners)
    print "EXITING (YOU CAN NOW MOVE): RUN {0}  in file {1} COMPLETED".format(
        options.runname,options.outfile)
    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()