Exemple #1
0
        public void Activate(bool activate, ViewType chgMode)
        {
            if (activate)
            {
                Comms.com.DataReceived += parameters.DataReceived;

                GrblWorkParameters.Get(parameters);

                dgrTools.ItemsSource   = new ObservableCollection <Tool>(from tool in GrblWorkParameters.Tools where tool.Code != GrblConstants.NO_TOOL orderby tool.Code select tool);
                dgrTools.SelectedIndex = 0;
            }
            else
            {
                Comms.com.DataReceived -= parameters.DataReceived;
                dgrTools.ItemsSource    = null;
            }
        }
Exemple #2
0
        public void Activate(bool activate, ViewType chgMode)
        {
            if (activate)
            {
                GrblWorkParameters.Get();

                Comms.com.DataReceived += DataReceived;

                dgrTools.ItemsSource   = GrblWorkParameters.Tools;
                dgrTools.SelectedIndex = 0;
            }
            else
            {
                Comms.com.DataReceived -= DataReceived;

                dgrTools.ItemsSource = null;
            }
        }
        public void Activate(bool activate, ViewType chgMode)
        {
            if (activate)
            {
                GrblWorkParameters.Get();

                Comms.com.DataReceived += DataReceived;

                dgrOffsets.ItemsSource   = GrblWorkParameters.CoordinateSystems;
                dgrOffsets.SelectedIndex = 0;
            }
            else
            {
                Comms.com.DataReceived -= DataReceived;
                Comms.com.PurgeQueue();
                dgrOffsets.ItemsSource = null;
            }
        }
        public void Activate(bool activate, ViewType chgMode)
        {
            if (activate)
            {
                Comms.com.DataReceived += parameters.DataReceived;

                GrblWorkParameters.Get(parameters);

                parameters.AxisEnabledFlags = GrblInfo.AxisFlags;

                dgrOffsets.ItemsSource   = GrblWorkParameters.CoordinateSystems;
                dgrOffsets.SelectedIndex = 0;
            }
            else
            {
                Comms.com.DataReceived -= parameters.DataReceived;
                Comms.com.PurgeQueue();
                dgrOffsets.ItemsSource = null;
            }
        }
Exemple #5
0
        bool InitSystem()
        {
            initOK = true;
            int timeout = 5;

            using (new UIUtils.WaitCursor())
            {
                GCodeSender.EnablePolling(false);
                while (!GrblInfo.Get())
                {
                    if (--timeout == 0)
                    {
                        model.Message = (string)FindResource("MsgNoResponse");
                        return(false);
                    }
                    Thread.Sleep(500);
                }
                GrblAlarms.Get();
                GrblErrors.Get();
                GrblSettings.Load();
                if (GrblInfo.IsGrblHAL)
                {
                    GrblParserState.Get();
                    GrblWorkParameters.Get();
                }
                else
                {
                    GrblParserState.Get(true);
                }
                GCodeSender.EnablePolling(true);
            }

            GrblCommand.ToolChange = GrblInfo.ManualToolChange ? "M61Q{0}" : "T{0}";

            showProgramLimits();

            if (!AppConfig.Settings.GCodeViewer.IsEnabled)
            {
                tabGCode.Items.Remove(tab3D);
            }

            if (GrblInfo.NumAxes > 3)
            {
                limitsControl.Visibility = Visibility.Collapsed;
            }

            if (GrblInfo.LatheModeEnabled)
            {
                MainWindow.EnableView(true, ViewType.Turning);
                //      MainWindow.EnableView(true, ViewType.Parting);
                //      MainWindow.EnableView(true, ViewType.Facing);
                MainWindow.EnableView(true, ViewType.G76Threading);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Turning);
                MainWindow.ShowView(false, ViewType.Parting);
                MainWindow.ShowView(false, ViewType.Facing);
                MainWindow.ShowView(false, ViewType.G76Threading);
            }

            if (GrblInfo.HasSDCard)
            {
                MainWindow.EnableView(true, ViewType.SDCard);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.SDCard);
            }

            if (GrblInfo.HasPIDLog)
            {
                MainWindow.EnableView(true, ViewType.PIDTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.PIDTuner);
            }

            if (GrblInfo.NumTools > 0)
            {
                MainWindow.EnableView(true, ViewType.Tools);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Tools);
            }

            if (GrblInfo.HasProbe && GrblSettings.ReportProbeCoordinates)
            {
                MainWindow.EnableView(true, ViewType.Probing);
            }

            MainWindow.EnableView(true, ViewType.Offsets);
            MainWindow.EnableView(true, ViewType.GRBLConfig);

            if (!string.IsNullOrEmpty(GrblInfo.TrinamicDrivers))
            {
                MainWindow.EnableView(true, ViewType.TrinamicTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.TrinamicTuner);
            }

            return(true);
        }
