Exemple #1
0
 public gcodeByLine(gcodeByLine tmp)
 {
     resetAll();
     lineNumber   = tmp.lineNumber; figureNumber = tmp.figureNumber; codeLine = tmp.codeLine;
     motionMode   = tmp.motionMode; isdistanceModeG90 = tmp.isdistanceModeG90; ismachineCoordG53 = tmp.ismachineCoordG53;
     isSubroutine = tmp.isSubroutine; spindleState = tmp.spindleState; coolantState = tmp.coolantState;
     spindleSpeed = tmp.spindleSpeed; feedRate = tmp.feedRate;
     x            = tmp.x; y = tmp.y; z = tmp.z; i = tmp.i; j = tmp.j; a = tmp.a; b = tmp.b; c = tmp.c; u = tmp.u; v = tmp.v; w = tmp.w;
     actualPos    = tmp.actualPos; distance = tmp.distance;
 }
 public static void Reset()
 {
     lineNr        = 0;  isIntermediate = false;
     diff.XY       = diff.Z = diff.A = diff.Arc = 0;
     distance      = 0; dt = 50; posZ = 0; posA = 0;
     remainingStep = stepWidth = 10;
     posXY         = grbl.posMarker = new xyPoint();
     posAngle      = grbl.posMarkerAngle = 0;
     codeNext      = new gcodeByLine(simuList[lineNr]);
     createMarkerPath();
     isTangentialZ = (tangentialAxisName == "Z");
 }
            private static bool getNextPos()
            {
                lineNr++;
                if (lineNr >= simuList.Count)
                {
                    return(false);
                }
                codeLast = new gcodeByLine(codeNext);
                codeNext = new gcodeByLine(simuList[lineNr]);
                if (codeNext.codeLine.Contains("M30"))          // program end
                {
                    return(false);
                }
                distance = getDistance();
                updateFeedRate();
//                Logger.Trace(" Code line {0}",codeNext.codeLine);
                return(true);
            }
        /// <summary>
        /// mirror gcode
        /// </summary>
        public static string transformGCodeMirror(translate shiftToZero = translate.MirrorX)
        {
            Logger.Debug("Mirror {0}", shiftToZero);
#if (debuginfo)
            log.Add("   GCodeVisu transform Mirror");
#endif
            if (gcodeList == null)
            {
                return("");
            }

            xyPoint centerOfFigure = xyzSize.getCenter();
            if (lastFigureNumber > 0)
            {
                centerOfFigure = getCenterOfMarkedFigure();
            }

            oldLine.resetAll(grbl.posWork);         // reset coordinates and parser modes
            clearDrawingnPath();                    // reset path, dimensions

            foreach (gcodeByLine gcline in gcodeList)
            {
                if ((lastFigureNumber > 0) && (gcline.figureNumber != lastFigureNumber))
                {
                    continue;
                }

                if (!gcline.ismachineCoordG53)
                {
                    // switch circle direction
                    if ((shiftToZero == translate.MirrorX) || (shiftToZero == translate.MirrorY))           // mirror xy
                    {
                        if (gcline.motionMode == 2)
                        {
                            gcline.motionMode = 3;
                        }
                        else if (gcline.motionMode == 3)
                        {
                            gcline.motionMode = 2;
                        }
                    }
                    if (shiftToZero == translate.MirrorX)           // mirror x
                    {
                        if (gcline.x != null)
                        {
                            //                            if (gcline.isdistanceModeG90)
                            //                                gcline.x = oldmaxx - gcline.x;
                            //                            else
                            gcline.x = -gcline.x + 2 * centerOfFigure.X;
                        }
                        gcline.i = -gcline.i;
                    }
                    if (shiftToZero == translate.MirrorY)           // mirror y
                    {
                        if (gcline.y != null)
                        {
                            //                            if (gcline.isdistanceModeG90)
                            //                                gcline.y = oldmaxy - gcline.y;
                            //                            else
                            gcline.y = -gcline.y + 2 * centerOfFigure.Y;
                        }
                        gcline.j = -gcline.j;
                    }
                    if (shiftToZero == translate.MirrorRotary)           // mirror rotary
                    {
                        string rotary = Properties.Settings.Default.ctrl4thName;
                        if ((rotary == "A") && (gcline.a != null))
                        {
                            gcline.a = -gcline.a;
                        }
                        else if ((rotary == "B") && (gcline.b != null))
                        {
                            gcline.b = -gcline.b;
                        }
                        else if ((rotary == "C") && (gcline.c != null))
                        {
                            gcline.c = -gcline.c;
                        }
                    }

                    calcAbsPosition(gcline, oldLine);
                    oldLine = new gcodeByLine(gcline);   // get copy of newLine
                }
            }
            return(createGCodeProg());
        }
 private static bool sameXYPos(gcodeByLine tmp1, gcodeByLine tmp2)
 {
     return((tmp1.x == tmp2.x) && (tmp1.y == tmp2.y) && (tmp1.z == tmp2.z));
 }
 private static bool xyMove(gcodeByLine tmp)
 {
     return((tmp.x != null) || (tmp.y != null));
 }