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. --- .../Tango.Integration/Operators/MachineOperator.cs | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs (limited to 'Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs') diff --git a/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs new file mode 100644 index 000000000..aa039e7ae --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR; +using Tango.PMR.Diagnostics; +using Tango.Transport; +using Tango.Transport.Transporters; +using System.Reactive.Linq; +using System.Reactive.Concurrency; +using System.Reactive.Threading; + +namespace Tango.Integration.Operators +{ + public class MachineOperator : BasicTransporter, IMachineOperator + { + /// + /// Occurs when there is new sensors data available. + /// + public event EventHandler SensorsDataAvailable; + + private bool _enableDiagnostics; + /// + /// Gets or sets a value indicating whether to enable diagnostics messages by requesting diagnostics messages. + /// + public bool EnableSensorsUpdate + { + get { return _enableDiagnostics; } + set + { + if (_enableDiagnostics != value) + { + _enableDiagnostics = value; + RaisePropertyChangedAuto(); + OnEnableSensorsUpdateChanged(value); + } + } + } + + /// + /// Called when the enable sensors update property has been changed + /// + /// if set to true [value]. + protected virtual void OnEnableSensorsUpdateChanged(bool value) + { + if (value && State == TransportComponentState.Connected) + { + SendContinuousRequest(new TangoMessage(new PushSensorsRequest(), PMR.Common.MessageType.PushSensorsRequest)).ObserveOn(new NewThreadScheduler()).Subscribe( + (response) => + { + OnSensorsDataAvailable(response); + }, + (ex) => + { + //Do I need separate event for each one ?? + }, + () => + { + //What to do now ?? + }); + } + } + + /// + /// Invokes the event. + /// + /// The sensors data. + protected virtual void OnSensorsDataAvailable(PushSensorsResponse data) + { + SensorsDataAvailable?.Invoke(this, data); + } + + /// + /// Called when the component state has changed. + /// + /// The state. + protected override void OnStateChanged(TransportComponentState state) + { + base.OnStateChanged(state); + + OnEnableSensorsUpdateChanged(EnableSensorsUpdate); + } + } +} -- cgit v1.3.1