From 9c59f5be697bd0a1a7992239a3701dd7670747ec Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 13 Oct 2020 08:20:23 +0300 Subject: Implemented ink waste cartridge filling emptying progress. --- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 130 +++++++++++++++++++++ 1 file changed, 130 insertions(+) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 2bb4e9286..65df72878 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -3,11 +3,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; using System.Windows.Threading; +using Tango.Core; using Tango.Core.Commands; using Tango.Core.DI; using Tango.Integration.Operation; +using Tango.PMR.IFS; using Tango.PPC.Common; +using Tango.PPC.Common.Connection; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.UI.Views; @@ -31,6 +36,86 @@ namespace Tango.PPC.UI.ViewModels [TangoInject] public IPPCModuleLoader ModuleLoader { get; set; } + #region Classes + + public class CartridgeModel : ExtendedObject + { + private IMachineProvider _machineProvider; + + public CartridgeStatus Status { get; set; } + + public bool InProgress + { + get { return Status.State == CartridgeState.Filling || Status.State == CartridgeState.Emptying; } + } + + public String Message + { + get { return Status.Cartridge.Slot == PMR.Diagnostics.CartridgeSlot.Ink ? "Ink filling is in progress..." : "Waste emptying is in progress..."; } + } + + public Brush Brush + { + get + { + if (Status.Cartridge.Slot == PMR.Diagnostics.CartridgeSlot.Ink) + { + try + { + int index = Status.Cartridge.Index; + + var idsPack = _machineProvider.Machine.Configuration.IdsPacks.FirstOrDefault(x => x.PackIndex == index); + + if (idsPack != null) + { + switch (idsPack.LiquidType.Type) + { + case BL.Enumerations.LiquidTypes.Cyan: + return Application.Current.Resources["TangoCyanInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Magenta: + return Application.Current.Resources["TangoMagentaInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Yellow: + return Application.Current.Resources["TangoYellowInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Black: + return Application.Current.Resources["TangoBlackInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Lubricant: + return Application.Current.Resources["TangoLubricantBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Cleaner: + return Application.Current.Resources["TangoCleanerBrush"] as Brush; + case BL.Enumerations.LiquidTypes.TransparentInk: + return Application.Current.Resources["TangoTransparentInkBrush"] as Brush; + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error generating ink filling brush."); + } + + return Application.Current.Resources["TangoPrimaryAccentBrush"] as Brush; + } + else + { + return Application.Current.Resources["TangoWasteBrush"] as Brush; + } + } + } + + public CartridgeModel(IMachineProvider machineProvider) + { + _machineProvider = machineProvider; + Status = new CartridgeStatus(); + } + + public void Invalidate() + { + RaisePropertyChanged(nameof(InProgress)); + RaisePropertyChanged(nameof(Status)); + } + } + + #endregion + #region Properties private bool _isMenuOpened; @@ -74,6 +159,23 @@ namespace Tango.PPC.UI.ViewModels set { _isPowerOpened = value; RaisePropertyChangedAuto(); } } + private bool _isInkFillingOrWasteEmptying; + /// + /// Gets or sets a value indicating whether ink filling or waste emptying is active. + /// + public bool IsInkFillingOrWasteEmptying + { + get { return _isInkFillingOrWasteEmptying; } + set { _isInkFillingOrWasteEmptying = value; RaisePropertyChangedAuto(); } + } + + private List _cartridges; + public List Cartridges + { + get { return _cartridges; } + set { _cartridges = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -312,6 +414,34 @@ namespace Tango.PPC.UI.ViewModels { base.OnApplicationStarted(); MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; + MachineProvider.MachineOperator.InkFillingStatusChanged += MachineOperator_InkFillingStatusChanged; + } + + private void MachineOperator_InkFillingStatusChanged(object sender, InkFillingStatusChangedEventArgs e) + { + if (Cartridges == null) + { + Cartridges = MachineProvider.MachineOperator.InkFillingStatus.CartridgesStatuses.Select(x => new CartridgeModel(MachineProvider) { Status = x }).ToList(); + } + else + { + foreach (var cartridgeStatus in e.Status.CartridgesStatuses) + { + var model = Cartridges.SingleOrDefault(x => x.Status == cartridgeStatus); + + if (model != null) + { + model.Status = cartridgeStatus; + } + } + } + + foreach (var cartridgeModel in Cartridges) + { + cartridgeModel.Invalidate(); + } + + IsInkFillingOrWasteEmptying = Cartridges.Any(x => x.Status.State == CartridgeState.Filling || x.Status.State == CartridgeState.Emptying); } /// -- cgit v1.3.1 From 43895ee9f170f68e7383e39ce089532a257f2d6d Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 16 Oct 2020 00:45:34 +0300 Subject: Implemented PPC standby. --- Software/PMR/Messages/Common/MessageType.proto | 2 + Software/PMR/Messages/Power/StandByRequest.proto | 9 ++ Software/PMR/Messages/Power/StandByResponse.proto | 9 ++ .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 23 ++++ .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 2 +- .../Tango.Emulations/Emulators/MachineEmulator.cs | 10 ++ .../Operation/IMachineOperator.cs | 6 + .../Tango.Integration/Operation/MachineOperator.cs | 10 ++ .../Visual_Studio/Tango.PMR/Common/MessageType.cs | 23 ++-- .../Tango.PMR/Power/StandByRequest.cs | 131 +++++++++++++++++++++ .../Tango.PMR/Power/StandByResponse.cs | 131 +++++++++++++++++++++ Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj | 4 +- 12 files changed, 348 insertions(+), 12 deletions(-) create mode 100644 Software/PMR/Messages/Power/StandByRequest.proto create mode 100644 Software/PMR/Messages/Power/StandByResponse.proto create mode 100644 Software/Visual_Studio/Tango.PMR/Power/StandByRequest.cs create mode 100644 Software/Visual_Studio/Tango.PMR/Power/StandByResponse.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs') diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index 38c0f3ec4..533b3e4a6 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -291,6 +291,8 @@ enum MessageType StartPowerUpResponse = 10005; AbortPowerUpRequest = 10006; AbortPowerUpResponse = 10007; + StandByRequest = 10008; + StandByResponse = 10009; //Thread Loading StartThreadLoadingRequest = 11000; diff --git a/Software/PMR/Messages/Power/StandByRequest.proto b/Software/PMR/Messages/Power/StandByRequest.proto new file mode 100644 index 000000000..d87c0b9ff --- /dev/null +++ b/Software/PMR/Messages/Power/StandByRequest.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Power; +option java_package = "com.twine.tango.pmr.power"; + +message StandByRequest +{ + +} \ No newline at end of file diff --git a/Software/PMR/Messages/Power/StandByResponse.proto b/Software/PMR/Messages/Power/StandByResponse.proto new file mode 100644 index 000000000..dec061f1f --- /dev/null +++ b/Software/PMR/Messages/Power/StandByResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Power; +option java_package = "com.twine.tango.pmr.power"; + +message StandByResponse +{ + +} \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 65df72878..fe28dfb20 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -235,6 +235,11 @@ namespace Tango.PPC.UI.ViewModels /// public RelayCommand ResetCommand { get; set; } + /// + /// Gets or sets the stand by command. + /// + public RelayCommand StandByCommand { get; set; } + #endregion #region Constructors @@ -262,6 +267,7 @@ namespace Tango.PPC.UI.ViewModels RestartApplicationCommand = new RelayCommand(RestartApplication); PowerOffCommand = new RelayCommand(PowerOffMachine, () => MachineProvider.MachineOperator.Status != MachineStatuses.Disconnected); ResetCommand = new RelayCommand(ResetMachine, () => MachineProvider.MachineOperator.Status != MachineStatuses.Disconnected); + StandByCommand = new RelayCommand(StandBy, () => MachineProvider.MachineOperator.CanPrint); } #endregion @@ -403,6 +409,22 @@ namespace Tango.PPC.UI.ViewModels } } + private async void StandBy() + { + IsMenuOpened = false; + + try + { + LogManager.Log("Executing stand-by command."); + await MachineProvider.MachineOperator.StandBy(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error switching to stand-by mode."); + await NotificationProvider.ShowError($"Error switching to stand-by mode.\n{ex.FlattenMessage()}"); + } + } + #endregion #region Override Methods @@ -464,6 +486,7 @@ namespace Tango.PPC.UI.ViewModels { PowerOffCommand.RaiseCanExecuteChanged(); ResetCommand.RaiseCanExecuteChanged(); + StandByCommand.RaiseCanExecuteChanged(); }); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 9e774ab60..c93a23d42 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -188,7 +188,7 @@ Turn Off - Stand By + Stand By Reset diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 856b3b2d8..8ab5bd553 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -466,6 +466,9 @@ namespace Tango.Emulations.Emulators case MessageType.StartInkFillingStatusRequest: HandleStartInkFillingStatusRequest(MessageFactory.ParseTangoMessageFromContainer(container)); break; + case MessageType.StandByRequest: + HandleStandByRequest(MessageFactory.ParseTangoMessageFromContainer(container)); + break; } } @@ -1708,6 +1711,13 @@ namespace Tango.Emulations.Emulators }); } + private async void HandleStandByRequest(TangoMessage request) + { + await Task.Delay(1500); + MachineStatus.State = MachineState.Sleep; + await Transporter.SendResponse(new StandByResponse(), request.Container.Token); + } + #endregion #region Public Methods diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index 9bd0932e9..8fd4a6438 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -475,6 +475,12 @@ namespace Tango.Integration.Operation /// Task Reset(); + /// + /// Directs the embedded device to switch to stand-by mode. + /// + /// + Task StandBy(); + /// /// Resets the device through the DFU channel. /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 0fa8cc290..b2db9dd11 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -3499,6 +3499,16 @@ namespace Tango.Integration.Operation return response; } + /// + /// Directs the embedded device to switch to stand-by mode. + /// + /// + public async Task StandBy() + { + LogManager.Log("Switching to stand-by mode..."); + await SendRequest(new StandByRequest(), new TransportRequestConfig() { ShouldLog = true }); + } + /// /// Resets the device through the DFU channel. /// diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index feacd9352..d2908fa53 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static MessageTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiq3PAoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiriPAoLTWVz", "c2FnZVR5cGUSCAoETm9uZRAAEhEKDUVycm9yUmVzcG9uc2UQARIUChBDYWxj", "dWxhdGVSZXF1ZXN0EAMSFQoRQ2FsY3VsYXRlUmVzcG9uc2UQBBITCg9Qcm9n", "cmVzc1JlcXVlc3QQBRIUChBQcm9ncmVzc1Jlc3BvbnNlEAYSHAoYU3R1YkNh", @@ -187,15 +187,16 @@ namespace Tango.PMR.Common { "UG93ZXJEb3duUmVxdWVzdBCSThIbChZBYm9ydFBvd2VyRG93blJlc3BvbnNl", "EJNOEhgKE1N0YXJ0UG93ZXJVcFJlcXVlc3QQlE4SGQoUU3RhcnRQb3dlclVw", "UmVzcG9uc2UQlU4SGAoTQWJvcnRQb3dlclVwUmVxdWVzdBCWThIZChRBYm9y", - "dFBvd2VyVXBSZXNwb25zZRCXThIeChlTdGFydFRocmVhZExvYWRpbmdSZXF1", - "ZXN0EPhVEh8KGlN0YXJ0VGhyZWFkTG9hZGluZ1Jlc3BvbnNlEPlVEiEKHENv", - "bnRpbnVlVGhyZWFkTG9hZGluZ1JlcXVlc3QQ+lUSIgodQ29udGludWVUaHJl", - "YWRMb2FkaW5nUmVzcG9uc2UQ+1USHQoYU3RvcFRocmVhZExvYWRpbmdSZXF1", - "ZXN0EPxVEh4KGVN0b3BUaHJlYWRMb2FkaW5nUmVzcG9uc2UQ/VUSHAoXVHJ5", - "VGhyZWFkTG9hZGluZ1JlcXVlc3QQ/lUSHQoYVHJ5VGhyZWFkTG9hZGluZ1Jl", - "c3BvbnNlEP9VEiEKHFN0YXJ0SW5rRmlsbGluZ1N0YXR1c1JlcXVlc3QQ4F0S", - "IgodU3RhcnRJbmtGaWxsaW5nU3RhdHVzUmVzcG9uc2UQ4V1CHAoaY29tLnR3", - "aW5lLnRhbmdvLnBtci5jb21tb25iBnByb3RvMw==")); + "dFBvd2VyVXBSZXNwb25zZRCXThITCg5TdGFuZEJ5UmVxdWVzdBCYThIUCg9T", + "dGFuZEJ5UmVzcG9uc2UQmU4SHgoZU3RhcnRUaHJlYWRMb2FkaW5nUmVxdWVz", + "dBD4VRIfChpTdGFydFRocmVhZExvYWRpbmdSZXNwb25zZRD5VRIhChxDb250", + "aW51ZVRocmVhZExvYWRpbmdSZXF1ZXN0EPpVEiIKHUNvbnRpbnVlVGhyZWFk", + "TG9hZGluZ1Jlc3BvbnNlEPtVEh0KGFN0b3BUaHJlYWRMb2FkaW5nUmVxdWVz", + "dBD8VRIeChlTdG9wVGhyZWFkTG9hZGluZ1Jlc3BvbnNlEP1VEhwKF1RyeVRo", + "cmVhZExvYWRpbmdSZXF1ZXN0EP5VEh0KGFRyeVRocmVhZExvYWRpbmdSZXNw", + "b25zZRD/VRIhChxTdGFydElua0ZpbGxpbmdTdGF0dXNSZXF1ZXN0EOBdEiIK", + "HVN0YXJ0SW5rRmlsbGluZ1N0YXR1c1Jlc3BvbnNlEOFdQhwKGmNvbS50d2lu", + "ZS50YW5nby5wbXIuY29tbW9uYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -500,6 +501,8 @@ namespace Tango.PMR.Common { [pbr::OriginalName("StartPowerUpResponse")] StartPowerUpResponse = 10005, [pbr::OriginalName("AbortPowerUpRequest")] AbortPowerUpRequest = 10006, [pbr::OriginalName("AbortPowerUpResponse")] AbortPowerUpResponse = 10007, + [pbr::OriginalName("StandByRequest")] StandByRequest = 10008, + [pbr::OriginalName("StandByResponse")] StandByResponse = 10009, /// ///Thread Loading /// diff --git a/Software/Visual_Studio/Tango.PMR/Power/StandByRequest.cs b/Software/Visual_Studio/Tango.PMR/Power/StandByRequest.cs new file mode 100644 index 000000000..122abd35c --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Power/StandByRequest.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: StandByRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Power { + + /// Holder for reflection information generated from StandByRequest.proto + public static partial class StandByRequestReflection { + + #region Descriptor + /// File descriptor for StandByRequest.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static StandByRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChRTdGFuZEJ5UmVxdWVzdC5wcm90bxIPVGFuZ28uUE1SLlBvd2VyIhAKDlN0", + "YW5kQnlSZXF1ZXN0QhsKGWNvbS50d2luZS50YW5nby5wbXIucG93ZXJiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Power.StandByRequest), global::Tango.PMR.Power.StandByRequest.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class StandByRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new StandByRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Power.StandByRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StandByRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StandByRequest(StandByRequest other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StandByRequest Clone() { + return new StandByRequest(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as StandByRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(StandByRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(StandByRequest other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Power/StandByResponse.cs b/Software/Visual_Studio/Tango.PMR/Power/StandByResponse.cs new file mode 100644 index 000000000..4c63b1257 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Power/StandByResponse.cs @@ -0,0 +1,131 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: StandByResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Power { + + /// Holder for reflection information generated from StandByResponse.proto + public static partial class StandByResponseReflection { + + #region Descriptor + /// File descriptor for StandByResponse.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static StandByResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChVTdGFuZEJ5UmVzcG9uc2UucHJvdG8SD1RhbmdvLlBNUi5Qb3dlciIRCg9T", + "dGFuZEJ5UmVzcG9uc2VCGwoZY29tLnR3aW5lLnRhbmdvLnBtci5wb3dlcmIG", + "cHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Power.StandByResponse), global::Tango.PMR.Power.StandByResponse.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class StandByResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new StandByResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Power.StandByResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StandByResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StandByResponse(StandByResponse other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StandByResponse Clone() { + return new StandByResponse(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as StandByResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(StandByResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(StandByResponse other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index a7b982949..1852068ea 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -283,6 +283,8 @@ + + @@ -474,7 +476,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From 3dad2354fa07e71210bb0308406558ae3b96b54c Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 16 Oct 2020 00:54:58 +0300 Subject: Prevent a machine update while dyeing. --- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 20 ++++++++++++++------ .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 6 ++++++ 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index fe28dfb20..562a3b659 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -256,12 +256,7 @@ namespace Tango.PPC.UI.ViewModels StopPrintingCommand = new RelayCommand(StopPrinting); SignOutCommand = new RelayCommand(SignOut); - UpdateCommand = new RelayCommand(() => - { - NavigationManager.NavigateTo(NavigationView.MachineUpdateView); - TangoIOC.Default.GetInstance().CheckForUpdates(); - IsMenuOpened = false; - }); + UpdateCommand = new RelayCommand(UpdateMachine); PowerCommand = new RelayCommand(() => IsPowerOpened = true); RestartApplicationCommand = new RelayCommand(RestartApplication); @@ -425,6 +420,19 @@ namespace Tango.PPC.UI.ViewModels } } + private void UpdateMachine() + { + if (MachineProvider.MachineOperator.IsPrinting) + { + NotificationProvider.ShowInfo("Cannot perform a machine update while the machine is dyeing."); + return; + } + + NavigationManager.NavigateTo(NavigationView.MachineUpdateView); + TangoIOC.Default.GetInstance().CheckForUpdates(); + IsMenuOpened = false; + } + #endregion #region Override Methods diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index bbace48dd..613c70809 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -539,6 +539,12 @@ namespace Tango.PPC.UI.ViewModels _updateNotificationItem.IsDatabaseUpdate = e.IsDatabaseUpdateAvailable && !e.IsUpdateAvailable; _updateNotificationItem.Pressed += (_, __) => { + if (MachineProvider.MachineOperator.IsPrinting) + { + NotificationProvider.ShowInfo("Cannot perform a machine update while the machine is dyeing."); + return; + } + _updateNotificationItem = null; if (!IsVisible) -- cgit v1.3.1