Beispiel #1
0
        private void Dele_Btn_Click(object sender, EventArgs e)
        {
            //从列表中删除参考点
            if (PortID == null || PortID.Equals(""))
            {
                return;
            }
            PrecisePositionLibrary.BsInfo removebs = null;
            Group grp = null;

            if (null != strcurgroupid && !"".Equals(strcurgroupid))
            {
                if (frm.Groups.TryGetValue(strcurgroupid, out grp))
                {
                    grp.groupbss.Remove(PortID);
                }
            }
            else
            {
                if (frm.InnerPorts.ContainsKey(PortID))
                {
                    frm.InnerPorts.TryRemove(PortID, out removebs);
                }
            }
            this.Close();
        }
Beispiel #2
0
 public AddPort(Form1 frm, String PortID)
 {
     InitializeComponent();
     this.frm = frm;
     PortID_01_textBox.Text = PortID.Substring(0, 2);
     PortID_02_textBox.Text = PortID.Substring(2, 2);
     this.PortID            = PortID;
     if (frm.InnerPorts.ContainsKey(PortID))
     {
         PrecisePositionLibrary.BsInfo prt = null;
         frm.InnerPorts.TryGetValue(PortID, out prt);
         PortHeightTB.Text = "" + Math.Round(prt.Place.z, 0);
     }
 }
Beispiel #3
0
        public AddPort(Form1 frm, String PortID, String strgroupid)
        {
            InitializeComponent();
            this.strcurgroupid     = strgroupid;
            this.frm               = frm;
            PortID_01_textBox.Text = PortID.Substring(0, 2);
            PortID_02_textBox.Text = PortID.Substring(2, 2);
            this.PortID            = PortID;
            Group group = null;

            if (frm.Groups.TryGetValue(strgroupid, out group))
            {
                PrecisePositionLibrary.BsInfo prt = null;
                if (group.groupbss.TryGetValue(PortID, out prt))
                {
                    PortHeightTB.Text = "" + Math.Round(prt.Place.z, 0);
                }
            }
        }
Beispiel #4
0
        private void timer_Tick(Object obj, EventArgs args)
        {
            string str = "", StrGroup = "";

            PrecisePositionLibrary.BsInfo bs = null;
            Group gp = null;

            if (null == form)
            {
                return;
            }
            foreach (KeyValuePair <string, Form1.PortInfor> port in form.Ports)
            {
                if (PortListView.Items.ContainsKey(port.Key))
                {
                    ListViewItem[] items = PortListView.Items.Find(port.Key, false);
                    if (items.Length <= 0)
                    {
                        continue;
                    }
                    //获取指定的基站
                    if (form.IsExistRefer(port.Key, out bs))
                    {
                        StrGroup = bs.GroupID[0].ToString("X2") + bs.GroupID[1].ToString("X2");
                        if (form.Groups.TryGetValue(StrGroup, out gp))
                        {
                            StrGroup = gp.name;
                        }
                    }
                    else
                    {
                        StrGroup = "****";
                    }
                    items[0].SubItems[1].Text = StrGroup;
                    items[0].SubItems[2].Text = port.Value.sleep + " S";
                    items[0].SubItems[3].Text = port.Value.ReportTime.ToString();
                    items[0].SubItems[4].Text = port.Value.ver.ToString("X2");
                    continue;
                }
                ListViewItem item = new ListViewItem();
                item.Name = port.Key;
                str       = Ini.GetValue(Ini.PortPath, port.Key, Ini.Name);
                if (null == str || "".Equals(str))
                {
                    item.Text = port.Key;
                }
                else
                {
                    item.Text = str + "(" + port.Key + ")";
                }
                //获取指定的基站
                if (form.IsExistRefer(port.Key, out bs))
                {
                    StrGroup = bs.GroupID[0].ToString("X2") + bs.GroupID[1].ToString("X2");
                    if (form.Groups.TryGetValue(StrGroup, out gp))
                    {
                        StrGroup = gp.name;
                    }
                }
                else
                {
                    StrGroup = "****";
                }
                item.SubItems.Add(StrGroup);
                item.SubItems.Add(port.Value.sleep + " S");
                item.SubItems.Add(port.Value.ReportTime.ToString());
                item.SubItems.Add(port.Value.ver.ToString("X2"));
                PortListView.Items.Add(item);
            }
        }
