aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Emulations
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-19 04:53:19 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-19 04:53:19 +0300
commit1ba3500b421ddc58888a909fefdf2e2792c8e2be (patch)
tree57d9a908d0c57bc65cd9f3e6f2cc616fbbfcbe04 /Software/Visual_Studio/Tango.Emulations
parentb9d18dcd6e6795ed2c870a73e3111b608118a35b (diff)
downloadTango-1ba3500b421ddc58888a909fefdf2e2792c8e2be.tar.gz
Tango-1ba3500b421ddc58888a909fefdf2e2792c8e2be.zip
Implemeneted continuous ActivateVersionRequest.
Added Progress & Total.
Diffstat (limited to 'Software/Visual_Studio/Tango.Emulations')
-rw-r--r--Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs29
1 files changed, 22 insertions, 7 deletions
diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
index 5c260f639..40900f9b4 100644
--- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
+++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
@@ -715,13 +715,13 @@ namespace Tango.Emulations.Emulators
Task.Factory.StartNew(() =>
{
MachineStatus.State = MachineState.RunningJob;
-
+
List<int> calculatedStopIndexes = new List<int>();
double progress = 0;
double lastProgress = 0;
Stopwatch watch = new Stopwatch();
Dictionary<int, IDSPackLevel> dispenserindexToPacklevel = new Dictionary<int, IDSPackLevel>();
-
+
for (int i = 0; i < units; i++)
{
@@ -778,8 +778,8 @@ namespace Tango.Emulations.Emulators
var nextStop = segment.BrushStops[index + 1];
nextStopPosition = nextStop.OffsetMeters;
}
-
- if(!calculatedStopIndexes.Contains(stop.Index))
+
+ if (!calculatedStopIndexes.Contains(stop.Index))
{
var brushStopPosition = currentPosition + stop.OffsetMeters;
if (brushStopPosition >= lastProgress && brushStopPosition <= progress)
@@ -788,7 +788,7 @@ namespace Tango.Emulations.Emulators
{
var quantity = dispenser.NanoliterPerCentimeter * (nextStopPosition - stop.OffsetMeters) * 100d;
IDSPackLevel packLevel;
- if(!dispenserindexToPacklevel.TryGetValue(dispenser.Index, out packLevel))
+ if (!dispenserindexToPacklevel.TryGetValue(dispenser.Index, out packLevel))
{
packLevel = MachineStatus.IDSPacksLevels.SingleOrDefault(x => x.Index == dispenser.Index);
dispenserindexToPacklevel.Add(dispenser.Index, packLevel);
@@ -806,7 +806,7 @@ namespace Tango.Emulations.Emulators
}
watch.Stop();
lastProgress = progress;
- int delay = (100 - (int)watch.ElapsedMilliseconds) > 0? (100 - (int)watch.ElapsedMilliseconds) : 5;
+ int delay = (100 - (int)watch.ElapsedMilliseconds) > 0 ? (100 - (int)watch.ElapsedMilliseconds) : 5;
Thread.Sleep(delay);
if (_cancelJob)
@@ -1468,7 +1468,22 @@ namespace Tango.Emulations.Emulators
VersionPackageDescriptor package = VersionPackageDescriptor.Parser.ParseFrom(fs);
}
- Transporter.SendResponse<ActivateVersionResponse>(new ActivateVersionResponse(), request.Container.Token);
+ for (int i = 0; i < 100; i++)
+ {
+ Transporter.SendResponse<ActivateVersionResponse>(new ActivateVersionResponse()
+ {
+ Progress = i + 1,
+ Total = 100
+ }, request.Container.Token);
+
+ Thread.Sleep(10);
+ }
+
+ Transporter.SendResponse<ActivateVersionResponse>(new ActivateVersionResponse()
+ {
+ Progress = 100,
+ Total = 100
+ }, request.Container.Token, new TransportResponseConfig() { Completed = true });
}
catch (Exception ex)
{