7260 lines
417 KiB
7260 lines
417 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;
|
||
|
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_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
|
||
|
int routeid = -1;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE ((FSTACK <= 0) or (FCONTROLTASKTYPE=3) or (FCONTROLTASKTYPE=5) OR (FCONTROLTASKTYPE=6)) 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++)//��ѡû�жѶ�������������
|
||
|
{
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
#region update by lyj20180423
|
||
|
// routeid = MinRouteID(Convert.ToInt32(dvM[i]["FSTARTDEVICE"]), Convert.ToInt32(dvM[i]["FENDDEVICE"]), dvM[i]["FUseAwayFork"]);
|
||
|
routeid = MinRouteID(Convert.ToInt32(dvM[i]["FSTARTDEVICE"]), Convert.ToInt32(dvM[i]["FENDDEVICE"]), dvM[i]["FUseAwayFork"], dvM[i]["FSTARTCELL"].ToString(), dvM[i]["FENDCELL"].ToString(), Convert.ToInt32(dvM[i]["FCONTROLTASKTYPE"]));
|
||
|
#endregion
|
||
|
|
||
|
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());
|
||
|
|
||
|
//�ɵ� �����������д��룬�ƿ����ȼ���Ϊ10�������������ΰ����ȼ�������ʱ������ִ�У�
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=10 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
||
|
dvM[i]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dvM[i]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20100323
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]));
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_StackIndex FROM T_Base_StackInfo");
|
||
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
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++)//�������Ѷ��������������ȴ�����
|
||
|
{
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
#region update by lyj20180423
|
||
|
// routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]��
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"], dv[j]["FSTARTCELL"].ToString(), dv[j]["FENDCELL"].ToString(), Convert.ToInt32(dv[j]["FCONTROLTASKTYPE"]));
|
||
|
#endregion
|
||
|
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�������
|
||
|
{
|
||
|
#region update by lyj20180423
|
||
|
// routeid = MinRouteID(Convert.ToInt32(dv[0]["FSTARTDEVICE"]), Convert.ToInt32(dv[0]["FENDDEVICE"]), dv[0]["FUseAwayFork"]);
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[0]["FSTARTDEVICE"]), Convert.ToInt32(dv[0]["FENDDEVICE"]), dv[0]["FUseAwayFork"], dv[0]["FSTARTCELL"].ToString(), dv[0]["FENDCELL"].ToString(), Convert.ToInt32(dv[0]["FCONTROLTASKTYPE"]));
|
||
|
#endregion
|
||
|
|
||
|
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,FStartLayer 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,FENDUCODEF,StartLayer 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++)
|
||
|
{
|
||
|
|
||
|
//sql.Append("SELECT F_StackIndex FROM T_Base_StackInfo");
|
||
|
//dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
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");
|
||
|
sql.Append("SELECT * 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') order by FTASKLEVEL desc");//�ɵ�ͬ����������3���Ͳ�����
|
||
|
}
|
||
|
|
||
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
//�ɵ������յ�ȡ�����Ƶ�����
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT * FROM T_Base_TaskCount2 WHERE F_DeviceIndex_End = ").Append(Convert.ToInt32(dv[j]["FENDDEVICE"])).Append(" and F_DeviceIndex_Start =").Append( Convert.ToInt32(dv[j]["FSTARTDEVICE"]));
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
if (dv1[0]["F_StackIndex"].ToString() != dvM[i]["F_StackIndex"].ToString())
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//�ɵ�
|
||
|
if (dv112.Count >= Convert.ToInt32(dv1[0]["F_MaxCount"]))
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#region update by lyj20180423
|
||
|
// routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[0]["FSTARTDEVICE"]), Convert.ToInt32(dv[0]["FENDDEVICE"]), dv[0]["FUseAwayFork"], dv[0]["FSTARTCELL"].ToString(), dv[0]["FENDCELL"].ToString(), Convert.ToInt32(dv[0]["FCONTROLTASKTYPE"]));
|
||
|
#endregion
|
||
|
|
||
|
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"]);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
|
||
|
#region ���ֳɹ�����IOControl����Ӧ������״̬ lzm20250311
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_CONTROL set CONTROL_STATUS=10 where MANAGE_ID=").Append(dv[j]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
#endregion
|
||
|
//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);
|
||
|
//20130710sql.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");
|
||
|
|
||
|
#region update by lyj20180424 �����������ͺ���ʼcell
|
||
|
//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");
|
||
|
|
||
|
sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE,FCONTROLTASKTYPE,FSTARTCELL,FENDCELL,FStartLayer 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,FCONTROLTASKTYPE,FSTARTCELL,FENDCELL,FStartLayer ORDER BY FTASKLEVEL DESC, FID asc");
|
||
|
#endregion
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int j = 0; j < dv.Count; j++)
|
||
|
//�������Ѷ����ij��������ȴ�����
|
||
|
{
|
||
|
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 * 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");
|
||
|
sql.Append("SELECT * 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') order by FTASKLEVEL desc");//�ɵ�ͬ����������3���Ͳ�����
|
||
|
|
||
|
}
|
||
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT * FROM T_Base_TaskCount2 WHERE F_DeviceIndex_End = ").Append(Convert.ToInt32(dv[j]["FENDDEVICE"])).Append(" and F_DeviceIndex_Start =").Append(Convert.ToInt32(dv[j]["FSTARTDEVICE"]));
|
||
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
|
||
|
if (dv1[0]["F_StackIndex"].ToString() != dvM[i]["F_StackIndex"].ToString()) {
|
||
|
continue;
|
||
|
}
|
||
|
//lzm
|
||
|
if (dv112.Count >= Convert.ToInt32(dv1[0]["F_MaxCount"]))
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
#region update by lyj20180423
|
||
|
// routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
||
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"], dv[j]["FSTARTCELL"].ToString(), dv[j]["FENDCELL"].ToString(), Convert.ToInt32(dv[j]["FCONTROLTASKTYPE"]));
|
||
|
#endregion
|
||
|
|
||
|
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());
|
||
|
//20161219 �����������д��룬�����������ȼ�Ĭ����9����������������ִ�е����⣨���������ΰ����ȼ�������ʱ������ִ�У�
|
||
|
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());
|
||
|
//20161219 �������������
|
||
|
//20100323
|
||
|
//20101028���ӳ�������
|
||
|
if (deviceInfo != null)
|
||
|
{
|
||
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
//20101124
|
||
|
|
||
|
|
||
|
}
|
||
|
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,string FSTARTCELL,string FENDCELL,int tasktype)
|
||
|
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
|
||
|
|
||
|
//int conveyorindex= conveyorNumFromPosition(FSTARTCELL, FENDCELL, startdevice, enddevice, tasktype);
|
||
|
|
||
|
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 ");//and T_Base_Route_Device.F_DeviceIndex=12018
|
||
|
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_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(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);//·���豸������
|
||
|
}
|
||
|
|
||
|
//������·������·������*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>
|
||
|
///
|
||
|
/// </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();
|
||
|
DataView dvahead = new DataView();//add by lyj 20171026
|
||
|
int tasktype = 0;
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
|
||
|
//if (isOrNotAllowDisaemble(drv) == false) //20171106 add by lyj ���Ƴ����� �ɵ�ע��
|
||
|
//{
|
||
|
|
||
|
// return 0;
|
||
|
//}
|
||
|
|
||
|
#region add by lyj 20171026
|
||
|
tasktype = Convert.ToInt32(drv["FCONTROLTASKTYPE"]);
|
||
|
|
||
|
#endregion
|
||
|
//20121203
|
||
|
//����A�ؿ���ȥ�������İ���12068�������ֱ����ܳ�������
|
||
|
//����B��������12019�IJ��ܳ���4����
|
||
|
//����Bȥ�������ͻؿ�����������12034�ȴ�ִ�еIJ��ܳ���3��
|
||
|
//�������B����������ÿ��������������
|
||
|
//if (ControlTaskAmountUnDisassemble(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���豸����
|
||
|
|
||
|
#region 20210326_�Ϻ��ɵ����ؼ��豸����һ���ؼ��豸
|
||
|
//List<int> SecondNextKeyDevice = new List<int>();
|
||
|
#endregion
|
||
|
|
||
|
//��ֹ���ͻ��豸���ظ����ҹؼ��豸
|
||
|
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"]));
|
||
|
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]);
|
||
|
|
||
|
#region 20210326_�Ϻ��ɵ����ؼ��豸����һ���ؼ��豸��ֵ
|
||
|
|
||
|
//for (int j = CurSerialNumber + 1; j < dvRoute.Count; j++)
|
||
|
//{
|
||
|
// SecondNextKeyDevice = GetNextKeyDevice(routeIDSub, j);
|
||
|
// if (SecondNextKeyDevice.Count > 0)
|
||
|
// break;
|
||
|
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
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);//����ID
|
||
|
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
|
||
|
//20101124
|
||
|
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]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
}
|
||
|
|
||
|
//20161221
|
||
|
//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]));
|
||
|
#region lzm20250225 ȡ���ص�������У��
|
||
|
//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());
|
||
|
//}
|
||
|
#endregion
|
||
|
////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
|
||
|
#region update by lyj20180424 ���������ⲻ�������ͻ�����
|
||
|
//if (NextKeyDevice[0]!=10000)
|
||
|
//{
|
||
|
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());
|
||
|
//}
|
||
|
//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
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#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 || (NextDevice[0] == 14005 || NextDevice[0] == 14006)) //20210201_�Ϻ��ɵ���������һ���豸Ϊ19004����������ȡ�յ���λ��������ʽ��ͬ
|
||
|
{
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
Coor[3] = Coor3_5[3];
|
||
|
Coor[4] = Coor3_5[4];
|
||
|
Coor[5] = Coor3_5[5];
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 20210125_�Ϻ��ɵ��������廻���������� ����
|
||
|
|
||
|
//������һ���豸�Ƿ�Ϊ19005���������������������ǣ��ı�������Ϊ��
|
||
|
//1.������ȡ�������������ڲ�
|
||
|
//2.�������˶���������
|
||
|
//3.�������ͻ���Ŀ����
|
||
|
//4.�������˶���Ŀ����λ
|
||
|
//��Ϊ����������������������������������ͬ���ɵģ���ǰ������Ҫ���������������������к���
|
||
|
//19004ִ����ȡ����Ҫ��������ֹ���������������˶�
|
||
|
if (NextDevice[0] == 14005 || NextDevice[0] == 14006)
|
||
|
{
|
||
|
//RunningLock.Remove(0, RunningLock.Length);
|
||
|
//RunningLock.Append("19003;19005"); //��������������
|
||
|
int x_c_p = 0;//����
|
||
|
if (NextDevice[0] == 14005)
|
||
|
{
|
||
|
|
||
|
x_c_p = 2;
|
||
|
}
|
||
|
else if (NextDevice[0] == 14006)
|
||
|
{
|
||
|
|
||
|
x_c_p = 31;
|
||
|
}
|
||
|
#region �������˶�����2�У�1��ʾ�������˶� 14006�˶����� 31��
|
||
|
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
if (tw != string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append("D").Append(tw);//19005��������
|
||
|
}
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger.Append(NextKeyDevice[0].ToString()); //�Ϻ��ɵ������浽��һ�д���������
|
||
|
|
||
|
//AheadDetect.Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//19005����������
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//����������
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 6, 0) ==
|
||
|
false)
|
||
|
{
|
||
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
TriggerTaskNo = mindex;//�Ϻ��ɵ������浽��2�д���������ȡ��
|
||
|
|
||
|
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(",1,").Append(routeIDSub).Append(",")
|
||
|
.Append(status).Append(",2").Append(",").Append(x_c_p)
|
||
|
.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 ������ȡ��
|
||
|
|
||
|
Rgvorder = 4;
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
|
||
|
#region 20210201_������ȡ����ǰ���⣬���������������Ƿ����У������Ƿ�������ִ�е�������������
|
||
|
|
||
|
//if (NextDevice[0] == 14005)
|
||
|
//{
|
||
|
// AheadDetect.Append(GetBeDetectedDevices(14003)).Append(";").Append(GetBeDetectedDevices(14004));
|
||
|
// AheadDetect.Append(";D14003.0;D14004.0;");
|
||
|
// AheadDetect.Append(";D14005.0");//14005��
|
||
|
// AheadDetect.Append(GetBeDetectedDevices(NextDevice[0]));
|
||
|
|
||
|
//}
|
||
|
//else if (NextDevice[0] == 14006)
|
||
|
//{
|
||
|
// AheadDetect.Append(GetBeDetectedDevices(14001)).Append(";").Append(GetBeDetectedDevices(14002));
|
||
|
// AheadDetect.Append(";D14001.0;D14002.0;");
|
||
|
// AheadDetect.Append(";D14006.0");//14006��
|
||
|
// AheadDetect.Append(GetBeDetectedDevices(NextDevice[0]));
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#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(NextDevice[0]).Append(",").Append(Rgvorder)
|
||
|
.Append(",").Append(routeIDSub).Append(",").Append(status).Append(",")
|
||
|
.Append(Coor[2]).Append(",0,0,0").Append(",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());
|
||
|
if (AheadTrigger != null)
|
||
|
{
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadTrigger.Append(NextKeyDevice[0]).Append("-").Append(mindex);
|
||
|
|
||
|
sql.Clear();
|
||
|
sql.Append("update T_Monitor_Task set F_AheadTrigger='").Append(AheadTrigger).Append("' where F_MonitorIndex=").Append(TriggerTaskNo);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �������˶�����������1��ʾ�������˶� ��������������
|
||
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
if (tw != string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append("D").Append(tw);//19005��������
|
||
|
}
|
||
|
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//19005����������
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//����������
|
||
|
|
||
|
int x_c = 0;//����
|
||
|
if (NextDevice[0] == 14005)
|
||
|
{
|
||
|
AheadDetect.Append(";D-14005.1"); //D-14005.1Ϊ1���������������쵽λ
|
||
|
x_c = 1;
|
||
|
}
|
||
|
else if (NextDevice[0] == 14006)
|
||
|
{
|
||
|
AheadDetect.Append(";D-14006.1");
|
||
|
x_c = 32;
|
||
|
}
|
||
|
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 6, 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_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(",1,").Append(routeIDSub).Append(",")
|
||
|
.Append(status).Append(",2").Append(",").Append(x_c)
|
||
|
.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 �������ͳ�
|
||
|
Rgvorder = 5;
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
|
||
|
#region 20210201_������ȡ����ǰ���⣬���������������Ƿ����У������Ƿ�������ִ�е�������������
|
||
|
|
||
|
AheadDetect.Append(GetBeDetectedDevices(NextDevice[0]));//����������
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
if (tw != string.Empty)
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(tw);//19005�������л�
|
||
|
}
|
||
|
|
||
|
//AheadDetect.Append(";K19005");
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#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(NextDevice[0]).Append(",").Append(Rgvorder)
|
||
|
.Append(",").Append(routeIDSub).Append(",").Append(status).Append(",")
|
||
|
.Append(Coor[5]).Append(",0,0,0,").Append("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
|
||
|
|
||
|
#region �������˶�
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
AheadDetect.Append("D-").Append(NextDevice[0]).Append(".0");
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextDevice[0]));
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//����������
|
||
|
|
||
|
int mindex1 = ccf.GetMonitorIndex(ManFID, Mankind);
|
||
|
int x_c_S = 0;//����
|
||
|
if (NextDevice[0] == 14005)
|
||
|
{
|
||
|
AheadDetect.Append(";D-14005.1"); //D-14005.1Ϊ1���������������쵽λ
|
||
|
x_c_S = 2;
|
||
|
}
|
||
|
else if (NextDevice[0] == 14006)
|
||
|
{
|
||
|
AheadDetect.Append(";D-14006.1");
|
||
|
x_c_S = 31;
|
||
|
}
|
||
|
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(mindex1).Append(",").Append(drv["FTASKLEVEL"]).Append(",")
|
||
|
.Append(NextKeyDevice[0]).Append(",1,").Append(routeIDSub).Append(",")
|
||
|
.Append(status).Append(",").Append(2).Append(",").Append(x_c_S)
|
||
|
.Append(",").Append(Coor[5]).Append(",").Append(2).Append(",")
|
||
|
.Append(2).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
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 202110330_�Ϻ��ɵ����������� ����
|
||
|
|
||
|
else if (tasktype == 6) //�����dz������� ���е�2��
|
||
|
{
|
||
|
int mindex1 = 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(mindex1).Append(",").Append(drv["FTASKLEVEL"]).Append(",")
|
||
|
.Append(NextKeyDevice[0]).Append(",1,").Append(routeIDSub).Append(",")
|
||
|
.Append(status).Append(",").Append(Coor[3]).Append(",").Append(2)
|
||
|
.Append(",").Append(Coor[5]).Append(",").Append(Coor[3]).Append(",")
|
||
|
.Append(2).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
|
||
|
|
||
|
else
|
||
|
{
|
||
|
#region ���ɶѶ���ָ��:��ȡ+ȡ��+�ͻ�
|
||
|
|
||
|
#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] == 10) //�ɵ�
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
|
||
|
|
||
|
//AheadDetect.Append("M").Append(PriorDevice[0].ToString());//���⼰�ƿ� ȡ����Ҫ���� ˫����λ
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
if (NextDevice[1] == 10)
|
||
|
{
|
||
|
//AheadDetect.Append(";").Append("J").Append(PriorDevice[0].ToString());//�ƿ����յ� �൱����Ҫ����
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
if (PriorDevice[1] == 2)
|
||
|
{//ȡ������ǰ����
|
||
|
#region ����ʱ�����豸��
|
||
|
RunningLock.Append(PriorDevice[0].ToString());
|
||
|
#endregion
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
||
|
//20101011
|
||
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], PriorDevice[0]);
|
||
|
if (cdi != null)
|
||
|
{//�����������Ѷ���ȡ��ʱ�����ڶ�����λ���л�
|
||
|
//AheadDetect.Append("D-").Append(cdi[1]).Append(";D-").Append(cdi[3]);
|
||
|
AheadDetect.Append(";D-").Append(cdi[3]);
|
||
|
}
|
||
|
//20101011
|
||
|
else
|
||
|
{
|
||
|
tw = GetBindingDeviceIndex(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
|
||
|
|
||
|
if (NextDevice.Count > 0)//�ɵ�
|
||
|
{
|
||
|
if (NextDevice[1] == 10) //վ̨���ƿⲻ��J
|
||
|
{
|
||
|
////AheadDetect.Append(";J").Append(NextKeyDevice[0].ToString());//˫��ȡ���͵ü���
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Append(GetGDDetect);
|
||
|
}
|
||
|
}
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
if (NextDevice[1] == 2)
|
||
|
{
|
||
|
|
||
|
|
||
|
//20101011
|
||
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], NextDevice[0]);
|
||
|
if (cdi != null)
|
||
|
{///20120906���ⱻ�Ѷ����ͻ��Ķ��������ڶ�����λ�����������5��Զ����6Ҳ����
|
||
|
//AheadDetect.Append(";D-").Append(cdi[1]).Append(";D").Append(cdi[3]);
|
||
|
//if (cdi[5] != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(cdi[5]);
|
||
|
//}
|
||
|
//if (cdi[6] != "")
|
||
|
//{
|
||
|
// AheadDetect.Append(";D").Append(cdi[6]);
|
||
|
//}
|
||
|
}
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
||
|
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(",2,").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 �ͻ�
|
||
|
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Ҳ����
|
||
|
//AheadDetect.Append(";D-").Append(cdi[1]).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 if (NextDevice[1] == 10)// �ɵ� �������ƿ��ͻ�����˫������
|
||
|
{
|
||
|
//AheadDetect.Append("J").Append(PriorDevice[0].ToString());// �������ƿ��ͻ�����˫������
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Append(";").Append(SendGDDetect);
|
||
|
}
|
||
|
|
||
|
AheadDetect.Append(";")
|
||
|
.Append(GetBeDetectedDevices(NextKeyDevice[0])); //20101124
|
||
|
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(",3,").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();
|
||
|
//20161221
|
||
|
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 != "")
|
||
|
{
|
||
|
// AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
||
|
AheadDetect.Append("D-").Append(tw.ToString());
|
||
|
}
|
||
|
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 = GetBindingDeviceIndex(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�Ľӻ�����������������
|
||
|
Rgvorder = 4; //GetRGVOrder(PriorDevice[0], true);
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
#region Ŀ�����ͻ�������ǰ����������
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
if (NextDevice[0] == 13003 || NextDevice[0] == 13004)//���������Խ�վ̨
|
||
|
{
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
// AheadDetect.Append(";D-").Append(tw.ToString()).Append(";");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//��������ȡʱ�������ж�Ŀ�� ������ֻ�������� Ŀ���Ų���ȥҲ��ȡ���� �ӿ�����
|
||
|
//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
|
||
|
//AheadDetect.Append(";I").Append(NextDevice[0]);//.Append(";L").Append(NextDevice[0]); //20160421
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
#region ȡ�����ͻ�������ǰ����������
|
||
|
if (PriorDevice[0] == 13001 || PriorDevice[0] == 13002)//���������Խ�վ̨
|
||
|
{
|
||
|
tw = GetBindingDeviceIndex(PriorDevice[0]);
|
||
|
// AheadDetect.Append(";D-").Append(tw.ToString()).Append(";");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
tw = GetBindingDeviceIndex(PriorDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
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 != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));
|
||
|
}
|
||
|
// AheadDetect.Append(";I").Append(NextKeyDevice[0]);
|
||
|
|
||
|
#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���ͻ�
|
||
|
|
||
|
Rgvorder =5;// GetRGVOrder(NextDevice[0], false);
|
||
|
|
||
|
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
|
||
|
|
||
|
AheadDetect .Remove(0,AheadDetect.Length);
|
||
|
if (NextDevice[0] == 13003 || NextDevice[0] == 13004)//���������Խ�վ̨
|
||
|
{
|
||
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
||
|
//AheadDetect.Append(";D-").Append(tw.ToString()).Append(";");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
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]).Append(";L").Append(NextDevice[0]); //20160421
|
||
|
}
|
||
|
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 20210201_�Ϻ��ɵ��������Ǵ�����ȡ�ͻ�������������K19004���ж��Ƿ���19004�Ļ��������������У��Ȳ�ִ��
|
||
|
|
||
|
//if (NextKeyDevice[0] == 19003 || NextKeyDevice[0] == 19004)
|
||
|
//{
|
||
|
// AheadDetect.Append(";K19005");
|
||
|
//}
|
||
|
|
||
|
#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
|
||
|
|
||
|
}
|
||
|
|
||
|
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��̽��
|
||
|
#region ���ɸ�ע��
|
||
|
//tw = GetBindingDeviceIndex(CurDevice[0]);
|
||
|
//if (tw != "")
|
||
|
//{
|
||
|
// AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
||
|
|
||
|
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
//}
|
||
|
#endregion
|
||
|
tw = GetSendOutDetect(CurDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//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 != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
|
||
|
AheadDetect.Append(";").Append("N").Append(nextConveyor[0].ToString());
|
||
|
////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;
|
||
|
int station;
|
||
|
#region AGVȡ��
|
||
|
if (PriorDevice.Count > 0)
|
||
|
{
|
||
|
agvorder = 2;//AGVȡ��
|
||
|
RunningLock.Remove(0, RunningLock.Length) ;
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
|
||
|
station = Coor[1];
|
||
|
;
|
||
|
if (CStaticClass.GetDeviceKindIdx(station) == 2)
|
||
|
{//20100714
|
||
|
#region ����ʱ�����豸��
|
||
|
RunningLock.Append(station.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
|
||
|
if (station == 12001)
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(GetBindingDeviceIndex(station).ToString()).Append(";I").Append(station.ToString());
|
||
|
}
|
||
|
else
|
||
|
if (station == 12002)
|
||
|
{
|
||
|
AheadDetect.Append("D-12002.0").Append(";I").Append(station.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Append("D-").Append(GetBindingDeviceIndexOut(station).ToString()).Append(";I").Append(station.ToString());
|
||
|
}
|
||
|
#region ���Ӽ��ⶥ���Ƿ��ڵ�λ20100710
|
||
|
//AheadDetect .Append( ";D-" ).Append( PriorDevice[0].ToString() ).Append( ".2");
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
station = Coor[4];
|
||
|
|
||
|
|
||
|
//if (CStaticClass.GetDeviceKindIdx(station) == 2)
|
||
|
// {//20100714
|
||
|
// if (station == 12002)
|
||
|
// {
|
||
|
// AheadDetect.Append(";D12002.0;D12002.1;D12002.2").Append(";I").Append(station.ToString()).Append(";N").Append(station.ToString());
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// AheadDetect.Append(";D").Append(GetBindingDeviceIndex(station).ToString()).Append(";I").Append(station.ToString()).Append(";N").Append(station.ToString());
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
}
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0) == false)
|
||
|
{//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
|
||
|
|
||
|
#region AGV�ͻ�
|
||
|
if (NextDevice.Count > 0)
|
||
|
{
|
||
|
agvorder = 3;//AGV�ͻ�
|
||
|
RunningLock.Remove(0, RunningLock.Length);
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
|
||
|
station = Coor[4];
|
||
|
|
||
|
|
||
|
if (CStaticClass.GetDeviceKindIdx(station) == 2)
|
||
|
{//20100714
|
||
|
|
||
|
agvorder = 1;//AGV�˶�
|
||
|
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0) == false)
|
||
|
{
|
||
|
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[4]
|
||
|
).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());
|
||
|
}
|
||
|
if (station == 12001)
|
||
|
{
|
||
|
AheadDetect.Append(";D12001.0;D12001.1").Append(";I").Append(station.ToString()).Append(";N").Append(station.ToString());
|
||
|
}
|
||
|
else
|
||
|
if (station == 12002)
|
||
|
{
|
||
|
AheadDetect.Append(";D12002.0;D12002.1;D12002.2").Append(";I").Append(station.ToString()).Append(";N").Append(station.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndex(station).ToString()).Append(";I").Append(station.ToString()).Append(";N").Append(station.ToString());
|
||
|
}
|
||
|
AheadDetect.Append(";L").Append(station.ToString());//20160421
|
||
|
RunningLock.Append(station.ToString());
|
||
|
}
|
||
|
|
||
|
agvorder = 3;//AGV�ͻ�
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0) == false)
|
||
|
{//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()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
||
|
|
||
|
}
|
||
|
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 �������ͻ�����
|
||
|
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
|
||
|
case 17://20161221 ����������
|
||
|
#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);
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
||
|
|
||
|
tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
||
|
if (tw != "")
|
||
|
{
|
||
|
AheadDetect.Append(";D-").Append(tw.ToString());//20101118
|
||
|
}
|
||
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
||
|
#endregion
|
||
|
#region ע��
|
||
|
//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
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
#region ���ɲ�����������1
|
||
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
||
|
{
|
||
|
//��Ͳ������������д��F_NumParam1
|
||
|
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,").Append(drv["GOODS_NUM"]).Append(",'").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��̽��
|
||
|
#region ע�� by lyj 20171113
|
||
|
// tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
||
|
#endregion
|
||
|
tw = GetSendOutDetect(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 = GetBindingDeviceIndex(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
|
||
|
// }
|
||
|
// //20090803�����豸�Ƿ�����idle
|
||
|
// AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
//#region 20210326_�Ϻ��ɵ��������dz�������������Ҫ�ж���һ���������Ƿ��л�
|
||
|
|
||
|
//if (NextDevice[0] == 19003 || NextDevice[0] == 19005)
|
||
|
//{
|
||
|
// if (SecondNextKeyDevice.Count > 0)
|
||
|
// {
|
||
|
// int iNextDevice = GetPriorDevice(routeIDSub, SecondNextKeyDevice[2])[0];
|
||
|
// tw = GetBindingDeviceIndex(iNextDevice);
|
||
|
// 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;
|
||
|
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;
|
||
|
#region add by lyj20180424˫������������
|
||
|
case 40:
|
||
|
#region ˫��������ȡ��
|
||
|
//˫��������ȡ����
|
||
|
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;
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
arrowdev = PriorDevice[0];
|
||
|
CurDevice[3] = 6;
|
||
|
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Base_AheadDetect where F_DeviceIndex=").Append(CurDevice[0]).Append("and F_TaskType=").Append(tasktype).Append(" and F_CommondIndex=6").Append(" and F_GoalDeviceIndex=").Append(PriorDevice[0]);
|
||
|
dvahead = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvahead.Count > 0)
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
AheadDetect.Append(dvahead[0]["F_AheadDetect"].ToString());
|
||
|
}
|
||
|
|
||
|
|
||
|
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�Ľӻ�����������������
|
||
|
Rgvorder = 4; //GetRGVOrder(PriorDevice[0], true);
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
#region ��ǰ���������ݿ���ȡ add by lyj20180424
|
||
|
if (tasktype == 1)
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Base_AheadDetect where F_DeviceIndex=").Append(NextKeyDevice[0]).Append("and F_TaskType=1 and F_CommondIndex=4").Append(" and F_GoalDeviceIndex=").Append(PriorDevice[0]);
|
||
|
dvahead = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvahead.Count > 0)
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
AheadDetect.Append(dvahead[0]["F_AheadDetect"].ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (tasktype == 2)
|
||
|
{
|
||
|
int goaldevice=12037;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
//sql.Append("select * from T_Base_AheadDetect where F_DeviceIndex=").Append(NextKeyDevice[0]).Append("and F_TaskType=2 and F_CommondIndex=4").Append(" and F_GoalDeviceIndex=").Append(NextDevice[0]);
|
||
|
|
||
|
sql.Append("select * from T_Base_AheadDetect where F_DeviceIndex=").Append(NextKeyDevice[0]).Append("and F_TaskType=2 and F_CommondIndex=4").Append(" and F_GoalDeviceIndex=").Append(PriorDevice[0]);
|
||
|
dvahead = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvahead.Count > 0)
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
AheadDetect.Append(dvahead[0]["F_AheadDetect"].ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
#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,").Append(PriorDevice[0]).Append(",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
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
//����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���ͻ�
|
||
|
|
||
|
Rgvorder = 5;// GetRGVOrder(NextDevice[0], false);
|
||
|
|
||
|
|
||
|
|
||
|
#region ������ǰ����������
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
#region �ͻ������ݿ���ȡ add by lyj 20171026
|
||
|
if (tasktype == 1)
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Base_AheadDetect where F_DeviceIndex=").Append(NextKeyDevice[0]).Append("and F_TaskType=1 and F_CommondIndex=5").Append(" and F_GoalDeviceIndex=").Append(NextDevice[0]);
|
||
|
dvahead = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvahead.Count > 0)
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
AheadDetect.Append(dvahead[0]["F_AheadDetect"].ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (tasktype == 2)
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
|
||
|
// sql.Append("select * from T_Base_AheadDetect where F_DeviceIndex=").Append(NextKeyDevice[0]).Append("and F_TaskType=2 and F_CommondIndex=5").Append(" and F_GoalDeviceIndex=").Append(NextDevice[0]);
|
||
|
sql.Append("select * from T_Base_AheadDetect where F_DeviceIndex=").Append(NextKeyDevice[0]).Append("and F_TaskType=2 and F_CommondIndex=5").Append(" and F_GoalDeviceIndex=").Append(NextDevice[0]);
|
||
|
dvahead = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvahead.Count > 0)
|
||
|
{
|
||
|
AheadDetect.Remove(0, AheadDetect.Length);
|
||
|
AheadDetect.Append(dvahead[0]["F_AheadDetect"].ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
#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,").Append(NextDevice[0]).Append(",0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
mainTask = mindex;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
#endregion
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
}
|
||
|
PriorDevice0 = PriorDevice;
|
||
|
PriorKeyDevice0 = NextKeyDevice;
|
||
|
//20091107
|
||
|
PriorDevice = null;
|
||
|
NextKeyDevice = null;
|
||
|
CurDevice = null;
|
||
|
NextKeyDevice = null;
|
||
|
}
|
||
|
//20120820
|
||
|
string dtime = DateTime.Now.ToString("u");
|
||
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
||
|
dbo.ExecuteSql(string.Format("update T_Monitor_Task set F_SplitTime= '{0}' where F_ManageTASKKINDINDEX={1} and F_ManageTASKINDEX={2}",dtime,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>
|
||
|
/// ����������Ҫ�������������������в��֣�����ֵtrue�Ͳ�����
|
||
|
/// </summary>
|
||
|
/// <param name="drv"></param>
|
||
|
/// <returns></returns>
|
||
|
public static bool ControlTaskAmountUnDisassemble(DataRowView drv)
|
||
|
{//20121203
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
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];
|
||
|
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;
|
||
|
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 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;
|
||
|
stackCoo[4] = Convert.ToInt32(dv[0]["FENDCELL"]);
|
||
|
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);
|
||
|
#region ע�� by lyj 20171117
|
||
|
// sql.Append("select * from T_Base_Lane_Gate where F_LaneGateDeviceIndex=" ).Append( devIndex ).Append( " and F_LaneIndex=").Append(LaneWay);
|
||
|
#endregion
|
||
|
sql.Append("select * from T_Base_Lane_Gate where F_LaneGateDeviceIndex=").Append(devIndex);
|
||
|
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>
|
||
|
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
|
||
|
{
|
||
|
//20170104 ���������������ƣ����ܹ�����������
|
||
|
if (ccf.GetTaskCountsCanDisassembleToEndDevice(Convert.ToInt32(dr["FID"]), Convert.ToInt32(dr["FENDDEVICE"])) == false) return;
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// �Ƿ������������� ,ͬһ��վ̨�������������������� 20171106 by lyj add
|
||
|
/// </summary>
|
||
|
/// <param name="drv"></param>
|
||
|
/// <returns></returns>
|
||
|
|
||
|
|
||
|
/*
|
||
|
* ������:isOrNotAllowDisaemble
|
||
|
* �� �ߣ�LYJ
|
||
|
* �������ܣ��Ƿ������������� ,ͬһ��վ̨��������������������
|
||
|
* �������ܣ�
|
||
|
* �� �� ֵ������true��ʾ���֣�false��ʾ������
|
||
|
* �������ڣ�2018/01/15
|
||
|
* ά����Ա��
|
||
|
* ά�����ڣ�
|
||
|
* ά��ԭ����
|
||
|
* ��ǰ�汾��1.0
|
||
|
* ǰ�̰汾��1.0beta
|
||
|
*/
|
||
|
public static bool isOrNotAllowDisaemble(DataRowView drv)
|
||
|
{
|
||
|
DataView dvoutin=new DataView();;
|
||
|
int tasktype = 0;
|
||
|
int startdevice = 0;
|
||
|
int enddevice = 0;
|
||
|
Model.MDevice devinfoion;
|
||
|
string intask = string.Empty;
|
||
|
string outtask = string.Empty;
|
||
|
try
|
||
|
{
|
||
|
tasktype = Convert.ToInt32(drv["FCONTROLTASKTYPE"]);
|
||
|
|
||
|
startdevice = Convert.ToInt32(drv["FSTARTDEVICE"]);
|
||
|
|
||
|
enddevice = Convert.ToInt32(drv["FENDDEVICE"]);
|
||
|
|
||
|
#region add by lyj20180621�����岻���Ƴ���������
|
||
|
if (tasktype == 1)
|
||
|
{
|
||
|
if (enddevice == 18005)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (tasktype == 2)
|
||
|
{
|
||
|
if (startdevice == 18005)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
if (tasktype == 1)
|
||
|
{
|
||
|
|
||
|
|
||
|
outtask = "select * from T_Manage_Task where FCONTROLTASKTYPE=2 and FENDDEVICE =" + startdevice;
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
|
||
|
sql.Append(outtask);
|
||
|
|
||
|
dvoutin = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvoutin.Count > 0)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (tasktype == 2 )
|
||
|
{
|
||
|
|
||
|
|
||
|
intask = "select * from T_Manage_Task where FCONTROLTASKTYPE=1 and FSTARTDEVICE =" + enddevice;
|
||
|
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
|
||
|
sql.Append(intask);
|
||
|
|
||
|
dvoutin = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvoutin.Count > 0)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
devinfoion = Model.CGetInfo.GetDeviceInfo(enddevice);
|
||
|
|
||
|
|
||
|
if (devinfoion.SplitByte_0==1)
|
||
|
{
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
#region ��ѡ�����Ŀ��ƣ�ÿ��ֻ����һ����ѡ���� 20160303 add by lyj
|
||
|
//else if (tasktype == 2 && Convert.ToInt32(drv["FChooseTask"]) == 1)
|
||
|
//{
|
||
|
|
||
|
// #region update by lyj 20160525 վ̨ռ�ü�ѡ������
|
||
|
// checkStationStatus = "select * from T_Base_Device where F_StationStatus=1 and F_DeviceIndex=" + enddevice;
|
||
|
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
|
||
|
// sql.Append(checkStationStatus);
|
||
|
|
||
|
// dvoutin = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
// if (dvoutin.Count > 0)
|
||
|
// {
|
||
|
// return false;
|
||
|
// }
|
||
|
// #endregion
|
||
|
|
||
|
// #region update by lyj 20160525 ����ͬһ��վ̨ÿ����һ����ѡ��������
|
||
|
// choosetask = "select * from T_Manage_Task where FCONTROLTASKTYPE=2 and FChooseTask=1 and FIntoStepOK=1 and FENDDEVICE =" + enddevice;
|
||
|
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
|
||
|
// sql.Append(choosetask);
|
||
|
|
||
|
// dvoutin = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
// if (dvoutin.Count > 0)
|
||
|
// {
|
||
|
// return false;
|
||
|
// }
|
||
|
|
||
|
// #endregion
|
||
|
|
||
|
// #region add by lyj 20160525 ����������ʱ��ѡ������
|
||
|
// if (startdevice < 18004)
|
||
|
// {
|
||
|
|
||
|
// if (enddevice == 52107 || enddevice == 62101 || enddevice == 72101)
|
||
|
// {
|
||
|
// intask = "select * from T_Manage_Task where FCONTROLTASKTYPE=1 and FSTARTDEVICE in ('52107','62101','72101')";
|
||
|
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
|
||
|
// intask = "select * from T_Manage_Task where FCONTROLTASKTYPE=1 and FSTARTDEVICE =" + enddevice;
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// if (enddevice == 52008 || enddevice == 62001 || enddevice == 72001)
|
||
|
// {
|
||
|
// intask = "select * from T_Manage_Task where FCONTROLTASKTYPE=1 and FSTARTDEVICE in ('52008','62001','72001')";
|
||
|
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// intask = "select * from T_Manage_Task where FCONTROLTASKTYPE=1 and FSTARTDEVICE =" + enddevice;
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
|
||
|
// sql.Append(intask);
|
||
|
|
||
|
// dvoutin = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
// if (dvoutin.Count > 0)
|
||
|
// {
|
||
|
// return false;
|
||
|
// }
|
||
|
// #endregion
|
||
|
|
||
|
// updateStationStatus = "update T_Base_Device set F_StationStatus=1 where F_DeviceIndex=" + enddevice;
|
||
|
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
|
||
|
// sql.Append(updateStationStatus);
|
||
|
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
#endregion
|
||
|
return true;
|
||
|
|
||
|
}
|
||
|
catch (Exception eiad)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/*
|
||
|
* ������:conveyorNumFromPosition
|
||
|
* �� �ߣ�LYJ
|
||
|
* �������ܣ�������ʼλ���ҵ����ʵ����ͻ�����
|
||
|
* �������ܣ�
|
||
|
* �� �� ֵ�����ͻ�����
|
||
|
* �������ڣ�2018/04/23
|
||
|
* ά����Ա��
|
||
|
* ά�����ڣ�
|
||
|
* ά��ԭ����
|
||
|
* ��ǰ�汾��1.0
|
||
|
* ǰ�̰汾��1.0beta
|
||
|
*/
|
||
|
public static int conveyorNumFromPosition(string FSTARTCELL, string FENDCELL, int startdevice, int enddevice,int tasktype)
|
||
|
{
|
||
|
|
||
|
|
||
|
string sy = "";//��ʾ��
|
||
|
int iy = 0;//��ʾ��
|
||
|
int deviceindex = 0;
|
||
|
DataView dvconveyor = new DataView(); ;
|
||
|
string sqlconveyor = string.Empty;
|
||
|
try
|
||
|
{
|
||
|
|
||
|
if(tasktype==1&&(startdevice==18001||enddevice==18001))
|
||
|
{
|
||
|
|
||
|
if(FENDCELL!=null)
|
||
|
{
|
||
|
if (FENDCELL.Length == 8)
|
||
|
{
|
||
|
sy = FENDCELL.Substring(6);
|
||
|
if(sy!="")
|
||
|
{
|
||
|
iy = Convert.ToInt32(sy);
|
||
|
sqlconveyor = "select * from T_Base_conveyorNumFromPosition where FTASKTYPE=1 and F_Station ="+ startdevice + " and FLAYER=" + iy;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
|
||
|
sql.Append(sqlconveyor);
|
||
|
|
||
|
dvconveyor = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvconveyor.Count>0)
|
||
|
{
|
||
|
deviceindex = Convert.ToInt32(dvconveyor[0]["FCONVEYORNUM"]);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (tasktype == 2 && (startdevice == 18001 || enddevice == 18001))
|
||
|
{
|
||
|
if (FSTARTCELL != null)
|
||
|
{
|
||
|
if (FSTARTCELL.Length == 8)
|
||
|
{
|
||
|
sy = FSTARTCELL.Substring(6);
|
||
|
if (sy != "")
|
||
|
{
|
||
|
iy = Convert.ToInt32(sy);
|
||
|
sqlconveyor = "select * from T_Base_conveyorNumFromPosition where FTASKTYPE=2 and F_Station =" + enddevice + " and FLAYER=" + iy;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
|
||
|
sql.Append(sqlconveyor);
|
||
|
|
||
|
dvconveyor = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvconveyor.Count > 0)
|
||
|
{
|
||
|
deviceindex = Convert.ToInt32(dvconveyor[0]["FCONVEYORNUM"]);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
return deviceindex;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MinRouteIDʱ��������:" + ex.Message;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 20100702
|
||
|
/// ���ݵ����������������յ��豸��������·�����̵�RouteIDSub update by lyj20180423
|
||
|
/// </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)
|
||
|
public static int MinRouteID(int startdevice, int enddevice, object useAwayfork,string FSTARTCELL,string FENDCELL,int tasktype)
|
||
|
|
||
|
{
|
||
|
//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
|
||
|
#region add by lyj20180424 �ҵ�����ƥ�������ͻ�
|
||
|
//if ((tasktype == 1 || tasktype == 2)&&(startdevice==18001||enddevice==18001))
|
||
|
//{
|
||
|
// int conveyorindex = conveyorNumFromPosition(FSTARTCELL, FENDCELL, startdevice, enddevice, tasktype);
|
||
|
|
||
|
// 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 and T_Base_Route_Device.F_DeviceIndex=").Append(conveyorindex);//and T_Base_Route_Device.F_DeviceIndex=12018
|
||
|
//}
|
||
|
//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 ");//and T_Base_Route_Device.F_DeviceIndex=12018
|
||
|
//}
|
||
|
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 ");
|
||
|
#endregion
|
||
|
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_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(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);//·���豸������
|
||
|
}
|
||
|
|
||
|
//������·������·������*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();
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|