Beispiel #1
0
 private void AxisEnabled_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (AxisEnabled.Value.ToString().Length == 1)
     {
         Comms.com.WriteString(string.Format("M122{0}S1\r", AxisEnabled.Value.ToString()));
         SGValue = GrblSettings.GetInteger(grblHALSetting.StallGuardBase + GrblInfo.AxisLetterToIndex(AxisEnabled.Value.ToString()));
     }
 }
Beispiel #2
0
        void cvOffset_Click(object sender, RoutedEventArgs e)
        {
            if (selectedTool != null)
            {
                string axisletter = (string)((CoordValueSetControl)sender).Tag;
                int    axis       = GrblInfo.AxisLetterToIndex(axisletter);

                selectedTool.Values[axis] = offset.Values[axis];
                saveOffset(axisletter);
            }
        }
Beispiel #3
0
        public DROControl()
        {
            InitializeComponent();

            foreach (DROBaseControl axis in UIUtils.FindLogicalChildren <DROBaseControl>(this))
            {
                axis.Tag = GrblInfo.AxisLetterToIndex(axis.Label);
                axis.txtReadout.GotFocus     += TxtReadout_GotFocus;
                axis.txtReadout.LostFocus    += txtPos_LostFocus;
                axis.txtReadout.PreviewKeyUp += txtPos_KeyPress;
                axis.btnZero.Click           += btnZero_Click;
            }
        }
        // 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);
        }
        // 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;
            string axes    = axis == "All" ? "X{1}Y{2}Z{3}" : (axis + "{" + (GrblInfo.AxisLetterToIndex(axis) + 1).ToString() + "}");
            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, xOffset, selectedOffset.Y.ToInvariantString(), selectedOffset.Z.ToInvariantString());
            }
            else
            {
                s = string.Format("G90G10L2P{0}" + axes, selectedOffset.Id, xOffset, selectedOffset.Y.ToInvariantString(), selectedOffset.Z.ToInvariantString());
            }

            Comms.com.WriteCommand(s);
        }
        public void Activate(bool activate, ViewType chgMode)
        {
            Comms.com.WriteString(string.Format("M122S{0}H{1}\r", activate ? 1 : 0, SFiltEnabled == true ? 1 : 0));

            if (activate)
            {
                DataContext = model;
                model.OnResponseReceived += ProcessSGValue;
                model.PropertyChanged    += OnDataContextPropertyChanged;
                SGValue = GrblSettings.GetInteger(GrblSetting.StallGuardBase + GrblInfo.AxisLetterToIndex(AxisEnabled.Value.ToString()));
            }
            else
            {
                model.OnResponseReceived -= ProcessSGValue;
                model.PropertyChanged    -= OnDataContextPropertyChanged;
                DataContext = null;
            }
            model.Poller.SetState(activate ? AppConfig.Settings.Base.PollInterval : 0);
        }
Beispiel #7
0
        private void AddEdge(ProbingViewModel probing, char axisletter, bool negative, double XYClearance)
        {
            int axis = GrblInfo.AxisLetterToIndex(axisletter);

            af[axis] = negative ? -1d : 1d;

            axisflags = GrblInfo.AxisLetterToFlag(axisletter);

            var rapidto = new Position(probing.StartPosition);

            rapidto.Values[axis] -= XYClearance * af[axis];
            rapidto.Z            -= probing.Depth;

            probing.Program.AddRapidToMPos(rapidto, axisflags);
            probing.Program.AddRapidToMPos(rapidto, AxisFlags.Z);

            probing.Program.AddProbingAction(axisflags, negative);

            rapidto.Values[axis] = probing.StartPosition.Values[axis] - XYClearance * af[axis];
            probing.Program.AddRapidToMPos(rapidto, axisflags);
            probing.Program.AddRapidToMPos(probing.StartPosition, AxisFlags.Z);
        }
