379 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			379 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								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 elelab
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								   public class ele_base
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        public elelab.dnwms init_port = new dnwms();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //public static Thread pick_work;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //public static uart_dis_data[] ele_return_data = new uart_dis_data[10000];
							 | 
						|||
| 
								 | 
							
								        //public static int ele_return_receive_address = 0;
							 | 
						|||
| 
								 | 
							
								        //public static int ele_return_manage_address = 0;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public static bool receive_state = false;
							 | 
						|||
| 
								 | 
							
								        public static string name = "";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public int main_state = 0;//处理本分区的状态 0 空闲,等待新任务进入 1 正在读取数据 2 数据读取完毕,正在处理 3 预处理 如果发现有新数据,转入1 没有新数据转入0 
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public uart_dis_data[] return_data = new uart_dis_data[10000];
							 | 
						|||
| 
								 | 
							
								        public int receive_address = 0;
							 | 
						|||
| 
								 | 
							
								        public int manage_address = 0;
							 | 
						|||
| 
								 | 
							
								        public int return_max = 10000;
							 | 
						|||
| 
								 | 
							
								        public bool wait_data = false;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        //public static int ele_return_max = 10000;
							 | 
						|||
| 
								 | 
							
								        //判断当前端口是否被使用
							 | 
						|||
| 
								 | 
							
								        public bool port_state = false;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public event receive_data on_dis_event;
							 | 
						|||
| 
								 | 
							
								        public delegate void receive_data(string result1);
							 | 
						|||
| 
								 | 
							
								        public string table = "";//拣货 
							 | 
						|||
| 
								 | 
							
								        public bool usart_send_state = true;
							 | 
						|||
| 
								 | 
							
								        public string usart_send_result = "";
							 | 
						|||
| 
								 | 
							
								        public bool send_state_finish = true;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public void get_send_power()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            while (send_state_finish == false) ;
							 | 
						|||
| 
								 | 
							
								            send_state_finish = false;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public 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;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        public 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;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public 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
							 | 
						|||
| 
								 | 
							
								            int full = Convert.ToInt16(count[0]);
							 | 
						|||
| 
								 | 
							
								            int dot_num;
							 | 
						|||
| 
								 | 
							
								            dot_station = 0;
							 | 
						|||
| 
								 | 
							
								            total_num = full;
							 | 
						|||
| 
								 | 
							
								            if (count.Length > 1)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                dot_num = Convert.ToInt16(count[1]);
							 | 
						|||
| 
								 | 
							
								                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;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public 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 蓝闪 
							 | 
						|||
| 
								 | 
							
								                    ele_data_comment[j].ele_id = Convert.ToInt16(ds.Rows[j]["ele_lab_id"].ToString());
							 | 
						|||
| 
								 | 
							
								                    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
							 | 
						|||
| 
								 | 
							
								                    //total_num = Convert.ToInt16(count[0]);
							 | 
						|||
| 
								 | 
							
								                    ele_data_comment[j].send_count = total_num;//.ToString());
							 | 
						|||
| 
								 | 
							
								                    ele_data_comment[j].dot = Convert.ToByte(dot_station);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                    ele_data_comment[j].WarehousingID = 0;
							 | 
						|||
| 
								 | 
							
								                    pick.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 (unart_manage.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 (unart_manage.com_manage[port].send_state_finish == false) ;
							 | 
						|||
| 
								 | 
							
								                unart_manage.com_manage[port].send_state_finish = false;
							 | 
						|||
| 
								 | 
							
								                unart_manage.com_manage[port].usart_send_state = false;
							 | 
						|||
| 
								 | 
							
								                unart_manage.com_manage[port].usart_send_result = "";
							 | 
						|||
| 
								 | 
							
								                if (unart_manage.com_manage[port].write_data(ele_data_comment) == false)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    unart_manage.com_manage[port].send_state_finish = true;
							 | 
						|||
| 
								 | 
							
								                    unart_manage.com_manage[port].usart_send_state = true;
							 | 
						|||
| 
								 | 
							
								                    unart_manage.com_manage[port].usart_send_result = "";
							 | 
						|||
| 
								 | 
							
								                    return false;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                string result;
							 | 
						|||
| 
								 | 
							
								                return unart_manage.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)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                int len = Convert.ToInt16(str[0]);
							 | 
						|||
| 
								 | 
							
								                int len1 = Convert.ToInt16(str[1]);
							 | 
						|||
| 
								 | 
							
								                len = len * 10 + len1;
							 | 
						|||
| 
								 | 
							
								                return Convert.ToByte(len);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else if (str.Count == 3)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                int len = Convert.ToInt16(str[0]);
							 | 
						|||
| 
								 | 
							
								                int len1 = Convert.ToInt16(str[1]);
							 | 
						|||
| 
								 | 
							
								                int len2 = Convert.ToInt16(str[2]);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                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.pick.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)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								             
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        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;
							 | 
						|||
| 
								 | 
							
								                pick.wake_thread();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        public void receive_dis_data_result(byte order, byte resul, string result)
							 | 
						|||
| 
								 | 
							
								        {//接收串口发来的结果
							 | 
						|||
| 
								 | 
							
								            usart_send_result = result;
							 | 
						|||
| 
								 | 
							
								            usart_send_state = true;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public 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;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public void exit()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            init_port.exit_wms_sys();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public bool write_data(uart_dis_data[] data)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (data.Length > 0)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return init_port.write_dis_comment(data);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            return false;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public bool clear_order(clear_order data)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            return init_port.clear_order(data);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public bool write_reset_device()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            dis_id id;
							 | 
						|||
| 
								 | 
							
								            id.order = 0;
							 | 
						|||
| 
								 | 
							
								            id.ele_id = 65535;
							 | 
						|||
| 
								 | 
							
								            id.state = 1;
							 | 
						|||
| 
								 | 
							
								           return init_port.write_reset_device(id);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public void displayLabel()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            dis_id id;
							 | 
						|||
| 
								 | 
							
								            id.order = 0;
							 | 
						|||
| 
								 | 
							
								            id.ele_id = 65535;
							 | 
						|||
| 
								 | 
							
								            id.state = 1;
							 | 
						|||
| 
								 | 
							
								            init_port.write_dis_id_comment(id);
							 | 
						|||
| 
								 | 
							
								           
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public void clearLabel()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            dis_id id;
							 | 
						|||
| 
								 | 
							
								            id.order = 0;
							 | 
						|||
| 
								 | 
							
								            id.ele_id = 65535;
							 | 
						|||
| 
								 | 
							
								            id.state = 1;
							 | 
						|||
| 
								 | 
							
								            init_port.write_clear_comment(id);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public bool turnOnLight(channel_led id_data)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								           return init_port.write_open_channel_led(id_data);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        public bool turnOffLight(channel_led id_data)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								           return init_port.write_close_channel_led(id_data);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public bool configLightColor(config_channel_led id_data)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								           return init_port.write_config_channel_led(id_data);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |