Пример #1
0
        private void TimerUpdate()
        {
            SuspendLayout();
            TTTStatus.Text = GrblCore.TranslateEnum(Core.MachineStatus);

            if (Core.InProgram)
            {
                TTTEstimated.Text = Tools.Utils.TimeSpanToString(Core.ProjectedTime, Tools.Utils.TimePrecision.Second, Tools.Utils.TimePrecision.Second, " ,", true);
            }
            else
            {
                TTTEstimated.Text = Tools.Utils.TimeSpanToString(Core.LoadedFile.EstimatedTime, Tools.Utils.TimePrecision.Second, Tools.Utils.TimePrecision.Second, " ,", true);
            }

            if (Core.InProgram)
            {
                TTLEstimated.Text = Strings.MainFormProjectedTime;
            }
            else
            {
                TTLEstimated.Text = Strings.MainFormEstimatedTime;
            }

            MnFileOpen.Enabled          = Core.CanLoadNewFile;
            MnSaveProject.Enabled       = MnAdvancedSave.Enabled = MnSaveProgram.Enabled = Core.HasProgram;
            MnFileSend.Enabled          = Core.CanSendFile;
            MnStartFromPosition.Enabled = Core.CanSendFile;
            MnRunMulti.Enabled          = Core.CanSendFile || Core.CanResumeHold || Core.CanFeedHold;
            MnGrblConfig.Enabled        = true;
            //MnExportConfig.Enabled = Core.CanImportExport;
            //MnImportConfig.Enabled = Core.CanImportExport;
            MnGrblReset.Enabled = Core.CanResetGrbl;

            MNEsp8266.Visible = false;            // (Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsBSerial)) == ComWrapper.WrapperType.LaserWebESP8266;

            MnConnect.Visible    = !Core.IsConnected;
            MnDisconnect.Visible = Core.IsConnected;

            MnGoHome.Visible = Core.Configuration.HomingEnabled;
            MnGoHome.Enabled = Core.CanDoHoming;
            MnUnlock.Enabled = Core.CanUnlock;

            TTOvG0.Visible = Core.SupportOverride;
            TTOvG1.Visible = Core.SupportOverride;
            TTOvS.Visible  = Core.SupportOverride;
            spacer.Visible = Core.SupportOverride;

            ComWrapper.WrapperType wt = Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);
            MnWiFiDiscovery.Visible = wt == ComWrapper.WrapperType.LaserWebESP8266 || wt == ComWrapper.WrapperType.Telnet;
            MnWiFiDiscovery.Enabled = !Core.IsConnected;

            switch (Core.MachineStatus)
            {
            //Disconnected, Connecting, Idle, *Run, *Hold, *Door, Home, *Alarm, *Check, *Jog

            case GrblCore.MacStatus.Alarm:
                TTTStatus.BackColor = Color.Red;
                TTTStatus.ForeColor = Color.White;
                break;

            case GrblCore.MacStatus.Door:
            case GrblCore.MacStatus.Hold:
            case GrblCore.MacStatus.Cooling:
                TTTStatus.BackColor = Color.DarkOrange;
                TTTStatus.ForeColor = Color.Black;
                break;

            case GrblCore.MacStatus.Jog:
            case GrblCore.MacStatus.Run:
            case GrblCore.MacStatus.Check:
                TTTStatus.BackColor = Color.LightGreen;
                TTTStatus.ForeColor = Color.Black;
                break;

            default:
                TTTStatus.BackColor = ColorScheme.FormBackColor;
                TTTStatus.ForeColor = ColorScheme.FormForeColor;
                break;
            }

            PbBuffer.Maximum     = Core.BufferSize;
            PbBuffer.Value       = Core.UsedBuffer;
            PbBuffer.ToolTipText = $"Buffer: {Core.UsedBuffer}/{Core.BufferSize} Free:{Core.FreeBuffer}";

            bool stuck = Core.IsBufferStuck();

            if (stuck != IsBufferStuck)
            {
                IsBufferStuck = stuck;
                PbBuffer.ProgressBar.SetState(stuck ? 2 : 1);
                BtnUnlockFromStuck.Enabled = stuck;
            }

            MnOrtur.Visible = Core.IsOrturBoard;

            ResumeLayout();
        }