private void OnFrRxChanged(object sender) { Rs <RdSrvRxRs> rs = (Rs <RdSrvRxRs>)sender; Debug.Assert(_AssociateRxRs.Contains(rs)); if (Rx) { string rsId = rs.Id.ToUpper(); _Logger.Debug("*** OnFrRxchanged({2}). rs.IsValid es {0} {1}:", rs.IsValid, Pos, rsId); if (rs.IsValid) { // Debug.Assert(!_RxPorts.ContainsKey(rsId)); if (_RxPorts.ContainsKey(rsId)) { //_RxPorts.Remove(rsId); /* Provocar el paso por aspas cuando se cae la red*/ RxOff(); // Provocar la liberación del transmisor HF // en caso de que estuviera ocupado por este usuario if (_TipoFrecuencia == TipoFrecuencia_t.HF) { _RtxGroup = Math.Min(_RtxGroup, 0); Tx = false; Top.Registry.SetTx(_Literal, false, _Priority, false); } _Rx = AssignState.Idle; _RtxGroup = 0; _Squelch = SquelchState.Unavailable; _Ptt = PttState.Unavailable; _PttSrcId = string.Empty; _Estado = RdSrvFrRs.FrequencyStatusType.NotAvailable; General.SafeLaunchEvent(StateChanged, this); /* Fin cambio */ } _Logger.Debug("*** OnFrRxchanged({2}). Llamando a CreateRdRxPort({0}, pos {1})", rsId, Pos, rsId); CreateRxAudio(rs, rsId); } else { int port; if (_RxPorts.TryGetValue(rsId, out port)) { Top.Mixer.Unlink(port); _Logger.Debug("*** OnFrRxChanged({2}). Llamando a DestroyRdRxPort({0})", port, rsId); SipAgent.DestroyRdRxPort(port); _RxPorts.Remove(rsId); } } } }
private void RxOff() { if (Rx) { foreach (int port in _RxPorts.Values) { Top.Mixer.Unlink(port); SipAgent.DestroyRdRxPort(port); _Logger.Debug("*** RxOff. Llamando a DestroyRdRxPort({0}) {1}", port, Literal); } _RxPorts.Clear(); _AudioVia = RdRxAudioVia.NoAudio; _RealAudioVia = RdRxAudioVia.NoAudio; _Tx = AssignState.Idle; _RtxGroup = Math.Min(_RtxGroup, 0); } }
private void OnSiteChanged(object msg, short type) { if (type == Identifiers.SITE_CHANGING_RSP) { // En principio, para hacer cambio de emplazamiento // no tiene por qué estar en Tx // if (Tx) if (((ChangeSiteRsp)msg).resultado) { _OldAlias = Alias = ((ChangeSiteRsp)msg).Alias; // Switch audio if (Rx) { // Rx off foreach (int port in _RxPorts.Values) { Top.Mixer.Unlink(port); SipAgent.DestroyRdRxPort(port); } _RxPorts.Clear(); // Rx on foreach (Rs <RdSrvRxRs> rxRs in _AssociateRxRs) { if (rxRs.IsValid && _RscSite.ContainsKey(rxRs.Id) && _RscSite[rxRs.Id] == Alias) { if (!_RxPorts.ContainsKey(rxRs.Id.ToUpper())) { CreateRxAudio(rxRs, rxRs.Id.ToUpper()); } } } } } else { Alias = _OldAlias; } General.SafeLaunchEvent(SiteChangedResult, this, (ChangeSiteRsp)msg); } }
public void Reset(CfgEnlaceExterno cfg) { uint oldPriority = _Priority; SquelchState oldSquelch = Squelch; if (string.Compare(cfg.Literal, _Literal, true) != 0) { Reset(); _AssociateFrRs = Top.Registry.GetRs <RdSrvFrRs>(cfg.Literal); if (_AssociateFrRs.IsValid) { RdSrvFrRs frRs = _AssociateFrRs.Info; _Alias = frRs.SqSite; _Squelch = oldSquelch = (SquelchState)frRs.Squelch; _Ptt = GetPtt(frRs.PttSrcId); _RtxGroup = 0; if (frRs.RtxGroupId != 0) { _RtxGroup = (frRs.RtxGroupOwner != Top.HostId ? -1 : (int)frRs.RtxGroupId); } } } else { _AssociateRxRs.Clear(); _AssociateTxRs.Clear(); } _AssociateFrRs.NewMsg += OnFrMsg; _AssociateFrRs.Changed += OnFrChanged; _AssociateFrRs.SelCalMsg += OnSelCalMsg; _AssociateFrRs.SiteChanged += OnSiteChanged; _Literal = cfg.Literal; /** 20180321. AGL. ALIAS a mostrar en la tecla... */ var Alias = cfg.GetType().GetProperty("Alias"); _KeyAlias = Alias == null ? "NoAlias" : Alias.GetValue(cfg) as string; // _KeyAlias = cfg.Alias; //_Alias = cfg.ListaRecursos.Count > 0 ? cfg.ListaRecursos[0].IdEmplazamiento : ""; _Priority = cfg.Prioridad; _TipoFrecuencia = (TipoFrecuencia_t)cfg.TipoFrecuencia; _Monitoring = cfg.EstadoAsignacion == "M"; _RxOnly = false; switch (cfg.EstadoAsignacion) { case "M": // Monitor Rx = true; Tx = false; AudioVia = RdRxAudioVia.Speaker; SetTx(false, false); break; case "T": // Trafico if (!Tx) { SetTx(true, false); } AudioVia = RdRxAudioVia.Speaker; break; default: // Reposo break; } _RscSite.Clear(); foreach (CfgRecursoEnlaceExterno dst in cfg.ListaRecursos) { _RscSite.Add(dst.IdRecurso, dst.IdEmplazamiento); // Se añaden todos los recursos que con el estado // Estado=="S"elected o Estado=="A"ctivo if (dst.Estado == "S" || dst.Estado == "A") { if (dst.Estado == "S") { if (_Alias != dst.IdEmplazamiento) { Squelch = oldSquelch; _Alias = dst.IdEmplazamiento; } } //_Alias = dst.Estado == "S" ? dst.IdEmplazamiento : _Alias; if ((dst.Tipo == Cd40Cfg.RD_RX) || (dst.Tipo == Cd40Cfg.RD_RXTX)) { Rs <RdSrvRxRs> rs = Top.Registry.GetRs <RdSrvRxRs>(dst.IdRecurso); rs.Changed += OnFrRxChanged; _AssociateRxRs.Add(rs); } if ((dst.Tipo == Cd40Cfg.RD_TX) || (dst.Tipo == Cd40Cfg.RD_RXTX)) { Rs <RdSrvTxRs> rs = Top.Registry.GetRs <RdSrvTxRs>(dst.IdRecurso); //rs.Changed += OnFrTxChanged; _AssociateTxRs.Add(rs); } } } if ((_AssociateTxRs.Count == 0) && (_AssociateRxRs.Count > 0) && _TipoFrecuencia != TipoFrecuencia_t.HF) { _RxOnly = true; } if (_Rx == AssignState.Set) { Dictionary <string, int> portsToRemove = new Dictionary <string, int>(_RxPorts); foreach (Rs <RdSrvRxRs> rs in _AssociateRxRs) { string rsId = rs.Id.ToUpper(); if (rs.IsValid && !portsToRemove.Remove(rsId)) { _Logger.Debug("*** M+N. Reset(sender). Llamando a CreateRdRxPort({0},{1})", ((RdSrvRxRs)rs.Content).ToString(), Top.SipIp); CreateRxAudio(rs, rsId); } else { _Logger.Debug("*** M+N. Reset(sender). rs.IsValid && !portsToRemove.Remove(rsId) es false)"); } } foreach (KeyValuePair <string, int> p in portsToRemove) { Top.Mixer.Unlink(p.Value); _Logger.Debug("*** M+N. RxOff(sender). Llamando a DestroyRdRxPort({0})", p.Value); SipAgent.DestroyRdRxPort(p.Value); _RxPorts.Remove(p.Key); } } if ((_Tx != AssignState.Idle) && (_Priority != oldPriority)) { Top.Registry.SetTx(_Literal, true, _Priority, _Tx == AssignState.Trying); } }