diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-05-17 15:25:51 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-05-17 15:25:51 +0300 |
| commit | b9c99b358ba0124e32a12f401b7054ce1f85f18c (patch) | |
| tree | 80638cf96c8973061a3b2e6f415c2934ebd89861 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs | |
| parent | 1a3a15ed7845e68ba473c69a4842d8617bc41c11 (diff) | |
| parent | 8d223ccd400fb855eb73f046b25338a04e5f9d34 (diff) | |
| download | Tango-b9c99b358ba0124e32a12f401b7054ce1f85f18c.tar.gz Tango-b9c99b358ba0124e32a12f401b7054ce1f85f18c.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
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.cs | 62 |
1 files changed, 53 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 9c587b7c8..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)) { @@ -521,6 +526,10 @@ namespace Tango.MachineStudio.Technician.ViewModels { CreateElement<DancerElementEditor, DancerItem, HardwareDancerType>(bounds, Adapter.HardwareDancerTypes.FirstOrDefault()); } + else if (item is SpeedSensorItem) + { + CreateElement<SpeedSensorElementEditor, SpeedSensorItem, HardwareSpeedSensorType>(bounds, Adapter.HardwareSpeedSensorTypes.FirstOrDefault()); + } } /// <summary> @@ -635,6 +644,11 @@ namespace Tango.MachineStudio.Technician.ViewModels (item as DancerItem).HardwareDancerType = Adapter.HardwareDancerTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); CreateElement<DancerElementEditor>(item); } + else if (item is SpeedSensorItem) + { + (item as SpeedSensorItem).HardwareSpeedSensorType = Adapter.HardwareSpeedSensorTypes.FirstOrDefault(x => x.Guid == item.ItemGuid); + CreateElement<SpeedSensorElementEditor>(item); + } } /// <summary> @@ -671,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; @@ -682,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; @@ -914,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(); @@ -930,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(); @@ -1271,7 +1285,7 @@ namespace Tango.MachineStudio.Technician.ViewModels { InvokeUINow(() => { - SettingsManager.Default.MachineStudio.TechnicianModule.LasTechProjectFile = _lastTechProjectFile; + _settings.LastTechProjectFile = _lastTechProjectFile; }); } @@ -1327,6 +1341,16 @@ namespace Tango.MachineStudio.Technician.ViewModels } } + foreach (var speedSensorConfig in config.SpeedSensors) + { + var itemConfig = SpeedSensorItem.SpeedSensorConfigurations.SingleOrDefault(x => x.HardwareSpeedSensorType.Code == speedSensorConfig.HardwareSpeedSensorType.ToInt32()); + + if (itemConfig != null) + { + speedSensorConfig.MapPrimitivesTo(itemConfig); + } + } + _notification.ShowInfo("Visual elements synced to the last uploaded hardware configuration."); } else @@ -1371,13 +1395,23 @@ namespace Tango.MachineStudio.Technician.ViewModels } } - foreach (var DancerConfig in hw.HardwareDancers) + foreach (var dancerConfig in hw.HardwareDancers) + { + var itemConfig = DancerItem.DancerConfigurations.SingleOrDefault(x => x.HardwareDancerType.Code == dancerConfig.HardwareDancerType.Code); + + if (itemConfig != null) + { + itemConfig.MapPrimitivesTo(dancerConfig); + } + } + + foreach (var speedSensorConfig in hw.HardwareSpeedSensors) { - var itemConfig = DancerItem.DancerConfigurations.SingleOrDefault(x => x.HardwareDancerType.Code == DancerConfig.HardwareDancerType.Code); + var itemConfig = SpeedSensorItem.SpeedSensorConfigurations.SingleOrDefault(x => x.HardwareSpeedSensorType.Code == speedSensorConfig.HardwareSpeedSensorType.Code); if (itemConfig != null) { - itemConfig.MapPrimitivesTo(DancerConfig); + itemConfig.MapPrimitivesTo(speedSensorConfig); } } @@ -1442,6 +1476,16 @@ namespace Tango.MachineStudio.Technician.ViewModels } } + foreach (var speedSensorConfig in hw.HardwareSpeedSensors) + { + var itemConfig = SpeedSensorItem.SpeedSensorConfigurations.SingleOrDefault(x => x.HardwareSpeedSensorType.Code == speedSensorConfig.HardwareSpeedSensorType.Code); + + if (itemConfig != null) + { + speedSensorConfig.MapPrimitivesTo(itemConfig); + } + } + _notification.ShowInfo("Visual elements synced to hardware version " + hw.Name + ", " + hw.Version + "."); } } |
