예제 #1
0
        private void RunScan()
        {
            if (Settings.Tilt)
            {
                Tilt.CompensateTilt(); //check status after movement
                                       //todo: log the new position
            }

            int i = 0;
            enuScannerErrors res = enuScannerErrors.Ready;
            while ((!res.HasFlag(enuScannerErrors.Finished)) && (!abortExperiment))
            {
                // Here we run all child experiments including Autoapproch if contained in the queue at the first (and may be single) point of the scan
                Task childRunner = RunChildExperiments();
                // Wait for completion of ChildExperiments
                childRunner.Wait();

                if (status != enExperimentStatus.Completed)
                {
                    // Child Run did not complete regularly, do Error handling
                    NotifyExperimentEndedNow(new ExperimentEndedEventArgs(enExperimentStatus.Error, null));
                    return;
                }

                // Notify about Data update
                NotifyExperimentDataUpdatedNow(new ExperimentDataEventArgs(scanData, i > 0));

                // Go to Next Point (if there is one)
                //the scanner takes care of pre- and post-movements
                //but also tilt correction if set
                res = Scanner.NextPosition();

                i++;
            }

            //if (!abortExperiment)
            Scanner.BackToStart();

            // Signal Experiment end
            if (abortExperiment)
            {
                // Experiment was aborted
                status = enExperimentStatus.Aborted;
                NotifyExperimentEndedNow(new ExperimentEndedEventArgs(enExperimentStatus.Aborted, null));
            }
            else if (res.HasFlag(enuScannerErrors.Finished))
            {
                // Experiment ended regularly
                status = enExperimentStatus.Completed;
                NotifyExperimentEndedNow(new ExperimentEndedEventArgs(enExperimentStatus.Completed, scanData));
            }
            else
            {
                // Something else happend => error
                status = enExperimentStatus.Error;
                NotifyExperimentEndedNow(new ExperimentEndedEventArgs(enExperimentStatus.Error, null));
            }
        }
예제 #2
0
        public enuScannerErrors NextPosition()
        {
            if (!mStatus.HasFlag(enuScannerErrors.Initialized))
            {
                //todo log error
                return(mStatus);
            }

            //premovement hook: usually move away from surface to avoid damage of the tip
            if (mPositioner.SetRelativePosition(mPreMove) != enuPositionerStatus.Ready)
            {
                return(enuScannerErrors.Error); //todo either validate the position, or use automatic parameters validation by positioner
            }
            Position oldpos = new Position();   //this will be the current absolute position

            if (mPositioner.GetAbsolutePosition(ref oldpos) != enuPositionerStatus.Ready)
            {
                return(enuScannerErrors.Error);                    // todo: log the error?
            }
            Position Dest = CalculateNextAbsolutePosition(oldpos); // here we get a new absolute position to go as next

            if (Dest == null)
            {//no next position, scan finished
                mStatus |= enuScannerErrors.Finished;
                return(mStatus);
            }

            if (mTilt != null)
            {//consider the tilt corrected Z-height if tilt is set
                Dest.Z = mTilt.CalculateZ(Dest);
            }
            //and move to the next position

            //set speeds first, otherwise motors fail-safes will be used
            if (mPositioner.SetSpeeds(mSpeeds) != enuPositionerStatus.Ready)
            {
                return(enuScannerErrors.Error);                                                             // todo: log the error?
            }
            // move to dest position
            if (mPositioner.SetAbsolutePosition(Dest) != enuPositionerStatus.Ready)
            {
                return(enuScannerErrors.Error);                                                                    // todo: log the error?
            }
            log.AddStatusUpdate(0, Dest);

            //postmovement hook: usually move down to surface to reduce travel distance for FBC.
            //The hook is less, then the premovement. Not really meaningful while using tilt correction
            if (mPositioner.SetRelativePosition(mPostMove) != enuPositionerStatus.Ready)
            {
                return(enuScannerErrors.Error);
            }
            return(mStatus);
        }