diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index eb994afc6..1da752d23 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -76,6 +76,7 @@ namespace Tango.Integration.Operation private bool _machineStatusSent; private bool _inkFillingStatusSent; private bool _telemetryWireSent; + private bool _notificationsSent; private bool _threadLoadingSent; private bool _isPowerDownRequestInProgress; private bool _isHeadCleaningInProgress; @@ -357,6 +358,7 @@ namespace Tango.Integration.Operation public event EventHandler WasteReplacementRequired; public event EventHandler<StartTelemetryWireResponse> TelemetryWireAvailable; + public event EventHandler<StartNotificationResponse> NotificationAvailable; #endregion @@ -673,6 +675,20 @@ namespace Tango.Integration.Operation } } + private bool _enableNotifications; + public bool EnableNotifications + { + get { return _enableNotifications; } + set + { + if (_enableNotifications != value) + { + _enableNotifications = value; + RaisePropertyChangedAuto(); + OnEnableNotificationsChanged(value); + } + } + } /// <summary> /// Gets or sets the machine events state provider used to get notifications about current machine events and errors. @@ -734,6 +750,7 @@ namespace Tango.Integration.Operation /// </summary> public MachineTypes MachineType { get; set; } + #endregion #region Virtual Methods @@ -824,6 +841,33 @@ namespace Tango.Integration.Operation } } + private void OnEnableNotificationsChanged(bool value) + { + if (value && State == TransportComponentState.Connected && !_notificationsSent) + { + var request = new StartNotificationRequest(); + + _notificationsSent = true; + + LogManager.Log($"Sending '{nameof(StartNotificationRequest)}'..."); + + SendContinuousRequest<StartNotificationRequest, StartNotificationResponse>(request, new TransportContinuousRequestConfig() { ShouldLog = false }).ObserveOn(new NewThreadScheduler()).Subscribe( + (response) => + { + OnNotificationAvailable(response); + }, + (ex) => + { + _notificationsSent = false; + }, + () => + { + _notificationsSent = false; + LogManager.Log("Notifications response completed!?", LogCategory.Warning); + }); + } + } + /// <summary> /// Called when the enable events property has been changed. /// </summary> @@ -1079,6 +1123,11 @@ namespace Tango.Integration.Operation TelemetryWireAvailable?.Invoke(this, response); } + private void OnNotificationAvailable(StartNotificationResponse response) + { + NotificationAvailable?.Invoke(this, response); + } + /// <summary> /// Called when events notification message has been received. /// </summary> @@ -1543,6 +1592,7 @@ namespace Tango.Integration.Operation _eventsSent = false; _machineStatusSent = false; _telemetryWireSent = false; + _notificationsSent = false; //MachineStatus = null; @@ -1646,6 +1696,7 @@ namespace Tango.Integration.Operation _debugSent = false; _machineStatusSent = false; _telemetryWireSent = false; + _notificationsSent = false; _bitResults = null; @@ -1656,6 +1707,7 @@ namespace Tango.Integration.Operation OnEnableAutomaticThreadLoadingChanged(EnableAutomaticThreadLoading); OnEnableInkFillingStatus(EnableInkFillingStatus); OnEnableTelemetryWireChanged(EnableTelemetryWire); + OnEnableNotificationsChanged(EnableNotifications); if (EnablePowerUpSequence) { |
