From 0fda2ba3ff49bdc1ffc6833f658e2164af187008 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 16 Jan 2018 12:17:10 +0200 Subject: Embedded RealTimeGraphEx library to solution. Added graphs to technician view. Implemented simple sensors data test using Machine Emulator. --- .../Modules/Tango.MachineStudio.DB/DBModule.cs | 9 +- .../DeveloperModule.cs | 6 + .../MachineDesignerModule.cs | 7 + .../Tango.MachineStudio.Stubs/StubsModule.cs | 7 + .../SynchronizationModule.cs | 9 +- .../ViewModels/MainViewVM.cs | 2 +- .../Converters/SecondsToGraphPointsConverter.cs | 23 ++++ .../Converters/TransitionLinkConverter.cs | 55 ++++++++ .../Helpers/GraphsMaxPointsHelper.cs | 26 ++++ .../Navigation/TechNavigationManager.cs | 17 +++ .../Navigation/TechNavigationView.cs | 15 +++ .../Resources/GraphEx.xaml | 126 ++++++++++++++++++ .../Tango.MachineStudio.Technician.csproj | 35 +++++ .../TechnicianModule.cs | 14 ++ .../ViewModelLocator.cs | 15 +++ .../ViewModels/MainViewVM.cs | 27 ++++ .../ViewModels/SensorsViewVM.cs | 139 ++++++++++++++++++++ .../Views/MainView.xaml | 90 ++++++++++++- .../Views/MainView.xaml.cs | 3 + .../Views/MotorsView.xaml | 12 ++ .../Views/MotorsView.xaml.cs | 28 ++++ .../Views/OverviewView.xaml | 12 ++ .../Views/OverviewView.xaml.cs | 28 ++++ .../Views/SensorsView.xaml | 141 +++++++++++++++++++++ .../Views/SensorsView.xaml.cs | 53 ++++++++ 25 files changed, 891 insertions(+), 8 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/SecondsToGraphPointsConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/TransitionLinkConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Helpers/GraphsMaxPointsHelper.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationManager.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationView.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Resources/GraphEx.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs index 4f751d9da..c433a4cd4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs @@ -17,10 +17,8 @@ namespace Tango.MachineStudio.DB /// public class DBModule : IStudioModule { - /// - /// The is initialized - /// private bool _isInitialized; + private bool _isLoaded; /// /// Gets the module name. @@ -52,6 +50,11 @@ namespace Tango.MachineStudio.DB /// public Permissions Permission => Permissions.RunDataBaseModule; + /// + /// Sets a value indicating whether this module is loaded. + /// + public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs index c3d351468..4401245a9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs @@ -15,6 +15,7 @@ namespace Tango.MachineStudio.Developer public class DeveloperModule : IStudioModule { private bool _isInitialized; + private bool _isLoaded; public string Name => "Developer"; @@ -26,6 +27,11 @@ namespace Tango.MachineStudio.Developer public bool IsInitialized => _isInitialized; + /// + /// Sets a value indicating whether this module is loaded. + /// + public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + public Permissions Permission => Permissions.RunDeveloperModule; public void Dispose() diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs index ca13bd350..8fbac790f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs @@ -18,6 +18,8 @@ namespace Tango.MachineStudio.MachineDesigner /// public class MachineDesignerModule : IStudioModule { + private bool _isLoaded; + /// /// Gets the module name. /// @@ -33,6 +35,11 @@ namespace Tango.MachineStudio.MachineDesigner /// public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/machine-designer-module.jpg"); + /// + /// Sets a value indicating whether this module is loaded. + /// + public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + /// /// Gets the module entry point view. /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs index 23214cf55..8b072ea46 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs @@ -18,6 +18,8 @@ namespace Tango.MachineStudio.Stubs /// public class StubsModule : IStudioModule { + private bool _isLoaded; + /// /// Gets the module name. /// @@ -38,6 +40,11 @@ namespace Tango.MachineStudio.Stubs /// public FrameworkElement MainView => new MainView(); + /// + /// Sets a value indicating whether this module is loaded. + /// + public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + /// /// Gets the permission required to see and load this module. /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs index f6381a482..4a753b05e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs @@ -18,9 +18,7 @@ namespace Tango.MachineStudio.Synchronization /// public class SynchronizationModule : IStudioModule { - /// - /// The is initialized - /// + private bool _isLoaded; private bool _isInitialized; /// @@ -43,6 +41,11 @@ namespace Tango.MachineStudio.Synchronization /// public FrameworkElement MainView => new MainView(); + /// + /// Sets a value indicating whether this module is loaded. + /// + public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + /// /// Gets a value indicating whether this module has been initialized. /// diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MainViewVM.cs index 48a5c64bd..21d76d7d7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/MainViewVM.cs @@ -22,7 +22,7 @@ namespace Tango.MachineStudio.Synchronization.ViewModels MainViewLogger logger = new MainViewLogger(); logger.NewLog += (output) => { - Log += output + Environment.NewLine; + //Log += output + Environment.NewLine; }; LogManager.RegisterLogger(logger); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/SecondsToGraphPointsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/SecondsToGraphPointsConverter.cs new file mode 100644 index 000000000..3120c44a6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/SecondsToGraphPointsConverter.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.MachineStudio.Technician.Converters +{ + public class SecondsToGraphPointsConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + double arrLength = double.Parse(parameter.ToString()); + return Helpers.GraphsMaxPointsHelper.GetMaxPoints(arrLength); + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return value; + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/TransitionLinkConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/TransitionLinkConverter.cs new file mode 100644 index 000000000..d67f3a259 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Converters/TransitionLinkConverter.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; + +namespace Tango.MachineStudio.Technician.Converters +{ + /// + /// Binding converter for converting TransitionControl child Tag to text style. + /// + /// + /// This converter is used by the patient page tabs, changing the selected tab text style to bold/normal. + /// + public class TransitionLinkConverter : IValueConverter + { + /// + /// Converts a ContentControl to font style. + /// + /// Content control. + /// + /// + /// + /// Font style. + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + ContentControl control = value as ContentControl; + + if (control != null && control.Tag != null && control.Tag.ToString().ToLower() == parameter.ToString().ToLower()) + { + return FontWeights.Bold; + } + else + { + return FontWeights.Normal; + } + } + + /// + /// Not Implemented. + /// + /// + /// + /// + /// + /// + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return value; + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Helpers/GraphsMaxPointsHelper.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Helpers/GraphsMaxPointsHelper.cs new file mode 100644 index 000000000..87aab5967 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Helpers/GraphsMaxPointsHelper.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; + +namespace Tango.MachineStudio.Technician.Helpers +{ + public static class GraphsMaxPointsHelper + { + public static int GetMaxPoints(double arrLength) + { + try + { + double seconds = SettingsManager.Default.MachineStudio.TechnicianModule.GraphsDuration; + double pullRate = SettingsManager.Default.MachineStudio.TechnicianModule.GraphsPullingInterval; + return (int)(((pullRate * arrLength * 10 * seconds) * (10 / pullRate)) * 0.65); + } + catch (Exception) + { + return 300; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationManager.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationManager.cs new file mode 100644 index 000000000..f473776d1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationManager.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Technician.Views; + +namespace Tango.MachineStudio.Technician.Navigation +{ + public class TechNavigationManager + { + public void NavigateTo(TechNavigationView view) + { + MainView.Instance.TransitionControl.AutoNavigate(view.ToString()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationView.cs new file mode 100644 index 000000000..27d9fb09b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Navigation/TechNavigationView.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Technician.Navigation +{ + public enum TechNavigationView + { + Overview, + Motors, + Sensors, + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Resources/GraphEx.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Resources/GraphEx.xaml new file mode 100644 index 000000000..85cccc2dd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Resources/GraphEx.xaml @@ -0,0 +1,126 @@ + + + Segoe UI + Lucida Console + + 28 + 26 + 20 + 16 + 14 + 12 + 9 + + + Silver + #FFE9E9E9 + Gray + #03A9F4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj index 2c5df42fc..097917fef 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Tango.MachineStudio.Technician.csproj @@ -77,15 +77,46 @@ + + + + + + + + MotorsView.xaml + + + OverviewView.xaml + + + SensorsView.xaml + MainView.xaml GlobalVersionInfo.cs + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -117,6 +148,10 @@ + + {b9ae25d6-be35-492f-9079-21a7f3e6f7cc} + RealTimeGraphEx + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs index a4eaff71e..b715b6710 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs @@ -14,6 +14,10 @@ namespace Tango.MachineStudio.Technician { public class TechnicianModule : IStudioModule { + private bool _isLoaded; + + public event EventHandler IsLoadedChanged; + public string Name => "Technician"; public string Description => "Provides access to low level machine components by exposing diagnostics and profiling tools."; @@ -26,6 +30,16 @@ namespace Tango.MachineStudio.Technician public bool IsInitialized => true; + /// + /// Sets a value indicating whether this module is loaded. + /// + public bool IsLoaded + { + get { return _isLoaded; } + set { _isLoaded = value; IsLoadedChanged?.Invoke(this, value); } + } + + public void Dispose() { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs index f922d5ec4..e7fea686d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs @@ -1,6 +1,7 @@ using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Ioc; using Microsoft.Practices.ServiceLocation; +using Tango.MachineStudio.Technician.Navigation; using Tango.MachineStudio.Technician.ViewModels; namespace Tango.MachineStudio.Technician @@ -17,7 +18,13 @@ namespace Tango.MachineStudio.Technician static ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + + SimpleIoc.Default.Unregister(); + + SimpleIoc.Default.Register(); } public static MainViewVM MainViewVM @@ -27,5 +34,13 @@ namespace Tango.MachineStudio.Technician return ServiceLocator.Current.GetInstance(); } } + + public static SensorsViewVM SensorsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file 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(NavigateToView); + } + + #endregion + + #region Commands + + public RelayCommand 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 _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(); + + 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; + /// + /// Gets or sets the temperature sensor graph controller . + /// + public GraphController TemperatureController + { + get { return _temperatureController; } + set { _temperatureController = value; RaisePropertyChanged(nameof(TemperatureController)); } + } + + private GraphController _pressureController; + /// + /// Gets or sets the pressure sensor graph controller . + /// + public GraphController PressureController + { + get { return _pressureController; } + set { _pressureController = value; RaisePropertyChanged(nameof(PressureController)); } + } + + #endregion + + private int _graphSeconds; + /// + /// Gets or sets the graphs number of seconds to complete FIFO capacity. + /// + public int GraphSeconds + { + get { return _graphSeconds; } + set { _graphSeconds = value; RaisePropertyChanged(nameof(GraphSeconds)); } + } + + /// + /// Clears the graphs. + /// + public void ClearGraphs() + { + _controllers.ForEach(x => x.Clear()); + } + + /// + /// Creates a dummy list with default value of -1000 (used to fill graphs buffer). + /// + /// List length. + /// + private List CreateDummyList(int count) + { + return Enumerable.Repeat(-1000, count + 1).ToList(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml index 1337358e1..6b84881fd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml @@ -5,10 +5,98 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:global="clr-namespace:Tango.MachineStudio.Technician" xmlns:vm="clr-namespace:Tango.MachineStudio.Technician.ViewModels" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:sharedUI="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.Technician.Views" + xmlns:converters="clr-namespace:Tango.MachineStudio.Technician.Converters" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}" Background="White"> + + + + + + + + + + + + + - Technician + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml.cs index 0701fbc50..b07fc597e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MainView.xaml.cs @@ -20,9 +20,12 @@ namespace Tango.MachineStudio.Technician.Views /// public partial class MainView : UserControl { + public static MainView Instance { get; set; } + public MainView() { InitializeComponent(); + Instance = this; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml new file mode 100644 index 000000000..3fb49d457 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml @@ -0,0 +1,12 @@ + + + MOTORS + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml.cs new file mode 100644 index 000000000..bd548766c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MotorsView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Technician.Views +{ + /// + /// Interaction logic for MotorsView.xaml + /// + public partial class MotorsView : UserControl + { + public MotorsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml new file mode 100644 index 000000000..3c064346d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml @@ -0,0 +1,12 @@ + + + OVERVIEW + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml.cs new file mode 100644 index 000000000..aeba42c00 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/OverviewView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Technician.Views +{ + /// + /// Interaction logic for OverviewView.xaml + /// + public partial class OverviewView : UserControl + { + public OverviewView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml new file mode 100644 index 000000000..2e074ec3c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml.cs new file mode 100644 index 000000000..4727a3603 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/SensorsView.xaml.cs @@ -0,0 +1,53 @@ +using Microsoft.Practices.ServiceLocation; +using RealTimeGraphEx.Synchronization; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Technician.Views +{ + /// + /// Interaction logic for DebugView.xaml + /// + public partial class SensorsView : UserControl + { + private SyncManager _syncManager; + + public SensorsView() + { + InitializeComponent(); + + _syncManager = new SyncManager(); + _syncManager.AddGraph(graphTemperature); + _syncManager.AddGraph(graphPressure); + _syncManager.RefreshRate = 30; + _syncManager.Start(); + } + + private void OnGraphFullScreen(object sender, RoutedEventArgs e) + { + + } + + private void Graph_MouseEnter(object sender, MouseEventArgs e) + { + + } + + private void Graph_MouseLeave(object sender, MouseEventArgs e) + { + + } + } +} -- cgit v1.3.1