From cc3480d4aac4175b1072060dd2d6d398d3451ae8 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 30 Dec 2018 01:27:53 +0200 Subject: Working on dispenserssssssss --- .../Contracts/IMainView.cs | 21 + .../Tango.MachineStudio.MachineDesigner.csproj | 26 +- .../ViewModels/MainViewVM.cs | 839 +++++++++------------ .../Views/ConfigurationView.xaml | 718 ++++++++++++++++++ .../Views/ConfigurationView.xaml.cs | 172 +++++ .../Views/MachineDetailsView.xaml | 44 ++ .../Views/MachineDetailsView.xaml.cs | 28 + .../Views/MachineView.xaml | 2 +- .../Views/MachinesView.xaml | 73 ++ .../Views/MachinesView.xaml.cs | 28 + .../Views/MainView.xaml | 811 +------------------- .../Views/MainView.xaml.cs | 148 +--- 12 files changed, 1475 insertions(+), 1435 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Contracts/IMainView.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Contracts/IMainView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Contracts/IMainView.cs new file mode 100644 index 000000000..392b557c4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Contracts/IMainView.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.MachineDesigner.Contracts +{ + public enum MachineDesignerNavigationView + { + MachinesView, + MachineDetailsView, + ConfigurationView, + } + + public interface IMainView : IView + { + void NavigateTo(MachineDesignerNavigationView view); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index 3fa7c60cf..8ced2e510 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -76,19 +76,37 @@ GlobalVersionInfo.cs + + + MachineDetailsView.xaml + + + MachinesView.xaml + MachineVersionDialog.xaml MachineView.xaml + + ConfigurationView.xaml + + MainView.xaml - + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -97,6 +115,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -232,7 +254,7 @@ - + \ No newline at end of file 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 5a5df0d0f..e2924a185 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 @@ -18,45 +18,38 @@ using Tango.MachineStudio.Common; using Tango.BL; using Tango.AutoComplete.Editors; using System.Data.Entity; +using Tango.BL.Builders; +using Tango.MachineStudio.MachineDesigner.Contracts; namespace Tango.MachineStudio.MachineDesigner.ViewModels { - public class MainViewVM : StudioViewModel + public class MainViewVM : StudioViewModel { private INotificationProvider _notification; - private ObservablesContext _db; - private Configuration _original_configuration; + private ObservablesContext _dbContext; + private ObservablesContext _machineContext; + private ObservablesContext _configContext; #region Properties - private ObservablesStaticCollections _adapter; + private ObservableCollection _machines; /// - /// Gets or sets the db static adapter. + /// Gets or sets the machines. /// - public ObservablesStaticCollections Adapter + public ObservableCollection Machines { - get { return _adapter; } - set { _adapter = value; RaisePropertyChangedAuto(); } + get { return _machines; } + set { _machines = value; RaisePropertyChangedAuto(); } } - private bool _canWork; + private ObservableCollection _dispensers; /// - /// Gets or sets a value indicating whether this instance can work. + /// Gets or sets the dispensers. /// - public bool CanWork + public ObservableCollection Dispensers { - get { return _canWork; } - set { _canWork = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } - } - - private Machine _machine; - /// - /// Gets or sets the current editable machine. - /// - public Machine Machine - { - get { return _machine; } - set { _machine = value; RaisePropertyChangedAuto(); } + get { return _dispensers; } + set { _dispensers = value; RaisePropertyChangedAuto(); } } private Machine _selectedMachine; @@ -70,11 +63,24 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { if (_selectedMachine != value) { - _selectedMachine = value; RaisePropertyChangedAuto(); OnSelectedMachineChanged(); + _selectedMachine = value; + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); } } } + private Machine _activeMachine; + /// + /// Gets or sets the active machine. + /// + public Machine ActiveMachine + { + get { return _activeMachine; } + set { _activeMachine = value; RaisePropertyChangedAuto(); } + } + + private Configuration _configuration; /// /// Gets or sets the editable machine configuration. @@ -95,29 +101,19 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _selectedIds = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } - private ObservableCollection _history; + private String _dispensersFilter; /// - /// Gets or sets the machine configuration history. + /// Gets or sets the dispensers filter. /// - public ObservableCollection History + public String DispensersFilter { - get { return _history; } - set { _history = value; RaisePropertyChangedAuto(); } - } - - private Configuration _selectedHistoryConfiguration; - /// - /// Gets or sets the machine selected configuration from history. - /// - public Configuration SelectedHistoryConfiguration - { - get { return _selectedHistoryConfiguration; } - set { _selectedHistoryConfiguration = value; RaisePropertyChangedAuto(); OnHistoryConfigurationSelected(); } + get { return _dispensersFilter; } + set { _dispensersFilter = value; RaisePropertyChangedAuto(); OnDispensersFilterChanged(); } } private String _filter; /// - /// Gets or sets the configuration components filter. + /// Gets or sets the machines filter. /// public String Filter { @@ -125,11 +121,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } } - /// - /// Gets or sets the machines provider. - /// - public ISuggestionProvider MachinesProvider { get; set; } - #endregion #region Commands @@ -150,19 +141,19 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public RelayCommand RemoveIdsCommand { get; set; } /// - /// Gets or sets the set version configuration command. + /// Gets or sets the remove machine command. /// - public RelayCommand SetVersionConfigurationCommand { get; set; } + public RelayCommand RemoveMachineCommand { get; set; } /// - /// Gets or sets the set as default command. + /// Gets or sets the add machine command. /// - public RelayCommand SetAsDefaultCommand { get; set; } + public RelayCommand AddMachineCommand { get; set; } /// - /// Gets or sets the reset command. + /// Gets or sets the edit machine command. /// - public RelayCommand ResetCommand { get; set; } + public RelayCommand EditMachineCommand { get; set; } #endregion @@ -178,195 +169,95 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// public MainViewVM(INotificationProvider notification) { - CanWork = true; - + _dbContext = ObservablesContext.CreateDefault(); _notification = notification; - Configuration = new Configuration(); - Configuration.Name = "Untitled"; - Machine = new Machine(); - Machine.Configuration = Configuration; - - SaveCommand = new RelayCommand(Save, (x) => CanWork); - AddIdsCommand = new RelayCommand(AddIds, (x) => CanWork && Configuration.IdsPacks.Count < 8); - RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => CanWork && SelectedIds != null); - SetVersionConfigurationCommand = new RelayCommand(SetVersionConfiguration, (x) => CanWork); - SetAsDefaultCommand = new RelayCommand(SetAsDefaultConfiguration, (x) => CanWork); - ResetCommand = new RelayCommand(Reset, () => CanWork); + //SaveCommand = new RelayCommand(Save); + AddIdsCommand = new RelayCommand(AddIds, (x) => Configuration != null && Configuration.IdsPacks.Count < 8); + RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => SelectedIds != null); + EditMachineCommand = new RelayCommand(EditSelectedMachine, () => SelectedMachine != null); + } - MachinesProvider = new SuggestionProvider((filter) => + private async void EditSelectedMachine() + { + using (_notification.PushTaskItem("Loading machine details...")) { - try - { - return _db.Machines.Where(x => x.SerialNumber.StartsWith(filter)).ToList(); - } - catch + IsFree = false; + + if (_machineContext != null) { - return new List(); + _machineContext.Dispose(); } - }); + + _machineContext = ObservablesContext.CreateDefault(); + ActiveMachine = (await new MachineBuilder(_machineContext).Set(SelectedMachine).WithOrganization().WithConfiguration().BuildAsync()); + View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); + + IsFree = true; + } } #endregion #region Application Ready - public async override void OnApplicationReady() + public override void OnApplicationReady() { - await InitCollections(); + } #endregion - private Task InitCollections() - { - return Task.Factory.StartNew(() => - { - CanWork = false; - - _db = ObservablesContext.CreateDefault(); - - Adapter = new ObservablesStaticCollections(); - Adapter.ApplicationDisplayPanelVersions = _db.ApplicationDisplayPanelVersions.ToObservableCollection(); - Adapter.ApplicationFirmwareVersions = _db.ApplicationFirmwareVersions.ToObservableCollection(); - Adapter.ApplicationOsVersions = _db.ApplicationOsVersions.ToObservableCollection(); - Adapter.EmbeddedFirmwareVersions = _db.EmbeddedFirmwareVersions.ToObservableCollection(); - Adapter.DispenserTypes = _db.DispenserTypes.ToObservableCollection(); - Adapter.LiquidTypes = _db.LiquidTypes.ToObservableCollection(); - Adapter.MidTankTypes = _db.MidTankTypes.ToObservableCollection(); - Adapter.CartridgeTypes = _db.CartridgeTypes.ToObservableCollection(); - Adapter.IdsPackFormulas = _db.IdsPackFormulas.ToObservableCollection(); - Adapter.HardwareVersions = _db.HardwareVersions.ToObservableCollection(); - Adapter.MachineVersions = _db.MachineVersions.ToObservableCollection(); - Adapter.Organizations = _db.Organizations.ToObservableCollection(); - - Adapter.InitCollectionSources(); - - CanWork = true; - }); - } + //private Task InitCollections() + //{ + // return Task.Factory.StartNew(() => + // { + // CanWork = false; + + // _dbContext = ObservablesContext.CreateDefault(); + + // Adapter = new ObservablesStaticCollections(); + // Adapter.ApplicationDisplayPanelVersions = _dbContext.ApplicationDisplayPanelVersions.ToObservableCollection(); + // Adapter.ApplicationFirmwareVersions = _dbContext.ApplicationFirmwareVersions.ToObservableCollection(); + // Adapter.ApplicationOsVersions = _dbContext.ApplicationOsVersions.ToObservableCollection(); + // Adapter.EmbeddedFirmwareVersions = _dbContext.EmbeddedFirmwareVersions.ToObservableCollection(); + // Adapter.DispenserTypes = _dbContext.DispenserTypes.ToObservableCollection(); + // Adapter.LiquidTypes = _dbContext.LiquidTypes.ToObservableCollection(); + // Adapter.MidTankTypes = _dbContext.MidTankTypes.ToObservableCollection(); + // Adapter.CartridgeTypes = _dbContext.CartridgeTypes.ToObservableCollection(); + // Adapter.IdsPackFormulas = _dbContext.IdsPackFormulas.ToObservableCollection(); + // Adapter.HardwareVersions = _dbContext.HardwareVersions.ToObservableCollection(); + // Adapter.MachineVersions = _dbContext.MachineVersions.ToObservableCollection(); + // Adapter.Organizations = _dbContext.Organizations.ToObservableCollection(); + + // Adapter.InitCollectionSources(); + + // CanWork = true; + // }); + //} private void Reset() { - using (_notification.PushTaskItem("Resetting designer...")) - { - SelectedMachine = null; - Machine = new Machine(); - Configuration = new Configuration(); - History = new ObservableCollection(); - SelectedHistoryConfiguration = null; - Filter = String.Empty; - InitCollections(); - } + //using (_notification.PushTaskItem("Resetting designer...")) + //{ + // SelectedMachine = null; + // Machine = new Machine(); + // Configuration = new Configuration(); + // InitCollections(); + //} } - #region Virtual Methods - - /// - /// Called when the selected machine has changed. - /// - protected virtual void OnSelectedMachineChanged() + private async void OnDispensersFilterChanged() { - if (SelectedMachine != null) + if (!String.IsNullOrWhiteSpace(DispensersFilter)) { - CanWork = false; - - using (_notification.PushTaskItem("Loading machine configuration...")) - { - Task.Factory.StartNew(() => - { - InitCollections().Wait(); - Machine = _db.Machines.Where(x => x.Guid == SelectedMachine.Guid).Include(x => x.Organization).SingleOrDefault(x => x.Guid == SelectedMachine.Guid); - Configuration = _db.Adapter.GetConfiguration(x => x.Guid == Machine.ConfigurationGuid); - - SetHistory(); - - _original_configuration = Configuration.Clone(); - }); - } - - CanWork = true; - } - else - { - History = new ObservableCollection(); - } - } - - /// - /// Called when the history configuration has been selected - /// - protected virtual void OnHistoryConfigurationSelected() - { - if (SelectedHistoryConfiguration != null && CanWork) - { - using (_notification.PushTaskItem("Loading Configuration...")) - { - Task.Factory.StartNew(() => - { - CanWork = false; - - SelectedHistoryConfiguration = _db.Adapter.GetConfiguration(x => x.Guid == SelectedHistoryConfiguration.Guid); - Configuration = SelectedHistoryConfiguration; - Machine.Configuration = Configuration; - - CanWork = true; - }); - } + IsFree = false; + Dispensers = (await _configContext.Dispensers.Where(x => x.SerialNumber.ToLower().StartsWith(DispensersFilter.ToLower())).ToListAsync()).ToObservableCollection(); + IsFree = true; } } - /// - /// Called when the filter has changed - /// - protected virtual void OnFilterChanged() - { - List collections = new List(); - collections.Add(Adapter.ApplicationFirmwareVersionsViewSource); - collections.Add(Adapter.ApplicationDisplayPanelVersionsViewSource); - collections.Add(Adapter.ApplicationOsVersionsViewSource); - collections.Add(Adapter.EmbeddedFirmwareVersionsViewSource); - collections.Add(Adapter.DispenserTypesViewSource); - collections.Add(Adapter.CartridgeTypesViewSource); - collections.Add(Adapter.LiquidTypesViewSource); - collections.Add(Adapter.MidTankTypesViewSource); - collections.Add(Adapter.HardwareVersionsViewSource); - - foreach (var collection in collections) - { - collection.Filter = (x) => - { - foreach (var prop in x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(String))) - { - String value = prop.GetValue(x).ToStringSafe(); - - if (value != null && Filter != null) - { - if (value.ToLower().Contains(Filter.ToLower())) - { - return true; - } - } - } - - return false; - }; - } - } - - #endregion - - #region Public Methods - - /// - /// Sets the selected machine without any further processing. - /// - /// The machine. - public void SetSelectedMachine(Machine machine) - { - _machine = machine; - RaisePropertyChanged(nameof(Machine)); - } + #region Virtual Methods #endregion @@ -433,25 +324,25 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } /// - /// Drops the type of the cartridge. + /// Drops the dispenser. /// - /// Type of the cartridge. + /// The dispenser. /// The ids pack. - public void DropCartridgeType(CartridgeType cartridgeType, IdsPack idsPack) + public void DropDispenser(Dispenser dispenser, IdsPack idsPack) { - idsPack.CartridgeType = cartridgeType; - idsPack.CartridgeTypeGuid = cartridgeType.Guid; + idsPack.Dispenser = dispenser; + idsPack.DispenserGuid = dispenser.Guid; } /// - /// Drops the dispenser. + /// Drops the type of the cartridge. /// - /// The dispenser. + /// Type of the cartridge. /// The ids pack. - public void DropDispenserType(DispenserType dispenserType, IdsPack idsPack) + public void DropCartridgeType(CartridgeType cartridgeType, IdsPack idsPack) { - idsPack.DispenserType = dispenserType; - idsPack.DispenserTypeGuid = dispenserType.Guid; + idsPack.CartridgeType = cartridgeType; + idsPack.CartridgeTypeGuid = cartridgeType.Guid; } /// @@ -497,7 +388,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// private void RemoveIds() { - _db.IdsPacks.Remove(SelectedIds); + _dbContext.IdsPacks.Remove(SelectedIds); SelectedIds = null; } @@ -506,277 +397,251 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// private void AddIds() { - _db.IdsPacks.Add(new IdsPack() { Configuration = Configuration }); + _dbContext.IdsPacks.Add(new IdsPack() { Configuration = Configuration }); InvalidateRelayCommands(); } - /// - /// Saves the current machine configuration. - /// - private async void Save() - { - foreach (var ids in Configuration.IdsPacks) - { - ids.PackIndex = Configuration.IdsPacks.IndexOf(ids); - ids.Configuration = Configuration; - ids.ConfigurationGuid = Configuration.Guid; - } - - //Validate - - List errors = new List(); - - if (Machine.MachineVersion == null) - { - errors.Add("Machine version is required."); - } - - if (Machine.Name.IsNullOrWhiteSpace()) - { - errors.Add("Machine name is required."); - } - - if (Machine.Organization == null) - { - errors.Add("Machine organization is required."); - } - - if (Machine.SerialNumber.IsNullOrWhiteSpace()) - { - errors.Add("Machine serial number is required."); - } - - if (Configuration.Name.IsNullOrWhiteSpace()) - { - errors.Add("Configuration name is required."); - } - - if (Configuration.ApplicationDisplayPanelVersion == null) - { - errors.Add("Touch Panel is required."); - } - - if (Configuration.ApplicationFirmwareVersion == null) - { - errors.Add("Application firmware is required."); - } - - if (Configuration.ApplicationOsVersion == null) - { - errors.Add("Application operation system is required."); - } - - if (Configuration.EmbeddedFirmwareVersion == null) - { - errors.Add("Embedded firmware is required."); - } - - if (Configuration.HardwareVersion == null) - { - errors.Add("Hardware version is required."); - } - - foreach (var pack in Configuration.IdsPacks) - { - if (pack.LiquidType != null || pack.CartridgeType != null || pack.DispenserType != null || pack.IdsPackFormula != null || pack.MidTankType != null) - { - if (pack.Name.IsNullOrWhiteSpace()) - { - errors.Add(String.Format("Name is required on IDS pack number '{0}'.", Configuration.IdsPacks.IndexOf(pack) + 1)); - continue; - } - if (pack.CartridgeType == null) - { - errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.DispenserType == null) - { - errors.Add(String.Format("Dispenser type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.LiquidType == null) - { - errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.MidTankType == null) - { - errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.IdsPackFormula == null) - { - errors.Add(String.Format("Formula type is required on IDS pack '{0}'.", pack.Name)); - } - - pack.IsEmpty = false; - } - else - { - pack.IsEmpty = true; - pack.Name = String.Empty; - } - } - - if (errors.Count > 0) - { - String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine; - errorsString += String.Join(Environment.NewLine, errors); - _notification.ShowError(errorsString); - return; - } + ///// + ///// Saves the current machine configuration. + ///// + //private async void Save() + //{ + // foreach (var ids in Configuration.IdsPacks) + // { + // ids.PackIndex = Configuration.IdsPacks.IndexOf(ids); + // ids.Configuration = Configuration; + // ids.ConfigurationGuid = Configuration.Guid; + // } + + // //Validate + + // List errors = new List(); + + // if (Machine.MachineVersion == null) + // { + // errors.Add("Machine version is required."); + // } + + // if (Machine.Name.IsNullOrWhiteSpace()) + // { + // errors.Add("Machine name is required."); + // } + + // if (Machine.Organization == null) + // { + // errors.Add("Machine organization is required."); + // } + + // if (Machine.SerialNumber.IsNullOrWhiteSpace()) + // { + // errors.Add("Machine serial number is required."); + // } + + // if (Configuration.Name.IsNullOrWhiteSpace()) + // { + // errors.Add("Configuration name is required."); + // } + + // if (Configuration.ApplicationDisplayPanelVersion == null) + // { + // errors.Add("Touch Panel is required."); + // } + + // if (Configuration.ApplicationFirmwareVersion == null) + // { + // errors.Add("Application firmware is required."); + // } + + // if (Configuration.ApplicationOsVersion == null) + // { + // errors.Add("Application operation system is required."); + // } + + // if (Configuration.EmbeddedFirmwareVersion == null) + // { + // errors.Add("Embedded firmware is required."); + // } + + // if (Configuration.HardwareVersion == null) + // { + // errors.Add("Hardware version is required."); + // } + + // foreach (var pack in Configuration.IdsPacks) + // { + // if (pack.LiquidType != null || pack.CartridgeType != null || pack.Dispenser != null || pack.IdsPackFormula != null || pack.MidTankType != null) + // { + // if (pack.CartridgeType == null) + // { + // errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.PackIndex)); + // } + // if (pack.Dispenser == null) + // { + // errors.Add(String.Format("Dispenser is required on IDS pack '{0}'.", pack.PackIndex)); + // } + // if (pack.LiquidType == null) + // { + // errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.PackIndex)); + // } + // if (pack.MidTankType == null) + // { + // errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.PackIndex)); + // } + // if (pack.IdsPackFormula == null) + // { + // errors.Add(String.Format("Formula type is required on IDS pack '{0}'.", pack.PackIndex)); + // } + + // pack.IsEmpty = false; + // } + // else + // { + // pack.IsEmpty = true; + // } + // } + + // if (errors.Count > 0) + // { + // String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine; + // errorsString += String.Join(Environment.NewLine, errors); + // _notification.ShowError(errorsString); + // return; + // } + + // //Validate + + // try + // { + // CanWork = false; + + // using (_notification.PushTaskItem("Saving Machine Configuration...")) + // { + // if (!_dbContext.Machines.Any(x => x.SerialNumber.ToLower() == Machine.SerialNumber.ToLower())) + // { + // if (!_notification.ShowQuestion("The specified machine serial number does not exist. Do you wish to create a new machine?")) + // { + // CanWork = true; + // return; + // } + // else + // { + // Machine.Configuration = Configuration; + // Configuration.CreationDate = DateTime.UtcNow; + // Machine.ProductionDate = DateTime.UtcNow; + + // _dbContext.Machines.Add(Machine); + // } + // } + + // await _dbContext.SaveChangesAsync(); + // OnSelectedMachineChanged(); + + // } + // } + // catch (Exception ex) + // { + // _notification.ShowError("An error occurred while trying to save the configuration" + Environment.NewLine + ex.Message); + // } + // finally + // { + // CanWork = true; + // InvalidateRelayCommands(); + // } + //} + + ///// + ///// Sets the current configuration to the selected machine version default configuration. + ///// + //private async void SetVersionConfiguration() + //{ + // if (Machine.MachineVersion != null) + // { + // using (_notification.PushTaskItem("Applying default configuration...")) + // { + // CanWork = false; + + // await Task.Factory.StartNew(() => + // { + // var version = _dbContext.MachineVersions.Where(x => x.Guid == Machine.MachineVersion.Guid).Include(x => x.DefaultConfiguration).FirstOrDefault(); + // var version_config = _dbContext.Adapter.GetConfiguration(x => x.Guid == version.DefaultConfiguration.Guid); + // Configuration = version_config.Clone(); + // Machine.Configuration = Configuration; + // }); + + // CanWork = true; + // } + // } + // else + // { + // _notification.ShowError("No machine version selected."); + // } + //} + + ///// + ///// Sets the current configuration as a default machine version configuration. + ///// + //private void SetAsDefaultConfiguration() + //{ + // _notification.ShowModalDialog(async (vm) => + // { + // CanWork = false; + + // try + // { + // using (_notification.PushTaskItem("Saving Default Configuration...")) + // { + // if (vm.SelectedVersion != null) + // { + // var version = _dbContext.MachineVersions.Where(x => x.Guid == vm.SelectedVersion.Guid).Include(x => x.DefaultConfiguration).SingleOrDefault(x => x.Guid == vm.SelectedVersion.Guid); + + // _dbContext.Configurations.Remove(version.DefaultConfiguration); + + // var cloned = Configuration.Clone(); + // _dbContext.Configurations.Add(cloned); + // version.DefaultConfiguration = cloned; + + // await _dbContext.SaveChangesAsync(); + // } + // else + // { + // MachineVersion newVersion = new MachineVersion(); + // newVersion.Version = vm.Version; + // newVersion.Name = vm.VersionName; + + // var cloned = Configuration.Clone(); + + // _dbContext.Configurations.Add(cloned); + // newVersion.DefaultConfiguration = cloned; + // _dbContext.MachineVersions.Add(newVersion); + // await _dbContext.SaveChangesAsync(); + // } + // } + // } + // catch (Exception ex) + // { + // _notification.ShowError(ex.Message); + // } + // finally + // { + // CanWork = true; + // } + + // }, () => + // { + + // }); + //} - //Validate - - try - { - CanWork = false; - - using (_notification.PushTaskItem("Saving Machine Configuration...")) - { - if (!_db.Machines.Any(x => x.SerialNumber.ToLower() == Machine.SerialNumber.ToLower())) - { - if (!_notification.ShowQuestion("The specified machine serial number does not exist. Do you wish to create a new machine?")) - { - CanWork = true; - return; - } - else - { - Machine.Configuration = Configuration; - Configuration.CreationDate = DateTime.UtcNow; - Machine.ProductionDate = DateTime.UtcNow; - - _db.Machines.Add(Machine); - _db.MachinesConfigurations.Add(new MachinesConfiguration() - { - Configuration = Configuration, - Machine = Machine, - }); - } - } - else - { - bool add_history = History.Count == 0 || _original_configuration.Name != Configuration.Name; - - if (add_history) - { - _db.Configurations.Add(_original_configuration); - - _db.MachinesConfigurations.Add(new MachinesConfiguration() - { - Configuration = _original_configuration, - Machine = Machine - }); - } - } - - await _db.SaveChangesAsync(); - OnSelectedMachineChanged(); - - } - } - catch (Exception ex) - { - _notification.ShowError("An error occurred while trying to save the configuration" + Environment.NewLine + ex.Message); - } - finally - { - CanWork = true; - InvalidateRelayCommands(); - } - } - - /// - /// Sets the specified machine history. - /// - /// The machine. - private void SetHistory() - { - History = _db.MachinesConfigurations.Where(x => x.MachineGuid == Machine.Guid).Select(x => x.Configuration).ToObservableCollection(); - //History.Insert(0, Machine.Configuration); - } + #endregion - /// - /// Sets the current configuration to the selected machine version default configuration. - /// - private async void SetVersionConfiguration() + private async void OnFilterChanged() { - if (Machine.MachineVersion != null) - { - using (_notification.PushTaskItem("Applying default configuration...")) - { - CanWork = false; - - await Task.Factory.StartNew(() => - { - var version = _db.MachineVersions.Where(x => x.Guid == Machine.MachineVersion.Guid).Include(x => x.DefaultConfiguration).FirstOrDefault(); - var version_config = _db.Adapter.GetConfiguration(x => x.Guid == version.DefaultConfiguration.Guid); - Configuration = version_config.Clone(); - Machine.Configuration = Configuration; - }); - - CanWork = true; - } - } - else + if (!String.IsNullOrWhiteSpace(Filter)) { - _notification.ShowError("No machine version selected."); + IsFree = false; + Machines = (await _dbContext.Machines.Where(x => x.SerialNumber.StartsWith(Filter)).ToListAsync()).ToObservableCollection(); + IsFree = true; } } - - /// - /// Sets the current configuration as a default machine version configuration. - /// - private void SetAsDefaultConfiguration() - { - _notification.ShowModalDialog(async (vm) => - { - CanWork = false; - - try - { - using (_notification.PushTaskItem("Saving Default Configuration...")) - { - if (vm.SelectedVersion != null) - { - var version = _db.MachineVersions.Where(x => x.Guid == vm.SelectedVersion.Guid).Include(x => x.DefaultConfiguration).SingleOrDefault(x => x.Guid == vm.SelectedVersion.Guid); - - _db.Configurations.Remove(version.DefaultConfiguration); - - var cloned = Configuration.Clone(); - _db.Configurations.Add(cloned); - version.DefaultConfiguration = cloned; - - await _db.SaveChangesAsync(); - } - else - { - MachineVersion newVersion = new MachineVersion(); - newVersion.Version = vm.Version; - newVersion.Name = vm.VersionName; - - var cloned = Configuration.Clone(); - - _db.Configurations.Add(cloned); - newVersion.DefaultConfiguration = cloned; - _db.MachineVersions.Add(newVersion); - await _db.SaveChangesAsync(); - } - } - } - catch (Exception ex) - { - _notification.ShowError(ex.Message); - } - finally - { - CanWork = true; - } - - }, () => - { - - }); - } - - #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml new file mode 100644 index 000000000..a96cd4685 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml @@ -0,0 +1,718 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hardware Version + + + + + + Add IDS + + + + + + Remove IDS + + + + + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NO IDS PACKS + + + + + + + + + + + + + + + + + + + + + Touch Panel + + + + + + Embedded Firmware + + + + + + Dispensers + + + + + + Mid Tanks + + + + + + Cartridges + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IDS PACKS + + + + + + + PACK: # + + + + + Dispenser: + + + + Mid Tank: + + + + Cartridge: + + + + Liquid: + + + + Formula: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml.cs new file mode 100644 index 000000000..941a2792d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +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.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.BL.Entities; +using Tango.DragAndDrop; +using Tango.MachineStudio.MachineDesigner.ViewModels; + +namespace Tango.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class ConfigurationView : UserControl + { + private MainViewVM _vm; + private Rectangle _highlightRect; + private bool _highlightShown; + private DoubleAnimation _highlightAnimation; + + public ColumnDefinition PanelColumnDefinition { get; set; } + + public ConfigurationView() + { + InitializeComponent(); + + PanelColumnDefinition = panelColumnDefinition; + + DraggingSurface = dragSufrace; + this.Loaded += (x, y) => + { + _vm = DataContext as MainViewVM; + }; + + DragAndDropService.DragStarted += DragAndDropService_DragStarted; + DragAndDropService.DragEnded += DragAndDropService_DragEnded; + + _highlightRect = new Rectangle(); + _highlightRect.IsHitTestVisible = false; + _highlightRect.Stroke = Application.Current.Resources["AccentColorBrush"] as Brush; + _highlightRect.StrokeThickness = 2; + _highlightRect.StrokeDashArray = new DoubleCollection(new double[] { 3, 3, 3, 3 }); + } + + private void DragAndDropService_DragEnded(object sender, FrameworkElement e) + { + canvas.Children.Remove(_highlightRect); + _highlightShown = false; + _highlightRect.BeginAnimation(Rectangle.OpacityProperty, null); + } + + private void DragAndDropService_DragStarted(object sender, FrameworkElement e) + { + if (e.DataContext is HardwareVersion) + { + SetHighlightRegion(hardwareGrid); + } + else if (e.DataContext is ApplicationOsVersion || e.DataContext is ApplicationDisplayPanelVersion || e.DataContext is ApplicationFirmwareVersion) + { + SetHighlightRegion(gridTablet); + } + else if (e.DataContext is EmbeddedFirmwareVersion) + { + SetHighlightRegion(gridEmbedded); + } + else if (e.DataContext is DispenserType || e.DataContext is CartridgeType || e.DataContext is LiquidType || e.DataContext is MidTankType || e.DataContext is IdsPackFormula) + { + SetHighlightRegion(gridIds); + } + } + + public DraggingSurface DraggingSurface + { + get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } + set { SetValue(DraggingSurfaceProperty, value); } + } + public static readonly DependencyProperty DraggingSurfaceProperty = + DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); + + private void OnDropOnIdsPack(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is Dispenser) + { + _vm.DropDispenser(e.Draggable.DataContext as Dispenser, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is LiquidType) + { + _vm.DropLiquidType(e.Draggable.DataContext as LiquidType, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is CartridgeType) + { + _vm.DropCartridgeType(e.Draggable.DataContext as CartridgeType, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is MidTankType) + { + _vm.DropMidTankType(e.Draggable.DataContext as MidTankType, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is IdsPackFormula) + { + _vm.DropIdsFormula(e.Draggable.DataContext as IdsPackFormula, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is IdsPack) + { + _vm.DropIdsPack(e.Draggable.DataContext as IdsPack, e.Droppable.DataContext as IdsPack); + } + } + + private void OnTabletDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is ApplicationDisplayPanelVersion) + { + _vm.DropTouchPanel(e.Draggable.DataContext as ApplicationDisplayPanelVersion); + } + else if (e.Draggable.DataContext is ApplicationOsVersion) + { + _vm.DropApplicationOsVersion(e.Draggable.DataContext as ApplicationOsVersion); + } + else if (e.Draggable.DataContext is ApplicationFirmwareVersion) + { + _vm.DropApplicationFirmwareVersion(e.Draggable.DataContext as ApplicationFirmwareVersion); + } + } + + private void OnEmbeddedDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is EmbeddedFirmwareVersion) + { + _vm.DropEmbeddedFirmware(e.Draggable.DataContext as EmbeddedFirmwareVersion); + } + } + + private void MachineDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is HardwareVersion) + { + _vm.DropHardwareVersion(e.Draggable.DataContext as HardwareVersion); + } + } + + private void SetHighlightRegion(FrameworkElement element) + { + if (!_highlightShown) + { + _highlightRect.Width = element.Width; + _highlightRect.Height = element.Height; + Canvas.SetLeft(_highlightRect, Canvas.GetLeft(element)); + Canvas.SetTop(_highlightRect, Canvas.GetTop(element)); + canvas.Children.Add(_highlightRect); + _highlightShown = true; + _highlightAnimation = new DoubleAnimation(); + _highlightAnimation.From = 0; + _highlightAnimation.To = 1; + _highlightAnimation.Duration = TimeSpan.FromSeconds(0.2); + _highlightAnimation.AutoReverse = true; + _highlightAnimation.RepeatBehavior = RepeatBehavior.Forever; + _highlightRect.BeginAnimation(Rectangle.OpacityProperty, _highlightAnimation); + } + } + } +} 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 new file mode 100644 index 000000000..320ce58aa --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml @@ -0,0 +1,44 @@ + + + + + + + + MACHINE + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml.cs new file mode 100644 index 000000000..07d012966 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.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.MachineDesigner.Views +{ + /// + /// Interaction logic for MachineDetailsView.xaml + /// + public partial class MachineDetailsView : UserControl + { + public MachineDetailsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml index 1ea8d2a74..ded14930a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml @@ -133,7 +133,7 @@ + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml.cs new file mode 100644 index 000000000..776a922ca --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.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.MachineDesigner.Views +{ + /// + /// Interaction logic for MachinesView.xaml + /// + public partial class MachinesView : UserControl + { + public MachinesView() + { + InitializeComponent(); + } + } +} 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 e25a64c5e..0ffcf400a 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 @@ -3,812 +3,17 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" + xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" xmlns:global="clr-namespace:Tango.MachineStudio.MachineDesigner" - xmlns:fa="http://schemas.fontawesome.io/icons/" - xmlns:providers="clr-namespace:Tango.MachineStudio.MachineDesigner.AutoComplete" - xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" - xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" - xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" - xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - - - - - - - - - + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - - - - - - - - - - - - - - - - - - - - - - MACHINE DESIGNER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Hardware Version - - - - - - Add IDS - - - - - - Remove IDS - - - - - - - - - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NO IDS PACKS - - - - - - - - - - - - - - - - - - - - - Touch Panel - - - - - - Embedded Firmware - - - - - - Dispensers - - - - - - Mid Tanks - - - - - - Cartridges - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IDS PACKS - - - - - - - - - - Dispenser: - - - - Mid Tank: - - - - Cartridge: - - - - Liquid: - - - - Formula: - - - - - - - - - - - - - - - - - - - - - - - - - Serial Number - - - Machine Name - - - Machine Version - - - - - - - - - - Organization - - - - Enable Synchronization - - - - Configuration Name - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs index 9c7496484..7e1b60a28 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -10,163 +9,28 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -using Tango.BL.Entities; -using Tango.DragAndDrop; -using Tango.MachineStudio.MachineDesigner.ViewModels; +using Tango.Core.DI; +using Tango.MachineStudio.MachineDesigner.Contracts; namespace Tango.MachineStudio.MachineDesigner.Views { /// /// Interaction logic for MainView.xaml /// - public partial class MainView : UserControl + public partial class MainView : UserControl , IMainView { - private MainViewVM _vm; - private Rectangle _highlightRect; - private bool _highlightShown; - private DoubleAnimation _highlightAnimation; - - public ColumnDefinition PanelColumnDefinition { get; set; } - public MainView() { InitializeComponent(); - - PanelColumnDefinition = panelColumnDefinition; - - DraggingSurface = dragSufrace; - this.Loaded += (x, y) => - { - _vm = DataContext as MainViewVM; - }; - - DragAndDropService.DragStarted += DragAndDropService_DragStarted; - DragAndDropService.DragEnded += DragAndDropService_DragEnded; - - _highlightRect = new Rectangle(); - _highlightRect.IsHitTestVisible = false; - _highlightRect.Stroke = Application.Current.Resources["AccentColorBrush"] as Brush; - _highlightRect.StrokeThickness = 2; - _highlightRect.StrokeDashArray = new DoubleCollection(new double[] { 3, 3, 3, 3 }); - } - - private void DragAndDropService_DragEnded(object sender, FrameworkElement e) - { - canvas.Children.Remove(_highlightRect); - _highlightShown = false; - _highlightRect.BeginAnimation(Rectangle.OpacityProperty, null); - } - - private void DragAndDropService_DragStarted(object sender, FrameworkElement e) - { - if (e.DataContext is HardwareVersion) - { - SetHighlightRegion(hardwareGrid); - } - else if (e.DataContext is ApplicationOsVersion || e.DataContext is ApplicationDisplayPanelVersion || e.DataContext is ApplicationFirmwareVersion) - { - SetHighlightRegion(gridTablet); - } - else if (e.DataContext is EmbeddedFirmwareVersion) - { - SetHighlightRegion(gridEmbedded); - } - else if (e.DataContext is DispenserType || e.DataContext is CartridgeType || e.DataContext is LiquidType || e.DataContext is MidTankType || e.DataContext is IdsPackFormula) - { - SetHighlightRegion(gridIds); - } - } - - public DraggingSurface DraggingSurface - { - get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } - set { SetValue(DraggingSurfaceProperty, value); } - } - public static readonly DependencyProperty DraggingSurfaceProperty = - DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); - - private void OnDropOnIdsPack(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is DispenserType) - { - _vm.DropDispenserType(e.Draggable.DataContext as DispenserType, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is LiquidType) - { - _vm.DropLiquidType(e.Draggable.DataContext as LiquidType, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is CartridgeType) - { - _vm.DropCartridgeType(e.Draggable.DataContext as CartridgeType, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is MidTankType) - { - _vm.DropMidTankType(e.Draggable.DataContext as MidTankType, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is IdsPackFormula) - { - _vm.DropIdsFormula(e.Draggable.DataContext as IdsPackFormula, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is IdsPack) - { - _vm.DropIdsPack(e.Draggable.DataContext as IdsPack, e.Droppable.DataContext as IdsPack); - } - } - - private void OnTabletDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is ApplicationDisplayPanelVersion) - { - _vm.DropTouchPanel(e.Draggable.DataContext as ApplicationDisplayPanelVersion); - } - else if (e.Draggable.DataContext is ApplicationOsVersion) - { - _vm.DropApplicationOsVersion(e.Draggable.DataContext as ApplicationOsVersion); - } - else if (e.Draggable.DataContext is ApplicationFirmwareVersion) - { - _vm.DropApplicationFirmwareVersion(e.Draggable.DataContext as ApplicationFirmwareVersion); - } - } - - private void OnEmbeddedDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is EmbeddedFirmwareVersion) - { - _vm.DropEmbeddedFirmware(e.Draggable.DataContext as EmbeddedFirmwareVersion); - } - } - - private void MachineDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is HardwareVersion) - { - _vm.DropHardwareVersion(e.Draggable.DataContext as HardwareVersion); - } + TangoIOC.Default.Register(this); } - private void SetHighlightRegion(FrameworkElement element) + public void NavigateTo(MachineDesignerNavigationView view) { - if (!_highlightShown) - { - _highlightRect.Width = element.Width; - _highlightRect.Height = element.Height; - Canvas.SetLeft(_highlightRect, Canvas.GetLeft(element)); - Canvas.SetTop(_highlightRect, Canvas.GetTop(element)); - canvas.Children.Add(_highlightRect); - _highlightShown = true; - _highlightAnimation = new DoubleAnimation(); - _highlightAnimation.From = 0; - _highlightAnimation.To = 1; - _highlightAnimation.Duration = TimeSpan.FromSeconds(0.2); - _highlightAnimation.AutoReverse = true; - _highlightAnimation.RepeatBehavior = RepeatBehavior.Forever; - _highlightRect.BeginAnimation(Rectangle.OpacityProperty, _highlightAnimation); - } + navigationControl.NavigateTo(view.ToString()); } } } -- cgit v1.3.1 From 721e03d7e6926055111d4edbbdf5f700a11ed58a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 30 Dec 2018 15:23:34 +0200 Subject: Working on new Machine Designer. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Build/Shortcuts/Machine Emulator.lnk | Bin 1530 -> 1445 bytes .../Build/Shortcuts/Machine Studio.lnk | Bin 1581 -> 1516 bytes .../Build/Shortcuts/Proto Compiler GUI.lnk | Bin 1529 -> 1444 bytes .../Build/Shortcuts/Stubs Execution GUI.lnk | Bin 1547 -> 1462 bytes .../Build/Shortcuts/Transport Router.lnk | Bin 1578 -> 1493 bytes .../ViewModels/ConfigurationsViewVM.cs | 1 - .../Tango.MachineStudio.MachineDesigner.csproj | 9 +- .../ViewModels/MainViewVM.cs | 598 +++++++++------------ .../Views/ConfigurationView.xaml | 55 +- .../Views/MachineDetailsView.xaml | 43 +- .../Views/MachineSettingsView.xaml | 99 ++++ .../Views/MachineSettingsView.xaml.cs | 28 + .../Views/MachineView.xaml | 19 - .../Views/MachinesView.xaml | 7 +- .../Views/MainView.xaml | 3 +- .../Tango.MachineStudio.Common/DeploymentSlots.cs | 2 + .../PPC/Tango.PPC.Common/DeploymentSlots.cs | 2 + .../Tango.BL/Builders/ConfigurationBuilder.cs | 7 +- .../Tango.BL/Builders/MachineBuilder.cs | 12 +- .../Tango.BL/Entities/Configuration.cs | 76 --- .../Visual_Studio/Tango.BL/Entities/Machine.cs | 76 +-- Software/Visual_Studio/Tango.BL/Entities/Spool.cs | 140 +++++ .../Visual_Studio/Tango.BL/Entities/SpoolType.cs | 38 ++ .../Tango.BL/EntitiesExtensions/Configuration.cs | 2 - .../Tango.BL/ObservablesStaticCollections.cs | 10 + .../Tango.DAL.Remote/DB/CONFIGURATION.cs | 2 - .../Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs | 4 +- .../Tango.DAL.Remote/DB/RemoteADO.Designer.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 87 ++- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 154 +++--- .../Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs | 5 + .../Tango.DAL.Remote/DB/SPOOL_TYPES.cs | 3 + .../Tango.UnitTesting/SQLExaminer_TST.cs | 1 - .../Tango.UnitTesting/Synchronization_TST.cs | 17 +- Software/Visual_Studio/Tango.Web/DeploymentSlot.cs | 2 + 37 files changed, 875 insertions(+), 629 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 967eddb23..c6a231daa 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 65b2bce77..d85206fe7 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk index fd3743ce5..9f377363e 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index a454f518f..9151c74ac 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk index ff739ffcb..ac84d995e 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk and b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk b/Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk index 4115fb2ac..db7f7c338 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk and b/Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk differ diff --git a/Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk b/Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk index 9294fa274..6f0433af2 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk and b/Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ConfigurationsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ConfigurationsViewVM.cs index 18c8c3daa..d5022c761 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ConfigurationsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ConfigurationsViewVM.cs @@ -18,7 +18,6 @@ namespace Tango.MachineStudio.DB.ViewModels protected override void InitializeEntity(Configuration entity) { base.InitializeEntity(entity); - entity.CreationDate = DateTime.UtcNow; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index 8ced2e510..a55d7e696 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -83,6 +83,9 @@ MachineDetailsView.xaml + + MachineSettingsView.xaml + MachinesView.xaml @@ -103,6 +106,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -254,7 +261,7 @@ - + \ No newline at end of file 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 e2924a185..b0b97d7d4 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 @@ -26,30 +26,21 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public class MainViewVM : StudioViewModel { private INotificationProvider _notification; - private ObservablesContext _dbContext; - private ObservablesContext _machineContext; - private ObservablesContext _configContext; #region Properties - private ObservableCollection _machines; - /// - /// Gets or sets the machines. - /// - public ObservableCollection Machines + private ObservablesStaticCollections _machinesAdapter; + public ObservablesStaticCollections MachinesAdapter { - get { return _machines; } - set { _machines = value; RaisePropertyChangedAuto(); } + get { return _machinesAdapter; } + set { _machinesAdapter = value; RaisePropertyChangedAuto(); } } - private ObservableCollection _dispensers; - /// - /// Gets or sets the dispensers. - /// - public ObservableCollection Dispensers + private ObservablesStaticCollections _activeMachineAdapter; + public ObservablesStaticCollections ActiveMachineAdapter { - get { return _dispensers; } - set { _dispensers = value; RaisePropertyChangedAuto(); } + get { return _activeMachineAdapter; } + set { _activeMachineAdapter = value; RaisePropertyChangedAuto(); } } private Machine _selectedMachine; @@ -80,17 +71,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _activeMachine = value; RaisePropertyChangedAuto(); } } - - private Configuration _configuration; - /// - /// Gets or sets the editable machine configuration. - /// - public Configuration Configuration - { - get { return _configuration; } - set { _configuration = value; RaisePropertyChangedAuto(); } - } - private IdsPack _selectedIds; /// /// Gets or sets the selected ids pack. @@ -155,6 +135,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// public RelayCommand EditMachineCommand { get; set; } + /// + /// Gets or sets the back to machines command. + /// + public RelayCommand BackToMachinesCommand { get; set; } + #endregion #region Constructors @@ -169,32 +154,17 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// public MainViewVM(INotificationProvider notification) { - _dbContext = ObservablesContext.CreateDefault(); + MachinesAdapter = new ObservablesStaticCollections(ObservablesContext.CreateDefault()); _notification = notification; //SaveCommand = new RelayCommand(Save); - AddIdsCommand = new RelayCommand(AddIds, (x) => Configuration != null && Configuration.IdsPacks.Count < 8); + AddIdsCommand = new RelayCommand(AddIds, (x) => ActiveMachine != null && ActiveMachine.Configuration != null && ActiveMachine.Configuration.IdsPacks.Count < 8); RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => SelectedIds != null); - EditMachineCommand = new RelayCommand(EditSelectedMachine, () => SelectedMachine != null); - } - - private async void EditSelectedMachine() - { - using (_notification.PushTaskItem("Loading machine details...")) - { - IsFree = false; - - if (_machineContext != null) - { - _machineContext.Dispose(); - } - - _machineContext = ObservablesContext.CreateDefault(); - ActiveMachine = (await new MachineBuilder(_machineContext).Set(SelectedMachine).WithOrganization().WithConfiguration().BuildAsync()); - View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); - - IsFree = true; - } + EditMachineCommand = new RelayCommand(() => LoadSelectedMachine(), () => SelectedMachine != null); + BackToMachinesCommand = new RelayCommand(() => View.NavigateTo(MachineDesignerNavigationView.MachinesView)); + SaveCommand = new RelayCommand(SaveMachine); + AddMachineCommand = new RelayCommand(AddNewMachine); + RemoveMachineCommand = new RelayCommand(RemoveSelectedMachine,() => SelectedMachine != null); } #endregion @@ -208,59 +178,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels #endregion - //private Task InitCollections() - //{ - // return Task.Factory.StartNew(() => - // { - // CanWork = false; - - // _dbContext = ObservablesContext.CreateDefault(); - - // Adapter = new ObservablesStaticCollections(); - // Adapter.ApplicationDisplayPanelVersions = _dbContext.ApplicationDisplayPanelVersions.ToObservableCollection(); - // Adapter.ApplicationFirmwareVersions = _dbContext.ApplicationFirmwareVersions.ToObservableCollection(); - // Adapter.ApplicationOsVersions = _dbContext.ApplicationOsVersions.ToObservableCollection(); - // Adapter.EmbeddedFirmwareVersions = _dbContext.EmbeddedFirmwareVersions.ToObservableCollection(); - // Adapter.DispenserTypes = _dbContext.DispenserTypes.ToObservableCollection(); - // Adapter.LiquidTypes = _dbContext.LiquidTypes.ToObservableCollection(); - // Adapter.MidTankTypes = _dbContext.MidTankTypes.ToObservableCollection(); - // Adapter.CartridgeTypes = _dbContext.CartridgeTypes.ToObservableCollection(); - // Adapter.IdsPackFormulas = _dbContext.IdsPackFormulas.ToObservableCollection(); - // Adapter.HardwareVersions = _dbContext.HardwareVersions.ToObservableCollection(); - // Adapter.MachineVersions = _dbContext.MachineVersions.ToObservableCollection(); - // Adapter.Organizations = _dbContext.Organizations.ToObservableCollection(); - - // Adapter.InitCollectionSources(); - - // CanWork = true; - // }); - //} - - private void Reset() - { - //using (_notification.PushTaskItem("Resetting designer...")) - //{ - // SelectedMachine = null; - // Machine = new Machine(); - // Configuration = new Configuration(); - // InitCollections(); - //} - } - private async void OnDispensersFilterChanged() { if (!String.IsNullOrWhiteSpace(DispensersFilter)) { IsFree = false; - Dispensers = (await _configContext.Dispensers.Where(x => x.SerialNumber.ToLower().StartsWith(DispensersFilter.ToLower())).ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.Dispensers = (await ActiveMachineAdapter.Context.Dispensers.Where(x => x.SerialNumber.ToLower().StartsWith(DispensersFilter.ToLower())).ToListAsync()).ToObservableCollection(); IsFree = true; } } - #region Virtual Methods - - #endregion - #region Drag Drop Handlers /// @@ -270,7 +197,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// The ids pack2. public void DropIdsPack(IdsPack idsPack1, IdsPack idsPack2) { - Configuration.IdsPacks.Swap(idsPack1, idsPack2); + ActiveMachine.Configuration.IdsPacks.Swap(idsPack1, idsPack2); } /// @@ -279,8 +206,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// The application display panel version. public void DropTouchPanel(ApplicationDisplayPanelVersion applicationDisplayPanelVersion) { - Configuration.ApplicationDisplayPanelVersion = applicationDisplayPanelVersion; - Configuration.ApplicationDisplayPanelVersionGuid = applicationDisplayPanelVersion.Guid; + ActiveMachine.Configuration.ApplicationDisplayPanelVersion = applicationDisplayPanelVersion; + ActiveMachine.Configuration.ApplicationDisplayPanelVersionGuid = applicationDisplayPanelVersion.Guid; } /// @@ -289,8 +216,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// The application firmware version. public void DropApplicationFirmwareVersion(ApplicationFirmwareVersion applicationFirmwareVersion) { - Configuration.ApplicationFirmwareVersion = applicationFirmwareVersion; - Configuration.ApplicationFirmwareVersionGuid = applicationFirmwareVersion.Guid; + ActiveMachine.Configuration.ApplicationFirmwareVersion = applicationFirmwareVersion; + ActiveMachine.Configuration.ApplicationFirmwareVersionGuid = applicationFirmwareVersion.Guid; } /// @@ -299,8 +226,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// The hardware version. public void DropHardwareVersion(HardwareVersion hardwareVersion) { - Configuration.HardwareVersion = hardwareVersion; - Configuration.HardwareVersionGuid = hardwareVersion.Guid; + ActiveMachine.Configuration.HardwareVersion = hardwareVersion; + ActiveMachine.Configuration.HardwareVersionGuid = hardwareVersion.Guid; } /// @@ -309,8 +236,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// The embedded firmware version. public void DropEmbeddedFirmware(EmbeddedFirmwareVersion embeddedFirmwareVersion) { - Configuration.EmbeddedFirmwareVersion = embeddedFirmwareVersion; - Configuration.EmbeddedFirmwareVersionGuid = embeddedFirmwareVersion.Guid; + ActiveMachine.Configuration.EmbeddedFirmwareVersion = embeddedFirmwareVersion; + ActiveMachine.Configuration.EmbeddedFirmwareVersionGuid = embeddedFirmwareVersion.Guid; } /// @@ -319,8 +246,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// The application os version. public void DropApplicationOsVersion(ApplicationOsVersion applicationOsVersion) { - Configuration.ApplicationOsVersion = applicationOsVersion; - Configuration.ApplicationOsVersionGuid = applicationOsVersion.Guid; + ActiveMachine.Configuration.ApplicationOsVersion = applicationOsVersion; + ActiveMachine.Configuration.ApplicationOsVersionGuid = applicationOsVersion.Guid; } /// @@ -388,7 +315,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// private void RemoveIds() { - _dbContext.IdsPacks.Remove(SelectedIds); + ActiveMachineAdapter.Context.IdsPacks.Remove(SelectedIds); SelectedIds = null; } @@ -397,249 +324,242 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// private void AddIds() { - _dbContext.IdsPacks.Add(new IdsPack() { Configuration = Configuration }); + ActiveMachineAdapter.Context.IdsPacks.Add(new IdsPack() { Configuration = ActiveMachine.Configuration }); InvalidateRelayCommands(); } - ///// - ///// Saves the current machine configuration. - ///// - //private async void Save() - //{ - // foreach (var ids in Configuration.IdsPacks) - // { - // ids.PackIndex = Configuration.IdsPacks.IndexOf(ids); - // ids.Configuration = Configuration; - // ids.ConfigurationGuid = Configuration.Guid; - // } - - // //Validate - - // List errors = new List(); - - // if (Machine.MachineVersion == null) - // { - // errors.Add("Machine version is required."); - // } - - // if (Machine.Name.IsNullOrWhiteSpace()) - // { - // errors.Add("Machine name is required."); - // } - - // if (Machine.Organization == null) - // { - // errors.Add("Machine organization is required."); - // } - - // if (Machine.SerialNumber.IsNullOrWhiteSpace()) - // { - // errors.Add("Machine serial number is required."); - // } - - // if (Configuration.Name.IsNullOrWhiteSpace()) - // { - // errors.Add("Configuration name is required."); - // } - - // if (Configuration.ApplicationDisplayPanelVersion == null) - // { - // errors.Add("Touch Panel is required."); - // } - - // if (Configuration.ApplicationFirmwareVersion == null) - // { - // errors.Add("Application firmware is required."); - // } - - // if (Configuration.ApplicationOsVersion == null) - // { - // errors.Add("Application operation system is required."); - // } - - // if (Configuration.EmbeddedFirmwareVersion == null) - // { - // errors.Add("Embedded firmware is required."); - // } - - // if (Configuration.HardwareVersion == null) - // { - // errors.Add("Hardware version is required."); - // } - - // foreach (var pack in Configuration.IdsPacks) - // { - // if (pack.LiquidType != null || pack.CartridgeType != null || pack.Dispenser != null || pack.IdsPackFormula != null || pack.MidTankType != null) - // { - // if (pack.CartridgeType == null) - // { - // errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.PackIndex)); - // } - // if (pack.Dispenser == null) - // { - // errors.Add(String.Format("Dispenser is required on IDS pack '{0}'.", pack.PackIndex)); - // } - // if (pack.LiquidType == null) - // { - // errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.PackIndex)); - // } - // if (pack.MidTankType == null) - // { - // errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.PackIndex)); - // } - // if (pack.IdsPackFormula == null) - // { - // errors.Add(String.Format("Formula type is required on IDS pack '{0}'.", pack.PackIndex)); - // } - - // pack.IsEmpty = false; - // } - // else - // { - // pack.IsEmpty = true; - // } - // } - - // if (errors.Count > 0) - // { - // String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine; - // errorsString += String.Join(Environment.NewLine, errors); - // _notification.ShowError(errorsString); - // return; - // } - - // //Validate - - // try - // { - // CanWork = false; - - // using (_notification.PushTaskItem("Saving Machine Configuration...")) - // { - // if (!_dbContext.Machines.Any(x => x.SerialNumber.ToLower() == Machine.SerialNumber.ToLower())) - // { - // if (!_notification.ShowQuestion("The specified machine serial number does not exist. Do you wish to create a new machine?")) - // { - // CanWork = true; - // return; - // } - // else - // { - // Machine.Configuration = Configuration; - // Configuration.CreationDate = DateTime.UtcNow; - // Machine.ProductionDate = DateTime.UtcNow; - - // _dbContext.Machines.Add(Machine); - // } - // } - - // await _dbContext.SaveChangesAsync(); - // OnSelectedMachineChanged(); - - // } - // } - // catch (Exception ex) - // { - // _notification.ShowError("An error occurred while trying to save the configuration" + Environment.NewLine + ex.Message); - // } - // finally - // { - // CanWork = true; - // InvalidateRelayCommands(); - // } - //} - - ///// - ///// Sets the current configuration to the selected machine version default configuration. - ///// - //private async void SetVersionConfiguration() - //{ - // if (Machine.MachineVersion != null) - // { - // using (_notification.PushTaskItem("Applying default configuration...")) - // { - // CanWork = false; - - // await Task.Factory.StartNew(() => - // { - // var version = _dbContext.MachineVersions.Where(x => x.Guid == Machine.MachineVersion.Guid).Include(x => x.DefaultConfiguration).FirstOrDefault(); - // var version_config = _dbContext.Adapter.GetConfiguration(x => x.Guid == version.DefaultConfiguration.Guid); - // Configuration = version_config.Clone(); - // Machine.Configuration = Configuration; - // }); - - // CanWork = true; - // } - // } - // else - // { - // _notification.ShowError("No machine version selected."); - // } - //} - - ///// - ///// Sets the current configuration as a default machine version configuration. - ///// - //private void SetAsDefaultConfiguration() - //{ - // _notification.ShowModalDialog(async (vm) => - // { - // CanWork = false; - - // try - // { - // using (_notification.PushTaskItem("Saving Default Configuration...")) - // { - // if (vm.SelectedVersion != null) - // { - // var version = _dbContext.MachineVersions.Where(x => x.Guid == vm.SelectedVersion.Guid).Include(x => x.DefaultConfiguration).SingleOrDefault(x => x.Guid == vm.SelectedVersion.Guid); - - // _dbContext.Configurations.Remove(version.DefaultConfiguration); - - // var cloned = Configuration.Clone(); - // _dbContext.Configurations.Add(cloned); - // version.DefaultConfiguration = cloned; - - // await _dbContext.SaveChangesAsync(); - // } - // else - // { - // MachineVersion newVersion = new MachineVersion(); - // newVersion.Version = vm.Version; - // newVersion.Name = vm.VersionName; - - // var cloned = Configuration.Clone(); - - // _dbContext.Configurations.Add(cloned); - // newVersion.DefaultConfiguration = cloned; - // _dbContext.MachineVersions.Add(newVersion); - // await _dbContext.SaveChangesAsync(); - // } - // } - // } - // catch (Exception ex) - // { - // _notification.ShowError(ex.Message); - // } - // finally - // { - // CanWork = true; - // } - - // }, () => - // { - - // }); - //} + private async void LoadSelectedMachine(bool newMachine = false) + { + using (_notification.PushTaskItem("Loading machine details...")) + { + try + { + IsFree = false; + + if (ActiveMachineAdapter != null) + { + ActiveMachineAdapter.Context.Dispose(); + } + + ActiveMachineAdapter = new ObservablesStaticCollections(ObservablesContext.CreateDefault()); + ActiveMachineAdapter.Organizations = (await ActiveMachineAdapter.Context.Organizations.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.MachineVersions = (await ActiveMachineAdapter.Context.MachineVersions.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.Rmls = (await ActiveMachineAdapter.Context.Rmls.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.ColorSpaces = (await ActiveMachineAdapter.Context.ColorSpaces.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.SpoolTypes = (await ActiveMachineAdapter.Context.SpoolTypes.ToListAsync()).ToObservableCollection(); + + ActiveMachineAdapter.ApplicationDisplayPanelVersions = (await ActiveMachineAdapter.Context.ApplicationDisplayPanelVersions.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.ApplicationFirmwareVersions = (await ActiveMachineAdapter.Context.ApplicationFirmwareVersions.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.ApplicationOsVersions = (await ActiveMachineAdapter.Context.ApplicationOsVersions.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.EmbeddedFirmwareVersions = (await ActiveMachineAdapter.Context.EmbeddedFirmwareVersions.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.DispenserTypes = (await ActiveMachineAdapter.Context.DispenserTypes.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.LiquidTypes = (await ActiveMachineAdapter.Context.LiquidTypes.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.MidTankTypes = (await ActiveMachineAdapter.Context.MidTankTypes.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.CartridgeTypes = (await ActiveMachineAdapter.Context.CartridgeTypes.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.IdsPackFormulas = (await ActiveMachineAdapter.Context.IdsPackFormulas.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.HardwareVersions = (await ActiveMachineAdapter.Context.HardwareVersions.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.MachineVersions = (await ActiveMachineAdapter.Context.MachineVersions.ToListAsync()).ToObservableCollection(); + ActiveMachineAdapter.Organizations = (await ActiveMachineAdapter.Context.Organizations.ToListAsync()).ToObservableCollection(); + + if (!newMachine) + { + ActiveMachine = (await new MachineBuilder(ActiveMachineAdapter.Context).Set(SelectedMachine.Guid).WithOrganization().WithConfiguration().WithSpools().BuildAsync()); + } + else + { + ActiveMachine = new Machine(); + ActiveMachine.Configuration = new Configuration(); + ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + } + + View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading machine details for serial number {SelectedMachine.SerialNumber}"); + _notification.ShowError($"An error occurred while trying to load the selected machine details.\n{ex.Message}"); + } + finally + { + IsFree = true; + InvalidateRelayCommands(); + } + } + } + + private async void SaveMachine() + { + foreach (var ids in ActiveMachine.Configuration.IdsPacks) + { + ids.PackIndex = ActiveMachine.Configuration.IdsPacks.IndexOf(ids); + ids.Configuration = ActiveMachine.Configuration; + ids.ConfigurationGuid = ActiveMachine.Configuration.Guid; + } + + List errors = new List(); + + if (ActiveMachine.MachineVersion == null) + { + errors.Add("Machine version is required."); + } + + if (ActiveMachine.Name.IsNullOrWhiteSpace()) + { + errors.Add("Machine name is required."); + } + + if (ActiveMachine.Organization == null) + { + errors.Add("Machine organization is required."); + } + + if (ActiveMachine.SerialNumber.IsNullOrWhiteSpace()) + { + errors.Add("Machine serial number is required."); + } + + if (ActiveMachine.Configuration.ApplicationDisplayPanelVersion == null) + { + errors.Add("Touch Panel is required."); + } + + if (ActiveMachine.Configuration.ApplicationFirmwareVersion == null) + { + errors.Add("Application firmware is required."); + } + + if (ActiveMachine.Configuration.ApplicationOsVersion == null) + { + errors.Add("Application operation system is required."); + } + + if (ActiveMachine.Configuration.EmbeddedFirmwareVersion == null) + { + errors.Add("Embedded firmware is required."); + } + + if (ActiveMachine.Configuration.HardwareVersion == null) + { + errors.Add("Hardware version is required."); + } + + foreach (var pack in ActiveMachine.Configuration.IdsPacks) + { + if (pack.LiquidType != null || pack.CartridgeType != null || pack.Dispenser != null || pack.IdsPackFormula != null || pack.MidTankType != null) + { + if (pack.CartridgeType == null) + { + errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.PackIndex)); + } + if (pack.Dispenser == null) + { + errors.Add(String.Format("Dispenser is required on IDS pack '{0}'.", pack.PackIndex)); + } + if (pack.LiquidType == null) + { + errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.PackIndex)); + } + if (pack.MidTankType == null) + { + errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.PackIndex)); + } + if (pack.IdsPackFormula == null) + { + errors.Add(String.Format("Formula type is required on IDS pack '{0}'.", pack.PackIndex)); + } + + pack.IsEmpty = false; + } + else + { + pack.IsEmpty = true; + } + } + + foreach (var pack in ActiveMachine.Configuration.IdsPacks.Where(x => x.Dispenser != null)) + { + if (ActiveMachine.Configuration.IdsPacks.Where(x => x.Dispenser == pack.Dispenser).Count() > 1) + { + errors.Add($"Dispenser '{pack.Dispenser.SerialNumber}' is installed on multiple IDS packs."); + } + + if (ActiveMachineAdapter.Context.IdsPacks.Count(x => x.ConfigurationGuid != pack.ConfigurationGuid && x.DispenserGuid == pack.DispenserGuid) > 0) + { + errors.Add($"Dispenser '{pack.Dispenser.SerialNumber}' is already installed on a different machine."); + } + } + + if (errors.Count > 0) + { + String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine; + errorsString += String.Join(Environment.NewLine, errors.Distinct()); + _notification.ShowError(errorsString); + return; + } + + try + { + IsFree = false; + + using (_notification.PushTaskItem("Saving Machine Details...")) + { + + ActiveMachine.ConfigurationGuid = ActiveMachine.Configuration.Guid; + ActiveMachine.LastUpdated = DateTime.UtcNow; + ActiveMachine.ProductionDate = DateTime.UtcNow; + await ActiveMachineAdapter.Context.SaveChangesAsync(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving machine details."); + _notification.ShowError("An error occurred while trying to save the machine details" + Environment.NewLine + ex.Message); + } + finally + { + IsFree = true; + InvalidateRelayCommands(); + } + } + + private void AddNewMachine() + { + LoadSelectedMachine(true); + } + + private async void RemoveSelectedMachine() + { + if (_notification.ShowQuestion("Are you sure you want to delete the selected machine?")) + { + using (_notification.PushTaskItem("Removing machine...")) + { + try + { + IsFree = false; + await SelectedMachine.DeleteCascadeAsync(MachinesAdapter.Context); + MachinesAdapter.Context.Machines.Remove(SelectedMachine); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error removing machine {SelectedMachine.SerialNumber}."); + _notification.ShowError($"An error occurred while trying to delete the selected machine.\n{ex.Message}"); + } + finally + { + IsFree = true; + } + } + } + } #endregion private async void OnFilterChanged() { - if (!String.IsNullOrWhiteSpace(Filter)) + if (Filter != null) { IsFree = false; - Machines = (await _dbContext.Machines.Where(x => x.SerialNumber.StartsWith(Filter)).ToListAsync()).ToObservableCollection(); + MachinesAdapter.Machines = (await MachinesAdapter.Context.Machines.Where(x => x.SerialNumber.StartsWith(Filter)).Include(x => x.Organization).Include(x => x.MachineVersion).ToListAsync()).ToObservableCollection(); IsFree = true; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml index a96cd4685..97eceaa7d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml @@ -102,8 +102,8 @@ - - + + @@ -145,7 +145,7 @@ 8 - + + + + + + + + + + + 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 new file mode 100644 index 000000000..63d1d2305 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + Serial Number + + + Name + + + Machine Version + + + Organization + + + Default RML + + + Loaded RML + + + Default Color Space + + + Default Segment Length + + + Default Spool Type + + + OS Key + + + + + Auto Login + + + Auto Check For Updates + + + Setup Activation + + + Setup Remote Assistance + + + Setup UWF + + + Setup Firmware + + + Setup FPGA + + + Is Demo Machine + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml.cs new file mode 100644 index 000000000..29367c3c4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.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.MachineDesigner.Views +{ + /// + /// Interaction logic for MachineDetailsView.xaml + /// + public partial class MachineSettingsView : UserControl + { + public MachineSettingsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml index ded14930a..d6afd41bf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml @@ -69,25 +69,6 @@ - Add IDS - - - - - - Remove IDS - - - - - - - - 1 2 diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml index 48ce34688..91eda3491 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml @@ -53,7 +53,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.xaml.cs new file mode 100644 index 000000000..90a0c37f2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/SpoolsView.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.MachineDesigner.Views +{ + /// + /// Interaction logic for SpoolsView.xaml + /// + public partial class SpoolsView : UserControl + { + public SpoolsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs index c75c7cec0..dd27d94f0 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/MachineBuilder.cs @@ -47,9 +47,9 @@ namespace Tango.BL.Builders public virtual MachineBuilder WithSpools() { - return AddStep(3, () => + return AddStep(4, () => { - Context.Spools.Where(x => x.MachineGuide == Entity.Guid).Include(x => x.SpoolType).ToList(); + Context.Spools.Where(x => x.MachineGuid == Entity.Guid).Include(x => x.SpoolType).ToList(); }); } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Spool.cs b/Software/Visual_Studio/Tango.BL/Entities/Spool.cs index a38c1eb48..fa8816ec5 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Spool.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Spool.cs @@ -25,9 +25,15 @@ namespace Tango.BL.Entities public partial class Spool : ObservableEntity { - public event EventHandler MachineGuideChanged; + public event EventHandler StartOffsetPulsesChanged; - public event EventHandler MachineeChanged; + public event EventHandler BackingRateChanged; + + public event EventHandler SegmentOffsetPulsesChanged; + + public event EventHandler BottomBackingRateChanged; + + public event EventHandler MachineChanged; public event EventHandler SpoolTypeChanged; @@ -56,35 +62,140 @@ namespace Tango.BL.Entities } } - protected String _machineguide; + protected String _machineguid; + + /// + /// Gets or sets the spool machine guid. + /// + + [Column("MACHINE_GUID")] + [ForeignKey("Machine")] + + public String MachineGuid + { + get + { + return _machineguid; + } + + set + { + if (_machineguid != value) + { + _machineguid = value; + } + } + } + + protected Int32 _startoffsetpulses; + + /// + /// Gets or sets the spool start offset pulses. + /// + + [Column("START_OFFSET_PULSES")] + + public Int32 StartOffsetPulses + { + get + { + return _startoffsetpulses; + } + + set + { + if (_startoffsetpulses != value) + { + _startoffsetpulses = value; + + OnStartOffsetPulsesChanged(value); + + } + } + } + + protected Int32 _backingrate; + + /// + /// Gets or sets the spool backing rate. + /// + + [Column("BACKING_RATE")] + + public Int32 BackingRate + { + get + { + return _backingrate; + } + + set + { + if (_backingrate != value) + { + _backingrate = value; + + OnBackingRateChanged(value); + + } + } + } + + protected Int32 _segmentoffsetpulses; + + /// + /// Gets or sets the spool segment offset pulses. + /// + + [Column("SEGMENT_OFFSET_PULSES")] + + public Int32 SegmentOffsetPulses + { + get + { + return _segmentoffsetpulses; + } + + set + { + if (_segmentoffsetpulses != value) + { + _segmentoffsetpulses = value; + + OnSegmentOffsetPulsesChanged(value); + + } + } + } + + protected Int32 _bottombackingrate; /// - /// Gets or sets the spool machine guide. + /// Gets or sets the spool bottom backing rate. /// - [Column("MACHINE_GUIDE")] - [ForeignKey("Machinee")] + [Column("BOTTOM_BACKING_RATE")] - public String MachineGuide + public Int32 BottomBackingRate { get { - return _machineguide; + return _bottombackingrate; } set { - if (_machineguide != value) + if (_bottombackingrate != value) { - _machineguide = value; + _bottombackingrate = value; - OnMachineGuideChanged(value); + OnBottomBackingRateChanged(value); } } } - protected Machine _machinee; + protected Machine _machine; /// /// Gets or sets the spool machine. @@ -92,20 +203,20 @@ namespace Tango.BL.Entities [XmlIgnore] [JsonIgnore] - public virtual Machine Machinee + public virtual Machine Machine { get { - return _machinee; + return _machine; } set { - if (_machinee != value) + if (_machine != value) { - _machinee = value; + _machine = value; - OnMachineeChanged(value); + OnMachineChanged(value); } } @@ -139,21 +250,48 @@ namespace Tango.BL.Entities } /// - /// Called when the MachineGuide has changed. + /// Called when the StartOffsetPulses has changed. + /// + protected virtual void OnStartOffsetPulsesChanged(Int32 startoffsetpulses) + { + StartOffsetPulsesChanged?.Invoke(this, startoffsetpulses); + RaisePropertyChanged(nameof(StartOffsetPulses)); + } + + /// + /// Called when the BackingRate has changed. + /// + protected virtual void OnBackingRateChanged(Int32 backingrate) + { + BackingRateChanged?.Invoke(this, backingrate); + RaisePropertyChanged(nameof(BackingRate)); + } + + /// + /// Called when the SegmentOffsetPulses has changed. + /// + protected virtual void OnSegmentOffsetPulsesChanged(Int32 segmentoffsetpulses) + { + SegmentOffsetPulsesChanged?.Invoke(this, segmentoffsetpulses); + RaisePropertyChanged(nameof(SegmentOffsetPulses)); + } + + /// + /// Called when the BottomBackingRate has changed. /// - protected virtual void OnMachineGuideChanged(String machineguide) + protected virtual void OnBottomBackingRateChanged(Int32 bottombackingrate) { - MachineGuideChanged?.Invoke(this, machineguide); - RaisePropertyChanged(nameof(MachineGuide)); + BottomBackingRateChanged?.Invoke(this, bottombackingrate); + RaisePropertyChanged(nameof(BottomBackingRate)); } /// - /// Called when the Machinee has changed. + /// Called when the Machine has changed. /// - protected virtual void OnMachineeChanged(Machine machinee) + protected virtual void OnMachineChanged(Machine machine) { - MachineeChanged?.Invoke(this, machinee); - RaisePropertyChanged(nameof(Machinee)); + MachineChanged?.Invoke(this, machine); + RaisePropertyChanged(nameof(Machine)); } /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/SpoolType.cs b/Software/Visual_Studio/Tango.BL/Entities/SpoolType.cs index eafc39a25..a469220c5 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/SpoolType.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/SpoolType.cs @@ -35,14 +35,6 @@ namespace Tango.BL.Entities public event EventHandler DiameterChanged; - public event EventHandler StartOffsetPulsesChanged; - - public event EventHandler BackingRateChanged; - - public event EventHandler SegmentOffsetPulsesChanged; - - public event EventHandler BottomBackingRateChanged; - public event EventHandler RotationsPerPassageChanged; public event EventHandler> JobsChanged; @@ -186,114 +178,6 @@ namespace Tango.BL.Entities } } - protected Int32 _startoffsetpulses; - - /// - /// Gets or sets the spooltype start offset pulses. - /// - - [Column("START_OFFSET_PULSES")] - - public Int32 StartOffsetPulses - { - get - { - return _startoffsetpulses; - } - - set - { - if (_startoffsetpulses != value) - { - _startoffsetpulses = value; - - OnStartOffsetPulsesChanged(value); - - } - } - } - - protected Int32 _backingrate; - - /// - /// Gets or sets the spooltype backing rate. - /// - - [Column("BACKING_RATE")] - - public Int32 BackingRate - { - get - { - return _backingrate; - } - - set - { - if (_backingrate != value) - { - _backingrate = value; - - OnBackingRateChanged(value); - - } - } - } - - protected Int32 _segmentoffsetpulses; - - /// - /// Gets or sets the spooltype segment offset pulses. - /// - - [Column("SEGMENT_OFFSET_PULSES")] - - public Int32 SegmentOffsetPulses - { - get - { - return _segmentoffsetpulses; - } - - set - { - if (_segmentoffsetpulses != value) - { - _segmentoffsetpulses = value; - - OnSegmentOffsetPulsesChanged(value); - - } - } - } - - protected Int32 _bottombackingrate; - - /// - /// Gets or sets the spooltype bottom backing rate. - /// - - [Column("BOTTOM_BACKING_RATE")] - - public Int32 BottomBackingRate - { - get - { - return _bottombackingrate; - } - - set - { - if (_bottombackingrate != value) - { - _bottombackingrate = value; - - OnBottomBackingRateChanged(value); - - } - } - } - protected Double _rotationsperpassage; /// @@ -441,42 +325,6 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Diameter)); } - /// - /// Called when the StartOffsetPulses has changed. - /// - protected virtual void OnStartOffsetPulsesChanged(Int32 startoffsetpulses) - { - StartOffsetPulsesChanged?.Invoke(this, startoffsetpulses); - RaisePropertyChanged(nameof(StartOffsetPulses)); - } - - /// - /// Called when the BackingRate has changed. - /// - protected virtual void OnBackingRateChanged(Int32 backingrate) - { - BackingRateChanged?.Invoke(this, backingrate); - RaisePropertyChanged(nameof(BackingRate)); - } - - /// - /// Called when the SegmentOffsetPulses has changed. - /// - protected virtual void OnSegmentOffsetPulsesChanged(Int32 segmentoffsetpulses) - { - SegmentOffsetPulsesChanged?.Invoke(this, segmentoffsetpulses); - RaisePropertyChanged(nameof(SegmentOffsetPulses)); - } - - /// - /// Called when the BottomBackingRate has changed. - /// - protected virtual void OnBottomBackingRateChanged(Int32 bottombackingrate) - { - BottomBackingRateChanged?.Invoke(this, bottombackingrate); - RaisePropertyChanged(nameof(BottomBackingRate)); - } - /// /// Called when the RotationsPerPassage has changed. /// diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index bb3d1be20..eecb142ee 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -932,10 +932,6 @@ - - - - @@ -946,7 +942,11 @@ - + + + + + @@ -2071,7 +2071,7 @@ - + @@ -2080,7 +2080,7 @@ - + @@ -4107,10 +4107,6 @@ - - - - @@ -4124,7 +4120,11 @@ - + + + + + @@ -5180,7 +5180,7 @@ - + @@ -5189,7 +5189,7 @@ - + @@ -6370,10 +6370,6 @@ - - - - @@ -6388,7 +6384,11 @@ - + + + + + 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 d42da3d76..dc1208fee 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,82 +5,82 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs index 0194eb67f..74996acd0 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL.cs @@ -18,7 +18,11 @@ namespace Tango.DAL.Remote.DB public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } public string SPOOL_TYPE_GUID { get; set; } - public string MACHINE_GUIDE { get; set; } + public string MACHINE_GUID { get; set; } + public int START_OFFSET_PULSES { get; set; } + public int BACKING_RATE { get; set; } + public int SEGMENT_OFFSET_PULSES { get; set; } + public int BOTTOM_BACKING_RATE { get; set; } public virtual MACHINE MACHINE { get; set; } public virtual SPOOL_TYPES SPOOL_TYPES { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL_TYPES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL_TYPES.cs index dc264ea58..1d8b75f90 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL_TYPES.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SPOOL_TYPES.cs @@ -30,10 +30,6 @@ namespace Tango.DAL.Remote.DB public double LENGTH { get; set; } public double WEIGHT { get; set; } public double DIAMETER { get; set; } - public int START_OFFSET_PULSES { get; set; } - public int BACKING_RATE { get; set; } - public int SEGMENT_OFFSET_PULSES { get; set; } - public int BOTTOM_BACKING_RATE { get; set; } public double ROTATIONS_PER_PASSAGE { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index aa5f93b11..868a87d97 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -1213,6 +1213,18 @@ namespace Tango.Integration.Operation ticket.Spool = new JobSpool(); job.SpoolType.MapPrimitivesTo(ticket.Spool); + + var spool = job.Machine.Spools.SingleOrDefault(x => x.SpoolType == job.SpoolType); + + if (spool == null) + { + throw new InvalidOperationException("Job spool type is not registered with this machine."); + } + else + { + spool.MapPrimitivesTo(ticket.Spool); + } + ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; ProcessParameters process = new ProcessParameters(); diff --git a/Software/Visual_Studio/Tango.PMR/Hardware/HardwareDispenser.cs b/Software/Visual_Studio/Tango.PMR/Hardware/HardwareDispenser.cs index 9e5920f01..25a6742a3 100644 --- a/Software/Visual_Studio/Tango.PMR/Hardware/HardwareDispenser.cs +++ b/Software/Visual_Studio/Tango.PMR/Hardware/HardwareDispenser.cs @@ -26,12 +26,12 @@ namespace Tango.PMR.Hardware { "GhtIYXJkd2FyZURpc3BlbnNlclR5cGUucHJvdG8ikgEKEUhhcmR3YXJlRGlz", "cGVuc2VyEkgKFUhhcmR3YXJlRGlzcGVuc2VyVHlwZRgBIAEoDjIpLlRhbmdv", "LlBNUi5IYXJkd2FyZS5IYXJkd2FyZURpc3BlbnNlclR5cGUSDQoFSW5kZXgY", - "AiABKAUSEgoKTmxQZXJQdWxzZRgDIAEoARIQCghDYXBhY2l0eRgEIAEoAUIe", + "AiABKAUSEAoIQ2FwYWNpdHkYAyABKAESEgoKTmxQZXJQdWxzZRgEIAEoAUIe", "Chxjb20udHdpbmUudGFuZ28ucG1yLmhhcmR3YXJlYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Hardware.HardwareDispenserTypeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwareDispenser), global::Tango.PMR.Hardware.HardwareDispenser.Parser, new[]{ "HardwareDispenserType", "Index", "NlPerPulse", "Capacity" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwareDispenser), global::Tango.PMR.Hardware.HardwareDispenser.Parser, new[]{ "HardwareDispenserType", "Index", "Capacity", "NlPerPulse" }, null, null, null) })); } #endregion @@ -64,8 +64,8 @@ namespace Tango.PMR.Hardware { public HardwareDispenser(HardwareDispenser other) : this() { hardwareDispenserType_ = other.hardwareDispenserType_; index_ = other.index_; - nlPerPulse_ = other.nlPerPulse_; capacity_ = other.capacity_; + nlPerPulse_ = other.nlPerPulse_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -95,19 +95,8 @@ namespace Tango.PMR.Hardware { } } - /// Field number for the "NlPerPulse" field. - public const int NlPerPulseFieldNumber = 3; - private double nlPerPulse_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double NlPerPulse { - get { return nlPerPulse_; } - set { - nlPerPulse_ = value; - } - } - /// Field number for the "Capacity" field. - public const int CapacityFieldNumber = 4; + public const int CapacityFieldNumber = 3; private double capacity_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public double Capacity { @@ -117,6 +106,17 @@ namespace Tango.PMR.Hardware { } } + /// Field number for the "NlPerPulse" field. + public const int NlPerPulseFieldNumber = 4; + private double nlPerPulse_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double NlPerPulse { + get { return nlPerPulse_; } + set { + nlPerPulse_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HardwareDispenser); @@ -132,8 +132,8 @@ namespace Tango.PMR.Hardware { } if (HardwareDispenserType != other.HardwareDispenserType) return false; if (Index != other.Index) return false; - if (NlPerPulse != other.NlPerPulse) return false; if (Capacity != other.Capacity) return false; + if (NlPerPulse != other.NlPerPulse) return false; return true; } @@ -142,8 +142,8 @@ namespace Tango.PMR.Hardware { int hash = 1; if (HardwareDispenserType != 0) hash ^= HardwareDispenserType.GetHashCode(); if (Index != 0) hash ^= Index.GetHashCode(); - if (NlPerPulse != 0D) hash ^= NlPerPulse.GetHashCode(); if (Capacity != 0D) hash ^= Capacity.GetHashCode(); + if (NlPerPulse != 0D) hash ^= NlPerPulse.GetHashCode(); return hash; } @@ -162,13 +162,13 @@ namespace Tango.PMR.Hardware { output.WriteRawTag(16); output.WriteInt32(Index); } - if (NlPerPulse != 0D) { + if (Capacity != 0D) { output.WriteRawTag(25); - output.WriteDouble(NlPerPulse); + output.WriteDouble(Capacity); } - if (Capacity != 0D) { + if (NlPerPulse != 0D) { output.WriteRawTag(33); - output.WriteDouble(Capacity); + output.WriteDouble(NlPerPulse); } } @@ -181,10 +181,10 @@ namespace Tango.PMR.Hardware { if (Index != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Index); } - if (NlPerPulse != 0D) { + if (Capacity != 0D) { size += 1 + 8; } - if (Capacity != 0D) { + if (NlPerPulse != 0D) { size += 1 + 8; } return size; @@ -201,12 +201,12 @@ namespace Tango.PMR.Hardware { if (other.Index != 0) { Index = other.Index; } - if (other.NlPerPulse != 0D) { - NlPerPulse = other.NlPerPulse; - } if (other.Capacity != 0D) { Capacity = other.Capacity; } + if (other.NlPerPulse != 0D) { + NlPerPulse = other.NlPerPulse; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -226,11 +226,11 @@ namespace Tango.PMR.Hardware { break; } case 25: { - NlPerPulse = input.ReadDouble(); + Capacity = input.ReadDouble(); break; } case 33: { - Capacity = input.ReadDouble(); + NlPerPulse = input.ReadDouble(); break; } } diff --git a/Software/Visual_Studio/Tango.PMR/Printing/JobSpool.cs b/Software/Visual_Studio/Tango.PMR/Printing/JobSpool.cs index afe846303..7261ba19b 100644 --- a/Software/Visual_Studio/Tango.PMR/Printing/JobSpool.cs +++ b/Software/Visual_Studio/Tango.PMR/Printing/JobSpool.cs @@ -25,15 +25,15 @@ namespace Tango.PMR.Printing { "Cg5Kb2JTcG9vbC5wcm90bxISVGFuZ28uUE1SLlByaW50aW5nGhJKb2JTcG9v", "bFR5cGUucHJvdG8i+QEKCEpvYlNwb29sEjYKDEpvYlNwb29sVHlwZRgBIAEo", "DjIgLlRhbmdvLlBNUi5QcmludGluZy5Kb2JTcG9vbFR5cGUSDgoGTGVuZ3Ro", - "GAIgASgBEg4KBldlaWdodBgDIAEoARIQCghEaWFtZXRlchgEIAEoARIZChFT", - "dGFydE9mZnNldFB1bHNlcxgFIAEoBRITCgtCYWNraW5nUmF0ZRgGIAEoBRIb", - "ChNTZWdtZW50T2Zmc2V0UHVsc2VzGAcgASgFEhkKEUJvdHRvbUJhY2tpbmdS", - "YXRlGAggASgFEhsKE1JvdGF0aW9uc1BlclBhc3NhZ2UYCSABKAFCHgocY29t", + "GAIgASgBEg4KBldlaWdodBgDIAEoARIQCghEaWFtZXRlchgEIAEoARIbChNS", + "b3RhdGlvbnNQZXJQYXNzYWdlGAUgASgBEhkKEVN0YXJ0T2Zmc2V0UHVsc2Vz", + "GAYgASgFEhMKC0JhY2tpbmdSYXRlGAcgASgFEhsKE1NlZ21lbnRPZmZzZXRQ", + "dWxzZXMYCCABKAUSGQoRQm90dG9tQmFja2luZ1JhdGUYCSABKAVCHgocY29t", "LnR3aW5lLnRhbmdvLnBtci5wcmludGluZ2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Printing.JobSpoolTypeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.JobSpool), global::Tango.PMR.Printing.JobSpool.Parser, new[]{ "JobSpoolType", "Length", "Weight", "Diameter", "StartOffsetPulses", "BackingRate", "SegmentOffsetPulses", "BottomBackingRate", "RotationsPerPassage" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Printing.JobSpool), global::Tango.PMR.Printing.JobSpool.Parser, new[]{ "JobSpoolType", "Length", "Weight", "Diameter", "RotationsPerPassage", "StartOffsetPulses", "BackingRate", "SegmentOffsetPulses", "BottomBackingRate" }, null, null, null) })); } #endregion @@ -68,11 +68,11 @@ namespace Tango.PMR.Printing { length_ = other.length_; weight_ = other.weight_; diameter_ = other.diameter_; + rotationsPerPassage_ = other.rotationsPerPassage_; startOffsetPulses_ = other.startOffsetPulses_; backingRate_ = other.backingRate_; segmentOffsetPulses_ = other.segmentOffsetPulses_; bottomBackingRate_ = other.bottomBackingRate_; - rotationsPerPassage_ = other.rotationsPerPassage_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -124,8 +124,19 @@ namespace Tango.PMR.Printing { } } + /// Field number for the "RotationsPerPassage" field. + public const int RotationsPerPassageFieldNumber = 5; + private double rotationsPerPassage_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double RotationsPerPassage { + get { return rotationsPerPassage_; } + set { + rotationsPerPassage_ = value; + } + } + /// Field number for the "StartOffsetPulses" field. - public const int StartOffsetPulsesFieldNumber = 5; + public const int StartOffsetPulsesFieldNumber = 6; private int startOffsetPulses_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int StartOffsetPulses { @@ -136,7 +147,7 @@ namespace Tango.PMR.Printing { } /// Field number for the "BackingRate" field. - public const int BackingRateFieldNumber = 6; + public const int BackingRateFieldNumber = 7; private int backingRate_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int BackingRate { @@ -147,7 +158,7 @@ namespace Tango.PMR.Printing { } /// Field number for the "SegmentOffsetPulses" field. - public const int SegmentOffsetPulsesFieldNumber = 7; + public const int SegmentOffsetPulsesFieldNumber = 8; private int segmentOffsetPulses_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int SegmentOffsetPulses { @@ -158,7 +169,7 @@ namespace Tango.PMR.Printing { } /// Field number for the "BottomBackingRate" field. - public const int BottomBackingRateFieldNumber = 8; + public const int BottomBackingRateFieldNumber = 9; private int bottomBackingRate_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int BottomBackingRate { @@ -168,17 +179,6 @@ namespace Tango.PMR.Printing { } } - /// Field number for the "RotationsPerPassage" field. - public const int RotationsPerPassageFieldNumber = 9; - private double rotationsPerPassage_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double RotationsPerPassage { - get { return rotationsPerPassage_; } - set { - rotationsPerPassage_ = value; - } - } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as JobSpool); @@ -196,11 +196,11 @@ namespace Tango.PMR.Printing { if (Length != other.Length) return false; if (Weight != other.Weight) return false; if (Diameter != other.Diameter) return false; + if (RotationsPerPassage != other.RotationsPerPassage) return false; if (StartOffsetPulses != other.StartOffsetPulses) return false; if (BackingRate != other.BackingRate) return false; if (SegmentOffsetPulses != other.SegmentOffsetPulses) return false; if (BottomBackingRate != other.BottomBackingRate) return false; - if (RotationsPerPassage != other.RotationsPerPassage) return false; return true; } @@ -211,11 +211,11 @@ namespace Tango.PMR.Printing { if (Length != 0D) hash ^= Length.GetHashCode(); if (Weight != 0D) hash ^= Weight.GetHashCode(); if (Diameter != 0D) hash ^= Diameter.GetHashCode(); + if (RotationsPerPassage != 0D) hash ^= RotationsPerPassage.GetHashCode(); if (StartOffsetPulses != 0) hash ^= StartOffsetPulses.GetHashCode(); if (BackingRate != 0) hash ^= BackingRate.GetHashCode(); if (SegmentOffsetPulses != 0) hash ^= SegmentOffsetPulses.GetHashCode(); if (BottomBackingRate != 0) hash ^= BottomBackingRate.GetHashCode(); - if (RotationsPerPassage != 0D) hash ^= RotationsPerPassage.GetHashCode(); return hash; } @@ -242,26 +242,26 @@ namespace Tango.PMR.Printing { output.WriteRawTag(33); output.WriteDouble(Diameter); } + if (RotationsPerPassage != 0D) { + output.WriteRawTag(41); + output.WriteDouble(RotationsPerPassage); + } if (StartOffsetPulses != 0) { - output.WriteRawTag(40); + output.WriteRawTag(48); output.WriteInt32(StartOffsetPulses); } if (BackingRate != 0) { - output.WriteRawTag(48); + output.WriteRawTag(56); output.WriteInt32(BackingRate); } if (SegmentOffsetPulses != 0) { - output.WriteRawTag(56); + output.WriteRawTag(64); output.WriteInt32(SegmentOffsetPulses); } if (BottomBackingRate != 0) { - output.WriteRawTag(64); + output.WriteRawTag(72); output.WriteInt32(BottomBackingRate); } - if (RotationsPerPassage != 0D) { - output.WriteRawTag(73); - output.WriteDouble(RotationsPerPassage); - } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -279,6 +279,9 @@ namespace Tango.PMR.Printing { if (Diameter != 0D) { size += 1 + 8; } + if (RotationsPerPassage != 0D) { + size += 1 + 8; + } if (StartOffsetPulses != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(StartOffsetPulses); } @@ -291,9 +294,6 @@ namespace Tango.PMR.Printing { if (BottomBackingRate != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(BottomBackingRate); } - if (RotationsPerPassage != 0D) { - size += 1 + 8; - } return size; } @@ -314,6 +314,9 @@ namespace Tango.PMR.Printing { if (other.Diameter != 0D) { Diameter = other.Diameter; } + if (other.RotationsPerPassage != 0D) { + RotationsPerPassage = other.RotationsPerPassage; + } if (other.StartOffsetPulses != 0) { StartOffsetPulses = other.StartOffsetPulses; } @@ -326,9 +329,6 @@ namespace Tango.PMR.Printing { if (other.BottomBackingRate != 0) { BottomBackingRate = other.BottomBackingRate; } - if (other.RotationsPerPassage != 0D) { - RotationsPerPassage = other.RotationsPerPassage; - } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -355,24 +355,24 @@ namespace Tango.PMR.Printing { Diameter = input.ReadDouble(); break; } - case 40: { - StartOffsetPulses = input.ReadInt32(); + case 41: { + RotationsPerPassage = input.ReadDouble(); break; } case 48: { - BackingRate = input.ReadInt32(); + StartOffsetPulses = input.ReadInt32(); break; } case 56: { - SegmentOffsetPulses = input.ReadInt32(); + BackingRate = input.ReadInt32(); break; } case 64: { - BottomBackingRate = input.ReadInt32(); + SegmentOffsetPulses = input.ReadInt32(); break; } - case 73: { - RotationsPerPassage = input.ReadDouble(); + case 72: { + BottomBackingRate = input.ReadInt32(); break; } } diff --git a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs index fda19dbd1..849dd5cde 100644 --- a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs @@ -214,6 +214,14 @@ namespace Tango.PMRGenerator.CLI } } + foreach (var prop in typeof(Dispenser).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) + { + if (prop.Name != nameof(Dispenser.IsInstalled)) + { + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType), GetDbDescription(prop))); + } + } + String enumString = enumFile.GenerateCode(); String messageString = messageFile.GenerateCode(); @@ -534,6 +542,11 @@ namespace Tango.PMRGenerator.CLI } } + foreach (var prop in typeof(Spool).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsPrimitive)) + { + messageFile.Properties.Add(new ProtoProperty(prop.Name, CoercePropertyType(prop.PropertyType))); + } + String enumString = enumFile.GenerateCode(); String messageString = messageFile.GenerateCode(); -- cgit v1.3.1 From cfe28eaf0adcd54776c0a369210e6f7b4bca9558 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 30 Dec 2018 19:25:18 +0200 Subject: Added machine clone in machine designer ! --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../ViewModels/MainViewVM.cs | 5 +++- .../Views/DispensersView.xaml | 2 +- .../ViewModels/MainViewVM.cs | 31 ++++++++++++++++----- .../Views/MachinesView.xaml | 6 ++++ .../Tango.BL/EntitiesExtensions/Cat.cs | 7 +++++ .../Tango.BL/EntitiesExtensions/Configuration.cs | 3 +- .../Tango.BL/EntitiesExtensions/Machine.cs | 11 ++++++++ .../Tango.BL/EntitiesExtensions/Spool.cs | 18 ++++++++++++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 3 +- 11 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/EntitiesExtensions/Spool.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 2da0d929f..da510375d 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 f758ff284..7f70f4baf 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/MachineStudio.Dispensers/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/ViewModels/MainViewVM.cs index ca384f6bf..d92d86580 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/ViewModels/MainViewVM.cs @@ -170,7 +170,10 @@ namespace Tango.MachineStudio.Dispensers.ViewModels { IsFree = false; await _activeContext.SaveChangesAsync(); - await SelectedDispenser.Reload(_dbContext); + if (SelectedDispenser != null) + { + await SelectedDispenser.Reload(_dbContext); + } } catch (Exception ex) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml index 91ee5a189..9f36ee78a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml @@ -67,7 +67,7 @@ - + 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 a5b54fed2..2f77b0d14 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 @@ -158,6 +158,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// public RelayCommand RemoveSpoolCommand { get; set; } + public RelayCommand CloneMachineCommand { get; set; } #endregion #region Constructors @@ -182,12 +183,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels BackToMachinesCommand = new RelayCommand(() => View.NavigateTo(MachineDesignerNavigationView.MachinesView)); SaveCommand = new RelayCommand(SaveMachine); AddMachineCommand = new RelayCommand(AddNewMachine); - RemoveMachineCommand = new RelayCommand(RemoveSelectedMachine,() => SelectedMachine != null); + RemoveMachineCommand = new RelayCommand(RemoveSelectedMachine, () => SelectedMachine != null); AddSpoolCommand = new RelayCommand(AddNewSpool); - RemoveSpoolCommand = new RelayCommand(RemoveSpool,() => SelectedSpool != null); + RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null); + CloneMachineCommand = new RelayCommand(CloneMachine, () => SelectedMachine != null); } - - #endregion #region Application Ready @@ -349,7 +349,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels InvalidateRelayCommands(); } - private async void LoadSelectedMachine(bool newMachine = false) + private async void LoadSelectedMachine(bool newMachine = false, bool clone = false) { using (_notification.PushTaskItem("Loading machine details...")) { @@ -385,6 +385,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels if (!newMachine) { ActiveMachine = (await new MachineBuilder(ActiveMachineAdapter.Context).Set(SelectedMachine.Guid).WithOrganization().WithConfiguration().WithSpools().BuildAsync()); + + if (clone) + { + ActiveMachine = ActiveMachine.Clone(); + ActiveMachine.Name = "Untitled"; + ActiveMachine.SerialNumber = ""; + ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); + } } else { @@ -534,7 +542,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.LastUpdated = DateTime.UtcNow; ActiveMachine.ProductionDate = DateTime.UtcNow; await ActiveMachineAdapter.Context.SaveChangesAsync(); - await SelectedMachine.Reload(MachinesAdapter.Context); + + if (SelectedMachine != null) + { + await SelectedMachine.Reload(MachinesAdapter.Context); + } } } catch (Exception ex) @@ -581,11 +593,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels #endregion + private void CloneMachine() + { + LoadSelectedMachine(false, true); + } + private void AddNewSpool() { _activeMachineAdapter.Context.Spools.Add(new Spool() { - Machine = ActiveMachine, + Machine = ActiveMachine, }); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml index 91eda3491..096beee39 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml @@ -36,6 +36,12 @@ DELETE + + + + + + + + + Please specify the machine version in order to prototype the new machine with default machine settings and configuartion. + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml.cs new file mode 100644 index 000000000..3901309a9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.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.MachineDesigner.Views +{ + /// + /// Interaction logic for MachineCreationDialog.xaml + /// + public partial class MachineCreationDialog : UserControl + { + public MachineCreationDialog() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs index 2192483c9..46bf63194 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -226,7 +226,7 @@ namespace Tango.MachineStudio.UI.TFS sysModel.Machine = machine; sysModel.EmbeddedVersion = app.ConnectedMachine.DeviceInformation.Version; - sysModel.ConfigurationString = machine.Configuration.Clone().ToJsonString(nameof(Configuration.MachineVersions)); + sysModel.ConfigurationString = machine.Configuration.Clone().ToJsonString(); if (app.ConnectedMachine.CurrentProcessParameters != null) { diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MachineVersion.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MachineVersion.cs index 2b8d99652..1cd43dcf1 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MachineVersion.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/MachineVersion.cs @@ -23,7 +23,7 @@ namespace Tango.BL.Entities PrototypeMachineData = machine.ToJson(); } - public async Task CreatePrototypeMachine(ObservablesContext context) + public Machine CreatePrototypeMachine(ObservablesContext context) { Machine machine = Machine.FromJson(PrototypeMachineData); machine.OrganizationGuid = null; @@ -32,42 +32,21 @@ namespace Tango.BL.Entities foreach (var cat in machine.Cats) { - cat.LiquidType = await context.LiquidTypes.SingleOrDefaultAsync(x => x.Guid == cat.LiquidTypeGuid); cat.MachineGuid = machine.Guid; - cat.Machine = machine; - cat.Rml = await context.Rmls.SingleOrDefaultAsync(x => x.Guid == cat.RmlGuid); } - machine.DefaultColorSpace = await context.ColorSpaces.SingleOrDefaultAsync(x => x.Guid == machine.Guid); - machine.ConfigurationGuid = machine.Configuration.Guid; - machine.MachineVersion = this; - machine.MachineVersionGuid = this.Guid; + machine.MachineVersionGuid = Guid; machine.ProductionDate = DateTime.UtcNow; - machine.Configuration.ApplicationDisplayPanelVersion = await context.ApplicationDisplayPanelVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.ApplicationDisplayPanelVersionGuid); - machine.Configuration.ApplicationFirmwareVersion = await context.ApplicationFirmwareVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.ApplicationFirmwareVersionGuid); - machine.Configuration.ApplicationOsVersion = await context.ApplicationOsVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.ApplicationOsVersionGuid); - machine.Configuration.EmbeddedFirmwareVersion = await context.EmbeddedFirmwareVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.EmbeddedFirmwareVersionGuid); - machine.Configuration.HardwareVersion = await context.HardwareVersions.SingleOrDefaultAsync(x => x.Guid == machine.Configuration.HardwareVersionGuid); - foreach (var idsPack in machine.Configuration.IdsPacks) { - idsPack.CartridgeType = await context.CartridgeTypes.SingleOrDefaultAsync(x => x.Guid == idsPack.CartridgeTypeGuid); - idsPack.CartridgeType = await context.CartridgeTypes.SingleOrDefaultAsync(x => x.Guid == idsPack.CartridgeTypeGuid); - idsPack.LiquidType = await context.LiquidTypes.SingleOrDefaultAsync(x => x.Guid == idsPack.LiquidTypeGuid); - idsPack.IdsPackFormula = await context.IdsPackFormulas.SingleOrDefaultAsync(x => x.Guid == idsPack.IdsPackFormulaGuid); - idsPack.MidTankType = await context.MidTankTypes.SingleOrDefaultAsync(x => x.Guid == idsPack.MidTankTypeGuid); - idsPack.DispenserGuid = null; - idsPack.Configuration = machine.Configuration; idsPack.ConfigurationGuid = machine.ConfigurationGuid; } foreach (var spool in machine.Spools) { - spool.Machine = machine; spool.MachineGuid = machine.Guid; - spool.SpoolType = await context.SpoolTypes.SingleOrDefaultAsync(x => x.Guid == spool.SpoolTypeGuid); } return machine; diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs index 673136df9..0b06438b1 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs @@ -45,7 +45,7 @@ namespace Tango.UITests MachineVersion version = db.MachineVersions.First(); await version.ApplyPrototypeMachine(machine, db); - Machine m = await version.CreatePrototypeMachine(db); + Machine m = version.CreatePrototypeMachine(db); } } -- cgit v1.3.1 From 3415150ae12893d4f08d1afde512624755996095 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 31 Dec 2018 18:01:25 +0200 Subject: Implemented ActionTimer. Fixed some issue with machine designer and dispenser module. --- .../Views/DispenserView.xaml | 2 +- .../Views/DispensersView.xaml | 4 +- .../MachineStudio.Dispensers/Views/MainView.xaml | 2 +- .../ViewModels/MainViewVM.cs | 34 +++++++++++----- .../Views/MachineDetailsView.xaml | 2 +- .../Views/MachinesView.xaml | 4 +- .../Views/MainView.xaml | 2 +- .../MachineStudioSettings.cs | 2 +- .../Visual_Studio/Tango.Core/Tango.Core.csproj | 1 + .../Tango.Core/Threading/ActionTimer.cs | 47 ++++++++++++++++++++++ 10 files changed, 82 insertions(+), 18 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Core/Threading/ActionTimer.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispenserView.xaml b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispenserView.xaml index f571b8d61..d4b3b0655 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispenserView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispenserView.xaml @@ -39,7 +39,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml index 9f36ee78a..a7a57d801 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml @@ -29,7 +29,7 @@ - + - +