private static void ProccessSectors(TaskData td, int[] pendingSectorsList, GeoGrillas gg, Parser dev) { var enviarceros = true; if (td.Full) { enviarceros = dev.DataProvider.GetDetalleDispositivo(dev.Id, "SendZerosQTree").AsBoolean(false); } var buffer = new byte[BytesInSector * 2]; var sbZeros = new StringBuilder(); var sbNonZeros = new StringBuilder(); var totales = pendingSectorsList.Length; for (var index = 0; index < totales; index++) { var act = pendingSectorsList[index]; var nxt = (totales < (index + 2)) ? -1 : pendingSectorsList[index + 1]; int pending; if (act + 1 == nxt) { gg.get2Sectors(act, buffer); pending = BytesInSectorTimes2; index++; } else { gg.getSector(act, buffer); pending = BytesInSector; } Proccess1Or2Sectors(dev, act, buffer, sbZeros, sbNonZeros, totales, pending, enviarceros); } }
private void LoadQtreeInfo() { chkQtree.Visible = WebSecurity.IsSecuredAllowed(Securables.ViewQtree); tblVersion.Visible = chkQtree.Checked; tblEditar.Visible = chkQtree.Checked && WebSecurity.IsSecuredAllowed(Securables.EditQtree); if (chkQtree.Checked) { var vehicle = DAOFactory.CocheDAO.FindById(ddlMovil.Selected); if (vehicle.Dispositivo == null) { return; } var qtreeDir = DAOFactory.DetalleDispositivoDAO.GetQtreeFileNameValue(vehicle.Dispositivo.Id); var qtreeVersion = DAOFactory.DetalleDispositivoDAO.GetQtreeRevisionNumberValue(vehicle.Dispositivo.Id); lblArchivo.Text = qtreeDir; lblVersionEquipo.Text = qtreeVersion; var gg = new GeoGrillas { Repository = new Repository { BaseFolderPath = Path.Combine(Config.Qtree.QtreeGteDirectory, qtreeDir) } }; var revision = 0; var base_revision = 0; int.TryParse(qtreeVersion, out base_revision); var changedSectorsList = new TransactionLog(gg.Repository, vehicle.Dispositivo.Id).GetChangedSectorsAndRevision(base_revision, out revision); lblVersionServer.Text = revision.ToString(); pnlQtree.Update(); } }
private static void CreateGeogrillaTxtInternal(TaskData td) { try { if (td.Device.LastGeogrillaSentTimestamp.AddMinutes(30) > DateTime.UtcNow) { STrace.Log(typeof(Mensaje).FullName, null, td.Device.Id, td.Full ? LogTypes.Error : LogTypes.Debug, null, String.Format("No Foteo Geogrilla {0} por tiempo de espera minimo entre actualizaciones no alcanzado, ultima actualizacion: {1}", td.Full ? "full" : "incremental", td.Device.LastGeogrillaSentTimestamp.ToLocalTime())); return; } td.Device.LastGeogrillaSentTimestamp = DateTime.UtcNow; var gg = new GeoGrillas { Repository = new Repository { BaseFolderPath = td.Path, } }; var headers = gg.GridStructure; //si no esta bien cargado el header fix it if (headers.ActiveKey != 0x55AA55AA) { headers.ActiveKey = 0x55AA55AA; headers.DataStart = 1; } //si hay en fota un envio de qtree usar esa revision como base var fotaRev = GetPendingFotaRevision(td.Device); if (fotaRev > td.BaseRev) { td.BaseRev = fotaRev; } int revision; var changedSectorsList = new TransactionLog(gg.Repository, td.Device.Id) .GetChangedSectorsAndRevision(td.BaseRev, out revision) .SelectMany(file => file.Value, (file, sectorindex) => (file.Key) + sectorindex) .ToArray(); if (td.Full) { var countSectors = (int)(Math.Ceiling(headers.Lat_GridCount / 32.0) * Math.Ceiling(headers.Lon_GridCount / 32.0)); changedSectorsList = Enumerable.Range(0, countSectors).ToArray(); } if (changedSectorsList.Length == 0) { STrace.Debug(typeof(Parser).FullName, td.Device.Id, String.Format("Cancelando envio de geogrilla por no haber sectores cambiados, BaseRev={0} LatestRev={1}", td.BaseRev, revision)); return; } var limit = td.Device.DataProvider.GetDetalleDispositivo(td.Device.Id, "LimiteGeogrillaIncremental").As(20480); if (!td.Full && changedSectorsList.Length > limit) { //limite en el tamaño del diferencial generado de x sectores o megas, configurable en la plataforma con el detalle de dispositivo "LimiteGeogrillaIncremental". STrace.Trace(typeof(Parser).FullName, td.Device.Id, String.Format(@"Cancelando envio de geogrilla incremental por superar el limite de sectores (detalle de dispositivo ""LimiteGeogrillaIncremental""): limite={0} cantidad={1}", limit, changedSectorsList.Length)); return; } //seteo desde ya la revision en la base por si vuelven a enviar un qtree diferencial que se sume solo lo nuevo td.Device.DataProvider.SetDetalleDispositivo(td.Device.Id, "known_qtree_revision", revision.ToString("D4"), "int"); STrace.Debug(typeof(Parser).FullName, td.Device.Id, String.Format("Generando Geogrilla, BaseRev={0} LatestRev={1} GGName={2}", td.BaseRev, revision, td.Path)); if (td.Full) { var head = td.Device.DataProvider.GetDetalleDispositivo(td.Device.Id, "FullQtreePartitionsSd").AsBoolean(false) ? String.Format( ">SUV29*<{0}>SUVU55AA<{0}>SSDF,|G1,{1},TestMap<{0}>SUV29AQSDF,14,3,|G1<{0}", Environment.NewLine, td.Device.DataProvider.GetDetalleDispositivo(td.Device.Id, "QtreeSdPartitionSize").As("3800000")) : String.Empty; Fota.EnqueueLowPriority1(td.Device, 0, SetGGParams(headers, head)); } Fota.EnqueueLowPriority1(td.Device, 0, Fota.VirtualMessageFactory(MessageIdentifier.QtreeStart, td.Device.NextSequence)); ProccessSectors(td, changedSectorsList, gg, td.Device); var bytes = BitConverter.GetBytes(revision); var hexa = StringUtils.ByteArrayToHexString(bytes, 0, bytes.Length); var salida = String.Format("{1}>SSDG1,W0000008004{0}<{2}{1}>QSDG1,R0000008004<{1}", hexa, Environment.NewLine, Fota.VirtualMessageFactory(MessageIdentifier.QtreeSuccess, 0)); Fota.EnqueueLowPriority2(td.Device, td.MessageId, salida); STrace.Trace(typeof(Parser).FullName, td.Device.Id, String.Format("geogrilla a revision: {0} desde: {1} cantidad de sectores: {2}", revision, td.BaseRev, changedSectorsList.Length)); } catch (Exception e) { STrace.Exception(typeof(Parser).FullName, e, td.Device.Id, "Exception during CreateGeogrillaTxt"); } }