Exemple #6
0
        private void InitSystem()
        {
            initOK = true;

            // TODO: check if grbl is in a state that allows replies
            using (new UIUtils.WaitCursor())
            {
                GCodeSender.EnablePolling(false);
                GrblInfo.Get();
                GrblSettings.Get();
                GrblParserState.Get();
                GrblWorkParameters.Get();
                GCodeSender.EnablePolling(true);
            }

            model.Message = "";

            GrblCommand.ToolChange = GrblInfo.ManualToolChange ? "M61Q{0}" : "T{0}";

            GCodeSender.Config(MainWindow.UIViewModel.Profile.Config);

            if (GrblInfo.NumAxes > 3)
            {
                limitsControl.Visibility = Visibility.Collapsed;
            }

            if (GrblInfo.LatheModeEnabled)
            {
                MainWindow.EnableView(true, ViewType.Turning);
                MainWindow.EnableView(true, ViewType.Facing);
                MainWindow.EnableView(true, ViewType.G76Threading);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Turning);
                MainWindow.ShowView(false, ViewType.Facing);
                MainWindow.ShowView(false, ViewType.G76Threading);
            }

            if (GrblInfo.HasSDCard)
            {
                MainWindow.EnableView(true, ViewType.SDCard);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.SDCard);
            }

            if (GrblInfo.HasPIDLog)
            {
                MainWindow.EnableView(true, ViewType.PIDTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.PIDTuner);
            }

            if (GrblInfo.NumTools > 0)
            {
                MainWindow.EnableView(true, ViewType.Tools);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Tools);
            }

            MainWindow.EnableView(true, ViewType.Offsets);
            MainWindow.EnableView(true, ViewType.GRBLConfig);

            if (!string.IsNullOrEmpty(GrblInfo.TrinamicDrivers))
            {
                MainWindow.EnableView(true, ViewType.TrinamicTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.TrinamicTuner);
            }

            MainWindow.GCodePush += GCode.File.AddBlock;
        }
Exemple #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);
        }
