/// <summary> /// 给下行功率赋值 /// </summary> /// <param name="otherTrx"></param> /// <param name="sourcePwr"></param> /// <param name="ts"></param> /// <param name="otherUser"></param> /// <returns></returns> private float DLSourcePwr(GSMSimTRX otherTrx, float sourcePwr, GSMTimeSlot ts, GSMSimUser otherUser) { if (otherTrx.TSs[ts.Index].CurDLTxPower.ContainsKey(otherUser)) { sourcePwr = otherTrx.TSs[ts.Index].CurDLTxPower[otherUser]; }//不需要区分是否是在BCCH的TRX上 else if (otherTrx.TSs[ts.Index].PreDLTxPower.ContainsKey(otherUser)) { sourcePwr = otherTrx.TSs[ts.Index].PreDLTxPower[otherUser]; } else { sourcePwr = otherTrx.NeTRX.TRXPower; } return sourcePwr; }
/// <summary> /// 查找上行用户 /// </summary> private void FindSyULUser(GSMSimUser user, GSMSimTRX otherTrx, ref float sourcePwr, ref float loss, GSMTimeSlot ts, ref bool isFindOtherUser) { foreach (GSMSimUser otherUser in otherTrx.TSs[ts.Index].ULMsColl) { sourcePwr = ULSourcePwr(otherTrx, sourcePwr, ts, otherUser); m_IsOtherSignalDTX = otherUser.IsUseDTX; m_IsOtherUserCsService = otherUser.IsCs; isFindOtherUser = true; loss = m_TotalLossCalc.GetAllLoss(otherUser, user.BestServer, NetWorkType.GSM, false); break; } }
private static float ULSEandBCIResult(GSMSimUser user, NetWorkType netType, InterfResult res, float temp, GSMTimeSlot ts) { if (netType == NetWorkType.TDSCDMA) { if (!user.ULTDInterf.ContainsKey(ts)) { user.ULTDInterf.Add(ts, res.SE); } temp = user.ULTDInterf[ts]; temp = (float)UnitTrans.AdddBm(temp, res.SE); temp = (float)UnitTrans.AdddBm(temp, res.BCI); user.ULTDInterf[ts] = temp; } else { if (!user.ULUMTSInterf.ContainsKey(ts)) { user.ULUMTSInterf.Add(ts, res.SE); } temp = user.ULUMTSInterf[ts]; temp = (float)UnitTrans.AdddBm(temp, res.SE); temp = (float)UnitTrans.AdddBm(temp, res.BCI); user.ULUMTSInterf[ts] = temp; } return temp; }
/// <summary> /// 寻找同步下行用户 /// </summary> /// <param name="otherTrx"></param> /// <param name="sourcePwr"></param> /// <param name="ts"></param> /// <param name="isFindOtherUser"></param> private void FindSynDlUser(GSMSimTRX otherTrx, ref float sourcePwr, GSMTimeSlot ts, ref bool isFindOtherUser) { foreach (GSMSimUser otherUser in otherTrx.TSs[ts.Index].DLMsColl) { sourcePwr = DLSourcePwr(otherTrx, sourcePwr, ts, otherUser); m_IsOtherUserCsService = otherUser.IsCs; m_IsOtherSignalDTX = otherTrx.NeTRX.IsUseDTX; isFindOtherUser = true; //因为是静态仿真,只要找到一个用户即可。多个用户共享一个时隙是对一个时隙的帧(8个时隙长度)复用 break; } }
/// <summary> /// Mock8个时隙数组 /// </summary> /// <returns></returns> public static GSMTimeSlot[] Mock8GsmTimeSlot() { GSMSimTRX trx = MockGsmSimTrx(); GSMTimeSlot[] TSes = new GSMTimeSlot[8]; for (int i = 0; i < TSes.Length; i++) { Net.TimeGap timeGap = new Net.TimeGap(); TSes[i] = new GSMTimeSlot(timeGap); TSes[i].Index =(byte) i; TSes[i].Parent = trx; } TSes[0].NETimeSlot.ChanType = Net.ChannelType.BCCH; TSes[1].NETimeSlot.ChanType = Net.ChannelType.PDCH; TSes[2].NETimeSlot.ChanType = Net.ChannelType.PDCH; TSes[3].NETimeSlot.ChanType = Net.ChannelType.DPDCH; return TSes; }
private static float AddDLResult(GSMSimUser user, NetWorkType netType, InterfResult res, float temp, GSMTimeSlot ts) { if (netType == NetWorkType.TDSCDMA) { if (!user.DLTDInterf.ContainsKey(ts)) { user.DLTDInterf.Add(ts, float.NegativeInfinity); } temp = user.DLTDInterf[ts]; user.DLTDInterf[ts] = (float)UnitTrans.AdddBm(temp, res.IMP3); } else { if (!user.DLUMTSInterf.ContainsKey(ts)) { user.DLUMTSInterf.Add(ts, float.NegativeInfinity); } temp = user.DLUMTSInterf[ts]; user.DLUMTSInterf[ts] = (float)UnitTrans.AdddBm(temp, res.IMP3); } return temp; }
/// <summary> /// 将一个时隙分配给用户占用 /// </summary> /// <param name="user"></param> /// <param name="ts"></param> private void Allocation(GSMSimUser user, GSMTimeSlot ts) { if (m_IsDl) AllocationDlUser(user, ts); else AllocationUlUser(user, ts); }
//private bool ModifyDLSatisfy(GSMSimUser user) //{ // bool isSatisfy; // //modify by xg 5.17 // //modify by lyt 5.28 // if (m_ThrptCalc.MsCurDlThroughtput(user) > ((UnionPsService)user.TrafficUser.Service).DlMinThroughputDemand * 1000)//10000 /*(TrafficAssist.GetNetworkService<GSMPsService>(NetWorkType.GSM, user.TrafficUser.Service)).UlPSAssureRate) & JudeOtherUser(user, false)*/) // isSatisfy = true; // else // { // ClearUserDLResource(user); // isSatisfy = false; // } // return isSatisfy; //} //private void AllocateNewDLChn(List<GSMTimeSlot> TSs, GSMSimUser user) //{ // List<GSMTimeSlot> beAdded = new List<GSMTimeSlot>(); // RemoveDisMatchTs(TSs, user, true); // while (TSs.Count != 0) // { // GSMTimeSlot ts = FindDLBestChn(TSs, user); // AddOneDLTsToUser(TSs, user, beAdded, ts); // //add by 5.27 // CalculationCommon.UserAccessTrx(user, ts, false); // TSs.Remove(ts); // //if (thrptCalc.MsCurDlThroughtput(user) > (TrafficAssist.GetNetworkService<GSMPsService>(NetWorkType.GSM, user.SimUser.TrafficUser.Service)).DlPSReqRate && JudeOtherUser(user, true)) // //{ // // return; // //} // } //} //private void AddOneDLTsToUser(List<GSMTimeSlot> TSs, GSMSimUser user, List<GSMTimeSlot> beAdded, GSMTimeSlot ts) //{ // user.DlTs.Add(ts); // m_TchCir.Calc(user, true); // float dlCir = user.DlCirs[ts]; // CS cs = CalculationCommon.FindCs(user, dlCir, m_CsTable); // if (cs == CS.empty) // { // user.DlTs.Remove(ts); // user.DlCirs.Remove(ts); // TSs.Remove(ts); // return; // } // beAdded.Add(ts); // user.DlCs.Add(ts, cs); // float rate = FindRate(m_CsTable, cs, dlCir, user); // ts.CurDLThroughput.Add(user, rate); // ts.PreDLThroughput.Add(user, rate); // ts.CurDLTxPower.Add(user, ts.Parent.NeTRX.TRXPower); // ts.PreDLTxPower.Add(user, ts.Parent.NeTRX.TRXPower); // ts.DLMsColl.Add(user); // //add by 5.26 // if (CalculationCommon.HasContainUser(ts.Parent.CellUsers, user) == false) // { // ts.Parent.CellUsers.Add(user); // } //} //private GSMTimeSlot FindDLBestChn(List<GSMTimeSlot> TSs, GSMSimUser user) //{ // float bestCir = float.MinValue; // GSMTimeSlot bestTs = TSs[0]; // foreach (GSMTimeSlot ts in TSs) // { // GSMSimUser testUser = new GSMSimUser(user.TrafficUser); // testUser.BestServer = (GSMSimTRX)ts.Parent; // testUser.DlTs.Add(ts); // m_TchCir.Calc(testUser, true); // if (testUser.DlCirs[ts] > bestCir) // { // bestCir = testUser.DlCirs[ts]; // bestTs = ts; // } // } // return bestTs; //} //private List<GSMTimeSlot> AddDLTimeSlot(GSMSimUser user, List<GSMTimeSlot> remove, List<GSMSimTRX> trx) //{ // List<GSMTimeSlot> emptyTs = new List<GSMTimeSlot>(); // if (((user.DlTs.Count + 1) <= ((GSMTerminal)user.TrafficUser.Terminal.GetNetWorkTerminal(NetWorkType.GSM)).DlTimeslot) & ((user.UlTs.Count + 1 + user.DlTs.Count) <= ((GSMTerminal)user.TrafficUser.Terminal.GetNetWorkTerminal(NetWorkType.GSM)).TotalTimeslot)) // { // emptyTs.AddRange(FindDLEmptyTs(user, trx, remove)); // } // return emptyTs; //} //private List<GSMTimeSlot> FindDLEmptyTs(GSMSimUser user, List<GSMSimTRX> trxs, List<GSMTimeSlot> remove) //{ // List<GSMTimeSlot> emptyTs = new List<GSMTimeSlot>(); // foreach (GSMSimTRX trx in trxs) // { // emptyTs.AddRange(EmptyTsInTrx(trx, remove)); // } // return emptyTs; //} //private void FindTrxs(GSMSimUser user, List<GSMTimeSlot> Tss, List<GSMSimTRX> Trxs) //{ // List<GSMTimeSlot> allTs = new List<GSMTimeSlot>(); // allTs.AddRange(Tss); // allTs.AddRange(user.DlTs); // foreach (GSMTimeSlot ts in allTs) // { // if (Trxs.Contains(ts.Parent) == false) // Trxs.Add(ts.Parent); // } //} //private List<GSMTimeSlot> AdjustPerDLTs(GSMSimUser user) //{ // m_TchCir.Calc(user, true); // List<GSMTimeSlot> Tss = new List<GSMTimeSlot>(); // foreach (GSMTimeSlot ts in user.DlTs) // { // if (AdjustADLTs(user, ts) == false) // Tss.Add(ts); // } // ClearDLAccess(user, Tss); // return Tss; //} //private bool AdjustADLTs(GSMSimUser user, GSMTimeSlot ts) //{ // bool isSatisy = false; // if (((GSMTerminal)user.TrafficUser.Terminal.GetNetWorkTerminal(NetWorkType.GSM)).Technology == GsmTechnologyType.GPRS) // { // isSatisy = AdjustDL(user, ts, m_CsTable.CsToCir, m_CsTable.CsToCir[CS.Cs1]); // } // else if (((GSMTerminal)user.TrafficUser.Terminal.GetNetWorkTerminal(NetWorkType.GSM)).Technology == GsmTechnologyType.EGPRS) // { // isSatisy = AdjustDL(user, ts, m_CsTable.MCSToCir, m_CsTable.MCSToCir[CS.Mcs1]); // } // return isSatisy; //} //private bool AdjustDL(GSMSimUser user, GSMTimeSlot ts, Dictionary<CS, float> csToCir, float minCir) //{ // bool isSuccess; // float dlCir = user.DlCirs[ts]; // CS cs = user.DlCs[ts]; // float CurTd; // float CurNextTd; // SetDLThresthod(user, ts, out CurTd, out CurNextTd, csToCir); // //不需要调整编码方式 // if (CurTd < dlCir && dlCir < CurNextTd) // { // ts.CurDLThroughput.Add(user, ts.PreDLThroughput[user]); // isSuccess = true; // } // // Cir大于下一个编码方式的门限值或小于上一个编码方式的门限值,有上下调整空间 // else if (dlCir > CurNextTd | (dlCir < CurTd) & (cs != CS.Cs1) & (cs != CS.Mcs1) & (dlCir > minCir)) // { // //不是最高编码方式,可上调编码方式,则上调 // AdjustDLCs(user, ts, dlCir); // isSuccess = true; // } // else // { // //最低编码方式都不满足,该时隙不可用 // isSuccess = false; // } // return isSuccess; //} //private void AdjustDLCs(GSMSimUser user, GSMTimeSlot ts, float dlCir) //{ // CS cs = CalculationCommon.FindCs(user, dlCir, m_CsTable); // user.DlCs[ts] = cs; // ts.CurDLThroughput.Add(user, FindRate(m_CsTable, cs, dlCir, user)); //} //private void SetDLThresthod(GSMSimUser user, GSMTimeSlot ts, out float CurTd, out float CurNextTd, Dictionary<CS, float> csToCir) //{ // CurTd = csToCir[user.DlCs[ts]]; // if (user.DlCs[ts] != CS.Cs4 && user.DlCs[ts] != CS.Mcs9) // { // CurNextTd = csToCir[user.DlCs[ts] + 1]; // } // else // { // CurNextTd = float.MaxValue; // } //} //private void ClearDLAccess(GSMSimUser user, List<GSMTimeSlot> Tss) //{ // foreach (GSMTimeSlot toRemove in Tss) // { // ClearPerTsDLAccess(user, toRemove); // } // //若用户所有的下行时隙都无效后才将该用户从服务载波中清除 // if (user.DlTs.Count == 0) // { // user.DlCirs.Clear();//add by lyt 6.10 // RemoveUserFromTrx(user, Tss); // } //} //private void ClearPerTsDLAccess(GSMSimUser user, GSMTimeSlot ts) //{ // ts.PreDLThroughput.Remove(user); // ts.DLMsColl.Remove(user); // ts.PreDLTxPower.Remove(user); // ts.CurDLTxPower.Remove(user); // user.DlTs.Remove(ts); // //user.DlCs.Remove(ts); //} ///// <summary> ///// 给一个时隙寻找相对于当前cir和编码方式的速率 ///// </summary> ///// <param name="csTable"></param> ///// <param name="codeScheme"></param> ///// <param name="cir"></param> ///// <param name="user"></param> ///// <returns></returns> //private float FindRate(CodeSchemeTable csTable, CS codeScheme, float cir, GSMSimUser user) //{ // float rate; // if (((GSMTerminal)user.TrafficUser.Terminal.GetNetWorkTerminal(NetWorkType.GSM)).Technology == GsmTechnologyType.EGPRS && (int)codeScheme > 4) // { // rate = FindCreteRate(csTable.EDGECirToRate, cir, codeScheme, user, csTable); // } // else // { // rate = FindCreteRate(csTable.CirToRate, cir, codeScheme, user, csTable); // } // return rate; //} ///// <summary> ///// 具体寻找速率的方法 ///// </summary> ///// <param name="rateTable"></param> ///// <param name="cir"></param> ///// <param name="codeScheme"></param> ///// <param name="user"></param> ///// <param name="csTable"></param> ///// <returns></returns> //private float FindCreteRate(Dictionary<CS, Dictionary<float, float>> rateTable, float cir, CS codeScheme, GSMSimUser user, CodeSchemeTable csTable) //{ // float rate = float.MinValue; // //如速率可直接查表得到。则返回查表得到的数值 // if (rateTable[codeScheme].ContainsKey(cir)) // { // rate = rateTable[codeScheme][cir]; // } // //使用插值算法求速率 // else // { // rate = CalculationCommon.InquireRate(cir, rateTable, codeScheme); // } // return rate; //} ///// <summary> ///// 移除和用户不在同一个载波上的时隙 ///// </summary> ///// <param name="TSs"></param> ///// <param name="user"></param> //private void RemoveDisMatchTs(List<GSMTimeSlot> TSs, GSMSimUser user, bool isDl) //{ // List<GSMTimeSlot> toBeRemove = new List<GSMTimeSlot>(); // if (isDl == true && user.DlTs.Count != 0) // { // foreach (GSMTimeSlot ts in TSs) // { // if (ts.Parent != user.DlTs[0].Parent) // toBeRemove.Add(ts); // } // } // else if (isDl == false && user.UlTs.Count != 0) // { // foreach (GSMTimeSlot ts in TSs) // { // if (ts.Parent != user.UlTs[0].Parent) // toBeRemove.Add(ts); // } // } // foreach (GSMTimeSlot ts in toBeRemove) // { // TSs.Remove(ts); // } //} ////add by 5.26 //private void RemoveUserFromTrx(GSMSimUser user, List<GSMTimeSlot> Tss) //{ // if (Tss.Count != 0) // { // Tss[0].Parent.CellUsers.Remove(user); // Tss[0].Parent.LastKick.Add(user); // } //} ///// <summary> ///// 在用户所在trx上寻找空闲时隙 ///// </summary> ///// <param name="trx"></param> ///// <param name="remove"></param> ///// <returns></returns> //private List<GSMTimeSlot> EmptyTsInTrx(GSMSimTRX trx, List<GSMTimeSlot> remove) //{ // List<GSMTimeSlot> emptyTs = new List<GSMTimeSlot>(); // foreach (GSMTimeSlot ts in trx.TSs) // { // if (ts.DLMsColl.Count == 0 & ts.ULMsColl.Count == 0 & (ts.NETimeSlot.ChanType == Huawei.UNet.NE.Interface.ChannelType.PDCH || ts.NETimeSlot.ChanType == Huawei.UNet.NE.Interface.ChannelType.DPDCH) & (remove.Contains(ts) == false)) // emptyTs.Add(ts); // } // return emptyTs; //} //add by 5.26 private void RemoveUserFromTrx(GSMSimUser user, GSMTimeSlot ts) { ts.Parent.CellUsers.Remove(user); ts.Parent.LastKick.Add(user); }
/// <summary> /// 满足解调门限 /// </summary> private bool IsStatisfDemoThrd(GSMTimeSlot ts,float cir) { return m_ChnAllocation.CsTable.GetPsDemodulationThreshold(cir,m_Terminal.Technology); }
/// <summary> /// 时隙中的用户数 /// </summary> private List<GSMSimUser> GetUsersOfTs(GSMTimeSlot ts) { if (m_IsDl) return ts.DLMsColl; else return ts.ULMsColl; }
/// <summary> /// 判断若用户的接入后,时隙中已存在的用户是否还能达到保证速率 /// </summary> private bool IsStatisfAccessRate(GSMSimUser user, GSMTimeSlot ts, List<GSMSimUser> usersOfTs) { GSMSimUser tempUser = new GSMSimUser(user.TrafficUser); usersOfTs.Add(tempUser); foreach (GSMSimUser ur in usersOfTs) { if (ur == tempUser) continue; if (GetUserRate(ur) < ((UnionPsService)ur.TrafficUser.Service).DlMinThroughputDemand) return false; } usersOfTs.Remove(tempUser); return true; }
private static void JudgeCnvrgncPerTs(GSMSimUser user, ref int cngnvrTsNum, ref int notCngverTsNum, GSMTimeSlot ts) { if (user.CurULTxPower.ContainsKey(ts)) { cngnvrTsNum++; } else { notCngverTsNum++; } }
/// <summary> /// 计算一个时隙的下行功率收敛/不收敛数 /// </summary> /// <param name="ts">需计算的时隙</param> /// <param name="cngnvrInTs">收敛数</param> /// <param name="notCngverInTs">不收敛数</param> private void TsDLPwrCnvrgnc(GSMTimeSlot ts, ref int cngnvrInTs, ref int notCngverInTs) { foreach (GSMSimUser user in ts.PreDLTxPower.Keys) { if (ts.CurDLTxPower.ContainsKey(user) && (Math.Abs(ts.PreDLTxPower[user] - ts.CurDLTxPower[user]) <= ts.PreDLTxPower[user] * m_PowerError)) { cngnvrInTs++; } else { notCngverInTs++; } } notCngverInTs += MoidfyNotCngver(ts.PreDLTxPower.Count, ts.CurDLTxPower.Count); }
/// <summary> /// 给上行源功率赋值 /// </summary> private float ULSourcePwr(GSMSimTRX otherTrx, float sourcePwr, GSMTimeSlot ts, GSMSimUser otherUser) { if (otherUser.CurULTxPower.ContainsKey(otherTrx.TSs[ts.Index])) { sourcePwr = otherUser.CurULTxPower[otherTrx.TSs[ts.Index]]; } else if (otherUser.PreULTxPower.ContainsKey(otherTrx.TSs[ts.Index])) sourcePwr = otherUser.PreULTxPower[otherTrx.TSs[ts.Index]]; else sourcePwr = otherUser.TrafficUser.Terminal.GetNetWorkTerminal(NetWorkType.GSM).MaxTxPower; return sourcePwr; }
private void AllocationUlUser(GSMSimUser user, GSMTimeSlot ts) { user.UlTs.Add(ts); m_ChnAllocation.TchCir.Calc(user, false); float averCir = CalcAvarageCir(user.UlCirs); float throughput = 0f; user.PsCodeScheme = m_ChnAllocation.CsTable.PsCodeSeceme(averCir, m_Terminal.Technology, out throughput); user.SingleTsThroughput = throughput/1000; ts.ULMsColl.Add(user); if (!ts.Parent.CellUsers.Contains(user)) ts.Parent.CellUsers.Add(user); }
/// <summary> /// 时隙是否是所需要的信道类型 /// </summary> /// <param name="ts"></param> /// <param name="needChannelType"></param> /// <param name="isDl"></param> /// <returns></returns> public bool IsNeedChannelType(GSMTimeSlot ts, Net.ChannelType needChannelType,bool isDl) { if (isDl) { return ts.DlChanType == needChannelType; } else return ts.UlChanType == needChannelType; }
private bool AdjustULOrDLUser(Dictionary<GSMTimeSlot, float> cir, GSMTimeSlot ts,int userCountInTs, bool isDL, GSMSimUser user) { bool isSatisfy; m_TchCir.Calc(user, isDL); if (cir[ts] > (TrafficAssist.GetNetworkService<GSMService>(NetWorkType.GSM, user.TrafficUser.Service)).ReqCIR) { isSatisfy = true; user.CsCodeScheme = CsCodingSchemeUpData(user, userCountInTs); } else { //user.PCFlag = false; ClearData(user); isSatisfy = false; } return isSatisfy; }