| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using Model; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Windows.Forms; | 
					
						
							|  |  |  |  | using System.Threading; | 
					
						
							|  |  |  |  | //using Dal; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace Deiniu.win.elelab | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |    public class ease | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         internal elelab.dnwms init_port = new dnwms(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //internal static Thread pick_work; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //internal static uart_dis_data[] ele_return_data = new uart_dis_data[10000]; | 
					
						
							|  |  |  |  |         //internal static int ele_return_receive_address = 0; | 
					
						
							|  |  |  |  |         //internal static int ele_return_manage_address = 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal static bool receive_state = false; | 
					
						
							|  |  |  |  |         internal static string name = ""; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal int main_state = 0;//处理本分区的状态 0 空闲,等待新任务进入 1 正在读取数据 2 数据读取完毕,正在处理 3 预处理 如果发现有新数据,转入1 没有新数据转入0  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal uart_dis_data[] return_data = new uart_dis_data[10000]; | 
					
						
							|  |  |  |  |         internal int receive_address = 0; | 
					
						
							|  |  |  |  |         internal int manage_address = 0; | 
					
						
							|  |  |  |  |         internal int return_max = 10000; | 
					
						
							|  |  |  |  |         internal bool wait_data = false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //internal static int ele_return_max = 10000; | 
					
						
							|  |  |  |  |         //判断当前端口是否被使用 | 
					
						
							|  |  |  |  |         internal bool port_state = false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal event receive_data on_dis_event; | 
					
						
							|  |  |  |  |         internal delegate void receive_data(string result1); | 
					
						
							|  |  |  |  |         internal string table = "";//拣货  | 
					
						
							|  |  |  |  |         internal bool usart_send_state = true; | 
					
						
							|  |  |  |  |         internal string usart_send_result = ""; | 
					
						
							|  |  |  |  |         internal bool send_state_finish = true; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal void get_send_power() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             while (send_state_finish == false) ; | 
					
						
							|  |  |  |  |             send_state_finish = false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal void init(int com, bool write) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //test.port_event += new port.receive_data(ssss); | 
					
						
							|  |  |  |  |             //test.write_all_byte(); | 
					
						
							|  |  |  |  |             //test.init_wms_sys(1); | 
					
						
							|  |  |  |  |             init_port.init_wms_sys(com); | 
					
						
							|  |  |  |  |             port_state = true; | 
					
						
							|  |  |  |  |             init_port.check_state = write; | 
					
						
							|  |  |  |  |             init_port.on_dis_event += new dnwms.receive_dis_data(receive_dis_data); | 
					
						
							|  |  |  |  |             init_port.on_send_dis_result_event += new dnwms.send_dis_data_result(receive_dis_data_result); | 
					
						
							|  |  |  |  |             init_port.check_state = write; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         //internal static void init_pick() | 
					
						
							|  |  |  |  |         //{ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //    //为数据处理开辟线程 | 
					
						
							|  |  |  |  |         //    // Thread workTicketThread; | 
					
						
							|  |  |  |  |         //    //Thread workTicketThread; | 
					
						
							|  |  |  |  |         //    pick | 
					
						
							|  |  |  |  |         //    pick_work = new Thread(pick_sys); | 
					
						
							|  |  |  |  |         //    // Make this a background thread, so it will terminate when the main thread/process is de-activated | 
					
						
							|  |  |  |  |         //    pick_work.IsBackground = true; | 
					
						
							|  |  |  |  |         //    //pick_work.SetApartmentState(ApartmentState.STA); | 
					
						
							|  |  |  |  |         //    pick_work.SetApartmentState(ApartmentState.MTA); | 
					
						
							|  |  |  |  |         //    // Start the Work | 
					
						
							|  |  |  |  |         //    pick_work.Start(); | 
					
						
							|  |  |  |  |         //    //workerThreads[i] = workTicketThread; | 
					
						
							|  |  |  |  |         //} | 
					
						
							|  |  |  |  |         internal bool init(int com) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //test.init_wms_sys(1); | 
					
						
							|  |  |  |  |             if (init_port.init_wms_sys(com) == false) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             init_port.check_state = true; | 
					
						
							|  |  |  |  |             init_port.on_dis_event += new dnwms.receive_dis_data(receive_dis_data); | 
					
						
							|  |  |  |  |             init_port.on_send_dis_result_event += new dnwms.send_dis_data_result(receive_dis_data_result); | 
					
						
							|  |  |  |  |             init_port.check_state = true; | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         internal string return_test_state() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return init_port.test_state; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void get_data(string data, out int dot_station, out int total_num) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             data = Convert.ToDouble(data).ToString(); | 
					
						
							|  |  |  |  |             string[] count = data.Split('.');//Out_count | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             int full = Convert.ToInt16(count[0]); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             int dot_num; | 
					
						
							|  |  |  |  |             dot_station = 0; | 
					
						
							|  |  |  |  |             total_num = full; | 
					
						
							|  |  |  |  |             if (count.Length > 1) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 dot_num = Convert.ToInt16(count[1]); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 if (dot_num > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     if (dot_num < 10) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         total_num = full * 10 + dot_num; | 
					
						
							|  |  |  |  |                         dot_station = 1; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else if ((dot_num > 9) && (dot_num < 100)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         total_num = full * 100 + dot_num; | 
					
						
							|  |  |  |  |                         dot_station = 2; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else if ((dot_num > 99) && (dot_num < 1000)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         total_num = full * 1000 + dot_num; | 
					
						
							|  |  |  |  |                         dot_station = 3; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else if ((dot_num > 999) && (dot_num < 10000)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         total_num = full * 10000 + dot_num; | 
					
						
							|  |  |  |  |                         dot_station = 4; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         dot_station = 0; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal bool make_data(DataTable ds, byte led_color, byte ele_order_id, byte port, byte type) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //dt 列名 ele_lab_id  ele_address  Out_count | 
					
						
							|  |  |  |  |             //        电子标签id  控制的层列    数量 | 
					
						
							|  |  |  |  |             //led_color  灯的颜色 0 不亮 1 红灯 2 绿灯 3 蓝灯 4 红闪 5 绿闪 6 蓝闪 7红绿 8 红蓝 9 绿蓝 14红绿蓝 15 红绿蓝蜂鸣器 | 
					
						
							|  |  |  |  |             //ele_order_id  电子标签的订单号(电子标签使用)订单号范围 1-200  每个订单号有多条数据 控制器一次能处理多个订单号 | 
					
						
							|  |  |  |  |             //订单号唯一,一个订单号使用完毕,这个订单号才能被使用 | 
					
						
							|  |  |  |  |             //port 端口号  | 
					
						
							|  |  |  |  |             //DataTable ds = new DataTable(); | 
					
						
							|  |  |  |  |             if (ds != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (ds.Rows.Count == 0) | 
					
						
							|  |  |  |  |                     return false; | 
					
						
							|  |  |  |  |                 uart_dis_data[] ele_data_comment = new uart_dis_data[ds.Rows.Count]; | 
					
						
							|  |  |  |  |                 for (int j = 0; j < ds.Rows.Count; j++) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ele_data_comment[j].channel_id = 0;//暂不使用 默认为0 | 
					
						
							|  |  |  |  |                     ele_data_comment[j].dis_type = Convert.ToByte(ds.Rows[j]["color"].ToString()); ;// 灯的颜色 0 不亮 1 红灯 2 绿灯 3 蓝灯 4 红闪 5 绿闪 6 蓝闪  | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     ele_data_comment[j].ele_id = Convert.ToInt16(ds.Rows[j]["ele_lab_id"].ToString()); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                     ele_data_comment[j].kucun_id = 0; | 
					
						
							|  |  |  |  |                     ele_data_comment[j].little_ele_id = Convert.ToByte(ds.Rows[j]["ele_address"].ToString()); | 
					
						
							|  |  |  |  |                     ele_data_comment[j].order = Convert.ToByte(ele_order_id); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     ele_data_comment[j].port = "1"; | 
					
						
							|  |  |  |  |                     ele_data_comment[j].receive_count = 0; | 
					
						
							|  |  |  |  |                     int dot_station; | 
					
						
							|  |  |  |  |                     int total_num; | 
					
						
							|  |  |  |  |                     string[] count = ds.Rows[j]["send_count"].ToString().Split('.');//Out_count | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     get_data(ds.Rows[j]["send_count"].ToString(), out dot_station, out total_num); | 
					
						
							|  |  |  |  |                     //string[] count = ds.Rows[j]["send_count"].ToString().Split('.');//Out_count | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     //total_num = Convert.ToInt16(count[0]); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                     ele_data_comment[j].send_count = total_num;//.ToString()); | 
					
						
							|  |  |  |  |                     ele_data_comment[j].dot = Convert.ToByte(dot_station); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     ele_data_comment[j].WarehousingID = 0; | 
					
						
							|  |  |  |  |                     light.ele_lab[ele_data_comment[j].ele_id, ele_data_comment[j].little_ele_id] = type; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 }// //向串口发送数据 | 
					
						
							|  |  |  |  |                 clear_order order = new clear_order(); | 
					
						
							|  |  |  |  |                 order.order = Convert.ToByte(ele_order_id); | 
					
						
							|  |  |  |  |                 order.state = 1; | 
					
						
							|  |  |  |  |                 if (coms.com_manage[port].clear_order(order) == false) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     //MessageBox.Show("clear fail"); | 
					
						
							|  |  |  |  |                     return false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 //elelab.ele_base.usart_send_state = false; //ele .usart_send_state = false; | 
					
						
							|  |  |  |  |                 while (coms.com_manage[port].send_state_finish == false) ; | 
					
						
							|  |  |  |  |                 coms.com_manage[port].send_state_finish = false; | 
					
						
							|  |  |  |  |                 coms.com_manage[port].usart_send_state = false; | 
					
						
							|  |  |  |  |                 coms.com_manage[port].usart_send_result = ""; | 
					
						
							|  |  |  |  |                 if (coms.com_manage[port].write_data(ele_data_comment) == false) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     coms.com_manage[port].send_state_finish = true; | 
					
						
							|  |  |  |  |                     coms.com_manage[port].usart_send_state = true; | 
					
						
							|  |  |  |  |                     coms.com_manage[port].usart_send_result = ""; | 
					
						
							|  |  |  |  |                     return false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 string result; | 
					
						
							|  |  |  |  |                 return coms.com_manage[port].wait_ack(out result); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private static byte get_byte(string data) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             int length = data.Length; | 
					
						
							|  |  |  |  |             List<string> str = new List<string>(); | 
					
						
							|  |  |  |  |             for (int i = 0; i < length; i++) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string result = data.Substring(i, 1); | 
					
						
							|  |  |  |  |                 char aaaq = Convert.ToChar(result); | 
					
						
							|  |  |  |  |                 if ((aaaq >= 0x30) && (aaaq <= 0x39)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     str.Add(data.Substring(i, 1)); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (str.Count == 1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return Convert.ToByte(str[0]); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (str.Count == 2) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 int len = Convert.ToInt16(str[0]); | 
					
						
							|  |  |  |  |                 int len1 = Convert.ToInt16(str[1]); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 len = len * 10 + len1; | 
					
						
							|  |  |  |  |                 return Convert.ToByte(len); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (str.Count == 3) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 int len = Convert.ToInt16(str[0]); | 
					
						
							|  |  |  |  |                 int len1 = Convert.ToInt16(str[1]); | 
					
						
							|  |  |  |  |                 int len2 = Convert.ToInt16(str[2]); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 len = len * 100 + len1 * 10 + len2; | 
					
						
							|  |  |  |  |                 return Convert.ToByte(len); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return 0; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private bool send_data(DataTable[] ds, byte byt) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             for (int j = 0; j < ds.Length; j++) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 //string part = ; | 
					
						
							|  |  |  |  |                 byte part_byte = get_byte(ds[j].Rows[0]["part"].ToString()); | 
					
						
							|  |  |  |  |                 string port = ds[j].Rows[0]["port"].ToString(); | 
					
						
							|  |  |  |  |                 byte port_byte = get_byte(port); | 
					
						
							|  |  |  |  |                 byte led_color = get_byte(ds[j].Rows[0]["color"].ToString()); | 
					
						
							|  |  |  |  |                 elelab.light.make_data(ds[j], led_color, part_byte, port_byte, null, null, null, byt); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private string receive_data_dot(int count, int dot_station) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string result = "0"; | 
					
						
							|  |  |  |  |             if (dot_station == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 result = count.ToString(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (dot_station == 1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 result = (count / 10).ToString() + "." + (count % 10).ToString(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (dot_station == 2) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 result = (count / 100).ToString() + "." + (count % 100).ToString(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else if (dot_station == 3) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 result = (count / 1000).ToString() + "." + (count % 1000).ToString(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return result; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |        | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void next_line(string part, string line, bool order) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             // string sql =  "select * from tran where part = '" + part+"' and line = '" + line +"'";//sequeue | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |           //  WMSServiceDemo.WebApp.bll ss = new WMSServiceDemo.WebApp.bll(); | 
					
						
							|  |  |  |  |             //Bll.ele.ele_lab ss = new Bll.ele.ele_lab(); | 
					
						
							|  |  |  |  |             //DataTable[] ds = ss.get_tran_data(part, line, order); | 
					
						
							|  |  |  |  |             //send_data(ds, 2); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         private void receive_dis_data(uart_dis_data[] data) | 
					
						
							|  |  |  |  |         {//接收串口发来的数据 | 
					
						
							|  |  |  |  |             if (data.Length == 1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 uart_dis_data cc = data[0]; | 
					
						
							|  |  |  |  |                 return_data[receive_address] = cc; | 
					
						
							|  |  |  |  |                 receive_address++; | 
					
						
							|  |  |  |  |                 if (receive_address >= return_max) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     receive_address = 0; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 init_port.receive_state_finish = true; | 
					
						
							|  |  |  |  |                 init_port.receive_state = true; | 
					
						
							|  |  |  |  |                 wait_data = true; | 
					
						
							|  |  |  |  |                 light.wake_thread(); | 
					
						
							|  |  |  |  |                 lightPart.wake_thread(); | 
					
						
							|  |  |  |  |                 lightSeeds.wake_thread(); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         //private void receive_dis_data(uart_dis_data[] data) | 
					
						
							|  |  |  |  |         //{//接收串口发来的数据 | 
					
						
							|  |  |  |  |         //    if (data.Length == 1) | 
					
						
							|  |  |  |  |         //    { | 
					
						
							|  |  |  |  |         //        uart_dis_data cc = data[0]; | 
					
						
							|  |  |  |  |         //        ele_return_data[ele_return_receive_address] = cc; | 
					
						
							|  |  |  |  |         //        ele_return_receive_address++; | 
					
						
							|  |  |  |  |         //        if (ele_return_receive_address >= ele_return_max) | 
					
						
							|  |  |  |  |         //        { | 
					
						
							|  |  |  |  |         //            ele_return_receive_address = 0; | 
					
						
							|  |  |  |  |         //        } | 
					
						
							|  |  |  |  |         //        init_port.receive_state_finish = true; | 
					
						
							|  |  |  |  |         //        init_port.receive_state = true; | 
					
						
							|  |  |  |  |         //        pick.wake_thread(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //        return; | 
					
						
							|  |  |  |  |         //    } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //} | 
					
						
							|  |  |  |  |         internal void receive_dis_data_result(byte order, byte resul, string result) | 
					
						
							|  |  |  |  |         {//接收串口发来的结果 | 
					
						
							|  |  |  |  |             usart_send_result = result; | 
					
						
							|  |  |  |  |             usart_send_state = true; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         internal bool wait_ack(out string result) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             //result = ""; | 
					
						
							|  |  |  |  |             //send_state_finish = true; | 
					
						
							|  |  |  |  |             //return true; | 
					
						
							|  |  |  |  |             Int64 count = 0; | 
					
						
							|  |  |  |  |             do | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                  Thread.Sleep(1); | 
					
						
							|  |  |  |  |                 if (usart_send_state == true) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     result = usart_send_result; | 
					
						
							|  |  |  |  |                     if (usart_send_result == "执行成功") | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         send_state_finish = true; | 
					
						
							|  |  |  |  |                         return true; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     send_state_finish = true; | 
					
						
							|  |  |  |  |                     return false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 count++; | 
					
						
							|  |  |  |  |             } while (count < 4000); | 
					
						
							|  |  |  |  |             result = "电子标签没有应答"; | 
					
						
							|  |  |  |  |             send_state_finish = true; | 
					
						
							|  |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal void exit() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             init_port.exit_wms_sys(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         internal bool write_data(uart_dis_data[] data) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (data.Length > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return init_port.write_dis_comment(data); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         internal bool clear_order(clear_order data) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return init_port.clear_order(data); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal bool write_reset_device() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             dis_id id; | 
					
						
							|  |  |  |  |             id.order = 0; | 
					
						
							|  |  |  |  |             id.ele_id = 65535; | 
					
						
							|  |  |  |  |             id.state = 1; | 
					
						
							|  |  |  |  |           return  init_port.write_reset_device(id); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal void displayLabel() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             dis_id id; | 
					
						
							|  |  |  |  |             id.order = 0; | 
					
						
							|  |  |  |  |             id.ele_id = 65535; | 
					
						
							|  |  |  |  |             id.state = 1; | 
					
						
							|  |  |  |  |             init_port.write_dis_id_comment(id); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         internal void clearLabel() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             dis_id id; | 
					
						
							|  |  |  |  |             id.order = 0; | 
					
						
							|  |  |  |  |             id.ele_id = 65535; | 
					
						
							|  |  |  |  |             id.state = 1; | 
					
						
							|  |  |  |  |             init_port.write_clear_comment(id); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |