Commit 3171db77 by Mac Stephens

Refresh AVL unit locations on the map every 15 seconds

parent c34c8c72
......@@ -50,6 +50,9 @@ implementation
uses
System.StrUtils, System.DateUtils;
const
UNIT_MAP_REFRESH_INTERVAL_MS = 15000;
{ TWsDataModel }
constructor TWsDataModel.Create(ABroadcast: TWsBroadcastProc; AIntervalMs: Integer);
......@@ -77,20 +80,37 @@ begin
end;
procedure TWsDataModel.Execute;
var
unitMapElapsedMs: Integer;
begin
unitMapElapsedMs := 0;
try
while not TThread.CurrentThread.CheckTerminated do
begin
if FStopEvent.WaitFor(FIntervalMs) = wrSignaled then
Break;
if not FDb.StartUpdateListener then
Continue;
Inc(unitMapElapsedMs, FIntervalMs);
if not FDb.ConsumeCADUpdate then
if not FDb.StartUpdateListener then
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;
except
on E: Exception do
......
[Settings]
LogFileNum=107
LogFileNum=109
webClientVersion=0.9.4.3
[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