aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs108
1 files changed, 58 insertions, 50 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 1362ac55d..c7ba2e24d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineStatusViewVM.cs
@@ -31,6 +31,7 @@ using Tango.PPC.Common.Resume;
using Tango.Core.ExtensionMethods;
using Tango.PPC.Common.Printing;
using Tango.PPC.Common.RemoteJob;
+using Tango.PPC.UI.Dialogs;
namespace Tango.PPC.UI.ViewModels
{
@@ -74,6 +75,7 @@ namespace Tango.PPC.UI.ViewModels
private DispatcherTimer _productiondata_timer;
private bool startingJob = false;
+ private bool _jerricanDialogShowing;
#region Properties
@@ -456,16 +458,24 @@ namespace Tango.PPC.UI.ViewModels
{
Max = x.MidTankType.LiterCapacity,
IDSPack = x,
+ JerricanPresent = true,
}).OrderBy(y => y.IDSPack.LiquidType.Type).ToList();
var LubLevel = MachineProvider.Machine.Configuration.NoneEmptyIdsPacks.Where(x => x.MidTankType.Type == MidTankTypes.LubricantMidTank).FirstOrDefault();
- MidTankLubLevel = new JerricanLevelModel();
+ MidTankLubLevel = new JerricanLevelModel() { JerricanPresent = true };
if (LubLevel != null)
{
MidTankLubLevel.Max = LubLevel.MidTankType.LiterCapacity;
MidTankLubLevel.IDSPack = LubLevel;
};
+ MidTankLubLevel.PressedEvent += MidTankLevel_PressedEvent;
+
+ foreach (var midTank in MidTankLevels)
+ {
+ midTank.PressedEvent += MidTankLevel_PressedEvent;
+ }
+
MachineProvider.MachineOperator.MachineStatusChanged += MachineOperator_MachineStatusChanged;
DateTime dateTime = DateTime.Now;
@@ -514,65 +524,51 @@ namespace Tango.PPC.UI.ViewModels
if (model != null)
{
model.Level = item.MidTankLevel;
+
+ //Detect jerrican inserted
+ if (Settings.EnableJerricanChangePopup)
+ {
+ if (item.JerricanPresent && !model.JerricanPresent)
+ {
+#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
+ ShowAutoJerricanDialog(model);
+#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
+ }
+ }
model.JerricanPresent = item.JerricanPresent;
model.FillingTimeoutError = item.FillingTimeoutError;
model.MidTankEmpty = item.MidTankEmpty;
model.MidTankRefillPumpActive = item.MidTankRefillPumpActive;
model.RemainingTimeoutError = TimeSpan.FromSeconds(item.TimerRemainingSeconds);
}
- //TEST
- //if (model != null)
- //{
- // var Li = model.IDSPack.LiquidType.Type;
- // var Mid = model.IDSPack.MidTankType.Type;
- // model.Level = 0.0;
- //model.JerricanPresent = false;
- //model.FillingTimeoutError = false;
- //model.MidTankEmpty = true;
- //model.MidTankRefillPumpActive = false;
- //model.RemainingTimeoutError = TimeSpan.FromSeconds(300);
+ }
+ }
+ }
+
+ private async Task ShowAutoJerricanDialog(JerricanLevelModel model, bool opendManually = false)
+ {
+ _jerricanDialogShowing = true;
- //if (item.Index == 1)
- //{
- // model.Level = 1.0;
- //}
- //if (item.Index == 2)
- //{
- // model.Level = 2.0;
- //}
- //if (item.Index == 3)
- //{
- // model.Level = 3.0;
- //}
- //if (item.Index == 4)//TI
- //{
- // model.Level = 7.0;
- //}
- //if (item.Index == 5)//LC
- //{
- // model.Level = 7.0;
- //}
- //if (item.Index == 6)//LM
- //{
- // model.Level = 3.5;
- //}
- //if (item.Index == 7)//LY
- //{
- // model.Level = 2.5;
- //}
- // if (item.Index == 8)//Lub
- // {
- // model.Level = 1.5;
- // }
- // if (item.Index ==9)
- // {
- // model.Level = 4.99;
- // }
+ var mode = JerricanReplaceViewMode.Reinserted;
- //}
- //////////////////////////////
+ if (model.HasRemainingTimeoutError)
+ {
+ mode = JerricanReplaceViewMode.Full;
+ }
+
+ var vm = await NotificationProvider.ShowDialog(new JerricanReplaceViewVM() { IsOpenedManually = opendManually, IDSPack = model.IDSPack, ViewMode = mode });
+ if (vm.DialogResult && vm.ViewMode != JerricanReplaceViewMode.Reinserted)
+ {
+ try
+ {
+ await MachineProvider.MachineOperator.SetJerricanInsertedLiters(model.IDSPack.PackIndex, vm.LitersInserted);
+ }
+ catch (Exception ex)
+ {
+ await NotificationProvider.ShowError($"Error setting jerrican level.\n{ex.Message}");
}
}
+ _jerricanDialogShowing = false;
}
private void UpdateMachineStatusErrors(MachineStatus status)
@@ -602,6 +598,17 @@ namespace Tango.PPC.UI.ViewModels
{
var CurrentDateTime = DateTime.Now;
}
+
+ private async void MidTankLevel_PressedEvent(object sender, JerricanLevelModel e)
+ {
+ if (!_jerricanDialogShowing)
+ {
+ _jerricanDialogShowing = true;
+ await ShowAutoJerricanDialog(e, true);
+ _jerricanDialogShowing = false;
+ }
+ }
+
#endregion
#region printing
@@ -752,6 +759,7 @@ namespace Tango.PPC.UI.ViewModels
#region Methods
+
private bool IsEnableGoToJob()
{
return Job != null && _handler != null;