public bool Parse(GrblResponse response) { bool result = false; if (response != null) { switch (response.ResponseType) { case GrblResponseEnum.Coordinate: if (GCodeParameters.ContainsKey(response.Items[0])) { result = GCodeParameters[response.Items[0]].Relocate(response.Items[1], response.Items[2], response.Items[3]); } break; case GrblResponseEnum.Probe: if (GCodeParameters.ContainsKey("PRB")) { if (GCodeParameters["PRB"].Relocate(response.Items[0], response.Items[1], response.Items[2])) { LastProbeSuccess = response.Items[3].Equals("1"); result = true; } } break; case GrblResponseEnum.ParserState: ParserState.Clear(); for (int i = 0; i < response.Items.Count; i = i + 2) { ParserState.Add(new Tuple <string, string>(response.Items[i], response.Items[i + 1])); } result = true; break; case GrblResponseEnum.StartupBlock: if (response.Items[0].Equals("0")) { StartupBlock1 = response.Items[1]; result = true; } else if (response.Items[0].Equals("1")) { StartupBlock2 = response.Items[1]; result = true; } break; case GrblResponseEnum.Setting: if (Settings.ContainsKey(response.Items[0])) { Settings[response.Items[0]] = response.Items[1]; result = true; } break; case GrblResponseEnum.Status: GrblState = (GrblStateEnum)Enum.Parse(typeof(GrblStateEnum), response.Items[0], true); MachinePosition.Relocate(response.Items[1], response.Items[2], response.Items[3]); WorkPosition.Relocate(response.Items[4], response.Items[5], response.Items[6]); result = true; break; case GrblResponseEnum.ToolLengthOffset: ToolLengthOffset = double.Parse(response.Items[0]); result = true; break; case GrblResponseEnum.BuildInfo: BuildInfo = response.Items[0]; result = true; break; } } return(result); }