aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-02-27 00:34:46 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-02-27 00:34:46 +0200
commit882a6d54d60f05f3bf542ab43c3681f64152df41 (patch)
tree3d62d27ad3517f93fffd5d8e690f7551a15a4b5a /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
parent8e5ab17ced647a8c9fbba764c6fa0c06d56269c9 (diff)
downloadTango-882a6d54d60f05f3bf542ab43c3681f64152df41.tar.gz
Tango-882a6d54d60f05f3bf542ab43c3681f64152df41.zip
Added thread parameters DB, PMR, MachineOperator merging, Machine Studio.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs154
1 files changed, 83 insertions, 71 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
index b75d65fe0..1ceaf07df 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
@@ -283,102 +283,114 @@ namespace Tango.MachineStudio.RML.ViewModels
{
using (_notification.PushTaskItem("Loading RML..."))
{
- IsFree = false;
-
- if (_active_context != null)
+ try
{
- _active_context.Dispose();
- }
-
- _active_context = ObservablesContext.CreateDefault();
+ IsFree = false;
- CCTS = _active_context.Ccts
- .Select(x => new CctModel()
+ if (_active_context != null)
{
- Guid = x.Guid,
- FileName = x.FileName,
+ _active_context.Dispose();
+ }
- }).ToObservableCollection();
+ _active_context = ObservablesContext.CreateDefault();
- CCTS.Where(x => String.IsNullOrWhiteSpace(x.FileName)).ToList().ForEach(x => x.FileName = x.Guid);
+ CCTS = _active_context.Ccts
+ .Select(x => new CctModel()
+ {
+ Guid = x.Guid,
+ FileName = x.FileName,
- LoadRmlProperties();
+ }).ToObservableCollection();
- ActiveRML = await new RmlBuilder(_active_context)
- .Set(guid)
- .WithActiveParametersGroup()
- .WithLiquidFactors()
- .WithCCT()
- .WithSpools()
- .BuildAsync();
+ CCTS.Where(x => String.IsNullOrWhiteSpace(x.FileName)).ToList().ForEach(x => x.FileName = x.Guid);
- if (ActiveRML.Cct != null)
- {
- SelectedCCT = CCTS.SingleOrDefault(x => x.Guid == ActiveRML.Cct.Guid);
- }
+ LoadRmlProperties();
- if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0)
- {
- if (!_notification.ShowQuestion("Could not find any process group for the selected RML. Would you like to create one?"))
+ ActiveRML = await new RmlBuilder(_active_context)
+ .Set(guid)
+ .WithActiveParametersGroup()
+ .WithLiquidFactors()
+ .WithCCT()
+ .WithSpools()
+ .BuildAsync();
+
+ if (ActiveRML.Cct != null)
{
- _notification.ShowError("Cannot load an RML with no process group.");
- IsFree = true;
- return;
+ SelectedCCT = CCTS.SingleOrDefault(x => x.Guid == ActiveRML.Cct.Guid);
}
- else
+
+ if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0)
{
- ProcessParametersTablesGroup group = new ProcessParametersTablesGroup();
- group.Name = "Active Group";
- group.Active = true;
- group.ProcessParametersTables.Add(new ProcessParametersTable()
+ if (!_notification.ShowQuestion("Could not find any process group for the selected RML. Would you like to create one?"))
+ {
+ _notification.ShowError("Cannot load an RML with no process group.");
+ IsFree = true;
+ return;
+ }
+ else
{
- Name = "Process Table 1",
- });
+ ProcessParametersTablesGroup group = new ProcessParametersTablesGroup();
+ group.Name = "Active Group";
+ group.Active = true;
+ group.ProcessParametersTables.Add(new ProcessParametersTable()
+ {
+ Name = "Process Table 1",
+ });
- group.Rml = ActiveRML;
+ group.Rml = ActiveRML;
- _active_context.ProcessParametersTablesGroups.Add(group);
- _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]);
- await _active_context.SaveChangesAsync();
- LoadActiveRML(ActiveRML.Guid);
- return;
+ _active_context.ProcessParametersTablesGroups.Add(group);
+ _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]);
+ await _active_context.SaveChangesAsync();
+ LoadActiveRML(ActiveRML.Guid);
+ return;
+ }
}
- }
-
- ActiveProcessParametersGroup = ActiveRML.ProcessParametersTablesGroups.ToList().FirstOrDefault();
- ActiveProcessParametersTableView = CollectionViewSource.GetDefaultView(ActiveProcessParametersGroup.ProcessParametersTables);
- ActiveProcessParametersTableView.SortDescriptions.Add(new SortDescription(nameof(ProcessParametersTable.TableIndex), ListSortDirection.Ascending));
- CalibrationDataViewVM = new CalibrationDataViewVM(_notification);
- LiquidTypesRmls = ActiveRML.LiquidTypesRmls;
+ ActiveProcessParametersGroup = ActiveRML.ProcessParametersTablesGroups.ToList().FirstOrDefault();
+ ActiveProcessParametersTableView = CollectionViewSource.GetDefaultView(ActiveProcessParametersGroup.ProcessParametersTables);
+ ActiveProcessParametersTableView.SortDescriptions.Add(new SortDescription(nameof(ProcessParametersTable.TableIndex), ListSortDirection.Ascending));
- foreach (var liquidTypeRml in LiquidTypesRmls)
- {
- CalibrationDataVM catVM = new CalibrationDataVM(liquidTypeRml.LiquidType);
+ CalibrationDataViewVM = new CalibrationDataViewVM(_notification);
+ LiquidTypesRmls = ActiveRML.LiquidTypesRmls;
- if (liquidTypeRml.DefaultCatData != null)
+ foreach (var liquidTypeRml in LiquidTypesRmls)
{
- catVM.CalibrationPoints = liquidTypeRml.GetCalibrationData().CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection();
- }
+ CalibrationDataVM catVM = new CalibrationDataVM(liquidTypeRml.LiquidType);
- CalibrationDataViewVM.LiquidsCalibrationData.Add(catVM);
- }
+ if (liquidTypeRml.DefaultCatData != null)
+ {
+ catVM.CalibrationPoints = liquidTypeRml.GetCalibrationData().CalibrationPoints.Select(x => new CalibrationDataPointVM(x.X, x.Y)).ToObservableCollection();
+ }
- ColorConversionViewVM = new ColorConversionViewVM(_notification)
- {
- RML = ActiveRML,
- CCT = SelectedCCT,
- LiquidsCalibrationData = CalibrationDataViewVM.LiquidsCalibrationData,
- LiquidTypesRmls = LiquidTypesRmls,
- };
+ CalibrationDataViewVM.LiquidsCalibrationData.Add(catVM);
+ }
+
+ ColorConversionViewVM = new ColorConversionViewVM(_notification)
+ {
+ RML = ActiveRML,
+ CCT = SelectedCCT,
+ LiquidsCalibrationData = CalibrationDataViewVM.LiquidsCalibrationData,
+ LiquidTypesRmls = LiquidTypesRmls,
+ };
- _rmlBeforeSave = RmlDTO.FromObservable(ActiveRML);
+ _rmlBeforeSave = RmlDTO.FromObservable(ActiveRML);
- View.NavigateTo(RmlNavigationView.RmlView);
+ View.NavigateTo(RmlNavigationView.RmlView);
- InvalidateRelayCommands();
+ InvalidateRelayCommands();
- IsFree = true;
+ IsFree = true;
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log($"Error loading RML '{ActiveRML.Name}'...");
+ _notification.ShowError($"Error loading the selected thread.\n{ex.FlattenMessage()}");
+ }
+ finally
+ {
+ IsFree = true;
+ }
}
}
@@ -490,7 +502,7 @@ namespace Tango.MachineStudio.RML.ViewModels
if (rml_jobs.Count > 0)
{
- _notification.ShowError($"The following jobs must be removed or change thread type before the selected thread can be deleted:\n{String.Join("\n",rml_jobs.Select(x => $"{x.Machine.SerialNumber} => {x.Name}"))}");
+ _notification.ShowError($"The following jobs must be removed or change thread type before the selected thread can be deleted:\n{String.Join("\n", rml_jobs.Select(x => $"{x.Machine.SerialNumber} => {x.Name}"))}");
return;
}