aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-07-16 09:29:44 +0300
committerAvi Levkovich <avi@twine-s.com>2018-07-16 09:29:44 +0300
commitbeed152bc9c9c004991b414613fef17e06737962 (patch)
tree0aac90d453d846b6b1f2195f7211a3dc07280e8d /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
parent230606f80543e12f04f7ca674a208de9d78ad3a1 (diff)
parentd376387fa28a2091a21e2fc7193812d1f8a40ef2 (diff)
downloadTango-beed152bc9c9c004991b414613fef17e06737962.tar.gz
Tango-beed152bc9c9c004991b414613fef17e06737962.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
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.cs99
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>