diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-16 12:17:10 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-16 12:17:10 +0200 |
| commit | 0fda2ba3ff49bdc1ffc6833f658e2164af187008 (patch) | |
| tree | 6f3a24d0671ebda50debb8511ab40e0bda0a0df0 /Software/Visual_Studio/Tango.Integration/Operators | |
| parent | 28103646681686bf1b58275d5dbccb92d2b26f9f (diff) | |
| download | Tango-0fda2ba3ff49bdc1ffc6833f658e2164af187008.tar.gz Tango-0fda2ba3ff49bdc1ffc6833f658e2164af187008.zip | |
Embedded RealTimeGraphEx library to solution.
Added graphs to technician view.
Implemented simple sensors data test using Machine Emulator.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operators')
| -rw-r--r-- | Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs | 23 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs | 85 |
2 files changed, 108 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs new file mode 100644 index 000000000..435b44b23 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR.Diagnostics; +using Tango.Transport; + +namespace Tango.Integration.Operators +{ + public interface IMachineOperator : ITransporter + { + /// <summary> + /// Occurs when there is new sensors data available. + /// </summary> + event EventHandler<PushSensorsResponse> SensorsDataAvailable; + + /// <summary> + /// Gets or sets a value indicating whether to enable diagnostics messages by requesting diagnostics messages. + /// </summary> + bool EnableSensorsUpdate { get; set; } + } +} 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 + { + /// <summary> + /// Occurs when there is new sensors data available. + /// </summary> + public event EventHandler<PushSensorsResponse> SensorsDataAvailable; + + private bool _enableDiagnostics; + /// <summary> + /// Gets or sets a value indicating whether to enable diagnostics messages by requesting diagnostics messages. + /// </summary> + public bool EnableSensorsUpdate + { + get { return _enableDiagnostics; } + set + { + if (_enableDiagnostics != value) + { + _enableDiagnostics = value; + RaisePropertyChangedAuto(); + OnEnableSensorsUpdateChanged(value); + } + } + } + + /// <summary> + /// Called when the enable sensors update property has been changed + /// </summary> + /// <param name="value">if set to <c>true</c> [value].</param> + protected virtual void OnEnableSensorsUpdateChanged(bool value) + { + if (value && State == TransportComponentState.Connected) + { + SendContinuousRequest<PushSensorsRequest, PushSensorsResponse>(new TangoMessage<PushSensorsRequest>(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 ?? + }); + } + } + + /// <summary> + /// Invokes the <see cref="SensorsDataAvailable"/> event. + /// </summary> + /// <param name="data">The sensors data.</param> + protected virtual void OnSensorsDataAvailable(PushSensorsResponse data) + { + SensorsDataAvailable?.Invoke(this, data); + } + + /// <summary> + /// Called when the component state has changed. + /// </summary> + /// <param name="state">The state.</param> + protected override void OnStateChanged(TransportComponentState state) + { + base.OnStateChanged(state); + + OnEnableSensorsUpdateChanged(EnableSensorsUpdate); + } + } +} |
