You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2987 lines
144 KiB
2987 lines
144 KiB
3 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
using System.Threading;
|
||
|
using System.Net;
|
||
|
using System.Net.Sockets;
|
||
|
using System.Data.SqlClient;
|
||
|
using CommonLib;
|
||
|
using DBFactory;
|
||
|
using System.Data;
|
||
|
namespace WcfControlMonitorLib
|
||
|
{
|
||
|
static class CGeneralFunction
|
||
|
{
|
||
|
static StringBuilder sql = new StringBuilder();
|
||
|
static DBOperator dbo = CListenAGVState.dbo;
|
||
|
|
||
|
/// <summary>
|
||
|
/// �������������Ƿ���ͬ������
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static bool DoubleForkIfSync(int monitorIndex, int devIndex, int devKind)
|
||
|
{//���ҹ����ĵ������������������߸����������ͻ����Ѷ��������Դ�
|
||
|
//����ֻ���ҵ���������δ�����֣���ô��Ϊ��ͬ������20100323
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(monitorIndex);
|
||
|
int FID = GetManageTaskIndexfromMonitor(monitorIndex);
|
||
|
int devOrder = GetDeviceOrderFromMonitor(monitorIndex);
|
||
|
int dfx = GetDoubleForkX(mankind, FID, devIndex, devOrder);
|
||
|
int mx = GetXCoorFromMonitor(monitorIndex, devIndex, devOrder);
|
||
|
int dfy = GetDoubleForkY(mankind, FID, devIndex, devOrder);
|
||
|
int my = GetYCoorFromMonitor(monitorIndex, devIndex, devOrder);
|
||
|
int dfz = GetDoubleForkZ(mankind, FID, devIndex, devOrder);
|
||
|
int mz = GetZCoorFromMonitor(monitorIndex, devIndex, devOrder);
|
||
|
if (GetDoubleForkUnIntoStep(monitorIndex) == true) return true;
|
||
|
|
||
|
switch (devKind)
|
||
|
{
|
||
|
case 1:
|
||
|
//��������������������������1�У�����1121��1122��������������ͬ��
|
||
|
if (1 == GetDoubleForkX(mankind, FID, devIndex, devOrder) && (GetXCoorFromMonitor(monitorIndex, devIndex, devOrder) == 1))
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
//�Ѷ�����ͬ�ţ�ͬ�㣬���п���ͬ������ST_CELL��FDoubleForkֵƥ��
|
||
|
|
||
|
|
||
|
if ((Math.Abs(dfx - mx) == 1) && (dfy == my) && (mz == dfz))
|
||
|
{
|
||
|
if (EqualMonitorDoubleFork(mankind, FID, devIndex, devOrder) == true)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
case 2:
|
||
|
//���ͻ�ͬ��
|
||
|
return true;
|
||
|
case 6:
|
||
|
//AGV���п���ͬ������ST_CELL��F_UseAwayForkֵƥ��
|
||
|
|
||
|
|
||
|
if (Math.Abs(dfx - mx) == 1)
|
||
|
{
|
||
|
if (EqualAGVGateDoubleFork(mankind, FID, devIndex, devOrder) == true)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
default:
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ����˫�����ƵĶѶ������ͻ��������Ѿ�����Զ�������߽�����������ֵ
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetUseAwayFork(int monitorIndex)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_UseAwayFork FROM T_Monitor_Task WHERE (F_MonitorIndex = " ).Append( monitorIndex ).Append( ")");
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return dv[0][0].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "-";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��ȡ˫�����ƵĶѶ�����ȡ����������δָ��Ӧ��ʹ���ĸ����棩�Ƿ�ʹ��Զ���棨�����棩��0�������棻1Զ����
|
||
|
/// </summary>
|
||
|
/// <param name="z">��</param>
|
||
|
/// <param name="x">��</param>
|
||
|
/// <param name="y">��</param>
|
||
|
/// <param name="FWAREHOUSE">�ⷿ����</param>
|
||
|
/// <param name="Mankind">��������</param>
|
||
|
/// <param name="ManFID">������������</param>
|
||
|
/// <param name="devIndex">�豸����</param>
|
||
|
/// <param name="devOrder">ָ��</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetUseAwayFork(int monitorIndex, int devIndex, int devOrder)
|
||
|
{
|
||
|
int z = GetZCoorFromMonitor(monitorIndex, devIndex, devOrder);
|
||
|
int x = GetXCoorFromMonitor(monitorIndex, devIndex, devOrder);
|
||
|
int y = GetYCoorFromMonitor(monitorIndex, devIndex, devOrder);
|
||
|
|
||
|
string FWAREHOUSE = GetWAREHOUSEFromSTCELL(devIndex);
|
||
|
int Mankind = GetManageTaskKindIndexFromMonitor(monitorIndex);
|
||
|
int ManFID = GetManageTaskIndexfromMonitor(monitorIndex);
|
||
|
|
||
|
DataView dv; int UseAwayFork = 1;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FDoubleFork FROM ST_CELL WHERE (FWAREHOUSE='" ).Append( FWAREHOUSE
|
||
|
).Append( "') and (F_Z = " ).Append( z ).Append( ") AND (F_X = " ).Append( x ).Append( ") AND (F_Y = " ).Append( y ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
UseAwayFork = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = 0;
|
||
|
}
|
||
|
switch (UseAwayFork)
|
||
|
{
|
||
|
case 0://�����κ�һ������:
|
||
|
int xcoor = GetDoubleForkX(Mankind, ManFID, devIndex, devOrder);
|
||
|
if (xcoor != -1)
|
||
|
{
|
||
|
//���ݹ��������Ļ�λ�ж�ʹ�ý����棨������С������Զ���棨����������
|
||
|
if (xcoor != x)
|
||
|
{
|
||
|
if (xcoor < x)
|
||
|
{
|
||
|
UseAwayFork = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = 0;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//��������ͬ�ģ��жϲ����꣬�����棨������С������Զ���棨����������
|
||
|
int ycoor = GetDoubleForkY(Mankind, ManFID, devIndex, devOrder);
|
||
|
if (ycoor != -1)
|
||
|
{
|
||
|
if (ycoor != y)
|
||
|
{
|
||
|
if (ycoor < y)
|
||
|
{
|
||
|
UseAwayFork = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = 0;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//�кͲ㶼��ͬ�ģ��ж������꣬�����棨������С������Զ���棨����������
|
||
|
int zcoor = GetDoubleForkZ(Mankind, ManFID, devIndex, devOrder);
|
||
|
if (zcoor != -1)
|
||
|
{
|
||
|
if (zcoor != z)
|
||
|
{
|
||
|
if (zcoor < z)
|
||
|
{
|
||
|
UseAwayFork = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = 1;
|
||
|
}
|
||
|
break;
|
||
|
case 1://ֻ���ý���
|
||
|
UseAwayFork = 0;
|
||
|
break;
|
||
|
case 2://ֻ����Զ��
|
||
|
UseAwayFork = 1;
|
||
|
break;
|
||
|
}
|
||
|
return UseAwayFork;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int GetDoubleForkFromST_CELL(int z, int x, int y, string FWAREHOUSE)
|
||
|
{
|
||
|
DataView dv; int UseAwayFork = 1;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FDoubleFork FROM ST_CELL WHERE (FWAREHOUSE='" ).Append( FWAREHOUSE
|
||
|
).Append( "') and (F_Z = " ).Append( z ).Append( ") AND (F_X = " ).Append( x ).Append( ") AND (F_Y = " ).Append( y ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
UseAwayFork = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = 0;
|
||
|
}
|
||
|
|
||
|
return UseAwayFork;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
public static string GetWAREHOUSEFromSTCELL(int stackIndex)
|
||
|
{
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FWAREHOUSE FROM ST_CELL WHERE (FStack = " ).Append( stackIndex ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return dv[0][0].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "";
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally { dv = null; }
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���Ҷ�������������������
|
||
|
/// </summary>
|
||
|
/// <param name="mankind">��������</param>
|
||
|
/// <param name="fid">������������</param>
|
||
|
/// <param name="devIdx">�豸����</param>
|
||
|
/// <param name="devOrder">�豸ָ��</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetDoubleForkX(int mankind, int fid, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv;
|
||
|
string xc = "F_NumParam2";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4)
|
||
|
{
|
||
|
xc = "F_NumParam2";
|
||
|
}
|
||
|
else if (devOrder == 5)
|
||
|
{
|
||
|
xc = "F_NumParam5";
|
||
|
}
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
//���ұ����������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( xc ).Append( " FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.F_RELATIVECONTORLID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][xc]);
|
||
|
}
|
||
|
|
||
|
//���ҹ����Լ������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( xc ).Append( " FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][xc]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���Ҷ������������IJ�����
|
||
|
/// </summary>
|
||
|
/// <param name="mankind">��������</param>
|
||
|
/// <param name="fid">������������</param>
|
||
|
/// <param name="devIdx">�豸����</param>
|
||
|
/// <param name="devOrder">�豸ָ��</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetDoubleForkY(int mankind, int fid, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv;
|
||
|
string yc = "F_NumParam3";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4)
|
||
|
{
|
||
|
yc = "F_NumParam3";
|
||
|
}
|
||
|
else if (devOrder == 5)
|
||
|
{
|
||
|
yc = "F_NumParam6";
|
||
|
}
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
//���ұ����������豸ָ�������IJ�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( yc ).Append( " FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.F_RELATIVECONTORLID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][yc]);
|
||
|
}
|
||
|
|
||
|
//���ҹ����Լ������豸ָ�������IJ�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( yc ).Append( " FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
;
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][yc]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���Ҷ�������������������
|
||
|
/// </summary>
|
||
|
/// <param name="mankind">��������</param>
|
||
|
/// <param name="fid">������������</param>
|
||
|
/// <param name="devIdx">�豸����</param>
|
||
|
/// <param name="devOrder">�豸ָ��</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetDoubleForkZ(int mankind, int fid, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv;
|
||
|
string zc = "F_NumParam1";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4)
|
||
|
{
|
||
|
zc = "F_NumParam1";
|
||
|
}
|
||
|
else if (devOrder == 5)
|
||
|
{
|
||
|
zc = "F_NumParam4";
|
||
|
}
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
//���ұ����������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( zc ).Append( " FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.F_RELATIVECONTORLID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][zc]);
|
||
|
}
|
||
|
|
||
|
//���ҹ����Լ������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( zc ).Append( " FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][zc]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���Ҷ�������������ST_CELL����ʹ���ĸ����������Ƿ���ͬ
|
||
|
/// </summary>
|
||
|
/// <param name="mankind">��������</param>
|
||
|
/// <param name="fid">������������</param>
|
||
|
/// <param name="devIdx">�豸����</param>
|
||
|
/// <param name="devOrder">�豸ָ��</param>
|
||
|
/// <returns></returns>
|
||
|
public static bool EqualMonitorDoubleFork(int mankind, int fid, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv; char DoubleFork = '0', DoubleFork1 = '0';
|
||
|
string xc = "F_NumParam2"; string yc = "F_NumParam3"; string zc = "F_NumParam1";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if ((devOrder == 4) || (devOrder == 2))
|
||
|
{
|
||
|
xc = "F_NumParam2";
|
||
|
yc = "F_NumParam3";
|
||
|
zc = "F_NumParam1";
|
||
|
}
|
||
|
else if ((devOrder == 5) || (devOrder == 3))
|
||
|
{
|
||
|
xc = "F_NumParam5";
|
||
|
yc = "F_NumParam6";
|
||
|
zc = "F_NumParam4";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
try
|
||
|
{
|
||
|
|
||
|
int z = 0, x = 0, y = 0, z1 = 0, x1 = 0, y1 = 0;
|
||
|
//���ұ����������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( zc ).Append( "," ).Append( xc ).Append( "," ).Append( yc ).Append( ",F_UseAwayFork FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.F_RELATIVECONTORLID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
z = Convert.ToInt32(dv[0][zc]);
|
||
|
x = Convert.ToInt32(dv[0][xc]);
|
||
|
y = Convert.ToInt32(dv[0][yc]);
|
||
|
DoubleFork = Convert.ToChar(dv[0]["F_UseAwayFork"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//���ҹ����Լ������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( zc ).Append( "," ).Append( xc ).Append( "," ).Append( yc ).Append( ",F_UseAwayFork FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
;
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
z = Convert.ToInt32(dv[0][zc]);
|
||
|
x = Convert.ToInt32(dv[0][xc]);
|
||
|
y = Convert.ToInt32(dv[0][yc]);
|
||
|
DoubleFork = Convert.ToChar(dv[0]["F_UseAwayFork"]);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if ((z == 0) && (x == 0) && (y == 0))
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( zc ).Append( "," ).Append( xc ).Append( "," ).Append( yc ).Append( ",F_UseAwayFork FROM T_Monitor_Task Where ( F_ManageTASKKINDINDEX = " ).Append( mankind ).Append( ") AND (F_ManageTaskIndex = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
z1 = Convert.ToInt32(dv[0][zc]);
|
||
|
x1 = Convert.ToInt32(dv[0][xc]);
|
||
|
y1 = Convert.ToInt32(dv[0][yc]);
|
||
|
DoubleFork1 = Convert.ToChar(dv[0]["F_UseAwayFork"]);
|
||
|
if (((x1 > x) && (DoubleFork1 > DoubleFork)) || ((x > x1) && (DoubleFork > DoubleFork1)))
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���Ҷ�������������T_Base_AGV_Gate���Ļ��������Ƿ�ƥ��
|
||
|
/// </summary>
|
||
|
/// <param name="mankind">��������</param>
|
||
|
/// <param name="fid">������������</param>
|
||
|
/// <param name="devIdx">�豸����</param>
|
||
|
/// <param name="devOrder">�豸ָ��</param>
|
||
|
/// <returns></returns>
|
||
|
public static bool EqualAGVGateDoubleFork(int mankind, int fid, int devIdx, int devOrder)
|
||
|
{
|
||
|
//20110110 1����,2ȡ��,3�ͻ�,4ȡ�ͻ�,5����AGV����
|
||
|
DataView dv;
|
||
|
string xc = "F_NumParam2";
|
||
|
if (GetDeviceKindIdx(devIdx) == 6)
|
||
|
{
|
||
|
if (devOrder == 1)
|
||
|
{
|
||
|
xc = "F_NumParam5";
|
||
|
}
|
||
|
else if ((devOrder == 2) || (devOrder == 5))
|
||
|
{
|
||
|
xc = "F_NumParam2";
|
||
|
}
|
||
|
else if (devOrder == 3)
|
||
|
{
|
||
|
xc = "F_NumParam5";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
try
|
||
|
{
|
||
|
|
||
|
int x = 0, x1 = 0;
|
||
|
int channelleft = 0, channelleft1 = 0, xd = 0, xd1 = 0;
|
||
|
//���ұ����������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( xc ).Append( " FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.F_RELATIVECONTORLID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
;
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
|
||
|
xd = Convert.ToInt32(dv[0][xc]);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_Sequence FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = " ).Append( xd ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
x = Convert.ToInt32(dv[0]["F_Sequence"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
x = 0;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//���ҹ����Լ������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( xc ).Append( " FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
;
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
xd = Convert.ToInt32(dv[0][xc]);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_Sequence FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = " ).Append( xd ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
x = Convert.ToInt32(dv[0]["F_Sequence"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
x = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (x == 0)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( xc ).Append( " FROM T_Monitor_Task Where ( F_ManageTASKKINDINDEX = " ).Append( mankind ).Append( ") AND (F_ManageTaskIndex = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
;
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
xd1 = Convert.ToInt32(dv[0][xc]);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_Sequence FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = " ).Append( xd1 ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
x1 = Convert.ToInt32(dv[0]["F_Sequence"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
x1 = 0;
|
||
|
}
|
||
|
int DoubleFork = 0, DoubleFork1 = 0;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_UseAwayFork,F_IfChannelLeft FROM T_Base_AGV_Gate WHERE F_AGVGateDeviceIndex =" ).Append( xd);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
DoubleFork = Convert.ToInt32(dv[0]["F_UseAwayFork"]);
|
||
|
channelleft = Convert.ToInt32(dv[0]["F_IfChannelLeft"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_UseAwayFork,F_IfChannelLeft FROM T_Base_AGV_Gate WHERE F_AGVGateDeviceIndex =" ).Append( xd1);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
DoubleFork1 = Convert.ToInt32(dv[0]["F_UseAwayFork"]);
|
||
|
channelleft1 = Convert.ToInt32(dv[0]["F_IfChannelLeft"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
if ((((x1 > x) && (DoubleFork1 > DoubleFork)) || ((x > x1) && (DoubleFork > DoubleFork1))) && (channelleft == channelleft1))
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���豸ָ�����б���ȡZ ������
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetZCoorFromMonitor(int monitorIndex, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv;
|
||
|
string zc = "F_NumParam1";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4)
|
||
|
{
|
||
|
zc = "F_NumParam1";
|
||
|
}
|
||
|
else if (devOrder == 5)
|
||
|
{
|
||
|
zc = "F_NumParam4";
|
||
|
}
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( zc ).Append( " FROM T_Monitor_Task WHERE (F_MonitorIndex = " ).Append( monitorIndex ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���豸ָ�����б���ȡX ������
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetXCoorFromMonitor(int monitorIndex, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv;
|
||
|
string xc = "F_NumParam2";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4)
|
||
|
{
|
||
|
xc = "F_NumParam2";
|
||
|
}
|
||
|
else if (devOrder == 5)
|
||
|
{
|
||
|
xc = "F_NumParam5";
|
||
|
}
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( xc ).Append( " FROM T_Monitor_Task WHERE (F_MonitorIndex = " ).Append( monitorIndex ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���豸ָ�����б���ȡY ������
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetYCoorFromMonitor(int monitorIndex, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv;
|
||
|
string yc = "F_NumParam3";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4)
|
||
|
{
|
||
|
yc = "F_NumParam3";
|
||
|
}
|
||
|
else if (devOrder == 5)
|
||
|
{
|
||
|
yc = "F_NumParam6";
|
||
|
}
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( yc ).Append( " FROM T_Monitor_Task WHERE (F_MonitorIndex = " ).Append( monitorIndex ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���ض��������豸ָ����Ϣ����0���豸ָ��������1����ǰ���⡾2���豸������3��·��
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <param name="devIdx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
public static string[] GetDoubleForkMonitorInfo(int monitorIndex, int devIdx)
|
||
|
{
|
||
|
DataView dv;
|
||
|
|
||
|
string[] rr = null;
|
||
|
try
|
||
|
{
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(monitorIndex);
|
||
|
int fid = GetManageTaskIndexfromMonitor(monitorIndex);
|
||
|
int devOrder = GetDeviceOrderFromMonitor(monitorIndex);
|
||
|
//���ұ����������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_AheadDetect,F_DeviceIndex,F_RouteID FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.F_RELATIVECONTORLID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
rr = new string[4];
|
||
|
rr[0] = dv[0]["F_MonitorIndex"].ToString();
|
||
|
rr[1] = dv[0]["F_AheadDetect"].ToString();
|
||
|
rr[2] = dv[0]["F_DeviceIndex"].ToString();
|
||
|
rr[3] = dv[0]["F_RouteID"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//���ҹ����Լ������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_AheadDetect,F_DeviceIndex,F_RouteID FROM T_Manage_Task,T_Monitor_Task Where (T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex " ).Append(
|
||
|
" AND T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
rr = new string[4];
|
||
|
rr[0] = dv[0]["F_MonitorIndex"].ToString();
|
||
|
rr[1] = dv[0]["F_AheadDetect"].ToString();
|
||
|
rr[2] = dv[0]["F_DeviceIndex"].ToString();
|
||
|
rr[3] = dv[0]["F_RouteID"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
return rr;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
rr = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����δ���ֵĶ��������豸ָ��,true ������δ���ֵĶ��������豸ָ��
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static bool GetDoubleForkUnIntoStep(int monitorIndex)
|
||
|
{
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(monitorIndex);
|
||
|
int fid = GetManageTaskIndexfromMonitor(monitorIndex);
|
||
|
//���ұ����������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_RELATIVECONTORLID FROM T_Manage_Task Where (T_Manage_Task.F_RELATIVECONTORLID <>-1 ) and ( F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
fid ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID FROM T_Manage_Task Where ( F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
dv[0][0] ).Append( " and FIntoStepOK<>'1')");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//���ҹ����Լ������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID FROM T_Manage_Task Where ( F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( ")");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID FROM T_Manage_Task Where ( F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") AND (FID = " ).Append(
|
||
|
dv[0][0] ).Append( " and FIntoStepOK<>'1')");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int GetManageTaskIndexfromMonitor(int monitorIdx)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
//20100108
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTaskIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = " ).Append( monitorIdx ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_ManageTaskIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100108
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
public static int GetManageTaskKindIndexFromMonitor(int monitorIdx)
|
||
|
{//20100108
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
//20100108
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTaskKindIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = " ).Append( monitorIdx ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100108
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
dv = null;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// �ڵ��ȶ������ҵ��豸����
|
||
|
/// </summary>
|
||
|
/// <param name="MonitorIndex">��������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetDeviceOrderFromMonitor(int MonitorIndex)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceCommandIndex from T_Monitor_Task where (F_DeviceCommandIndex IS NOT NULL) and F_MonitorIndex=" ).Append( MonitorIndex);
|
||
|
;
|
||
|
//20100108
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_DeviceCommandIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int GetDeviceKindIdx(int devIdx)
|
||
|
{
|
||
|
object ob;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceKindIndex FROM T_Base_Device WHERE (F_DeviceIndex = " ).Append( devIdx ).Append( ")");
|
||
|
ob = dbo.GetSingle(sql.ToString());
|
||
|
|
||
|
if (ob != null)
|
||
|
{
|
||
|
return Convert.ToInt32(ob);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int GetDeviceIndexFromMonitor(int MonitorIndex)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceIndex from T_Monitor_Task where (F_DeviceIndex IS NOT NULL) and F_MonitorIndex=" ).Append( MonitorIndex);
|
||
|
|
||
|
//20100108
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu
|
||
|
/// �����̣߳�����AGV���������ݣ������н���
|
||
|
/// </summary>
|
||
|
public static class CListenAGVState
|
||
|
{
|
||
|
public static event CDataSourceChangeEventHandler DataChange;
|
||
|
public static event CUpdateDBEventHandler UpdateDB;
|
||
|
|
||
|
public static void OnDataChange(CDataChangeEventArgs e)
|
||
|
{
|
||
|
if (DataChange != null)
|
||
|
{
|
||
|
DataChange(null, e);
|
||
|
}
|
||
|
}
|
||
|
public static void OnUpdateDB(CUpdateDBChangeEventArgs e)
|
||
|
{
|
||
|
if (UpdateDB != null)
|
||
|
{
|
||
|
UpdateDB(null,e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//��¼AGV������ַ��
|
||
|
static ushort[] AgvActive = new ushort[4];
|
||
|
//static bool _exitThread = false;
|
||
|
static string _tcpServerError="";
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��������AGV���͵�����ʱ�����Ĺ���
|
||
|
/// </summary>
|
||
|
public static string TcpServerError
|
||
|
{
|
||
|
get { return CListenAGVState._tcpServerError; }
|
||
|
set { CListenAGVState._tcpServerError = value; }
|
||
|
}
|
||
|
static string _receiveOK = null;
|
||
|
/// <summary>
|
||
|
/// ��������AGV�������������
|
||
|
/// </summary>
|
||
|
public static string ReceiveOK
|
||
|
{
|
||
|
get { return CListenAGVState._receiveOK; }
|
||
|
set { CListenAGVState._receiveOK = value; }
|
||
|
}
|
||
|
static StringBuilder sql = new StringBuilder();
|
||
|
static Thread mythread;
|
||
|
static Socket Localsocket;
|
||
|
static bool exitThread = false;//20091107
|
||
|
static bool ConnectedServer = false;
|
||
|
static byte[] _GetData = new byte[8192];
|
||
|
public static DBOperator dbo = new DBOperator();
|
||
|
static DBOperator dboM = new DBOperator("ManConnString", "ManDBFactory");
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��ʼ�������յ�������
|
||
|
/// </summary>
|
||
|
private static void BeginListen()
|
||
|
{
|
||
|
//20091107
|
||
|
while (!exitThread )
|
||
|
{
|
||
|
|
||
|
try
|
||
|
{
|
||
|
int gcount = 0;
|
||
|
if (ConnectedServer == false)
|
||
|
{
|
||
|
if (ConnectTcpIPServer() == false)
|
||
|
{
|
||
|
Thread.Sleep(200);//20100710
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Localsocket.Listen(1);
|
||
|
try
|
||
|
|
||
|
{
|
||
|
//20090920
|
||
|
if (SocketsTCPIP.CClientTCPIP.ClientSocket.Connected == true)
|
||
|
{
|
||
|
|
||
|
gcount = SocketsTCPIP.CClientTCPIP.ClientSocket.Receive(_GetData);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SocketsTCPIP.CClientTCPIP.IfInit = false;
|
||
|
ConnectedServer = false;
|
||
|
}
|
||
|
if (gcount == 0)
|
||
|
{//20091107
|
||
|
SocketsTCPIP.CClientTCPIP.IfInit = false;
|
||
|
ConnectedServer = false;
|
||
|
Thread.Sleep(200);//20100710
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (SocketException ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.BeginListen:" + ex.Message;
|
||
|
SocketsTCPIP.CClientTCPIP.IfInit = false;
|
||
|
ConnectedServer = false;
|
||
|
Thread.Sleep(200);//20100710
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
//�������յ�����:����gcount��_GetData�в��Ҹ���֡ͷ����֡����
|
||
|
//֡��ÿ�����ֽڣ�һ���֣�����һ������
|
||
|
byte[] chatnew;
|
||
|
chatnew = new byte[gcount];
|
||
|
Array.Copy(_GetData,0, chatnew,0, gcount);
|
||
|
//��byte����ת����UInt16����
|
||
|
UInt16[] newData = ConvertByteToUInt16(chatnew);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "1000", chatnew);
|
||
|
|
||
|
|
||
|
//�����յ�����Ϣ
|
||
|
DisposeReceivedMessage(newData);
|
||
|
chatnew = null;//20100127
|
||
|
|
||
|
}
|
||
|
catch (SocketException ex)
|
||
|
{
|
||
|
ConnectedServer = false;
|
||
|
_tcpServerError = "CListenAGVState.BeginListen:" + ex.Message;
|
||
|
}
|
||
|
Thread.Sleep(200);//20100710
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#region ��BYTE����ת��ΪUInt16����
|
||
|
/// <summary>
|
||
|
/// ��BYTE����ת��ΪUInt16����
|
||
|
/// </summary>
|
||
|
/// <param name="srcData">��Ҫ������byte����</param>
|
||
|
/// <returns>����UInt16����</returns>
|
||
|
private static UInt16[] ConvertByteToUInt16(byte[] srcData)
|
||
|
{
|
||
|
byte[] chat = null;
|
||
|
//�ж�srcData������ά���Ƿ�Ϊ����������Ϊ��������������һλ
|
||
|
if (srcData.Length % 2 == 1)
|
||
|
{
|
||
|
chat = new byte[srcData.Length - 1];
|
||
|
Array.Copy(srcData,0, chat,0, srcData.Length - 1);
|
||
|
//Buffer.BlockCopy(srcData, 0, chat, 0, srcData.Length - 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
chat = new byte[srcData.Length];
|
||
|
Array.Copy(srcData,0, chat,0, srcData.Length);
|
||
|
//Buffer.BlockCopy(srcData, 0, chat, 0, srcData.Length);
|
||
|
}
|
||
|
|
||
|
UInt16[] newData = new UInt16[chat.Length / 2];
|
||
|
|
||
|
int temp = 0;
|
||
|
for (int i = 0; i < newData.Length; i++)
|
||
|
{
|
||
|
newData[i] = (UInt16)((chat[temp+ 1] << 8) + chat[temp ]);//C#�棺0�ǵ�λ��1�Ǹ�λ��VC++�棺1�ǵ�λ��0�Ǹ�λ��
|
||
|
temp += 2;
|
||
|
}
|
||
|
|
||
|
return newData;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �����յ�����Ϣ
|
||
|
/// <summary>
|
||
|
/// �����յ�����Ϣ
|
||
|
/// </summary>
|
||
|
/// <param name="message">��Ϣ����</param>
|
||
|
private static void DisposeReceivedMessage(UInt16[] message)
|
||
|
{
|
||
|
StringBuilder AheadDetect = new StringBuilder();
|
||
|
ushort[] chatnew;
|
||
|
byte[] _Sdata = new byte[6];
|
||
|
try
|
||
|
{
|
||
|
for (int i = 0; i < message.Length; )
|
||
|
{
|
||
|
|
||
|
switch (message[i])
|
||
|
{
|
||
|
case 60080://�����´�������Ӧ��60080[T1][T2](��60003[T1][T2][K][P][S][C]��Ӧ��)
|
||
|
#region 60080AGV�Լ����´�������Ӧ��
|
||
|
|
||
|
if (message.Length >= 3)//
|
||
|
{
|
||
|
if (message.Length <= (i + 2)) break;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_ErrorCode='', F_Status=2 WHERE F_MonitorIndex = ").Append(message[i + 2]).Append("");//20110505
|
||
|
SQLString(dbo, sql);
|
||
|
//20110608dbo.ExecuteSql(sql.ToString());
|
||
|
#region ����������������ͬ����һͬ����ʼ
|
||
|
if (CGeneralFunction.DoubleForkIfSync(message[i + 2], 1001, 6) == true)
|
||
|
{
|
||
|
string[] df = CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001);
|
||
|
if (df != null)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_ErrorCode='',F_Status=2 WHERE F_MonitorIndex = ").Append(Convert.ToInt32(df[0]));//20110505
|
||
|
SQLString(dbo, sql);
|
||
|
//20110608dbo.ExecuteSql( sql.ToString());
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
DataSourceChange();//20110405
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:����������Ϣ���У�" + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[3];
|
||
|
Array.Copy(message, i, chatnew, 0, 3);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV����������Ϣ����", chatnew);
|
||
|
i += 3;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
case 60081://����AGV���ص�Ӧ��:60081[T1][T2](��60005[T1][T2][N] [E] [O]��Ӧ��)
|
||
|
#region 60081����AGV���ص�Ӧ��
|
||
|
|
||
|
if (message.Length >= 3)
|
||
|
{
|
||
|
if (message.Length <= (i + 2)) break;
|
||
|
try
|
||
|
{
|
||
|
|
||
|
|
||
|
///////////////////////message[i + 2]��ӦF_AGVNextTask������F_MonitorIndex
|
||
|
object ob = dbo.GetSingle("select F_MonitorIndex from T_Monitor_Task where F_AGVNextTask=" + message[i + 2]);
|
||
|
if (ob != null)
|
||
|
{
|
||
|
int fid = message[i + 1];
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(Convert.ToInt32(ob));
|
||
|
///////////////////////
|
||
|
string[] df = CGeneralFunction.GetDoubleForkMonitorInfo(Convert.ToInt32(ob), 1001);
|
||
|
bool snyc = CGeneralFunction.DoubleForkIfSync(Convert.ToInt32(ob), 1001, 6);
|
||
|
ActionFinish(1001, Convert.ToInt32(ob), 0);
|
||
|
//20110608ActionComplete(1001, Convert.ToInt32(ob), 0);
|
||
|
//ˢ�¼���������ʾ
|
||
|
#region ����������������ͬ����ͬʱ�������ɣ��첽��ֱ��ִ�й���������
|
||
|
//20100323
|
||
|
if (df != null)//20100702
|
||
|
{
|
||
|
//20100817 zhangxy ��
|
||
|
fid = GetManageTaskIndexfromMonitor(Convert.ToInt32(df[0]));
|
||
|
mankind = GetManageTaskKindIndexFromMonitor(Convert.ToInt32(df[0]));
|
||
|
|
||
|
///////////////////////
|
||
|
if (snyc == true)//20100702
|
||
|
{
|
||
|
ActionFinish(1001, Convert.ToInt32(df[0]), 1);
|
||
|
//20110608ActionComplete(1001, Convert.ToInt32(df[0]), 1);//20100702
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
DataSourceChange();//20110405
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:����AGV���ص�Ӧ����" + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[3];
|
||
|
Array.Copy(message, i, chatnew, 0, 3);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "����AGV���ص�Ӧ��", chatnew);
|
||
|
i += 3;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
case 60050://60050[T1][T2][A] ;AGV����̨��ʼ����AGV����
|
||
|
#region AGV����̨��ʼ����AGV����
|
||
|
if (message.Length >= 4)
|
||
|
{
|
||
|
if (message.Length <= (i + 3)) break;
|
||
|
try
|
||
|
{
|
||
|
int fid = message[i + 1];
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(message[i + 2]);
|
||
|
|
||
|
if (mankind == 1)
|
||
|
{//20100714
|
||
|
SQLString(dboM,new StringBuilder ( "update IO_CONTROL set CONTROL_STATUS=11 where CONTROL_ID=" + fid ));
|
||
|
//20110608dboM.ExecuteSql("update IO_CONTROL set CONTROL_STATUS=11 where CONTROL_ID=" + fid + "");
|
||
|
}
|
||
|
|
||
|
//20100817 zhangxy ��
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_device set F_LockedState=").Append(message[i + 2]).Append(
|
||
|
" where F_DeviceIndex=").Append(message[i + 3]);
|
||
|
SQLString(dbo, sql);
|
||
|
//20110608dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_AgvNo=").Append(message[i + 3]).Append(" WHERE F_ManageTaskIndex=").Append(fid).Append(" and F_ManageTaskKindIndex=").Append(mankind).Append(" and F_DeviceIndex=1001 and (F_AgvNo is null) ");
|
||
|
SQLString(dbo, sql);
|
||
|
//20110608dbo.ExecuteSql(sql.ToString());
|
||
|
#region ������������һ�����䳵��
|
||
|
string[] df = CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001);
|
||
|
if (df != null)
|
||
|
{
|
||
|
fid = GetManageTaskIndexfromMonitor(Convert.ToInt32(df[0]));
|
||
|
mankind = GetManageTaskKindIndexFromMonitor(Convert.ToInt32(df[0]));
|
||
|
if (mankind == 1)
|
||
|
{//20100714
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_CONTROL set CONTROL_STATUS=11 where CONTROL_ID=" ).Append( fid);
|
||
|
SQLString(dboM, sql);
|
||
|
//20110608dboM.ExecuteSql( sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_AgvNo=").Append(message[i + 3]).Append(" WHERE F_ManageTaskIndex=").Append(fid).Append(" and F_ManageTaskKindIndex=").Append(mankind).Append(" and F_DeviceIndex=1001");
|
||
|
SQLString(dbo, sql);
|
||
|
//20110608dbo.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region ����һAGV������˫������
|
||
|
|
||
|
//if ((ir > 0) &&(GetDeviceOrderFromMonitor(message[i + 1])==1)&&(GetFCONTROLTASKTYPEFromManageTask(GetManageTaskKindIndexFromMonitor(message[i + 1]),GetManageTaskIndexfromMonitor(message[i + 1])))==1)//��һ�η��䳵�Ų���������������ȡ��ָ��
|
||
|
//{//����һ������λ�õ�δ���͵Ĺ��������ܻ��漰�������豸�ĵ����ط�������
|
||
|
// int xCoor=CGeneralFunction.GetXCoorFromMonitor(message[i + 1], 1001, 1);
|
||
|
// int agvSquence = GetAgvSquence(xCoor);
|
||
|
// int useAwayfork = GetUseAwayFork(message[i + 1]);
|
||
|
// if (useAwayfork == 1)
|
||
|
// {
|
||
|
// useAwayfork = 0;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// useAwayfork = 1;
|
||
|
// }
|
||
|
// DataView dv = dbo.ExceSQL(" SELECT TOP 1 T_Monitor_Task.F_ManageTaskIndex,T_Monitor_Task.F_ManageTASKKINDINDEX,T_Monitor_Task.F_MonitorIndex FROM T_Monitor_Task,T_Base_AGV_Gate,T_Manage_Task where T_Monitor_Task.F_NumParam2 = T_Base_AGV_Gate.F_AGVGateDeviceIndex and T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID AND T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex and (T_Monitor_Task.F_Status = 0) AND (T_Base_AGV_Gate.F_Sequence >" + agvSquence + ") AND(T_Monitor_Task.F_DeviceIndex = 1001) AND (T_Monitor_Task.F_DeviceCommandIndex = 1) AND (T_Manage_Task.F_RELATIVECONTORLID = - 1) and (FCONTROLTASKTYPE=1) and (F_UseAwayFork ='" + useAwayfork + "') and (F_AgvNo is null) ORDER BY F_Sequence asc").Tables[0].DefaultView;
|
||
|
// if (dv.Count > 0)
|
||
|
// {//�ҵ�һ�����ʵĶ�����������
|
||
|
// fid = GetManageTaskIndexfromMonitor(message[i + 1]);
|
||
|
// mankind = GetManageTaskKindIndexFromMonitor(message[i + 1]);
|
||
|
// int fidr =Convert.ToInt32( dv[0]["F_ManageTaskIndex"]);
|
||
|
// int mankindr = Convert.ToInt32(dv[0]["F_ManageTASKKINDINDEX"]);
|
||
|
// dbo.TransBegin();
|
||
|
// try
|
||
|
// {
|
||
|
// //��������������AGV����
|
||
|
// dbo.ExecuteSql("update T_Manage_Task set F_RELATIVECONTORLID=" + fidr + " where FID=" + fid + " and F_ManageTaskKindIndex="+mankind+"");
|
||
|
// dbo.ExecuteSql("update T_Manage_Task set F_RELATIVECONTORLID=" + fid + " where FID=" + fidr + " and F_ManageTaskKindIndex=" + mankindr + "");
|
||
|
// dbo.ExecuteSql("UPDATE T_Monitor_Task SET F_AgvNo=" + message[i + 2] + " WHERE F_ManageTaskIndex=" + fidr + " and F_ManageTaskKindIndex=" + mankindr + " and F_DeviceIndex=1001");
|
||
|
// dbo.TransCommit();
|
||
|
// }
|
||
|
// catch (Exception ex)
|
||
|
// {
|
||
|
// _tcpServerError = "CListenAGVState.DisposeReceivedMessage:����AGV����," + ex.Message;
|
||
|
// dbo.TransRollback();
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
// dv = null;
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
DataSourceChange();//20110405
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV����̨��ʼ����AGV����," + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[4];
|
||
|
Array.Copy(message, i, chatnew, 0, 4);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV����̨��ʼ����AGV����", chatnew);
|
||
|
i += 4;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
case 60051://60051[T1][T2][N�ڵ�] [E�����豸��] [O��������] [A����] OΪ��������( 1-��ȡ, 2-����,3��ȡ,4-����)
|
||
|
//AGV��λ���������ӵ㣩���������������ͻ�AGV��λ��,AGV����̨ѯ�ʼ���ϵͳ�����Ƿ�����
|
||
|
#region AGV��λ���������ӵ㣩�������������ͻ�AGV��λ��,AGV����̨ѯ�ʼ���ϵͳ�����Ƿ�����
|
||
|
|
||
|
{
|
||
|
|
||
|
if (message.Length >= 7)//20110110
|
||
|
{
|
||
|
if (message.Length <= (i + 6)) break;//20110110
|
||
|
//AGV��λ(�������ӵ�)��Ӧ��:60030[T1][T2](��60051[T1][T2][N] [E] [O] [A]��Ӧ��)
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex,F_DeviceKindIndex, F_LocalIP, F_LocalPort, F_RemoteIP, F_RemotePort FROM T_Base_Device where F_DeviceIndex=1001");
|
||
|
DataView dvc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvc.Count > 0)
|
||
|
{
|
||
|
_Sdata = new byte[6];
|
||
|
_Sdata[0] = Convert.ToByte(60030 & 255);
|
||
|
_Sdata[1] = Convert.ToByte(60030 >> 8);
|
||
|
|
||
|
_Sdata[2] = Convert.ToByte(message[i + 1] & 255);
|
||
|
_Sdata[3] = Convert.ToByte(message[i + 1] >> 8);
|
||
|
_Sdata[4] = Convert.ToByte(message[i + 2] & 255);
|
||
|
_Sdata[5] = Convert.ToByte(message[i + 2] >> 8);
|
||
|
SocketsTCPIP.CClientTCPIP.Send(dvc[0]["F_RemoteIP"].ToString(), Convert.ToInt32(dvc[0]["F_RemotePort"]), _Sdata);
|
||
|
}
|
||
|
dvc = null;
|
||
|
try
|
||
|
{
|
||
|
int device = GetDeviceIndexFromAgvAddress(message[i + 3], message[i + 4]);//20110110
|
||
|
|
||
|
if (GetDeviceOrderFromMonitor(message[i + 2]) == -1)//AGV����������������
|
||
|
{//�������ع���60008[T1][T2][N][C]
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (GetDeviceKindIdx(device) == 2)
|
||
|
{
|
||
|
_Sdata = new byte[12];
|
||
|
DataView dv;
|
||
|
//����״̬��0�����ɡ�������������1��ֻ���ɡ�����AGVȡ�����ء���2��ֻ���ɡ�����AGV�ͻ����ء���3�������ɡ������½���Ȼ�����ɡ�����AGV���ء�
|
||
|
|
||
|
#region �������ͻ��ͻ����������У�����������
|
||
|
if ((message[i + 5] == 2) || (message[i + 5] == 4))
|
||
|
{
|
||
|
|
||
|
#region 20110412������AGV�ͻ����ء�:���ͻ����С�������������
|
||
|
int ManFID = message[i + 1];
|
||
|
int Mankind = GetManageTaskKindIndexFromMonitor(message[i + 2]);
|
||
|
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
AheadDetect.Append("I").Append(Convert.ToString(device)).Append(";N").Append(Convert.ToString(device))
|
||
|
.Append(";D").Append(Convert.ToString(device)).Append(".0");
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, 1001, 5, device) == false)
|
||
|
{
|
||
|
|
||
|
#region ����AGV�ͻ�����
|
||
|
int mindex = message[i + 2] - 1;
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_NumParam2,F_RouteID,F_TxtParam,F_MonitorTaskLevel,F_UseAwayFork FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", message[i + 2])).Tables[0].DefaultView;
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
||
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam2, F_NumParam5,").Append(
|
||
|
" F_AheadDetect,F_TxtParam,F_AGVNextTask,F_UseAwayFork)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(dv[0]["F_MonitorTaskLevel"]
|
||
|
).Append(",").Append(1001).Append(",5,").Append(dv[0]["F_RouteID"]).Append(",0,").Append(device).Append(",0").Append(
|
||
|
",'").Append(AheadDetect).Append("','").Append(dv[0]["F_TxtParam"]).Append("',").Append(message[i + 2]).Append(",'").Append(dv[0]["F_UseAwayFork"]).Append("')");
|
||
|
SQLString(dbo,sql);
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ��������վ̨
|
||
|
string[] df=CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001) ;
|
||
|
if ((message[i + 4] == 3) && (df != null))//��������
|
||
|
{//��������վ̨
|
||
|
|
||
|
device = GetCorrDeviceIndex(device);
|
||
|
ManFID = GetManageTaskIndexfromMonitor(Convert.ToInt32(df[0]));
|
||
|
Mankind = GetManageTaskKindIndexFromMonitor(Convert.ToInt32(df[0]));
|
||
|
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
AheadDetect.Append("I").Append(Convert.ToString(device)).Append(";N").Append(Convert.ToString(device))
|
||
|
.Append(";D").Append(Convert.ToString(device)).Append(".0");
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, 1001, 5, device) == false)
|
||
|
{
|
||
|
#region ����AGV�ͻ�����
|
||
|
int mindex = Convert.ToInt32(df[0]) - 1;
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_NumParam2,F_RouteID,F_TxtParam,F_MonitorTaskLevel,F_UseAwayFork FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", Convert.ToInt32(df[0]))).Tables[0].DefaultView;
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
||
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam2, F_NumParam5,").Append(
|
||
|
" F_AheadDetect,F_TxtParam,F_AGVNextTask,F_UseAwayFork)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(dv[0]["F_MonitorTaskLevel"]
|
||
|
).Append(",").Append(1001).Append(",5,").Append(dv[0]["F_RouteID"]).Append(",0,").Append(device).Append(",0").Append(
|
||
|
",'").Append(AheadDetect).Append("','").Append(dv[0]["F_TxtParam"]).Append("',").Append(Convert.ToInt32(df[0])).Append(",'").Append(dv[0]["F_UseAwayFork"]).Append("')");
|
||
|
SQLString(dbo,sql);
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�ȡ�����������У��л���������λ
|
||
|
if ((message[i + 5] == 1) || (message[i + 5] == 3))
|
||
|
{
|
||
|
int ManFID = message[i + 1];
|
||
|
int Mankind = GetManageTaskKindIndexFromMonitor(message[i + 2]);
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
#region 20110412������AGVȡ�����ء�:���ͻ����С����������С�������λ�������л�
|
||
|
AheadDetect.Append("I").Append(Convert.ToString(device)).Append(
|
||
|
";I").Append(Convert.ToString(device - 2)).Append(
|
||
|
";D-").Append(device.ToString()).Append(".2").Append(
|
||
|
";D-").Append((device-2).ToString()).Append(".0");
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, 1001, 5, device) == false)
|
||
|
{
|
||
|
#region ����AGVȡ������
|
||
|
int mindex = message[i + 2] - 1;
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_NumParam2,F_RouteID,F_TxtParam,F_MonitorTaskLevel,F_UseAwayFork FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", message[i + 2])).Tables[0].DefaultView;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
||
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam2, F_NumParam5,").Append(
|
||
|
" F_AheadDetect,F_TxtParam,F_AGVNextTask,F_UseAwayFork)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(dv[0]["F_MonitorTaskLevel"]
|
||
|
).Append(",").Append(1001).Append(",5,").Append(dv[0]["F_RouteID"]).Append(",0,").Append(device).Append(",0").Append(
|
||
|
",'").Append(AheadDetect).Append("','").Append(dv[0]["F_TxtParam"]).Append("',").Append(message[i + 2]).Append(",'").Append(dv[0]["F_UseAwayFork"]).Append("')");
|
||
|
SQLString(dbo, sql);
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
#region ��������վ̨
|
||
|
string[] df=CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001);
|
||
|
if ((message[i + 4] == 3) && ( df!= null))//��������
|
||
|
{//��������վ̨
|
||
|
device = GetCorrDeviceIndex(device);
|
||
|
ManFID = GetManageTaskIndexfromMonitor(Convert.ToInt32(df[0]));
|
||
|
Mankind = GetManageTaskKindIndexFromMonitor(Convert.ToInt32(df[0]));
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
#region 20110412������AGVȡ�����ء�:���ͻ����С����������С�������λ�������л�
|
||
|
AheadDetect.Append("I").Append(Convert.ToString(device)).Append(
|
||
|
";I").Append(Convert.ToString(device - 2)).Append(
|
||
|
";D-").Append(device.ToString()).Append(".2").Append(
|
||
|
";D-").Append((device - 2).ToString()).Append(".0");
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, 1001, 5, device) == false)
|
||
|
{
|
||
|
#region ����AGVȡ������
|
||
|
int mindex = Convert.ToInt32(df[0]) - 1;
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_NumParam2,F_RouteID,F_TxtParam,F_MonitorTaskLevel,F_UseAwayFork FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", message[i + 2])).Tables[0].DefaultView;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
||
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam2, F_NumParam5,").Append(
|
||
|
" F_AheadDetect,F_TxtParam,F_AGVNextTask,F_UseAwayFork)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(dv[0]["F_MonitorTaskLevel"]
|
||
|
).Append(",").Append(1001).Append(",5,").Append(dv[0]["F_RouteID"]).Append(",0,").Append(device).Append(",0").Append(
|
||
|
",'").Append(AheadDetect).Append("','").Append(dv[0]["F_TxtParam"]).Append("',").Append(Convert.ToInt32(df[0])).Append(",'").Append(dv[0]["F_UseAwayFork"]).Append("')");
|
||
|
SQLString(dbo,sql);
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
dv = null;
|
||
|
}
|
||
|
else
|
||
|
{//�������ع���60008[T1][T2][N][C]
|
||
|
|
||
|
}
|
||
|
}
|
||
|
chatnew = new ushort[7];//20110110
|
||
|
Array.Copy(message, i, chatnew, 0, 7);//20110110
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "�����ͻ���"+device.ToString()+"��AGVѯ���Ƿ�������", chatnew);
|
||
|
DataSourceChange();//20110405
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:���������ͻ���AGVѯ���Ƿ�������," + ex.Message;
|
||
|
}
|
||
|
i += 7;//20110110
|
||
|
}
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
case 60052://60052[T1][T2][N�ڵ�] [E�����豸��] [O��������] [A����]
|
||
|
#region AGV���ؿ�ʼ
|
||
|
if (message.Length >= 7)//
|
||
|
{
|
||
|
if (message.Length <= (i + 6)) break;
|
||
|
//20110412AGV��ʱ������
|
||
|
//try
|
||
|
//{
|
||
|
// int devicegate = GetDeviceIndexFromAgvAddress(message[i + 3], message[i + 4]);//20110110
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("update T_Base_device set F_LockedState=").Append(message[i + 2]).Append(
|
||
|
// " where F_DeviceIndex=").Append(devicegate);
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// if ((message[i + 4] == 3) && (CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001) != null))//��������
|
||
|
// {//��������վ̨
|
||
|
|
||
|
// int deviceCorr = GetCorrDeviceIndex(devicegate);
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("update T_Base_device set F_LockedState=").Append(message[i + 2]).Append(
|
||
|
// " where F_DeviceIndex=").Append(deviceCorr);
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// }
|
||
|
|
||
|
//}
|
||
|
//catch (Exception ex)
|
||
|
//{
|
||
|
// _tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV���ؿ�ʼ��" + ex.Message;
|
||
|
//}
|
||
|
chatnew = new ushort[7];
|
||
|
Array.Copy(message, i, chatnew, 0, 7);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV���ؿ�ʼ", chatnew);
|
||
|
i += 7;
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
#endregion
|
||
|
|
||
|
case 60053://60053[T1][T2][N�ڵ�] [E�����豸��] [O��������] [A����] (�������ͣ� 1-��ȡ, 2-����,3��ȡ,4-����)
|
||
|
|
||
|
#region AGV���ؽ���
|
||
|
if (message.Length >= 7)//
|
||
|
{
|
||
|
if (message.Length <= (i + 6)) break;
|
||
|
//20110412AGV��ʱ������
|
||
|
//try
|
||
|
//{
|
||
|
// sql.Remove(0, sql.Length);//20110110
|
||
|
// sql.Append("update T_Base_device set F_LockedState=0").Append(
|
||
|
// " where F_LockedState=").Append(message[i + 2]);
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// #region ȡ���������ɣ����붥���� ����ָ��
|
||
|
// if ((message[i + 5] == 1) || (message[i + 5] == 3))//��ȡ ��ȡ
|
||
|
// {
|
||
|
// //����״̬��0�����ɡ�������������1��ֻ���ɡ�����AGVȡ�����ء���2��ֻ���ɡ�����AGV�ͻ����ء���3�������ɡ������½���Ȼ�����ɡ�����AGV���ء�
|
||
|
// int device = GetDeviceIndexFromAgvAddress(message[i + 3], message[i + 4]);
|
||
|
// int deviceCorr = 0;DataView dv;
|
||
|
// int LifterIndex1 = -1; int MonitorIndex1 = -1; int taskStatus1 = -1;
|
||
|
// #region ��������վ̨
|
||
|
|
||
|
// if ((message[i + 4] == 3) && (CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001) != null))//��������
|
||
|
// {//��������վ̨
|
||
|
|
||
|
// deviceCorr = GetCorrDeviceIndex(device);
|
||
|
// LifterIndex1 = deviceCorr;
|
||
|
// MonitorIndex1 = Convert.ToInt32(CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001)[0]);
|
||
|
// taskStatus1 = 0;
|
||
|
// }
|
||
|
// #endregion
|
||
|
|
||
|
// //���붥���� ����
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("select F_Pending_ID from T_Base_Pending_Lifter where F_MonitorIndex=").Append(message[i + 2]).Append(" or F_MonitorIndex1=").Append(message[i + 2]);
|
||
|
// dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
// if (dv.Count <= 0)
|
||
|
// {
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("INSERT INTO T_Base_Pending_Lifter( ")
|
||
|
// .Append(" F_LifterIndex, F_MonitorIndex, F_Status,")
|
||
|
// .Append(" F_LifterIndex1, F_MonitorIndex1, F_Status1)VALUES (")
|
||
|
// .Append(device).Append(",").Append(message[i + 2]).Append(",0,")
|
||
|
// .Append(LifterIndex1).Append(",").Append(MonitorIndex1).Append(",").Append(taskStatus1).Append(")");
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
// }
|
||
|
// dv = null;
|
||
|
|
||
|
// }
|
||
|
// DataSourceChange();//20110405
|
||
|
// #endregion
|
||
|
|
||
|
|
||
|
//}
|
||
|
//catch (Exception ex)
|
||
|
//{
|
||
|
// _tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV���ؽ�����" + ex.Message;
|
||
|
//}
|
||
|
chatnew = new ushort[7];
|
||
|
Array.Copy(message, i, chatnew, 0, 7);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV���ؽ���", chatnew);
|
||
|
i += 7;
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
#endregion
|
||
|
case 60054://60054[T1][T2][N] [C������] [A]
|
||
|
#region AGV���ع���
|
||
|
if (message.Length >= 6)//
|
||
|
{
|
||
|
if (message.Length <= (i + 5)) break;
|
||
|
try
|
||
|
{
|
||
|
//�й���¼�Ĺ����豸�������ţ������ظ�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex FROM T_Base_Device where F_DeviceIndex=").Append(message[i + 5]).Append(" and F_ErrorTaskNo=").Append(message[i + 2]);
|
||
|
|
||
|
//20100108
|
||
|
DataTable dt = dbo.ExceSQL(sql.ToString()).Tables[0];
|
||
|
if (dt.Rows.Count >= 1)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status= ").Append((message[i + 4]+30)).Append(" where (F_MonitorIndex= ").Append(message[i + 2]).Append(") and ((F_Status<> ").Append((message[i + 4]+30)).Append(") and (F_Status<> 3))");
|
||
|
SQLString(dbo, sql);
|
||
|
//20110608dbo.ExceSQL(sql.ToString());
|
||
|
DataSourceChange();//20110405
|
||
|
}
|
||
|
dt = null;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV���ع��ϣ�" + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[6];
|
||
|
Array.Copy(message, i, chatnew, 0, 6);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV���ع���", chatnew);
|
||
|
i += 6;
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
#endregion
|
||
|
case 60055://60055[T1][T2] AGV������������Ҫ����Ӧ��֡������
|
||
|
#region AGV��������
|
||
|
|
||
|
if (message.Length >= 3)
|
||
|
{
|
||
|
if (message.Length <= (i + 2)) break;
|
||
|
try
|
||
|
{
|
||
|
int fid = message[i + 1];
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(message[i + 2]);
|
||
|
int fid1 = 0;
|
||
|
int mankind1 =0;
|
||
|
///////////////////////
|
||
|
string[] df = CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001);
|
||
|
bool snyc = CGeneralFunction.DoubleForkIfSync(message[i + 2], 1001, 6);
|
||
|
//����DeviceIndex,�õ�SocketsͨѶ�ij�ʼ����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex,F_DeviceKindIndex, F_LocalIP, F_LocalPort, F_RemoteIP, F_RemotePort FROM T_Base_Device where F_DeviceIndex=1001");
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{//AGV�������ɵ�Ӧ��:60031[T1][T2](��60055[T1][T2]��Ӧ��)
|
||
|
_Sdata = new byte[6];
|
||
|
_Sdata[0] = Convert.ToByte(60031 & 255);
|
||
|
_Sdata[1] = Convert.ToByte(60031 >> 8);
|
||
|
|
||
|
_Sdata[2] = Convert.ToByte(message[i + 1] & 255);
|
||
|
_Sdata[3] = Convert.ToByte(message[i + 1] >> 8);
|
||
|
_Sdata[4] = Convert.ToByte(message[i + 2] & 255);
|
||
|
_Sdata[5] = Convert.ToByte(message[i + 2] >> 8);
|
||
|
if (SocketsTCPIP.CClientTCPIP.Send(dv[0]["F_RemoteIP"].ToString(), Convert.ToInt32(dv[0]["F_RemotePort"]), _Sdata) == true)
|
||
|
{
|
||
|
//20110412����״̬��0�����ɡ�������������1��ֻ���ɡ�����AGVȡ�����ء���2��ֻ���ɡ�����AGV�ͻ����ء���3�������ɡ������½���Ȼ�����ɡ�����AGV���ء�
|
||
|
int device = 0;
|
||
|
int devorder=GetDeviceOrderFromMonitor(message[i + 2]);
|
||
|
int MonitorIndex1 = -1;
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_NumParam2,F_RouteID,F_TxtParam,F_MonitorTaskLevel FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", message[i + 2])).Tables[0].DefaultView ;
|
||
|
if (dv.Count >0)
|
||
|
{
|
||
|
device = Convert.ToInt32(dv[0]["F_NumParam2"]);
|
||
|
}
|
||
|
///////////////////////
|
||
|
ActionFinish(1001, message[i + 2], 0);
|
||
|
#region ����������
|
||
|
AheadDetect.Clear();
|
||
|
AheadDetect.Append("I").Append(Convert.ToString(device - 2)).Append(";D").Append(Convert.ToString(device-2))
|
||
|
.Append(".0;I").Append(Convert.ToString(device));
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(mankind, fid, (device), 9, 0) == false)
|
||
|
{
|
||
|
int mindex = message[i + 2] - 1;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
||
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
||
|
" F_AheadDetect,F_TxtParam)").Append(
|
||
|
"VALUES (").Append(fid).Append(",").Append(mankind).Append(",").Append(mindex).Append(",").Append(dv[0]["F_MonitorTaskLevel"]
|
||
|
).Append(",").Append((device)).Append(",9,").Append(dv[0]["F_RouteID"]).Append(",0,").Append((device)).Append(",0").Append(
|
||
|
",'").Append(AheadDetect).Append("','").Append(dv[0]["F_TxtParam"]).Append("')");
|
||
|
SQLString(dbo, sql);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ����������������ͬ����ͬʱ�������ɣ��첽��ֱ��ִ�й���������
|
||
|
//20100323
|
||
|
if (df != null)//20100702
|
||
|
{
|
||
|
//20100817 zhangxy ��
|
||
|
fid1 = GetManageTaskIndexfromMonitor(Convert.ToInt32(df[0]));
|
||
|
mankind1 = GetManageTaskKindIndexFromMonitor(Convert.ToInt32(df[0]));
|
||
|
|
||
|
///////////////////////
|
||
|
if (snyc == true)//20100702
|
||
|
{
|
||
|
|
||
|
#region 20110412��������վ̨
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_NumParam2,F_RouteID,F_TxtParam,F_MonitorTaskLevel FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", Convert.ToInt32(df[0]))).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
device = Convert.ToInt32(dv[0]["F_NumParam2"]);
|
||
|
}
|
||
|
MonitorIndex1 = Convert.ToInt32(df[0])-1;
|
||
|
|
||
|
#endregion
|
||
|
ActionFinish(1001, Convert.ToInt32(df[0]), 1);
|
||
|
#region ����������
|
||
|
AheadDetect.Clear();
|
||
|
AheadDetect.Append("I").Append(Convert.ToString(device - 2)).Append(";D").Append(Convert.ToString(device - 2))
|
||
|
.Append(".0;I").Append(Convert.ToString(device));
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(mankind1, fid1, device, 9, 0) == false)
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
||
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
||
|
" F_AheadDetect,F_TxtParam)").Append(
|
||
|
"VALUES (").Append(fid).Append(",").Append(mankind).Append(",").Append(MonitorIndex1).Append(",").Append(dv[0]["F_MonitorTaskLevel"]
|
||
|
).Append(",").Append((device)).Append(",9,").Append(dv[0]["F_RouteID"]).Append(",0,").Append((device)).Append(",0").Append(
|
||
|
",'").Append(AheadDetect).Append("','").Append(dv[0]["F_TxtParam"]).Append("')");
|
||
|
SQLString(dbo, sql);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_tcpServerError = "��AGV����������" + message[i + 1] + "��Ӧ��ʱ������ʧ�ܣ�";
|
||
|
}
|
||
|
DataSourceChange();//20110405
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
chatnew = new ushort[3];
|
||
|
Array.Copy(message, i, chatnew, 0, 3);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV��������", chatnew);
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV��������," + ex.Message;
|
||
|
}
|
||
|
|
||
|
i += 3;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
case 60056://60056[T1][T2]
|
||
|
#region AGV����̨����ɾ������
|
||
|
if (message.Length >= 3)//
|
||
|
{
|
||
|
if (message.Length <= (i + 2)) break;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
int fid = 0;
|
||
|
int mankind = 0;
|
||
|
int tasktype = 0;
|
||
|
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Monitor_Task where F_MonitorIndex = ").Append(message[i + 2]);
|
||
|
DataView dvMonintor = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvMonintor.Count > 0)
|
||
|
{
|
||
|
fid = message[i + 1];
|
||
|
mankind = GetManageTaskKindIndexFromMonitor(message[i + 2]);
|
||
|
tasktype = GetFCONTROLTASKTYPEFromManageTask(mankind, fid);
|
||
|
if ((tasktype != 1) && ((tasktype != 4)))
|
||
|
{
|
||
|
|
||
|
i += 3;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
//����DeviceIndex,�õ�SocketsͨѶ�ij�ʼ����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex,F_DeviceKindIndex, F_LocalIP, F_LocalPort, F_RemoteIP, F_RemotePort FROM T_Base_Device where F_DeviceIndex=1001");
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
_Sdata = new byte[6];
|
||
|
_Sdata[0] = Convert.ToByte(60009 & 255);
|
||
|
_Sdata[1] = Convert.ToByte(60009 >> 8);
|
||
|
|
||
|
_Sdata[2] = Convert.ToByte(message[i + 1] & 255);
|
||
|
_Sdata[3] = Convert.ToByte(message[i + 1] >> 8);
|
||
|
_Sdata[4] = Convert.ToByte(message[i + 2] & 255);
|
||
|
_Sdata[5] = Convert.ToByte(message[i + 2] >> 8);
|
||
|
SocketsTCPIP.CClientTCPIP.Send(dv[0]["F_RemoteIP"].ToString(), Convert.ToInt32(dv[0]["F_RemotePort"]), _Sdata);
|
||
|
|
||
|
|
||
|
}
|
||
|
dv = null;
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV����̨����ɾ�����룬" + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[3];
|
||
|
Array.Copy(message, i, chatnew, 0, 3);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV����̨����ɾ������", chatnew);
|
||
|
i += 3;
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
#endregion
|
||
|
case 60057://60057[T1][T2][A] AΪ����״̬(0-������,1-����)
|
||
|
#region �Լ��ص�������ɾ�������Ļظ�
|
||
|
if (message.Length >= 4)//
|
||
|
{
|
||
|
if (message.Length <= (i + 3)) break;
|
||
|
try
|
||
|
{
|
||
|
if (message[i + 3] == 0)//0-������
|
||
|
{
|
||
|
i += 4;
|
||
|
break;
|
||
|
}
|
||
|
int fid = 0;
|
||
|
int mankind = 0;
|
||
|
int tasktype = 0;
|
||
|
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Monitor_Task where F_MonitorIndex = ").Append(message[i + 2]);
|
||
|
DataView dvMonintor = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvMonintor.Count > 0)
|
||
|
{
|
||
|
fid = message[i + 1];
|
||
|
mankind = GetManageTaskKindIndexFromMonitor(message[i + 2]);
|
||
|
tasktype = GetFCONTROLTASKTYPEFromManageTask(mankind, fid);
|
||
|
if ((tasktype != 1) && ((tasktype != 4)))
|
||
|
{
|
||
|
i += 4;
|
||
|
break;
|
||
|
}
|
||
|
DataView dv;
|
||
|
|
||
|
AAA:
|
||
|
string[] df = CGeneralFunction.GetDoubleForkMonitorInfo(message[i + 2], 1001);
|
||
|
SQLString(dbo, new StringBuilder("update T_Manage_Task set FExceptionNO=" + Model.CGeneralFunction.TASKDELETE + " where (F_ManageTaskKindIndex = " + mankind + ") AND (FID = " + fid + ")"));
|
||
|
//20110608dbo.ExceSQL("update T_Manage_Task set FExceptionNO=" + Model.CGeneralFunction.TASKDELETE + " where (F_ManageTaskKindIndex = " + mankind + ") AND (FID = " + fid + ")");
|
||
|
SQLString(dbo, new StringBuilder("update T_Monitor_Task set F_STATUS=-1 where F_ManageTaskKindIndex=" + mankind + " and F_ManageTaskIndex=" + fid + " and F_STATUS=0"));
|
||
|
//20110608dbo.ExceSQL("update T_Monitor_Task set F_STATUS=-1 where F_ManageTaskKindIndex=" + mankind + " and F_ManageTaskIndex=" + fid + " and F_STATUS=0");
|
||
|
dv = dbo.ExceSQL("SELECT F_ManageTaskKindIndex, F_ManageTaskIndex,F_DeviceIndex,F_MonitorIndex,F_Status,F_DeviceCommandIndex " +
|
||
|
",F_NumParam2,F_NumParam5,F_TxtParam FROM T_Monitor_Task Where F_ManageTaskIndex=" + fid + " and F_ManageTaskKindIndex= " +
|
||
|
mankind).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
//20100108
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive AGV��������", "�������룺" + dvMonintor[0]["F_TxtParam"], "������������:" + fid.ToString());
|
||
|
for (int j = 0; j < dv.Count; j++)
|
||
|
{
|
||
|
ActionFinish(Convert.ToInt32(dv[j]["F_DeviceIndex"]), Convert.ToInt32(dv[j]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);
|
||
|
//20110608ActionComplete(Convert.ToInt32(dv[j]["F_DeviceIndex"]), Convert.ToInt32(dv[j]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);
|
||
|
}
|
||
|
}
|
||
|
dv = null;
|
||
|
|
||
|
if (df != null)
|
||
|
{
|
||
|
fid = GetManageTaskIndexfromMonitor(Convert.ToInt32(df[0]));
|
||
|
mankind = GetManageTaskKindIndexFromMonitor(Convert.ToInt32(df[0]));
|
||
|
goto AAA;
|
||
|
|
||
|
}
|
||
|
DataSourceChange();//20110405
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV�Լ��ص�������ɾ�������Ļظ���" + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[4];
|
||
|
Array.Copy(message, i, chatnew, 0, 4);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV�Լ��ص�������ɾ�������Ļظ�", chatnew);
|
||
|
i += 4;
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
#endregion
|
||
|
case 60058://60058[N][A]
|
||
|
#region AGV�������������ڵ�
|
||
|
if (message.Length >= 3)//
|
||
|
{
|
||
|
if (message.Length <= (i + 2)) break;
|
||
|
try
|
||
|
{
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV�������������ڵ㣬" + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[3];
|
||
|
Array.Copy(message, i, chatnew, 0, 3);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV�������������ڵ�", chatnew);
|
||
|
i += 3;
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
#endregion
|
||
|
case 60059://60059[A][S][X][Y][G] AΪ����;SΪ״̬(0-������1-����);XΪX����;YΪY����;GΪ�Ƕ�
|
||
|
|
||
|
#region AGV����λ��״̬
|
||
|
if (message.Length >= 6)//
|
||
|
{
|
||
|
if (message.Length <= (i + 5)) break;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV����λ��״̬��" + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[6];
|
||
|
Array.Copy(message, i, chatnew, 0, 6);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV����λ��״̬", chatnew);
|
||
|
i += 6;
|
||
|
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
#endregion
|
||
|
case 60060://60060[T1][T2][A][C]
|
||
|
#region AGV���ϱ���
|
||
|
if (message.Length >= 5)//
|
||
|
{
|
||
|
if (message.Length <= (i + 4)) break;
|
||
|
try
|
||
|
{
|
||
|
//�й���¼�Ĺ����豸�������ţ������ظ�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex FROM T_Base_Device where F_DeviceIndex=").Append(message[i + 3]).Append(" and F_ErrorTaskNo=").Append(message[i + 2]);
|
||
|
|
||
|
//20100108
|
||
|
DataTable dt = dbo.ExceSQL(sql.ToString()).Tables[0];
|
||
|
if (dt.Rows.Count >= 1)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status= ").Append((message[i + 4]+30)).Append(" where (F_MonitorIndex= ").Append(message[i + 2]).Append(") and ((F_Status<> ").Append((message[i + 4]+30)).Append(") and (F_Status<> 3))");
|
||
|
SQLString(dbo, sql);
|
||
|
//20110608dbo.ExceSQL(sql.ToString());
|
||
|
DataSourceChange();//20110405
|
||
|
}
|
||
|
dt = null;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DisposeReceivedMessage:AGV���ϱ��棬" + ex.Message;
|
||
|
}
|
||
|
chatnew = new ushort[5];
|
||
|
Array.Copy(message, i, chatnew, 0, 5);
|
||
|
CCarryConvert.WriteDarkCasket("ReceiveAGV", "SocketsTCPIP.CConnectTCPIP", "Receive", "AGV���ϱ���", chatnew);
|
||
|
i += 5;
|
||
|
|
||
|
}
|
||
|
break;
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CConnectTCPIP.DisposeReceiveMessage:" + ex.Message;
|
||
|
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
chatnew = null;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
public static int GetAgvSquence(int agvGate)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_Sequence FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = ").Append(agvGate).Append(")");
|
||
|
object ob = dbo.GetSingle(sql.ToString());
|
||
|
if (ob != null)
|
||
|
{
|
||
|
return Convert.ToInt32(ob);
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
public static int GetUseAwayFork(int taskno)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_UseAwayFork FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(taskno).Append(")");
|
||
|
string obj = dbo.GetSingle(sql.ToString()).ToString();
|
||
|
if (obj == "-")
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return Convert.ToInt32(obj);
|
||
|
}
|
||
|
}
|
||
|
public static int GetFCONTROLTASKTYPEFromManageTask(int taskKindIndex, int Managefid)
|
||
|
{
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FID = " ).Append( Managefid ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( taskKindIndex ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (dv[0]["FCONTROLTASKTYPE"] == DBNull.Value) return -1;
|
||
|
return Convert.ToInt32(dv[0]["FCONTROLTASKTYPE"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����Զ�������Ͱ��������˿�
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public static bool ConnectTcpIPServer()
|
||
|
{
|
||
|
string remoteIP; int remotePort; string localIP; int localPort;
|
||
|
//20100127
|
||
|
DataView dv;
|
||
|
IPAddress ipAddress ;
|
||
|
IPEndPoint EPlocal;
|
||
|
try
|
||
|
{
|
||
|
//����DeviceIndex,�õ�SocketsͨѶ�ij�ʼ����
|
||
|
//20100127
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex,F_DeviceKindIndex, F_LocalIP, F_LocalPort, F_RemoteIP, F_RemotePort FROM T_Base_Device where F_DeviceIndex=1001 and F_DeviceKindIndex=6");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dv.Count == 0)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
remoteIP = (dv[0]["F_RemoteIP"]).ToString();
|
||
|
localIP = (dv[0]["F_LocalIP"]).ToString();
|
||
|
remotePort = Convert.ToInt32(dv[0]["F_RemotePort"]);
|
||
|
localPort = Convert.ToInt32(dv[0]["F_LocalPort"]);
|
||
|
}
|
||
|
//20100127
|
||
|
ipAddress = IPAddress.Parse(localIP);
|
||
|
//20100127
|
||
|
EPlocal = new IPEndPoint(ipAddress, localPort);
|
||
|
|
||
|
|
||
|
// Create a TCP/IP socket.
|
||
|
if (Localsocket == null)
|
||
|
{
|
||
|
Localsocket = new Socket(AddressFamily.InterNetwork,
|
||
|
SocketType.Stream, ProtocolType.Tcp);
|
||
|
Localsocket.Bind((EndPoint)EPlocal);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
if (SocketsTCPIP.CClientTCPIP.IfInit == false)
|
||
|
{
|
||
|
if (SocketsTCPIP.CClientTCPIP.InitClientTCPIP(remoteIP, remotePort) == false)
|
||
|
{
|
||
|
_tcpServerError = SocketsTCPIP.CClientTCPIP.TcpError;
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ConnectedServer = true;
|
||
|
|
||
|
return ConnectedServer;
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CConnectTCPIP.ConnectTcpIPServer:" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dv = null;
|
||
|
ipAddress =null ;
|
||
|
EPlocal = null;
|
||
|
remoteIP = null;
|
||
|
localIP = null;
|
||
|
}
|
||
|
}
|
||
|
public static void EndListen()
|
||
|
{//20091107
|
||
|
exitThread=true ;
|
||
|
if (SocketsTCPIP.CClientTCPIP.ClientSocket != null)
|
||
|
{
|
||
|
SocketsTCPIP.CClientTCPIP.ClientSocket.Close();
|
||
|
}
|
||
|
if (mythread != null)
|
||
|
{
|
||
|
mythread.Abort();
|
||
|
|
||
|
mythread = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void StartListen()
|
||
|
{
|
||
|
exitThread = false ;
|
||
|
if (mythread == null)
|
||
|
{
|
||
|
mythread = new Thread(new ThreadStart(BeginListen));
|
||
|
mythread.IsBackground = true;
|
||
|
}
|
||
|
if (mythread.ThreadState != ThreadState.Running)
|
||
|
{
|
||
|
mythread.Start();
|
||
|
}
|
||
|
}
|
||
|
public static void ActionComplete(int DeviceIdx, int TaskIdx, int ClearZero)
|
||
|
{
|
||
|
int devKind = GetDeviceKindIdx(DeviceIdx);
|
||
|
int order = GetDeviceOrderFromMonitor(TaskIdx);
|
||
|
int fid = GetManageTaskIndexfromMonitor(TaskIdx);
|
||
|
int mti = GetManageTaskKindIndexFromMonitor(TaskIdx);
|
||
|
//20100710
|
||
|
#region ȡ��AGV�Ż������ͻ��ı��ţ�AGVͨ���ڵ�ͣ�����豸��
|
||
|
|
||
|
int AgvNextConveyor = 0;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_NumParam5 FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(TaskIdx).Append(") ");
|
||
|
object ob = dbo.GetSingle(sql.ToString());
|
||
|
if (ob != null)
|
||
|
{
|
||
|
if (GetDeviceKindIdx(Convert.ToInt32(ob)) == 2)
|
||
|
{
|
||
|
AgvNextConveyor = Convert.ToInt32(ob);
|
||
|
}
|
||
|
}//20100710
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
string cap;
|
||
|
int errrcode = GetExceptionNOFromManageTask(fid, mti);
|
||
|
DataView dv;//20100127
|
||
|
//dbo.TransBegin();
|
||
|
try
|
||
|
{
|
||
|
//20100127
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select count(F_MonitorIndex) as counts from T_Monitor_Task " ).Append(
|
||
|
" where F_ManageTaskIndex =" ).Append( fid ).Append( " and F_ManageTaskKindIndex= " ).Append( mti);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (Convert.ToInt32(dv[0]["counts"]) == 1)
|
||
|
{
|
||
|
//�̶�·��ģʽ
|
||
|
//����������fid������һ�����طֽ���������
|
||
|
|
||
|
if (mti == 1)
|
||
|
{
|
||
|
cap = "��������";
|
||
|
//����FSTATUS=999��970�Ѷ����ͻ��ع����쳣���ɣ�980�Ѷ���ȡ�չ����쳣���ɣ�990����ɨ���쳣���ɣ����ȳ���ɾ����������900
|
||
|
if (errrcode > 900)//�쳣����
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set Control_STATUS=" ).Append( errrcode ).Append( " where Control_ID=" ).Append( fid);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (ClearZero == Model.CGeneralFunction.TASKDELETE)//���ȳ���ɾ����������900
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set Control_STATUS=" ).Append( Model.CGeneralFunction.TASKDELETE ).Append( " where Control_ID=" ).Append( fid);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else//����FSTATUS=999
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set Control_STATUS=" ).Append( Model.CGeneralFunction.TASKFINISH ).Append( " where Control_ID=" ).Append( fid);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (mti == 4)
|
||
|
{
|
||
|
cap = "�ֹ�����";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cap = "��ʱ����";
|
||
|
}
|
||
|
//�������
|
||
|
if (ClearZero == Model.CGeneralFunction.TASKDELETE)//���ȳ���ɾ����������900
|
||
|
{
|
||
|
ReturnManageInfo(fid, mti, cap, false);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ReturnManageInfo(fid, mti, cap, true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#region AGV�����ͻ��Ż�����������20110110
|
||
|
if ((AgvNextConveyor > 0) && (order == 3) && (ClearZero != Model.CGeneralFunction.TASKDELETE))
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=1 where F_DeviceIndex=" ).Append( AgvNextConveyor ).Append( " ");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//�������������������豸ȫ������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_LockedState=" ).Append( TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
|
||
|
if (ClearZero == 1)
|
||
|
{
|
||
|
|
||
|
if (mti == 1)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE IO_CONTROL SET ERROR_TEXT ='' WHERE Control_ID=" ).Append( fid ).Append( " and Control_STATUS<900");
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex=" ).Append( TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.ActionComplete:" + ex.Message;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
static void ReturnManageInfo(int fid, int mti, string cap, bool IFOK)
|
||
|
{
|
||
|
//20100127
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
//200906240111���ӻ�λ��¼:����1-����λ���л�������2-��ʼλ����������3-��ʼλ����������λ���л�
|
||
|
//20100127
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex,FCONTROLTASKTYPE, FSTARTDEVICE,FSTARTCELL, FENDDEVICE,FENDCELL FROM T_Manage_Task where F_ManageTaskKindIndex=" ).Append( mti ).Append( " and FID=" ).Append( fid ).Append( "");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
switch (dv[0]["FCONTROLTASKTYPE"].ToString())
|
||
|
{
|
||
|
case "1":
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FCELLSTATUS = 1 WHERE (FLaneWay=" ).Append( dv[0]["FENDDEVICE"] ).Append( " and FCELLCODE = '" ).Append( dv[0]["FENDCELL"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
break;
|
||
|
case "2":
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FCELLSTATUS =0 WHERE (FLaneWay=" ).Append( dv[0]["FSTARTDEVICE"] ).Append( " and FCELLCODE = '" ).Append( dv[0]["FSTARTCELL"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
break;
|
||
|
case "3":
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FCELLSTATUS = 1 WHERE (FLaneWay=" ).Append( dv[0]["FENDDEVICE"] ).Append( " and FCELLCODE = '" ).Append( dv[0]["FENDCELL"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FCELLSTATUS =0 WHERE (FLaneWay=" ).Append( dv[0]["FSTARTDEVICE"] ).Append( " and FCELLCODE = '" ).Append( dv[0]["FSTARTCELL"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
//20101028
|
||
|
string dtime = DateTime.Now.ToString("u");//20101028
|
||
|
dtime = dtime.Substring(0, dtime.Length - 1);//20101028
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FSTATUS=999,FENDTIME='" ).Append( dtime ).Append( "' where FID=" ).Append( fid ).Append( " and F_ManageTaskKindIndex= " ).Append( mti);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101028
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Manage_Task_BAK SELECT * FROM T_Manage_Task where FID=" ).Append( fid ).Append( " and F_ManageTaskKindIndex<>1");
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Manage_Task where FID=" ).Append( fid ).Append( " and F_ManageTaskKindIndex= " ).Append( mti);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100127
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dv = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public static int GetDeviceKindIdx(int devIdx)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_DeviceKindIndex FROM T_Base_Device WHERE F_DeviceIndex=" + devIdx);
|
||
|
|
||
|
DataSet ds = dbo.ExceSQL(sql.ToString());
|
||
|
DataView dv = ds.Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_DeviceKindIndex"]);
|
||
|
}
|
||
|
else
|
||
|
return 0;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
public static int GetManageTaskIndexfromMonitor(int monitorIdx)
|
||
|
{
|
||
|
//20100127
|
||
|
DataView dv;
|
||
|
try
|
||
|
{//20100127
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTaskIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = " ).Append( monitorIdx ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_ManageTaskIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100127
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
public static int GetManageTaskKindIndexFromMonitor(int monitorIdx)
|
||
|
{
|
||
|
//20100127
|
||
|
DataView dv;
|
||
|
try
|
||
|
{//20100127
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTaskKindIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = " ).Append( monitorIdx ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
public static int GetDeviceOrderFromMonitor(int MonitorIndex)
|
||
|
{
|
||
|
//20100127
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceCommandIndex from T_Monitor_Task where (F_DeviceCommandIndex IS NOT NULL) and F_MonitorIndex=" ).Append( MonitorIndex);
|
||
|
|
||
|
//20100127
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_DeviceCommandIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
public static int GetExceptionNOFromManageTask(int FID, int ManTaskKind)
|
||
|
{
|
||
|
//20100127
|
||
|
DataTable dt;
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FExceptionNO FROM T_Manage_Task WHERE (FID = " ).Append( FID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( ManTaskKind ).Append( ") ");
|
||
|
;
|
||
|
//20100127
|
||
|
dt = dbo.ExceSQL(sql.ToString()).Tables[0];
|
||
|
if (dt.Rows.Count > 0)
|
||
|
{
|
||
|
if (dt.Rows[0]["FExceptionNO"] == DBNull.Value)
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
return Convert.ToInt32(dt.Rows[0]["FExceptionNO"]);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100127
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dt = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
static int GetDeviceIndexFromAgvActive(int AgvActive)
|
||
|
{
|
||
|
//20100127AGV
|
||
|
DataView dva;
|
||
|
try
|
||
|
{
|
||
|
//20100127
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_AGVGateDeviceIndex, F_Address FROM T_Base_AGV_Gate WHERE (F_Active = " ).Append( AgvActive ).Append( ") ");
|
||
|
dva = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dva.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dva[0]["F_AGVGateDeviceIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
catch (Exception ex)
|
||
|
{//20100127
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dva = null;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
/// <param name="AgvAddress"></param>
|
||
|
/// <param name="ForkIndex">1,ǰ�棻2���棻3˫��</param>
|
||
|
/// <returns></returns>
|
||
|
static int GetDeviceIndexFromAgvAddress(int AgvAddress,int ForkIndex)
|
||
|
{
|
||
|
//20110110AGV
|
||
|
DataView dva;
|
||
|
try
|
||
|
{
|
||
|
string F_UseAwayFork = string.Empty;
|
||
|
if (ForkIndex == 1)//ǰ��,Զ��
|
||
|
{
|
||
|
F_UseAwayFork=" and F_UseAwayFork = '1' ";
|
||
|
}
|
||
|
else if (ForkIndex == 2)
|
||
|
{
|
||
|
F_UseAwayFork = " and F_UseAwayFork = '0' ";
|
||
|
}
|
||
|
else//3
|
||
|
{
|
||
|
F_UseAwayFork = " and F_UseAwayFork <> '-' ";
|
||
|
}
|
||
|
//20100127
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_AGVGateDeviceIndex, F_Address FROM T_Base_AGV_Gate WHERE (F_Address = " ).Append( AgvAddress ).Append( ") ").Append(F_UseAwayFork);
|
||
|
dva = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dva.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dva[0]["F_AGVGateDeviceIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100127
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dva = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// �Ƿ�������
|
||
|
/// </summary>
|
||
|
/// <param name="deviceindex"></param>
|
||
|
/// <returns></returns>
|
||
|
static bool IfHaveLogicGoods(int deviceindex)
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_HaveGoods FROM T_Base_Device where F_HaveGoods=1 and F_DeviceIndex=" + deviceindex).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
static int GetCorrDeviceIndex(int device)
|
||
|
{//20110412
|
||
|
int deviceCorr=0;
|
||
|
if ((device % 2) == 1)
|
||
|
{
|
||
|
deviceCorr = device - 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
deviceCorr = device + 1;
|
||
|
}
|
||
|
return deviceCorr;
|
||
|
}
|
||
|
static string GetDeviceS7Connection(int deviceindex)
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_S7Connection FROM T_Base_Device WHERE (F_DeviceIndex = "+deviceindex+")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return dv[0]["F_S7Connection"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 20110405������ͼ����
|
||
|
/// </summary>
|
||
|
static void DataSourceChange()
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from V_Monitor_Task where ").Append(CStaticClass.Monstatus).Append(" order by �豸ָ������ asc ");
|
||
|
DataView dvmon = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from V_Manage_Task where ").Append(CStaticClass.Manstatus);
|
||
|
DataView dvman = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
CDataChangeEventArgs e = new CDataChangeEventArgs(dvman, dvmon);
|
||
|
OnDataChange(e);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 20110608ִ��SQL��������
|
||
|
/// </summary>
|
||
|
/// <param name="sqlList"></param>
|
||
|
static void SQLString(DBOperator dbo,StringBuilder sql)
|
||
|
{
|
||
|
|
||
|
CUpdateDBChangeEventArgs e = new CUpdateDBChangeEventArgs(dbo,sql);
|
||
|
OnUpdateDB(e);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 20110608��������
|
||
|
/// </summary>
|
||
|
/// <param name="device"></param>
|
||
|
/// <param name="task"></param>
|
||
|
/// <param name="taskstate"></param>
|
||
|
static void ActionFinish(int device, int task, int taskstate)
|
||
|
{
|
||
|
CUpdateDBChangeEventArgs e = new CUpdateDBChangeEventArgs(device,task,taskstate);
|
||
|
OnUpdateDB(e);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �жϵ��ȱ�T_Monitor_Task�Ƿ����ڵ����������豸������
|
||
|
/// </summary>
|
||
|
/// <param name="Mankind">������������</param>
|
||
|
/// <param name="ManFID">������������</param>
|
||
|
/// <param name="DeviceIndex">�豸����</param>
|
||
|
/// <param name="Order">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
public static bool DeviceAndOrderExitInMonitor(int Mankind, int ManFID, int DeviceIndex, int Order, int ArrowAddress)
|
||
|
{
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
if (Order == -1) return true;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
switch (GetDeviceKindIdx(DeviceIndex))
|
||
|
{
|
||
|
case 1://�Ѷ���
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
||
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
||
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(")");
|
||
|
break;
|
||
|
case 2://���ͻ�
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
||
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
||
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(")");
|
||
|
break;
|
||
|
case 4://RGV
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
||
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
||
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(") and F_NumParam1=").Append(ArrowAddress);
|
||
|
break;
|
||
|
case 6://AGV
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
||
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
||
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(")");
|
||
|
break;
|
||
|
default:
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
||
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
||
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(")");
|
||
|
break;
|
||
|
}
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_tcpServerError = "CListenAGVState.DeviceAndOrderExitInMonitor:" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|