562 lines
24 KiB
C#
562 lines
24 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Model;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
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 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;
|
|||
|
//}
|
|||
|
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;
|
|||
|
DNLights.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 manae_tran(string table, string ele_id, string little_ele_id, string order)
|
|||
|
{
|
|||
|
//Thread.Sleep(1000);
|
|||
|
Dal.ele_help sa = new Dal.ele_help();
|
|||
|
string sel = "select part,part_name,wave_order,line,order_by,sequeue from [dbo].[" + table + "]" +
|
|||
|
" WHERE state = '1' and ele_lab_id = '" + ele_id.ToString() + "' and ele_address = '" + little_ele_id.ToString() + "' and ele_order = '" + order + "'";
|
|||
|
|
|||
|
DataTable dt = sa.search_datatable(sel);
|
|||
|
if (dt.Rows.Count == 0)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
sel = "select part,line,order_by from [dbo].[" + table + "]" +
|
|||
|
" WHERE Pick_count <> send_count and state = '1' and part = '" + dt.Rows[0]["part"].ToString() + "' and line = '" + dt.Rows[0]["line"].ToString() + "' and sequeue = '" + dt.Rows[0]["sequeue"].ToString() + "'";
|
|||
|
DataTable dt1 = sa.search_datatable(sel);
|
|||
|
if (dt1.Rows.Count != 0)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
sel = "select part,line,order_by from [dbo].[" + table + "]" +
|
|||
|
" WHERE Pick_count <> send_count and state = '1' and part = '" + dt.Rows[0]["part"].ToString() + "' and line = '" + dt.Rows[0]["line"].ToString() + "'";
|
|||
|
dt1 = sa.search_datatable(sel);
|
|||
|
|
|||
|
if (dt1.Rows.Count != 0)
|
|||
|
{
|
|||
|
next_line(dt.Rows[0]["part"].ToString(), dt.Rows[0]["line"].ToString(), Convert.ToBoolean(dt.Rows[0]["order_by"].ToString()));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
string[] exe_str = new string[2];
|
|||
|
exe_str[0] = "update [tran] set state = '2' " +
|
|||
|
"where state = '1' and part = '" + dt.Rows[0]["part"].ToString() + "' and line = '" + dt.Rows[0]["line"].ToString() + "' and wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "'";
|
|||
|
exe_str[1] = "update [tran_m] set state = '2' " +
|
|||
|
"where state = '1' and part = '" + dt.Rows[0]["part"].ToString() + "' and line = '" + dt.Rows[0]["line"].ToString() + "' and wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "'";
|
|||
|
sa.exe_sql(exe_str);
|
|||
|
}
|
|||
|
}
|
|||
|
private void manae_pick_seed(string table, string ele_id, string little_ele_id, string order)
|
|||
|
{
|
|||
|
Dal.ele_help sa = new Dal.ele_help();
|
|||
|
string sel = "select part,part_name,wave_order from [dbo].[" + table + "]" +
|
|||
|
" WHERE state = '1' and ele_lab_id = '" + ele_id.ToString() + "' and ele_address = '" + little_ele_id.ToString() + "' and ele_order = '" + order + "'";
|
|||
|
|
|||
|
DataTable dt = sa.search_datatable(sel);
|
|||
|
if (dt.Rows.Count == 0)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
sel = "select part from [dbo].[" + table + "]" +
|
|||
|
" WHERE Pick_count <> send_count and part = '" + dt.Rows[0]["part"].ToString() + "' and wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "'";
|
|||
|
DataTable dt2 = sa.search_datatable(sel);
|
|||
|
if (dt2.Rows.Count == 0)
|
|||
|
{//处理完毕
|
|||
|
//on_dis_event(dt.Rows[0]["part_name"].ToString());
|
|||
|
string[] finish = new string[2];
|
|||
|
if (table == "pick")
|
|||
|
{
|
|||
|
finish[0] = "update pick set state = '2' where wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
finish[1] = "update pick_m set state = '2' where wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
sa.exe_sql(finish);
|
|||
|
return;
|
|||
|
}
|
|||
|
else if (table == "seed")
|
|||
|
{
|
|||
|
finish[0] = "update seed set state = '2' where wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
finish[1] = "update seed_m set state = '2' where wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
sa.exe_sql(finish);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
*/
|
|||
|
//public void return_data1()
|
|||
|
//{
|
|||
|
// string sql;
|
|||
|
// int ele_id;
|
|||
|
// int little_ele_id;
|
|||
|
// string receive_count;
|
|||
|
// string order;
|
|||
|
// Dal.ele_help sa = new Dal.ele_help();
|
|||
|
// while (ele_return_receive_address != ele_return_manage_address)
|
|||
|
// {
|
|||
|
// receive_count = receive_data_dot(Convert.ToInt16(ele_return_data[ele_return_manage_address].receive_count), Convert.ToInt16(ele_return_data[ele_return_manage_address].dot));
|
|||
|
// ele_id = Convert.ToInt16(ele_return_data[ele_return_manage_address].ele_id.ToString());
|
|||
|
// order = ele_return_data[ele_return_manage_address].order.ToString();
|
|||
|
// little_ele_id = Convert.ToInt16(ele_return_data[ele_return_manage_address].little_ele_id.ToString());
|
|||
|
// int state = elelab.pick.ele_lab[ele_id, little_ele_id];
|
|||
|
// if (state == 0)
|
|||
|
// {
|
|||
|
// table = "pick";
|
|||
|
// }
|
|||
|
// else if (state == 1)
|
|||
|
// {
|
|||
|
// table = "seed";
|
|||
|
// }
|
|||
|
// else if (state == 2)
|
|||
|
// {
|
|||
|
// table = "tran";
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// return;
|
|||
|
// }
|
|||
|
// sql = "UPDATE [dbo].[" + table + "] SET [Pick_count] = '" + receive_count + "',ele_lab_id = '" + ele_id.ToString() +
|
|||
|
// "',ele_address = '" + little_ele_id.ToString() + "',ele_order = '" + order + "',state = '1'" +
|
|||
|
// " WHERE state = '1' and ele_lab_id = '" + ele_id.ToString() + "' and ele_address = '" + little_ele_id.ToString() + "' and ele_order = '" + order + "'";
|
|||
|
// if (sa.exe_sql(sql) == true)
|
|||
|
// {
|
|||
|
// ele_return_manage_address++;
|
|||
|
// if (ele_return_manage_address >= ele_return_max)
|
|||
|
// {
|
|||
|
// ele_return_manage_address = 0;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// if(table == "tran")
|
|||
|
// {
|
|||
|
// manae_tran(table, ele_id.ToString(), little_ele_id.ToString(), order);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// manae_pick_seed(table,ele_id.ToString(),little_ele_id.ToString(),order);
|
|||
|
// }
|
|||
|
// //string sel = "select part,part_name,wave_order from [dbo].[" + table + "]" +
|
|||
|
// // " WHERE state = '1' and ele_lab_id = '" + ele_id.ToString() + "' and ele_address = '" + little_ele_id.ToString() + "' and ele_order = '" + order + "'";
|
|||
|
// //DataTable dt = sa.search_datatable(sel);
|
|||
|
// //if (dt.Rows.Count == 0)
|
|||
|
// //{
|
|||
|
// // continue;
|
|||
|
// //}
|
|||
|
// // sel = "select part from [dbo].[" + table + "]" +
|
|||
|
// // " WHERE Pick_count <> send_count and part = '" + dt.Rows[0]["part"].ToString() + "' and wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "'";
|
|||
|
// //DataTable dt2 = sa.search_datatable(sel);
|
|||
|
// // if (dt2.Rows.Count == 0)
|
|||
|
// // {//处理完毕
|
|||
|
// // //on_dis_event(dt.Rows[0]["part_name"].ToString());
|
|||
|
// // string[] finish = new string[2];
|
|||
|
// // if (table == "pick")
|
|||
|
// // {
|
|||
|
// // finish[0] = "update pick set state = '2' where wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
// // finish[1] = "update pick_m set state = '2' where wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
// // sa.exe_sql(finish);
|
|||
|
// // return;
|
|||
|
// // }
|
|||
|
// // else if (table == "seed")
|
|||
|
// // {
|
|||
|
// // finish[0] = "update seed set state = '2' where wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
// // finish[1] = "update seed_m set state = '2' where wave_order = '" + dt.Rows[0]["wave_order"].ToString() + "' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
// // sa.exe_sql(finish);
|
|||
|
// // return;
|
|||
|
// // }
|
|||
|
// // }
|
|||
|
// //string sale_order = "";
|
|||
|
// //if (table == "tran")
|
|||
|
// //{
|
|||
|
// // sel = "select part,line,order_by from [dbo].[" + table + "]" +
|
|||
|
// // " WHERE Pick_count <> send_count and state = '1' and part = '" + dt.Rows[0]["part"].ToString() + "'";
|
|||
|
// // dt = sa.search_datatable(sel);
|
|||
|
// // if (dt.Rows.Count != 0)
|
|||
|
// // {
|
|||
|
// // next_line(dt.Rows[0]["part"].ToString(), dt.Rows[0]["line"].ToString(), Convert.ToBoolean(dt.Rows[0]["order_by"].ToString()));
|
|||
|
// // }
|
|||
|
// // else
|
|||
|
// // {
|
|||
|
|
|||
|
// // }
|
|||
|
// //}
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
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;
|
|||
|
Console.WriteLine("......................................................");
|
|||
|
Console.WriteLine("1. received dis data " + receive_address);
|
|||
|
DNLights.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;
|
|||
|
// }
|
|||
|
|
|||
|
//}
|
|||
|
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 void write_reset_device()
|
|||
|
{
|
|||
|
dis_id id;
|
|||
|
id.order = 0;
|
|||
|
id.ele_id = 65535;
|
|||
|
id.state = 1;
|
|||
|
init_port.write_reset_device(id);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|