diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels')
3 files changed, 11 insertions, 255 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 ac78ef488..d8369ea7b 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 @@ -31,6 +31,7 @@ using Tango.BL; using Tango.MachineStudio.Common.EventLogging; using Tango.MachineStudio.Common; using Tango.Core.Commands; +using Tango.MachineStudio.Technician.Helpers; namespace Tango.MachineStudio.Technician.ViewModels { @@ -50,6 +51,8 @@ namespace Tango.MachineStudio.Technician.ViewModels private IEventLogger _eventLogger; private DateTime _lastDiagnosticsResponseUpdate; private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500; + private TechnicianModuleSettings _settings; + #region Properties @@ -191,6 +194,8 @@ namespace Tango.MachineStudio.Technician.ViewModels /// <param name="notificationProvider">The notification provider.</param> public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider _diagnosticsFrameProvider, IEventLogger eventLogger) { + _settings = SettingsManager.Default.GetOrCreate<TechnicianModuleSettings>(); + _notification = notificationProvider; _eventLogger = eventLogger; _singleControllers = new Dictionary<SingleGraphItem, GraphController>(); @@ -208,7 +213,7 @@ namespace Tango.MachineStudio.Technician.ViewModels SaveAsProjectCommand = new RelayCommand(SaveAsProject); SaveProjectCommand = new RelayCommand(SaveProject); - _lastTechProjectFile = SettingsManager.Default.MachineStudio.TechnicianModule.LasTechProjectFile; + _lastTechProjectFile = _settings.LastTechProjectFile; if (File.Exists(_lastTechProjectFile)) { @@ -680,7 +685,7 @@ namespace Tango.MachineStudio.Technician.ViewModels var graphItem = element.HostedElement as SingleGraphItem; var editor = element as SingleGraphElementEditor; graphItem.Editor = editor; - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); GraphController controller = new GraphController(); editor.InnerGraph.Controller = controller; @@ -691,7 +696,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { var graphItem = element.HostedElement as MultiGraphItem; var editor = element as MultiGraphElementEditor; - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); + editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(graphItem.TechMonitor.PointsPerFrame); graphItem.Editor = editor; @@ -923,7 +928,7 @@ namespace Tango.MachineStudio.Technician.ViewModels /// <param name="editor">The editor.</param> private void InitSingleGraphitem(SingleGraphItem item, SingleGraphElementEditor editor) { - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(item.TechMonitor.PointsPerFrame); + editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(item.TechMonitor.PointsPerFrame); item.Editor = editor; GraphController controller = new GraphController(); @@ -939,7 +944,7 @@ namespace Tango.MachineStudio.Technician.ViewModels /// <param name="editor">The editor.</param> private void InitMultiGraphItem(MultiGraphItem item, MultiGraphElementEditor editor) { - editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(item.TechMonitor.PointsPerFrame); + editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(item.TechMonitor.PointsPerFrame); item.Editor = editor; GraphMultiController controller = new GraphMultiController(); @@ -1280,7 +1285,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { InvokeUINow(() => { - SettingsManager.Default.MachineStudio.TechnicianModule.LasTechProjectFile = _lastTechProjectFile; + _settings.LastTechProjectFile = _lastTechProjectFile; }); } 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 deleted file mode 100644 index 306f15c5c..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MainViewVM.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -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 -{ - /// <summary> - /// Represents the technician module main view, view model. - /// </summary> - /// <seealso cref="Tango.SharedUI.ViewModel" /> - public class MainViewVM : ViewModel - { - private TechNavigationManager _navigation; - - #region Constructors - - /// <summary> - /// Initializes a new instance of the <see cref="MainViewVM"/> class. - /// </summary> - /// <param name="navigationManager">The navigation manager.</param> - public MainViewVM(TechNavigationManager navigationManager) - { - _navigation = navigationManager; - NavigateToViewCommand = new RelayCommand<string>(NavigateToView); - } - - #endregion - - #region Commands - - /// <summary> - /// Gets or sets the navigate to view command. - /// </summary> - public RelayCommand<String> NavigateToViewCommand { get; set; } - - #endregion - - #region Private Methods - - /// <summary> - /// Navigates to the specified view. - /// </summary> - /// <param name="view">The view.</param> - 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 deleted file mode 100644 index 403a6d510..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/SensorsViewVM.cs +++ /dev/null @@ -1,193 +0,0 @@ -using RealTimeGraphEx.Controllers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Integration.Operation; -using Tango.Integration.Services; -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 -{ - /// <summary> - /// Represents the technician module sensors view, view model. - /// </summary> - /// <seealso cref="Tango.SharedUI.ViewModel" /> - public class SensorsViewVM : ViewModel - { - private List<GraphControllerBase> _controllers; - - #region Properties - - /// <summary> - /// Gets or sets the application manager. - /// </summary> - public IStudioApplicationManager ApplicationManager { get; set; } - - private IMachineOperator _machineOperator; - /// <summary> - /// Gets or sets the machine operator. - /// </summary> - public IMachineOperator MachineOperator - { - get { return _machineOperator; } - set { _machineOperator = value; RaisePropertyChangedAuto(); } - } - - 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()); - } - - #endregion - - #region Constructors - - /// <summary> - /// Initializes a new instance of the <see cref="SensorsViewVM"/> class. - /// </summary> - /// <param name="applicationManager">The application manager.</param> - /// <param name="moduleLoader">The module loader.</param> - 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(); - VelocityController = new GraphController(); - - _controllers.Add(TemperatureController); - _controllers.Add(PressureController); - _controllers.Add(VelocityController); - - var module = moduleLoader.GetStudioModule<TechnicianModule>(); - - if (module != null) - { - module.IsLoadedChanged += Module_IsLoadedChanged; - } - } - } - - #endregion - - #region Event Handlers - - /// <summary> - /// Handles the technician module IsLoaded changed event. - /// </summary> - /// <param name="sender">The sender.</param> - /// <param name="loaded">if set to <c>true</c> [loaded].</param> - private void Module_IsLoadedChanged(object sender, bool loaded) - { - _controllers.ForEach(x => x.ChangeRenderMode(loaded)); - } - - /// <summary> - /// Handles the application manager connected machine changed event. - /// </summary> - /// <param name="sender">The sender.</param> - /// <param name="machineOperator">The machine operator.</param> - private void ApplicationManager_ConnectedMachineChanged(object sender, IExternalBridgeClient machineOperator) - { - InitializeConnectedMachine(machineOperator); - } - - /// <summary> - /// Handles the machine operator diagnostics data available event - /// </summary> - /// <param name="sender">The sender.</param> - /// <param name="data">The data.</param> - private void MachineOperator_DiagnosticsDataAvailable(object sender, StartDiagnosticsResponse data) - { - //TemperatureController.PushData(data.Temperature.ToArray()); - //PressureController.PushData(data.Temperature.ToArray()); - //VelocityController.PushData(data.Velocity.ToArray()); - } - - #endregion - - #region Private Methods - - /// <summary> - /// Initializes the connected machine. - /// </summary> - /// <param name="machineOperator">The machine operator.</param> - private void InitializeConnectedMachine(IMachineOperator machineOperator) - { - //MachineOperator = machineOperator; - - //if (MachineOperator != null) - //{ - // MachineOperator.EnableSensorsUpdate = true; - // MachineOperator.DiagnosticsDataAvailable -= MachineOperator_DiagnosticsDataAvailable; - // MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; - //} - } - - #endregion - - #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)); } - } - - private GraphController _velocityController; - /// <summary> - /// Gets or sets the velocity sensor graph controller . - /// </summary> - public GraphController VelocityController - { - get { return _velocityController; } - set { _velocityController = value; RaisePropertyChanged(nameof(VelocityController)); } - } - - #endregion - } -} |
