From dd13554edc2816b026b00fbad26d17f82d8d16c3 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 17 Jun 2025 07:26:14 +0300 Subject: Merge --- .../EventLogging/DefaultEventLogger.cs | 13 +++++++- .../Notifications/NotificationItem.cs | 5 +++ .../Notifications/DefaultNotificationProvider.cs | 1 + .../PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs | 3 +- .../PPC/Tango.PPC.UI/Views/MachineStatusView.xaml | 3 +- .../Tango.Emulations/Emulators/MachineEmulator.cs | 21 +++++++++++++ .../Tango.PMR/Common/MessageContainer.cs | 36 +++++++++++++++++++--- .../Tango.Transport/TransportResponseConfig.cs | 2 ++ .../Tango.Transport/TransporterBase.cs | 4 +++ .../Utilities/Tango.MachineEM.UI/MainWindow.xaml | 2 +- .../Tango.MachineEM.UI/Tango.MachineEM.UI.csproj | 5 +-- .../Tango.MachineEM.UI/ViewModels/MainViewVM.cs | 7 +++++ .../Tango.MachineEM.UI/Views/MainView.xaml | 9 +++++- 13 files changed, 100 insertions(+), 11 deletions(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs index ee96a77a5..4e00474f4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs @@ -155,7 +155,18 @@ namespace Tango.PPC.Common.EventLogging /// The instance containing the event data. private void MachineOperator_PrintingFailed(object sender, PrintingFailedEventArgs e) { - Log(EventTypes.JOB_FAILED, e.Exception.Message); + String eventInfo = String.Empty; + + if (e.Exception is Transport.ResponseErrorException responseError) + { + if (responseError.Container.EventCode > 0) + { + EventTypes evType = (EventTypes)responseError.Container.EventCode; + eventInfo = "\n#" + responseError.Container.EventCode + " " + evType.ToDescription(); + } + } + + Log(EventTypes.JOB_FAILED, e.Exception.Message + eventInfo); } /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs index 6a29511a9..963496508 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs @@ -32,6 +32,11 @@ namespace Tango.PPC.Common.Notifications Priority = NotificationPriority.Normal; } + /// + /// Gets or sets the notification date and time. + /// + public DateTime Time { get; set; } + private bool _canClose; /// /// Gets or sets a value indicating whether this instance can close. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index cc8f7b4ab..7b26d8425 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -299,6 +299,7 @@ namespace Tango.PPC.UI.Notifications /// public NotificationItem PushNotification(NotificationItem item) { + item.Time = DateTime.Now; LogManager.Log($"Pushing NotificationItem '{item.GetType().Name}'."); item.RemoveAction = () => { PopNotification(item); }; NotificationItems.Insert(0, item); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs index 07b58e55f..64c56e5e9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs @@ -14,6 +14,7 @@ using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.Logging; using Tango.PPC.UI.Views; +using System.Diagnostics; namespace Tango.PPC.UI.ViewModels { @@ -97,7 +98,7 @@ namespace Tango.PPC.UI.ViewModels { LogManager.Log("Application is ready! Navigating to home module..."); - if (BuildProvider.IsEureka) + if (BuildProvider.IsEureka && !Debugger.IsAttached) { var secondsPassed = (DateTime.Now - LoadingView.VideoStartTime).TotalSeconds; var secondsToHold = Math.Max(10 - secondsPassed, 0); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml index 2f1a54e64..0acd1d7e5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml @@ -1509,9 +1509,10 @@ - + + diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index c0eea704d..1bf2d3cb7 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -90,6 +90,7 @@ namespace Tango.Emulations.Emulators private String _machineStatusRequestToken; private MachineType _machineType; private ProcessParameters _processParameters; + private bool _failJob; #region Properties @@ -838,6 +839,8 @@ namespace Tango.Emulations.Emulators private void HandleJobRequest(TangoMessage request) { + _failJob = false; + MachineStatus.State = MachineState.PreparingJob; JobTicket job = request.Message.JobTicket; @@ -992,6 +995,19 @@ namespace Tango.Emulations.Emulators int delay = (100 - (int)watch.ElapsedMilliseconds) > 0 ? (100 - (int)watch.ElapsedMilliseconds) : 5; Thread.Sleep(delay); + if (_failJob) + { + Transporter.SendResponse(new JobResponse() + { + + }, request.Container.Token, new TransportResponseConfig() { + ErrorCode = ErrorCode.JobThreadBreak, + ErrorMessage = "This is a message about a thread break from the emulator", + EventType = PMR.Diagnostics.EventType.ThreadBreak, + }); + break; + } + if (_cancelJob) { break; @@ -2469,6 +2485,11 @@ namespace Tango.Emulations.Emulators } } + public void FailJobWithEvent() + { + _failJob = true; + } + #endregion } } diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageContainer.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageContainer.cs index 701423add..96594ada4 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageContainer.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageContainer.cs @@ -23,18 +23,18 @@ namespace Tango.PMR.Common { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChZNZXNzYWdlQ29udGFpbmVyLnByb3RvEhBUYW5nby5QTVIuQ29tbW9uGhFN", - "ZXNzYWdlVHlwZS5wcm90bxoPRXJyb3JDb2RlLnByb3RvIv4BChBNZXNzYWdl", + "ZXNzYWdlVHlwZS5wcm90bxoPRXJyb3JDb2RlLnByb3RvIpECChBNZXNzYWdl", "Q29udGFpbmVyEisKBFR5cGUYASABKA4yHS5UYW5nby5QTVIuQ29tbW9uLk1l", "c3NhZ2VUeXBlEg0KBVRva2VuGAIgASgJEg8KB1RpbWVvdXQYAyABKA0SEgoK", "Q29udGludW91cxgEIAEoCBIZChFDb250aW51b3VzVGltZW91dBgFIAEoDRIR", "CglDb21wbGV0ZWQYBiABKAgSDAoERGF0YRgHIAEoDBILCgNDUkMYCCABKA0S", "KgoFRXJyb3IYCSABKA4yGy5UYW5nby5QTVIuQ29tbW9uLkVycm9yQ29kZRIU", - "CgxFcnJvck1lc3NhZ2UYCiABKAlCHAoaY29tLnR3aW5lLnRhbmdvLnBtci5j", - "b21tb25iBnByb3RvMw==")); + "CgxFcnJvck1lc3NhZ2UYCiABKAkSEQoJRXZlbnRDb2RlGAsgASgFQhwKGmNv", + "bS50d2luZS50YW5nby5wbXIuY29tbW9uYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Common.MessageTypeReflection.Descriptor, global::Tango.PMR.Common.ErrorCodeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Common.MessageContainer), global::Tango.PMR.Common.MessageContainer.Parser, new[]{ "Type", "Token", "Timeout", "Continuous", "ContinuousTimeout", "Completed", "Data", "CRC", "Error", "ErrorMessage" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Common.MessageContainer), global::Tango.PMR.Common.MessageContainer.Parser, new[]{ "Type", "Token", "Timeout", "Continuous", "ContinuousTimeout", "Completed", "Data", "CRC", "Error", "ErrorMessage", "EventCode" }, null, null, null) })); } #endregion @@ -75,6 +75,7 @@ namespace Tango.PMR.Common { cRC_ = other.cRC_; error_ = other.error_; errorMessage_ = other.errorMessage_; + eventCode_ = other.eventCode_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -192,6 +193,17 @@ namespace Tango.PMR.Common { } } + /// Field number for the "EventCode" field. + public const int EventCodeFieldNumber = 11; + private int eventCode_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int EventCode { + get { return eventCode_; } + set { + eventCode_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as MessageContainer); @@ -215,6 +227,7 @@ namespace Tango.PMR.Common { if (CRC != other.CRC) return false; if (Error != other.Error) return false; if (ErrorMessage != other.ErrorMessage) return false; + if (EventCode != other.EventCode) return false; return true; } @@ -231,6 +244,7 @@ namespace Tango.PMR.Common { if (CRC != 0) hash ^= CRC.GetHashCode(); if (Error != 0) hash ^= Error.GetHashCode(); if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); + if (EventCode != 0) hash ^= EventCode.GetHashCode(); return hash; } @@ -281,6 +295,10 @@ namespace Tango.PMR.Common { output.WriteRawTag(82); output.WriteString(ErrorMessage); } + if (EventCode != 0) { + output.WriteRawTag(88); + output.WriteInt32(EventCode); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -316,6 +334,9 @@ namespace Tango.PMR.Common { if (ErrorMessage.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(ErrorMessage); } + if (EventCode != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(EventCode); + } return size; } @@ -354,6 +375,9 @@ namespace Tango.PMR.Common { if (other.ErrorMessage.Length != 0) { ErrorMessage = other.ErrorMessage; } + if (other.EventCode != 0) { + EventCode = other.EventCode; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -404,6 +428,10 @@ namespace Tango.PMR.Common { ErrorMessage = input.ReadString(); break; } + case 88: { + EventCode = input.ReadInt32(); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.Transport/TransportResponseConfig.cs b/Software/Visual_Studio/Tango.Transport/TransportResponseConfig.cs index 79940757d..2aa40d6ef 100644 --- a/Software/Visual_Studio/Tango.Transport/TransportResponseConfig.cs +++ b/Software/Visual_Studio/Tango.Transport/TransportResponseConfig.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core; using Tango.PMR.Common; +using Tango.PMR.Diagnostics; namespace Tango.Transport { @@ -12,6 +13,7 @@ namespace Tango.Transport { public bool Completed { get; set; } public ErrorCode? ErrorCode { get; set; } + public EventType EventType { get; set; } public String ErrorMessage { get; set; } public bool ShouldLog { get; set; } public bool Immediate { get; set; } diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index 5a56754b9..017f75158 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -977,6 +977,8 @@ namespace Tango.Transport container.ErrorMessage = config.ErrorMessage; } + container.EventCode = (int)config.EventType; + container.Completed = config.Completed; return SendResponse(container); @@ -1075,6 +1077,8 @@ namespace Tango.Transport response.Container.ErrorMessage = config.ErrorMessage; } + response.Container.EventCode = (int)config.EventType; + LogManager.Log($"{GetExtendedComponentName()}: Queuing response message: " + typeof(Response).Name, LogCategory.Debug); if (State != TransportComponentState.Connected) diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml index 875072faa..41ecbb552 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/MainWindow.xaml @@ -9,7 +9,7 @@ xmlns:local="clr-namespace:Tango.MachineEM.UI" xmlns:views="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" - Title="Firmware Emulator" Height="820" Width="1300" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> + Title="Firmware Emulator" Height="950" Width="1400" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj index c6f382afe..07e03cfd4 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj @@ -204,11 +204,12 @@ - $(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(SolutionDir)Build\Shortcuts\Machine Emulator.lnk" + + - + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs index 6b97bae31..7d74b5d04 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs @@ -148,6 +148,7 @@ namespace Tango.MachineEM.UI.ViewModels public RelayCommand RequestWasteReplaceCommand { get; set; } + public RelayCommand FailJobCommand { get; set; } #endregion #region Constructors @@ -182,6 +183,7 @@ namespace Tango.MachineEM.UI.ViewModels FinalizeThreadLoadingCommand = new RelayCommand(FinalizeThreadLoading, (x) => Emulator.IsStarted && _isThreadLoading); AbortJobCommand = new RelayCommand(() => Emulator?.AbortJob(), (x) => Emulator.IsStarted); RequestWasteReplaceCommand = new RelayCommand(RequestWasteReplace, (x) => Emulator.IsStarted); + FailJobCommand = new RelayCommand(FailJob, () => Emulator.IsStarted); Ports = new List() { @@ -376,6 +378,11 @@ namespace Tango.MachineEM.UI.ViewModels catch { } } + private void FailJob() + { + Emulator.FailJobWithEvent(); + } + #endregion #region Private Methods diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml index 98e70d6a5..cc49b0ccd 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml @@ -14,7 +14,7 @@ xmlns:localConverters="clr-namespace:Tango.MachineEM.UI.Converters" xmlns:local="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" - d:DesignHeight="780" d:DesignWidth="1300" Foreground="Gainsboro" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" > + d:DesignHeight="900" d:DesignWidth="1400" Foreground="Gainsboro" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" > @@ -182,6 +182,13 @@ PUT DATA STORE ITEM + + -- cgit v1.3.1