private void OnDataContextPropertyChanged(object sender, PropertyChangedEventArgs e) { if (sender is GrblViewModel) { switch (e.PropertyName) { case nameof(GrblViewModel.GrblState): GrblStateChanged(((GrblViewModel)sender).GrblState); break; case nameof(GrblViewModel.MDI): SendCommand(((GrblViewModel)sender).MDI); break; case nameof(GrblViewModel.IsMPGActive): grblState.MPG = ((GrblViewModel)sender).IsMPGActive == true; poller.SetState(grblState.MPG ? 0 : model.PollInterval); streamingHandler.Call(grblState.MPG ? StreamingState.Disabled : StreamingState.Idle, false); break; case nameof(GrblViewModel.Signals): { var signals = ((GrblViewModel)sender).Signals; if (JobPending && signals[Signals.CycleStart] && !signals[Signals.Hold] && holdSignal) { CycleStart(); } holdSignal = signals[Signals.Hold]; } break; case nameof(GrblViewModel.ProgramEnd): if (!GCode.File.IsLoaded) { streamingHandler.Call(job.IsSDFile ? StreamingState.JobFinished : StreamingState.NoFile, job.IsSDFile); } else if (JobTimer.IsRunning && !job.Complete) { streamingHandler.Call(StreamingState.JobFinished, true); } break; case nameof(GrblViewModel.FileName): { if (((GrblViewModel)sender).FileName != "") { job.IsSDFile = false; job.CurrLine = job.PendingLine = job.ACKPending = 0; job.PgmEndLine = GCode.File.Blocks - 1; streamingHandler.Call(GCode.File.IsLoaded ? StreamingState.Idle : StreamingState.NoFile, false); } break; } case nameof(GrblViewModel.GrblReset): { JobTimer.Stop(); streamingHandler.Call(StreamingState.Stop, true); } break; } } }
private void OnDataContextPropertyChanged(object sender, PropertyChangedEventArgs e) { if (sender is GrblViewModel) { switch (e.PropertyName) { case nameof(GrblViewModel.GrblState): GrblStateChanged(((GrblViewModel)sender).GrblState); break; case nameof(GrblViewModel.MDI): SendCommand(((GrblViewModel)sender).MDI); break; case nameof(GrblViewModel.IsMPGActive): grblState.MPG = ((GrblViewModel)sender).IsMPGActive == true; ((GrblViewModel)sender).Poller.SetState(grblState.MPG ? 0 : AppConfig.Settings.Base.PollInterval); streamingHandler.Call(grblState.MPG ? StreamingState.Disabled : StreamingState.Idle, false); break; case nameof(GrblViewModel.Signals): { var signals = ((GrblViewModel)sender).Signals.Value; if (JobPending && signals.HasFlag(Signals.CycleStart) && !signals.HasFlag(Signals.Hold) && !cycleStartSignal) { CycleStart(); } holdSignal = signals.HasFlag(Signals.Hold); cycleStartSignal = signals.HasFlag(Signals.CycleStart); } break; case nameof(GrblViewModel.ProgramEnd): if (!GCode.File.IsLoaded) { streamingHandler.Call(job.IsSDFile ? StreamingState.JobFinished : StreamingState.NoFile, job.IsSDFile); } else if (JobTimer.IsRunning && !job.Complete) { streamingHandler.Call(StreamingState.JobFinished, true); } break; case nameof(GrblViewModel.FileName): { if (string.IsNullOrEmpty(((GrblViewModel)sender).FileName)) { job.NextRow = null; } else { job.IsSDFile = false; job.CurrLine = job.PendingLine = job.ACKPending = model.BlockExecuting = 0; job.PgmEndLine = GCode.File.Blocks - 1; if (GCode.File.ToolChanges > 0 && GrblSettings.GetInteger(GrblSetting.ToolChangeMode) > 0 && !model.IsTloReferenceSet) { MessageBox.Show(string.Format("Job has {0} tool change(s), tool length reference should be established before start.", GCode.File.ToolChanges), "GCode Sender", MessageBoxButton.OK, MessageBoxImage.Warning); } streamingHandler.Call(GCode.File.IsLoaded ? StreamingState.Idle : StreamingState.NoFile, false); } break; } case nameof(GrblViewModel.GrblReset): { JobTimer.Stop(); streamingHandler.Call(StreamingState.Stop, true); } break; } } }
private void OnDataContextPropertyChanged(object sender, PropertyChangedEventArgs e) { if (sender is GrblViewModel) { switch (e.PropertyName) { case nameof(GrblViewModel.GrblState): GrblStateChanged((sender as GrblViewModel).GrblState); break; case nameof(GrblViewModel.MDI): SendCommand((sender as GrblViewModel).MDI); break; case nameof(GrblViewModel.IsMPGActive): grblState.MPG = (sender as GrblViewModel).IsMPGActive == true; (sender as GrblViewModel).Poller.SetState(grblState.MPG ? 0 : AppConfig.Settings.Base.PollInterval); streamingHandler.Call(grblState.MPG ? StreamingState.Disabled : StreamingState.Idle, false); break; case nameof(GrblViewModel.Signals): if (isActive) { var signals = (sender as GrblViewModel).Signals.Value; if (JobPending && signals.HasFlag(Signals.CycleStart) && !signals.HasFlag(Signals.Hold) && !cycleStartSignal) { CycleStart(); } holdSignal = signals.HasFlag(Signals.Hold); cycleStartSignal = signals.HasFlag(Signals.CycleStart); } break; case nameof(GrblViewModel.ProgramEnd): if (!GCode.File.IsLoaded) { streamingHandler.Call(model.IsSDCardJob ? StreamingState.JobFinished : StreamingState.NoFile, model.IsSDCardJob); } else if (JobTimer.IsRunning && !job.Complete) { streamingHandler.Call(StreamingState.JobFinished, true); } if (!model.IsParserStateLive) { SendCommand(GrblConstants.CMD_GETPARSERSTATE); } break; case nameof(GrblViewModel.FileName): { job.IsSDFile = false; if (string.IsNullOrEmpty((sender as GrblViewModel).FileName)) { job.NextRow = null; } else { job.ToolChangeLine = -1; job.CurrLine = job.PendingLine = job.ACKPending = model.BlockExecuting = 0; job.PgmEndLine = GCode.File.Blocks - 1; if ((sender as GrblViewModel).IsPhysicalFileLoaded) { if (GCode.File.ToolChanges > 0) { if (!GrblSettings.HasSetting(grblHALSetting.ToolChangeMode)) { MessageBox.Show(string.Format((string)FindResource("JobToolChanges"), GCode.File.ToolChanges), "ioSender", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (GrblSettings.GetInteger(grblHALSetting.ToolChangeMode) > 0 && !model.IsTloReferenceSet) { MessageBox.Show(string.Format((string)FindResource("JobToolReference"), GCode.File.ToolChanges), "ioSender", MessageBoxButton.OK, MessageBoxImage.Warning); } } if (GCode.File.HasGoPredefinedPosition && (sender as GrblViewModel).IsGrblHAL && (sender as GrblViewModel).HomedState != HomedState.Homed) { MessageBox.Show((string)FindResource("JobG28G30"), "ioSender", MessageBoxButton.OK, MessageBoxImage.Warning); } streamingHandler.Call(GCode.File.IsLoaded ? StreamingState.Idle : StreamingState.NoFile, false); } } break; } case nameof(GrblViewModel.GrblReset): { JobTimer.Stop(); streamingHandler.Call(StreamingState.Stop, true); } break; } } }