using System; using System.Collections.Generic; using System.Text; using System.Data; using ICommLayer; using DBFactory; using CommonClassLib; namespace SocketsTCPIP { /// /// 使用SocketsUDP的客户端进行通讯 /// 获得设备状态 /// 创建者:Richard.Liu /// public class CGetDeviceState:IGetDeviceState { string _commLayerError; public string CommLayerError { get { return _commLayerError; } set { _commLayerError = value; } } DBOperator dbo =CClientTCPIP.dbo; public CGetDeviceState() { dbo.Open(); } /// /// [T]:任务索引:20000-29000 ///[N]:节点索引 ///[N1]:取货点 ///[N2]:放货点 /// [R]:移载类型: ///0: 取货 ///1: 放货 ///[A]:LC的回复: /// 0:同意 /// 1:不同意 ///LC通知MAN任务开始执行63[T] ///LC通知MAN某AGV到位64[T][N][R] ///LC通知MAN移载开始65[T][N][R] ///LC通知MAN移载结束66[T][N][R] ///LC通知MAN移载暂停67[T][N][R] ///LC通知MAN移载恢复68[T][N][R] ///LC通知MAN AGV故障69[T][N][R] ///LC通知MAN任务结束70[T] ///LC通知MAN任务删除应答81[T][A] /// /// /// /// public int[] GetDeviceState(int DeviceIndex, int TaskIndex) { try { ////根据DeviceIndex,得到Sockets通讯的初始设置 //DataSet ds = dbo.ExceSQL("SELECT F_DeviceIndex,F_DeviceKindIndex, F_LocalIP, F_LocalPort, F_RemoteIP, F_RemotePort FROM T_Base_Device where F_DeviceIndex=" + DeviceIndex); //DataView dv = ds.Tables[0].DefaultView; //if (ds.Tables[0].DefaultView.Count == 0) //{ // return null; //} //int[] _IntData = new int[14]; //byte[] _GetData = new byte[4]; ////////////////////////////////////////// //_GetData = CClientTCPIP.Receive(dv[0]["F_RemoteIP"].ToString(), (int)dv[0]["F_RemotePort"]); //if (_GetData != null) //{ // ////////////////////////////////////// // if ((_GetData[0] == 70) && (Convert.ToInt32(_GetData[3] * Math.Pow(2, 8) + _GetData[2]) == TaskIndex)) // { // _IntData[1] = 1;//1-任务完成 // } // else if ((_GetData[0] == 71))//任务开始 // { // _IntData[1] = 3; // } // else if ((_GetData[0] == 69))//AGV故障 // { // _IntData[1] = 69; // } // //82 是否接受任务:1拒绝;0接受; // else if ((_GetData[2] ==0)&&(_GetData[0] == 82) && (Convert.ToInt32(_GetData[5] * Math.Pow(2, 8) + _GetData[4]) == TaskIndex))//AGV是否接受任务:0接受;1拒绝; // { // _IntData[0] = Convert.ToInt32(_GetData[3] * Math.Pow(2, 8) + _GetData[2]); // _IntData[1] = 3; // } // else //64,65,66,67,68 // { // _IntData[1] = 2;//2-报告坐标 // _IntData[3] = Convert.ToInt32(_GetData[5] * Math.Pow(2, 8) + _GetData[4]); // } // //_IntData[0] = 0;//实际值 // _IntData[2] = TaskIndex;//任务号 // _IntData[4] = 0; // _IntData[5] = DeviceIndex;// 设备号 // //cct.CloseSockets(); // return _IntData; //} //else //{ // //cct.CloseSockets(); // _commLayerError = "CClientTCPIP" + ":GetDeviceState---" + CClientTCPIP.TcpError; // return null; //} return null; } catch (Exception ex) { throw ex; } } public string GetStringData(int DeviceIndex, int TaskIndex) { return ""; } } }