aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Operators/JobHandler.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-02-07 13:08:53 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-02-07 13:08:53 +0200
commit942a428f90587a9ffdafaa593b780fb6ad06aabc (patch)
tree4dd27cc98c494a57b8366b7beb9d9b4477b41409 /Software/Visual_Studio/Tango.Integration/Operators/JobHandler.cs
parentccacf23ab2f33f830a830dd2c938f1863335f01d (diff)
downloadTango-942a428f90587a9ffdafaa593b780fb6ad06aabc.tar.gz
Tango-942a428f90587a9ffdafaa593b780fb6ad06aabc.zip
Refactored dispensing formula naming.
Added code comments for integration & Dispensing namespaces.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operators/JobHandler.cs')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operators/JobHandler.cs121
1 files changed, 121 insertions, 0 deletions
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
+ }
+}