Beispiel #8
0
        public void Activate(bool activate, ViewType chgMode)
        {
            Comms.com.WriteString(string.Format("M122S{0}H{1}\r", activate ? 1 : 0, SFiltEnabled == true ? 1 : 0));

            if (activate)
            {
                DataContext = model;
                model.OnResponseReceived += ProcessSGValue;
                model.PropertyChanged    += OnDataContextPropertyChanged;
                var sgdetails = GrblSettings.Get(grblHALSetting.StallGuardBase + GrblInfo.AxisLetterToIndex(AxisEnabled.Value.ToString()));
                SGValue    = int.Parse(sgdetails.Value);
                SGValueMin = (int)sgdetails.Min;
                SGValueMax = (int)sgdetails.Max;
                grbl_reset = false;
            }
            else
            {
                model.OnResponseReceived -= ProcessSGValue;
                model.PropertyChanged    -= OnDataContextPropertyChanged;
                DataContext = null;
            }
            model.Poller.SetState(activate ? AppConfig.Settings.Base.PollInterval : 0);
        }
Beispiel #9
0
        // 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 xOffset = GrblWorkParameters.ConvertX(GrblWorkParameters.LatheMode, GrblParserState.LatheMode, selectedTool.X).ToInvariantString();

            switch (axis)
            {
            case "R":
                axes = "R{4}";
                break;

            case "All":
                axes = "X{1}Y{2}Z{3}R{4}";
                break;

            default:
                axes = (axis + "{" + (GrblInfo.AxisLetterToIndex(axis) + 1).ToString() + "}");
                break;
            }

            s = string.Format("G10L1P{0}" + axes, selectedTool.Code, xOffset, selectedTool.Y.ToInvariantString(), selectedTool.Z.ToInvariantString(), selectedTool.R.ToInvariantString());

            Comms.com.WriteCommand(s);
        }
Beispiel #10
0
        private void JogCommand(string cmd)
        {
            GrblViewModel model = DataContext as GrblViewModel;

            if (cmd == "stop")
            {
                cmd = ((char)GrblConstants.CMD_JOG_CANCEL).ToString();
            }

            else
            {
                var distance = cmd[1] == '-' ? -JogData.Distance : JogData.Distance;

                if (softLimits)
                {
                    int axis = GrblInfo.AxisLetterToIndex(cmd[0]);

                    if (jogAxis != -1 && axis != jogAxis)
                    {
                        return;
                    }

                    if (axis != jogAxis)
                    {
                        position = distance + model.MachinePosition.Values[axis];
                    }
                    else
                    {
                        position += distance;
                    }

                    if (GrblInfo.ForceSetOrigin)
                    {
                        if (!GrblInfo.HomingDirection.HasFlag(GrblInfo.AxisIndexToFlag(axis)))
                        {
                            if (position > 0d)
                            {
                                position = 0d;
                            }
                            else if (position < (-GrblInfo.MaxTravel.Values[axis] + limitSwitchesClearance))
                            {
                                position = (-GrblInfo.MaxTravel.Values[axis] + limitSwitchesClearance);
                            }
                        }
                        else
                        {
                            if (position < 0d)
                            {
                                position = 0d;
                            }
                            else if (position > (GrblInfo.MaxTravel.Values[axis] - limitSwitchesClearance))
                            {
                                position = GrblInfo.MaxTravel.Values[axis] - limitSwitchesClearance;
                            }
                        }
                    }
                    else
                    {
                        if (position > -limitSwitchesClearance)
                        {
                            position = -limitSwitchesClearance;
                        }
                        else if (position < -(GrblInfo.MaxTravel.Values[axis] - limitSwitchesClearance))
                        {
                            position = -(GrblInfo.MaxTravel.Values[axis] - limitSwitchesClearance);
                        }
                    }

                    if (position == 0d)
                    {
                        return;
                    }

                    jogAxis = axis;

                    cmd = string.Format("$J=G53{0}{1}{2}F{3}", mode, cmd.Substring(0, 1), position.ToInvariantString(), Math.Ceiling(JogData.FeedRate).ToInvariantString());
                }
                else
                {
                    cmd = string.Format("$J=G91{0}{1}{2}F{3}", mode, cmd.Substring(0, 1), distance.ToInvariantString(), Math.Ceiling(JogData.FeedRate).ToInvariantString());
                }
            }

            model.ExecuteCommand(cmd);
        }
Beispiel #11
0
 void btnConfigureSGVal_Click(object sender, EventArgs e)
 {
     Comms.com.WriteString(string.Format("${0}={1}\r", (int)(grblHALSetting.StallGuardBase + GrblInfo.AxisLetterToIndex(AxisEnabled.Value.ToString())), SGValue));
 }