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();
            this.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 = this.helper.getTagList();//先拿到读取到的标签

            if (tagList.Count <= 0)
            {
                return;
            }
            MemoryTable.remindTable.Rows.Clear();
            //首先把不再存在的标签从列表中删除
            //DataRow[] allRows = MemoryTable.remindTable.Select();
            //for (int j = 0; j < allRows.Length; j++)
            //{
            //    DataRow dr = allRows[j];
            //    string epc = (string)dr["epc"];
            //    if (epc != null && epc.Length > 0)
            //    {
            //        bool bFinded = false;
            //        foreach (TagInfo ti in tagList)
            //        {
            //            if (ti.epc == epc)
            //            {
            //                bFinded = true;
            //                break;
            //            }
            //        }
            //        if (bFinded == false)
            //        {
            //            dr["action"] = "delete";
            //        }
            //    }
            //}
            ////删除掉标识为 delete 的行
            //DataRow[] deletedRows = MemoryTable.remindTable.Select("action = 'delete'");
            //if (deletedRows.Length > 0)
            //{
            //    for (int i = 0; i < deletedRows.Length; i++)
            //    {
            //        MemoryTable.remindTable.Rows.Remove(deletedRows[i]);
            //    }
            //}

            // 添加新出现的标签到显示列表中
            for (int i = 0; i < tagList.Count; i++)
            {
                TagInfo ti  = tagList[i];
                string  epc = ti.epc;
                if (epc != null && epc.Length >= 23)
                {
                    string    type = epc.Substring(20, 2); //取得标签标识的产品类型
                    DataRow[] drs  = MemoryTable.remindTable.Select("epc='" + epc + "'");
                    if (drs.Length <= 0)                   //说明这个标签还不存在
                    {
                        DataRow[] unitTypeRows = MemoryTable.typeMapTable.Select("type = '" + type + "'");
                        if (unitTypeRows.Length > 0)
                        {
                            string productName = (string)unitTypeRows[0]["productName"];
                            MemoryTable.remindTable.Rows.Add(new object[] { epc, "add", type, productName });
                        }
                    }
                }
            }


            //计算每种产品的数量
            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.remindTable.Select("type = '" + (string)typeRows[i]["type"] + "'");
                decimals[i]          = RowsTemp.Length;
                typeRows[i]["count"] = RowsTemp.Length;
                strs[i] = RowsTemp.Length.ToString();
            }
            string strToSend        = "当前库存:";
            string strToSpeakOut    = "库存提醒:";
            bool   blackOfInventory = false;

            for (int i = 0; i < MemoryTable.typeMapTable.Rows.Count; i++)
            {
                //if (int.Parse(MemoryTable.typeMapTable.Rows[i]["count"].ToString()) > 0)
                //{
                DataRow dr  = MemoryTable.typeMapTable.Rows[i];
                string  tmp = string.Format("{0} :{1}", dr["productName"].ToString(), dr["count"].ToString());
                Debug.WriteLine(
                    string.Format("frmRemind._timer_Tick  -> {0}"
                                  , tmp));
                strToSend = strToSend + "    " + tmp;
                int minCount = int.Parse(dr["minCount"].ToString());
                int crtCount = int.Parse(dr["count"].ToString());
                if (minCount > crtCount)
                {
                    blackOfInventory = true;
                    strToSpeakOut    = strToSpeakOut + " " + dr["productName"].ToString() + " 缺货数量:" + (minCount - crtCount).ToString();
                }
                //}
            }

            string url = staticClass.addCommandInfo;

            if (blackOfInventory == true)
            {
                //CommandInfo ctts = new CommandInfo("tts", strToSpeakOut, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "192.168.0.98");
                //string jsonStringToSpeak = string.Empty;
                //jsonStringToSpeak = JSON.Instance.ToJSON(ctts);
                //HttpWebConnect helper1 = new HttpWebConnect();
                //helper1.RequestCompleted += new deleGetRequestObject(helper1_RequestCompleted);
                ////helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_addLedInfo);
                //helper1.TryPostData(url, jsonStringToSpeak);

                //strToSend = strToSpeakOut + " " + strToSend;

                backgroundWorker1.RunWorkerAsync(strToSpeakOut);
            }
            CreateGraph_Chart(this.zedGraphControl1);  //图表
            //LedInfo c = new LedInfo(strToSend, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "192.168.0.98");
            CommandInfo c          = new CommandInfo("led", strToSend, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "172.16.13.99");
            string      jsonString = string.Empty;

            jsonString = JSON.Instance.ToJSON(c);
            HttpWebConnect helper = new HttpWebConnect();

            //helper.RequestCompleted += new deleGetRequestObject(helper_RequestCompleted_addLedInfo);
            helper.TryPostData(url, jsonString);
            //if (this.InvokeRequired)
            //{
            //    deleControlInvokeNull dele = delegate()
            //    {
            //        CreateGraph_Chart(this.zedGraphControl1);  //图表
            //    };
            //    this.Invoke(dele);
            //}
            //else
            //{
            //    CreateGraph_Chart(this.zedGraphControl1);  //图表
            //}
        }
        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 = null;// 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
        }
        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 update_cabinet_data(UDPServer server, TDJ_RFIDHelper helper, int carbinet_index)
        {
            string carbinet_epc_flag = (carbinet_index + 1).ToString("D2");//  01 02

            server.Manualstate.WaitOne();
            server.Manualstate.Reset();
            string temp1 = server.sbuilder.ToString();

            server.sbuilder.Remove(0, temp1.Length);

            server.Manualstate.Set();

            //if (temp1 != null && temp1.Length >= 0)
            //{
            //this.txtLog.Text = str + "\r\n" + this.txtLog.Text;
            //Debug.WriteLine(
            //    string.Format(".  _timer_Tick -> string = {0}"
            //    , str));
            //}
            //处理列表
            List <TagInfo> tagList = helper.ParseDataToTag(temp1);

            #region 检查标签是否应该放在放在的正确的货架
            int count4InWrongCarbinet = 0;
            foreach (TagInfo 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


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


            //
            DataRow[] allRows = MemoryTable.unitTable.Select("group = " + carbinet_index.ToString());
            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 (TagInfo ti in tagList)
                    {
                        if ((ti.epc == epc) && (this.getFloorByAntennaID(ti.antennaID) == floor))//这里的不存在应该和位置相关
                        {
                            bFinded = true;
                            break;
                        }
                    }
                    if (bFinded == false)//如果列表中不再存在这个标签,就把之前标签占据的位置的状态设为delete
                    {
                        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) != carbinet_epc_flag)
                {
                    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() + " and group = " + carbinet_index.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() + " and group = " + carbinet_index.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
        }
Exemplo n.º 5
0
 private static bool IsJustThisEpcAndWrongAntena(TagInfo ti)
 {
     return(ti.epc == strEpc && ti.antennaID != "01" && ti.antennaID != "02" && ti.antennaID != "04" && ti.antennaID != "08");
 }
Exemplo n.º 6
0
        static string strEpc      = string.Empty;//作为一个中转而已

        private static bool IsThisEpc(TagInfo ti)
        {
            return(ti.epc == strEpc);
        }
        static string strEpc      = string.Empty;//作为一个中转而已

        private static bool IsThisEpcAndAntena(TagInfo ti)
        {
            return(ti.epc == strEpc && ti.antennaID == strAntenaID);
        }