示例#1
0
        public static int sensor_init()
        {
            int  error_code = 0; // 0 = error, 1 = OK
            bool error_flag = false;

            load_language();
            int cntr = 0;

            while ((cntr < 5) && (iSensor == 0)) // Try create sensor instances 10 times
            {
                iSensor = MEDAQLib.CreateSensorInstByName("CONTROLLER_CSP2008");
                //cntr++;
            }
            if (iSensor == 0)
            {
                StringBuilder string_of_error = new StringBuilder(1024);
                MEDAQLib.GetError(iSensor, string_of_error, (UInt32)string_of_error.Capacity);
                string error_string = text_file_list[44] + "\n" + Convert.ToString(string_of_error);
                yazici.durum_yazici(error_string);
                MessageBox.Show(error_string, text_file_list[45], MessageBoxButtons.OK, MessageBoxIcon.Error);
                error_flag = true;
            }
            if (error_flag == false)
            {
                //Console.WriteLine("Open sensor...");
                if (Open() != MEDAQLib.ERR_CODE.ERR_NOERROR)
                {
                    StringBuilder string_of_error = new StringBuilder(1024);
                    MEDAQLib.GetError(iSensor, string_of_error, 1024);
                    string error_string = text_file_list[44] + "\n" + Convert.ToString(string_of_error);
                    yazici.durum_yazici(error_string);
                    MessageBox.Show(error_string, text_file_list[45], MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //System.Windows.Forms.MessageBox.Show(error_string, System.Windows.Forms.MessageBoxIcon.Error);
                    MEDAQLib.ReleaseSensorInstance(iSensor);
                    error_flag = true;
                }
            }

            if (error_flag == true)
            {
                error_code = 0;
            }

            if (error_flag == false)
            {
                error_code = 1;
            }

            return(error_code);
        }