From cc407822ab637108a1b7868c3dd6f2f27b2ee5f8 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 28 Nov 2019 14:00:29 +0200 Subject: Deprecated the use of loaded rml, default rml, default spool type, target color spaces, target job types and implemented through settings on PPC. Related Work Items: #1499 --- .../Views/MachineSettingsView.xaml | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml index 5e3f170dd..b6c1ba974 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml @@ -48,21 +48,6 @@ Organization - Default RML - - - Loaded RML - - - Default Color Space - - - Default Segment Length - - - Default Spool Type - - OS Key -- cgit v1.3.1 From 76a028f95dc2bdb2aba4a58ca298268be32a5879 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 14 Dec 2019 19:04:41 +0200 Subject: Implemented sites module on MS. Implemented site selection on Machine Designer. --- Software/DB/TCC/TCC.mdf | Bin 8388608 -> 8388608 bytes Software/DB/TCC/TCC_log.ldf | Bin 8388608 -> 8388608 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../ViewModels/MainViewVM.cs | 21 ++- .../Views/MachineSettingsView.xaml | 3 + .../Modules/Tango.MachineStudio.Sites/App.xaml | 12 ++ .../Contracts/IMainView.cs | 20 +++ .../Images/machine_site.png | Bin 0 -> 207547 bytes .../Tango.MachineStudio.Sites/Models/SiteModel.cs | 18 ++ .../Tango.MachineStudio.Sites.csproj | 32 +++- .../ViewModels/MainViewVM.cs | 198 ++++++++++++++++++++- .../ViewModels/SiteDetailsViewVM.cs | 153 ++++++++++++++++ .../Tango.MachineStudio.Sites/Views/MainView.xaml | 6 +- .../Views/MainView.xaml.cs | 10 +- .../Views/SiteDetailsView.xaml | 170 ++++++++++++++++++ .../Views/SiteDetailsView.xaml.cs | 28 +++ .../Tango.MachineStudio.Sites/Views/SitesView.xaml | 76 ++++++++ .../Views/SitesView.xaml.cs | 28 +++ .../Modules/Tango.MachineStudio.Sites/app.config | 10 ++ .../Tango.MachineStudio.Sites/packages.config | 1 + Software/Visual_Studio/Tango.BL/Entities/Site.cs | 36 ++++ 22 files changed, 816 insertions(+), 6 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/App.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Contracts/IMainView.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/machine_site.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Models/SiteModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml') diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf index 37ed9b842..f77c2e733 100644 Binary files a/Software/DB/TCC/TCC.mdf and b/Software/DB/TCC/TCC.mdf differ diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf index 616875f6b..048d3ccb0 100644 Binary files a/Software/DB/TCC/TCC_log.ldf and b/Software/DB/TCC/TCC_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 5650526a0..6af55afc8 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 6a5c87335..33e76f9de 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 768f93de1..fd31cd950 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -115,6 +115,21 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _selectedSpool = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private Site _selectedSite; + public Site SelectedSite + { + get { return _selectedSite; } + set { _selectedSite = value; RaisePropertyChangedAuto(); } + } + + private List _sites; + public List Sites + { + get { return _sites; } + set { _sites = value; RaisePropertyChangedAuto(); } + } + + private ColorCalibrationViewVM _colorCalibrationViewVM; public ColorCalibrationViewVM ColorCalibrationViewVM { @@ -474,6 +489,10 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + Sites = await ActiveMachineAdapter.Context.Sites.ToListAsync(); + Sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); + SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid); + ColorCalibrationViewVM = new ColorCalibrationViewVM(_notification, ActiveMachine, _activeMachineAdapter.Context) { Rmls = ActiveMachineAdapter.Rmls, @@ -487,7 +506,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels await MachineUpdatesViewVM.Init(ActiveMachine, ActiveMachineAdapter.Context); TupViewVM.Init(ActiveMachine); - ActiveMachine.Configuration.HardwareVersionChanged += Configuration_HardwareVersionChanged; View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); @@ -651,6 +669,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.ConfigurationGuid = ActiveMachine.Configuration.Guid; ActiveMachine.LastUpdated = DateTime.UtcNow; ActiveMachine.ProductionDate = DateTime.UtcNow; + ActiveMachine.SiteGuid = SelectedSite == null ? null : (SelectedSite.ID == -1 ? null : SelectedSite.Guid); ColorCalibrationViewVM.Save(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml index b6c1ba974..0a0c1ecef 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml @@ -48,6 +48,9 @@ Organization + Site + + OS Key diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/App.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/App.xaml new file mode 100644 index 000000000..01a064b05 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/App.xaml @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Contracts/IMainView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Contracts/IMainView.cs new file mode 100644 index 000000000..67f57b28c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Contracts/IMainView.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Sites.Contracts +{ + public enum SitesNavigationView + { + SitesView, + SiteDetailsView, + } + + public interface IMainView : IView + { + void NavigateTo(SitesNavigationView view); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/machine_site.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/machine_site.png new file mode 100644 index 000000000..9b22e53b0 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/machine_site.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Models/SiteModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Models/SiteModel.cs new file mode 100644 index 000000000..007f8a3ad --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Models/SiteModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.SharedUI.Components; + +namespace Tango.MachineStudio.Sites.Models +{ + public class SiteModel : Site + { + public String Organization { get; set; } + public int MachineCount { get; set; } + public int CatalogCount { get; set; } + public int ThreadCount { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Tango.MachineStudio.Sites.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Tango.MachineStudio.Sites.csproj index 95f71baa8..ea9162ce2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Tango.MachineStudio.Sites.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Tango.MachineStudio.Sites.csproj @@ -32,6 +32,12 @@ 4 + + ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll @@ -48,6 +54,7 @@ ..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll @@ -66,8 +73,11 @@ + + + MainView.xaml @@ -75,10 +85,28 @@ GlobalVersionInfo.cs + + SiteDetailsView.xaml + + + SitesView.xaml + + + MSBuild:Compile + Designer + Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + @@ -105,7 +133,9 @@ Settings.Designer.cs - + + + {f441feee-322a-4943-b566-110e12fd3b72} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs index d0be162dd..486c8b46f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs @@ -4,15 +4,209 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.Core.Threading; using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Sites.Contracts; +using Tango.MachineStudio.Sites.Models; namespace Tango.MachineStudio.Sites.ViewModels { - public class MainViewVM : StudioViewModel + public class MainViewVM : StudioViewModel { + private ObservablesContext _db; + private INotificationProvider _notification; + private ActionTimer _filter_timer; + + private List _sites; + public List Sites + { + get { return _sites; } + set { _sites = value; RaisePropertyChangedAuto(); } + } + + private SiteModel _selectedSite; + public SiteModel SelectedSite + { + get { return _selectedSite; } + set { _selectedSite = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private String _filter; + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + private SiteDetailsViewVM _siteDetailsViewVM; + public SiteDetailsViewVM SiteDetailsViewVM + { + get { return _siteDetailsViewVM; } + set { _siteDetailsViewVM = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand AddSiteCommand { get; set; } + + public RelayCommand RemoveSiteCommand { get; set; } + + public RelayCommand ManageSiteCommand { get; set; } + + public RelayCommand BackToSitesCommand { get; set; } + + public MainViewVM(INotificationProvider notificationProvider) + { + _notification = notificationProvider; + _filter_timer = new ActionTimer(TimeSpan.FromMilliseconds(500)); + + ManageSiteCommand = new RelayCommand(() => LoadSelectedSite(), () => SelectedSite != null); + BackToSitesCommand = new RelayCommand(() => { View.NavigateTo(SitesNavigationView.SitesView); }); + AddSiteCommand = new RelayCommand(AddNewSite); + RemoveSiteCommand = new RelayCommand(RemoveSelectedSite, () => SelectedSite != null); + } + + private async void RemoveSelectedSite() + { + if (!_notification.ShowQuestion("Are you sure you wish to remove the selected site?")) return; + + try + { + using (_notification.PushTaskItem("Removing site...")) + { + IsFree = false; + await Task.Factory.StartNew(() => + { + var site = _db.Sites.SingleOrDefault(x => x.Guid == SelectedSite.Guid); + site.Delete(_db); + _db.SaveChanges(); + Sites.Remove(SelectedSite); + LoadSites(); + }); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error removing site."); + _notification.ShowError($"Error removing site.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private async void AddNewSite() + { + try + { + String name = _notification.ShowTextInput("Enter site name", "name"); + if (String.IsNullOrWhiteSpace(name)) return; + + using (_notification.PushTaskItem("Creating site...")) + { + IsFree = false; + SiteDetailsViewVM = new SiteDetailsViewVM(); + SiteDetailsViewVM.Saved += SiteDetailsViewVM_Saved; + await SiteDetailsViewVM.Init(SelectedSite?.Guid, _notification, true, name); + View.NavigateTo(SitesNavigationView.SiteDetailsView); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error creating site."); + _notification.ShowError($"Error creating site.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private async void LoadSelectedSite() + { + try + { + using (_notification.PushTaskItem("Loading site details...")) + { + IsFree = false; + SiteDetailsViewVM = new SiteDetailsViewVM(); + SiteDetailsViewVM.Saved += SiteDetailsViewVM_Saved; + await SiteDetailsViewVM.Init(SelectedSite.Guid, _notification, false); + View.NavigateTo(SitesNavigationView.SiteDetailsView); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading site details."); + _notification.ShowError($"Error loading site details.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private void SiteDetailsViewVM_Saved(object sender, EventArgs e) + { + OnFilterChanged(); + View.NavigateTo(SitesNavigationView.SitesView); + } + + private void OnFilterChanged() + { + if (Filter != null) + { + _filter_timer.ResetReplace(() => + { + try + { + LoadSites(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error loading sites list."); + } + }); + } + } + + private void LoadSites() + { + using (_notification.PushTaskItem("Loading sites...")) + { + Sites = (from site in _db.Sites + join organization in _db.Organizations on site.OrganizationGuid equals organization.Guid + join sites_rmls in _db.SitesRmls on site.Guid equals sites_rmls.SiteGuid into rmls + join sites_catalogs in _db.SitesCatalogs on site.Guid equals sites_catalogs.SiteGuid into catalogs + join sites_machines in _db.Machines on site.Guid equals sites_machines.SiteGuid into machines + where Filter == null || Filter == "" || site.Name.ToLower().StartsWith(Filter.ToLower()) || organization.Name.ToLower().StartsWith(Filter.ToLower()) + select new + { + Site = site, + OrganizationName = organization.Name, + ThreadCount = rmls.Count(x => x.SiteGuid == site.Guid), + CatalogCount = catalogs.Count(x => x.SiteGuid == site.Guid), + MachineCount = machines.Count(x => x.SiteGuid == site.Guid) + }).Distinct().ToList().DistinctBy(x => x.Site.Guid).Select(x => new SiteModel() + { + Guid = x.Site.Guid, + ID = x.Site.ID, + Name = x.Site.Name, + Description = x.Site.Description, + ThreadCount = x.ThreadCount, + CatalogCount = x.CatalogCount, + MachineCount = x.MachineCount, + Organization = x.OrganizationName, + }).ToList(); + } + } + public override void OnApplicationReady() { - + _db = ObservablesContext.CreateDefault(); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs new file mode 100644 index 000000000..0e4dcbb47 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.SharedUI; +using Tango.SharedUI.Components; +using System.Data.Entity; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.Sites.ViewModels +{ + public class SiteDetailsViewVM : ViewModel + { + private ObservablesContext _db; + private INotificationProvider _notification; + + public event EventHandler Saved; + + private Site _site; + public Site Site + { + get { return _site; } + set { _site = value; RaisePropertyChangedAuto(); } + } + + private List _organizations; + public List Organizations + { + get { return _organizations; } + set { _organizations = value; RaisePropertyChangedAuto(); } + } + + private Organization _selectedOrganization; + public Organization SelectedOrganization + { + get { return _selectedOrganization; } + set { _selectedOrganization = value; RaisePropertyChangedAuto(); } + } + + private SelectedObjectCollection _rmls; + public SelectedObjectCollection Rmls + { + get { return _rmls; } + set { _rmls = value; RaisePropertyChangedAuto(); } + } + + private SelectedObjectCollection _catalogs; + public SelectedObjectCollection Catalogs + { + get { return _catalogs; } + set { _catalogs = value; RaisePropertyChangedAuto(); } + } + + private List _machines; + public List Machines + { + get { return _machines; } + set { _machines = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand SaveCommand { get; set; } + + public SiteDetailsViewVM() + { + SaveCommand = new RelayCommand(Save, () => IsFree); + } + + public async Task Init(String siteGuid, INotificationProvider notification, bool isNew, string newSiteName = null) + { + _notification = notification; + + _db = ObservablesContext.CreateDefault(); + Organizations = await _db.Organizations.ToListAsync(); + + if (isNew) + { + Site = new Site(); + Site.Name = newSiteName; + Site.Description = "My site description"; + _db.Sites.Add(Site); + } + else + { + Site = await _db.Sites.SingleOrDefaultAsync(x => x.Guid == siteGuid); + } + + Machines = await _db.Machines.Where(x => x.SiteGuid == Site.Guid).Include(x => x.Organization).ToListAsync(); + + var site_rmls = await _db.SitesRmls.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); + var site_catalogs = await _db.SitesCatalogs.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); + + var rmls = await _db.Rmls.OrderBy(x => x.Name).ToListAsync(); + var catalogs = await _db.ColorCatalogs.OrderBy(x => x.Name).ToListAsync(); + + Rmls = new SelectedObjectCollection(rmls.ToObservableCollection(), rmls.Where(rml => site_rmls.Exists(siteRml => siteRml.RmlGuid == rml.Guid)).ToObservableCollection()); + Catalogs = new SelectedObjectCollection(catalogs.ToObservableCollection(), catalogs.Where(catalog => site_catalogs.Exists(siteCatalog => siteCatalog.CatalogGuid == catalog.Guid)).ToObservableCollection()); + + SelectedOrganization = Organizations.SingleOrDefault(x => x.Guid == Site.OrganizationGuid); + } + + private async void Save() + { + try + { + Site.OrganizationGuid = SelectedOrganization?.Guid; + + if (!Site.Validate(_db)) + { + _notification.ShowError(String.Join("\n", Site.ValidationErrors)); + return; + } + + IsFree = false; + + using (_notification.PushTaskItem("Saving site details...")) + { + var site_rmls = await _db.SitesRmls.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); + var site_catalogs = await _db.SitesCatalogs.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); + + _db.SitesRmls.RemoveRange(site_rmls); + _db.SitesCatalogs.RemoveRange(site_catalogs); + + foreach (var selectedRml in Rmls.SynchedSource) + { + _db.SitesRmls.Add(new SitesRml() { SiteGuid = Site.Guid, RmlGuid = selectedRml.Guid }); + } + + foreach (var selectedCatalog in Catalogs.SynchedSource) + { + _db.SitesCatalogs.Add(new SitesCatalog() { SiteGuid = Site.Guid, CatalogGuid = selectedCatalog.Guid }); + } + + await _db.SaveChangesAsync(); + } + _db.Dispose(); + Saved?.Invoke(this, new EventArgs()); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving site details."); + _notification.ShowError($"Error saving site details.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml index 80f9ae151..4ca82c4f7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml @@ -7,9 +7,13 @@ xmlns:vm="clr-namespace:Tango.MachineStudio.Sites.ViewModels" xmlns:global="clr-namespace:Tango.MachineStudio.Sites" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - Comming soon... + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml.cs index 75ced5ae2..c4f9995ce 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml.cs @@ -12,17 +12,25 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Core.DI; +using Tango.MachineStudio.Sites.Contracts; namespace Tango.MachineStudio.Sites.Views { /// /// Interaction logic for MainView.xaml /// - public partial class MainView : UserControl + public partial class MainView : UserControl, IMainView { public MainView() { InitializeComponent(); + TangoIOC.Default.Register(this); + } + + public void NavigateTo(SitesNavigationView view) + { + navigationControl.NavigateTo(view.ToString()); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml new file mode 100644 index 000000000..b3496a5e2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PROPERTIES + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SITE RML + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml.cs new file mode 100644 index 000000000..03e9a2f75 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Sites.Views +{ + /// + /// Interaction logic for SiteDetailsView.xaml + /// + public partial class SiteDetailsView : UserControl + { + public SiteDetailsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml new file mode 100644 index 000000000..437003a8a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml.cs new file mode 100644 index 000000000..e6a4a6fe6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Sites.Views +{ + /// + /// Interaction logic for SitesView.xaml + /// + public partial class SitesView : UserControl + { + public SitesView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/app.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/app.config index 97a204217..7b82e5f7c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/app.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/app.config @@ -1,5 +1,9 @@  + + +
+ @@ -72,4 +76,10 @@ + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/packages.config index fd88f4804..e57143046 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/packages.config @@ -1,5 +1,6 @@  + diff --git a/Software/Visual_Studio/Tango.BL/Entities/Site.cs b/Software/Visual_Studio/Tango.BL/Entities/Site.cs index d88a00567..6e95aa39d 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Site.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Site.cs @@ -8,5 +8,41 @@ namespace Tango.BL.Entities { public class Site : SiteBase { + public override void Delete(ObservablesContext context) + { + base.Delete(context); + + var site_rmls = context.SitesRmls.Where(x => x.SiteGuid == Guid).ToList(); + var site_catalogs = context.SitesCatalogs.Where(x => x.SiteGuid == Guid).ToList(); + context.SitesRmls.RemoveRange(site_rmls); + context.SitesCatalogs.RemoveRange(site_catalogs); + context.Machines.Where(x => x.SiteGuid == Guid).ToList().ForEach(x => x.SiteGuid = null); + context.Sites.Remove(this); + } + + protected override void OnValidating(ObservablesContext context) + { + base.OnValidating(context); + + if (String.IsNullOrWhiteSpace(Name)) + { + InsertError(nameof(Name), "Site name is required"); + } + + if (Name != null && Name.Length > 100) + { + InsertError(nameof(Name), "The site name exceeds the maximum allowed characters."); + } + + if (Description != null && Description.Length > 200) + { + InsertError(nameof(Description), "The site description exceeds the maximum allowed characters."); + } + + if (OrganizationGuid == null) + { + InsertError(nameof(OrganizationGuid), "Site organization is required."); + } + } } } -- cgit v1.3.1 From 51151796efb23162ca0b3d6701d90dfb6d3baeb9 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 14 Dec 2019 22:33:55 +0200 Subject: Enabled transparent color for catalogs. Added machine last update check for quick db check PPC = >Service. Implemented AutoUpdateCheck vai PPC settings. Dropped use of AutoUpdateCheck from DB. Added skipping over TFP firmware upgrade upload if no other files other than mcu were found. Added more logs to firmware upgrade. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes .../Views/MachineSettingsView.xaml | 4 +- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 5 ++ .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 3 +- .../ViewModels/MainViewVM.cs | 10 ++++ .../Tango.PPC.MachineSettings/Views/MainView.xaml | 14 +++++ .../MachineUpdate/IMachineUpdateManager.cs | 2 +- .../MachineUpdate/MachineUpdateManager.cs | 19 ++++--- .../PPC/Tango.PPC.Common/PPCSettings.cs | 6 +++ .../Tango.PPC.Common/Web/CheckForUpdateRequest.cs | 1 + .../Printing/DefaultPrintingManager.cs | 2 +- .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 2 +- .../Tango.Integration/Operation/MachineOperator.cs | 60 +++++++++++++++++++-- .../Controllers/PPCController.cs | 7 ++- 15 files changed, 116 insertions(+), 19 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index a204a2664..a4ca7dd67 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 38b8da37b..13145f312 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml index 0a0c1ecef..4631ac068 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml @@ -62,8 +62,8 @@ Auto Login - Auto Check For Updates - + Setup Activation diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 798b333e7..785472d0d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -414,6 +414,11 @@ namespace Tango.PPC.Jobs.ViewModels Settings.SupportedColorSpaces.Count > 0 ? Settings.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x.IsUserSpace() || (ApplicationManager.IsInTechnicianMode && x == ColorSpaces.Volume)).ToList() ); + if (_catalogs.Count == 0) + { + vm.SupportedColorSpaces.Remove(ColorSpaces.Catalog); + } + CatalogSelectionViewVM catalogVM = new CatalogSelectionViewVM(_catalogs.ToList(), _catalogs.ToList().SingleOrDefault(x => x.Guid == settings.LastSelectedCatalogGuid)); if (settings.LastJobType != null) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 9b28d7709..97756ffd5 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -412,7 +412,6 @@ - @@ -422,7 +421,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs index d12617264..5077fd884 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs @@ -144,6 +144,13 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _synchronizeDiagnostics = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private bool _autoCheckForUpdates; + public bool AutoCheckForUpdates + { + get { return _autoCheckForUpdates; } + set { _autoCheckForUpdates = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -196,6 +203,7 @@ namespace Tango.PPC.MachineSettings.ViewModels Settings.DefaultSpoolTypeGuid = DefaultSpoolType?.Guid; Settings.SynchronizeJobs = SynchronizeJobs; Settings.SynchronizeDiagnostics = SynchronizeDiagnostics; + Settings.AutoCheckForUpdates = AutoCheckForUpdates; MachineDataSynchronizer.IsEnabled = SynchronizeJobs || SynchronizeDiagnostics; @@ -264,6 +272,8 @@ namespace Tango.PPC.MachineSettings.ViewModels SynchronizeJobs = Settings.SynchronizeJobs; SynchronizeDiagnostics = Settings.SynchronizeDiagnostics; + + AutoCheckForUpdates = Settings.AutoCheckForUpdates; } private async void OnEnableRemoteAssistanceChanged() diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 017649f8e..4a2f1e253 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -199,7 +199,21 @@ + + + Auto Update Check + + + + Automatically check for software and database updates. + + + + + + + Synchronize Jobs diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs index e11eab3a5..421b4ee54 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs @@ -20,7 +20,7 @@ namespace Tango.PPC.Common.MachineUpdate /// /// Gets or sets a value indicating whether to automatically check for new application updates. /// - bool AutoCheckForUpdates { get; set; } + bool EnableAutoCheckForUpdates { get; set; } /// /// Gets the current machine update progress status. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index 4c71c2a1a..088e80f61 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -41,6 +41,7 @@ namespace Tango.PPC.Common.MachineUpdate private List _logs; private System.Timers.Timer _checkForUpdateTimer; private bool _isUpdating; + private PPCSettings _settings; #region Events @@ -77,7 +78,7 @@ namespace Tango.PPC.Common.MachineUpdate /// /// Gets or sets a value indicating whether to automatically check for new application updates. /// - public bool AutoCheckForUpdates + public bool EnableAutoCheckForUpdates { get { return _autoCheckForUpdates; } set { _autoCheckForUpdates = value; RaisePropertyChangedAuto(); } @@ -105,6 +106,8 @@ namespace Tango.PPC.Common.MachineUpdate _checkForUpdateTimer = new System.Timers.Timer(TimeSpan.FromMinutes(1).TotalMilliseconds); _checkForUpdateTimer.Elapsed += _checkForUpdateTimer_Elapsed; _checkForUpdateTimer.Start(); + + _settings = SettingsManager.Default.GetOrCreate(); } #endregion @@ -421,7 +424,7 @@ namespace Tango.PPC.Common.MachineUpdate { _isUpdating = true; - var machineServiceAddress = SettingsManager.Default.GetOrCreate().GetMachineServiceAddress(); + var machineServiceAddress = _settings.GetMachineServiceAddress(); LogManager.Log($"Starting machine update for serial number {serialNumber}..."); @@ -688,7 +691,7 @@ namespace Tango.PPC.Common.MachineUpdate { _isUpdating = true; - var machineServiceAddress = SettingsManager.Default.GetOrCreate().GetMachineServiceAddress(); + var machineServiceAddress = _settings.GetMachineServiceAddress(); LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); @@ -702,6 +705,8 @@ namespace Tango.PPC.Common.MachineUpdate try { + request.MachineLastUpdated = _machineProvider.Machine.LastUpdated; + using (ObservablesContext db = ObservablesContext.CreateDefault()) { request.Rmls = db.Rmls.ToList().Select(x => new UpdatedEntity(x)).ToList(); @@ -861,7 +866,7 @@ namespace Tango.PPC.Common.MachineUpdate { return Task.Factory.StartNew(() => { - var machineServiceAddress = SettingsManager.Default.GetOrCreate().GetMachineServiceAddress(); + var machineServiceAddress = _settings.GetMachineServiceAddress(); LogManager.Log($"Checking if database update is required for serial number {serialNumber}..."); @@ -1042,7 +1047,7 @@ namespace Tango.PPC.Common.MachineUpdate throw new InvalidOperationException("The specified tup file is invalid. The package was generated for a different machine."); } - if (publishInfo.MachineDeploymentSlot != SettingsManager.Default.GetOrCreate().DeploymentSlot) + if (publishInfo.MachineDeploymentSlot != _settings.DeploymentSlot) { throw new InvalidOperationException("The specified tup file is invalid. The package was generated on a different environment."); } @@ -1292,7 +1297,7 @@ namespace Tango.PPC.Common.MachineUpdate String packagesFolder = Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), "packages"); Version previousVersion = null; - String str = SettingsManager.Default.GetOrCreate().PreviousApplicationVersion; + String str = _settings.PreviousApplicationVersion; if (Version.TryParse(str, out previousVersion)) { @@ -1333,7 +1338,7 @@ namespace Tango.PPC.Common.MachineUpdate private async void _checkForUpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { - if (AutoCheckForUpdates && !_isUpdating) + if (EnableAutoCheckForUpdates && _settings.AutoCheckForUpdates && !_isUpdating) { _checkForUpdateTimer.Stop(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index acdfb6a8a..cb17f5be3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -214,6 +214,11 @@ namespace Tango.PPC.Common /// public TimeSpan PowerUpScreenTimeout { get; set; } + /// + /// Gets or sets a value indicating whether to automatically check for software and database (quick) updates. + /// + public bool AutoCheckForUpdates { get; set; } + /// /// Gets the machine service address. /// @@ -255,6 +260,7 @@ namespace Tango.PPC.Common FirmwareVersion = "1.0.0.0"; DisplayPowerUpScreen = true; PowerUpScreenTimeout = TimeSpan.FromSeconds(20); + AutoCheckForUpdates = true; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs index 0feb32aaf..3d606b918 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs @@ -15,6 +15,7 @@ namespace Tango.PPC.Common.Web public List Rmls { get; set; } public List HardwareVersions { get; set; } public List Catalogs { get; set; } + public DateTime MachineLastUpdated { get; set; } public CheckForUpdateRequest() { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs index 56ec2fa7e..4c5a87ab4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -259,7 +259,7 @@ namespace Tango.PPC.UI.Printing { throw new InvalidOperationException("Error starting job. Color is out of range."); } - if (job.Segments.SelectMany(x => x.BrushStops).Any(x => x.BrushColorSpace == ColorSpaces.Catalog && x.ColorCatalogsItem == null)) + if (job.Segments.SelectMany(x => x.BrushStops).Any(x => x.BrushColorSpace == ColorSpaces.Catalog && x.ColorCatalogsItem == null && !x.IsTransparent)) { throw new InvalidOperationException("Error starting job. Please select a catalog color."); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index c0654f643..49b2aef89 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -297,7 +297,7 @@ namespace Tango.PPC.UI.ViewModels } else { - MachineUpdateManager.AutoCheckForUpdates = MachineProvider.Machine.AutoCheckForUpdates; + MachineUpdateManager.EnableAutoCheckForUpdates = true; } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index a96693bdf..bae0ec55e 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -1753,10 +1753,14 @@ namespace Tango.Integration.Operation liquidVolume.Volume = stop.ColorCatalogsItem.Black; } } - else + else if (!stop.IsTransparent) { throw new InvalidOperationException($"No catalog item specified for segment color."); } + else + { + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + } } else if (stop.BrushColorSpace == ColorSpaces.Volume) { @@ -2911,33 +2915,46 @@ namespace Tango.Integration.Operation try { + LogManager.Log("Starting firmware upgrade..."); + LogManager.Log($"Firmware upgrade flags: {String.Join(", ", FirmwareUpgradeMode.GetFlags().Select(x => x.ToString()))}"); + if (Status != MachineStatuses.ReadyToDye) { throw LogManager.Log(new InvalidOperationException($"Could not perform firmware upgrade while operator status is '{Status}'.")); } + LogManager.Log("Extracting tfp package..."); var package_info = await GetFirmwarePackageInfo(tfpStream); tfpStream.Position = 0; + LogManager.Log("Reading zip stream..."); zip = ZipFile.Read(tfpStream); + LogManager.Log("Creating storage manager..."); var storage = CreateStorageManager(); + LogManager.Log("Getting storage drive information..."); var drive = await storage.GetStorageDrive(); + LogManager.Log($"Storage drive info:\n{drive.ToJsonString()}"); + LogManager.Log("Getting root folder..."); var root = await storage.GetRootFolder(); + LogManager.Log($"Root folder: '{root.Path}'"); var existing_folder = root.Items.SingleOrDefault(x => x.Name == FIRMWARE_UPGRADE_FOLDER_NAME); if (existing_folder != null) { + LogManager.Log("Root folder exists. Deleting..."); await storage.DeleteItem(existing_folder); } String package_folder = Path.Combine(drive.Root, FIRMWARE_UPGRADE_FOLDER_NAME); + LogManager.Log($"Creating new folder: '{package_folder}'."); await storage.CreateFolder(package_folder); List handlers = new List(); List entries = zip.Entries.ToList(); List streams = new List(); + LogManager.Log("Disabling keep alive..."); var keepAlive = UseKeepAlive; UseKeepAlive = false; @@ -2960,7 +2977,19 @@ namespace Tango.Integration.Operation { if (FirmwareUpgradeMode.HasFlag(FirmwareUpgradeModes.DFU)) { - var mcuEntry = zip.Entries.Single(x => x.FileName == package_info.FileDescriptors.Single(y => y.Destination == VersionFileDestination.Mcu).FileName); + LogManager.Log("DFU enabled. Starting upgrade via DFU..."); + LogManager.Log("Extracting MCU file..."); + ZipEntry mcuEntry = null; + try + { + mcuEntry = zip.Entries.Single(x => x.FileName == package_info.FileDescriptors.Single(y => y.Destination == VersionFileDestination.Mcu).FileName); + } + catch (Exception ex) + { + upgradeHandler.RaiseFailed(new IOException("Firmware upgrade via DFU is enabled but no MCU file was found in the package.", ex)); + return; + } + MemoryStream ms = new MemoryStream(); mcuEntry.Extract(ms); ms.Position = 0; @@ -2974,35 +3003,52 @@ namespace Tango.Integration.Operation upgradeHandler.RaiseProgress((long)e.Progress, FirmwareUpgradeStatus.Upgrading, e.State.ToDescription()); }; + LogManager.Log("Disconnecting adapter..."); Adapter.Disconnect().Wait(); if (MachineEventsStateProvider != null) { + LogManager.Log("Resetting active events..."); MachineEventsStateProvider.Reset(); } + LogManager.Log("Upgrading..."); upgradeManager.PerformUpgrade(data).Wait(); + LogManager.Log("Waiting for the device..."); upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Waiting for the device..."); Thread.Sleep(5000); + LogManager.Log("Reconnecting adapter..."); upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Connecting..."); Adapter.Connect().Wait(); Connect().Wait(); + LogManager.Log("Connected..."); upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Connected."); Thread.Sleep(2000); + LogManager.Log("Waiting..."); upgradeHandler.RaiseProgress(100, FirmwareUpgradeStatus.Upgrading, "Waiting..."); Thread.Sleep(2000); Status = MachineStatuses.Upgrading; } + //Upload tfp package only if specified in flag && package info contains more files other than the mcu bin file. if (FirmwareUpgradeMode.HasFlag(FirmwareUpgradeModes.TFP_PACKAGE)) { - upgradeHandler.Total = zip.Entries.Sum(x => x.UncompressedSize); - uploadNext(); + if (package_info.FileDescriptors.Where(x => x.Destination != VersionFileDestination.Mcu).Count() > 0) + { + LogManager.Log("TFP package is enabled. Starting upload..."); + upgradeHandler.Total = zip.Entries.Sum(x => x.UncompressedSize); + uploadNext(); + } + else + { + LogManager.Log("TFP package is enabled but no other files other than the MCU file were found on the package. Skipping..."); + postActivation(); + } } else { @@ -3026,6 +3072,8 @@ namespace Tango.Integration.Operation var entry = entries.First(); entries.Remove(entry); + LogManager.Log($"Uploading file '{entry.FileName}'..."); + var reader = entry.OpenReader(); streams.Add(reader); @@ -3061,6 +3109,7 @@ namespace Tango.Integration.Operation { try { + LogManager.Log("Validating version..."); streams.ForEach(x => x.Dispose()); upgradeHandler.RaiseProgress(upgradeHandler.Total, FirmwareUpgradeStatus.Validating, "Validating version..."); var validateRequest = new ValidateVersionRequest(); @@ -3078,6 +3127,7 @@ namespace Tango.Integration.Operation { try { + LogManager.Log("Activating version..."); upgradeHandler.RaiseProgress(upgradeHandler.Total, FirmwareUpgradeStatus.Activating, "Activating version..."); var activateRequest = new ActivateVersionRequest(); activateRequest.Path = package_folder; @@ -3092,8 +3142,10 @@ namespace Tango.Integration.Operation postActivation = new Action(() => { + LogManager.Log("Firmware upgrade completed."); upgradeHandler.RaiseCompleted(); Status = MachineStatuses.ReadyToDye; + LogManager.Log("Enabling keep alive..."); UseKeepAlive = keepAlive; }); diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index b2a1da980..77b3a180f 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -322,7 +322,12 @@ namespace Tango.MachineService.Controllers bool hasDatabaseUpdates = false; - hasDatabaseUpdates = rmls.Exists(x => request.Rmls.Exists(y => x.Guid == y.Guid && x.LastUpdated > y.LastUpdated) || !request.Rmls.Exists(y => x.Guid == y.Guid)); + hasDatabaseUpdates = machine.LastUpdated > request.MachineLastUpdated; + + if (!hasDatabaseUpdates) + { + hasDatabaseUpdates = rmls.Exists(x => request.Rmls.Exists(y => x.Guid == y.Guid && x.LastUpdated > y.LastUpdated) || !request.Rmls.Exists(y => x.Guid == y.Guid)); + } if (!hasDatabaseUpdates) { -- cgit v1.3.1