CNCGUI.MainForm.GPlotAppend C# (CSharp) Method

GPlotAppend() private method

private GPlotAppend ( string line ) : void
line string
return void
        private void GPlotAppend(string line)
        {
            if (!string.IsNullOrEmpty(line))
            {
                GPoint point = new GPoint();
                float f_value;
                int i_value;
                string[] tokens = line.Split(Common.CHAR_COMMA, StringSplitOptions.RemoveEmptyEntries);

                foreach (string token in tokens)
                {
                    int idx = token.IndexOf(':');
                    if (idx <= 0)
                        continue;
                    string key = token.Substring(0, idx).ToLowerInvariant();
                    string value = (idx+1 < token.Length) ? token.Substring(idx+1).Trim() : string.Empty;
                    if (value.Length > 0)
                    {
                        idx = value.IndexOf(' ');
                        if (idx > 0)
                            value = value.Substring(0, idx);
                    }
                    switch (key)
                    {
                        case "posx":
                            if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out f_value))
                                point.X = f_value;
                            else
                                point.Invalid = true;
                            break;
                        case "posy":
                            if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out f_value))
                                point.Y = f_value;
                            else
                                point.Invalid = true;
                            break;
                        case "posz":
                            if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out f_value))
                                point.Z = f_value;
                            else
                                point.Invalid = true;
                            break;
                        case "vel":
                            if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out f_value))
                                point.Velocity = f_value;
                            break;
                        case "stat":
                            // 5	Start
                            // 3	Stop
                            if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out i_value))
                                point.Status = i_value;
                            switch (i_value)
                            {
                                case 5:
                                    break;
                                case 3:
                                    break;
                                default:
                                    break;
                            }
                            break;
                        case "momo":
                            if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out i_value))
                                point.Momo = i_value;
                            switch (i_value)
                            {
                                case 0:
                                    break;
                                case 1:
                                    break;
                                case 2:
                                    break;
                                case 3:
                                    break;
                                default:
                                    break;
                            }
                            break;
                        case "frmo":
                        case "dist":
                        case "unit":
                            break;
                        case "coor":
                            break;
                        case "posa":
                            break;
                        case "feed":
                            break;
                        case "line":
                            break;
                        case "line number":
                            break;
                        case "x position":
                            if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out f_value))
                                GPlotCurrent.X = f_value;
                            break;
                        case "y position":
                            if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out f_value))
                                GPlotCurrent.Y = f_value;
                            break;
                        case "z position":
                            if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out f_value))
                                GPlotCurrent.Z = f_value;
                            break;
                        case "a position":
                            break;
                        case "feed rate":
                            break;
                        case "velocity":
                            break;
                        case "units":
                            break;
                        case "coordinate system":
                            break;
                        case "distance mode":
                            break;
                        case "feed rate mode":
                            break;
                        case "motion mode":
                            break;
                        case "machine state":
                            break;
                        default:
                            break;
                    }
                }

                if (!point.Invalid &&
                    !point.IsEmpty &&
                    GPlotQueue.Count < GPLOT_QUEUE_SIZE
                    )
                    GPlotQueue.Enqueue(point);
            }
        }