Esempio n. 1
0
    public bool close()
    {
        bool result = false;

        opened = false;

        if (!initialized)
        {
            return(result);
        }

        mut.WaitOne();

        try
        {
            int error = 0;
            SeaBreezeWrapper.seabreeze_close_spectrometer(specIndex, ref error);
            result = checkSeaBreezeError("close_spectrometer", error);
        }
        catch (Exception e)
        {
            logger.log("Error closing spectrometer: {0}", e);
        }
        finally
        {
            mut.ReleaseMutex();
        }

        return(result);
    }
Esempio n. 2
0
        public void Close()
        {
            if (isActive)
            {
                Int32  myErrorCode = 0;
                Int32  aLength     = SeaBreezeWrapper.seabreeze_get_error_string_maximum_length();
                byte[] myBuffer    = new byte[aLength];

                int    totallyBogus  = SeaBreezeWrapper.seabreeze_close_spectrometer(SEABREEZE_ID, ref myErrorCode);
                int    bytesInBuffer = SeaBreezeWrapper.seabreeze_get_error_string(myErrorCode, ref myBuffer[0], aLength);
                string myErrorString = "Exception closing spectrometer: " + System.Text.Encoding.Default.GetString(myBuffer);


                if (myErrorCode == 0)
                {
                    logListBox.Items.Add("Disconnected from spectrometer.");
                }
                else
                {
                    logListBox.Items.Add("Error disconnecting: " + myErrorString);
                }
            }
        }