Esempio n. 1
0
 public PosEventArgs(xyzPoint world, xyzPoint machine, grblState stat, string last)
 {
     posWorld   = world;
     posMachine = machine;
     status     = stat;
     lastCmd    = last;
 }
Esempio n. 2
0
        private void setCoord(int nr, xyzPoint tmp = new xyzPoint())
        {
            string cmd = String.Format("G10 L2 P{0} X{1:0.000} Y{2:0.000} Z{3:0.000}", nr, tmp.X, tmp.Y, tmp.Z);

            sendCommandEvent(new CmdEventArgs(cmd.Replace(',', '.')));
            refreshValues();
        }
Esempio n. 3
0
        private void btnStartTL_Click(object sender, EventArgs e)
        {
            lblEFProgressInfo.Text = Localization.getString("probingProbingOn") + " Z"; //"Probing on X";
            lblTLProgress.Text     = "";
            lblTLStatus.Text       = "";
            probingValuesIndex     = 0;
            probingAction          = probingMode.toolLenght;
            setRBEnable(cBnow, false);

            for (int i = 0; i < stateCommandsMax; i++)
            {
                stateCommands[i] = "";
            }

            probeStartMachine  = grbl.posMachine;
            probingValuesIndex = 0;
            int k = 1;

            stateCommands[k++] = string.Format("{0} Z-{1} F{2};", ProbeCommand, nUDProbeTravelZ.Value, nUDProbeFeed.Value);    // index=1 will be send below
            stateCommands[k++] = string.Format("G53 G00 Z{0};", probeStartMachine.Z);
            //        stateCommands[k++] = string.Format("G91 G00 Z{0};", nUDProbeTravelZ.Value);

            probingCount = 1;
            sendCommandEvent(new CmdEventArgs(stateCommands[probingCount++].Replace(',', '.')));
            setProgressTL(nUDProbeTravelZ.Value);
            isIdle         = false;
            timer1.Enabled = true;
        }
Esempio n. 4
0
        // store gcode parameters https://github.com/gnea/grbl/wiki/Grbl-v1.1-Commands#---view-gcode-parameters
        public static void setCoordinates(string id, string value, string info)
        {
            xyzPoint tmp     = new xyzPoint();
            string   allowed = "PRBG54G55G56G57G58G59G28G30G92TLO";

            if (allowed.Contains(id))
            {
                getPosition("abc:" + value, ref tmp);   // parse string [PRB:-155.000,-160.000,-28.208:1]
                if (coordinates.ContainsKey(id))
                {
                    coordinates[id] = tmp;
                }
                else
                {
                    coordinates.Add(id, tmp);
                }

                if ((info.Length > 0) && (id == "PRB"))
                {
                    xyzPoint tmp2 = new xyzPoint();
                    tmp2               = coordinates["PRB"];
                    tmp2.A             = info == "1" ? 1 : 0;
                    coordinates["PRB"] = tmp2;
                }
            }
        }
