using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace LTEMvcApp.Models
{
///
/// LTE能力解析器
///
public class LTECapabilities
{
public string UEId { get; set; }
public List Bands { get; set; } = new List();
public int? Category { get; set; }
public int? CategoryDL { get; set; }
public int? CategoryUL { get; set; }
public List> ASN1Data { get; set; } = new List>();
public Dictionary BandCombinations { get; set; } = new Dictionary();
public List> CA { get; set; }
public List NRBands { get; set; }
public string VoNR { get; set; }
public List> MRDC { get; set; }
private List _pendingData = new List();
private int _count = 0;
public static readonly Dictionary UE_CAPS_MIMO = new Dictionary
{
["twoLayers"] = 2,
["fourLayers"] = 4,
["eightLayers"] = 8
};
///
/// 获取类别信息
///
public string GetCategory()
{
var cat = new List();
if (CategoryDL.HasValue)
cat.Add($"DL={CategoryDL}");
if (CategoryUL.HasValue)
cat.Add($"UL={CategoryUL}");
if (cat.Count > 0)
return string.Join(", ", cat);
if (Category.HasValue)
return Category.ToString();
return "?";
}
///
/// 添加待解析数据
///
public void Add(string[] data)
{
if (data != null && data.Length > 0)
{
_pendingData.Add(data);
}
}
///
/// 解析所有待处理数据
///
public LTECapabilities Parse()
{
while (_pendingData.Count > 0)
{
_count++;
ParseASN1(ASN1Parser.FromGSER(_pendingData[0]));
_pendingData.RemoveAt(0);
}
return _count > 0 ? this : null;
}
///
/// 解析ASN1数据
///
private void ParseASN1(Dictionary asn1)
{
if (asn1 == null) return;
ASN1Data.Add(asn1);
var ratList = ASN1Parser.Dig(asn1, "ueCapabilityInformation", "ueCapabilityInformation-r8", "ue-CapabilityRAT-ContainerList") as List