/// <summary> /// finishes a tactics run, moves graphics where it will be accessible to HTTP /// </summary> private void finishTactics() { if (currentStatusGraphics != null) { // move current StatusGraphics to last, to be available for HttpGet: //lock (lockStatusGraphics) { StatusGraphics tmp = lastStatusGraphics; lastStatusGraphics = currentStatusGraphics; if (tmp != null) { tmp.Dispose(); } currentStatusGraphics = null; } } }
private const double DrawTopInterval = 1.0d; // allow thinking only after so many seconds /// <summary> /// prepares HTTP graphics and planner, can call _routePlanner.planRoute() if doPlanRoute is true /// </summary> /// <param name="doPlanRoute"></param> private void initTactics(bool doPlanRoute) { bool canDrawTop = (DateTime.Now - lastDrawTop).TotalSeconds > DrawTopInterval; if (currentStatusGraphics != null) { currentStatusGraphics.Dispose(); currentStatusGraphics = null; } // we limit drawing to the cycles when laser data comes in, to limit frequency of drawing: if (canDrawTop) { lastDrawTop = DateTime.Now; currentStatusGraphics = new StatusGraphics(); } // ===== we can start writing to currentStatusGraphics bitmaps at will here. //Tracer.Trace("calling planRoute()"); _routePlanner.ObstacleDistanceMeters = ((double)ObstacleDistanceMm) / 1000.0d * 1.5d; if (doPlanRoute) { _currentRoutePlan = _routePlanner.planRoute(); } else { _currentRoutePlan = null; } if (canDrawTop) { // draw laser sweep data and basic markings: int fieldOfView = (int)Math.Round(_routePlanner.sweepAngleNormal / 2.0d); // to either side //Tracer.Trace("calling GenerateTop()"); GenerateTop(_laserData, fieldOfView, _currentRoutePlan); } sPlan = "no good plan"; }