Beispiel #5
0
        private void Add_Btn_Click(object sender, EventArgs e)
        {
            string ID1       = PortID_01_textBox.Text.ToUpper();
            string ID2       = PortID_02_textBox.Text.ToUpper();
            string strheight = PortHeightTB.Text;
            int    height    = 0;

            byte[] BYTE_ID = new byte[2];
            if (ID1.Equals("") && ID2.Equals(""))
            {
                MessageBox.Show("Sorry, Reference point ID can not be empty!");
                return;
            }
            if (ID1.Length != 2 || ID2.Length != 2)
            {
                MessageBox.Show("Sorry, Reference point ID format is wrong!");
                return;
            }
            try
            {
                BYTE_ID[0] = Convert.ToByte(ID1, 16);
                BYTE_ID[1] = Convert.ToByte(ID2, 16);
            }
            catch (Exception)
            {
                MessageBox.Show("Sorry, Reference point ID format is wrong!");
                return;
            }
            if (BYTE_ID[0] == 0x00 && BYTE_ID[1] == 0x00)
            {
                MessageBox.Show("Sorry, Reference point ID not for 0000!");
                return;
            }
            try
            {
                height = Convert.ToInt32(strheight);
            }
            catch (Exception)
            {
                MessageBox.Show("Sorry, the height of the base station is wrong!");
                return;
            }
            if (height < 0)
            {
                MessageBox.Show("Sorry, base station height cannot be less than 0!");
                return;
            }
            // 判断当前是多区域还是单区域
            if (null == strcurgroupid || "".Equals(strcurgroupid))
            {// 单区域
                if (!PortID.Equals(""))
                {
                    if (!PortID.Equals(ID1 + ID2))
                    {
                        if (frm.InnerPorts.ContainsKey(ID1 + ID2))
                        {
                            MessageBox.Show("Sorry, the newly modified base station already exists!");
                            return;
                        }
                        PrecisePositionLibrary.BsInfo prt = null;
                        if (frm.InnerPorts.ContainsKey(PortID))
                        {// 包含这个参考点
                            frm.InnerPorts.TryGetValue(PortID, out prt);
                            PrecisePositionLibrary.BsInfo prt_ = new PrecisePositionLibrary.BsInfo();
                            try
                            {
                                prt_.ID[0] = Convert.ToByte(ID1, 16);
                                prt_.ID[1] = Convert.ToByte(ID2, 16);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Sorry, Point of reference for the change ID failure!");
                                return;
                            }
                            prt_.Place   = prt.Place;
                            prt_.Place.z = height;
                            PrecisePositionLibrary.BsInfo removebs = null;
                            frm.InnerPorts.TryRemove(PortID, out removebs);
                            frm.InnerPorts.TryAdd(ID1 + ID2, prt_);
                            this.Close();
                        }
                    }
                    else
                    {
                        //说明是重新修改当前基站的高度
                        if (frm.InnerPorts.ContainsKey(PortID))
                        {
                            PrecisePositionLibrary.BsInfo prt = null;
                            frm.InnerPorts.TryGetValue(PortID, out prt);
                            prt.Place.z = height;
                            this.Close();
                        }
                    }
                    return;
                }
                PrecisePositionLibrary.BsInfo port = null;
                if (frm.InnerPorts.ContainsKey(ID1 + ID2))
                {// 包含这个参考点
                    MessageBox.Show("Sorry, Reference points already exists!");
                    return;
                }
                else
                {
                    //没有包含这个参考点,将这个参考点添加到集合中去
                    port    = new PrecisePositionLibrary.BsInfo();
                    port.ID = BYTE_ID;
                    if (point != null)
                    {
                        port.Place = point;
                    }
                    port.Place.z = height;
                    frm.InnerPorts.TryAdd(ID1 + ID2, port);
                }
            }
            else
            {//多个区域
                //判断当前是修改区域基站讯息,还是添加区域基站讯息
                Group curgroup = null;
                if (!frm.Groups.TryGetValue(strcurgroupid, out curgroup))
                {
                    return;
                }
                if (!PortID.Equals(""))
                {
                    if (!PortID.Equals(ID1 + ID2))
                    {
                        PrecisePositionLibrary.BsInfo prt = null;
                        //先判断新改的ID是否已经存在
                        if (frm.IsExistRefer(ID1 + ID2, out prt))
                        {
                            MessageBox.Show("Sorry, the newly modified base station already exists in the area!");
                            return;
                        }
                        if (curgroup.groupbss.ContainsKey(PortID))
                        {//此时我们需要删除掉原来的基站,并重新设置新的基站
                            curgroup.groupbss.TryGetValue(PortID, out prt);
                            PrecisePositionLibrary.BsInfo prt_ = new PrecisePositionLibrary.BsInfo();
                            try
                            {
                                prt_.ID[0] = Convert.ToByte(ID1, 16);
                                prt_.ID[1] = Convert.ToByte(ID2, 16);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Sorry, Point of reference for the change ID failure!");
                                return;
                            }
                            prt_.Place   = prt.Place;
                            prt_.Place.z = height;
                            System.Buffer.BlockCopy(curgroup.id, 0, prt_.GroupID, 0, 2);
                            curgroup.groupbss.Add(ID1 + ID2, prt_);
                            curgroup.groupbss.Remove(PortID);
                            this.Close();
                        }
                    }
                    else
                    {
                        if (curgroup.groupbss.ContainsKey(PortID))
                        {
                            PrecisePositionLibrary.BsInfo prt = null;
                            if (curgroup.groupbss.TryGetValue(PortID, out prt))
                            {
                                prt.Place.z = height;
                                System.Buffer.BlockCopy(curgroup.id, 0, prt.GroupID, 0, 2);
                            }
                            this.Close();
                        }
                    }
                    return;
                }
                PrecisePositionLibrary.BsInfo port = null;
                if (frm.IsExistRefer(ID1 + ID2, out port))
                {
                    MessageBox.Show("Sorry, Reference points already exists!");
                    return;
                }
                else
                {
                    //没有包含这个参考点,将这个参考点添加到集合中去
                    port    = new PrecisePositionLibrary.BsInfo();
                    port.ID = BYTE_ID;
                    System.Buffer.BlockCopy(curgroup.id, 0, port.GroupID, 0, 2);
                    if (point != null)
                    {
                        port.Place = point;
                    }
                    port.Place.z = height;
                    curgroup.groupbss.Add(ID1 + ID2, port);
                }
            }
            this.Close();
        }