コード例 #1
0
        private void start_Click(object sender, RoutedEventArgs e)
        {
            var probing = DataContext as ProbingViewModel;

            if (!probing.Init())
            {
                return;
            }

            probing.PropertyChanged += Probing_PropertyChanged;

            probing.Program.Add(string.Format("G91F{0}", probing.ProbeFeedRate.ToInvariantString()));

            origin = new Position(probing.Grbl.MachinePosition);

            if (probing.ProbeFixture)
            {
                var g59_3 = GrblWorkParameters.GetCoordinateSystem("G59.3");
                g59_3.Z += probing.Offset.Z;
                probing.Program.Add("G53G0" + g59_3.ToString(AxisFlags.X | AxisFlags.Y));
                probing.Program.Add("G53G0" + g59_3.ToString(AxisFlags.Z));
            }
            probing.Program.Add(Probing.Command + probing.Distance.ToString(AxisFlags.Z, true));
            probing.Execute.Execute(true);
        }
コード例 #2
0
        public void Activate(bool activate, ViewType chgMode)
        {
            if (activate)
            {
                if (model.CoordinateSystems.Count == 0)
                {
                    //                   model.CoordinateSystems.Add(model.CoordinateSystem = new CoordinateSystem("Active", "0"));
                    foreach (var cs in GrblWorkParameters.CoordinateSystems)
                    {
                        if (cs.Id > 0 && cs.Id < 9)
                        {
                            model.CoordinateSystems.Add(new CoordinateSystem(cs.Code, "0"));
                        }

                        if (cs.Id == 9)
                        {
                            model.HasCoordinateSystem9 = true;
                        }
                    }
                    model.HasToolTable = GrblInfo.NumTools > 0;
                }

                GrblParserState.Get(!GrblSettings.IsGrblHAL);
                mode                   = GrblParserState.DistanceMode;
                model.Tool             = model.Grbl.Tool == GrblConstants.NO_TOOL ? "0" : model.Grbl.Tool;
                model.CanProbe         = !model.Grbl.Signals.Value.HasFlag(Signals.Probe);
                model.HeightMapApplied = GCode.File.HeightMapApplied;
                int csid = GrblWorkParameters.GetCoordinateSystem(model.Grbl.WorkCoordinateSystem).Id;
                model.CoordinateSystem = csid == 0 || csid >= 9 ? 1 : csid;

                if (model.Grbl.IsTloReferenceSet && !double.IsNaN(model.Grbl.TloReference))
                {
                    model.TloReference        = model.Grbl.TloReference;
                    model.ReferenceToolOffset = false;
                }

                model.Grbl.PropertyChanged += Grbl_PropertyChanged;

                probeTriggered = model.Grbl.Signals.Value.HasFlag(Signals.Probe);

                DisplayPosition(model.Grbl);
            }
            else
            {
                model.Grbl.PropertyChanged -= Grbl_PropertyChanged;

                // If probing alarm active unlock
                if (model.Grbl.GrblState.State == GrblStates.Alarm && (model.Grbl.GrblState.Substate == 4 || model.Grbl.GrblState.Substate == 5))
                {
                    model.Grbl.ExecuteCommand(GrblConstants.CMD_UNLOCK);
                }
                else if (model.Grbl.GrblError != 0)
                {
                    model.Grbl.ExecuteCommand("");  // Clear error
                }
                model.Grbl.ExecuteCommand(mode == DistanceMode.Absolute ? "G90" : "G91");
            }

            model.Grbl.Poller.SetState(activate ? AppConfig.Settings.Base.PollInterval : 0);
        }
コード例 #3
0
        public void Activate(bool activate, ViewType chgMode)
        {
            if (activate)
            {
                if (model.CoordinateSystems.Count == 0)
                {
                    //                   model.CoordinateSystems.Add(model.CoordinateSystem = new CoordinateSystem("Active", "0"));
                    foreach (var cs in GrblWorkParameters.CoordinateSystems)
                    {
                        if (cs.Id > 0 && cs.Id < 9)
                        {
                            model.CoordinateSystems.Add(new CoordinateSystem(cs.Code, "0"));
                        }

                        if (cs.Id == 9)
                        {
                            model.HasCoordinateSystem9 = true;
                        }
                    }
                    model.HasToolTable = GrblInfo.NumTools > 0;
                }

                GrblParserState.Get();
                mode                   = GrblParserState.DistanceMode;
                model.Tool             = model.Grbl.Tool == GrblConstants.NO_TOOL ? "0" : model.Grbl.Tool;
                model.CanProbe         = !model.Grbl.Signals.Value.HasFlag(Signals.Probe);
                model.HeightMapApplied = GCode.File.HeightMapApplied;
                int csid = GrblWorkParameters.GetCoordinateSystem(model.Grbl.WorkCoordinateSystem).Id;
                model.CoordinateSystem = csid == 0 || csid >= 9 ? 1 : csid;

                model.Grbl.PropertyChanged += Grbl_PropertyChanged;
            }
            else
            {
                model.Grbl.PropertyChanged -= Grbl_PropertyChanged;
                if (model.Grbl.GrblError != 0)
                {
                    model.Grbl.ExecuteCommand("");  // Clear error
                }
                model.Grbl.ExecuteCommand(mode == DistanceMode.Absolute ? "G90" : "G91");
            }

            model.Grbl.Poller.SetState(activate ? AppConfig.Settings.Base.PollInterval : 0);
        }
