コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <returns></returns>
        private bool IsConnected(string remoteIP)
        {
            CommPortProxysCollection cpps = Singles.S.TaskScheduler.CppsCollection;

            foreach (CommPortProxy c in cpps)
            {
                if (c.RemoteHostIP == remoteIP &&
                    c.IsConnected)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: frmControl.cs プロジェクト: wwkkww1983/bt
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteIP"></param>
        /// <returns></returns>
        private string GetConnectState(string remoteIP)
        {
            CommPortProxysCollection cpps = Singles.S.TaskScheduler.CppsCollection;

            foreach (CommPortProxy cpp in cpps)
            {
                if (cpp.RemoteHostIP == remoteIP &&
                    cpp.IsConnected)
                {
                    return("已连接");
                }
            }
            return("未连接");
        }
コード例 #3
0
        private void RefreshCpps()
        {
            this.LoadGprsTable();

            this.lvCpps.Items.Clear();
            //MsgBox.Show( lvCpps.Columns.Count.ToString() );
            int i = 1;
            CommPortProxysCollection cpps = Singles.S.TaskScheduler.CppsCollection;

            // connected gprs
            //
            foreach (CommPortProxy c in cpps)
            {
                ListViewItem lvi      = this.lvCpps.Items.Add(i++.ToString("00"));
                string[]     subItems = new string[] { GetGprsStationName(c.RemoteHostIP),
                                                       c.LocalHostIP,
                                                       c.LocalPort.ToString(),
                                                       c.RemoteHostIP,
                                                       c.RemotePort.ToString(),
                                                       GetStateText(c.State),
                                                       c.CreateTime.ToString() };
                lvi.SubItems.AddRange(subItems);
            }

            // not connected gprs
            //
            foreach (DataRow r in _gprsTable.Rows)
            {
                string       name     = r["name"].ToString();
                ListViewItem lvi      = this.lvCpps.Items.Add(i++.ToString("00"));
                string []    subItems = new string[] { name,
                                                       string.Empty,
                                                       string.Empty,
                                                       string.Empty,
                                                       string.Empty,
                                                       "未连接",
                                                       string.Empty, };
                lvi.SubItems.AddRange(subItems);
            }

            this.lvCpps.Refresh();
        }
コード例 #4
0
        /// <summary>
        /// 判断该巡更站点是否已连接
        /// </summary>
        /// <param name="xgName"></param>
        /// <returns></returns>
        private bool IsGprsConnected(XGStation xgst)
        {
            CommPortProxysCollection cpps = Singles.S.TaskScheduler.CppsCollection;

            for (int i = 0; i < cpps.Count; i++)
            {
                CommPortProxy cpp = cpps[i];
                if (cpp.RemoteIP == xgst.DestinationIP)
                {
                    if (cpp.IsConnected)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cpps"></param>
        /// <param name="remoteIP"></param>
        private void RemoveExist(CommPortProxysCollection cpps, string remoteIP)
        {
            ArgumentChecker.CheckNotNull(cpps);
            //foreach( CommPortProxy c in cpps )

            bool removed = true;

            while (removed)
            {
                removed = false;

                for (int i = 0; i < cpps.Count; i++)
                {
                    CommPortProxy c = cpps[i];
                    if (c.RemoteHostIP == remoteIP)
                    {
                        c.Close();
                        cpps.RemoveAt(i);
                        removed = true;
                        break;
                    }
                }
            }
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: wwkkww1983/bt
        /// <summary>
        /// 读取配置文件
        /// </summary>
        /// <returns></returns>
        public static bool InitialGlobal()
        {
            ReadConfigFile();

            XGDB.XGDBConnectionString = XGConfig.Default.ConnectionString;

            // 2007-10-12 Added process sql exception
            //
            try
            {
                XGDB.DbClient.Open();
            }
            catch (SqlException sqlex)
            {
                //MessageBox.Show( sqlex.Message );
                MsgBox.Show(sqlex.Message, GT.TEXT_TIP, MessageBoxIcon.Error);
                Environment.Exit(0);
            }

            // 生成并启动网络端口监听。
            //
            if (!ListenPort())
            {
                return(false);
            }


            // 解析gprs_station表,生成gr real data command task
            //
            //
            TasksCollection tasks = ResolveGRRealDataTaskFromDB();

            CommPortProxysCollection cpps = new CommPortProxysCollection();

            // 生成 TaskScheduler
            //
            TaskScheduler sch = new TaskScheduler(cpps, XGConfig.Default.TaskSchedulerInterval);

            sch.Executed             += new EventHandler(CommTaskResultProcessor.Default.Process);
            sch.Executing            += new EventHandler(TaskExecutingProcessor.Default.Process);
            sch.NotFindMatchCPPEvent += new EventHandler(NotFindMatchCppProcesser.Default.Process);

            //
            //
            AddTasks(sch.Tasks, tasks);

            //
            //
            sch.Enabled = true;

            //
            //
            Singles.S.TaskScheduler = sch;



            // TODO: cpps receive event process.
            //
            cpps.ReceiveARDEvent += new ReceiveARDHandler(ARDProcessor.Default.Process);
            //cpps.ReceiveTimeOutEvent +=new ReceiveTimeOutEventHandler(CommTaskResultProcessor.Default.Process);


            // TODO: 解析tbl_xgTask表,生成XGTask及XGTaskScheduler。
            //
            //



            //连接请求:
            //	接受
            //	加入TaskScheduler.CppsCollection中,(检查是否有同源的连接,如有先删除)

            return(true);
        }