Exemple #8
0
        private void InitSystem()
        {
            initOK = true;

            // TODO: check if grbl is in a state that allows replies
            using (new UIUtils.WaitCursor())
            {
                GCodeSender.EnablePolling(false);
                GrblInfo.Get();
                GrblSettings.Get();
                GrblParserState.Get();
                GrblWorkParameters.Get();
                GCodeSender.EnablePolling(true);
            }

            model.Message = string.Empty;

            GrblCommand.ToolChange = GrblInfo.ManualToolChange ? "M61Q{0}" : "T{0}";

            if (keyboard == null)
            {
                keyboard = new KeypressHandler(model);
                GCodeSender.Configure(keyboard);
                gcodeRenderer.Configure();
            }

            showProgramLimits();

            if (!AppConfig.Settings.GCodeViewer.IsEnabled)
            {
                tabGCode.Items.Remove(tab3D);
            }

            if (GrblInfo.NumAxes > 3)
            {
                limitsControl.Visibility = Visibility.Collapsed;
            }

            if (GrblInfo.LatheModeEnabled)
            {
                MainWindow.EnableView(true, ViewType.Turning);
                MainWindow.EnableView(true, ViewType.Facing);
                MainWindow.EnableView(true, ViewType.G76Threading);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Turning);
                MainWindow.ShowView(false, ViewType.Facing);
                MainWindow.ShowView(false, ViewType.G76Threading);
            }

            if (GrblInfo.HasSDCard)
            {
                MainWindow.EnableView(true, ViewType.SDCard);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.SDCard);
            }

            if (GrblInfo.HasPIDLog)
            {
                MainWindow.EnableView(true, ViewType.PIDTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.PIDTuner);
            }

            if (GrblInfo.NumTools > 0)
            {
                MainWindow.EnableView(true, ViewType.Tools);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Tools);
            }

            MainWindow.EnableView(true, ViewType.Probing);
            MainWindow.EnableView(true, ViewType.Offsets);
            MainWindow.EnableView(true, ViewType.GRBLConfig);

            if (!string.IsNullOrEmpty(GrblInfo.TrinamicDrivers))
            {
                MainWindow.EnableView(true, ViewType.TrinamicTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.TrinamicTuner);
            }
        }
        private void InitSystem()
        {
            initOK = true;
            int timeout = 5;

            using (new UIUtils.WaitCursor())
            {
                GCodeSender.EnablePolling(false);
                while (!GrblInfo.Get())
                {
                    if (--timeout == 0)
                    {
                        model.Message = "Controller is not responding!";
                        initOK        = false;
                    }
                    Thread.Sleep(500);
                }
                GrblAlarms.Get();
                GrblErrors.Get();
                GrblSettings.Get();
                GrblParserState.Get();
                GrblWorkParameters.Get();
                GCodeSender.EnablePolling(true);
            }

            GrblCommand.ToolChange = GrblInfo.ManualToolChange ? "M61Q{0}" : "T{0}";

            if (keyboard == null)
            {
                keyboard = new KeypressHandler(model);
                GCodeSender.Configure(keyboard);
                gcodeRenderer.Configure();
            }

            showProgramLimits();

            if (!AppConfig.Settings.GCodeViewer.IsEnabled)
            {
                tabGCode.Items.Remove(tab3D);
            }

            if (GrblInfo.NumAxes > 3)
            {
                limitsControl.Visibility = Visibility.Collapsed;
            }

            if (GrblInfo.LatheModeEnabled)
            {
                MainWindow.EnableView(true, ViewType.Turning);
                //      MainWindow.EnableView(true, ViewType.Parting);
                //      MainWindow.EnableView(true, ViewType.Facing);
                MainWindow.EnableView(true, ViewType.G76Threading);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Turning);
                MainWindow.ShowView(false, ViewType.Parting);
                MainWindow.ShowView(false, ViewType.Facing);
                MainWindow.ShowView(false, ViewType.G76Threading);
            }

            if (GrblInfo.HasSDCard)
            {
                MainWindow.EnableView(true, ViewType.SDCard);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.SDCard);
            }

            if (GrblInfo.HasPIDLog)
            {
                MainWindow.EnableView(true, ViewType.PIDTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.PIDTuner);
            }

            if (GrblInfo.NumTools > 0)
            {
                MainWindow.EnableView(true, ViewType.Tools);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Tools);
            }

            if (GrblInfo.HasProbe && GrblSettings.ReportProbeCoordinates)
            {
                MainWindow.EnableView(true, ViewType.Probing);
            }

            MainWindow.EnableView(true, ViewType.Offsets);
            MainWindow.EnableView(true, ViewType.GRBLConfig);

            if (!string.IsNullOrEmpty(GrblInfo.TrinamicDrivers))
            {
                MainWindow.EnableView(true, ViewType.TrinamicTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.TrinamicTuner);
            }
        }
        private void InitSystem()
        {
            initOK = true;

            // TODO: check if grbl is in a state that allows replies
            using (new UIUtils.WaitCursor())
            {
                GCodeSender.EnablePolling(false);
                GrblInfo.Get();
                GrblSettings.Get();
                GrblParserState.Get();
                GrblWorkParameters.Get();
                GCodeSender.EnablePolling(true);
            }

            workParametersControl.ToolChangeCommand = GrblInfo.ManualToolChange ? "T{0}M6" : "T{0}";

            GCodeSender.Config();

            if (GrblInfo.LatheModeEnabled)
            {
                DRO.EnableLatheMode();
                signalsControl.SetLatheMode();
                MainWindow.EnableView(true, ViewType.Turning);
                MainWindow.EnableView(true, ViewType.Facing);
                MainWindow.EnableView(true, ViewType.G76Threading);
            }
            else
            {
                DRO.SetNumAxes(GrblInfo.NumAxes);
                signalsControl.SetNumAxes(GrblInfo.NumAxes);
                MainWindow.ShowView(false, ViewType.Turning);
                MainWindow.ShowView(false, ViewType.Facing);
                MainWindow.ShowView(false, ViewType.G76Threading);
            }

            if (GrblInfo.HasSDCard)
            {
                MainWindow.EnableView(true, ViewType.SDCard);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.SDCard);
            }

            if (GrblInfo.HasPIDLog)
            {
                MainWindow.EnableView(true, ViewType.PIDTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.PIDTuner);
            }

            if (GrblInfo.NumTools > 0)
            {
                MainWindow.EnableView(true, ViewType.Tools);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.Tools);
            }

            MainWindow.EnableView(true, ViewType.Offsets);
            MainWindow.EnableView(true, ViewType.GRBLConfig);

            if (!string.IsNullOrEmpty(GrblInfo.TrinamicDrivers))
            {
                MainWindow.EnableView(true, ViewType.TrinamicTuner);
            }
            else
            {
                MainWindow.ShowView(false, ViewType.TrinamicTuner);
            }

            MainWindow.GCodePush += UserUI_GCodePush;

            txtStatus.Text = "";
        }