private void OnConfigChanged(object sender) { _ChangingCfg = true; try { RangeMsg <LcInfo> lcPositions = new RangeMsg <LcInfo>(0, _LcPositions.Length); foreach (CfgEnlaceInterno link in Top.Cfg.LcLinks) { try { int pos = (int)link.PosicionHMI - 1; if (pos < _LcPositions.Length) { LcPosition lc = _LcPositions[pos]; lc.Reset(link); LcInfo posInfo = new LcInfo(lc.Literal, lc.RxState, lc.TxState, lc.Group); lcPositions.Info[pos] = posInfo; } } catch (Exception excep) { _Logger.Error("Excepcion OnConfigChanged. Mensaje: {0}", excep.Message); } } for (int i = 0, to = _LcPositions.Length; i < to; i++) { if (lcPositions.Info[i] == null) { LcPosition lc = _LcPositions[i]; lc.Reset(); LcInfo posInfo = new LcInfo(lc.Literal, lc.RxState, lc.TxState, lc.Group); lcPositions.Info[i] = posInfo; } } General.SafeLaunchEvent(NewPositions, this, lcPositions); } catch (Exception exc) { _Logger.Error(String.Format("LcManager:OnConfigChanged exception {0}, {1}", exc.Message, exc.StackTrace)); } finally { _ChangingCfg = false; } }
public void Reset(RangeMsg <LcInfo> msg) { Debug.Assert(msg.From + msg.Count <= NumDestinations); for (int i = 0; i < msg.Count; i++) { LcDst dst = _Dst[i + msg.From]; LcInfo 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); }
public void Reset(LcInfo dst) { if (dst.Dst == "") { Reset(); } else if (dst.Dst != _Dst) { _Dst = dst.Dst; _Group = dst.Group; ChangeTxState(dst.Tx); ChangeRxState(dst.Rx, false); } else { _Group = dst.Group; Reset(new LcState(dst.Rx, dst.Tx)); } }