예제 #1
0
        private void AddData()
        {
            lock (TcpControl.DataQueue)
            {
                while (TcpControl.DataQueue.Count > 0)
                {
                    string str  = TcpControl.DataQueue.Dequeue();
                    string temp = ExecServiceList.UpdLsm(str);
                    temp = ExecServiceList.UpdDBConnectionState(temp);
                    temp = ExecRTUList.Updrdm(temp);
                    temp = ExecCommandList.UpdCommand(temp);
                    temp = synxml(temp);


                    Text = temp.Replace("++", "");
                }
            }

            TcpControl.SendData();
            if (!TcpControl.Connected)
            {
                ExecServiceList.UpdLsm();
                ExecRTUList.Updrdm();
                ExecServiceList.ServiceDBConnectionState = false;
            }
        }
예제 #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            PubObject.PubObjectInit(imageList2);
            IList <Service.Model.YY_RTU_Basic> rtus = null;

            ExecCommandList.LC = new List <Command>();


            ExecServiceList.Lsm = Program.wrx.XMLObj.LsM; //读取服务信息
            buttonItem1.Text   += "[" + ProName + "]";


            AddControls();               //根据xml文件动态添加服务显示灯控件
            TcpControl.TcpClient_Init(); //tcp与服务交互初始化


            PublicBD.Path = Program.xmlpath;
            PublicBD.ReInit();
            //连接数据库
            if (PublicBD.ConnectState)
            {
                //得到RTU列表
                rtus = Service.PublicBD.db.GetRTUList("");
                //得到命令列表
                ExecCommandList.Commands = Service.PublicBD.db.GetRTUCommandList();
                //得到命令临时表中的要发送的召测命令
                ExecRTUList.SetLrdm(rtus);

                //提示可能是自动入库的测站信息
                AlertFomrShow(rtus);

                //显示数据窗体控件
                buttonItem_dataShow_Click(null, null);
            }
            else
            {
                //显示系统设置窗体控件
                buttonItem_SetSystem_Click(null, null);
            }



            ////根据服务在线状态更新服务显示灯
            Thread updcontrols = new Thread(new ThreadStart(ThreadUpdControls));

            // 设置为背景线程,主线程一旦退出,该线程也不等待而立即结束
            updcontrols.IsBackground = true;
            updcontrols.Start();



            //添加明文数据
            Thread adddata = new Thread(new ThreadStart(ThreadAddData));

            // 设置为背景线程,主线程一旦退出,该线程也不等待而立即结束
            adddata.IsBackground = true;
            adddata.Start();


            Thread ReConnect = new Thread(new ThreadStart(ThreadReConnect));

            ReConnect.IsBackground = true;
            ReConnect.Start();
        }
예제 #3
0
        /// <summary>
        /// 数据处理后更新测站在线状态
        /// </summary>
        /// <param name="data">数据报</param>
        /// <returns></returns>
        public static string Updrdm(string data)
        {
            //上线例子--stcd|0012345679:udp 0012345678:tcp
            //下线例子--stcd|0012345679:udp: 0012345678:tcp:
            string Rstr = "";

            if (Lrdm != null)
            {
                string[] datas = data.Split(new string[] { "\n" }, StringSplitOptions.None);
                for (int k = 0; k < datas.Count(); k++)
                {
                    data = datas[k];
                    #region
                    if (data.Length >= 6)
                    {
                        //说明所有测站不在线
                        if (data == "--stcd|")
                        {
                            ExecRTUList.Updrdm();
                            return("");
                        }

                        //有在线测站
                        string tem = data.Substring(0, 6);
                        if (tem == "--stcd")
                        {
                            string[] strs = data.Replace("--stcd|", "").Split(new char[] { ' ' });

                            foreach (var item in strs)
                            {
                                string[] temp = item.Split(new char[] { ':' });
                                if (temp.Length == 2)//上线
                                {
                                    var rtu = from r in Lrdm where r.STCD == temp[0] select r;
                                    if (rtu.Count() > 0)
                                    {
                                        rtu.First().SERVICETYPE = temp[1];
                                    }
                                }
                                else if (temp.Length == 3)//下线
                                {
                                    var rtu = from r in Lrdm where r.STCD == temp[0] select r;
                                    if (rtu.Count() > 0)
                                    {
                                        rtu.First().SERVICETYPE = null;
                                    }
                                }
                            }
                        }
                        else  //不是在线测站的数据报从新整理返回
                        {
                            Rstr += data + "\n";
                        }
                    }
                    else
                    {
                        if (data != "")
                        {
                            Rstr += data + "\n";
                        }
                    }

                    #endregion
                }
            }
            else
            {
                Rstr += data;
            }

            return(Rstr);
        }