Exemplo n.º 1
0
        // Methods
        public void ReadTextStream(TextReader tr, StringBuilder errs)
        {
            GcodeOpCode code    = null;
            ArrayList   list    = new ArrayList();
            ArrayList   list2   = new ArrayList();
            long        linenum = 1L;

            while (true)
            {
                GcodeToken token;
                do
                {
                    token = GcodeToken.ReadToken(tr, errs, linenum);
                    if (token.ID == 0xffff)
                    {
                        if (code != null)
                        {
                            code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                            list.Add(code);
                        }
                        goto Label_0150;
                    }
                }while (token.ID == 'N');
                if (token.ID == '\n')
                {
                    linenum += 1L;
                    if (code != null)
                    {
                        code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                        list.Add(code);
                        code = null;
                    }
                }
                else if ((token.ID == 'G') || (token.ID == 'M'))
                {
                    if (code != null)
                    {
                        code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                        list.Add(code);
                    }
                    code = new GcodeOpCode(string.Format("{0}{1:02}", token.ID, token.Value.ToString("00")));
                    list2.Clear();
                }
                else
                {
                    if (code == null)
                    {
                        code = new GcodeOpCode(GcodeOpCode.OpCodes.Unknown);
                    }
                    GcodeParameter parameter = new GcodeParameter(token);
                    if (parameter.OpCode != GcodeOpCode.OpCodes.Unknown)
                    {
                        list2.Add(parameter);
                    }
                }
            }
Label_0150:
            this.GCodes = (GcodeOpCode[])list.ToArray(typeof(GcodeOpCode));
        }
Exemplo n.º 2
0
 // Methods
 public void ReadTextStream(TextReader tr, StringBuilder errs)
 {
     GcodeOpCode code = null;
     ArrayList list = new ArrayList();
     ArrayList list2 = new ArrayList();
     long linenum = 1L;
     while (true)
     {
         GcodeToken token;
         do
         {
             token = GcodeToken.ReadToken(tr, errs, linenum);
             if (token.ID == 0xffff)
             {
                 if (code != null)
                 {
                     code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                     list.Add(code);
                 }
                 goto Label_0150;
             }
         }
         while (token.ID == 'N');
         if (token.ID == '\n')
         {
             linenum += 1L;
             if (code != null)
             {
                 code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                 list.Add(code);
                 code = null;
             }
         }
         else if ((token.ID == 'G') || (token.ID == 'M'))
         {
             if (code != null)
             {
                 code.Parameter = (GcodeParameter[])list2.ToArray(typeof(GcodeParameter));
                 list.Add(code);
             }
             code = new GcodeOpCode(string.Format("{0}{1:02}", token.ID, token.Value.ToString("00")));
             list2.Clear();
         }
         else
         {
             if (code == null)
             {
                 code = new GcodeOpCode(GcodeOpCode.OpCodes.Unknown);
             }
             GcodeParameter parameter = new GcodeParameter(token);
             if (parameter.OpCode != GcodeOpCode.OpCodes.Unknown)
             {
                 list2.Add(parameter);
             }
         }
     }
     Label_0150:
     this.GCodes = (GcodeOpCode[])list.ToArray(typeof(GcodeOpCode));
 }
Exemplo n.º 3
0
 public GcodeParameter(GcodeOpCode.OpCodes opcode, double fval)
 {
     this.OpCode = opcode;
     this.Value = fval;
 }
Exemplo n.º 4
0
 public GcodeParameter(GcodeToken tok)
 {
     this.OpCode = GcodeOpCode.ParseOpCode(tok.ID.ToString());
     this.Value  = tok.Value;
 }
Exemplo n.º 5
0
 public GcodeParameter(string id, double fval)
     : this(GcodeOpCode.ParseOpCode(id), fval)
 {
 }