Skip to content

Commit

Permalink
Fix bug: multiple measurements were taken in a row when only one shou…
Browse files Browse the repository at this point in the history
…ld have been taken.
  • Loading branch information
Arcitectus committed Mar 5, 2016
1 parent b484c0c commit afa24ea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Binary file modified lib.intermediate/Sanderling.dll
Binary file not shown.
8 changes: 5 additions & 3 deletions src/Sanderling/Sanderling.Exe/App.Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ void InterfaceExchange()

var EveOnlineClientProcessId = this.EveOnlineClientProcessId;

var RequestedMeasurementTime = this.RequestedMeasurementTime ?? 0;

if (EveOnlineClientProcessId.HasValue &&
!(MemoryMeasurementLastAge < 1000) && RequestedMeasurementTime <= Bib3.Glob.StopwatchZaitMiliSictInt())
Task.Run(() => MeasurementMemoryTake(EveOnlineClientProcessId.Value));
Task.Run(() => MeasurementMemoryTake(EveOnlineClientProcessId.Value, RequestedMeasurementTime));
}

void LicenseClientExchange()
Expand Down Expand Up @@ -199,13 +201,13 @@ void LicenseClientExchange()
}
}

void MeasurementMemoryTake(int processId)
void MeasurementMemoryTake(int processId, Int64 measurementBeginTimeMinMilli)
{
FromProcessMeasurement<MemoryStruct.IMemoryMeasurement> MeasurementRaw = null;

try
{
MeasurementRaw = SensorServerDispatcher.InterfaceAppManager.MeasurementTake(processId);
MeasurementRaw = SensorServerDispatcher.InterfaceAppManager.MeasurementTake(processId, measurementBeginTimeMinMilli);
}
finally
{
Expand Down
13 changes: 7 additions & 6 deletions src/Sanderling/Sanderling/InterfaceAppManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BotEngine.Interface;
using Sanderling.Interface;
using System;
using System.Threading;
using MemoryStruct = Sanderling.Interface.MemoryStruct;

Expand All @@ -18,10 +19,9 @@ static public FromInterfaceResponse ClientRequest(

static public FromInterfaceResponse MeasurementTakeRequest(
this InterfaceAppManager interfaceAppManager,
int processId)
int processId,
Int64 measurementBeginTimeMinMilli)
{
var MeasurementBeginTimeMin = Bib3.Glob.StopwatchZaitMiliSictInt();

while (interfaceAppManager?.MeasurementInProgress() ?? false)
Thread.Sleep(11);

Expand All @@ -43,7 +43,7 @@ static public FromInterfaceResponse MeasurementTakeRequest(
MemoryMeasurementGetLast = true,
});

if (!(MeasurementBeginTimeMin <= Response?.MemoryMeasurement?.Begin))
if (!(measurementBeginTimeMinMilli <= Response?.MemoryMeasurement?.Begin))
Response = interfaceAppManager?.ClientRequest(new ToInterfaceRequest
{
MemoryMeasurementTake = true,
Expand All @@ -54,7 +54,8 @@ static public FromInterfaceResponse MeasurementTakeRequest(

static public FromProcessMeasurement<MemoryStruct.IMemoryMeasurement> MeasurementTake(
this InterfaceAppManager interfaceAppManager,
int processId) =>
MeasurementTakeRequest(interfaceAppManager, processId)?.MemoryMeasurement;
int processId,
Int64 measurementBeginTimeMinMilli) =>
MeasurementTakeRequest(interfaceAppManager, processId, measurementBeginTimeMinMilli)?.MemoryMeasurement;
}
}
4 changes: 3 additions & 1 deletion src/sample/Sanderling.Sample.Read/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ static void SampleRun()
{
SensorServerHub?.Exchange();

var response = SensorServerHub?.InterfaceAppManager?.MeasurementTakeRequest(Config.EveOnlineClientProcessId);
var response = SensorServerHub?.InterfaceAppManager?.MeasurementTakeRequest(
Config.EveOnlineClientProcessId,
Bib3.Glob.StopwatchZaitMiliSictInt());

if (null == response)
Console.WriteLine("Sensor Interface not yet ready.");
Expand Down

0 comments on commit afa24ea

Please sign in to comment.