Esempio n. 1
0
        public string GetName()
        {
            string result = "Not Connected";

            if (isActive)
            {
                Int32 myErrorCode = 0;

                Int32  errorStringLength = SeaBreezeWrapper.seabreeze_get_error_string_maximum_length();
                byte[] errorStringBuffer = new byte[errorStringLength];

                Int32  modelStringLength = SeaBreezeWrapper.seabreeze_get_model_string_maximum_length();
                byte[] myModelTypeBuffer = new byte[modelStringLength];

                int bytesInBuffer = SeaBreezeWrapper.seabreeze_get_model(SEABREEZE_ID, ref myErrorCode, ref myModelTypeBuffer[0], modelStringLength);
                if (myErrorCode != 0)
                {
                    bytesInBuffer = SeaBreezeWrapper.seabreeze_get_error_string(myErrorCode, ref errorStringBuffer[0], errorStringLength);
                    string myErrorString = "Exception getting model description: " + System.Text.Encoding.Default.GetString(errorStringBuffer);
                    throw (new Exception(myErrorString));
                }

                result = System.Text.Encoding.UTF8.GetString(myModelTypeBuffer).TrimEnd((char)0);
            }
            return(result);
        }
Esempio n. 2
0
    // returns true if last operation was successful, false if last operation had an error
    private bool checkSeaBreezeError(string operation, int errorCode)
    {
        if (errorCode == SeaBreezeWrapper.ERROR_SUCCESS)
        {
            return(true);
        }

        byte[] buffer = new byte[64];
        SeaBreezeWrapper.seabreeze_get_error_string(errorCode, ref buffer[0], 64);
        string msg = byteToString(buffer);

        if (logger != null)
        {
            logger.log("[SeaBreeze] error during {0}: {1}", operation, msg);
        }

        return(false);
    }
Esempio n. 3
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);
                }
            }
        }
Esempio n. 4
0
        public void GetSerialNumber()
        {
            Int32 myErrorCode = 0;

            Int32 errorStringLength = SeaBreezeWrapper.seabreeze_get_error_string_maximum_length();

            byte[] errorStringBuffer = new byte[errorStringLength];

            Int32 serialNumberStringLength = SeaBreezeWrapper.seabreeze_get_serial_number_max_length(SEABREEZE_ID, ref myErrorCode);

            byte[] mySerialNumberBuffer = new byte[serialNumberStringLength];

            int bytesInBuffer = SeaBreezeWrapper.seabreeze_get_serial_number(SEABREEZE_ID, ref myErrorCode, ref mySerialNumberBuffer[0], serialNumberStringLength);

            if (myErrorCode != 0)
            {
                bytesInBuffer = SeaBreezeWrapper.seabreeze_get_error_string(myErrorCode, ref errorStringBuffer[0], errorStringLength);
                string myErrorString = "Exception getting model description: " + System.Text.Encoding.Default.GetString(errorStringBuffer);
                throw (new Exception(myErrorString));
            }
            string mySerialNumber = System.Text.Encoding.UTF8.GetString(mySerialNumberBuffer).TrimEnd((char)0);

            Log("Serial Number: " + mySerialNumber);
        }
Esempio n. 5
0
        public string GetErrorDescription(int errorCode)
        {
            int stringlength = SeaBreezeWrapper.seabreeze_get_error_string(errorCode, ref errorMessage[0], errorStringLength);

            return(errorMessage.ToString());
        }