internal void InvokeFinishRendering(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col) { var args = new TileProgressEventArgs(CallbackStates.FinishRenderTile, batchMap, group, scaleindex, row, col, m_cancel); this.FinishRenderingTile?.Invoke(this, args); m_cancel = args.Cancel; }
internal Exception InvokeError(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col, Exception exception) { var args = new TileRenderingErrorEventArgs(CallbackStates.FailedRenderingTile, batchMap, group, scaleindex, row, col, exception); this.FailedRenderingTile?.Invoke(this, args); return(args.Error); }
internal void InvokeFinishRendering(MapTilingConfiguration batchMap, string group) { var args = new TileProgressEventArgs(CallbackStates.FinishRenderGroup, batchMap, group, -1, -1, -1, m_cancel); this.FinishRenderingGroup?.Invoke(this, args); m_cancel = args.Cancel; }
internal void InvokeBeginRendering(MapTilingConfiguration batchMap) { var args = new TileProgressEventArgs(CallbackStates.StartRenderMap, batchMap, null, -1, -1, -1, m_cancel); this.BeginRenderingMap?.Invoke(this, args); m_cancel = args.Cancel; PauseEvent.WaitOne(); }
internal void InvokeBeginRendering(MapTilingConfiguration batchMap, string group, int scaleindex) { var args = new TileProgressEventArgs(CallbackStates.StartRenderScale, batchMap, group, scaleindex, -1, -1, m_cancel); this.BeginRenderingScale?.Invoke(this, args); m_cancel = args.Cancel; PauseEvent.WaitOne(); }
/// <summary> /// /// </summary> /// <param name="state">The state that invoked the callback</param> /// <param name="map">The map currently being processed</param> /// <param name="group">The group being processed</param> /// <param name="scaleindex">The scaleindex being processed</param> /// <param name="row">The row being processed</param> /// <param name="column">The column being processed</param> /// <param name="error"></param> public TileRenderingErrorEventArgs(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, Exception error) { this.State = state; this.Map = map; this.Group = group; this.ScaleIndex = scaleindex; this.Row = row; this.Column = column; this.Error = error; }
/// <summary> /// /// </summary> /// <param name="state">The state that invoked the callback</param> /// <param name="map">The map currently being processed</param> /// <param name="group">The group being processed</param> /// <param name="scaleindex">The scaleindex being processed</param> /// <param name="row">The row being processed</param> /// <param name="column">The column being processed</param> /// <param name="cancel">A control flag to stop the tile rendering</param> public TileProgressEventArgs(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, bool cancel) { this.State = state; this.Map = map; this.Group = group; this.ScaleIndex = scaleindex; this.Row = row; this.Column = column; this.Cancel = cancel; }
public RenderThreads(MapTilingConfiguration invoker, TilingRunCollection parent, int scale, string group, string mapdef, int rows, int cols, int rowOffset, int colOffset, bool randomize) { this.TileSet = new Queue <KeyValuePair <int, int> >(); _syncLock = new object(); _event = new AutoResetEvent(false); _completeFlag = parent.Config.ThreadCount; _raiseEvents = new Queue <EventPassing>(); _scale = scale; _group = group; _parent = parent; _mapDefinition = mapdef; _invoker = invoker; _randomize = randomize; _rows = rows; _cols = cols; _rowOffset = rowOffset; _colOffset = colOffset; }
public RenderThreads(MapTilingConfiguration invoker, TilingRunCollection parent, int scale, string group, string mapdef, int rows, int cols, int rowOffset, int colOffset, bool randomize) { TileSet = new Queue<KeyValuePair<int, int>>(); SyncLock = new object(); Event = new AutoResetEvent(false); CompleteFlag = parent.Config.ThreadCount; RaiseEvents = new Queue<EventPassing>(); this.Scale = scale; this.Group = group; this.Parent = parent; this.MapDefinition = mapdef; this.Invoker = invoker; Randomize = randomize; Rows = rows; Cols = cols; this.RowOffset = rowOffset; this.ColOffset = colOffset; }
/// <summary> /// Adds the specified map definition ids /// </summary> /// <param name="maps"></param> public void AddMapDefinitions(string[] maps) { if (maps == null || maps.Length == 0 || (maps.Length == 1 && maps[0].Trim().Length == 0)) { List <string> tmp = new List <string>(); foreach (var doc in m_connection.ResourceService.GetRepositoryResources(StringConstants.RootIdentifier, ResourceTypes.MapDefinition.ToString()).Children) { tmp.Add(doc.ResourceId); } maps = tmp.ToArray(); } foreach (string s in maps) { MapTilingConfiguration bm = new MapTilingConfiguration(this, s); if (bm.Resolutions > 0) { m_maps.Add(bm); } } }
static void bx_BeginRenderingScale(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { beginScale = DateTime.Now; if (m_logableProgress) Console.WriteLine(string.Format(Strings.ConsoleOperationBeginScale, beginMap, map.MapDefinition.BaseMap.GetScaleAt(scaleindex), scaleindex, map.Resolutions)); }
static void bx_FailedRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref Exception exception) { exceptionList.Add(exception); exception = null; }
static void bx_FinishRenderingScale(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { TimeSpan duration = DateTime.Now - beginScale; if (m_logableProgress) Console.WriteLine(string.Format(Strings.ConsoleOperationFinishScale, DateTime.Now, map.MapDefinition.BaseMap.GetScaleAt(scaleindex), duration)); }
internal Exception InvokeError(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col, ref Exception exception) { if (this.FailedRenderingTile != null) this.FailedRenderingTile(CallbackStates.FailedRenderingTile, batchMap, group, scaleindex, row, col, ref exception); return exception; }
static void DisplayProgress(MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { if (hasConsole) Console.Clear(); Console.WriteLine(string.Format(Strings.ConsoleUpdateTime.Replace("\\t", "\t"), DateTime.Now)); Console.WriteLine(string.Format(Strings.ConsoleCurrentMap.Replace("\\t", "\t"), map.ResourceId, mapCount, map.Parent.Maps.Count)); Console.WriteLine(string.Format(Strings.ConsoleCurrentGroup.Replace("\\t", "\t"), group, groupCount, map.MapDefinition.BaseMap.GroupCount)); Console.WriteLine(string.Format(Strings.ConsoleCurrentScale.Replace("\\t", "\t"), map.MapDefinition.BaseMap.GetScaleAt(Array.IndexOf<int>(map.ScaleIndexMap, scaleindex)), Array.IndexOf<int>(map.ScaleIndexMap, scaleindex) + 1, map.MapDefinition.BaseMap.ScaleCount)); Console.WriteLine(string.Format(Strings.ConsoleCurrentTile.Replace("\\t", "\t"), tileCount, totalTiles)); Console.WriteLine(); Console.WriteLine(string.Format(Strings.ConsoleGroupDuration.Replace("\\t", "\t"), DateTime.Now - beginGroup)); Console.WriteLine(string.Format(Strings.ConsoleGroupEstimate.Replace("\\t", "\t"), new TimeSpan(prevDuration.Ticks * totalTiles))); if (exceptionList.Count != 0) { Console.WriteLine(); Console.WriteLine(string.Format(Strings.ConsoleErrorSummary, exceptionList.Count, exceptionList[exceptionList.Count - 1].ToString())); } }
private void DisplayProgress(MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { if (m_cancel) cancel = true; if (this.InvokeRequired) this.Invoke(new DisplayProgressDelegate(DisplayProgress), new object[] { map, group, scaleindex, row, column, cancel }); else { label1.Text = string.Format(Strings.CurrentGroupStatus, group, map.ResourceId); tilePG.Value = (int)Math.Max(Math.Min((m_tileCount / (double)m_totalTiles) * (tilePG.Maximum - tilePG.Minimum), tilePG.Maximum), tilePG.Minimum); totalPG.Value = (int)Math.Max(Math.Min((m_grandTotalTileCount / (double)m_grandTotalTiles) * (totalPG.Maximum - totalPG.Minimum), totalPG.Maximum), totalPG.Minimum); if (m_failCount == 0) tileCounter.Text = string.Format(Strings.CurrentTileCounter, m_grandTotalTileCount, m_grandTotalTiles, ""); else tileCounter.Text = string.Format(Strings.CurrentTileCounter, m_grandTotalTileCount, m_grandTotalTiles, string.Format(Strings.TileErrorCount, m_failCount)); TimeSpan elapsed = DateTime.Now - m_grandBegin; DateTime finish = DateTime.Now + (new TimeSpan(m_prevDuration.Ticks * m_grandTotalTiles) - elapsed); TimeSpan remain = finish - DateTime.Now; if (finish < DateTime.Now) finishEstimate.Text = Strings.InsufficientTimePassed; else finishEstimate.Text = string.Format(Strings.RemainingTime, finish.ToShortTimeString(), string.Format("{0}:{1}:{2}", (int)Math.Floor(remain.TotalHours), remain.Minutes.ToString("00"), remain.Seconds.ToString("00"))); } }
void bx_FinishRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { m_tileRuns.Add(DateTime.Now - m_beginTile); m_tileCount++; m_grandTotalTileCount++; //Update display, after 1000 tiles if (m_tileRuns.Count > 500 || (DateTime.Now - m_lastUpdate).TotalSeconds > 5 || m_cancel) { long d = 0; foreach (TimeSpan ts in m_tileRuns) d += ts.Ticks; d /= m_tileRuns.Count; //For all other than the first calculation, we use the previous counts too if (m_grandTotalTileCount != m_tileRuns.Count) d = (d + m_prevDuration.Ticks) / 2; m_prevDuration = new TimeSpan(d); TimeSpan duration = new TimeSpan(d * m_totalTiles); m_tileRuns.Clear(); m_lastUpdate = DateTime.Now; DisplayProgress(map, group, scaleindex, row, column, ref cancel); } }
void bx_FinishRenderingMaps(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { if (this.InvokeRequired) this.Invoke(new System.Threading.ThreadStart(DoClose)); else DoClose(); }
void bx_FailedRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref Exception exception) { m_failCount++; exception = null; //Eat it }
void bx_BeginRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { m_beginTile = DateTime.Now; }
void bx_BeginRenderingMap(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { m_tileCount = 0; }
private static void TriggerEvent(TileProgressEventHandler evt, object sender, CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { var args = new TileProgressEventArgs(state, map, group, scaleindex, row, column, cancel); evt?.Invoke(sender, args); cancel = args.Cancel; }
private void button1_Click(object sender, EventArgs e) { IServerConnection con = m_connection; if (chkUseDifferentConnection.Checked) { if (UseNativeAPI.Checked) { string webconfig = System.IO.Path.Combine(Application.StartupPath, "webconfig.ini"); //NOXLATE if (!System.IO.File.Exists(webconfig)) { MessageBox.Show(this, string.Format(Strings.MissingWebConfigFile, webconfig), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { var initP = new NameValueCollection(); initP["ConfigFile"] = webconfig; //NOXLATE initP["Username"] = Username.Text; //NOXLATE initP["Password"] = Password.Text; //NOXLATE con = ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative", initP); //NOXLATE } catch (Exception ex) { string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); MessageBox.Show(this, string.Format(Strings.ConnectionError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { try { var initP = new NameValueCollection(); initP["Url"] = MapAgent.Text; //NOXLATE initP["Username"] = Username.Text; //NOXLATE initP["Password"] = Password.Text; //NOXLATE initP["AllowUntestedVersion"] = "true"; //NOXLATE con = ConnectionProviderRegistry.CreateConnection("Maestro.Http", initP); //NOXLATE } catch (Exception ex) { string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); MessageBox.Show(this, string.Format(Strings.ConnectionError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } try { TilingRunCollection bx = new TilingRunCollection(con); if (LimitTileset.Checked) { if (MaxRowLimit.Value > 0) bx.LimitRows((int)MaxRowLimit.Value); if (MaxColLimit.Value > 0) bx.LimitCols((int)MaxColLimit.Value); } if (UseOfficialMethod.Checked) { bx.Config.MetersPerUnit = (double)MetersPerUnit.Value; bx.Config.UseOfficialMethod = true; } bx.Config.ThreadCount = (int)ThreadCount.Value; bx.Config.RandomizeTileSequence = RandomTileOrder.Checked; foreach (Config c in ReadTree()) { MapTilingConfiguration bm = new MapTilingConfiguration(bx, c.MapDefinition); bm.SetGroups(new string[] { c.Group }); bm.SetScalesAndExtend(c.ScaleIndexes,c.ExtentOverride); bx.Maps.Add(bm); } Progress p = new Progress(bx); if (p.ShowDialog(this) != DialogResult.Cancel) { var ts = p.TotalTime; MessageBox.Show(string.Format(Strings.TileGenerationCompleted, ((ts.Days * 24) + ts.Hours), ts.Minutes, ts.Seconds)); } } catch (Exception ex) { string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); MessageBox.Show(this, string.Format(Strings.InternalError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal void InvokeBeginRendering(MapTilingConfiguration batchMap, string group) { if (this.BeginRenderingGroup != null) this.BeginRenderingGroup(CallbackStates.StartRenderGroup, batchMap, group, -1, -1, -1, ref m_cancel); PauseEvent.WaitOne(); }
static void bx_FinishRenderingTile(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { tileRuns.Add(DateTime.Now - beginTile); tileCount++; //Update display, after 1000 tiles if (tileRuns.Count > 500 || (DateTime.Now - lastUpdate).TotalSeconds > 5) { long d = 0; foreach (TimeSpan ts in tileRuns) d += ts.Ticks; d /= tileRuns.Count; //For all other than the first calculation, we use the previous counts too if (tileCount != tileRuns.Count) d = (d + prevDuration.Ticks) / 2; prevDuration = new TimeSpan(d); TimeSpan duration = new TimeSpan(d * totalTiles); tileRuns.Clear(); lastUpdate = DateTime.Now; if (m_logableProgress) Console.WriteLine(string.Format(Strings.ConsoleOperationFinishTile, tileCount, totalTiles, group, duration)); else DisplayProgress(map, group, scaleindex, row, column, ref cancel); } }
/// <summary> /// Adds the specified map definition ids /// </summary> /// <param name="maps"></param> public void AddMapDefinitions(string[] maps) { if (maps == null || maps.Length == 0 || (maps.Length == 1 && maps[0].Trim().Length == 0)) { List<string> tmp = new List<string>(); foreach (var doc in m_connection.ResourceService.GetRepositoryResources(StringConstants.RootIdentifier, ResourceTypes.MapDefinition.ToString()).Children) tmp.Add(doc.ResourceId); maps = tmp.ToArray(); } foreach (string s in maps) { MapTilingConfiguration bm = new MapTilingConfiguration(this, s); if (bm.Resolutions > 0) m_maps.Add(bm); } }
internal void InvokeFinishRendering(MapTilingConfiguration batchMap, string group) { if (this.FinishRenderingGroup != null) this.FinishRenderingGroup(CallbackStates.FinishRenderGroup, batchMap, group, -1, -1, -1, ref m_cancel); }
internal void InvokeBeginRendering(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col) { if (this.BeginRenderingTile != null) this.BeginRenderingTile(CallbackStates.StartRenderTile, batchMap, group, scaleindex, row, col, ref m_cancel); PauseEvent.WaitOne(); }
static void bx_BeginRenderingMap(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { mapCount++; beginMap = DateTime.Now; if (m_logableProgress) Console.WriteLine(string.Format(Strings.ConsoleOperationBeginMap, beginMap, map.ResourceId)); }
internal void InvokeFinishRendering(MapTilingConfiguration batchMap) { if (this.FinishRenderingMap != null) this.FinishRenderingMap(CallbackStates.FinishRenderMap, batchMap, null, -1, -1, -1, ref m_cancel); }
static void bx_FinishRenderingMap(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { groupCount = 0; TimeSpan duration = DateTime.Now - beginMap; if (m_logableProgress) Console.WriteLine(string.Format(Strings.ConsoleOperationFinishMap, DateTime.Now, map.ResourceId, duration)); }
internal void InvokeFinishRendering(MapTilingConfiguration batchMap, string group, int scaleindex, int row, int col) { if (this.FinishRenderingTile != null) this.FinishRenderingTile(CallbackStates.FinishRenderTile, batchMap, group, scaleindex, row, col, ref m_cancel); }
static void bx_BeginRenderingGroup(CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel) { groupCount++; beginGroup = DateTime.Now; if (m_logableProgress) Console.WriteLine(string.Format(Strings.ConsoleOperationBeginGroup, beginGroup, group, 1, 1)); tileRuns = new List<TimeSpan>(); tileCount = 0; totalTiles = map.TotalTiles; }