Exemplo n.º 1
0
        /// <summary>
        /// 建立网元连接。
        /// TODO LMT-B还会连接基站,这两个连接不一样,需要协调
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="neConfig"></param>
        public bool ConnectNetElement(string ip, NetElementConfig neConfig)
        {
            if (string.IsNullOrWhiteSpace(ip) ||
                string.IsNullOrEmpty(ip) ||
                null == neConfig)
            {
                throw new ArgumentNullException("ip is null or empty, or neConfig is null");
            }

            if (HasLinkWithSameIp(ip))
            {
                return(false);
            }

            NetElementLinkBase link = LinkFactory.CreateLink(neConfig.conType);

            _mapNetElementLinks[ip] = link;

            //此处只有udp协议的数据处理,后面增加其他类型的协议
            SubscribeHelper.AddSubscribe($"udp-recv://{ip}:{CommonPort.AtpLinkPort}", OnLinkMsgFromBoard);

            link.Connect(neConfig);

            return(true);
            //TODO 启动定时器,超时后启动取消还是让前台手动取消?或者设定时间间隔,一直重试?
        }
Exemplo n.º 2
0
        public static NetElementLinkBase CreateLink(ConnectType ct)
        {
            NetElementLinkBase link = null;

            switch (ct)
            {
            case ConnectType.ATP_DIRECT_LINK:
                link = new AtpDirectLink();
                break;

            case ConnectType.ATP_REMOTE_LOG:
                link = new AtpRemoteLogLink();
                break;

            case ConnectType.ATP_REMOTE_MSG:
                link = new AtpRemoteMsgLink();
                break;

            case ConnectType.OSP:
                break;

            case ConnectType.LMT:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(ct), ct, null);
            }

            return(link);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理设备发回的登录响应报文
        /// </summary>
        /// <param name="ip"></param>
        private void DealConnectRsp(string ip)
        {
            if (string.IsNullOrWhiteSpace(ip) || string.IsNullOrEmpty(ip))
            {
                throw new ArgumentNullException();
            }

            if (_mapNetElementLinks.ContainsKey(ip))
            {
                NetElementLinkBase link = _mapNetElementLinks[ip];
                link.OnLogonResult(true);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 断开网元连接
        /// </summary>
        /// <param name="ip"></param>
        public bool DisconnectNe(string ip)
        {
            if (string.IsNullOrWhiteSpace(ip) ||
                string.IsNullOrEmpty(ip))
            {
                throw new ArgumentNullException("ip is null or empty");
            }

            if (!HasLinkWithSameIp(ip))
            {
                return(false);
            }

            NetElementLinkBase link = _mapNetElementLinks[ip];

            link.Disconnect();

            SubscribeHelper.CancelSubscribe($"from:{ip}:{CommonPort.AtpLinkPort}");
            _mapNetElementLinks.Remove(ip);

            return(true);
        }