public TimeSpan AnalyzeCommand(GrblCommand cmd, bool compute, GrblConf conf = null)
            {
                bool delete = !cmd.JustBuilt;

                if (!cmd.JustBuilt)
                {
                    cmd.BuildHelper();
                }

                UpdateModalsNB(cmd);

                mCurX.Update(cmd.X, ABS);
                mCurY.Update(cmd.Y, ABS);

                mCurF.Update(cmd.F);
                mCurS.Update(cmd.S);

                TimeSpan rv = compute ? ComputeExecutionTime(cmd, conf) : TimeSpan.Zero;

                if (delete)
                {
                    cmd.DeleteHelper();
                }

                return(rv);
            }
 private decimal GetSegmentLenght(GrblCommand cmd)
 {
     if (cmd.IsLinearMovement)
     {
         return(Tools.MathHelper.LinearDistance(mCurX.Previous, mCurY.Previous, mCurX.Number, mCurY.Number));
     }
     else if (cmd.IsArcMovement)                 //arc of given radius
     {
         return(Tools.MathHelper.ArcDistance(mCurX.Previous, mCurY.Previous, mCurX.Number, mCurY.Number, cmd.GetArcRadius()));
     }
     else
     {
         return(0);
     }
 }
            //private void UpdateModals(GrblCommand cmd) //update modals - BUILD IF NEEDED
            //{
            //	bool delete = !cmd.JustBuilt;
            //	if (!cmd.JustBuilt) cmd.BuildHelper();

            //	UpdateModalsNB(cmd);

            //	if (delete) cmd.DeleteHelper();
            //}

            protected void UpdateModalsNB(GrblCommand cmd)             //update modals - EXTERNAL BUILD
            {
                MotionMode.Update(cmd.G);
                CoordinateSelect.Update(cmd.G);
                PlaneSelect.Update(cmd.G);
                DistanceMode.Update(cmd.G);
                ArcDistanceMode.Update(cmd.G);
                FeedRateMode.Update(cmd.G);
                CutterRadiusCompensation.Update(cmd.G);
                ToolLengthOffset.Update(cmd.G);

                ProgramMode.Update(cmd.M);
                CoolantState.Update(cmd.M);
                SpindleState.Update(cmd.M);
            }
 private TimeSpan ComputeExecutionTime(GrblCommand cmd, GrblConf conf)
 {
     if (G0 && cmd.IsLinearMovement)
     {
         return(TimeSpan.FromMinutes((double)GetSegmentLenght(cmd) / (double)conf.MaxRateX));                    //todo: use a better computation of xy if different speed
     }
     else if (G1G2G3 && cmd.IsMovement && mCurF.Number != 0)
     {
         return(TimeSpan.FromMinutes((double)GetSegmentLenght(cmd) / (double)Math.Min(mCurF.Number, conf.MaxRateX)));
     }
     else if (cmd.IsPause)
     {
         return(cmd.P != null?TimeSpan.FromSeconds((double)cmd.P.Number) : cmd.S != null?TimeSpan.FromSeconds((double)cmd.S.Number) : TimeSpan.Zero);
     }
     else
     {
         return(TimeSpan.Zero);
     }
 }
Exemple #5
0
 public GrblCommand(Element first, GrblCommand toappend)
 {
     mLine = string.Format("{0} {1}", first, toappend.mLine);
 }