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);
    }
        public bool init()
        {
            int error   = 0;
            int openErr = SeaBreezeWrapper.seabreeze_open_spectrometer(0, ref error);

            if (openErr != 0)
            {
                logger.queue("ERROR: SeaBreeze could not open first spectrometer");
                return(false);
            }

            Thread.Sleep(100); // Testing...

            numberOfSpectrometers = 1;
            specIndex             = 0;

            logger.queue("Found {0} spectrometers", numberOfSpectrometers);
            if (numberOfSpectrometers < 1)
            {
                logger.queue("ERROR: no spectrometers found");
                return(false);
            }
            if (numberOfSpectrometers > 1)
            {
                logger.queue("WARNING: defaulting to first-detected spectrometer");
            }

            ////////////////////////////////////////////////////////////////////
            // initialize metadata for each spectrometer
            ////////////////////////////////////////////////////////////////////

            pixels       = getPixels();
            wavelengths  = readWavelengths();
            serialNumber = getSerialNumber();
            modelName    = getModel();

            ////////////////////////////////////////////////////////////////////
            // init GPIO
            ////////////////////////////////////////////////////////////////////

            gpio = new FeatureControllerGPIO();
            gpio.init();
            gpio.setCacheEnabled(true);

            ////////////////////////////////////////////////////////////////////
            // finished
            ////////////////////////////////////////////////////////////////////

            logger.queue("Spectrometer at index {0} is a {1} with serial {2} and {3} pixels from {4:0.00} to {5:0.00}nm",
                         specIndex, modelName, serialNumber, pixels, wavelengths[0], wavelengths[wavelengths.Length - 1]);

            return(true);
        }
Esempio n. 3
0
        // opens the first spectrometer found. It will have a SeaBreeze ID of 0
        public SeaBreezeSpectrometerClass(ListBox listBoxForLogging, ref Boolean isConnected)
        {
            int zero_on_success = 0;
            int errorCode       = 0;

            logListBox = listBoxForLogging;
            if (File.Exists(SeaBreezeWrapper.DLL))
            {
                zero_on_success = SeaBreezeWrapper.seabreeze_open_spectrometer(SEABREEZE_ID, ref errorCode);
                if ((zero_on_success == 0) && (errorCode == 0))
                {
                    isActive = true;
                    myName   = GetName();
                    logListBox.Items.Add("Connected to: " + myName);
                    isConnected = true;

                    if (myName.StartsWith("FLAMEX"))
                    {
                        myTests = new FlameTestClass(logListBox, SEABREEZE_ID);
                    }
                    else if (myName.StartsWith("STS"))
                    {
                        myTests = new STSTestClass(logListBox);
                    }
                    else if (myName.StartsWith("QEPRO"))
                    {
                        myTests = new QEPROTestClass(logListBox);
                    }
                    else
                    {
                        logListBox.Items.Add(string.Format("A spectrometer test class was not found for {0}.", myName));
                    }
                }
                isConnected = isActive;
            }
            else
            {
                throw (new Exception("The DLL library link was incorrect in the SeaBreezeWrapper.cs file."));
            }
        }