コード例 #1
0
        void HandleStatusLine(string line)
        {
            if (machineState == MachineState.waitStatus)
            {
                machineState = MachineState.Idle;
            }

            GrblStatus.MachineState oldState = grblStatus.state;
            float[] axis = new float[grblStatus.axisPos.Length];
            for (int i = 0; i < axis.Length; i++)
            {
                axis[i] = grblStatus.axisPos[i];
            }

            grblStatus.Parse(line);
            if (StatusUpdate != null)
            {
                StatusUpdate(this, grblStatus);
            }
            grblStatus.gStateChange = false;
            if (oldState != grblStatus.state)
            {
                HandleStateChange(oldState);
            }

            if (wasRunningWhenToolChanged)
            {
                float absZ = grblStatus.axisPos[Z_AXIS] + grblStatus.workingCoords[Z_AXIS];
                if (absZ > tcpZmax)
                {
                    tcpZmax = absZ;
                }
            }

            // handle stopping, if in action. Fixme: need to find a better way to do it.
            if (machineState == MachineState.Stopping && grblStatus.state != GrblStatus.MachineState.Run)
            {
                bool motionStopped = true;
                for (int i = 0; i < axis.Length; i++)
                {
                    if (axis[i] != grblStatus.axisPos[i])
                    {
                        motionStopped = false;
                        break;
                    }
                }
                if (motionStopped)
                {
                    SendStop();
                }
            }
            if (machineState == MachineState.ToolChange && grblStatus.state != GrblStatus.MachineState.Run)
            {
                ChangeTool();
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: chinaray/GrblCNC
 void grblComm_GrblStatusChanged(object sender, GrblStatus.MachineState newState, GrblStatus.MachineState oldState)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new MethodInvoker(() => { grblComm_GrblStatusChanged(sender, newState, oldState); }));
         return;
     }
     toolStripStep.Enabled  = newState == GrblStatus.MachineState.Idle;
     toolStripStart.Enabled = newState == GrblStatus.MachineState.Idle || newState == GrblStatus.MachineState.Hold;
     toolStripStart.Checked = newState == GrblStatus.MachineState.Run;
     toolStripPause.Enabled = newState == GrblStatus.MachineState.Run;
     toolStripPause.Checked = newState == GrblStatus.MachineState.Hold;
 }
コード例 #3
0
 void HandleStateChange(GrblStatus.MachineState oldState)
 {
     if (grblStatus.state == GrblStatus.MachineState.Hold && machineState != MachineState.Paused && machineState != MachineState.Stopping)
     {
         machineState = MachineState.Paused;
     }
     if (GrblStatusChanged != null)
     {
         GrblStatusChanged(this, grblStatus.state, oldState);
     }
     if (grblStatus.state == GrblStatus.MachineState.Idle)
     {
         if (machineState == MachineState.ProbeTool)
         {
             ProbeToolEnd();
         }
         if (machineState == MachineState.ProbeAxis && insertMsgQueue.Count == 0)
         {
             machineState = MachineState.waitStatus;
             GetGcodeCoordOfsets();
         }
     }
 }
コード例 #4
0
 public MachineStateTransition(State target, GrblStatus.MachineState state, bool negate = false) : base(target)
 {
     this.state  = state;
     this.negate = negate;
 }