Esempio n. 1
0
 public sealed override bool onUpdateCounts(uint[] counts)
 {
     customMeasureEventArgs = null;//ATTENTION! need to be modified if measure mode without waiting for count answer is applied
     //lock here?
     saveData(counts);
     if (toContinue())
     {
         // TODO:!
         if (CancelRequested)
         {
             stop();
             return(true);
         }
         if (!onNextStep())
         {
             // TODO: cannot perform step!
             OnDisable();
             return(false);
         }
     }
     else
     {
         OnSuccessfulExit(EventArgs.Empty);
         stop();
     }
     return(true);
 }
Esempio n. 2
0
 MeasureMode(ushort min, ushort max, ushort befTime, ushort iTime, ushort eTime, EventHandler successfulExit)
     : base(successfulExit)
 {
     _min = min;
     _max = max;
     instantMeasureEventArgs = new SingleMeasureEventArgs(0, eTime);
     generalMeasureEventArgs = new SingleMeasureEventArgs(iTime, eTime);
     firstMeasureEventArgs   = new SingleMeasureEventArgs(befTime, eTime);
 }
Esempio n. 3
0
 MeasureMode(ushort min, ushort max, ushort befTime, ushort iTime, ushort eTime, EventHandler successfulExit)
     : base(successfulExit)
 {
     _min = min;
     _max = max;
     instantMeasureEventArgs = new SingleMeasureEventArgs(0, eTime);
     generalMeasureEventArgs = new SingleMeasureEventArgs(iTime, eTime);
     firstMeasureEventArgs = new SingleMeasureEventArgs(befTime, eTime);
 }
Esempio n. 4
0
 public override sealed bool onUpdateCounts(uint[] counts)
 {
     customMeasureEventArgs = null;//ATTENTION! need to be modified if measure mode without waiting for count answer is applied
     //lock here?
     saveData(counts);
     if (toContinue()) {
         // TODO:!
         if (CancelRequested) {
             stop();
             return true;
         }
         if (!onNextStep()) {
             // TODO: cannot perform step!
             OnDisable();
             return false;
         }
     } else {
         OnSuccessfulExit(EventArgs.Empty);
         stop();
     }
     return true;
 }
Esempio n. 5
0
 public override bool Start()
 {
     //first measure point with increased idle time
     customMeasureEventArgs = firstMeasureEventArgs;
     return(base.Start());
 }
Esempio n. 6
0
            Precise(ushort min, ushort max, List <PreciseEditorData> peaks, ushort startDelay, ushort stepDelay, ushort exposition, ushort forwardDelay, ushort backwardDelay, Action <ushort, PreciseEditorData> graphUpdater, Action <long[][], List <PreciseEditorData>, short?> successfulExit, short?shift, Action <PreciseEditorData> checkOnPeakEnd)
                : base(min, max, startDelay, stepDelay, exposition, (s, e) => {
                var ee = (SuccessfulExitEventArgs)e;
                successfulExit(ee.Counts, ee.Points, ee.Shift);
            }) {
                _graphUpdater            = graphUpdater;
                _checkOnPeakEnd          = checkOnPeakEnd;
                forwardMeasureEventArgs  = new SingleMeasureEventArgs(forwardDelay, exposition);
                backwardMeasureEventArgs = new SingleMeasureEventArgs(backwardDelay, exposition);

                this.shift = shift;
                //Sort in increased order
                int count = peaks.Count;
                if (count == 0)
                {
                    // nothing to do... strange. throw smth?
                    return;
                }

                noPoints = false;
                // only peak value?
                peaks.Sort(PreciseEditorData.ComparePreciseEditorDataByPeakValue);
                _maxIterations = new ushort[count];
                smpiSumMax     = 0;
                _counts        = new long[count][];
                for (int i = 0; i < _maxIterations.Length; ++i)
                {
                    var peak      = peaks[i];
                    int dimension = 2 * peak.Width + 1;
                    _counts[i] = new long[dimension];
                    ushort iterations = peak.Iterations;
                    _maxIterations[i] = iterations;
                    smpiSumMax       += iterations;;
                    _overallSteps    += dimension * iterations;
                }
                _peaks = peaks;

                _overallExposition = _overallSteps * exposition;
                _iterations        = (ushort[])_maxIterations.Clone();
                ushort delay = startDelay;
                int    s     = 0;
                // TODO: unify with toContinue()
                for (int i = smpiSumMax, j = 0; i > 0; --i)
                {
                    for (int k = 0; k < count; ++k)
                    {
                        ++j;
                        j %= count;
                        if (_iterations[j] > 0)
                        {
                            break;
                        }
                    }
                    var p     = peaks[j];
                    int start = p.Step - p.Width;
                    int end   = p.Step + p.Width;
                    int diff  = start - s;
                    switch (diff)
                    {
                    case 0:
                        delay = 0;
                        break;

                    case 1:
                    case -1:
                        delay = stepDelay;
                        break;

                    default:
                        delay = diff > 0 ? forwardDelay : backwardDelay;
                        break;
                    }
                    _overallDelay += delay;
                    _overallDelay += (end - start) * stepDelay;
                    s              = end;
                    --_iterations[j];
                }
            }
