Exemplo n.º 1
0
 private void buttonMoveToZero_Click(object sender, EventArgs e)
 {
     // All of this operation has been placed inside a "catch-all" exception
     // handler. Normally you would catch the more specific exceptions that
     // the API call might throw (details of which can be found in the
     // Kinesis .NET API document).
     try
     {
         // Move the device to position 0. We specify 0 as the wait timeout
         // as we don't care how long it takes.
         _kCubeDCServoMotor.MoveTo(0, 0);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to move to position 0\n" + ex);
     }
 }
Exemplo n.º 2
0
        private void getFrogTrace()
        {
            double starttemp = startposition;
            double stoptemp  = stopposition;
            int    nsteps    = (int)Math.Floor((stoptemp - starttemp) / interval) + 1;

            tau       = new double[nsteps + 1];
            FrogTrace = new double[nsteps, 3647];

            for (int i = 0; i < nsteps + 1; i++)
            {
                tau[i] = starttemp + (i - 0.5) * interval;
            }

            bool direction = KDC101.Position < (decimal)tau[nsteps / 2];

            for (int i = 0; i < nsteps; i++)
            {
                if (forcestop)
                {
                    forcestop = false;
                    return;
                }

                if (direction)
                {
                    KDC101.MoveTo((decimal)starttemp, 10000);
                    ccsSeries.getDeviceStatus(out int status);
                    if (status == 17 || status == 1)
                    {
                        ccsSeries.getScanData(spectrumdata);
                    }
                    ccsSeries.startScan();
                    while (true)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(inttime_frog));
                        ccsSeries.getDeviceStatus(out status);
                        if (status == 1)
                        {
                            ccsSeries.getScanData(spectrumdata);
                            break;
                        }
                        else if (status == 17)
                        {
                            ccsSeries.startScan();
                        }
                    }

                    for (int j = 0; j < 3647; j++)
                    {
                        FrogTrace[i, j] = spectrumdata[j];
                    }

                    starttemp += interval;
                }
                else
                {
                    KDC101.MoveTo((decimal)stoptemp, 10000);
                    ccsSeries.getDeviceStatus(out int status);
                    if (status == 17 || status == 1)
                    {
                        ccsSeries.getScanData(spectrumdata);
                    }
                    ccsSeries.startScan();
                    while (true)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(inttime_frog));
                        ccsSeries.getDeviceStatus(out status);
                        if (status == 1)
                        {
                            ccsSeries.getScanData(spectrumdata);
                            break;
                        }
                        else if (status == 17)
                        {
                            ccsSeries.startScan();
                        }
                    }
                    for (int j = 0; j < 3647; j++)
                    {
                        FrogTrace[nsteps - i - 1, j] = spectrumdata[j];
                    }
                    stoptemp -= interval;
                }
                heatMap1.Dispatcher.Invoke(DispatcherPriority.Loaded, new Action(PlotHeatMap));
            }
            UpdateInfoBox("Trace Scan Finished");
            da.RunAlgorithmAsync(DataToTxt()).Wait();
            if (da.ResultCount > 0)
            {
                da.GetResult(out double duration, out double spectralwidth, out double[][] result);
                Dispatcher.Invoke(new Action(() =>
                {
                    lineGraph2.Plot(result[2], result[0]);
                }));
                UpdateInfoBox($"Pulse duration: {duration} fs");
                UpdateInfoBox($"Spectral width: {spectralwidth} nm");
            }
        }