Esempio n. 5
0
 public static void getPosition(string text, ref xyzPoint position)
 {
     string[] dataField = text.Split(':');
     string[] dataValue = dataField[1].Split(',');
     //            axisA = false; axisB = false; axisC = false;
     axisCount = 0;
     if (dataValue.Length > 2)
     {
         Double.TryParse(dataValue[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.X);
         Double.TryParse(dataValue[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.Y);
         Double.TryParse(dataValue[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.Z);
         axisCount = 3;
     }
     if (dataValue.Length > 3)
     {
         Double.TryParse(dataValue[3], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.A);
         axisA = true; axisCount++;
     }
     if (dataValue.Length > 4)
     {
         Double.TryParse(dataValue[4], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.B);
         axisB = true; axisCount++;
     }
     if (dataValue.Length > 5)
     {
         Double.TryParse(dataValue[5], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.C);
         axisC = true; axisCount++;
     }
     //axisA = true; axisB = true; axisC = true;     // for test only
 }
Esempio n. 6
0
 public PosEventArgs(xyzPoint world, xyzPoint machine, grblState stat, mState msg, pState last)
 {
     posWorld   = world;
     posMachine = machine;
     status     = stat;
     statMsg    = msg;
     lastCmd    = last;
 }
Esempio n. 7
0
 public static void getPosition(string text, ref xyzPoint position)
 {
     string[] dataField = text.Split(':');
     string[] dataValue = dataField[1].Split(',');
     Double.TryParse(dataValue[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.X);
     Double.TryParse(dataValue[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.Y);
     Double.TryParse(dataValue[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out position.Z);
 }
Esempio n. 8
0
        public static int getPosition(int serNr, string text, ref xyzPoint position)
        {
            string[] dataField = text.Split(':');
            if (dataField.Length <= 1)
            {
                return(0);
            }
            string[] dataValue = dataField[1].Split(',');
            //            axisA = false; axisB = false; axisC = false;
            int axisCountLocal = 0;

            if (dataValue.Length == 1)
            {
                Double.TryParse(dataValue[0], NumberStyles.Any, CultureInfo.InvariantCulture, out position.Z);
                position.X = 0;
                position.Y = 0;
            }
            if (dataValue.Length > 2)
            {
                Double.TryParse(dataValue[0], NumberStyles.Any, CultureInfo.InvariantCulture, out position.X);
                Double.TryParse(dataValue[1], NumberStyles.Any, CultureInfo.InvariantCulture, out position.Y);
                Double.TryParse(dataValue[2], NumberStyles.Any, CultureInfo.InvariantCulture, out position.Z);
                axisCountLocal = 3;
            }
            if (dataValue.Length > 3)
            {
                Double.TryParse(dataValue[3], NumberStyles.Any, CultureInfo.InvariantCulture, out position.A);
                axisCountLocal++;
                if (serNr == 1)
                {
                    axisA = true;
                }
            }
            if (dataValue.Length > 4)
            {
                Double.TryParse(dataValue[4], NumberStyles.Any, CultureInfo.InvariantCulture, out position.B);
                axisCountLocal++;
                if (serNr == 1)
                {
                    axisB = true;
                }
            }
            if (dataValue.Length > 5)
            {
                Double.TryParse(dataValue[5], NumberStyles.Any, CultureInfo.InvariantCulture, out position.C);
                axisCountLocal++;
                if (serNr == 1)
                {
                    axisC = true;
                }
            }
            if (serNr == 1)
            {
                axisCount = axisCountLocal;
            }
            return(axisCountLocal);
            //axisA = true; axisB = true; axisC = true;     // for test only
        }
Esempio n. 9
0
        public static xyzPoint operator -(xyzPoint b, xyzPoint c)
        {
            xyzPoint a = new xyzPoint();

            a.X = b.X - c.X;
            a.Y = b.Y - c.Y;
            a.Z = b.Z - c.Z;
            a.A = b.A - c.A;
            return(a);
        }
Esempio n. 10
0
        // Overload + operator
        public static xyzPoint operator +(xyzPoint b, xyzPoint c)
        {
            xyzPoint a = new xyzPoint();

            a.X = b.X + c.X;
            a.Y = b.Y + c.Y;
            a.Z = b.Z + c.Z;
            a.A = b.A + c.A;
            return(a);
        }
Esempio n. 11
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;
 }
Esempio n. 12
0
        // handle position events from serial form
        private void OnRaisePosEvent(object sender, PosEventArgs e)
        {
            posWorld      = e.PosWorld;
            posMachine    = e.PosMachine;
            machineStatus = e.Status;

            label_mx.Text          = string.Format("{0:0.000}", posMachine.X);
            label_my.Text          = string.Format("{0:0.000}", posMachine.Y);
            label_mz.Text          = string.Format("{0:0.000}", posMachine.Z);
            label_wx.Text          = string.Format("{0:0.000}", posWorld.X);
            label_wy.Text          = string.Format("{0:0.000}", posWorld.Y);
            label_wz.Text          = string.Format("{0:0.000}", posWorld.Z);
            label_status.Text      = grbl.statusToText(machineStatus);
            label_status.BackColor = grbl.grblStateColor(machineStatus);
        }
Esempio n. 13
0
        public static void setCoordinates(string id, string value)
        {
            xyzPoint tmp     = new xyzPoint();
            string   allowed = "PRBG54G55G56G57G58G59G28G30G92";

            if (allowed.Contains(id))
            {
                getPosition("abc:" + value, ref tmp);
                if (coordinates.ContainsKey(id))
                {
                    coordinates[id] = tmp;
                }
                else
                {
                    coordinates.Add(id, tmp);
                }
            }
        }
Esempio n. 14
0
        public bool withinLimits(xyzPoint actualMachine, double tstx, double tsty)
        {
            double minlx = (double)Properties.Settings.Default.machineLimitsHomeX;
            double maxlx = minlx + (double)Properties.Settings.Default.machineLimitsRangeX;
            double minly = (double)Properties.Settings.Default.machineLimitsHomeY;
            double maxly = minly + (double)Properties.Settings.Default.machineLimitsRangeY;

            tstx += actualMachine.X;
            tsty += actualMachine.Y;
            if ((tstx < minlx) || (tstx > maxlx))
            {
                return(false);
            }
            if ((tsty < minly) || (tsty > maxly))
            {
                return(false);
            }
            return(true);
        }
        private void setCoord(int nr, xyzPoint tmp = new xyzPoint())
        {
            string cmd = String.Format("G10 L2 P{0} X{1:0.000} Y{2:0.000} Z{3:0.000}", nr, tmp.X, tmp.Y, tmp.Z);

            if (grbl.axisA)
            {
                cmd = String.Format("{0} A{1:0.000}", cmd, tmp.A);
            }
            if (grbl.axisB)
            {
                cmd = String.Format("{0} B{1:0.000}", cmd, tmp.B);
            }
            if (grbl.axisC)
            {
                cmd = String.Format("{0} C{1:0.000}", cmd, tmp.C);
            }
            sendCommandEvent(new CmdEventArgs(cmd.Replace(',', '.')));
//            refreshValues();
        }
Esempio n. 16
0
        private void cmsPicBoxZeroXYAtMarkedPosition_Click(object sender, EventArgs e)
        {
            xyzPoint tmp = grbl.posWork - grbl.posMarker;

            sendCommand(String.Format(zeroCmd + " X{0} Y{1}", gcode.frmtNum(tmp.X), gcode.frmtNum(tmp.Y)).Replace(',', '.'));
        }
Esempio n. 17
0
        private void btnStartCF_Click(object sender, EventArgs e)
        {
            btnCancelCF.Enabled    = true;
            btnStartCF.Enabled     = false;
            lblEFProgressInfo.Text = Localization.getString("probingProbingOn") + " X"; //"Probing on X";
            lblCFProgress.Text     = "";
            lblCFStatus.Text       = "";
            probingValuesIndex     = 0;
            probingAction          = probingMode.centerFinder;
            setRBEnable(cBnow, false);

            for (int i = 0; i < stateCommandsMax; i++)
            {
                stateCommands[i] = "";
            }

            probeStartMachine  = grbl.posMachine;
            probingValuesIndex = 0;
            int k = 1;

            if (rBCF1.Checked)
            {
                stateCommands[k++] = string.Format("{0} X-{1} F{2};", ProbeCommand, nUDWorkpieceDiameter.Value, nUDProbeFeed.Value);    // index=1 will be send below
                stateCommands[k++] = string.Format("G53 G00 X{0};", probeStartMachine.X);
                stateCommands[k++] = string.Format("{0} X{1} F{2};", ProbeCommand, nUDWorkpieceDiameter.Value, nUDProbeFeed.Value);
                stateCommands[k++] = string.Format("G53 G00 X{0};", probeStartMachine.X);                                               // replace 4
                stateCommands[k++] = string.Format("{0} Y-{1} F{2};", ProbeCommand, nUDWorkpieceDiameter.Value, nUDProbeFeed.Value);
                stateCommands[k++] = string.Format("G53 G00 Y{0};", probeStartMachine.Y);
                stateCommands[k++] = string.Format("{0} Y{1} F{2};", ProbeCommand, nUDWorkpieceDiameter.Value, nUDProbeFeed.Value);
                stateCommands[k++] = string.Format("G53 G00 Y{0};", probeStartMachine.Y);
            }
            else
            {
                stateCommands[k++] = string.Format("{0} X{1} F{2};", ProbeCommand, nUDProbeTravelX.Value, nUDProbeFeed.Value);  // probe 0
                stateCommands[k++] = string.Format("G91 G00 X-{0};", nUDProbeSaveX.Value);
                stateCommands[k++] = string.Format("Z{0};", nUDProbeTravelZ.Value);
                stateCommands[k++] = string.Format("X{0};", (nUDWorkpieceDiameter.Value + 2 * nUDProbeSaveX.Value + nUDDiameter.Value));
                stateCommands[k++] = string.Format("Z-{0}", nUDProbeTravelZ.Value);
                // k=6
                stateCommands[k++] = string.Format("{0} X-{1} F{2};", ProbeCommand, nUDProbeTravelX.Value, nUDProbeFeed.Value); // probe 1
                stateCommands[k++] = string.Format("G91 G00 X{0};", nUDProbeSaveX.Value);
                stateCommands[k++] = string.Format("Z{0};", nUDProbeTravelZ.Value);
                stateCommands[k++] = string.Format("X-{0};", (nUDProbeSaveX.Value + nUDWorkpieceDiameter.Value / 2));         // 9 will be replaced
                stateCommands[k++] = string.Format("G91 G00 Y-{0};", (nUDProbeTravelY.Value + nUDWorkpieceDiameter.Value / 2));
                stateCommands[k++] = string.Format("Z-{0}", nUDProbeTravelZ.Value);
                // 12
                stateCommands[k++] = string.Format("{0} Y{1} F{2};", ProbeCommand, nUDWorkpieceDiameter.Value, nUDProbeFeed.Value); // probe 2
                stateCommands[k++] = string.Format("G91 G00 Y-{0};", nUDProbeSaveY.Value);
                stateCommands[k++] = string.Format("Z{0};", nUDProbeTravelZ.Value);
                stateCommands[k++] = string.Format("Y{0};", (nUDWorkpieceDiameter.Value + 2 * nUDProbeSaveY.Value + nUDDiameter.Value));
                stateCommands[k++] = string.Format("Z-{0}", nUDProbeTravelZ.Value);
                // 17
                stateCommands[k++] = string.Format("{0} Y-{1} F{2};", ProbeCommand, nUDWorkpieceDiameter.Value, nUDProbeFeed.Value);    // probe 3
                stateCommands[k++] = string.Format("G91 G00 Y{0};", nUDProbeSaveY.Value);
                stateCommands[k++] = string.Format("Z{0};", nUDProbeTravelZ.Value);
                stateCommands[k++] = string.Format("G53 G00 Y{0};", probeStartMachine.Y);
            }

            probingCount = 1;
            sendCommandEvent(new CmdEventArgs(stateCommands[probingCount++].Replace(',', '.')));
            setProgressCF(nUDWorkpieceDiameter.Value);
            isIdle         = false;
            timer1.Enabled = true;
        }
Esempio n. 18
0
 public static bool AlmostEqual(xyzPoint a, xyzPoint b)
 {
     //     return (Math.Abs(a.X - b.X) <= grbl.resolution) && (Math.Abs(a.Y - b.Y) <= grbl.resolution) && (Math.Abs(a.Z - b.Z) <= grbl.resolution);
     return(gcode.isEqual(a.X, b.X) && gcode.isEqual(a.Y, b.Y) && gcode.isEqual(a.Z, b.Z));
 }
Esempio n. 19
0
 public bool withinLimits(xyzPoint actualMachine, xyzPoint actualWorld)
 {
     return(withinLimits(actualMachine, minx - actualWorld.X, miny - actualWorld.Y) && withinLimits(actualMachine, maxx - actualWorld.X, maxy - actualWorld.Y));
 }
Esempio n. 20
0
 public xyArcPoint(xyzPoint tmp)
 {
     X = tmp.X; Y = tmp.Y; CX = 0; CY = 0; mode = 0;
 }
Esempio n. 21
0
 public xyPoint(xyzPoint tmp)
 {
     X = tmp.X; Y = tmp.Y;
 }
Esempio n. 22
0
 public xyzabcuvwPoint(xyzPoint tmp)
 {
     X = tmp.X; Y = tmp.Y; Z = tmp.Z;  A = tmp.A; B = 0; C = 0; U = 0; V = 0; W = 0;
 }
Esempio n. 23
0
 public coordByLine(int line, int figure, xyzPoint p, double a, double dist)
 {
     lineNumber = line; figureNumber = figure; actualPos = p; alpha = a; distance = dist; isArc = false;
 }
Esempio n. 24
0
 public coordByLine(int line, int figure, xyzPoint p, double a, bool isarc)
 {
     lineNumber = line; figureNumber = figure; actualPos = p; alpha = a; distance = -1; isArc = isarc;
 }
Esempio n. 25
0
 public void resetAll(xyzPoint tmp)
 {
     resetAll();
     actualPos = new xyzabcuvwPoint(tmp);
 }
Esempio n. 26
0
 public static bool AlmostEqual(xyzPoint b, xyzPoint c)
 {
     return((Math.Abs(b.X - c.X) <= grbl.resolution) && (Math.Abs(b.Y - c.Y) <= grbl.resolution) && (Math.Abs(b.Z - c.Z) <= grbl.resolution));
 }
Esempio n. 27
0
 public void resetAll(xyzPoint tmp)
 {
     resetAll();
     actualPos = tmp;
 }