aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2023-05-11 20:23:33 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2023-05-11 20:23:33 +0300
commitb597a69f85fec4f5b5a1aca65228fc840911d314 (patch)
tree0a4e622292c48e788ce9c008bccaa0834c898db4 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parent7f3f3d55b9b3dfc66d0bbb2f778298e1e9b224b4 (diff)
downloadTango-b597a69f85fec4f5b5a1aca65228fc840911d314.tar.gz
Tango-b597a69f85fec4f5b5a1aca65228fc840911d314.zip
IMplemented dynamic mid tank capacity on TwineX4 & FSE.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs87
1 files changed, 86 insertions, 1 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 6d77ebcb9..1f4040460 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
@@ -9,6 +9,7 @@ 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;
@@ -16,6 +17,9 @@ 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;
namespace Tango.PPC.UI.ViewModels
{
@@ -26,6 +30,9 @@ namespace Tango.PPC.UI.ViewModels
[TangoInject]
public IDiagnosticsFrameProvider DefaultDiagnosticsFrameProvider { get; set; }
+ private DispatcherTimer _ink_timer;
+ private Stopwatch _stopwatch;
+
private JobHandler _handler;
@@ -190,6 +197,15 @@ namespace Tango.PPC.UI.ViewModels
public MachineOverviewModel OverviewModel { get; set; }
+ private TimeSpan _timer;
+
+ public TimeSpan FullInkTimer
+ {
+ get { return _timer; }
+ set { _timer = value; RaisePropertyChangedAuto();}
+ }
+
+
#endregion
#region Commands
@@ -216,6 +232,10 @@ namespace Tango.PPC.UI.ViewModels
public MachineStatusViewVM()
{
+ _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);
@@ -237,11 +257,76 @@ 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
public override void OnApplicationStarted()