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.
2307 lines
98 KiB
2307 lines
98 KiB
3 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
using System.Data;
|
||
|
using DBFactory;
|
||
|
|
||
|
namespace Model
|
||
|
{
|
||
|
public static class CGeneralFunction
|
||
|
{
|
||
|
static StringBuilder sql = new StringBuilder();
|
||
|
static DBOperator dbo = CGetInfo.dbo;
|
||
|
static DBOperator dboM = CGetInfo.dboM;
|
||
|
static Model.MDevice devinfo;
|
||
|
/// <summary>
|
||
|
/// 20120616�������������Ƿ��ܺ�monitorIndexͬ������;���ض��������������豸ָ���������飨���������ţ������Լ���������ֻ�����Լ�������ֻ���Լ�һ�������ţ���������������û�в������ϣ��ȴ�
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns>���������������豸ָ���������飬���������Լ���������������û�в������ϣ��ȴ�</returns>
|
||
|
public static int[] MutiForkIfSync(int monitorIndex, int devIndex, int devKind)
|
||
|
{//���ҹ����ĵ������������������߸����������ͻ����Ѷ��������Դ�
|
||
|
//����ֻ���ҵ���������δ�����֣���ô��Ϊ��ͬ������20100323
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(monitorIndex);
|
||
|
int FID = GetManageTaskIndexfromMonitor(monitorIndex);
|
||
|
int devOrder = GetDeviceOrderFromMonitor(monitorIndex);
|
||
|
Dictionary<int, int[]> mutiTaskZxyForkNo = GetMutiForkTaskZxyForkNo(mankind,FID,devIndex,devOrder);
|
||
|
int relaiddd = GetRELATIVECONTORLIDFromManageTask(mankind, FID);
|
||
|
if (mutiTaskZxyForkNo == null) return null;
|
||
|
int[] monitortask;
|
||
|
List<int> mt = new List<int>();
|
||
|
if (GetMutiForkUnIntoStep(monitorIndex) == true)
|
||
|
{//����ֻ����ǰ����ʱʹ��
|
||
|
monitortask = new int[1] { monitorIndex };
|
||
|
return monitortask;
|
||
|
}
|
||
|
int[] zxy,zxy1;
|
||
|
switch (devKind)
|
||
|
{
|
||
|
case 1:
|
||
|
//�Ѷ�����ͬ�ţ�ͬ�㣬���п���ͬ������ST_CELL��FDoubleForkֵƥ��
|
||
|
|
||
|
zxy = mutiTaskZxyForkNo[monitorIndex];
|
||
|
foreach (int mtask1 in mutiTaskZxyForkNo.Keys)
|
||
|
{
|
||
|
zxy1 = mutiTaskZxyForkNo[mtask1];
|
||
|
if (monitorIndex != mtask1)
|
||
|
{
|
||
|
if ((zxy[0] == zxy1[0]) && (zxy[2] == zxy1[2]) && ((zxy[1] - zxy1[1]) == (zxy[3] - zxy1[3])))
|
||
|
{//ͬ�š��㣬�������Ų�ֵ==�в�ֵ��ͬ������
|
||
|
if (mt.Contains(monitorIndex) == false)
|
||
|
{
|
||
|
mt.Add(monitorIndex);
|
||
|
}
|
||
|
if (mt.Contains(mtask1) == false)
|
||
|
{
|
||
|
mt.Add(mtask1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
if (mt.Count > 0)
|
||
|
{
|
||
|
monitortask = mt.ToArray();
|
||
|
return monitortask;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
case 2:
|
||
|
//���ͻ�ͬ��
|
||
|
foreach (int mtask in mutiTaskZxyForkNo.Keys)
|
||
|
{
|
||
|
if (mt.Contains(mtask) == false)
|
||
|
{
|
||
|
mt.Add(mtask);
|
||
|
}
|
||
|
}
|
||
|
if (mt.Count >= 1)
|
||
|
{
|
||
|
monitortask = mt.ToArray();
|
||
|
return monitortask;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
case 6:
|
||
|
if (EqualAGVGateDoubleFork(mankind, FID, devIndex, devOrder) == true)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
#region add by lyj20180427 ���봩������Ŀ˫��������
|
||
|
case 40:
|
||
|
|
||
|
int[] monitorTaskNum=new int[2];
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
|
||
|
sql.Append("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task,dbo.T_Manage_Task WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and (F_ManageTaskIndex != ")
|
||
|
.Append(FID).Append(" )AND (dbo.T_Monitor_Task.F_ManageTASKKINDINDEX = ").Append(mankind).Append(") and F_RELATIVECONTORLID=").Append(FID);
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0 && dv[0]["mmi"] != DBNull.Value)
|
||
|
{
|
||
|
|
||
|
|
||
|
monitorTaskNum[0] = Convert.ToInt32(dv[0]["mmi"]);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���ҹ���������", devIndex.ToString(), "���ҹ���������" + monitorTaskNum[0] + "��ǰ������" + monitorIndex.ToString());
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
|
||
|
sql.Append("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task,dbo.T_Manage_Task WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and (F_ManageTaskIndex = ")
|
||
|
.Append(relaiddd).Append(" )AND (dbo.T_Monitor_Task.F_ManageTASKKINDINDEX = ").Append(mankind).Append(") and F_RELATIVECONTORLID=").Append(relaiddd);
|
||
|
DataView dvv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���ҹ���������", devIndex.ToString(), "���ҹ�����������������ǰ������" + monitorIndex.ToString());
|
||
|
if (dvv.Count > 0 && dvv[0]["mmi"] != DBNull.Value)
|
||
|
{
|
||
|
monitorTaskNum[0] = Convert.ToInt32(dvv[0]["mmi"]);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
return monitorTaskNum;
|
||
|
#endregion
|
||
|
default:
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
public static int GetRELATIVECONTORLIDFromManageTask(int taskKindIndex, int Managefid)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_RELATIVECONTORLID 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]["F_RELATIVECONTORLID"] == DBNull.Value) return -1;
|
||
|
return Convert.ToInt32(dv[0]["F_RELATIVECONTORLID"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100108
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
dv.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <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 = new DataView(); 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.Dispose(); ;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ؾ���ԭ��λ�õ�б��ƽ��
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex"></param>
|
||
|
/// <param name="devinfo"></param>
|
||
|
/// <param name="devOrder"></param>
|
||
|
/// <returns></returns>
|
||
|
public static double GetMinZeroDistance(int monitorIndex,Model.MDevice devinfo, int devOrder)
|
||
|
{
|
||
|
int x = GetXCoorFromMonitor(monitorIndex, devinfo.DeviceIndex, devOrder);
|
||
|
int y = GetYCoorFromMonitor(monitorIndex, devinfo.DeviceIndex, devOrder);
|
||
|
int xzero=0,yzero=0;
|
||
|
if (devinfo.StackZeroColLayer != "")
|
||
|
{
|
||
|
char[] cc = new char[1] { ',' };
|
||
|
string[] xy = devinfo.StackZeroColLayer.Split(cc);
|
||
|
if (xy.GetLength(0) <= 1) return -1;
|
||
|
xzero = Convert.ToInt32(xy[0]);
|
||
|
yzero = Convert.ToInt32(xy[1]);
|
||
|
return Math.Pow(Convert.ToDouble( x - xzero), 2) + Math.Pow(Convert.ToDouble(y - yzero), 2);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
public static void GetMinZeroDistanceTask(int[] mtasks , Model.MDevice devinfo, int devOrder,out int mintask ,out double minDist)
|
||
|
{
|
||
|
minDist = 0; mintask = 0;
|
||
|
double temp = 0; minDist = 0;
|
||
|
foreach (int monitorIndex in mtasks)
|
||
|
{
|
||
|
|
||
|
int x = GetXCoorFromMonitor(monitorIndex, devinfo.DeviceIndex, devOrder);
|
||
|
int y = GetYCoorFromMonitor(monitorIndex, devinfo.DeviceIndex, devOrder);
|
||
|
int xzero = 0, yzero = 0;
|
||
|
if (devinfo.StackZeroColLayer != "")
|
||
|
{
|
||
|
char[] cc = new char[1] { ',' };
|
||
|
string[] xy = devinfo.StackZeroColLayer.Split(cc);
|
||
|
xzero = Convert.ToInt32(xy[0]);
|
||
|
yzero = Convert.ToInt32(xy[1]);
|
||
|
temp = Math.Pow(Convert.ToDouble(x - xzero), 2);// 20130704 +Math.Pow(Convert.ToDouble(y - yzero), 2)
|
||
|
}
|
||
|
if (temp <= minDist)
|
||
|
{
|
||
|
minDist = temp;
|
||
|
mintask = monitorIndex;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (minDist == 0)
|
||
|
{
|
||
|
minDist = temp;
|
||
|
mintask = monitorIndex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
public static int GetDoubleForkFromST_CELL(int z, int x, int y, string FWAREHOUSE)
|
||
|
{
|
||
|
DataView dv = new DataView();; 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.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
public static string GetWAREHOUSEFromSTCELL(int stackIndex)
|
||
|
{
|
||
|
DataView dv=new DataView();
|
||
|
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.Dispose(); }
|
||
|
}
|
||
|
/// <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 = new DataView(); ;
|
||
|
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 F_RELATIVECONTORLID from T_Manage_Task where (FID = " ).Append(
|
||
|
fid ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( mankind ).Append( ")");
|
||
|
DataView dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv0.Count == 0) return -1;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( xc ).Append( " FROM T_Monitor_Task Where ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind
|
||
|
).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder ).Append( ") AND (T_Monitor_Task.F_ManageTaskIndex=" ).Append( dv0[0]["F_RELATIVECONTORLID"] ).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 T_Manage_Task.FID from T_Manage_Task where (T_Manage_Task.F_ManageTaskKindIndex = ").Append(mankind).Append(") AND (F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( ")");
|
||
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv0.Count == 0) return -1;
|
||
|
//���ҹ����Լ������豸ָ��������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT ").Append(xc).Append(" FROM T_Monitor_Task Where ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).Append( ") and (F_DeviceIndex=" ).Append( devIdx ).Append( " and F_DeviceCommandIndex=" ).Append( devOrder
|
||
|
).Append( ") and (T_Monitor_Task.F_ManageTaskIndex= " ).Append( dv0[0]["FID"] ).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.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <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 = new DataView();
|
||
|
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 F_RELATIVECONTORLID from T_Manage_Task where FID = " ).Append(
|
||
|
fid ).Append( " and F_ManageTaskKindIndex=").Append(mankind );
|
||
|
DataView dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv0.Count == 0) return -1;
|
||
|
//���ұ����������豸ָ�������IJ�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( yc ).Append( " FROM T_Monitor_Task Where (T_Monitor_Task.F_ManageTaskIndex=" ).Append( dv0[0]["F_RELATIVECONTORLID"] ).Append( " " ).Append(
|
||
|
" ) and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).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]);
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select FID from T_Manage_Task where F_RELATIVECONTORLID = " ).Append(
|
||
|
fid ).Append( " and F_ManageTaskKindIndex=" ).Append( mankind );
|
||
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv0.Count == 0) return -1;
|
||
|
|
||
|
//���ҹ����Լ������豸ָ�������IJ�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT " ).Append( yc ).Append( " FROM T_Monitor_Task Where (T_Monitor_Task.F_ManageTaskIndex=" ).Append( dv0[0]["FID"] ).Append( " " ).Append(
|
||
|
") and ( T_Monitor_Task.F_ManageTaskKindIndex = " ).Append( mankind ).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.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <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 = new DataView();
|
||
|
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.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public static Dictionary<int, int[]> GetMutiForkTaskZxyForkNo(int mankind, int fid, int devIdx, int devOrder)
|
||
|
{//20120616
|
||
|
Dictionary<int, int[]> rettask = new Dictionary<int, int[]>();
|
||
|
DataView dv = new DataView(); DataView dv1 = new DataView();
|
||
|
int RELATIVECONTORLID=-1;
|
||
|
string zc = "F_NumParam1"; string xc = "F_NumParam2"; string yc = "F_NumParam3";
|
||
|
StringBuilder devstr= new StringBuilder(" and F_DeviceIndex=").Append(devIdx);
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4)
|
||
|
{
|
||
|
zc = "F_NumParam1";
|
||
|
xc = "F_NumParam2";
|
||
|
yc = "F_NumParam3";
|
||
|
}
|
||
|
else if (devOrder == 5)
|
||
|
{
|
||
|
zc = "F_NumParam4";
|
||
|
xc = "F_NumParam5";
|
||
|
yc = "F_NumParam6";
|
||
|
}
|
||
|
}
|
||
|
else if (GetDeviceKindIdx(devIdx) == 6)
|
||
|
{//1����,2ȡ��,3�ͻ�,4ȡ�ͻ�,5����AGV����
|
||
|
if (devOrder == 2)
|
||
|
{
|
||
|
zc = "F_NumParam1";
|
||
|
xc = "F_NumParam2";
|
||
|
yc = "F_NumParam3";
|
||
|
}
|
||
|
else if (devOrder == 3)
|
||
|
{
|
||
|
zc = "F_NumParam4";
|
||
|
xc = "F_NumParam5";
|
||
|
yc = "F_NumParam6";
|
||
|
}
|
||
|
}
|
||
|
else if (GetDeviceKindIdx(devIdx) == 2)
|
||
|
{
|
||
|
devstr = new StringBuilder(" and F_DeviceIndex like '%").Append(devIdx.ToString().Substring(0,5)).Append("%'");
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_RELATIVECONTORLID from T_Manage_Task where (FID = ").Append(
|
||
|
fid).Append(") AND (F_ManageTaskKindIndex = ").Append(mankind).Append(") and F_RELATIVECONTORLID>0");
|
||
|
DataView dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv0.Count == 0) return null ;
|
||
|
RELATIVECONTORLID = Convert.ToInt32(dv0[0]["F_RELATIVECONTORLID"]);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,").Append(zc).Append(",").Append(xc).Append(",").Append(yc)
|
||
|
.Append(",F_UseAwayFork,T_Manage_Task.F_ManageTaskKindIndex,fid FROM T_Monitor_Task,T_Manage_Task Where ( T_Monitor_Task.F_ManageTaskKindIndex = ").Append(mankind
|
||
|
).Append(")").Append(devstr.ToString()).Append(" and F_DeviceCommandIndex=")
|
||
|
.Append(devOrder).Append(" AND (F_RELATIVECONTORLID=").Append(RELATIVECONTORLID).Append(")")
|
||
|
.Append(" and T_Monitor_Task.F_ManageTaskIndex=FID");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
//int rmankind = Convert.ToInt32(dv[i]["F_ManageTaskKindIndex"]);
|
||
|
//int rman = Convert.ToInt32(dv[i]["fid"]);
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(rman).Append(") AND (F_ManageTASKKINDINDEX = ").Append(rmankind).Append(")");
|
||
|
//dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//if (dv1.Count > 0)
|
||
|
//{
|
||
|
// if ((dv1[0]["mmi"] != DBNull.Value) && (dv1[0]["mmi"].ToString() != dv[i]["F_MonitorIndex"].ToString()))
|
||
|
// {
|
||
|
// continue;
|
||
|
// }
|
||
|
//}
|
||
|
int[] zxy = new int[4];
|
||
|
zxy[0] = Convert.ToInt32(dv[i][zc]);
|
||
|
zxy[1] = Convert.ToInt32(dv[i][xc]);
|
||
|
zxy[2] = Convert.ToInt32(dv[i][yc]);
|
||
|
zxy[3] = Convert.ToInt32(dv[i]["F_UseAwayFork"]);
|
||
|
rettask.Add(Convert.ToInt32(dv[i]["F_MonitorIndex"]), zxy);
|
||
|
}
|
||
|
return rettask;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <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= new DataView(); 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.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <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 = new DataView();
|
||
|
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;
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_RELATIVECONTORLID from T_Manage_Task where (FID = ").Append(
|
||
|
fid).Append(") AND (F_ManageTaskKindIndex = ").Append(mankind).Append(") and F_RELATIVECONTORLID>0");
|
||
|
DataView dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv0.Count == 0) return false;
|
||
|
int RELATIVECONTORLID = Convert.ToInt32(dv0[0]["F_RELATIVECONTORLID"]);
|
||
|
//���ұ����������豸ָ��������������
|
||
|
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 (FID = " ).Append(
|
||
|
fid).Append(") and (F_DeviceIndex=").Append(devIdx).Append(" and F_DeviceCommandIndex=").Append(devOrder).Append(") and F_RELATIVECONTORLID=").Append(RELATIVECONTORLID);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
|
||
|
xd = Convert.ToInt32(dv[0][xc]);
|
||
|
dv = dbo.ExceSQL("SELECT F_Sequence FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = " + xd + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
x = Convert.ToInt32(dv[0]["F_Sequence"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
x = 0;
|
||
|
}
|
||
|
}
|
||
|
if (x == 0)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
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]);
|
||
|
dv = dbo.ExceSQL("SELECT F_Sequence FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = " + xd1 + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
x1 = Convert.ToInt32(dv[0]["F_Sequence"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
x1 = 0;
|
||
|
}
|
||
|
int DoubleFork = 0, DoubleFork1 = 0;
|
||
|
dv = dbo.ExceSQL("SELECT F_UseAwayFork,F_IfChannelLeft FROM T_Base_AGV_Gate WHERE F_AGVGateDeviceIndex =" + xd).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
DoubleFork = Convert.ToInt32(dv[0]["F_UseAwayFork"]);
|
||
|
channelleft = Convert.ToInt32(dv[0]["F_IfChannelLeft"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
dv = dbo.ExceSQL("SELECT F_UseAwayFork,F_IfChannelLeft FROM T_Base_AGV_Gate WHERE F_AGVGateDeviceIndex =" + xd1).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.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���豸ָ�����б���ȡZ ������
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetZCoorFromMonitor(int monitorIndex, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
string zc = "F_NumParam1";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4 || devOrder == 2)
|
||
|
{
|
||
|
zc = "F_NumParam1";
|
||
|
}
|
||
|
else if (devOrder == 5 || devOrder == 3)
|
||
|
{
|
||
|
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.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���豸ָ�����б���ȡX ������
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetXCoorFromMonitor(int monitorIndex, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
string xc = "F_NumParam2";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4 || devOrder == 2)
|
||
|
{
|
||
|
xc = "F_NumParam2";
|
||
|
}
|
||
|
else if (devOrder == 5 || devOrder == 3)
|
||
|
{
|
||
|
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.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���豸ָ�����б���ȡY ������
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetYCoorFromMonitor(int monitorIndex, int devIdx, int devOrder)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
string yc = "F_NumParam3";
|
||
|
if (GetDeviceKindIdx(devIdx) == 1)
|
||
|
{
|
||
|
if (devOrder == 4 || devOrder == 2)
|
||
|
{
|
||
|
yc = "F_NumParam3";
|
||
|
}
|
||
|
else if (devOrder == 5 || devOrder == 3)
|
||
|
{
|
||
|
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.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ����˫�������豸ָ����Ϣ(����NULL��ʾû�У����ذ����Լ������л������豸ָ����Ϣ)����0�������š�1������
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <param name="devIdx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetDoubleLiftInfo(int monitorIndex, int devIdx)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
|
||
|
try
|
||
|
{
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(monitorIndex);
|
||
|
int fid = GetManageTaskIndexfromMonitor(monitorIndex);
|
||
|
int devOrder = GetDeviceOrderFromMonitor(monitorIndex);
|
||
|
int relFID = GetRelativeControlID(mankind, fid);
|
||
|
if (relFID == -1) return 0;
|
||
|
|
||
|
//--------��ȡ�豸���棬�������Ļ���ȡ��
|
||
|
string str_device = "";
|
||
|
int i_fork = 0;
|
||
|
switch (devIdx.ToString().Substring(5, 1))
|
||
|
{
|
||
|
case "1":
|
||
|
i_fork = 2;
|
||
|
str_device = devIdx.ToString().Substring(0, 5) + i_fork.ToString();
|
||
|
break;
|
||
|
case "2":
|
||
|
i_fork = 1;
|
||
|
str_device = devIdx.ToString().Substring(0, 5) + i_fork.ToString();
|
||
|
break;
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_TxtParam,F_DeviceIndex 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_DeviceIndex=").Append(str_device).Append(" and F_DeviceCommandIndex=").Append(devOrder).Append(") and F_RELATIVECONTORLID=").Append(relFID).Append(" and F_MonitorIndex<>").Append(monitorIndex);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return (int) dv[0]["F_MonitorIndex"];
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ض��������豸ָ����Ϣ(����NULL��ʾû�У����ذ����Լ������л������豸ָ����Ϣ)����0���豸ָ��������1����ǰ���⡾2���豸������3��·��
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <param name="devIdx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
public static Dictionary<int, string[]> GetDoubleForkMonitorInfo(int monitorIndex, int devIdx)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
|
||
|
Dictionary<int, string[]> rtd = new Dictionary<int, string[]>();;
|
||
|
string[] rr = null;
|
||
|
try
|
||
|
{//
|
||
|
devIdx =Convert.ToInt32( devIdx.ToString().Substring(0, 5));//20160419��������վ̨�Ĵ���
|
||
|
|
||
|
int mankind = GetManageTaskKindIndexFromMonitor(monitorIndex);
|
||
|
int fid = GetManageTaskIndexfromMonitor(monitorIndex);
|
||
|
int devOrder = GetDeviceOrderFromMonitor(monitorIndex);
|
||
|
int relFID = GetRelativeControlID(mankind, fid);
|
||
|
if (relFID == -1) return null;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
//20160419
|
||
|
sql.Append("SELECT F_MonitorIndex,F_AheadDetect,F_DeviceIndex,F_RouteID,F_TxtParam 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_DeviceIndex like '").Append(devIdx).Append("%' and F_DeviceCommandIndex=").Append(devOrder).Append(") and F_RELATIVECONTORLID=").Append(relFID ).Append(" and F_MonitorIndex<>").Append(monitorIndex);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dv.Count == 0) return null;
|
||
|
for(int i=0;i<dv.Count;i++)
|
||
|
{//20141201���ڷ���ûʹ��dv[i]������ʹ��dv[0]����������rr��ʹ��
|
||
|
rr = new string[4];
|
||
|
rr[0] = dv[i]["F_MonitorIndex"].ToString();
|
||
|
rr[1] = dv[i]["F_AheadDetect"].ToString();
|
||
|
rr[2] = dv[i]["F_DeviceIndex"].ToString();
|
||
|
rr[3] = dv[i]["F_RouteID"].ToString();
|
||
|
rtd.Add(Convert.ToInt32(dv[i]["F_MonitorIndex"]), rr);
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_AheadDetect,F_DeviceIndex,F_RouteID,F_TxtParam 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_DeviceIndex like '").Append(devIdx).Append("%' and F_DeviceCommandIndex=").Append(devOrder).Append(") and F_MonitorIndex=").Append(monitorIndex);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
rr = new string[4];//20141201���ڷ��ִ���ʹ��dv[0]����������rr��ʹ��
|
||
|
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();
|
||
|
rtd.Add(Convert.ToInt32(dv[0]["F_MonitorIndex"]), rr);
|
||
|
}
|
||
|
return rtd;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
rr = null;
|
||
|
rtd = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����δ���ֵĶ��������豸ָ��,true ������δ���ֵĶ��������豸ָ��
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">�豸ָ������</param>
|
||
|
/// <returns></returns>
|
||
|
public static bool GetMutiForkUnIntoStep(int monitorIndex)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
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 (F_RELATIVECONTORLID = ").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.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int GetManageTaskIndexfromMonitor(int monitorIdx)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv = new DataView();
|
||
|
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.Dispose();
|
||
|
}
|
||
|
}
|
||
|
public static int GetManageTaskKindIndexFromMonitor(int monitorIdx)
|
||
|
{//20100108
|
||
|
DataView dv = new DataView();
|
||
|
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.Dispose();
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
public static int GetRelativeControlID(int mankind, int fid)
|
||
|
{
|
||
|
object ob = dbo.GetSingle(string.Format("SELECT F_RELATIVECONTORLID FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = {0}) AND (FID = {1})", mankind, fid));
|
||
|
if (ob != null)
|
||
|
{
|
||
|
return Convert.ToInt32(ob);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
public static string GetXcorrFromForkNoAndDevice(int device, int forkno)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_ZXY FROM T_Base_Lane_Gate where F_LaneGateDeviceIndex like '{0}%' and F_UseAwayFork='{1}'",device,forkno )).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] zxy=dv[0][0].ToString().Split(cc);
|
||
|
if (zxy.GetLength(0) >= 2)
|
||
|
{
|
||
|
return zxy[1];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "0";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "0";
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �ڵ��ȶ������ҵ��豸����
|
||
|
/// </summary>
|
||
|
/// <param name="MonitorIndex">��������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetDeviceOrderFromMonitor(int MonitorIndex)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv = new DataView();
|
||
|
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.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int GetDeviceKindIdx(int devIdx)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(devIdx);
|
||
|
return devinfo.DeviceKind;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
//20170301
|
||
|
/// <summary>
|
||
|
/// �ڷ��ͻ����˲���ָ��֮ǰ���жϹ���ϵͳ�Ƿ�Ҫ������
|
||
|
/// CONTROL_BACK_FLAGΪ��ʱ����ʾ�������⣬Ϊ1ʱ��ʾ����
|
||
|
/// </summary>
|
||
|
/// <param name="ManageTaskIndex"></param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetBackFlagFromIOControl(int ManageTaskIndex)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select CONTROL_ID,CONTROL_BACK_FLAG from IO_CONTROL where (CONTROL_BACK_FLAG IS NOT NULL) and CONTROL_ID=").Append(ManageTaskIndex);
|
||
|
//20100108
|
||
|
|
||
|
dv = dboM.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["CONTROL_BACK_FLAG"]);//Ϊ1ʱ��ʾ�������ȴ�����ϵͳ�´�����
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 0;//��������
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
return 0;//��������
|
||
|
//throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
public static int GetDeviceIndexFromMonitor(int MonitorIndex)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv = new DataView();
|
||
|
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.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 20110608��ȡ�����豸ָ�ʼʱ��
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetMonitorTaskBeginTime(int monitorIndex)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_StartTime FROM T_Monitor_Task WHERE F_MonitorIndex = ").Append(monitorIndex);
|
||
|
object ob=dbo.GetSingle(sql.ToString());
|
||
|
if (ob != null)
|
||
|
{
|
||
|
return ob.ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "-";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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);
|
||
|
string cap;
|
||
|
int errrcode = GetExceptionNOFromManageTask(fid, mti);
|
||
|
DataView dv = new DataView();
|
||
|
//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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
//�������������������豸ȫ������
|
||
|
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)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100127
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int GetExceptionNOFromManageTask(int FID, int ManTaskKind)
|
||
|
{
|
||
|
//20100127
|
||
|
DataTable dt = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FExceptionNO FROM T_Manage_Task WHERE (FID = " + FID + ") AND (F_ManageTaskKindIndex = " + ManTaskKind + ") ");
|
||
|
//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.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
static void ReturnManageInfo(int fid, int mti, string cap, bool IFOK)
|
||
|
{
|
||
|
//20100127
|
||
|
DataView dv = new DataView();
|
||
|
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 );
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
////////////////////
|
||
|
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.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public const string DBSend = "DB1";
|
||
|
public const string DBGet = "DB2";
|
||
|
|
||
|
/// <summary>
|
||
|
/// 20110216����ReadSubscription��ʶ�ҵ��˶��ĵĿ�ʼ�豸
|
||
|
/// </summary>
|
||
|
/// <param name="sb">ReadSubscription��ʶ</param>
|
||
|
/// <returns></returns>
|
||
|
public static Model.MDevice GetDeviceReadSubscriptionDB2Data(StringBuilder sb)
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_DeviceIndex FROM T_Base_Device WHERE (F_DeviceIndex=" + sb.ToString() + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#region �����������ĵ�������״̬
|
||
|
|
||
|
/// <summary>
|
||
|
/// �����ȴ���Ĭ��0
|
||
|
/// </summary>
|
||
|
public static readonly int TASKWAIT = CGetInfo.GetIOControlStatus("TASKWAIT").StatusID;
|
||
|
/// <summary>
|
||
|
/// ������ʼ���У�Ĭ��10
|
||
|
/// </summary>
|
||
|
public static readonly int TASKRUN = CGetInfo.GetIOControlStatus("TASKRUN").StatusID;
|
||
|
/// <summary>
|
||
|
/// ���������ĵ���Ĭ��30
|
||
|
/// </summary>
|
||
|
public static readonly int TASKALTERROUTEAPPLY = CGetInfo.GetIOControlStatus("TASKALTERROUTEAPPLY").StatusID;
|
||
|
/// <summary>
|
||
|
/// �����ĵ����룬Ĭ��40
|
||
|
/// </summary>
|
||
|
public static readonly int TASKALTERROUTEREPLY = CGetInfo.GetIOControlStatus("TASKALTERROUTEREPLY").StatusID;
|
||
|
/// <summary>
|
||
|
/// ����������ɾ����Ĭ��900
|
||
|
/// </summary>
|
||
|
public static readonly int TASKDELETE = CGetInfo.GetIOControlStatus("TASKDELETE").StatusID;
|
||
|
/// <summary>
|
||
|
/// ָ���ط���Ĭ��920
|
||
|
/// </summary>
|
||
|
public static readonly int TASKRESTORE = CGetInfo.GetIOControlStatus("TASKRESTORE").StatusID;
|
||
|
/// <summary>
|
||
|
/// �˹���ͣ���⣬Ĭ��940
|
||
|
/// </summary>
|
||
|
public static readonly int TASKSTOPOUTPUT = CGetInfo.GetIOControlStatus("TASKSTOPOUTPUT").StatusID;
|
||
|
|
||
|
//54 PICKUPEMPTY ȡ����
|
||
|
//47 PICKUPWEIGHTLEFT �����Ż�ʱ�����л�
|
||
|
//48 PICKUPWEIGHTRIGHT �Ҳ��Ż�ʱ�����л�
|
||
|
//56 NEARSTOCKLEFT ����ȡԶ��ʱ�������л�
|
||
|
//57 NEARSTOCKRIGHT ����ȡԶ��ʱ�������л�
|
||
|
/// <summary>
|
||
|
/// ȡ���գ�Ĭ�� 54
|
||
|
/// </summary>
|
||
|
public static readonly int PICKUPEMPTY = CGetInfo.GetIOControlStatus("PICKUPEMPTY").StatusID;
|
||
|
/// <summary>
|
||
|
/// �����Ż�ʱ�����л���Ĭ�� 47
|
||
|
/// </summary>
|
||
|
public static readonly int PICKUPWEIGHTLEFT = CGetInfo.GetIOControlStatus("PICKUPWEIGHTLEFT").StatusID;
|
||
|
/// <summary>
|
||
|
/// �Ҳ��Ż�ʱ�����л���Ĭ��48
|
||
|
/// </summary>
|
||
|
public static readonly int PICKUPWEIGHTRIGHT = CGetInfo.GetIOControlStatus("PICKUPWEIGHTRIGHT").StatusID;
|
||
|
/// <summary>
|
||
|
/// ����ȡԶ��ʱ�������л���Ĭ�� 56
|
||
|
/// </summary>
|
||
|
public static readonly int NEARSTOCKLEFT = CGetInfo.GetIOControlStatus("NEARSTOCKLEFT").StatusID;
|
||
|
/// <summary>
|
||
|
/// ����ȡԶ��ʱ�������л���Ĭ�� 57
|
||
|
/// </summary>
|
||
|
public static readonly int NEARSTOCKRIGHT = CGetInfo.GetIOControlStatus("NEARSTOCKRIGHT").StatusID;
|
||
|
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// �������ʹ����͵����̻��IJ��ǿ������飬Ĭ��950
|
||
|
/// </summary>
|
||
|
public static readonly int TASKTYPEERROR = CGetInfo.GetIOControlStatus("TASKTYPEERROR").StatusID;
|
||
|
/// <summary>
|
||
|
/// ������ȡ�������˵��쳣����վ̨��Ĭ��960
|
||
|
/// </summary>
|
||
|
public static readonly int TASKCANCEL = CGetInfo.GetIOControlStatus("TASKCANCEL").StatusID;
|
||
|
/// <summary>
|
||
|
/// �Ѷ������ͻ�����Ҫ��·��������Ĭ��970
|
||
|
/// </summary>
|
||
|
public static readonly int TASKREPEATINPUT = CGetInfo.GetIOControlStatus("TASKREPEATINPUT").StatusID;
|
||
|
/// <summary>
|
||
|
/// �Ѷ�����ȡ�մ���������ȡ��ִ�й���������Ĭ��980
|
||
|
/// </summary>
|
||
|
public static readonly int TASKEMPTYOUTPUT = CGetInfo.GetIOControlStatus("TASKEMPTYOUTPUT").StatusID;
|
||
|
/// <summary>
|
||
|
/// �����쳣���ɣ�Ĭ��990
|
||
|
/// </summary>
|
||
|
public static readonly int TASKABEND = CGetInfo.GetIOControlStatus("TASKABEND").StatusID;
|
||
|
/// <summary>
|
||
|
/// �����������ɣ�Ĭ��999
|
||
|
/// </summary>
|
||
|
public static readonly int TASKFINISH = CGetInfo.GetIOControlStatus("TASKFINISH").StatusID;
|
||
|
/// <summary>
|
||
|
/// ��������RFID�ȶԴ�����Ĭ��ֵ930
|
||
|
/// </summary>
|
||
|
public static readonly int TASKINPUTRFIDERROR = CGetInfo.GetIOControlStatus("TASKINPUTRFIDERROR").StatusID;
|
||
|
/// <summary>
|
||
|
/// 20100617���������Գ�������ȷ�Ͻ��գ�Ĭ��ֵ50
|
||
|
/// </summary>
|
||
|
public static readonly int TASKOUTCONFIRM = CGetInfo.GetIOControlStatus("TASKOUTCONFIRM").StatusID;
|
||
|
/// <summary>
|
||
|
/// 20101011˫�漫��λ��Ҫ�������棬Ĭ��ֵ800
|
||
|
/// </summary>
|
||
|
public static readonly int TASKCHANGEFORK = CGetInfo.GetIOControlStatus("TASKCHANGEFORK").StatusID;
|
||
|
/// <summary>
|
||
|
/// 20120820˫�Ѷ���ͬ�죬����λ����Ҫ�����Ѷ���������ҵ��Ĭ��ֵ810
|
||
|
/// </summary>
|
||
|
public static readonly int TASKCHANGESTACK = CGetInfo.GetIOControlStatus("TASKCHANGESTACK").StatusID;
|
||
|
/// <summary>
|
||
|
/// 20101011�����Ѿ���ȡ������Ĭ��ֵ7
|
||
|
/// </summary>
|
||
|
public static readonly int TASKCONTROLREADED = CGetInfo.GetIOControlStatus("TASKCONTROLREADED").StatusID;
|
||
|
/// <summary>
|
||
|
/// 20101028�Ѷ�������������������ִ�У�Ĭ��ֵ��25
|
||
|
/// </summary>
|
||
|
public static readonly int TASKSINGLEFORKRUN = CGetInfo.GetIOControlStatus("TASKSINGLEFORKRUN").StatusID;
|
||
|
#region ɨ���쳣����20110210
|
||
|
/// <summary>
|
||
|
/// 20110210���������⡢����ɨ���쳣��Ĭ��ֵ��70
|
||
|
/// </summary>
|
||
|
public static readonly int TASKINPUTSCANERROR = CGetInfo.GetIOControlStatus("TASKINPUTSCANERROR").StatusID;
|
||
|
/// <summary>
|
||
|
/// 20110210��������¥����ɨ���쳣��Ĭ��ֵ��60
|
||
|
/// </summary>
|
||
|
public static readonly int TASKOUTPUTSCANERROR = CGetInfo.GetIOControlStatus("TASKOUTPUTSCANERROR").StatusID;
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �Ѷ���ȡ�պ����صĹ�����
|
||
|
///// <summary>
|
||
|
///// �Ѷ��������ع����룬Ĭ��48��˫���еĽ��棩
|
||
|
///// </summary>
|
||
|
//public static readonly int STACKREPEATINPUT =CGetInfo.GetIOControlStatus("STACKREPEATINPUT").StatusID;
|
||
|
///// <summary>
|
||
|
///// �Ѷ�����ȡ�չ����룬Ĭ��49��˫���еĽ��棩
|
||
|
///// </summary>
|
||
|
//public static readonly int STACKEMPTYOUTPUT =CGetInfo.GetIOControlStatus("STACKEMPTYOUTPUT").StatusID;
|
||
|
///// <summary>
|
||
|
///// �Ѷ��������ع����룬Ĭ��60��˫���е�Զ�棩
|
||
|
///// </summary>
|
||
|
//public static readonly int STACKREPEATINPUTAWAY = CGetInfo.GetIOControlStatus("STACKREPEATINPUTAWAY").StatusID;
|
||
|
///// <summary>
|
||
|
///// �Ѷ�����ȡ�չ����룬Ĭ��62��˫���е�Զ�棩
|
||
|
///// </summary>
|
||
|
//public static readonly int STACKEMPTYOUTPUTAWAY = CGetInfo.GetIOControlStatus("STACKEMPTYOUTPUTAWAY").StatusID;
|
||
|
///// <summary>
|
||
|
///// �Ѷ��������ع����룬Ĭ��61��˫�棩
|
||
|
///// </summary>
|
||
|
//public static readonly int STACKREPEATINPUTDOUBLE = CGetInfo.GetIOControlStatus("STACKREPEATINPUTDOUBLE").StatusID;
|
||
|
///// <summary>
|
||
|
///// �Ѷ�����ȡ�չ����룬Ĭ��63��˫�棩
|
||
|
///// </summary>
|
||
|
//public static readonly int STACKEMPTYOUTPUTDOUBLE = CGetInfo.GetIOControlStatus("STACKEMPTYOUTPUTDOUBLE").StatusID;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �豸����
|
||
|
/// <summary>
|
||
|
/// 20110803�Ѷ������豸���ͣ�Ĭ��ֵ1
|
||
|
/// </summary>
|
||
|
public static readonly int StackKind = CGetInfo.GetDeviceKind("StackKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803���ͻ����豸���ͣ�Ĭ��ֵ2
|
||
|
/// </summary>
|
||
|
public static readonly int ConveyorKind = CGetInfo.GetDeviceKind("ConveyorKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803���������豸���ͣ�Ĭ��ֵ3
|
||
|
/// </summary>
|
||
|
public static readonly int LifterKind = CGetInfo.GetDeviceKind("LifterKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803RGV�����豸���ͣ�Ĭ��ֵ4
|
||
|
/// </summary>
|
||
|
public static readonly int RGVKind = CGetInfo.GetDeviceKind("RGVKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803���̻����豸���ͣ�Ĭ��ֵ5
|
||
|
/// </summary>
|
||
|
public static readonly int PileKind = CGetInfo.GetDeviceKind("PileKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803AGV�����豸���ͣ�Ĭ��ֵ6
|
||
|
/// </summary>
|
||
|
public static readonly int AGVKind = CGetInfo.GetDeviceKind("AGVKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803��������ɨ���ǵ��豸���ͣ�Ĭ��ֵ7
|
||
|
/// </summary>
|
||
|
public static readonly int BarcodeScanKind = CGetInfo.GetDeviceKind("BarcodeScanKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803�����豸���豸���ͣ�Ĭ��ֵ8
|
||
|
/// </summary>
|
||
|
public static readonly int WeighKind = CGetInfo.GetDeviceKind("WeighKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803վ̨���豸���ͣ�Ĭ��ֵ9
|
||
|
/// </summary>
|
||
|
public static readonly int PlatFormKind = CGetInfo.GetDeviceKind("PlatFormKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803�������豸���ͣ�Ĭ��ֵ10
|
||
|
/// </summary>
|
||
|
public static readonly int LanewayKind = CGetInfo.GetDeviceKind("LanewayKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803AGVͨ�����豸���ͣ�Ĭ��ֵ11
|
||
|
/// </summary>
|
||
|
public static readonly int AGVLane = CGetInfo.GetDeviceKind("AGVLane").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803�����ؼ��豸���豸���ͣ�Ĭ��ֵ12
|
||
|
/// </summary>
|
||
|
public static readonly int DummyKind = CGetInfo.GetDeviceKind("DummyKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803���豸���豸���ͣ�Ĭ��ֵ13
|
||
|
/// </summary>
|
||
|
public static readonly int BlankKind = CGetInfo.GetDeviceKind("BlankKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803ȷ�ϰ�ť���豸���ͣ�Ĭ��ֵ14
|
||
|
/// </summary>
|
||
|
public static readonly int ConfirmButtonKind = CGetInfo.GetDeviceKind("ConfirmButtonKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803ȷ�ϰ�ť���豸���ͣ�Ĭ��ֵ15
|
||
|
/// </summary>
|
||
|
public static readonly int TimerKind = CGetInfo.GetDeviceKind("TimerKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803ָʾ�Ƶ��豸���ͣ�Ĭ��ֵ16
|
||
|
/// </summary>
|
||
|
public static readonly int LightKind = CGetInfo.GetDeviceKind("LightKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803���������豸���ͣ�Ĭ��ֵ17
|
||
|
/// </summary>
|
||
|
public static readonly int RobotKind = CGetInfo.GetDeviceKind("RobotKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803����ص��豸���ͣ�Ĭ��ֵ18
|
||
|
/// </summary>
|
||
|
public static readonly int DetectSwitchKind = CGetInfo.GetDeviceKind("DetectSwitchKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803�����Ƹ��豸���ͣ�Ĭ��ֵ19
|
||
|
/// </summary>
|
||
|
public static readonly int HandspikeKind = CGetInfo.GetDeviceKind("HandspikeKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803�����赲�豸���ͣ�Ĭ��ֵ20
|
||
|
/// </summary>
|
||
|
public static readonly int BlockKind = CGetInfo.GetDeviceKind("BlockKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803һ�Ź�����ɨ�����豸���ͣ�Ĭ��ֵ21
|
||
|
/// </summary>
|
||
|
public static readonly int FirstProjectCodeScanKind = CGetInfo.GetDeviceKind("FirstProjectCodeScanKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803�ֳ����ƴ�����������Ϣ�豸���ͣ�Ĭ��ֵ22
|
||
|
/// </summary>
|
||
|
public static readonly int HMIKind = CGetInfo.GetDeviceKind("HMIKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803һ�Ź������������豸���ͣ�Ĭ��ֵ23
|
||
|
/// </summary>
|
||
|
public static readonly int FirstProjectCodeCounterKind = CGetInfo.GetDeviceKind("FirstProjectCodeCounterKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803������������Ϣ�豸���ͣ�Ĭ��ֵ24
|
||
|
/// </summary>
|
||
|
public static readonly int RobotPileInfoKind = CGetInfo.GetDeviceKind("RobotPileInfoKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803����������ͨ���豸���ͣ�Ĭ��ֵ25
|
||
|
/// </summary>
|
||
|
public static readonly int RobotPileLaneKind = CGetInfo.GetDeviceKind("RobotPileLaneKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803���β����������豸���ͣ�Ĭ��ֵ26
|
||
|
/// </summary>
|
||
|
public static readonly int ClassOutputCounter = CGetInfo.GetDeviceKind("ClassOutputCounter").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803����Ʒ���豸���ͣ�Ĭ��ֵ27
|
||
|
/// </summary>
|
||
|
public static readonly int TobaccoBoxBreed = CGetInfo.GetDeviceKind("TobaccoBoxBreed").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803�������ʼ���豸���ͣ�Ĭ��ֵ28
|
||
|
/// </summary>
|
||
|
public static readonly int DetectSwitchStartKind = CGetInfo.GetDeviceKind("DetectSwitchStartKind").DeviceKindIndex;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 20110803����ͷ�豸���ͣ�Ĭ��ֵ29
|
||
|
/// </summary>
|
||
|
public static readonly int CameraKind = CGetInfo.GetDeviceKind("CameraKind").DeviceKindIndex;
|
||
|
/// <summary>
|
||
|
/// 20110803���������������豸���ͣ�Ĭ��ֵ30
|
||
|
/// </summary>
|
||
|
public static readonly int IOControlDummyKind = CGetInfo.GetDeviceKind("IOControlDummyKind").DeviceKindIndex;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��������Ϊ���������Ѷ��� add by lyj 20171115
|
||
|
/// </summary>
|
||
|
/// <param name="tasknum">������</param>
|
||
|
/// <param name="deviceindx">�豸����</param>
|
||
|
/// <param name="order">����</param>
|
||
|
/// <returns></returns>
|
||
|
public static int getStacknum(int tasknum,int deviceIndx,int order)
|
||
|
{
|
||
|
int stacknum1 = 0;
|
||
|
int stacknumonlane = 0;
|
||
|
int stacknum = 0;
|
||
|
int ordernum = 0;
|
||
|
int x = 0;
|
||
|
int z = 0;
|
||
|
int laneInfo = 0;
|
||
|
int lanesimple=0;
|
||
|
string lanefromz=string.Empty;
|
||
|
DataView dvlane;
|
||
|
StringBuilder mysql = new StringBuilder();
|
||
|
Model.MDevice deviceinfo = null;
|
||
|
Model.MDevice deviceinfo1 = null;
|
||
|
int managernum=0;
|
||
|
try
|
||
|
{
|
||
|
ordernum = GetDeviceOrderFromMonitor(tasknum);
|
||
|
x = Model.CGeneralFunction.GetXCoorFromMonitor(tasknum, deviceIndx, ordernum);
|
||
|
z = Model.CGeneralFunction.GetZCoorFromMonitor(tasknum, deviceIndx, ordernum);
|
||
|
managernum=GetManageTaskIndexfromMonitor(tasknum);
|
||
|
if(z>0)
|
||
|
{
|
||
|
mysql.Append("select top 1 * from ST_CELL where F_Z=").Append(z);
|
||
|
dvlane = dbo.ExceSQL(mysql.ToString()).Tables[0].DefaultView;
|
||
|
if(dvlane.Count>0)
|
||
|
{
|
||
|
laneInfo = Convert.ToInt32(dvlane[0]["FLaneWay"]);
|
||
|
}
|
||
|
if(laneInfo>0)
|
||
|
{
|
||
|
switch (laneInfo)
|
||
|
{
|
||
|
case 18001:
|
||
|
lanesimple = 1;
|
||
|
break;
|
||
|
case 18002:
|
||
|
lanesimple = 2;
|
||
|
break;
|
||
|
case 18003:
|
||
|
lanesimple = 3;
|
||
|
break;
|
||
|
case 18004:
|
||
|
lanesimple = 4;
|
||
|
break;
|
||
|
}
|
||
|
if (order == 4)
|
||
|
{
|
||
|
|
||
|
|
||
|
mysql.Remove(0,mysql.Length);
|
||
|
mysql.Append("select * from T_Base_StackLaneAndLayuerInfo where F_LaneNum=").Append(laneInfo);
|
||
|
dvlane = dbo.ExceSQL(mysql.ToString()).Tables[0].DefaultView;
|
||
|
#region �����´��������������ĶѶ���̨��
|
||
|
if (dvlane.Count == 1)
|
||
|
{
|
||
|
stacknum1 = Convert.ToInt32(dvlane[0]["F_DeviceIndex"]);
|
||
|
deviceinfo = Model.CGetInfo.GetDeviceInfo(stacknum1);
|
||
|
if(deviceinfo.RunState==0&&deviceinfo.ManTaskReserve==0)
|
||
|
{
|
||
|
stacknum = stacknum1;
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (dvlane.Count == 2)
|
||
|
{
|
||
|
|
||
|
|
||
|
}
|
||
|
else if (dvlane.Count == 0)
|
||
|
{
|
||
|
|
||
|
mysql.Remove(0, mysql.Length);
|
||
|
mysql.Append("select top 1 * from T_Base_StackLaneAndLayuerInfo where abs(F_LaneNum").Append(lanesimple).Append(")=1 order by F_Col desc");
|
||
|
dvlane = dbo.ExceSQL(mysql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvlane.Count > 0)
|
||
|
{
|
||
|
|
||
|
stacknum1 = Convert.ToInt32(dvlane[0]["F_DeviceIndex"]);
|
||
|
}
|
||
|
deviceinfo = Model.CGetInfo.GetDeviceInfo(stacknum1);
|
||
|
if (deviceinfo.RunState == 0 && deviceinfo.ManTaskReserve == 0)
|
||
|
{
|
||
|
stacknum = stacknum1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if(stacknum>0)
|
||
|
{
|
||
|
mysql.Remove(0, mysql.Length);
|
||
|
mysql.Append("update T_Manage_Task set FSTACK=").Append(stacknum).Append(" where FID=").Append(managernum);
|
||
|
int a = dbo.ExecuteSql(mysql.ToString());
|
||
|
mysql.Remove(0, mysql.Length);
|
||
|
mysql.Append("update T_Monitor_Task set F_DeviceIndex=").Append(stacknum).Append(" where F_DeviceIndex=11000 and F_ManageTaskIndex=").Append(managernum);
|
||
|
int b = dbo.ExecuteSql(mysql.ToString());
|
||
|
}
|
||
|
}
|
||
|
else if(order==5)
|
||
|
{
|
||
|
mysql.Remove(0, mysql.Length);
|
||
|
mysql.Append("select F_StackNum from T_Base_Device where F_DeviceKindIndex=10 and F_DeviceIndex=").Append(laneInfo);
|
||
|
dvlane = dbo.ExceSQL(mysql.ToString()).Tables[0].DefaultView;
|
||
|
if(dvlane.Count>0)
|
||
|
{
|
||
|
stacknumonlane = Convert.ToInt32(dvlane[0]["F_StackNum"]);
|
||
|
|
||
|
if(stacknumonlane>0)
|
||
|
{
|
||
|
|
||
|
deviceinfo1 = Model.CGetInfo.GetDeviceInfo(stacknumonlane);
|
||
|
if(deviceinfo1.RunState==0&&deviceinfo1.ManTaskReserve==0)
|
||
|
{
|
||
|
#region add by lyj 20170903 �ͻ�����ʱ������һ����ԭ�����ֹ�����sss
|
||
|
|
||
|
//if (DeviceIdx == 11001 && order == 5 && mti != 4)
|
||
|
//{
|
||
|
// string goalcell = "01-06-01";
|
||
|
// string errorfinfo = string.Empty;
|
||
|
// SControlMonitor scm = new SControlMonitor();
|
||
|
// try
|
||
|
// {
|
||
|
|
||
|
// Model.HandTask ht = new Model.HandTask(DeviceIdx, 2, 0, "0", goalcell, goalcell, 0, "");
|
||
|
|
||
|
// bool blreturn = scm.InsertHandTask(ht, out errorfinfo);
|
||
|
|
||
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("�����뿪ת̨�Ľ�ȡ����", "���ز����IJ����ͽ���:" + blreturn.ToString(), "����ʱ�����Ĵ�����Ϣ:" + errorfinfo, "Ŀ��λ��:" + goalcell);
|
||
|
// }
|
||
|
// catch (Exception ee116) { }
|
||
|
// finally
|
||
|
// {
|
||
|
|
||
|
// scm = null;
|
||
|
|
||
|
// goalcell = null;
|
||
|
|
||
|
// }
|
||
|
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return stacknum; ;
|
||
|
|
||
|
}catch(Exception gsn)
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��ȡ���͵������� add by lyj20180502
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">Сָ��������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int getDoubleForkMonitorCount(int monitorIndex,int tasktype,int order)
|
||
|
{
|
||
|
int iRetVal = 1;
|
||
|
DataView dv;
|
||
|
string sql = string.Empty;
|
||
|
string goalnum = string.Empty;
|
||
|
try
|
||
|
{
|
||
|
int refID = getRefTaskIndexFromMonitor(monitorIndex);
|
||
|
|
||
|
if (refID > 0)
|
||
|
{
|
||
|
|
||
|
//if(tasktype==1)
|
||
|
//{
|
||
|
// sql = "SELECT distinct F_ManageTaskIndex FROM dbo.T_Monitor_Task,dbo.T_Manage_Task,dbo.T_Base_Device WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and dbo.T_Monitor_Task.F_DeviceIndex=dbo.T_Base_Device.F_DeviceIndex and dbo.T_Base_Device.F_DeviceKindIndex=40 and dbo.T_Manage_Task.F_RELATIVECONTORLID=" + refID.ToString();
|
||
|
//}else if(tasktype==2)
|
||
|
//{
|
||
|
//sql = "SELECT distinct F_NumParam4 FROM dbo.T_Monitor_Task,dbo.T_Manage_Task,dbo.T_Base_Device WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and dbo.T_Monitor_Task.F_DeviceIndex=dbo.T_Base_Device.F_DeviceIndex and dbo.T_Manage_Task.FCONTROLTASKTYPE=1 and dbo.T_Monitor_Task.F_DeviceCommandIndex=5 and dbo.T_Base_Device.F_DeviceKindIndex=40 and dbo.T_Manage_Task.F_RELATIVECONTORLID= " + refID.ToString();
|
||
|
//}
|
||
|
if(tasktype==1)
|
||
|
{
|
||
|
sql = "SELECT distinct F_NumParam4 FROM dbo.T_Monitor_Task,dbo.T_Manage_Task,dbo.T_Base_Device WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and dbo.T_Monitor_Task.F_DeviceIndex=dbo.T_Base_Device.F_DeviceIndex and dbo.T_Manage_Task.FCONTROLTASKTYPE=1 and dbo.T_Monitor_Task.F_DeviceCommandIndex=5 and dbo.T_Base_Device.F_DeviceKindIndex=40 and dbo.T_Manage_Task.F_RELATIVECONTORLID= " + refID.ToString();
|
||
|
|
||
|
}else if(tasktype==2)
|
||
|
{
|
||
|
sql = "SELECT distinct F_NumParam1 FROM dbo.T_Monitor_Task,dbo.T_Manage_Task,dbo.T_Base_Device WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and dbo.T_Monitor_Task.F_DeviceIndex=dbo.T_Base_Device.F_DeviceIndex and dbo.T_Manage_Task.FCONTROLTASKTYPE=2 and dbo.T_Monitor_Task.F_DeviceCommandIndex=4 and dbo.T_Base_Device.F_DeviceKindIndex=40 and dbo.T_Manage_Task.F_RELATIVECONTORLID= " + refID.ToString();
|
||
|
//sql = "SELECT distinct F_ManageTaskIndex FROM dbo.T_Monitor_Task,dbo.T_Manage_Task,dbo.T_Base_Device WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and dbo.T_Monitor_Task.F_DeviceIndex=dbo.T_Base_Device.F_DeviceIndex and dbo.T_Base_Device.F_DeviceKindIndex=40 and dbo.T_Manage_Task.F_RELATIVECONTORLID=" + refID.ToString();
|
||
|
}
|
||
|
|
||
|
//sql = "SELECT distinct F_NumParam4 FROM dbo.T_Monitor_Task,dbo.T_Manage_Task,dbo.T_Base_Device WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and dbo.T_Monitor_Task.F_DeviceIndex=dbo.T_Base_Device.F_DeviceIndex and dbo.T_Monitor_Task.F_DeviceCommandIndex=5 and dbo.T_Base_Device.F_DeviceKindIndex=40 and dbo.T_Manage_Task.F_RELATIVECONTORLID= " + refID.ToString();
|
||
|
dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
if (dv.Count == 2)
|
||
|
{
|
||
|
if (tasktype == 1)
|
||
|
{
|
||
|
if (order == 4)
|
||
|
{
|
||
|
iRetVal = 2;
|
||
|
}
|
||
|
else if (order == 5)
|
||
|
{
|
||
|
iRetVal = 1;
|
||
|
}
|
||
|
}
|
||
|
else if (tasktype == 2)
|
||
|
{
|
||
|
if (order == 4)
|
||
|
{
|
||
|
iRetVal = 1;
|
||
|
}
|
||
|
else if (order == 5)
|
||
|
{
|
||
|
iRetVal = 2;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
else if (dv.Count == 1 || dv.Count == 0)
|
||
|
{
|
||
|
|
||
|
//if (tasktype == 2 && order == 4)
|
||
|
//{
|
||
|
// iRetVal = 1;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
sql = "SELECT distinct F_ManageTaskIndex FROM dbo.T_Monitor_Task,dbo.T_Manage_Task,dbo.T_Base_Device WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and dbo.T_Monitor_Task.F_DeviceIndex=dbo.T_Base_Device.F_DeviceIndex and dbo.T_Base_Device.F_DeviceKindIndex=40 and dbo.T_Manage_Task.F_RELATIVECONTORLID=" + refID.ToString();
|
||
|
dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
iRetVal = dv.Count;
|
||
|
//}
|
||
|
sql = "SELECT F_NumParam1 FROM dbo.T_Monitor_Task,dbo.T_Manage_Task,dbo.T_Base_Device WHERE dbo.T_Monitor_Task.F_ManageTaskIndex=dbo.T_Manage_Task.FID and dbo.T_Monitor_Task.F_DeviceIndex=dbo.T_Base_Device.F_DeviceIndex and dbo.T_Manage_Task.FCONTROLTASKTYPE=2 and dbo.T_Monitor_Task.F_DeviceCommandIndex=4 and dbo.T_Base_Device.F_DeviceKindIndex=40 and dbo.T_Manage_Task.F_RELATIVECONTORLID= " + refID.ToString();
|
||
|
dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
if (tasktype == 2 && order == 4 && dv.Count == 1)
|
||
|
{
|
||
|
iRetVal = 1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
return iRetVal;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �õ����������� add by lyj20180502
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex">Сָ��������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int getRefTaskIndexFromMonitor(int monitorIdx)
|
||
|
{//20100108
|
||
|
DataView dv;
|
||
|
try
|
||
|
{
|
||
|
//20100108
|
||
|
dv = dbo.ExceSQL("SELECT * FROM T_Monitor_Task WHERE (F_MonitorIndex = " + monitorIdx + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
dv = dbo.ExceSQL("SELECT F_RELATIVECONTORLID FROM T_Manage_Task WHERE (FID = " + Convert.ToInt32(dv[0]["F_ManageTaskIndex"]) + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0 && dv[0]["F_RELATIVECONTORLID"] != DBNull.Value)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_RELATIVECONTORLID"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100108
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|