예제 #1
0
        // to disconnect
        public static int DisconnectCS200()
        {
            StringBuilder returnString = new StringBuilder(250);
            string        cMeasure     = "RMT,0\r\n";
            int           length       = cMeasure.Length;

            int r = CaptureEngine.write64_usb(0, cMeasure, 1, length);

            r = CaptureEngine.read64_usb(0, returnString, 1, 250);

            int i = CaptureEngine.end_usb(0);

            return(i);
        }
예제 #2
0
        /// <summary>
        /// function to connect cs200
        /// </summary>
        /// <returns>1 if connected sucessfully ,0 if not</returns>
        public static int ConnectToCS200()
        {
            int           i            = CaptureEngine.end_usb(0);
            StringBuilder returnString = new StringBuilder(250);
            int           numOfDevices = CaptureEngine.get_num();

            //to check if the device is connected
            if (numOfDevices > 0)
            {
                int    returnvar = CaptureEngine.int_usb(0);
                string cRemote   = "RMT,1\r\n";
                int    length    = cRemote.Length;

                int r = CaptureEngine.write64_usb(0, cRemote, 1, length);
                r = CaptureEngine.read64_usb(0, returnString, 1, 250);
                return(returnvar);
            }
            else
            {
                return(1);
            }
        }
예제 #3
0
        public static CIEXYZ StartMeasureXYZForPhone()
        {
            int time1 = 500;

            if (caputerIndex != 1)
            {
                System.Threading.Thread.Sleep(2350);
            }
            caputerIndex = 0;
            StringBuilder returnString = new StringBuilder(250);
            //measure
            string cMeasure = "MES,1\r\n";
            int    length   = cMeasure.Length;

            int r = CaptureEngine.write64_usb(0, cMeasure, 1, length);

            r = CaptureEngine.read64_usb(0, returnString, 1, 250);

            string waittime = returnString.ToString(5, 2);

            CIEXYZ xyz = new CIEXYZ(0, 0, 0);
            int    t   = Convert.ToInt32(waittime);

            t = t * 1000;
            t = t - 500;
            int temp = t;


            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //take the if out for any other than phone
            //
            if (t < 800)
            {
                System.Threading.Thread.Sleep(t);

                cMeasure = "MDR,3\r\n";
                length   = cMeasure.Length;

                r = CaptureEngine.write64_usb(0, cMeasure, 1, length);
                r = CaptureEngine.read64_usb(0, returnString, 1, 250);

                string error = returnString.ToString(0, 4);

                while (error == "ER02")
                {
                    t = t + 300;
                    if (t < 800)
                    {
                        //System.Threading.Thread.Sleep(300);
                        cMeasure = "MDR,3\r\n";
                        length   = cMeasure.Length;

                        r     = CaptureEngine.write64_usb(0, cMeasure, 1, length);
                        r     = CaptureEngine.read64_usb(0, returnString, 1, 250);
                        error = returnString.ToString(0, 4);
                    }
                    else
                    {
                        int tMinus = Math.Abs(2750);
                        //System.Threading.Thread.Sleep(500);
                        xyz      = new CIEXYZ(0, 0, 0);
                        xyz.stdx = t;
                        xyz.stdy = 0;
                        xyz.stdz = 0;
                        break;
                    }
                }

                if (t < 800)
                {
                    string op = returnString.ToString();
                    string x  = returnString.ToString(27, 10);
                    string y  = returnString.ToString(39, 10);
                    string z  = returnString.ToString(51, 10);

                    double X = Convert.ToDouble(x) / 100;
                    double Y = Convert.ToDouble(y) / 100;
                    double Z = Convert.ToDouble(z) / 100;

                    xyz      = new CIEXYZ(X, Y, Z);
                    xyz.stdx = t;
                    xyz.stdy = 1;
                    xyz.stdz = 1;
                }
            }
            else
            {
                System.Threading.Thread.Sleep(500);

                xyz      = new CIEXYZ(-1, -1, -1);
                xyz.stdx = 0;
                xyz.stdy = 0;
                xyz.stdz = 0;
            }
            return(xyz);
        }
예제 #4
0
        /// <summary>
        /// function to get XYZ vales from CS200
        /// </summary>
        /// <returns></returns>
        public static CIEXYZ StartMeasureXYZ()
        {
            StringBuilder returnString = new StringBuilder(250);
            //measure
            string cMeasure = "MES,1\r\n";
            int    length   = cMeasure.Length;

            int r = CaptureEngine.write64_usb(0, cMeasure, 1, length);

            r = CaptureEngine.read64_usb(0, returnString, 1, 250);

            string waittime = returnString.ToString(5, 2);


            int t = Convert.ToInt32(waittime);

            t = t * 1000;
            t = t - 500;

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //take the if out for any other than phone
            //

            System.Threading.Thread.Sleep(t);

            cMeasure = "MDR,3\r\n";
            length   = cMeasure.Length;

            r = CaptureEngine.write64_usb(0, cMeasure, 1, length);
            r = CaptureEngine.read64_usb(0, returnString, 1, 250);

            string error = returnString.ToString(0, 4);

            if (error == "ER21")
            {
                CIEXYZ xyz = new CIEXYZ(0, 0, 0);
                xyz.stdx = t;
                xyz.stdy = 0;
                xyz.stdz = 0;
                return(xyz);
            }

            while (error == "ER02")
            {
                t = t + 300;
                System.Threading.Thread.Sleep(300);
                cMeasure = "MDR,3\r\n";
                length   = cMeasure.Length;

                r     = CaptureEngine.write64_usb(0, cMeasure, 1, length);
                r     = CaptureEngine.read64_usb(0, returnString, 1, 250);
                error = returnString.ToString(0, 4);
            }

            if (error == "ER21")
            {
                CIEXYZ xyz = new CIEXYZ(0, 0, 0);
                xyz.stdx = t;
                xyz.stdy = 0;
                xyz.stdz = 0;
                return(xyz);
            }
            else
            {
                string op = returnString.ToString();
                string x  = returnString.ToString(27, 10);
                string y  = returnString.ToString(39, 10);
                string z  = returnString.ToString(51, 10);

                double X = Convert.ToDouble(x) / 100;
                double Y = Convert.ToDouble(y) / 100;
                double Z = Convert.ToDouble(z) / 100;

                CIEXYZ xyz = new CIEXYZ(X, Y, Z);
                xyz.stdx = t;
                xyz.stdy = 0;
                xyz.stdz = 0;

                return(xyz);
            }
        }