You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
6931 lines
403 KiB
6931 lines
403 KiB
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();
|
|
//ChangeEndDeviceToEmergencyExit();
|
|
switch (Pri)
|
|
{
|
|
case 0://按照调度任务优先级
|
|
SelectTask_ManPRI();
|
|
break;
|
|
case 1://单纯入库优先
|
|
SelectTask_OnlyIn();
|
|
break;
|
|
case 12://入库优先携带附带运行条件的出库任务
|
|
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")
|
|
//如果是出库任务:判断堆垛机是否有调度命令在执行或者被锁定
|
|
{
|
|
//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
|
|
//判断将要被拆分的出库任务是否在已拆分的队列中有终点相同的出库任务,没有就找一个拆分
|
|
//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")
|
|
//如果是出库任务:判断堆垛机是否有调度命令在执行或者被锁定
|
|
{
|
|
//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
|
|
//判断将要被拆分的出库任务是否在已拆分的队列中有终点相同的出库任务,没有就找一个拆分
|
|
//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>
|
|
/// 入库优先附带符合运行条件的出库任务
|
|
/// 具体实现:判断T_Manage_Task表中是否有此堆垛机任务正在执行:如果没有,则挑选一个入库任务;
|
|
/// 如果有堆垛机正在执行入库任务,并且队列中没有等待执行的堆垛机出库任务,挑选一个此堆垛机的出库任务优先级设为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)//没有此堆垛机的出库任务在排队
|
|
{
|
|
#region 挑选此堆垛机的出库任务
|
|
|
|
//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)//挑选此堆垛机的出库任务
|
|
{
|
|
|
|
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 GGGG add for CATL wwttt
|
|
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 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)//挑选此堆垛机的出库任务
|
|
{
|
|
//20091102
|
|
for (int j = 0; j < dv.Count; j++)
|
|
{
|
|
if (stackUcode.IndexOf(dvM[i]["F_StackIndex"].ToString()) >= 0)
|
|
{//20120309 有此堆垛机的出库任务而且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有此堆垛机的出库任务而且终点相同在排队就不拆分了
|
|
//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")
|
|
//如果是出库任务:判断堆垛机是否有调度命令在执行或者被锁定
|
|
{
|
|
if (stackUcode.IndexOf(dvM[i]["F_StackIndex"].ToString()) >= 0)
|
|
{//20120309 有此堆垛机的出库任务而且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有此堆垛机的出库任务而且终点相同在排队就不拆分了
|
|
//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")
|
|
//如果是出库任务:判断堆垛机是否有调度命令在执行或者被锁定
|
|
{
|
|
//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
|
|
//判断将要被拆分的出库任务是否在已拆分的队列中有终点相同的出库任务,没有就找一个拆分
|
|
//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();
|
|
}
|
|
}
|
|
public static int GetLaneIndexFromLaneGate(int lanegate)
|
|
{//20120820
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_LaneIndex FROM T_Base_Lane_Gate WHERE (F_LaneGateDeviceIndex = {0}) ", lanegate)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
int a = 0;
|
|
if (int.TryParse(dv[0]["F_LaneIndex"].ToString(), out a) == false)
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{//2019-12-30
|
|
//if ( Convert.ToInt32(dv[0]["F_LaneIndex"]) == 120241 || Convert.ToInt32(dv[0]["F_LaneIndex"]) == 120281)
|
|
//{
|
|
// return 0;
|
|
//}
|
|
//else
|
|
//{
|
|
return Convert.ToInt32(dv[0]["F_LaneIndex"]);
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
static void ChangeEndDeviceToEmergencyExit()
|
|
{
|
|
DataView dv = new DataView();
|
|
DataView dv1 = new DataView();
|
|
try
|
|
{
|
|
string sql = string.Empty;
|
|
sql = string.Format("select F_DeviceIndex,F_EmergencyExit from T_Base_TaskCount where F_EmergencyExit>0");//查找终点设备对应的出库任务获取数量和执行数量
|
|
dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|
sql = string.Format("SELECT distinct FENDDEVICE FROM T_Manage_Task WHERE (FSTATUS = 0) AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0')");//查找未执行未拆分且终点是enddevice的任务
|
|
dv1 = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|
|
|
for (int k = 0; k < dv1.Count;k++ )
|
|
{
|
|
int taskenddevice = Convert.ToInt32(dv1[k]["FENDDEVICE"]);//任务终点
|
|
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
int enddevice = Convert.ToInt32(dv[i]["F_DeviceIndex"]);
|
|
int newenddevice = Convert.ToInt32(dv[i]["F_EmergencyExit"]);
|
|
|
|
//判读newenddevice 是否为固定站台,获取新的 enddevice 和endcell
|
|
int lane = GetLaneIndexFromLaneGate(newenddevice);//巷道
|
|
string endcell = "";
|
|
if (lane!=0)
|
|
{
|
|
endcell =Convert.ToString( newenddevice);
|
|
newenddevice = lane;
|
|
|
|
}
|
|
|
|
if (taskenddevice == enddevice)//
|
|
{
|
|
|
|
sql = string.Format("update T_Manage_Task set FENDDEVICE= {0},FENDCELL='{1}',FOLDENDDEVICE={2} WHERE (FENDDEVICE={3}) and (FSTATUS = 0) AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0')", newenddevice, endcell,enddevice, enddevice);//查找未执行未拆分且终点是enddevice的任务
|
|
dbo.ExceSQL(sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.ChangeEndDeviceToEmergencyExit时发生错误:" + ex.StackTrace + ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv1.Dispose();
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 出库优先附带符合运行条件的入库任务 kkkkkkkkkkkkkkkkkk
|
|
/// 具体实现:在收到出库任务的完成时,挑选一个可以执行的入库任务把优先级设成最高9
|
|
/// </summary>
|
|
static void SelectTask_OutSubjoinIn()
|
|
{
|
|
DataView dvM = new DataView();
|
|
DataView dv = new DataView();
|
|
DataView dv112 = new DataView();
|
|
DataView dv0 = new DataView();
|
|
DataView dv1 = new DataView();
|
|
try
|
|
{
|
|
Model.MDevice deviceInfo;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_StackIndex FROM T_Base_StackInfo");
|
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
int routeid = -1;
|
|
for (int i = 0; i < dvM.Count; i++)
|
|
{//20090928
|
|
#region 首先选择此堆垛机所有入库任务,判断那个能执行
|
|
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTATUS = 0) AND (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 1) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int j = 0; j < dv.Count; j++)//有这个堆垛机的入库任务等待拆分
|
|
{
|
|
//选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
|
if (routeid == -1)
|
|
{
|
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
|
{//20091107
|
|
GetUsableDestination(dv[j]);
|
|
}
|
|
continue;
|
|
}
|
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
|
{
|
|
//分解完成,修改T_Manage_Task表FIntoStepOK=1
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[j]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20100323
|
|
//20101028增加出库关联
|
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
//20091005
|
|
#region 然后给正在执行的入库堆垛机任务配上一个出库任务
|
|
|
|
|
|
//然后给正在执行的入库堆垛机任务配上一个出库任务
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT T_Monitor_Task.F_MonitorIndex FROM T_Monitor_Task ,T_Manage_Task WHERE ").Append(
|
|
" (T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID AND ").Append(
|
|
" T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex)").Append(
|
|
" And (T_Monitor_Task.F_Status = 1 OR T_Monitor_Task.F_Status = 2) AND F_DeviceCommandIndex=5 and ").Append(
|
|
"(T_Monitor_Task.F_DeviceIndex = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (T_Manage_Task.FCONTROLTASKTYPE = 1)");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)//有这个堆垛机的入库任务在执行
|
|
{
|
|
#region 有这个堆垛机的入库任务在执行
|
|
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc,FBEGTIME asc");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count <= 0)//没有此堆垛机的出库任务在排队或者执行
|
|
{
|
|
#region 挑选此堆垛机的出库任务
|
|
|
|
//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)//挑选此堆垛机的出库任务
|
|
{
|
|
|
|
routeid = MinRouteID(Convert.ToInt32(dv[0]["FSTARTDEVICE"]), Convert.ToInt32(dv[0]["FENDDEVICE"]), dv[0]["FUseAwayFork"]);
|
|
if (routeid == -1)
|
|
{
|
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
|
{//20091107
|
|
GetUsableDestination(dv[0]);
|
|
}
|
|
continue;
|
|
}
|
|
//20101028增加出库关联
|
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[0]["FSTACK"]));
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
GetOutDoubleForkTask(dv[0]);
|
|
}
|
|
}
|
|
if (CreateMonitor(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[0]["FID"]), routeid, dv[0], 0) > 0)
|
|
{
|
|
//分解完成,修改T_Manage_Task表FIntoStepOK=1
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[0]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[0]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20101124
|
|
// add for CATL YB2
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update 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");
|
|
//20181029
|
|
//sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE,FLOGIC_AREA 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,FLOGIC_AREA ORDER BY FTASKLEVEL DESC");
|
|
sql.Append("SELECT FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE,FLOGIC_AREA 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,FLOGIC_AREA ,FID ORDER BY FTASKLEVEL DESC , FID ");
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)//挑选此堆垛机的出库任务
|
|
{
|
|
|
|
//20091102
|
|
for (int j = 0; j < dv.Count; j++)
|
|
{
|
|
if (stackUcode.IndexOf(dvM[i]["F_StackIndex"].ToString()) >= 0)
|
|
{//20120309 有此堆垛机的出库任务而且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有此堆垛机的出库任务而且终点相同在排队就不拆分了
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FLOGIC_AREA=").Append(dv[j]["FLOGIC_AREA"]).Append( //20170923 FLOGIC_AREA 替换 FENDDEVICE
|
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
|
|
|
}
|
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv112.Count > 0)
|
|
{
|
|
continue;//20141130
|
|
}
|
|
|
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
|
if (routeid == -1)
|
|
{
|
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
|
{//20091107
|
|
GetUsableDestination(dv[j]);
|
|
}
|
|
continue;
|
|
}
|
|
//20101028增加出库关联
|
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
GetOutDoubleForkTask(dv[j]);
|
|
}
|
|
}
|
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
|
{
|
|
//分解完成,修改T_Manage_Task表FIntoStepOK=1
|
|
int level = Convert.ToInt32(dv[j]["FTASKLEVEL"]) == 100 ? 100 : 9;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1',FTASKLEVEL=").Append(level).Append(" where FID=").Append(dv[j]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
|
dv[j]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dv[j]["FID"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20100323
|
|
//20101028增加出库关联
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select * from T_Manage_Task WHERE (FSTACK = ").Append(
|
|
dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0)");
|
|
DataView dvv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int aa = 0; aa < dvv.Count; aa++)
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FTASKLEVEL=9 WHERE (FTASKLEVEL<>100) and F_ManageTASKKINDINDEX=").Append(
|
|
dvv[aa]["F_ManageTaskKindIndex"]).Append(" and FID=").Append(dvv[aa]["FID"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
|
dvv[aa]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dvv[aa]["FID"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
//20091005
|
|
else
|
|
{
|
|
|
|
//首先选择此堆垛机一个出库任务
|
|
#region 首先选择此堆垛机一个出库任务
|
|
|
|
//判断堆垛机是否有调度命令在执行或者被锁定
|
|
//20130620
|
|
sql.Remove(0, sql.Length);
|
|
|
|
sql.Append("SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task").Append(
|
|
" where F_DeviceIndex=").Append(dvM[i]["F_StackIndex"]).Append(" and F_Status>0 ");
|
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
continue;
|
|
}
|
|
//被锁定20130620
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["F_StackIndex"]).Append(" and (F_LockedState>0 or F_ManTaskReserve>0)");
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
continue;
|
|
}
|
|
sql.Remove(0, sql.Length);
|
|
//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");
|
|
//20181029
|
|
sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE,FLOGIC_AREA 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,FLOGIC_AREA ORDER BY FTASKLEVEL DESC");
|
|
//sql.Append("SELECT FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE,FLOGIC_AREA 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,FLOGIC_AREA ,FID ORDER BY FTASKLEVEL DESC , FID ");
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int j = 0; j < dv.Count; j++)
|
|
//有这个堆垛机的出库任务等待拆分
|
|
{
|
|
if (stackUcode.IndexOf(dvM[i]["F_StackIndex"].ToString()) >= 0)
|
|
{//20120309 有此堆垛机的出库任务而且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");
|
|
|
|
//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 (FENDCELL = ").Append(dv[j]["FENDCELL"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0)order by FTASKLEVEL desc");
|
|
|
|
|
|
}
|
|
else
|
|
{//20110110有此堆垛机的出库任务而且终点相同在排队就不拆分了
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FID,F_RELATIVECONTORLID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FLOGIC_AREA=").Append(dv[j]["FLOGIC_AREA"]).Append( //20170923 FLOGIC_AREA 替换 FENDDEVICE 同意逻辑区域视为终点相同
|
|
") and (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
|
|
|
//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 (FENDCELL = ").Append(dv[j]["FENDCELL"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0) order by FTASKLEVEL desc");
|
|
|
|
}
|
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv112.Count > 0)
|
|
{
|
|
#region add for YB5 关联任务拆分时 已经拆分一条 另一条因为路径不通没拆分
|
|
//判断下当前任务是不是关联任务并且其中一条已经拆分了
|
|
for (int g = 0; g < dv112.Count; g++)
|
|
{
|
|
if (Convert.ToInt32(dv112[g]["F_RELATIVECONTORLID"]) != -1)
|
|
{
|
|
//判断已经拆分的关联任务对应的另一条任务是否拆分 未拆分 进行拆分
|
|
DataView dvGL = new DataView();
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FID,F_RELATIVECONTORLID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FID !=").Append(dv112[g]["F_RELATIVECONTORLID"]).Append(
|
|
") and (F_RELATIVECONTORLID = ").Append(dv112[g]["F_RELATIVECONTORLID"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') AND (FStatus = 0) order by FTASKLEVEL desc");
|
|
dvGL = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvGL.Count > 0)
|
|
{
|
|
Model.MDevice deviceInfo1;
|
|
deviceInfo1 = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["F_StackIndex"]));
|
|
if (deviceInfo1 != null)
|
|
{
|
|
if (deviceInfo1.IfCorrelDoubleFork == "1")
|
|
{
|
|
CreateRelativeMonitor(Convert.ToInt32(dvGL[0]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvGL[0]["FID"]));
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CDisassembleTask", "拆分任务特殊:", "FID:" + dvGL[0]["FID"].ToString(), "F_RELATIVECONTORLID:" + dv112[g]["F_RELATIVECONTORLID"].ToString());
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
|
|
|
|
//选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
|
if (routeid == -1)
|
|
{
|
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
|
{//20091107
|
|
GetUsableDestination(dv[j]);
|
|
}
|
|
continue;
|
|
}
|
|
//20101028增加出库关联
|
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
GetOutDoubleForkTask(dv[j]);
|
|
}
|
|
}
|
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
|
{
|
|
//分解完成,修改T_Manage_Task表FIntoStepOK=1
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[j]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//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
|
|
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;
|
|
}
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FENDDEVICE=").Append(dvM[i]["FENDDEVICE"]).Append(") AND (FCONTROLTASKTYPE =3) AND (FIntoStepOK = '1') order by FTASKLEVEL desc");
|
|
|
|
|
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv112.Count > 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (CreateMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]), routeid, dvM[i], 0) > 0)
|
|
{
|
|
//分解完成,修改T_Manage_Task表FIntoStepOK=1
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dvM[i]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dvM[i]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20100323
|
|
CreateRelativeMonitor(Convert.ToInt32(dvM[i]["F_ManageTaskKindIndex"]), Convert.ToInt32(dvM[i]["FID"]));
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.SelectTask_OutSubjoinIn时发生错误:" + ex.StackTrace + ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv0.Dispose();
|
|
dv1.Dispose();
|
|
dv112.Dispose();
|
|
dvM.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据调度任务的起点和终点设备索引查找路径最短的RouteIDSub
|
|
/// </summary>
|
|
/// <param name="startdevice">起点设备索引</param>
|
|
/// <param name="enddevice">终点设备索引</param>
|
|
/// <returns></returns>
|
|
public static int MinRouteID(int startdevice,int enddevice)
|
|
{
|
|
DataView dv = new DataView(); DataView dvd = new DataView(); DataView dv1 = new DataView(); DataView dv2 = new DataView();
|
|
List<double> minroute=new List<double>() ;
|
|
try
|
|
{
|
|
int retrouteidsub =GetSameStartDeviceEnddeviceRouteID(startdevice, enddevice);
|
|
if (retrouteidsub > 0)
|
|
{
|
|
return retrouteidsub;
|
|
}
|
|
//选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and F_Status=1");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//0,routIDSub;1,路径最小值
|
|
if (dv.Count == 0)
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "起点设备:" + startdevice + "和终点设备:" + enddevice + "之间路径不可用!");
|
|
OnRefreshMonitor(rme);
|
|
return -1;
|
|
}
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_RouteIDSub, F_LockedState,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Base_Route_Device WHERE ").Append(
|
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and (T_Base_Route_Device.F_RouteIDSub = ").Append(
|
|
dv[i]["F_RouteIDSub"]).Append(") AND (T_Base_Device.F_LockedState = - 1 or T_Base_Device.F_ErrorCode>=30)");//20121203
|
|
dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvd.Count > 0)
|
|
{
|
|
int dvin = Convert.ToInt32(dvd[0]["F_DeviceIndex"]);
|
|
if ((dvin >= 35001 && dvin <= 35003) || (dvin == 45001))
|
|
{//20120207机器人地位无法取代,不判断是否被禁用
|
|
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
List<double> route = new List<double>();//0,routIDSub;1,步长;2,路径使用频率;3,路径设备任务数
|
|
//路径步长(设备总数)最短(权重0.3),路径使用频率最小(权重0.3)的路径,路径设备任务数(权重0.3)
|
|
|
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
|
).Append(dv[i]["F_RouteIDSub"]);
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//步长
|
|
//route.Add(0);
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
//路径使用频率:路径执行调度任务的数量
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)
|
|
{
|
|
int a = -1;
|
|
if (int.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
|
{
|
|
route.Add(Convert.ToDouble(dv2[0]["ManCount"]));//路径使用频率
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径使用频率
|
|
}
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径使用频率
|
|
}
|
|
//路径设备任务数
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)
|
|
{
|
|
int a = -1;
|
|
if (int.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
|
{
|
|
route.Add(Convert.ToDouble(dv2[0]["mtask"]));//路径设备任务数
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径设备任务数
|
|
}
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径设备任务数
|
|
}
|
|
|
|
//求最短路径((路径步长*0.3+路径使用频率*0.3+设备占有数*0.3)的最小值)
|
|
if (minroute.Count == 0)
|
|
{
|
|
minroute.Add(route[0]);
|
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
|
}
|
|
else
|
|
{
|
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3))
|
|
{
|
|
minroute[0] = route[0];
|
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
|
}
|
|
}
|
|
}
|
|
if (minroute.Count > 0)
|
|
{
|
|
return Convert.ToInt32(minroute[0]);
|
|
}
|
|
else
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "起点设备:" + startdevice + "和终点设备:" + enddevice + "之间路径不可用!");
|
|
OnRefreshMonitor(rme);
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MinRouteID时发生错误:" +ex.StackTrace+ ex.Message;
|
|
return -1;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv1.Dispose();
|
|
dv2.Dispose();
|
|
dvd.Dispose();
|
|
minroute = null;
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 20091005
|
|
/// 根据调度任务的起点和终点设备索引查找路径最短的RouteIDSub
|
|
/// </summary>
|
|
/// <param name="startdevice">起点设备索引</param>
|
|
/// <param name="enddevice">终点设备索引</param>
|
|
/// /// <param name="enddevice">当前设备索引</param>
|
|
/// <returns></returns>
|
|
public static int MinRouteID(int startdevice, int enddevice,int nowdevice)
|
|
{
|
|
DataView dv = new DataView(); DataView dvd = new DataView();
|
|
DataView dv1 = new DataView(); DataView dv2 = new DataView();
|
|
List<double> minroute = new List<double>();//0,routIDSub;1,路径最小值
|
|
try
|
|
{
|
|
int retrouteidsub = GetSameStartDeviceEnddeviceRouteID(startdevice, enddevice);
|
|
if (retrouteidsub > 0)
|
|
{
|
|
return retrouteidsub;
|
|
}
|
|
//选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and F_Status=1 and T_Base_Device.F_DeviceIndex =").Append(nowdevice);
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
|
|
if (dv.Count == 0)
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "起点设备:" + startdevice + "和终点设备:" + enddevice + "之间路径不可用!");
|
|
OnRefreshMonitor(rme);
|
|
return -1;
|
|
}
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_RouteIDSub, F_LockedState,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Base_Route_Device WHERE ").Append(
|
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and (T_Base_Route_Device.F_RouteIDSub = ").Append(
|
|
dv[i]["F_RouteIDSub"]).Append(") AND (T_Base_Device.F_LockedState = - 1 or T_Base_Device.F_ErrorCode>=30)");//20121203
|
|
dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvd.Count > 0)
|
|
{
|
|
int dvin = Convert.ToInt32(dvd[0]["F_DeviceIndex"]);
|
|
if ((dvin >= 35001 && dvin <= 35003) || (dvin == 45001))
|
|
{//20120207机器人地位无法取代,不判断是否被禁用
|
|
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
List<double> route = new List<double>();//0,routIDSub;1,步长;2,路径使用频率;3,路径设备任务数
|
|
//路径步长(设备总数)最短(权重0.3),路径使用频率最小(权重0.3)的路径,路径设备任务数(权重0.3)
|
|
|
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
|
).Append(dv[i]["F_RouteIDSub"]);
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//步长
|
|
//route.Add(0);
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
//路径使用频率:路径执行调度任务的数量
|
|
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)
|
|
{
|
|
double a = 0;
|
|
if (double.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
|
{
|
|
route.Add(Convert.ToDouble(dv2[0]["ManCount"]));//路径使用频率
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径使用频率
|
|
}
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径使用频率
|
|
}
|
|
//路径设备任务数
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)
|
|
{
|
|
double a = 0;
|
|
if (double.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
|
{
|
|
route.Add(Convert.ToDouble(dv2[0]["mtask"]));//路径设备任务数
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径设备任务数
|
|
}
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径设备任务数
|
|
}
|
|
|
|
//求最短路径((路径步长*0.3+路径使用频率*0.3+设备占有数*0.3)的最小值)
|
|
if (minroute.Count == 0)
|
|
{
|
|
minroute.Add(route[0]);
|
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
|
}
|
|
else
|
|
{
|
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3))
|
|
{
|
|
minroute[0] = route[0];
|
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
|
}
|
|
}
|
|
}
|
|
if (minroute.Count > 0)
|
|
{
|
|
return Convert.ToInt32(minroute[0]);
|
|
}
|
|
else
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "起点设备:" + startdevice + "和终点设备:" + enddevice + "之间路径不可用!");
|
|
OnRefreshMonitor(rme);
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MinRouteID时发生错误:" +ex.StackTrace+ ex.Message;
|
|
return -1;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv1.Dispose();
|
|
dv2.Dispose();
|
|
dvd.Dispose();
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 根据调度任务的起点和终点设备索引查找路径最短的RouteIDSub
|
|
/// </summary>
|
|
/// <param name="startdevice">起点设备索引</param>
|
|
/// <param name="enddevice">终点设备索引</param>
|
|
/// <param name="AllStatus">不考虑路径状态:true和false都可以</param>
|
|
/// <returns></returns>
|
|
public static int MinRouteID(int startdevice, int enddevice, bool AllStatus, object useAwayfork)
|
|
{
|
|
//20101124
|
|
DataView dv = new DataView();
|
|
DataView dv1 = new DataView(); DataView dv2 = new DataView();
|
|
StringBuilder dff =new StringBuilder();
|
|
if (useAwayfork.ToString() == "-")
|
|
{
|
|
dff .Append( "F_UseAwayFork<>'n'");
|
|
}
|
|
else
|
|
{
|
|
dff .Append( "(F_UseAwayFork='" ).Append( useAwayfork ).Append( "' or F_UseAwayFork='-' )");//20101028
|
|
}
|
|
//20101124
|
|
try
|
|
{
|
|
//选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and ").Append(dff.ToString());
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
List<double> minroute = new List<double>();//0,routIDSub;1,路径最小值
|
|
if (dv.Count == 0)
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "起点设备:" + startdevice + "和终点设备:" + enddevice + "之间路径不可用!");
|
|
OnRefreshMonitor(rme);
|
|
return -1;
|
|
}
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
|
|
|
|
List<double> route = new List<double>();//0,routIDSub;1,步长;2,路径使用频率;3,路径设备任务数
|
|
//路径步长(设备总数)最短(权重0.3),路径使用频率最小(权重0.3)的路径,路径设备任务数(权重0.3)
|
|
|
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
|
).Append(dv[i]["F_RouteIDSub"]);
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//步长
|
|
//route.Add(0);
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
//路径使用频率:路径执行调度任务的数量
|
|
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)
|
|
{
|
|
double a = 0;
|
|
if (double.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
|
{
|
|
route.Add(Convert.ToDouble(dv2[0]["ManCount"]));//路径使用频率
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径使用频率
|
|
}
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径使用频率
|
|
}
|
|
//路径设备任务数
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)
|
|
{
|
|
double a = 0;
|
|
if (double.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
|
{
|
|
route.Add(Convert.ToDouble(dv2[0]["mtask"]));//路径设备任务数
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径设备任务数
|
|
}
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径设备任务数
|
|
}
|
|
|
|
//求最短路径((路径步长*0.3+路径使用频率*0.3+设备占有数*0.3)的最小值)
|
|
if (minroute.Count == 0)
|
|
{
|
|
minroute.Add(route[0]);
|
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
|
}
|
|
else
|
|
{
|
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3))
|
|
{
|
|
minroute[0] = route[0];
|
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
|
}
|
|
}
|
|
}
|
|
if (minroute.Count > 0)
|
|
{
|
|
return Convert.ToInt32(minroute[0]);
|
|
}
|
|
else
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "起点设备:" + startdevice + "和终点设备:" + enddevice + "之间路径不可用!");
|
|
OnRefreshMonitor(rme);
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.MinRouteID时发生错误:" +ex.StackTrace+ ex.Message;
|
|
return -1;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv1.Dispose();
|
|
dv2.Dispose();
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 20100702
|
|
/// 根据调度任务的起点和终点设备索引查找路径最短的RouteIDSub
|
|
/// </summary>
|
|
/// <param name="startdevice">起点设备索引</param>
|
|
/// <param name="enddevice">终点设备索引</param>
|
|
/// <param name="useAwayfork">是否使用远货叉</param>
|
|
/// <returns></returns>
|
|
public static int MinRouteID(int startdevice, int enddevice, object useAwayfork)
|
|
{
|
|
//20101124
|
|
DataView dv = new DataView(); DataView dvd = new DataView();
|
|
DataView dv1 = new DataView(); DataView dv2 = new DataView();
|
|
StringBuilder dff = new StringBuilder();
|
|
if (useAwayfork.ToString() == "-")
|
|
{
|
|
dff.Append( "F_UseAwayFork<>'n'");
|
|
}
|
|
else
|
|
{
|
|
dff .Append( "(F_UseAwayFork='" ).Append( useAwayfork).Append( "' or F_UseAwayFork='-' )");//20101028
|
|
}
|
|
#region 工位堆垛机的路径优选20120207
|
|
//过桥输送机的选择是临近取货位优先
|
|
//35000双顶升机的选择是小列(1排6列;2排26列)选择顶升机32038
|
|
|
|
//if (startdevice == 35000 && (enddevice == 32025 || enddevice == 10100 || enddevice == 10200 || enddevice == 10300))
|
|
//{
|
|
|
|
// dff.Append(" and T_Base_Route_Device.F_DeviceIndex=32038");
|
|
//}
|
|
//else
|
|
//{
|
|
|
|
//}
|
|
#endregion
|
|
//20101124
|
|
try
|
|
{
|
|
int retrouteidsub = GetSameStartDeviceEnddeviceRouteID(startdevice, enddevice);
|
|
if (retrouteidsub > 0)
|
|
{
|
|
return retrouteidsub;
|
|
}
|
|
//选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and ").Append(dff.ToString()).Append(" and F_Status=1 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
List<double> minroute = new List<double>();//0,routIDSub;1,路径最小值
|
|
if (dv.Count == 0)
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "起点设备:" + startdevice + "和终点设备:" + enddevice + "之间路径不可用!");
|
|
OnRefreshMonitor(rme);
|
|
return -1;
|
|
}
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_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) and F_DeviceOrder !=-1");//20180131
|
|
dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvd.Count > 0)
|
|
{
|
|
int dvin = Convert.ToInt32(dvd[0]["F_DeviceIndex"]);
|
|
//判读是否是checkforbiden设备,查看lanegate表
|
|
bool ifisforbiddendevice = GetChangeCheckForbiddenFromLaneGate(dvin);
|
|
//if ((dvin >= 35001 && dvin <= 35003) || (dvin == 45001))
|
|
if (ifisforbiddendevice)
|
|
{//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();
|
|
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)
|
|
//{
|
|
|
|
// return 0;
|
|
//}
|
|
//add for CATL YB2
|
|
int tasktype = Convert.ToInt32(drv["FCONTROLTASKTYPE"]);
|
|
|
|
//#endregion
|
|
//立库到化成B倒箔间任务每个巷道最多两个
|
|
// 辛化双深堆垛机拆分限制 对于双伸货位,当两个互斥货位同时存在出库任务时,要先拆分2,3排,后拆分1,4拍
|
|
// 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;
|
|
//test for bug
|
|
//if ((dvRoute.Count >= 10) && (((routeIDSub >= 54001) && (routeIDSub <= 76001)) || ((routeIDSub >= 240001) && (routeIDSub <= 263001))))
|
|
//{
|
|
// string dvRouteDeviceString = "";
|
|
// for (int i = 0; i < dvRoute.Count; i++)
|
|
// {
|
|
// dvRouteDeviceString = dvRouteDeviceString + dvRoute[i]["F_DeviceIndex"].ToString() + ";";
|
|
// }
|
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("CDisassembleTask", "拆分任务出现异常", ",fid" + ManFID.ToString(), ",routeidsub:" + routeIDSub.ToString().ToUpper() + ",dvRouteDeviceString:" + dvRouteDeviceString.ToString());
|
|
// return 0;
|
|
//}
|
|
for (int i = 0; i < dvRoute.Count; i++)
|
|
{
|
|
AheadDetect.Remove(0,AheadDetect.Length);
|
|
RunningLock.Remove(0,RunningLock.Length);
|
|
AheadTrigger.Remove(0,AheadTrigger.Length);
|
|
uncontrol= (dvRoute[i]["F_UnControl"] + "").ToString();
|
|
|
|
List<int> PriorDevice = new List<int>(), NextDevice = new List<int>(),
|
|
CurDevice = new List<int>(), NextKeyDevice = new List<int>();//0设备所引;1设备类型;2:路径序号;3:设备命令
|
|
//防止输送机设备组重复查找关键设备
|
|
if (Convert.ToInt32(dvRoute[i]["F_SerialNumber"]) <= CurSerialNumber) continue;
|
|
|
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceIndex"]));
|
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceKindIndex"]));
|
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_SerialNumber"]));
|
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceOrder"]));
|
|
//判断下一个关键设备 1 设备索引 2 设备类型 3、设备序号 4、设备命令
|
|
NextKeyDevice = GetNextKeyDevice(routeIDSub, Convert.ToInt32(dvRoute[i]["F_SerialNumber"]));
|
|
if (NextKeyDevice.Count > 0)//找到关键设备:0设备所引;1设备类型;2:路径序号;3:设备命令
|
|
{
|
|
|
|
CurSerialNumber = NextKeyDevice[2];
|
|
NextDevice = GetNextDevice(routeIDSub, NextKeyDevice[2]);
|
|
PriorDevice = GetPriorDevice(routeIDSub, NextKeyDevice[2]);
|
|
|
|
int TriggerTaskNo = 0;
|
|
int[] Coor = new int[6] { 0, 0, 0, 0, 0, 0 };
|
|
//20101118
|
|
string tw = string.Empty;
|
|
int mainTask = 0; int Rgvorder = 0;
|
|
int lifterUP=0,snextq = 0, snexts = 0;
|
|
int snextqtemp = 0, snextstemp = 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, Coor) == false)
|
|
{
|
|
|
|
#region 生成高端输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam,F_UseAwayFork)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(udev).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append("," + arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
#endregion
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 生成一个设备命令并且获得取送货坐标
|
|
string Uzxy = string.Empty;//20111020
|
|
StringBuilder GetGDDetect=new StringBuilder("");
|
|
StringBuilder SendGDDetect=new StringBuilder("");
|
|
int SendUdevConveyor = 0;
|
|
//堆垛机取货:
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
|
|
#region 插入高端U型线控制//20111020
|
|
if (Convert.ToInt32(drv["FSTARTUCODE"]) > 0 )
|
|
{//直接插入高端设备U型内部的送出指令
|
|
int arrowdev =0;
|
|
GetUAreaOutputDevice(NextKeyDevice[0],Convert.ToInt32(drv["FSTARTUCODE"]), out arrowdev, out Uzxy);
|
|
if (arrowdev > 0)
|
|
{
|
|
GetGDDetect.Clear();
|
|
GetGDDetect.Append("D-").Append(arrowdev).Append(".0;D-").Append(arrowdev).Append(".2");
|
|
CurDevice[3] = 6;
|
|
CurDevice[0] = Convert.ToInt32(drv["FSTARTCELL"]);
|
|
if (arrowdev != CurDevice[0])
|
|
{
|
|
int udev = Convert.ToInt32(drv["FSTARTUCODE"]);
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20101124
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
#endregion
|
|
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, udev, CurDevice[3], arrowdev, Coor) == 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( ";" );
|
|
}
|
|
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
|
|
{
|
|
int a = Convert.ToInt32(nextConveyor[0]);
|
|
if (a != 22221)
|
|
{
|
|
//209-12-33
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
|
}
|
|
if (a == 22221)
|
|
{
|
|
DataView uccsdxh = new DataView();
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FUseAwayFork from T_Manage_Task where FID = ").Append(ManFID).Append(" and FCONTROLTASKTYPE = 1");
|
|
uccsdxh = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (uccsdxh.Count > 0 )
|
|
{
|
|
if (Convert.ToInt32( uccsdxh[0]["FUseAwayFork"] )== 1)
|
|
{
|
|
AheadDetect.Append(";D").Append("22022.0").Append(";D").Append("22022.2").Append(";I").Append("22022");
|
|
}
|
|
else if (Convert.ToInt32( uccsdxh[0]["FUseAwayFork"] )== 2)
|
|
{
|
|
AheadDetect.Append(";D").Append("22021.0").Append(";D").Append("22021.2").Append(";I").Append("22021");
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Append(";D").Append("22022.0").Append(";D").Append("22022.2").Append(";I").Append("22022");
|
|
}
|
|
}
|
|
}
|
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
|
if (tw != "")
|
|
{//青岛思锐检测顶升地位
|
|
AheadDetect.Append(";D").Append(tw.ToString());
|
|
}
|
|
//青岛思锐第一节输送线送出检测.2开关
|
|
// tw = GetBindingDeviceIndexOut(CurDevice[0]); // CurDevice[3]
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(tw.ToString());
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
|
}
|
|
|
|
//青岛思锐入库检测第一节输送线.2开关是不是有货 检测近叉是不是有货 检测顶升是不是 在低位
|
|
#endregion
|
|
}
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
AheadTrigger .Append( PriorDevice[0].ToString()); //+ "-" + (被触发的调度任务号);//此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0, Coor) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append( "INSERT INTO T_Monitor_Task " ).Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," ).Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4," ).Append(
|
|
" F_AheadDetect,F_TxtParam,F_UseAwayFork)" ).Append(
|
|
"VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
|
).Append( "," ).Append( CurDevice[0] ).Append( "," ).Append( CurDevice[3] ).Append( "," ).Append( routeIDSub ).Append("," ).Append( status ).Append( "," ).Append( CurDevice[0] ).Append( "," + arrowdev
|
|
).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( drv["FUseAwayFork"] ).Append( "')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 前一设备是条码扫描器等,不载物的关键设备
|
|
|
|
if ((PriorDevice[1] == 7) || (PriorDevice[1] == 12))
|
|
{
|
|
int arrowdev;
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
PriorDevice = PriorDevice0;
|
|
//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(CurDevice[0]);
|
|
if (devinfo.UnControl != "1")
|
|
{
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20101124
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);//20101124
|
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (被触发的调度任务号);//此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0, Coor) == 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)
|
|
{
|
|
int lanegate = 0;
|
|
#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
|
|
if (int.TryParse(Convert.ToString(drv["FSTARTCELL"]), out lanegate))//是lanegate
|
|
{
|
|
Coor0_2 = GetStackCoordinateFromLaneGate(NextKeyDevice[0], lanegate, true);
|
|
}
|
|
else
|
|
{
|
|
Coor0_2 = GetStackCoordinateFromManage(Mankind, ManFID, true);
|
|
}
|
|
}
|
|
else if (PriorDevice[1] == 2 || PriorDevice[1] == 9)
|
|
{
|
|
//如果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)
|
|
{
|
|
int lanegate = 0;
|
|
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
|
|
if (int.TryParse(Convert.ToString(drv["FENDCELL"]), out lanegate))//是lanegate
|
|
{
|
|
Coor3_5 = GetStackCoordinateFromLaneGate(NextKeyDevice[0], lanegate, false);
|
|
}
|
|
else
|
|
{
|
|
Coor3_5 = GetStackCoordinateFromManage(Mankind, ManFID, false);
|
|
}
|
|
}
|
|
else if (NextDevice[1] == 2 || NextDevice[1] == 9)
|
|
{
|
|
//如果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 生成堆垛机指令:将取+取货+送货
|
|
|
|
#region 将取
|
|
//AheadDetect = "";
|
|
//if (NextDevice[1] == 2)
|
|
//{//将取时做送货做提前检测
|
|
// //20091107
|
|
// if (CStaticClass.OutDetectArrowIdleGoods == "1")
|
|
// {
|
|
// #region 运行提前检测光电组
|
|
|
|
|
|
// tw = GetBindingDeviceIndex(NextDevice[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect = tw.ToString() + ";" + GetBeDetectedDevices(NextDevice[0]);
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
// }
|
|
// tw = GetBindingDeviceIndexOut(NextDevice[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect = AheadDetect + ";" + tw.ToString();
|
|
// }
|
|
// ////20090803检测设备是否空闲idle
|
|
// AheadDetect += ";" + "I" + NextDevice[0].ToString();
|
|
// //20090918给堆垛机送货的输送机增加是否逻辑有物的判断
|
|
// AheadDetect += ";" + "N" + NextDevice[0].ToString();
|
|
// #endregion
|
|
// }
|
|
//}
|
|
//AheadDetect += ";" + GetBeDetectedDevices(NextKeyDevice[0]);
|
|
|
|
//#region 双叉堆垛机修改:列坐标和F_UseAwayFork
|
|
|
|
//int UseAwayFork = 1;//远货叉是主货叉
|
|
|
|
//devinfo = Model.CGetInfo.GetDeviceInfo(NextKeyDevice[0]);
|
|
//if (devinfo.IfCorrelDoubleFork == "1")
|
|
//{
|
|
// UseAwayFork = ccf.GetUseAwayFork(Coor[0], Coor[1], Coor[2], ccf.GetWAREHOUSEFromSTCELL(NextKeyDevice[0]), Mankind, ManFID, NextKeyDevice[0],2);
|
|
|
|
// }
|
|
//#endregion
|
|
|
|
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 2, 0) == false)
|
|
//{
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// sql = "INSERT INTO T_Monitor_Task " +
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," +
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," +
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect,F_UseAwayFork)" +
|
|
// "VALUES (" + ManFID + "," + Mankind + "," + mindex + "," + drv["FTASKLEVEL"]
|
|
// + "," + NextKeyDevice[0] + ",2," + routeIDSub + "," + status + "," + Coor[0] + "," + Coor[1]
|
|
// + "," + Coor[2] + "," + Coor[3] + "," + Coor[4] + "," + Coor[5] + ",'" + drv["FPALLETBARCODE"] + "','" + AheadDetect + "','"+UseAwayFork+"')";
|
|
// dbo.ExceSQL(sql);
|
|
|
|
// //更新最后一个输送机运行时的堆垛机将取的提前触发
|
|
// //格式:运行的设备索引+被触发的调度任务号
|
|
// if (AheadTrigger != null)
|
|
// {
|
|
// AheadTrigger = PriorDevice[0] + "-" + mindex;
|
|
// //此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
// dbo.ExceSQL("update T_Monitor_Task set F_AheadTrigger='" + AheadTrigger + "' where F_MonitorIndex=" + TriggerTaskNo);
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
#region 取货
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
if (PriorDevice[1] == 10)
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
int lanegate=0;
|
|
if (int.TryParse(Convert.ToString(drv["FSTARTCELL"]), out lanegate))
|
|
{
|
|
tw = GetBindingDeviceIndex(lanegate);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(tw.ToString());
|
|
}
|
|
}
|
|
}
|
|
RunningLock.Remove(0, RunningLock.Length);//20101124
|
|
//***堆垛机取货前一节设备是输送线
|
|
if (PriorDevice[1] == 2)
|
|
{//取货做提前检测
|
|
#region 运行时锁定设备组
|
|
RunningLock.Append(PriorDevice[0].ToString());//20101124
|
|
#endregion
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
#region add for CATL YB2 新增输送线允许不允许信号,前一节设备是输送线
|
|
//堆垛机取货允许不允许信号
|
|
string[] allowDevice = ccf.GetLanewayDeviceInfoFromSignal(NextKeyDevice[0], PriorDevice[0]);
|
|
if (allowDevice != null)
|
|
{
|
|
//输送线允许堆垛机
|
|
if (allowDevice[0] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(allowDevice[0]);
|
|
}
|
|
//堆垛机允许输送线
|
|
if (allowDevice[1] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(allowDevice[1]);
|
|
}
|
|
}
|
|
#endregion
|
|
#region add for CATL YB2 前一节是输送线的检测lange gate 表
|
|
//前一节设备是输送机检测lanegate表
|
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], PriorDevice[0]);
|
|
if (cdi != null)
|
|
{//顶升机构被堆垛机取货时检测在顶升高位,有货
|
|
if (cdi[1] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
|
}
|
|
|
|
if (cdi[3] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[3]);
|
|
}
|
|
// YB2双叉堆垛机叉对应的开关检测
|
|
if (cdi[5] != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[5]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString());
|
|
//AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
}
|
|
#endregion
|
|
//20090803检测设备是否空闲idle
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));//20180123更改位置
|
|
// AheadDetect.Append(";").Append("I").Append(PriorDevice[0].ToString());
|
|
//AheadDetect.Append(";R").Append(PriorDevice[0].ToString());//20140109
|
|
#endregion
|
|
}
|
|
//***堆垛机取货前一节设备是站台
|
|
else
|
|
if (PriorDevice[1] == 9)
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Append(GetGDDetect);
|
|
}
|
|
}
|
|
#region 下一节设备是输送机
|
|
// ****取货下一节设备为输送线
|
|
if (NextDevice[1] == 2)
|
|
{
|
|
//堆垛机取货允许不允许信号
|
|
string[] allowDevice = ccf.GetLanewayDeviceInfoFromSignal(NextKeyDevice[0], NextDevice[0]);
|
|
if (allowDevice != null)
|
|
{
|
|
//输送线允许堆垛机
|
|
if (allowDevice[0] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(allowDevice[0]);
|
|
}
|
|
//堆垛机允许输送线
|
|
if (allowDevice[1] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(allowDevice[1]);
|
|
}
|
|
}
|
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], NextDevice[0]);
|
|
if (cdi != null)
|
|
{///20120906检测被堆垛机送货的顶升机构在顶升高位,无物,近巷道5和远巷道6也无物
|
|
if (cdi[1] != "")
|
|
{
|
|
//CATL YB2,堆垛机取货 顶升要在高位
|
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
|
}
|
|
|
|
if (cdi[5] != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[5]);
|
|
}
|
|
if (cdi[6] != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[6]);
|
|
}
|
|
if (cdi[3] != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[3]);//检测是否有货
|
|
}
|
|
if (cdi[2] != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[2]);//检测是否有货
|
|
}
|
|
}
|
|
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
|
|
}
|
|
// 加锁字段 add for CATL YB2 取货锁双顶升
|
|
//AheadDetect.Append(";").Append("L").Append(NextDevice[0].ToString());
|
|
#region 注释
|
|
//20101124检测被堆垛机送货的输送机空闲
|
|
//AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString()).Append(";").Append("N").Append(NextDevice[0].ToString()).Append(";").Append("L").Append(NextDevice[0].ToString());//20160421
|
|
//AheadDetect.Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20180123
|
|
//20160421 .Append("I").Append(NextDevice[0].ToString()).Append(";")
|
|
// AheadDetect.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()); ;
|
|
//}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
else
|
|
if (NextDevice[1] == 9)
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextDevice[0]));
|
|
AheadDetect.Append(";").Append("N").Append(NextDevice[0].ToString());//20180522
|
|
}
|
|
else
|
|
if (NextDevice[1] == 10)
|
|
{
|
|
int lanegate = 0;
|
|
if (int.TryParse(Convert.ToString(drv["FENDCELL"]), out lanegate))//是lanegate 20180916
|
|
{
|
|
|
|
tw = GetBindingDeviceIndex(lanegate);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
AheadDetect.Append(";").Append("N").Append(lanegate.ToString());//20180522
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Append(";").Append(SendGDDetect);
|
|
}
|
|
#region 注释
|
|
//if (NextDevice.Count > 0)
|
|
//{
|
|
// devinfo = Model.CGetInfo.GetDeviceInfo(NextKeyDevice[0]);
|
|
// //if (devinfo.VirtualStack > 0)
|
|
// //{
|
|
// // //20120906
|
|
// if ((SendUdevConveyor > 0) )
|
|
// {
|
|
// AheadDetect.Append(";R").Append(SendUdevConveyor.ToString());
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Append(";R").Append(NextDevice[0].ToString());
|
|
// }
|
|
// //}
|
|
//}
|
|
#endregion
|
|
#region 安全门申请进入开关点
|
|
//增加安全门申请进入 .7 允许判断
|
|
int keydevice = NextKeyDevice[0];
|
|
if (NextKeyDevice[1] == 1)
|
|
{
|
|
tw = GetBindingDeviceIndexOut(keydevice);
|
|
if (tw != "")
|
|
{
|
|
// 申请进入时候开关电有
|
|
AheadDetect.Append(";D").Append(tw.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
if(CStaticClass.WorkStack!="0")//制定堆垛机 20180124
|
|
{
|
|
keydevice =Convert.ToInt32( CStaticClass.WorkStack);
|
|
}
|
|
//AheadDetect .Append( ";" ).Append( GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
|
AheadDetect .Append( ";" ).Append( GetBeDetectedDevices(keydevice));
|
|
#region 生成取货任务
|
|
//取货
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, keydevice, 4, 0, Coor) == false)
|
|
{
|
|
lifterUP = ccf.GetMonitorIndex(ManFID, Mankind);//升降机顶升
|
|
|
|
snextq = ccf.GetMonitorIndex(ManFID, Mankind);//用于后续追加的任务
|
|
snextqtemp = ccf.GetMonitorIndex(ManFID, Mankind);//用于后续二次追加的任务
|
|
|
|
snexts = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
snextstemp = ccf.GetMonitorIndex(ManFID, Mankind);//用于后续二次追加的任务
|
|
|
|
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_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(keydevice).Append(",4,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
|
).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",").Append(Coor[5])
|
|
.Append(",'").Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','").Append(drv["FPALLETBARCODE"])
|
|
.Append("','").Append(drv["FUseAwayFork"]).Append("',").Append(lifterUP).Append(",").Append(snextq).Append(",").Append(snexts).Append(")");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 将送
|
|
|
|
//if (NextDevice[1] == 10)
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
//}
|
|
//RunningLock = "";
|
|
//AheadDetect = GetBeDetectedDevices(NextKeyDevice[0]);
|
|
////将送
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 3, 0) == false)
|
|
//{
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// sql = "INSERT INTO T_Monitor_Task " +
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," +
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," +
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" +
|
|
// "VALUES (" + ManFID + "," + Mankind + "," + mindex + "," + drv["FTASKLEVEL"]
|
|
// + "," + NextKeyDevice[0] + ",3," + routeIDSub + "," + status + "," + Coor[0] + "," + Coor[1]
|
|
// + "," + Coor[2] + "," + Coor[3] + "," + Coor[4] + "," + Coor[5] + ",'" + drv["FPALLETBARCODE"] + "','" + AheadDetect + "')";
|
|
// dbo.ExceSQL(sql);
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 送货
|
|
|
|
|
|
RunningLock.Remove(0,RunningLock.Length);//20101124
|
|
AheadDetect.Remove(0,AheadDetect.Length);//20101124
|
|
if (NextDevice[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也无物
|
|
if (cdi[1] != "")
|
|
{
|
|
//宜宾2 送货顶升高位检测
|
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
|
}
|
|
// YB2 检测堆垛机送货时 是否有货
|
|
if (cdi[5] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[5]);
|
|
}
|
|
//南宁电力拣选出库 送出任务不检测 端头输送线
|
|
//if (cdi[6] != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(cdi[6]);
|
|
//}
|
|
if (cdi[3] != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[3]);//检测是否有货
|
|
}
|
|
}
|
|
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 != "")
|
|
{
|
|
// add for CATL YB2 送出時候检测下节输送线
|
|
AheadDetect.Append(";D").Append(tw.ToString());
|
|
//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(GetBeDetectedDevices(NextDevice[0]));//20180123
|
|
//堆垛机送货 YB2 出库修改.Append("I").Append(NextDevice[0].ToString()).Append(";")
|
|
//加锁字段 add for CATL YB2 送货锁双顶升 加锁重发有问题
|
|
//AheadDetect.Append(";").Append("L").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] == 9)
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextDevice[0]));
|
|
AheadDetect.Append(";").Append("N").Append(NextDevice[0].ToString());
|
|
}
|
|
else
|
|
// **** 下节设备为巷道
|
|
if (NextDevice[1] == 10)
|
|
{
|
|
int lanegate = 0;
|
|
if (int.TryParse(Convert.ToString(drv["FENDCELL"]), out lanegate))//是lanegate 20180916
|
|
{
|
|
if (lanegate != 120241 && lanegate != 120281)
|
|
{
|
|
tw = GetBindingDeviceIndex(lanegate);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());
|
|
AheadDetect.Append(";").Append("N").Append(lanegate.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Append(";").Append(SendGDDetect);
|
|
}
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(keydevice));//20101124
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(NextKeyDevice[0]);
|
|
//青岛思锐送货检测堆垛机上有没有货
|
|
if (devinfo.IfCorrelDoubleFork != "1")
|
|
{
|
|
AheadDetect.Append(";D-").Append(NextKeyDevice[0].ToString()).Append(".0");
|
|
}
|
|
else if (tasktype != 2)
|
|
{
|
|
// 双叉堆垛机送货时候检测对应开关是否有货
|
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], PriorDevice[0]);
|
|
if (cdi != null)
|
|
{
|
|
// YB2双叉堆垛机叉对应的开关检测 出库提前检测在发送前需要替换,入库不需要
|
|
if (cdi[5] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[5]);
|
|
}
|
|
}
|
|
}
|
|
#region 注释
|
|
//青岛思锐双叉堆垛机送出任务检测1叉还是2叉开关
|
|
//DataView ForkCount = new DataView();
|
|
//sql.Remove(0, sql.Length);
|
|
//sql.Append("SELECT FSTARTDEVICE from T_Manage_Task where FID = ").Append(ManFID).Append(" and FCONTROLTASKTYPE <> ").Append( 2 ).Append(" and FSTARTDEVICE is not null");
|
|
//ForkCount = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//if (devinfo.IfCorrelDoubleFork == "1")
|
|
//{
|
|
// if (ForkCount.Count > 0)
|
|
// {
|
|
// AheadDetect.Append(";D-").Append(NextKeyDevice[0].ToString()).Append(".1");
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Append(";D-").Append(NextKeyDevice[0].ToString()).Append(".0");
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// AheadDetect.Append(";D-").Append(NextKeyDevice[0].ToString()).Append(".0");
|
|
//}
|
|
#endregion
|
|
#region 安全门申请进入信号 有时 此条任务不发送
|
|
// 增加安全门申请进入 .7 允许判断
|
|
if (NextKeyDevice[1] == 1)
|
|
{
|
|
tw = GetBindingDeviceIndexOut(NextKeyDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
// 申请进入时候开关电有
|
|
AheadDetect.Append(";D").Append(tw.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
#region 送货任务生成
|
|
//送货
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, keydevice, 5, 0, Coor) == 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(keydevice).Append(",5,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
|
).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",")
|
|
.Append(Coor[5]).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','")
|
|
.Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("',").Append(lifterUP).Append(",").Append(snextq).Append(",").Append(snexts).Append(")");
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
#endregion
|
|
#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, Coor) == 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;
|
|
int laneway = 0;
|
|
if (dvs.Count > 0)
|
|
{
|
|
laneway = Convert.ToInt32(dvs[0]["F_LaneDeviceIndex"]);
|
|
}
|
|
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());
|
|
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检测被堆垛机送货的顶升机构在顶升高位,空闲
|
|
if (cdi[1] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
|
}
|
|
|
|
if (cdi[5] != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[5]);
|
|
}
|
|
if (cdi[6] != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[6]);
|
|
}
|
|
if (cdi[3] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[3]);//检测是否有货
|
|
}
|
|
AheadDetect.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, Coor) == 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, Coor) == 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
|
|
}
|
|
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]));
|
|
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, Coor) == 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 = 2; //GetRGVOrder(PriorDevice[0], true);
|
|
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
int senddevice = 0;//20181003
|
|
#region 目标输送机运行提前检测光电组
|
|
if (NextDevice.Count > 0)
|
|
{
|
|
senddevice = NextDevice[0];
|
|
//tw = GetSendOutDetect(NextDevice[0]);//目标输送机是否安全 20180303
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append(";D-").Append(tw.ToString());//20101118
|
|
//}
|
|
//else
|
|
//{
|
|
tw = GetBindingDeviceIndex(NextDevice[0]);//目标输送机入口无探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D").Append(tw.ToString());//20101124
|
|
}
|
|
//}
|
|
//20111215
|
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);//目标输送机出口无探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
|
|
//
|
|
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextDevice[0]));
|
|
//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 取货输送机运行提前检测光电组
|
|
|
|
//GetLanewayDeviceInfoFromSignal
|
|
//允许不允许信号
|
|
string[] allowDevice = ccf.GetLanewayDeviceInfoFromSignal( NextKeyDevice[0],PriorDevice[0]);
|
|
if (allowDevice != null)
|
|
{
|
|
//穿梭车允许输送线
|
|
if (allowDevice[2] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(allowDevice[2]);
|
|
}
|
|
//输送线允许穿梭车
|
|
if (allowDevice[3] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(allowDevice[3]);
|
|
}
|
|
}
|
|
tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(tw.ToString());
|
|
}
|
|
|
|
tw = GetBindingDeviceIndex(PriorDevice[0]);//判断输送机是否允许RGV取货
|
|
if (tw != "")
|
|
{
|
|
if (PriorDevice[0] != 12007 && PriorDevice[0] != 12009 && PriorDevice[0] != 12011)
|
|
{
|
|
AheadDetect.Append(";D-").Append(tw.ToString());//20180303
|
|
}
|
|
|
|
}
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
|
//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, Coor) == 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(senddevice).Append(",0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");//20181003
|
|
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 = 3;// GetRGVOrder(NextDevice[0], false);
|
|
|
|
|
|
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
//tw = GetSendOutDetect(NextDevice[0]);//目标输送机是否安全 20180303
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append(";D-").Append(tw.ToString());
|
|
//}
|
|
//else
|
|
//{
|
|
tw = GetBindingDeviceIndex(NextDevice[0]);//目标输送机入口无探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D").Append(tw.ToString());//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
//}
|
|
//20111215
|
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);//目标输送机出口无探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
|
|
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextDevice[0]));
|
|
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
|
|
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], Rgvorder, 0, Coor) == 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, Coor) == 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
|
|
//青岛思锐 qdsr qdsr qdsr AGV取货 判断取货站台 .2有货
|
|
AheadDetect.Append(";D-").Append(station).Append(".0").Append(";I").Append(station.ToString());
|
|
#region 增加检测顶升是否在低位20100710
|
|
//AheadDetect .Append( ";D-" ).Append( PriorDevice[0].ToString() ).Append( ".2");
|
|
#endregion
|
|
}
|
|
else
|
|
//AGV的送出站台检测
|
|
if (PriorDevice[1] == 9)//20170710
|
|
{
|
|
tw = GetSendOutDetect(PriorDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(tw.ToString());//20101118
|
|
}
|
|
|
|
}
|
|
|
|
if (NextDevice.Count > 0)
|
|
{
|
|
station = Coor[4];
|
|
}
|
|
AheadDetect.Append(";C").Append(NextKeyDevice[0]);//20170710 判断AGV控制台是否连接
|
|
|
|
|
|
#region AGV 拆分插入取货小任务
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0, Coor) == false)//出库搬运指令对申请出库无影响,暂不发送 20170914
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
|
mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
|
sql.Remove(0, sql.Length);
|
|
sql .Append( "INSERT INTO T_Monitor_Task " ).Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," ).Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," ).Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork)" ).Append(
|
|
"VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
|
).Append( "," ).Append( NextKeyDevice[0] ).Append( ",").Append(agvorder).Append("," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
|
).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" )
|
|
.Append( AheadDetect.ToString() ).Append( "','" ).Append( RunningLock.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( drv["FUseAwayFork"] ).Append( "')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
#region AGV送货
|
|
|
|
if (NextDevice.Count > 0)
|
|
{
|
|
#region AGV 送货注释
|
|
//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,Coor) == 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());
|
|
//}
|
|
#endregion
|
|
agvorder = 3;//AGV送货
|
|
RunningLock.Remove(0, RunningLock.Length);
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
#region qdsr AGV送货检测 用不上
|
|
//if (NextDevice.Count > 0)
|
|
//{
|
|
// if (NextDevice[1] == 2)
|
|
// {//20100714
|
|
// AheadDetect.Append(";D").Append(GetBindingDeviceIndex(NextDevice[0]).ToString()).Append(";I").Append(NextDevice[0].ToString());
|
|
|
|
// }
|
|
// else if (NextDevice[1] == 11)
|
|
// {
|
|
// AheadDetect.Append(";D").Append(Coor[4]).Append(".0").Append(";I").Append(Coor[4]);
|
|
// }
|
|
|
|
//}
|
|
#endregion
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0,Coor) == 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检测被堆垛机送货的顶升机构在顶升高位,空闲
|
|
if (cdi[1] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
|
}
|
|
if (cdi[3] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[3]);
|
|
}
|
|
AheadDetect.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, Coor) == 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, Coor) == 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, Coor) == 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, Coor) == 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")
|
|
{
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
}
|
|
int arrowdev;
|
|
if (CurDevice[0] == PriorDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
//arrowdev = 0;
|
|
arrowdev = CurDevice[0];
|
|
#region 运行提前检测光电组
|
|
//20101011
|
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
|
if (null != cdi && (CurDevice[3] == 2 || CurDevice[3] == 6))
|
|
{//20100406检测被堆垛机送货的顶升机构在顶升高位,空闲
|
|
//磊哥原版
|
|
//if (cdi[1] != "")
|
|
//{
|
|
// AheadDetect.Append(";D-").Append(cdi[1]);
|
|
//}
|
|
|
|
//if (cdi[5] != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(cdi[5]);
|
|
//}
|
|
//if (cdi[6] != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(cdi[6]);
|
|
//}
|
|
//if (cdi[3] != "")
|
|
//{
|
|
// AheadDetect.Append(";D-").Append(cdi[3]);//检测是否有货
|
|
//}
|
|
//AheadDetect.Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
if (CurDevice[3] == 2)
|
|
{
|
|
if (cdi[3] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[3]);//检测是否有货
|
|
}
|
|
}
|
|
if (CurDevice[3] == 6)
|
|
{
|
|
if (cdi[5] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[5]);//检测是否有货
|
|
}
|
|
}
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
//20101011
|
|
else
|
|
{
|
|
if (CurDevice[3] == 1)
|
|
{
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect .Append( ";D" ).Append( tw.ToString());//20101118
|
|
}
|
|
}
|
|
else if ((CurDevice[3] == 2) )//20110510反转
|
|
{
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = PriorDevice[0];
|
|
CurDevice[3] = 6;
|
|
#region 运行提前检测光电组
|
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
|
if (null != cdi)
|
|
{
|
|
if (cdi[1] != "")
|
|
{
|
|
// CATL YB2 输送线送出 时检测顶升在高位,电气根据任务让顶升落低位
|
|
AheadDetect.Append(";D-").Append(cdi[1]);
|
|
|
|
}
|
|
if (cdi[2] != "")
|
|
{
|
|
AheadDetect.Append(cdi[2]);
|
|
}
|
|
//if (cdi[5] != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(cdi[5]);
|
|
//}
|
|
if (cdi[6] != "")
|
|
{
|
|
//YB2 顶升对应的输送线送出有货检测
|
|
AheadDetect.Append(";D-").Append(cdi[6]);
|
|
}
|
|
if (cdi[3] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[3]);//检测是否有货
|
|
}
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20091107
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
}
|
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
|
if (nextConveyor.Count > 0)//20110331
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0, Coor) == 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, Coor) == 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, Coor) == 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;
|
|
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的不能超过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等待执行的不能超过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>
|
|
/// 特殊任务需要控制任务数量,不进行拆分,返回值true就不拆分 双伸任务
|
|
/// </summary>
|
|
/// <param name="drv"></param>
|
|
/// <returns></returns>
|
|
public static bool ControlTaskAmountUnDisassemble(DataRowView drv)
|
|
{//20121203
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
string FSTARTDEVICE = Convert.ToString(drv["FSTARTDEVICE"]) ;
|
|
string FSTARTCELL = Convert.ToString(drv["FSTARTCELL"]);
|
|
int freach = 1;
|
|
string sqlstr=string.Empty;
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_ForkAmount,F_Reach from T_Base_StackInfo where F_LaneNo like '%{0}%'", FSTARTDEVICE)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
freach = Convert.ToInt32(dv[0]["F_Reach"]);
|
|
}
|
|
if (freach == 2)
|
|
{
|
|
string[] zxy = FSTARTCELL.Split('-');//获得任务坐标
|
|
if (zxy.Length > 2)
|
|
{
|
|
int getZ = Convert.ToInt32(zxy[0]);//取货的排坐标
|
|
int newZ;
|
|
int tempZ = getZ;
|
|
//山东辛化特殊双伸
|
|
if (tempZ > 4)
|
|
{
|
|
//tempZ = getZ % 4;
|
|
tempZ = getZ % 3;
|
|
if (tempZ == 2)
|
|
{
|
|
//山东辛化这是单排不判断
|
|
tempZ = 6;
|
|
}
|
|
else if (tempZ == 0)
|
|
{
|
|
tempZ = 3;
|
|
}
|
|
else
|
|
{
|
|
tempZ = 4;
|
|
}
|
|
}
|
|
if (tempZ == 1 || tempZ == 4)//里位取货时,要判读是否有外位的取货任务
|
|
{//获取外位坐标
|
|
if (tempZ == 1)
|
|
{
|
|
newZ = getZ + 1;
|
|
}
|
|
else
|
|
{
|
|
newZ = getZ - 1;
|
|
}
|
|
string neighborzxy = string.Format("{0:D2}-{1:D2}-{2:D2}", newZ, zxy[1], zxy[2]);//获得外位坐标
|
|
sqlstr = string.Format("SELECT FID FROM T_Manage_Task WHERE (FSTATUS = 0) AND(FSTARTDEVICE = {0}) AND (FSTARTCELL = '{1}') ", FSTARTDEVICE, neighborzxy);
|
|
dv = dbo.ExceSQL(sqlstr).Tables[0].DefaultView;
|
|
if (dv.Count > 0)//
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "拆分任务时,ControlTaskAmountUnDisassemble:" + ex.Message;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查找路径运行方向的反方向的最近的设备,返回值:索引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>
|
|
/// 获得巷道的出入口处设备对应的堆垛机坐标取排-列-层(Z-X-Y);送排-列-层(Z-X-Y)
|
|
/// </summary>
|
|
/// <param name="devIndex">设备索引</param>
|
|
/// <param name="ifGet">是否取货</param>
|
|
/// <returns></returns>
|
|
static int[] GetStackCoordinateFromLaneGate(int stackIndex,int devIndex,bool ifGet)
|
|
{
|
|
char[] cc = new char[1] { '-' };//20100305
|
|
string[] split;
|
|
int[] rt = new int[6] { 0,0,0,0,0,0};
|
|
DataView dv = new DataView();
|
|
int LaneWay = ccf.GetLaneWayFromLaneInfo(stackIndex);
|
|
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
//sql.Append("select * from T_Base_Lane_Gate where F_LaneGateDeviceIndex=" ).Append( devIndex ).Append( " and F_LaneIndex=").Append(LaneWay);
|
|
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="devIndex"></param>
|
|
/// <returns></returns>
|
|
static bool GetChangeCheckForbiddenFromLaneGate( int devIndex )
|
|
{
|
|
|
|
DataView dv = new DataView();
|
|
|
|
string sqlstr = string.Empty;
|
|
try
|
|
{
|
|
sqlstr = string.Format("SELECT F_ChangeCheckForbidden FROM T_Base_Lane_Gate where F_ChangeCheckForbidden={0} ", devIndex);//在lanegate表中查找需要判断的lanegate
|
|
dv = dbo.ExceSQL(sqlstr).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
|
|
return true;
|
|
}
|
|
|
|
sqlstr = string.Format("SELECT F_ChangeCheckForbidden FROM T_Base_RGV_Gate WHERE F_ChangeCheckForbidden={0}", devIndex);//在lanegate表中查找需要判断的lanegate
|
|
dv = dbo.ExceSQL(sqlstr).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.GetChangeCheckForbiddenFromLaneGate:" + ex.StackTrace + ex.Message;
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
|
|
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>
|
|
/// 获得输送机设备的出库口探物光电的设备索引值
|
|
/// </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,int [] coor)
|
|
{
|
|
DataView dv = new DataView();
|
|
string sqlstr = string.Empty;
|
|
try
|
|
{
|
|
if (Order == -1) return true;
|
|
sql.Remove(0, sql.Length);
|
|
switch (ccf.GetDeviceKindIdx(DeviceIndex))
|
|
{
|
|
case 1://堆垛机
|
|
sqlstr = string.Format(" AND F_NumParam1={0} AND F_NumParam2={1} AND F_NumParam3={2} AND F_NumParam4={3} AND F_NumParam5={4} AND F_NumParam6={5}",
|
|
coor[0],coor[1],coor[2],coor[3],coor[4],coor[5]);
|
|
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(sqlstr).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();
|
|
}
|
|
|
|
}
|
|
//关联任务 kkkkkkkkkkkkkkkkkk
|
|
|
|
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>
|
|
/// 找到一个双叉最合适货位,修改关联关系 配置双叉 找最近原则 //修改双叉配对ab货物
|
|
/// add for CATL YB2 出库任务在拆分任务时候进行一次配对,在次配对是在任务发送时 没有配对成功的任务不在进行自关联 ,关联任务
|
|
/// ID仍然为-1 双叉配对不出在及现货位(极限货位未确定) 并且保证奇偶配对
|
|
/// </summary>
|
|
/// <param name="dr"></param>
|
|
public static void GetOutDoubleForkTask(DataRowView dr)
|
|
{ //sqlser的 SUBSTRING(express1,1开始,2);C#的.Substring(0开始, 2)
|
|
DataView dv = new DataView();
|
|
DataView sr = new DataView();
|
|
DataView srcount = new DataView();
|
|
try
|
|
{
|
|
// 出库任务数量限制,不能关联出库任务 如果出库任务数+1超过了出库任务数限制 不允许进行拆分配对 add for CATLYB6 注释
|
|
//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["FCONTROLTASKTYPE"].ToString() != "2")
|
|
//{
|
|
if (dr["F_RELATIVECONTORLID"].ToString() != "-1") return;
|
|
//}
|
|
int forwlimitX = 0, backlimitX = 0;
|
|
sql.Remove(0, sql.Length);
|
|
//FLANEWAY 是巷道
|
|
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();
|
|
//FSTACK 是几号堆垛机 通过堆垛机查询出对应堆垛机的货叉数量
|
|
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;
|
|
|
|
////青岛思锐分配双叉堆垛机单双叉出库 判断获取前几条任务
|
|
|
|
//sql.Clear();
|
|
////查询所有本巷道没拆分的管理下达的出库任务
|
|
//sql.Append("SELECT * FROM T_Manage_Task WHERE FLANEWAY = ").Append(dr["FLANEWAY"]).Append(" and FIntoStepOK = '0' and FSTATUS = 0 and FUseAwayFork <> '3' and FCONTROLTASKTYPE = 2 and F_RELATIVECONTORLID = - 1 and F_ManageTaskKindIndex= 1 ");
|
|
//srcount = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
|
|
StringBuilder sqladd = new StringBuilder(" ");
|
|
//前极限列 T_Base_LaneInfo 里 这里只能配两个 如果出现多个,直接用语句写死在程序里
|
|
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(" ");
|
|
}
|
|
//列的速度是层的速度的3倍,所以层的差值要乘以三(提升一层的时间相当于移动三列的时间)
|
|
sql.Remove(0, sql.Length);
|
|
if (CStaticClass.DBFactory == "OracleDBFactory")
|
|
{
|
|
// add for CATL YB2 双叉堆垛机配对逻辑 不同终点位置 同巷道也可配对双叉
|
|
//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(")").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");
|
|
|
|
//.Append(") AND ( FLOGIC_AREA is null or FLOGIC_AREA = '").Append(dr["FLOGIC_AREA"]) FLOGIC_AREA,
|
|
|
|
// 不同终点的按照任务号优先,相邻奇偶组合 优先 不同终点位置也可以配对双叉
|
|
sql.Append("SELECT * FROM (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 ").Append(
|
|
"(FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = ").Append(dr["FCONTROLTASKTYPE"]).Append(
|
|
") AND (FCONTORL_BATCH is null or 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 ) WHERE ROWNUM <=").Append(forkamount).Append("ORDER BY ROWNUM ASC");
|
|
}
|
|
else
|
|
{
|
|
#region qdsr特殊配对原则
|
|
//20151120调度系统SQLServer的特殊语句 配叉选货位的语句kkkkkkkkkkkkkkkkkkk
|
|
//F_GOODMatchID 管理关联任务ID 查询当前任务ID的 的管理关联ID
|
|
//判断关联任务ID 当前.Append(" FLANEWAY = ").Append(dr["FLANEWAY"])
|
|
//sql.Append("SELECT F_GOODMatchID FROM T_Manage_Task WHERE FID = ").Append(Convert.ToInt32(dr["FID"])).Append(" and F_GOODMatchID is not ").Append(" NULL ").Append( "and F_GOODMatchID <> ").Append( -1 );
|
|
//sr = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//// F_GOODMatchID 管理关联任务ID 不为空 且 控制任务类型是出库的 两种情况第一种是正常双叉出库 第二种是双叉堆垛机单叉出库
|
|
//if ( Convert.ToInt32(dr["FCONTROLTASKTYPE"]) == 2 )
|
|
//{
|
|
// if (sr.Count > 0)
|
|
// {
|
|
// //青岛思锐新的配对原则 查询本巷道前两条任务的FID 让他俩配对
|
|
// // select top (2) F_ManageTaskKindIndex, FID from T_Manage_Task where FLANEWAY = 18003 and FIntoStepOK = '0' and FSTATUS = 0 and FUseAwayFork <> '3' and FCONTROLTASKTYPE = 2 and F_RELATIVECONTORLID = - 1 and F_ManageTaskKindIndex= 1 and FID <> 1
|
|
// // GROUP BY F_ManageTaskKindIndex, FID order by FID asc
|
|
// //青岛思锐按任务号小的配双叉 kkkkkkkkkkkk GGGGGGGGGGGGG 查任务号不相等的
|
|
// sql.Clear();
|
|
// sql.Append("SELECT TOP ").Append(forkamount).Append(" F_ManageTaskKindIndex, FID FROM T_Manage_Task WHERE (FIntoStepOK = '0') AND ").Append(
|
|
// "(FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = ").Append("2 )").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) ").Append("and F_ManageTaskKindIndex= 1").Append(" and FID <> ").Append(dr["fid"]).Append(" and F_GOODMatchID <> ").Append(-1).Append(" GROUP BY F_ManageTaskKindIndex, FID order by FID asc");
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// //没有关联任务号的配对双叉 没有关联任务为-1
|
|
// // sql.Clear();
|
|
// // sql.Append("SELECT TOP ").Append(forkamount).Append(" F_ManageTaskKindIndex, FID FROM T_Manage_Task WHERE (FIntoStepOK = '0') AND ").Append(
|
|
// // "(FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = ").Append("2 )").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) ").Append("and F_ManageTaskKindIndex= 1").Append(" and FID <> ").Append(dr["fid"]).Append(" and F_GOODMatchID = ").Append( -1 ).Append(" GROUP BY F_ManageTaskKindIndex, FID order by FID asc");
|
|
// //}
|
|
// //关联任务不存在就按原来配对原则配对外加一个关联任务字段等于-1
|
|
|
|
// sql.Clear();
|
|
// 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(" and F_GOODMatchID = ").Append(-1).Append(" GROUP BY F_ManageTaskKindIndex, FID order by Expr1 asc");
|
|
|
|
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
#endregion
|
|
//正常配对原则 GGGGGGGGGGGGGGGGGGGGGGGG
|
|
//例句
|
|
//SELECT TOP 1 F_ManageTaskKindIndex, FID, MIN(POWER(FStartCol - 0, 2) + POWER((FStartLayer - 0) * 3, 2)) AS Expr1 FROM T_Manage_Task WHERE (FIntoStepOK = '0')
|
|
//AND (FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = 2) AND (FLOGIC_AREA = '18005') AND (FCONTORL_BATCH = '')
|
|
//AND (FLANEWAY = 18003) AND (F_RELATIVECONTORLID = - 1)
|
|
//and F_ManageTaskKindIndex=2 and FID<>12090 GROUP BY F_ManageTaskKindIndex, FID order by Expr1 asc
|
|
sql.Clear();
|
|
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;
|
|
//把当前ID赋值给两个管理大任务 这个for循环是赋值与本条管理大任务关联的 任务的关联ID
|
|
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());
|
|
}
|
|
// add for CATL YB2 双叉配对关联修改关联任务ID 时候 只有真正配对的才允许修改关联任务ID ,不允许自关联
|
|
// 这种情况就是在拆分任务后还是保证关联任务ID为 -1 可以在发送任务时候在进行一次关联任务配对
|
|
if (dv.Count>=1)
|
|
{
|
|
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("拆分任务时,判断是否存在同一逻辑区域且不同批号的出库任务:{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();
|
|
}
|
|
}
|
|
/*
|
|
* 方法名:GetSameStartDeviceEnddeviceRouteID
|
|
*
|
|
* 方法功能:判断是不是有相同起点和终点设备的路径,如果有返回返回值
|
|
* 参数介绍:
|
|
* 返 回 值:F_routeIDSub
|
|
* 完成日期:
|
|
* 维护人员:
|
|
* 维护日期:
|
|
* 维护原因:
|
|
*
|
|
*/
|
|
static int GetSameStartDeviceEnddeviceRouteID(int startdevice, int enddevice)
|
|
{
|
|
DataView dv=new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
//去重查询出T_Base_Route_Device表里的F_routeIDSub 字段 从T_Base_Device,T_Base_Route_Device,T_Base_Route 这几个表
|
|
//条件是Route_Device 表里的DeviceIndex 是不是 Base_Devie 表里的 设备 并且Route_Device 表里的开始设备和终点设备是不是相同
|
|
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();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
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"]);
|
|
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
catch (Exception eiad)
|
|
{
|
|
|
|
return false;
|
|
throw eiad;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|