Example #1
0
        public void ParseAndExecuteCommand(string command)
        {
            if (command == null)
            {
                return;
            }

            char[]   seperator = { ' ' };
            string[] cmd       = command.Split(seperator, 50);

            string cmdStr    = cmd[0];
            string cmdParam1 = "";
            string cmdParam2 = "";

            if (cmd.Length == 2)
            {
                cmdParam1 = cmd[1];
            }

            else if (cmd.Length == 3)
            {
                cmdParam1 = cmd[1];
                cmdParam2 = cmd[2];
            }

            switch (cmdStr)
            {
                #region Calibration

            case Protocol.CalibrationStart:
                Calibration.Start();
                break;

            case Protocol.CalibrationAbort:
                Calibration.Abort();
                break;

            case Protocol.CalibrationParameters:
                Calibration.Parameters(cmdParam1);
                break;

            case Protocol.CalibrationAreaSize:
                Calibration.AreaSize(int.Parse(cmdParam1), int.Parse(cmdParam2));
                break;

            case Protocol.CalibrationValidate:
                Calibration.Accept();
                break;

            case Protocol.CalibrationQuality:
                break;


            //    case Commands.CalibrationPointChange:
            //        //OnCalibrationPointChange(Int32.Parse(cmd[1])); // Next point number
            //        break;

            //    case Commands.CalibrationParameters:

            //        CalibrationParameters calParams = new CalibrationParameters();
            //        calParams.ExtractParametersFromString(cmdParam);

            //        if (OnCalibrationParameters != null)
            //            OnCalibrationParameters(calParams);

            //        break;


            //    //case CalibrationAreaSize:
            //    //    break;

            //    //case CalibratitonEnd:
            //    //    if (OnCalibratitonEnd != null)
            //    //        OnCalibratitonEnd();
            //    //    break;

            //    //case CalibrationCheckLevel:
            //    //    if (OnCalibrationCheckLevel != null)
            //    //        OnCalibrationCheckLevel(Int32.Parse(cmd[1]));
            //    //    break;

            case Protocol.CalibrationPoint:
                //Console.WriteLine("New calibration point from dedicated interface: " + command);

                //How many points have been buffeded?
                List <int> CalPointsIndex = new List <int>();
                for (int c = 0; c < cmd.Length; c++)
                {
                    if (cmd[c] == "CAL_POINT")
                    {
                        CalPointsIndex.Add(c);
                    }
                }

                for (int c = 0; c < CalPointsIndex.Count; c++)
                {
                    //OnCalibrationFeedbackPoint(
                    //    long.Parse(cmd[CalPointsIndex[c] + 1]),     //time
                    //    int.Parse(cmd[CalPointsIndex[c] + 2]),      //packace number
                    //    int.Parse(cmd[CalPointsIndex[c] + 3]),      //targetX
                    //    int.Parse(cmd[CalPointsIndex[c] + 4]),      //targetY
                    //    int.Parse(cmd[CalPointsIndex[c] + 5]),      //gazeX
                    //    int.Parse(cmd[CalPointsIndex[c] + 6]),      //gazeY
                    //    float.Parse(cmd[CalPointsIndex[c] + 7]),    //distance - will not be used
                    //    int.Parse(cmd[CalPointsIndex[c] + 8]));     //acquisition time
                }
                break;

            case Protocol.CalibrationUpdateMethod:
                Console.Write("Calibration Update Method Changed to:" + cmdParam1);
                //onCalibrationUpdateMethod(int.Parse(cmdParam));
                //Settings.Instance.Calibration.RecalibrationType = GazeTrackingLibrary.Utils.RecalibrationTypeEnum.Continuous
                break;

                #endregion
            }
        }
Example #2
0
        public void ParseAndExecuteCommand(string command)
        {
            if (command == null)
            {
                return;
            }

            char[]   seperator = { ' ' };
            string[] cmd       = command.Split(seperator, 50);

            string cmdStr    = cmd[0];
            string cmdParam1 = "";
            string cmdParam2 = "";

            if (cmd.Length == 2)
            {
                cmdParam1 = cmd[1];
            }

            else if (cmd.Length == 3)
            {
                cmdParam1 = cmd[1];
                cmdParam2 = cmd[2];
            }

            switch (cmdStr)
            {
                #region Calibration

            case Protocol.CalibrationStart:
                Calibration.Start();
                break;

            case Protocol.CalibrationAbort:
                Calibration.Abort();
                break;

            case Protocol.CalibrationParameters:
                Calibration.Parameters(cmdParam1);
                break;

            case Protocol.CalibrationAreaSize:
                Calibration.AreaSize(int.Parse(cmdParam1), int.Parse(cmdParam2));
                break;

            case Protocol.CalibrationValidate:
                Calibration.Accept();
                break;

            //    //case CalibrationCheckLevel:
            //    //    if (OnCalibrationCheckLevel != null)
            //    //        OnCalibrationCheckLevel(Int32.Parse(cmd[1]));
            //    //    break;

            case Protocol.StreamStart:
                break;

            case Protocol.StreamStop:
                break;

                #endregion
            }
        }