Commit 3171db77 by Mac Stephens

Refresh AVL unit locations on the map every 15 seconds

parent c34c8c72
...@@ -50,6 +50,9 @@ implementation ...@@ -50,6 +50,9 @@ implementation
uses uses
System.StrUtils, System.DateUtils; System.StrUtils, System.DateUtils;
const
UNIT_MAP_REFRESH_INTERVAL_MS = 15000;
{ TWsDataModel } { TWsDataModel }
constructor TWsDataModel.Create(ABroadcast: TWsBroadcastProc; AIntervalMs: Integer); constructor TWsDataModel.Create(ABroadcast: TWsBroadcastProc; AIntervalMs: Integer);
...@@ -77,20 +80,37 @@ begin ...@@ -77,20 +80,37 @@ begin
end; end;
procedure TWsDataModel.Execute; procedure TWsDataModel.Execute;
var
unitMapElapsedMs: Integer;
begin begin
unitMapElapsedMs := 0;
try try
while not TThread.CurrentThread.CheckTerminated do while not TThread.CurrentThread.CheckTerminated do
begin begin
if FStopEvent.WaitFor(FIntervalMs) = wrSignaled then if FStopEvent.WaitFor(FIntervalMs) = wrSignaled then
Break; Break;
if not FDb.StartUpdateListener then Inc(unitMapElapsedMs, FIntervalMs);
Continue;
if not FDb.ConsumeCADUpdate then if not FDb.StartUpdateListener then
Continue; Continue;
BroadcastAll; if FDb.ConsumeCADUpdate then
begin
BroadcastAll;
unitMapElapsedMs := 0;
end
else if unitMapElapsedMs >= UNIT_MAP_REFRESH_INTERVAL_MS then
begin
try
FBroadcast(BuildUnitMapJson);
except
on E: Exception do
Logger.Log(2, 'WsDataModel UNIT_MAP refresh error: ' + E.Message);
end;
unitMapElapsedMs := 0;
end;
end; end;
except except
on E: Exception do on E: Exception do
......
[Settings] [Settings]
LogFileNum=107 LogFileNum=109
webClientVersion=0.9.4.3 webClientVersion=0.9.4.3
[Database] [Database]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment