public static IGcode Parse(string frame, IGcode current) { if (current == null) { throw new ArgumentNullException("current"); } if (string.IsNullOrEmpty(frame)) { throw new ArgumentException("Frame is empty", "frame"); } IGcode result; var paramRegex = new Regex(@"([XxYyZzFfSsRrIiJjKk])((-?\d+)([,.]\d+)?|([,.]\d+))"); var gcodeRegex = new Regex(@"([GgMm])((-?\d+)([,.]\d+)?|([,.]\d+))"); var paramMatches = paramRegex.Matches(frame); var gcodeMatches = gcodeRegex.Matches(frame); if (gcodeMatches.Count == 0) { result = CloneCode(current); } else { switch (gcodeMatches.Cast <Match>().Last().Value.ToUpper()) { case "G0": case "G00": result = new G00(); break; case "G1": case "G01": result = new G01(); break; case "G2": case "G02": result = new G02(); break; case "G3": case "G03": result = new G03(); break; case "G90": result = new G90(); break; case "G91": result = new G91(); break; default: result = CloneCode(current); break; } } return(ApplyParameters(result, current, paramMatches.Cast <Match>().Select(x => x.Value))); }
public static void Process(G91 isoLine) => Messenger.Default.Send(new G91Message());