コード例 #4
0
        public void Start(bool preview = false)
        {
            var probing = DataContext as ProbingViewModel;

            if (!probing.ValidateInput())
            {
                return;
            }

            if (probing.ProbeFixture && probing.Grbl.HomedState != HomedState.Homed)
            {
                MessageBox.Show("Axes must be homed before probing the fixture!", "Probing");
                return;
            }

            if (!probing.Program.Init())
            {
                return;
            }

            probing.Program.Add(string.Format("G91F{0}", probing.ProbeFeedRate.ToInvariantString()));

            if (probing.ProbeFixture)
            {
                g59_3    = new Position(GrblWorkParameters.GetCoordinateSystem("G59.3"));
                safeZ    = new Position(probing.StartPosition);
                safeZ.Z  = System.Math.Max(g59_3.Z, probing.StartPosition.Z) + probing.Depth;
                g59_3.Z += probing.Depth;
                if (safeZ.Z < 0d)
                {
                    probing.Program.AddRapidToMPos(safeZ, AxisFlags.Z);
                }
                else
                {
                    safeZ.Z = g59_3.Z;
                }
                probing.Program.AddRapidToMPos(g59_3, AxisFlags.X | AxisFlags.Y);
                probing.Program.AddRapidToMPos(g59_3, AxisFlags.Z);
                g59_3.Z -= probing.Depth;
            }
            probing.Program.AddProbingAction(AxisFlags.Z, true);
            probing.Program.Execute(true);
            OnCompleted();
        }
コード例 #5
0
        private void start_Click(object sender, RoutedEventArgs e)
        {
            var probing = DataContext as ProbingViewModel;

            if (!probing.ValidateInput())
            {
                return;
            }

            if (probing.ProbeFixture && probing.Grbl.HomedState != HomedState.Homed)
            {
                MessageBox.Show("Axes must be homed before probing the fixture!", "Probing");
                return;
            }

            if (!probing.Program.Init())
            {
                return;
            }

            probing.PropertyChanged += Probing_PropertyChanged;

            probing.Program.Add(string.Format("G91F{0}", probing.ProbeFeedRate.ToInvariantString()));

            origin = new Position(probing.Grbl.MachinePosition);

            if (probing.ProbeFixture)
            {
                g59_3 = new Position(GrblWorkParameters.GetCoordinateSystem("G59.3"));
                var safeZ = System.Math.Max(g59_3.Z, origin.Z) + probing.Depth;
                g59_3.Z += probing.Depth;
                probing.Program.Add("G53G0Z" + safeZ.ToInvariantString());
                probing.Program.Add("G53G0" + g59_3.ToString(AxisFlags.X | AxisFlags.Y));
                probing.Program.Add("G53G0" + g59_3.ToString(AxisFlags.Z));
                g59_3.Z -= probing.Depth;
            }
            probing.Program.AddProbingAction(AxisFlags.Z, true);
            probing.Program.Execute(true);
        }
