Пример #1
0
        /// <summary>
        /// 获取Tag在指定的区域呆的总时间;
        /// </summary>
        /// <param name="Tags"></param>
        /// <param name="StrAreaID"></param>
        /// <param name="StrTagID"></param>
        /// <returns></returns>
        public int GetTagInAreaTime(List <TagPack> Tags, string StrAreaID, string StrTagID)
        {
            if (null == Tags || null == StrAreaID || "".Equals(StrAreaID) || null == StrTagID || "".Equals(StrTagID))
            {
                return(0);
            }
            int TotalTime = 0;

            foreach (TagPack tpk in Tags)
            {
                if (null == tpk)
                {
                    continue;
                }
                string StrTID = tpk.TD[0].ToString("X2") + tpk.TD[1].ToString("X2");
                if (StrTID.Equals(StrTagID))
                {
                    string StrRID  = tpk.RD_New[0].ToString("X2") + tpk.RD_New[1].ToString("X2");
                    Area   CurArea = CommonBoxOperation.GetAreaFromRouterID(StrRID);
                    if (null == CurArea)
                    {
                        continue;
                    }
                    string StrAid = CurArea.ID[0].ToString("X2") + CurArea.ID[1].ToString("X2");
                    if (StrAid.Equals(StrAreaID))
                    {
                        TotalTime += tpk.Sleep;
                    }
                }
            }
            return(TotalTime);
        }
Пример #2
0
        public List <Area> GetAreas(List <TagPack> Tags)
        {
            if (null == Tags)
            {
                return(null);
            }
            if (Tags.Count <= 0)
            {
                return(null);
            }
            List <Area> Areas = new List <Area>();

            foreach (TagPack tp in Tags)
            {
                if (null == tp)
                {
                    continue;
                }
                string StrRouterID = tp.RD_New[0].ToString("X2") + tp.RD_New[1].ToString("X2");
                Area   area        = CommonBoxOperation.GetAreaFromRouterID(StrRouterID);
                if (null == area)
                {
                    continue;
                }
                string StrAreaID = area.ID[0].ToString("X2") + area.ID[1].ToString("X2");
                if (!IsAreas(Areas, StrAreaID))
                {
                    Areas.Add(area);
                }
            }
            return(Areas);
        }
Пример #3
0
        /// <summary>
        /// 获取在集合Tags中在区域StrAreaID上的数量
        /// </summary>
        /// <param name="Tags"></param>
        /// <param name="StrAreaID"></param>
        /// <returns></returns>
        public int GetTagNum(List <TagPack> Tags, string StrAreaID)
        {
            if (null == Tags || Tags.Count <= 0)
            {
                return(0);
            }
            if (null == StrAreaID || "".Equals(StrAreaID))
            {
                return(0);
            }
            int num = 0;

            foreach (TagPack tpk in Tags)
            {
                if (null == tpk)
                {
                    continue;
                }
                string StrRouterID = tpk.RD_New[0].ToString("X2") + tpk.RD_New[1].ToString("X2");
                Area   CurArea     = CommonBoxOperation.GetAreaFromRouterID(StrRouterID);
                if (null == CurArea)
                {
                    continue;
                }
                string StrCurAreaID = CurArea.ID[0].ToString("X2") + CurArea.ID[1].ToString("X2");
                if (StrAreaID.Equals(StrCurAreaID))
                {
                    num++;
                }
            }
            return(num);
        }
