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.
6962 lines
408 KiB
6962 lines
408 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;
|
|
using System.Linq;
|
|
|
|
namespace WcfControlMonitorLib
|
|
{
|
|
/// <summary>
|
|
/// Creator:Richard.liu
|
|
/// 任务拆分类
|
|
/// 选取调度任务时以保障设备利用率最大化为原则:1、每个路径端头的入库站台要有一个任务;
|
|
/// 2、每个堆垛机要有一个任务(以优先方式决定先执行哪种任务);
|
|
/// 3、组合优先方式时,在调度任务完成时调整已拆分任务优先级为最高级9,进行优先执行。
|
|
///
|
|
/// 把调度任务分解成多个监控搬运任务
|
|
/// 分解原则:把一个调度任务按照出入库路径的设备索引排出多个步骤的设备指令
|
|
/// </summary>
|
|
|
|
|
|
//20091107增加对五个调度策略SelectTask_ManPRI();SelectTask_OnlyIn();SelectTask_InSubjoinOut();
|
|
//SelectTask_OnlyOut();SelectTask_OutSubjoinIn();的优先级相同时根据下达时间的升序执行order by FTASKLEVEL desc,FBEGTIME asc
|
|
|
|
public static class CDisassembleTask
|
|
{
|
|
public static event CDataSourceChangeEventHandler DataChange;
|
|
public static void OnDataChange(object sender, CDataChangeEventArgs e)
|
|
{
|
|
if (DataChange != null)
|
|
{
|
|
DataChange(sender, e);
|
|
}
|
|
}
|
|
public static event RefreshMonitorEventHandler RefreshMonitor;
|
|
public static void OnRefreshMonitor(RefreshMonitorEventArgs e)
|
|
{
|
|
if (RefreshMonitor != null)
|
|
{
|
|
RefreshMonitor(e);
|
|
}
|
|
}
|
|
static string stackUcode = "35000,35001,35002,35003,45001";
|
|
static StringBuilder sql = new StringBuilder();
|
|
static Thread mythread;
|
|
static bool exitThread = false;//20091107
|
|
private static void BeginListen()
|
|
{//20091107
|
|
while (!exitThread)
|
|
{
|
|
try
|
|
{
|
|
MyTaskIntoSteps();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
public static void EndListen()
|
|
{//20091107
|
|
exitThread = true;
|
|
|
|
if (mythread != null)
|
|
{
|
|
|
|
dbo.Close();
|
|
|
|
mythread.Abort();
|
|
mythread = null;
|
|
}
|
|
}
|
|
public static void StartListen()
|
|
{
|
|
exitThread = false;
|
|
mythread = new Thread(new ThreadStart(BeginListen));
|
|
mythread.IsBackground = true;
|
|
mythread.Start();
|
|
}
|
|
static string _DisassembleTaskError = "";
|
|
public static string DisassembleTaskError
|
|
{
|
|
get { return _DisassembleTaskError; }
|
|
set
|
|
{
|
|
_DisassembleTaskError = value;
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", DisassembleTaskError);
|
|
OnRefreshMonitor(rme);
|
|
}
|
|
}
|
|
static DBOperator dbo = new DBOperator();//20130926
|
|
static DBOperator dboM = CStaticClass.dboM; //20130510
|
|
static CCommonFunction ccf = new CCommonFunction();
|
|
|
|
static Model.MDevice devinfo;
|
|
|
|
/// <summary>
|
|
/// 拆分调度任务,不包括手工任务(直接生成存入调度T_Monitor_Task表)
|
|
/// </summary>
|
|
public static void MyTaskIntoSteps()
|
|
{
|
|
try
|
|
{
|
|
int Pri = ccf.SelectTaskPriPrecept();
|
|
switch (Pri)
|
|
{
|
|
case 0://按照调度任务优先级
|
|
SelectTask_ManPRI();
|
|
break;
|
|
case 1://单纯入库优先
|
|
SelectTask_OnlyIn();
|
|
break;
|
|
case 12://入库优先携带附带运行条件的出库任务
|
|
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;
|
|
}
|
|
//判断设备是否被锁定
|
|
//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
|
|
int level = Convert.ToInt32(dv[0]["FTASKLEVEL"]) == 100 ? 100 : 9;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1',FTASKLEVEL=").Append(level).Append(" where FID=").Append(dv[0]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[0]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update dbo.T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
|
dv[0]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dv[0]["FID"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20100323
|
|
//20101028增加出库关联
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
CreateRelativeMonitor(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[0]["FID"]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{//20091014
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
//20130710sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(
|
|
// ") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
|
sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE FROM T_Manage_Task WHERE (FSTACK = ")
|
|
.Append(dvM[i]["F_StackIndex"]).Append(") AND (FSTATUS = 0) AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') GROUP BY F_ManageTaskKindIndex,FENDDEVICE,FTASKLEVEL,FSTARTDEVICE,FSTACK, FUseAwayFork,FENDUCODE ORDER BY FTASKLEVEL DESC");
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)//挑选此堆垛机的出库任务
|
|
{
|
|
//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();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 出库优先附带符合运行条件的入库任务
|
|
/// 具体实现:在收到出库任务的完成时,挑选一个可以执行的入库任务把优先级设成最高9
|
|
/// </summary>
|
|
static void SelectTask_OutSubjoinIn()
|
|
{
|
|
DataView dvM = new DataView();
|
|
DataView dv = new DataView();
|
|
DataView dv112 = new DataView();
|
|
DataView dv0 = new DataView();
|
|
DataView dv1 = new DataView();
|
|
try
|
|
{
|
|
Model.MDevice deviceInfo;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_StackIndex FROM T_Base_StackInfo");
|
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
int routeid = -1;
|
|
for (int i = 0; i < dvM.Count; i++)
|
|
{//20090928
|
|
#region 首先选择此堆垛机所有入库任务,判断那个能执行
|
|
//if (Convert.ToInt32(dvM[i]["F_StackIndex"])==11003)
|
|
//{
|
|
// string kk = "";
|
|
//}
|
|
//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
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update dbo.T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
|
dv[0]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dv[0]["FID"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20100323
|
|
//20101028增加出库关联
|
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[0]["FSTACK"]));
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
CreateRelativeMonitor(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[0]["FID"]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
//20130710sql.Append("SELECT * FROM T_Manage_Task WHERE (FSTACK = ").Append(dvM[i]["F_StackIndex"]).Append(
|
|
// ") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') order by FTASKLEVEL desc,FBEGTIME asc");
|
|
sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE FROM T_Manage_Task WHERE (FSTACK = ")
|
|
.Append(dvM[i]["F_StackIndex"]).Append(") AND (FSTATUS = 0) AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') GROUP BY F_ManageTaskKindIndex,FENDDEVICE,FTASKLEVEL,FSTARTDEVICE,FSTACK, FUseAwayFork,FENDUCODE ORDER BY FTASKLEVEL DESC");
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)//挑选此堆垛机的出库任务
|
|
{
|
|
|
|
//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");
|
|
|
|
}//20141201张磊发现先拆分的出库有问题无法携带,只执行入库任务,不执行出库
|
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv112.Count > 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
|
if (routeid == -1)
|
|
{
|
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
|
{//20091107
|
|
GetUsableDestination(dv[j]);
|
|
}
|
|
continue;
|
|
}
|
|
//20101028增加出库关联
|
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
GetOutDoubleForkTask(dv[j]);
|
|
}
|
|
}
|
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
|
{
|
|
//分解完成,修改T_Manage_Task表FIntoStepOK=1
|
|
int level = Convert.ToInt32(dv[j]["FTASKLEVEL"]) == 100 ? 100 : 9;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1',FTASKLEVEL=").Append(level).Append(" where FID=").Append(dv[j]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
|
dv[j]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dv[j]["FID"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20100323
|
|
//20101028增加出库关联
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select * from T_Manage_Task WHERE (FSTACK = ").Append(
|
|
dvM[i]["F_StackIndex"]).Append(") AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '1') AND (FStatus = 0)");
|
|
DataView dvv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int aa = 0; aa < dvv.Count; aa++)
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FTASKLEVEL=9 WHERE (FTASKLEVEL<>100) and F_ManageTASKKINDINDEX=").Append(
|
|
dvv[aa]["F_ManageTaskKindIndex"]).Append(" and FID=").Append(dvv[aa]["FID"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=9 where F_MonitorTaskLevel<>100 and F_ManageTASKKINDINDEX=").Append(
|
|
dvv[aa]["F_ManageTaskKindIndex"]).Append(" and F_ManageTaskIndex=").Append(dvv[aa]["FID"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
//20091005
|
|
else
|
|
{
|
|
|
|
//首先选择此堆垛机一个出库任务
|
|
#region 首先选择此堆垛机一个出库任务
|
|
|
|
//判断堆垛机是否有调度命令在执行或者被锁定
|
|
//20130620
|
|
sql.Remove(0, sql.Length);
|
|
|
|
sql.Append("SELECT F_ManageTASKKINDINDEX, F_DeviceIndex, F_Status FROM T_Monitor_Task").Append(
|
|
" where F_DeviceIndex=").Append(dvM[i]["F_StackIndex"]).Append(" and F_Status>0 ");
|
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
continue;
|
|
}
|
|
//被锁定20130620
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_DeviceIndex, F_LockedState FROM T_Base_Device where F_DeviceIndex=").Append(dvM[i]["F_StackIndex"]).Append(" and (F_LockedState>0 or F_ManTaskReserve>0)");
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
continue;
|
|
}
|
|
sql.Remove(0, sql.Length);
|
|
//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");
|
|
sql.Append("SELECT MIN(FID) AS FID,FTASKLEVEL,F_ManageTaskKindIndex, FENDDEVICE, FSTARTDEVICE, FSTACK, FUseAwayFork,FENDUCODE FROM T_Manage_Task WHERE (FSTACK = ")
|
|
.Append(dvM[i]["F_StackIndex"]).Append(") AND (FSTATUS = 0) AND (FCONTROLTASKTYPE = 2) AND (FIntoStepOK = '0') GROUP BY F_ManageTaskKindIndex,FENDDEVICE,FTASKLEVEL,FSTARTDEVICE,FSTACK, FUseAwayFork,FENDUCODE ORDER BY FTASKLEVEL DESC");
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int j = 0; j < dv.Count; j++)
|
|
//有这个堆垛机的出库任务等待拆分
|
|
{
|
|
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");
|
|
|
|
}
|
|
dv112 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv112.Count > 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
|
|
|
|
|
|
//选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
routeid = MinRouteID(Convert.ToInt32(dv[j]["FSTARTDEVICE"]), Convert.ToInt32(dv[j]["FENDDEVICE"]), dv[j]["FUseAwayFork"]);
|
|
if (routeid == -1)
|
|
{
|
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
|
{//20091107
|
|
GetUsableDestination(dv[j]);
|
|
}
|
|
continue;
|
|
}
|
|
//20101028增加出库关联
|
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dv[j]["FSTACK"]));
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
GetOutDoubleForkTask(dv[j]);
|
|
}
|
|
}
|
|
if (CreateMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]), routeid, dv[j], 0) > 0)
|
|
{
|
|
//分解完成,修改T_Manage_Task表FIntoStepOK=1
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dv[j]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dv[j]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20100323
|
|
//20101028增加出库关联
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
CreateRelativeMonitor(Convert.ToInt32(dv[j]["F_ManageTaskKindIndex"]), Convert.ToInt32(dv[j]["FID"]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
}
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT * FROM T_Manage_Task WHERE ((FSTACK <= 0) or (FCONTROLTASKTYPE=3)) AND (FIntoStepOK = '0') order by FTASKLEVEL desc, FCONTROLTASKTYPE asc,FBEGTIME asc");
|
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int i = 0; i < dvM.Count; i++)//挑选没有堆垛机参与的任务
|
|
{
|
|
//选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
routeid = MinRouteID(Convert.ToInt32(dvM[i]["FSTARTDEVICE"]), Convert.ToInt32(dvM[i]["FENDDEVICE"]), dvM[i]["FUseAwayFork"]);
|
|
if (routeid == -1)
|
|
{
|
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
|
{//20091107
|
|
GetUsableDestination(dvM[i]);
|
|
}
|
|
continue;
|
|
}
|
|
#region 202410 HSCP - 双伸双叉巷道移库关联
|
|
if (dvM[i]["FCONTROLTASKTYPE"].ToString() == "3")
|
|
{
|
|
deviceInfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(dvM[i]["FSTACK"]));
|
|
if (deviceInfo != null)
|
|
{
|
|
if (deviceInfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
GetInLaneDoubleForkTask(dvM[i]);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
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
|
|
{
|
|
//add for TJBS BUG
|
|
//int retrouteidsub = GetSameStartDeviceEnddeviceRouteID(startdevice, enddevice);
|
|
//if (retrouteidsub > 0)
|
|
//{
|
|
// return retrouteidsub;
|
|
//}
|
|
////选择最短调度路径并且判断此路径上是否有设备发生故障
|
|
////add for TJBS 路径不通也拆分
|
|
// if ("18001,12060,12064,12066,12070,12078,12074,12080,12109,12112,12115,12119,12126,12123".Contains(startdevice.ToString()) &&
|
|
// "12059,12062,12063,12065,12068,12069,12072,12077,12073,12075,12079,12091".Contains(enddevice.ToString()))
|
|
//{
|
|
// 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());
|
|
//}else
|
|
//{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device, T_Base_Route_Device, T_Base_Route")
|
|
.Append(" 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 order by F_RouteIDSub asc");
|
|
//}
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
List<double> minroute = new List<double>();//0,routIDSub;1,路径最小值
|
|
//if (dv.Count == 0 && !"18001,12060,12064,12066,12070,12078,12074,12080,12109,12112,12115,12119,12126,12123".Contains(enddevice.ToString())
|
|
// && "12059,12062,12063,12065,12068,12069,12072,12077,12073,12075,12079,12091".Contains(enddevice.ToString()))
|
|
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 && !"18001,12060,12064,12066,12070,12078,12074,12080,12109,12112,12115,12119,12126,12123".Contains(startdevice.ToString())
|
|
// && "12059,12062,12063,12065,12068,12069,12072,12077,12073,12075,12079,12091".Contains(enddevice.ToString()))
|
|
if (dvd.Count > 0)
|
|
{
|
|
int dvin = Convert.ToInt32(dvd[0]["F_DeviceIndex"]);
|
|
if ((dvin >= 35001 && dvin <= 35003) || (dvin == 45001))
|
|
{//20120207机器人地位无法取代,不判断是否被禁用
|
|
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
List<double> route = new List<double>();//0,routIDSub;1,步长;2,路径使用频率;3,路径设备任务数
|
|
//路径步长(设备总数)最短(权重0.3),路径使用频率最小(权重0.3)的路径,路径设备任务数(权重0.3)
|
|
|
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
|
).Append(dv[i]["F_RouteIDSub"]);
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//步长
|
|
//route.Add(0);
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
//路径使用频率:路径执行调度任务的数量
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)
|
|
{
|
|
double a = 0;
|
|
if (double.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
|
{
|
|
route.Add(a);//路径使用频率
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径使用频率
|
|
}
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径使用频率
|
|
}
|
|
//路径设备任务数
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_deviceindex = T_Base_Route_Device.F_deviceindex) and (T_Monitor_Task.F_RouteID = T_Base_Route_Device.F_RouteIDSub) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)
|
|
{
|
|
double a = 0;
|
|
if (double.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
|
{
|
|
route.Add(a);//路径设备任务数
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径设备任务数
|
|
}
|
|
}
|
|
else
|
|
{
|
|
route.Add(0);//路径设备任务数
|
|
}
|
|
|
|
//求最短路径((路径步长*0.3+路径使用频率*0.3+设备占有数*0.3)的最小值)
|
|
if (minroute.Count == 0)
|
|
{
|
|
minroute.Add(route[0]);
|
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
|
}
|
|
else
|
|
{
|
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3))
|
|
{
|
|
minroute[0] = route[0];
|
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
|
}
|
|
}
|
|
}
|
|
if (minroute.Count > 0)
|
|
{
|
|
return Convert.ToInt32(minroute[0]);
|
|
}
|
|
else
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "起点设备:" + startdevice + "和终点设备:" + enddevice + "之间路径不可用!");
|
|
OnRefreshMonitor(rme);
|
|
return -1;
|
|
}
|
|
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_RouteIDSub"]);
|
|
}
|
|
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
|
|
if (ccf.GetMonitorIndex(ManFID, Mankind) >= 29000)
|
|
{
|
|
|
|
ccf.UpdateMonitorIndex(1);
|
|
}
|
|
|
|
#region TJBS,如果是移库任务,检测移库任务的次数,如果次数大于阈值,移库至检定货位
|
|
bool bReivse = false;
|
|
//if (drv["FCONTROLTASKTYPE"].ToString() == "3")
|
|
//{
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("SELECT * FROM T_Change_Times WHERE F_BarCode = '").Append(drv["FPALLETBARCODE"].ToString()).Append("'");
|
|
// dvs = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
// if (dvs.Count > 0)
|
|
// {
|
|
// int iTimes = Convert.ToInt16(dvs[0]["F_Times"].ToString());
|
|
// int TimesMaxCounts = Convert.ToInt32(CommonClassLib.AppSettings.GetValue("ChangeTimes"));
|
|
// if (iTimes >= TimesMaxCounts)
|
|
// {
|
|
// bReivse = true;
|
|
// }
|
|
// else
|
|
// {
|
|
// bReivse = false;
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
if (ControlTaskAmountUnDisassemble(drv) == true) return 0;
|
|
|
|
#region TJBS
|
|
//Model.MDevice devinfoTJBS;
|
|
//devinfoTJBS = Model.CGetInfo.GetDeviceInfo(11001);
|
|
//if (devinfoTJBS.RunState !=4)
|
|
//{
|
|
// //1号堆垛机被禁用时候 2号可以取9列
|
|
// #region add for TJBS 拆分任务时 判断当前任务是否为 1巷道的堆垛机倒车任务
|
|
// /* add for TJBS 18001 倒堆垛机,实现拆分任务选 02小路径视图
|
|
// * 跟电气沟通 预留后12列, 后12列入库需要倒库
|
|
// * 判断当前任务的起点和终点是不是 12018 或者 12041
|
|
// * 实际对应的是两条路径 路径中倒货的站台 是用了 虚拟站台12223 如果需要适配多货位,可以在发送时候替换
|
|
// */
|
|
// bool boolFlag = false;
|
|
// bool boolChoseFlag = false;
|
|
// if ("12017,12041".Contains(drv["FSTARTDEVICE"].ToString()) || "12017,12041".Contains(drv["FENDDEVICE"].ToString())
|
|
// )
|
|
// {
|
|
// if ((!string.IsNullOrEmpty(drv["FENDCELL"].ToString()) || !string.IsNullOrEmpty(drv["FSTARTCELL"].ToString())) &&
|
|
// (drv["FENDCELL"].ToString().Length > 1 || drv["FSTARTCELL"].ToString().Length > 1))
|
|
// {
|
|
// boolFlag = true;
|
|
// boolChoseFlag = true;
|
|
// }
|
|
|
|
// }
|
|
// if (boolChoseFlag)
|
|
// {
|
|
// switch (Convert.ToInt32(drv["FCONTROLTASKTYPE"]))
|
|
// {
|
|
// //入库 判断终点位置
|
|
// case 1:
|
|
// //102
|
|
// if (Convert.ToInt32(drv["FENDCELL"].ToString().Substring(4, 3)) >= 99 && boolFlag && ("1,2").Contains(Convert.ToInt32(drv["FENDCELL"].ToString().Substring(0, 3)).ToString()))
|
|
// {
|
|
// routeIDSub += 1;
|
|
// CCarryConvert.WriteDarkCasket("**Cdisassembletask**", "**拆分的RouteID为:", routeIDSub.ToString(), "***堆垛机倒车任务");
|
|
// }
|
|
// break;
|
|
// //出库 判断起点位置
|
|
// case 2:
|
|
// //102
|
|
// if (Convert.ToInt32(drv["FSTARTCELL"].ToString().Substring(4, 3)) >= 99 && boolFlag && ("1,2").Contains(Convert.ToInt32(drv["FSTARTCELL"].ToString().Substring(0, 3)).ToString()))
|
|
// {
|
|
// routeIDSub += 1;
|
|
// CCarryConvert.WriteDarkCasket("**Cdisassembletask**", "**拆分的RouteID为:", routeIDSub.ToString(), "***堆垛机倒车任务");
|
|
// }
|
|
// break;
|
|
// }
|
|
|
|
// }
|
|
// #endregion
|
|
// #region add for TJBS 13号门 倒库
|
|
|
|
// if (Convert.ToInt32(drv["FCONTROLTASKTYPE"]) != 4)
|
|
// {
|
|
|
|
// if (drv["FSTARTCELL"].ToString().Length >5)
|
|
// {
|
|
// if (Convert.ToInt32(drv["FSTARTCELL"].ToString().Substring(0, 3)) < 3)
|
|
// {
|
|
// bool boolChoseFlag13 = false;
|
|
// //13号门入库货位列小于10 就用堆垛机倒叉
|
|
// if (("12080".Contains(drv["FSTARTDEVICE"].ToString()) && Convert.ToInt32(drv["FENDCELL"].ToString().Substring(4, 3)) < 13) || ("12091".Contains(drv["FENDDEVICE"].ToString()) && Convert.ToInt32(drv["FSTARTCELL"].ToString().Substring(4, 3)) < 13)
|
|
// || ("12079".Contains(drv["FENDDEVICE"].ToString()) && Convert.ToInt32(drv["FSTARTCELL"].ToString().Substring(4, 3)) < 13))
|
|
// {
|
|
// if ((!string.IsNullOrEmpty(drv["FENDCELL"].ToString()) || !string.IsNullOrEmpty(drv["FSTARTCELL"].ToString())) &&
|
|
// (drv["FENDCELL"].ToString().Length > 1 || drv["FSTARTCELL"].ToString().Length > 1))
|
|
// {
|
|
// boolChoseFlag13 = true;
|
|
// }
|
|
|
|
// }
|
|
// if (boolChoseFlag13)
|
|
// {
|
|
// routeIDSub += 1;
|
|
// CCarryConvert.WriteDarkCasket("**Cdisassembletask**", "**拆分的RouteID为:", routeIDSub.ToString(), "***堆垛机倒车任务");
|
|
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
|
|
// #endregion
|
|
|
|
// #region add for TJBS 6号门 倒库
|
|
|
|
// if (Convert.ToInt32(drv["FCONTROLTASKTYPE"]) != 4)
|
|
// {
|
|
// bool boolChoseFlag6 = false;
|
|
// //13号门入库货位列小于10 就用堆垛机倒叉 001-002-003
|
|
// if ( ("12075".Contains(drv["FENDDEVICE"].ToString()) && Convert.ToInt32(drv["FSTARTCELL"].ToString().Substring(4, 3))< 13&& Convert.ToInt32(drv["FSTARTCELL"].ToString().Substring(0, 3)) < 3))
|
|
// {
|
|
// if (!string.IsNullOrEmpty(drv["FSTARTCELL"].ToString()) && drv["FSTARTCELL"].ToString().Length > 1)
|
|
// {
|
|
// boolChoseFlag6= true;
|
|
// }
|
|
|
|
// }
|
|
// if (boolChoseFlag6)
|
|
// {
|
|
// routeIDSub += 1;
|
|
// CCarryConvert.WriteDarkCasket("**Cdisassembletask**", "**拆分的RouteID为:", routeIDSub.ToString(), "***堆垛机倒车任务");
|
|
|
|
// }
|
|
// }
|
|
|
|
// #endregion
|
|
|
|
//}
|
|
#endregion
|
|
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT T_Base_Route_Device.F_DeviceIndex,F_DeviceOrder, T_Base_Route_Device.F_SerialNumber, ").Append(
|
|
"T_Base_Device.F_DeviceKindIndex,F_UnControl FROM ").Append(
|
|
"T_Base_Device,T_Base_Route_Device where ").Append(
|
|
"T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_RouteIDSub=").Append(
|
|
routeIDSub + " order by F_SerialNumber asc ");
|
|
dvRoute = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvRoute.Count == 0) return 0;
|
|
dbo.TransBegin(IsolationLevel.ReadCommitted);
|
|
int CurSerialNumber = 0;
|
|
List<int> PriorDevice0 = new List<int>(), PriorKeyDevice0 = new List<int>();
|
|
StringBuilder AheadDetect = new StringBuilder();//20101124
|
|
StringBuilder RunningLock = new StringBuilder();//20101124
|
|
StringBuilder AheadTrigger = new StringBuilder();//20101124
|
|
string uncontrol = string.Empty;
|
|
for (int i = 0; i < dvRoute.Count; i++)
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
RunningLock.Remove(0, RunningLock.Length);
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
uncontrol = (dvRoute[i]["F_UnControl"] + "").ToString();
|
|
|
|
List<int> PriorDevice = new List<int>(), NextDevice = new List<int>(),
|
|
CurDevice = new List<int>(), NextKeyDevice = new List<int>();//0设备所引;1设备类型;2:路径序号;3:设备命令
|
|
//防止输送机设备组重复查找关键设备
|
|
if (Convert.ToInt32(dvRoute[i]["F_SerialNumber"]) <= CurSerialNumber) continue;
|
|
|
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceIndex"]));
|
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceKindIndex"]));
|
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_SerialNumber"]));
|
|
CurDevice.Add(Convert.ToInt32(dvRoute[i]["F_DeviceOrder"]));
|
|
NextKeyDevice = GetNextKeyDevice(routeIDSub, Convert.ToInt32(dvRoute[i]["F_SerialNumber"]));
|
|
if (NextKeyDevice.Count > 0)//找到关键设备:0设备所引;1设备类型;2:路径序号;3:设备命令
|
|
{
|
|
|
|
CurSerialNumber = NextKeyDevice[2];
|
|
NextDevice = GetNextDevice(routeIDSub, NextKeyDevice[2]);
|
|
PriorDevice = GetPriorDevice(routeIDSub, NextKeyDevice[2]);
|
|
|
|
int TriggerTaskNo = 0;
|
|
int[] Coor = new int[6] { 0, 0, 0, 0, 0, 0 };
|
|
//20101118
|
|
string tw = string.Empty;
|
|
int mainTask = 0; int Rgvorder = 0;
|
|
int lifterUP = 0, snextq = 0, snexts = 0;
|
|
switch (NextKeyDevice[1])
|
|
{
|
|
|
|
case 1:
|
|
#region 堆垛机
|
|
if (NextKeyDevice[3] == -1) continue;
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
#region 3、4楼的巷道的同一U型移库操作//20111020
|
|
if (NextDevice.Count > 0 && PriorDevice.Count > 0)
|
|
{
|
|
if (Convert.ToInt32(drv["FSTARTUCODE"]) > 0 && Convert.ToInt32(drv["FENDUCODE"]) == Convert.ToInt32(drv["FSTARTUCODE"]))
|
|
{//直接插入高端设备U型内部的送出指令
|
|
int arrowdev = Convert.ToInt32(drv["FENDCELL"]);
|
|
CurDevice[3] = 6;
|
|
CurDevice[0] = Convert.ToInt32(drv["FSTARTCELL"]);
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20101124
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
int udev = Convert.ToInt32(drv["FSTARTUCODE"]);
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, udev, CurDevice[3], arrowdev) == false)
|
|
{
|
|
|
|
#region 生成高端输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam,F_UseAwayFork)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(udev).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append("," + arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
#endregion
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 生成一个设备命令并且获得取送货坐标
|
|
string Uzxy = string.Empty;//20111020
|
|
StringBuilder GetGDDetect = new StringBuilder("");
|
|
StringBuilder SendGDDetect = new StringBuilder("");
|
|
int SendUdevConveyor = 0;
|
|
//堆垛机取货:
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
|
|
#region 插入高端U型线控制//20111020
|
|
if (Convert.ToInt32(drv["FSTARTUCODE"]) > 0)
|
|
{//直接插入高端设备U型内部的送出指令
|
|
int arrowdev = 0;
|
|
GetUAreaOutputDevice(NextKeyDevice[0], Convert.ToInt32(drv["FSTARTUCODE"]), out arrowdev, out Uzxy);
|
|
if (arrowdev > 0)
|
|
{
|
|
GetGDDetect.Clear();
|
|
GetGDDetect.Append("D-").Append(arrowdev).Append(".0;D-").Append(arrowdev).Append(".2");
|
|
CurDevice[3] = 6;
|
|
CurDevice[0] = Convert.ToInt32(drv["FSTARTCELL"]);
|
|
if (arrowdev != CurDevice[0])
|
|
{
|
|
int udev = Convert.ToInt32(drv["FSTARTUCODE"]);
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
#endregion
|
|
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, udev, CurDevice[3], arrowdev) == false)
|
|
{
|
|
|
|
#region 生成高端输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam,F_UseAwayFork)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(udev).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append("," + arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
//如果PriorDevice是输送机则生成输送机命令【CurDevice-->PriorDevice目标设备,出库:2】,
|
|
//收到输送机PriorDevice的PLC上报的运行状态则提前触发堆垛机将取命令,然后是取送货命令,获取堆垛机取坐标
|
|
#region 前一设备是输送机
|
|
if (uncontrol != "1")
|
|
{//20091107
|
|
if (PriorDevice[1] == 2)
|
|
{
|
|
int arrowdev;
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
|
|
}
|
|
|
|
if (CurDevice[0] == PriorDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20101118
|
|
//20101124
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20101118
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
}
|
|
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = PriorDevice[0];
|
|
CurDevice[3] = 6;
|
|
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20101124
|
|
//AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));
|
|
AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//TJBS
|
|
}
|
|
//else
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
//}
|
|
string twi = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (twi != "")
|
|
{//20101124
|
|
//AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));
|
|
AheadDetect.Append(";D-").Append(twi.ToString());//TJBS
|
|
}
|
|
|
|
|
|
string[] cdi = ccf.GetLanewayDeviceInfoFromDev(CurDevice[0]);//TJBS无两个巷道共享输送线所可以这么写,后续完善成通用代码
|
|
|
|
//rr[0] = dv[0]["F_LaneGateDeviceIndex"].ToString();
|
|
//rr[1] = dv[0]["F_HighDetect"].ToString();
|
|
//rr[2] = dv[0]["F_LowDetect"].ToString();
|
|
//rr[3] = dv[0]["F_HavingDetect"].ToString();
|
|
//rr[4] = dv[0]["F_RunDetect"].ToString();.4
|
|
//rr[5] = dv[0]["F_NearDetect"].ToString();
|
|
//rr[6] = dv[0]["F_FarDetect"].ToString();.3
|
|
//rr[7] = dv[0]["F_UseAwayFork"].ToString();
|
|
//rr[8] = dv[0]["F_CorrelDeviceIndex"].ToString();
|
|
//rr[9] = dv[0]["F_zxy"].ToString();
|
|
if (cdi != null)
|
|
{
|
|
if (cdi[6] != "")
|
|
{//移动设备允许输送线动作
|
|
AheadDetect.Append(";D-").Append(cdi[6]);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (被触发的调度任务号);//此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam,F_UseAwayFork)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append("," + arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 前一设备是条码扫描器等,不载物的关键设备
|
|
|
|
if ((PriorDevice[1] == 7) || (PriorDevice[1] == 12))
|
|
{
|
|
int arrowdev;
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
PriorDevice = PriorDevice0;
|
|
//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(CurDevice[0]);
|
|
if (devinfo.UnControl != "1")
|
|
{
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20101124
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);//20101124
|
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (被触发的调度任务号);//此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
sql.Remove(0, sql.Length);//20101124
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
//如果PriorDevice是固定站台不生成命令,堆垛机生成取送货命令,获取堆垛机取坐标
|
|
//如果PriorDevice是巷道,PriorDevice不拆分命令,获取堆垛机取坐标,拆分堆垛机命令取送货
|
|
#region 获得取送货坐标
|
|
|
|
|
|
int[] Coor0_2 = new int[6] { 0, 0, 0, 0, 0, 0 };
|
|
//如果NextDevice是巷道,NextDevice不拆分命令,获取堆垛机送坐标,拆分堆垛机命令取送货
|
|
if ((PriorDevice[1] == 7) || (PriorDevice[1] == 12))
|
|
{
|
|
PriorDevice = PriorDevice0;
|
|
}
|
|
if (PriorDevice[1] == 10)
|
|
{
|
|
#region 插入高端U型线控制//20111020
|
|
if ((Convert.ToInt32(drv["FSTARTUCODE"]) > 0) && (Uzxy != "-"))
|
|
{
|
|
char[] cc = new char[1] { '-' };
|
|
string[] sp = Uzxy.Split(cc);
|
|
for (int ip = 0; ip < sp.Length; ip++)
|
|
{
|
|
Coor0_2[ip] = Convert.ToInt32(sp[ip]);
|
|
}
|
|
}
|
|
#endregion
|
|
else
|
|
Coor0_2 = GetStackCoordinateFromManage(Mankind, ManFID, true);
|
|
}
|
|
else if (PriorDevice[1] == 2)
|
|
{
|
|
//如果NextDevice是输送机则取送货命令,获取堆垛机送坐标
|
|
|
|
//如果NextDevice是固定站台则取送货命令,获取堆垛机送坐标
|
|
Coor0_2 = GetStackCoordinateFromLaneGate(NextKeyDevice[0], PriorDevice[0], true);
|
|
}
|
|
|
|
Coor[0] = Coor0_2[0];
|
|
Coor[1] = Coor0_2[1];
|
|
Coor[2] = Coor0_2[2];
|
|
#endregion
|
|
}
|
|
|
|
//堆垛机送货:
|
|
if (NextDevice.Count > 0)
|
|
{
|
|
int[] Coor3_5 = new int[6] { 0, 0, 0, 0, 0, 0 };
|
|
//如果NextDevice是巷道,NextDevice不拆分命令,获取堆垛机送坐标,拆分堆垛机命令取送货
|
|
if (NextDevice[1] == 10)
|
|
{
|
|
|
|
if (Convert.ToInt32(drv["FENDUCODE"]) > 0)
|
|
{
|
|
#region 插入高端U型线控制//20111020
|
|
char[] cc = new char[1] { '-' }; int curdev = 0;
|
|
GetUAreaInputDevice(NextKeyDevice[0], Convert.ToInt32(drv["FENDUCODE"]), out curdev, out Uzxy);
|
|
if (curdev > 0)
|
|
{
|
|
SendUdevConveyor = curdev;
|
|
SendGDDetect.Clear();
|
|
SendGDDetect.Append("D").Append(curdev).Append(".0;D-").Append(curdev).Append(".2");
|
|
string[] sp = Uzxy.Split(cc);
|
|
for (int ip = 0; ip < sp.Length; ip++)
|
|
{
|
|
Coor3_5[3 + ip] = Convert.ToInt32(sp[ip]);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
else
|
|
{
|
|
Coor3_5 = GetStackCoordinateFromManage(Mankind, ManFID, false);
|
|
}
|
|
}
|
|
else if (NextDevice[1] == 2)
|
|
{
|
|
//如果NextDevice是输送机则取送货命令,获取堆垛机送坐标
|
|
|
|
//如果NextDevice是固定站台则取送货命令,获取堆垛机送坐标
|
|
Coor3_5 = GetStackCoordinateFromLaneGate(NextKeyDevice[0], NextDevice[0], false);
|
|
}
|
|
|
|
Coor[3] = Coor3_5[3];
|
|
Coor[4] = Coor3_5[4];
|
|
Coor[5] = Coor3_5[5];
|
|
}
|
|
#endregion
|
|
|
|
#region TJBS,如果需要校正,添加中间校正货位
|
|
|
|
//int[] MidCoor = new int[3] { 0, 0, 0 };
|
|
//if (bReivse)
|
|
//{
|
|
// int iWorkMode = Convert.ToInt16(drv["Work_Mode"]);
|
|
// string strReivse = String.Empty;
|
|
// if (iWorkMode == 1)
|
|
// {
|
|
// strReivse = CommonClassLib.AppSettings.GetValue("SmallResive");
|
|
|
|
// }
|
|
// else if (iWorkMode == 2)
|
|
// {
|
|
// strReivse = CommonClassLib.AppSettings.GetValue("BigResive");
|
|
// }
|
|
// string[] strsRevise = strReivse.Split('-');
|
|
// for (int j = 0; j < strsRevise.Length; j++)
|
|
// {
|
|
// //MidCoor[i] = Convert.ToInt32(strsRevise[i]);//bug
|
|
// MidCoor[j] = Convert.ToInt32(strsRevise[j]);
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 生成堆垛机指令:将取+取货+送货
|
|
|
|
#region 将取
|
|
//AheadDetect = "";
|
|
//if (NextDevice[1] == 2)
|
|
//{//将取时做送货做提前检测
|
|
// //20091107
|
|
// if (CStaticClass.OutDetectArrowIdleGoods == "1")
|
|
// {
|
|
// #region 运行提前检测光电组
|
|
|
|
|
|
// tw = GetBindingDeviceIndex(NextDevice[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect = tw.ToString() + ";" + GetBeDetectedDevices(NextDevice[0]);
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
// }
|
|
// tw = GetBindingDeviceIndexOut(NextDevice[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect = AheadDetect + ";" + tw.ToString();
|
|
// }
|
|
// ////20090803检测设备是否空闲idle
|
|
// AheadDetect += ";" + "I" + NextDevice[0].ToString();
|
|
// //20090918给堆垛机送货的输送机增加是否逻辑有物的判断
|
|
// AheadDetect += ";" + "N" + NextDevice[0].ToString();
|
|
// #endregion
|
|
// }
|
|
//}
|
|
//AheadDetect += ";" + GetBeDetectedDevices(NextKeyDevice[0]);
|
|
|
|
//#region 双叉堆垛机修改:列坐标和F_UseAwayFork
|
|
|
|
//int UseAwayFork = 1;//远货叉是主货叉
|
|
|
|
//devinfo = Model.CGetInfo.GetDeviceInfo(NextKeyDevice[0]);
|
|
//if (devinfo.IfCorrelDoubleFork == "1")
|
|
//{
|
|
// UseAwayFork = ccf.GetUseAwayFork(Coor[0], Coor[1], Coor[2], ccf.GetWAREHOUSEFromSTCELL(NextKeyDevice[0]), Mankind, ManFID, NextKeyDevice[0],2);
|
|
|
|
// }
|
|
//#endregion
|
|
|
|
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 2, 0) == false)
|
|
//{
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// sql = "INSERT INTO T_Monitor_Task " +
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," +
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," +
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect,F_UseAwayFork)" +
|
|
// "VALUES (" + ManFID + "," + Mankind + "," + mindex + "," + drv["FTASKLEVEL"]
|
|
// + "," + NextKeyDevice[0] + ",2," + routeIDSub + "," + status + "," + Coor[0] + "," + Coor[1]
|
|
// + "," + Coor[2] + "," + Coor[3] + "," + Coor[4] + "," + Coor[5] + ",'" + drv["FPALLETBARCODE"] + "','" + AheadDetect + "','"+UseAwayFork+"')";
|
|
// dbo.ExceSQL(sql);
|
|
|
|
// //更新最后一个输送机运行时的堆垛机将取的提前触发
|
|
// //格式:运行的设备索引+被触发的调度任务号
|
|
// if (AheadTrigger != null)
|
|
// {
|
|
// AheadTrigger = PriorDevice[0] + "-" + mindex;
|
|
// //此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
// dbo.ExceSQL("update T_Monitor_Task set F_AheadTrigger='" + AheadTrigger + "' where F_MonitorIndex=" + TriggerTaskNo);
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
#region 取货
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
if (PriorDevice[1] == 10)
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
RunningLock.Remove(0, RunningLock.Length);//20101124
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
if (PriorDevice[1] == 2)
|
|
{//取货做提前检测
|
|
#region 运行时锁定设备组
|
|
RunningLock.Append(PriorDevice[0].ToString());//20101124
|
|
//List<int> PriorDevice2 = GetPriorDevice(routeIDSub, PriorDevice[2]);
|
|
//if (PriorDevice2.Count > 0)
|
|
//{
|
|
// if (PriorDevice2[1] == 2)//保证两个输送机对接的第一个输送机也被锁定
|
|
// {
|
|
// RunningLock.Append(";").Append(PriorDevice2[0].ToString());//20101124
|
|
// }
|
|
|
|
//}
|
|
|
|
#endregion
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//20101011
|
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], PriorDevice[0]);
|
|
|
|
//rr[0] = dv[0]["F_LaneGateDeviceIndex"].ToString();
|
|
//rr[1] = dv[0]["F_HighDetect"].ToString();
|
|
//rr[2] = dv[0]["F_LowDetect"].ToString();
|
|
//rr[3] = dv[0]["F_HavingDetect"].ToString();
|
|
//rr[4] = dv[0]["F_RunDetect"].ToString();.4
|
|
//rr[5] = dv[0]["F_NearDetect"].ToString();
|
|
//rr[6] = dv[0]["F_FarDetect"].ToString();.3
|
|
//rr[7] = dv[0]["F_UseAwayFork"].ToString();
|
|
//rr[8] = dv[0]["F_CorrelDeviceIndex"].ToString();
|
|
//rr[9] = dv[0]["F_zxy"].ToString();
|
|
if (cdi != null)
|
|
{
|
|
if (cdi[3] != "")
|
|
{//取货位有货
|
|
AheadDetect.Append(";D-").Append(cdi[3]);
|
|
}
|
|
if (cdi[4] != "")
|
|
{//取货位输送线允许移动设备动作
|
|
AheadDetect.Append(";D-").Append(cdi[4]);
|
|
}
|
|
if (cdi[5] != "")
|
|
{//垛机无货
|
|
AheadDetect.Append(";D").Append(cdi[5]);
|
|
}
|
|
}
|
|
//20101011
|
|
//else
|
|
//{
|
|
// tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
|
// if (tw != "")
|
|
// {//20101118
|
|
// AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
// }
|
|
//}
|
|
|
|
|
|
//20090803检测设备是否空闲idle
|
|
AheadDetect.Append(";").Append("I").Append(PriorDevice[0].ToString());
|
|
//AheadDetect.Append(";R").Append(PriorDevice[0].ToString());//20140109
|
|
#endregion
|
|
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Append(GetGDDetect);
|
|
}
|
|
}
|
|
if (NextDevice.Count > 0)
|
|
{
|
|
if (NextDevice[1] == 2)//
|
|
{
|
|
//20101011
|
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], NextDevice[0]);
|
|
//rr[0] = dv[0]["F_LaneGateDeviceIndex"].ToString();
|
|
//rr[1] = dv[0]["F_HighDetect"].ToString();
|
|
//rr[2] = dv[0]["F_LowDetect"].ToString();
|
|
//rr[3] = dv[0]["F_HavingDetect"].ToString();
|
|
//rr[4] = dv[0]["F_RunDetect"].ToString();.4
|
|
//rr[5] = dv[0]["F_NearDetect"].ToString();
|
|
//rr[6] = dv[0]["F_FarDetect"].ToString(); .3
|
|
//rr[7] = dv[0]["F_UseAwayFork"].ToString();
|
|
//rr[8] = dv[0]["F_CorrelDeviceIndex"].ToString();
|
|
//rr[9] = dv[0]["F_zxy"].ToString();
|
|
if (cdi != null)
|
|
{
|
|
if (cdi[4] != "")//移动设备允许输送线动作
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[4]);
|
|
}
|
|
if (cdi[5] != "")//移动设备无货
|
|
{
|
|
AheadDetect.Append(";D").Append(cdi[5]);
|
|
}
|
|
}
|
|
//else
|
|
//{
|
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());
|
|
}
|
|
if (NextDevice[0] == 12223)
|
|
{
|
|
//add for TJBS 增加倒车时的R检测,R锁是在动作完成时候清的, 在任务发送的时候加的
|
|
AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString()).Append(";").Append("R").Append(NextDevice[0].ToString()).Append(";");//.Append("R").Append(NextDevice[0].ToString())
|
|
}
|
|
//PriorDevice[1]
|
|
if (PriorDevice[0] == 12223)
|
|
{
|
|
//add for TJBS 增加倒车时的R检测,R锁是在动作完成时候清的, 在任务发送的时候加的
|
|
AheadDetect.Append(";").Append("I").Append(PriorDevice[0].ToString()).Append(";").Append("R").Append(PriorDevice[0].ToString()).Append(";");//.Append("R").Append(NextDevice[0].ToString())
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Append(";").Append(SendGDDetect);
|
|
}
|
|
}
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));
|
|
#region 安全门申请进入开关点 add for TJBS
|
|
//增加安全门申请进入 .7 允许判断
|
|
int keydevice = NextKeyDevice[0];
|
|
if (NextKeyDevice[1] == 1)
|
|
{
|
|
tw = GetBindingDeviceIndexOut(keydevice);
|
|
if (tw != "")
|
|
{
|
|
// 申请进入时候开关电有
|
|
AheadDetect.Append(";D").Append(tw.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
//取货
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 4, 0) == false)
|
|
{
|
|
lifterUP = ccf.GetMonitorIndex(ManFID, Mankind);//升降机顶升
|
|
snextq = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
snexts = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
|
|
sql.Remove(0, sql.Length);//20101124
|
|
|
|
#region TJBS,如果需要校正,终止货位为校正货位
|
|
/*
|
|
if (bReivse)
|
|
{
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork,F_PriorMonitor,F_AgvTask,F_AGVNextTask)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",4,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
|
).Append(",").Append(Coor[2]).Append(",").Append(MidCoor[0]).Append(",").Append(MidCoor[1]).Append(",").Append(MidCoor[2])
|
|
.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());
|
|
|
|
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(NextKeyDevice[0]).Append(",5,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
|
).Append(",").Append(Coor[2]).Append(",").Append(MidCoor[0]).Append(",").Append(MidCoor[1]).Append(",").Append(MidCoor[2])
|
|
.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());
|
|
}
|
|
else
|
|
{
|
|
}
|
|
*/
|
|
|
|
#endregion
|
|
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork,F_PriorMonitor,F_AgvTask,F_AGVNextTask)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",4,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
|
).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",").Append(Coor[5])
|
|
.Append(",'").Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','").Append(drv["FPALLETBARCODE"])
|
|
.Append("','").Append(drv["FUseAwayFork"]).Append("',").Append(lifterUP).Append(",").Append(snextq).Append(",").Append(snexts).Append(")");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 将送
|
|
|
|
//if (NextDevice[1] == 10)
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
//}
|
|
//RunningLock = "";
|
|
//AheadDetect = GetBeDetectedDevices(NextKeyDevice[0]);
|
|
////将送
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 3, 0) == false)
|
|
//{
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// sql = "INSERT INTO T_Monitor_Task " +
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," +
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," +
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" +
|
|
// "VALUES (" + ManFID + "," + Mankind + "," + mindex + "," + drv["FTASKLEVEL"]
|
|
// + "," + NextKeyDevice[0] + ",3," + routeIDSub + "," + status + "," + Coor[0] + "," + Coor[1]
|
|
// + "," + Coor[2] + "," + Coor[3] + "," + Coor[4] + "," + Coor[5] + ",'" + drv["FPALLETBARCODE"] + "','" + AheadDetect + "')";
|
|
// dbo.ExceSQL(sql);
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 送货
|
|
|
|
|
|
RunningLock.Remove(0, RunningLock.Length);//20101124
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
if (NextDevice.Count > 0)
|
|
{
|
|
if (NextDevice[1] == 2)
|
|
{//送货做提前检测+运行时锁定
|
|
////20120405
|
|
//string r2 = "12002,42002,32002,12010,42010,32010,12018,42018,32018";
|
|
#region 运行时锁定设备组
|
|
|
|
//sql.Remove(0, sql.Length);//20101124
|
|
//sql.Append("SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate WHERE (F_LaneGateDeviceIndex =").Append(NextDevice[0]).Append(") AND (F_RunLock = '1')");
|
|
//DataView dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
////20101124
|
|
//if (dvlane.Count > 0)
|
|
//{
|
|
// RunningLock.Append(NextDevice[0].ToString());//20101124
|
|
// //20120405
|
|
// if (r2.IndexOf(NextDevice[0].ToString()) >= 0)
|
|
// {
|
|
// RunningLock.Append(NextDevice[0].ToString()).Append(";").Append((NextDevice[0] - 1).ToString());
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// RunningLock.Remove(0, RunningLock.Length);//20101124
|
|
//}
|
|
|
|
#endregion
|
|
#region 运行提前检测光电组
|
|
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//20101011
|
|
string[] cdi = ccf.GetLanewayDeviceInfoFromStackDev(NextKeyDevice[0], NextDevice[0]);
|
|
//rr[0] = dv[0]["F_LaneGateDeviceIndex"].ToString();
|
|
//rr[1] = dv[0]["F_HighDetect"].ToString();
|
|
//rr[2] = dv[0]["F_LowDetect"].ToString();
|
|
//rr[3] = dv[0]["F_HavingDetect"].ToString();
|
|
//rr[4] = dv[0]["F_RunDetect"].ToString();.4
|
|
//rr[5] = dv[0]["F_NearDetect"].ToString();
|
|
//rr[6] = dv[0]["F_FarDetect"].ToString();.3
|
|
//rr[7] = dv[0]["F_UseAwayFork"].ToString();
|
|
//rr[8] = dv[0]["F_CorrelDeviceIndex"].ToString();
|
|
//rr[9] = dv[0]["F_zxy"].ToString();
|
|
if (cdi != null)
|
|
{
|
|
if (cdi[5] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[5]);
|
|
}
|
|
if (cdi[4] != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(cdi[4]);
|
|
}
|
|
//if (cdi[6] != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(cdi[6]);
|
|
//}
|
|
}
|
|
//else
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
// tw = GetBindingDeviceIndexOut(NextDevice[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101124
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
// }
|
|
//}
|
|
tw = GetBindingDeviceIndex(NextDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString());//20101124
|
|
////20090918给堆垛机送货的输送机增加是否逻辑有物的判断
|
|
//AheadDetect.Append(";").Append("N").Append(NextDevice[0].ToString());//20101124
|
|
|
|
//20101124检测被堆垛机送货的输送机空闲
|
|
//if (NextDevice[0] == 12223)
|
|
//{
|
|
// //add for TJBS 增加倒车时的R检测,R锁是在动作完成时候清的, 在任务发送的时候加的
|
|
// AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString()).Append(";").Append("R").Append(NextDevice[0].ToString()).Append(";");//.Append("R").Append(NextDevice[0].ToString())
|
|
//}
|
|
//if (PriorDevice[0] == 12223)
|
|
//{
|
|
// //add for TJBS 增加倒车时的R检测,R锁是在动作完成时候清的, 在任务发送的时候加的
|
|
// AheadDetect.Append(";").Append("I").Append(PriorDevice[0].ToString()).Append(";").Append("R").Append(PriorDevice[0].ToString()).Append(";");//.Append("R").Append(NextDevice[0].ToString())
|
|
//}
|
|
// AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString()).Append(";").Append("N").Append(NextDevice[0].ToString());
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Append(";").Append(SendGDDetect);
|
|
}
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
|
#region 安全门申请进入信号 add for TJBS
|
|
// 增加安全门申请进入 .7 允许判断
|
|
if (NextKeyDevice[1] == 1)
|
|
{
|
|
tw = GetBindingDeviceIndexOut(NextKeyDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
// 申请进入时候开关电有
|
|
AheadDetect.Append(";D").Append(tw.ToString());
|
|
}
|
|
}
|
|
#endregion
|
|
#region TJBS,如果需要校正,生成从校正货位的取送
|
|
/*
|
|
if (bReivse)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);//20101124
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork,F_PriorMonitor,F_AGVTask,F_AGVNextTask)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",4,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(MidCoor[0]).Append(",").Append(MidCoor[1]
|
|
).Append(",").Append(MidCoor[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());
|
|
|
|
mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);//20101124
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork,F_PriorMonitor,F_AGVTask,F_AGVNextTask)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",5,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(MidCoor[0]).Append(",").Append(MidCoor[1]
|
|
).Append(",").Append(MidCoor[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());
|
|
}
|
|
else
|
|
{
|
|
}
|
|
*/
|
|
#endregion
|
|
//送货
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 5, 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);//20101124
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork,F_PriorMonitor,F_AGVTask,F_AGVNextTask)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",5,").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
|
).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",")
|
|
.Append(Coor[5]).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','")
|
|
.Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("',").Append(lifterUP).Append(",").Append(snextq).Append(",").Append(snexts).Append(")");
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20101124
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
#region 插入高端U型线控制//20111020
|
|
if (NextDevice.Count > 0 && Convert.ToInt32(drv["FENDUCODE"]) > 0)
|
|
{//直接插入高端设备U型内部的送出指令
|
|
int arrowdev = Convert.ToInt32(drv["FENDCELL"]);
|
|
CurDevice[3] = 6;
|
|
int curdev = 0; int udev = Convert.ToInt32(drv["FENDUCODE"]);
|
|
GetUAreaInputDevice(NextKeyDevice[0], Convert.ToInt32(drv["FENDUCODE"]), out curdev, out Uzxy);
|
|
if (curdev > 0)
|
|
{
|
|
CurDevice[0] = curdev;
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20101124
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, udev, CurDevice[3], arrowdev) == false)
|
|
{
|
|
|
|
#region 生成高端输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam,F_UseAwayFork)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(udev).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append("," + arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
//修改T_Manage_Task的FLANEWAY,FSTACK
|
|
sql.Remove(0, sql.Length);//20101124
|
|
sql.Append("SELECT F_LaneDeviceIndex,F_StackIndex FROM T_Base_LaneInfo where F_StackIndex=").Append(NextKeyDevice[0]);
|
|
dvs = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//20101124
|
|
int laneway = 0;
|
|
if (dvs.Count > 0)
|
|
{
|
|
laneway = Convert.ToInt32(dvs[0]["F_LaneDeviceIndex"]);
|
|
|
|
}//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FLANEWAY=").Append(laneway).Append(",FSTACK=").Append(NextKeyDevice[0]).Append(" where (FLANEWAY=-1) and (FSTACK=-1) and (F_ManageTaskKindIndex=").Append(Mankind).Append(") and FID=").Append(ManFID);
|
|
dbo.ExceSQL(sql.ToString());
|
|
//20101124
|
|
break;
|
|
|
|
#endregion
|
|
case 2://输送机(关键点:例如十字路口(有前一个和后一个设备)或者路径终点(没有后一个设备))
|
|
case 5:
|
|
#region 输送机
|
|
if (NextDevice.Count == 0)//终点输送机
|
|
{
|
|
if (uncontrol != "1")
|
|
{//20091107
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
}
|
|
int arrowdev;
|
|
if (CurDevice[0] == NextKeyDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
arrowdev = 0;
|
|
|
|
#region 运行提前检测光电组
|
|
if ((CurDevice[3] == 1) || ((CurDevice[3] == 2)))
|
|
{
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
}
|
|
|
|
}
|
|
//else if (CurDevice[3] == 2)
|
|
//{
|
|
// tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect = "D-" + tw.ToString() + ";" + GetBeDetectedDevices(CurDevice[0]);//20101118
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
// }
|
|
//}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = NextKeyDevice[0];
|
|
CurDevice[3] = 6;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
|
if (null != cdi)
|
|
{//20100406检测被堆垛机送货的顶升机构在顶升高位,空闲
|
|
AheadDetect.Append(";D-").Append(cdi[1]).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
//20101011
|
|
else
|
|
{
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
|
|
//List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
|
//if (nextConveyor.Count > 0)//20110331
|
|
//{
|
|
// AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
|
|
|
// tw = GetBindingDeviceIndex(nextConveyor[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
// }
|
|
// tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
// }
|
|
// ////20090803检测设备是否空闲idle
|
|
// //AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
|
//}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
else//20110104与AGV交互的顶升机或者路径十字路口
|
|
{
|
|
int arrowdev;
|
|
#region 前一设备是输送机
|
|
if (PriorDevice[1] == 2)
|
|
{
|
|
if (uncontrol != "1")
|
|
{//20091107
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
}
|
|
if (CurDevice[0] == PriorDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = PriorDevice[0];
|
|
CurDevice[3] = 6;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101124
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
|
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
|
if (nextConveyor.Count > 0)//20110331
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));//20110331
|
|
|
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
}
|
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
|
}
|
|
#endregion
|
|
}
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (被触发的调度任务号);//此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
RunningLock.Clear();//20120420
|
|
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
sql.Remove(0, sql.Length);//20101124
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam,F_RunningLock)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(RunningLock).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 顶升机前一输送机PriorDevice[0]空闲,有物:允许顶升机下降
|
|
//arrowdev = 0;
|
|
//#region 运行提前检测光电组
|
|
////CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
//AheadDetect.Remove(0, AheadDetect.Length);//20101124
|
|
|
|
//tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append(";D-").Append(tw.ToString());//20101124
|
|
//}
|
|
//AheadDetect.Append(";I").Append( PriorDevice[0].ToString());
|
|
//#endregion
|
|
//AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
|
//{
|
|
// #region 运行时锁定设备组
|
|
|
|
// #endregion
|
|
|
|
// #region 生成输送机命令
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// TriggerTaskNo = mindex;
|
|
// sql.Remove(0, sql.Length);//20101124
|
|
// sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
// " F_AheadDetect,F_TxtParam)").Append(
|
|
// "VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
// ).Append(",").Append(NextKeyDevice[0]).Append(",").Append(NextKeyDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(NextKeyDevice[0]).Append(",").Append(arrowdev
|
|
// ).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// #endregion
|
|
//}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
break;
|
|
case 4:
|
|
#region RGV
|
|
//RGV取货:
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
//如果PriorDevice是输送机则生成输送机命令【CurDevice-->PriorDevice目标设备,出库:2】,
|
|
//收到输送机PriorDevice的PLC上报的运行状态则提前触发RGV运行命令(7),然后是取送货命令,获取堆垛机取坐标
|
|
#region 前一设备是输送机
|
|
|
|
if (PriorDevice[1] == 2)
|
|
{
|
|
if ((uncontrol != "1") && (CurDevice[1] == 2 || CurDevice[1] == 5))
|
|
{//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) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
sql.Remove(0, sql.Length);//20101124
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{//20111020
|
|
List<int> newPrior = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newPrior != null)
|
|
{
|
|
PriorDevice = newPrior;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获得RGV运行的接货位的设备索引
|
|
Coor[0] = PriorDevice[0];
|
|
Coor[1] = 0;
|
|
Coor[2] = 0;
|
|
Coor[3] = 0;
|
|
Coor[4] = 0;
|
|
Coor[5] = 0;
|
|
#endregion
|
|
|
|
|
|
#region 生成RGV指令:7-运动(到目标设备索引)+(2-左接货3-左送货)或者(4-右接货5-右送货)
|
|
////20090625
|
|
//#region 运行提前检测光电组
|
|
//AheadDetect.Remove(0, AheadDetect.Length);
|
|
////20111215 ;
|
|
//tw = GetBindingDeviceIndex(NextDevice[0]);//目标输送机入口无探物,能运行
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101124
|
|
//}
|
|
//else
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
//}
|
|
////tw = GetBindingDeviceIndexOut(NextDevice[0]);//目标输送机出口无探物,能运行
|
|
////if (tw != "")
|
|
////{
|
|
//// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
////}
|
|
|
|
////20111215
|
|
//////20090803检测设备是否空闲idle
|
|
////AheadDetect .Append( ";" ).Append( "I" ).Append( NextDevice[0].ToString());//20101124
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect.Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101124
|
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101124
|
|
//}
|
|
//#endregion
|
|
|
|
////运动
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 2, Coor[0]) == false)
|
|
//{
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// sql.Remove(0, sql.Length);//20101124
|
|
// sql.Append("INSERT INTO T_Monitor_Task " ).Append(
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," ).Append(
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" ).Append(
|
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
|
// ).Append( "," ).Append( NextKeyDevice[0] ).Append( ",7," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
|
// ).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( AheadDetect.ToString()).Append( "')");
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// //20101124
|
|
// //更新最后一个输送机运行时的RGV运行的提前触发
|
|
// //格式:运行的设备索引+被触发的调度任务号
|
|
// if (AheadTrigger != null)
|
|
// {//20101124
|
|
// AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
// AheadTrigger .Append( PriorDevice[0] ).Append( "-" ).Append( mindex);
|
|
// //此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
// sql.Clear();
|
|
// sql.Append("update T_Monitor_Task set F_AheadTrigger='" ).Append( AheadTrigger ).Append( "' where F_MonitorIndex=" ).Append( TriggerTaskNo);
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// //20101124
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 输送机的送货
|
|
|
|
//#region 运行提前检测光电组
|
|
////2011124
|
|
//AheadDetect.Remove(0, AheadDetect.Length); ;
|
|
//tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append("D-").Append(tw.ToString());//20111215.Append( ";" ).Append( GetBeDetectedDevices(PriorDevice[0]));//20101124
|
|
|
|
//}
|
|
//else
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
//}
|
|
//////20090803检测设备是否空闲idle
|
|
////AheadDetect += ";" + "I" + PriorDevice[0].ToString();
|
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(tw.ToString());//20111215 +";" + GetBeDetectedDevices(NextKeyDevice[0]);//20101118
|
|
//}
|
|
////20101124
|
|
//#endregion
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, PriorDevice[0], 3, 0) == false)
|
|
//{
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," ).Append(
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)" ).Append(
|
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
|
// ).Append( "," ).Append( PriorDevice[0] ).Append( "," ).Append( 3 ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( PriorDevice[0] ).Append( ",0,"
|
|
// ).Append( "0,0,0,0,'" ).Append( AheadDetect.ToString() ).Append( "','").Append( drv["FPALLETBARCODE"] ).Append( "')");
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// mainTask = mindex;
|
|
//}
|
|
////20101124
|
|
|
|
#endregion
|
|
|
|
#region RGV的接货(被关联的任务)
|
|
Rgvorder = 2; //GetRGVOrder(PriorDevice[0], true);
|
|
//20130510如果是防爆车28001则在管理任务取得
|
|
if (PriorDevice[0] == 28001)
|
|
{
|
|
PriorDevice[0] = GetAGVAddressFromManage(Mankind, ManFID, true)[1];
|
|
Rgvorder = 7;
|
|
}
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
#region 目标输送机运行提前检测光电组
|
|
tw = GetBindingDeviceIndex(NextDevice[0]);//目标输送机入口无探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101124
|
|
}
|
|
//20111215
|
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);//目标输送机出口无探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
//20090803检测设备是否空闲idle
|
|
AheadDetect.Append(";").Append("I").Append(NextDevice[0].ToString());//20101124
|
|
|
|
#endregion
|
|
#region 取货输送机运行提前检测光电组
|
|
tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(PriorDevice[0]));
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
//20090803检测设备是否空闲idle
|
|
AheadDetect.Append(";").Append("I").Append(PriorDevice[0].ToString());//20101124
|
|
#endregion
|
|
tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));
|
|
}
|
|
AheadDetect.Append(";I").Append(NextKeyDevice[0]);
|
|
#endregion
|
|
//20101124
|
|
if (PriorDevice[0] == 22102 || PriorDevice[0] == 22104)//20130510
|
|
{
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 7, 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(7).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(PriorDevice[0]).Append(",0").Append(
|
|
",0,0,0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
}
|
|
}
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], Rgvorder, 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(Rgvorder).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(PriorDevice[0]).Append(",0").Append(
|
|
",0,0,0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_Associate=").Append(mindex).Append(" where F_MonitorIndex=").Append(mainTask);
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
}
|
|
//20101124
|
|
#endregion
|
|
|
|
#region RGV是条码绑定设备需要条码比对
|
|
int barcodedev = GetBarcodeDeviceFromBindDevice(NextKeyDevice[0]);
|
|
if (barcodedev > 0)
|
|
{
|
|
#region 生成条码比对命令
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, barcodedev, 1, 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(barcodedev).Append(",").Append(1).Append(",").Append(ccf.GetRouteIDsub(barcodedev)).Append(",").Append(status).Append(",0,0,'").Append("").Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
//获得RGV运行的送货位的设备索引:
|
|
if (NextDevice.Count > 0)
|
|
{
|
|
Coor[0] = NextDevice[0];
|
|
Coor[1] = 0;
|
|
Coor[2] = 0;
|
|
Coor[3] = 0;
|
|
Coor[4] = 0;
|
|
Coor[5] = 0;
|
|
}
|
|
|
|
|
|
#region 生成RGV指令:7-运动(到目标设备索引)+(2-左接货3-左送货)或者(4-右接货5-右送货)
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect.Remove(0, AheadDetect.Length);
|
|
//AheadDetect.Append( GetBeDetectedDevices(NextKeyDevice[0]));
|
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append(";D-").Append(tw.ToString());//20101124
|
|
//}
|
|
////运动
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 7, Coor[0]) == false)
|
|
//{
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// sql.Remove(0, sql.Length);
|
|
// sql .Append( "INSERT INTO T_Monitor_Task " ).Append(
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," ).Append(
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," ).Append(
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_TxtParam,F_AheadDetect)" ).Append(
|
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
|
// ).Append( "," ).Append( NextKeyDevice[0] ).Append( ",7," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
|
// ).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( AheadDetect.ToString() ).Append( "')");
|
|
// dbo.ExceSQL(sql.ToString());
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region RGV的送货
|
|
|
|
Rgvorder = 3;// GetRGVOrder(NextDevice[0], false);
|
|
//20130510如果是防爆车28001则在管理任务取得
|
|
if (NextDevice[0] == 28001)
|
|
{
|
|
NextDevice[0] = GetAGVAddressFromManage(Mankind, ManFID, false)[4];
|
|
Rgvorder = 7;
|
|
}
|
|
|
|
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
tw = GetBindingDeviceIndex(NextDevice[0]);//目标输送机入口无探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
//20111215
|
|
tw = GetBindingDeviceIndexOut(NextDevice[0]);//目标输送机出口无探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
AheadDetect.Append(";I").Append(NextDevice[0]);
|
|
|
|
tw = GetBindingDeviceIndex(NextKeyDevice[0]);//RGV有探物,能运行
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";").Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextKeyDevice[0]));//20101118
|
|
}
|
|
AheadDetect.Append(";I").Append(NextKeyDevice[0]);
|
|
#endregion
|
|
if (NextDevice[0] == 22102 || NextDevice[0] == 22104)//20130510
|
|
{
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], 7, 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(7).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(NextDevice[0]).Append(",0").Append(
|
|
",0,0,0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
}
|
|
}
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], Rgvorder, 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(Rgvorder).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(NextDevice[0]).Append(",0").Append(
|
|
",0,0,0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
mainTask = mindex;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 输送机的接货(被关联的任务)
|
|
|
|
|
|
//#region 运行提前检测光电组
|
|
//AheadDetect.Remove(0, AheadDetect.Length) ;
|
|
//tw = GetBindingDeviceIndexOut(NextDevice[0]);//目标输送机出口无探物,能运行
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect .Append( ";D" ).Append( tw.ToString());//20101118
|
|
//}
|
|
////20111215
|
|
//tw = GetBindingDeviceIndex(NextDevice[0]);//输送机入口无探物,能运行
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(NextDevice[0]));//20101118
|
|
//}
|
|
//else
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
//}
|
|
//////20090803检测设备是否空闲idle
|
|
////AheadDetect += ";" + "I" + NextDevice[0].ToString();
|
|
|
|
//tw = GetBindingDeviceIndex(NextKeyDevice[0]);//RGV有探物,能运行
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect .Append( ";D" ).Append( "-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(NextKeyDevice[0]));//20101118
|
|
//}
|
|
//////20090803检测设备是否空闲idle
|
|
////AheadDetect += ";" + "I" + NextKeyDevice[0].ToString();
|
|
//#endregion
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextDevice[0], 4, 0) == false)
|
|
//{
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append( "INSERT INTO T_Monitor_Task " ).Append(
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," ).Append(
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," ).Append(
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_TxtParam)" ).Append(
|
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
|
// ).Append( "," ).Append( NextDevice[0] ).Append( "," ).Append( 4 ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( NextDevice[0] ).Append( ",0,"
|
|
// ).Append( "0,0,0,0,'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("update T_Monitor_Task set F_Associate=" ).Append( mindex ).Append( " where F_MonitorIndex=" ).Append( mainTask);
|
|
// dbo.ExceSQL(sql.ToString());
|
|
|
|
//}
|
|
#endregion
|
|
break;
|
|
|
|
|
|
|
|
#endregion
|
|
case 6:
|
|
#region AGV
|
|
|
|
#region 生成一个设备命令并且获得取送货坐标
|
|
int topAddress = 0;
|
|
int leftAddress = 0;
|
|
int realAddress = 0;
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
#region 前一设备是输送机
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
if (PriorDevice[1] == 2)
|
|
{
|
|
if (uncontrol != "1")
|
|
{//20091107
|
|
bool IfConveyor = false;
|
|
if (PriorKeyDevice0.Count > 0)
|
|
{
|
|
if (PriorKeyDevice0[1] != 2)//20110104前一关键设备不是类输送机
|
|
{
|
|
IfConveyor = false;
|
|
}
|
|
else
|
|
{
|
|
IfConveyor = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
IfConveyor = false;
|
|
}
|
|
if (IfConveyor == false)//20110104前一关键设备不是类输送机
|
|
{
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
}
|
|
int arrowdev;
|
|
if (CurDevice[0] == PriorDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
if (CStaticClass.AGVAllowSingleFork == "0")//20100710
|
|
{
|
|
#region 隔壁输送机空闲无物
|
|
//奇数加一;偶数减一
|
|
if ((CurDevice[0] % 2) == 0)
|
|
{
|
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndexOut(CurDevice[0] - 1).ToString());//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Append(";D").Append(GetBindingDeviceIndexOut(CurDevice[0] + 1).ToString());//20101118
|
|
}
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = PriorDevice[0];
|
|
CurDevice[3] = 6;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
|
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
|
if (nextConveyor.Count > 0)//20110331
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
//tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
//}
|
|
|
|
AheadDetect.Append(";").Append("N").Append(nextConveyor[0].ToString());
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
|
}
|
|
|
|
#region 22034\22035
|
|
if (arrowdev == 22036)//20101203
|
|
{
|
|
AheadDetect.Append(";D").Append("22036.0");
|
|
}
|
|
if (arrowdev == 22037)//20101203
|
|
{
|
|
AheadDetect.Append(";D").Append("22037.0");
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
}
|
|
#region 顶升机下降20110210
|
|
//AheadDetect.Remove(0, AheadDetect.Length);
|
|
//AheadDetect.Append("I").Append(Convert.ToString(arrowdev-2)).Append(";I").Append(Convert.ToString(arrowdev));
|
|
//tw = ccf.GetBindingDeviceIndexOut(arrowdev - 2);
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect .Append( ";D-" ).Append( tw.ToString());
|
|
//}
|
|
//AheadDetect.Append(";D").Append(arrowdev.ToString()).Append(".2");//20110331
|
|
//if (DeviceAndOrderExitInMonitor(Mankind, ManFID, arrowdev, 8, 0) == false)
|
|
//{
|
|
// #region 运行时锁定设备组
|
|
|
|
// #endregion
|
|
|
|
// #region 生成输送机命令
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append( "INSERT INTO T_Monitor_Task " ).Append(
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," ).Append(
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4," ).Append(
|
|
// " F_AheadDetect,F_TxtParam)" ).Append(
|
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
|
// ).Append( "," ).Append( arrowdev ).Append( "," ).Append( 8 ).Append( "," ).Append( routeIDSub ).Append( "," ).Append( status
|
|
// ).Append( "," ).Append( arrowdev ).Append( "," ).Append( 0
|
|
// ).Append( ",'" ).Append( AheadDetect.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "')");
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// #endregion
|
|
//}
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
int[] Coor0_2 = new int[6] { 0, 0, 0, 0, 0, 0 };
|
|
//如果PriorDevice是AGV通道,PriorDevice不拆分命令,获取送坐标,拆分AGV命令取、送货
|
|
if (PriorDevice[1] == 11)
|
|
{
|
|
Coor0_2 = GetAGVAddressFromManage(Mankind, ManFID, true);
|
|
//add for hbth
|
|
leftAddress = GetLeftAGVAddress(Coor0_2[1]);
|
|
}
|
|
else
|
|
{
|
|
//如果NextDevice是输送机则取送货命令,获取送坐标
|
|
|
|
//如果NextDevice是固定站台则取送货命令,获取送坐标
|
|
Coor0_2[1] = PriorDevice[0];
|
|
}
|
|
Coor[0] = Coor0_2[0];
|
|
if (leftAddress == 0)
|
|
{
|
|
Coor[1] = Coor0_2[1];//站台设备索引
|
|
}
|
|
else
|
|
{
|
|
Coor[1] = leftAddress;
|
|
}
|
|
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);
|
|
//add for hbth
|
|
topAddress = GetTopAGVAddress(Coor3_5[4]);
|
|
}
|
|
else
|
|
{
|
|
//如果NextDevice是输送机则取送货命令,获取送坐标
|
|
|
|
//如果NextDevice是固定站台则取送货命令,获取送坐标
|
|
Coor3_5[4] = NextDevice[0];
|
|
}
|
|
Coor[3] = Coor3_5[3];
|
|
//add for hbth
|
|
if (topAddress == 0)
|
|
{
|
|
Coor[4] = Coor3_5[4];//站台设备索引
|
|
}
|
|
else
|
|
{
|
|
Coor[4] = topAddress;
|
|
realAddress = Coor3_5[4];
|
|
}
|
|
Coor[5] = Coor3_5[5];
|
|
}
|
|
#endregion
|
|
|
|
#region 生成AGV指令:取送货//20110104
|
|
//转换调度任务类型和AGV任务类型
|
|
int agvorder = 0;
|
|
|
|
#region AGV取送货
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
agvorder = 4;//AGV取送货
|
|
RunningLock.Remove(0, RunningLock.Length);
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
//if (PriorDevice[1] == 2)
|
|
//{
|
|
// #region 运行时锁定设备组
|
|
// RunningLock.Append(PriorDevice[0].ToString());
|
|
// //取货时锁定隔壁输送机
|
|
// if (CStaticClass.AGVAllowSingleFork == "0")
|
|
// {
|
|
// if ((PriorDevice[0] % 2) == 0)
|
|
// {
|
|
// RunningLock.Append(";").Append((PriorDevice[0] - 1).ToString());
|
|
// }
|
|
// else
|
|
// {
|
|
// RunningLock.Append(";").Append((PriorDevice[0] + 1).ToString());
|
|
// }
|
|
// }
|
|
// #endregion
|
|
|
|
// AheadDetect.Append("D-").Append(GetBindingDeviceIndexOut(PriorDevice[0]).ToString()).Append(";I").Append(PriorDevice[0].ToString());
|
|
// #region 增加检测顶升是否在低位20100710
|
|
// //AheadDetect .Append( ";D-" ).Append( PriorDevice[0].ToString() ).Append( ".2");
|
|
// #endregion
|
|
//}
|
|
|
|
//if (NextDevice.Count > 0)
|
|
//{
|
|
// if (NextDevice[1] == 2)
|
|
// {//20100714
|
|
// AheadDetect.Append(";D").Append(GetBindingDeviceIndex(NextDevice[0]).ToString()).Append(";I").Append(NextDevice[0].ToString()).Append(";N").Append(NextDevice[0].ToString());
|
|
|
|
// }
|
|
|
|
//}
|
|
//add for hbth
|
|
AheadDetect.Append(";D-").Append(Coor[1]).Append(".0").Append(";I").Append(Coor[1]).Append(";D").Append(Coor[4]).Append(".0").Append(";I").Append(Coor[4]);
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0) == false)
|
|
{//20091107
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
|
mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
" F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(agvorder).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
|
).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",").Append(Coor[5]).Append(",'")
|
|
.Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
//#region AGV取货
|
|
//if (PriorDevice.Count > 0)
|
|
//{
|
|
// agvorder = 2;//AGV取货
|
|
// RunningLock.Remove(0, RunningLock.Length) ;
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
// if (PriorDevice[1] == 2)
|
|
// {
|
|
// #region 运行时锁定设备组
|
|
// RunningLock .Append(PriorDevice[0].ToString());
|
|
// //取货时锁定隔壁输送机
|
|
// if (CStaticClass.AGVAllowSingleFork == "0")
|
|
// {
|
|
// if ((PriorDevice[0] % 2) == 0)
|
|
// {
|
|
// RunningLock .Append( ";" ).Append( (PriorDevice[0] - 1).ToString());
|
|
// }
|
|
// else
|
|
// {
|
|
// RunningLock.Append( ";" ).Append( (PriorDevice[0] + 1).ToString());
|
|
// }
|
|
// }
|
|
// #endregion
|
|
|
|
// AheadDetect .Append( "D-" ).Append( GetBindingDeviceIndexOut(PriorDevice[0]).ToString() ).Append( ";I" ).Append( PriorDevice[0].ToString());
|
|
// #region 增加检测顶升是否在低位20100710
|
|
// //AheadDetect .Append( ";D-" ).Append( PriorDevice[0].ToString() ).Append( ".2");
|
|
// #endregion
|
|
// }
|
|
|
|
// if (NextDevice.Count > 0)
|
|
// {
|
|
// if (NextDevice[1] == 2)
|
|
// {//20100714
|
|
// AheadDetect .Append( ";D" ).Append( GetBindingDeviceIndex(NextDevice[0]).ToString() ).Append( ";I" ).Append( NextDevice[0].ToString() ).Append( ";N" ).Append( NextDevice[0].ToString());
|
|
|
|
// }
|
|
|
|
// }
|
|
// if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0) == false)
|
|
// {//20091107
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
|
// mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
|
// sql.Remove(0, sql.Length);
|
|
// sql .Append( "INSERT INTO T_Monitor_Task " ).Append(
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," ).Append(
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2," ).Append(
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork)" ).Append(
|
|
// "VALUES (" ).Append( ManFID ).Append( "," ).Append( Mankind ).Append( "," ).Append( mindex ).Append( "," ).Append( drv["FTASKLEVEL"]
|
|
// ).Append( "," ).Append( NextKeyDevice[0] ).Append( ",").Append(agvorder).Append("," ).Append( routeIDSub ).Append( "," ).Append( status ).Append( "," ).Append( Coor[0] ).Append( "," ).Append( Coor[1]
|
|
// ).Append( "," ).Append( Coor[2] ).Append( "," ).Append( Coor[3] ).Append( "," ).Append( Coor[4] ).Append( "," ).Append( Coor[5] ).Append( ",'" )
|
|
// .Append( AheadDetect.ToString() ).Append( "','" ).Append( RunningLock.ToString() ).Append( "','" ).Append( drv["FPALLETBARCODE"] ).Append( "','" ).Append( drv["FUseAwayFork"] ).Append( "')");
|
|
// dbo.ExceSQL(sql.ToString());
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
//#endregion
|
|
|
|
//#region AGV送货
|
|
//if (PriorDevice.Count > 0)
|
|
//{
|
|
// agvorder = 3;//AGV送货
|
|
// RunningLock.Remove(0, RunningLock.Length);
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
|
|
// if (NextDevice.Count > 0)
|
|
// {
|
|
// if (NextDevice[1] == 2)
|
|
// {//20100714
|
|
// AheadDetect.Append(";D").Append(GetBindingDeviceIndex(NextDevice[0]).ToString()).Append(";I").Append(NextDevice[0].ToString()).Append(";N").Append(NextDevice[0].ToString());
|
|
|
|
// }
|
|
|
|
// }
|
|
// if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], agvorder, 0) == false)
|
|
// {//20091107
|
|
// int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
// mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
|
// mindex = ccf.GetMonitorIndex(ManFID, Mankind);//20110104
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
// "(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
// " F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2,").Append(
|
|
// " F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6,F_AheadDetect,F_RunningLock,F_TxtParam,F_UseAwayFork)").Append(
|
|
// "VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
// ).Append(",").Append(NextKeyDevice[0]).Append(",").Append(agvorder).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(Coor[0]).Append(",").Append(Coor[1]
|
|
// ).Append(",").Append(Coor[2]).Append(",").Append(Coor[3]).Append(",").Append(Coor[4]).Append(",").Append(Coor[5]).Append(",'")
|
|
// .Append(AheadDetect.ToString()).Append("','").Append(RunningLock.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("','").Append(drv["FUseAwayFork"]).Append("')");
|
|
// dbo.ExceSQL(sql.ToString());
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
//#endregion
|
|
#endregion
|
|
|
|
#endregion
|
|
break;
|
|
case 7:
|
|
#region 条码扫描仪(托盘条码比对1)
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
//如果PriorDevice是输送机则生成输送机命令【CurDevice-->PriorDevice目标设备,出库:2】,
|
|
//收到输送机PriorDevice的PLC上报的运行状态则提前触发RGV运行命令(7),然后是取送货命令,获取堆垛机取坐标
|
|
#region 前一设备是输送机
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
if (PriorDevice[1] == 2)
|
|
{
|
|
if ((uncontrol != "1") && (CurDevice[1] == 2))
|
|
{//20091107
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
}
|
|
int arrowdev;
|
|
if (CurDevice[0] == PriorDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
if (CurDevice[3] == 1)
|
|
{
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D" + tw.ToString());//20101118
|
|
}
|
|
|
|
}
|
|
else if (CurDevice[3] == 2)
|
|
{
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D" + tw.ToString());//20101118
|
|
}
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = PriorDevice[0];
|
|
CurDevice[3] = 6;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
|
if (null != cdi)
|
|
{//20100406检测被堆垛机送货的顶升机构在顶升高位,空闲
|
|
AheadDetect.Append(";D-").Append(cdi[1]).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
//20101011
|
|
else
|
|
{
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString());//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
|
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
|
if (nextConveyor.Count > 0)//20110331
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
|
if ((tw != "") && (nextConveyor[0] != 12304) && (nextConveyor[0] != 12310))//20130510
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (被触发的调度任务号);//此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
if ((CurDevice[0] == 32037) || (CurDevice[0] == 32050))
|
|
{
|
|
RunningLock.Clear();
|
|
RunningLock.Append(Convert.ToInt32(CurDevice[0] - 1));
|
|
}
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString());
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
#region 生成条码比对命令
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(NextKeyDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
break;
|
|
case 8://20130510
|
|
#region 称重设备(称重命令1)
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
//如果PriorDevice是输送机则生成输送机命令【CurDevice-->PriorDevice目标设备,出库:2】,
|
|
//收到输送机PriorDevice的PLC上报的运行状态则提前触发RGV运行命令(7),然后是取送货命令,获取堆垛机取坐标
|
|
#region 前一设备是输送机
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
if (PriorDevice[1] == 2)
|
|
{
|
|
if ((uncontrol != "1") && (CurDevice[1] == 2))
|
|
{//20091107
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
}
|
|
int arrowdev;
|
|
if (CurDevice[0] == PriorDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
if (CurDevice[3] == 1)
|
|
{
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D" + tw.ToString());//20101118
|
|
}
|
|
|
|
}
|
|
else if (CurDevice[3] == 2)
|
|
{
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D" + tw.ToString());//20101118
|
|
}
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = PriorDevice[0];
|
|
CurDevice[3] = 6;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
|
if (null != cdi)
|
|
{//20100406检测被堆垛机送货的顶升机构在顶升高位,空闲
|
|
AheadDetect.Append(";D-").Append(cdi[1]).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
//20101011
|
|
else
|
|
{
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString());//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
|
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
|
if (nextConveyor.Count > 0)//20110331
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(CurDevice[0]));
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (被触发的调度任务号);//此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
if ((CurDevice[0] == 32037) || (CurDevice[0] == 32050))
|
|
{
|
|
RunningLock.Clear();
|
|
RunningLock.Append(Convert.ToInt32(CurDevice[0] - 1));
|
|
}
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
#region 运行提前检测光电组
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
tw = GetSendOutDetect(PriorDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString());
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
#endregion
|
|
if (CurDevice[0] == 12304 || CurDevice[0] == 12310)
|
|
{//20130510 16006,16008
|
|
int dev = GetBarcodeDeviceFromBindDevice(CurDevice[0]);
|
|
#region 生成条码比对命令1
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, dev, 1, 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(dev).Append(",").Append(1).Append(",").Append(ccf.GetRouteIDsub(dev)).Append(",").Append(status).Append(",0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
#region 生成称重命令1
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(NextKeyDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",0,0,'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
break;
|
|
case 12:
|
|
#region 虚拟关键设备(只作为路径分割点)
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
//如果PriorDevice是输送机则生成输送机命令【CurDevice-->PriorDevice目标设备,出库:2】,
|
|
//收到输送机PriorDevice的PLC上报的运行状态则提前触发RGV运行命令(7),然后是取送货命令,获取堆垛机取坐标
|
|
#region 前一设备是输送机
|
|
//HSCP-PriorDevice[1] == 5 或是叠盘机
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
if (PriorDevice[1] == 2 || PriorDevice[1] == 5)
|
|
{
|
|
if (uncontrol != "1")
|
|
{//20091107
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
}
|
|
int arrowdev;
|
|
if (CurDevice[0] == PriorDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
//20101011
|
|
string[] cdi = ccf.GetOwnCorrel_DeviceInfo(CurDevice[0]);
|
|
if ((null != cdi) && (CurDevice[3] == 1 || CurDevice[3] == 7))
|
|
//if ((null != cdi) && (CurDevice[3] == 2))
|
|
{//20100406检测被堆垛机送货的顶升机构在顶升高位,空闲
|
|
AheadDetect.Append(";D-").Append(cdi[1]).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
//20101011
|
|
else
|
|
{
|
|
if (CurDevice[3] == 1 || CurDevice[3] == 7)
|
|
{
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
}
|
|
else if ((CurDevice[3] == 2))//20110510反转
|
|
{
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
}
|
|
|
|
}
|
|
//else if (CurDevice[3] == 2)
|
|
//{
|
|
// tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect = "D-" + tw.ToString() + ";" + GetBeDetectedDevices(CurDevice[0]);//20101118
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
// }
|
|
//}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = PriorDevice[0];
|
|
CurDevice[3] = 6;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{//20091107
|
|
//AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
AheadDetect.Append("D").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//TJBS
|
|
}
|
|
//else
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
//}
|
|
string twi = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (twi != "")
|
|
{//20101124
|
|
//AheadDetect .Append( "D-" ).Append( tw.ToString() ).Append( ";" ).Append( GetBeDetectedDevices(CurDevice[0]));
|
|
AheadDetect.Append(";D-").Append(twi.ToString());//TJBS
|
|
}
|
|
string[] cdi = ccf.GetLanewayDeviceInfoFromDev(CurDevice[0]);//TJBS无两个巷道共享输送线所可以这么写,后续完善成通用代码
|
|
|
|
//rr[0] = dv[0]["F_LaneGateDeviceIndex"].ToString();
|
|
//rr[1] = dv[0]["F_HighDetect"].ToString();
|
|
//rr[2] = dv[0]["F_LowDetect"].ToString();
|
|
//rr[3] = dv[0]["F_HavingDetect"].ToString();
|
|
//rr[4] = dv[0]["F_RunDetect"].ToString();.4
|
|
//rr[5] = dv[0]["F_NearDetect"].ToString();
|
|
//rr[6] = dv[0]["F_FarDetect"].ToString();.3
|
|
//rr[7] = dv[0]["F_UseAwayFork"].ToString();
|
|
//rr[8] = dv[0]["F_CorrelDeviceIndex"].ToString();
|
|
//rr[9] = dv[0]["F_zxy"].ToString();
|
|
if (cdi != null)
|
|
{
|
|
if (cdi[6] != "")
|
|
{//移动设备允许输送线动作
|
|
AheadDetect.Append(";D-").Append(cdi[6]);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
#endregion
|
|
break;
|
|
case 30:
|
|
#region 20100617和管理交互虚拟设备,1:出库托盘确认
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
if (PriorDevice.Count > 0)
|
|
{
|
|
//如果PriorDevice是输送机则生成输送机命令【CurDevice-->PriorDevice目标设备,出库:2】,
|
|
//收到输送机PriorDevice的PLC上报的运行状态则提前触发RGV运行命令(7),然后是取送货命令,获取堆垛机取坐标
|
|
#region 前一设备是输送机
|
|
|
|
if (PriorDevice[1] == 2)
|
|
{
|
|
if (uncontrol != "1")
|
|
{//20091107
|
|
List<int> newcur = NewCurDevice(PriorDevice0, PriorKeyDevice0);
|
|
if (newcur != null)
|
|
{
|
|
CurDevice = newcur;
|
|
}
|
|
int arrowdev;
|
|
if (CurDevice[0] == PriorDevice[0])
|
|
{//输送机的起点设备和终点设备相同时,目标设备索引置为零
|
|
arrowdev = 0;
|
|
#region 运行提前检测光电组
|
|
if ((CurDevice[3] == 1) || (CurDevice[3] == 2))
|
|
{
|
|
//CurDevice的F_BindingDevice里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetBindingDeviceIndex(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString()).Append(";").Append(GetBeDetectedDevices(CurDevice[0]));//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
|
|
}
|
|
//else if (CurDevice[3] == 2)
|
|
//{
|
|
// tw = GetBindingDeviceIndexOut(CurDevice[0]);
|
|
// if (tw != "")
|
|
// {
|
|
// AheadDetect = "D-" + tw.ToString() + ";" + GetBeDetectedDevices(CurDevice[0]);//20101118
|
|
// }
|
|
// else
|
|
// {
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
// }
|
|
//}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
arrowdev = PriorDevice[0];
|
|
CurDevice[3] = 6;
|
|
#region 运行提前检测光电组
|
|
//CurDevice的F_SendOutDetect里存的光电开关的设备所引。CurDevice有探物
|
|
tw = GetSendOutDetect(CurDevice[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append("D-").Append(tw.ToString());//20101118
|
|
}
|
|
else
|
|
{
|
|
AheadDetect.Remove(0, AheadDetect.Length);
|
|
}
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + CurDevice[0].ToString();
|
|
|
|
List<int> nextConveyor = GetCurConveyorNextDevice(routeIDSub, CurDevice[2]);
|
|
if (nextConveyor.Count > 0)//20110331
|
|
{
|
|
AheadDetect.Append(";").Append(GetBeDetectedDevices(nextConveyor[0]));
|
|
tw = GetBindingDeviceIndex(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
tw = GetBindingDeviceIndexOut(nextConveyor[0]);
|
|
if (tw != "")
|
|
{
|
|
AheadDetect.Append(";D").Append(tw.ToString());//20101118
|
|
}
|
|
|
|
////20090803检测设备是否空闲idle
|
|
//AheadDetect += ";" + "I" + nextConveyor[0].ToString();
|
|
}
|
|
#endregion
|
|
}
|
|
AheadTrigger.Remove(0, AheadTrigger.Length);
|
|
AheadTrigger.Append(PriorDevice[0].ToString()); //+ "-" + (被触发的调度任务号);//此设备的运行状态(货物当前位置=PriorDevice[0])触发堆垛机的将取
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, CurDevice[0], CurDevice[3], 0) == false)
|
|
{
|
|
#region 运行时锁定设备组
|
|
|
|
#endregion
|
|
|
|
#region 生成输送机命令
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
TriggerTaskNo = mindex;
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(CurDevice[0]).Append(",").Append(CurDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",").Append(CurDevice[0]).Append(",").Append(arrowdev
|
|
).Append(",'").Append(AheadDetect.ToString()).Append("','").Append(drv["FPALLETBARCODE"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
#region 运行提前检测光电组
|
|
|
|
//tw = GetBindingDeviceIndexOut(PriorDevice[0]);
|
|
//if (tw != "")
|
|
//{
|
|
// AheadDetect = "D-" + tw.ToString();//20101118
|
|
//}
|
|
//else
|
|
//{
|
|
// AheadDetect.Remove(0, AheadDetect.Length);
|
|
//}
|
|
#endregion
|
|
|
|
#region 生成和管理交互虚拟设备的【出库确认】命令
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, NextKeyDevice[0], NextKeyDevice[3], 0) == false)
|
|
{
|
|
int mindex = ccf.GetMonitorIndex(ManFID, Mankind);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO T_Monitor_Task ").Append(
|
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel,").Append(
|
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4,").Append(
|
|
" F_AheadDetect,F_TxtParam)").Append(
|
|
"VALUES (").Append(ManFID).Append(",").Append(Mankind).Append(",").Append(mindex).Append(",").Append(drv["FTASKLEVEL"]
|
|
).Append(",").Append(NextKeyDevice[0]).Append(",").Append(NextKeyDevice[3]).Append(",").Append(routeIDSub).Append(",").Append(status).Append(",0,0,'").Append(AheadDetect).Append("','").Append(drv["FPALLETBARCODE"] + "')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
PriorDevice0 = PriorDevice;
|
|
PriorKeyDevice0 = NextKeyDevice;
|
|
//20091107
|
|
PriorDevice = null;
|
|
NextKeyDevice = null;
|
|
CurDevice = null;
|
|
NextKeyDevice = null;
|
|
}
|
|
//20120820
|
|
dbo.ExecuteSql(string.Format("update T_Monitor_Task set F_SplitTime= '{0}' where F_ManageTASKKINDINDEX={1} and F_ManageTASKINDEX={2}", DateTime.Now.ToString("u"), Mankind, ManFID));//20120616
|
|
dbo.TransCommit();
|
|
//20091107
|
|
PriorDevice0 = null;
|
|
PriorKeyDevice0 = null;
|
|
|
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
|
OnDataChange("CreateMonitor", cea);
|
|
return 1;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.CreateMonitor时发生错误:" + ex.StackTrace + ex.Message;
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", DisassembleTaskError);
|
|
OnRefreshMonitor(rme);
|
|
dbo.TransRollback();
|
|
|
|
return 0;
|
|
}
|
|
finally
|
|
{
|
|
//dvRoute.Dispose();
|
|
//dvs.Dispose();
|
|
|
|
}
|
|
}
|
|
|
|
//add for hbth
|
|
static int GetTopAGVAddress(int adress)//查找agv送货任务的设备
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_Top FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = ").Append(adress).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_Top"]);
|
|
}
|
|
else
|
|
{
|
|
//return 65535;
|
|
return 0;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
|
|
static int GetLeftAGVAddress(int adress)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_Left FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = ").Append(adress).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_Left"]);
|
|
}
|
|
else
|
|
{
|
|
//return 65535;
|
|
return 0;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.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;
|
|
// }
|
|
//}
|
|
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;
|
|
}
|
|
if (tempZ == 1 || tempZ == 4 || tempZ == 0)//里位取货时,要判读是否有外位的取货任务//
|
|
{//获取外位坐标
|
|
if (tempZ == 1)
|
|
{
|
|
newZ = getZ + 1;
|
|
}
|
|
else
|
|
{
|
|
newZ = getZ - 1;
|
|
}
|
|
string neighborzxy = string.Format("{0:D3}-{1:D3}-{2:D3}", newZ, zxy[1], zxy[2]);//TJBS按三位货位码处理
|
|
|
|
|
|
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="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)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
if (Order == -1) return true;
|
|
sql.Remove(0, sql.Length);
|
|
switch (ccf.GetDeviceKindIdx(DeviceIndex))
|
|
{
|
|
case 1://堆垛机
|
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(")");
|
|
break;
|
|
case 2://输送机
|
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(")");
|
|
break;
|
|
case 4://RGV
|
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(") and F_NumParam1=").Append(ArrowAddress);
|
|
break;
|
|
case 6://AGV
|
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(")");
|
|
break;
|
|
default:
|
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManFID).Append(")").Append(
|
|
" AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")").Append(
|
|
" AND (F_DeviceCommandIndex = ").Append(Order).Append(")");
|
|
break;
|
|
}
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.DeviceAndOrderExitInMonitor:" + ex.StackTrace + ex.Message;
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 找到不能移动托盘的关键设备的前一个设备:例如,条码扫描器前一个位置(运动反方向)的输送机
|
|
/// </summary>
|
|
/// <param name="prirorDevice">关键设备的前一个设备</param>
|
|
/// <param name="prirorKeydevice">关键设备</param>
|
|
/// <returns></returns>
|
|
static List<int> NewCurDevice(List<int> prirorDevice, List<int> prirorKeydevice)
|
|
{//0设备所引;1设备类型;2:路径序号;3:设备命令
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
if ((prirorKeydevice.Count > 0) && (prirorDevice.Count > 0))
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_GoodsMoveKindIndex, F_DeviceKindIndex FROM T_Base_Device_Kind WHERE ").Append(
|
|
"(F_DeviceKindIndex = ").Append(prirorKeydevice[1]).Append(") and (F_GoodsMoveKindIndex=2)");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (Model.CGetInfo.GetDeviceInfo(prirorDevice[0]).UnControl != "1")
|
|
{
|
|
return prirorDevice;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "ControlSystem.CDisassembleTask.NewCurDevice:" + ex.StackTrace + ex.Message;
|
|
return null;
|
|
}
|
|
finally
|
|
{
|
|
prirorDevice = null;
|
|
prirorKeydevice = null;
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取可用的目标位置:入库的巷道或者出库站台;同时修改调度任务为不可拆分状态
|
|
/// </summary>
|
|
/// <param name="dr">T_Manage_Task表的行记录</param>
|
|
/// <returns></returns>
|
|
public static void GetUsableDestination(DataRowView dr)
|
|
{
|
|
DataView dvIO = new DataView(); DataTable dtd = new DataTable();
|
|
try
|
|
{
|
|
dr = dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE (FID = {0}) AND (F_ManageTaskKindIndex = {1})", Convert.ToInt32(dr["FID"]), Convert.ToInt32(dr["F_ManageTaskKindIndex"]))).Tables[0].DefaultView[0];//20130620
|
|
|
|
//只修申请改调度任务的路径,不修改调度自动任务路径
|
|
if (dr["F_ManageTaskKindIndex"].ToString() != "1") return;
|
|
|
|
|
|
string adviceDev = string.Empty;
|
|
//20100610查找一个路径可用,任务数最少的终点设备
|
|
Dictionary<int, int> advDev = new Dictionary<int, int>();
|
|
object ob;
|
|
|
|
//20091107
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select CONTROL_ID, CONTROL_STATUS from IO_Control where (CONTROL_ID = ").Append(Convert.ToInt32(dr["FID"])).Append(") AND ((CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKALTERROUTEAPPLY).Append(") or (CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKALTERROUTEREPLY).Append("))");
|
|
dvIO = dboM.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvIO.Count <= 0)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_TASKKIND, F_DESTINATION FROM T_Base_Destination WHERE (F_Warehouse='").Append(dr["FENDWAREHOUSE"]).Append("') and (F_TASKKIND = ").Append(dr["FCONTROLTASKTYPE"]).Append(") and (F_AbendStation=1) and (F_DESTINATION=").Append(dr["FENDDEVICE"]).Append(")");
|
|
dtd = dbo.ExceSQL(sql.ToString()).Tables[0];
|
|
if (dtd.Rows.Count > 0)//原来终点是应急站台那么还分配这个站台,不需要改变
|
|
{
|
|
adviceDev = dtd.Rows[0]["F_DESTINATION"].ToString();
|
|
//20091005
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
//查找可用目标位置
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_TASKKIND, F_DESTINATION FROM T_Base_Destination WHERE (F_Warehouse='").Append(dr["FENDWAREHOUSE"]).Append("') and (F_TASKKIND = ").Append(dr["FCONTROLTASKTYPE"]).Append(") and (F_DESTINATION <>").Append(dr["FENDDEVICE"]).Append(") and (F_AbendStation=0)");
|
|
DataTable dt = dbo.ExceSQL(sql.ToString()).Tables[0];
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
if (CDisassembleTask.MinRouteID(Convert.ToInt32(dr["FSTARTDEVICE"]), Convert.ToInt32(dt.Rows[i]["F_DESTINATION"]), dr["FUseAwayFork"]) != -1)
|
|
{
|
|
//20100610统计到终点设备正在执行的任务数
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT count(FENDDEVICE) as counts FROM T_Manage_Task where FENDDEVICE='").Append(dt.Rows[i]["F_DESTINATION"]).Append("' and fstatus>0");
|
|
ob = dbo.GetSingle(sql.ToString());
|
|
advDev.Add(Convert.ToInt32(dt.Rows[i]["F_DESTINATION"]), Convert.ToInt32(ob));
|
|
|
|
//20100610 adviceDev = dt.Rows[i]["F_DESTINATION"].ToString();
|
|
//break;
|
|
}
|
|
}
|
|
if (advDev.Count == 0)//20100610
|
|
{
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
else
|
|
{//20100610
|
|
int mincount = 9999;
|
|
foreach (int aaa in advDev.Keys)
|
|
{
|
|
if (advDev[aaa] < mincount)
|
|
{
|
|
mincount = advDev[aaa];
|
|
adviceDev = aaa.ToString();
|
|
}
|
|
}
|
|
if (adviceDev == "")
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
//DataView DV = dboM.ExceSQL("select IO_CONTROL_APPLY_SEQ.NEXTVAL FROM DUAL").Tables[0].DefaultView;
|
|
//20101108int fid = dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
|
string dtime = DateTime.Now.ToString("u");
|
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
|
//20091128
|
|
dboM.TransBegin();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKALTERROUTEAPPLY).Append(" where CONTROL_ID=").Append(dr["FID"]);
|
|
dboM.ExceSQL(sql.ToString());
|
|
//向管理申请修改任务//
|
|
int appid = dboM.GetManageTableIndex("IO_CONTROL_APPLY", true);//CONTROL_APPLY_ID
|
|
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("INSERT INTO IO_CONTROL_APPLY (CONTROL_APPLY_ID, CONTROL_ID,CONTROL_APPLY_TYPE,WAREHOUSE_CODE, STOCK_BARCODE, DEVICE_CODE, APPLY_TASK_STATUS, CREATE_TIME, ").Append(
|
|
" CONTROL_APPLY_REMARK)").Append(
|
|
"VALUES (").Append(appid).Append(",").Append(dr["FID"] + ",2,'" + dr["FENDWAREHOUSE"]).Append("','").Append(dr["FPALLETBARCODE"]).Append("','").Append(adviceDev).Append("',0,'").Append(dtime).Append("',null)");
|
|
dboM.ExceSQL(sql.ToString());
|
|
dboM.TransCommit();
|
|
//修改调度任务为不可拆分状态
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='-' where (FID = ").Append(Convert.ToInt32(dr["FID"])).Append(") AND (F_ManageTASKKINDINDEX =1)");
|
|
dbo.ExceSQL(sql.ToString());
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CControl.GetUsableDestination", "拆分任务,向管理申请改道", "管理任务:" + dr["FID"].ToString(), "条码:" + dr["FPALLETBARCODE"].ToString().ToUpper());
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = string.Format("拆分任务,向管理申请改道时:{0}", ex.StackTrace + ex.Message);
|
|
dboM.TransRollback();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dvIO.Dispose();
|
|
dtd.Dispose();
|
|
}
|
|
|
|
}
|
|
|
|
public static void CreateRelativeMonitor(int manKind, int FID)
|
|
{//20120906
|
|
|
|
//if (DoubleForkSingleCell(manKind, FID) == true) return;
|
|
int relativeFID = -1;
|
|
DataView dv = new DataView(); DataView dvs = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_RELATIVECONTORLID FROM T_Manage_Task WHERE (FID = ").Append(FID).Append(") AND (F_ManageTaskKindIndex = ").Append(manKind).Append(") and (F_RELATIVECONTORLID<>-1)");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
relativeFID = Convert.ToInt32(dv[0]["F_RELATIVECONTORLID"]);
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
|
|
}
|
|
//多叉关联调度任务在此拆分20100323
|
|
//获取多叉关联任务的路径和任务信息,递归调用CreateMonitor
|
|
|
|
|
|
if (relativeFID != -1)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT T_Manage_Task.* FROM T_Manage_Task WHERE (F_RELATIVECONTORLID = ").Append(relativeFID).Append(") AND (F_ManageTaskKindIndex = ").Append(manKind).Append(") and (FIntoStepOK=0)");
|
|
dvs = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int j = 0; j < dvs.Count; j++)
|
|
{
|
|
int minrid = MinRouteID(Convert.ToInt32(dvs[j]["FSTARTDEVICE"]), Convert.ToInt32(dvs[j]["FENDDEVICE"]), dvs[j]["FUseAwayFork"]);
|
|
if (minrid != -1)
|
|
{
|
|
if (CreateMonitor(manKind, Convert.ToInt32(dvs[j]["FID"]), minrid, dvs[j], 0) > 0)
|
|
{
|
|
//分解完成,修改T_Manage_Task表FIntoStepOK=1
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FIntoStepOK='1' where FID=").Append(dvs[j]["FID"]
|
|
).Append(" and F_ManageTaskKindIndex=").Append(dvs[0]["F_ManageTaskKindIndex"]);
|
|
dbo.ExceSQL(sql.ToString());
|
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
|
OnDataChange("CreateRelativeMonitor", cea);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DisassembleTaskError = "CreateRelativeMonitor," + ex.StackTrace + ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dvs.Dispose();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 找到一个双叉最合适货位,修改关联关系
|
|
/// </summary>
|
|
/// <param name="dr"></param>
|
|
public static void GetOutDoubleForkTask(DataRowView dr)
|
|
{//sqlser的 SUBSTRING(express1,1开始,2);C#的.Substring(0开始, 2)
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dr = dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE (FID = {0}) AND (F_ManageTaskKindIndex = {1})", Convert.ToInt32(dr["FID"]), Convert.ToInt32(dr["F_ManageTaskKindIndex"]))).Tables[0].DefaultView[0];//20130620
|
|
|
|
if (dr["F_RELATIVECONTORLID"].ToString() != "-1") return;
|
|
int forwlimitX = 0, backlimitX = 0;
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_ForwardLimitX, F_BackLimitX FROM T_Base_LaneInfo WHERE (F_LaneDeviceIndex = ").Append(dr["FLANEWAY"]).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
forwlimitX = Convert.ToInt32(dv[0]["F_ForwardLimitX"]);
|
|
backlimitX = Convert.ToInt32(dv[0]["F_BackLimitX"]);
|
|
}
|
|
else
|
|
return;
|
|
int forkamount = 1;
|
|
sql.Clear();
|
|
sql.Append("SELECT F_ForkAmount FROM T_Base_StackInfo WHERE F_StackIndex = ").Append(Convert.ToInt32(dr["FSTACK"]));
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//forkamount = Convert.ToInt32(dv[0]["F_ForkAmount"]) - 1;
|
|
// 202410 HSCP--找两个相关的任务,前后配对
|
|
forkamount = Convert.ToInt32(dv[0]["F_ForkAmount"]);
|
|
forkamount = 5; // 出库任务可以多找几个配对
|
|
}
|
|
else
|
|
return;
|
|
StringBuilder sqladd = new StringBuilder(" ");
|
|
if (forwlimitX.ToString() == dr["FStartCol"].ToString())
|
|
{
|
|
sqladd.Append(" and FStartCol <>").Append(forwlimitX).Append(" ");
|
|
}
|
|
else if (backlimitX.ToString() == dr["FStartCol"].ToString())
|
|
{
|
|
sqladd.Append(" and FStartCol <>").Append(backlimitX).Append(" ");
|
|
}
|
|
else
|
|
{
|
|
sqladd.Append(" ");
|
|
}
|
|
//列的速度是层的速度的3倍,所以层的差值要乘以三(提升一层的时间相当于移动三列的时间)
|
|
sql.Remove(0, sql.Length);
|
|
if (CStaticClass.DBFactory == "OracleDBFactory")
|
|
{//20151120调度系统oracle的特殊语句
|
|
sql.Append("SELECT ").Append(" F_ManageTaskKindIndex, FID, MIN(POWER(FStartCol - ").Append(dr["FStartCol"]).Append(", 2) + POWER((FStartLayer - ").Append(
|
|
dr["FStartLayer"]).Append(") * 3, 2)) AS Expr1 FROM T_Manage_Task WHERE (FIntoStepOK = '0') AND rownum<=").Append(forkamount).Append(
|
|
" and (FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = ").Append(dr["FCONTROLTASKTYPE"]).Append(") AND (FLOGIC_AREA = '").Append(dr["FLOGIC_AREA"]).Append(
|
|
"') AND (FCONTORL_BATCH = '").Append(dr["FCONTORL_BATCH"]).Append("') AND (FLANEWAY = ").Append(dr["FLANEWAY"]).Append(
|
|
") AND (F_RELATIVECONTORLID = - 1) and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]).Append(" and FID<>").Append(dr["fid"]).Append(
|
|
sqladd.ToString()).Append(" GROUP BY F_ManageTaskKindIndex, FID order by Expr1 asc");
|
|
}
|
|
else
|
|
{//20151120调度系统SQLServer的特殊语句
|
|
//sql.Append("SELECT TOP ").Append(forkamount).Append(" F_ManageTaskKindIndex, FID, MIN(POWER(FStartCol - ").Append(dr["FStartCol"]).Append(", 2) + POWER((FStartLayer - ").Append(dr["FStartLayer"]).Append(") * 3, 2)) AS Expr1 FROM T_Manage_Task WHERE (FIntoStepOK = '0') AND ").Append(
|
|
// "(FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = ").Append(dr["FCONTROLTASKTYPE"]).Append(") AND (FLOGIC_AREA = '").Append(dr["FLOGIC_AREA"]).Append(
|
|
// "') AND (FCONTORL_BATCH = '").Append(dr["FCONTORL_BATCH"]).Append("') AND (FLANEWAY = ").Append(dr["FLANEWAY"]).Append(
|
|
// ") AND (F_RELATIVECONTORLID = - 1) and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]).Append(" and FID<>").Append(dr["fid"]).Append(
|
|
// sqladd.ToString()).Append(" GROUP BY F_ManageTaskKindIndex, FID order by Expr1 asc");
|
|
|
|
// 202410 HSCP--计算列、层 修改增加Z FStartZ 坐标条件,双叉双伸,Z坐标系数*2
|
|
sql.Append("SELECT TOP ").Append(forkamount).Append(" F_ManageTaskKindIndex,FStartCol,FStartZ,FStartLayer, FID, MIN(POWER(FStartCol - ").
|
|
Append(dr["FStartCol"]).Append(", 2) + POWER((FStartLayer - ").Append(dr["FStartLayer"]).Append(") * 3, 2) + POWER( ABS(FStartZ - ").Append(dr["FStartZ"]).
|
|
Append(")* 2, 2)+ POWER(2-ABS(FStartCol - ").Append(dr["FStartCol"]).Append("), 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, FStartCol,FStartZ,FStartLayer,FID order by Expr1 asc");
|
|
}
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(dr["fid"]).Append(" where FID=").Append(dv[i]["FID"]).Append(" and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
|
|
}
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(dr["fid"]).Append(" where FID=").Append(dr["fid"]).Append(" and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 找到巷道内移库的适合双叉任务,修改关联关联
|
|
/// </summary>
|
|
/// <param name="dr"></param>
|
|
public static void GetInLaneDoubleForkTask(DataRowView dr)
|
|
{//sqlserver的 SUBSTRING(express1,1开始,2);C#的.Substring(0开始, 2)
|
|
DataView dv = new DataView();
|
|
DataView dv2 = new DataView();
|
|
try
|
|
{
|
|
dr = dbo.ExceSQL(string.Format("SELECT * FROM T_Manage_Task WHERE (FID = {0}) AND (F_ManageTaskKindIndex = {1})", Convert.ToInt32(dr["FID"]), Convert.ToInt32(dr["F_ManageTaskKindIndex"]))).Tables[0].DefaultView[0];//20130620
|
|
|
|
if (dr["F_RELATIVECONTORLID"].ToString() != "-1") return; // 已经设置关联
|
|
int forwlimitX = 0, backlimitX = 0;
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_ForwardLimitX, F_BackLimitX FROM T_Base_LaneInfo WHERE (F_LaneDeviceIndex = ").Append(dr["FLANEWAY"]).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; // 得到巷道的极限货位
|
|
if (dv.Count > 0)
|
|
{
|
|
forwlimitX = Convert.ToInt32(dv[0]["F_ForwardLimitX"]);
|
|
backlimitX = Convert.ToInt32(dv[0]["F_BackLimitX"]);
|
|
}
|
|
else
|
|
return;
|
|
int forkamount = 1;
|
|
sql.Clear();
|
|
sql.Append("SELECT F_ForkAmount FROM T_Base_StackInfo WHERE F_StackIndex = ").Append(Convert.ToInt32(dr["FSTACK"]));
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
// forkamount = Convert.ToInt32(dv[0]["F_ForkAmount"]) - 1;
|
|
// 202410 HSCP - 找两个相关的任务,前后配对
|
|
forkamount = Convert.ToInt32(dv[0]["F_ForkAmount"]);
|
|
forkamount = 3;
|
|
}
|
|
else
|
|
return;
|
|
StringBuilder sqladd = new StringBuilder(" ");
|
|
// 判断起点货位X 是否 前后极限;不能关联两个极限货位
|
|
|
|
int XStart = 0; int ZStart = 0;
|
|
int XEnd = 0; int ZEnd = 0;
|
|
string[] xyz = dr["FSTARTCELL"].ToString().Split('-');
|
|
if (xyz.Length > 2)
|
|
{
|
|
ZStart = Convert.ToInt32(xyz[0]);
|
|
XStart = Convert.ToInt32(xyz[1]);
|
|
|
|
}
|
|
string[] xyz2 = dr["FSTARTCELL"].ToString().Split('-');
|
|
if (xyz2.Length > 2)
|
|
{
|
|
ZEnd = Convert.ToInt32(xyz2[0]);
|
|
XEnd = Convert.ToInt32(xyz2[1]);
|
|
|
|
}
|
|
|
|
|
|
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")
|
|
{//20151120调度系统oracle的特殊语句
|
|
sql.Append("SELECT ").Append(" F_ManageTaskKindIndex, FID, MIN(POWER(FStartCol - ").Append(dr["FStartCol"]).Append(", 2) + POWER((FStartLayer - ").Append(
|
|
dr["FStartLayer"]).Append(") * 3, 2)) AS Expr1 FROM T_Manage_Task WHERE (FIntoStepOK = '0') AND rownum<=").Append(forkamount).Append(
|
|
" and (FSTATUS = 0 and FUseAwayFork<>'3') AND (FCONTROLTASKTYPE = ").Append(dr["FCONTROLTASKTYPE"]).Append(") AND (FLOGIC_AREA = '").Append(dr["FLOGIC_AREA"]).Append(
|
|
"') AND (FCONTORL_BATCH = '").Append(dr["FCONTORL_BATCH"]).Append("') AND (FLANEWAY = ").Append(dr["FLANEWAY"]).Append(
|
|
") AND (F_RELATIVECONTORLID = - 1) and F_ManageTaskKindIndex=").Append(dr["F_ManageTaskKindIndex"]).Append(" and FID<>").Append(dr["fid"]).Append(
|
|
sqladd.ToString()).Append(" GROUP BY F_ManageTaskKindIndex, FID order by Expr1 asc");
|
|
}
|
|
else
|
|
{ //20151120调度系统SQLServer的特殊语句,计算列、层
|
|
// 202410 HSCP - 修改增加Z FStartZ 坐标条件,双叉双伸,Z坐标系数*2
|
|
sql.Append("SELECT TOP ").Append(forkamount).Append(" F_ManageTaskKindIndex,FStartCol,FStartZ,FStartLayer, FID, MIN(POWER(FStartCol - ")
|
|
.Append(dr["FStartCol"]).Append(", 2) + POWER((FStartLayer - ").Append(dr["FStartLayer"]).Append(") * 3, 2) + POWER( ABS(FStartZ - ")
|
|
.Append(dr["FStartZ"]).Append(")* 2, 2)+ POWER(2-ABS(FStartCol - ").Append(dr["FStartCol"])
|
|
.Append("), 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, FStartCol,FStartZ,FStartLayer,FID order by Expr1 asc");
|
|
}
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++) // 找到相关任务,还要继续判断是否在用一个大格,X 货位双数列=相邻但数列+1
|
|
{
|
|
// HSYL 设置大货格内的两个任务关联: 偶数列-1 = 奇数列,同排才配对 ZStart = FStartZ
|
|
// HSYL 设置大货格内的两个任务关联: 偶数列-1 = 奇数列,同排才配对 ZStart = FStartZ
|
|
bool bUpdate = false;
|
|
int iRelativX = Convert.ToInt32(dv[i]["FStartCol"]);
|
|
int iRelativZ = Convert.ToInt32(dv[i]["FStartZ"]);
|
|
int iRelativY = Convert.ToInt32(dv[i]["FStartLayer"]);
|
|
#region 最优情况,大货格直接配对
|
|
if (XStart % 2 == 0 && (XStart - 1 == iRelativX) && ZStart == iRelativZ)
|
|
{
|
|
|
|
bUpdate = true;
|
|
}
|
|
else if (XStart % 2 == 1 && (XStart + 1 == iRelativX) && ZStart == iRelativZ)
|
|
{
|
|
|
|
bUpdate = true;
|
|
}
|
|
#endregion
|
|
// 不是最优,可以再判断找到任务有没有相同大货格任务,没有就强行配对
|
|
if (bUpdate == false && iRelativX % 2 == 0 && ZStart == iRelativZ) // 没有同排,同层,相邻2个以内的货位,找一个强行关联
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select FStartCol,FStartZ, FID 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("and FStartZ = ").Append(iRelativZ).Append(" and FStartLayer = ").Append(iRelativY).Append(" and FStartCol = ").Append(iRelativX - 1).Append(sqladd.ToString());
|
|
// 查找的关联有没有最优
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count == 0)
|
|
{
|
|
// 没有同格任务
|
|
bUpdate = true;
|
|
}
|
|
|
|
}
|
|
if (bUpdate == false && iRelativX % 2 == 1 && ZStart == iRelativZ) // 没有同排,同层,相邻2个以内的货位,找一个强行关联
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
// 查找的关联有没有最优
|
|
sql.Append("select FStartCol,FStartZ, FID 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("and FStartZ = ").Append(iRelativZ).Append(" and FStartLayer = ").Append(iRelativY).Append(" and FStartCol = ").Append(iRelativX + 1).Append(sqladd.ToString());
|
|
|
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv2.Count == 0)
|
|
{
|
|
// 没有同格任务
|
|
bUpdate = true;
|
|
}
|
|
}
|
|
|
|
if (bUpdate == true)
|
|
{
|
|
// 设置查询到的任务,F_RELATIVECONTORLID 字段为本任务
|
|
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());
|
|
break; // 设置一个就跳出
|
|
}
|
|
|
|
}
|
|
// 设置本任务,F_RELATIVECONTORLID 字段为自己,不会被循环查找
|
|
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();
|
|
dv2.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();
|
|
}
|
|
}
|
|
static int GetSameStartDeviceEnddeviceRouteID(int startdevice, int enddevice)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and F_StartDevice=F_EndDevice and (F_StartDevice=30100 or F_StartDevice=30200 or F_StartDevice=40100)");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0][0]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|