// G10 L1 P- axes <R- I- J- Q-> Set Tool Table
        // L10 - ref G5x + G92 - useful for probe (G38)
        // L11 - ref g59.3 only
        // Q: 1 - 8: 1: 135, 2: 45, 3: 315, 4: 225, 5: 180, 6: 90, 7: 0, 8: 270

        void saveOffset(string axis)
        {
            string s, axes = string.Empty;

            string[] soffset = new string[6];

            if (axis == "All")
            {
                int i = 0, axisflags = GrblInfo.AxisFlags;
                while (axisflags != 0)
                {
                    if ((axisflags & 0x01) != 0)
                    {
                        axes += string.Format("{0}{{{1}}}", GrblInfo.AxisIndexToLetter(i), i + 1);
                    }
                    i++; axisflags >>= 1;
                }
            }
            else
            {
                axes = axis + "{" + (GrblInfo.AxisLetterToIndex(axis) + 1).ToString() + "}";
            }

            for (int i = 0; i < selectedOffset.Values.Length; i++)
            {
                if (i == 0)
                {
                    soffset[i] = GrblWorkParameters.ConvertX(GrblWorkParameters.LatheMode, GrblParserState.LatheMode, selectedOffset.X).ToInvariantString();
                }
                else
                {
                    soffset[i] = selectedOffset.Values[i].ToInvariantString();
                }
            }

            string xOffset = GrblWorkParameters.ConvertX(GrblWorkParameters.LatheMode, GrblParserState.LatheMode, selectedOffset.X).ToInvariantString();

            if (selectedOffset.Id == 0)
            {
                string code = selectedOffset.Code == "G28" || selectedOffset.Code == "G30" ? selectedOffset.Code + ".1" : selectedOffset.Code;
                s = string.Format("G90{0}" + axes, code, soffset[0], soffset[1], soffset[2], soffset[3], soffset[4], soffset[5]);
            }
            else
            {
                s = string.Format("G90G10L2P{0}" + axes, selectedOffset.Id, soffset[0], soffset[1], soffset[2], soffset[3], soffset[4], soffset[5]);
            }

            Comms.com.WriteCommand(s);
        }
Exemple #2
0
 void AxisPositionChanged(string axis, double position)
 {
     if (axis == "ALL")
     {
         string s = "G90G10L20P0";
         foreach (int i in GrblInfo.AxisFlags.ToIndices())
         {
             s += GrblInfo.AxisIndexToLetter(i) + "{0}";
         }
         (DataContext as GrblViewModel).ExecuteCommand(string.Format(s, position.ToInvariantString("F3")));
     }
     else
     {
         (DataContext as GrblViewModel).ExecuteCommand(string.Format("G10L20P0{0}{1}", axis, position.ToInvariantString("F3")));
     }
 }
Exemple #3
0
        private void txtPos_KeyPress(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                NumericTextBox axis = (NumericTextBox)sender;

                if (axis.Value != orgpos)
                {
                    AxisPositionChanged(GrblInfo.AxisIndexToLetter((int)axis.Tag), axis.Value);
                }

                axis.IsReadOnly = true;

                DROEnabledChanged?.Invoke(false);
            }
        }
        public void SetNumAxes(int numAxes)
        {
            if (numAxes <= 3 || numAxes > 6)
            {
                return;
            }

            string axes = "XYZ";

            for (int axis = 3; axis < numAxes; axis++)
            {
                axes += GrblInfo.AxisIndexToLetter(axis);
            }

            Config(axes + baseSignals);
        }
 void AxisPositionChanged(string axis, double position)
 {
     if (axis == "ALL")
     {
         string s = "G90G10L20P0";
         for (int i = 0; i < GrblInfo.NumAxes; i++)
         {
             s += GrblInfo.AxisIndexToLetter(i) + "{0}";
         }
         Grbl.MDICommand(DataContext, string.Format(s, position.ToInvariantString("F3")));
     }
     else
     {
         Grbl.MDICommand(DataContext, string.Format("G10L20P0{0}{1}", axis, position.ToInvariantString("F3")));
     }
 }
Exemple #6
0
 void btnZero_Click(object sender, EventArgs e)
 {
     AxisPositionChanged(GrblInfo.AxisIndexToLetter((int)(sender as Button).Tag), 0.0d);
 }