aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-29 13:03:22 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-29 13:03:22 +0300
commit86919dc24020229cbd1d8c59f29a4a36895f5b7a (patch)
treee0acd81cad23bbd0948978d76dc841d0553bcbcf /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels
parentd62b12aab4f521ff287da135b6e66e92629a50dd (diff)
downloadTango-86919dc24020229cbd1d8c59f29a4a36895f5b7a.tar.gz
Tango-86919dc24020229cbd1d8c59f29a4a36895f5b7a.zip
Implemented diagnostics frame rate monitor on IDiagnosticsFrameProvider.
Added diagnostics frame rate to connected machine dialog. Implemented dynamic graphs max points using frame rate on tech board!. Implemented speed control on DIagnosticsFilePlayer & Data Capture module. Implemented graphs duration control on tech board.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs98
1 files changed, 89 insertions, 9 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 d403223ec..3dff65fbc 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
@@ -43,6 +43,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
public class MachineTechViewVM : StudioViewModel<TechnicianModule>
{
private List<PropertyInfo> _diagnoticsMonitorsDataProperties;
+ private IDiagnosticsFrameProvider _diagnosticsFrameProvider;
private Dictionary<SingleGraphItem, GraphController> _singleControllers;
private Dictionary<MultiGraphItem, GraphMultiController> _multiControllers;
private static object _elementsLock = new object();
@@ -149,6 +150,28 @@ namespace Tango.MachineStudio.Technician.ViewModels
set { _currentDiagnosticsResponseSize = value; RaisePropertyChanged(nameof(CurrentDiagnosticsResponseSize)); }
}
+ private int _graphsDurationSeconds;
+ /// <summary>
+ /// Gets or sets the graphs duration seconds.
+ /// </summary>
+ public int GraphsDurationSeconds
+ {
+ get { return _graphsDurationSeconds; }
+ set { _graphsDurationSeconds = value; RaisePropertyChangedAuto(); }
+ }
+
+ private int _tempGraphsDurationSeconds;
+ /// <summary>
+ /// Gets or sets the temporary graphs duration seconds.
+ /// </summary>
+ public int TempGraphsDurationSeconds
+ {
+ get { return _tempGraphsDurationSeconds; }
+ set { _tempGraphsDurationSeconds = value; RaisePropertyChangedAuto(); }
+ }
+
+
+
#endregion
#region Commands
@@ -183,6 +206,8 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// </summary>
public RelayCommand ResetHardwareConfigurationCommand { get; set; }
+ public RelayCommand UpdateGraphsDurationCommand { get; set; }
+
#endregion
#region Constructors
@@ -192,10 +217,13 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// </summary>
/// <param name="applicationManager">The application manager.</param>
/// <param name="notificationProvider">The notification provider.</param>
- public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider _diagnosticsFrameProvider, IEventLogger eventLogger)
+ public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IEventLogger eventLogger)
{
_settings = SettingsManager.Default.GetOrCreate<TechnicianModuleSettings>();
+ GraphsDurationSeconds = _settings.GraphsDuration;
+ TempGraphsDurationSeconds = GraphsDurationSeconds;
+
_notification = notificationProvider;
_eventLogger = eventLogger;
_singleControllers = new Dictionary<SingleGraphItem, GraphController>();
@@ -217,14 +245,28 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (File.Exists(_lastTechProjectFile))
{
- OpenProjectFile(_lastTechProjectFile);
+ try
+ {
+ OpenProjectFile(_lastTechProjectFile);
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error loading last project file.");
+ }
}
+ _diagnosticsFrameProvider = diagnosticsFrameProvider;
_diagnosticsFrameProvider.FrameReceived += DiagnosticsFrameProvider_FrameReceived;
UploadHardwareConfigurationCommand = new RelayCommand(UploadHardwareConfiguration);
SyncHardwareConfigurationCommand = new RelayCommand(SyncHardwareConfiguration);
ResetHardwareConfigurationCommand = new RelayCommand(() => ResetHardwareConfiguration());
+ UpdateGraphsDurationCommand = new RelayCommand(() =>
+ {
+ GraphsDurationSeconds = TempGraphsDurationSeconds;
+ _settings.GraphsDuration = GraphsDurationSeconds;
+ ClearAllGraphs();
+ });
}
#endregion
@@ -320,7 +362,16 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (_singleControllers.TryGetValue(graphItem, out controller))
{
- controller.PushData(GetDataArray(graphItem.TechMonitor, prop.GetValue(data.Monitors)));
+ var points = GetDataArray(graphItem.TechMonitor, prop.GetValue(data.Monitors));
+
+ int maxPoints = (int)(_diagnosticsFrameProvider.FrameRate * GraphsDurationSeconds * points.Count);
+
+ InvokeUI(() =>
+ {
+ graphItem.Editor.InnerGraph.InnerGraph.MaxPoints = maxPoints;
+ });
+
+ controller.PushData(points);
}
}
}
@@ -336,7 +387,19 @@ namespace Tango.MachineStudio.Technician.ViewModels
if (_multiControllers.TryGetValue(graphItem, out controller))
{
- controller.PushData(GetDataMatrix(graphItem.TechMonitor, prop.GetValue(data.Monitors)));
+ var points = GetDataMatrix(graphItem.TechMonitor, prop.GetValue(data.Monitors));
+
+ if (points.Count > 0)
+ {
+ int maxPoints = (int)(_diagnosticsFrameProvider.FrameRate * GraphsDurationSeconds * points[0].Count);
+
+ InvokeUI(() =>
+ {
+ graphItem.Editor.InnerGraph.InnerGraph.MaxPoints = maxPoints;
+ });
+ }
+
+ controller.PushData(points);
}
}
}
@@ -1179,7 +1242,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
catch (Exception ex)
{
String msg = "Error uploading process parameters:" + Environment.NewLine + parameters.ToJsonString();
- _eventLogger.Log(ex,msg);
+ _eventLogger.Log(ex, msg);
LogManager.Log(ex, msg);
_notification.ShowError("Could not upload process parameters." + Environment.NewLine + ex.Message);
}
@@ -1199,7 +1262,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// <exception cref="NotImplementedException"></exception>
private void InitJobRunnerItem(JobRunnerItem item)
{
- item.StartJob += () =>
+ item.StartJob += () =>
{
try
{
@@ -1209,12 +1272,12 @@ namespace Tango.MachineStudio.Technician.ViewModels
item.JobHandler = handler;
- handler.StatusChanged += (x, status) =>
+ handler.StatusChanged += (x, status) =>
{
item.RunningJobStatus = status;
};
- handler.Stopped += (x,e) =>
+ handler.Stopped += (x, e) =>
{
item.IsJobStarted = false;
};
@@ -1226,7 +1289,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
}
};
- item.StopJob += () =>
+ item.StopJob += () =>
{
if (item.JobHandler != null)
{
@@ -1597,5 +1660,22 @@ namespace Tango.MachineStudio.Technician.ViewModels
}
#endregion
+
+ #region Graphs
+
+ public void ClearAllGraphs()
+ {
+ foreach (var controller in _singleControllers)
+ {
+ controller.Value.Clear();
+ }
+
+ foreach (var controller in _multiControllers)
+ {
+ controller.Value.Clear();
+ }
+ }
+
+ #endregion
}
}