Esempio n. 1
0
        private void RunNextExperiment(int expIndex)
        {
            IExperiment exp = (IExperiment)scanMethod[expIndex];

            log.Add("Configuring " + ((ParametrizableObject)exp).Name + "...");
            enExperimentStatus expStatus = exp.Configure(null, scanMethodResultsPath);

            if ((expStatus != enExperimentStatus.OK) && (expStatus != enExperimentStatus.Idle))
            {
                log.Warning("Experiment Sequence Aborted due to exp.Configure() returning: " + expStatus);
                OnNotifyScanEnded(new ExperimentEndedEventArgs(enExperimentStatus.Error, null));
            }

            exp.NotifyExperimentDataUpdated -= Exp_NotifyExperimentDataUpdated;
            exp.NotifyExperimentDataUpdated += Exp_NotifyExperimentDataUpdated;
            exp.NotifyExperimentEnded       -= Exp_NotifyExperimentEnded;
            exp.NotifyExperimentEnded       += Exp_NotifyExperimentEnded;
            experimentRunning     = expIndex;
            experimentRunningName = (scanMethod[experimentRunning] as ParametrizableObject).Name;

            log.Add("Running " + ((ParametrizableObject)exp).Name + "...");
            expStatus = exp.Run();
            if ((expStatus != enExperimentStatus.OK) && (expStatus != enExperimentStatus.Running))
            {
                exp.NotifyExperimentDataUpdated -= Exp_NotifyExperimentDataUpdated;
                exp.NotifyExperimentEnded       -= Exp_NotifyExperimentEnded;
                try
                {
                    // just in case Experiment was started
                    exp.Abort();
                }
                catch (Exception e)
                {
                }
                log.Warning("Experiment Sequence Aborted due to exp.Run() returning: " + expStatus);
                OnNotifyScanEnded(new ExperimentEndedEventArgs(enExperimentStatus.Error, null));
            }
        }