Пример #4
0
        /// <summary>
        /// 根据接收到的数据包统计总的时间
        /// </summary>
        /// <returns></returns>
        public int GetTagInAreaTimeReport(List <TagPack> Tags, string StrAreaID, string StrTagID)
        {
            if (null == Tags || null == StrAreaID || "".Equals(StrAreaID) || null == StrTagID || "".Equals(StrTagID))
            {
                return(0);
            }
            if (Tags.Count <= 0)
            {
                return(0);
            }
            int TotalTime = 0;

            TagPack[] tpks = Tags.ToArray();
            for (int i = 0; i < tpks.Length; i++)
            {
                if (null == Tags[i])
                {
                    continue;
                }
                string StrTID = Tags[i].TD[0].ToString("X2") + Tags[i].TD[1].ToString("X2");
                if (StrTID.Equals(StrTagID))
                {
                    string StrRID  = Tags[i].RD_New[0].ToString("X2") + Tags[i].RD_New[1].ToString("X2");
                    Area   CurArea = CommonBoxOperation.GetAreaFromRouterID(StrRID);
                    if (null == CurArea)
                    {
                        continue;
                    }
                    string StrAID = CurArea.ID[0].ToString("X2") + CurArea.ID[1].ToString("X2");
                    if (StrAID.Equals(StrAreaID))
                    { //判断确定在区域中了
                        if (i + 1 < tpks.Length)
                        {
                            TotalTime += (tpks[i + 1].ReportTime - tpks[i].ReportTime).Seconds;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
            return(TotalTime);
        }
Пример #5
0
        /// <summary>
        /// 刷新列表
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="args"></param>
        private void ShowTimer_Tick(Object obj, EventArgs args)
        {
            String       StrRouterName, StrRouterID, StrTagName, StrID;
            ListViewItem item = null;
            int          num  = CommonBoxOperation.GetCurAreaTagNum(StrAreaID);

            label4.Text = "人員當前總數:" + num;
            ArrayList MyArrayList = new ArrayList();
            Area      ar          = null;

            try{
                foreach (ListViewItem im in AreaTaglistView.Items)
                {
                    StrID = im.Name;
                    if (!CommonCollection.TagPacks.ContainsKey(StrID))
                    {
                        MyArrayList.Add(StrID);
                    }
                }
                //清除TagPacks中已经不存在的项
                for (int i = 0; i < MyArrayList.Count; i++)
                {
                    AreaTaglistView.Items.RemoveByKey(MyArrayList[i].ToString());
                }

                foreach (KeyValuePair <string, TagPack> tbk in CommonCollection.TagPacks)
                {
                    StrRouterID = tbk.Value.RD_New[0].ToString("X2") + tbk.Value.RD_New[1].ToString("X2");
                    //判断当前的Router是否在本区域中
                    Area CurArea = CommonBoxOperation.GetAreaFromRouterID(StrRouterID);
                    if (null == CurArea)
                    {
                        continue;
                    }
                    if (CurArea.ID[0] != MyArea.ID[0] || CurArea.ID[1] != MyArea.ID[1])
                    {
                        continue;
                    }
                    StrRouterName = CommonBoxOperation.GetRouterName(StrRouterID);
                    //判断当前Tag是否在当前的区域中
                    if (AreaTaglistView.Items.ContainsKey(tbk.Key))
                    {
                        item = null;
                        if (AreaTaglistView.Items.Count > 0)
                        {
                            item = AreaTaglistView.FindItemWithText(tbk.Key, false, 0);
                        }
                        else
                        {
                            continue;
                        }
                        if (null == item)
                        {
                            StrTagName = CommonBoxOperation.GetTagName(tbk.Key);
                            if (null == StrTagName)
                            {
                                continue;
                            }
                            item = AreaTaglistView.FindItemWithText(StrTagName, false, 0);
                        }
                        ar = CommonBoxOperation.GetRouterArea(StrRouterID);
                        if (ar == null)
                        {
                            continue;
                        }
                        if (!(ar.ID[0].ToString("X2") + ar.ID[1].ToString("X2")).Equals(StrAreaID))
                        {
                            continue;
                        }
                        if (null != item)
                        {
                            if (null == StrRouterName || "".Equals(StrRouterName))
                            {
                                item.SubItems[2].Text = StrRouterID;
                            }
                            else
                            {
                                item.SubItems[2].Text = StrRouterName;
                            }
                            item.SubItems[3].Text = tbk.Value.SigStren.ToString();
                            item.SubItems[4].Text = tbk.Value.Bat.ToString();
                            item.SubItems[5].Text = tbk.Value.ResTime.ToString();
                            item.SubItems[6].Text = tbk.Value.ReportTime.ToString();
                        }
                    }
                    else
                    {
                        ListViewItem Item = new ListViewItem();
                        Item.Name  = tbk.Key;//其中Name是指Tag的ID
                        Item.Text  = tbk.Key;
                        StrTagName = CommonBoxOperation.GetTagName(tbk.Key);
                        if (null == StrTagName)
                        {
                            Item.SubItems.Add("****");
                        }
                        else
                        {
                            Item.SubItems.Add(StrTagName);
                        }
                        if (null == StrRouterName || "".Equals(StrRouterName))
                        {
                            Item.SubItems.Add(StrRouterID);
                        }
                        else
                        {
                            Item.SubItems.Add(StrRouterName);
                        }
                        Item.SubItems.Add(tbk.Value.SigStren.ToString());
                        Item.SubItems.Add(tbk.Value.Bat.ToString());
                        Item.SubItems.Add(tbk.Value.ResTime.ToString());
                        Item.SubItems.Add(tbk.Value.ReportTime.ToString());
                        AreaTaglistView.Items.Add(Item);
                    }
                }
            }catch (Exception)
            {
            }
        }
Пример #6
0
        /// <summary>
        /// 查找按钮,用于查找Tag和设备讯息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchBtn_Click(object sender, EventArgs e)
        {
            String StrIDorName = TagIDorNameTB.Text.ToUpper();

            if ("".Equals(StrIDorName))
            {
                MessageBox.Show("設備的ID或名稱不能為空!");
                return;
            }
            if (tagrb.Checked)
            {
                #region 查找Tag设备
                PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchTag);
                CommonCollection.personOpers.Add(curpersonoper);
                TagPack MyTag = null;
                MyTag = SysParam.GetPackTag(StrIDorName);
                if (null == MyTag)
                {
                    MyTag = SysParam.GetPackTag_Name(StrIDorName);
                }
                if (null == MyTag)
                {
                    MessageBox.Show("查詢" + StrIDorName + "的Tag設備不存在!");
                    return;
                }
                Area curarea = CommonBoxOperation.GetAreaFromRouterID(MyTag.RD_New[0].ToString("X2") + MyTag.RD_New[1].ToString("X2"));
                if (null == curarea)
                {
                    MessageBox.Show("對不起,卡片所在的區域不存在!");
                    return;
                }
                try
                {
                    SysParam.isTracking = true;
                    MyAllRegInfoWin     = new AllRegInfoWin(frm, SpeceilAlarm.PersonHelp, MyTag.TD[0].ToString("X2") + MyTag.TD[1].ToString("X2"));
                    MyAllRegInfoWin.ShowDialog();
                }
                catch (Exception ex)
                {
                    FileOperation.WriteLog("搜索Tag設備出現異常!異常原因:" + ex.ToString());
                }
                finally
                {
                    this.Close();
                }
                #endregion
            }
            else if (rfrb.Checked)
            {
                #region 查找Refer设备
                PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchRefer);
                CommonCollection.personOpers.Add(curpersonoper);
                string      strareaid = "";
                BasicRouter mrt       = null;
                foreach (KeyValuePair <string, Area> marea in CommonCollection.Areas)
                {
                    if (null == marea.Value)
                    {
                        continue;
                    }
                    marea.Value.AreaRouter.TryGetValue(StrIDorName, out mrt);
                    if (mrt != null)
                    {
                        strareaid = marea.Key;
                        break;
                    }
                    foreach (KeyValuePair <string, BasicRouter> router in marea.Value.AreaRouter)
                    {
                        if (null == router.Value)
                        {
                            continue;
                        }
                        if (StrIDorName.Equals(router.Value.Name))
                        {
                            mrt = router.Value;
                            break;
                        }
                    }
                    if (null != mrt)
                    {
                        strareaid = marea.Key;
                        break;
                    }
                }
                if (null == strareaid || "".Equals(strareaid))
                {
                    MessageBox.Show("查詢" + StrIDorName + @"的參考點設備不存在!");
                    return;
                }

                RegInfoWin myregwin = new RegInfoWin(frm, strareaid);
                myregwin.ShowDialog();
                this.Close();
                #endregion
            }
            else if (ndrb.Checked)
            {
                #region 查找Node设备
                PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchNode);
                CommonCollection.personOpers.Add(curpersonoper);
                string    strareaid = "";
                BasicNode mnd       = null;
                foreach (KeyValuePair <string, Area> marea in CommonCollection.Areas)
                {
                    if (null == marea.Value)
                    {
                        continue;
                    }
                    marea.Value.AreaNode.TryGetValue(StrIDorName, out mnd);
                    if (mnd != null)
                    {
                        strareaid = marea.Key;
                        break;
                    }
                    foreach (KeyValuePair <string, BasicNode> node in marea.Value.AreaNode)
                    {
                        if (null == node.Value)
                        {
                            continue;
                        }
                        if (StrIDorName.Equals(node.Value.Name))
                        {
                            mnd = node.Value;
                            break;
                        }
                    }
                    if (null != mnd)
                    {
                        strareaid = marea.Key;
                        break;
                    }
                }
                if (null == strareaid || "".Equals(strareaid))
                {
                    MessageBox.Show("查詢" + StrIDorName + @"的數據節點設備不存在!");
                    return;
                }

                RegInfoWin myregwin = new RegInfoWin(frm, strareaid);
                myregwin.ShowDialog();
                this.Close();
                #endregion
            }
        }
Пример #7
0
        public void DrawTimer_Tick(Object obj, EventArgs args)
        {
            StartDTe    = StartDTe.AddMilliseconds(1000);//每次增加1s
            label7.Text = "當前時間:" + StartDTe.ToString();
            if (CurIndex >= PickTags.Length)
            {
                Stop();
                return;
            }
            float scalew, scaleh;

            if (DateTime.Compare(StartDTe, PickTags[CurIndex].ReportTime) >= 0)
            {//画出当前的地图
                string StrTagID    = PickTags[CurIndex].TD[0].ToString("X2") + PickTags[CurIndex].TD[1].ToString("X2");
                string StrRouterID = PickTags[CurIndex].RD_New[0].ToString("X2") + PickTags[CurIndex].RD_New[1].ToString("X2");
                Area   CurArea     = CommonBoxOperation.GetAreaFromRouterID(StrRouterID);
                if (CurArea != null)
                {
                    if (null == CurArea.Name || "".Equals(CurArea.Name))
                    {
                        CurAreaLabel.Text = "當前區域:" + CurArea.ID[0].ToString("X2") + CurArea.ID[1].ToString("X2");
                    }
                    else
                    {
                        CurAreaLabel.Text = "當前區域:" + CurArea.Name + "(" + CurArea.ID[0].ToString("X2") + CurArea.ID[1].ToString("X2") + ")";
                    }
                    BasicRouter CurBasic = CommonBoxOperation.GetBasicRouter(StrRouterID);
                    CurBasic.isReport = true;
                    string StrTagInfor = "";
                    string StrTagName  = CommonBoxOperation.GetTagName(StrTagID);
                    if (null == StrTagName || "".Equals(StrTagName))
                    {
                        StrTagInfor = StrTagID;
                    }
                    else
                    {
                        StrTagInfor = StrTagName + "(" + StrTagID + ")";
                    }

                    scalew   = (float)TrackPanel.Width / CurArea.AreaBitMap.MyBitmap.Width;
                    scaleh   = (float)TrackPanel.Height / CurArea.AreaBitMap.MyBitmap.Height;
                    TrackBtm = new Bitmap(655, 358);
                    TrackBtm = new Bitmap(CurArea.AreaBitMap.MyBitmap, TrackPanel.Width, TrackPanel.Height);
                    //画Router的信息
                    DrawAreaMap.DrawBasicRouter(TrackBtm, CurArea.ID[0].ToString("X2") + CurArea.ID[1].ToString("X2"), 1, scalew, scaleh);
                    //画Tag的信息
                    if (null != CurBasic)
                    {
                        if (PickTags[CurIndex].isAlarm == 0x03)
                        {
                            Graphics.FromImage(TrackBtm).FillEllipse(SimpleBrush, CurBasic.x * scalew - 8, CurBasic.y * scaleh - 32, ConstInfor.TagR * 2, ConstInfor.TagR * 2);
                            Graphics.FromImage(TrackBtm).DrawString(StrTagInfor, new Font("宋体", 10), SimpleBrush, CurBasic.x * scalew - 5, CurBasic.y * scaleh - 42);
                        }
                        else if (PickTags[CurIndex].isAlarm == 0x04)
                        {
                            Graphics.FromImage(TrackBtm).FillEllipse(AlarmBrush, CurBasic.x * scalew - 8, CurBasic.y * scaleh - 32, ConstInfor.TagR * 2, ConstInfor.TagR * 2);
                            Graphics.FromImage(TrackBtm).DrawString(StrTagInfor, new Font("宋体", 10), AlarmBrush, CurBasic.x * scalew - 5, CurBasic.y * scaleh - 42);
                        }
                    }
                    TrackPanel_Paint(null, null);
                }
                CurIndex++;
            }
        }
Пример #8
0
        //定时器触发的事件
        private void MyTimer_Tick(Object obj, EventArgs arg)
        {
            // 列表中的每一项都将对应的警告集合中的项,这样便于查找
            string        strtagid, strtagname, strreferid, strrefername, strareaid;
            StringBuilder strtaginfor = null, strreferinfor = null, strareainfo = null;
            Area          curarea = null;

            ListViewItem    item      = null;
            List <WarmInfo> tempwarms = null;

            lock (CommonCollection.warm_lock)
            {
                tempwarms = CommonCollection.WarmInfors.ToList();
            }
            for (int i = 0; i < tempwarms.Count; i++)
            {
                if (null == tempwarms[i])
                {
                    continue;
                }
                string strclassname = tempwarms[i].GetType().Name;
                switch (CurSpeceilAlarm)
                {
                case SpeceilAlarm.PersonHelp:
                {
                    if (!"PersonHelp".Equals(strclassname))
                    {
                        continue;
                    }
                    strtagid   = ((PersonHelp)tempwarms[i]).TD[0].ToString("X2") + ((PersonHelp)tempwarms[i]).TD[1].ToString("X2");
                    strtagname = CommonBoxOperation.GetTagName(strtagid);
                    if (null != strtagname && !"".Equals(strtagname))
                    {
                        strtaginfor = new StringBuilder(strtagname);
                        strtaginfor.Append("(");
                        strtaginfor.Append(strtagid);
                        strtaginfor.Append(")");
                        //TagInfo = TagName + "(" + TagInfo + ")";
                    }
                    else
                    {
                        strtaginfor = new StringBuilder(strtagid);
                    }
                    break;
                }

                case SpeceilAlarm.AreaControl:
                {
                    if (!"AreaAdmin".Equals(strclassname))
                    {
                        continue;
                    }
                    strtagid   = ((AreaAdmin)tempwarms[i]).TD[0].ToString("X2") + ((AreaAdmin)tempwarms[i]).TD[1].ToString("X2");
                    strtagname = CommonBoxOperation.GetTagName(strtagid);
                    if (null != strtagname && !"".Equals(strtagname))
                    {
                        strtaginfor = new StringBuilder(strtagname);
                        strtaginfor.Append("(");
                        strtaginfor.Append(strtagid);
                        strtaginfor.Append(")");
                    }
                    else
                    {
                        strtaginfor = new StringBuilder(strtagid);
                    }
                    break;
                }

                case SpeceilAlarm.Resid:
                {
                    if (!"PersonRes".Equals(strclassname))
                    {
                        continue;
                    }
                    strtagid   = ((PersonRes)tempwarms[i]).TD[0].ToString("X2") + ((PersonRes)tempwarms[i]).TD[1].ToString("X2");
                    strtagname = CommonBoxOperation.GetTagName(strtagid);
                    if (null != strtagname && !"".Equals(strtagname))
                    {
                        strtaginfor = new StringBuilder(strtagname);
                        strtaginfor.Append("(");
                        strtaginfor.Append(strtagid);
                        strtaginfor.Append(")");
                    }
                    else
                    {
                        strtaginfor = new StringBuilder(strtagid);
                    }
                    break;
                }

                default:
                    break;
                }
                strreferid   = tempwarms[i].RD[0].ToString("X2") + tempwarms[i].RD[1].ToString("X2");
                curarea      = CommonBoxOperation.GetAreaFromRouterID(strreferid);
                strrefername = CommonBoxOperation.GetRouterName(strreferid);
                if (null != strrefername && !"".Equals(strrefername))
                {
                    strreferinfor = new StringBuilder(strrefername);
                    strreferinfor.Append("(");
                    strreferinfor.Append(strreferid);
                    strreferinfor.Append(")");
                }
                else
                {
                    strreferinfor = new StringBuilder(strreferid);
                }
                if (null != curarea)
                {
                    strareaid = curarea.ID[0].ToString("X2") + curarea.ID[1].ToString("X2");
                    if (null != curarea.Name && !"".Equals(curarea.Name))
                    {
                        strareainfo = new StringBuilder(curarea.Name);
                        strareainfo.Append("(");
                        strareainfo.Append(strareaid);
                        strareainfo.Append(")");
                    }
                    else
                    {
                        strareainfo = new StringBuilder(strareaid);
                    }
                }
                else
                {
                    strareainfo = new StringBuilder("****");
                }
                if (PersonAlarmListView.Items.ContainsKey(i + ""))
                {//没有包含这一项
                    ListViewItem[] Items = PersonAlarmListView.Items.Find(i.ToString(), false);
                    if (null != Items && Items.Length > 0)
                    {
                        Items[0].SubItems[3].Text = tempwarms[i].AlarmTime.ToString();
                        if (!tempwarms[i].isHandler)
                        {//说明没有被处理
                            Items[0].SubItems[4].Text = "****";
                            Items[0].SubItems[5].Text = "未處理";
                        }
                        else
                        {
                            Items[0].SubItems[4].Text = tempwarms[i].ClearAlarmTime.ToString();
                            Items[0].SubItems[5].Text = "處理";
                        }
                    }
                }
                else
                {
                    if (tempwarms[i].isClear)
                    {
                        continue;
                    }
                    //包含这一项
                    item      = new ListViewItem();
                    item.Name = i.ToString();
                    item.Text = strtaginfor.ToString();//Tag信息
                    item.SubItems.Add(strareainfo.ToString());
                    item.SubItems.Add(strreferinfor.ToString());
                    item.SubItems.Add(tempwarms[i].AlarmTime.ToString());
                    if (!tempwarms[i].isHandler)
                    {
                        item.SubItems.Add("****");
                        item.SubItems.Add("未處理");
                    }
                    else
                    {
                        item.SubItems.Add(tempwarms[i].ClearAlarmTime.ToString());
                        item.SubItems.Add("處理");
                    }
                    PersonAlarmListView.Items.Add(item);
                }
            }
            //显示当前的总人数
            label1.Text = "報警資訊數量:" + PersonAlarmListView.Items.Count;
        }