From bd49bdcb109a227130d7db6856e659b435d16530 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 11 Jul 2018 12:37:11 +0300 Subject: Embedded Tango.AnimatedGif ! --- .../PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 4978fa6e0..c67e83fc6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -194,7 +194,7 @@ namespace Tango.PPC.UI.PPCApplication private async void ConnectToMachine() { Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_9600); - var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(60)); + var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); var machine = new MachineOperator(response.Adapter); await machine.Connect(); -- cgit v1.3.1 From 009a02d57e244e9a8ed5d70fc0743f10f68f5a33 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 11 Jul 2018 16:12:53 +0300 Subject: Done some work on PPC & Color Lab Module. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes Software/Graphics/Mobile/sample-dye.png | Bin 0 -> 2120 bytes .../ViewModels/MainViewVM.cs | 41 +++++++ .../Views/MainView.xaml | 73 ++++++----- .../Tango.MachineStudio.UI/Resources/BuildDate.txt | 2 +- .../Native/Tango.ColorLib/Utils/Interp.cpp | 10 ++ .../Tango.PPC.Jobs/Images/JobView/sample-dye.png | Bin 0 -> 2120 bytes .../Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj | 3 + .../Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs | 19 +-- .../Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs | 3 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 53 +++++++- .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 41 ++++++- .../PPCApplication/DefaultPPCApplicationManager.cs | 10 +- .../Tango.BL/Entities/HardwareMotor.cs | 6 +- Software/Visual_Studio/Tango.BL/Entities/Job.cs | 50 +++++--- .../ExtensionMethods/IEnumerableExtensions.cs | 12 ++ Software/Visual_Studio/Tango.DAL.Remote/DB/JOB.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 3 + .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 134 ++++++++++----------- .../Tango.Touch/Controls/TouchNumericTextBox.cs | 4 +- .../Tango.Touch/Controls/TouchToggleButton.cs | 31 ++++- .../Visual_Studio/Utilities/Tango.UITests/App.xaml | 8 +- .../Utilities/Tango.UITests/MainWindow.xaml | 2 +- .../Utilities/Tango.UITests/MainWindow.xaml.cs | 12 +- 25 files changed, 378 insertions(+), 140 deletions(-) create mode 100644 Software/Graphics/Mobile/sample-dye.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/JobView/sample-dye.png (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 66c3a8783..a94e39894 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 45f9ba68b..e74145160 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Graphics/Mobile/sample-dye.png b/Software/Graphics/Mobile/sample-dye.png new file mode 100644 index 000000000..f8989e19a Binary files /dev/null and b/Software/Graphics/Mobile/sample-dye.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs index 48d16104a..0e9109b28 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/ViewModels/MainViewVM.cs @@ -13,6 +13,7 @@ using System.Windows.Media; using Tango.BL; using Tango.BL.ColorConversion; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.Core.Commands; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Controls; @@ -32,6 +33,33 @@ namespace Tango.MachineStudio.ColorLab.ViewModels #region Properties + private bool _isVolumesOutOfRange; + /// + /// Gets or sets a value indicating whether the liquid volumes are out of range. + /// + public bool IsVolumesOutOfRange + { + get { return _isVolumesOutOfRange; } + set + { + if (_isVolumesOutOfRange != value) + { + _isVolumesOutOfRange = value; + RaisePropertyChangedAuto(); + } + } + } + + private bool _isOutOfGamut; + /// + /// Gets or sets a value indicating whether the source color is out of gamut. + /// + public bool IsOutOfGamut + { + get { return _isOutOfGamut; } + set { _isOutOfGamut = value; RaisePropertyChangedAuto(); } + } + private ObservableCollection _machines; /// /// Gets or sets the machines. @@ -280,6 +308,8 @@ namespace Tango.MachineStudio.ColorLab.ViewModels var output = TangoColorConverter.GetSuggestions(input); + IsOutOfGamut = output.OutOfGamut; + HiveSuggestions = TangoColorConverter.CreateHiveSuggestions(output); }); } @@ -396,6 +426,17 @@ namespace Tango.MachineStudio.ColorLab.ViewModels try { if (LiquidsCalibrationData == null) return; + + //TODO: This is temporary because of out of range volumes. + if (LiquidVolumes.Where(x => x.IdsPack.IdsPackFormula.Code == IdsPackFormulas.StandardColor.ToInt32()).Sum(x => x.Volume) > 200) + { + IsVolumesOutOfRange = true; + return; + } + else + { + IsVolumesOutOfRange = false; + } ConversionInput input = new ConversionInput(); input.ColorSpace = PMR.ColorLab.ColorSpace.Volume; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml index 8b62604d6..d8ef015be 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorLab/Views/MainView.xaml @@ -26,6 +26,7 @@ + @@ -163,6 +164,12 @@ + + + + Color is out of gamut + + @@ -254,30 +261,39 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + @@ -286,11 +302,14 @@ COMPOSITE - - - - - + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt index 0aa0af85a..60d433d99 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Resources/BuildDate.txt @@ -1 +1 @@ -Wed 07/11/2018 11:23:32.16 +Wed 07/11/2018 16:02:40.40 diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.cpp b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.cpp index 7346a9898..68b7e0c93 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.cpp +++ b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.cpp @@ -5,6 +5,7 @@ #include #include +#define epsTol 0.05 Interp::Interp(void) { } @@ -26,6 +27,15 @@ void Interp::Eval(double InValue, double &OutValue) int errType = 0; ind = -1; + //Check Bounds + if((InValuem_xValues[m_length - 1] + epsTol)) + throw std::exception("Value out of Bounds"); + if ((InValue > m_xValues[0] - epsTol) && (InValue < m_xValues[0])) + InValue = m_xValues[0]; + + if ((InValue > m_xValues[m_length - 1] ) && (InValue < m_xValues[m_length - 1]+ epsTol)) + InValue = m_xValues[m_length - 1]; + for (m = 0; m < m_length - 1; ++m) { if (m_xValues[m] <= InValue && m_xValues[m + 1] >= InValue) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/JobView/sample-dye.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/JobView/sample-dye.png new file mode 100644 index 000000000..f8989e19a Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/JobView/sample-dye.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 0163b77c2..aaf9fb453 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -311,5 +311,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs index a111d3be2..6039dafb8 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs @@ -10,9 +10,10 @@ using Tango.PPC.Common.Navigation; namespace Tango.PPC.Jobs.ViewModels { - public class JobProgressViewVM : PPCViewModel, INavigationResultProvider + public class JobProgressViewVM : PPCViewModel { private Job _job; + public Job Job { get { return _job; } @@ -32,21 +33,21 @@ namespace Tango.PPC.Jobs.ViewModels } - public void OnNavigationObjectReceived(Job job) + public override void OnApplicationStarted() { - Job = job; - var jobHandler = ApplicationManager.ConnectedMachine.Print(Job, Adapter.ProcessParametersTables.First()); - jobHandler.StatusChanged += JobHandler_StatusChanged; + ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged; } - public object GetNavigationResult() + private void ApplicationManager_ConnectedMachineChanged(object sender, IMachineOperator e) { - return null; + e.PrintingStarted -= PrintingStarted; + e.PrintingStarted += PrintingStarted; } - public override void OnApplicationStarted() + private void PrintingStarted(object sender, JobHandler jobHandler) { - + Job = jobHandler.Job; + jobHandler.StatusChanged += JobHandler_StatusChanged; } private void JobHandler_StatusChanged(object sender, RunningJobStatus e) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs index a59b0fe27..12f2c9642 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs @@ -47,7 +47,8 @@ namespace Tango.PPC.Jobs.ViewModels private void StartJob() { - var result = NavigationManager.NavigateForResult(Job); + ApplicationManager.ConnectedMachine.Print(Job, Adapter.ProcessParametersTables.First()); + NavigationManager.NavigateTo(nameof(JobProgressView)); } public override void OnApplicationStarted() diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 6b25d323f..82cfc3456 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -39,7 +39,6 @@ namespace Tango.PPC.Jobs.ViewModels #region Properties private Job _job; - /// /// Gets or sets the selected job. /// @@ -172,6 +171,16 @@ namespace Tango.PPC.Jobs.ViewModels /// public RelayCommand TwineCatalogFieldTapCommand { get; set; } + /// + /// Gets or sets the increase decrease samples to dye command. + /// + public RelayCommand IncreaseDecreaseSamplesToDyeCommand { get; set; } + + /// + /// Gets or sets the start sample dye command. + /// + public RelayCommand StartSampleDyeCommand { get; set; } + #endregion #region Constructors @@ -205,9 +214,22 @@ namespace Tango.PPC.Jobs.ViewModels SaveJobCommand = new RelayCommand(SaveJob); ReplaceBrushStopCommand = new RelayCommand(InvokeColorAdjustmentForBrushStop); TwineCatalogFieldTapCommand = new RelayCommand(InvokeTwineCatalogForBrushStop); + IncreaseDecreaseSamplesToDyeCommand = new RelayCommand((x) => + { + if (x == "+") + { + Job.SampleUnitsOrMeters++; + } + else + { + Job.SampleUnitsOrMeters--; + } + }); _check_gamut_thread = new Thread(CheckGamutThreadMethod); _check_gamut_thread.IsBackground = true; + + StartSampleDyeCommand = new RelayCommand(StartSampleDye); } #endregion @@ -390,6 +412,35 @@ namespace Tango.PPC.Jobs.ViewModels #endregion + #region Sample Dye + + /// + /// Starts a sample dye. + /// + private async void StartSampleDye() + { + Job sampleDyeJob = Job.Clone(); + sampleDyeJob.Name += " sample"; + + if (Job.JobType == BL.Enumerations.JobTypes.Embroidery) + { + sampleDyeJob.NumberOfUnits = Job.SampleUnitsOrMeters; + } + else + { + sampleDyeJob.NumberOfUnits = 1; + + foreach (var segment in sampleDyeJob.Segments) + { + segment.Length = Job.SampleUnitsOrMeters; + } + } + + await NavigationManager.NavigateForResult(sampleDyeJob); + } + + #endregion + #region Out Of Gamut Check Thread private void CheckGamutThreadMethod() diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index ce7f7b528..43917fe55 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -538,7 +538,11 @@ - + + Additional Tools + + + + + + + + + Sample Dye + + + + + + Dye 1 or more units in order to get approval. + + Once approved, you can dye the entire job. + + + + How many sample units? + + + + + + + + + + START + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index c67e83fc6..8c112ff7a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -193,12 +193,12 @@ namespace Tango.PPC.UI.PPCApplication private async void ConnectToMachine() { - Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_9600); - var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); + //Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_9600); + //var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); - var machine = new MachineOperator(response.Adapter); - await machine.Connect(); - ConnectedMachine = machine; + //var machine = new MachineOperator(response.Adapter); + //await machine.Connect(); + //ConnectedMachine = machine; } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/HardwareMotor.cs b/Software/Visual_Studio/Tango.BL/Entities/HardwareMotor.cs index 3104dfafd..cb7abbd64 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/HardwareMotor.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/HardwareMotor.cs @@ -23,7 +23,7 @@ namespace Tango.BL.Entities /// /// - /// + /// [Table("HARDWARE_MOTORS")] public partial class HardwareMotor : ObservableEntity @@ -584,8 +584,8 @@ namespace Tango.BL.Entities protected Int32 _fsspd; /// - ///The speed in which the motor moves to full step operation. - /// + /// The speed in which the motor moves to full step operation. + /// [Column("FS_SPD")] diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs index 15ac3d199..0adfe0b23 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs @@ -23,7 +23,7 @@ namespace Tango.BL.Entities /// /// - /// + /// [Table("JOBS")] public partial class Job : ObservableEntity @@ -433,13 +433,13 @@ namespace Tango.BL.Entities protected Int32 _status; /// - ///0 = Draft - ///1 = PendingApproval - ///2 = Ready - ///3 = Approved - ///4 = Disrupted - ///5 = Completed - /// + /// 0 = Draft + /// 1 = PendingApproval + /// 2 = Ready + /// 3 = Approved + /// 4 = Disrupted + /// 5 = Completed + /// [Column("STATUS")] @@ -505,9 +505,9 @@ namespace Tango.BL.Entities protected Int32 _type; /// - ///0 = Sewing - ///1 = Embroidery - /// + /// 0 = Sewing + /// 1 = Embroidery + /// [Column("TYPE")] @@ -551,9 +551,9 @@ namespace Tango.BL.Entities protected Int32 _spoolsdistribution; /// - ///0 = All segments per spool - ///1 = One segments per spool - /// + /// 0 = All segments per spool + /// 1 = One segments per spool + /// [Column("SPOOLS_DISTRIBUTION")] @@ -593,6 +593,28 @@ namespace Tango.BL.Entities } + protected Int32 _sampleunitsormeters; + + /// + /// Gets or sets the job sample units or meters. + /// + + [Column("SAMPLE_UNITS_OR_METERS")] + + public Int32 SampleUnitsOrMeters + { + get + { + return _sampleunitsormeters; + } + + set + { + _sampleunitsormeters = value; RaisePropertyChanged(nameof(SampleUnitsOrMeters)); + } + + } + protected ColorSpace _colorspace; /// diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs index ffe164a53..0f15ad060 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs @@ -80,5 +80,17 @@ public static class IEnumerableExtensions { return String.Join(separator, source); } + + /// + /// Returns a distinct collection by the specified property. + /// + /// + /// The source. + /// The property. + /// + public static IEnumerable DistinctBy(this IEnumerable source, Func property) + { + return source.GroupBy(property).Select(g => g.First()); + } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB.cs index 433dacee4..109e876b5 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/JOB.cs @@ -49,6 +49,7 @@ namespace Tango.DAL.Remote.DB public string CUSTOMER_GUID { get; set; } public int SPOOLS_DISTRIBUTION { get; set; } public int NUMBER_OF_HEADS { get; set; } + public int SAMPLE_UNITS_OR_METERS { get; set; } public virtual COLOR_SPACES COLOR_SPACES { get; set; } public virtual CUSTOMER CUSTOMER { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 7f17f8940..9030a9f0b 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -582,6 +582,7 @@ + @@ -3397,6 +3398,7 @@ + @@ -5462,6 +5464,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 668abf151..305fe3ebd 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,78 +5,78 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - + + + + + - - - - + + + + - - - - - - - - + + + + + + + + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index c45701e99..aee5fae26 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -70,7 +70,7 @@ namespace Tango.Touch.Controls set { SetValue(MinimumProperty, value); } } public static readonly DependencyProperty MinimumProperty = - DependencyProperty.Register("Minimum", typeof(double), typeof(TouchNumericTextBox), new PropertyMetadata(.0)); + DependencyProperty.Register("Minimum", typeof(double), typeof(TouchNumericTextBox), new PropertyMetadata(0.0)); public double Maximum { @@ -108,6 +108,8 @@ namespace Tango.Touch.Controls _text_box.GotFocus += _text_box_GotFocus; _text_box.TextChanged += _text_box_TextChanged; + Value = Value; + OnValueChanged(); } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs index 8187645ca..f24d716db 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleButton.cs @@ -19,6 +19,8 @@ namespace Tango.Touch.Controls public class TouchToggleButton : ToggleButton, ITouchControl { private Object _uncheckedContent; + private bool _loaded; + private bool first_checked; #region ITouchControl @@ -91,8 +93,33 @@ namespace Tango.Touch.Controls public TouchToggleButton() { - Loaded += (_, __) => _uncheckedContent = Content; - Checked += (_, __) => Content = CheckedContent != null ? CheckedContent : Content; + Loaded += (_, __) => + { + if (!_loaded) + { + _uncheckedContent = Content; + _loaded = true; + } + }; + + Checked += (_, __) => + { + if (_loaded) + { + Content = CheckedContent != null ? CheckedContent : Content; + } + else + { + Loaded += (x, y) => + { + if (!first_checked) + { + Content = CheckedContent != null ? CheckedContent : Content; + first_checked = true; + } + }; + } + }; Unchecked += (_, __) => Content = _uncheckedContent; } } diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/App.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/App.xaml index 0ede32b42..43576481f 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/App.xaml +++ b/Software/Visual_Studio/Utilities/Tango.UITests/App.xaml @@ -6,20 +6,20 @@ StartupUri="MainWindow.xaml"> - - + + --> diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml index 05bcad25c..6f821d30f 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml @@ -16,6 +16,6 @@ Title="MainWindow" Height="500" Width="800" Foreground="Red" DataContext="{Binding RelativeSource={RelativeSource Self}}"> - + diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs index 06613ee1e..c3eca4c76 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs @@ -110,6 +110,14 @@ namespace Tango.UITests public RelayCommand DropCommand { get; set; } + public int Value + { + get { return (int)GetValue(ValueProperty); } + set { SetValue(ValueProperty, value); } + } + public static readonly DependencyProperty ValueProperty = + DependencyProperty.Register("Value", typeof(int), typeof(MainWindow), new PropertyMetadata(0)); + public MainWindow() { Persons = new ObservableCollection(); @@ -127,9 +135,11 @@ namespace Tango.UITests DropCommand = new RelayCommand(OnDrop); + Value = 10; + InitializeComponent(); - DataContext = new VM(); + //DataContext = new VM(); } private void OnDrop(DropEventArgs e) -- cgit v1.3.1 From 14cd4ba2174c3e0bd74f58f2cc72769fd326a6e6 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 11 Jul 2018 20:05:13 +0300 Subject: Working on PPC. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml | 9 ++- .../Controls/JobSummeryViewer.xaml.cs | 8 +- .../Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs | 2 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 41 ++++++++-- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 3 + .../Tango.PPC.Jobs/Views/JobProgressView.xaml | 17 ++-- .../Tango.PPC.Jobs/Views/JobSummeryView.xaml | 2 +- .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 70 +++++++++++++---- .../Navigation/INavigationBlocker.cs | 7 ++ .../PPC/Tango.PPC.Common/PPCViewModel.cs | 10 +++ .../Navigation/DefaultNavigationManager.cs | 19 ++++- .../PPCApplication/DefaultPPCApplicationManager.cs | 10 +-- .../ColorConversion/TangoColorConverter.cs | 5 ++ .../Tango.BL/EntitiesExtensions/Job.cs | 16 +++- .../Operation/IMachineOperator.cs | 9 +++ .../Tango.Integration/Operation/JobHandler.cs | 6 +- .../Tango.Integration/Operation/MachineOperator.cs | 86 ++++++++++++++++++++- .../Operation/RunningJobStatus.cs | 15 ++++ 20 files changed, 295 insertions(+), 40 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index a94e39894..44805a30c 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 e74145160..6bd51c604 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml index 550accac3..c7f42f14d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml @@ -101,9 +101,13 @@ @@ -112,6 +116,5 @@ - diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml.cs index 2b9d9c7a9..2c03ad452 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/JobSummeryViewer.xaml.cs @@ -20,7 +20,13 @@ namespace Tango.PPC.Jobs.Controls /// public partial class JobSummeryViewer : UserControl { - + public bool IsActive + { + get { return (bool)GetValue(IsActiveProperty); } + set { SetValue(IsActiveProperty, value); } + } + public static readonly DependencyProperty IsActiveProperty = + DependencyProperty.Register("IsActive", typeof(bool), typeof(JobSummeryViewer), new PropertyMetadata(false)); public bool DisplayMarkers { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs index 12f2c9642..19e28f6a9 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs @@ -47,7 +47,7 @@ namespace Tango.PPC.Jobs.ViewModels private void StartJob() { - ApplicationManager.ConnectedMachine.Print(Job, Adapter.ProcessParametersTables.First()); + ApplicationManager.ConnectedMachine.Print(Job); NavigationManager.NavigateTo(nameof(JobProgressView)); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 82cfc3456..b23e8b8ed 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -181,6 +181,11 @@ namespace Tango.PPC.Jobs.ViewModels /// public RelayCommand StartSampleDyeCommand { get; set; } + /// + /// Gets or sets the dye command. + /// + public RelayCommand DyeCommand { get; set; } + #endregion #region Constructors @@ -230,6 +235,7 @@ namespace Tango.PPC.Jobs.ViewModels _check_gamut_thread.IsBackground = true; StartSampleDyeCommand = new RelayCommand(StartSampleDye); + DyeCommand = new RelayCommand(StartJob, CanStartJob); } #endregion @@ -260,6 +266,19 @@ namespace Tango.PPC.Jobs.ViewModels } } + private void StartJob() + { + ApplicationManager.ConnectedMachine.Print(Job); + NavigationManager.NavigateTo(nameof(JobProgressView)); + } + + private bool CanStartJob() + { + return + Job != null && + !Job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.IsOutOfGamut); + } + #endregion #region Segments Management @@ -417,10 +436,10 @@ namespace Tango.PPC.Jobs.ViewModels /// /// Starts a sample dye. /// - private async void StartSampleDye() + private void StartSampleDye() { Job sampleDyeJob = Job.Clone(); - sampleDyeJob.Name += " sample"; + sampleDyeJob.Name = Job.Name + " (sample)"; if (Job.JobType == BL.Enumerations.JobTypes.Embroidery) { @@ -436,7 +455,9 @@ namespace Tango.PPC.Jobs.ViewModels } } - await NavigationManager.NavigateForResult(sampleDyeJob); + ApplicationManager.ConnectedMachine.Print(sampleDyeJob); + + NavigationManager.NavigateTo(nameof(JobProgressView)); } #endregion @@ -458,6 +479,11 @@ namespace Tango.PPC.Jobs.ViewModels stop.IsOutOfGamut = TangoColorConverter.IsOutOfGamut(stop); stop.OutOfGamutChecked = true; } + + InvokeUI(() => + { + DyeCommand.RaiseCanExecuteChanged(); + }); } } } @@ -479,6 +505,8 @@ namespace Tango.PPC.Jobs.ViewModels /// public async override void OnNavigatedTo() { + if (_job_to_load == null) return; + NotificationProvider.SetGlobalBusyMessage("Loading job details..."); _can_navigate_back = false; @@ -518,14 +546,17 @@ namespace Tango.PPC.Jobs.ViewModels { NotificationProvider.ReleaseGlobalBusyMessage(); }); + + _job_to_load = null; } + /// - /// Called before the navigation system navigates from this object. + /// Called before the navigation system navigates back from this object. /// Return false to abort the navigation. /// /// - public async override Task OnNavigateOutRequest() + public async override Task OnNavigateBackRequest() { bool result = true; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 39963201e..8f2ea355f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -270,6 +270,9 @@ namespace Tango.PPC.Jobs.ViewModels Job job = new Job(); job.Name = "untitled"; + job.NumberOfHeads = 1; + job.NumberOfUnits = 1; + job.SampleUnitsOrMeters = 1; job.CreationDate = DateTime.UtcNow; job.JobStatus = JobStatuses.Draft; job.JobType = vm.SelectedJobType.Value; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml index 3a4a895dc..28672a920 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml @@ -15,7 +15,7 @@ - + @@ -54,18 +54,25 @@ - - + + - + now dying - + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml index b956d7b6c..377348581 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobSummeryView.xaml @@ -56,7 +56,7 @@ Tap 'DYE' to start the dying process... - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 43917fe55..cf1c3fa37 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -573,21 +573,63 @@ - - Dye 1 or more units in order to get approval. - - Once approved, you can dye the entire job. - - - - How many sample units? - - - - - - + + + + + START diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationBlocker.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationBlocker.cs index ea5173b95..622c9e2d4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationBlocker.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationBlocker.cs @@ -17,5 +17,12 @@ namespace Tango.PPC.Common.Navigation /// /// Task OnNavigateOutRequest(); + + /// + /// Called before the navigation system navigates back from this object. + /// Return false to abort the navigation. + /// + /// + Task OnNavigateBackRequest(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index fae905b13..12534959e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -139,6 +139,16 @@ namespace Tango.PPC.Common { return Task.FromResult(true); } + + /// + /// Called before the navigation system navigates back from this object. + /// Return false to abort the navigation. + /// + /// + public virtual Task OnNavigateBackRequest() + { + return Task.FromResult(true); + } } /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs index 448fc0edc..0ede1306f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -28,6 +28,7 @@ namespace Tango.PPC.UI.Navigation private Object _currentVM; private String _lastFullPath; private bool _preventHistory; + private bool _navigating_back; private Stack _navigationHistory; @@ -139,9 +140,19 @@ namespace Tango.PPC.UI.Navigation if (_currentVM != null && _currentVM is INavigationBlocker) { - if (!await (_currentVM as INavigationBlocker).OnNavigateOutRequest()) + if (_navigating_back) { - return false; + if (!await (_currentVM as INavigationBlocker).OnNavigateBackRequest()) + { + return false; + } + } + else + { + if (!await (_currentVM as INavigationBlocker).OnNavigateOutRequest()) + { + return false; + } } } @@ -260,6 +271,8 @@ namespace Tango.PPC.UI.Navigation /// public async Task NavigateBack() { + _navigating_back = true; + String first = _navigationHistory.Pop(); _preventHistory = true; @@ -268,12 +281,14 @@ namespace Tango.PPC.UI.Navigation { RaisePropertyChanged(nameof(CanNavigateBack)); _preventHistory = false; + _navigating_back = false; return true; } else { _navigationHistory.Push(first); _preventHistory = false; + _navigating_back = false; RaisePropertyChanged(nameof(CanNavigateBack)); return false; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 8c112ff7a..c67e83fc6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -193,12 +193,12 @@ namespace Tango.PPC.UI.PPCApplication private async void ConnectToMachine() { - //Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_9600); - //var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); + Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_9600); + var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); - //var machine = new MachineOperator(response.Adapter); - //await machine.Connect(); - //ConnectedMachine = machine; + var machine = new MachineOperator(response.Adapter); + await machine.Connect(); + ConnectedMachine = machine; } } } diff --git a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs index 210d4d3e8..147309f54 100644 --- a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs +++ b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs @@ -82,6 +82,11 @@ namespace Tango.BL.ColorConversion return GetSuggestions(brushStop).OutOfGamut; } + public static int GetLeastCommonProcessParametersTableIndex(IEnumerable stops) + { + return stops.Select(x => GetSuggestions(x)).Select(x => x.SingleCoordinates).Min(x => x.ProcessParametersTableIndex); + } + private static ConversionInput CreateConversionInput(BrushStop brushStop) { ConversionInput conversionInput = new ConversionInput(); diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs index 4c68f3c72..292fe000d 100644 --- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs +++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs @@ -55,6 +55,19 @@ namespace Tango.BL.Entities } } + /// + /// Gets the total job segments length multiplied by number of units if it is an embroidery job. + /// + [NotMapped] + [JsonIgnore] + public double LengthIncludingNumberOfUnits + { + get + { + return _lastLength * NumberOfUnits; + } + } + /// /// Gets or sets the job property as enum instead of int. /// @@ -193,6 +206,7 @@ namespace Tango.BL.Entities if (_lastLength != GetLength()) { RaisePropertyChanged(nameof(Length)); + RaisePropertyChanged(nameof(LengthIncludingNumberOfUnits)); LengthChanged?.Invoke(this, new EventArgs()); } } @@ -349,7 +363,7 @@ namespace Tango.BL.Entities /// public TimeSpan GetEstimatedDuration(ProcessParametersTable processParameters) { - return TimeSpan.FromSeconds(Length / (processParameters.DyeingSpeed / 100d)); + return TimeSpan.FromSeconds(LengthIncludingNumberOfUnits / (processParameters.DyeingSpeed / 100d)); } /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index c0bf390c0..24ec40fc3 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -93,6 +93,15 @@ namespace Tango.Integration.Operation /// IMachineEventsStateProvider MachineEventsStateProvider { get; set; } + /// + /// Prints the specified job. + /// The process parameters table will be calculated using color conversion gamut region. + /// This method cannot accept brush stops with 'Volume' as color space. + /// + /// The job. + /// + JobHandler Print(Job job); + /// /// Prints the specified job using the specified job parameters. /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs index 02c663e1b..02579b20a 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/JobHandler.cs @@ -116,7 +116,9 @@ namespace Tango.Integration.Operation Status = new RunningJobStatus(); Status.TotalTime = job.GetEstimatedDuration(processParameters); - Status.TotalProgress = Job.Length; + Status.RemainingUnits = job.NumberOfUnits; + Status.TotalProgress = Job.LengthIncludingNumberOfUnits; + Status.CurrentUnitTotalProgress = Job.Length; Status.Progress = 0; Status.RemainingTime = Status.TotalTime; Status.RemainingProgress = Status.TotalProgress; @@ -177,6 +179,8 @@ namespace Tango.Integration.Operation Status.Progress = s.Progress; Status.RemainingTime = Status.TotalTime - Job.TranslateProgressToTime(Status.Progress, ProcessParameters); Status.RemainingProgress = Status.TotalProgress - Status.Progress; + Status.RemainingUnits = Job.NumberOfUnits - (int)((Job.LengthIncludingNumberOfUnits / Status.CurrentUnitTotalProgress) * Status.Progress / Status.TotalProgress); + Status.CurrentUnitProgress = s.Progress - (Status.CurrentUnitTotalProgress * (Job.NumberOfUnits - Status.RemainingUnits)); if (s.Message != _lastStatusMessage && s.Message != String.Empty) { diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 8cc2465b9..d75e2fc49 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -21,6 +21,8 @@ using Tango.BL.Entities; using Tango.PMR.Hardware; using Google.Protobuf; using Tango.PMR.Connection; +using Tango.BL.Enumerations; +using Tango.BL.ColorConversion; namespace Tango.Integration.Operation { @@ -470,6 +472,74 @@ namespace Tango.Integration.Operation #region Public Methods + /// + /// Prints the specified job. + /// The process parameters table will be calculated using color conversion gamut region. + /// This method cannot accept brush stops with 'Volume' as color space. + /// + /// The job. + /// + public JobHandler Print(Job job) + { + //Check not brush stop has color space 'Volume'. + if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32())) + { + throw new InvalidOperationException("Cannot print a brush stop with volume color space when process parameters table has not been specified."); + } + + //Get least common process parameters table index. + int processParametersTableIndex = TangoColorConverter.GetLeastCommonProcessParametersTableIndex(job.Segments.SelectMany(x => x.BrushStops)); + + if (job.Rml == null) + { + throw new NullReferenceException("Job RML is null"); + } + + var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); + + if (processGroup == null) + { + throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name); + } + + var processParameters = processGroup.ProcessParametersTables.FirstOrDefault(x => x.TableIndex == processParametersTableIndex); + + if (processParameters == null) + { + throw new NullReferenceException("Could not locate process parameters table index " + processParametersTableIndex + " in group " + processGroup.Name + " for RML " + job.Rml.Name); + } + + //Perform color correction + foreach (var stop in job.Segments.SelectMany(x => x.BrushStops)) + { + if (stop.LiquidVolumes == null) + { + var suggestions = TangoColorConverter.GetSuggestions(stop); + + if (suggestions.OutOfGamut) + { + throw new InvalidOperationException("Cannot print a brush stop which is out of gamut."); + } + + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + + foreach (var outputLiquid in suggestions.SingleCoordinates.OutputLiquids) + { + var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32()); + + if (liquidVolume == null) + { + throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'."); + } + + liquidVolume.Volume = outputLiquid.Volume; + } + } + } + + return Print(job, processParameters); + } + /// /// Prints the specified job using the specified job parameters. /// @@ -478,10 +548,24 @@ namespace Tango.Integration.Operation /// public JobHandler Print(Job job, ProcessParametersTable processParameters) { + var originalJob = job; + CurrentProcessParameters = processParameters; JobRequest request = new JobRequest(); + job = job.Clone(); + + var segments = job.Segments.ToList(); + + for (int i = 0; i < job.NumberOfUnits - 1; i++) + { + foreach (var s in segments) + { + job.Segments.Add(s); + } + } + JobTicket ticket = new JobTicket(); ticket.EnableInterSegment = job.EnableInterSegment; ticket.InterSegmentLength = job.InterSegmentLength; @@ -553,7 +637,7 @@ namespace Tango.Integration.Operation { LogManager.Log(ex, "Failed to cancel job."); } - }, job, processParameters); + }, originalJob, processParameters); LogRequestSent(request); bool responseLogged = false; diff --git a/Software/Visual_Studio/Tango.Integration/Operation/RunningJobStatus.cs b/Software/Visual_Studio/Tango.Integration/Operation/RunningJobStatus.cs index 335930277..17e5f3a40 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/RunningJobStatus.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/RunningJobStatus.cs @@ -36,6 +36,21 @@ namespace Tango.Integration.Operation /// public double RemainingProgress { get; set; } + /// + /// Gets or sets the remaining units if it is an embroidery job. + /// + public int RemainingUnits { get; set; } + + /// + /// Gets or sets the current unit progress. + /// + public double CurrentUnitProgress { get; set; } + + /// + /// Gets or sets the current unit total progress. + /// + public double CurrentUnitTotalProgress { get; set; } + /// /// Gets or sets a value indicating whether this instance is canceled. /// -- cgit v1.3.1