public static NearestPciCellView ConstructView(this NearestPciCell stat, IENodebRepository repository) { var view = Mapper.Map <NearestPciCell, NearestPciCellView>(stat); var eNodeb = repository.FirstOrDefault(x => x.ENodebId == stat.NearestCellId); view.NearestENodebName = eNodeb == null ? "Undefined" : eNodeb.Name; return(view); }
public static NearestPciCellView ConstructView(NearestPciCell stat, IENodebRepository repository, ICellRepository cellRepository, IInfrastructureRepository infrastructureRepository) { var view = Mapper.Map <NearestPciCell, NearestPciCellView>(stat); var eNodeb = repository.GetByENodebId(stat.NearestCellId); view.NearestENodebName = eNodeb == null ? "Undefined" : eNodeb.Name; return(view); }
public void TestImportCell_CellExistedInNeighbors(short pci) { repository.AddNeighbors(neiRepository.Object, 1); Mock <ICell> cell = new Mock <ICell>(); cell.SetupGet(x => x.CellId).Returns(1); cell.SetupGet(x => x.SectorId).Returns(1); NearestPciCell pciCell = repository.Import(cell.Object, pci); Assert.AreEqual(repository.NearestPciCells.Count, 3); Assert.AreEqual(pciCell.Pci, pci); }
public void UploadHwNeighbors(StreamReader reader) { var groupInfos = NeighborCellHwCsv.ReadNeighborCellHwCsvs(reader); foreach (var info in groupInfos) { var cell = NearestPciCell.ConstructCell(info, _cellRepository); if (cell.Pci >= 0) { NearestCells.Push(cell); } } }
public void TestImportCell_CanCalculateDistance(int eNodebId, byte sectorId, short pci, int neiCellId, byte neiSectorId) { repository.AddNeighbors(neiRepository.Object, 1); Mock <ICell> cell = new Mock <ICell>(); cell.SetupGet(x => x.CellId).Returns(eNodebId); cell.SetupGet(x => x.SectorId).Returns(sectorId); NearestPciCell pciCell = repository.Import(cell.Object, pci); Assert.AreEqual(repository.NearestPciCells.Count, 4); Assert.AreEqual(pciCell.Pci, pci); Assert.AreEqual(pciCell.NearestCellId, neiCellId); Assert.AreEqual(pciCell.NearestSectorId, neiSectorId); }
public void UpdateNeighborCell(NearestPciCell cell) { var item = _repository.GetNearestPciCell(cell.CellId, cell.SectorId, cell.Pci); if (item != null) { item.NearestCellId = cell.NearestCellId; item.NearestSectorId = cell.NearestSectorId; _repository.Update(item); } else { cell.TotalTimes = 98; _repository.Insert(cell); } _repository.SaveChanges(); }
public void ImportRecordSet(INearestPciCellRepository repository) { foreach (MrRecord record in RecordList) { foreach (MrNeighborCell neighborCell in record.NbCells) { NearestPciCell pciCell = repository.NearestPciCells.FirstOrDefault(x => x.CellId == record.RefCell.CellId && x.SectorId == record.RefCell.SectorId && x.Pci == neighborCell.Pci && (x.NearestSectorId < 30) == (neighborCell.Frequency < 1000)) ?? repository.Import(record.RefCell, neighborCell.Pci); if (pciCell == null) { continue; } neighborCell.CellId = pciCell.NearestCellId; neighborCell.SectorId = pciCell.NearestSectorId; } } }
public NearestPciCell Import(ICell cell, short pci) { int neiCellId = 0; byte neiSecId = 255; Cell refCell = _cells.FirstOrDefault(x => x.ENodebId == cell.CellId && x.SectorId == cell.SectorId); if (refCell == null) return null; Cell innerCell = _cells.FirstOrDefault(x => x.ENodebId == cell.CellId && x.SectorId != cell.SectorId && x.Pci == pci); if (innerCell != null) { neiCellId = cell.CellId; neiSecId = innerCell.SectorId; } else { IEnumerable<Cell> candidateCells = _cells.Where(x => x.Pci == pci); if (candidateCells.Any()) { double distance = Double.MaxValue; Cell objCell = candidateCells.ElementAt(0); foreach (Cell candidateCell in candidateCells) { double tempDistance = candidateCell.SimpleDistance(refCell); if (tempDistance < distance) { objCell = candidateCell; distance = tempDistance; } } neiCellId = objCell.ENodebId; neiSecId = objCell.SectorId; } } NearestPciCell newCell = NearestPciCells.FirstOrDefault(x => x.CellId == cell.CellId && x.SectorId == cell.SectorId && x.Pci == pci); if (newCell == null) { newCell = new NearestPciCell { CellId = cell.CellId, SectorId = cell.SectorId, NearestCellId = neiCellId, NearestSectorId = neiSecId, Pci = pci }; NearestPciCells.Add(newCell); } else { newCell.NearestCellId = neiCellId; newCell.NearestSectorId = neiSecId; } return newCell; }
public void Put(NearestPciCell cell) { _service.UpdateNeighborCell(cell); }
public NearestPciCell Import(ICell cell, short pci) { int neiCellId = 0; byte neiSecId = 255; Cell refCell = _cells.FirstOrDefault(x => x.ENodebId == cell.CellId && x.SectorId == cell.SectorId); if (refCell == null) { return(null); } Cell innerCell = _cells.FirstOrDefault(x => x.ENodebId == cell.CellId && x.SectorId != cell.SectorId && x.Pci == pci); if (innerCell != null) { neiCellId = cell.CellId; neiSecId = innerCell.SectorId; } else { IEnumerable <Cell> candidateCells = _cells.Where(x => x.Pci == pci); if (candidateCells.Any()) { double distance = Double.MaxValue; Cell objCell = candidateCells.ElementAt(0); foreach (Cell candidateCell in candidateCells) { double tempDistance = candidateCell.SimpleDistance(refCell); if (tempDistance < distance) { objCell = candidateCell; distance = tempDistance; } } neiCellId = objCell.ENodebId; neiSecId = objCell.SectorId; } } NearestPciCell newCell = NearestPciCells.FirstOrDefault(x => x.CellId == cell.CellId && x.SectorId == cell.SectorId && x.Pci == pci); if (newCell == null) { newCell = new NearestPciCell { CellId = cell.CellId, SectorId = cell.SectorId, NearestCellId = neiCellId, NearestSectorId = neiSecId, Pci = pci }; NearestPciCells.Add(newCell); } else { newCell.NearestCellId = neiCellId; newCell.NearestSectorId = neiSecId; } return(newCell); }