Esempio n. 7
0
 public override bool Start()
 {
     //first measure point with increased idle time
     customMeasureEventArgs = firstMeasureEventArgs;
     return base.Start();
 }
Esempio n. 8
0
            Precise(ushort min, ushort max, List<PreciseEditorData> peaks, ushort startDelay, ushort stepDelay, ushort exposition, ushort forwardDelay, ushort backwardDelay, Action<ushort, PreciseEditorData> graphUpdater, Action<long[][], List<PreciseEditorData>, short?> successfulExit, short? shift, Action<PreciseEditorData> checkOnPeakEnd)
                : base(min, max, startDelay, stepDelay, exposition, (s, e) => {
                    var ee = (SuccessfulExitEventArgs)e;
                    successfulExit(ee.Counts, ee.Points, ee.Shift);
                })
            {
                _graphUpdater = graphUpdater;
                _checkOnPeakEnd = checkOnPeakEnd;
                forwardMeasureEventArgs = new SingleMeasureEventArgs(forwardDelay, exposition);
                backwardMeasureEventArgs = new SingleMeasureEventArgs(backwardDelay, exposition);

                this.shift = shift;
                //Sort in increased order
                int count = peaks.Count;
                if (count == 0) {
                    // nothing to do... strange. throw smth?
                    return;
                }

                noPoints = false;
                // only peak value?
                peaks.Sort(PreciseEditorData.ComparePreciseEditorDataByPeakValue);
                _maxIterations = new ushort[count];
                smpiSumMax = 0;
                _counts = new long[count][];
                for (int i = 0; i < _maxIterations.Length; ++i) {
                    var peak = peaks[i];
                    int dimension = 2 * peak.Width + 1;
                    _counts[i] = new long[dimension];
                    ushort iterations = peak.Iterations;
                    _maxIterations[i] = iterations;
                    smpiSumMax += iterations; ;
                    _overallSteps += dimension * iterations;
                }
                _peaks = peaks;

                _overallExposition = _overallSteps * exposition;
                _iterations = (ushort[])_maxIterations.Clone();
                ushort delay = startDelay;
                int s = 0;
                // TODO: unify with toContinue()
                for (int i = smpiSumMax, j = 0; i > 0; --i) {
                    for (int k = 0; k < count; ++k) {
                        ++j;
                        j %= count;
                        if (_iterations[j] > 0)
                            break;
                    }
                    var p = peaks[j];
                    int start = p.Step - p.Width;
                    int end = p.Step + p.Width;
                    int diff = start - s;
                    switch (diff) {
                        case 0:
                            delay = 0;
                            break;
                        case 1:
                        case -1:
                            delay = stepDelay;
                            break;
                        default:
                            delay = diff > 0 ? forwardDelay : backwardDelay;
                            break;
                    }
                    _overallDelay += delay;
                    _overallDelay += (end - start) * stepDelay;
                    s = end;
                    --_iterations[j];
                }
            }