diff options
| author | Roy <Roy.mail.net@gmail.com> | 2023-05-14 15:40:06 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2023-05-14 15:40:06 +0300 |
| commit | b605553a75d7a9d860123a0c759387039b666ff8 (patch) | |
| tree | f9b722a41b4889c578bcca29fddbd3b0eeaf0d54 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | |
| parent | 9f19a398394adf03f212e68746c099a59caca8e7 (diff) | |
| parent | 963f8c4fa2b4da7d875dc223cd70c55e0d5390c1 (diff) | |
| download | Tango-b605553a75d7a9d860123a0c759387039b666ff8.tar.gz Tango-b605553a75d7a9d860123a0c759387039b666ff8.zip | |
Merge branch 'eureka' of https://twinetfs.visualstudio.com/Tango/_git/Tango into eureka
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs | 187 |
1 files changed, 148 insertions, 39 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs index fba49ced3..7cd328e7b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs @@ -8,12 +8,19 @@ using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.Core.DI; using Tango.Integration.Operation; +using Tango.PMR.Diagnostics; +using Tango.PMR.MachineStatus; using Tango.PPC.Common; using Tango.PPC.Common.Diagnostics; using Tango.PPC.Jobs; using Tango.PPC.Jobs.NavigationObjects; using Tango.PPC.Jobs.Views; using Tango.PPC.Maintenance.Models; +using Tango.PPC.UI.Models; +using System.Timers; +using System.Windows.Threading; +using System.Diagnostics; +using Tango.PMR.Printing; namespace Tango.PPC.UI.ViewModels { @@ -23,9 +30,12 @@ namespace Tango.PPC.UI.ViewModels [TangoInject] public IDiagnosticsFrameProvider DefaultDiagnosticsFrameProvider { get; set; } - - private JobHandler _handler; + private DispatcherTimer _ink_timer; + private Stopwatch _stopwatch; + + + private JobHandler _handler; private Job _job; /// <summary> @@ -34,10 +44,13 @@ namespace Tango.PPC.UI.ViewModels public Job Job { get { return _job; } - set { _job = value; - if(_job == null) + set + { + _job = value; + if (_job == null) IsDyeingProcess = false; - RaisePropertyChangedAuto(); } + RaisePropertyChangedAuto(); + } } private RunningJobStatus _runningJobStatus; @@ -47,15 +60,9 @@ namespace Tango.PPC.UI.ViewModels public RunningJobStatus RunningJobStatus { get { return _runningJobStatus; } - set { + set + { _runningJobStatus = value; - IsDyeingProcess = (_runningJobStatus != null && _runningJobStatus.CurrentSegment != null); - if(_runningJobStatus != null && _runningJobStatus.CurrentSegment != null) - { - var segment = Job.Segments.FirstOrDefault(x=>x.SegmentIndex == _runningJobStatus.CurrentSegment.SegmentIndex); - if(segment != null) - CurrentBrushStop = segment.FirstBrushStop; - } RaisePropertyChangedAuto(); } } @@ -104,8 +111,9 @@ namespace Tango.PPC.UI.ViewModels public bool IsDyeingProcess { get { return _isDyeingProcess; } - set { - if(_isDyeingProcess != value) + set + { + if (_isDyeingProcess != value) { _isDyeingProcess = value; RaisePropertyChangedAuto(); @@ -114,12 +122,12 @@ namespace Tango.PPC.UI.ViewModels } private BrushStop _currentBrushStop; - public BrushStop CurrentBrushStop { get { return _currentBrushStop; } - set { - if(_currentBrushStop != value) + set + { + // if (_currentBrushStop != value) { _currentBrushStop = value; OnUpdateCurrentBrush(); @@ -128,6 +136,8 @@ namespace Tango.PPC.UI.ViewModels } } + public JobBrushStop JobBrushStop { get; set; } + public double CyanOutput { get { return GetVolumeLiquidType(LiquidTypes.Cyan); } @@ -147,7 +157,7 @@ namespace Tango.PPC.UI.ViewModels { get { return GetVolumeLiquidType(LiquidTypes.Black); } } - + public double LightCyanOutput { get { return GetVolumeLiquidType(LiquidTypes.LightCyan); } @@ -180,6 +190,17 @@ namespace Tango.PPC.UI.ViewModels set { _midTankLevels = value; RaisePropertyChangedAuto(); } } + public MachineOverviewModel OverviewModel { get; set; } + + private TimeSpan _timer; + + public TimeSpan FullInkTimer + { + get { return _timer; } + set { _timer = value; RaisePropertyChangedAuto(); } + } + + #endregion #region Commands @@ -206,7 +227,11 @@ namespace Tango.PPC.UI.ViewModels public MachineStatusViewVM() { - StopCommand = new RelayCommand(StopJob, ()=>CanStopped()); + _ink_timer = new DispatcherTimer(); + _ink_timer.Interval = TimeSpan.FromSeconds(1); + _ink_timer.Tick += _ink_timer_Tick; + + StopCommand = new RelayCommand(StopJob, () => CanStopped()); AbortCommand = new RelayCommand(AbortJob, () => CanStopped()); GoToJobCommand = new RelayCommand(GoToJob); JobStatusViewCommand = new RelayCommand(JobStatusView); @@ -217,6 +242,8 @@ namespace Tango.PPC.UI.ViewModels IsEnabledStopButton = false; IsSpoolView = false; IsWeghtView = false; + + OverviewModel = new MachineOverviewModel(); } public override void OnApplicationReady() @@ -225,10 +252,75 @@ namespace Tango.PPC.UI.ViewModels MidTankLevels = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.HasLevelMeasure).OrderBy(x => x.PackIndex).Select(x => new MidTankLevelModel() { - Max = MachineOperator.MAX_MIDTANK_LITERS, + Max = x.MidTankType.LiterCapacity, IDSPack = x, }).OrderBy(y => y.IDSPack.LiquidType.Code).ToList(); + // MachineProvider.MachineOperator.InkFillingStatusChanged += MachineOperator_InkFillingStatusChanged; + MachineProvider.MachineOperator.MachineStatusChanged += MachineOperator_MachineStatusChanged; + } + + #region Events + + private void MachineOperator_MachineStatusChanged(object sender, MachineStatus status) + { + UpdateMidTankLevels(status); } + private void UpdateMidTankLevels(MachineStatus status) + { + if (!IsJobStatusViewEnable) + { + foreach (var item in status.IDSPacksLevels) + { + var model = MidTankLevels.SingleOrDefault(x => x.IDSPack.PackIndex == item.Index); + + if (model != null) + { + model.Level = item.MidTankLevel; + model.JerricanPresent = item.JerricanPresent; + model.FillingTimeoutError = item.FillingTimeoutError; + model.MidTankEmpty = item.MidTankEmpty; + model.MidTankRefillPumpActive = item.MidTankRefillPumpActive; + if (model.FillingTimeoutError) + { + //StartInkTimer() + } + } + } + } + } + private void StartInkTimer() + { + _stopwatch = Stopwatch.StartNew(); + _ink_timer.Start(); + } + + private void StopInkTimer() + { + if (_stopwatch.IsRunning) + { + _stopwatch.Stop(); + _ink_timer.Stop(); + } + } + + private void _ink_timer_Tick(object sender, EventArgs e) + { + FullInkTimer = _stopwatch.Elapsed; + } + private void MachineOperator_InkFillingStatusChanged(object sender, InkFillingStatusChangedEventArgs e) + { + //foreach (var cartridge in e.Status.CartridgesStatuses.Where(x => x.Cartridge.Slot != CartridgeSlot.Ink)) + //{ + // var wasteState = WasteStates.SingleOrDefault(x => x.Slot == cartridge.Cartridge.Slot); + + // if (wasteState != null) + // { + // wasteState.State = cartridge.State; + // } + //} + } + + #endregion #region printing @@ -237,12 +329,12 @@ namespace Tango.PPC.UI.ViewModels MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; MachineProvider.MachineOperator.PrintingEnded += MachineOperator_PrintingEnded; - //DefaultDiagnosticsFrameProvider.FrameReceived += DefaultDiagnosticsFrameProvider_FrameReceived; + DefaultDiagnosticsFrameProvider.FrameReceived += DefaultDiagnosticsFrameProvider_FrameReceived; } private void DefaultDiagnosticsFrameProvider_FrameReceived(object sender, PMR.Diagnostics.StartDiagnosticsResponse e) { - var frame = e; + OverviewModel.Update(e, this.Job != null ? Job.Rml : null, null); } private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) @@ -288,32 +380,49 @@ namespace Tango.PPC.UI.ViewModels private void JobHandler_StatusChanged(object sender, RunningJobStatus e) { - InvokeUI(() => + //InvokeUI(() => + //{ + + + RunningJobStatus = e; + IsDyeingProcess = (RunningJobStatus != null && RunningJobStatus.CurrentSegment != null); + if (RunningJobStatus != null && RunningJobStatus.CurrentSegment != null) { - RunningJobStatus = e; - }); + var segment = Job.Segments.FirstOrDefault(x => x.SegmentIndex == _runningJobStatus.CurrentSegment.SegmentIndex); + if (segment != null) + { + + if (_handler.JobTicket.Segments.Count > 0) + { + JobBrushStop = _handler.JobTicket.Segments[Job.OrderedSegments.IndexOf(segment)].BrushStops.First(); + } + + CurrentBrushStop = segment.FirstBrushStop; + } + } + //}); } private void JobHandler_CanCancelChanged(object sender, EventArgs e) { - InvokeUI( () => - { - IsEnabledStopButton = _handler.CanCancel; - StopCommand.RaiseCanExecuteChanged(); - AbortCommand.RaiseCanExecuteChanged(); - }); + InvokeUI(() => + { + IsEnabledStopButton = _handler.CanCancel; + StopCommand.RaiseCanExecuteChanged(); + AbortCommand.RaiseCanExecuteChanged(); + }); } - + #endregion #region Methods private void GoToJob() { - + NavigationManager.NavigateWithObject<JobsV2Module, JobEurekaView, JobNavigationObject>(new JobNavigationObject() { Job = _handler.Job }); NavigationManager.ClearHistoryExcept<JobsView>(); - + } /// <summary> /// Toggles the application technician mode. @@ -329,7 +438,7 @@ namespace Tango.PPC.UI.ViewModels ApplicationManager.ExitTechnicianMode(); } } - + protected void JobStatusView() { IsJobStatusViewEnable = true; @@ -342,9 +451,9 @@ namespace Tango.PPC.UI.ViewModels private double GetVolumeLiquidType(LiquidTypes liquidType) { - if(CurrentBrushStop != null && CurrentBrushStop.LiquidVolumes != null && CurrentBrushStop.LiquidVolumes.Count > 0) + if (JobBrushStop != null && JobBrushStop.Dispensers != null && JobBrushStop.Dispensers.Count > 0) { - var lt = CurrentBrushStop.LiquidVolumes.FirstOrDefault(x => x.LiquidType == liquidType); + var lt = JobBrushStop.Dispensers.FirstOrDefault(x => x.DispenserLiquidType == (DispenserLiquidType)liquidType); if (lt != null) { @@ -372,7 +481,7 @@ namespace Tango.PPC.UI.ViewModels protected void ClearAllNotifications() { - NotificationProvider.NotificationItems.Where(x=>x.CanClose).ToList().ForEach(y=> NotificationProvider.PopNotification(y)); + NotificationProvider.NotificationItems.Where(x => x.CanClose).ToList().ForEach(y => NotificationProvider.PopNotification(y)); } protected void OnUpdateCurrentBrush() |
