示例#1
0
        /// <summary>
        /// 系统启动后,
        /// 系统自动会将在线的信号机进行搜索。并将数据填写到列表中
        /// 这个方法是处理:选中后,以后的配置的信号机都是选中的参数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void myListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TscInfo ti = (TscInfo)myListView.SelectedItem;

            Application.Current.Properties[Define.TSC_INFO] = ti;
            if (ti == null)
            {
                return;
            }
            InitTscData(ti);
        }
示例#2
0
        void AddListViewTscData(object state)
        {
            // 创建并实例化IP终端结点
            IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, 0);

            listTscInfo = new List <TscInfo>();
            // 消息接收循环
            while (true)
            {
                try
                {
                    if (recevieUdpClient == null)
                    {
                        return;
                    }
                    if (recevieUdpClient.Available > 0)
                    {
                        // 同步阻塞接收消息

                        byte[] byt = recevieUdpClient.Receive(ref ipEndPoint);
                        string msg = Encoding.Default.GetString(byt);
                        if (byt.Length > 6)
                        {
                            string  pot1       = Convert.ToString(byt[6], 16);
                            string  pot2       = Convert.ToString(byt[7], 16);
                            string  tt         = pot1 + pot2;
                            string  tscId      = Convert.ToString(byt[3]);
                            string  tscName    = byt[0] + "" + byt[1] + "" + byt[2] + "" + byt[3];
                            string  tscIp      = byt[0] + "." + byt[1] + "." + byt[2] + "." + byt[3];
                            int     tscPort    = Convert.ToInt32(tt, 16);
                            string  tscVersion = Convert.ToString(byt[8], 10) + Convert.ToString(byt[9], 10) + Convert.ToString(byt[10], 10);
                            TscInfo titemp     = new TscInfo(tscId, tscName, tscIp, tscVersion, tscPort);
                            if (currentTI == null)
                            {
                                currentTI = titemp;
                            }
                            myListView.Dispatcher.Invoke(showMsgCallBack, titemp);
                            //Thread.Sleep(300);
                        }
                    }
                }
                catch (ThreadAbortException)
                {
                    // 人为终止线程
                    //MessageBox.Show("人为线程的中止,请联系软件厂商!");
                }
                catch (Exception ex)
                {
                    // 接收发生异常
                    // MessageBox.Show("网络出现异常,请联系软件厂商!"+ex.Message);
                }
            }
            //return listTscInfo;
        }
示例#3
0
 public void InitTscData(TscInfo ti)
 {
     TscData td = new TscData();
     Node node = new Node(ti.Ip, ti.Name, ti.Version, ti.Port);
     td.Node = node;
     Application.Current.Properties[Define.TSC_DATA] = td;
     try
     {
         td.ListSchedule = TscDataUtils.GetSchedule();
         td.ListPlan = TscDataUtils.GetPlan();
         td.ListModule = TscDataUtils.GetModule();
         td.ListPhase = TscDataUtils.GetPhase();
         try
         {
             td.ListCollision = TscDataUtils.GetCollision();
             td.Node.sProtocol = "GBT_V32";
         }
         catch(Exception ex)
         {
             td.ListCollision = TscDataUtils.GetCollision16();
             td.Node.sProtocol = "GBT_V16";
         }
         
         td.ListDetector = TscDataUtils.GetDetector();
         td.ListChannel = TscDataUtils.GetChannel();
         td.ListEventLog = TscDataUtils.GetEventLog();
         td.ListPattern = TscDataUtils.GetPattern();
         try
         {
             td.ListStagePattern = TscDataUtils.GetStagePattern();
         }
         catch(Exception ex)
         {
             td.ListStagePattern = TscDataUtils.GetStagePattern16();
         }
         
         td.ListOverlapPhase = TscDataUtils.GetOverlapPhase();
         
         td.ListPhaseToDirec = TscDataUtils.GetPhaseToDirec();
         td.ListLampCheck = TscDataUtils.GetLampCheck();
         currentTI = null;
         
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         MessageBox.Show("信号机为16相位,协议无法匹配!");
     }
     
 }
