aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs75
1 files changed, 65 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
index 558953ccb..79e62e097 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
@@ -138,6 +138,11 @@ namespace Tango.Integration.Operation
public event EventHandler<MachineStatus> MachineStatusChanged;
/// <summary>
+ /// Occurs when a new cartridge validation request has been received.
+ /// </summary>
+ public event EventHandler<CartridgeValidationEventArgs> CartridgeValidationRequestReceived;
+
+ /// <summary>
/// Occurs when a request has been sent.
/// </summary>
public event EventHandler<IMessage> RequestSent;
@@ -640,6 +645,8 @@ namespace Tango.Integration.Operation
/// <param name="value">if set to <c>true</c> [value].</param>
protected virtual async void OnEnableMachineStatusUpdatesChanged(bool value)
{
+ return; //TODO: Remove this when Shlomo Solves the bug.
+
if (value && State == TransportComponentState.Connected && !_machineStatusSent)
{
var request = new StartMachineStatusUpdateRequest();
@@ -777,6 +784,20 @@ namespace Tango.Integration.Operation
}
/// <summary>
+ /// Called when a new request has been received.
+ /// </summary>
+ /// <param name="container">The request.</param>
+ protected override void OnRequestReceived(MessageContainer container)
+ {
+ base.OnRequestReceived(container);
+
+ if (container.Type == MessageType.CartridgeValidationRequest)
+ {
+ OnCartridgeValidationRequestReceived(container.Token, MessageFactory.ExtractMessageFromContainer<CartridgeValidationRequest>(container));
+ }
+ }
+
+ /// <summary>
/// Called when the response has been sent
/// </summary>
/// <param name="response">The response.</param>
@@ -803,6 +824,37 @@ namespace Tango.Integration.Operation
StatusChanged?.Invoke(this, status);
}
+ /// <summary>
+ /// Called when the cartridge validation request has been received.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ protected virtual void OnCartridgeValidationRequestReceived(String token, CartridgeValidationRequest request)
+ {
+ if (request.Action == CartridgeAction.Inserted)
+ {
+ CartridgeValidationEventArgs e = new CartridgeValidationEventArgs(request, (index) =>
+ {
+ //Approve
+ SendResponse<CartridgeValidationResponse>(new CartridgeValidationResponse()
+ {
+ IsValid = true,
+ Index = index,
+ }, token).Wait();
+
+ }, () =>
+ {
+ //Decline
+ SendResponse<CartridgeValidationResponse>(new CartridgeValidationResponse()
+ {
+
+ }, token).Wait();
+
+ });
+
+ CartridgeValidationRequestReceived?.Invoke(this, e);
+ }
+ }
+
#endregion
#region Override Methods
@@ -1272,26 +1324,27 @@ namespace Tango.Integration.Operation
{
Dictionary<int, double> liquidQuantities = new Dictionary<int, double>();
- int packIndex = 0;
-
- foreach (var item in configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex))
+ foreach (var pack in configuration.NoneEmptyIdsPacks.OrderBy(x => x.PackIndex))
{
- liquidQuantities.Add(packIndex++, 0);
+ liquidQuantities.Add(pack.PackIndex, 0);
}
for (int segmentIndex = 0; segmentIndex < ticket.Segments.Count; segmentIndex++)
{
var segment = ticket.Segments[segmentIndex];
+ var segment_length_cm = segment.Length * 100d;
- for (int stopIndex = 0; stopIndex < segment.BrushStops.Count; stopIndex++)
+ var stop_count = segment.BrushStops.Count - (segment.BrushStops.Count == 1 ? 0 : 1);
+ var stop_length_centimeters = segment_length_cm / stop_count;
+
+ for (int stopIndex = 0; stopIndex < stop_count; stopIndex++)
{
var stop = segment.BrushStops[stopIndex];
- //var position = segment.
- //foreach (var dispenser in stop.Dispensers)
- //{
-
- //}
+ foreach (var dispenser in stop.Dispensers)
+ {
+ liquidQuantities[dispenser.Index] += dispenser.NanoliterPerCentimeter * stop_length_centimeters;
+ }
}
}
}
@@ -1474,6 +1527,7 @@ namespace Tango.Integration.Operation
var originalJob = job;
var clonedJob = job.Clone();
clonedJob.Guid = job.Guid;
+ clonedJob.Name = job.Name;
CurrentProcessParameters = processParameters;
@@ -1481,6 +1535,7 @@ namespace Tango.Integration.Operation
job = job.Clone();
job.Guid = originalJob.Guid;
+ job.Name = originalJob.Name;
int max = job.OrderedSegments.Last().SegmentIndex + 1;