Exemple #1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Generates the gcode for a pad touchdown or drill
        /// </summary>
        /// <remarks>the gcode file is assumed to have been populated with the standard headers.
        /// We just add our lines onto the end.</remarks>
        /// <param name="x0">x coord</param>
        /// <param name="y0">y coord</param>
        /// <param name="cutLevel">the cut level we drill to</param>
        /// <param name="drillDwellTime">drill dwell time at bottom of hole</param>
        /// <param name="drillWidth">the drill width. This is mostly used for plotting</param>
        /// <param name="errStr">the error string</param>
        public int AddPadTouchDownOrDrillLine(int x0, int y0, GCodeCmd_ZMove.GCodeZMoveHeightEnum cutLevel, float drillWidth, float drillDwellTime, ref string errStr)
        {
            GCodeCmd_ZMove     zLine  = null;
            GCodeCmd_RapidMove rmLine = null;
            GCodeCmd_Dwell     dwLine = null;

            errStr = "";

            // test these
            if ((x0 == int.MaxValue) ||
                (y0 == int.MaxValue) ||
                (x0 == int.MinValue) ||
                (y0 == int.MinValue))
            {
                LogMessage("AddDrillCodeLines: One or more of the x0,y0 coordinates are invalid.");
                errStr = "The X and Y coordinates of the drill target are invalid.";
                return(1024);
            }

            if (StateMachine.CurrentZFeedrate <= 0)
            {
                LogMessage("AddDrillCodeLines: The zFeedRate is invalid.");
                errStr = "The zFeedRate is invalid.";
                return(1029);
            }
            if (StateMachine.CurrentXYFeedrate <= 0)
            {
                LogMessage("AddDrillCodeLines: The xyFeedRate is invalid.");
                errStr = "The xyFeedRate is invalid.";
                return(1030);
            }

            // we do not display a non sensible value here
            if (drillWidth <= 0)
            {
                drillWidth = 0.125f;
            }

            // G00 rapid move tool head to the x0, y0
            rmLine = new GCodeCmd_RapidMove(x0, y0);
            this.AddLine(rmLine);

            // G00 - put the bit into the work piece
            zLine = new GCodeCmd_ZMove(cutLevel);
            zLine.SetGCodePlotDrillValues(x0, y0, drillWidth);
            zLine.WantLinearMove = true;
            this.AddLine(zLine);

            // dwell at the bottom
            dwLine = new GCodeCmd_Dwell(drillDwellTime);
            this.AddLine(dwLine);

            // G00 - pull the bit out of the work piece
            zLine = new GCodeCmd_ZMove(GCodeCmd_ZMove.GCodeZMoveHeightEnum.GCodeZMoveHeight_ZCoordForClear);
            zLine.SetGCodePlotDrillValues(x0, y0, drillWidth);
            this.AddLine(zLine);
            return(0);
        }
