public void Clear() { _fileName = _mdiCommand = string.Empty; _streamingState = StreamingState.NoFile; _isMPos = _reset = _isJobRunning = false; _mpg = ""; _grblState.Error = 0; _grblState.State = GrblStates.Unknown; _grblState.Substate = 0; _grblState.MPG = false; GrblState = _grblState; IsMPGActive = null; //?? _MPos = _WPos = _wco = string.Empty; Position.Clear(); MachinePosition.Clear(); WorkPosition.Clear(); WorkPositionOffset.Clear(); ProgramLimits.Clear(); Set("Pn", string.Empty); Set("A", string.Empty); Set("FS", string.Empty); Set("Sc", string.Empty); Set("T", "0"); Set("Ov", string.Empty); Set("Ex", string.Empty); SDCardStatus = string.Empty; HomedState = HomedState.Unknown; if (_latheMode != LatheMode.Disabled) { LatheMode = LatheMode.Radius; } }
public void Clear() { _fileName = _mdiCommand = string.Empty; _streamingState = StreamingState.NoFile; _isMPos = _reset = _isJobRunning = _isProbeSuccess = _pgmEnd = _isTloRefSet = false; _canReset = true; _pb_avail = _rxb_avail = string.Empty; _mpg = null; _line = _pwm = _scrollpos = 0; _grblState.Error = 0; _grblState.State = GrblStates.Unknown; _grblState.Substate = 0; _grblState.MPG = false; GrblState = _grblState; IsMPGActive = null; //?? has_wco = false; _MPos = _WPos = _wco = _h = string.Empty; Position.Clear(); MachinePosition.Clear(); WorkPosition.Clear(); WorkPositionOffset.Clear(); ProgramLimits.Clear(); Set("Pn", string.Empty); Set("A", string.Empty); Set("FS", string.Empty); Set("Sc", string.Empty); Set("T", "0"); Set("Ov", string.Empty); Set("Ex", string.Empty); SDCardStatus = string.Empty; HomedState = HomedState.Unknown; if (_latheMode != LatheMode.Disabled) { LatheMode = LatheMode.Radius; } _thcv = _thcs = string.Empty; }
private bool Set(string parameter, string value) { bool pos_changed = false; switch (parameter) { case "MPos": if ((pos_changed = _MPos != value)) { if (!_isMPos) { IsMachinePosition = true; } _MPos = value; MachinePosition.Parse(_MPos); } break; case "WPos": if ((pos_changed = _WPos != value)) { if (_isMPos) { IsMachinePosition = false; } _WPos = value; WorkPosition.Parse(_WPos); } break; case "WCO": if ((pos_changed = _wco != value)) { _wco = value; has_wco = true; WorkPositionOffset.Parse(value); } break; case "A": if (_a != value) { _a = value; if (_a == "") { Mist = Flood = IsToolChanging = false; SpindleState.Value = GCode.SpindleState.Off; } else { Mist = value.Contains("M"); Flood = value.Contains("F"); IsToolChanging = value.Contains("T"); SpindleState.Value = value.Contains("S") ? GCode.SpindleState.CW : (value.Contains("C") ? GCode.SpindleState.CCW : GCode.SpindleState.Off); } } break; case "WCS": if (_wcs != value) { WorkCoordinateSystem = GrblParserState.WorkOffset = value; } break; case "Bf": string[] buffers = value.Split(','); if (buffers[0] != _pb_avail) { _pb_avail = buffers[0]; OnPropertyChanged(nameof(PlanBufferAvailable)); } if (buffers[1] != _rxb_avail) { _rxb_avail = buffers[1]; OnPropertyChanged(nameof(RxBufferAvailable)); } break; case "Ln": LineNumber = int.Parse(value); break; case "FS": if (_fs != value) { _fs = value; if (_fs == "") { FeedRate = ProgrammedRPM = 0d; if (!double.IsNaN(ActualRPM)) { ActualRPM = 0d; } } else { double[] values = dbl.ParseList(_fs); if (_feedrate != values[0]) { FeedRate = values[0]; } if (_rpm != values[1]) { ProgrammedRPM = values[1]; } if (values.Length > 2 && _rpmActual != values[2]) { ActualRPM = values[2]; } } } break; case "F": if (_fs != value) { _fs = value; if (_fs == "") { FeedRate = ProgrammedRPM = 0d; if (!double.IsNaN(ActualRPM)) { ActualRPM = 0d; } } else { FeedRate = dbl.Parse(_fs); } } break; case "PWM": PWM = int.Parse(value); break; case "Pn": if (_pn != value) { _pn = value; int s = 0; foreach (char c in _pn) { int i = GrblConstants.SIGNALS.IndexOf(c); if (i >= 0) { s |= (1 << i); } } Signals.Value = (Signals)s; } break; case "Ov": if (_ov != value) { _ov = value; if (_ov == string.Empty) { FeedOverride = RapidsOverride = RPMOverride = 100d; } else { double[] values = dbl.ParseList(_ov); if (_feedOverride != values[0]) { FeedOverride = values[0]; } if (_rapidsOverride != values[1]) { RapidsOverride = values[1]; } if (_rpmOverride != values[2]) { RPMOverride = values[2]; } } } break; case "Sc": if (_sc != value) { int s = 0; foreach (char c in value) { int i = GrblInfo.AxisLetterToIndex(c); if (i >= 0) { s |= (1 << i); } } AxisScaled.Value = (AxisFlags)s; Scaling = value; } break; case "Ex": if (_ex != value) { TubeCoolant = value == "C"; } break; case "SD": value = string.Format("SD Card streaming {0}% complete", value.Split(',')[0]); if (SDCardStatus != value) { Message = SDCardStatus = value; } break; case "T": if (_tool != value) { Tool = value == "0" ? GrblConstants.NO_TOOL : value; } break; case "TLR": IsTloReferenceSet = value != "0"; break; case "MPG": GrblInfo.MPGMode = _grblState.MPG = value == "1"; IsMPGActive = _grblState.MPG; break; case "H": if (_h != value) { _h = value; var hs = _h.Split(','); HomedState = hs[0] == "1" ? HomedState.Homed : (GrblState.State == GrblStates.Alarm && GrblState.Substate == 11 ? HomedState.NotHomed : HomedState.Unknown); } break; case "D": _d = value; LatheMode = GrblParserState.LatheMode = value == "0" ? LatheMode.Radius : LatheMode.Diameter; break; case "THC": { var values = value.Split(','); if (_thcv != values[0]) { _thcv = values[0]; THCVoltage = dbl.Parse(_thcv); } value = values.Length > 1 ? values[1] : ""; if (_thcs != value) { _thcs = value; int s = 0; foreach (char c in _thcs) { int i = GrblConstants.THCSIGNALS.IndexOf(c); if (i >= 0) { s |= (1 << i); } } THCSignals.Value = (THCSignals)s; } } break; case "Enc": { var enc = value.Split(','); OverrideEncoderMode = (GrblEncoderMode)int.Parse(enc[0]); } break; } return(pos_changed); }
public bool Set(string parameter, string value) { bool changed = false; switch (parameter) { case "MPos": if ((changed = _MPos != value)) { if (!_isMPos) { IsMachinePosition = true; } _MPos = value; MachinePosition.Parse(_MPos); for (int i = 0; i < GrblInfo.NumAxes; i++) { double newpos = MachinePosition.Values[i] - WorkPositionOffset.Values[i]; if (!Position.Values[i].Equals(newpos)) { Position.Values[i] = newpos; } } } break; case "WPos": if ((changed = _WPos != value)) { if (_isMPos) { IsMachinePosition = false; } _WPos = value; WorkPosition.Parse(_WPos); for (int i = 0; i < GrblInfo.NumAxes; i++) { if (!Position.Values[i].Equals(WorkPosition.Values[i])) { Position.Values[i] = WorkPosition.Values[i]; } } } break; case "A": if ((changed = _a != value)) { _a = value; if (_a == "") { Mist = Flood = IsToolChanging = false; SpindleState.Value = GCode.SpindleState.Off; } else { Mist = value.Contains("M"); Flood = value.Contains("F"); IsToolChanging = value.Contains("T"); SpindleState.Value = value.Contains("S") ? GCode.SpindleState.CW : (value.Contains("C") ? GCode.SpindleState.CCW : GCode.SpindleState.Off); } } break; case "WCO": if ((changed = _wco != value)) { _wco = value; WorkPositionOffset.Parse(value); if (_isMPos) { for (int i = 0; i < GrblInfo.NumAxes; i++) { double newpos = MachinePosition.Values[i] - WorkPositionOffset.Values[i]; if (!Position.Values[i].Equals(newpos)) { Position.Values[i] = newpos; } } } } break; case "WCS": if ((changed = _wcs != value)) { WorkCoordinateSystem = GrblParserState.WorkOffset = value; } break; case "FS": if ((changed = _fs != value)) { _fs = value; if (_fs == "") { FeedRate = ProgrammedRPM = 0d; if (!double.IsNaN(ActualRPM)) { ActualRPM = 0d; } } else { double[] values = dbl.ParseList(_fs); if (_feedrate != values[0]) { FeedRate = values[0]; } if (_rpm != values[1]) { ProgrammedRPM = values[1]; } if (values.Length > 2 && _rpmActual != values[2]) { ActualRPM = values[2]; } } } break; case "Pn": if ((changed = _pn != value)) { _pn = value; int s = 0; foreach (char c in _pn) { int i = GrblConstants.SIGNALS.IndexOf(c); if (i >= 0) { s |= (1 << i); } } Signals.Value = (Signals)s; } break; case "Ov": if ((changed = _ov != value)) { _ov = value; if (_ov == string.Empty) { FeedOverride = RapidsOverride = RPMOverride = 100d; } else { double[] values = dbl.ParseList(_ov); if (_feedOverride != values[0]) { FeedOverride = values[0]; } if (_rapidsOverride != values[1]) { RapidsOverride = values[1]; } if (_rpmOverride != values[2]) { RPMOverride = values[2]; } } } break; case "Sc": if ((changed = _sc != value)) { int s = 0; foreach (char c in value) { int i = GrblInfo.AxisLetterToIndex(c); if (i >= 0) { s |= (1 << i); } } AxisScaled.Value = (AxisFlags)s; Scaling = value; } break; case "Ex": if ((changed = _ex != value)) { TubeCoolant = value == "C"; } break; case "SD": value = string.Format("SD Card streaming {0}% complete", value); if ((changed = SDCardStatus != value)) { Message = SDCardStatus = value; } break; case "T": if ((changed = _tool != value)) { Tool = GrblParserState.Tool = value == "0" ? GrblConstants.NO_TOOL : value; } break; case "MPG": GrblInfo.MPGMode = _grblState.MPG = value == "1"; IsMPGActive = _grblState.MPG; changed = true; break; case "H": if (_h != value) { _h = value; HomedState = value == "1" ? HomedState.Homed : HomedState.Unknown; changed = true; } break; case "D": _d = value; LatheMode = GrblParserState.LatheMode = value == "0" ? LatheMode.Radius : LatheMode.Diameter; changed = true; break; } return(changed); }