From bd3cb640be12621ac37253e8a8c627ae40692e4d Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 7 Feb 2019 15:39:12 +0200 Subject: Some fixes and improvements for PPC & Machine Studio. --- .../Operation/DefaultMachineEventsStateProvider.cs | 10 +++++++ .../Operation/IMachineEventsStateProvider.cs | 5 ++++ .../Tango.Integration/Operation/MachineOperator.cs | 34 +++++++++++++--------- 3 files changed, 36 insertions(+), 13 deletions(-) (limited to 'Software/Visual_Studio/Tango.Integration') diff --git a/Software/Visual_Studio/Tango.Integration/Operation/DefaultMachineEventsStateProvider.cs b/Software/Visual_Studio/Tango.Integration/Operation/DefaultMachineEventsStateProvider.cs index 96f865cc3..8c376ea3e 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/DefaultMachineEventsStateProvider.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/DefaultMachineEventsStateProvider.cs @@ -136,5 +136,15 @@ namespace Tango.Integration.Operation { EventsChanged?.Invoke(this, events); } + + /// + /// Resets the current events tracking. + /// + public void Reset() + { + _events = new ReadOnlyCollection(new List()); + RaisePropertyChanged(nameof(Events)); + OnEventsChanged(new List()); + } } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineEventsStateProvider.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineEventsStateProvider.cs index 0fc086fe3..2cf00904f 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineEventsStateProvider.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineEventsStateProvider.cs @@ -49,5 +49,10 @@ namespace Tango.Integration.Operation /// /// The events. void ApplyEvents(IEnumerable events); + + /// + /// Resets the current events tracking. + /// + void Reset(); } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 0edc04845..d0e03f873 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -189,12 +189,15 @@ namespace Tango.Integration.Operation get { return _status; } protected set { - _status = value; - RaisePropertyChangedAuto(); - OnMachineStatusChanged(value); - RaisePropertyChanged(nameof(IsPrinting)); - RaisePropertyChanged(nameof(CanPrint)); - LogManager.Log("Machine operator status changed: " + _status); + if (_status != value) + { + _status = value; + RaisePropertyChangedAuto(); + OnMachineStatusChanged(value); + RaisePropertyChanged(nameof(IsPrinting)); + RaisePropertyChanged(nameof(CanPrint)); + LogManager.Log("Machine operator status changed: " + _status); + } } } @@ -690,11 +693,11 @@ namespace Tango.Integration.Operation { LogRequestFailed(request, ex); } + } - if (MachineEventsStateProvider != null) - { - MachineEventsStateProvider.ApplyEvents(new List()); - } + if (MachineEventsStateProvider != null) + { + MachineEventsStateProvider.Reset(); } await base.Disconnect(); @@ -724,6 +727,10 @@ namespace Tango.Integration.Operation DeviceInformation = response.Message.DeviceInformation; + _diagnosticsSent = false; + _eventsSent = false; + _debugSent = false; + OnEnableDiagnosticsChanged(EnableDiagnostics); OnEnableEmbeddedDebuggingChanged(EnableEmbeddedDebugging); OnEnableEventsNotification(EnableEventsNotification); @@ -1305,6 +1312,10 @@ namespace Tango.Integration.Operation LogRequestSent(request); bool responseLogged = false; + Status = MachineStatuses.Printing; + RunningJob = originalJob; + PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => { handler.RaiseStatusReceived(response.Message.Status); @@ -1312,9 +1323,6 @@ namespace Tango.Integration.Operation if (!responseLogged) { responseLogged = true; - Status = MachineStatuses.Printing; - RunningJob = originalJob; - PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); LogResponseReceived(response.Message); } }, (ex) => -- cgit v1.3.1