public Lc() { for (int i = 0; i < NumDestinations; i++) { _Dst[i] = new LcDst(i); _Dst[i].StChanged += OnLcStChanged; } }
public LcDst ActiveLc(int group, int preferred) { Debug.Assert(_Groups.ContainsKey(group)); List <int> members = _Groups[group]; LcDst activeLc = _Dst[preferred].Unavailable ? null : _Dst[preferred]; foreach (int id in members) { LcDst dst = _Dst[id]; if (!dst.Unavailable) { if (dst.Tx != LcTxState.Idle) { activeLc = dst; break; } else if (dst.Rx == LcRxState.Rx) { activeLc = dst; break; } else if (dst.Rx == LcRxState.RxNotif) { if ((activeLc == null) || (activeLc.Rx == LcRxState.Idle) || (activeLc.Rx == LcRxState.Mem)) { activeLc = dst; } } else if (dst.Rx == LcRxState.Mem) { if ((activeLc == null) || (activeLc.Rx == LcRxState.Idle)) { activeLc = dst; } } else if (dst.Rx == LcRxState.Idle) { if (activeLc == null) { activeLc = dst; } } } } return(activeLc != null ? activeLc : _Dst[members[0]]); }
public void Reset(RangeMsg <LcDestination> msg) { Debug.Assert(msg.From + msg.Count <= NumDestinations); for (int i = 0; i < msg.Count; i++) { LcDst dst = _Dst[i + msg.From]; LcDestination info = msg.Info[i]; if (dst.Group != info.Group) { if (dst.Group != 0) //17_01_13 { Debug.Assert(_Groups.ContainsKey(dst.Group)); List <int> members = _Groups[dst.Group]; members.Remove(dst.Id); if (members.Count == 0) { _Groups.Remove(dst.Group); } } if (info.Group != 0)//17_01_13 { List <int> members = null; if (!_Groups.TryGetValue(info.Group, out members)) { members = new List <int>(); _Groups[info.Group] = members; } members.Add(i + msg.From); members.Sort(); } } dst.Reset(info); } General.SafeLaunchEvent(LcChanged, this, (RangeMsg)msg); }