aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs48
1 files changed, 48 insertions, 0 deletions
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.
/// </summary>
public ObservableCollection<CaptureDevice> CaptureDevices { get; set; }
+
+ private IMachineOperator _machineOperator;
+ /// <summary>
+ /// Gets or sets the machine operator.
+ /// </summary>
+ 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<CaptureDevice>(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<double>);
+ (controller as GraphController).PushData(arr);
+ }
+ else
+ {
+ //Multi Graph...
+ }
+ }
+ }
}
#endregion