コード例 #6
0
        public void Start(bool preview = false)
        {
            var probing = DataContext as ProbingViewModel;

            if (!probing.ValidateInput(true))
            {
                return;
            }

            if (probing.ProbeFixture && !probing.Grbl.AxisHomed.Value.HasFlag(AxisFlags.X | AxisFlags.Y | AxisFlags.Z))
            {
                MessageBox.Show((string)FindResource("InitFailed"), "Probing");
                return;
            }

            if (!probing.Program.Init(AppConfig.Settings.Probing.CheckProbeStatus || !probing.ProbeFixture))
            {
                return;
            }

            probing.Program.Add(string.Format("G91F{0}", probing.ProbeFeedRate.ToInvariantString()));

            if (probing.ProbeFixture)
            {
                g59_3 = new Position(GrblWorkParameters.GetCoordinateSystem("G59.3"));
                double g59_3_Z = g59_3.Z;
                g59_3.Z = System.Math.Min(probing.Grbl.HomePosition.Z, g59_3.Z + probing.Depth);
                probing.Program.AddRapidToMPos(probing.Grbl.HomePosition, AxisFlags.Z);
                probing.Program.AddRapidToMPos(g59_3, AxisFlags.X | AxisFlags.Y);
                probing.Program.AddRapidToMPos(g59_3, AxisFlags.Z);
                g59_3.Z = g59_3_Z;
            }
            probing.Program.AddProbingAction(AxisFlags.Z, true);
            probing.Program.Execute(true);
            OnCompleted();
        }
コード例 #7
0
        public void Activate(bool activate, ViewType chgMode)
        {
            if (activate)
            {
                if (model.CoordinateSystems.Count == 0)
                {
                    //                   model.CoordinateSystems.Add(model.CoordinateSystem = new CoordinateSystem("Active", "0"));
                    foreach (var cs in GrblWorkParameters.CoordinateSystems)
                    {
                        if (cs.Id > 0 && cs.Id < 9)
                        {
                            model.CoordinateSystems.Add(new CoordinateSystem(cs.Code, "0"));
                        }

                        if (cs.Id == 9)
                        {
                            model.HasCoordinateSystem9 = true;
                        }
                    }
                    model.HasToolTable = GrblInfo.NumTools > 0;
                }

                if (GrblInfo.IsGrblHAL)
                {
                    Comms.com.WriteByte(GrblConstants.CMD_STATUS_REPORT_ALL);
                }

                if (!model.Grbl.IsGrblHAL && !AppConfig.Settings.Jog.KeyboardEnable)
                {
                    Jog.Visibility = Visibility.Collapsed;
                }

                if (GrblInfo.IsGrblHAL)
                {
                    GrblParserState.Get();
                    GrblWorkParameters.Get();
                }
                else
                {
                    GrblParserState.Get(true);
                }

                model.DistanceMode     = GrblParserState.DistanceMode;
                model.Tool             = model.Grbl.Tool == GrblConstants.NO_TOOL ? "0" : model.Grbl.Tool;
                model.CanProbe         = !model.Grbl.Signals.Value.HasFlag(Signals.Probe);
                model.HeightMapApplied = GCode.File.HeightMapApplied;
                int csid = GrblWorkParameters.GetCoordinateSystem(model.Grbl.WorkCoordinateSystem).Id;
                model.CoordinateSystem     = csid == 0 || csid >= 9 ? 1 : csid;
                model.ReferenceToolOffset &= model.CanReferenceToolOffset;

                if (model.Grbl.IsTloReferenceSet && !double.IsNaN(model.Grbl.TloReference))
                {
                    model.TloReference        = model.Grbl.TloReference;
                    model.ReferenceToolOffset = false;
                }

                Probing.Command = GrblInfo.ReportProbeResult ? "G38.3" : "G38.2";

                getView(tab.SelectedItem as TabItem)?.Activate();

                model.Grbl.PropertyChanged += Grbl_PropertyChanged;

                probeTriggered    = model.Grbl.Signals.Value.HasFlag(Signals.Probe);
                probeDisconnected = model.Grbl.Signals.Value.HasFlag(Signals.ProbeDisconnected);
                cycleStartSignal  = model.Grbl.Signals.Value.HasFlag(Signals.CycleStart);

                DisplayPosition(model.Grbl);
            }
            else
            {
                model.Grbl.PropertyChanged -= Grbl_PropertyChanged;

                if (!model.Grbl.IsGCLock)
                {
                    // If probing alarm active unlock
                    //if(model.Grbl.GrblState.State == GrblStates.Alarm && (model.Grbl.GrblState.Substate == 4 || model.Grbl.GrblState.Substate == 5))
                    //    model.WaitForResponse(GrblConstants.CMD_UNLOCK);
                    //else
                    if (model.Grbl.GrblError != 0)
                    {
                        model.WaitForResponse("");  // Clear error
                    }
                    model.WaitForResponse(model.DistanceMode == DistanceMode.Absolute ? "G90" : "G91");
                }
            }

            model.Message = string.Empty;
            model.Grbl.Poller.SetState(activate ? AppConfig.Settings.Base.PollInterval : 0);
        }