Browse Source
- 修复OnLTECellConfigurationReceived和OnNrCellConfigurationReceived方法中的命名错误和异常处理 - 规范化参数命名,将CellConfiguration改为cellConfiguration,符合C#命名约定 - 增强空值检查,添加输入参数的空值验证,避免空引用异常 - 改进异常处理,移除空的异常处理块,改为记录错误而不是重新抛出异常 - 添加详细的日志记录,为每个处理步骤提供完整的跟踪信息 - 实现错误隔离,单个配置项处理失败不影响其他配置项的处理 - 优化代码结构,提高可读性和维护性 修复的关键问题: - 参数命名不规范导致代码可读性差 - 缺少空值检查可能导致空引用异常 - 异常处理不当影响整体处理流程 - 日志记录不详细难以调试问题 - 单个错误导致整个处理流程失败 影响范围:小区配置处理的稳定性和可靠性,错误处理和日志记录能力,代码可读性和维护性,调试和问题排查能力feature/protocol-log-Perfect
10 changed files with 796 additions and 1 deletions
@ -0,0 +1,79 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace CoreAgent.Domain.Models.Network |
|||
{ |
|||
public class CellConfigurationProvider |
|||
{ |
|||
private readonly List<LTECellConfiguration> _lteCellConfigurations; |
|||
private readonly List<NrCellConfiguration> _nrCellConfigurations; |
|||
|
|||
public IReadOnlyList<LTECellConfiguration> LTECellConfigurations => _lteCellConfigurations.AsReadOnly(); |
|||
public IReadOnlyList<NrCellConfiguration> NrCellConfigurations => _nrCellConfigurations.AsReadOnly(); |
|||
|
|||
public CellConfigurationProvider() |
|||
{ |
|||
_lteCellConfigurations = new List<LTECellConfiguration>(); |
|||
_nrCellConfigurations = new List<NrCellConfiguration>(); |
|||
} |
|||
|
|||
public void AddLTEConfiguration(LTECellConfiguration configuration) |
|||
{ |
|||
var existingConfig = _lteCellConfigurations.FirstOrDefault(s => s.CellID == configuration.CellID); |
|||
if (existingConfig != null) |
|||
_lteCellConfigurations.Remove(existingConfig); |
|||
_lteCellConfigurations.Add(configuration); |
|||
} |
|||
|
|||
public void AddNrConfiguration(NrCellConfiguration configuration) |
|||
{ |
|||
var existingConfig = _nrCellConfigurations.FirstOrDefault(s => s.CellID == configuration.CellID); |
|||
if (existingConfig != null) |
|||
_nrCellConfigurations.Remove(existingConfig); |
|||
_nrCellConfigurations.Add(configuration); |
|||
} |
|||
|
|||
private void RemoveLTEConfiguration(int cellId) |
|||
{ |
|||
var config = _lteCellConfigurations.FirstOrDefault(s => s.CellID == cellId); |
|||
if (config != null) |
|||
_lteCellConfigurations.Remove(config); |
|||
} |
|||
|
|||
private void RemoveNrConfiguration(int cellId) |
|||
{ |
|||
var config = _nrCellConfigurations.FirstOrDefault(s => s.CellID == cellId); |
|||
if (config != null) |
|||
_nrCellConfigurations.Remove(config); |
|||
} |
|||
|
|||
public LTECellConfiguration? GetLTEConfiguration(int cellId) |
|||
{ |
|||
return _lteCellConfigurations.FirstOrDefault(s => s.CellID == cellId); |
|||
} |
|||
|
|||
public NrCellConfiguration? GetNrConfiguration(int cellId) |
|||
{ |
|||
return _nrCellConfigurations.FirstOrDefault(s => s.CellID == cellId); |
|||
} |
|||
|
|||
public Dictionary<int, int> GetCellPortMapping() |
|||
{ |
|||
var result = new Dictionary<int, int>(); |
|||
|
|||
// 添加LTE配置
|
|||
foreach (var config in _lteCellConfigurations) |
|||
{ |
|||
result[config.CellID] = config.RfPort; |
|||
} |
|||
|
|||
// 添加NR配置
|
|||
foreach (var config in _nrCellConfigurations) |
|||
{ |
|||
result[config.CellID] = config.RfPort; |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,251 @@ |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace CoreAgent.Domain.Models.Network |
|||
{ |
|||
/// <summary>
|
|||
/// 小区配置实体,对应无线参数配置
|
|||
/// 用于存储LTE小区的各种物理层和协议层配置参数
|
|||
/// 支持JSON序列化,属性名与外部API保持一致
|
|||
/// </summary>
|
|||
public class LTECellConfiguration |
|||
{ |
|||
/// <summary>
|
|||
/// 小区ID
|
|||
/// </summary>
|
|||
[JsonProperty("cell_Id")] |
|||
public int CellID { get; set; } |
|||
/// <summary>下行天线数量</summary>
|
|||
[JsonProperty("n_antenna_dl")] |
|||
public int NAntennaDl { get; set; } |
|||
|
|||
/// <summary>上行天线数量</summary>
|
|||
[JsonProperty("n_antenna_ul")] |
|||
public int NAntennaUl { get; set; } |
|||
|
|||
/// <summary>下行传输层数</summary>
|
|||
[JsonProperty("n_layer_dl")] |
|||
public int NLayerDl { get; set; } |
|||
|
|||
/// <summary>上行传输层数</summary>
|
|||
[JsonProperty("n_layer_ul")] |
|||
public int NLayerUl { get; set; } |
|||
|
|||
/// <summary>天线增益(dB)</summary>
|
|||
[JsonProperty("gain")] |
|||
public int Gain { get; set; } |
|||
|
|||
/// <summary>上行链路是否禁用</summary>
|
|||
[JsonProperty("ul_disabled")] |
|||
public bool UlDisabled { get; set; } |
|||
|
|||
/// <summary>射频端口号</summary>
|
|||
[JsonProperty("rf_port")] |
|||
public int RfPort { get; set; } |
|||
|
|||
/// <summary>下行QAM调制阶数</summary>
|
|||
[JsonProperty("dl_qam")] |
|||
public int DlQam { get; set; } |
|||
|
|||
/// <summary>上行QAM调制阶数</summary>
|
|||
[JsonProperty("ul_qam")] |
|||
public int UlQam { get; set; } |
|||
|
|||
/// <summary>物理小区标识(PCI)</summary>
|
|||
[JsonProperty("n_id_cell")] |
|||
public int NIdCell { get; set; } |
|||
|
|||
/// <summary>下行资源块数量</summary>
|
|||
[JsonProperty("n_rb_dl")] |
|||
public int NRbDl { get; set; } |
|||
|
|||
/// <summary>上行资源块数量</summary>
|
|||
[JsonProperty("n_rb_ul")] |
|||
public int NRbUl { get; set; } |
|||
|
|||
/// <summary>下行E-UTRA绝对射频信道号</summary>
|
|||
[JsonProperty("dl_earfcn")] |
|||
public int DlEarfcn { get; set; } |
|||
|
|||
/// <summary>上行E-UTRA绝对射频信道号</summary>
|
|||
[JsonProperty("ul_earfcn")] |
|||
public int UlEarfcn { get; set; } |
|||
|
|||
/// <summary>LTE频段号</summary>
|
|||
[JsonProperty("band")] |
|||
public int Band { get; set; } |
|||
|
|||
/// <summary>下行载波频率(Hz)</summary>
|
|||
[JsonProperty("dl_freq")] |
|||
public long DlFreq { get; set; } |
|||
|
|||
/// <summary>上行载波频率(Hz)</summary>
|
|||
[JsonProperty("ul_freq")] |
|||
public long UlFreq { get; set; } |
|||
|
|||
/// <summary>双工模式(FDD/TDD)</summary>
|
|||
[JsonProperty("mode")] |
|||
public string Mode { get; set; } = string.Empty; |
|||
|
|||
/// <summary>PRACH序列索引</summary>
|
|||
[JsonProperty("prach_sequence_index")] |
|||
public int PrachSequenceIndex { get; set; } |
|||
|
|||
/// <summary>下行循环前缀类型</summary>
|
|||
[JsonProperty("dl_cyclic_prefix")] |
|||
public string DlCyclicPrefix { get; set; } = string.Empty; |
|||
|
|||
/// <summary>上行循环前缀类型</summary>
|
|||
[JsonProperty("ul_cyclic_prefix")] |
|||
public string UlCyclicPrefix { get; set; } = string.Empty; |
|||
|
|||
/// <summary>PRACH配置索引</summary>
|
|||
[JsonProperty("prach_config_index")] |
|||
public int PrachConfigIndex { get; set; } |
|||
|
|||
/// <summary>PRACH频域偏移</summary>
|
|||
[JsonProperty("prach_freq_offset")] |
|||
public int PrachFreqOffset { get; set; } |
|||
|
|||
/// <summary>PUCCH delta shift参数</summary>
|
|||
[JsonProperty("delta_pucch_shift")] |
|||
public int DeltaPucchShift { get; set; } |
|||
|
|||
/// <summary>CQI报告的资源块数量</summary>
|
|||
[JsonProperty("n_rb_cqi")] |
|||
public int NRbCqi { get; set; } |
|||
|
|||
/// <summary>循环移位天线端口数量</summary>
|
|||
[JsonProperty("n_cs_an")] |
|||
public int NCsAn { get; set; } |
|||
|
|||
/// <summary>PUCCH资源配置列表</summary>
|
|||
[JsonProperty("pucch_allocation")] |
|||
public List<PucchAllocation> PucchAllocation { get; set; } = new(); |
|||
|
|||
/// <summary>PUCCH ACK/NACK起始位置</summary>
|
|||
[JsonProperty("pucch_ack_nack_start")] |
|||
public int PucchAckNackStart { get; set; } |
|||
|
|||
/// <summary>PUCCH保留资源块列表</summary>
|
|||
[JsonProperty("pucch_reserved_rbs")] |
|||
public List<int> PucchReservedRbs { get; set; } = new(); |
|||
|
|||
/// <summary>调度请求(SR)资源数量</summary>
|
|||
[JsonProperty("sr_resource_count")] |
|||
public int SrResourceCount { get; set; } |
|||
|
|||
/// <summary>CQI资源数量</summary>
|
|||
[JsonProperty("cqi_resource_count")] |
|||
public int CqiResourceCount { get; set; } |
|||
|
|||
/// <summary>SRS资源配置</summary>
|
|||
[JsonProperty("srs_resources")] |
|||
public SrsResources SrsResources { get; set; } = new(); |
|||
|
|||
/// <summary>保证比特率(GBR)配置</summary>
|
|||
[JsonProperty("gbr")] |
|||
public GbrConfig Gbr { get; set; } = new(); |
|||
|
|||
/// <summary>跟踪区域码(TAC)</summary>
|
|||
[JsonProperty("tac")] |
|||
public int Tac { get; set; } |
|||
|
|||
/// <summary>邻区信息</summary>
|
|||
[JsonProperty("nr_scell_list")] |
|||
public List<NrScellItem> NrScellList { get; set; } = new(); |
|||
|
|||
/// <summary>公共陆地移动网络(PLMN)列表</summary>
|
|||
[JsonProperty("plmn_list")] |
|||
public List<PlmnItem> PlmnList { get; set; } = new(); |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
public void SetCellId(int id) |
|||
{ |
|||
this.CellID =id; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// PUCCH资源配置结构
|
|||
/// 定义物理上行控制信道的资源配置参数
|
|||
/// </summary>
|
|||
public class PucchAllocation |
|||
{ |
|||
/// <summary>PUCCH格式类型</summary>
|
|||
[JsonProperty("type")] |
|||
public string Type { get; set; } = string.Empty; |
|||
|
|||
/// <summary>分配的资源块数量</summary>
|
|||
[JsonProperty("rbs")] |
|||
public int Rbs { get; set; } |
|||
|
|||
/// <summary>PUCCH参数n</summary>
|
|||
[JsonProperty("n")] |
|||
public int N { get; set; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// SRS资源配置结构
|
|||
/// 定义探测参考信号的资源配置参数
|
|||
/// </summary>
|
|||
public class SrsResources |
|||
{ |
|||
/// <summary>频域偏移</summary>
|
|||
[JsonProperty("offsets")] |
|||
public int Offsets { get; set; } |
|||
|
|||
/// <summary>频点数量</summary>
|
|||
[JsonProperty("freqs")] |
|||
public int Freqs { get; set; } |
|||
|
|||
/// <summary>总资源数量</summary>
|
|||
[JsonProperty("total")] |
|||
public int Total { get; set; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 保证比特率(GBR)配置结构
|
|||
/// 定义服务质量相关的比特率限制
|
|||
/// </summary>
|
|||
public class GbrConfig |
|||
{ |
|||
/// <summary>下行速率限制(bps)</summary>
|
|||
[JsonProperty("dl_limit")] |
|||
public int DlLimit { get; set; } |
|||
|
|||
/// <summary>上行速率限制(bps)</summary>
|
|||
[JsonProperty("ul_limit")] |
|||
public int UlLimit { get; set; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// PLMN配置项
|
|||
/// 定义公共陆地移动网络的配置信息
|
|||
/// </summary>
|
|||
public class PlmnItem |
|||
{ |
|||
/// <summary>PLMN编码(MCC+MNC)</summary>
|
|||
[JsonProperty("plmn")] |
|||
public string Plmn { get; set; } = string.Empty; |
|||
|
|||
/// <summary>是否为保留PLMN</summary>
|
|||
[JsonProperty("reserved")] |
|||
public bool Reserved { get; set; } |
|||
} |
|||
/// <summary>
|
|||
/// 邻区信息
|
|||
/// </summary>
|
|||
public class NrScellItem |
|||
{ |
|||
[JsonProperty("cell_id")] |
|||
public int CellId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,152 @@ |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace CoreAgent.Domain.Models.Network |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 5G NR小区配置实体,对应5G无线参数配置
|
|||
/// 用于存储5G NR小区的各种物理层和协议层配置参数
|
|||
/// 支持JSON序列化,属性名与外部API保持一致
|
|||
/// </summary>
|
|||
public class NrCellConfiguration |
|||
{ |
|||
/// <summary>
|
|||
/// 小区ID
|
|||
/// </summary>
|
|||
[JsonProperty("cell_Id")] |
|||
public int CellID { get; set; } |
|||
/// <summary>下行天线数量</summary>
|
|||
[JsonProperty("n_antenna_dl")] |
|||
public int NAntennaDl { get; set; } |
|||
|
|||
/// <summary>上行天线数量</summary>
|
|||
[JsonProperty("n_antenna_ul")] |
|||
public int NAntennaUl { get; set; } |
|||
|
|||
/// <summary>下行传输层数</summary>
|
|||
[JsonProperty("n_layer_dl")] |
|||
public int NLayerDl { get; set; } |
|||
|
|||
/// <summary>上行传输层数</summary>
|
|||
[JsonProperty("n_layer_ul")] |
|||
public int NLayerUl { get; set; } |
|||
|
|||
/// <summary>天线增益(dB)</summary>
|
|||
[JsonProperty("gain")] |
|||
public int Gain { get; set; } |
|||
|
|||
/// <summary>上行链路是否禁用</summary>
|
|||
[JsonProperty("ul_disabled")] |
|||
public bool UlDisabled { get; set; } |
|||
|
|||
/// <summary>射频端口号</summary>
|
|||
[JsonProperty("rf_port")] |
|||
public int RfPort { get; set; } |
|||
|
|||
/// <summary>下行QAM调制阶数</summary>
|
|||
[JsonProperty("dl_qam")] |
|||
public int DlQam { get; set; } |
|||
|
|||
/// <summary>上行QAM调制阶数</summary>
|
|||
[JsonProperty("ul_qam")] |
|||
public int UlQam { get; set; } |
|||
|
|||
/// <summary>5G NR物理小区标识</summary>
|
|||
[JsonProperty("n_id_nrcell")] |
|||
public int NIdNrCell { get; set; } |
|||
|
|||
/// <summary>5G NR频段号</summary>
|
|||
[JsonProperty("band")] |
|||
public int Band { get; set; } |
|||
|
|||
/// <summary>下行5G NR绝对射频信道号</summary>
|
|||
[JsonProperty("dl_nr_arfcn")] |
|||
public int DlNrArfcn { get; set; } |
|||
|
|||
/// <summary>上行5G NR绝对射频信道号</summary>
|
|||
[JsonProperty("ul_nr_arfcn")] |
|||
public int UlNrArfcn { get; set; } |
|||
|
|||
/// <summary>下行载波频率(Hz)</summary>
|
|||
[JsonProperty("dl_freq")] |
|||
public long DlFreq { get; set; } |
|||
|
|||
/// <summary>上行载波频率(Hz)</summary>
|
|||
[JsonProperty("ul_freq")] |
|||
public long UlFreq { get; set; } |
|||
|
|||
/// <summary>下行资源块数量</summary>
|
|||
[JsonProperty("n_rb_dl")] |
|||
public int NRbDl { get; set; } |
|||
|
|||
/// <summary>上行资源块数量</summary>
|
|||
[JsonProperty("n_rb_ul")] |
|||
public int NRbUl { get; set; } |
|||
|
|||
/// <summary>SSB 5G NR绝对射频信道号</summary>
|
|||
[JsonProperty("ssb_nr_arfcn")] |
|||
public int SsbNrArfcn { get; set; } |
|||
|
|||
/// <summary>下行MU-MIMO配置</summary>
|
|||
[JsonProperty("dl_mu")] |
|||
public int DlMu { get; set; } |
|||
|
|||
/// <summary>上行MU-MIMO配置</summary>
|
|||
[JsonProperty("ul_mu")] |
|||
public int UlMu { get; set; } |
|||
|
|||
/// <summary>SSB MU-MIMO配置</summary>
|
|||
[JsonProperty("ssb_mu")] |
|||
public int SsbMu { get; set; } |
|||
|
|||
/// <summary>双工模式(FDD/TDD)</summary>
|
|||
[JsonProperty("mode")] |
|||
public string Mode { get; set; } = string.Empty; |
|||
|
|||
/// <summary>PRACH序列索引</summary>
|
|||
[JsonProperty("prach_sequence_index")] |
|||
public int PrachSequenceIndex { get; set; } |
|||
|
|||
/// <summary>保证比特率(GBR)配置</summary>
|
|||
[JsonProperty("gbr")] |
|||
public GbrConfig Gbr { get; set; } = new(); |
|||
|
|||
/// <summary>公共陆地移动网络(PLMN)列表</summary>
|
|||
[JsonProperty("plmn_list")] |
|||
public List<NrPlmnItem> PlmnList { get; set; } = new(); |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
public void SetCellId(int id) |
|||
{ |
|||
this.CellID = id; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 5G NR PLMN配置项
|
|||
/// 定义5G NR公共陆地移动网络的配置信息
|
|||
/// </summary>
|
|||
public class NrPlmnItem |
|||
{ |
|||
/// <summary>PLMN标识列表</summary>
|
|||
[JsonProperty("plmn_ids")] |
|||
public List<string> PlmnIds { get; set; } = new(); |
|||
|
|||
/// <summary>是否为保留PLMN</summary>
|
|||
[JsonProperty("reserved")] |
|||
public bool Reserved { get; set; } |
|||
|
|||
/// <summary>跟踪区域码(TAC)</summary>
|
|||
[JsonProperty("tac")] |
|||
public int Tac { get; set; } |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue