public void Parse(string running, GerberNumberFormat form) { GerberNumberPair GNP = new GerberNumberPair(); GNP.Orig = Orig; GNP.Command = Command; GNP.Parse(running, form); Numbers.Add(GNP); }
internal void Set(string name, double val) { if (Has(name) == false) { Pairs[name] = new GerberNumberPair(); Pairs[name].Command = name; CommandsInOrder.Add(name); } Pairs[name].Number = val; }
public void Split(string p, GerberNumberFormat form, bool finddecimalpoint = false) { // StandardConsoleLog L = new StandardConsoleLog(); // L.PushActivity("Split"); if (p.Length < 2) { return; } try { if (p.Substring(0, 3) == "G04") { GNP.Command = "G"; GNP.Number = 4; Pairs[GNP.Command] = GNP; CommandsInOrder.Add(GNP.Command); // line is a comment! // Console.WriteLine("comment: {0}", p.Substring(3)); // L.PopActivity(); return; } bool wasnumber = false; bool isnumber = false; // bool hasdecimalpoint = false; string running = ""; for (int i = 0; i < p.Length; i++) { char current = p[i]; // L.AddString(p[i].ToString()); if (char.IsNumber(current) || current == '+' || current == '-' || current == '.') { isnumber = true; // L.AddString(p[i].ToString() +" is a number" ); } else { isnumber = false; // L.AddString(p[i].ToString() + " is not a number"); } if (isnumber != wasnumber) { // L.AddString("number state change!"); if (isnumber) { // L.AddString("Setting up running command: " + running); GNP.Command = running; GNP.Orig = running; } else { // L.AddString("trying to parse" + running); GNP.Orig += running; GNP.Parse(running, form, finddecimalpoint); Pairs[GNP.Command] = GNP; CommandsInOrder.Add(GNP.Command); GNP = new GerberNumberPair(); } wasnumber = isnumber; running = ""; } if (current != '+') { running += current; } } if (GNP.Command.Length > 0) { GNP.Parse(running, form, finddecimalpoint); Pairs[GNP.Command] = GNP; CommandsInOrder.Add(GNP.Command); } } catch (Exception) { Console.WriteLine("this line does not seem to contain gerber: {0}", p); } // L.PopActivity(); }
internal void Split(string p, GerberNumberFormat form, bool hasdecimalpoint = false) { try { bool wasnumber = false; bool isnumber = false; string running = ""; for (int i = 0; i < p.Length; i++) { char current = p[i]; if (char.IsNumber(current) || current == '+' || current == '-' || (hasdecimalpoint && current == '.')) { isnumber = true; } else { isnumber = false; } if (isnumber != wasnumber) { if (isnumber) { GNP.Command = running; GNP.Orig = running; } else { GNP.Orig += running; GNP.Parse(running, form, hasdecimalpoint); if (Pairs.ContainsKey(GNP.Command) == false) { GerberNumberPairList GNPL = new GerberNumberPairList(); GNPL.Command = GNP.Command; GNPL.Orig = GNP.Orig; Pairs[GNP.Command] = GNPL; } Pairs[GNP.Command].Numbers.Add(GNP); CommandsInOrder.Add(GNP.Command); GNP = new GerberNumberPair(); } wasnumber = isnumber; running = ""; } if (current != '+') { running += current; } } if (GNP.Command.Length > 0) { GNP.Parse(running, form, hasdecimalpoint); if (Pairs.ContainsKey(GNP.Command) == false) { GerberNumberPairList GNPL = new GerberNumberPairList(); GNPL.Command = GNP.Command; GNPL.Orig = GNP.Orig; Pairs[GNP.Command] = GNPL; } Pairs[GNP.Command].Numbers.Add(GNP); CommandsInOrder.Add(GNP.Command); } } catch (Exception) { Console.WriteLine("this line does not seem to contain gerber: {0}", p); } }
public void Split(string p, GerberNumberFormat form, bool finddecimalpoint = false) { if (p.Length < 2) { return; } try { if (p.Substring(0, 3) == "G04") { GNP.Command = "G"; GNP.Number = 4; Pairs[GNP.Command] = GNP; CommandsInOrder.Add(GNP.Command); // line is a comment! // Console.WriteLine("comment: {0}", p.Substring(3)); return; } bool wasnumber = false; bool isnumber = false; // bool hasdecimalpoint = false; string running = ""; for (int i = 0; i < p.Length; i++) { char current = p[i]; if (char.IsNumber(current) || current == '+' || current == '-' || current == '.') { isnumber = true; } else { isnumber = false; } if (isnumber != wasnumber) { if (isnumber) { GNP.Command = running; GNP.Orig = running; } else { GNP.Orig += running; GNP.Parse(running, form, finddecimalpoint); Pairs[GNP.Command] = GNP; CommandsInOrder.Add(GNP.Command); GNP = new GerberNumberPair(); } wasnumber = isnumber; running = ""; } if (current != '+') { running += current; } } if (GNP.Command.Length > 0) { GNP.Parse(running, form, finddecimalpoint); Pairs[GNP.Command] = GNP; CommandsInOrder.Add(GNP.Command); } } catch (Exception) { Console.WriteLine("this line does not seem to contain gerber: {0}", p); } }