aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2024-05-19 09:59:19 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2024-05-19 09:59:19 +0300
commit61fdeccc6976d5dd2cca30495a26a67233fcde02 (patch)
tree6f58487a33692607fe1e74ea2bcca8c1eb16c403 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
parentd35f80a12e3b4258e429f479a489ba930c583873 (diff)
downloadTango-61fdeccc6976d5dd2cca30495a26a67233fcde02.tar.gz
Tango-61fdeccc6976d5dd2cca30495a26a67233fcde02.zip
Abort Thread Loading.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs107
1 files changed, 76 insertions, 31 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
index 2279b8bb5..2dc494cb3 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
@@ -64,7 +64,7 @@ namespace Tango.PPC.Maintenance.ViewModels
Winder_3 = 13,
[Description("Winder 4")]
Winder_4 = 14,
-
+
}
public class WasteStateModel : ExtendedObject
{
@@ -154,19 +154,24 @@ namespace Tango.PPC.Maintenance.ViewModels
public Boards SelecteadBoard
{
get { return _selectedBoard; }
- set { _selectedBoard = value;
+ set
+ {
+ _selectedBoard = value;
RaisePropertyChangedAuto();
}
}
public List<Rml> Rmls { get; set; }
-
+
private ObservableCollection<WasteStateModel.RMLDisplayModel> _RMLDisplayList;
public ObservableCollection<WasteStateModel.RMLDisplayModel> RMLDisplayList
{
get { return _RMLDisplayList; }
- set { _RMLDisplayList = value;
- RaisePropertyChangedAuto();}
+ set
+ {
+ _RMLDisplayList = value;
+ RaisePropertyChangedAuto();
+ }
}
@@ -189,7 +194,8 @@ namespace Tango.PPC.Maintenance.ViewModels
public String ThreadLoadingStatus
{
get { return _threadLoadingStatus; }
- set {
+ set
+ {
_threadLoadingStatus = value;
RaisePropertyChangedAuto();
}
@@ -200,8 +206,11 @@ namespace Tango.PPC.Maintenance.ViewModels
public bool ReadyForLoading
{
get { return _readyForLoading; }
- set { _readyForLoading = value;
- RaisePropertyChangedAuto();}
+ set
+ {
+ _readyForLoading = value;
+ RaisePropertyChangedAuto();
+ }
}
private bool _startedDryerWinding;
@@ -221,8 +230,9 @@ namespace Tango.PPC.Maintenance.ViewModels
public bool EnableHeaters
{
get { return _enableHeaters; }
- set {
- if(_enableHeaters != value)
+ set
+ {
+ if (_enableHeaters != value)
{
_enableHeaters = value;
OnHeatersStateChanged();
@@ -230,7 +240,7 @@ namespace Tango.PPC.Maintenance.ViewModels
}
}
}
-
+
public RelayCommand ExportLogsCommand { get; set; }
public OpenCloseDyeingHeadCommand OpenCloseDyeingHeadCommand { get; set; }
@@ -257,6 +267,15 @@ namespace Tango.PPC.Maintenance.ViewModels
public RelayCommand StartDryerWindingCommand { get; set; }
+ public RelayCommand AbortThreadLoadingCommand { get; set; }
+
+ private bool _canAbortThreadLoading;
+ public bool CanAbortThreadLoading
+ {
+ get { return _canAbortThreadLoading; }
+ set { _canAbortThreadLoading = value; RaisePropertyChangedAuto(); }
+ }
+
public MaintenanceViewVM()
{
Guides = new ObservableCollection<GuideBase>(GuideHelper.CreateAllGuides());
@@ -273,11 +292,11 @@ namespace Tango.PPC.Maintenance.ViewModels
StartThreadLoadingCommand = new RelayCommand(StartThreadLoadingWizard, () => MachineProvider.MachineOperator.CanPrint);
StartThreadBreakCommand = new RelayCommand(StartThreadBreakWizard, () => MachineProvider.MachineOperator.CanPrint);
ViewBitResultsCommand = new RelayCommand(ViewBitResult, () => MachineProvider.MachineOperator.IsConnected);
-
+
ResetBoardCommand = new RelayCommand(RunReset, () => MachineProvider.MachineOperator.IsConnected);
- MoveToLoadPositionCommand = new RelayCommand( MoveToLoadPosition, () => { return MachineProvider.MachineOperator.IsConnected && MachineProvider.MachineOperator.CanPrint && false == StartedDryerWinding; });
+ MoveToLoadPositionCommand = new RelayCommand(MoveToLoadPosition, () => { return MachineProvider.MachineOperator.IsConnected && MachineProvider.MachineOperator.CanPrint && false == StartedDryerWinding; });
StartDryerWindingCommand = new RelayCommand(StartDryerWinding, () => ReadyForLoading);
WasteStates = new List<WasteStateModel>()
@@ -288,9 +307,10 @@ namespace Tango.PPC.Maintenance.ViewModels
SelecteadBoard = Boards.Dryer;
ReadyForLoading = false;
+
+ AbortThreadLoadingCommand = new RelayCommand(AbortThreadLoading);
}
-
public override void OnApplicationStarted()
{
MachineProvider.MachineOperator.InkFillingStatusChanged += MachineOperator_InkFillingStatusChanged;
@@ -312,19 +332,19 @@ namespace Tango.PPC.Maintenance.ViewModels
RaisePropertyChanged(nameof(DispenseCleanerLiquidCommand));
_enableHeaters = true;
- RaisePropertyChanged( nameof(EnableHeaters));
+ RaisePropertyChanged(nameof(EnableHeaters));
}
-
+
public async void CresteRMLS()
{
using (ObservablesContext db = ObservablesContext.CreateDefault())
{
- LogManager.Log("Loading RMLS...");
+ LogManager.Log("Loading RMLS...");
Rmls = (await new RmlsCollectionBuilder(db).SetAll().WithActiveParametersGroup().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).OrderBy(x => x.FinalName).ToList();
//Rmls = (await new RmlsCollectionBuilder(db).SetAll().WithActiveParametersGroup().BuildAsync()).OrderBy(x => x.FinalName).ToList();
RMLDisplayList = Rmls.Select(p => new WasteStateModel.RMLDisplayModel { Guid = p.Guid, Name = p.Name, FinalName = p.FinalName }).OrderBy(x => x.FinalName).ToObservableCollection();
- SelectedRML = RMLDisplayList.FirstOrDefault();
+ SelectedRML = RMLDisplayList.FirstOrDefault();
}
}
@@ -377,7 +397,7 @@ namespace Tango.PPC.Maintenance.ViewModels
private void MachineOperator_ThreadLoadingStatusChanged(object sender, StartThreadLoadingResponse e)
{
- if( e != null)
+ if (e != null)
{
var State = e.State;
switch (e.State)
@@ -419,13 +439,17 @@ namespace Tango.PPC.Maintenance.ViewModels
break;
}
default:
- {
+ {
ThreadLoadingStatus = "";
StartedDryerWinding = false;
return;
}
-
};
+
+ if (e.State != ThreadLoadingState.None && e.State != ThreadLoadingState.Completed)
+ {
+ CanAbortThreadLoading = true;
+ }
}
}
@@ -619,28 +643,48 @@ namespace Tango.PPC.Maintenance.ViewModels
await NotificationProvider.ShowError($"We could not reset the {SelecteadBoard.ToDescription()}.\n{ex.FlattenMessage()}");
}
}
-
- private void MoveToLoadPosition(object obj)
+
+ private void MoveToLoadPosition()
{
MachineProvider.MachineOperator.StartThreadLoading();
}
- private void StartDryerWinding(object obj)
+ private async void AbortThreadLoading()
+ {
+ if (CanAbortThreadLoading)
+ {
+ try
+ {
+ CanAbortThreadLoading = false;
+ ThreadLoadingStatus = "Aborting thread loading...";
+ await MachineProvider.MachineOperator.AbortThreadLoading();
+ await Task.Delay(1000);
+ ThreadLoadingStatus = "Thread loading aborted";
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error aborting thread loading.");
+ CanAbortThreadLoading = true;
+ }
+ }
+ }
+
+ private void StartDryerWinding()
{
try
{
- var rml = Rmls.Where( x=> x.Guid == SelectedRML.Guid).FirstOrDefault();
- if(rml != null && rml.GetActiveProcessGroup()!= null)
+ var rml = Rmls.Where(x => x.Guid == SelectedRML.Guid).FirstOrDefault();
+ if (rml != null && rml.GetActiveProcessGroup() != null)
{
var processParametersTable = rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault();
- if(processParametersTable != null)
+ if (processParametersTable != null)
{
StartedDryerWinding = true;
MachineProvider.MachineOperator.ContinueThreadLoading(processParametersTable.Clone());
}
}
}
- catch (Exception ex)
+ catch (Exception)
{
StartedDryerWinding = false;
}
@@ -648,7 +692,7 @@ namespace Tango.PPC.Maintenance.ViewModels
private async void OnHeatersStateChanged()
{
- if(EnableHeaters == false)//turn off heaters
+ if (EnableHeaters == false)//turn off heaters
{
try
{
@@ -659,14 +703,15 @@ namespace Tango.PPC.Maintenance.ViewModels
LogManager.Log(ex, "Error resetting process parameters.");
}
}
- else {
+ else
+ {
try
{
var currentProcessParameters = MachineProvider.MachineOperator.CurrentProcessParameters;
if (currentProcessParameters == null || currentProcessParameters.Guid == null)
{
var settings = SettingsManager.Default.GetOrCreate<MaitenanceModuleSettings>();
-
+
var defRmlGuid = Settings.DefaultRmlGuid ?? Rmls.First().Guid;
var rml = Rmls.Where(x => x.Guid == defRmlGuid).FirstOrDefault();
if (rml != null && rml.GetActiveProcessGroup() != null)