Esempio n. 1
0
        public void TimerUpdate()
        {
            SuspendLayout();

            if (!Core.IsOpen && System.IO.Ports.SerialPort.GetPortNames().Length != CBPort.Items.Count)
            {
                InitPortCB();
            }

            PB.Maximum       = Core.ProgramTarget;
            PB.Bars[0].Value = Core.ProgramSent;
            PB.Bars[1].Value = Core.ProgramExecuted;

            string val = Tools.Utils.TimeSpanToString(Core.ProgramTime, Tools.Utils.TimePrecision.Minute, Tools.Utils.TimePrecision.Second, " ,", true);

            if (val != "now")
            {
                PB.PercString = val;
            }
            else if (Core.InProgram)
            {
                PB.PercString = "0 sec";
            }
            else
            {
                PB.PercString = "";
            }

            PB.Invalidate();



            /*
             * Idle: All systems are go, no motions queued, and it's ready for anything.
             * Run: Indicates a cycle is running.
             * Hold: A feed hold is in process of executing, or slowing down to a stop. After the hold is complete, Grbl will remain in Hold and wait for a cycle start to resume the program.
             * Door: (New in v0.9i) This compile-option causes Grbl to feed hold, shut-down the spindle and coolant, and wait until the door switch has been closed and the user has issued a cycle start. Useful for OEM that need safety doors.
             * Home: In the middle of a homing cycle. NOTE: Positions are not updated live during the homing cycle, but they'll be set to the home position once done.
             * Alarm: This indicates something has gone wrong or Grbl doesn't know its position. This state locks out all G-code commands, but allows you to interact with Grbl's settings if you need to. '$X' kill alarm lock releases this state and puts Grbl in the Idle state, which will let you move things again. As said before, be cautious of what you are doing after an alarm.
             * Check: Grbl is in check G-code mode. It will process and respond to all G-code commands, but not motion or turn on anything. Once toggled off with another '$C' command, Grbl will reset itself.
             */

            TT.SetToolTip(BtnConnectDisconnect, Core.IsOpen ? "Disconnect" : "Connect");

            BtnConnectDisconnect.UseAltImage = Core.IsOpen;
            BtnRunProgram.Enabled            = Core.CanSendFile;
            BtnRunProgram.Visible            = !Core.CanAbortProgram;
            BtnAbortProgram.Visible          = Core.CanAbortProgram;
            BtnOpen.Enabled = Core.CanLoadNewFile;

            bool old = TxtManualCommand.Enabled;

            TxtManualCommand.Enabled = Core.CanSendManualCommand;
            //if (old == false && TxtManualCommand.Enabled == true)
            //	TxtManualCommand.Focus();

            //CBProtocol.Enabled = !Core.IsOpen;
            CBPort.Enabled     = !Core.IsOpen;
            CBSpeed.Enabled    = !Core.IsOpen;
            TxtAddress.Enabled = !Core.IsOpen;

            CmdLog.TimerUpdate();

            if (!Core.IsOpen)
            {
                ComWrapper.WrapperType actualWrapper = (ComWrapper.WrapperType)Settings.GetObject("ComWrapper Protocol", ComWrapper.WrapperType.UsbSerial);
                if (actualWrapper != currentWrapper)
                {
                    currentWrapper = actualWrapper;
                    UpdateConf();
                }
            }

            ResumeLayout();
        }