Exemplo n.º 1
0
    public double[] getSpectrum()
    {
        double[] result = null;

        mut.WaitOne();

        try
        {
            int      error = 0;
            double[] spec  = new double[pixels];

            SeaBreezeWrapper.seabreeze_get_formatted_spectrum(specIndex, ref error, ref spec[0], pixels);
            if (checkSeaBreezeError("get_formatted_spectrum", error))
            {
                // KLUDGE: Some spectrometers (e.g. HR4000) insert non-pixel data
                // into the first few pixels of the spectrum they report, which
                // we can override here to avoid confusing EDC and stray noise on
                // graphs.
                //
                // TODO: Put in appropriate logic based on spectrometer model.
                for (int i = 0; i < 5; i++)
                {
                    spec[i] = spec[5];
                }

                result = spec;
            }
        }
        catch (Exception e)
        {
            logger.log("Error getting spectrum: {0}", e);
        }
        finally
        {
            mut.ReleaseMutex();
        }

        return(result);
    }