From 40990f3c352117fc536fdf004956d120bc63ee09 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 1 Feb 2018 18:22:44 +0200 Subject: Added sensors data support for developer module. --- .../ViewModels/MainViewVM.cs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 52d67a141..4f045627d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -19,6 +19,9 @@ using System.Windows.Threading; using Tango.Settings; using Tango.MachineStudio.Developer.Views; using Tango.Video.DirectCapture; +using Tango.Integration.Operators; +using Tango.PMR.Diagnostics; +using System.Reflection; namespace Tango.MachineStudio.Developer.ViewModels { @@ -292,6 +295,17 @@ namespace Tango.MachineStudio.Developer.ViewModels /// Gets or sets the capture devices. /// public ObservableCollection CaptureDevices { get; set; } + + private IMachineOperator _machineOperator; + /// + /// Gets or sets the machine operator. + /// + public IMachineOperator MachineOperator + { + get { return _machineOperator; } + set { _machineOperator = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -441,6 +455,40 @@ namespace Tango.MachineStudio.Developer.ViewModels } ToggleCameraCommand = new RelayCommand(ToggleCamera); + + ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; + } + + private void ApplicationManager_ConnectedMachineChanged(object sender, Integration.Services.IExternalBridgeClient machine) + { + MachineOperator = machine; + + if (MachineOperator != null) + { + MachineOperator.EnableSensorsUpdate = true; + MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; + } + } + + private void MachineOperator_DiagnosticsDataAvailable(object sender, StartDiagnosticsResponse response) + { + foreach (var prop in response.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + GraphControllerBase controller = null; + + if (_controllers.TryGetValue(prop.Name, out controller)) + { + if (controller is GraphController) + { + double[] arr = Enumerable.ToArray(prop.GetValue(response) as IEnumerable); + (controller as GraphController).PushData(arr); + } + else + { + //Multi Graph... + } + } + } } #endregion -- cgit v1.3.1