void Form1_Shown(object sender, EventArgs e) { UDPServer.startUDPListening(); //this.InitialClassRoom(); this.InitializePanelControl(); //饼图添加图例 int initialTop = staticClass.getRealHeight(500); DataRow[] typeRows = MemoryTable.typeMapTable.Select(); for (int i = 0; i < typeRows.Length; i++, initialTop = initialTop + staticClass.getRealHeight(45)) { Button btnLegend = new Button(); btnLegend.FlatStyle = FlatStyle.Flat; btnLegend.FlatAppearance.BorderSize = 0; btnLegend.Width = staticClass.getRealWidth(70); btnLegend.Height = staticClass.getRealHeight(23); btnLegend.BackColor = Color.FromArgb(alpha, int.Parse(typeRows[i]["red"].ToString()), int.Parse(typeRows[i]["green"].ToString()), int.Parse(typeRows[i]["blue"].ToString())); btnLegend.Left = staticClass.getRealWidth(900); btnLegend.Top = initialTop; this.Controls.Add(btnLegend); this.legendButtonList.Add(btnLegend); Label lblLegend = new Label(); lblLegend.Left = staticClass.getRealWidth(990); lblLegend.Top = initialTop + 8; //this.lblLocation.Location = new System.Drawing.Point(855, initialTop + 5); lblLegend.Text = (string)typeRows[i]["productName"]; this.Controls.Add(lblLegend); this.legendLabelList.Add(lblLegend); } //在下拉列表中增加内容 for (int i = 0; i < typeRows.Length; i++) { this.cmbProductName.Items.Add((string)typeRows[i]["productName"]); } _timer.Enabled = true; }
void Form1_Shown(object sender, EventArgs e) { UDPServer.startUDPListening(); this.InitialClassRoom(); this.InitializePanelControl(); //饼图添加图例 int initialTop = 350; DataRow[] typeRows = MemoryTable.typeMapTable.Select(); for (int i = 0; i < typeRows.Length; i++, initialTop = initialTop + 40) { Button btnLegend = new Button(); btnLegend.FlatStyle = FlatStyle.Flat; btnLegend.FlatAppearance.BorderSize = 0; btnLegend.Width = 61; btnLegend.Height = 23; btnLegend.BackColor = Color.FromArgb(alpha, (int)typeRows[i]["red"], (int)typeRows[i]["green"], (int)typeRows[i]["blue"]); btnLegend.Left = 780; btnLegend.Top = initialTop; this.Controls.Add(btnLegend); this.legendButtonList.Add(btnLegend); Label lblLegend = new Label(); lblLegend.Left = 855; lblLegend.Top = initialTop + 5; lblLegend.Text = (string)typeRows[i]["productName"]; this.Controls.Add(lblLegend); this.legendLabelList.Add(lblLegend); } //在下拉列表中增加内容 for (int i = 0; i < typeRows.Length; i++) { this.cmbProductName.Items.Add((string)typeRows[i]["productName"]); } _timer.Enabled = true; }
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 }
void frmRemind_Shown(object sender, EventArgs e) { UDPServer.startUDPListening(); CreateGraph_Chart(this.zedGraphControl1); //图表 _timer.Enabled = true; }