Exemple #2
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Converts the excellon line into a GCode line and returns it
        /// </summary>
        /// <param name="stateMachine">the state machine with the configuration</param>
        /// <param name="gcLineList">a list of the equivalent gcode line object. This can be
        /// empty if there is no direct conversion</param>
        /// <returns>z success, nz fail</returns>
        public override int GetGCodeCmd(ExcellonFileStateMachine stateMachine, out List <GCodeCmd> gcLineList)
        {
            gcLineList = null;
            GCodeCmd_ZMove     zLine  = null;
            GCodeCmd_RapidMove rmLine = null;

            gcLineList = new List <GCodeCmd>();
            int workingXCoord;
            int workingYCoord;
            int workingXOffset;
            int workingYOffset;

            if (RepeatCount < 0)
            {
                LogMessage("GetGCodeCmd (R) invalid repeat count of " + RepeatCount.ToString() + " on line " + LineNumber.ToString());
                return(101);
            }

            // setup our offsets now
            workingXOffset = GetOffsetInPlotCoords_X(stateMachine);
            workingYOffset = GetOffsetInPlotCoords_Y(stateMachine);

            // now put out our loop
            for (int i = 0; i < RepeatCount; i++)
            {
                workingXCoord = stateMachine.LastPlotXCoord;
                workingYCoord = stateMachine.LastPlotYCoord;

                // calculate the new coordinate now
                workingXCoord += workingXOffset;
                workingYCoord += workingYOffset;

                // G00 rapid move tool head to the xOffset, yCoord
                rmLine = new GCodeCmd_RapidMove(workingXCoord, workingYCoord);
                gcLineList.Add(rmLine);
                stateMachine.LastXCoord = workingXCoord;
                stateMachine.LastYCoord = workingYCoord;

                // set the drill width
                float workingDrillWidth = stateMachine.LastDrillWidth * stateMachine.IsoPlotPointsPerAppUnit;

                // G00 - put the bit into the work piece
                zLine = new GCodeCmd_ZMove(GCodeCmd_ZMove.GCodeZMoveHeightEnum.GCodeZMoveHeight_ZCoordForCut);
                zLine.SetGCodePlotDrillValues(workingXCoord, workingYCoord, workingDrillWidth);
                gcLineList.Add(zLine);

                // G00 - pull the bit out of the work piece
                zLine = new GCodeCmd_ZMove(GCodeCmd_ZMove.GCodeZMoveHeightEnum.GCodeZMoveHeight_ZCoordForClear);
                zLine.SetGCodePlotDrillValues(workingXCoord, workingYCoord, workingDrillWidth);
                gcLineList.Add(zLine);
            }
            return(0);
        }
Exemple #3
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Converts the excellon line into a GCode line and returns it
        /// </summary>
        /// <param name="stateMachine">the state machine with the configuration</param>
        /// <param name="gcLineList">a list of the equivalent gcode line object. This can be
        /// empty if there is no direct conversion</param>
        /// <returns>z success, nz fail</returns>
        public override int GetGCodeCmd(ExcellonFileStateMachine stateMachine, out List <GCodeCmd> gcLineList)
        {
            gcLineList = null;

            GCodeCmd_ZMove     zLine  = null;
            GCodeCmd_RapidMove rmLine = null;

            gcLineList = new List <GCodeCmd>();

            int x0 = GetIsoPlotCoordOriginCompensated_X(stateMachine);
            int y0 = GetIsoPlotCoordOriginCompensated_Y(stateMachine);

            // G00 rapid move tool head to the xCoord, yCoord
            rmLine = new GCodeCmd_RapidMove(x0, y0);
            gcLineList.Add(rmLine);
            stateMachine.LastXCoord     = XCoord;
            stateMachine.LastYCoord     = YCoord;
            stateMachine.LastPlotXCoord = x0;
            stateMachine.LastPlotYCoord = y0;
            // record locally
            lastPlotXCoordEnd = x0;
            lastPlotYCoordEnd = y0;

            // set the drill width
            float workingDrillWidth = stateMachine.LastDrillWidth * stateMachine.IsoPlotPointsPerAppUnit;

            // remember this
            LastDrillWidth = stateMachine.LastDrillWidth;

            // G00 - put the bit into the work piece
            zLine = new GCodeCmd_ZMove(GCodeCmd_ZMove.GCodeZMoveHeightEnum.GCodeZMoveHeight_ZCoordForCut);
            zLine.SetGCodePlotDrillValues(x0, y0, workingDrillWidth);
            zLine.WantLinearMove = true;
            gcLineList.Add(zLine);

            // G00 - pull the bit out of the work piece
            zLine = new GCodeCmd_ZMove(GCodeCmd_ZMove.GCodeZMoveHeightEnum.GCodeZMoveHeight_ZCoordForClear);
            zLine.SetGCodePlotDrillValues(x0, y0, workingDrillWidth);
            gcLineList.Add(zLine);

            return(0);
        }