aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
diff options
context:
space:
mode:
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.cs100
1 files changed, 90 insertions, 10 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 0c09850c1..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
@@ -25,7 +25,7 @@ using Tango.MachineStudio.Technician.TechItems;
using Tango.PMR.Diagnostics;
using Tango.Settings;
using Tango.SharedUI;
-using Tango.Integration.Services;
+using Tango.Integration.ExternalBridge;
using Tango.BL.Enumerations;
using Tango.BL;
using Tango.MachineStudio.Common.EventLogging;
@@ -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
}
}