Esempio n. 1
0
    public bool open()
    {
        initialized = false;
        opened      = false;
        wavelengths = null;

        int error = 0;

        SeaBreezeWrapper.seabreeze_open_spectrometer(specIndex, ref error);
        if (!checkSeaBreezeError("open_spectrometer", error))
        {
            return(false);
        }
        opened = true;

        pixels = SeaBreezeWrapper.seabreeze_get_formatted_spectrum_length(specIndex, ref error);
        if (!checkSeaBreezeError("get_formatted_spectrum_length", error))
        {
            return(false);
        }

        double[] tmp = new double[pixels];
        SeaBreezeWrapper.seabreeze_get_wavelengths(specIndex, ref error, ref tmp[0], pixels);
        if (!checkSeaBreezeError("get_wavelengths", error))
        {
            return(false);
        }

        wavelengths = tmp;
        initialized = true;

        return(initialized);
    }
        double[] readWavelengths()
        {
            if (specIndex < 0)
            {
                return(null);
            }

            double[] wl = new double[pixels];

            int error = 0;

            bool ok = mut.WaitOne(2);

            if (!ok)
            {
                return(null);
            }

            SeaBreezeWrapper.seabreeze_get_wavelengths(specIndex, ref error, ref wl[0], pixels);
            mut.ReleaseMutex();

            if (error != 0)
            {
                logger.queue("Error calling readWavelengths(): errorCode = {0}", error);
                specIndex = -1;
                return(null);
            }

            return(wl);
        }