示例#4
0
        public void InitTscData(TscInfo ti)
        {
            TscData td   = new TscData();
            Node    node = new Node(ti.Ip, ti.Name, ti.Version, ti.Port);

            td.Node = node;
            Application.Current.Properties[Define.TSC_DATA] = td;
            try
            {
                td.ListSchedule = TscDataUtils.GetSchedule();
                td.ListPlan     = TscDataUtils.GetPlan();
                td.ListModule   = TscDataUtils.GetModule();
                td.ListPhase    = TscDataUtils.GetPhase();
                try
                {
                    td.ListCollision  = TscDataUtils.GetCollision();
                    td.Node.sProtocol = "GBT_V32";
                }
                catch (Exception ex)
                {
                    td.ListCollision  = TscDataUtils.GetCollision16();
                    td.Node.sProtocol = "GBT_V16";
                }

                td.ListDetector = TscDataUtils.GetDetector();
                td.ListChannel  = TscDataUtils.GetChannel();
                td.ListEventLog = TscDataUtils.GetEventLog();
                td.ListPattern  = TscDataUtils.GetPattern();
                try
                {
                    td.ListStagePattern = TscDataUtils.GetStagePattern();
                }
                catch (Exception ex)
                {
                    td.ListStagePattern = TscDataUtils.GetStagePattern16();
                }

                td.ListOverlapPhase = TscDataUtils.GetOverlapPhase();

                td.ListPhaseToDirec = TscDataUtils.GetPhaseToDirec();
                td.ListLampCheck    = TscDataUtils.GetLampCheck();
                currentTI           = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show("信号机为16相位,协议无法匹配!");
            }
        }
示例#5
0
 // 显示消息回调方法
 private void ShowMsg(TscInfo tscInfo)
 {
     myListView.Items.Add(tscInfo);
 }
示例#6
0
 // 显示消息回调方法
 private void ShowMsg(TscInfo tscInfo)
 {
     myListView.Items.Add(tscInfo);
 }
示例#7
0
        void AddListViewTscData(object state)
        {
            // 创建并实例化IP终端结点
            IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, 0);
            listTscInfo = new List<TscInfo>();
            // 消息接收循环
            while (true)
            {
                try
                {
                    if (recevieUdpClient == null)
                    {
                        return;
                    }
                    if (recevieUdpClient.Available > 0)
                    {
                        // 同步阻塞接收消息

                        byte[] byt = recevieUdpClient.Receive(ref ipEndPoint);
                        string msg = Encoding.Default.GetString(byt);
                        if (byt.Length > 6)
                        {
                            string pot1 = Convert.ToString(byt[6], 16);
                            string pot2 = Convert.ToString(byt[7], 16);
                            string tt = pot1 + pot2;
                            string tscId = Convert.ToString(byt[3]);
                            string tscName = byt[0] + "" + byt[1] + "" + byt[2] + "" + byt[3];
                            string tscIp = byt[0] + "." + byt[1] + "." + byt[2] + "." + byt[3];
                            int tscPort = Convert.ToInt32(tt, 16);
                            string tscVersion = Convert.ToString(byt[8], 10) + Convert.ToString(byt[9], 10) + Convert.ToString(byt[10], 10);
                            TscInfo titemp = new TscInfo(tscId, tscName, tscIp, tscVersion, tscPort);
                            if (currentTI == null)
                                currentTI = titemp;
                            myListView.Dispatcher.Invoke(showMsgCallBack, titemp);
                            //Thread.Sleep(300);
                        }
                    }
                    
                }
                catch (ThreadAbortException)
                {
                    // 人为终止线程
                    //MessageBox.Show("人为线程的中止,请联系软件厂商!");
                }
                catch (Exception ex)
                {
                    // 接收发生异常
                   // MessageBox.Show("网络出现异常,请联系软件厂商!"+ex.Message);
                }
            }
            //return listTscInfo;
        }