6988 lines
414 KiB
6988 lines
414 KiB
3 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
using System.Data;
|
||
|
using DBFactory;
|
||
|
using CommonClassLib;
|
||
|
using Microsoft.VisualBasic;
|
||
|
using System.Threading;
|
||
|
using CommonLib;
|
||
|
namespace WcfControlMonitorLib
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu
|
||
|
/// ����������
|
||
|
/// ѡȡ��������ʱ�Ա����豸������������Ϊԭ����1��ÿ��·����ͷ������վ̨Ҫ��һ��������
|
||
|
/// 2��ÿ���Ѷ���Ҫ��һ�������������ȷ�ʽ������ִ����������
|
||
|
/// 3���������ȷ�ʽʱ���ڵ�����������ʱ�����Ѳ����������ȼ�Ϊ����9����������ִ�С�
|
||
|
///
|
||
|
/// �ѵ��������ֽ��ɶ������ذ�������
|
||
|
/// �ֽ�ԭ��һ�������������ճ�����·�����豸�����ų������������豸ָ��
|
||
|
/// </summary>
|
||
|
|
||
|
|
||
|
//20091107���Ӷ��������Ȳ���SelectTask_ManPRI();SelectTask_OnlyIn();SelectTask_InSubjoinOut();
|
||
|
//SelectTask_OnlyOut();SelectTask_OutSubjoinIn();�����ȼ���ͬʱ�����´�ʱ��������ִ��order by FTASKLEVEL desc,FBEGTIME asc
|
||
|
|
||
|
public static class CDisassembleTask
|
||
|
{
|
||
|
public static event CDataSourceChangeEventHandler DataChange;
|
||
|
public static void OnDataChange(object sender, CDataChangeEventArgs e)
|
||
|
{
|
||
|
if (DataChange != null)
|
||
|
{
|
||
|
DataChange(sender, e);
|
||
|
}
|
||
|
}
|
||
|
public static event RefreshMonitorEventHandler RefreshMonitor;
|
||
|
public static void OnRefreshMonitor(RefreshMonitorEventArgs e)
|
||
|
{
|
||
|
if (RefreshMonitor != null)
|
||
|
{
|
||
|
RefreshMonitor(e);
|
||
|
}
|
||
|
}
|
||
|
static string stackUcode = "35000,35001,35002,35003,45001";
|
||
|
static StringBuilder sql = new StringBuilder();
|
||
|
static Thread mythread;
|
||
|
static bool exitThread = false;//20091107
|
||
|
private static void BeginListen()
|
||
|
{//20091107
|
||
|
while (!exitThread )
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
MyTaskIntoSteps();
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError =ex.StackTrace+ ex.Message;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
public static void EndListen()
|
||
|
{//20091107
|
||
|
exitThread = true;
|
||
|
|
||
|
if (mythread != null)
|
||
|
{
|
||
|
|
||
|
dbo.Close();
|
||
|
|
||
|
mythread.Abort();
|
||
|
mythread = null;
|
||
|
}
|
||
|
}
|
||
|
public static void StartListen()
|
||
|
{
|
||
|
exitThread = false;
|
||
|
mythread = new Thread(new ThreadStart(BeginListen));
|
||
|
mythread.IsBackground = true;
|
||
|
mythread.Start();
|
||
|
}
|
||
|
static string _DisassembleTaskError="";
|
||
|
public static string DisassembleTaskError
|
||
|
{
|
||
|
get { return _DisassembleTaskError; }
|
||
|
set { _DisassembleTaskError = value;
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", DisassembleTaskError);
|
||
|
OnRefreshMonitor(rme);
|
||
|
}
|
||
|
}
|
||
|
static DBOperator dbo =new DBOperator();//20130926
|
||
|
static DBOperator dboM = CStaticClass.dboM; //20130510
|
||
|
static CCommonFunction ccf = new CCommonFunction();
|
||
|
|
||
|
static Model.MDevice devinfo;
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���ֵ������������ֹ�������ֱ�����ɴ�������T_Monitor_Task����
|
||
|
/// </summary>
|
||
|
public static void MyTaskIntoSteps()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
int Pri = ccf.SelectTaskPriPrecept();
|
||
|
switch (Pri)
|
||
|
{
|
||
|
case 0://���յ����������ȼ�
|
||
|
SelectTask_ManPRI();
|
||
|
break;
|
||
|
case 1://������������
|
||
|
SelectTask_OnlyIn();
|
||
|
break;
|
||
|
case 12://�����������������������ij�������
|
||
|
SelectTask_InSubjoinOut();
|
||
|
break;
|
||
|
case 2://������������
|
||
|
SelectTask_OnlyOut();
|
||
|
break;
|
||
|
case 21://��������������������������������
|
||
|
SelectTask_OutSubjoinIn();
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MyTaskIntoStepsʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���յ����������ȼ���������
|
||
|
/// </summary>
|
||
|
static void SelectTask_ManPRI()
|
||
|
{
|
||
|
DataView dvM = new DataView();
|
||
|
DataView dv = new DataView();
|
||
|
DataView dv1 = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Manage_Task where ").Append(
|
||
|
" FIntoStepOK='0' order by FTASKLEVEL desc,F_ManageTaskKindIndex asc,FBEGTIME asc, FID asc ");
|
||
|
|
||
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
dv = new DataView();//20091107
|
||
|
dv1 = new DataView();//20091107
|
||
|
Model.MDevice deviceInfo;
|
||
|
for (int i = 0; i < dvM.Count; i++)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (dvM[i]["FCONTROLTASKTYPE"].ToString() == "1")
|
||
|
//�����������������ж������豸�Ƿ��е���������ִ�л��߱�����
|
||
|
{
|
||
|
//sql = "SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task" +
|
||
|
// " where F_ManageTASKKINDINDEX=" + dvM[i]["F_ManageTASKKINDINDEX"] + " and F_DeviceIndex=" + dvM[i]["FSTARTDEVICE"] + " and F_Status>=1";
|
||
|
//dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
//if (dv.Count > 0)
|
||
|
//{
|
||
|
// continue;
|
||
|
//}
|
||
|
//������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["FSTARTDEVICE"]).Append(" and F_LockedState>0");
|
||
|
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//20091107
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (dvM[i]["FCONTROLTASKTYPE"].ToString() == "2")
|
||
|
//�����dz����������ж϶Ѷ����Ƿ��е���������ִ�л��߱�����
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task").Append(
|
||
|
" where F_ManageTASKKINDINDEX=").Append(dvM[i]["F_ManageTASKKINDINDEX"]).Append(
|
||
|
" and F_DeviceIndex=").Append(dvM[i]["FSTACK"]).Append(" and F_Status>0 ");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//������20091009
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["FSTACK"]).Append(" and (F_LockedState>0 or F_ManTaskReserve>0)");
|
||
|
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//20091107
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//20091128
|
||
|
//�жϽ�Ҫ�����ֵij��������Ƿ����Ѳ��ֵĶ��������յ���ͬ�ij���������û�о���һ������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dvM[i]["FENDDEVICE"]).Append(") and (FSTACK = ").Append(
|
||
|
dvM[i]["FSTACK"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
int OutMaxTask = 0;
|
||
|
#region 20200414 ˫¹�ģ�ԭ��������ͬ�յ�����ֻ����һ�����Ŀ��Բ��ֶ���
|
||
|
// �ɴ����ݿ����õõ�
|
||
|
OutMaxTask = 3;// ˫����λ����ֵֻ�ж�һ������
|
||
|
if (dv1.Count > OutMaxTask)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
#endregion
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dvM[i]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
int routeid = MinRouteID(Convert.ToInt32(dvM[i]["FSTARTDEVICE"]), Convert.ToInt32(dvM[i]["FENDDEVICE"]), dvM[i]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dvM[i]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (CreateMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]), routeid, dvM[i], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dvM[i]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dvM[i]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.SelectTask_ManPRIʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dvM.Dispose() ;
|
||
|
dv.Dispose();
|
||
|
dv1.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ������������������û����������ʱ�ٲ��ֳ�������
|
||
|
/// </summary>
|
||
|
static void SelectTask_OnlyIn()
|
||
|
{
|
||
|
DataView dvM = new DataView(); DataView dv = new DataView(); DataView dv1 = new DataView();
|
||
|
try
|
||
|
{
|
||
|
Model.MDevice deviceInfo;
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Manage_Task where ").Append(
|
||
|
" FIntoStepOK='0' order by FCONTROLTASKTYPE asc, F_ManageTaskKindIndex asc,FBEGTIME asc, FID asc ");
|
||
|
|
||
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
for (int i = 0; i < dvM.Count; i++)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (dvM[i]["FCONTROLTASKTYPE"].ToString() == "1")
|
||
|
//�����������������ж������豸�Ƿ��е���������ִ�л��߱�����
|
||
|
{
|
||
|
//sql = "SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task" +
|
||
|
// " where F_ManageTASKKINDINDEX=" + dvM[i]["F_ManageTASKKINDINDEX"] + " and F_DeviceIndex=" + dvM[i]["FSTARTDEVICE"] + " and F_Status>0";
|
||
|
//dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
//if (dv.Count > 0)
|
||
|
//{
|
||
|
// continue;
|
||
|
//}
|
||
|
//������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["FSTARTDEVICE"]).Append(" and F_LockedState>0");
|
||
|
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (dvM[i]["FCONTROLTASKTYPE"].ToString() == "2")
|
||
|
//�����dz����������ж϶Ѷ����Ƿ��е���������ִ�л��߱�����
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task").Append(
|
||
|
" where F_ManageTASKKINDINDEX=").Append(dvM[i]["F_ManageTASKKINDINDEX"]).Append(
|
||
|
" and F_DeviceIndex=").Append(dvM[i]["FSTACK"]).Append(" and F_Status>0");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//������20091009
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["FSTACK"]).Append(" and (F_LockedState>0 or F_ManTaskReserve>0)");
|
||
|
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
////20091128
|
||
|
//�жϽ�Ҫ�����ֵij��������Ƿ����Ѳ��ֵĶ��������յ���ͬ�ij���������û�о���һ������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dvM[i]["FENDDEVICE"]).Append(") and (FSTACK = ").Append(
|
||
|
dvM[i]["FSTACK"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dvM[i]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
int routeid = MinRouteID(Convert.ToInt32(dvM[i]["FSTARTDEVICE"]), Convert.ToInt32(dvM[i]["FENDDEVICE"]), dvM[i]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dvM[i]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (CreateMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]), routeid, dvM[i], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dvM[i]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dvM[i]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.SelectTask_OnlyInʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dv1.Dispose();
|
||
|
dvM.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �������ȸ����������������ij�������
|
||
|
/// ����ʵ�֣��ж�T_Manage_Task�����Ƿ��д˶Ѷ�����������ִ�У�����û�У�����ѡһ������������
|
||
|
/// �����жѶ�������ִ�����������Ҷ�����û�еȴ�ִ�еĶѶ���������������ѡһ���˶Ѷ����ij����������ȼ���Ϊ9��
|
||
|
///
|
||
|
/// </summary>
|
||
|
static void SelectTask_InSubjoinOut()
|
||
|
{
|
||
|
DataView dvM = new DataView();
|
||
|
DataView dv = new DataView();//20091107
|
||
|
DataView dv12 = new DataView();
|
||
|
DataView dvv = new DataView();
|
||
|
DataView dv0 = new DataView();
|
||
|
DataView dv1 = new DataView();
|
||
|
DataView dv00 = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_StackIndex FROM T_Base_StackInfo");
|
||
|
|
||
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
Model.MDevice deviceInfo;
|
||
|
int routeid = -1;
|
||
|
for (int i = 0; i < dvM.Count; i++)
|
||
|
{
|
||
|
//����ѡ���˶Ѷ������������������ж��Ǹ���ִ��
|
||
|
#region ����ѡ���˶Ѷ������������������ж��Ǹ���ִ��
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTATUS = 0) AND (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 1) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//20091107
|
||
|
for (int j = 0; j < dv.Count; j++)//�������Ѷ��������������ȴ�����
|
||
|
{
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dv[j]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[j]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Ȼ��������ִ�е������Ѷ�����������һ����������
|
||
|
|
||
|
|
||
|
//Ȼ��������ִ�е������Ѷ�����������һ����������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT T_Monitor_Task.F_MonitorIndex FROM T_Monitor_Task ,T_Manage_Task WHERE ").Append(
|
||
|
" (T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID AND ").Append(
|
||
|
" T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex)").Append(
|
||
|
" And (T_Monitor_Task.F_Status = 1 OR T_Monitor_Task.F_Status = 2) AND F_DeviceCommandIndex=5 and ").Append(
|
||
|
"(T_Monitor_Task.F_DeviceIndex = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (T_Manage_Task.FCONTROLTASKTYPE = 1)");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)//�������Ѷ���������������ִ��
|
||
|
{
|
||
|
#region �������Ѷ���������������ִ����Я����������
|
||
|
//20091013
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(
|
||
|
") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count <= 0)//û�д˶Ѷ����ij����������Ŷ�
|
||
|
{
|
||
|
#region ��ѡ�˶Ѷ����ij�������
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)//��ѡ�˶Ѷ����ij�������
|
||
|
{
|
||
|
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[0]["FSTARTDEVICE"]), Convert.ToInt32(dv[0]["FENDDEVICE"]), dv[0]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dv[0]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[0]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dv[0]);
|
||
|
}
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[0]["FID"]), routeid, dv[0], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
int level = Convert.ToInt32(dv[0]["FTASKLEVEL"]) == 100 ? 100 : 9;
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1',FTASKLEVEL=").Append(level).Append(" where FID=").Append(dv[0]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[0]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update dbo.T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
||
|
dv[0]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dv[0]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[0]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{//20091014
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
//20130710sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(
|
||
|
// ") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE FROM T_Manage_Task WHERE (FSTACK = ")
|
||
|
.Append(dvM[i]["F_StackIndex"]).Append(") AND (FSTATUS = 0) AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') GROUP BY F_ManageTaskKindIndex,FENDDEVICE,FTASKLEVEL,FSTARTDEVICE,FSTACK, FUseAwayFork,FENDUCODE ORDER BY FTASKLEVEL DESC");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)//��ѡ�˶Ѷ����ij�������
|
||
|
{
|
||
|
//20091102
|
||
|
for (int j = 0; j < dv.Count; j++)
|
||
|
{
|
||
|
if (stackUcode.IndexOf(dvM[i]["F_StackIndex"].ToString()) >= 0)
|
||
|
{//20120309 �д˶Ѷ����ij�����������FENDUCODE�յ���ͬ���ŶӾͲ�������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDUCODE=").Append(dv[j]["FENDUCODE"]).Append(
|
||
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{//20110110�д˶Ѷ����ij������������յ���ͬ���ŶӾͲ�������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dv[j]["FENDDEVICE"]).Append(
|
||
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
|
||
|
}
|
||
|
dv12 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv12.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dv[j]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dv[j]);
|
||
|
}
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
int level = Convert.ToInt32(dv[j]["FTASKLEVEL"]) == 100 ? 100 : 9;
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1',FTASKLEVEL=").Append(level).Append(" where FID=").Append(dv[j]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
||
|
dv[j]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dv[j]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//20091107
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Manage_Task WHERE (FSTACK = ").Append(
|
||
|
dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0)");
|
||
|
dvv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int aa = 0; aa < dvv.Count; aa++)
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FTASKLEVEL=9 WHERE (FTASKLEVEL<>100) and F_ManageTASKKINDINDEX=").Append(
|
||
|
dvv[aa]["F_ManageTaskKindIndex"]).Append(" and FID=").Append(dvv[aa]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
||
|
dvv[aa]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dvv[aa]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
else//û�д˶Ѷ�������
|
||
|
{
|
||
|
#region û�д˶Ѷ�������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FIntoStepOK = '0') order by FTASKLEVEL desc, FCONTROLTASKTYPE asc,FBEGTIME asc");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//20091102
|
||
|
for (int j = 0; j < dv.Count; j++)
|
||
|
//if (dv.Count > 0)//������ѡһ���˶Ѷ���������
|
||
|
{
|
||
|
if (dv[j]["FCONTROLTASKTYPE"].ToString() == "2")
|
||
|
//�����dz����������ж϶Ѷ����Ƿ��е���������ִ�л��߱�����
|
||
|
{
|
||
|
if (stackUcode.IndexOf(dvM[i]["F_StackIndex"].ToString()) >= 0)
|
||
|
{//20120309 �д˶Ѷ����ij�����������FENDUCODE�յ���ͬ���ŶӾͲ�������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDUCODE=").Append(dv[j]["FENDUCODE"]).Append(
|
||
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{//20110110�д˶Ѷ����ij������������յ���ͬ���ŶӾͲ�������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dv[j]["FENDDEVICE"]).Append(
|
||
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
|
||
|
}
|
||
|
dv12 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv12.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task").Append(
|
||
|
" where F_DeviceIndex=").Append(dv[j]["FSTACK"]).Append(" and F_Status>0 ");
|
||
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//20091107
|
||
|
if (dv0.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//������20091009
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dv[j]["FSTACK"]).Append(" and (F_LockedState>0 or F_ManTaskReserve>0)");
|
||
|
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//220091007
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//20101028���ӳ�������
|
||
|
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dv[j]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dv[j]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[j]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE ((FSTACK <= 0) or (FCONTROLTASKTYPE=3)) AND (FIntoStepOK = '0') order by FTASKLEVEL desc, FCONTROLTASKTYPE asc,FBEGTIME asc");
|
||
|
|
||
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int i = 0; i < dvM.Count; i++)//��ѡû�жѶ�������������
|
||
|
{
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
routeid = MinRouteID(Convert.ToInt32(dvM[i]["FSTARTDEVICE"]), Convert.ToInt32(dvM[i]["FENDDEVICE"]), dvM[i]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dvM[i]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]), routeid, dvM[i], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dvM[i]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dvM[i]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.SelectTask_InSubjoinOutʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
//20091107
|
||
|
dvM.Dispose();
|
||
|
dv.Dispose();
|
||
|
dv12.Dispose();
|
||
|
dvv.Dispose();
|
||
|
dv0.Dispose();
|
||
|
dv1.Dispose();
|
||
|
dv00.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �������ֳ���������û�г�������ʱ�ٲ�����������
|
||
|
/// </summary>
|
||
|
static void SelectTask_OnlyOut()
|
||
|
{
|
||
|
DataView dvM = new DataView(); DataView dv = new DataView(); DataView dv1 = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Manage_Task where ").Append(
|
||
|
" FIntoStepOK='0' order by FCONTROLTASKTYPE decs, F_ManageTaskKindIndex asc,FBEGTIME asc, FID asc ");
|
||
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
Model.MDevice deviceInfo;
|
||
|
for (int i = 0; i < dvM.Count; i++)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (dvM[i]["FCONTROLTASKTYPE"].ToString() == "1")
|
||
|
//�����������������ж������豸�Ƿ��е���������ִ�л��߱�����
|
||
|
{
|
||
|
//sql = "SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task" +
|
||
|
// " where F_ManageTASKKINDINDEX=" + dvM[i]["F_ManageTASKKINDINDEX"] + " and F_DeviceIndex=" + dvM[i]["FSTARTDEVICE"] + " and F_Status>0";
|
||
|
//dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
//if (dv.Count > 0)
|
||
|
//{
|
||
|
// continue;
|
||
|
//}
|
||
|
//������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["FSTARTDEVICE"]).Append(" and F_LockedState>0");
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (dvM[i]["FCONTROLTASKTYPE"].ToString() == "2")
|
||
|
//�����dz����������ж϶Ѷ����Ƿ��е���������ִ�л��߱�����
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task").Append(
|
||
|
" where F_ManageTASKKINDINDEX=").Append(dvM[i]["F_ManageTASKKINDINDEX"]
|
||
|
).Append(" and F_DeviceIndex=").Append(dvM[i]["FSTACK"]).Append(" and F_Status>0 ");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//������20091009
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["FSTACK"]).Append(" and (F_LockedState>0 or F_ManTaskReserve>0)");
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//20091128
|
||
|
//�жϽ�Ҫ�����ֵij��������Ƿ����Ѳ��ֵĶ��������յ���ͬ�ij���������û�о���һ������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dvM[i]["FENDDEVICE"]).Append(") and (FSTACK = ").Append(
|
||
|
dvM[i]["FSTACK"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dvM[i]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
int routeid = MinRouteID(Convert.ToInt32(dvM[i]["FSTARTDEVICE"]), Convert.ToInt32(dvM[i]["FENDDEVICE"]), dvM[i]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dvM[i]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]), routeid, dvM[i], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dvM[i]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dvM[i]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["FSTACK"]));
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.SelectTask_OnlyOutʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dv1.Dispose();
|
||
|
dvM.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �������ȸ�������������������������
|
||
|
/// ����ʵ�֣����յ���������������ʱ����ѡһ������ִ�е��������������ȼ���������9
|
||
|
/// </summary>
|
||
|
static void SelectTask_OutSubjoinIn()
|
||
|
{
|
||
|
DataView dvM = new DataView();
|
||
|
DataView dv = new DataView();
|
||
|
DataView dv112 = new DataView();
|
||
|
DataView dv0 = new DataView();
|
||
|
DataView dv1 = new DataView();
|
||
|
try
|
||
|
{
|
||
|
Model.MDevice deviceInfo;
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_StackIndex FROM T_Base_StackInfo");
|
||
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
int routeid = -1;
|
||
|
for (int i = 0; i < dvM.Count; i++)
|
||
|
{//20090928
|
||
|
#region ����ѡ���˶Ѷ������������������ж��Ǹ���ִ��
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTATUS = 0) AND (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 1) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int j = 0; j < dv.Count; j++)//�������Ѷ��������������ȴ�����
|
||
|
{
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dv[j]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[j]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
//20091005
|
||
|
#region Ȼ��������ִ�е������Ѷ�����������һ����������
|
||
|
|
||
|
|
||
|
//Ȼ��������ִ�е������Ѷ�����������һ����������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT T_Monitor_Task.F_MonitorIndex FROM T_Monitor_Task ,T_Manage_Task WHERE ").Append(
|
||
|
" (T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID AND ").Append(
|
||
|
" T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex)").Append(
|
||
|
" And (T_Monitor_Task.F_Status = 1 OR T_Monitor_Task.F_Status = 2) AND F_DeviceCommandIndex=5 and ").Append(
|
||
|
"(T_Monitor_Task.F_DeviceIndex = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (T_Manage_Task.FCONTROLTASKTYPE = 1)");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)//�������Ѷ���������������ִ��
|
||
|
{
|
||
|
#region �������Ѷ���������������ִ��
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count <= 0)//û�д˶Ѷ����ij����������Ŷӻ���ִ��
|
||
|
{
|
||
|
#region ��ѡ�˶Ѷ����ij�������
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)//��ѡ�˶Ѷ����ij�������
|
||
|
{
|
||
|
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[0]["FSTARTDEVICE"]), Convert.ToInt32(dv[0]["FENDDEVICE"]), dv[0]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dv[0]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[0]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dv[0]);
|
||
|
}
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[0]["FID"]), routeid, dv[0], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[0]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[0]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update dbo.T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
||
|
dv[0]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dv[0]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[0]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[0]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
//20130710sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(
|
||
|
// ") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE FROM T_Manage_Task WHERE (FSTACK = ")
|
||
|
.Append(dvM[i]["F_StackIndex"]).Append(") AND (FSTATUS = 0) AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') GROUP BY F_ManageTaskKindIndex,FENDDEVICE,FTASKLEVEL,FSTARTDEVICE,FSTACK, FUseAwayFork,FENDUCODE ORDER BY FTASKLEVEL DESC");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)//��ѡ�˶Ѷ����ij�������
|
||
|
{
|
||
|
|
||
|
//20091102
|
||
|
for (int j = 0; j < dv.Count; j++)
|
||
|
{
|
||
|
if (stackUcode.IndexOf(dvM[i]["F_StackIndex"].ToString()) >= 0)
|
||
|
{//20120309 �д˶Ѷ����ij�����������FENDUCODE�յ���ͬ���ŶӾͲ�������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDUCODE=").Append(dv[j]["FENDUCODE"]).Append(
|
||
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{//20110110�д˶Ѷ����ij������������յ���ͬ���ŶӾͲ�������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dv[j]["FENDDEVICE"]).Append(
|
||
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
|
||
|
}//20141201���ڷ����Ȳ��ֵij�����������Я����ִֻ����������ִ�г���
|
||
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv112.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dv[j]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dv[j]);
|
||
|
}
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
int level = Convert.ToInt32(dv[j]["FTASKLEVEL"]) == 100 ? 100 : 9;
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1',FTASKLEVEL=").Append(level).Append(" where FID=").Append(dv[j]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
||
|
dv[j]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dv[j]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Manage_Task WHERE (FSTACK = ").Append(
|
||
|
dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0)");
|
||
|
DataView dvv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int aa = 0; aa < dvv.Count; aa++)
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FTASKLEVEL=9 WHERE (FTASKLEVEL<>100) and F_ManageTASKKINDINDEX=").Append(
|
||
|
dvv[aa]["F_ManageTaskKindIndex"]).Append(" and FID=").Append(dvv[aa]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
||
|
dvv[aa]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dvv[aa]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
//20091005
|
||
|
else
|
||
|
{
|
||
|
|
||
|
//����ѡ���˶Ѷ���һ����������
|
||
|
#region ����ѡ���˶Ѷ���һ����������
|
||
|
|
||
|
//�ж϶Ѷ����Ƿ��е���������ִ�л��߱�����
|
||
|
//20130620
|
||
|
sql.Remove(0, sql.Length);
|
||
|
|
||
|
sql.Append("SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task").Append(
|
||
|
" where F_DeviceIndex=").Append(dvM[i]["F_StackIndex"]).Append(" and F_Status>0 ");
|
||
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv0.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//������20130620
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["F_StackIndex"]).Append(" and (F_LockedState>0 or F_ManTaskReserve>0)");
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
//20130710-20210301 ˫����λ����ֵ����һ������
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTATUS = 0) AND (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
||
|
//sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE FROM T_Manage_Task WHERE (FSTACK = ")
|
||
|
// .Append(dvM[i]["F_StackIndex"]).Append(") AND (FSTATUS = 0) AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') GROUP BY F_ManageTaskKindIndex,FENDDEVICE,FTASKLEVEL,FSTARTDEVICE,FSTACK, FUseAwayFork,FENDUCODE ORDER BY FTASKLEVEL DESC");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int j = 0; j < dv.Count; j++)
|
||
|
//�������Ѷ����ij��������ȴ�����
|
||
|
{
|
||
|
#region ��Ŀ��������
|
||
|
//if (stackUcode.IndexOf(dvM[i]["F_StackIndex"].ToString()) >= 0)
|
||
|
//{//20120309 �д˶Ѷ����ij�����������FENDUCODE�յ���ͬ���ŶӾͲ�������
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDUCODE=").Append(dv[j]["FENDUCODE"]).Append(
|
||
|
// ") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
//}
|
||
|
//else
|
||
|
//{//20110110�д˶Ѷ����ij������������յ���ͬ���ŶӾͲ�������
|
||
|
// //20101124
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dv[j]["FENDDEVICE"]).Append(
|
||
|
// ") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
//20190726�д˶Ѷ����ij������������յ���ͬ���ŶӾͲ�������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dv[j]["FENDDEVICE"]).Append(
|
||
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
||
|
|
||
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
int OutMaxTask = 0;
|
||
|
#region 20200414 ˫¹�ģ�ԭ��������ͬ�յ�����ֻ����һ�����Ŀ��Բ��ֶ���
|
||
|
// �ɴ����ݿ����õõ�
|
||
|
//OutMaxTask = 3;//LHDF
|
||
|
|
||
|
#endregion
|
||
|
if (dv112.Count > OutMaxTask)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dv[j]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
//20101028���ӳ�������
|
||
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
GetOutDoubleForkTask(dv[j]);
|
||
|
}
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[j]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE ((FSTACK <= 0) or (FCONTROLTASKTYPE=3)) AND (FIntoStepOK = '0') order by FTASKLEVEL desc, FCONTROLTASKTYPE asc,FBEGTIME asc");
|
||
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int i = 0; i < dvM.Count; i++)//��ѡû�жѶ�������������
|
||
|
{
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
routeid = MinRouteID(Convert.ToInt32(dvM[i]["FSTARTDEVICE"]), Convert.ToInt32(dvM[i]["FENDDEVICE"]), dvM[i]["FUseAwayFork"]);
|
||
|
if (routeid == -1)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(dvM[i]);
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
if (CreateMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]), routeid, dvM[i], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dvM[i]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dvM[i]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]));
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.SelectTask_OutSubjoinInʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dv0.Dispose();
|
||
|
dv1.Dispose();
|
||
|
dv112.Dispose();
|
||
|
dvM.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ݵ����������������յ��豸��������·�����̵�RouteIDSub
|
||
|
/// </summary>
|
||
|
/// <param name="startdevice">�����豸����</param>
|
||
|
/// <param name="enddevice">�յ��豸����</param>
|
||
|
/// <returns></returns>
|
||
|
public static int MinRouteID(int startdevice,int enddevice)
|
||
|
{
|
||
|
DataView dv = new DataView(); DataView dvd = new DataView(); DataView dv1 = new DataView(); DataView dv2 = new DataView();
|
||
|
List<double> minroute=new List<double>() ;
|
||
|
try
|
||
|
{
|
||
|
int retrouteidsub =GetSameStartDeviceEnddeviceRouteID(startdevice, enddevice);
|
||
|
if (retrouteidsub > 0)
|
||
|
{
|
||
|
return retrouteidsub;
|
||
|
}
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
||
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
||
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
||
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and F_Status=1");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//0,routIDSub��1��·����Сֵ
|
||
|
if (dv.Count == 0)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_RouteIDSub, F_LockedState,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Base_Route_Device WHERE ").Append(
|
||
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and (T_Base_Route_Device.F_RouteIDSub = ").Append(
|
||
|
dv[i]["F_RouteIDSub"]).Append(") AND (T_Base_Device.F_LockedState = - 1 or T_Base_Device.F_ErrorCode>=30)");//20121203
|
||
|
dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvd.Count > 0)
|
||
|
{
|
||
|
int dvin = Convert.ToInt32(dvd[0]["F_DeviceIndex"]);
|
||
|
if ((dvin >= 35001 && dvin <= 35003) || (dvin == 45001))
|
||
|
{//20120207�����˵�λ��ȡ�������ж��Ƿ���
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
List<double> route = new List<double>();//0,routIDSub��1,������2��·��ʹ��Ƶ�ʣ�3��·���豸������
|
||
|
//·���������豸���������̣�Ȩ��0.3����·��ʹ��Ƶ����С��Ȩ��0.3����·����·���豸��������Ȩ��0.3��
|
||
|
|
||
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
||
|
).Append(dv[i]["F_RouteIDSub"]);
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//����
|
||
|
//route.Add(0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//·��ʹ��Ƶ�ʣ�·��ִ�е�������������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
int a = -1;
|
||
|
if (int.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv2[0]["ManCount"]));//·��ʹ��Ƶ��
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
//·���豸������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
int a = -1;
|
||
|
if (int.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv2[0]["mtask"]));//·���豸������
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
|
||
|
//������·������·������*0.3+·��ʹ��Ƶ��*0.3+�豸ռ����*0.3������Сֵ��
|
||
|
if (minroute.Count == 0)
|
||
|
{
|
||
|
minroute.Add(route[0]);
|
||
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3))
|
||
|
{
|
||
|
minroute[0] = route[0];
|
||
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (minroute.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(minroute[0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MinRouteIDʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
return -1;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dv1.Dispose();
|
||
|
dv2.Dispose();
|
||
|
dvd.Dispose();
|
||
|
minroute = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 20091005
|
||
|
/// ���ݵ����������������յ��豸��������·�����̵�RouteIDSub
|
||
|
/// </summary>
|
||
|
/// <param name="startdevice">�����豸����</param>
|
||
|
/// <param name="enddevice">�յ��豸����</param>
|
||
|
/// /// <param name="enddevice">��ǰ�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
public static int MinRouteID(int startdevice, int enddevice,int nowdevice)
|
||
|
{
|
||
|
DataView dv = new DataView(); DataView dvd = new DataView();
|
||
|
DataView dv1 = new DataView(); DataView dv2 = new DataView();
|
||
|
List<double> minroute = new List<double>();//0,routIDSub��1��·����Сֵ
|
||
|
try
|
||
|
{
|
||
|
int retrouteidsub = GetSameStartDeviceEnddeviceRouteID(startdevice, enddevice);
|
||
|
if (retrouteidsub > 0)
|
||
|
{
|
||
|
return retrouteidsub;
|
||
|
}
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
||
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
||
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
||
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and F_Status=1 and T_Base_Device.F_DeviceIndex =").Append(nowdevice);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dv.Count == 0)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_RouteIDSub, F_LockedState,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Base_Route_Device WHERE ").Append(
|
||
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and (T_Base_Route_Device.F_RouteIDSub = ").Append(
|
||
|
dv[i]["F_RouteIDSub"]).Append(") AND (T_Base_Device.F_LockedState = - 1 or T_Base_Device.F_ErrorCode>=30)");//20121203
|
||
|
dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvd.Count > 0)
|
||
|
{
|
||
|
int dvin = Convert.ToInt32(dvd[0]["F_DeviceIndex"]);
|
||
|
if ((dvin >= 35001 && dvin <= 35003) || (dvin == 45001))
|
||
|
{//20120207�����˵�λ��ȡ�������ж��Ƿ���
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
List<double> route = new List<double>();//0,routIDSub��1,������2��·��ʹ��Ƶ�ʣ�3��·���豸������
|
||
|
//·���������豸���������̣�Ȩ��0.3����·��ʹ��Ƶ����С��Ȩ��0.3����·����·���豸��������Ȩ��0.3��
|
||
|
|
||
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
||
|
).Append(dv[i]["F_RouteIDSub"]);
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//����
|
||
|
//route.Add(0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//·��ʹ��Ƶ�ʣ�·��ִ�е�������������
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv2[0]["ManCount"]));//·��ʹ��Ƶ��
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
//·���豸������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv2[0]["mtask"]));//·���豸������
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
|
||
|
//������·������·������*0.3+·��ʹ��Ƶ��*0.3+�豸ռ����*0.3������Сֵ��
|
||
|
if (minroute.Count == 0)
|
||
|
{
|
||
|
minroute.Add(route[0]);
|
||
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3))
|
||
|
{
|
||
|
minroute[0] = route[0];
|
||
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (minroute.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(minroute[0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MinRouteIDʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
return -1;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dv1.Dispose();
|
||
|
dv2.Dispose();
|
||
|
dvd.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ݵ����������������յ��豸��������·�����̵�RouteIDSub
|
||
|
/// </summary>
|
||
|
/// <param name="startdevice">�����豸����</param>
|
||
|
/// <param name="enddevice">�յ��豸����</param>
|
||
|
/// <param name="AllStatus">������·��״̬��true��false������</param>
|
||
|
/// <returns></returns>
|
||
|
public static int MinRouteID(int startdevice, int enddevice, bool AllStatus, object useAwayfork)
|
||
|
{
|
||
|
//20101124
|
||
|
DataView dv = new DataView();
|
||
|
DataView dv1 = new DataView(); DataView dv2 = new DataView();
|
||
|
StringBuilder dff =new StringBuilder();
|
||
|
if (useAwayfork.ToString() == "-")
|
||
|
{
|
||
|
dff .Append( "F_UseAwayFork<>'n'");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
dff .Append( "(F_UseAwayFork='" ).Append( useAwayfork ).Append( "' or F_UseAwayFork='-' )");//20101028
|
||
|
}
|
||
|
//20101124
|
||
|
try
|
||
|
{
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
||
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
||
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
||
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and ").Append(dff.ToString());
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
List<double> minroute = new List<double>();//0,routIDSub��1��·����Сֵ
|
||
|
if (dv.Count == 0)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
|
||
|
|
||
|
List<double> route = new List<double>();//0,routIDSub��1,������2��·��ʹ��Ƶ�ʣ�3��·���豸������
|
||
|
//·���������豸���������̣�Ȩ��0.3����·��ʹ��Ƶ����С��Ȩ��0.3����·����·���豸��������Ȩ��0.3��
|
||
|
|
||
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
||
|
).Append(dv[i]["F_RouteIDSub"]);
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//����
|
||
|
//route.Add(0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//·��ʹ��Ƶ�ʣ�·��ִ�е�������������
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv2[0]["ManCount"]));//·��ʹ��Ƶ��
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
//·���豸������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv2[0]["mtask"]));//·���豸������
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
|
||
|
//������·������·������*0.3+·��ʹ��Ƶ��*0.3+�豸ռ����*0.3������Сֵ��
|
||
|
if (minroute.Count == 0)
|
||
|
{
|
||
|
minroute.Add(route[0]);
|
||
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3))
|
||
|
{
|
||
|
minroute[0] = route[0];
|
||
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (minroute.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(minroute[0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MinRouteIDʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
return -1;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dv1.Dispose();
|
||
|
dv2.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 20100702
|
||
|
/// ���ݵ����������������յ��豸��������·�����̵�RouteIDSub
|
||
|
/// </summary>
|
||
|
/// <param name="startdevice">�����豸����</param>
|
||
|
/// <param name="enddevice">�յ��豸����</param>
|
||
|
/// <param name="useAwayfork">�Ƿ�ʹ��Զ����</param>
|
||
|
/// <returns></returns>
|
||
|
public static int MinRouteID(int startdevice, int enddevice, object useAwayfork)
|
||
|
{
|
||
|
//20101124
|
||
|
DataView dv = new DataView(); DataView dvd = new DataView();
|
||
|
DataView dv1 = new DataView(); DataView dv2 = new DataView();
|
||
|
StringBuilder dff = new StringBuilder();
|
||
|
if (useAwayfork.ToString() == "-")
|
||
|
{
|
||
|
dff.Append( "F_UseAwayFork<>'n'");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
dff .Append( "(F_UseAwayFork='" ).Append( useAwayfork).Append( "' or F_UseAwayFork='-' )");//20101028
|
||
|
}
|
||
|
#region ��λ�Ѷ�����·����ѡ20120207
|
||
|
//�������ͻ���ѡ�����ٽ�ȡ��λ����
|
||
|
//35000˫��������ѡ����С�У�1��6�У�2��26�У�ѡ��������32038
|
||
|
|
||
|
//if (startdevice == 35000 && (enddevice == 32025 || enddevice == 10100 || enddevice == 10200 || enddevice == 10300))
|
||
|
//{
|
||
|
|
||
|
// dff.Append(" and T_Base_Route_Device.F_DeviceIndex=32038");
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
|
||
|
//}
|
||
|
#endregion
|
||
|
//20101124
|
||
|
try
|
||
|
{
|
||
|
int retrouteidsub = GetSameStartDeviceEnddeviceRouteID(startdevice, enddevice);
|
||
|
if (retrouteidsub > 0)
|
||
|
{
|
||
|
return retrouteidsub;
|
||
|
}
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
//20101124
|
||
|
if (enddevice == 41001 || enddevice == 41002 || enddevice == 41003) //LHDF
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT TOP 1* FROM (SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
||
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
||
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
||
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and ").Append(dff.ToString()).Append(" and F_Status=1) AS T ");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
||
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
||
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
||
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and ").Append(dff.ToString()).Append(" and F_Status=1 ");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
}
|
||
|
List<double> minroute = new List<double>();//0,routIDSub��1��·����Сֵ
|
||
|
if (dv.Count == 0)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT f_routeid,F_RouteIDSub,F_LockedState,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Base_Route_Device WHERE ").Append(
|
||
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and (T_Base_Route_Device.F_RouteIDSub = ").Append(
|
||
|
dv[i]["F_RouteIDSub"]).Append(") AND (T_Base_Device.F_LockedState = - 1 or T_Base_Device.F_ErrorCode>=30)");//20121203
|
||
|
dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvd.Count > 0)
|
||
|
{
|
||
|
int dvin = Convert.ToInt32(dvd[0]["F_DeviceIndex"]);
|
||
|
//LHDF
|
||
|
#region
|
||
|
|
||
|
int iRouteID = Convert.ToInt32(dvd[0]["F_routeid"]);
|
||
|
if (iRouteID >= 92 && iRouteID <= 99)
|
||
|
{
|
||
|
string str = string.Format("select f_routeid from t_base_route where f_status = 1 and f_routeid = {0}",iRouteID);
|
||
|
object obj = dbo.GetSingle(str);
|
||
|
if (obj != null)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
else if ((dvin >= 35001 && dvin <= 35003) || (dvin == 45001))
|
||
|
{//20120207�����˵�λ��ȡ�������ж��Ƿ���
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
#region ��������·��·�����ж�����ģʽ1�ϣ�2��
|
||
|
//20190715 ����ҩҵ������·�������ж�����ģʽ1�ϣ�2��
|
||
|
if (startdevice == 38001 && enddevice!= 38001)
|
||
|
{
|
||
|
// 3���µ�2��,��·����F_AppendBarcode = 1 ���豸·��������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_RouteIDSub,F_AppendBarcode,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Base_Route_Device WHERE ").Append(
|
||
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and (T_Base_Route_Device.F_RouteIDSub = ").Append(
|
||
|
dv[i]["F_RouteIDSub"]).Append(") AND (T_Base_Device.F_AppendBarcode = 1 )");//20121203
|
||
|
dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvd.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (enddevice == 38001 )
|
||
|
{
|
||
|
//2���ϵ�3�㣬��·����F_AppendBarcode = 2 ���豸·��������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_RouteIDSub,F_AppendBarcode,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Base_Route_Device WHERE ").Append(
|
||
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and (T_Base_Route_Device.F_RouteIDSub = ").Append(
|
||
|
dv[i]["F_RouteIDSub"]).Append(") AND (T_Base_Device.F_AppendBarcode = 2 )");//20121203
|
||
|
dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvd.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
List<double> route = new List<double>();//0,routIDSub��1,������2��·��ʹ��Ƶ�ʣ�3��·���豸������
|
||
|
//·���������豸���������̣�Ȩ��0.3����·��ʹ��Ƶ����С��Ȩ��0.3����·����·���豸��������Ȩ��0.3��
|
||
|
|
||
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
||
|
).Append(dv[i]["F_RouteIDSub"]);
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//����
|
||
|
//route.Add(0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//·��ʹ��Ƶ�ʣ�·��ִ�е�������������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(a);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
//·���豸������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_deviceindex = T_Base_Route_Device.F_deviceindex) and (T_Monitor_Task.F_RouteID = T_Base_Route_Device.F_RouteIDSub) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(a);//·���豸������
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
|
||
|
#region 20190716 �����������豸������ռ0.3,20200411 ˫¹���ظij��������豸������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_deviceindex from T_Base_Route_Device where F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(" and (F_deviceindex >25000 and F_deviceindex <25010)");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
// ��·�������������豸�����������������ͳ�����8��
|
||
|
int i3Lconveyor = Convert.ToInt32(dv2[0]["F_deviceindex"]);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select COUNT (F_MonitorIndex)AS mtask from T_Monitor_Task where F_DeviceCommandIndex = 8 and ").Append(" F_DeviceIndex = ").Append(i3Lconveyor).Append("");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(a);//·��������������
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��������������
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��������������
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��������������
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//������·������·������*0.3+·��ʹ��Ƶ��*0.3+�豸ռ����*0.3+ ������������*0.3������Сֵ��
|
||
|
if (minroute.Count == 0)
|
||
|
{
|
||
|
minroute.Add(route[0]);
|
||
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3 + route[4] * 0.3);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3 + route[4] * 0.3))
|
||
|
{
|
||
|
minroute[0] = route[0];
|
||
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3 + route[4] * 0.3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (minroute.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(minroute[0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MinRouteIDʱ��������:" +ex.StackTrace+ ex.Message;
|
||
|
return -1;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dv1.Dispose();
|
||
|
dv2.Dispose();
|
||
|
dvd.Dispose();
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ��������
|
||
|
/// </summary>
|
||
|
/// <param name="Mankind">����������������</param>
|
||
|
/// <param name="ManFID">io_control����</param>
|
||
|
/// <param name="routeIDSub">����·������·������</param>
|
||
|
/// <param name="drv">������������ͼ</param>
|
||
|
/// <returns></returns>
|
||
|
public static int CreateMonitor(int Mankind,int ManFID, int routeIDSub,DataRowView drv,int status)
|
||
|
{
|
||
|
//�����豸������Ҫͬ��ִ�е��豸��
|
||
|
//�����Ѷ�����AGV�����ڹؼ��豸��Ҫ�������ȣ�
|
||
|
//���Դ����豸��·���ֶ������ķָ��㣬
|
||
|
//����������Ʒ����·����
|
||
|
//1�����ͻ����ͷֶο���
|
||
|
//2�����ͻ����⣨ȡ��������
|
||
|
//3��RGV��ȡ+RGVȡ����ȡ������+RGV����+RGV�ͻ�����������
|
||
|
//4�����ͻ����⣨������
|
||
|
//5�����ͻ����ͷֶο���
|
||
|
//6���Ѷ���ȡ�ͻ�(��ȡ+ȡ�����߽���+�ͻ�)��
|
||
|
//7������ɨ����
|
||
|
//12�������ؼ��豸
|
||
|
DataView dvRoute = new DataView(); DataView dvs = new DataView();
|
||
|
try
|
||
|
{
|
||
|
drv = dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE (FID = {0}) AND (F_ManageTaskKindIndex = {1})", ManFID, Mankind)).Tables[0].DefaultView[0];//20130620
|
||
|
//20110104
|
||
|
if (ccf.GetMonitorIndex(ManFID, Mankind) >= 29000)
|
||
|
{
|
||
|
|
||
|
//ccf.UpdateMonitorIndex(1);
|
||
|
ccf.UpdateMonitorIndex(3001);//LHDF
|
||
|
}
|
||
|
if (drv != null && Convert.ToString(drv["FENDDEVICE"]) == "22270" && Convert.ToString(drv["FCONTROLTASKTYPE"]) == "2")
|
||
|
{
|
||
|
var result = dbo.ExceSQL(string.Format("select * from T_Monitor_Task where F_NumParam4 = 22270")).Tables[0].Rows.Count;
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(22262);
|
||
|
if (result > 7 || devinfo.SplitByte_0 == 1 || devinfo.RunState > 0)
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
//20121203
|
||
|
//����A�ؿ���ȥ�������İ���12068�������ֱ����ܳ�������
|
||
|
//����B��������12019�IJ��ܳ���4����
|
||
|
//����Bȥ�������ͻؿ�����������12034�ȴ�ִ�еIJ��ܳ���3��
|
||
|
//�������B����������ÿ��������������
|
||
|
//if (ControlTaskAmountUnDisassemble(drv) == true) return 0;
|
||
|
|
||
|
// 20190723 ����˫���Ѷ����ij�����������������λͬʱ���ڳ�������ʱ��Ҫ�Ȳ���2��3�ţ�������1��4
|
||
|
if (Stack2ReachCannotOut(drv)== true) return 0;
|
||
|
|
||
|
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append( "SELECT T_Base_Route_Device.F_DeviceIndex,F_DeviceOrder, T_Base_Route_Device.F_SerialNumber, " ).Append(
|
||
|
"T_Base_Device.F_DeviceKindIndex,F_UnControl FROM " ).Append(
|
||
|
"T_Base_Device,T_Base_Route_Device where " ).Append(
|
||
|
"T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_RouteIDSub=" ).Append(
|
||
|
routeIDSub + " order by F_SerialNumber asc ");
|
||
|
dvRoute = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvRoute.Count == 0) return 0;
|
||
|
dbo.TransBegin(IsolationLevel.ReadCommitted);
|
||
|
int CurSerialNumber = 0;
|
||
|
List<int> PriorDevice0 = new List<int>(), PriorKeyDevice0 = new List<int>();
|
||
|
StringBuilder AheadDetect =new StringBuilder();//20101124
|
||
|
StringBuilder RunningLock = new StringBuilder();//20101124
|
||
|
StringBuilder AheadTrigger = new StringBuilder();//20101124
|
||
|
string uncontrol = string.Empty;
|
||
|
for (int i = 0; i < dvRoute.Count; i++)
|
||
|
{
|
||
|
AheadDetect.Remove(0,AheadDetect.Length);
|
||
|
RunningLock.Remove(0,RunningLock.Length);
|
||
|
AheadTrigger.Remove(0,AheadTrigger.Length);
|
||
|
uncontrol= (dvRoute[i]["F_UnControl"] + "").ToString();
|
||
|
|
||
|
List<int> PriorDevice = new List<int>(), NextDevice = new List<int>(),
|
||
|
CurDevice = new List<int>(), NextKeyDevice = new List<int>();//0�豸������1�豸����;2:·�����ţ�3���豸����
|
||
|
//��ֹ���ͻ��豸���ظ����ҹؼ��豸
|
||
|
if (Convert.ToInt32(dvRoute[i]["F_SerialNumber"]) <= CurSerialNumber) continue;
|
||
|
|
||
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceIndex"]));
|
||
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceKindIndex"]));
|
||
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_SerialNumber"]));
|
||
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceOrder"]));
|
||
|
int aaa = routeIDSub;
|
||
|
NextKeyDevice = GetNextKeyDevice(routeIDSub, Convert.ToInt32(dvRoute[i]["F_SerialNumber"]));
|
||
|
if (NextKeyDevice.Count > 0)//�ҵ��ؼ��豸��0�豸������1�豸����;2:·�����ţ�3���豸����
|
||
|
{
|
||
|
|
||
|
CurSerialNumber = NextKeyDevice[2];
|
||
|
NextDevice = GetNextDevice(routeIDSub, NextKeyDevice[2]);
|
||
|
PriorDevice = GetPriorDevice(routeIDSub, NextKeyDevice[2]);
|
||
|
|
||
|
int TriggerTaskNo = 0;
|
||
|
int[] Coor = new int[6] { 0, 0, 0, 0, 0, 0 };
|
||
|
//20101118
|
||
|
string tw = string.Empty;
|
||
|
int mainTask = 0; int Rgvorder = 0;
|
||
|
int lifterUP=0,snextq = 0, snexts = 0;
|
||
|
switch (NextKeyDevice[1])
|
||
|
{
|
||
|
|
||
|
case 1:
|
||
|
#region �Ѷ���
|
||
|
if (NextKeyDevice[3] == -1) continue;
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
#region 3��4¥��������ͬһU���ƿ�����//20111020
|
||
|
if (NextDevice.Count > 0 && PriorDevice.Count > 0)
|
||
|
{
|
||
|
if (Convert.ToInt32(drv["FSTARTUCODE"]) > 0 && Convert.ToInt32(drv["FENDUCODE"]) == Convert.ToInt32(drv["FSTARTUCODE"]))
|
||
|
{//ֱ�Ӳ����߶��豸U���ڲ����ͳ�ָ��
|
||
|
int arrowdev = Convert.ToInt32(drv["FENDCELL"]);
|
||
|
CurDevice[3] = 6;
|
||
|
CurDevice[0] = Convert.ToInt32(drv["FSTARTCELL"]);
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{//20101124
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
int udev = Convert.ToInt32(drv["FSTARTUCODE"]);
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, udev, CurDevice[3], arrowdev) == false)
|
||
|
{
|
||
|
|
||
|
#region ���ɸ߶����ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
//20101124
|
||
|
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,F_UseAwayFork)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(udev).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append("," + arrowdev
|
||
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
#region ����һ���豸����һ���ȡ�ͻ�����
|
||
|
string Uzxy = string.Empty;//20111020
|
||
|
StringBuilder GetGDDetect=new StringBuilder("");
|
||
|
StringBuilder SendGDDetect=new StringBuilder("");
|
||
|
int SendUdevConveyor = 0;
|
||
|
//�Ѷ���ȡ����
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
|
||
|
#region �����߶�U���߿���//20111020
|
||
|
if (Convert.ToInt32(drv["FSTARTUCODE"]) > 0 )
|
||
|
{//ֱ�Ӳ����߶��豸U���ڲ����ͳ�ָ��
|
||
|
int arrowdev =0;
|
||
|
GetUAreaOutputDevice(NextKeyDevice[0],Convert.ToInt32(drv["FSTARTUCODE"]), out arrowdev, out Uzxy);
|
||
|
if (arrowdev > 0)
|
||
|
{
|
||
|
GetGDDetect.Clear();
|
||
|
GetGDDetect.Append("D-").Append(arrowdev).Append(".0;D-").Append(arrowdev).Append(".2");
|
||
|
CurDevice[3] = 6;
|
||
|
CurDevice[0] = Convert.ToInt32(drv["FSTARTCELL"]);
|
||
|
if (arrowdev != CurDevice[0])
|
||
|
{
|
||
|
int udev = Convert.ToInt32(drv["FSTARTUCODE"]);
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{//20101124
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, udev, CurDevice[3], arrowdev) == false)
|
||
|
{
|
||
|
|
||
|
#region ���ɸ߶����ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
//20101124
|
||
|
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,F_UseAwayFork)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(udev).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append("," + arrowdev
|
||
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
//����PriorDevice�����ͻ����������ͻ����CurDevice-->PriorDeviceĿ���豸,���⣺2����
|
||
|
//�յ����ͻ�PriorDevice��PLC�ϱ�������״̬����ǰ�����Ѷ�����ȡ���Ȼ����ȡ�ͻ������ȡ�Ѷ���ȡ����
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
if (uncontrol != "1")
|
||
|
{//20091107
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
int arrowdev;
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
|
||
|
}
|
||
|
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{//20101118
|
||
|
|
||
|
AheadDetect.Append("D-").Append( tw.ToString() ).Append(";").Append( GetBeDetectedDevices(CurDevice[0]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{//20101118
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
}
|
||
|
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetSendOutDetect(CurDevice[0]);// �ͳ�����������
|
||
|
if (tw != "")
|
||
|
{//20101124
|
||
|
AheadDetect .Append("D-").Append( tw.ToString() ).Append(";").Append( GetBeDetectedDevices(CurDevice[0]));
|
||
|
|
||
|
#region 20220422 �Ѷ���֮ǰ���ͳ�������Լ����յ������ߵ������������绷�߳���վλ��
|
||
|
//AheadDetect.Append(";D").Append(GetBindingDeviceIndex(arrowdev)).Append(";I").Append(arrowdev);
|
||
|
if (GetSendOutDetect(arrowdev) != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(GetSendOutDetect(arrowdev));
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
|
||
|
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
//List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
//if (nextConveyor.Count > 0)//20110331
|
||
|
//{
|
||
|
// AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
||
|
|
||
|
// tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
// if (tw != "")
|
||
|
// {//20101124
|
||
|
// AheadDetect .Append( ";D" ).Append( tw.ToString() );
|
||
|
// }
|
||
|
// tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
// if (tw != "")
|
||
|
// {//20101124
|
||
|
// AheadDetect .Append( ";D" ).Append( tw.ToString());
|
||
|
// }
|
||
|
// ////20090803�����豸�Ƿ�����idle
|
||
|
// //AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
//}
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger .Append( PriorDevice[0].ToString()); //+ "-" + (�������ĵ���������);//���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
//20101124
|
||
|
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,F_UseAwayFork)" ).Append(
|
||
|
"VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( CurDevice[3] ).Append( "," ).Append( routeIDSub ).Append("," ).Append( status ).Append( "," ).Append( CurDevice[0] ).Append( "," + arrowdev
|
||
|
).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( drv["FUseAwayFork"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ǰһ�豸������ɨ�����ȣ��������Ĺؼ��豸
|
||
|
|
||
|
if ((PriorDevice[1] == 7) || (PriorDevice[1] == 12))
|
||
|
{
|
||
|
int arrowdev;
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
PriorDevice = PriorDevice0;
|
||
|
//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(CurDevice[0]);
|
||
|
if (devinfo.UnControl != "1")
|
||
|
{
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{//20101124
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);//20101124
|
||
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (�������ĵ���������);//���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
sql.Remove(0, sql.Length);//20101124
|
||
|
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(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
||
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//����PriorDevice�ǹ̶�վ̨����������Ѷ�������ȡ�ͻ������ȡ�Ѷ���ȡ����
|
||
|
//����PriorDevice��������PriorDevice�����������ȡ�Ѷ���ȡ���꣬���ֶѶ�������ȡ�ͻ�
|
||
|
#region ����ȡ�ͻ�����
|
||
|
|
||
|
|
||
|
int[] Coor0_2 = new int[6] { 0, 0, 0, 0, 0, 0 };
|
||
|
//����NextDevice��������NextDevice�����������ȡ�Ѷ��������꣬���ֶѶ�������ȡ�ͻ�
|
||
|
if ((PriorDevice[1] == 7) || (PriorDevice[1] == 12))
|
||
|
{
|
||
|
PriorDevice = PriorDevice0;
|
||
|
}
|
||
|
if (PriorDevice[1] == 10)
|
||
|
{
|
||
|
#region �����߶�U���߿���//20111020
|
||
|
if ((Convert.ToInt32(drv["FSTARTUCODE"]) > 0) && (Uzxy!="-"))
|
||
|
{
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] sp = Uzxy.Split(cc);
|
||
|
for (int ip = 0; ip < sp.Length; ip++)
|
||
|
{
|
||
|
Coor0_2[ip] =Convert.ToInt32( sp[ip]);
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
else
|
||
|
Coor0_2 = GetStackCoordinateFromManage(Mankind, ManFID, true);
|
||
|
}
|
||
|
else if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
//����NextDevice�����ͻ���ȡ�ͻ������ȡ�Ѷ���������
|
||
|
|
||
|
//����NextDevice�ǹ̶�վ̨��ȡ�ͻ������ȡ�Ѷ���������
|
||
|
Coor0_2 = GetStackCoordinateFromLaneGate(NextKeyDevice[0], PriorDevice[0], true);
|
||
|
}
|
||
|
|
||
|
Coor[0] = Coor0_2[0];
|
||
|
Coor[1] = Coor0_2[1];
|
||
|
Coor[2] = Coor0_2[2];
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
//�Ѷ����ͻ���
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
int[] Coor3_5 = new int[6] { 0, 0, 0, 0, 0, 0 };
|
||
|
//����NextDevice��������NextDevice�����������ȡ�Ѷ��������꣬���ֶѶ�������ȡ�ͻ�
|
||
|
if (NextDevice[1] == 10)
|
||
|
{
|
||
|
|
||
|
if (Convert.ToInt32(drv["FENDUCODE"]) > 0)
|
||
|
{
|
||
|
#region �����߶�U���߿���//20111020
|
||
|
char[] cc = new char[1] { '-' }; int curdev = 0;
|
||
|
GetUAreaInputDevice(NextKeyDevice[0],Convert.ToInt32(drv["FENDUCODE"]), out curdev, out Uzxy);
|
||
|
if (curdev > 0)
|
||
|
{
|
||
|
SendUdevConveyor = curdev;
|
||
|
SendGDDetect.Clear();
|
||
|
SendGDDetect.Append("D").Append(curdev).Append(".0;D-").Append(curdev).Append(".2");
|
||
|
string[] sp = Uzxy.Split(cc);
|
||
|
for (int ip = 0; ip < sp.Length; ip++)
|
||
|
{
|
||
|
Coor3_5[3 + ip] = Convert.ToInt32(sp[ip]);
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
else
|
||
|
{
|
||
|
Coor3_5 = GetStackCoordinateFromManage(Mankind, ManFID, false);
|
||
|
}
|
||
|
}
|
||
|
else if (NextDevice[1] == 2)
|
||
|
{
|
||
|
//����NextDevice�����ͻ���ȡ�ͻ������ȡ�Ѷ���������
|
||
|
|
||
|
//����NextDevice�ǹ̶�վ̨��ȡ�ͻ������ȡ�Ѷ���������
|
||
|
Coor3_5 = GetStackCoordinateFromLaneGate(NextKeyDevice[0],NextDevice[0], false);
|
||
|
}
|
||
|
else if (NextDevice[1] == 9)
|
||
|
{
|
||
|
//����NextDevice�ǹ̶�վ̨��ȡ�ͻ������ȡ�Ѷ���������
|
||
|
Coor3_5 = GetStackCoordinateFromLaneGate(NextKeyDevice[0],NextDevice[0], false);
|
||
|
|
||
|
}
|
||
|
|
||
|
Coor[3] = Coor3_5[3];
|
||
|
Coor[4] = Coor3_5[4];
|
||
|
Coor[5] = Coor3_5[5];
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ���ɶѶ���ָ��:��ȡ+ȡ��+�ͻ�
|
||
|
|
||
|
#region ��ȡ
|
||
|
//AheadDetect = "";
|
||
|
//if (NextDevice[1] == 2)
|
||
|
//{//��ȡʱ���ͻ�����ǰ����
|
||
|
// //20091107
|
||
|
// if (CStaticClass.OutDetectArrowIdleGoods == "1")
|
||
|
// {
|
||
|
// #region ������ǰ����������
|
||
|
|
||
|
|
||
|
// tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect = tw.ToString() + ";" + GetBeDetectedDevices(NextDevice[0]);
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
// }
|
||
|
// tw = GetBindingDeviceIndexOut(NextDevice[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect = AheadDetect + ";" + tw.ToString();
|
||
|
// }
|
||
|
// ////20090803�����豸�Ƿ�����idle
|
||
|
// AheadDetect += ";" + "I" + NextDevice[0].ToString();
|
||
|
// //20090918���Ѷ����ͻ������ͻ������Ƿ����������ж�
|
||
|
// AheadDetect += ";" + "N" + NextDevice[0].ToString();
|
||
|
// #endregion
|
||
|
// }
|
||
|
//}
|
||
|
//AheadDetect += ";" + GetBeDetectedDevices(NextKeyDevice[0]);
|
||
|
|
||
|
//#region ˫���Ѷ����ģ���������F_UseAwayFork
|
||
|
|
||
|
//int UseAwayFork = 1;//Զ������������
|
||
|
|
||
|
//devinfo = Model.CGetInfo.GetDeviceInfo(NextKeyDevice[0]);
|
||
|
//if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
//{
|
||
|
// UseAwayFork = ccf.GetUseAwayFork(Coor[0], Coor[1], Coor[2], ccf.GetWAREHOUSEFromSTCELL(NextKeyDevice[0]), Mankind, ManFID, NextKeyDevice[0],2);
|
||
|
|
||
|
// }
|
||
|
//#endregion
|
||
|
|
||
|
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 2, 0) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// sql = "INSERT INTO T_Monitor_Task " +
|
||
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," +
|
||
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," +
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect,F_UseAwayFork)" +
|
||
|
// "VALUES (" + ManFID + "," + Mankind + "," + mindex + "," + drv["FTASKLEVEL"]
|
||
|
// + "," + NextKeyDevice[0] + ",2," + routeIDSub + "," + status + "," + Coor[0] + "," + Coor[1]
|
||
|
// + "," + Coor[2] + "," + Coor[3] + "," + Coor[4] + "," + Coor[5] + ",'" + drv["FPALLETBARCODE"] + "','" + AheadDetect + "','"+UseAwayFork+"')";
|
||
|
// dbo.ExceSQL(sql);
|
||
|
|
||
|
// //��������һ�����ͻ�����ʱ�ĶѶ�����ȡ����ǰ����
|
||
|
// //��ʽ�����е��豸����+�������ĵ���������
|
||
|
// if (AheadTrigger != null)
|
||
|
// {
|
||
|
// AheadTrigger = PriorDevice[0] + "-" + mindex;
|
||
|
// //���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
// dbo.ExceSQL("update T_Monitor_Task set F_AheadTrigger='" + AheadTrigger + "' where F_MonitorIndex=" + TriggerTaskNo);
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
#region ȡ��
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
if (PriorDevice[1] == 10)
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
RunningLock.Remove(0, RunningLock.Length);//20101124
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{//ȡ������ǰ���⣬ȡ��λ�������ߵļ���
|
||
|
#region ����ʱ�����豸��
|
||
|
RunningLock.Append(PriorDevice[0].ToString());//20101124
|
||
|
//List<int> PriorDevice2 = GetPriorDevice(routeIDSub, PriorDevice[2]);
|
||
|
//if (PriorDevice2.Count > 0)
|
||
|
//{
|
||
|
// if (PriorDevice2[1] == 2)//��֤�������ͻ��Խӵĵ�һ�����ͻ�Ҳ������
|
||
|
// {
|
||
|
// RunningLock.Append(";").Append(PriorDevice2[0].ToString());//20101124
|
||
|
// }
|
||
|
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
//20101011
|
||
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], PriorDevice[0]);
|
||
|
if (cdi != null)
|
||
|
{//�����������Ѷ���ȡ��ʱ�����ڶ�����λ���л�
|
||
|
//20200411 û�ж��������ڲ���Ҫ������λ����
|
||
|
if (cdi[1].ToString()!= string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
||
|
}
|
||
|
if (cdi[3].ToString()!= string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(cdi[3]);
|
||
|
}
|
||
|
AheadDetect.Append(";").Append(cdi[4]);
|
||
|
|
||
|
}
|
||
|
//20101011
|
||
|
else
|
||
|
{
|
||
|
//û����дLanegate�ֶε����������ߣ���Ҫ��дsendOutDetevtive
|
||
|
tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
||
|
if (tw != "")
|
||
|
{//20101118
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//20090803�����豸�Ƿ�����idle
|
||
|
AheadDetect.Append(";").Append("I").Append(PriorDevice[0].ToString());
|
||
|
AheadDetect.Append(";R").Append(PriorDevice[0].ToString());//20140109
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Append(GetGDDetect);
|
||
|
}
|
||
|
}
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
if (NextDevice[1] == 2)
|
||
|
{
|
||
|
|
||
|
|
||
|
//�Ż�λ�������ͻ��ļ���
|
||
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], NextDevice[0]);
|
||
|
if (cdi != null)
|
||
|
{///20120906���ⱻ�Ѷ����ͻ��Ķ��������ڶ�����λ�����������5��Զ����6Ҳ����
|
||
|
//20200411 û�ж��������ڲ���Ҫ������λ����
|
||
|
if (cdi[1].ToString() != string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
||
|
}
|
||
|
if (cdi[3].ToString() != string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(cdi[3]);// �ӻ����ͻ���
|
||
|
}
|
||
|
|
||
|
if (cdi[5] != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(cdi[5]);
|
||
|
}
|
||
|
if (cdi[6] != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(cdi[6]);
|
||
|
}
|
||
|
if (cdi[10] != "")
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(cdi[10]);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
//}
|
||
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
}
|
||
|
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101124
|
||
|
}
|
||
|
//20101124���ⱻ�Ѷ����ͻ������ͻ�����
|
||
|
AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString()).Append(";").Append("N").Append(NextDevice[0].ToString());
|
||
|
//20140309AheadDetect.Append(";R").Append(NextDevice[0].ToString());
|
||
|
////20120405
|
||
|
//string r2 = "12002,42002,32002,12010,42010,32010,12018,42018,32018";
|
||
|
|
||
|
//if (r2.IndexOf(NextDevice[0].ToString()) >= 0)
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(Convert.ToInt32(NextDevice[0] - 1).ToString()).Append(".0;N").Append(Convert.ToInt32(NextDevice[0] - 1).ToString()); ;
|
||
|
//}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(SendGDDetect);
|
||
|
}
|
||
|
}
|
||
|
//20120409
|
||
|
//if (NextDevice.Count > 0)
|
||
|
//{
|
||
|
// devinfo = Model.CGetInfo.GetDeviceInfo(NextKeyDevice[0]);
|
||
|
// //if (devinfo.VirtualStack > 0)
|
||
|
// //{
|
||
|
// // //20120906
|
||
|
// if ((SendUdevConveyor > 0) )
|
||
|
// {
|
||
|
// AheadDetect.Append(";R").Append(SendUdevConveyor.ToString());
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// AheadDetect.Append(";R").Append(NextDevice[0].ToString());
|
||
|
// }
|
||
|
// //}
|
||
|
//}
|
||
|
AheadDetect .Append( ";" ).Append( GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
||
|
//LHDF
|
||
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndex(NextKeyDevice[0])); //ȥ���ո�
|
||
|
//ȡ��
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 4, 0) == false)
|
||
|
{
|
||
|
lifterUP = ccf.GetMonitorIndex(ManFID, Mankind);//����������
|
||
|
snextq = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
snexts = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
|
||
|
sql.Remove(0,sql.Length);//20101124
|
||
|
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_NumParam2," ).Append(
|
||
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork,F_PriorMonitor,F_AgvTask,F_AGVNextTask)").Append(
|
||
|
"VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( NextKeyDevice[0] ).Append( ",4," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
||
|
).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] )
|
||
|
.Append( ",'" ).Append( AheadDetect.ToString()).Append( "','" ).Append( RunningLock.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] )
|
||
|
.Append("','").Append(drv["FUseAwayFork"]).Append("',").Append(lifterUP).Append(",").Append(snextq).Append(",").Append(snexts).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ����
|
||
|
|
||
|
//if (NextDevice[1] == 10)
|
||
|
//{
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//}
|
||
|
//RunningLock = "";
|
||
|
//AheadDetect = GetBeDetectedDevices(NextKeyDevice[0]);
|
||
|
////����
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 3, 0) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// sql = "INSERT INTO T_Monitor_Task " +
|
||
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," +
|
||
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," +
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" +
|
||
|
// "VALUES (" + ManFID + "," + Mankind + "," + mindex + "," + drv["FTASKLEVEL"]
|
||
|
// + "," + NextKeyDevice[0] + ",3," + routeIDSub + "," + status + "," + Coor[0] + "," + Coor[1]
|
||
|
// + "," + Coor[2] + "," + Coor[3] + "," + Coor[4] + "," + Coor[5] + ",'" + drv["FPALLETBARCODE"] + "','" + AheadDetect + "')";
|
||
|
// dbo.ExceSQL(sql);
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �ͻ�
|
||
|
|
||
|
|
||
|
RunningLock.Remove(0,RunningLock.Length);//20101124
|
||
|
AheadDetect.Remove(0,AheadDetect.Length);//20101124
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
if (NextDevice[1] == 2)
|
||
|
{//�ͻ�����ǰ����+����ʱ����
|
||
|
////20120405
|
||
|
//string r2 = "12002,42002,32002,12010,42010,32010,12018,42018,32018";
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
//sql.Remove(0, sql.Length);//20101124
|
||
|
//sql.Append("SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate WHERE (F_LaneGateDeviceIndex =").Append(NextDevice[0]).Append(") AND (F_RunLock = '1')");
|
||
|
//DataView dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
////20101124
|
||
|
//if (dvlane.Count > 0)
|
||
|
//{
|
||
|
// RunningLock.Append(NextDevice[0].ToString());//20101124
|
||
|
// //20120405
|
||
|
// if (r2.IndexOf(NextDevice[0].ToString()) >= 0)
|
||
|
// {
|
||
|
// RunningLock.Append(NextDevice[0].ToString()).Append(";").Append((NextDevice[0] - 1).ToString());
|
||
|
// }
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// RunningLock.Remove(0, RunningLock.Length);//20101124
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
#region ������ǰ����������
|
||
|
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
//20101011
|
||
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], NextDevice[0]);
|
||
|
if (cdi != null)
|
||
|
{//20120906���ⱻ�Ѷ����ͻ��Ķ��������ڶ�����λ�����������5��Զ����6Ҳ����
|
||
|
//20200411 û�ж��������ڲ���Ҫ������λ����
|
||
|
if (cdi[1].ToString() != string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
||
|
}
|
||
|
if (cdi[3].ToString() != string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(cdi[3]);
|
||
|
}
|
||
|
if (cdi[5] != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(cdi[5]);
|
||
|
}
|
||
|
if (cdi[6] != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(cdi[6]);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101124
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
}
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString());//20101124
|
||
|
////20090918���Ѷ����ͻ������ͻ������Ƿ����������ж�
|
||
|
//AheadDetect.Append(";").Append("N").Append(NextDevice[0].ToString());//20101124
|
||
|
|
||
|
//20101124���ⱻ�Ѷ����ͻ������ͻ�����
|
||
|
AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString()).Append(";").Append("N").Append(NextDevice[0].ToString());
|
||
|
////20120405
|
||
|
//if (r2.IndexOf(NextDevice[0].ToString()) >= 0)
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(Convert.ToInt32(NextDevice[0] - 1).ToString()).Append(".0;N").Append(Convert.ToInt32(NextDevice[0] - 1).ToString()); ;
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(SendGDDetect);
|
||
|
}
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
||
|
//LHDF
|
||
|
AheadDetect.Append(";D-").Append(GetBindingDeviceIndex(NextKeyDevice[0]));
|
||
|
//�ͻ�
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 5, 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110510
|
||
|
sql.Remove(0, sql.Length);//20101124
|
||
|
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_NumParam2,").Append(
|
||
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork,F_PriorMonitor,F_AGVTask,F_AGVNextTask)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(NextKeyDevice[0]).Append(",5,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
||
|
).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",")
|
||
|
.Append(Coor[5]).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','")
|
||
|
.Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("',").Append(lifterUP).Append(",").Append(snextq).Append(",").Append(snexts).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101124
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
#region �����߶�U���߿���//20111020
|
||
|
if (NextDevice.Count > 0 && Convert.ToInt32(drv["FENDUCODE"]) > 0 )
|
||
|
{//ֱ�Ӳ����߶��豸U���ڲ����ͳ�ָ��
|
||
|
int arrowdev =Convert.ToInt32(drv["FENDCELL"]);
|
||
|
CurDevice[3] = 6;
|
||
|
int curdev = 0; int udev = Convert.ToInt32(drv["FENDUCODE"]);
|
||
|
GetUAreaInputDevice(NextKeyDevice[0],Convert.ToInt32(drv["FENDUCODE"]), out curdev, out Uzxy);
|
||
|
if (curdev > 0)
|
||
|
{
|
||
|
CurDevice[0] = curdev;
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{//20101124
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, udev, CurDevice[3], arrowdev) == false)
|
||
|
{
|
||
|
|
||
|
#region ���ɸ߶����ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
//20101124
|
||
|
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,F_UseAwayFork)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(udev).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append("," + arrowdev
|
||
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
//��T_Manage_Task��FLANEWAY��FSTACK
|
||
|
sql.Remove(0, sql.Length);//20101124
|
||
|
sql.Append("SELECT F_LaneDeviceIndex,F_StackIndex FROM T_Base_LaneInfo where F_StackIndex=" ).Append( NextKeyDevice[0]);
|
||
|
dvs = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//20101124
|
||
|
int laneway = 0;
|
||
|
if (dvs.Count > 0)
|
||
|
{
|
||
|
laneway = Convert.ToInt32(dvs[0]["F_LaneDeviceIndex"]);
|
||
|
|
||
|
}//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FLANEWAY=" ).Append( laneway ).Append( ",FSTACK=" ).Append( NextKeyDevice[0] ).Append( " where (FLANEWAY=-1) and (FSTACK=-1) and (F_ManageTaskKindIndex=" ).Append( Mankind ).Append( ") and FID=" ).Append( ManFID);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20101124
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
case 2://���ͻ����ؼ��㣺����ʮ��·�ڣ���ǰһ���ͺ�һ���豸������·���յ㣨û�к�һ���豸����
|
||
|
#region ���ͻ�
|
||
|
if (NextDevice.Count == 0)//�յ����ͻ�
|
||
|
{
|
||
|
if (uncontrol != "1")
|
||
|
{//20091107
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
int arrowdev;
|
||
|
if (CurDevice[0] == NextKeyDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
if ((CurDevice[3] == 1) || ((CurDevice[3] == 2)))
|
||
|
{
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( ";D" ).Append( tw.ToString());//20101124
|
||
|
}
|
||
|
|
||
|
}
|
||
|
//else if (CurDevice[3] == 2)
|
||
|
//{
|
||
|
// tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect = "D-" + tw.ToString() + ";" + GetBeDetectedDevices(CurDevice[0]);//20101118
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
// }
|
||
|
//}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = NextKeyDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
||
|
if (null != cdi)
|
||
|
{//20100406���ⱻ�Ѷ����ͻ��Ķ��������ڶ�����λ������
|
||
|
AheadDetect.Append(";D-").Append(cdi[1]).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
//20101011
|
||
|
else
|
||
|
{
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
|
||
|
//List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
//if (nextConveyor.Count > 0)//20110331
|
||
|
//{
|
||
|
// AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
||
|
|
||
|
// tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
// }
|
||
|
// tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
// }
|
||
|
// ////20090803�����豸�Ƿ�����idle
|
||
|
// //AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
//}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
|
||
|
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( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( CurDevice[3] ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( arrowdev
|
||
|
).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
else//20110104��AGV�����Ķ���������·��ʮ��·��
|
||
|
{
|
||
|
int arrowdev;
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
if (uncontrol != "1")
|
||
|
{//20091107
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
|
||
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
if (nextConveyor.Count > 0)//20110331
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));//20110331
|
||
|
|
||
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (�������ĵ���������);//���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
RunningLock.Clear();//20120420
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
sql.Remove(0, sql.Length);//20101124
|
||
|
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,F_RunningLock)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
||
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(RunningLock).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ������ǰһ���ͻ�PriorDevice[0]���У���������������½�
|
||
|
//arrowdev = 0;
|
||
|
//#region ������ǰ����������
|
||
|
////CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
//AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
|
||
|
//tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D-").Append(tw.ToString());//20101124
|
||
|
//}
|
||
|
//AheadDetect.Append(";I").Append( PriorDevice[0].ToString());
|
||
|
//#endregion
|
||
|
//AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
||
|
//{
|
||
|
// #region ����ʱ�����豸��
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// #region �������ͻ�����
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// TriggerTaskNo = mindex;
|
||
|
// sql.Remove(0, sql.Length);//20101124
|
||
|
// 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(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
// ).Append(",").Append(NextKeyDevice[0]).Append(",").Append(NextKeyDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(NextKeyDevice[0]).Append(",").Append(arrowdev
|
||
|
// ).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// #endregion
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
break;
|
||
|
case 4:
|
||
|
#region RGV
|
||
|
//RGVȡ����
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
//����PriorDevice�����ͻ����������ͻ����CurDevice-->PriorDeviceĿ���豸,���⣺2����
|
||
|
//�յ����ͻ�PriorDevice��PLC�ϱ�������״̬����ǰ����RGV�������7����Ȼ����ȡ�ͻ������ȡ�Ѷ���ȡ����
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
// ȡ�������ߵļ���
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
if ((uncontrol != "1") && (CurDevice[1] == 2))
|
||
|
{//20091107
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
int arrowdev;
|
||
|
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")// .0
|
||
|
{
|
||
|
// 20201015 ����������ͬʱ������ת��������յ����鿪���෴
|
||
|
if (CurDevice[3] == 1)// �������.0 �л� ��1��
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
}
|
||
|
if (CurDevice[3] == 2) // ��ת����������
|
||
|
{
|
||
|
AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")// ��1
|
||
|
{
|
||
|
// 20201015 ����������ͬʱ������ת��������յ����鿪���෴
|
||
|
if (CurDevice[3] == 1)// �������������
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
}
|
||
|
if (CurDevice[3] == 2) // ��ת���������л�
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(tw.ToString());//20101124
|
||
|
}
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
|
||
|
//List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
//if (nextConveyor.Count > 0)//20110331
|
||
|
//{
|
||
|
// AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
||
|
// tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
// }
|
||
|
// tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
// }
|
||
|
// ////20090803�����豸�Ƿ�����idle
|
||
|
// //AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (�������ĵ���������);//���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
sql.Remove(0, sql.Length);//20101124
|
||
|
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(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
||
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{//20111020
|
||
|
List<int> newPrior = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newPrior != null)
|
||
|
{
|
||
|
PriorDevice = newPrior;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ����RGV���еĽӻ�λ���豸����
|
||
|
Coor[0] = PriorDevice[0];
|
||
|
Coor[1] = 0;
|
||
|
Coor[2] = 0;
|
||
|
Coor[3] = 0;
|
||
|
Coor[4] = 0;
|
||
|
Coor[5] = 0;
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region ����RGVָ��:7-�˶�����Ŀ���豸������+��2-���ӻ�3-���ͻ������ߣ�4-�ҽӻ�5-���ͻ���
|
||
|
////20090625
|
||
|
//#region ������ǰ����������
|
||
|
//AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
////20111215 ;
|
||
|
//tw = GetBindingDeviceIndex(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101124
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//}
|
||
|
////tw = GetBindingDeviceIndexOut(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
////if (tw != "")
|
||
|
////{
|
||
|
//// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
////}
|
||
|
|
||
|
////20111215
|
||
|
//////20090803�����豸�Ƿ�����idle
|
||
|
////AheadDetect .Append( ";" ).Append( "I" ).Append( NextDevice[0].ToString());//20101124
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
||
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
//}
|
||
|
//#endregion
|
||
|
|
||
|
////�˶�
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 2, Coor[0]) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// sql.Remove(0, sql.Length);//20101124
|
||
|
// 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_NumParam2," ).Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" ).Append(
|
||
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
// ).Append( "," ).Append( NextKeyDevice[0] ).Append( ",7," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
||
|
// ).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( AheadDetect.ToString()).Append( "')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// //20101124
|
||
|
// //��������һ�����ͻ�����ʱ��RGV���е���ǰ����
|
||
|
// //��ʽ�����е��豸����+�������ĵ���������
|
||
|
// if (AheadTrigger != null)
|
||
|
// {//20101124
|
||
|
// AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
// AheadTrigger .Append( PriorDevice[0] ).Append( "-" ).Append( mindex);
|
||
|
// //���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
// sql.Clear();
|
||
|
// sql.Append("update T_Monitor_Task set F_AheadTrigger='" ).Append( AheadTrigger ).Append( "' where F_MonitorIndex=" ).Append( TriggerTaskNo);
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// //20101124
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ���ͻ����ͻ�
|
||
|
|
||
|
//#region ������ǰ����������
|
||
|
////2011124
|
||
|
//AheadDetect.Remove(0, AheadDetect.Length); ;
|
||
|
//tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append("D-").Append(tw.ToString());//20111215.Append( ";" ).Append( GetBeDetectedDevices(PriorDevice[0]));//20101124
|
||
|
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//}
|
||
|
//////20090803�����豸�Ƿ�����idle
|
||
|
////AheadDetect += ";" + "I" + PriorDevice[0].ToString();
|
||
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20111215 +";" + GetBeDetectedDevices(NextKeyDevice[0]);//20101118
|
||
|
//}
|
||
|
////20101124
|
||
|
//#endregion
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, PriorDevice[0], 3, 0) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// 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_NumParam2," ).Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)" ).Append(
|
||
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
// ).Append( "," ).Append( PriorDevice[0] ).Append( "," ).Append( 3 ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( PriorDevice[0] ).Append( ",0,"
|
||
|
// ).Append( "0,0,0,0,'" ).Append( AheadDetect.ToString() ).Append( "','").Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// mainTask = mindex;
|
||
|
//}
|
||
|
////20101124
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region RGV�Ľӻ�����������������
|
||
|
Rgvorder = 2; //GetRGVOrder(PriorDevice[0], true);
|
||
|
//20130510�����Ƿ�����28001���ڹ�������ȡ��
|
||
|
#region AGV�Խ���������
|
||
|
//if (PriorDevice[0] == 28001)
|
||
|
//{
|
||
|
// PriorDevice[0] = GetAGVAddressFromManage(Mankind, ManFID, true)[1];
|
||
|
// Rgvorder = 7;
|
||
|
//}
|
||
|
#endregion
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
#region Ŀ�����ͻ�������ǰ����������
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101124
|
||
|
}
|
||
|
//20111215
|
||
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
//20090803�����豸�Ƿ�����idle
|
||
|
AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString());//20101124
|
||
|
#region 20201015 ˫¹���طּ�������˫����������������;M ������ȡ������ �յ����ͻ��Ƿ��жѶ�������
|
||
|
//if (NextDevice[0] == 22047 || NextDevice[0]== 22042 || NextDevice[0]== 22036)
|
||
|
//{
|
||
|
// AheadDetect.Append(";M").Append(NextDevice[0].ToString());//20101124
|
||
|
|
||
|
//}
|
||
|
#endregion
|
||
|
#endregion
|
||
|
#region ȡ�����ͻ�������ǰ����������
|
||
|
tw = GetBindingDeviceIndexOut(PriorDevice[0]);// .1
|
||
|
if (tw != "")
|
||
|
{
|
||
|
// ������������˫���� ��ת��ת��ͬ20201016
|
||
|
if (PriorDevice[3] == 1)
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
||
|
}
|
||
|
if (PriorDevice[3] == 2)
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
||
|
tw = GetBindingDeviceIndex(PriorDevice[0]);//.0
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(tw.ToString());
|
||
|
}
|
||
|
}
|
||
|
if (PriorDevice[3] == -1)
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
//20090803�����豸�Ƿ�����idle
|
||
|
AheadDetect.Append(";").Append("I").Append(PriorDevice[0].ToString());//20101124
|
||
|
|
||
|
#endregion
|
||
|
tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
// ������������˫���� ��ת��ת��ͬ20201016
|
||
|
if (NextKeyDevice[3] == 1)
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));
|
||
|
}
|
||
|
}
|
||
|
AheadDetect.Append(";I").Append(NextKeyDevice[0]);
|
||
|
#endregion
|
||
|
|
||
|
#region ����ȡ����
|
||
|
//20101124
|
||
|
//if (PriorDevice[0] == 22102 || PriorDevice[0] == 22104)//20130510�����뽫ȡ
|
||
|
//{
|
||
|
// if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 7, 0) == false)
|
||
|
// {
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// 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_NumParam2,").Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)").Append(
|
||
|
// "VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
// ).Append(",").Append(NextKeyDevice[0]).Append(",").Append(7).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(PriorDevice[0]).Append(",0").Append(
|
||
|
// ",0,0,0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], Rgvorder, 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
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_NumParam2," ).Append(
|
||
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)" ).Append(
|
||
|
"VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( NextKeyDevice[0] ).Append( "," ).Append( Rgvorder).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( PriorDevice[0] ).Append( ",0" ).Append(
|
||
|
",0,0,0,0,'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
|
||
|
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Associate=" ).Append( mindex ).Append( " where F_MonitorIndex=" ).Append( mainTask);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
//20101124
|
||
|
#endregion
|
||
|
|
||
|
#region RGV�����������豸��Ҫ�����ȶ�
|
||
|
int barcodedev = GetBarcodeDeviceFromBindDevice(NextKeyDevice[0]);
|
||
|
if (barcodedev > 0)
|
||
|
{
|
||
|
#region ���������ȶ�����
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, barcodedev, 1, 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
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(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(barcodedev).Append(",").Append(1).Append(",").Append(ccf.GetRouteIDsub(barcodedev)).Append(",").Append(status).Append(",0,0,'").Append("").Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
//����RGV���е��ͻ�λ���豸������
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
Coor[0] = NextDevice[0];
|
||
|
Coor[1] = 0;
|
||
|
Coor[2] = 0;
|
||
|
Coor[3] = 0;
|
||
|
Coor[4] = 0;
|
||
|
Coor[5] = 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
#region ����RGVָ��:7-�˶�����Ŀ���豸������+��2-���ӻ�3-���ͻ������ߣ�4-�ҽӻ�5-���ͻ���
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//AheadDetect.Append( GetBeDetectedDevices(NextKeyDevice[0]));
|
||
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D-").Append(tw.ToString());//20101124
|
||
|
//}
|
||
|
////�˶�
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 7, Coor[0]) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// 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_NumParam2," ).Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" ).Append(
|
||
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
// ).Append( "," ).Append( NextKeyDevice[0] ).Append( ",7," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
||
|
// ).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( AheadDetect.ToString() ).Append( "')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region RGV���ͻ�
|
||
|
|
||
|
Rgvorder =3;// GetRGVOrder(NextDevice[0], false);
|
||
|
//20130510�����Ƿ�����28001���ڹ�������ȡ��
|
||
|
if (NextDevice[0] == 28001)
|
||
|
{
|
||
|
NextDevice[0] = GetAGVAddressFromManage(Mankind, ManFID, false)[4];
|
||
|
Rgvorder = 7;
|
||
|
}
|
||
|
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect .Remove(0,AheadDetect.Length);
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
//20111215
|
||
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( ";D" ).Append( tw.ToString());//20101118
|
||
|
}
|
||
|
AheadDetect.Append(";I").Append(NextDevice[0]);
|
||
|
|
||
|
tw = GetBindingDeviceIndex(NextKeyDevice[0]);//RGV��̽�������
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append(";" ).Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(NextKeyDevice[0]));//20101118
|
||
|
}
|
||
|
AheadDetect.Append(";I").Append(NextKeyDevice[0]);
|
||
|
#endregion
|
||
|
if (NextDevice[0] == 22102 || NextDevice[0] == 22104)//20130510
|
||
|
{
|
||
|
#region �ͻ���Ҫ��ǰ�˶�
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 7, 0) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// 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_NumParam2,").Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)").Append(
|
||
|
// "VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
// ).Append(",").Append(NextKeyDevice[0]).Append(",").Append(7).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(NextDevice[0]).Append(",0").Append(
|
||
|
// ",0,0,0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], Rgvorder, 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
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_NumParam2," ).Append(
|
||
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)" ).Append(
|
||
|
"VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(Rgvorder).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(NextDevice[0]).Append(",0").Append(
|
||
|
",0,0,0,0,'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
|
||
|
|
||
|
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
mainTask = mindex;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ���ͻ��Ľӻ�����������������
|
||
|
|
||
|
|
||
|
//#region ������ǰ����������
|
||
|
//AheadDetect.Remove(0, AheadDetect.Length) ;
|
||
|
//tw = GetBindingDeviceIndexOut(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect .Append( ";D" ).Append( tw.ToString());//20101118
|
||
|
//}
|
||
|
////20111215
|
||
|
//tw = GetBindingDeviceIndex(NextDevice[0]);//���ͻ�������̽�������
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101118
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//}
|
||
|
//////20090803�����豸�Ƿ�����idle
|
||
|
////AheadDetect += ";" + "I" + NextDevice[0].ToString();
|
||
|
|
||
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);//RGV��̽�������
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect .Append( ";D" ).Append( "-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(NextKeyDevice[0]));//20101118
|
||
|
//}
|
||
|
//////20090803�����豸�Ƿ�����idle
|
||
|
////AheadDetect += ";" + "I" + NextKeyDevice[0].ToString();
|
||
|
//#endregion
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextDevice[0], 4, 0) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// 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_NumParam2," ).Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)" ).Append(
|
||
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
// ).Append( "," ).Append( NextDevice[0] ).Append( "," ).Append( 4 ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( NextDevice[0] ).Append( ",0,"
|
||
|
// ).Append( "0,0,0,0,'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("update T_Monitor_Task set F_Associate=" ).Append( mindex ).Append( " where F_MonitorIndex=" ).Append( mainTask);
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
//}
|
||
|
#endregion
|
||
|
break;
|
||
|
#endregion
|
||
|
case 6:
|
||
|
#region AGV
|
||
|
|
||
|
#region ����һ���豸����һ���ȡ�ͻ�����
|
||
|
//AGVȡ����
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
if (uncontrol != "1")
|
||
|
{//20091107
|
||
|
bool IfConveyor = false;
|
||
|
if (PriorKeyDevice0.Count > 0)
|
||
|
{
|
||
|
if (PriorKeyDevice0[1] != 2)//20110104ǰһ�ؼ��豸���������ͻ�
|
||
|
{
|
||
|
IfConveyor = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
IfConveyor = true;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
IfConveyor = false;
|
||
|
}
|
||
|
if (IfConveyor == false)//20110104ǰһ�ؼ��豸���������ͻ�
|
||
|
{
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
int arrowdev;
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
if (CStaticClass.AGVAllowSingleFork == "0")//20100710
|
||
|
{
|
||
|
#region �������ͻ���������
|
||
|
//������һ��ż����һ
|
||
|
if ((CurDevice[0] % 2) == 0)
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndexOut(CurDevice[0] - 1).ToString());//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndexOut(CurDevice[0] + 1).ToString());//20101118
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
|
||
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
if (nextConveyor.Count > 0)//20110331
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
||
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
if (tw != "" )
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
#region AGV ȡ��֮ǰ���������߲���Ҫ�����յ㣬���㼯�ţ�����Ч��;���ڿ��Լ��ϼ���
|
||
|
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
#endregion
|
||
|
}
|
||
|
#region AGV ȡ��֮ǰ���������߲���Ҫ�����յ㣬���㼯�ţ�����Ч��;���ڿ��Լ��ϼ���
|
||
|
// AheadDetect.Append(";").Append("N").Append(nextConveyor[0].ToString());
|
||
|
#endregion
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
#region 22034\22035
|
||
|
//if (arrowdev == 22036)//20101203
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append("22036.0");
|
||
|
//}
|
||
|
//if (arrowdev == 22037)//20101203
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append("22037.0");
|
||
|
//}
|
||
|
#endregion
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
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( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( CurDevice[3] ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( arrowdev
|
||
|
).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
}
|
||
|
#region �������½�20110210
|
||
|
//AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//AheadDetect.Append("I").Append(Convert.ToString(arrowdev-2)).Append(";I").Append(Convert.ToString(arrowdev));
|
||
|
//tw = ccf.GetBindingDeviceIndexOut(arrowdev - 2);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect .Append( ";D-" ).Append( tw.ToString());
|
||
|
//}
|
||
|
//AheadDetect.Append(";D").Append(arrowdev.ToString()).Append(".2");//20110331
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, arrowdev, 8, 0) == false)
|
||
|
//{
|
||
|
// #region ����ʱ�����豸��
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// #region �������ͻ�����
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
|
||
|
// 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( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
// ).Append( "," ).Append( arrowdev ).Append( "," ).Append( 8 ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status
|
||
|
// ).Append( "," ).Append( arrowdev ).Append( "," ).Append( 0
|
||
|
// ).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// #endregion
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
int[] Coor0_2 = new int[6] { 0, 0, 0, 0, 0, 0 };
|
||
|
//����PriorDevice��AGVͨ����PriorDevice�����������ȡ�����꣬����AGV����ȡ���ͻ�
|
||
|
if (PriorDevice[1] == 11)
|
||
|
{
|
||
|
Coor0_2 =GetAGVAddressFromManage (Mankind, ManFID, true);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//����NextDevice�����ͻ���ȡ�ͻ������ȡ������
|
||
|
|
||
|
//����NextDevice�ǹ̶�վ̨��ȡ�ͻ������ȡ������
|
||
|
Coor0_2[1] =PriorDevice[0];
|
||
|
}
|
||
|
Coor[0] = Coor0_2[0];
|
||
|
Coor[1] = Coor0_2[1];//վ̨�豸����
|
||
|
Coor[2] = Coor0_2[2];
|
||
|
}
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
int[] Coor3_5 = new int[6] { 0, 0, 0, 0, 0, 0 };
|
||
|
//����NextDevice��AGVͨ����NextDevice�����������ȡ�����꣬����AGV����ȡ���ͻ�
|
||
|
if (NextDevice[1] == 11)
|
||
|
{
|
||
|
Coor3_5 = GetAGVAddressFromManage(Mankind, ManFID, false);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//����NextDevice�����ͻ���ȡ�ͻ������ȡ������
|
||
|
|
||
|
//����NextDevice�ǹ̶�վ̨��ȡ�ͻ������ȡ������
|
||
|
Coor3_5[4] =NextDevice[0];
|
||
|
}
|
||
|
Coor[3] = Coor3_5[3];
|
||
|
Coor[4] = Coor3_5[4];//վ̨�豸����
|
||
|
Coor[5] = Coor3_5[5];
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ����AGVָ��:ȡ�ͻ�//20110104
|
||
|
//ת�������������ͺ�AGV��������
|
||
|
int agvorder = 0;
|
||
|
|
||
|
#region AGVȡ��
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
agvorder = 2;//AGVȡ��
|
||
|
RunningLock.Remove(0, RunningLock.Length) ;
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
RunningLock .Append(PriorDevice[0].ToString());
|
||
|
//ȡ��ʱ�����������ͻ�
|
||
|
if (CStaticClass.AGVAllowSingleFork == "0")
|
||
|
{
|
||
|
if ((PriorDevice[0] % 2) == 0)
|
||
|
{
|
||
|
RunningLock .Append( ";" ).Append( (PriorDevice[0] - 1).ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
RunningLock.Append( ";" ).Append( (PriorDevice[0] + 1).ToString());
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//AheadDetect .Append( "D-" ).Append( GetBindingDeviceIndexOut(PriorDevice[0]).ToString() ).Append( ";I" ).Append( PriorDevice[0].ToString());
|
||
|
//20190709 ˫�������߲��ܼ���IndexOut������bangdingdevice
|
||
|
AheadDetect.Append("D-").Append(GetBindingDeviceIndex(PriorDevice[0]).ToString()).Append(";I").Append(PriorDevice[0].ToString());
|
||
|
|
||
|
#region ���Ӽ��ⶥ���Ƿ��ڵ�λ20100710
|
||
|
//AheadDetect .Append( ";D-" ).Append( PriorDevice[0].ToString() ).Append( ".2");
|
||
|
#endregion
|
||
|
}
|
||
|
//20190709 ����AGVͨ���ƿ��������飬ǰ������AGVͨ��
|
||
|
if (PriorDevice[1] == 11)
|
||
|
{
|
||
|
int type = ccf.GetDeviceKindIdx(Coor[1]);// �õ�ȡ��վ̨����
|
||
|
if (type == 2)
|
||
|
{
|
||
|
// �����������鿴��������
|
||
|
AheadDetect.Append(";D-").Append(GetBindingDeviceIndex(Coor[1])).Append(";I").Append(Coor[1]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
if (NextDevice[1] == 2)
|
||
|
{//20100714
|
||
|
AheadDetect .Append( ";D" ).Append( GetBindingDeviceIndex(NextDevice[0]).ToString() ).Append( ";I" ).Append( NextDevice[0].ToString() ).Append( ";N" ).Append( NextDevice[0].ToString());
|
||
|
|
||
|
}
|
||
|
//20190709 �ͻ�վ̨������
|
||
|
int type = ccf.GetDeviceKindIdx(Coor[4]);// �õ��ͻ�վ̨����
|
||
|
if (type == 2)
|
||
|
{
|
||
|
// �����������鿴�����������ͻ������߿�
|
||
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndex(Coor[4])).Append(";I").Append(Coor[4]);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (PriorDevice[1]== 2)
|
||
|
{
|
||
|
#region ȡ��λ�������ͻ��������˶�����
|
||
|
////20190715 ����ҩҵ1������̨��������AGV
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 1, 0) == false || NextKeyDevice[0] == 23001)
|
||
|
//{//20091107
|
||
|
// //int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// //mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
||
|
// //mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
||
|
// //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_NumParam2,").Append(
|
||
|
// // " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork)").Append(
|
||
|
// //"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
// // ).Append(",").Append(NextKeyDevice[0]).Append(",1,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
||
|
// // ).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",").Append(Coor[5]).Append(",'")
|
||
|
// // .Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
||
|
// // dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
//20190715 ����ҩҵ1������̨��������AGV
|
||
|
#region 20200416 ˫¹���� AGV�����ij�һ������ȡ�ͻ���û��ȡ����������
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0) == false || NextKeyDevice[0]== 23001)
|
||
|
//{//20091107
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
||
|
// mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
||
|
// 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_NumParam2," ).Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork)" ).Append(
|
||
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
// ).Append( "," ).Append( NextKeyDevice[0] ).Append( ",").Append(agvorder).Append("," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
||
|
// ).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" )
|
||
|
// .Append( AheadDetect.ToString() ).Append( "','" ).Append( RunningLock.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( drv["FUseAwayFork"] ).Append( "')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region AGV�ͻ�
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
//agvorder = 3;//AGV�ͻ�
|
||
|
//20200416 ˫¹���� AGV�����ij�һ������ȡ�ͻ�4
|
||
|
agvorder = 4;//AGVȡ�ͻ�
|
||
|
|
||
|
RunningLock.Remove(0, RunningLock.Length);
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//20190709 ����AGVͨ���ƿ��������飬ǰ������AGVͨ��
|
||
|
if (PriorDevice[1] == 11)
|
||
|
{
|
||
|
int type = ccf.GetDeviceKindIdx(Coor[1]);// �õ�ȡ��վ̨����
|
||
|
if (type == 2)
|
||
|
{
|
||
|
// �����������鿴��������
|
||
|
AheadDetect.Append(";D-").Append(GetBindingDeviceIndex(Coor[1])).Append(";I").Append(Coor[1]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
if (NextDevice[1] == 2)
|
||
|
{//20100714
|
||
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndex(NextDevice[0]).ToString()).Append(";I").Append(NextDevice[0].ToString()).Append(";N").Append(NextDevice[0].ToString());
|
||
|
|
||
|
}
|
||
|
//20190709 �ͻ�վ̨��������
|
||
|
int type = ccf.GetDeviceKindIdx(Coor[4]);// �õ��ͻ�վ̨����
|
||
|
if (type == 2)
|
||
|
{
|
||
|
// �����������鿴�����������ͻ������߿�
|
||
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndex(Coor[4])).Append(";I").Append(Coor[4]);
|
||
|
AheadDetect.Append(";D-").Append(GetBindingDeviceIndex(Coor[1])).Append(";I").Append(Coor[1]);
|
||
|
|
||
|
#region �ͻ�λ�������ͻ��������ƶ�����
|
||
|
//20190715 ����ҩҵ1������̨��������AGV
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 1, 0) == false || NextKeyDevice[0] == 23001)
|
||
|
//{//20091107
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
||
|
// mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
||
|
// 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_NumParam2,").Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork)").Append(
|
||
|
// "VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
// ).Append(",").Append(NextKeyDevice[0]).Append(",1,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
||
|
// ).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",").Append(Coor[5]).Append(",'")
|
||
|
// .Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
||
|
// // dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
}
|
||
|
//20190715 ����ҩҵ1������̨��������AGV
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0) == false || NextKeyDevice[0] == 23001)
|
||
|
{//20091107
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
//mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
||
|
//mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
||
|
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_NumParam2,").Append(
|
||
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(agvorder).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
||
|
).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",").Append(Coor[5]).Append(",'")
|
||
|
.Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
break;
|
||
|
case 7:
|
||
|
#region ����ɨ���ǣ����������ȶ�1��
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
//����PriorDevice�����ͻ����������ͻ����CurDevice-->PriorDeviceĿ���豸,���⣺2����
|
||
|
//�յ����ͻ�PriorDevice��PLC�ϱ�������״̬����ǰ����RGV�������7����Ȼ����ȡ�ͻ������ȡ�Ѷ���ȡ����
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
if ((uncontrol != "1") && (CurDevice[1]==2))
|
||
|
{//20091107
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
int arrowdev;
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
if (CurDevice[3] == 1)
|
||
|
{
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( ";D" + tw.ToString());//20101118
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (CurDevice[3] == 2)
|
||
|
{
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D" + tw.ToString());//20101118
|
||
|
}
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0] );
|
||
|
if (null != cdi)
|
||
|
{//20100406���ⱻ�Ѷ����ͻ��Ķ��������ڶ�����λ������
|
||
|
AheadDetect.Append(";D-").Append(cdi[1]).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
//20101011
|
||
|
else
|
||
|
{
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
|
||
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
if (nextConveyor.Count > 0)//20110331
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
||
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
if ((tw != "")&&(nextConveyor[0]!=12304)&&(nextConveyor[0]!=12310))//20130510
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger .Append( PriorDevice[0].ToString()); //+ "-" + (�������ĵ���������);//���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
if ((CurDevice[0] == 32037) || (CurDevice[0] == 32050))
|
||
|
{
|
||
|
RunningLock.Clear() ;
|
||
|
RunningLock.Append(Convert.ToInt32(CurDevice[0]-1));
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
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( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( CurDevice[3] ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( arrowdev
|
||
|
).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
|
||
|
#region ���������ȶ�����
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
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( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( NextKeyDevice[0] ).Append( "," ).Append( NextKeyDevice[3] ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( ",0,0,'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
break;
|
||
|
case 8://20130510
|
||
|
#region �����豸����������1��
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
//����PriorDevice�����ͻ����������ͻ����CurDevice-->PriorDeviceĿ���豸,���⣺2����
|
||
|
//�յ����ͻ�PriorDevice��PLC�ϱ�������״̬����ǰ����RGV�������7����Ȼ����ȡ�ͻ������ȡ�Ѷ���ȡ����
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
if ((uncontrol != "1") && (CurDevice[1] == 2))
|
||
|
{//20091107
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
int arrowdev;
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
if (CurDevice[3] == 1)
|
||
|
{
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D" + tw.ToString());//20101118
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (CurDevice[3] == 2)
|
||
|
{
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D" + tw.ToString());//20101118
|
||
|
}
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
||
|
if (null != cdi)
|
||
|
{//20100406���ⱻ�Ѷ����ͻ��Ķ��������ڶ�����λ������
|
||
|
AheadDetect.Append(";D-").Append(cdi[1]).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
//20101011
|
||
|
else
|
||
|
{
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
|
||
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
if (nextConveyor.Count > 0)//20110331
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
||
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (�������ĵ���������);//���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
if ((CurDevice[0] == 32037) || (CurDevice[0] == 32050))
|
||
|
{
|
||
|
RunningLock.Clear();
|
||
|
RunningLock.Append(Convert.ToInt32(CurDevice[0] - 1));
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
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(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
||
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
tw = GetSendOutDetect(PriorDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
#endregion
|
||
|
if (CurDevice[0] == 12304 || CurDevice[0] == 12310)
|
||
|
{//20130510 16006,16008
|
||
|
int dev = GetBarcodeDeviceFromBindDevice(CurDevice[0]);
|
||
|
#region ���������ȶ�����1
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, dev, 1, 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
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(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(dev).Append(",").Append(1).Append(",").Append(ccf.GetRouteIDsub(dev)).Append(",").Append(status).Append(",0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
#region ���ɳ�������1
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
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(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(NextKeyDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
break;
|
||
|
case 12:
|
||
|
#region �����ؼ��豸��ֻ��Ϊ·���ָ��㣩
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
//����PriorDevice�����ͻ����������ͻ����CurDevice-->PriorDeviceĿ���豸,���⣺2����
|
||
|
//�յ����ͻ�PriorDevice��PLC�ϱ�������״̬����ǰ����RGV�������7����Ȼ����ȡ�ͻ������ȡ�Ѷ���ȡ����
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
if (uncontrol != "1")
|
||
|
{//20091107
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
int arrowdev;
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
//20101011
|
||
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
||
|
if ((null!= cdi)&&(CurDevice[3] == 2))
|
||
|
{//20100406���ⱻ�Ѷ����ͻ��Ķ��������ڶ�����λ������
|
||
|
AheadDetect .Append( ";D-" ).Append( cdi[1] ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
//20101011
|
||
|
else
|
||
|
{
|
||
|
if (CurDevice[3] == 1)// ��ת����
|
||
|
{
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( ";D" ).Append( tw.ToString());//20101118
|
||
|
}
|
||
|
}
|
||
|
else if ((CurDevice[3] == 2) )//20110510��ת
|
||
|
{
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
//else if (CurDevice[3] == 2)
|
||
|
//{
|
||
|
// tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect = "D-" + tw.ToString() + ";" + GetBeDetectedDevices(CurDevice[0]);//20101118
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
// }
|
||
|
//}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{//20091107
|
||
|
AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
|
||
|
|
||
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
//if (nextConveyor.Count > 0)//20110331
|
||
|
//{
|
||
|
// AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
||
|
// tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
// }
|
||
|
// tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
// }
|
||
|
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
#region 2020-03-31 ����������һ�Σ�Ϊ���ܹ���������Ч�ʣ�ָ��λ�ò������յ�״̬���л�
|
||
|
if (NextKeyDevice[0]== 31701)
|
||
|
{
|
||
|
|
||
|
//�������������
|
||
|
//AheadDetect.Append("I").Append(CurDevice[0]).Append(";D-").Append(CurDevice[0]).Append(".0");
|
||
|
tw = GetAheadDetect(routeIDSub, NextKeyDevice[0], NextKeyDevice[2]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Clear();
|
||
|
AheadDetect.Append(tw);
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
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( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( CurDevice[3] ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( arrowdev
|
||
|
).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
break;
|
||
|
case 30:
|
||
|
#region 20100617�������������豸��1����������ȷ��
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
//����PriorDevice�����ͻ����������ͻ����CurDevice-->PriorDeviceĿ���豸,���⣺2����
|
||
|
//�յ����ͻ�PriorDevice��PLC�ϱ�������״̬����ǰ����RGV�������7����Ȼ����ȡ�ͻ������ȡ�Ѷ���ȡ����
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
if (uncontrol != "1")
|
||
|
{//20091107
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
int arrowdev;
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
if ((CurDevice[3] == 1) || (CurDevice[3] == 2))
|
||
|
{
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( ";D" ).Append( tw.ToString());//20101118
|
||
|
}
|
||
|
|
||
|
}
|
||
|
//else if (CurDevice[3] == 2)
|
||
|
//{
|
||
|
// tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
// if (tw != "")
|
||
|
// {
|
||
|
// AheadDetect = "D-" + tw.ToString() + ";" + GetBeDetectedDevices(CurDevice[0]);//20101118
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
// }
|
||
|
//}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect .Append( "D-" ).Append( tw.ToString());//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
|
||
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
||
|
if (nextConveyor.Count > 0)//20110331
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
||
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger .Append( PriorDevice[0].ToString()); //+ "-" + (�������ĵ���������);//���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
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( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( CurDevice[3] ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( arrowdev
|
||
|
).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
#region ������ǰ����������
|
||
|
|
||
|
//tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect = "D-" + tw.ToString();//20101118
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
#region ���ɺ������������豸�ġ�����ȷ�ϡ�����
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
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( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
).Append( "," ).Append( NextKeyDevice[0] ).Append( "," ).Append( NextKeyDevice[3] ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( ",0,0,'" ).Append( AheadDetect ).Append( "','" ).Append( drv["FPALLETBARCODE"] + "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
break;
|
||
|
case 50:
|
||
|
#region Circle RGV
|
||
|
//RGVȡ����
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
//����PriorDevice�����ͻ����������ͻ����CurDevice-->PriorDeviceĿ���豸,���⣺2����
|
||
|
//�յ����ͻ�PriorDevice��PLC�ϱ�������״̬����ǰ����RGV�������7����Ȼ����ȡ�ͻ������ȡ�Ѷ���ȡ����
|
||
|
#region ǰһ�豸�����ͻ�
|
||
|
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{
|
||
|
if ((uncontrol != "1") && (CurDevice[1] == 2))
|
||
|
{//20091107
|
||
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newcur != null)
|
||
|
{
|
||
|
CurDevice = newcur;
|
||
|
}
|
||
|
int arrowdev;
|
||
|
|
||
|
if (CurDevice[0] == PriorDevice[0])
|
||
|
{//���ͻ��������豸���յ��豸��ͬʱ��Ŀ���豸������Ϊ��
|
||
|
arrowdev = 0;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_BindingDevice�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
}
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
#region ������ǰ����������
|
||
|
//CurDevice��F_SendOutDetect�����Ĺ��翪�ص��豸������CurDevice��̽��
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (�������ĵ���������);//���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
||
|
{
|
||
|
#region ����ʱ�����豸��
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �������ͻ�����
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;
|
||
|
sql.Remove(0, sql.Length);//20101124
|
||
|
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(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
||
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{//20111020
|
||
|
List<int> newPrior = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
||
|
if (newPrior != null)
|
||
|
{
|
||
|
PriorDevice = newPrior;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ����RGV���еĽӻ�λ���豸����
|
||
|
Coor[0] = PriorDevice[0];
|
||
|
Coor[1] = 0;
|
||
|
Coor[2] = 0;
|
||
|
Coor[3] = 0;
|
||
|
Coor[4] = 0;
|
||
|
Coor[5] = 0;
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region ����RGVָ��:7-�˶�����Ŀ���豸������+��2-���ӻ�3-���ͻ������ߣ�4-�ҽӻ�5-���ͻ���
|
||
|
////20090625
|
||
|
//#region ������ǰ����������
|
||
|
//AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
////20111215 ;
|
||
|
//tw = GetBindingDeviceIndex(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101124
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//}
|
||
|
////tw = GetBindingDeviceIndexOut(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
////if (tw != "")
|
||
|
////{
|
||
|
//// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
////}
|
||
|
|
||
|
////20111215
|
||
|
//////20090803�����豸�Ƿ�����idle
|
||
|
////AheadDetect .Append( ";" ).Append( "I" ).Append( NextDevice[0].ToString());//20101124
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
||
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
||
|
//}
|
||
|
//#endregion
|
||
|
|
||
|
////�˶�
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 2, Coor[0]) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// sql.Remove(0, sql.Length);//20101124
|
||
|
// 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_NumParam2," ).Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" ).Append(
|
||
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
// ).Append( "," ).Append( NextKeyDevice[0] ).Append( ",7," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
||
|
// ).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( AheadDetect.ToString()).Append( "')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// //20101124
|
||
|
// //��������һ�����ͻ�����ʱ��RGV���е���ǰ����
|
||
|
// //��ʽ�����е��豸����+�������ĵ���������
|
||
|
// if (AheadTrigger != null)
|
||
|
// {//20101124
|
||
|
// AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
// AheadTrigger .Append( PriorDevice[0] ).Append( "-" ).Append( mindex);
|
||
|
// //���豸������״̬�����ﵱǰλ��=PriorDevice[0]�������Ѷ����Ľ�ȡ
|
||
|
// sql.Clear();
|
||
|
// sql.Append("update T_Monitor_Task set F_AheadTrigger='" ).Append( AheadTrigger ).Append( "' where F_MonitorIndex=" ).Append( TriggerTaskNo);
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// //20101124
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
//����RGV���е��ͻ�λ���豸������
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
Coor[0] = NextDevice[0];
|
||
|
Coor[1] = 0;
|
||
|
Coor[2] = 0;
|
||
|
Coor[3] = 0;
|
||
|
Coor[4] = 0;
|
||
|
Coor[5] = 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
#region ����RGVָ��:7-�˶�����Ŀ���豸������+��2-���ӻ�3-���ͻ������ߣ�4-�ҽӻ�5-���ͻ���
|
||
|
////20090803�����豸�Ƿ�����idle
|
||
|
//AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//AheadDetect.Append( GetBeDetectedDevices(NextKeyDevice[0]));
|
||
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D-").Append(tw.ToString());//20101124
|
||
|
//}
|
||
|
////�˶�
|
||
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 7, Coor[0]) == false)
|
||
|
//{
|
||
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
// 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_NumParam2," ).Append(
|
||
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" ).Append(
|
||
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
||
|
// ).Append( "," ).Append( NextKeyDevice[0] ).Append( ",7," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
||
|
// ).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( AheadDetect.ToString() ).Append( "')");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ����RGV���ͻ�
|
||
|
|
||
|
Rgvorder = 3;// GetRGVOrder(NextDevice[0], false);
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101118
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
//20111215
|
||
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);//Ŀ�����ͻ�������̽�������
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
AheadDetect.Append(";I").Append(NextDevice[0]);
|
||
|
|
||
|
tw = GetBindingDeviceIndex(NextKeyDevice[0]);//RGV��̽�������
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";").Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101118
|
||
|
}
|
||
|
AheadDetect.Append(";I").Append(NextKeyDevice[0]);
|
||
|
#endregion
|
||
|
#region 2020-03-31 ˫¹���أ����δ���ֻ��ȡ�ͻ�������Ҫ��������
|
||
|
|
||
|
Rgvorder = 1;
|
||
|
AheadDetect.Clear();
|
||
|
#endregion
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], Rgvorder, 0) == false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
#region 2020-03-31 ˫¹���أ������������������,û��ȡ����ֻ��ȡ�ͻ�����������
|
||
|
|
||
|
string ArrowDevice = NextDevice[0].ToString();
|
||
|
//������������ʵվ̨������Ҫ�ģ��ڷ�������ʱ����������12999�������
|
||
|
if (NextDevice[0] == 12999 && drv["FCONTROLTASKTYPE"].ToString() == "2")// ��������վ̨������ת���������յ�
|
||
|
{
|
||
|
ArrowDevice = drv["FENDDEVICE"].ToString();
|
||
|
}
|
||
|
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_NumParam2,").Append(
|
||
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)").Append(
|
||
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
||
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(Rgvorder).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(PriorDevice[0]).Append(",0").Append(
|
||
|
",0,'").Append(ArrowDevice).Append("',0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
mainTask = mindex;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
}
|
||
|
PriorDevice0 = PriorDevice;
|
||
|
PriorKeyDevice0 = NextKeyDevice;
|
||
|
//20091107
|
||
|
PriorDevice = null;
|
||
|
NextKeyDevice = null;
|
||
|
CurDevice = null;
|
||
|
NextKeyDevice = null;
|
||
|
}
|
||
|
//20120820
|
||
|
dbo.ExecuteSql(string.Format("update T_Monitor_Task set F_SplitTime= '{0}' where F_ManageTASKKINDINDEX={1} and F_ManageTASKINDEX={2}",DateTime.Now.ToString("u"),Mankind,ManFID));//20120616
|
||
|
dbo.TransCommit();
|
||
|
//20091107
|
||
|
PriorDevice0 = null;
|
||
|
PriorKeyDevice0 = null;
|
||
|
|
||
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange("CreateMonitor",cea);
|
||
|
return 1;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.CreateMonitorʱ��������:" + ex.StackTrace+ex.Message ;
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", DisassembleTaskError);
|
||
|
OnRefreshMonitor(rme);
|
||
|
dbo.TransRollback();
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
//dvRoute.Dispose();
|
||
|
//dvs.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 20190723
|
||
|
/// ˫���Ѷ��������������Ʋ���������������������λͬʱ���ڳ�������ʱ��Ҫ�Ȳ���2��3�ţ�������1��4
|
||
|
/// </summary>
|
||
|
/// <param name="drv">����������</param>
|
||
|
/// <returns></returns>
|
||
|
public static bool Stack2ReachCannotOut(DataRowView drv)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
string FSTARTDEVICE = Convert.ToString(drv["FSTARTDEVICE"]);
|
||
|
string FSTARTCELL = Convert.ToString(drv["FSTARTCELL"]);
|
||
|
int freach = 1;
|
||
|
string sqlstr = string.Empty;
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_ForkAmount,F_Reach from T_Base_StackInfo where F_LaneNo like '%{0}%'", FSTARTDEVICE)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
freach = Convert.ToInt32(dv[0]["F_Reach"]);
|
||
|
}
|
||
|
|
||
|
if (freach == 2)
|
||
|
{
|
||
|
string[] zxy = FSTARTCELL.Split('-');//������������
|
||
|
if (zxy.Length > 2)
|
||
|
{
|
||
|
int getZ = Convert.ToInt32(zxy[0]);//ȡ����������
|
||
|
int newZ;
|
||
|
int tempZ = getZ;
|
||
|
if (tempZ > 4)
|
||
|
{
|
||
|
tempZ = getZ % 4;
|
||
|
}
|
||
|
if (tempZ == 1 || tempZ == 0)//��λȡ��ʱ��Ҫ�ж��Ƿ�����λ��ȡ������
|
||
|
{//��ȡ��λ����
|
||
|
if (tempZ == 1)
|
||
|
{
|
||
|
newZ = getZ + 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
newZ = getZ - 1;
|
||
|
}
|
||
|
string neighborzxy = string.Format("{0:D2}-{1:D2}-{2:D2}", newZ, zxy[1], zxy[2]);//���������
|
||
|
|
||
|
|
||
|
sqlstr = string.Format("SELECT FID FROM T_Manage_Task WHERE (FSTATUS = 0) AND(FSTARTDEVICE = {0}) AND (FSTARTCELL = '{1}') ", FSTARTDEVICE, neighborzxy);
|
||
|
|
||
|
dv = dbo.ExceSQL(sqlstr).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)//
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
return false;
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "��������ʱ,ControlTaskAmountUnDisassemble��" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����������Ҫ�������������������в��֣�����ֵtrue�Ͳ�����
|
||
|
/// </summary>
|
||
|
/// <param name="drv"></param>
|
||
|
/// <returns></returns>
|
||
|
public static bool ControlTaskAmountUnDisassemble(DataRowView drv)
|
||
|
{//20121203
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
#region ����
|
||
|
//if (Convert.ToInt32(drv["FSTARTDEVICE"]) == 19001 && Convert.ToInt32(drv["FENDDEVICE"]) != 19001)
|
||
|
//{//����A�ؿ���ȥ�������İ���12068�������ֱ����ܳ�������(12076,12083,18001,18002...18005)
|
||
|
// sql.Clear();
|
||
|
// sql.Append("SELECT count(distinct FID) as taskamount FROM T_Monitor_Task,T_Manage_Task WHERE T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex")
|
||
|
// .Append(" AND T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID and T_Monitor_Task.F_DeviceIndex = 12068 and FSTARTDEVICE=19001 ");
|
||
|
// if (Convert.ToInt32(drv["FENDDEVICE"]) == 12076 || Convert.ToInt32(drv["FENDDEVICE"]) == 12083)
|
||
|
// {
|
||
|
// sql.Append(" and (FENDDEVICE=12076 or FENDDEVICE=12083) ");
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// sql.Append(" and (FENDDEVICE<>12076 and FENDDEVICE<>12083 and FENDDEVICE<>19001) ");
|
||
|
// }
|
||
|
// object ob = dbo.GetSingle(sql.ToString());
|
||
|
// if (ob != null)
|
||
|
// {
|
||
|
// if (Convert.ToInt32(ob) > 6)
|
||
|
// {
|
||
|
// return true;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
//else if (Convert.ToInt32(drv["FSTARTDEVICE"]) != 19002 && Convert.ToInt32(drv["FENDDEVICE"]) == 19002 )
|
||
|
//{//����B��������12019�IJ��ܳ���4����
|
||
|
// sql.Clear();
|
||
|
// sql.Append("SELECT count(distinct FID) as taskamount FROM T_Monitor_Task,T_Manage_Task WHERE T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex")
|
||
|
// .Append(" AND T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID and T_Monitor_Task.F_DeviceIndex = 12019 ");
|
||
|
// sql.Append(" and (FENDDEVICE=19002 and FSTARTDEVICE<>19002) ");
|
||
|
// object ob = dbo.GetSingle(sql.ToString());
|
||
|
// if (ob != null)
|
||
|
// {
|
||
|
// if (Convert.ToInt32(ob) > 4)
|
||
|
// {
|
||
|
// return true;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
//else if (Convert.ToInt32(drv["FSTARTDEVICE"]) == 19002 && Convert.ToInt32(drv["FENDDEVICE"]) != 19002 )
|
||
|
//{//����Bȥ�������ͻؿ�����������12034�ȴ�ִ�еIJ��ܳ���3��
|
||
|
// sql.Clear();
|
||
|
// sql.Append("SELECT count(distinct FID) as taskamount FROM T_Monitor_Task,T_Manage_Task WHERE T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex")
|
||
|
// .Append(" AND T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID and T_Monitor_Task.F_DeviceIndex = 12034 and f_status=0 and FSTARTDEVICE=19002 ");
|
||
|
// if (Convert.ToInt32(drv["FENDDEVICE"]) == 12042 || Convert.ToInt32(drv["FENDDEVICE"]) == 12051)
|
||
|
// {
|
||
|
// sql.Append(" and (FENDDEVICE=12042 or FENDDEVICE=12051) ");
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// sql.Append(" and (FENDDEVICE<>12042 and FENDDEVICE<>12051 and FENDDEVICE<>19002) ");
|
||
|
// }
|
||
|
// object ob = dbo.GetSingle(sql.ToString());
|
||
|
// if (ob != null)
|
||
|
// {
|
||
|
// if (Convert.ToInt32(ob) > 3)
|
||
|
// {
|
||
|
// return true;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
//else if (Convert.ToInt32(drv["FSTARTDEVICE"]) >= 18001 && Convert.ToInt32(drv["FSTARTDEVICE"]) <= 18005 && (Convert.ToInt32(drv["FENDDEVICE"]) == 12042 || Convert.ToInt32(drv["FENDDEVICE"]) == 12051))
|
||
|
//{//�������B����������ÿ��������������
|
||
|
// sql.Clear();
|
||
|
// sql.Append("SELECT count(distinct FID) as taskamount FROM T_Monitor_Task,T_Manage_Task WHERE T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex")
|
||
|
// .Append(" AND T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID and (FENDDEVICE=12042 or FENDDEVICE=12051) and FSTARTDEVICE=").Append(Convert.ToInt32(drv["FSTARTDEVICE"]));
|
||
|
|
||
|
// object ob = dbo.GetSingle(sql.ToString());
|
||
|
// if (ob != null)
|
||
|
// {
|
||
|
// if (Convert.ToInt32(ob) >=2)
|
||
|
// {
|
||
|
// return true;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
// ����T_Base_OutCount���������趨�ij���վ̨������������
|
||
|
if (drv["FCONTROLTASKTYPE"].ToString() == "2")
|
||
|
{
|
||
|
int OutStation = Convert.ToInt32(drv["FENDDEVICE"]);
|
||
|
dv = dbo.ExceSQL(" select * from T_Base_OutCount where F_OutStationID = " + OutStation).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
int MaxCount = Convert.ToInt32(dv[0]["F_MaxTaskCount"]);
|
||
|
dv = dbo.ExceSQL("select * from T_Manage_Task where FIntoStepOK = 1 and FENDDEVICE = " + OutStation).Tables[0].DefaultView;
|
||
|
if (dv.Count >= MaxCount)
|
||
|
{
|
||
|
return true;// ����������������
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "��������ʱ���ж��Ƿ���¥�춨�����Ƿ�����8�⣺" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ����·�����з����ķ��������������豸������ֵ������0���豸����������1���豸����;2:·�����ţ�3���豸����
|
||
|
/// </summary>
|
||
|
/// <param name="CurRouteID">·��ID</param>
|
||
|
/// <param name="CurSerialNumber">·���ϵ�����</param>
|
||
|
/// <returns></returns>
|
||
|
public static List<int> GetPriorDevice(int CurRouteIDSub, int CurSerialNumber)
|
||
|
{
|
||
|
|
||
|
List<int> keyDevice = new List<int>();
|
||
|
DataView dvRoute = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//�����豸�������豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append( "SELECT T_Base_Route_Device.F_DeviceIndex,F_DeviceOrder, T_Base_Route_Device.F_SerialNumber, " ).Append(
|
||
|
"T_Base_Device_Command.F_DeviceCommandIndex,T_Base_Device.F_DeviceKindIndex FROM T_Base_Device_Command " ).Append(
|
||
|
",T_Base_Device,T_Base_Route_Device where T_Base_Device_Command.F_DeviceKindIndex = T_Base_Device.F_DeviceKindIndex" ).Append(
|
||
|
" and T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_RouteIDSub=" ).Append(
|
||
|
CurRouteIDSub ).Append( " and F_SerialNumber < " ).Append( CurSerialNumber ).Append( " order by F_SerialNumber desc ");
|
||
|
dvRoute = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvRoute.Count > 0)
|
||
|
{
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceKindIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_SerialNumber"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceOrder"]));
|
||
|
}
|
||
|
return keyDevice;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format("ControlSystem.CDisassembleTask.GetPriorDevice:{0}" , ex.StackTrace+ex.Message );
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
keyDevice=null;
|
||
|
dvRoute.Dispose() ;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ڳ������ͻ��飬��Ҫ�жϵ�ǰ�豸����һ���豸�Ƿ��߱�����״̬
|
||
|
/// </summary>
|
||
|
/// <param name="CurRouteIDSub">��ǰ���ȵ���·��</param>
|
||
|
/// <param name="CurSerialNumber">���ͻ����ĵ�ǰ���ͻ���Ӧ��·������</param>
|
||
|
/// <returns></returns>
|
||
|
static List<int> GetCurConveyorNextDevice(int CurRouteIDSub, int CurSerialNumber)
|
||
|
{
|
||
|
List<int> CurDeviceNextDev = new List<int>();//20130510 return CurDeviceNextDev;//20120906��������
|
||
|
DataView dvRoute = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//�ҵ�ǰһ���豸CurDevice����һ���豸
|
||
|
sql.Remove(0, sql.Length );
|
||
|
sql.Append("SELECT T_Base_Route_Device.F_DeviceIndex,F_DeviceOrder, T_Base_Route_Device.F_SerialNumber, " ).Append(
|
||
|
"T_Base_Device_Command.F_DeviceCommandIndex,T_Base_Device.F_DeviceKindIndex FROM T_Base_Device_Command " ).Append(
|
||
|
",T_Base_Device,T_Base_Route_Device where T_Base_Device_Command.F_DeviceKindIndex = T_Base_Device.F_DeviceKindIndex" ).Append(
|
||
|
" and T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_RouteIDSub=" ).Append(
|
||
|
CurRouteIDSub ).Append( " and F_SerialNumber > " ).Append( CurSerialNumber ).Append( " and T_Base_Device.F_DeviceKindIndex=2 order by F_SerialNumber asc ");
|
||
|
dvRoute = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvRoute.Count > 0)
|
||
|
{
|
||
|
CurDeviceNextDev.Add(Convert.ToInt32(dvRoute[0]["F_DeviceIndex"]));
|
||
|
CurDeviceNextDev.Add(Convert.ToInt32(dvRoute[0]["F_DeviceKindIndex"]));
|
||
|
CurDeviceNextDev.Add(Convert.ToInt32(dvRoute[0]["F_SerialNumber"]));
|
||
|
CurDeviceNextDev.Add(Convert.ToInt32(dvRoute[0]["F_DeviceOrder"]));
|
||
|
}
|
||
|
return CurDeviceNextDev;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format("ControlSystem.CDisassembleTask.GetCurConveyorNextDevice:{0}" ,ex.StackTrace+ex.Message );
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
CurDeviceNextDev=null;
|
||
|
dvRoute.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ����·�������������Ĺؼ��豸������ֵ������0���豸����������1���豸���ͣ�2:·�����ţ�3���豸����
|
||
|
/// </summary>
|
||
|
/// <param name="CurRouteID">·��ID</param>
|
||
|
/// <param name="CurSerialNumber">·���ϵ�����</param>
|
||
|
/// <returns></returns>
|
||
|
static List<int> GetNextKeyDevice(int CurRouteIDSub, int CurSerialNumber)
|
||
|
{
|
||
|
List<int> keyDevice = new List<int>(); DataView dvRoute = new DataView(); DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//�����жϱ��豸�Ƿ�Ϊ�ؼ��豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_SerialNumber, T_Base_Device.F_DeviceIndex,F_DeviceOrder,F_DeviceKindIndex FROM T_Base_Device," ).Append(
|
||
|
"T_Base_Route_Device where T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex " ).Append(
|
||
|
" and F_RouteIDSub=" ).Append( CurRouteIDSub ).Append( " and F_SerialNumber=" ).Append( CurSerialNumber
|
||
|
).Append( " and F_KeyDevice = '1'");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
keyDevice.Add(Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dv[0]["F_DeviceKindIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dv[0]["F_SerialNumber"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dv[0]["F_DeviceOrder"]));
|
||
|
return keyDevice;
|
||
|
}
|
||
|
//Ȼ�������жϺ����豸�����Ĺؼ��豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT T_Base_Route_Device.F_DeviceIndex,F_DeviceOrder, T_Base_Route_Device.F_SerialNumber, " ).Append(
|
||
|
"T_Base_Device_Command.F_DeviceCommandIndex,T_Base_Device.F_DeviceKindIndex FROM T_Base_Device_Command " ).Append(
|
||
|
",T_Base_Device,T_Base_Route_Device where T_Base_Device_Command.F_DeviceKindIndex = T_Base_Device.F_DeviceKindIndex" ).Append(
|
||
|
" and T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_RouteIDSub=" ).Append(
|
||
|
CurRouteIDSub ).Append( " and F_SerialNumber > " ).Append( CurSerialNumber ).Append( " and T_Base_Device.F_KeyDevice = '1' order by F_SerialNumber asc ");
|
||
|
dvRoute = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvRoute.Count > 0)
|
||
|
{
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceKindIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_SerialNumber"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceOrder"]));
|
||
|
|
||
|
}
|
||
|
return keyDevice;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format("ControlSystem.CDisassembleTask.GetNextKeyDevice:{0}" ,ex.StackTrace+ex.Message );
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
keyDevice=null;
|
||
|
dvRoute.Dispose();
|
||
|
dv.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ����·����������һ���豸������ֵ������0���豸����������1���豸���ͣ�2:·�����ţ�3���豸����
|
||
|
/// </summary>
|
||
|
/// <param name="CurRouteID">·��ID</param>
|
||
|
/// <param name="CurSerialNumber">·���ϵ�����</param>
|
||
|
/// <returns></returns>
|
||
|
public static List<int> GetNextDevice(int CurRouteIDSub, int CurSerialNumber)
|
||
|
{
|
||
|
List<int> keyDevice = new List<int>(); DataView dvRoute = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//Ȼ�������жϺ����豸�������豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT T_Base_Route_Device.F_DeviceIndex,F_DeviceOrder, T_Base_Route_Device.F_SerialNumber, " ).Append(
|
||
|
"T_Base_Device_Command.F_DeviceCommandIndex,T_Base_Device.F_DeviceKindIndex FROM T_Base_Device_Command " ).Append(
|
||
|
",T_Base_Device,T_Base_Route_Device where T_Base_Device_Command.F_DeviceKindIndex = T_Base_Device.F_DeviceKindIndex" ).Append(
|
||
|
" and T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_RouteIDSub=" ).Append(
|
||
|
CurRouteIDSub ).Append( " and F_SerialNumber > " ).Append( CurSerialNumber ).Append( " order by F_SerialNumber asc ");
|
||
|
dvRoute = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvRoute.Count > 0)
|
||
|
{
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceKindIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_SerialNumber"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceOrder"]));
|
||
|
|
||
|
}
|
||
|
return keyDevice;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format( "ControlSystem.CDisassembleTask.GetNextDevice:{0}" ,ex.StackTrace+ex.Message );
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
keyDevice=null;
|
||
|
dvRoute.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ����AGV����
|
||
|
/// </summary>
|
||
|
/// <param name="Mankind">������������</param>
|
||
|
/// <param name="ManFID">������������</param>
|
||
|
/// <param name="IOType">�����������ͣ�1�����⣨�����꣩��2�����⣨ȡ���꣩��3���ƿ⣨ȡ�������꣩</param>
|
||
|
/// <returns></returns>
|
||
|
static int[] GetAGVAddressFromManage(int Mankind, int ManFID, DataRowView drv)
|
||
|
{
|
||
|
int[] stackCoo = new int[6] { 0, 0, 0, 0, 0, 0 };//ȡ��-��-�㣨Z-X-Y��������-��-�㣨Z-X-Y��
|
||
|
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] split = new string[3];
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
switch (Convert.ToInt32(drv["FCONTROLTASKTYPE"]))
|
||
|
{
|
||
|
case 1://���⣬ȡ���꣺��̨վ̨�������꣺·����һ���豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT FSTARTCELL,FSTARTDEVICE,FENDDEVICE FROM T_Manage_Task WHERE (FID = " ).Append( ManFID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( Mankind ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
stackCoo[0] = 0;
|
||
|
stackCoo[1] =Convert.ToInt32(dv[0]["FSTARTCELL"]);
|
||
|
stackCoo[2] = 0;
|
||
|
|
||
|
stackCoo[3] = 0;
|
||
|
stackCoo[4] = 0;
|
||
|
stackCoo[5] = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ�����������AGV���꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 2://���⣺ȡ������·����һ���豸ȡ�������꣺��̨վ̨
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT FENDCELL,FENDDEVICE FROM T_Manage_Task WHERE (FID = " ).Append( ManFID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( Mankind ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
stackCoo[0] = 0;
|
||
|
stackCoo[1] = 0;
|
||
|
stackCoo[2] = 0;
|
||
|
|
||
|
stackCoo[3] = 0;
|
||
|
stackCoo[4] = Convert.ToInt32(dv[0]["FENDCELL"]);
|
||
|
stackCoo[5] = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ�����������AGV���꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
case 3://�ƿ⣬ȡ���꣺��̨վ̨�������꣺·����һ���豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT FSTARTCELL,FSTARTDEVICE,FENDCELL,FENDDEVICE FROM T_Manage_Task WHERE (FID = " ).Append( ManFID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( Mankind ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
stackCoo[0] = 0; int a = 0;
|
||
|
if (int.TryParse(dv[0]["FSTARTCELL"].ToString(),out a)==true)
|
||
|
{
|
||
|
stackCoo[1] = Convert.ToInt32(dv[0]["FSTARTCELL"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackCoo[1] = 0;
|
||
|
}
|
||
|
stackCoo[2] = 0;
|
||
|
|
||
|
stackCoo[3] = 0;
|
||
|
if(int.TryParse (dv[0]["FENDCELL"].ToString(),out a)==true)
|
||
|
{
|
||
|
stackCoo[4] = Convert.ToInt32(dv[0]["FENDCELL"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackCoo[4] = 0;
|
||
|
}
|
||
|
stackCoo[5] = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ�����������AGV���꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
|
||
|
return stackCoo;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format( "ControlSystem.CDisassembleTask.GetAGVAddressFromManage:{0}" , ex.StackTrace+ex.Message );
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
stackCoo = null;
|
||
|
|
||
|
cc = null ;
|
||
|
split =null ;
|
||
|
dv.Dispose() ;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 20101219�����Ƿ�����AGVͨ��ȡ�����ж�����
|
||
|
/// </summary>
|
||
|
/// <param name="Mankind"></param>
|
||
|
/// <param name="ManFID"></param>
|
||
|
/// <param name="IfGetGoods"></param>
|
||
|
/// <returns></returns>
|
||
|
static int[] GetAGVAddressFromManage(int Mankind, int ManFID,bool IfGetGoods)
|
||
|
{
|
||
|
int[] stackCoo = new int[6] { 0, 0, 0, 0, 0, 0 };//ȡ��-��-�㣨Z-X-Y��������-��-�㣨Z-X-Y��
|
||
|
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] split = new string[3];
|
||
|
int a = 0;
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
switch (IfGetGoods)
|
||
|
{
|
||
|
case true://��AGVͨ��ȡ����ȡ���꣺��̨վ̨�������꣺·����һ���豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT FSTARTCELL,FSTARTDEVICE,FENDDEVICE FROM T_Manage_Task WHERE (FID = " ).Append( ManFID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( Mankind ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
stackCoo[0] = 0;
|
||
|
|
||
|
if (int.TryParse(dv[0]["FSTARTCELL"].ToString(), out a)) // �ж��Ƿ�����
|
||
|
{
|
||
|
stackCoo[1] = Convert.ToInt32(dv[0]["FSTARTCELL"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackCoo[1] = Convert.ToInt32(dv[0]["FSTARTDEVICE"]);
|
||
|
}
|
||
|
stackCoo[2] = 0;
|
||
|
|
||
|
stackCoo[3] = 0;
|
||
|
stackCoo[4] = 0;
|
||
|
stackCoo[5] = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ�����������AGV���꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case false://��AGVͨ���ͻ���ȡ������·����һ���豸ȡ�������꣺��̨վ̨
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT FENDCELL,FENDDEVICE FROM T_Manage_Task WHERE (FID = " ).Append( ManFID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( Mankind ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
|
||
|
stackCoo[0] = 0;
|
||
|
stackCoo[1] = 0;
|
||
|
stackCoo[2] = 0;
|
||
|
|
||
|
stackCoo[3] = 0;
|
||
|
if (int.TryParse(dv[0]["FENDCELL"].ToString(), out a)) // �ж��Ƿ�����
|
||
|
{
|
||
|
stackCoo[4] = Convert.ToInt32(dv[0]["FENDCELL"]);
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackCoo[4] = Convert.ToInt32(dv[0]["FENDDEVICE"]);
|
||
|
|
||
|
}
|
||
|
stackCoo[5] = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ�����������AGV���꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
return stackCoo;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format( "ControlSystem.CDisassembleTask.GetAGVAddressFromManage:{0}" ,ex.StackTrace+ex.Message );
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
stackCoo = null;
|
||
|
|
||
|
cc = null ;
|
||
|
split =null ;
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �ڱ�T_Base_AGV_Gate����AGV��ַ
|
||
|
/// </summary>
|
||
|
/// <param name="devindex">AGV��ַ��Ӧ���豸����</param>
|
||
|
/// <returns></returns>
|
||
|
static int GetAGVAddressFromAgvGate(int devindex)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_Address from T_Base_AGV_Gate where F_AGVGateDeviceIndex=" ).Append( devindex);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_Address"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format( "ControlSystem.CDisassembleTask.GetAGVAddressFromAgvGate:{0}" ,ex.StackTrace+ex.Message );
|
||
|
return -1;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���öѶ�������ȡ��-��-�㣨Z-X-Y��������-��-�㣨Z-X-Y��
|
||
|
/// </summary>
|
||
|
/// <param name="Mankind">������������</param>
|
||
|
/// <param name="ManFID">������������</param>
|
||
|
/// <param name="IOType">�����������ͣ�1�����⣨�����꣩��2�����⣨ȡ���꣩��3���ƿ⣨ȡ�������꣩</param>
|
||
|
/// <returns></returns>
|
||
|
static int[] GetStackCoordinateFromManage(int Mankind, int ManFID,DataRowView drv)
|
||
|
{
|
||
|
int[] stackCoo = new int[6] { 0, 0, 0, 0, 0, 0 };//ȡ��-��-�㣨Z-X-Y��������-��-�㣨Z-X-Y��
|
||
|
char[] cc = new char[1] {'-' };
|
||
|
string[] split = new string[3];
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
switch (Convert.ToInt32(drv["FCONTROLTASKTYPE"]))
|
||
|
{
|
||
|
case 1://���⣬������
|
||
|
sql .Append( "SELECT FENDCELL FROM T_Manage_Task WHERE (FID = " ).Append( ManFID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( Mankind ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
split = dv[0]["FENDCELL"].ToString().Split(cc);
|
||
|
stackCoo[3] = Convert.ToInt32(split[0]);
|
||
|
stackCoo[4] = Convert.ToInt32(split[1]);
|
||
|
stackCoo[5] = Convert.ToInt32(split[2]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ����������öѶ������꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 2://���⣬ȡ����
|
||
|
sql.Append( "SELECT FSTARTCELL FROM T_Manage_Task WHERE (FID = " ).Append( ManFID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( Mankind ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
split = dv[0]["FSTARTCELL"].ToString().Split(cc);
|
||
|
stackCoo[0] = Convert.ToInt32(split[0]);
|
||
|
stackCoo[1] = Convert.ToInt32(split[1]);
|
||
|
stackCoo[2] = Convert.ToInt32(split[2]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ����������öѶ������꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
case 3:
|
||
|
sql .Append( "SELECT FSTARTCELL,FENDCELL FROM T_Manage_Task WHERE (FID = " ).Append( ManFID ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( Mankind ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (dv[0]["FSTARTCELL"].ToString() != "-")
|
||
|
{
|
||
|
split = dv[0]["FSTARTCELL"].ToString().Split(cc);
|
||
|
stackCoo[0] = Convert.ToInt32(split[0]);
|
||
|
stackCoo[1] = Convert.ToInt32(split[1]);
|
||
|
stackCoo[2] = Convert.ToInt32(split[2]);
|
||
|
}
|
||
|
if (dv[0]["FENDCELL"].ToString() != "-")
|
||
|
{
|
||
|
split = dv[0]["FENDCELL"].ToString().Split(cc);
|
||
|
stackCoo[3] = Convert.ToInt32(split[0]);
|
||
|
stackCoo[4] = Convert.ToInt32(split[1]);
|
||
|
stackCoo[5] = Convert.ToInt32(split[2]);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ����������öѶ������꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return stackCoo;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManage��������������������"+ex.StackTrace+ex.Message ;
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
finally{
|
||
|
stackCoo = null;
|
||
|
|
||
|
cc = null ;
|
||
|
split=null ;
|
||
|
dv.Dispose() ;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 20101219�����Ƿ�������ȡ�����ж�����
|
||
|
/// </summary>
|
||
|
/// <param name="Mankind"></param>
|
||
|
/// <param name="ManFID"></param>
|
||
|
/// <param name="IfGetGoods"></param>
|
||
|
/// <returns></returns>
|
||
|
static int[] GetStackCoordinateFromManage(int Mankind, int ManFID,bool IfGetGoods)
|
||
|
{
|
||
|
int[] stackCoo = new int[6] { 0, 0, 0, 0, 0, 0 };//ȡ��-��-�㣨Z-X-Y��������-��-�㣨Z-X-Y��
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] split = new string[3];
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
switch (IfGetGoods)
|
||
|
{
|
||
|
case false://�������ͻ���������
|
||
|
sql.Append("SELECT FENDCELL FROM T_Manage_Task WHERE (FID = ").Append(ManFID).Append(") AND (F_ManageTaskKindIndex = ").Append(Mankind).Append(")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
split = dv[0]["FENDCELL"].ToString().Split(cc);
|
||
|
stackCoo[3] = Convert.ToInt32(split[0]);
|
||
|
stackCoo[4] = Convert.ToInt32(split[1]);
|
||
|
stackCoo[5] = Convert.ToInt32(split[2]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ����������öѶ������꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case true://������ȡ����ȡ����
|
||
|
sql.Append("SELECT FSTARTCELL FROM T_Manage_Task WHERE (FID = ").Append(ManFID).Append(") AND (F_ManageTaskKindIndex = ").Append(Mankind).Append(")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
split = dv[0]["FSTARTCELL"].ToString().Split(cc);
|
||
|
stackCoo[0] = Convert.ToInt32(split[0]);
|
||
|
stackCoo[1] = Convert.ToInt32(split[1]);
|
||
|
stackCoo[2] = Convert.ToInt32(split[2]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManageʱû�ܴӵ����������öѶ������꣡";
|
||
|
return null;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return stackCoo;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromManage��������������������" +ex.StackTrace+ ex.Message;
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
finally
|
||
|
{
|
||
|
stackCoo = null;
|
||
|
|
||
|
cc = null;
|
||
|
split = null;
|
||
|
dv.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���������ij����ڴ��豸��Ӧ�ĶѶ�������ȡ��-��-�㣨Z-X-Y��������-��-�㣨Z-X-Y��
|
||
|
/// </summary>
|
||
|
/// <param name="devIndex">�豸����</param>
|
||
|
/// <param name="ifGet">�Ƿ�ȡ��</param>
|
||
|
/// <returns></returns>
|
||
|
static int[] GetStackCoordinateFromLaneGate(int stackIndex,int devIndex,bool ifGet)
|
||
|
{
|
||
|
char[] cc = new char[1] { '-' };//20100305
|
||
|
string[] split;
|
||
|
int[] rt = new int[6] { 0,0,0,0,0,0};
|
||
|
DataView dv = new DataView();
|
||
|
int LaneWay = ccf.GetLaneWayFromLaneInfo(stackIndex);
|
||
|
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Base_Lane_Gate where F_LaneGateDeviceIndex=" ).Append( devIndex ).Append( " and F_LaneIndex=").Append(LaneWay);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (ifGet == true)//ȡ����
|
||
|
{
|
||
|
//20100305
|
||
|
split = dv[0]["F_ZXY"].ToString().Split(cc);
|
||
|
|
||
|
rt[0] = Convert.ToInt32(split[0]);//��Z
|
||
|
rt[1] = Convert.ToInt32(split[1]);//��X
|
||
|
rt[2] = Convert.ToInt32(split[2]);//��Y
|
||
|
//20100305
|
||
|
}
|
||
|
else//������
|
||
|
{
|
||
|
//20100305
|
||
|
split = dv[0]["F_ZXY"].ToString().Split(cc);
|
||
|
|
||
|
rt[3] = Convert.ToInt32(split[0]);//��Z
|
||
|
rt[4] = Convert.ToInt32(split[1]);//��X
|
||
|
rt[5] = Convert.ToInt32(split[2]);//��Y
|
||
|
//20100305
|
||
|
}
|
||
|
|
||
|
}
|
||
|
return rt;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetStackCoordinateFromLaneGate:" +ex.StackTrace+ ex.Message;
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
cc =null ;
|
||
|
split=null ;
|
||
|
rt =null ;
|
||
|
dv.Dispose() ;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �����豸��������̽���������豸����ֵ
|
||
|
/// </summary>
|
||
|
/// <param name="devinx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
/// 20101118
|
||
|
static string GetBindingDeviceIndex(int devinx)
|
||
|
{
|
||
|
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(devinx);
|
||
|
|
||
|
if (devinfo.BindingDevice == null) return "";
|
||
|
return devinfo.BindingDevice;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetBindingDeviceIndex:" +ex.StackTrace+ ex.Message;
|
||
|
return "";
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �������ͻ��豸�ij�����̽���������豸����ֵ
|
||
|
/// </summary>
|
||
|
/// <param name="devinx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
/// 20101118
|
||
|
static string GetBindingDeviceIndexOut(int devinx)
|
||
|
{
|
||
|
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(devinx);
|
||
|
if (devinfo.BindingDeviceOut == null)return "";
|
||
|
return devinfo.BindingDeviceOut;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetBindingDeviceIndexOut:" +ex.StackTrace+ ex.Message;
|
||
|
return "";
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
///���ٽ��豸����ǰ�����Ĺ����źŶ�Ӧ���豸�����飨���ϣ���ת����ת���������½��ȣ���
|
||
|
/// ����֮��ʹ�÷ֺš�;������������ǰ���Ӹ��š�-����ʾ��Ҫ����ֵΪ��1�����ź�
|
||
|
/// </summary>
|
||
|
/// <param name="devinx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
static string GetBeDetectedDevices(int devinx)
|
||
|
{
|
||
|
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(devinx);
|
||
|
return devinfo.BeDetected;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetBeDetectedDevices:" +ex.StackTrace+ ex.Message;
|
||
|
return null ;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ��ȡ���ͻ�ִ���ͳ�����ʱ����Ҫ��ǰ�����Ĺ��翪���豸����
|
||
|
/// </summary>
|
||
|
/// <param name="devinx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
/// 20101118
|
||
|
static string GetSendOutDetect(int devinx)
|
||
|
{
|
||
|
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(devinx);
|
||
|
if (devinfo.SendOutDetect == null)return "";
|
||
|
return devinfo.SendOutDetect;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetSendOutDetect:" +ex.StackTrace+ ex.Message;
|
||
|
return "";
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��ȡ���ͻ�ִ���ͳ�����ʱ����Ҫ��ǰ�����Ĺ��翪���豸����
|
||
|
/// </summary>
|
||
|
/// <param name="devinx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
/// LHDF
|
||
|
static string GetAheadDetect(int F_RouteIDSub, int F_DeviceIndex, int F_SerialNumber)
|
||
|
{
|
||
|
|
||
|
|
||
|
try
|
||
|
{
|
||
|
string strAheadDetect = "";
|
||
|
string str = string.Format("select f_aheaddetect from t_base_route_device where f_routeidsub = {0} and f_deviceindex={1} and f_serialnumber = {2}", F_RouteIDSub, F_DeviceIndex, F_SerialNumber);
|
||
|
DataView dv= dbo.ExceSQL(str).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
strAheadDetect = string.IsNullOrEmpty(dv[0]["f_aheaddetect"].ToString()) ? "" : dv[0]["f_aheaddetect"].ToString();
|
||
|
}
|
||
|
|
||
|
return strAheadDetect;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetAheadDetect:" + ex.StackTrace + ex.Message;
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��ȡ�豸�Ƿ����л�
|
||
|
/// </summary>
|
||
|
/// <param name="devinx">�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
static string GetIfHaveGoods(int devinx)
|
||
|
{
|
||
|
|
||
|
|
||
|
DataView db = new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT F_HaveGoods FROM T_Base_Device WHERE (F_DeviceIndex = " ).Append( devinx ).Append( ") and F_HaveGoods is not null");
|
||
|
db = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (db.Count > 0)
|
||
|
{
|
||
|
return db[0]["F_HaveGoods"].ToString();
|
||
|
}
|
||
|
else
|
||
|
return "";
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetIfHaveGoods:" +ex.StackTrace+ ex.Message;
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
finally
|
||
|
{
|
||
|
db.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
/// <param name="devidx">RGV��ַ���豸������</param>
|
||
|
/// <param name="IfGet">�Ƿ��ǽӻ�</param>
|
||
|
/// <returns></returns>
|
||
|
static int GetRGVOrder(int devidx,bool IfGet)
|
||
|
{//��2-���ӻ�3-���ͻ������ߣ�4-�ҽӻ�5-���ͻ���
|
||
|
int order = 0;
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_IFChannelLeft, F_RGVGateDeviceIndex" ).Append(
|
||
|
" FROM T_Base_RGV_Gate WHERE (F_RGVGateDeviceIndex = " ).Append( devidx ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (dv[0]["F_IFChannelLeft"].ToString() == "1")
|
||
|
{
|
||
|
if (IfGet == true)
|
||
|
{
|
||
|
order = 2;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
order = 3;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (IfGet == true)
|
||
|
{
|
||
|
order = 4;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
order = 5;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return order;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetRGVOrder:" +ex.StackTrace + ex.Message;
|
||
|
return 0;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ����AGV��ǰһ���豸��Ϣ
|
||
|
/// 20090625
|
||
|
/// </summary>
|
||
|
/// <param name="CurRouteIDSub">·���ӱ���</param>
|
||
|
/// <param name="CurSerialNumber">AGV�豸��·������</param>
|
||
|
/// <returns></returns>
|
||
|
static List<int> GetAGVPriorDevice(int CurRouteIDSub, int CurSerialNumber)
|
||
|
{
|
||
|
DataView dvRoute = new DataView();
|
||
|
List<int> Device = new List<int>();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "SELECT T_Base_Route_Device.F_DeviceIndex,F_DeviceOrder, T_Base_Route_Device.F_SerialNumber, " ).Append(
|
||
|
"T_Base_Device_Command.F_DeviceCommandIndex,T_Base_Device.F_DeviceKindIndex FROM T_Base_Device_Kind,T_Base_Device_Command " ).Append(
|
||
|
",T_Base_Device,T_Base_Route_Device where T_Base_Device_Command.F_DeviceKindIndex = T_Base_Device.F_DeviceKindIndex" ).Append(
|
||
|
" and T_Base_Device_Kind.F_DeviceKindIndex = T_Base_Device_Command.F_DeviceKindIndex and T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_RouteIDSub=" ).Append(
|
||
|
CurRouteIDSub ).Append( " and F_SerialNumber < " ).Append( CurSerialNumber ).Append( " and F_GoodsMoveKindIndex=1 order by F_SerialNumber desc ");
|
||
|
dvRoute = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvRoute.Count > 0)
|
||
|
{
|
||
|
Device.Add(Convert.ToInt32(dvRoute[0]["F_DeviceIndex"]));
|
||
|
Device.Add(Convert.ToInt32(dvRoute[0]["F_DeviceKindIndex"]));
|
||
|
Device.Add(Convert.ToInt32(dvRoute[0]["F_SerialNumber"]));
|
||
|
Device.Add(Convert.ToInt32(dvRoute[0]["F_DeviceOrder"]));
|
||
|
}
|
||
|
return Device;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetAGVPriorDevice:" +ex.StackTrace+ ex.Message;
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
Device=null ;
|
||
|
dvRoute.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <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 = new DataView();
|
||
|
try
|
||
|
{
|
||
|
if (Order == -1) return true;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
switch (ccf.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)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.DeviceAndOrderExitInMonitor:" +ex.StackTrace+ ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �ҵ������ƶ����̵Ĺؼ��豸��ǰһ���豸�����磬����ɨ����ǰһ��λ�ã��˶����������ͻ�
|
||
|
/// </summary>
|
||
|
/// <param name="prirorDevice">�ؼ��豸��ǰһ���豸</param>
|
||
|
/// <param name="prirorKeydevice">�ؼ��豸</param>
|
||
|
/// <returns></returns>
|
||
|
static List<int> NewCurDevice(List<int> prirorDevice, List<int> prirorKeydevice)
|
||
|
{//0�豸������1�豸����;2:·�����ţ�3���豸����
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
if ((prirorKeydevice.Count > 0) && (prirorDevice.Count > 0))
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_GoodsMoveKindIndex, F_DeviceKindIndex FROM T_Base_Device_Kind WHERE " ).Append(
|
||
|
"(F_DeviceKindIndex = " ).Append( prirorKeydevice[1] ).Append( ") and (F_GoodsMoveKindIndex=2)");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (Model.CGetInfo.GetDeviceInfo(prirorDevice[0]).UnControl != "1")
|
||
|
{
|
||
|
return prirorDevice;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.NewCurDevice:" +ex.StackTrace+ ex.Message;
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
prirorDevice=null;
|
||
|
prirorKeydevice=null;
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ��ȡ���õ�Ŀ��λ�ã��������������߳���վ̨��ͬʱ�ĵ�������Ϊ���ɲ���״̬
|
||
|
/// </summary>
|
||
|
/// <param name="dr">T_Manage_Task�����м�¼</param>
|
||
|
/// <returns></returns>
|
||
|
public static void GetUsableDestination(DataRowView dr)
|
||
|
{
|
||
|
DataView dvIO = new DataView(); DataTable dtd = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
dr = dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE (FID = {0}) AND (F_ManageTaskKindIndex = {1})", Convert.ToInt32(dr["FID"]), Convert.ToInt32(dr["F_ManageTaskKindIndex"]))).Tables[0].DefaultView[0];//20130620
|
||
|
|
||
|
//ֻ�������ĵ���������·�������ĵ����Զ�����·��
|
||
|
if (dr["F_ManageTaskKindIndex"].ToString() != "1") return;
|
||
|
|
||
|
|
||
|
string adviceDev = string.Empty;
|
||
|
//20100610����һ��·�����ã����������ٵ��յ��豸
|
||
|
Dictionary<int, int> advDev = new Dictionary<int, int>();
|
||
|
object ob;
|
||
|
|
||
|
//20091107
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select CONTROL_ID, CONTROL_STATUS from IO_Control where (CONTROL_ID = ").Append(Convert.ToInt32(dr["FID"])).Append(") AND ((CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKALTERROUTEAPPLY).Append(") or (CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKALTERROUTEREPLY).Append("))");
|
||
|
dvIO = dboM.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvIO.Count <= 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_TASKKIND, F_DESTINATION FROM T_Base_Destination WHERE (F_Warehouse='").Append(dr["FENDWAREHOUSE"]).Append("') and (F_TASKKIND = ").Append(dr["FCONTROLTASKTYPE"]).Append(") and (F_AbendStation=1) and (F_DESTINATION=").Append(dr["FENDDEVICE"]).Append(")");
|
||
|
dtd = dbo.ExceSQL(sql.ToString()).Tables[0];
|
||
|
if (dtd.Rows.Count > 0)//ԭ���յ���Ӧ��վ̨��ô����������վ̨������Ҫ�ı�
|
||
|
{
|
||
|
adviceDev = dtd.Rows[0]["F_DESTINATION"].ToString();
|
||
|
//20091005
|
||
|
return;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//���ҿ���Ŀ��λ��
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_TASKKIND, F_DESTINATION FROM T_Base_Destination WHERE (F_Warehouse='").Append(dr["FENDWAREHOUSE"]).Append("') and (F_TASKKIND = ").Append(dr["FCONTROLTASKTYPE"]).Append(") and (F_DESTINATION <>").Append(dr["FENDDEVICE"]).Append(") and (F_AbendStation=0)");
|
||
|
DataTable dt = dbo.ExceSQL(sql.ToString()).Tables[0];
|
||
|
if (dt.Rows.Count > 0)
|
||
|
{
|
||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
||
|
{
|
||
|
if (CDisassembleTask.MinRouteID(Convert.ToInt32(dr["FSTARTDEVICE"]), Convert.ToInt32(dt.Rows[i]["F_DESTINATION"]), dr["FUseAwayFork"]) != -1)
|
||
|
{
|
||
|
//20100610ͳ�Ƶ��յ��豸����ִ�е�������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT count(FENDDEVICE) as counts FROM T_Manage_Task where FENDDEVICE='").Append(dt.Rows[i]["F_DESTINATION"]).Append("' and fstatus>0");
|
||
|
ob = dbo.GetSingle(sql.ToString());
|
||
|
advDev.Add(Convert.ToInt32(dt.Rows[i]["F_DESTINATION"]), Convert.ToInt32(ob));
|
||
|
|
||
|
//20100610 adviceDev = dt.Rows[i]["F_DESTINATION"].ToString();
|
||
|
//break;
|
||
|
}
|
||
|
}
|
||
|
if (advDev.Count == 0)//20100610
|
||
|
{
|
||
|
|
||
|
return;
|
||
|
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{//20100610
|
||
|
int mincount = 9999;
|
||
|
foreach (int aaa in advDev.Keys)
|
||
|
{
|
||
|
if (advDev[aaa] < mincount)
|
||
|
{
|
||
|
mincount = advDev[aaa];
|
||
|
adviceDev = aaa.ToString();
|
||
|
}
|
||
|
}
|
||
|
if (adviceDev == "")
|
||
|
{
|
||
|
|
||
|
return;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
//DataView DV = dboM.ExceSQL("select IO_CONTROL_APPLY_SEQ.NEXTVAL FROM DUAL").Tables[0].DefaultView;
|
||
|
//20101108int fid = dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
||
|
string dtime = DateTime.Now.ToString("u");
|
||
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
||
|
//20091128
|
||
|
dboM.TransBegin();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKALTERROUTEAPPLY).Append(" where CONTROL_ID=").Append(dr["FID"]);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
//����������������//
|
||
|
int appid = dboM.GetManageTableIndex("IO_CONTROL_APPLY", true);//CONTROL_APPLY_ID
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO IO_CONTROL_APPLY (CONTROL_APPLY_ID, CONTROL_ID,CONTROL_APPLY_TYPE,WAREHOUSE_CODE, STOCK_BARCODE, DEVICE_CODE, APPLY_TASK_STATUS, CREATE_TIME, ").Append(
|
||
|
" CONTROL_APPLY_REMARK)").Append(
|
||
|
"VALUES (").Append(appid).Append(",").Append(dr["FID"] + ",2,'" + dr["FENDWAREHOUSE"]).Append("','").Append(dr["FPALLETBARCODE"]).Append("','").Append(adviceDev).Append("',0,'").Append(dtime).Append("',null)");
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
dboM.TransCommit();
|
||
|
//�ĵ�������Ϊ���ɲ���״̬
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='-' where (FID = ").Append(Convert.ToInt32(dr["FID"])).Append(") AND (F_ManageTASKKINDINDEX =1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CControl.GetUsableDestination", "���������������������ĵ�", "����������" + dr["FID"].ToString(), "���룺" + dr["FPALLETBARCODE"].ToString().ToUpper());
|
||
|
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format("���������������������ĵ�ʱ��{0}", ex.StackTrace+ex.Message );
|
||
|
dboM.TransRollback();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dvIO.Dispose();
|
||
|
dtd.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public static void CreateRelativeMonitor(int manKind, int FID)
|
||
|
{//20120906
|
||
|
|
||
|
//if (DoubleForkSingleCell(manKind, FID) == true) return;
|
||
|
int relativeFID = -1;
|
||
|
DataView dv=new DataView() ; DataView dvs=new DataView() ;
|
||
|
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<>-1)");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
relativeFID = Convert.ToInt32(dv[0]["F_RELATIVECONTORLID"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return ;
|
||
|
|
||
|
}
|
||
|
//�����������������ڴ˲���20100323
|
||
|
//��ȡ��������������·����������Ϣ���ݹ�����CreateMonitor
|
||
|
|
||
|
|
||
|
if (relativeFID != -1)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT T_Manage_Task.* FROM T_Manage_Task WHERE (F_RELATIVECONTORLID = ").Append(relativeFID).Append(") AND (F_ManageTaskKindIndex = ").Append(manKind).Append(") and (FIntoStepOK=0)");
|
||
|
dvs = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int j = 0; j < dvs.Count;j++ )
|
||
|
{
|
||
|
int minrid = MinRouteID(Convert.ToInt32(dvs[j]["FSTARTDEVICE"]), Convert.ToInt32(dvs[j]["FENDDEVICE"]), dvs[j]["FUseAwayFork"]);
|
||
|
if (minrid != -1)
|
||
|
{
|
||
|
if (CreateMonitor(manKind, Convert.ToInt32(dvs[j]["FID"]), minrid, dvs[j], 0) > 0)
|
||
|
{
|
||
|
//�ֽ����ɣ���T_Manage_Task��FIntoStepOK=1
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dvs[j]["FID"]
|
||
|
).Append(" and F_ManageTaskKindIndex=").Append(dvs[0]["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange("CreateRelativeMonitor", cea);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "CreateRelativeMonitor,"+ex.StackTrace+ex.Message ;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dvs.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �ҵ�һ��˫�������ʻ�λ���Ĺ�����ϵ
|
||
|
/// </summary>
|
||
|
/// <param name="dr"></param>
|
||
|
public static void GetOutDoubleForkTask(DataRowView dr)
|
||
|
{//sqlser�� SUBSTRING(express1,1��ʼ,2);C#��.Substring(0��ʼ, 2)
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
dr = dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE (FID = {0}) AND (F_ManageTaskKindIndex = {1})", Convert.ToInt32(dr["FID"]), Convert.ToInt32(dr["F_ManageTaskKindIndex"]))).Tables[0].DefaultView[0];//20130620
|
||
|
|
||
|
if (dr["F_RELATIVECONTORLID"].ToString() != "-1") return;
|
||
|
int forwlimitX = 0, backlimitX = 0;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ForwardLimitX, F_BackLimitX FROM T_Base_LaneInfo WHERE (F_LaneDeviceIndex = ").Append(dr["FLANEWAY"]).Append(")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
forwlimitX = Convert.ToInt32(dv[0]["F_ForwardLimitX"]);
|
||
|
backlimitX = Convert.ToInt32(dv[0]["F_BackLimitX"]);
|
||
|
}
|
||
|
else
|
||
|
return;
|
||
|
int forkamount = 1;
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT F_ForkAmount FROM T_Base_StackInfo WHERE F_StackIndex = ").Append(Convert.ToInt32(dr["FSTACK"]));
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
forkamount = Convert.ToInt32(dv[0]["F_ForkAmount"])-1;
|
||
|
}
|
||
|
else
|
||
|
return;
|
||
|
StringBuilder sqladd = new StringBuilder(" ");
|
||
|
if (forwlimitX.ToString() == dr["FStartCol"].ToString())
|
||
|
{
|
||
|
sqladd.Append(" and FStartCol <>").Append(forwlimitX).Append(" ");
|
||
|
}
|
||
|
else if (backlimitX.ToString() == dr["FStartCol"].ToString())
|
||
|
{
|
||
|
sqladd.Append(" and FStartCol <>").Append(backlimitX).Append(" ");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sqladd.Append(" ");
|
||
|
}
|
||
|
//�е��ٶ��Dz����ٶȵ�3�������Բ��IJ�ֵҪ������������һ����ʱ���൱���ƶ����е�ʱ�䣩
|
||
|
sql.Remove(0, sql.Length);
|
||
|
if (CStaticClass.DBFactory == "OracleDBFactory")
|
||
|
{//20151120����ϵͳoracle����������
|
||
|
sql.Append("SELECT ").Append(" F_ManageTaskKindIndex, FID, MIN(POWER(FStartCol - ").Append(dr["FStartCol"]).Append(", 2) + POWER((FStartLayer - ").Append(
|
||
|
dr["FStartLayer"]).Append(") * 3, 2)) AS Expr1 FROM T_Manage_Task WHERE (FIntoStepOK = '0') AND rownum<=").Append(forkamount).Append(
|
||
|
" and (FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = ").Append(dr["FCONTROLTASKTYPE"]).Append(") AND (FLOGIC_AREA = '").Append(dr["FLOGIC_AREA"]).Append(
|
||
|
"') AND (FCONTORL_BATCH = '").Append(dr["FCONTORL_BATCH"]).Append("') AND (FLANEWAY = ").Append(dr["FLANEWAY"]).Append(
|
||
|
") AND (F_RELATIVECONTORLID = - 1) and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]).Append(" and FID<>").Append(dr["fid"]).Append(
|
||
|
sqladd.ToString()).Append(" GROUP BY F_ManageTaskKindIndex, FID order by Expr1 asc");
|
||
|
}
|
||
|
else
|
||
|
{//20151120����ϵͳSQLServer����������
|
||
|
sql.Append("SELECT TOP ").Append(forkamount).Append(" F_ManageTaskKindIndex, FID, MIN(POWER(FStartCol - ").Append(dr["FStartCol"]).Append(", 2) + POWER((FStartLayer - ").Append(
|
||
|
dr["FStartLayer"]).Append(") * 3, 2)) AS Expr1 FROM T_Manage_Task WHERE (FIntoStepOK = '0') AND ").Append(
|
||
|
"(FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = ").Append(dr["FCONTROLTASKTYPE"]).Append(") AND (FLOGIC_AREA = '").Append(dr["FLOGIC_AREA"]).Append(
|
||
|
"') AND (FCONTORL_BATCH = '").Append(dr["FCONTORL_BATCH"]).Append("') AND (FLANEWAY = ").Append(dr["FLANEWAY"]).Append(
|
||
|
") AND (F_RELATIVECONTORLID = - 1) and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]).Append(" and FID<>").Append(dr["fid"]).Append(
|
||
|
sqladd.ToString()).Append(" GROUP BY F_ManageTaskKindIndex, FID order by Expr1 asc");
|
||
|
}
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(dr["fid"]).Append(" where FID=").Append(dv[i]["FID"]).Append(" and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(dr["fid"]).Append(" where FID=").Append(dr["fid"]).Append(" and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 20110412�Ƿ����ڲ�ͬ��������δͨ�������ֵ�
|
||
|
/// </summary>
|
||
|
/// <param name="Area">������</param>
|
||
|
/// <returns></returns>
|
||
|
public static bool IfExitElseAreaTask(int mankind,int FID)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
object ob = dbo.GetSingle(string.Format("select FLOGIC_AREA from T_Manage_Task where F_ManageTaskKindIndex={0} and FID={1} and FCONTROLTASKTYPE=2 and FLOGIC_AREA>'20000'", mankind, FID));
|
||
|
if (ob != null)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_NumParam4 FROM T_Manage_Task ,T_Monitor_Task where F_NumParam4=12030 and T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX AND T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex and FCONTROLTASKTYPE=2 and T_Monitor_Task.F_ManageTaskKindIndex=1 and FLOGIC_AREA>'20000' and FLOGIC_AREA <>'").Append(ob.ToString()).Append("'");//and FSTATUS>020110412
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return true;
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format("��������ʱ���ж��Ƿ�����ͬһ�������Ҳ�ͬ���ŵij���������{0}", ex.StackTrace+ex.Message );
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static bool GetUAreaOutputDevice(int StackIndex,int UCode,out int OutputUdevice,out string OutputUZxy)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
OutputUdevice = 0;
|
||
|
OutputUZxy = "-";
|
||
|
try
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT DISTINCT F_OutputUDevice, F_OutputUZxy FROM T_Base_UArea,ST_CELL where T_Base_UArea.F_UCODE = ST_CELL.FUCODE and (T_Base_UArea.F_UCODE = {0}) AND (ST_CELL.FStack = {1})", UCode, StackIndex)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
OutputUdevice = Convert.ToInt32(dv[0]["F_OutputUDevice"]);
|
||
|
OutputUZxy = dv[0]["F_OutputUZxy"].ToString();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format("CDisassembleTask.GetUAreaOutputDevice����:{0}", ex.StackTrace+ex.Message );
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
static bool GetUAreaInputDevice(int StackIndex,int UCode, out int InputUdevice, out string InputUZxy)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
InputUdevice = 0;
|
||
|
InputUZxy = "-";
|
||
|
try
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT DISTINCT F_InputUDevice, F_InputUZxy FROM T_Base_UArea,ST_CELL where T_Base_UArea.F_UCODE = ST_CELL.FUCODE and (T_Base_UArea.F_UCODE = {0}) AND (ST_CELL.FStack = {1})", UCode, StackIndex)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
InputUdevice = Convert.ToInt32(dv[0]["F_InputUDevice"]);
|
||
|
InputUZxy = dv[0]["F_InputUZxy"].ToString();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = string.Format("CDisassembleTask.GetUAreaOutputDevice����:{0}", ex.StackTrace+ex.Message );
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
static bool DoubleForkSingleCell(int manKind,int FID)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT T_Manage_Task.FID FROM T_Manage_Task ,ST_CELL WHERE T_Manage_Task.FSTARTWAREHOUSE = ST_CELL.FWAREHOUSE AND T_Manage_Task.FSTARTCELL = ST_CELL.FCELLCODE and ST_CELL.FDoubleFork = '3' AND T_Manage_Task.FID = {1} AND T_Manage_Task.F_ManageTaskKindIndex = {0}", manKind, FID)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT T_Manage_Task.FID FROM T_Manage_Task ,ST_CELL WHERE T_Manage_Task.FENDWAREHOUSE = ST_CELL.FWAREHOUSE AND T_Manage_Task.FENDCELL = ST_CELL.FCELLCODE and ST_CELL.FDoubleFork = '3' AND T_Manage_Task.FID = {1} AND T_Manage_Task.F_ManageTaskKindIndex = {0}", manKind, FID)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
static int GetBarcodeDeviceFromBindDevice(int barcodeBindDevice)
|
||
|
{
|
||
|
DataView ob = new DataView();
|
||
|
try
|
||
|
{
|
||
|
ob = dbo.ExceSQL(string.Format("SELECT F_DeviceIndex FROM T_Base_PLC_Ask WHERE (F_BindingDevice = {0})", barcodeBindDevice)).Tables[0].DefaultView;
|
||
|
if (ob.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(ob[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
ob.Dispose();
|
||
|
}
|
||
|
}
|
||
|
static int GetSameStartDeviceEnddeviceRouteID(int startdevice, int enddevice)
|
||
|
{
|
||
|
DataView dv=new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
||
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
||
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
||
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and F_StartDevice=F_EndDevice and (F_StartDevice=30100 or F_StartDevice=30200 or F_StartDevice=40100)");
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|