void ClearControls()
        {
            #region 清空货架 清空table
            DataRow[] rows = MemoryTable.unitTable.Select("status = 'occupied'");
            if (rows.Length > 0)
            {
                for (int i = 0; i < rows.Length; i++)
                {
                    string id = (string)rows[i]["id"];
                    if (id != null && id.Length > 0)
                    {
                        int          groupIndex = int.Parse(rows[i]["group"].ToString());
                        Carbinet     _carbinet  = this.groups[groupIndex];
                        DocumentFile df         = _carbinet.getDoc(id);
                        if (df != null)
                        {
                            df.setBackgroundImage(null);
                            df.setBorderWidth(0);
                            df.indexBase = "z" + df.columnNumber.ToString("0000");//重置为基础的排序依据
                        }
                    }

                    rows[i]["action"] = "normal";
                    rows[i]["epc"]    = "";
                    rows[i]["type"]   = "";
                    rows[i]["status"] = "empty";
                }
            }
            #endregion

            #region 初始化饼图
            m_panelDrawing.Values = new decimal[] { 0, 0 };
            // m_panelDrawing.Values = new decimal[] { 0 };

            m_panelDrawing.Colors = new Color[] { Color.FromArgb(alpha, Color.Gray), Color.FromArgb(alpha, Color.GreenYellow) };
            //m_panelDrawing.SliceRelativeDisplacements = new float[] { 0.1F, 0.2F, 0.2F, 0.2F };
            m_panelDrawing.Texts = new string[] { " ", " " };
            //            m_panelDrawing.Texts = new string[] { "未知", "A", "B", "C", "D" };
            m_panelDrawing.ToolTips = new string[] { "", "" };
            #endregion
        }
        public void NewTagMessage()
        {
            deleControlInvoke dele = delegate(object o)
            {
                List <EpcProduct> tagList = current_helper.GetCurrentProductList();
                if (tagList.Count > 0)
                {
                    foreach (EpcProduct ep in tagList)
                    {
                        Debug.WriteLine(string.Format("epc => {0}   antena => {1}", ep.tagInfo.epc, ep.tagInfo.antennaID));
                    }
                    #region 检查标签是否应该放在放在的正确的货架
                    //int count4InWrongCarbinet = 0;
                    //foreach (EpcProduct t in tagList)
                    //{
                    //    string tEpc = t.epc;
                    //    if (tEpc.Substring(16, 2) != carbinet_epc_flag)
                    //    {
                    //        count4InWrongCarbinet++;
                    //    }
                    //}
                    //if (count4InWrongCarbinet > 0)
                    //{
                    //    this.lblStatus.Text = "有不属于本货架的产品放置在本货架中,请检查!";
                    //}
                    //else
                    //{
                    //    this.lblStatus.Text = string.Empty;
                    //}
                    #endregion
                }
                else
                {
                    Debug.WriteLine("no products now!!!");
                }

                #region 首先把不再存在的标签从列表中删除
                //
                DataRow[] allRows = MemoryTable.unitTable.Select();
                for (int j = 0; j < allRows.Length; j++)
                {
                    DataRow dr    = allRows[j];
                    string  epc   = (string)dr["epc"];
                    int     floor = int.Parse(dr["floor"].ToString());
                    if (epc != null && epc.Length > 0)
                    {
                        bool bFinded = false;
                        foreach (EpcProduct ti in tagList)
                        {
                            if ((ti.tagInfo.epc == epc) && (this.getFloorByAntennaID(ti.tagInfo.antennaID) == floor))//这里的不存在应该和位置相关
                            {
                                bFinded = true;
                                break;
                            }
                        }
                        if (bFinded == false)//如果列表中不再存在这个标签,就把之前标签占据的位置的状态设为delete
                        {
                            dr["action"] = "delete";
                            MemoryTable.staticsTable.Rows.Add(new object[] { epc, "下架", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
                        }
                    }
                }
                #endregion

                #region 添加新出现的标签到显示列表中
                //
                for (int i = 0; i < tagList.Count; i++)
                {
                    EpcProduct ti  = tagList[i];
                    string     epc = ti.tagInfo.epc;
                    //if (epc.Substring(16, 2) != carbinet_epc_flag)
                    //{
                    //    continue;
                    //}
                    int anticipatedFloor = 0;
                    try
                    {
                        string strFloor = this.getAnticipatedFloorByEpc(epc);// 18,2
                        anticipatedFloor = int.Parse(strFloor);
                    }
                    catch
                    {
                    }
                    if (anticipatedFloor == 0)
                    {
                        continue;
                    }
                    int tagFloor = this.getFloorByAntennaID(ti.tagInfo.antennaID);

                    bool      bOnWrongFloor = false; //是否放置在错误的货架层上
                    DataRow[] drs           = MemoryTable.unitTable.Select("epc='" + epc + "' and floor=" + tagFloor.ToString());
                    if (drs.Length <= 0)             //说明这个标签还不存在
                    {
                        //Debug.WriteLine("antinna To floor ->  antenna = " + ti.antennaID);
                        int antenna = int.Parse(ti.tagInfo.antennaID);//todo  暂时把设备的天线和货架的层数挂钩
                        int floor   = -1;
                        switch (antenna)
                        {
                        case 1:
                            floor = 1;
                            break;

                        case 2:
                            floor = 2;
                            break;

                        case 4:
                            floor = 3;
                            break;

                        case 8:
                            floor = 4;
                            break;
                        }
                        if (floor != anticipatedFloor)
                        {
                            Debug.WriteLine(string.Format("antinna To floor ->  floor = {0}   anticipatedFloor = {1}", floor.ToString(), anticipatedFloor.ToString()));
                            bOnWrongFloor = true;//设计放产品的层和实际的层不一致
                        }
                        if (floor != -1)
                        {
                            DataRow[] emptyRows = MemoryTable.unitTable.Select("status = 'empty' and floor=" + floor.ToString());
                            if (emptyRows.Length > 0)
                            {
                                Debug.WriteLine(
                                    string.Format("Form1._timer_Tick  -> equipID = {0}"
                                                  , emptyRows[0]["id"]));
                                emptyRows[0]["epc"]    = epc;
                                emptyRows[0]["status"] = "occupied";
                                if (bOnWrongFloor == true)
                                {
                                    emptyRows[0]["action"] = "addOnWrongFloor";
                                }
                                else
                                {
                                    emptyRows[0]["action"] = "add";
                                }
                                if (epc != null && epc.Length >= 23)
                                {
                                    string type = epc.Substring(20, 2);

                                    emptyRows[0]["type"] = type;
                                }
                            }
                        }
                        MemoryTable.staticsTable.Rows.Add(new object[] { epc, "上架", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
                    }
                }

                #endregion
                #region 其它逻辑处理

                //
                // 1 搜索某类商品
                string productName = this.cmbProductName.Text;
                //            string productName = this.txtProductName.Text;
                if (productName != null && productName.Length > 0 && productName != "无")
                {
                    DataRow[] rowsProduct = MemoryTable.typeMapTable.Select("productName <>'" + productName + "'");
                    for (int j = 0; j < rowsProduct.Length; j++)
                    {
                        DataRow   dr         = rowsProduct[j];
                        string    type       = (string)dr["type"];
                        DataRow[] rowsFilter = MemoryTable.unitTable.Select("type = '" + type + "'");
                        for (int k = 0; k < rowsFilter.Length; k++)
                        {
                            DataRow drFilter = rowsFilter[k];

                            //drFilter["status"] = "empty";
                            drFilter["action"] = "delete";
                        }
                    }
                }

                #endregion


                #region 处理显示
                //
                //需要删除的
                DataRow[] rows = MemoryTable.unitTable.Select("action = 'delete'");
                if (rows.Length > 0)
                {
                    List <epcInfo> epcList = new List <epcInfo>();
                    for (int i = 0; i < rows.Length; i++)
                    {
                        string  id      = (string)rows[i]["id"];
                        string  epc     = (string)rows[i]["epc"];
                        string  type    = (string)rows[i]["type"];
                        epcInfo epcinfo = new epcInfo(epc, type);
                        epcList.Add(epcinfo);
                        if (id != null && id.Length > 0)
                        {
                            int          groupIndex = int.Parse(rows[i]["group"].ToString());
                            Carbinet     _carbinet  = this.groups[groupIndex];
                            DocumentFile df         = _carbinet.getDoc(id);
                            if (df != null)
                            {
                                df.setBackgroundImage(null);
                                df.setBorderWidth(0);
                                df.indexBase = "z" + df.columnNumber.ToString("0000");//重置为基础的排序依据
                            }
                        }

                        rows[i]["action"] = "normal";
                        rows[i]["epc"]    = "";
                        rows[i]["type"]   = "";
                        rows[i]["status"] = "empty";
                    }

                    //TODO 处于防盗模式下需要语音提醒,处于讲解模式下需要对产品进行讲解
                    if (staticClass.mode == MonitorMode.防盗模式)
                    {
                        this.SpeakAboutSomething(epcList);
                    }
                    //else
                    //    if (staticClass.mode == MonitorMode.讲解模式)
                    //    {
                    //        for (int i = 0; i < epcList.Count; i++)
                    //        {
                    //            epcInfo ei = epcList[i];
                    //            MemoryTable.staticsTable.Rows.Add(new object[] { ei.epc, "下架", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
                    //        }
                    //    }
                }
                // 需要增加的
                rows = MemoryTable.unitTable.Select("action = 'add' OR action = 'addOnWrongFloor'");
                if (rows.Length > 0)
                {
                    for (int i = 0; i < rows.Length; i++)
                    {
                        int    groupIndex    = int.Parse(rows[i]["group"].ToString());
                        string id            = (string)rows[i]["id"];
                        string epc           = (string)rows[i]["epc"];
                        string action        = (string)rows[i]["action"];
                        bool   bOnWrongFloor = false;
                        if (action == "addOnWrongFloor")
                        {
                            bOnWrongFloor = true;
                        }
                        Carbinet _carbinet = this.groups[groupIndex];
                        // 不同种类的物品设置成不同的大小
                        string type = MemoryTable.getProductTypeID(epc);

                        DataRow[] drsType = MemoryTable.typeMapTable.Select("type='" + type + "'");
                        if (drsType.Length > 0)
                        {
                            int    width  = int.Parse(drsType[0]["width"].ToString());
                            int    height = int.Parse(drsType[0]["height"].ToString());
                            string path   = (string)drsType[0]["picname"];
                            path = PublicConfig.staticClass.PicturePath + path;
                            Image newImage = null;
                            try
                            {
                                newImage = Image.FromFile(path);
                            }
                            catch (System.Exception ex)
                            {
                                Debug.WriteLine(
                                    string.Format("Form1._timer_Tick  -> loadImage error = {0}"
                                                  , ex.Message));
                            }
                            DocumentFile df = _carbinet.getDoc(id);
                            if (df != null)
                            {
                                df.setBackgroundImage(newImage);
                                if (bOnWrongFloor == true)
                                {
                                    df.setBorderWidth(5);
                                }
                                //df.setBorderWidth(0);//边框重置为0
                                df.indexBase = type;
                            }
                            //_carbinet.setDocBGImage(id, newImage);

                            _carbinet.setDocSize(id, width, height);

                            //drsType[0]["count"] = ((int)drsType[0]["count"]) + 1;
                        }
                        rows[i]["action"] = "normal";
                    }
                }

                #endregion



                #region 设置饼图

                //
                DataRow[] typeRows = MemoryTable.typeMapTable.Select();
                decimal[] decimals = new decimal[typeRows.Length];
                string[]  strs     = new string[typeRows.Length];
                Color[]   colors   = new Color[typeRows.Length];
                for (int i = 0; i < typeRows.Length; i++)
                {
                    DataRow[] RowsTemp = MemoryTable.unitTable.Select("type = '" + (string)typeRows[i]["type"] + "'");
                    decimals[i]          = RowsTemp.Length;
                    typeRows[i]["count"] = RowsTemp.Length;
                    //                decimals[i] = (int)typeRows[i]["count"];
                    strs[i] = RowsTemp.Length.ToString();
                    //                strs[i] = typeRows[i]["count"].ToString();
                    //strs[i] = typeRows[i]["productName"] + ":" + typeRows[i]["count"].ToString();
                    colors[i] = Color.FromArgb(alpha,
                                               int.Parse(typeRows[i]["red"].ToString()),
                                               int.Parse(typeRows[i]["green"].ToString()),
                                               int.Parse(typeRows[i]["blue"].ToString()));
                }
                m_panelDrawing.Values = decimals;
                m_panelDrawing.Texts  = strs;
                m_panelDrawing.Colors = colors;
                #endregion
            };

            this.Invoke(dele, new object());
        }
        void _timer_Tick(object sender, EventArgs e)
        {
            UDPServer.Manualstate.WaitOne();
            UDPServer.Manualstate.Reset();
            string str = UDPServer.sbuilder.ToString();

            UDPServer.sbuilder.Remove(0, str.Length);

            UDPServer.Manualstate.Set();
            helper.ParseDataToTag(str);
            if (str != null && str.Length >= 0)
            {
                //this.txtLog.Text = str + "\r\n" + this.txtLog.Text;
                //Debug.WriteLine(
                //    string.Format(".  _timer_Tick -> string = {0}"
                //    , str));
            }
            //处理列表
            List <TagInfo> tagList = helper.getTagList();//先拿到读取到的标签

            //首先把不再存在的标签从列表中删除
            DataRow[] allRows = MemoryTable.unitTable.Select();
            for (int j = 0; j < allRows.Length; j++)
            {
                DataRow dr    = allRows[j];
                string  epc   = (string)dr["epc"];
                int     floor = (int)dr["floor"];
                if (epc != null && epc.Length > 0)
                {
                    //int tagFloor = -1;
                    //tagFloor=this.getFloorByAntennaID()
                    bool bFinded = false;
                    foreach (TagInfo ti in tagList)
                    {
                        if ((ti.epc == epc) && (this.getFloorByAntennaID(ti.antennaID) == floor))//这里的不存在应该和位置相关
                        //if (ti.epc == epc)
                        {
                            bFinded = true;
                            break;
                        }
                    }
                    if (bFinded == false)//如果列表中不再存在这个标签,就把之前标签占据的位置的状态设为delete
                    {
                        //dr["epc"] = "";
                        //dr["status"] = "empty";
                        dr["action"] = "delete";
                    }
                }
            }
            // 添加新出现的标签到显示列表中
            for (int i = 0; i < tagList.Count; i++)
            {
                TagInfo ti       = tagList[i];
                string  epc      = ti.epc;
                int     tagFloor = this.getFloorByAntennaID(ti.antennaID);

                DataRow[] drs = MemoryTable.unitTable.Select("epc='" + epc + "' and floor=" + tagFloor.ToString());
                if (drs.Length <= 0)//说明这个标签还不存在
                {
                    Debug.WriteLine("antinna To floor ->  antenna = " + ti.antennaID);
                    int antenna = int.Parse(ti.antennaID);//todo  暂时把设备的天线和货架的层数挂钩
                    int floor   = -1;
                    switch (antenna)
                    {
                    case 1:
                        floor = 1;
                        break;

                    case 2:
                        floor = 2;
                        break;

                    case 4:
                        floor = 3;
                        break;

                    case 8:
                        floor = 4;
                        break;
                    }
                    Debug.WriteLine("antinna To floor ->  floor = " + floor.ToString());

                    if (floor != -1)
                    {
                        DataRow[] emptyRows = MemoryTable.unitTable.Select("status = 'empty' and floor=" + floor.ToString());
                        if (emptyRows.Length > 0)
                        {
                            Debug.WriteLine(
                                string.Format("Form1._timer_Tick  -> equipID = {0}"
                                              , emptyRows[0]["id"]));
                            emptyRows[0]["epc"]    = epc;
                            emptyRows[0]["status"] = "occupied";
                            emptyRows[0]["action"] = "add";
                            if (epc != null && epc.Length >= 23)
                            {
                                string type = epc.Substring(20, 2);

                                emptyRows[0]["type"] = type;
                            }
                        }
                    }
                }
            }

            //其它逻辑处理
            // 1 搜索某类商品
            string productName = this.cmbProductName.Text;

            //            string productName = this.txtProductName.Text;
            if (productName != null && productName.Length > 0 && productName != "无")
            {
                DataRow[] rowsProduct = MemoryTable.typeMapTable.Select("productName <>'" + productName + "'");
                for (int j = 0; j < rowsProduct.Length; j++)
                {
                    DataRow   dr         = rowsProduct[j];
                    string    type       = (string)dr["type"];
                    DataRow[] rowsFilter = MemoryTable.unitTable.Select("type = '" + type + "'");
                    for (int k = 0; k < rowsFilter.Length; k++)
                    {
                        DataRow drFilter = rowsFilter[k];

                        //drFilter["status"] = "empty";
                        drFilter["action"] = "delete";
                    }
                }
            }

            //处理显示
            //需要删除的
            DataRow[] rows = MemoryTable.unitTable.Select("action = 'delete'");
            if (rows.Length > 0)
            {
                for (int i = 0; i < rows.Length; i++)
                {
                    string id = (string)rows[i]["id"];
                    if (id != null && id.Length > 0)
                    {
                        int          groupIndex = (int)rows[i]["group"];
                        Carbinet     _carbinet  = this.groups[groupIndex];
                        DocumentFile df         = _carbinet.getDoc(id);
                        if (df != null)
                        {
                            df.setBackgroundImage(null);
                            df.indexBase = "z" + df.columnNumber.ToString("0000");//重置为基础的排序依据
                        }
                        //_carbinet.setDocBGImage(id, null);
                        // _carbinet.setDocBGColor(id, Color.Gray);
                    }

                    // 不同种类的物品减去消失标签的数量
                    //string epc = (string)rows[i]["epc"];
                    //if (epc.Length >= 22)
                    //{
                    //    string type = epc.Substring(20, 2);
                    //    DataRow[] drsType = MemoryTable.typeMapTable.Select("type='" + type + "'");
                    //    if (drsType.Length > 0)
                    //    {

                    //        drsType[0]["count"] = ((int)drsType[0]["count"]) - 1;

                    //    }
                    //}
                    rows[i]["action"] = "normal";
                    rows[i]["epc"]    = "";
                    rows[i]["type"]   = "";
                    rows[i]["status"] = "empty";
                }
            }
            // 需要增加的
            rows = MemoryTable.unitTable.Select("action = 'add'");
            if (rows.Length > 0)
            {
                for (int i = 0; i < rows.Length; i++)
                {
                    int      groupIndex = (int)rows[i]["group"];
                    string   id         = (string)rows[i]["id"];
                    string   epc        = (string)rows[i]["epc"];
                    Carbinet _carbinet  = this.groups[groupIndex];
                    // 不同种类的物品设置成不同的大小
                    string type = MemoryTable.getProductTypeID(epc);

                    DataRow[] drsType = MemoryTable.typeMapTable.Select("type='" + type + "'");
                    if (drsType.Length > 0)
                    {
                        int    width  = int.Parse(drsType[0]["width"].ToString());
                        int    height = int.Parse(drsType[0]["height"].ToString());
                        string path   = (string)drsType[0]["picname"];
                        path = PublicConfig.staticClass.PicturePath + path;
                        Image newImage = null;
                        try
                        {
                            newImage = Image.FromFile(path);
                        }
                        catch (System.Exception ex)
                        {
                            Debug.WriteLine(
                                string.Format("Form1._timer_Tick  -> loadImage error = {0}"
                                              , ex.Message));
                        }
                        DocumentFile df = _carbinet.getDoc(id);
                        if (df != null)
                        {
                            df.setBackgroundImage(newImage);
                            df.indexBase = type;
                        }
                        //_carbinet.setDocBGImage(id, newImage);

                        _carbinet.setDocSize(id, width, height);

                        //drsType[0]["count"] = ((int)drsType[0]["count"]) + 1;
                    }
                    rows[i]["action"] = "normal";
                }
            }

            //设置饼图
            DataRow[] typeRows = MemoryTable.typeMapTable.Select();
            decimal[] decimals = new decimal[typeRows.Length];
            string[]  strs     = new string[typeRows.Length];
            Color[]   colors   = new Color[typeRows.Length];
            for (int i = 0; i < typeRows.Length; i++)
            {
                DataRow[] RowsTemp = MemoryTable.unitTable.Select("type = '" + (string)typeRows[i]["type"] + "'");
                decimals[i]          = RowsTemp.Length;
                typeRows[i]["count"] = RowsTemp.Length;
                //                decimals[i] = (int)typeRows[i]["count"];
                strs[i] = RowsTemp.Length.ToString();
                //                strs[i] = typeRows[i]["count"].ToString();
                //strs[i] = typeRows[i]["productName"] + ":" + typeRows[i]["count"].ToString();
                colors[i] = Color.FromArgb(alpha,
                                           int.Parse(typeRows[i]["red"].ToString()),
                                           int.Parse(typeRows[i]["green"].ToString()),
                                           int.Parse(typeRows[i]["blue"].ToString()));
            }
            m_panelDrawing.Values = decimals;
            m_panelDrawing.Texts  = strs;
            m_panelDrawing.Colors = colors;
        }
        void _timer_Tick(object sender, EventArgs e)
        {
            this.udp_server.Manualstate.WaitOne();
            this.udp_server.Manualstate.Reset();
            string str = this.udp_server.sbuilder.ToString();

            this.udp_server.sbuilder.Remove(0, str.Length);

            this.udp_server.Manualstate.Set();
            helper.ParseDataToTag(str);
            if (str != null && str.Length >= 0)
            {
                //this.txtLog.Text = str + "\r\n" + this.txtLog.Text;
                //Debug.WriteLine(
                //    string.Format(".  _timer_Tick -> string = {0}"
                //    , str));
            }
            //处理列表
            List <TagInfo> tagList = helper.getTagList();//先拿到读取到的标签

            #region 检查标签是否应该放在放在的正确的货架
            int count4InWrongCarbinet = 0;
            foreach (TagInfo t in tagList)
            {
                string tEpc = t.epc;
                if (tEpc.Substring(16, 2) != "01")
                {
                    count4InWrongCarbinet++;
                }
            }
            if (count4InWrongCarbinet > 0)
            {
                this.lblStatus.Text = "有不属于本货架的产品放置在本货架中,请检查!";
            }
            else
            {
                this.lblStatus.Text = string.Empty;
            }
            #endregion


            #region 首先把不再存在的标签从列表中删除


            //
            DataRow[] allRows = MemoryTable.unitTable.Select();
            for (int j = 0; j < allRows.Length; j++)
            {
                DataRow dr    = allRows[j];
                string  epc   = (string)dr["epc"];
                int     floor = int.Parse(dr["floor"].ToString());
                if (epc != null && epc.Length > 0)
                {
                    //int tagFloor = -1;
                    //tagFloor=this.getFloorByAntennaID()
                    bool bFinded = false;
                    foreach (TagInfo ti in tagList)
                    {
                        if ((ti.epc == epc) && (this.getFloorByAntennaID(ti.antennaID) == floor))//这里的不存在应该和位置相关
                        //if (ti.epc == epc)
                        {
                            bFinded = true;
                            break;
                        }
                    }
                    if (bFinded == false)//如果列表中不再存在这个标签,就把之前标签占据的位置的状态设为delete
                    {
                        //dr["epc"] = "";
                        //dr["status"] = "empty";
                        dr["action"] = "delete";
                    }
                }
            }


            #endregion

            #region 添加新出现的标签到显示列表中

            //
            for (int i = 0; i < tagList.Count; i++)
            {
                TagInfo ti  = tagList[i];
                string  epc = ti.epc;
                if (epc.Substring(16, 2) != "01")
                {
                    continue;
                }
                int anticipatedFloor = 0;
                try
                {
                    string strFloor = this.getAnticipatedFloorByEpc(epc);// 18,2
                    anticipatedFloor = int.Parse(strFloor);
                }
                catch (System.Exception ex)
                {
                }
                if (anticipatedFloor == 0)
                {
                    continue;
                }
                int tagFloor = this.getFloorByAntennaID(ti.antennaID);

                bool      bOnWrongFloor = false; //是否放置在错误的货架层上
                DataRow[] drs           = MemoryTable.unitTable.Select("epc='" + epc + "' and floor=" + tagFloor.ToString());
                if (drs.Length <= 0)             //说明这个标签还不存在
                {
                    Debug.WriteLine("antinna To floor ->  antenna = " + ti.antennaID);
                    int antenna = int.Parse(ti.antennaID);//todo  暂时把设备的天线和货架的层数挂钩
                    int floor   = -1;
                    switch (antenna)
                    {
                    case 1:
                        floor = 1;
                        break;

                    case 2:
                        floor = 2;
                        break;

                    case 4:
                        floor = 3;
                        break;

                    case 8:
                        floor = 4;
                        break;
                    }
                    if (floor != anticipatedFloor)
                    {
                        Debug.WriteLine(string.Format("antinna To floor ->  floor = {0}   anticipatedFloor = {1}", floor.ToString(), anticipatedFloor.ToString()));
                        bOnWrongFloor = true;//设计放产品的层和实际的层不一致
                    }
                    if (floor != -1)
                    {
                        DataRow[] emptyRows = MemoryTable.unitTable.Select("status = 'empty' and floor=" + floor.ToString());
                        if (emptyRows.Length > 0)
                        {
                            Debug.WriteLine(
                                string.Format("Form1._timer_Tick  -> equipID = {0}"
                                              , emptyRows[0]["id"]));
                            emptyRows[0]["epc"]    = epc;
                            emptyRows[0]["status"] = "occupied";
                            if (bOnWrongFloor == true)
                            {
                                emptyRows[0]["action"] = "addOnWrongFloor";
                            }
                            else
                            {
                                emptyRows[0]["action"] = "add";
                            }
                            if (epc != null && epc.Length >= 23)
                            {
                                string type = epc.Substring(20, 2);

                                emptyRows[0]["type"] = type;
                            }
                        }
                    }
                }
            }

            #endregion


            #region 其它逻辑处理

            //
            // 1 搜索某类商品
            string productName = this.cmbProductName.Text;
            //            string productName = this.txtProductName.Text;
            if (productName != null && productName.Length > 0 && productName != "无")
            {
                DataRow[] rowsProduct = MemoryTable.typeMapTable.Select("productName <>'" + productName + "'");
                for (int j = 0; j < rowsProduct.Length; j++)
                {
                    DataRow   dr         = rowsProduct[j];
                    string    type       = (string)dr["type"];
                    DataRow[] rowsFilter = MemoryTable.unitTable.Select("type = '" + type + "'");
                    for (int k = 0; k < rowsFilter.Length; k++)
                    {
                        DataRow drFilter = rowsFilter[k];

                        //drFilter["status"] = "empty";
                        drFilter["action"] = "delete";
                    }
                }
            }

            #endregion



            #region 处理显示

            //
            //需要删除的
            DataRow[] rows = MemoryTable.unitTable.Select("action = 'delete'");
            if (rows.Length > 0)
            {
                List <epcInfo> epcList = new List <epcInfo>();
                for (int i = 0; i < rows.Length; i++)
                {
                    string  id      = (string)rows[i]["id"];
                    string  epc     = (string)rows[i]["epc"];
                    string  type    = (string)rows[i]["type"];
                    epcInfo epcinfo = new epcInfo(epc, type);
                    epcList.Add(epcinfo);
                    if (id != null && id.Length > 0)
                    {
                        int          groupIndex = int.Parse(rows[i]["group"].ToString());
                        Carbinet     _carbinet  = this.groups[groupIndex];
                        DocumentFile df         = _carbinet.getDoc(id);
                        if (df != null)
                        {
                            df.setBackgroundImage(null);
                            df.setBorderWidth(0);
                            df.indexBase = "z" + df.columnNumber.ToString("0000");//重置为基础的排序依据
                        }
                    }

                    rows[i]["action"] = "normal";
                    rows[i]["epc"]    = "";
                    rows[i]["type"]   = "";
                    rows[i]["status"] = "empty";
                }

                //TODO 处于防盗模式下需要语音提醒,处于讲解模式下需要对产品进行讲解
                //if (staticClass.mode == MonitorMode.防盗模式)
                //{
                //    this.SpeakAboutSomething(epcList);
                //}
            }
            // 需要增加的
            rows = MemoryTable.unitTable.Select("action = 'add' OR action = 'addOnWrongFloor'");
            if (rows.Length > 0)
            {
                for (int i = 0; i < rows.Length; i++)
                {
                    int    groupIndex    = int.Parse(rows[i]["group"].ToString());
                    string id            = (string)rows[i]["id"];
                    string epc           = (string)rows[i]["epc"];
                    string action        = (string)rows[i]["action"];
                    bool   bOnWrongFloor = false;
                    if (action == "addOnWrongFloor")
                    {
                        bOnWrongFloor = true;
                    }
                    Carbinet _carbinet = this.groups[groupIndex];
                    // 不同种类的物品设置成不同的大小
                    string type = MemoryTable.getProductTypeID(epc);

                    DataRow[] drsType = MemoryTable.typeMapTable.Select("type='" + type + "'");
                    if (drsType.Length > 0)
                    {
                        int    width  = int.Parse(drsType[0]["width"].ToString());
                        int    height = int.Parse(drsType[0]["height"].ToString());
                        string path   = (string)drsType[0]["picname"];
                        path = PublicConfig.staticClass.PicturePath + path;
                        Image newImage = null;
                        try
                        {
                            newImage = Image.FromFile(path);
                        }
                        catch (System.Exception ex)
                        {
                            Debug.WriteLine(
                                string.Format("Form1._timer_Tick  -> loadImage error = {0}"
                                              , ex.Message));
                        }
                        DocumentFile df = _carbinet.getDoc(id);
                        if (df != null)
                        {
                            df.setBackgroundImage(newImage);
                            if (bOnWrongFloor == true)
                            {
                                df.setBorderWidth(5);
                            }
                            //df.setBorderWidth(0);//边框重置为0
                            df.indexBase = type;
                        }
                        //_carbinet.setDocBGImage(id, newImage);

                        _carbinet.setDocSize(id, width, height);

                        //drsType[0]["count"] = ((int)drsType[0]["count"]) + 1;
                    }
                    rows[i]["action"] = "normal";
                }
            }

            #endregion
        }
示例#5
0
        //string strClickedType = string.Empty;
        void _timer_Tick(object sender, EventArgs e)
        {
            this.update_cabinet_data(this.udp_server1, this.helper1, 0);
            this.update_cabinet_data(this.udp_server2, this.helper2, 1);


            #region 处理显示

            //
            //需要删除的
            DataRow[] rows = MemoryTable.unitTable.Select("action = 'delete'");
            if (rows.Length > 0)
            {
                List <epcInfo> epcList = new List <epcInfo>();
                for (int i = 0; i < rows.Length; i++)
                {
                    string  id      = (string)rows[i]["id"];
                    string  epc     = (string)rows[i]["epc"];
                    string  type    = (string)rows[i]["type"];
                    epcInfo epcinfo = new epcInfo(epc, type);
                    epcList.Add(epcinfo);
                    if (id != null && id.Length > 0)
                    {
                        int          groupIndex = int.Parse(rows[i]["group"].ToString());
                        Carbinet     _carbinet  = this.groups[groupIndex];
                        DocumentFile df         = _carbinet.getDoc(id);
                        if (df != null)
                        {
                            df.setBackgroundImage(null);
                            df.setBorderWidth(0);
                            df.indexBase = "z" + df.columnNumber.ToString("0000");//重置为基础的排序依据
                        }
                    }

                    rows[i]["action"] = "normal";
                    rows[i]["epc"]    = "";
                    rows[i]["type"]   = "";
                    rows[i]["status"] = "empty";
                }

                //TODO 处于防盗模式下需要语音提醒,处于讲解模式下需要对产品进行讲解
                //if (staticClass.mode == MonitorMode.防盗模式)
                //{
                //    this.SpeakAboutSomething(epcList);
                //}
            }
            // 需要增加的
            rows = MemoryTable.unitTable.Select("action = 'add' OR action = 'addOnWrongFloor'");
            if (rows.Length > 0)
            {
                for (int i = 0; i < rows.Length; i++)
                {
                    int    groupIndex    = int.Parse(rows[i]["group"].ToString());
                    string id            = (string)rows[i]["id"];
                    string epc           = (string)rows[i]["epc"];
                    string action        = (string)rows[i]["action"];
                    bool   bOnWrongFloor = false;
                    if (action == "addOnWrongFloor")
                    {
                        bOnWrongFloor = true;
                    }
                    Carbinet _carbinet = this.groups[groupIndex];
                    // 不同种类的物品设置成不同的大小
                    string type = MemoryTable.getProductTypeID(epc);

                    DataRow[] drsType = MemoryTable.typeMapTable.Select("type='" + type + "'");
                    if (drsType.Length > 0)
                    {
                        int    width  = int.Parse(drsType[0]["width"].ToString());
                        int    height = int.Parse(drsType[0]["height"].ToString());
                        string path   = (string)drsType[0]["picname"];
                        path = PublicConfig.staticClass.PicturePath + path;
                        Image newImage = null;
                        try
                        {
                            newImage = Image.FromFile(path);
                        }
                        catch (System.Exception ex)
                        {
                            Debug.WriteLine(
                                string.Format("Form1._timer_Tick  -> loadImage error = {0}"
                                              , ex.Message));
                        }
                        DocumentFile df = _carbinet.getDoc(id);
                        if (df != null)
                        {
                            df.setBackgroundImage(newImage);
                            if (bOnWrongFloor == true)
                            {
                                df.setBorderWidth(5);
                            }
                            //df.setBorderWidth(0);//边框重置为0
                            df.indexBase = type;
                        }
                        //_carbinet.setDocBGImage(id, newImage);

                        _carbinet.setDocSize(id, width, height);

                        //drsType[0]["count"] = ((int)drsType[0]["count"]) + 1;
                    }
                    rows[i]["action"] = "normal";
                }
            }

            #endregion



            #region 设置饼图

            //
            DataRow[] typeRows = MemoryTable.typeMapTable.Select();
            decimal[] decimals = new decimal[typeRows.Length];
            string[]  strs     = new string[typeRows.Length];
            Color[]   colors   = new Color[typeRows.Length];
            for (int i = 0; i < typeRows.Length; i++)
            {
                DataRow[] RowsTemp = MemoryTable.unitTable.Select("type = '" + (string)typeRows[i]["type"] + "'");
                decimals[i]          = RowsTemp.Length;
                typeRows[i]["count"] = RowsTemp.Length;
                //                decimals[i] = (int)typeRows[i]["count"];
                strs[i] = RowsTemp.Length.ToString();
                //                strs[i] = typeRows[i]["count"].ToString();
                //strs[i] = typeRows[i]["productName"] + ":" + typeRows[i]["count"].ToString();
                colors[i] = Color.FromArgb(alpha,
                                           int.Parse(typeRows[i]["red"].ToString()),
                                           int.Parse(typeRows[i]["green"].ToString()),
                                           int.Parse(typeRows[i]["blue"].ToString()));
            }
            m_panelDrawing.Values = decimals;
            m_panelDrawing.Texts  = strs;
            m_panelDrawing.Colors = colors;

            #endregion
        }