Exemplo n.º 1
0
        void GrblFileView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataRow row = ((DataRowView)this.GrblFileView.Rows[e.RowIndex].DataBoundItem).Row;

            if ((bool)row["Invalid"])
            {
                MessageBox.Show(string.Format("File: \"{0}\"\r\r!,?,~ and SPACE is not supported in filenames, please rename.", (string)row["Name"]), "Unsupported characters in filename",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                JobTimer.Start();
                Comms.com.WriteCommand(GrblConstants.CMD_SDCARD_RUN + (string)row["Name"]);

                if (FileSelected != null)
                {
                    FileSelected("SDCard:" + (string)row["Name"]);
                }
            }
            //       GCode_Sender.UserUI.ui.
        }
Exemplo n.º 2
0
 public void CycleStart()
 {
     if (this.grblState.State == GrblStates.Hold || this.grblState.State == GrblStates.Tool)
     {
         SendRTCommand(GrblConstants.CMD_CYCLE_START);
     }
     else if (this.file.Loaded)
     {
         txtRunTime.Text = "";
         this.ACKPending = this.CurrLine = this.serialUsed = 0;
         this.pgmStarted = false;
         System.Threading.Thread.Sleep(250);
         Comms.com.PurgeQueue();
         if (GrblMessage != null)
         {
             GrblMessage("");
         }
         this.nextRow = file.Data.Rows[0];
         JobTimer.Start();
         SetStreamingState(StreamingState.Send);
         //         this.DataReceived("!start");
     }
 }
Exemplo n.º 3
0
        void SetGRBLState(string newState, int substate, bool force)
        {
            GrblStates newstate = (GrblStates)Enum.Parse(typeof(GrblStates), newState);

            if (newstate != this.grblState.State || substate != this.grblState.Substate || force)
            {
                switch (newstate)
                {
                case GrblStates.Idle:
                    this.grblState.Color = Color.White;
                    if (this.pgmComplete)
                    {
                        JobTimer.Stop();
                        this.txtRunTime.Text = JobTimer.RunTime;
                        RewindFile();
                    }
                    if (JobTimer.IsRunning)
                    {
                        JobTimer.Pause = true;
                    }
                    else
                    {
                        SetStreamingState(StreamingState.Idle);
                    }
                    break;

                case GrblStates.Run:
                    if (JobTimer.IsPaused)
                    {
                        JobTimer.Pause = false;
                    }
                    this.grblState.Color = Color.LightGreen;
                    //                if (this.grblState.State == GrblStates.Hold || this.grblState.State == GrblStates.Door || this.grblState.State == GrblStates.Tool)
                    SetStreamingState(StreamingState.Send);
                    break;

                case GrblStates.Alarm:
                    this.grblState.Color = Color.Red;
                    break;

                case GrblStates.Jog:
                    this.grblState.Color = Color.Yellow;
                    break;

                case GrblStates.Tool:
                    this.grblState.Color = Color.LightSalmon;
                    SetStreamingState(StreamingState.ToolChange);
                    Comms.com.WriteByte((byte)GrblConstants.CMD_TOOL_ACK);
                    break;

                case GrblStates.Hold:
                    this.grblState.Color = Color.LightSalmon;
                    SetStreamingState(StreamingState.FeedHold);
                    break;

                case GrblStates.Door:
                    if (substate > 0)
                    {
                        this.grblState.Color = grblState.Substate == 1 ? Color.Red : Color.LightSalmon;
                        if (this.streamingState == StreamingState.Send)
                        {
                            SetStreamingState(StreamingState.FeedHold);
                        }
                    }
                    break;

                default:
                    this.grblState.Color = Color.White;
                    break;
                }

                this.grblState.State    = newstate;
                this.grblState.Substate = substate;

                if (GrblStateChanged != null)
                {
                    GrblStateChanged(grblState);
                }
            }
        }
Exemplo n.º 4
0
        public void SetStreamingState(StreamingState newState)
        {
            switch (newState)
            {
            case StreamingState.Disabled:
                this.Enabled = false;
                break;

            case StreamingState.Idle:
            case StreamingState.NoFile:
                this.Enabled           = true;
                this.btnStart.Enabled  = file.Loaded;
                this.btnStop.Enabled   = false;
                this.btnHold.Enabled   = true;
                this.btnRewind.Enabled = file.Loaded && this.CurrLine != 0;
                break;

            case StreamingState.Send:
                this.btnStart.Enabled  = false;
                this.btnHold.Enabled   = true;
                this.btnStop.Enabled   = true;
                this.btnRewind.Enabled = false;
                if (file.Loaded)
                {
                    SendNextLine();
                }
                break;

            case StreamingState.Halted:
                this.btnStart.Enabled = true;
                this.btnHold.Enabled  = false;
                this.btnStop.Enabled  = true;
                break;

            case StreamingState.FeedHold:
                this.btnStart.Enabled = true;
                this.btnHold.Enabled  = false;
                break;

            case StreamingState.ToolChange:
                this.btnStart.Enabled = true;
                this.btnHold.Enabled  = false;
                break;

            case StreamingState.Stop:
                this.btnStart.Enabled  = false;
                this.btnStop.Enabled   = false;
                this.btnRewind.Enabled = true;
                Comms.com.WriteByte((byte)GrblConstants.CMD_STOP);
                if (JobTimer.IsRunning)
                {
                    JobTimer.Stop();
                }
                break;
            }

            this.streamingState = newState;

            if (StreamingStateChanged != null)
            {
                StreamingStateChanged(this.streamingState);
            }
        }