diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs | 99 |
1 files changed, 98 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index 381101c7e..7c2acfdbb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -52,7 +52,7 @@ namespace Tango.MachineStudio.Technician.ViewModels private DateTime _lastDiagnosticsResponseUpdate; private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500; private TechnicianModuleSettings _settings; - + #region Properties @@ -535,6 +535,16 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement<SpeedSensorElementEditor, SpeedSensorItem, HardwareSpeedSensorType>(bounds, Adapter.HardwareSpeedSensorTypes.FirstOrDefault()); } + else if (item is ProcessParametersItem) + { + var editor = CreateElement<ProcessParametersElementEditor, ProcessParametersItem, object>(bounds, null); + InitProcessParameterItem(editor.ProcessParametersItem); + } + else if (item is JobRunnerItem) + { + var editor = CreateElement<JobRunnerElementEditor, JobRunnerItem, object>(bounds, null); + InitJobRunnerItem(editor.JobRunnerItem); + } } /// <summary> @@ -654,6 +664,16 @@ namespace Tango.MachineStudio.Technician.ViewModels (item as SpeedSensorItem).HardwareSpeedSensorType = Adapter.HardwareSpeedSensorTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); CreateElement<SpeedSensorElementEditor>(item); } + else if (item is ProcessParametersItem) + { + var editor = CreateElement<ProcessParametersElementEditor>(item); + InitProcessParameterItem(editor.ProcessParametersItem); + } + else if (item is JobRunnerItem) + { + var editor = CreateElement<JobRunnerElementEditor>(item); + InitJobRunnerItem(editor.JobRunnerItem); + } } /// <summary> @@ -1139,6 +1159,83 @@ namespace Tango.MachineStudio.Technician.ViewModels } /// <summary> + /// Initializes the process parameter item. + /// </summary> + /// <param name="item">The item.</param> + private void InitProcessParameterItem(ProcessParametersItem item) + { + item.PushParametersPressed += async (x, parameters) => + { + try + { + CheckMachineOperator(); + + using (_notification.PushTaskItem("Uploading process parameters...")) + { + try + { + await MachineOperator.UploadProcessParameters(parameters); + } + catch (Exception ex) + { + String msg = "Error uploading process parameters:" + Environment.NewLine + parameters.ToJsonString(); + _eventLogger.Log(ex,msg); + LogManager.Log(ex, msg); + _notification.ShowError("Could not upload process parameters." + Environment.NewLine + ex.Message); + } + } + } + catch (Exception ex) + { + _notification.ShowError(ex.Message); + } + }; + } + + /// <summary> + /// Initializes the job runner item. + /// </summary> + /// <param name="item">The item.</param> + /// <exception cref="NotImplementedException"></exception> + private void InitJobRunnerItem(JobRunnerItem item) + { + item.StartJob += () => + { + try + { + CheckMachineOperator(); + + var handler = MachineOperator.Print(item.Job, item.ProcessParameters); + + item.JobHandler = handler; + + handler.StatusChanged += (x, status) => + { + item.RunningJobStatus = status; + }; + + handler.Stopped += (x,e) => + { + item.IsJobStarted = false; + }; + } + catch (Exception ex) + { + _notification.ShowError(ex.Message); + } + }; + + item.StopJob += () => + { + if (item.JobHandler != null) + { + item.JobHandler.Cancel(); + item.JobHandler = null; + } + }; + } + + /// <summary> /// Checks the machine operator. /// </summary> /// <exception cref="InvalidOperationException">No machine connected.</exception> |
