From 3d8c362cd5409246c7026ea956ce10d51ed9ebc3 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 21 Aug 2025 16:49:02 +0300 Subject: Telemetry Wires. Implemented Firmware User Notifications. Added Missing UI Settings Units Display. Add Machine Name to General Information Dialog. --- .../Operation/IMachineOperator.cs | 10 +++++ .../Tango.Integration/Operation/MachineOperator.cs | 52 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'Software/Visual_Studio/Tango.Integration') diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index 0f9f3b008..0a46e0eb4 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -272,6 +272,11 @@ namespace Tango.Integration.Operation /// event EventHandler TelemetryWireAvailable; + /// + /// Occurs when a new user notification is available. + /// + event EventHandler NotificationAvailable; + /// /// Occurs when waste replacement is required. /// @@ -322,6 +327,11 @@ namespace Tango.Integration.Operation /// bool EnableTelemetryWire { get; set; } + /// + /// Gets or set a value indicating whether to enable user notifications from the firmware. + /// + bool EnableNotifications { get; set; } + /// /// Gets the last process parameters table sent to the embedded device. /// 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 TelemetryWireAvailable; + public event EventHandler 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); + } + } + } /// /// 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 /// 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(request, new TransportContinuousRequestConfig() { ShouldLog = false }).ObserveOn(new NewThreadScheduler()).Subscribe( + (response) => + { + OnNotificationAvailable(response); + }, + (ex) => + { + _notificationsSent = false; + }, + () => + { + _notificationsSent = false; + LogManager.Log("Notifications response completed!?", LogCategory.Warning); + }); + } + } + /// /// Called when the enable events property has been changed. /// @@ -1079,6 +1123,11 @@ namespace Tango.Integration.Operation TelemetryWireAvailable?.Invoke(this, response); } + private void OnNotificationAvailable(StartNotificationResponse response) + { + NotificationAvailable?.Invoke(this, response); + } + /// /// Called when events notification message has been received. /// @@ -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) { -- cgit v1.3.1