From a4761335999936b8e1bd0091861b3b08ad3f6343 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 20 Jan 2020 13:11:40 +0200 Subject: Fixed main menu style. Fixed issues with machine prototype creation. Implemented "make prototype". --- .../ViewModels/MainViewVM.cs | 73 ++++++++++++++++++++-- 1 file changed, 69 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs') 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 7b6ae7ef0..8b0401dc7 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 @@ -228,6 +228,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// public RelayCommand ResetDeviceRegistrationCommand { get; set; } + /// + /// Gets or sets the make prototype command. + /// + public RelayCommand MakePrototypeCommand { get; set; } + #endregion #region Constructors @@ -261,6 +266,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null); CloneMachineCommand = new RelayCommand(CloneMachine, () => SelectedMachine != null); ResetDeviceRegistrationCommand = new RelayCommand(ResetDeviceRegistration); + MakePrototypeCommand = new RelayCommand(MakePrototype); MachineUpdatesViewVM = new MachineUpdatesViewVM(_notification); TupViewVM = new TupViewVM(_notification); @@ -470,6 +476,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachineAdapter.MachineVersions = (await ActiveMachineAdapter.Context.MachineVersions.ToListAsync()).ToObservableCollection(); ActiveMachineAdapter.Organizations = (await ActiveMachineAdapter.Context.Organizations.ToListAsync()).ToObservableCollection(); + bool initHwConfig = true; + if (!newMachine) { ActiveMachine = (await new MachineBuilder(ActiveMachineAdapter.Context).Set(SelectedMachine.Guid).WithOrganization().WithConfiguration().WithSpools().BuildAsync()); @@ -500,8 +508,22 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } else { - ActiveMachine = selectedVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); - ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + try + { + initHwConfig = false; + ActiveMachine = selectedVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); + ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + + HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); + var version = await new HardwareVersionBuilder(ActiveMachineAdapter.Context).Set(ActiveMachine.Configuration.HardwareVersionGuid).WithHardwareComponents().BuildAsync(); + HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + } + catch (Exception ex) + { + _notification.ShowError($"Invalid machine version prototype.\n{ex.FlattenMessage()}"); + View.NavigateTo(MachineDesignerNavigationView.MachinesView); + return; + } } } @@ -516,8 +538,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels SelectedRML = ActiveMachineAdapter.Rmls.FirstOrDefault(), }; - HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); - HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + if (initHwConfig) + { + HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); + HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + } await MachineUpdatesViewVM.Init(ActiveMachine, ActiveMachineAdapter.Context); TupViewVM.Init(ActiveMachine); @@ -549,6 +574,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { try { + if (HardwareConfigurationViewVM == null) + { + HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); + } + version = await new HardwareVersionBuilder(ActiveMachineAdapter.Context).Set(version.Guid).WithHardwareComponents().BuildAsync(); HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); } @@ -775,6 +805,41 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + private async void MakePrototype() + { + if (ActiveMachine.MachineVersion == null) + { + _notification.ShowError("Machine version must be selected in order to make a prototype."); + return; + } + + if (_notification.ShowQuestion($"Are you sure you wish to make this machine configuration as a prototype for version '{ActiveMachine.MachineVersion.Name}' ?")) + { + using (_notification.PushTaskItem($"Making prototype machine for '{ActiveMachine.MachineVersion.Name}'...")) + { + try + { + IsFree = false; + + using (var db = ObservablesContext.CreateDefault()) + { + var machineVersion = await db.MachineVersions.SingleOrDefaultAsync(x => x.Guid == ActiveMachine.MachineVersionGuid); + await machineVersion.ApplyPrototypeMachine(ActiveMachine, db); + await db.SaveChangesAsync(); + } + } + catch (Exception ex) + { + _notification.ShowError($"Error making machine version prototype\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + } + } + #endregion private void CloneMachine() -- cgit v1.3.1 From 2dce6d8d825850b942d8065877bdc2d3af9cf499 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 21 Jan 2020 17:27:52 +0200 Subject: Implemented new machine clone and creation. Implemented auto dispenser generation. --- .../ViewModels/MachineCreationDialogVM.cs | 45 +++++++++ .../ViewModels/MainViewVM.cs | 101 ++++++++++++++++++--- .../Views/MachineCreationDialog.xaml | 47 ++++++++-- .../Views/MachineDetailsView.xaml | 12 ++- .../Tango.BL/Entities/MachineVersion.cs | 6 +- 5 files changed, 187 insertions(+), 24 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs index 0f6ab3314..4584d3508 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs @@ -13,5 +13,50 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public List MachineVersions { get; set; } public MachineVersion SelectedMachineVersion { get; set; } + + private bool _isNewMachine; + public bool IsNewMachine + { + get { return _isNewMachine; } + set { _isNewMachine = value; RaisePropertyChangedAuto(); } + } + + private String _serialNumber; + public String SerialNumber + { + get { return _serialNumber; } + set { _serialNumber = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private String _name; + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private bool _generateDispensers; + public bool GenerateDispensers + { + get { return _generateDispensers; } + set { _generateDispensers = value; RaisePropertyChangedAuto(); } + } + + private double _dispenserFactor; + public double DispenserFactor + { + get { return _dispenserFactor; } + set { _dispenserFactor = value; RaisePropertyChangedAuto(); } + } + + public MachineCreationDialogVM() : base() + { + DispenserFactor = 2.34; + } + + protected override bool CanOK() + { + return base.CanOK() && !String.IsNullOrWhiteSpace(SerialNumber) && !String.IsNullOrWhiteSpace(Name); + } } } 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 8b0401dc7..1bd790eb6 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 @@ -39,10 +39,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private ActionTimer _machines_action_timer; private ActionTimer _dispensers_action_timer; private MachineDTO _machineBeforeSave; - private bool _isNewMachine; #region Properties + private bool _isNewMachine; + public bool IsNewMachine + { + get { return _isNewMachine; } + set { _isNewMachine = value; RaisePropertyChangedAuto(); } + } + private ObservablesStaticCollections _machinesAdapter; public ObservablesStaticCollections MachinesAdapter { @@ -441,9 +447,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels InvalidateRelayCommands(); } - private async void LoadSelectedMachine(bool newMachine = false, bool clone = false, MachineVersion selectedVersion = null) + private async void LoadSelectedMachine(bool newMachine = false, bool clone = false, MachineCreationDialogVM machineCreationDialogVM = null) { - _isNewMachine = false; + IsNewMachine = false; using (_notification.PushTaskItem("Loading machine details...")) { @@ -478,6 +484,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels bool initHwConfig = true; + Configuration machineConfigBeforeClone = null; + if (!newMachine) { ActiveMachine = (await new MachineBuilder(ActiveMachineAdapter.Context).Set(SelectedMachine.Guid).WithOrganization().WithConfiguration().WithSpools().BuildAsync()); @@ -486,10 +494,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels if (clone) { - _isNewMachine = true; + machineConfigBeforeClone = ActiveMachine.Configuration; + + IsNewMachine = true; ActiveMachine = ActiveMachine.Clone(); - ActiveMachine.Name = ""; - ActiveMachine.SerialNumber = ""; + ActiveMachine.Name = machineCreationDialogVM.Name; + ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber; ActiveMachine.IsDeviceRegistered = false; ActiveMachine.DeviceId = null; ActiveMachine.DeviceName = null; @@ -498,12 +508,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } else { - _isNewMachine = true; + IsNewMachine = true; - if (selectedVersion == null) + if (machineCreationDialogVM.SelectedMachineVersion == null) { ActiveMachine = new Machine(); ActiveMachine.Configuration = new Configuration(); + ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber; + ActiveMachine.Name = machineCreationDialogVM.Name; ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); } else @@ -511,7 +523,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels try { initHwConfig = false; - ActiveMachine = selectedVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); + ActiveMachine = machineCreationDialogVM.SelectedMachineVersion.CreatePrototypeMachine(ActiveMachineAdapter.Context); + ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber; + ActiveMachine.Name = machineCreationDialogVM.Name; ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); @@ -527,6 +541,47 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + if ((newMachine || clone) && machineCreationDialogVM.GenerateDispensers) + { + for (int i = 0; i < 8; i++) + { + Dispenser dispenser = new Dispenser(); + dispenser.SerialNumber = machineCreationDialogVM.SerialNumber + "-" + (i + 1); + + if (newMachine) + { + dispenser.NlPerPulse = machineCreationDialogVM.DispenserFactor; + dispenser.DispenserTypeGuid = ActiveMachineAdapter.DispenserTypes.First().Guid; + } + else + { + var packBefore = machineConfigBeforeClone.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == i); + + if (packBefore != null) + { + dispenser.NlPerPulse = packBefore.Dispenser.NlPerPulse; + dispenser.DispenserTypeGuid = packBefore.Dispenser.DispenserType.Guid; + } + else + { + continue; + } + } + + dispenser.ProductionDate = DateTime.UtcNow; + + ActiveMachineAdapter.Context.Dispensers.Add(dispenser); + + var idsPack = ActiveMachine.Configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == i); + + if (idsPack != null) + { + idsPack.Dispenser = dispenser; + idsPack.DispenserGuid = dispenser.Guid; + } + } + } + Sites = await ActiveMachineAdapter.Context.Sites.ToListAsync(); Sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid); @@ -722,7 +777,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.Configuration.SetHardwareConfiguration(hwConfig); await ActiveMachineAdapter.Context.SaveChangesAsync(); - if (_isNewMachine) + if (IsNewMachine) { _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.MachineCreated, _authentication.CurrentUser, ActiveMachine.Name, ActiveMachine, "New machine created using Machine Studio."); } @@ -756,16 +811,23 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private void AddNewMachine() { MachineCreationDialogVM vm = new MachineCreationDialogVM(); + vm.IsNewMachine = true; vm.MachineVersions = MachinesAdapter.MachineVersions.ToList(); _notification.ShowModalDialog(vm, (x) => { + if (MachinesAdapter.Context.Machines.Any(y => y.SerialNumber == vm.SerialNumber || y.Name.ToLower() == vm.Name.ToLower())) + { + _notification.ShowError("Machine serial number or name already exists."); + return; + } + if (vm.SelectedMachineVersion != null && String.IsNullOrWhiteSpace(vm.SelectedMachineVersion.PrototypeMachineData)) { _notification.ShowError("The selected version does not contain any prototype machine data."); return; } - LoadSelectedMachine(true, false, vm.SelectedMachineVersion); + LoadSelectedMachine(true, false, vm); }, () => { }); } @@ -779,8 +841,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { IsFree = false; await SelectedMachine.DeleteCascadeAsync(MachinesAdapter.Context); - MachinesAdapter.Context.Machines.Remove(SelectedMachine); _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.MachineDeleted, _authentication.CurrentUser, SelectedMachine.Name, SelectedMachine, "Machine deleted using Machine Studio."); + MachinesAdapter.Context.Machines.Remove(SelectedMachine); + MachinesAdapter.Machines.Remove(SelectedMachine); } catch (Exception ex) { @@ -844,7 +907,19 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private void CloneMachine() { - LoadSelectedMachine(false, true); + MachineCreationDialogVM vm = new MachineCreationDialogVM(); + vm.IsNewMachine = false; + vm.MachineVersions = MachinesAdapter.MachineVersions.ToList(); + _notification.ShowModalDialog(vm, (x) => + { + if (MachinesAdapter.Context.Machines.Any(y => y.SerialNumber == vm.SerialNumber || y.Name.ToLower() == vm.Name.ToLower())) + { + _notification.ShowError("Machine serial number or name already exists."); + return; + } + + LoadSelectedMachine(false, true, vm); + }, () => { }); } private void AddNewSpool() diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml index 2d380c0d2..417dfbc0b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml @@ -6,9 +6,15 @@ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" mc:Ignorable="d" - d:DesignHeight="400" d:DesignWidth="700" Height="400" Width="700" Background="{StaticResource WhiteBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:MachineCreationDialogVM, IsDesignTimeCreatable=False}"> + d:DesignHeight="400" d:DesignWidth="700" Height="460" Width="750" Background="{StaticResource WhiteBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:MachineCreationDialogVM, IsDesignTimeCreatable=False}"> + + + + + @@ -17,7 +23,18 @@ - NEW MACHINE + + + + + @@ -33,12 +50,30 @@ - - - Please specify the machine version in order to prototype the new machine with default machine settings and configuartion. + + + Please specify the machine version in order to prototype the new machine with default machine settings and configuration. - + + + Serial Number + + + Name + + + + + Automatically generate 8 dispensers for this machine + (-1-8) + + + + + Dispenser max nl/cm + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml index b3cef3083..b2b770698 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml @@ -5,11 +5,17 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" xmlns:global="clr-namespace:Tango.MachineStudio.MachineDesigner" - xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" 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}"> + + + + + @@ -61,10 +67,10 @@ - + - + diff --git a/Software/Visual_Studio/Tango.BL/Entities/MachineVersion.cs b/Software/Visual_Studio/Tango.BL/Entities/MachineVersion.cs index f9975cf32..3f386beb2 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/MachineVersion.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/MachineVersion.cs @@ -34,7 +34,8 @@ namespace Tango.BL.Entities .Ignore(() => machine.LoadedRmlGuid) .Ignore(() => machine.DeviceId) .Ignore(() => machine.DeviceName) - .Ignore(() => machine.IsDeviceRegistered), + .Ignore(() => machine.IsDeviceRegistered) + .Ignore(() => machine.SiteGuid), EntitySerializationFlags.IgnoreGuids | EntitySerializationFlags.IgnoreReferenceTypes); } @@ -56,7 +57,8 @@ namespace Tango.BL.Entities .Ignore(() => m.LoadedRmlGuid) .Ignore(() => m.DeviceId) .Ignore(() => m.DeviceName) - .Ignore(() => m.IsDeviceRegistered), + .Ignore(() => m.IsDeviceRegistered) + .Ignore(() => m.SiteGuid), EntitySerializationFlags.IgnoreGuids | EntitySerializationFlags.IgnoreReferenceTypes); -- cgit v1.3.1 From 287af6d4bed5333087cb9d702d20035b1ad9a326 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 22 Jan 2020 16:38:48 +0200 Subject: Implemented team viewer join group. Prevent multiple power up dialogs from showing. Implement auto available dispenser assignment for machine creation. Sorting for machines and dispensers in Machine designer. Implemented new PPC factory reset with team viewer and device name change. Fixed "Exit To Shell" to open real explorer. Redesigned restarting system view. Updated power off animation. Updated loading animation. --- .../ViewModels/MachineUpdatesViewVM.cs | 2 + .../ViewModels/MainViewVM.cs | 60 +++++++++++++++------ .../Views/MainView.xaml | 2 +- .../ViewModels/SystemViewVM.cs | 37 +++++++++---- .../MachineSetup/MachineSetupManager.cs | 37 ++++++++----- .../OS/DefaultOperationSystemManager.cs | 22 ++++++++ .../Tango.PPC.Common/OS/IOperationSystemManager.cs | 11 ++++ .../DefaultRemoteAssistanceProvider.cs | 31 ++++++----- .../RemoteAssistance/IRemoteAssistanceProvider.cs | 3 +- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 2 +- .../Tango.PPC.Common/Web/MachineSetupResponse.cs | 1 + .../PPC/Tango.PPC.UI/Images/loading_anim.gif | Bin 0 -> 798338 bytes .../PPC/Tango.PPC.UI/Images/power_off_2.gif | Bin 0 -> 32040 bytes .../PPCApplication/DefaultPPCApplicationManager.cs | 2 +- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 4 +- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 9 ++++ .../PPC/Tango.PPC.UI/Views/LoadingView.xaml | 11 ++-- .../PPC/Tango.PPC.UI/Views/MachineSetupView.xaml | 2 +- .../PPC/Tango.PPC.UI/Views/PowerOffView.xaml | 2 +- .../Tango.PPC.UI/Views/RestartingSystemView.xaml | 40 ++++++++++---- .../Tango.BL/ObservablesStaticCollections.cs | 40 +++++++------- .../Controllers/PPCController.cs | 3 +- 22 files changed, 224 insertions(+), 97 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/loading_anim.gif create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/power_off_2.gif (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs index 41bcc2a87..616ad0a47 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs @@ -110,6 +110,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels DisplayMachineSetups = true; DisplayDatabaseUpdates = true; DisplaySynchronizations = true; + DisplayOfflineUpdates = true; + DisplayFirmwareUpgrades = true; RefreshCommand = new RelayCommand(Refresh, () => IsFree); } 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 1bd790eb6..bd08e3e7c 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 @@ -298,7 +298,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { Task.Factory.StartNew(() => { - ActiveMachineAdapter.Dispensers = ActiveMachineAdapter.Context.Dispensers.Where(x => x.SerialNumber.ToLower().StartsWith(DispensersFilter.ToLower())).ToSynchronizedObservableCollection(); + ActiveMachineAdapter.Dispensers = ActiveMachineAdapter.Context.Dispensers.Where(x => x.SerialNumber.ToLower().StartsWith(DispensersFilter.ToLower())).OrderBy(x => x.SerialNumber).ToSynchronizedObservableCollection(); }); }); } @@ -545,32 +545,60 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { for (int i = 0; i < 8; i++) { - Dispenser dispenser = new Dispenser(); - dispenser.SerialNumber = machineCreationDialogVM.SerialNumber + "-" + (i + 1); + var serial = machineCreationDialogVM.SerialNumber + "-" + (i + 1); + + var existingDispenser = await ActiveMachineAdapter.Context.Dispensers.Include(x => x.IdsPacks).SingleAsync(x => x.SerialNumber == serial); - if (newMachine) + if (existingDispenser != null) { - dispenser.NlPerPulse = machineCreationDialogVM.DispenserFactor; - dispenser.DispenserTypeGuid = ActiveMachineAdapter.DispenserTypes.First().Guid; + if (existingDispenser.IsInstalled) + { + _notification.ShowError($"Dispenser '{serial}' already exists. Cannot create machine."); + return; + } + else + { + if (!_notification.ShowErrorQuestion($"Dispenser '{serial}' already exists and is not installed. Do you wish to assign the existing dispenser to this machine?")) + { + return; + } + } } - else + + Dispenser dispenser = new Dispenser(); + + if (existingDispenser == null) { - var packBefore = machineConfigBeforeClone.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == i); + dispenser.SerialNumber = serial; - if (packBefore != null) + if (newMachine) { - dispenser.NlPerPulse = packBefore.Dispenser.NlPerPulse; - dispenser.DispenserTypeGuid = packBefore.Dispenser.DispenserType.Guid; + dispenser.NlPerPulse = machineCreationDialogVM.DispenserFactor; + dispenser.DispenserTypeGuid = ActiveMachineAdapter.DispenserTypes.First().Guid; } else { - continue; + var packBefore = machineConfigBeforeClone.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == i); + + if (packBefore != null) + { + dispenser.NlPerPulse = packBefore.Dispenser.NlPerPulse; + dispenser.DispenserTypeGuid = packBefore.Dispenser.DispenserType.Guid; + } + else + { + continue; + } } - } - dispenser.ProductionDate = DateTime.UtcNow; + dispenser.ProductionDate = DateTime.UtcNow; - ActiveMachineAdapter.Context.Dispensers.Add(dispenser); + ActiveMachineAdapter.Context.Dispensers.Add(dispenser); + } + else + { + dispenser = existingDispenser; + } var idsPack = ActiveMachine.Configuration.NoneEmptyIdsPacks.SingleOrDefault(x => x.PackIndex == i); @@ -950,7 +978,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels try { IsFree = false; - MachinesAdapter.Machines = MachinesAdapter.Context.Machines.Where(x => x.SerialNumber.StartsWith(Filter)).Include(x => x.Organization).Include(x => x.MachineVersion).ToSynchronizedObservableCollection(); + MachinesAdapter.Machines = MachinesAdapter.Context.Machines.Where(x => x.SerialNumber.StartsWith(Filter)).Include(x => x.Organization).Include(x => x.MachineVersion).OrderBy(x => x.SerialNumber).ToSynchronizedObservableCollection(); } catch { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml index bc9b038dc..833086bf0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml @@ -9,7 +9,7 @@ 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}"> - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs index f3ffcda14..e0b8d278b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/SystemViewVM.cs @@ -14,12 +14,14 @@ using Tango.PPC.Common; using Tango.PPC.Common.OS; using Tango.Settings; using System.Data.Entity; +using Tango.PPC.Common.UWF; namespace Tango.PPC.Technician.ViewModels { public class SystemViewVM : PPCViewModel { private IOperationSystemManager _os; + private IUnifiedWriteFilterManager _uwf; private Timer _statsTimer; private bool _resettingDevice; @@ -82,9 +84,10 @@ namespace Tango.PPC.Technician.ViewModels public RelayCommand ExitToExplorerCommand { get; set; } - public SystemViewVM(IOperationSystemManager os) + public SystemViewVM(IOperationSystemManager os, IUnifiedWriteFilterManager uwf) { _os = os; + _uwf = uwf; CPU = 0; RAM = 0; @@ -118,11 +121,30 @@ namespace Tango.PPC.Technician.ViewModels private async void FactoryReset() { - if (await NotificationProvider.ShowQuestion("Are you sure you want to reset this device and back to factory settings?")) + if (await NotificationProvider.ShowQuestion("Are you sure you want to reset this device back to factory settings?")) { Settings.ApplicationState = ApplicationStates.FactoryRestore; Settings.Save(); - ApplicationManager.Restart(); + try + { + NotificationProvider.SetGlobalBusyMessage("Disabling write filter protection..."); + await _uwf.Disable(); + await Task.Delay(2000); + NotificationProvider.ReleaseGlobalBusyMessage(); + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.RestartingSystemView); + await Task.Delay(4000); + _os.Restart(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error executing factory reset."); + NotificationProvider.ReleaseGlobalBusyMessage(); + await NotificationProvider.ShowError($"Error executing factory reset.\n{ex.FlattenMessage()}"); + } + finally + { + NotificationProvider.ReleaseGlobalBusyMessage(); + } } } @@ -138,6 +160,8 @@ namespace Tango.PPC.Technician.ViewModels { if (await NotificationProvider.ShowQuestion("Are you sure you want to restart the device?")) { + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.RestartingSystemView); + await Task.Delay(4000); _os.Restart(); } } @@ -146,12 +170,7 @@ namespace Tango.PPC.Technician.ViewModels { if (await NotificationProvider.ShowQuestion("Close the application and start OS shell?")) { - Process.Start(new ProcessStartInfo() - { - UseShellExecute = true, - FileName = "explorer.exe", - }); - + _os.OpenShell(); ApplicationManager.ShutDown(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 29daedb4c..2177efecc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -235,10 +235,21 @@ namespace Tango.PPC.Common.MachineSetup Login(serialNumber).Wait(); + String deviceName = $"Tango-{serialNumber}-{settings.DeploymentSlot.ToString()}"; + LogManager.Log($"Settings device name: '{deviceName}'..."); + try + { + await _windows_manager.SetDeviceName(deviceName); + } + catch + { + throw new IOException("Error setting device name."); + } + MachineSetupRequest request = new MachineSetupRequest(); request.SerialNumber = serialNumber; request.DeviceID = await _windows_manager.GetDeviceId(); - request.DeviceName = await _windows_manager.GetDeviceName(); + request.DeviceName = deviceName; try { @@ -278,20 +289,20 @@ namespace Tango.PPC.Common.MachineSetup UpdateProgress("Activating operation system license", "Activating..."); await _windows_manager.Activate(setup_response.OSKey); } + } - if (setup_response.SetupRemoteAssistance) - { - LogManager.Log("Installing remote assistance..."); - UpdateProgress("Installing remote assistance", "Installing..."); - await _remoteAssistance.InstallRemoteAssistance(serialNumber, settings.DeploymentSlot.ToString()); - } + if (setup_response.SetupRemoteAssistance) + { + LogManager.Log("Installing remote assistance..."); + UpdateProgress("Installing remote assistance", "Installing..."); + await _remoteAssistance.InstallRemoteAssistance(serialNumber, setup_response.Organization, settings.DeploymentSlot.ToString()); + } - if (setup_response.SetupUWF) - { - LogManager.Log("Activating unified write filter..."); - UpdateProgress("Activating disk protection", "Activating..."); - await _uwf.Setup(); - } + if (setup_response.SetupUWF) + { + LogManager.Log("Activating unified write filter..."); + UpdateProgress("Activating disk protection", "Activating..."); + await _uwf.Setup(); } //Create temporary folders for packages. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs index 2164a71c3..32fd74646 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -232,5 +232,27 @@ namespace Tango.PPC.Common.OS return Environment.MachineName; }); } + + /// + /// Sets the device host name. + /// + /// + public async Task SetDeviceName(String name) + { + var command = new CmdCommand("wmic", $"computersystem where caption='{Environment.MachineName}' rename '{name}'"); + await command.Run(); + } + + /// + /// Opens the operating system shell (explorer). + /// + public void OpenShell() + { + Process.Start(new ProcessStartInfo() + { + FileName = @"C:\Windows\Sysnative\cmd.exe", + Arguments = @"/c start /B explorer.exe" + }); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs index 3e24ffe72..4faef33f9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/IOperationSystemManager.cs @@ -56,6 +56,12 @@ namespace Tango.PPC.Common.OS /// Task GetDeviceName(); + /// + /// Sets the device host name. + /// + /// + Task SetDeviceName(String name); + /// /// Restarts the system. /// @@ -67,5 +73,10 @@ namespace Tango.PPC.Common.OS /// /// void Shutdown(); + + /// + /// Opens the operating system shell (explorer). + /// + void OpenShell(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs index 65327e705..c266ba7c0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs @@ -96,8 +96,12 @@ namespace Tango.PPC.Common.RemoteAssistance /// Installs the remote assistance. /// /// The machine serial number. + /// The remote assistance group. + /// The machine working environment. /// - public async Task InstallRemoteAssistance(String machineSerialNumber, String environment) + /// + /// The remote assistance service was installed but could not be found. + public async Task InstallRemoteAssistance(String machineSerialNumber, String group, String environment) { try { @@ -106,26 +110,21 @@ namespace Tango.PPC.Common.RemoteAssistance throw new FileNotFoundException($"The remote assistance installer file could not be found at {_installer_path}."); } - if (!(await IsRemoteAssistanceInstalled())) - { - CmdCommand command = new CmdCommand("msiexec.exe", $"/i \"{_installer_path}\" /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS=\" --reassign --alias {"TANGO-" + machineSerialNumber}-{environment} --grant-easy-access\""); - command.Timeout = TimeSpan.FromSeconds(30); - await command.Run(); + String q = "\""; + //CmdCommand command = new CmdCommand("msiexec.exe", $"/i \"{_installer_path}\" /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS=\" --reassign --alias {"TANGO-" + machineSerialNumber}-{environment} --grant-easy-access\""); + CmdCommand command = new CmdCommand("msiexec.exe", $"/i {q}{_installer_path}{q} /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS={q} --group {q}{q} {group} {q}{q} --reassign --alias TANGO-{machineSerialNumber}-{environment} --grant-easy-access{q}"); + command.Timeout = TimeSpan.FromSeconds(30); + await command.Run(); - bool exist = await IsRemoteAssistanceInstalled(); + bool exist = await IsRemoteAssistanceInstalled(); - if (exist) - { - await DisableRemoteAssistance(); - } - else - { - throw new ApplicationException("The remote assistance service was installed but could not be found."); - } + if (exist) + { + await DisableRemoteAssistance(); } else { - LogManager.Log("Remote assistance is already installed."); + throw new ApplicationException("The remote assistance service was installed but could not be found."); } } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/IRemoteAssistanceProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/IRemoteAssistanceProvider.cs index 3d3b4e532..3b7d489e6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/IRemoteAssistanceProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/IRemoteAssistanceProvider.cs @@ -32,8 +32,9 @@ namespace Tango.PPC.Common.RemoteAssistance /// Installs the remote assistance. /// /// The machine serial number. + /// The remote assistance group. /// The machine working environment. /// - Task InstallRemoteAssistance(String machineSerialNumber, String environment); + Task InstallRemoteAssistance(String machineSerialNumber, String group, String environment); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 7142f461b..6eda39722 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -421,7 +421,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs index a642eddf2..f5d03c6ce 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineSetupResponse.cs @@ -31,5 +31,6 @@ namespace Tango.PPC.Common.Web public bool SetupFPGA { get; set; } public bool IsDemo { get; set; } public String DeviceComPort { get; set; } + public String Organization { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/loading_anim.gif b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/loading_anim.gif new file mode 100644 index 000000000..793007cc4 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/loading_anim.gif differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/power_off_2.gif b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/power_off_2.gif new file mode 100644 index 000000000..867107140 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/power_off_2.gif differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 149fb549f..003938303 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -242,7 +242,7 @@ namespace Tango.PPC.UI.PPCApplication { LogManager.Log("Application started with '-update_ok' startup arguments. The application has been successfully updated."); - if (settings.ApplicationState == ApplicationStates.PreSetup) + if (settings.ApplicationState == ApplicationStates.PreSetup || settings.ApplicationState == ApplicationStates.FactoryRestore) { isAfterSetup = true; LogManager.Log("System restart is required."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index eef669d4f..467b68d8b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -428,6 +428,8 @@ + + @@ -691,7 +693,7 @@ if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)" - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index f78a7f334..5c518f60d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -31,6 +31,7 @@ namespace Tango.PPC.UI.ViewModels public class MainViewVM : PPCViewModel { private DispatcherTimer _date_timer; + private bool _isPowerUpDialogShown; private DateTime _currentDateTime; /// @@ -100,6 +101,12 @@ namespace Tango.PPC.UI.ViewModels private async void MachineOperator_PowerUpStarted(object sender, EventArgs e) { + if (_isPowerUpDialogShown) + { + LogManager.Log("Power up detected but power up dialog is already shown. Skipping..."); + return; + } + LogManager.Log("Power up detected, showing power up screen..."); if (!Settings.DisplayPowerUpScreen) @@ -136,7 +143,9 @@ namespace Tango.PPC.UI.ViewModels InvokeUI(async () => { + _isPowerUpDialogShown = true; await NotificationProvider.ShowDialog(vm); + _isPowerUpDialogShown = false; await Task.Factory.StartNew(() => { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml index 79d9cd54b..a917695af 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml @@ -10,9 +10,9 @@ xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.UI.Views" mc:Ignorable="d" - d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:LoadingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoadingView}"> + d:DesignHeight="1280" d:DesignWidth="800" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:LoadingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoadingView}"> - + - - - + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml index 9437caac9..40b296d1e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineSetupView.xaml @@ -25,7 +25,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml index 9762ef621..22952a827 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml @@ -11,7 +11,7 @@ d:DesignHeight="1280" d:DesignWidth="800" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:PowerOffViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.PowerOffViewVM}"> - + Machine is turning Off Do not unplug machine while turning off ABORT diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml index 996b1788d..dd4d2f5d5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/RestartingSystemView.xaml @@ -10,17 +10,37 @@ mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:RestartingSystemViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RestartingSystemViewVM}" Background="{StaticResource TangoPrimaryBackgroundBrush}"> - - - - - Setup completed. - - - - Restarting the system for the last time... - + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs index 1b45e959d..c12b622a4 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollections.cs @@ -56,73 +56,73 @@ namespace Tango.BL { if (!_initialized) { - progressLog.Invoke("Loading static collections..."); + progressLog?.Invoke("Loading static collections..."); db = ObservablesContext.CreateDefault(); WindingMethods = db.WindingMethods.ToObservableCollection(); - progressLog.Invoke("Loading color spaces..."); + progressLog?.Invoke("Loading color spaces..."); ColorSpaces = db.ColorSpaces.ToObservableCollection(); - progressLog.Invoke("Loading spools..."); + progressLog?.Invoke("Loading spools..."); SpoolTypes = db.SpoolTypes.ToObservableCollection(); - progressLog.Invoke("Loading event..."); + progressLog?.Invoke("Loading event..."); EventTypes = db.EventTypes.ToObservableCollection(); - progressLog.Invoke("Loading blowers..."); + progressLog?.Invoke("Loading blowers..."); HardwareBlowerTypes = db.HardwareBlowerTypes.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); //HardwareBlowers = db.HardwareBlowers.ToObservableCollection(); - progressLog.Invoke("Loading break sensors..."); + progressLog?.Invoke("Loading break sensors..."); HardwareBreakSensorTypes = db.HardwareBreakSensorTypes.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); //HardwareBreakSensors = db.HardwareBreakSensors.ToObservableCollection(); - progressLog.Invoke("Loading dancers..."); + progressLog?.Invoke("Loading dancers..."); HardwareDancerTypes = db.HardwareDancerTypes.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); //HardwareDancers = db.HardwareDancers.ToObservableCollection(); - progressLog.Invoke("Loading motors..."); + progressLog?.Invoke("Loading motors..."); HardwareMotorTypes = db.HardwareMotorTypes.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); //HardwareMotors = db.HardwareMotors.ToObservableCollection(); - progressLog.Invoke("Loading pid controls..."); + progressLog?.Invoke("Loading pid controls..."); HardwarePidControlTypes = db.HardwarePidControlTypes.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); //HardwarePidControls = db.HardwarePidControls.ToObservableCollection(); - progressLog.Invoke("Loading speed sensors..."); + progressLog?.Invoke("Loading speed sensors..."); HardwareSpeedSensorTypes = db.HardwareSpeedSensorTypes.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); //HardwareSpeedSensors = db.HardwareSpeedSensors.ToObservableCollection(); - progressLog.Invoke("Loading winders..."); + progressLog?.Invoke("Loading winders..."); HardwareWinderTypes = db.HardwareWinderTypes.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); //HardwareWinders = db.HardwareWinders.ToObservableCollection(); - progressLog.Invoke("Loading tech controllers..."); + progressLog?.Invoke("Loading tech controllers..."); TechControllers = db.TechControllers.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); - progressLog.Invoke("Loading tech dispensers..."); + progressLog?.Invoke("Loading tech dispensers..."); TechDispensers = db.TechDispensers.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); - progressLog.Invoke("Loading tech io's..."); + progressLog?.Invoke("Loading tech io's..."); TechIos = db.TechIos.ToObservableCollection(); - progressLog.Invoke("Loading tech monitors..."); + progressLog?.Invoke("Loading tech monitors..."); TechMonitors = db.TechMonitors.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); - progressLog.Invoke("Loading tech valves..."); + progressLog?.Invoke("Loading tech valves..."); TechValves = db.TechValves.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); - progressLog.Invoke("Loading tech heaters..."); + progressLog?.Invoke("Loading tech heaters..."); TechHeaters = db.TechHeaters.ToList().OrderByAlphaNumeric(x => x.Description).ToObservableCollection(); - progressLog.Invoke("Loading machines..."); + progressLog?.Invoke("Loading machines..."); Machines = db.Machines.Include(x => x.Organization).ToObservableCollection(); - progressLog.Invoke("Loading users..."); + progressLog?.Invoke("Loading users..."); Users = db.Users.Where(x => !x.Deleted).Include(x => x.Contact).ToObservableCollection(); - progressLog.Invoke("Loading machine versions..."); + progressLog?.Invoke("Loading machine versions..."); MachineVersions = db.MachineVersions.ToObservableCollection(); //Load later... diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 1bb025217..6ac2e3657 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -71,7 +71,7 @@ namespace Tango.MachineService.Controllers { String machine_guid = RequestToken.Object.MachineGuid; - var machine = db.Machines.SingleOrDefault(x => x.Guid == machine_guid); + var machine = db.Machines.Include(x => x.Organization).SingleOrDefault(x => x.Guid == machine_guid); if (machine == null) { @@ -151,6 +151,7 @@ namespace Tango.MachineService.Controllers response.SetupUWF = machine.SetupUwf; response.SetupFirmware = machine.SetupFirmware; response.IsDemo = machine.IsDemo; + response.Organization = machine.Organization.Name; TangoUpdate tangoUpdate = new TangoUpdate(); tangoUpdate.ApplicationVersion = latest_machine_version.Version; -- cgit v1.3.1 From 58f79af3b62e7737191205e029ccdc8fb79c40cc Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 23 Jan 2020 16:53:51 +0200 Subject: Fixed a bug with none site for machine. Added Job run designation, source, uploading, heating time... --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../ViewModels/MainViewVM.cs | 13 +- .../ViewModels/MainViewVM.cs | 1 + .../Connection/DefaultMachineProvider.cs | 1 + .../Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs | 16 +++ Software/Visual_Studio/Tango.BL/Entities/JobRun.cs | 22 +++ .../Visual_Studio/Tango.BL/Entities/JobRunBase.cs | 76 ++++++++++ .../Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs | 2 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 6 + .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 156 ++++++++++----------- .../Tango.Emulations/Emulators/MachineEmulator.cs | 16 +-- .../JobRuns/BasicJobRunsLogger.cs | 20 ++- .../Tango.Integration/JobRuns/IJobRunsLogger.cs | 7 +- .../Tango.Integration/Operation/MachineOperator.cs | 30 ++++ .../Operation/PrintingEventArgs.cs | 3 + 16 files changed, 274 insertions(+), 95 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 92607a44c..8408613fb 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 b0d5a8efe..a9a07d0c3 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 bd08e3e7c..e0d99d0f0 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 @@ -610,8 +610,10 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } - Sites = await ActiveMachineAdapter.Context.Sites.ToListAsync(); - Sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); + var sites = await ActiveMachineAdapter.Context.Sites.ToListAsync(); + sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); + + Sites = sites; SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid); ColorCalibrationViewVM = new ColorCalibrationViewVM(_notification, ActiveMachine, _activeMachineAdapter.Context) @@ -627,8 +629,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); } - await MachineUpdatesViewVM.Init(ActiveMachine, ActiveMachineAdapter.Context); - TupViewVM.Init(ActiveMachine); + if (!IsNewMachine) + { + await MachineUpdatesViewVM.Init(ActiveMachine, ActiveMachineAdapter.Context); + TupViewVM.Init(ActiveMachine); + } ActiveMachine.Configuration.HardwareVersionChanged += Configuration_HardwareVersionChanged; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index ce3b825c8..23765de35 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -464,6 +464,7 @@ namespace Tango.MachineStudio.UI.ViewModels x.SelectedMachine.EnableEventsNotification = x.EnableDiagnostics; x.SelectedMachine.UseKeepAlive = x.EnableKeepAlive; x.SelectedMachine.JobUnitsMethod = _settings.JobUnitsMethod; + x.SelectedMachine.JobRunsLogger.JobSource = BL.Enumerations.JobSource.Remote; if (x.SelectedMachine is ExternalBridgeTcpClient) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 9b818bd9d..0475f43ac 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -84,6 +84,7 @@ namespace Tango.PPC.Common.Connection MachineOperator.EnableDiagnostics = true; MachineOperator.EnableEmbeddedDebugging = settings.EnableEmbeddedDebugLogs; MachineOperator.EnableAutomaticThreadLoading = settings.EnableAutomaticThreadLoading; + MachineOperator.JobRunsLogger.JobSource = BL.Enumerations.JobSource.Local; MachineOperator.FirmwareUpgradeMode = Integration.Upgrade.FirmwareUpgradeModes.DFU | Integration.Upgrade.FirmwareUpgradeModes.TFP_PACKAGE; diff --git a/Software/Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs index 83e04fde0..3542a7c08 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/JobRunDTOBase.cs @@ -53,6 +53,14 @@ namespace Tango.BL.DTO get; set; } + /// + /// job designation + /// + public Int32 JobDesignation + { + get; set; + } + /// /// job source /// @@ -133,6 +141,14 @@ namespace Tango.BL.DTO get; set; } + /// + /// gradient resolution cm + /// + public Int32 GradientResolutionCm + { + get; set; + } + /// /// liquid quantity string /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs b/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs index 1c4f3a5cd..6afb493cf 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/JobRun.cs @@ -22,6 +22,28 @@ namespace Tango.BL.Entities set { Status = (int)value; } } + /// + /// Gets or sets the job designation. + /// + [NotMapped] + [JsonIgnore] + public JobDesignations Designation + { + get { return (JobDesignations)JobDesignation; } + set { JobDesignation = value.ToInt32(); RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the job designation. + /// + [NotMapped] + [JsonIgnore] + public JobSource Source + { + get { return (JobSource)JobSource; } + set { JobSource = value.ToInt32(); RaisePropertyChangedAuto(); } + } + [NotMapped] [JsonIgnore] public List LiquidQuantities diff --git a/Software/Visual_Studio/Tango.BL/Entities/JobRunBase.cs b/Software/Visual_Studio/Tango.BL/Entities/JobRunBase.cs index 32efcdd9e..6aff11e23 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/JobRunBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/JobRunBase.cs @@ -29,6 +29,8 @@ namespace Tango.BL.Entities public event EventHandler JobNameChanged; + public event EventHandler JobDesignationChanged; + public event EventHandler JobSourceChanged; public event EventHandler JobStringChanged; @@ -49,6 +51,8 @@ namespace Tango.BL.Entities public event EventHandler IsGradientChanged; + public event EventHandler GradientResolutionCmChanged; + public event EventHandler LiquidQuantityStringChanged; public event EventHandler EndPositionChanged; @@ -159,6 +163,33 @@ namespace Tango.BL.Entities } } + protected Int32 _jobdesignation; + + /// + /// Gets or sets the jobrunbase job designation. + /// + + [Column("JOB_DESIGNATION")] + + public Int32 JobDesignation + { + get + { + return _jobdesignation; + } + + set + { + if (_jobdesignation != value) + { + _jobdesignation = value; + + OnJobDesignationChanged(value); + + } + } + } + protected Int32 _jobsource; /// @@ -431,6 +462,33 @@ namespace Tango.BL.Entities } } + protected Int32 _gradientresolutioncm; + + /// + /// Gets or sets the jobrunbase gradient resolution cm. + /// + + [Column("GRADIENT_RESOLUTION_CM")] + + public Int32 GradientResolutionCm + { + get + { + return _gradientresolutioncm; + } + + set + { + if (_gradientresolutioncm != value) + { + _gradientresolutioncm = value; + + OnGradientResolutionCmChanged(value); + + } + } + } + protected String _liquidquantitystring; /// @@ -548,6 +606,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(JobName)); } + /// + /// Called when the JobDesignation has changed. + /// + protected virtual void OnJobDesignationChanged(Int32 jobdesignation) + { + JobDesignationChanged?.Invoke(this, jobdesignation); + RaisePropertyChanged(nameof(JobDesignation)); + } + /// /// Called when the JobSource has changed. /// @@ -638,6 +705,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(IsGradient)); } + /// + /// Called when the GradientResolutionCm has changed. + /// + protected virtual void OnGradientResolutionCmChanged(Int32 gradientresolutioncm) + { + GradientResolutionCmChanged?.Invoke(this, gradientresolutioncm); + RaisePropertyChanged(nameof(GradientResolutionCm)); + } + /// /// Called when the LiquidQuantityString has changed. /// diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs index ca9dae507..482923dbc 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB_RUNS.cs @@ -21,6 +21,7 @@ namespace Tango.DAL.Remote.DB public string JOB_GUID { get; set; } public string USER_GUID { get; set; } public string JOB_NAME { get; set; } + public int JOB_DESIGNATION { get; set; } public int JOB_SOURCE { get; set; } public string JOB_STRING { get; set; } public System.DateTime START_DATE { get; set; } @@ -31,6 +32,7 @@ namespace Tango.DAL.Remote.DB public int STATUS { get; set; } public double JOB_LENGTH { get; set; } public bool IS_GRADIENT { get; set; } + public int GRADIENT_RESOLUTION_CM { get; set; } public string LIQUID_QUANTITY_STRING { get; set; } public double END_POSITION { get; set; } public string FAILED_MESSAGE { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index f18c157ba..032d79b90 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -605,6 +605,7 @@ + @@ -615,6 +616,7 @@ + @@ -3871,6 +3873,7 @@ + @@ -3881,6 +3884,7 @@ + @@ -6318,6 +6322,7 @@ + @@ -6328,6 +6333,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index fb41299df..6763cdcc3 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,84 +5,84 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 6d0bdbfc4..5e6fdbc63 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -852,16 +852,16 @@ namespace Tango.Emulations.Emulators private void HandleAbortJobRequest(TangoMessage request) { - if (_jobAbortCounter == 1) - { + //if (_jobAbortCounter == 1) + //{ _cancelJob = true; Transporter.SendResponse(new AbortJobResponse(), request.Container.Token); - _jobAbortCounter = 0; - } - else - { - _jobAbortCounter++; - } + // _jobAbortCounter = 0; + //} + //else + //{ + // _jobAbortCounter++; + //} } private void HandleMotorJoggingRequest(TangoMessage request) diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs index ce175e3d2..bb6c81a82 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/BasicJobRunsLogger.cs @@ -35,7 +35,12 @@ namespace Tango.Integration.JobRuns /// /// Gets or sets the job designations of which the logger should log (supports multiple flags). /// - public JobDesignations JobDesignation { get; set; } + public JobDesignations JobDesignationFilter { get; set; } + + /// + /// Gets or sets the job run source when logging job runs. + /// + public JobSource JobSource { get; set; } #endregion @@ -47,7 +52,7 @@ namespace Tango.Integration.JobRuns /// The machine operator. public BasicJobRunsLogger(IMachineOperator machineOperator) { - JobDesignation = JobDesignations.Default; + JobDesignationFilter = JobDesignations.Default | JobDesignations.SampleDye | JobDesignations.FineTuning; MachineOperator = machineOperator; Init(); } @@ -73,7 +78,7 @@ namespace Tango.Integration.JobRuns private bool ShouldLog() { - return IsStarted && _job != null && JobDesignation.HasFlag(_job.Designation); + return IsStarted && _job != null && JobDesignationFilter.HasFlag(_job.Designation); } private void InsertJobRun(PrintingEventArgs e, JobRunStatus status, Exception exception) @@ -90,17 +95,24 @@ namespace Tango.Integration.JobRuns { JobRun run = new JobRun(); + run.UserGuid = _job.UserGuid; run.StartDate = _start_date; + run.UploadingStartDate = e.UploadingStartTime; + run.HeatingStartDate = e.HeatingStartTime; + run.ActualStartDate = e.ActualStartTime; run.EndDate = DateTime.UtcNow; run.JobName = _job.Name; run.JobLength = _job.LengthIncludingNumberOfUnits; - run.JobSource = _job.Source; + run.Source = JobSource; + run.Designation = _job.Designation; run.JobGuid = _job.Guid; run.MachineGuid = _job.MachineGuid; run.JobRunStatus = status; run.EndPosition = e.JobHandler.Status.Progress; run.JobLength = e.JobHandler.Status.TotalProgress; run.LiquidQuantities = e.LiquidQuantities; + run.IsGradient = _job.Segments.Any(x => x.BrushStops.Count > 1); + run.GradientResolutionCm = MachineOperator.GradientGenerationConfiguration.ResolutionCM; run.JobString = _job.ToJobFileWhenLoaded().ToString(); if (exception != null) diff --git a/Software/Visual_Studio/Tango.Integration/JobRuns/IJobRunsLogger.cs b/Software/Visual_Studio/Tango.Integration/JobRuns/IJobRunsLogger.cs index 8c4174311..a5242c1a4 100644 --- a/Software/Visual_Studio/Tango.Integration/JobRuns/IJobRunsLogger.cs +++ b/Software/Visual_Studio/Tango.Integration/JobRuns/IJobRunsLogger.cs @@ -21,7 +21,12 @@ namespace Tango.Integration.JobRuns /// /// Gets or sets the job designations of which the logger should log (supports multiple flags). /// - JobDesignations JobDesignation { get; set; } + JobDesignations JobDesignationFilter { get; set; } + + /// + /// Gets or sets the job run source when logging job runs. + /// + JobSource JobSource { get; set; } /// /// Gets a value indicating whether this instance is started. diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 2205fad8d..cd320e023 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -75,6 +75,9 @@ namespace Tango.Integration.Operation private List _currentJobLiquidQuantities; private DateTime _diagnosticsTime; private MachineStatus _machineStatusBeforeJobStart; + private DateTime? _jobUploadingStartDate; + private DateTime? _jobHeatingStartDate; + private DateTime? _jobActualStartDate; public static String EmbeddedLogsFolder { get; private set; } public static String EmbeddedLogsTag { get; private set; } @@ -1180,6 +1183,9 @@ namespace Tango.Integration.Operation PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + UploadingStartTime = _jobUploadingStartDate, + HeatingStartTime = _jobHeatingStartDate, + ActualStartTime = _jobActualStartDate, }); OnPrintingEnded(handler, job); @@ -1196,6 +1202,9 @@ namespace Tango.Integration.Operation PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, job, exception) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + UploadingStartTime = _jobUploadingStartDate, + HeatingStartTime = _jobHeatingStartDate, + ActualStartTime = _jobActualStartDate, }); OnPrintingEnded(handler, job); } @@ -1210,6 +1219,9 @@ namespace Tango.Integration.Operation PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + UploadingStartTime = _jobUploadingStartDate, + HeatingStartTime = _jobHeatingStartDate, + ActualStartTime = _jobActualStartDate, }); OnPrintingEnded(handler, job); } @@ -1224,6 +1236,9 @@ namespace Tango.Integration.Operation PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, job) { LiquidQuantities = _currentJobLiquidQuantities.ToList(), + UploadingStartTime = _jobUploadingStartDate, + HeatingStartTime = _jobHeatingStartDate, + ActualStartTime = _jobActualStartDate, }); } @@ -2291,6 +2306,9 @@ namespace Tango.Integration.Operation LogManager.Log($"Executing job '{job.Name}'..."); _currentJobLiquidQuantities = new List(); + _jobUploadingStartDate = null; + _jobHeatingStartDate = null; + _jobActualStartDate = null; RunningJob = null; RunningJobStatus = null; @@ -2568,6 +2586,7 @@ namespace Tango.Integration.Operation LogManager.Log($"Uploading job description file '{job_file_path}' of size: {ms.Length}"); TaskCompletionSource uploadCompletion = new TaskCompletionSource(); + _jobUploadingStartDate = DateTime.UtcNow; fileUploadHandler = await storage.UploadFile(job_file_path, ms); bool uploadCanceled = false; Exception uploadException = null; @@ -2631,6 +2650,10 @@ namespace Tango.Integration.Operation return; } } + else + { + _jobUploadingStartDate = DateTime.UtcNow; + } if (handler.IsCanceled) { @@ -2645,6 +2668,8 @@ namespace Tango.Integration.Operation bool responseLogged = false; bool completed = false; //Use this in case Shlomo is sending progress after completion. + _jobHeatingStartDate = DateTime.UtcNow; + SendContinuousRequest(request, null, ContinuousRequestTimeout.Add(TimeSpan.FromSeconds(3))).Subscribe((response) => { if (!completed) @@ -2658,6 +2683,11 @@ namespace Tango.Integration.Operation { UseKeepAlive = oldKeepAlive; } + + if (_jobActualStartDate == null) + { + _jobActualStartDate = DateTime.UtcNow; + } } if (!responseLogged) diff --git a/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs index d4c2ad4e8..f68204127 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs @@ -13,6 +13,9 @@ namespace Tango.Integration.Operation public JobHandler JobHandler { get; private set; } public Job Job { get; private set; } public List LiquidQuantities { get; set; } + public DateTime? UploadingStartTime { get; set; } + public DateTime? HeatingStartTime { get; set; } + public DateTime? ActualStartTime { get; set; } public PrintingEventArgs(JobHandler jobHandler, Job job) { -- cgit v1.3.1