Beispiel #1
0
 public PosEventArgs(xyzPoint world, xyzPoint machine, grblState stat, mState msg, pState last)
 {
     posWorld   = world;
     posMachine = machine;
     status     = stat;
     statMsg    = msg;
     lastCmd    = last;
 }
        private void processStatusMessage(mState StatMsg)
        {
            if (logPosEvent)
            {
                Logger.Trace("processStatusMessage  ");
            }
            if (StatMsg.Ov.Length > 1)
            {
                processOverrideValues(StatMsg.Ov);
            }
            if (StatMsg.FS.Length > 1)
            {
                processOverrideCurrentFeedSpeed(StatMsg.FS);
            }

            cBSpindle.CheckedChanged -= cBSpindle_CheckedChanged;               // disable event-handler
            cBCoolant.CheckedChanged -= cBCoolant_CheckedChanged;

            if (StatMsg.A.Contains("S"))
            {
                btnOverrideSpindle.Image = Properties.Resources.led_on;                   // Spindle on CW
                btnOverrideSpindle.Text  = "Spindle CW";
                cBSpindle.Checked        = true;
            }
            if (StatMsg.A.Contains("C"))
            {
                btnOverrideSpindle.Image = Properties.Resources.led_on;                   // Spindle on CCW
                btnOverrideSpindle.Text  = "Spindle CCW";
                cBSpindle.Checked        = true;
            }
            if (!StatMsg.A.Contains("S") && !StatMsg.A.Contains("C"))
            {
                btnOverrideSpindle.Image = Properties.Resources.led_off; cBSpindle.Checked = false;
            }                                                                                                    // Spindle off

            if (StatMsg.A.Contains("F"))
            {
                btnOverrideFlood.Image = Properties.Resources.led_on; cBCoolant.Checked = true;
            }                                                                                                                              // Flood on
            else
            {
                btnOverrideFlood.Image = Properties.Resources.led_off; cBCoolant.Checked = false;
            }

            if (StatMsg.A.Contains("M"))
            {
                btnOverrideMist.Image = Properties.Resources.led_on;
            }                                                                                                 // Mist on
            else
            {
                btnOverrideMist.Image = Properties.Resources.led_off;
            }

            cBCoolant.CheckedChanged += cBCoolant_CheckedChanged;               // enable even-handler
            cBSpindle.CheckedChanged += cBSpindle_CheckedChanged;
        }
        /************************************************************
        * handle status report and position event from serial form
        * processStatus()
        ************************************************************/
        private void OnRaisePosEvent(object sender, PosEventArgs e)
        {
            //  if (logPosEvent)  Logger.Trace("OnRaisePosEvent  {0}  connect {1}  status {2}", e.Status.ToString(), _serial_form.serialPortOpen, e.Status.ToString());
            machineStatus        = e.Status;
            machineStatusMessage = e.StatMsg;
            machineParserState   = e.parserState;

/***** Restore saved position after reset and set initial feed rate: *****/
            if (flagResetOffset || (e.Status == grblState.reset))
            {
                processReset();
            }

/***** process grblState {idle, run, hold, home, alarm, check, door} *****/
            processStatus(e.Raw);

/***** check and submit override values, set labels, checkbox *****/
            processStatusMessage(e.StatMsg);

/***** set DRO digital-read-out labels with machine and work coordinates *****/
            if (!simuEnabled)
            {
                updateDRO();
            }

/***** parser state Spinde/Coolant on/off, on other Forms: FeedRate, SpindleSpeed, G54-Coord *****/
            processParserState(e.parserState);

/***** update 2D view *****/
            if (grbl.posChanged)
            {
                VisuGCode.createMarkerPath();
                VisuGCode.updatePathPositions();
                checkMachineLimit();
                pictureBox1.Invalidate();
                if (Properties.Settings.Default.flowCheckRegistryChange && !isStreaming)
                {
                    gui.writePositionToRegistry();
                }
                grbl.posChanged = false;
            }
            if (grbl.wcoChanged)
            {
                checkMachineLimit();
                grbl.wcoChanged = false;
            }
            if (((isStreaming || isStreamingRequestStop)) && Properties.Settings.Default.guiProgressShow)
            {
                VisuGCode.ProcessedPath.processedPathDraw(grbl.posWork);
            }


            if (_diyControlPad != null)
            {
                if (oldRaw != e.Raw)
                {
                    _diyControlPad.sendFeedback(e.Raw);     //hand over original grbl text
                    oldRaw = e.Raw;
                }
            }
        }