aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy.mail.net@gmail.com>2023-05-14 19:57:36 +0300
committerRoy Ben-Shabat <Roy.mail.net@gmail.com>2023-05-14 19:57:36 +0300
commite652ac7e0e32485ebec69090d01721046ac79aaf (patch)
treed89dd56ad02085c0401c33b1a77280f58fdec021 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parentbaf96c13dbdb1510cb86221f8e12396af7251f59 (diff)
parent207ac666dd0e091ec58af244b0e98cda33789d7f (diff)
downloadTango-e652ac7e0e32485ebec69090d01721046ac79aaf.tar.gz
Tango-e652ac7e0e32485ebec69090d01721046ac79aaf.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')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs156
1 files changed, 112 insertions, 44 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..a47b68a4f 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,18 @@ 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 +29,8 @@ namespace Tango.PPC.UI.ViewModels
[TangoInject]
public IDiagnosticsFrameProvider DefaultDiagnosticsFrameProvider { get; set; }
-
- private JobHandler _handler;
+ private JobHandler _handler;
private Job _job;
/// <summary>
@@ -34,10 +39,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 +55,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 +106,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 +117,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 +131,8 @@ namespace Tango.PPC.UI.ViewModels
}
}
+ public JobBrushStop JobBrushStop { get; set; }
+
public double CyanOutput
{
get { return GetVolumeLiquidType(LiquidTypes.Cyan); }
@@ -147,7 +152,7 @@ namespace Tango.PPC.UI.ViewModels
{
get { return GetVolumeLiquidType(LiquidTypes.Black); }
}
-
+
public double LightCyanOutput
{
get { return GetVolumeLiquidType(LiquidTypes.LightCyan); }
@@ -173,13 +178,15 @@ namespace Tango.PPC.UI.ViewModels
// get { return GetVolumeLiquidType(LiquidTypes.Lubricant); }
//}
- private List<MidTankLevelModel> _midTankLevels;
- public List<MidTankLevelModel> MidTankLevels
+ private List<JerricanLevelModel> _midTankLevels;
+ public List<JerricanLevelModel> MidTankLevels
{
get { return _midTankLevels; }
set { _midTankLevels = value; RaisePropertyChangedAuto(); }
}
+ public MachineOverviewModel OverviewModel { get; set; }
+
#endregion
#region Commands
@@ -206,7 +213,9 @@ namespace Tango.PPC.UI.ViewModels
public MachineStatusViewVM()
{
- StopCommand = new RelayCommand(StopJob, ()=>CanStopped());
+
+
+ StopCommand = new RelayCommand(StopJob, () => CanStopped());
AbortCommand = new RelayCommand(AbortJob, () => CanStopped());
GoToJobCommand = new RelayCommand(GoToJob);
JobStatusViewCommand = new RelayCommand(JobStatusView);
@@ -217,19 +226,66 @@ namespace Tango.PPC.UI.ViewModels
IsEnabledStopButton = false;
IsSpoolView = false;
IsWeghtView = false;
+
+ OverviewModel = new MachineOverviewModel();
}
public override void OnApplicationReady()
{
base.OnApplicationReady();
- MidTankLevels = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.HasLevelMeasure).OrderBy(x => x.PackIndex).Select(x => new MidTankLevelModel()
+ MidTankLevels = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.HasLevelMeasure || x.MidTankType.Type == MidTankTypes.LubricantMidTank).OrderBy(x => x.PackIndex).Select(x => new JerricanLevelModel()
{
- Max = MachineOperator.MAX_MIDTANK_LITERS,
+ Max = x.MidTankType.LiterCapacity,
IDSPack = x,
- }).OrderBy(y => y.IDSPack.LiquidType.Code).ToList();
+ }).OrderBy(y => y.IDSPack.LiquidType.PreferredIndex).ToList();
+
+ 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;
+ model.RemainingTimeoutError = TimeSpan.FromSeconds(item.TimerRemainingSeconds);
+ }
+ }
+ }
+ }
+
+ 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
public override void OnApplicationStarted()
@@ -237,12 +293,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 +344,44 @@ namespace Tango.PPC.UI.ViewModels
private void JobHandler_StatusChanged(object sender, RunningJobStatus e)
{
- 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 +397,7 @@ namespace Tango.PPC.UI.ViewModels
ApplicationManager.ExitTechnicianMode();
}
}
-
+
protected void JobStatusView()
{
IsJobStatusViewEnable = true;
@@ -342,9 +410,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 +440,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()