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-01-16 12:17:10 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-16 12:17:10 +0200
commit0fda2ba3ff49bdc1ffc6833f658e2164af187008 (patch)
tree6f3a24d0671ebda50debb8511ab40e0bda0a0df0 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels
parent28103646681686bf1b58275d5dbccb92d2b26f9f (diff)
downloadTango-0fda2ba3ff49bdc1ffc6833f658e2164af187008.tar.gz
Tango-0fda2ba3ff49bdc1ffc6833f658e2164af187008.zip
Embedded RealTimeGraphEx library to solution.
Added graphs to technician view. Implemented simple sensors data test using Machine Emulator.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs27
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs139
2 files changed, 166 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs
index c715af6cb..68852fe20 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs
@@ -3,12 +3,39 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.Core.Commands;
+using Tango.MachineStudio.Technician.Navigation;
using Tango.SharedUI;
namespace Tango.MachineStudio.Technician.ViewModels
{
public class MainViewVM : ViewModel
{
+ private TechNavigationManager _navigation;
+ #region Constructors
+
+ public MainViewVM(TechNavigationManager navigationManager)
+ {
+ _navigation = navigationManager;
+ NavigateToViewCommand = new RelayCommand<string>(NavigateToView);
+ }
+
+ #endregion
+
+ #region Commands
+
+ public RelayCommand<String> NavigateToViewCommand { get; set; }
+
+ #endregion
+
+ #region Private Methods
+
+ private void NavigateToView(string view)
+ {
+ _navigation.NavigateTo((TechNavigationView)Enum.Parse(typeof(TechNavigationView), view, true));
+ }
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs
new file mode 100644
index 000000000..cb3114f4c
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs
@@ -0,0 +1,139 @@
+using RealTimeGraphEx.Controllers;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Integration.Operators;
+using Tango.Logging;
+using Tango.MachineStudio.Common.Modules;
+using Tango.MachineStudio.Common.StudioApplication;
+using Tango.PMR.Diagnostics;
+using Tango.Settings;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.Technician.ViewModels
+{
+ public class SensorsViewVM : ViewModel
+ {
+ private List<GraphControllerBase> _controllers;
+
+ public IStudioApplicationManager ApplicationManager { get; set; }
+
+ private IMachineOperator _machineOperator;
+ public IMachineOperator MachineOperator
+ {
+ get { return _machineOperator; }
+ set { _machineOperator = value; RaisePropertyChangedAuto(); }
+ }
+
+ public SensorsViewVM(IStudioApplicationManager applicationManager, IStudioModuleLoader moduleLoader)
+ {
+ ApplicationManager = applicationManager;
+ ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged;
+
+ InitializeConnectedMachine(ApplicationManager.ConnectedMachine);
+
+ if (!DesignMode)
+ {
+ //Set graphs FIFO capacity by seconds (this will be converted to MaxPoints by the view).
+ GraphSeconds = SettingsManager.Default.MachineStudio.TechnicianModule.GraphsDuration;
+
+ _controllers = new List<GraphControllerBase>();
+
+ TemperatureController = new GraphController();
+ PressureController = new GraphController();
+
+ _controllers.Add(TemperatureController);
+ _controllers.Add(PressureController);
+
+ var module = moduleLoader.UserModules.SingleOrDefault(x => x is TechnicianModule) as TechnicianModule;
+
+ if (module != null)
+ {
+ module.IsLoadedChanged += Module_IsLoadedChanged;
+ }
+ }
+ }
+
+ private void Module_IsLoadedChanged(object sender, bool loaded)
+ {
+ //_controllers.ForEach(x => x.ChangeRenderMode(loaded));
+ }
+
+ private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machineOperator)
+ {
+ InitializeConnectedMachine(machineOperator);
+ }
+
+ private void MachineOperator_SensorsDataAvailable(object sender, PushSensorsResponse data)
+ {
+ TemperatureController.PushData(data.Temperature.ToArray().Select(Convert.ToDouble).ToArray());
+ PressureController.PushData(data.Temperature.ToArray().Select(Convert.ToDouble).ToArray());
+ }
+
+ private void InitializeConnectedMachine(IMachineOperator machineOperator)
+ {
+ MachineOperator = machineOperator;
+
+ if (MachineOperator != null)
+ {
+ MachineOperator.EnableSensorsUpdate = true;
+ MachineOperator.SensorsDataAvailable -= MachineOperator_SensorsDataAvailable;
+ MachineOperator.SensorsDataAvailable += MachineOperator_SensorsDataAvailable;
+ }
+ }
+
+ #region Graphs Controllers
+
+ private GraphController _temperatureController;
+ /// <summary>
+ /// Gets or sets the temperature sensor graph controller .
+ /// </summary>
+ public GraphController TemperatureController
+ {
+ get { return _temperatureController; }
+ set { _temperatureController = value; RaisePropertyChanged(nameof(TemperatureController)); }
+ }
+
+ private GraphController _pressureController;
+ /// <summary>
+ /// Gets or sets the pressure sensor graph controller .
+ /// </summary>
+ public GraphController PressureController
+ {
+ get { return _pressureController; }
+ set { _pressureController = value; RaisePropertyChanged(nameof(PressureController)); }
+ }
+
+ #endregion
+
+ private int _graphSeconds;
+ /// <summary>
+ /// Gets or sets the graphs number of seconds to complete FIFO capacity.
+ /// </summary>
+ public int GraphSeconds
+ {
+ get { return _graphSeconds; }
+ set { _graphSeconds = value; RaisePropertyChanged(nameof(GraphSeconds)); }
+ }
+
+ /// <summary>
+ /// Clears the graphs.
+ /// </summary>
+ public void ClearGraphs()
+ {
+ _controllers.ForEach(x => x.Clear());
+ }
+
+ /// <summary>
+ /// Creates a dummy list with default value of -1000 (used to fill graphs buffer).
+ /// </summary>
+ /// <param name="count">List length.</param>
+ /// <returns></returns>
+ private List<double> CreateDummyList(int count)
+ {
+ return Enumerable.Repeat<double>(-1000, count + 1).ToList();
+ }
+ }
+}