コード例 #1
0
ファイル: Instruction.cs プロジェクト: srt4/GCodeShortener
 // Instructions /should/ have a parent, unless they are of type "M"
 public void addParent(Instruction parent)
 {
     if (this.type.ToLower().Equals ("m04"))
     {
         throw new ArgumentException ("The instruction of type M cannot be called with a parent");
     }
     this.parent = parent;
 }
コード例 #2
0
ファイル: GCParser.cs プロジェクト: srt4/GCodeShortener
        // Takes a string, such as "G01 X2.0000 Y1.0000", and converts
        // it to an instruction object
        public Instruction StringToInstruction(String line)
        {
            // Split on whitespace
            String[] pieces = line.Split (' ');
            Instruction i = new Instruction ();

            foreach (String piece in pieces)
            {
                if (piece.Length > 1)
                {
                    string pieceType = piece.Substring (0, 1);
                    double pieceValue = Double.Parse (piece.Substring (1));

                    switch (Char.Parse (pieceType)) {
                    case 'M':
                        i.setType (piece);
                        break;
                    case 'G':
                        if (piece.Substring (1, 1).Equals ("-"))
                            i.extra += piece + " ";
                        else
                            i.setType (piece);
                        break;
                    case 'X':
                        i.setX (pieceValue);
                        break;
                    case 'Y':
                        i.setY (pieceValue);
                        break;
                    case 'Z':
                        i.setZ (pieceValue);
                        break;
                    default:
                        i.extra += piece + " ";
                        break;
                    }
                }
            }
            return i;
        }
コード例 #3
0
 // TODO: check and instruction block for integrity
 public Boolean addInstruction(Instruction instruction)
 {
     this.instructions.Add (instruction);
     return true;
 }