Exemplo n.º 1
0
    public string getSpectrometerType()
    {
        string result = null;

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

        mut.WaitOne();

        try
        {
            byte[] slot  = new byte[SeaBreezeWrapper.SLOT_LENGTH];
            int    error = 0;
            SeaBreezeWrapper.seabreeze_get_model(specIndex, ref error, ref slot[0], SeaBreezeWrapper.SLOT_LENGTH);
            if (checkSeaBreezeError("get_spectrometer_type", error))
            {
                result = byteToString(slot);
            }
        }
        catch (Exception e)
        {
            logger.log("Error getting spectrometer type: {0}", e);
        }
        finally
        {
            mut.ReleaseMutex();
        }

        return(result);
    }
Exemplo n.º 2
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);
        }
        string getModel()
        {
            int error = 0;

            if (specIndex < 0)
            {
                return(null);
            }

            byte[] buf = new byte[16];

            bool ok = mut.WaitOne(2);

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

            SeaBreezeWrapper.seabreeze_get_model(specIndex, ref error, ref buf[0], buf.Length);
            mut.ReleaseMutex();

            if (error != 0)
            {
                logger.queue("error getting model (error = {0})", error);
                return(null);
            }

            return(byteToString(buf));
        }