Exemple #1
0
        /// <summary>
        /// urinatedong 20170312
        /// 新增一键改频后台代码
        /// </summary>
        /// <param name="frequency">新频率</param>
        private void updatefrequency(object frequency)
        {
            GNetwork.Clear();
            GNetwork             = new GScenario(Nmax);
            GNetwork.CurrObjIndx = 0;

            //this.panel2.Refresh();
            this.Invoke(new DPanel2Refresh(Panel2Refresh));



            List <MeshNode> updatefrequencynodelist = new List <MeshNode>();



            _rwlock.AcquireWriterLock(100);

            updatefrequencynodelist = this.ShowBlockNodes.Nodelist.ToArray().ToList();

            _rwlock.ReleaseWriterLock();



            if (updatefrequencynodelist.Count > 0)
            {
                ///尝试关闭进程
                try
                {
                    if (GetRealInfoThread != null)
                    {
                        GetRealInfoThread.Abort();
                        GetRealInfoThread = null;
                    }

                    if (RefreshPanelContext != null)
                    {
                        RefreshPanelContext.Abort();
                        RefreshPanelContext = null;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog("关闭前后台现成时异常:" + ex.Message.ToString());
                    MessageBox.Show("无法关闭前后台现成,不能进行一键改频操作");
                    return;
                }

                double param = (double)frequency;

                int nodecount = updatefrequencynodelist.Count;


                for (int i = nodecount - 1; i >= 0; i--)
                {
                    LogHelper.WriteLog("开始修改IP为" + updatefrequencynodelist[i].IpAddress + " 节点的frequency 信息!");
                    LogHelper.WriteLog("当前频率: " + updatefrequencynodelist[i].Frequency.ToString() + " 计划修改频率: " + param.ToString());
                    try
                    {
                        if (updatefrequencynodelist[i].Frequency.Equals(param))
                        {
                            LogHelper.WriteLog("频率与原来频率相同无需修改!!!");
                        }
                        else
                        {
                            UpdateFrequencyTelnetTelegram(updatefrequencynodelist[i].IpAddress, param);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogHelper.WriteLog("该IP修改频率未成功,不再修改其他节点频率!!!");
                        MessageBox.Show("IP为" + updatefrequencynodelist[i].IpAddress + " 节点的频率信息未修改成功!");
                        break;
                    }
                }
                this.MYBlockNodes.Nodelist.Clear();
                this.MYBlockNodes.Relationlist.Clear();
                this.ShowBlockNodes.Nodelist.Clear();
                this.ShowBlockNodes.Relationlist.Clear();
                this.StoreBlockNodes.Nodelist.Clear();
                this.StoreBlockNodes.Relationlist.Clear();
                MessageBox.Show("更改频率完成,请重新扫描拓扑检查信息!!!");
            }
            else
            {
                MessageBox.Show("没有发现节点,请检查拓扑结构!");
            }
        }
Exemple #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     GNetwork = new GScenario(Nmax);
     GNetwork.Clear();
     GNetwork.CurrObjIndx = 0;
 }