Esempio n. 1
0
        // Full circle
        public string ArcMove(double[] cen, WorkingPlane plane, bool clkwise, double[] vel, double[] acc, bool extrude, bool interpolated, bool abs_coord, int line)
        {
            PackageJSON package = new PackageJSON();

            package.line = line;
            if (abs_coord)
            {
                package.keycode = (int)move_codes.CircleMove;
                package.text    = "Circle Move";
            }
            else
            {
                package.keycode = (int)move_codes.IncCircleMove;
                package.text    = "Incremental Circle Move";
            }
            ////Convert milimeters to meters
            //for (int i = 0; i < 3; ++i)
            //{
            //    cen[i] /= 1000;
            //    vel[i] /= 1000;
            //    acc[i] /= 1000;
            //}

            package.pos2     = cen;
            package.plane    = (int)plane;
            package.clkwise  = clkwise;
            package.interpol = interpolated;
            package.vel      = vel;
            package.acc      = acc;
            package.extrude  = extrude;

            string pack_json = JsonConvert.SerializeObject(package);

            return(pack_json);
        }
Esempio n. 2
0
        // With R
        public string ArcMove(double[] pos, double radius, WorkingPlane plane, bool clkwise, double[] vel, double[] acc, bool extrude,
                              bool interpolated, bool abs_coord, int line)
        {
            PackageJSON package = new PackageJSON();

            package.line = line;
            if (abs_coord)
            {
                package.keycode = (int)move_codes.ArcMoveRadius;
                package.text    = "Arc Move Radius";
            }
            else
            {
                package.keycode = (int)move_codes.IncArcMoveRadius;
                package.text    = "Incremental Arc Move Radius";
            }

            package.pos1     = pos;
            package.aux      = radius;
            package.plane    = (int)plane;
            package.clkwise  = clkwise;
            package.interpol = interpolated;
            package.vel      = vel;
            package.acc      = acc;
            package.extrude  = extrude;

            string pack_json = JsonConvert.SerializeObject(package);

            return(pack_json);
        }
Esempio n. 3
0
        private List<string> ProcessCommand(string command)
        {
            int code;
            List<string> result = new List<string>();
            double feedRate = HasValueParameter('F', command) ? GetValueParameter('F', command) : Configuration.defaultFeedrate; // Ver qué valor va cuando no hay valor - CONFIGURACION? -

            if (HasValueParameter('G', command))
            {
                code = Convert.ToInt32(GetValueParameter('G', command));
                string finalLine;
                switch (code)
                {
                    case 0:
                    case 1:
                        UnitsPosition line = this.GetFinalPosition(command);
                        finalLine = line.ToStepsPosition(CurrentPosition, feedRate, code == 0).ToString(-1);
                        logger.Debug("Resultado Linea: " + finalLine);
                        result.Add(finalLine);
                        CurrentPosition = line;
                        break;

                    case 2:
                    case 3:
                        List<UnitsPosition> curveLines = this.ProcessCurveCommand(command);

                        foreach (UnitsPosition curveLine in curveLines)
                        {
                            finalLine = curveLine.ToStepsPosition(CurrentPosition, feedRate).ToString(-1);
                            logger.Debug("Resultado Sección de Curva: " + finalLine);
                            result.Add(finalLine);
                            CurrentPosition = curveLine;
                        }
                        break;

                    case 4:
                        result.Add(command);
                        break;

                    case 17:
                        this.WorkingPlane = WorkingPlane.XY;
                        break;

                    case 18:
                        this.WorkingPlane = WorkingPlane.XZ;
                        break;

                    case 19:
                        this.WorkingPlane = WorkingPlane.YZ;
                        break;

                    case 20:
                        Configuration.millimetersProgramming = false;
                        break;

                    case 21:
                        Configuration.millimetersProgramming = true;
                        break;

                    case 90:
                        Configuration.absoluteProgamming = true;
                        break;

                    case 91:
                        Configuration.absoluteProgamming = false;
                        break;

                    default:
                        logger.Error("Comando no soportado: " + command + ".");
                        throw new Exception("Comando no soportado: " + command + ".");
                }
            }
            else if (HasValueParameter('M', command))
            {
                code = Convert.ToInt32(GetValueParameter('M', command));
                switch(code)
                {
                    case 0:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                        result.Add(command);
                        break;

                    default:
                        logger.Error("Comando no soportado: " + command + ".");
                        throw new Exception("Comando no soportado: " + command + ".");
                }
            }

            return result;
        }
Esempio n. 4
0
        public void UpdateWorkingGrid()
        {
            m_RenderView.SceneManager.ComputeBBox();

            WorkingPlane wp = m_RenderView.Renderer.GetWorkingPlane();

            GridNode gridNode  = new GridNode();
            Vector3  modelSize = m_RenderView.SceneManager.GetBBox().Size();
            Vector2  cellSize  = gridNode.GetCellSize();
            int      nCountX   = (int)(modelSize.X / cellSize.X + 0.5f) + 1;
            int      nCountY   = (int)(modelSize.Y / cellSize.Y + 0.5f) + 1;

            if (nCountX < 2)
            {
                nCountX = 2;
            }
            if (nCountY < 2)
            {
                nCountY = 2;
            }

            gridNode.SetCellCount(nCountX, nCountY);

            LineStyle lineStyle = new LineStyle();

            lineStyle.SetColor(new ColorValue(1.0f, 1.0f, 1.0f));
            lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DotLine);
            {
                //Z
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(0, 0, -1000), new Vector3(0, 0, 1000));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }
            {
                //X
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(-1000, 0, 0), new Vector3(1000, 0, 0));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }
            {
                //Y
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(0, -1000, 0), new Vector3(0, 1000, 0));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }

            lineStyle = new LineStyle();
            lineStyle.SetColor(new ColorValue(0.9f, 0.9f, 0.9f));
            gridNode.SetLineStyle(lineStyle);
            for (int ii = -1; ii <= nCountX; ++ii)
            {
                if (ii == 0)
                {
                    continue;
                }

                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(ii * cellSize.X, cellSize.Y, 0), new Vector3(ii * cellSize.X, -nCountY * cellSize.Y, 0));

                gridNode.AddNode(lineNode);
            }
            for (int ii = -1; ii <= nCountY; ++ii)
            {
                if (ii == 0)
                {
                    continue;
                }

                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(-cellSize.X, -ii * cellSize.Y, 0), new Vector3(nCountX * cellSize.X, -ii * cellSize.Y, 0));
                gridNode.AddNode(lineNode);
            }
            gridNode.Update();
            wp.SetGridNode(gridNode);
            m_RenderView.ShowWorkingGrid(true);
        }
Esempio n. 5
0
 protected CommandPreprocessor()
 {
     this.workingPlane = WorkingPlane.XY;
     this.currentPosition = new UnitsPosition(0, 0, 0);
     this.referencePosition = new UnitsPosition(0, 0, 0);
 }