Esempio n. 1
0
        //定时触发重连
        private void ReTime_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            var timer = sender as System.Timers.Timer;

            timer.Enabled = false;
            if (clientAsync.Connect())
            {
                clientAsync.ReadMetaData();
            }
            else
            {
                timer.Enabled = true;
            }
        }
Esempio n. 2
0
        private void init()
        {
            //数据配置
            pointMetaData = new List <PointMetadata>();

            //Meu窗口配置
            searchWin = new SearchWindow()
            {
                SignalDisplayList = signalList, ClientAsync = clientAsync
            };
            connectWindow = new ConnectWindow();
            SignalMeItem.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(signalMeItemMouseLeftButtonDown), true);
            ConnectMeItem.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(ConnectMeItemMouseLeftButtonDown), true);


            ///连接到服务端配置
            EthernetSetUp setUp   = new EthernetSetUp("127.0.0.1", 9527);
            ILog          log     = new DefaultLog("SignalMonitor");
            TimeOut       timeOut = new TimeOut("SignalMonitor", 1000, log);

            clientAsync = new FreedomClientAsync(setUp, timeOut, log);


            //读服务器元数据
            clientAsync.AsyncReadMetaData += asyncReadMetaData;

            //订阅client操作事件
            clientAsync.AsyncReadOrSubsEvent += asyncReadOrSubsEvent;
            clientAsync.AsyncWriteEvent      += ayncWriteEvent;
            clientAsync.DisconnectEvent      += disconnectEvent;

            //断线重连事件
            reTime          = new System.Timers.Timer(3000);
            reTime.Elapsed += ReTime_Elapsed;

            if (clientAsync.Connect())
            {
                clientAsync.ReadMetaData();
            }
        }