diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-07 13:08:53 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-07 13:08:53 +0200 |
| commit | 942a428f90587a9ffdafaa593b780fb6ad06aabc (patch) | |
| tree | 4dd27cc98c494a57b8366b7beb9d9b4477b41409 /Software/Visual_Studio | |
| parent | ccacf23ab2f33f830a830dd2c938f1863335f01d (diff) | |
| download | Tango-942a428f90587a9ffdafaa593b780fb6ad06aabc.tar.gz Tango-942a428f90587a9ffdafaa593b780fb6ad06aabc.zip | |
Refactored dispensing formula naming.
Added code comments for integration & Dispensing namespaces.
Diffstat (limited to 'Software/Visual_Studio')
23 files changed, 613 insertions, 294 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 2c1851f19..e1d4bc7fa 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -552,7 +552,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (MachineOperator != null) { - MachineOperator.EnableSensorsUpdate = true; + MachineOperator.EnableDiagnostics = true; MachineOperator.DiagnosticsDataAvailable += MachineOperator_DiagnosticsDataAvailable; } } diff --git a/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcAttribute.cs b/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcAttribute.cs new file mode 100644 index 000000000..310b2d5be --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcAttribute.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Observables; + +namespace Tango.Integration.Dispensing +{ + /// <summary> + /// Represents a dispensing calculator attribute used to decorate an <see cref="IDispensingCalc"/> derived types + /// and define the associated IDS Pack calculation formula code. + /// </summary> + /// <seealso cref="System.Attribute" /> + public class DispensingCalcAttribute : Attribute + { + /// <summary> + /// Gets or sets the IDS pack formula. + /// </summary> + public IdsPackFormulas Formula { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="DispensingCalcAttribute"/> class. + /// </summary> + /// <param name="formula">The IDS pack formula.</param> + public DispensingCalcAttribute(IdsPackFormulas formula) + { + Formula = formula; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Formulation/FormulaCalculatorBase.cs b/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcBase.cs index ca186bf62..27f5de79d 100644 --- a/Software/Visual_Studio/Tango.Integration/Formulation/FormulaCalculatorBase.cs +++ b/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcBase.cs @@ -5,10 +5,19 @@ using System.Text; using System.Threading.Tasks; using Tango.Integration.Printing; -namespace Tango.Integration.Formulation +namespace Tango.Integration.Dispensing { - public abstract class FormulaCalculatorBase : IFormulaCalculator + /// <summary> + /// Represents an IDS pack dispensing calculator base class. + /// </summary> + /// <seealso cref="Tango.Integration.Dispensing.IDispensingCalc" /> + public abstract class DispensingCalcBase : IDispensingCalc { + /// <summary> + /// Calculates the required nanoliter per centimeter. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> public virtual double CalculateNanoliterPerCentimeter(LiquidVolume liquidVolume) { if (liquidVolume.Configuration != null && liquidVolume.RML != null && liquidVolume.ProcessParametersTable != null) @@ -21,6 +30,11 @@ namespace Tango.Integration.Formulation } } + /// <summary> + /// Calculates the required nanoliter per second. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> public virtual double CalculateNanoliterPerSecond(LiquidVolume liquidVolume) { if (liquidVolume.ProcessParametersTable != null) @@ -33,11 +47,21 @@ namespace Tango.Integration.Formulation } } + /// <summary> + /// Calculates the required pulses per second. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> public virtual double CalculatePulsePerSecond(LiquidVolume liquidVolume) { return CalculateNanoliterPerSecond(liquidVolume) / liquidVolume.IdsPack.DispenserType.NlPerPulse; } + /// <summary> + /// Coerces the specified liquid volume. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> public virtual double CoerceVolume(LiquidVolume liquidVolume) { return liquidVolume.Volume; diff --git a/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcResolver.cs b/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcResolver.cs new file mode 100644 index 000000000..8d0386e7a --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcResolver.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Observables; +using Tango.Integration.Printing; +using System.Reflection; + +namespace Tango.Integration.Dispensing +{ + /// <summary> + /// IDS pack dispensing calculators resolver used to inquire the proper calculator instance. + /// </summary> + public static class DispensingCalcResolver + { + private static List<KeyValuePair<IdsPackFormulas, IDispensingCalc>> _calculators { get; set; } + + /// <summary> + /// Initializes the <see cref="DispensingCalcResolver"/> class. + /// </summary> + static DispensingCalcResolver() + { + _calculators = new List<KeyValuePair<IdsPackFormulas, IDispensingCalc>>(); + + foreach (var type in typeof(DispensingCalcResolver).Assembly.GetTypes().Where(x => x.GetCustomAttribute<DispensingCalcAttribute>() != null)) + { + _calculators.Add(new KeyValuePair<IdsPackFormulas, IDispensingCalc>(type.GetCustomAttribute<DispensingCalcAttribute>().Formula, Activator.CreateInstance(type) as IDispensingCalc)); + } + } + + /// <summary> + /// Returns an IDS pack dispensing calculator instance by the specified <see cref="LiquidVolume"/>. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + public static IDispensingCalc Resolve(LiquidVolume liquidVolume) + { + return _calculators.SingleOrDefault(x => x.Key == (IdsPackFormulas)liquidVolume.IdsPack.IdsPackFormula.Code).Value; + } + + /// <summary> + /// Returns an IDS pack dispensing calculator instance by the specified <see cref="IdsPackFormula"/>. + /// </summary> + /// <param name="formulaCode">The formula code.</param> + /// <returns></returns> + public static IDispensingCalc Resolve(IdsPackFormulas formulaCode) + { + return _calculators.SingleOrDefault(x => x.Key == formulaCode).Value; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcService.cs b/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcService.cs new file mode 100644 index 000000000..668bd085e --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Dispensing/DispensingCalcService.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Printing; + +namespace Tango.Integration.Dispensing +{ + /// <summary> + /// Represents a static IDS pack dispensing calculation service for easy access to common calculation methods. + /// </summary> + public static class DispensingCalcService + { + /// <summary> + /// Calculates the nanoliter per centimeter. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + public static double CalculateNanoliterPerCentimeter(LiquidVolume liquidVolume) + { + IDispensingCalc formula = DispensingCalcResolver.Resolve(liquidVolume); + return formula.CalculateNanoliterPerCentimeter(liquidVolume); + } + + /// <summary> + /// Calculates the nanoliter per second. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + public static double CalculateNanoliterPerSecond(LiquidVolume liquidVolume) + { + IDispensingCalc formula = DispensingCalcResolver.Resolve(liquidVolume); + return formula.CalculateNanoliterPerSecond(liquidVolume); + } + + /// <summary> + /// Calculates the pulse per second. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + public static double CalculatePulsePerSecond(LiquidVolume liquidVolume) + { + IDispensingCalc formula = DispensingCalcResolver.Resolve(liquidVolume); + return formula.CalculatePulsePerSecond(liquidVolume); + } + + /// <summary> + /// Coerces the volume. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + public static double CoerceVolume(LiquidVolume liquidVolume) + { + IDispensingCalc formula = DispensingCalcResolver.Resolve(liquidVolume); + return formula.CoerceVolume(liquidVolume); + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Dispensing/IDispensingCalc.cs b/Software/Visual_Studio/Tango.Integration/Dispensing/IDispensingCalc.cs new file mode 100644 index 000000000..c4cbb86e3 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Dispensing/IDispensingCalc.cs @@ -0,0 +1,38 @@ +using Tango.Integration.Printing; + +namespace Tango.Integration.Dispensing +{ + /// <summary> + /// Represents an IDS pack dispensing calculator. + /// </summary> + public interface IDispensingCalc + { + /// <summary> + /// Calculates the required nanoliter per second. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + double CalculateNanoliterPerSecond(LiquidVolume liquidVolume); + + /// <summary> + /// Calculates the required nanoliter per centimeter. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + double CalculateNanoliterPerCentimeter(LiquidVolume liquidVolume); + + /// <summary> + /// Calculates the required pulses per second. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + double CalculatePulsePerSecond(LiquidVolume liquidVolume); + + /// <summary> + /// Coerces the specified liquid volume. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> + double CoerceVolume(LiquidVolume liquidVolume); + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Dispensing/LubricantDispensingCalc.cs b/Software/Visual_Studio/Tango.Integration/Dispensing/LubricantDispensingCalc.cs new file mode 100644 index 000000000..37923ab00 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Dispensing/LubricantDispensingCalc.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Observables; + +namespace Tango.Integration.Dispensing +{ + /// <summary> + /// Represents a lubricant IDS pack dispensing calculator. + /// </summary> + /// <seealso cref="Tango.Integration.Dispensing.DispensingCalcBase" /> + [DispensingCalc(IdsPackFormulas.Lubricant)] + public class LubricantDispensingCalc : DispensingCalcBase + { + + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Dispensing/StandardColorDispensingCalc.cs b/Software/Visual_Studio/Tango.Integration/Dispensing/StandardColorDispensingCalc.cs new file mode 100644 index 000000000..e2ed7d1b8 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Dispensing/StandardColorDispensingCalc.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Observables; +using Tango.Integration.Printing; +using static Tango.Integration.Observables.BrushStop; + +namespace Tango.Integration.Dispensing +{ + /// <summary> + /// Represents a standard color (CYMK...) IDS pack dispensing calculator. + /// </summary> + /// <seealso cref="Tango.Integration.Dispensing.DispensingCalcBase" /> + [DispensingCalc(IdsPackFormulas.StandardColor)] + public class StandardColorDispensingCalc : DispensingCalcBase + { + + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Formulation/TransparentLiquidFormulaCalculator.cs b/Software/Visual_Studio/Tango.Integration/Dispensing/TransparentLiquidDispensingCalc.cs index bad40f7f8..2c475dcfc 100644 --- a/Software/Visual_Studio/Tango.Integration/Formulation/TransparentLiquidFormulaCalculator.cs +++ b/Software/Visual_Studio/Tango.Integration/Dispensing/TransparentLiquidDispensingCalc.cs @@ -6,11 +6,20 @@ using System.Threading.Tasks; using Tango.Integration.Observables; using Tango.Integration.Printing; -namespace Tango.Integration.Formulation +namespace Tango.Integration.Dispensing { - [Formula(IdsPackFormulas.TransparentLiquid)] - public class TransparentLiquidFormulaCalculator : FormulaCalculatorBase + /// <summary> + /// Represents a transparent liquid (Diluter) IDS pack dispensing calculator. + /// </summary> + /// <seealso cref="Tango.Integration.Dispensing.DispensingCalcBase" /> + [DispensingCalc(IdsPackFormulas.TransparentLiquid)] + public class TransparentLiquidDispensingCalc : DispensingCalcBase { + /// <summary> + /// Coerces the specified liquid volume. + /// </summary> + /// <param name="liquidVolume">The liquid volume.</param> + /// <returns></returns> public override double CoerceVolume(LiquidVolume liquidVolume) { if (liquidVolume.ProcessParametersTable != null) diff --git a/Software/Visual_Studio/Tango.Integration/Formulation/FormulaAttribute.cs b/Software/Visual_Studio/Tango.Integration/Formulation/FormulaAttribute.cs deleted file mode 100644 index 521c12ea3..000000000 --- a/Software/Visual_Studio/Tango.Integration/Formulation/FormulaAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Integration.Observables; - -namespace Tango.Integration.Formulation -{ - public class FormulaAttribute : Attribute - { - public IdsPackFormulas Formula { get; set; } - - public FormulaAttribute(IdsPackFormulas formula) - { - Formula = formula; - } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Formulation/FormulaResolver.cs b/Software/Visual_Studio/Tango.Integration/Formulation/FormulaResolver.cs deleted file mode 100644 index d30d077b8..000000000 --- a/Software/Visual_Studio/Tango.Integration/Formulation/FormulaResolver.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Integration.Observables; -using Tango.Integration.Printing; -using System.Reflection; - -namespace Tango.Integration.Formulation -{ - public static class FormulaResolver - { - private static List<KeyValuePair<IdsPackFormulas, IFormulaCalculator>> _calculators { get; set; } - - static FormulaResolver() - { - _calculators = new List<KeyValuePair<IdsPackFormulas, IFormulaCalculator>>(); - - foreach (var type in typeof(FormulaResolver).Assembly.GetTypes().Where(x => x.GetCustomAttribute<FormulaAttribute>() != null)) - { - _calculators.Add(new KeyValuePair<IdsPackFormulas, IFormulaCalculator>(type.GetCustomAttribute<FormulaAttribute>().Formula, Activator.CreateInstance(type) as IFormulaCalculator)); - } - } - - public static IFormulaCalculator Resolve(LiquidVolume liquidVolume) - { - return _calculators.SingleOrDefault(x => x.Key == (IdsPackFormulas)liquidVolume.IdsPack.IdsPackFormula.Code).Value; - } - - public static IFormulaCalculator Resolve(IdsPackFormulas formulaCode) - { - return _calculators.SingleOrDefault(x => x.Key == formulaCode).Value; - } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Formulation/FormulasCalculationService.cs b/Software/Visual_Studio/Tango.Integration/Formulation/FormulasCalculationService.cs deleted file mode 100644 index 6cbf8aebd..000000000 --- a/Software/Visual_Studio/Tango.Integration/Formulation/FormulasCalculationService.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Integration.Printing; - -namespace Tango.Integration.Formulation -{ - public static class FormulasCalculationService - { - public static double CalculateNanoliterPerCentimeter(LiquidVolume liquidVolume) - { - IFormulaCalculator formula = FormulaResolver.Resolve(liquidVolume); - return formula.CalculateNanoliterPerCentimeter(liquidVolume); - } - - public static double CalculateNanoliterPerSecond(LiquidVolume liquidVolume) - { - IFormulaCalculator formula = FormulaResolver.Resolve(liquidVolume); - return formula.CalculateNanoliterPerSecond(liquidVolume); - } - - public static double CalculatePulsePerSecond(LiquidVolume liquidVolume) - { - IFormulaCalculator formula = FormulaResolver.Resolve(liquidVolume); - return formula.CalculatePulsePerSecond(liquidVolume); - } - - public static double CoerceVolume(LiquidVolume liquidVolume) - { - IFormulaCalculator formula = FormulaResolver.Resolve(liquidVolume); - return formula.CoerceVolume(liquidVolume); - } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Formulation/IFormulaCalculator.cs b/Software/Visual_Studio/Tango.Integration/Formulation/IFormulaCalculator.cs deleted file mode 100644 index 89894f334..000000000 --- a/Software/Visual_Studio/Tango.Integration/Formulation/IFormulaCalculator.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Tango.Integration.Printing; - -namespace Tango.Integration.Formulation -{ - public interface IFormulaCalculator - { - double CalculateNanoliterPerSecond(LiquidVolume liquidVolume); - - double CalculateNanoliterPerCentimeter(LiquidVolume liquidVolume); - - double CalculatePulsePerSecond(LiquidVolume liquidVolume); - - double CoerceVolume(LiquidVolume liquidVolume); - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Formulation/LubricantFormulaCalculator.cs b/Software/Visual_Studio/Tango.Integration/Formulation/LubricantFormulaCalculator.cs deleted file mode 100644 index 3d75c9748..000000000 --- a/Software/Visual_Studio/Tango.Integration/Formulation/LubricantFormulaCalculator.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Integration.Observables; - -namespace Tango.Integration.Formulation -{ - [Formula(IdsPackFormulas.Lubricant)] - public class LubricantFormulaCalculator : FormulaCalculatorBase - { - - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Formulation/StandardColorFormulaCalculator.cs b/Software/Visual_Studio/Tango.Integration/Formulation/StandardColorFormulaCalculator.cs deleted file mode 100644 index 8b40f45e8..000000000 --- a/Software/Visual_Studio/Tango.Integration/Formulation/StandardColorFormulaCalculator.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Integration.Observables; -using Tango.Integration.Printing; -using static Tango.Integration.Observables.BrushStop; - -namespace Tango.Integration.Formulation -{ - [Formula(IdsPackFormulas.StandardColor)] - public class StandardColorFormulaCalculator : FormulaCalculatorBase - { - - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs index 58b19c914..bba5ff094 100644 --- a/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operators/IMachineOperator.cs @@ -12,6 +12,10 @@ using Tango.Integration.Printing; namespace Tango.Integration.Operators { + /// <summary> + /// Represents a Tango machine operator. + /// </summary> + /// <seealso cref="Tango.Transport.ITransporter" /> public interface IMachineOperator : ITransporter { /// <summary> @@ -20,12 +24,12 @@ namespace Tango.Integration.Operators event EventHandler<PushDiagnosticsResponse> DiagnosticsDataAvailable; /// <summary> - /// Gets or sets a value indicating whether to enable diagnostics messages by requesting diagnostics messages. + /// Gets or sets a value indicating whether direct the embedded device to send diagnostics messages. /// </summary> - bool EnableSensorsUpdate { get; set; } + bool EnableDiagnostics { get; set; } /// <summary> - /// Prints the specified job. + /// Prints the specified job using the specified job parameters. /// </summary> /// <param name="job">The job.</param> /// <param name="processParameters">Process parameters table</param> diff --git a/Software/Visual_Studio/Tango.Integration/Operators/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Operators/JobHandler.cs new file mode 100644 index 000000000..4c2c9f3f4 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operators/JobHandler.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR.Printing; + +namespace Tango.Integration.Operators +{ + /// <summary> + /// Represents a <see cref="MachineOperator.Print(Observables.Job, Observables.ProcessParametersTable)"/> handler. + /// </summary> + public class JobHandler + { + private Action _cancelAction; + + #region Events + + /// <summary> + /// Occurs when a job status has been received. + /// </summary> + public event EventHandler<JobStatus> StatusReceived; + + /// <summary> + /// Occurs when the job has failed. + /// </summary> + public event EventHandler<Exception> Failed; + + /// <summary> + /// Occurs when the job has completed successfully. + /// </summary> + public event EventHandler Completed; + + /// <summary> + /// Occurs when the job has been canceled. + /// </summary> + public event EventHandler Canceled; + + #endregion + + #region Properties + + /// <summary> + /// Gets a value indicating whether this handler job has been canceled. + /// </summary> + public bool IsCanceled { get; internal set; } + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="JobHandler"/> class. + /// </summary> + public JobHandler() + { + + } + + /// <summary> + /// Initializes a new instance of the <see cref="JobHandler"/> class. + /// </summary> + /// <param name="cancelAction">The cancel action.</param> + internal JobHandler(Action cancelAction) : this() + { + _cancelAction = () => { IsCanceled = true; cancelAction(); }; + } + + #endregion + + #region Internal Methods + + /// <summary> + /// Raises the status received event. + /// </summary> + /// <param name="status">The status.</param> + internal void RaiseStatusReceived(JobStatus status) + { + StatusReceived?.Invoke(this, status); + } + + /// <summary> + /// Raises the failed event. + /// </summary> + /// <param name="ex">The ex.</param> + internal void RaiseFailed(Exception ex) + { + Failed?.Invoke(this, ex); + } + + /// <summary> + /// Raises the completed event. + /// </summary> + internal void RaiseCompleted() + { + Completed?.Invoke(this, new EventArgs()); + } + + /// <summary> + /// Raises the canceled event. + /// </summary> + internal void RaiseCanceled() + { + Canceled?.Invoke(this, new EventArgs()); + } + + #endregion + + #region Public Methods + + /// <summary> + /// Cancels the associated job. + /// </summary> + public void Cancel() + { + _cancelAction(); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs index 1ae4c078a..cc42b64ed 100644 --- a/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operators/MachineOperator.cs @@ -18,18 +18,29 @@ using Tango.Integration.Printing; namespace Tango.Integration.Operators { + /// <summary> + /// Represents the Tango machine operator default implementation. + /// </summary> + /// <seealso cref="Tango.Transport.Transporters.BasicTransporter" /> + /// <seealso cref="Tango.Integration.Operators.IMachineOperator" /> public class MachineOperator : BasicTransporter, IMachineOperator { + #region Events + /// <summary> /// Occurs when there is new diagnostics data available. /// </summary> public event EventHandler<PushDiagnosticsResponse> DiagnosticsDataAvailable; + #endregion + + #region Properties + private bool _enableDiagnostics; /// <summary> - /// Gets or sets a value indicating whether to enable diagnostics messages by requesting diagnostics messages. + /// Gets or sets a value indicating whether direct the embedded device to send diagnostics messages. /// </summary> - public bool EnableSensorsUpdate + public bool EnableDiagnostics { get { return _enableDiagnostics; } set @@ -38,16 +49,20 @@ namespace Tango.Integration.Operators { _enableDiagnostics = value; RaisePropertyChangedAuto(); - OnEnableSensorsUpdateChanged(value); + OnEnableDiagnosticsChanged(value); } } } + #endregion + + #region Virtual Methods + /// <summary> /// Called when the enable sensors update property has been changed /// </summary> /// <param name="value">if set to <c>true</c> [value].</param> - protected virtual void OnEnableSensorsUpdateChanged(bool value) + protected virtual void OnEnableDiagnosticsChanged(bool value) { if (value && State == TransportComponentState.Connected) { @@ -81,6 +96,10 @@ namespace Tango.Integration.Operators DiagnosticsDataAvailable?.Invoke(this, data); } + #endregion + + #region Protected Methods + /// <summary> /// Called when the component state has changed. /// </summary> @@ -89,11 +108,15 @@ namespace Tango.Integration.Operators { base.OnStateChanged(state); - OnEnableSensorsUpdateChanged(EnableSensorsUpdate); + OnEnableDiagnosticsChanged(EnableDiagnostics); } + #endregion + + #region Public Methods + /// <summary> - /// Prints the specified job. + /// Prints the specified job using the specified job parameters. /// </summary> /// <param name="job">The job.</param> /// <param name="processParameters">Process parameters table</param> @@ -131,7 +154,7 @@ namespace Tango.Integration.Operators JobHandler handler = null; - handler = new JobHandler(async () => + handler = new JobHandler(async () => { try { @@ -144,21 +167,23 @@ namespace Tango.Integration.Operators } }); - SendContinuousRequest<JobRequest, JobResponse>(request).Subscribe((response) => + SendContinuousRequest<JobRequest, JobResponse>(request).Subscribe((response) => { handler.RaiseStatusReceived(response.Message.Status); - },(ex) => - { - if (!handler.IsCanceled) - { - handler.RaiseFailed(ex); - } - },() => - { - handler.RaiseCompleted(); - }); + }, (ex) => + { + if (!handler.IsCanceled) + { + handler.RaiseFailed(ex); + } + }, () => + { + handler.RaiseCompleted(); + }); return handler; } + + #endregion } } diff --git a/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs b/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs index b11ef9f15..f5b10e669 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/BrushStop.cs @@ -13,9 +13,21 @@ using Tango.Integration.Printing; namespace Tango.Integration.Observables { + /// <summary> + /// Extends the standard observable BrushStop class. + /// </summary> + /// <seealso cref="Tango.Integration.Observables.ObservableEntity{Tango.Integration.Observables.BrushStop}" /> public partial class BrushStop { + [NotMapped] + private bool _ignorePropChanged; + + #region Properties + private ObservableCollection<LiquidVolume> _liquidVolumes; + /// <summary> + /// Gets or sets the collection of this brush stop liquid volumes. + /// </summary> [NotMapped] public ObservableCollection<LiquidVolume> LiquidVolumes { @@ -24,6 +36,9 @@ namespace Tango.Integration.Observables } private Color _color; + /// <summary> + /// Gets or sets the brush stop color. + /// </summary> [NotMapped] public Color Color { @@ -38,30 +53,45 @@ namespace Tango.Integration.Observables } } + /// <summary> + /// Gets the brush stop index within it's segment brush stops collection. + /// </summary> [NotMapped] public int Index { get { return Segment.BrushStops.IndexOf(this); } } + /// <summary> + /// Gets a value indicating whether this brush stop is the first one within its segment brush stops. + /// </summary> [NotMapped] public bool IsFirst { get { return Segment.BrushStops.IndexOf(this) == 0; } } + /// <summary> + /// Gets a value indicating whether this brush stop is the last one within its segment brush stops. + /// </summary> [NotMapped] - public bool IsMiddle + public bool IsLast { - get { return !IsFirst && !IsLast; } + get { return Segment.BrushStops.IndexOf(this) == Segment.BrushStops.Count - 1; } } + /// <summary> + /// Gets a value indicating whether this brush stop is not the first nor last within its segment brush stops. + /// </summary> [NotMapped] - public bool IsLast + public bool IsMiddle { - get { return Segment.BrushStops.IndexOf(this) == Segment.BrushStops.Count - 1; } + get { return !IsFirst && !IsLast; } } + /// <summary> + /// Gets this brush stop offset in meters. + /// </summary> [NotMapped] public double OffsetMeters { @@ -78,6 +108,13 @@ namespace Tango.Integration.Observables } } + #endregion + + #region Public Methods + + /// <summary> + /// Notifies about the offset percentage and offset meters changes. + /// </summary> public void RaiseOffsetChanged() { RaisePropertyChanged(nameof(OffsetPercent)); @@ -86,6 +123,12 @@ namespace Tango.Integration.Observables RaisePropertyChanged(nameof(IsLast)); } + /// <summary> + /// Sets this brush stop liquid volumes. + /// </summary> + /// <param name="configuration">The configuration.</param> + /// <param name="rml">The RML.</param> + /// <param name="processParametersTable">The process parameters table.</param> public void SetLiquidVolumes(Configuration configuration, Rml rml, ProcessParametersTable processParametersTable) { LiquidVolumes = new ObservableCollection<LiquidVolume>(); @@ -96,49 +139,22 @@ namespace Tango.Integration.Observables } } - [NotMapped] - private bool _ignorePropChanged; + #endregion + #region Override Methods + + /// <summary> + /// Raises the property changed event. + /// </summary> + /// <param name="propName">Name of the property.</param> protected override void RaisePropertyChanged(string propName) { base.RaisePropertyChanged(propName); if (!_ignorePropChanged && propName != nameof(ColorSpace) && ColorSpace != null) { - Rgb rgb = new Rgb(Red, Green, Blue); - Cmyk cmyk = new Cmyk(Cyan, Magenta, Yellow, Black); - Lab lab = new Lab(L, A, B); - - switch ((ColorSpaces)ColorSpace.Code) - { - case ColorSpaces.RGB: - cmyk = rgb.To<Cmyk>(); - lab = rgb.To<Lab>(); - break; - case ColorSpaces.CMYK: - rgb = cmyk.To<Rgb>(); - lab = cmyk.To<Lab>(); - break; - case ColorSpaces.LAB: - rgb = lab.To<Rgb>(); - cmyk = lab.To<Cmyk>(); - break; - } - - _red = (int)rgb.R; - _green = (int)rgb.G; - _blue = (int)rgb.B; - - _cyan = cmyk.C * 100d; - _magenta = cmyk.M * 100d; - _yellow = cmyk.Y * 100d; - _black = cmyk.K * 100d; - - _l = lab.L; - _a = lab.A; - _b = lab.B; - _color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); + SynchronizeColorSpaces(); _ignorePropChanged = true; @@ -150,5 +166,52 @@ namespace Tango.Integration.Observables _ignorePropChanged = false; } } + + #endregion + + #region Private Methods + + /// <summary> + /// Synchronizes between the different brush stop color spaces. + /// </summary> + private void SynchronizeColorSpaces() + { + Rgb rgb = new Rgb(Red, Green, Blue); + Cmyk cmyk = new Cmyk(Cyan, Magenta, Yellow, Black); + Lab lab = new Lab(L, A, B); + + switch ((ColorSpaces)ColorSpace.Code) + { + case ColorSpaces.RGB: + cmyk = rgb.To<Cmyk>(); + lab = rgb.To<Lab>(); + break; + case ColorSpaces.CMYK: + rgb = cmyk.To<Rgb>(); + lab = cmyk.To<Lab>(); + break; + case ColorSpaces.LAB: + rgb = lab.To<Rgb>(); + cmyk = lab.To<Cmyk>(); + break; + } + + _red = (int)rgb.R; + _green = (int)rgb.G; + _blue = (int)rgb.B; + + _cyan = cmyk.C * 100d; + _magenta = cmyk.M * 100d; + _yellow = cmyk.Y * 100d; + _black = cmyk.K * 100d; + + _l = lab.L; + _a = lab.A; + _b = lab.B; + + _color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); + } + + #endregion } } diff --git a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs index e78e0a195..9ffff3372 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/Job.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/Job.cs @@ -7,31 +7,41 @@ using System.Threading.Tasks; namespace Tango.Integration.Observables { + /// <summary> + /// Extends the standard observable Job class. + /// </summary> + /// <seealso cref="Tango.Integration.Observables.ObservableEntity{Tango.Integration.Observables.Job}" /> public partial class Job { - public event EventHandler LengthChanged; + #region Events - protected override void RaisePropertyChanged(string propName) - { - base.RaisePropertyChanged(propName); + /// <summary> + /// Occurs when the job total segments length has changed. + /// </summary> + public event EventHandler LengthChanged; - if (propName == nameof(Segments)) - { - if (Segments != null) - { - Segments.CollectionChanged -= Segments_CollectionChanged; - Segments.CollectionChanged += Segments_CollectionChanged; + #endregion - OnLengthChanged(); - } - } + #region Properties - if (propName == nameof(InterSegmentLength) || propName == nameof(EnableInterSegment)) - { - OnLengthChanged(); - } + /// <summary> + /// Gets the total job segments length. + /// </summary> + [NotMapped] + public double Length + { + get { return Segments.Sum(x => x.Length) + (EnableInterSegment ? (InterSegmentLength * (Segments.Count > 0 ? Segments.Count - 1 : Segments.Count)) : 0); } } + #endregion + + #region Event Handlers + + /// <summary> + /// Handles the CollectionChanged event of the Segments collection. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="System.Collections.Specialized.NotifyCollectionChangedEventArgs"/> instance containing the event data.</param> private void Segments_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { foreach (var segment in Segments) @@ -42,6 +52,11 @@ namespace Tango.Integration.Observables OnLengthChanged(); } + /// <summary> + /// Handles the PropertyChanged event of all job segments. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param> private void Segment_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == nameof(Segment.Length)) @@ -50,16 +65,48 @@ namespace Tango.Integration.Observables } } + #endregion + + #region Virtual Methods + + /// <summary> + /// Called when the <see cref="Length"/> property has been changed + /// </summary> protected virtual void OnLengthChanged() { RaisePropertyChanged(nameof(Length)); LengthChanged?.Invoke(this, new EventArgs()); } - [NotMapped] - public double Length + #endregion + + #region Override Methods + + /// <summary> + /// Raises the property changed event. + /// </summary> + /// <param name="propName">Name of the property.</param> + protected override void RaisePropertyChanged(string propName) { - get { return Segments.Sum(x => x.Length) + (EnableInterSegment ? (InterSegmentLength * (Segments.Count > 0 ? Segments.Count - 1 : Segments.Count)) : 0); } + base.RaisePropertyChanged(propName); + + if (propName == nameof(Segments)) + { + if (Segments != null) + { + Segments.CollectionChanged -= Segments_CollectionChanged; + Segments.CollectionChanged += Segments_CollectionChanged; + + OnLengthChanged(); + } + } + + if (propName == nameof(InterSegmentLength) || propName == nameof(EnableInterSegment)) + { + OnLengthChanged(); + } } + + #endregion } } diff --git a/Software/Visual_Studio/Tango.Integration/Printing/JobHandler.cs b/Software/Visual_Studio/Tango.Integration/Printing/JobHandler.cs deleted file mode 100644 index 761ce6602..000000000 --- a/Software/Visual_Studio/Tango.Integration/Printing/JobHandler.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.PMR.Printing; - -namespace Tango.Integration.Printing -{ - public class JobHandler - { - private Action _cancelAction; - - public event EventHandler<JobStatus> StatusReceived; - public event EventHandler<Exception> Failed; - public event EventHandler Completed; - public event EventHandler Canceled; - - public bool IsCanceled { get; set; } - - public JobHandler() - { - - } - - internal JobHandler(Action cancelAction) : this() - { - _cancelAction = () => { IsCanceled = true; cancelAction(); }; - } - - internal void RaiseStatusReceived(JobStatus status) - { - StatusReceived?.Invoke(this, status); - } - - internal void RaiseFailed(Exception ex) - { - Failed?.Invoke(this, ex); - } - - internal void RaiseCompleted() - { - Completed?.Invoke(this, new EventArgs()); - } - - internal void RaiseCanceled() - { - Canceled?.Invoke(this, new EventArgs()); - } - - public void Cancel() - { - _cancelAction(); - } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Printing/LiquidVolume.cs b/Software/Visual_Studio/Tango.Integration/Printing/LiquidVolume.cs index b86c3e52c..802ea8462 100644 --- a/Software/Visual_Studio/Tango.Integration/Printing/LiquidVolume.cs +++ b/Software/Visual_Studio/Tango.Integration/Printing/LiquidVolume.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core; -using Tango.Integration.Formulation; +using Tango.Integration.Dispensing; using Tango.Integration.Observables; namespace Tango.Integration.Printing @@ -71,7 +71,7 @@ namespace Tango.Integration.Printing private void InvalidateSolo() { - _volume = FormulasCalculationService.CoerceVolume(this); + _volume = DispensingCalcService.CoerceVolume(this); typeof(BrushStop).GetProperty("V" + Configuration.IdsPacks.IndexOf(IdsPack)).SetValue(BrushStop, Volume); RaisePropertyChanged(nameof(LiquidMaxNanoliterPerCentimeter)); @@ -125,7 +125,7 @@ namespace Tango.Integration.Printing { get { - return FormulasCalculationService.CalculateNanoliterPerSecond(this); + return DispensingCalcService.CalculateNanoliterPerSecond(this); } } @@ -133,7 +133,7 @@ namespace Tango.Integration.Printing { get { - return FormulasCalculationService.CalculateNanoliterPerCentimeter(this); + return DispensingCalcService.CalculateNanoliterPerCentimeter(this); } } @@ -141,7 +141,7 @@ namespace Tango.Integration.Printing { get { - return FormulasCalculationService.CalculatePulsePerSecond(this); + return DispensingCalcService.CalculatePulsePerSecond(this); } } } diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 594863093..59e232352 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -78,14 +78,14 @@ <Compile Include="Diagnostics\DiagnosticsTimeCodeChannel.cs" /> <Compile Include="Diagnostics\DiagnosticsTimeCodeChannelFrame.cs" /> <Compile Include="ExtensionMethods\IExternalBridgeClientExtensions.cs" /> - <Compile Include="Formulation\TransparentLiquidFormulaCalculator.cs" /> - <Compile Include="Formulation\FormulaCalculatorBase.cs" /> - <Compile Include="Formulation\FormulasCalculationService.cs" /> - <Compile Include="Formulation\FormulaResolver.cs" /> - <Compile Include="Formulation\FormulaAttribute.cs" /> - <Compile Include="Formulation\IFormulaCalculator.cs" /> - <Compile Include="Formulation\LubricantFormulaCalculator.cs" /> - <Compile Include="Formulation\StandardColorFormulaCalculator.cs" /> + <Compile Include="Dispensing\TransparentLiquidDispensingCalc.cs" /> + <Compile Include="Dispensing\DispensingCalcBase.cs" /> + <Compile Include="Dispensing\DispensingCalcService.cs" /> + <Compile Include="Dispensing\DispensingCalcResolver.cs" /> + <Compile Include="Dispensing\DispensingCalcAttribute.cs" /> + <Compile Include="Dispensing\IDispensingCalc.cs" /> + <Compile Include="Dispensing\LubricantDispensingCalc.cs" /> + <Compile Include="Dispensing\StandardColorDispensingCalc.cs" /> <Compile Include="Observables\Entities\ActionType.cs" /> <Compile Include="Observables\Entities\Address.cs" /> <Compile Include="Observables\Entities\ApplicationDisplayPanelVersion.cs" /> @@ -173,7 +173,7 @@ <Compile Include="Operators\IMachineOperator.cs" /> <Compile Include="Operators\MachineOperator.cs" /> <Compile Include="Printing\Job.cs" /> - <Compile Include="Printing\JobHandler.cs" /> + <Compile Include="Operators\JobHandler.cs" /> <Compile Include="Printing\LiquidVolume.cs" /> <Compile Include="Printing\ProcessParametersTable.cs" /> <Compile Include="Printing\Segment.cs" /> |
