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.
6693 lines
353 KiB
6693 lines
353 KiB
using System.Runtime.InteropServices;
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
using System.Data;
|
|
using System;
|
|
using CommLayerFactory;
|
|
using ICommLayer;
|
|
using DBFactory;
|
|
using CommonLib;
|
|
using System.Diagnostics;
|
|
using System.Collections;
|
|
using System.Net.NetworkInformation;
|
|
using System.Security.Cryptography;
|
|
using System.Net.Sockets;
|
|
using System.Linq;
|
|
|
|
namespace WcfControlMonitorLib
|
|
{
|
|
|
|
/// <summary>
|
|
/// Creator:Richard.liu
|
|
/// ¼à¿Øµ÷¶ÈÀà
|
|
/// </summary>
|
|
|
|
public class CControl
|
|
{
|
|
int StackMutexXCoor = 4800;
|
|
int minStackMutexXCoor = 2400;
|
|
int StackZeroXCoor = 1950;
|
|
StringBuilder AheadDetectUnallow = new StringBuilder();//20110505
|
|
StringBuilder sql = new StringBuilder();
|
|
char[] dd = new char[1] { '.' };//20101124
|
|
string[] DS;//20101124
|
|
private Object thisLock = new Object();
|
|
DBOperator dbo = CStaticClass.dbo;
|
|
DBOperator dboM = CStaticClass.dboM;
|
|
//CGetState cgs = new CGetState();
|
|
Model.MDevice devinfo;
|
|
ISendDeviceOrder sdo;
|
|
CCommonFunction ccf = new CCommonFunction();
|
|
int _DeviceIdx = 0;//É豸Ë÷Òý
|
|
int _routeID = 0;//·¾¶Î¨Ò»Ë÷Òý
|
|
int _serialNumber = 0;//·¾¶ÉϵÄÉ豸·½ÏòÐÔÁ´±íµÄÐòºÅ
|
|
int _ManageTaskIdx = 0;//µ÷¶ÈÈÎÎñË÷Òý
|
|
int _ManageKindIdx = 0;//µ÷¶ÈÈÎÎñÀàÐÍ
|
|
int _DeviceOrder = 0;//É豸ÃüÁî
|
|
int _LockedState = 0;
|
|
int _Associate = 0;
|
|
int _ManTaskReserve = 0;
|
|
string _AheadDetect = "";
|
|
int _NumParam1 = 0;
|
|
int _NumParam2 = 0;
|
|
int _NumParam3 = 0;
|
|
int _NumParam4 = 0;
|
|
int _NumParam5 = 0;
|
|
int _NumParam6 = 0;
|
|
string _TxtParam = "-";
|
|
int _DeviceKind = 0;
|
|
int _OutsideAltDevice = 0;
|
|
int _InsideAltDevice = 0;
|
|
int _StartDevice = 0;
|
|
int _EndDevice = 0;
|
|
int _RouteKind = 0;
|
|
//CGetState cgs = new CGetState();
|
|
//int _UseAwayFork = 1;
|
|
int _AgvNo = 65535;
|
|
string _CControlError = "";//¼à¿Øµ÷¶ÈÀà´íÎó˵Ã÷
|
|
public string CControlError
|
|
{
|
|
get { return _CControlError; }
|
|
set
|
|
{
|
|
_CControlError = value;
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", _CControlError);
|
|
OnRefreshMonitor(rme);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ìù±ê»ú
|
|
/// </summary>
|
|
public static Socket socketSendPrint201;
|
|
|
|
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);
|
|
}
|
|
}
|
|
public CControl()
|
|
{
|
|
//dbo.Open();
|
|
}
|
|
//~CControl()
|
|
//{
|
|
// dbo.Close();
|
|
//}
|
|
public void StartOrder()
|
|
{
|
|
//Ê×Ïȼì²âµÚÒ»¸öµ÷¶ÈÈÎÎñµ¥µÄ¡°µÚÒ»¸ö¡±£¨ËùÓÐÊ£ÏÂÖеĵÚÒ»¸ö£©É豸ÊÇ·ñ±»Õ¼Ó㬱»Õ¼ÓÃÔòÖ´ÐÐÏÂÒ»¸öµ÷¶ÈÈÎÎñµ¥£»
|
|
//È»ºó¼ì²âµÚÒ»¸öÉ豸µÄF_AheadDetect¶¼ÊÇ·ñÂú×ãÌõ¼þ£¬²»Âú×㣬ÔòÖ´ÐÐÏÂÒ»¸öµ÷¶ÈÈÎÎñµ¥£»
|
|
//×îºó¿ªÊ¼Ö´ÐÐʱ¼ì²éͬ²½ÔËÐеĹØÁªÉ豸F_AssociateDeviceIndex,×¼±¸¸ø¸ÃÉ豸·¢Ö¸Á
|
|
//¸ü¸Ä×÷Òµ¼Ç¼µÄ״̬F_StatusΪ1,¸ü¸ÄÉ豸ΪռÓÃ״̬£¨T_Base_deviceµÄF_LockedState=É豸ָÁîµ¥£©
|
|
//¸øµ÷¶ÈÈÎÎñ±í»ØÐ´µ÷¶ÈÈÎÎñIO_ControlµÄÕýÔÚÖ´ÐÐ״̬FSTATUS=1;T_Manage_TaskµÄÕýÔÚÖ´ÐÐ״̬FSTATUS=1
|
|
//·¾¶Ã÷ϸ±íF_LockedDeviceIndexÀïµÄËùÓжÔÓ¦É豸Ë÷Òý¼ÓËø£¬µ«ÊǹØÁªÉ豸²»¼ÓËø
|
|
StringBuilder taskkind = new StringBuilder();
|
|
DataView dv = new DataView(); DataView dvM = new DataView(); DataView dvD = new DataView();
|
|
string tray = string.Empty;//AGV ÈÎÎñÍÐÅ̺Å
|
|
try
|
|
{
|
|
#region ²éѯAGVÈÎÎñ״̬
|
|
sql.Clear();
|
|
//sql.Append("select * from AGV_TASK where AGV_TASK_STATUS in(5)");
|
|
sql.Append("select * from AGV_TASK where AGV_TASK_STATUS in(1,2,3,4,5,6)");
|
|
var result = dbo.Query(sql.ToString()).Tables[0];
|
|
if (result.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow item in result.Rows)
|
|
{
|
|
int status = Convert.ToInt32(item["AGV_TASK_STATUS"].ToString());
|
|
sql.Clear();
|
|
sql.AppendFormat("select * from T_Monitor_Task where F_DeviceCommandIndex = 4 and F_ManageTaskIndex = {0}", item["fid"]);
|
|
var data = dbo.Query(sql.ToString()).Tables[0];
|
|
if (status == 5)
|
|
{
|
|
if (data.Rows.Count > 0)
|
|
{
|
|
CGetState cgs = new CGetState();
|
|
cgs.ActionComplete(Convert.ToInt32(data.Rows[0]["F_DeviceIndex"]), Convert.ToInt32(data.Rows[0]["F_MonitorIndex"]), 1);
|
|
|
|
}
|
|
}
|
|
else if (status == 1)
|
|
{
|
|
if (data.Rows.Count > 0)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update IO_CONTROL set CONTROL_STATUS=10 where CONTROL_ID =").Append(item["fid"]);
|
|
dboM.ExecuteSql(sql.ToString());
|
|
|
|
}
|
|
}
|
|
if (status == 3)
|
|
{
|
|
if (data.Rows.Count > 0)
|
|
{
|
|
//AGV È¡Íê»õºó£¬Çå³þÈ¡»õÉè±¸Ô¤Ô¼Ëø
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append($"SELECT * FROM T_Base_Device WHERE F_DeviceIndex = {data.Rows[0]["F_NumParam2"]} AND F_LockedState = {data.Rows[0]["F_MonitorIndex"]}");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append($"update T_Base_Device set F_LockedState = 0 where F_DeviceIndex = {data.Rows[0]["F_NumParam2"]} AND F_LockedState = {data.Rows[0]["F_MonitorIndex"]}");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
}
|
|
}
|
|
}
|
|
//AGV վ̨ȡ»õµØÖ·Îª29008 È¡»õÍê³É£¬Çå³ý 29008 վ̨¼Ç¼ÍÐÅ̺ÅÐÅÏ¢
|
|
if (status == 3 && Convert.ToInt32(item["START_DEVICE_CODE"]) == 29009)
|
|
{
|
|
dvD = dbo.ExceSQL($"SELECT FPALLETBARCODE FROM T_Manage_Task where FID = {item["FID"]}").Tables[0].DefaultView;
|
|
if (dvD.Count > 0)
|
|
{
|
|
tray = dvD[0]["FPALLETBARCODE"].ToString();
|
|
dvD = dbo.ExceSQL("SELECT F_PALLETBARCODE FROM T_Base_Device where F_DeviceIndex = 29008").Tables[0].DefaultView;
|
|
if (dvD.Count > 0)
|
|
{
|
|
//¸ù¾Ý È¡»õÍê³ÉÐÅÏ¢£¬ÒƳý 29008 ÍÐÅÌÐÅÏ¢
|
|
string[] trayList = dvD[0]["F_PALLETBARCODE"].ToString().Split(',').Distinct().Where(c => !string.IsNullOrEmpty(c)).ToArray();
|
|
if (trayList.Contains(tray))
|
|
{
|
|
string[] newTray = trayList.Except(tray.Split(',')).Distinct().Where(c => !string.IsNullOrEmpty(c)).ToArray();
|
|
sql.Append($"update T_Base_Device set F_PALLETBARCODE = '{string.Join(",", newTray)}' where F_DeviceIndex = 29008 ");
|
|
dbo.ExceSQL(sql.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
if (CStaticClass.Order == true)
|
|
{
|
|
taskkind.Append(" (F_ManageTaskKindIndex = 1 or F_ManageTaskKindIndex = 2 or F_ManageTaskKindIndex = 4) "); //µ÷¶ÈÈÎÎñÓëµ÷¶ÈÉú³ÉµÄ×Ô¶¯ÈÎÎñ
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
dvM = new DataView();
|
|
|
|
char[] sep = new char[1] { '-' };
|
|
|
|
//»ñµÃ¹ÜÀíµ¥¾Ý
|
|
sql.Remove(0, sql.Length);
|
|
//20120820
|
|
sql.Append("SELECT DISTINCT F_ManageTaskIndex AS MIndex,F_MonitorTaskLevel,F_ManageTaskKindIndex,F_SplitTime FROM T_Monitor_Task where ").Append(
|
|
taskkind.ToString()).Append(" order by F_ManageTaskKindIndex desc, F_MonitorTaskLevel desc,F_SplitTime asc, F_ManageTaskIndex asc");//20120616
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
try
|
|
{
|
|
//1£ºÌáȡÿ¸ö¹ÜÀíµ¥¾ÝµÄµÚÒ»¸öÉ豸ָÁî
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select top 1 min(F_MonitorIndex) as minMidx,f_status from T_Monitor_Task where ").Append(taskkind.ToString()).Append(" and F_ManageTaskIndex = ").Append(dv[i]["MIndex"]).Append(" GROUP BY F_MonitorIndex, F_Status");
|
|
|
|
dvM = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvM.Count > 0)
|
|
{//20110412
|
|
|
|
if (dvM[0]["F_Status"].ToString() == "0" && dvM[0]["minMidx"] != DBNull.Value)
|
|
{
|
|
SendMonitorTask(Convert.ToInt32(dvM[0]["minMidx"]));
|
|
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = string.Format("·¢ËÍÃüÁîµ÷ÓÃStartOrderʱ£º{0}", ex.StackTrace + ex.Message);
|
|
}
|
|
|
|
}//forÓï¾ä½áÊø
|
|
//20091107
|
|
|
|
|
|
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
|
|
dvM.Dispose();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Ìáȡÿ¸ö¹ÜÀíµ¥¾ÝµÄµÚÒ»¸öÉ豸ÊÇ·ñ±»Ëø¶¨,true±íʾ±»Ëø¶¨£»false±íʾ¿ÕÏÐ
|
|
/// </summary>
|
|
/// <param name="minMidx">µ÷¶ÈÈÎÎñºÅ</param>
|
|
/// <returns>true±íʾ±»Ëø¶¨£»false±íʾ¿ÕÏÐ</returns>
|
|
public bool GetFirstDeviceIFLocked(int minMidx, bool checkLockedstate)
|
|
{
|
|
char[] sep = new char[1] { '-' };
|
|
int msgIdx = 0;//ÏûÏ¢±àºÅ
|
|
int adidx = 0;//¹ØÁªÉ豸µÄÉ豸ָÁîË÷Òý
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
|
|
//»ñµÃÒª·¢Ë͵ÄÐÅÏ¢
|
|
if (GetSendInfo(minMidx) == false)
|
|
{//20120420
|
|
return true;
|
|
}
|
|
|
|
int DeviceIdx = _DeviceIdx;//É豸Ë÷Òý
|
|
int routeID = _routeID;//·¾¶Î¨Ò»Ë÷Òý
|
|
int serialNumber = _serialNumber;//·¾¶ÉϵÄÉ豸·½ÏòÐÔÁ´±íµÄÐòºÅ
|
|
int ManageTaskIdx = _ManageTaskIdx;//µ÷¶ÈÈÎÎñË÷Òý
|
|
int ManageKindIdx = _ManageKindIdx;//µ÷¶ÈÈÎÎñÀàÐÍ
|
|
int DeviceOrder = _DeviceOrder;//É豸ÃüÁî
|
|
int LockedState = _LockedState;
|
|
int Associate = _Associate;
|
|
int ManTaskReserve = _ManTaskReserve;
|
|
string AheadDetect = _AheadDetect;
|
|
int NumParam1 = _NumParam1;
|
|
int NumParam2 = _NumParam2;
|
|
int NumParam3 = _NumParam3;
|
|
int NumParam4 = _NumParam4;
|
|
int NumParam5 = _NumParam5;
|
|
int NumParam6 = _NumParam6;
|
|
string TxtParam = _TxtParam;
|
|
int DeviceKind = _DeviceKind;
|
|
int OutsideAltDevice = _OutsideAltDevice;
|
|
int InsideAltDevice = _InsideAltDevice;
|
|
int StartDevice = _StartDevice;
|
|
int EndDevice = _EndDevice;
|
|
int RouteKind = _RouteKind;
|
|
int AgvNo = _AgvNo;
|
|
|
|
#region É豸¹ÊÕÏʱÊÇ·ñ×Ô¶¯¸ÄµÀ
|
|
|
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
|
{//20100108
|
|
#region Ö»Õë¶ÔÓëRGVÓйصÄÎå¸ö¶¯×÷ÅжϸÄ·¾¶
|
|
//20100108 ÊäËÍ»úµÄ½Ó»õ¶Ô½ÓÖ¸Áî²»²ÎÓë¸ÄµÀ
|
|
if ((_DeviceKind == 4) || ((_DeviceKind == 2) && ((_DeviceOrder == 3))) && (RouteKind != 3))
|
|
{
|
|
bool IfModify = false, IfUseNegativeDevice = false;//20100610
|
|
//20091102 RGVµÄµÚÒ»¸ö±»Ìáǰ´¥·¢µÄÔ˶¯Ö¸Áî²»ÐèÒª¸ü¸Ä·¾¶
|
|
if ((_DeviceKind == 4) && (_DeviceOrder == 7) &&
|
|
(ccf.GetSerialNumberFromRouteDevice(_routeID, _DeviceIdx) >
|
|
ccf.GetSerialNumberFromRouteDevice(_routeID, _NumParam1)))
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(ManageTaskIdx).Append(") AND (F_ManageTASKKINDINDEX = 1)");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//20091218
|
|
|
|
if ((dv[0]["mmi"] != DBNull.Value) && (dv[0]["mmi"].ToString() == minMidx.ToString()))
|
|
{
|
|
IfModify = true;
|
|
IfUseNegativeDevice = true;//20100610
|
|
}
|
|
}
|
|
|
|
}
|
|
else if ((_DeviceKind == 4) && ((_DeviceOrder == 3) || (_DeviceOrder == 5)))
|
|
{//20100108¶Ô´©Ëó³µËÍ»õ¶Ô½ÓÓ¦¸Ã¼ÓÓÚÏÞÖÆ£¬ÔØ»õ£¬¿ÕÏÐ
|
|
devinfo = Model.CGetInfo.DeviceInfo[DeviceIdx];
|
|
if ((devinfo.RunState == 0) && (devinfo.HaveGoods == true))
|
|
{
|
|
IfModify = true;
|
|
IfUseNegativeDevice = false;//20100610
|
|
}
|
|
devinfo = null;
|
|
}
|
|
else
|
|
{
|
|
IfModify = true;
|
|
IfUseNegativeDevice = true;//20100610
|
|
|
|
}
|
|
if (IfModify == true)
|
|
{
|
|
int altsn = ccf.GetSerialNumberFromRouteDevice(_routeID, _OutsideAltDevice);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_SerialNumber FROM T_Base_Device,T_Base_Route_Device,T_Base_Device_State where ").Append(
|
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_ErrorCode =F_DeviceErrorIndex and ").Append(
|
|
" T_Base_Device_State.F_DeviceKindIndex = T_Base_Device.F_DeviceKindIndex AND T_Base_Device.F_ErrorCode > 0 AND ").Append(
|
|
" T_Base_Route_Device.F_SerialNumber > ").Append(_serialNumber).Append(" AND T_Base_Route_Device.F_SerialNumber > ").Append(
|
|
altsn).Append(" AND T_Base_Route_Device.F_RouteIDSub = ").Append(_routeID).Append(" and F_ErrorLevel=2 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//ÅжÏÄÜ·ñ¸ÄµÀ;Ïò¹ÜÀíÉêÇë¸ÄµÀ;°ÑManageTaskIdx£¬ManageKindIdx µÄµ÷¶ÈÈÎÎñÈ«²¿ÉêÇë¸ÄµÀ
|
|
if (GetUsableDestination(_ManageTaskIdx, _ManageKindIdx) == true)
|
|
{
|
|
|
|
return true;
|
|
}
|
|
}
|
|
#region RGVÄ¿±êλÖñ»Õ¼ÓÃÐèÒªÉêÇë¸ÄµÀ
|
|
//20100610
|
|
devinfo = null;
|
|
if (_DeviceKind == 4)
|
|
{//RGV
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(CDisassembleTask.GetNextDevice(_routeID, _serialNumber)[0]);
|
|
}
|
|
else
|
|
{//ÊäËÍ»úËÍ»õ
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(CDisassembleTask.GetNextDevice(_routeID, _serialNumber)[0]);//RGV
|
|
int sn = 0;
|
|
if (devinfo != null)
|
|
{
|
|
sn = ccf.GetSerialNumberFromRouteDevice(_routeID, devinfo.DeviceIndex);
|
|
}
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(CDisassembleTask.GetNextDevice(_routeID, sn)[0]);//½Ó»õÊäËÍ»ú
|
|
|
|
}
|
|
if (devinfo != null)
|
|
{
|
|
if (devinfo.HaveGoods == true)
|
|
{//Ä¿±êλÖñ»Õ¼Óã¬ÉêÇë¸ÄµÀ
|
|
if (GetRGVIdleDestination(_ManageTaskIdx, _ManageKindIdx, devinfo.DeviceIndex, IfUseNegativeDevice) == true)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (DeviceKind == 6)
|
|
{//20100512 AGV
|
|
#region AGV
|
|
|
|
if (AgvNo != 65535)//Èç¹ûÊÇÒѾ·ÖÅä³µºÅµÄAGVÃüÁ¼ì²éÕâ¸ö³µºÅ¶ÔÓ¦µÄÉ豸Ë÷ÒýÊÇ·ñ±»Ëø¶¨
|
|
{
|
|
LockedState = Convert.ToInt32(dbo.GetSingle("SELECT F_LockedState FROM T_Base_Device where F_DeviceIndex=" + (DeviceIdx + AgvNo) + ""));
|
|
if (LockedState > 0) return true;
|
|
}
|
|
if (AheadDetectOK(minMidx, _AheadDetect) == true)//Ìáǰ¼ì²âͨ¹ý
|
|
{
|
|
#region Ë«²æAGV¼ì²â£¬ÄÜͬ²½µÄ¹ØÁªÈÎÎñÊÇ·ñAheadDetectOK cz20240226¸Ä È¡ÏûË«²æ¼ì²â
|
|
//20100323
|
|
//devinfo = Model.CGetInfo.GetDeviceInfo(_DeviceIdx);
|
|
//if (devinfo.IfCorrelDoubleFork == "1")
|
|
//{
|
|
// int[] synctask = Model.CGeneralFunction.MutiForkIfSync(minMidx, _DeviceIdx, _DeviceKind);
|
|
// if (synctask != null)//20120616
|
|
// {
|
|
// if ((synctask.GetLength(0) == 1) && (synctask[0] == minMidx)) return true;//20120616µÈ´ýδ²ð·ÖµÄ¿Éͬ²½Ö´ÐеÄÈÎÎñ
|
|
// string[] df = null;
|
|
// Dictionary<int, string[]> mforkmonitorinfo = Model.CGeneralFunction.GetDoubleForkMonitorInfo(minMidx, _DeviceIdx);
|
|
// foreach (int i in mforkmonitorinfo.Keys)
|
|
// {
|
|
// df = mforkmonitorinfo[i];
|
|
// if (df != null)
|
|
// {
|
|
// if (AheadDetectOK(Convert.ToInt32(df[0]), df[1]) == false)//¶à²æ¹ØÁªÌáǰ¼ì²âʧ°Ü
|
|
// {
|
|
// return true;
|
|
// }
|
|
// #region ¹ØÁªÖ¸Áî²»ÊǵÚÒ»¸öÖ¸Áî²»ÄÜ·¢ËÍ
|
|
// int rmankind = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(Convert.ToInt32(df[0]));
|
|
// int rman = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(Convert.ToInt32(df[0]));
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(rman).Append(") AND (F_ManageTASKKINDINDEX = ").Append(rmankind).Append(")");
|
|
// dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
// if (dv.Count > 0)
|
|
// {
|
|
// if ((dv[0]["mmi"] != DBNull.Value) && (dv[0]["mmi"].ToString() != df[0]))
|
|
// {
|
|
// return true;
|
|
// }
|
|
// }
|
|
// #endregion
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
//}
|
|
#endregion
|
|
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{//·ÇAGVÉ豸£ºÊäËÍ»ú¡¢¶Ñ¶â»ú¡¢RGVµÈ
|
|
#region ·ÇAGVÉ豸£ºÊäËÍ»ú¡¢¶Ñ¶â»ú¡¢RGVµÈ
|
|
|
|
//µÚÒ»¸öÉ豸ÊÇ·ñ±»Õ¼Óã¬RGVºÍ¶Ñ¶â»úÒª¿¼ÂÇ·Ö²½¿ØÖÆÊ±£¬Ã»Ö´ÐÐÍêÁ¬Ðø¶¯×÷ʱ²»½ÓÊÜеĵ÷¶ÈÈÎÎñ
|
|
|
|
if (((_LockedState == 0) && (checkLockedstate == true)) || (checkLockedstate == false))
|
|
{
|
|
|
|
#region ¼ì²éRGV¡¢¶Ñ¶â»úµÈÊÇ·ñ±»µ÷¶ÈÈÎÎñÔ¤Ô¼F_ManTaskReserve
|
|
|
|
if (_ManTaskReserve > 0 && DeviceKind != 2)//20140309
|
|
{
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(_DeviceIdx);
|
|
if (devinfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
#region ¶à²æ¹ØÁª
|
|
Dictionary<int, string[]> mforkmonInfo = Model.CGeneralFunction.GetDoubleForkMonitorInfo(minMidx, _DeviceIdx);
|
|
bool iftrue = true;
|
|
int relfid = ccf.GetRELATIVECONTORLIDFromManageTask(_ManageKindIdx, _ManageTaskIdx);
|
|
|
|
if (_ManTaskReserve.ToString() == _ManageKindIdx.ToString() + _ManageTaskIdx.ToString())
|
|
{
|
|
iftrue = false;
|
|
}
|
|
else
|
|
{
|
|
if (relfid > 0)
|
|
{//20130704
|
|
dv = dbo.ExceSQL(string.Format("SELECT FID FROM T_Manage_Task where F_RELATIVECONTORLID={0} and F_ManageTaskKindIndex={1}", relfid, _ManageKindIdx)).Tables[0].DefaultView;
|
|
for (int mt = 0; mt < dv.Count; mt++)
|
|
{
|
|
if (_ManTaskReserve.ToString() == _ManageKindIdx.ToString() + dv[mt]["FID"].ToString())
|
|
{
|
|
iftrue = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (iftrue == true)
|
|
{
|
|
UpdateAheadDetectUnallow(new StringBuilder(_DeviceIdx.ToString() + "±»ÈÎÎñÔ¤Ô¼" + _ManTaskReserve.ToString().Substring(1)), minMidx);
|
|
return true;
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
if (_ManTaskReserve.ToString() != _ManageKindIdx.ToString() + _ManageTaskIdx.ToString())
|
|
{
|
|
UpdateAheadDetectUnallow(new StringBuilder(_DeviceIdx.ToString() + "±»ÈÎÎñÔ¤Ô¼" + _ManTaskReserve.ToString().Substring(1)), minMidx);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
//3£ºF_AheadDetect¼ì²â(¼ì²â¿ª¹Ø±àºÅ×é¡°;¡±)
|
|
if (AheadDetectOK(minMidx, _AheadDetect) == true)//Ìáǰ¼ì²âͨ¹ý
|
|
{
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(_DeviceIdx);
|
|
if (_DeviceIdx == devinfo.VirtualStack)
|
|
{//20111020
|
|
AssignStackNo(_DeviceIdx, minMidx, ManageKindIdx, ManageTaskIdx);
|
|
return true;//20120906
|
|
|
|
}
|
|
#region ¶à²æ¶Ñ¶â»ú¼ì²â£¬ÄÜͬ²½µÄDoubleForkÊÇ·ñAheadDetectOK
|
|
//20100323
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(_DeviceIdx);
|
|
if (devinfo.IfCorrelDoubleFork == "1" && devinfo.DeviceKind == 1)
|
|
{
|
|
int[] synctask = Model.CGeneralFunction.MutiForkIfSync(minMidx, _DeviceIdx, _DeviceKind);
|
|
if (synctask != null)//20120616
|
|
{
|
|
if ((synctask.GetLength(0) == 1) && (synctask[0] == minMidx)) return true;//20120616µÈ´ýδ²ð·ÖµÄ¿Éͬ²½Ö´ÐеÄÈÎÎñ
|
|
string[] df = null;
|
|
Dictionary<int, string[]> mforkmonitorinfo = Model.CGeneralFunction.GetDoubleForkMonitorInfo(minMidx, _DeviceIdx);
|
|
foreach (int i in mforkmonitorinfo.Keys)
|
|
{
|
|
if (Array.IndexOf<int>(synctask, i) >= 0)
|
|
{//20120906
|
|
df = mforkmonitorinfo[i];
|
|
if (df != null)
|
|
{
|
|
if (AheadDetectOK(Convert.ToInt32(df[0]), df[1]) == false)//¶à²æ¹ØÁªÌáǰ¼ì²âʧ°Ü
|
|
{
|
|
return true;
|
|
}
|
|
#region ¹ØÁªÖ¸Áî²»ÊǵÚÒ»¸öÖ¸Áî²»ÄÜ·¢ËÍ
|
|
int rmankind = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(Convert.ToInt32(df[0]));
|
|
int rman = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(Convert.ToInt32(df[0]));
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(rman).Append(") AND (F_ManageTASKKINDINDEX = ").Append(rmankind).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if ((dv[0]["mmi"] != DBNull.Value) && (dv[0]["mmi"].ToString() != df[0]))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
//¼ì²éͬ²½ÔËÐеĹØÁªÉ豸F_AssociateDeviceIndex
|
|
//4£ºÊÇ·ñÓйØÁªÉ豸ÃüÁ
|
|
#region ÊÇ·ñÓйØÁªÉ豸ÃüÁî
|
|
|
|
//AssociateDevice = ccf.GetAssociateDevice(minMidx);
|
|
if (_Associate != 0)
|
|
{
|
|
//5£ºÈç¹ûÓУ¬ÕÒµ½¿ÉÒÔÔËÐеĹØÁªÉ豸µÄÉ豸ָÁî,ÄÜ·ñÔËÐУ¿
|
|
//ÖØ¸´µÝ¹éµ½2
|
|
//split = AssociateDevice.Split(sep);
|
|
adidx = _Associate;
|
|
if (adidx != 0)
|
|
{
|
|
#region ÓйØÁªÈÎÎñ
|
|
|
|
if (ccf.GetAssociateMonitor(minMidx) == 0)
|
|
{
|
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", "É豸ָÁ" + minMidx.ToString() + "ÎÞ·¨»ñµÃ¹ØÁªÈÎÎñ" + adidx.ToString() + "£¬²»ÄÜ·¢ËÍ´ËÀàÃüÁ");
|
|
OnRefreshMonitor(rmea);
|
|
return true;
|
|
}
|
|
if (GetFirstDeviceIFLocked(adidx, false) == false)
|
|
{
|
|
//6£º·¢Ë͹ØÁªÉ豸ÃüÁî
|
|
//CStaticClass.MessageIndex++;
|
|
CStaticClass.MessageIndex = 1;
|
|
msgIdx = (CStaticClass.MessageIndex);
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(_DeviceIdx);
|
|
//ÅжÏÊÇ·ñΪ¶Ñ¶â»úÉ豸
|
|
bool sendok;
|
|
int[] gc = new int[6] { _NumParam2, _NumParam3, _NumParam1, _NumParam5, _NumParam6, _NumParam4 }; //ccf.GetCoordinatesFromMonitorTask(adidx);//»ñµÃ×ø±ê
|
|
|
|
if ((_DeviceKind == 1) || (_DeviceKind == 6))
|
|
{
|
|
|
|
//1£º¶Ñ¶â»ú£»4£ºRGV£»6£ºAGVÈç¹ûÐèÒªÓÅ»¯µ÷¶È£¨É豸±íµÄF_NeedOptimize='1'£©
|
|
//Ö±½ÓдÈë±í£ºT_Monitor_Task_Child£¬²»·¢ËÍÃüÁî
|
|
if (ccf.NeedOptimize(_DeviceIdx) == true)
|
|
{
|
|
ccf.InsertMonitorOptimizeChildTask(adidx);
|
|
sendok = true;
|
|
}
|
|
else
|
|
{
|
|
sendok = sdo.SendDeviceOrder(msgIdx, adidx, _DeviceOrder,
|
|
_DeviceIdx, gc[0], gc[1], gc[2], gc[3], gc[4], gc[5]);
|
|
}
|
|
|
|
}
|
|
else if (_DeviceKind == 4)
|
|
{
|
|
if (ccf.NeedOptimize(_DeviceIdx) == true)
|
|
{
|
|
ccf.InsertMonitorOptimizeChildTask(adidx);
|
|
sendok = true;
|
|
}
|
|
else
|
|
{
|
|
sendok = sdo.SendDeviceOrder(msgIdx, adidx, _DeviceOrder, _DeviceIdx, gc[2]);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
sendok = sdo.SendDeviceOrder(msgIdx, adidx, _DeviceOrder, _DeviceIdx, gc[5]);
|
|
}
|
|
if (sendok == false)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
//8£º¸ü¸Ä×÷Òµ¼Ç¼µÄ״̬F_StatusΪ1,¸ü¸ÄÉ豸ΪռÓÃ״̬£¨T_Base_deviceµÄF_LockedState=É豸ָÁîµ¥£©
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_StartTime='").Append(DateTime.Now.ToString("u")).Append("',F_Status='1' where F_MonitorIndex=").Append(adidx);
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
//·µ»Øµ½ÔÀ´É豸ֵ
|
|
_DeviceIdx = DeviceIdx;//É豸Ë÷Òý
|
|
_routeID = routeID;//·¾¶Î¨Ò»Ë÷Òý
|
|
_serialNumber = serialNumber;//·¾¶ÉϵÄÉ豸·½ÏòÐÔÁ´±íµÄÐòºÅ
|
|
_ManageTaskIdx = ManageTaskIdx;//µ÷¶ÈÈÎÎñË÷Òý
|
|
_ManageKindIdx = ManageKindIdx;//µ÷¶ÈÈÎÎñÀàÐÍ
|
|
_DeviceOrder = DeviceOrder;//É豸ÃüÁî
|
|
_LockedState = LockedState;
|
|
_Associate = Associate;
|
|
_ManTaskReserve = ManTaskReserve;
|
|
_AheadDetect = AheadDetect;
|
|
_NumParam1 = NumParam1;
|
|
_NumParam2 = NumParam2;
|
|
_NumParam3 = NumParam3;
|
|
_NumParam4 = NumParam4;
|
|
_NumParam5 = NumParam5;
|
|
_NumParam6 = NumParam6;
|
|
_TxtParam = TxtParam;
|
|
_DeviceKind = DeviceKind;
|
|
_OutsideAltDevice = OutsideAltDevice;
|
|
_InsideAltDevice = InsideAltDevice;
|
|
_StartDevice = StartDevice;
|
|
_EndDevice = EndDevice;
|
|
_RouteKind = RouteKind;
|
|
_AgvNo = AgvNo;
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
#endregion
|
|
}
|
|
else//
|
|
{
|
|
#region MyRegion
|
|
|
|
|
|
//·µ»Øµ½ÔÀ´É豸ֵ
|
|
_DeviceIdx = DeviceIdx;//É豸Ë÷Òý
|
|
_routeID = routeID;//·¾¶Î¨Ò»Ë÷Òý
|
|
_serialNumber = serialNumber;//·¾¶ÉϵÄÉ豸·½ÏòÐÔÁ´±íµÄÐòºÅ
|
|
_ManageTaskIdx = ManageTaskIdx;//µ÷¶ÈÈÎÎñË÷Òý
|
|
_ManageKindIdx = ManageKindIdx;//µ÷¶ÈÈÎÎñÀàÐÍ
|
|
_DeviceOrder = DeviceOrder;//É豸ÃüÁî
|
|
_LockedState = LockedState;
|
|
_Associate = Associate;
|
|
_ManTaskReserve = ManTaskReserve;
|
|
_AheadDetect = AheadDetect;
|
|
_NumParam1 = NumParam1;
|
|
_NumParam2 = NumParam2;
|
|
_NumParam3 = NumParam3;
|
|
_NumParam4 = NumParam4;
|
|
_NumParam5 = NumParam5;
|
|
_NumParam6 = NumParam6;
|
|
_TxtParam = TxtParam;
|
|
_DeviceKind = DeviceKind;
|
|
_OutsideAltDevice = OutsideAltDevice;
|
|
_InsideAltDevice = InsideAltDevice;
|
|
_StartDevice = StartDevice;
|
|
_EndDevice = EndDevice;
|
|
_RouteKind = RouteKind;
|
|
#endregion
|
|
CControlError = string.Format("²ð·Öµ÷¶ÈÈÎÎñµÃµ½µÄÉ豸ָÁîÓëÏêϸ·¾¶µÄ¼ìË÷µ½µÄ¹ØÁªÉ豸ָÁƥÅ䣬ϵͳ×÷ΪûÓйØÁªÉ豸ָÁî´¦Àí£¡");
|
|
return false;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
#region ·µ»Øµ½ÔÀ´É豸ֵ
|
|
|
|
//·µ»Øµ½ÔÀ´É豸ֵ
|
|
_DeviceIdx = DeviceIdx;//É豸Ë÷Òý
|
|
_routeID = routeID;//·¾¶Î¨Ò»Ë÷Òý
|
|
_serialNumber = serialNumber;//·¾¶ÉϵÄÉ豸·½ÏòÐÔÁ´±íµÄÐòºÅ
|
|
_ManageTaskIdx = ManageTaskIdx;//µ÷¶ÈÈÎÎñË÷Òý
|
|
_ManageKindIdx = ManageKindIdx;//µ÷¶ÈÈÎÎñÀàÐÍ
|
|
_DeviceOrder = DeviceOrder;//É豸ÃüÁî
|
|
_LockedState = LockedState;
|
|
_Associate = Associate;
|
|
_ManTaskReserve = ManTaskReserve;
|
|
_AheadDetect = AheadDetect;
|
|
_NumParam1 = NumParam1;
|
|
_NumParam2 = NumParam2;
|
|
_NumParam3 = NumParam3;
|
|
_NumParam4 = NumParam4;
|
|
_NumParam5 = NumParam5;
|
|
_NumParam6 = NumParam6;
|
|
_TxtParam = TxtParam;
|
|
_DeviceKind = DeviceKind;
|
|
_OutsideAltDevice = OutsideAltDevice;
|
|
_InsideAltDevice = InsideAltDevice;
|
|
_StartDevice = StartDevice;
|
|
_EndDevice = EndDevice;
|
|
_RouteKind = RouteKind;
|
|
|
|
#endregion
|
|
return false;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = string.Format("·¢ËÍÃüÁîµ÷ÓÃGetFirstDeviceIFLockedʱ£º{0}", ex.StackTrace + ex.Message);
|
|
|
|
return true;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ¼ì²âÖ¸¶¨É豸ÃüÁîµÄÖ´ÐÐÏȾöÌõ¼þÊÇ·ñ³ÉÁ¢
|
|
/// </summary>
|
|
/// <param name="minMidx">¼à¿ØÎ¨Ò»Ë÷Òý</param>
|
|
/// <returns>ÊÇ·ñ¼ì²âͨ¹ý£¬true±íʾÉ豸ִÐÐÃüÁîµÄÏȾöÌõ¼þ³ÉÁ¢</returns>
|
|
public bool AheadDetectOK(int minMidx, string _AheadDetect)
|
|
{
|
|
//TODO Ìõ¼þ¼ì²â
|
|
AheadDetectUnallow.Remove(0, AheadDetectUnallow.Length);//20110505
|
|
int[] States;
|
|
string dtime = DateTime.Now.ToString("u");
|
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
|
int DeviceIdx = _DeviceIdx;
|
|
int TaskIdx = minMidx;
|
|
int fid = ccf.GetManageTaskIndexfromMonitor(TaskIdx);
|
|
int mti = ccf.GetManageTaskKindIndexFromMonitor(TaskIdx);
|
|
int DeviceKind = ccf.GetDeviceKindIdx(DeviceIdx);//20100617
|
|
int order = ccf.GetDeviceOrderFromMonitor(TaskIdx);
|
|
string barcode = ccf.GetBarCodeFromMonitor(minMidx);
|
|
|
|
int StartDevice = _StartDevice;//µ±Ç°µ÷¶ÈÈÎÎñÆðµã
|
|
int EndDevice = _EndDevice;//µ±Ç°µ÷¶ÈÈÎÎñÖÕµã
|
|
int EXECUTIONCOUNT = 0;//ÈÎÎñÖ´ÐÐÊý
|
|
|
|
#region ²¹³ä¶¥Éý»ú²»ÔÚ¸ßλµÄ¶¥ÉýÃüÁî
|
|
//if ((DeviceIdx >= 35000) && (DeviceIdx <= 35003)&&(order ==4))
|
|
//{//20120110²¹³ä¶¥Éý»ú²»ÔÚ¸ßλµÄ¶¥ÉýÃüÁî
|
|
|
|
// if (_AheadDetect.IndexOf("D-32036.6") >= 0)
|
|
// {
|
|
// if(CStaticClass.GetDevicePhotoelectric(32036,7)==1)
|
|
// {
|
|
// InsertUpDeviceUP(32036, mti, fid,minMidx);
|
|
// }
|
|
// }
|
|
// else if (_AheadDetect.IndexOf("D-32049.6") >= 0)
|
|
// {
|
|
// if (CStaticClass.GetDevicePhotoelectric(32049, 7) == 1)
|
|
// {
|
|
// InsertUpDeviceUP(32049, mti, fid, minMidx);
|
|
// }
|
|
// }
|
|
//}
|
|
#endregion
|
|
//20100706
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
|
if (ccf.GetBarCodeFromMonitor(minMidx) == "brbrbr")//±ÜÈÃÖ¸Áî¼ì²âÌõ¼þ20120110
|
|
{
|
|
int zc = 1, xc = 0;
|
|
GetStackRunX_Zcoor(DeviceIdx, out xc, out zc);
|
|
if (devinfo.RunState == 0 && xc == 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
//¼ì²â(¼ì²â¿ª¹Ø±àºÅ×é¡°;¡±)
|
|
DataView dv = new DataView();
|
|
DataView dvdv = new DataView();
|
|
try
|
|
{
|
|
|
|
if (devinfo.CommType == "OPCClient")//20100706 Ö»ÓÐOPCClientͨѶÀàÐ͵ļì²éÉ豸״̬
|
|
{
|
|
#region OPCͨѶÉ豸¼ì²âÉ豸ÊÇ·ñ¹ÊÕÏ
|
|
|
|
|
|
// //gds = CommModeCreate.CreateGetDeviceState(DeviceIdx);
|
|
// try
|
|
// {
|
|
// //States = gds.GetDeviceState(DeviceIdx, TaskIdx);//1Íê³É,2ÈÎÎñºÅ,5É豸ºÅ
|
|
// if (DeviceKind == 13)
|
|
// {
|
|
// DeviceIdx = GetNowDevice(minMidx);
|
|
// }
|
|
// States = CStaticClass.GetDeviceState(DeviceIdx);
|
|
|
|
// }
|
|
// catch (Exception ex)
|
|
// {//20110505
|
|
// RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", "Ìáǰ¼ì²âʱ£º" + ex.Message);
|
|
// OnRefreshMonitor(rmea);
|
|
// return false;
|
|
// }
|
|
// if (States == null)//û½ÓÊÕµ½Èκηµ»ØÖµ
|
|
// {
|
|
// RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", "·¢ËÍÃüÁîʱ£¬Ìáǰ¼ì²âûÊÕµ½PLCÊý¾Ý£¡");
|
|
// OnRefreshMonitor(rmea);
|
|
|
|
// return false;
|
|
// }
|
|
|
|
// if (((States[1] == 1) || (States[1] >= 30)) && ((DeviceKind != 13) && (DeviceKind != 31)))//ÔËÐлòÕß¹ÊÕÏ
|
|
// {
|
|
// if (States[1] >= 30)
|
|
// {
|
|
// devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
|
// int ErrId = States[1];
|
|
// //20110505
|
|
// errs = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(_DeviceKind.ToString() + States[1].ToString()));
|
|
// AheadDetectUnallow.Append(DeviceIdx + "ÓйÊÕÏ£º" + errs.ErrorName);
|
|
// //20090910
|
|
// //Óйý¼Ç¼µÄ¹ÊÕÏÉ豸µÄÈÎÎñºÅ£¬²»ÔÙÖØ¸´´¦Àí
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("SELECT F_DeviceIndex FROM T_Base_Device where F_DeviceIndex=" ).Append( DeviceIdx ).Append( " and F_ErrorTaskNo=" ).Append( TaskIdx );
|
|
// ;
|
|
// dt = dbo.ExceSQL(sql.ToString()).Tables[0];
|
|
// if (dt.Rows.Count >= 1)
|
|
// {
|
|
// //20110505
|
|
// UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
// return false;
|
|
// }
|
|
// //¼Ç¼·¢Éú¹ÊÕϵÄÉ豸ÕýÔÚÖ´ÐеÄÈÎÎñºÅ
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("update T_Base_Device set F_ErrorTaskNo= " ).Append( TaskIdx ).Append( " where F_DeviceIndex= " ).Append( DeviceIdx);
|
|
// dbo.ExceSQL(sql.ToString());
|
|
|
|
// if (CStaticClass.IsEquals(devinfo.ReturnMessage, States, 2) == true) return false;
|
|
|
|
// //if ((_DeviceKind == 2) || (_DeviceKind == 4))
|
|
// //{//ÊäËÍ»ú¹ÊÕÏÇåÁã
|
|
// // sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
// // sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
|
// //}
|
|
// //if (_DeviceKind == 1) //¶Ñ¶â»ú¡¢RGV
|
|
// //{
|
|
|
|
// // sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
// // sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
// //}
|
|
// //20110505
|
|
// RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", "É豸Ë÷Òý" + DeviceIdx + "ÓйÊÕÏ£º" + errs.ErrorName);
|
|
// OnRefreshMonitor(rmea);
|
|
// rmea = new RefreshMonitorEventArgs("notifyIcon1", "¾¯¸æ:" + devinfo.DeviceName + "," + DeviceIdx + "·¢Éú¹ÊÕÏ£º" + errs.ErrorName);
|
|
// OnRefreshMonitor(rmea);
|
|
|
|
// if (mti == 1)
|
|
// {
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("update IO_Control set ERROR_TEXT='" ).Append( "×¼±¸Ö´ÐйÜÀíÈÎÎñʱ£º" ).Append( devinfo.DeviceName ).Append( "," ).Append( DeviceIdx ).Append( errs.ErrorName ).Append( "' where Control_ID=" ).Append( fid);
|
|
// dboM.ExceSQL(sql.ToString());
|
|
// }
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("update T_Manage_Task set FERRORCODE='" ).Append( "×¼±¸Ö´ÐйÜÀíÈÎÎñʱ£º" ).Append( devinfo.DeviceName ).Append( "," ).Append( DeviceIdx ).Append( errs.ErrorName ).Append( "' where F_ManageTaskKindIndex=" ).Append( mti ).Append( " and FID=" ).Append( fid);
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
|
// OnDataChange("·¢ËÍÖ¸ÁîÌáǰ¼ì²âʱ£¬",cea);
|
|
|
|
|
|
// }
|
|
// return false;
|
|
// }
|
|
// #endregion
|
|
|
|
//}
|
|
//else
|
|
//{
|
|
// #region ÑÓ¼ª£º20100319 AGVµÄÖ¸Áî67£ºÔÊÐíAGV·Å²ÐÍÐʱ£¬Èç¹ûÓÐ1219µÄËͳöÖ¸Áî¡¢1220µÄÖ¸ÁîÕýÔÚÖ´ÐлòÕßÒÑ·¢ËÍ£¬Ìáǰ¼ì²âʧ°Ü£¬ÐèÒªµÈ´ý
|
|
|
|
|
|
// //
|
|
|
|
// //if (ccf.GetDeviceOrderFromMonitor(minMidx) == 67)
|
|
// //{
|
|
// // dv = dbo.ExceSQL("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_DeviceIndex = 1219) AND (F_DeviceCommandIndex = 6) AND (F_Status > 0)").Tables[0].DefaultView;
|
|
// // if (dv.Count > 0)
|
|
// // {
|
|
// // return false;
|
|
// // }
|
|
// // dv = dbo.ExceSQL("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_DeviceIndex = 1220) AND (F_Status > 0)").Tables[0].DefaultView;
|
|
// // if (dv.Count > 0)
|
|
// // {
|
|
// // return false;
|
|
// // }
|
|
// //}
|
|
#endregion
|
|
}
|
|
#region ¸ß¶ËÉ豸UÏßÕýÔÚÔËÐÐ×ÜÊý¿ØÖÆ
|
|
//if ((DeviceKind == 13) && (order==6))
|
|
//{//20120328
|
|
// int arrdevice = ccf.GetDeviceArrowFromMonitor(minMidx);
|
|
// int startdevice = ccf.GetDeviceStartFromMonitor(minMidx);
|
|
// object ob0 = dbo.GetSingle(string.Format("SELECT count(F_MonitorIndex) as UTaskCount FROM T_Monitor_Task where F_DeviceIndex={0} and F_DeviceCommandIndex={1} and F_Status>0", DeviceIdx, order));
|
|
// DataView dvu = dbo.ExceSQL(string.Format("SELECT F_MaxRunTask,F_OutputUDevice,F_InputUDevice FROM T_Base_UArea WHERE (F_UCODE = {0})", DeviceIdx)).Tables[0].DefaultView;
|
|
// if ((dvu.Count>0) && (ob0 != null))
|
|
// {
|
|
// if (arrdevice == Convert.ToInt32(dvu[0]["F_OutputUDevice"]))
|
|
// {
|
|
// //if (Convert.ToInt32(ob0) >= Convert.ToInt32(dvu[0]["F_MaxRunTask"]))
|
|
// //{
|
|
// // AheadDetectUnallow.Append("UÏߣº" + DeviceIdx.ToString() + "ÕýÔÚÔËÐÐÈÎÎñÒѾ³¬ÏÞ£¡");
|
|
// // UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
// // return false;
|
|
// //}
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// if ((Convert.ToInt32(ob0) >= (Convert.ToInt32(dvu[0]["F_MaxRunTask"]) - 2)) && (startdevice == Convert.ToInt32(dvu[0]["F_InputUDevice"])))
|
|
// {
|
|
// AheadDetectUnallow.Append("UÏߣº" + DeviceIdx.ToString() + "ÕýÔÚÔËÐÐÈÎÎñÒѾ³¬ÏÞ£¡");
|
|
// UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
// return false;
|
|
// }
|
|
// if ((Convert.ToInt32(ob0) >= (Convert.ToInt32(dvu[0]["F_MaxRunTask"]) - 1)) && (startdevice != Convert.ToInt32(dvu[0]["F_InputUDevice"])))
|
|
// {
|
|
// //AheadDetectUnallow.Append("UÏߣº" + DeviceIdx.ToString() + "ÕýÔÚÔËÐÐÈÎÎñÒѾ³¬ÏÞ£¡");
|
|
// //UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
// //return false;
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
//}
|
|
#endregion
|
|
|
|
if (new int[] { 19002, 19003 }.Contains(StartDevice) && EndDevice == 12008)
|
|
{
|
|
_AheadDetect = _AheadDetect + ";D12006.0;D12008.0;";
|
|
}
|
|
if (mti != 4 && DeviceKind == 1 && order == 4 && EndDevice == 39003)
|
|
{
|
|
_AheadDetect = _AheadDetect + ";D32001.0;I32001;D32002.0;I32002;D32003.0;I32003;";
|
|
}
|
|
|
|
#region Ìáǰ¼ì²âÐÅÏ¢´¦Àí
|
|
if ((_AheadDetect != "") && (_AheadDetect != null))
|
|
{
|
|
|
|
|
|
char[] cc = new char[1];
|
|
cc[0] = ';';
|
|
string[] AheadDetect = _AheadDetect.Split(cc);
|
|
string[] sp;
|
|
|
|
//ͨ¹ý³éÏóÀ๤³§»ñµÃIGetDeviceStateµÄÅÉÉúÀà
|
|
//IGetDeviceState GDS;
|
|
int s = 0;
|
|
//int[] sss;
|
|
int fs = 1;
|
|
//int[] fsss;
|
|
//ÌáÈ¡¹âµç¿ª¹ØË÷ÒýÖµ
|
|
int devk = 0;
|
|
for (int i = AheadDetect.GetLowerBound(0); i <= AheadDetect.GetUpperBound(0); i++)
|
|
{
|
|
if (AheadDetect[i].Trim().Length <= 0) continue;
|
|
#region ¼ì²âÂß¼ÓÐ̽ÎïH
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "H")//¼ì²âÂß¼ÓÐ̽Îï
|
|
{
|
|
devk = ccf.GetDeviceKindIdx(Convert.ToInt32(AheadDetect[i].Trim().Substring(1)));
|
|
if (devk == 9)
|
|
{//»ų́ÐèÒª´Ó¹ÜÀíÉ豸±í¶ÁÈ¡
|
|
//sql.Remove(0, sql.Length);
|
|
//sql.Append("SELECT FID FROM T_ITEMDEVICESTATION WHERE (FCODE = '" ).Append( AheadDetect[i].Trim().Substring(1) ).Append( "') AND (FSTATUS = '1002')");
|
|
//if (dboM.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count > 0)
|
|
//{
|
|
// fs = fs & 1;
|
|
//}
|
|
//else
|
|
//{
|
|
// fs = fs & 0;
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
//±¾µØÉ豸±í¶ÁÈ¡
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_DeviceIndex, F_HaveGoods FROM T_Base_Device where F_DeviceIndex=").Append(
|
|
Convert.ToInt32(AheadDetect[i].Trim().Substring(1)));
|
|
dvdv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvdv.Count > 0)
|
|
{
|
|
int havegoods = -1;
|
|
if (Convert.ToInt32(dvdv[0]["F_HaveGoods"]) == 0)//20110505
|
|
{
|
|
havegoods = 0;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "É豸Âß¼ÎÞÎ");
|
|
}
|
|
else
|
|
{
|
|
havegoods = 1;
|
|
}
|
|
fs = fs & havegoods;
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ¼ì²âÂß¼ÎÞ̽ÎïN
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "N")//¼ì²âÂß¼ÎÞ̽Îï
|
|
{
|
|
devk = ccf.GetDeviceKindIdx(Convert.ToInt32(AheadDetect[i].Trim().Substring(1)));
|
|
if (devk == 9)
|
|
{//»ų́ÐèÒª´Ó¹ÜÀíÉ豸±í¶ÁÈ¡;20101028¹ÜÀíÒÀÀµÈÎÎñ¿ØÖÆ»ų́µÄվ̨ÊÇ·ñÓÐÎï
|
|
//if (dboM.ExceSQL("SELECT FID FROM T_ITEMDEVICESTATION WHERE (FCODE = '" + AheadDetect[i].Trim().Substring(1) + "') AND (FSTATUS = '1002')").Tables[0].DefaultView.Count > 0)
|
|
//{
|
|
// fs = fs & 1;
|
|
//}
|
|
//else
|
|
//{
|
|
// fs = fs & 0;
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
//±¾µØÉ豸±í¶ÁÈ¡
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_DeviceIndex, F_HaveGoods FROM T_Base_Device where F_DeviceIndex=").Append(
|
|
Convert.ToInt32(AheadDetect[i].Trim().Substring(1)));
|
|
dvdv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvdv.Count > 0)
|
|
{
|
|
if (Convert.ToInt32(dvdv[0]["F_HaveGoods"]) > 0)//20110505
|
|
{
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "É豸Âß¼ÓÐÎ");
|
|
}
|
|
s = s + Convert.ToInt32(dvdv[0]["F_HaveGoods"]);
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐI
|
|
|
|
//20090803¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "I")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
int idev = Convert.ToInt32(AheadDetect[i].Trim().Substring(1));
|
|
if (idev.ToString().Length == 6)
|
|
{
|
|
idev = Convert.ToInt32(idev.ToString().Substring(0, 5));
|
|
}
|
|
States = CStaticClass.GetDeviceState(idev);
|
|
|
|
if (States != null)
|
|
{
|
|
//if ((States[1] == 5) && (ccf.GetDeviceKindIdx(Convert.ToInt32(AheadDetect[i].Trim().Substring(1))) == 2))
|
|
//{//20120409Ö»ÓÐÊäËÍ»úµÄÍê³É¿É×÷Ϊ¿ÕÏÐ
|
|
// States[1] = 0;
|
|
//}
|
|
if (DeviceHandTaskIfRun(Convert.ToInt32(AheadDetect[i].Trim().Substring(1))) == true)
|
|
{//20120207
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "ÊÖ¹¤ÈÎÎñ»òÕß±ÜÈÃÈÎÎñÕýÔÚÔËÐУ¡");
|
|
States[1] = 1;
|
|
}
|
|
if (States[1] != 0)//20110505
|
|
{
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "É豸²»¿ÕÏУ¡");
|
|
}
|
|
s = s + States[1];
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²â»úеÊÖÊÇ·ñ¿ÉÒÔ·¢ÈÎÎñP
|
|
|
|
//20090803¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "P")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
int idev = Convert.ToInt32(AheadDetect[i].Trim().Substring(1));
|
|
if (idev.ToString().Length == 6)
|
|
{
|
|
idev = Convert.ToInt32(idev.ToString().Substring(0, 5));
|
|
}
|
|
States = CStaticClass.GetDeviceState(idev);
|
|
|
|
if (States != null)
|
|
{
|
|
//if ((States[1] == 5) && (ccf.GetDeviceKindIdx(Convert.ToInt32(AheadDetect[i].Trim().Substring(1))) == 2))
|
|
//{//20120409Ö»ÓÐÊäËÍ»úµÄÍê³É¿É×÷Ϊ¿ÕÏÐ
|
|
// States[1] = 0;
|
|
//}
|
|
//if (DeviceHandTaskIfRun(Convert.ToInt32(AheadDetect[i].Trim().Substring(1))) == true)
|
|
//{//20120207
|
|
// AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "ÊÖ¹¤ÈÎÎñ»òÕß±ÜÈÃÈÎÎñÕýÔÚÔËÐУ¡");
|
|
// States[1] = 1;
|
|
//}
|
|
if (States[1] != 0)//20110505
|
|
{
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "É豸²»¿ÕÏУ¡");
|
|
}
|
|
s = s + States[1];
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²âÉ豸ÊÇ·ñ´®ÅÌËø¶¨A
|
|
|
|
//20090803¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "A")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
int idev = Convert.ToInt32(AheadDetect[i].Trim().Substring(1));
|
|
if (idev.ToString().Length == 6)
|
|
{
|
|
idev = Convert.ToInt32(idev.ToString().Substring(0, 5));
|
|
}
|
|
if (Convert.ToInt32(dbo.GetSingle("select F_lock from T_NeedLock where F_DeviceIndex=" + idev)) > 0)
|
|
{
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "¸ÃλÖôæÔÚ´®ÅÌ·çÏÕ£¡");
|
|
s = s + 1;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ÌáÉý»úÊÇ·ñÐèÒª±ä¸üZ
|
|
|
|
//20090803¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "Z")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
int arrow = Convert.ToInt32(dbo.GetSingle("select F_NumParam4 from t_monitor_task where F_MonitorIndex=" + minMidx));
|
|
int idev = Convert.ToInt32(AheadDetect[i].Trim().Substring(1));
|
|
if (idev.ToString().Length == 6)
|
|
{
|
|
idev = Convert.ToInt32(idev.ToString().Substring(0, 5));
|
|
}
|
|
if (idev == 32006)
|
|
{
|
|
int count1 = CStaticClass.GetDevicePhotoelectric(32002, 0);
|
|
int count2 = CStaticClass.GetDevicePhotoelectric(32001, 0);
|
|
int count3 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=32002 and F_Status>0"));
|
|
int count4 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=32001 and F_Status>0"));
|
|
if (arrow == 32002)
|
|
{
|
|
if (count1 + count3 > 0 || CStaticClass.GetDeviceState(25004)[1] > 1)
|
|
{
|
|
if (count2 + count4 < 1 && CStaticClass.GetDeviceState(25003)[1] <= 1)//32002¸Äµ½32001
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=(case when F_NumParam4=32002 then 32001 when F_NumParam4=32001 then 32002 else F_NumParam4 end),F_NumParam1=(case when F_NumParam1=32002 then 32001 when F_NumParam1=32001 then 32002 when F_NumParam1=42012 then 42011 when F_NumParam1=42011 then 42012 when F_NumParam1=52012 then 52011 when F_NumParam1=52011 then 52012 else F_NumParam1 end),F_DeviceIndex=(case when F_DeviceIndex=25003 then 25004 when F_DeviceIndex=25004 then 25003 when F_DeviceIndex=42012 then 42011 when F_DeviceIndex=42011 then 42012 when F_DeviceIndex=52012 then 52011 when F_DeviceIndex=52011 then 52012 else F_DeviceIndex end) where F_ManageTaskIndex=" + fid);
|
|
dbo.ExceSQL("update T_Monitor_Task set F_AheadDetect=REPLACE(REPLACE(replace(REPLACE(F_AheadDetect,'25004','25003'),'32002','32001'),'42012','42011'),'52012','52011') where F_ManageTaskIndex=" + fid);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
if (arrow == 32001)
|
|
{
|
|
if (count2 + count4 > 1 || CStaticClass.GetDeviceState(25003)[1] > 1)
|
|
{
|
|
if (count1 + count3 < 1 && CStaticClass.GetDeviceState(25004)[1] <= 1)//32001¸Äµ½32002
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=(case when F_NumParam4=32002 then 32001 when F_NumParam4=32001 then 32002 else F_NumParam4 end),F_NumParam1=(case when F_NumParam1=32002 then 32001 when F_NumParam1=32001 then 32002 when F_NumParam1=42012 then 42011 when F_NumParam1=42011 then 42012 when F_NumParam1=52012 then 52011 when F_NumParam1=52011 then 52012 else F_NumParam1 end),F_DeviceIndex=(case when F_DeviceIndex=25003 then 25004 when F_DeviceIndex=25004 then 25003 when F_DeviceIndex=42012 then 42011 when F_DeviceIndex=42011 then 42012 when F_DeviceIndex=52012 then 52011 when F_DeviceIndex=52011 then 52012 else F_DeviceIndex end) where F_ManageTaskIndex=" + fid);
|
|
dbo.ExceSQL("update T_Monitor_Task set F_AheadDetect=REPLACE(REPLACE(replace(REPLACE(F_AheadDetect,'25003','25004'),'32001','32002'),'42011','42012'),'52011','52012') where F_ManageTaskIndex=" + fid);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (idev == 42007)
|
|
{
|
|
int count1 = CStaticClass.GetDevicePhotoelectric(42002, 0);
|
|
int count2 = CStaticClass.GetDevicePhotoelectric(42001, 0);
|
|
int count3 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=42002 and F_Status>0"));
|
|
int count4 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=42001 and F_Status>0"));
|
|
if (arrow == 42002)
|
|
{
|
|
if (count1 + count3 > 0 || CStaticClass.GetDeviceState(25002)[1] > 1)
|
|
{
|
|
if (count2 + count4 < 1 && CStaticClass.GetDeviceState(25001)[1] <= 1)//42002¸Äµ½42001
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=(case when F_NumParam4=42002 then 42001 when F_NumParam4=42001 then 42002 when F_NumParam4=52002 then 52001 when F_NumParam4=52001 then 52002 else F_NumParam4 end),F_NumParam1=(case when F_NumParam1=42002 then 42001 when F_NumParam1=42001 then 42002 when F_NumParam1=22001 then 22002 when F_NumParam1=22002 then 22001 when F_NumParam1=52001 then 52002 when F_NumParam1=52002 then 52001 else F_NumParam1 end),F_DeviceIndex=(case when F_DeviceIndex=25001 then 25002 when F_DeviceIndex=25002 then 25001 when F_DeviceIndex=22001 then 22002 when F_DeviceIndex=22002 then 22001 else F_DeviceIndex end) where F_ManageTaskIndex=" + fid);
|
|
dbo.ExceSQL("update T_Monitor_Task set F_AheadDetect=REPLACE(REPLACE(REPLACE(F_AheadDetect,'25002','25001'),'42002','42001'),'22002','22001') where F_ManageTaskIndex=" + fid);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
if (arrow == 42001)
|
|
{
|
|
if (count2 + count4 > 0 || CStaticClass.GetDeviceState(25001)[1] > 1)
|
|
{
|
|
if (count1 + count3 < 1 && CStaticClass.GetDeviceState(25002)[1] <= 1)//42002¸Äµ½42001
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=(case when F_NumParam4=42002 then 42001 when F_NumParam4=42001 then 42002 when F_NumParam4=52002 then 52001 when F_NumParam4=52001 then 52002 else F_NumParam4 end),F_NumParam1=(case when F_NumParam1=42002 then 42001 when F_NumParam1=42001 then 42002 when F_NumParam1=22001 then 22002 when F_NumParam1=22002 then 22001 when F_NumParam1=52001 then 52002 when F_NumParam1=52002 then 52001 else F_NumParam1 end),F_DeviceIndex=(case when F_DeviceIndex=25001 then 25002 when F_DeviceIndex=25002 then 25001 when F_DeviceIndex=22001 then 22002 when F_DeviceIndex=22002 then 22001 else F_DeviceIndex end) where F_ManageTaskIndex=" + fid);
|
|
dbo.ExceSQL("update T_Monitor_Task set F_AheadDetect=REPLACE(REPLACE(REPLACE(F_AheadDetect,'25001','25002'),'42001','42002'),'22001','22002') where F_ManageTaskIndex=" + fid);
|
|
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (idev == 52007)
|
|
{
|
|
int count1 = CStaticClass.GetDevicePhotoelectric(52002, 0);
|
|
int count2 = CStaticClass.GetDevicePhotoelectric(52001, 0);
|
|
int count3 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=52002 and F_Status>0"));
|
|
int count4 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=52001 and F_Status>0"));
|
|
if (arrow == 52002)
|
|
{
|
|
if (count1 + count3 > 0 || CStaticClass.GetDeviceState(25002)[1] > 1)
|
|
{
|
|
if (count2 + count4 < 1 && CStaticClass.GetDeviceState(25001)[1] <= 1)//52002¸Äµ½52001
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=(case when F_NumParam4=42002 then 42001 when F_NumParam4=42001 then 42002 when F_NumParam4=52002 then 52001 when F_NumParam4=52001 then 52002 else F_NumParam4 end),F_NumParam1=(case when F_NumParam1=42002 then 42001 when F_NumParam1=42001 then 42002 when F_NumParam1=22001 then 22002 when F_NumParam1=22002 then 22001 when F_NumParam1=52001 then 52002 when F_NumParam1=52002 then 52001 else F_NumParam1 end),F_DeviceIndex=(case when F_DeviceIndex=25001 then 25002 when F_DeviceIndex=25002 then 25001 when F_DeviceIndex=22001 then 22002 when F_DeviceIndex=22002 then 22001 else F_DeviceIndex end) where F_ManageTaskIndex=" + fid);
|
|
dbo.ExceSQL("update T_Monitor_Task set F_AheadDetect=REPLACE(REPLACE(REPLACE(F_AheadDetect,'25002','25001'),'52002','52001'),'22002','22001') where F_ManageTaskIndex=" + fid);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
if (arrow == 52001)
|
|
{
|
|
if (count2 + count4 > 0 || CStaticClass.GetDeviceState(25001)[1] > 1)
|
|
{
|
|
if (count1 + count3 < 1 && CStaticClass.GetDeviceState(25002)[1] <= 1)//42002¸Äµ½42001
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=(case when F_NumParam4=42002 then 42001 when F_NumParam4=42001 then 42002 when F_NumParam4=52002 then 52001 when F_NumParam4=52001 then 52002 else F_NumParam4 end),F_NumParam1=(case when F_NumParam1=42002 then 42001 when F_NumParam1=42001 then 42002 when F_NumParam1=22001 then 22002 when F_NumParam1=22002 then 22001 when F_NumParam1=52001 then 52002 when F_NumParam1=52002 then 52001 else F_NumParam1 end),F_DeviceIndex=(case when F_DeviceIndex=25001 then 25002 when F_DeviceIndex=25002 then 25001 when F_DeviceIndex=22001 then 22002 when F_DeviceIndex=22002 then 22001 else F_DeviceIndex end) where F_ManageTaskIndex=" + fid);
|
|
dbo.ExceSQL("update T_Monitor_Task set F_AheadDetect=REPLACE(REPLACE(REPLACE(F_AheadDetect,'25001','25002'),'52001','52002'),'22001','22002') where F_ManageTaskIndex=" + fid);
|
|
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (idev == 12076 || idev == 12079)
|
|
{
|
|
int count1 = CStaticClass.GetDevicePhotoelectric(12103, 0);
|
|
int count2 = CStaticClass.GetDevicePhotoelectric(12101, 0);
|
|
int count3 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=12103 and F_Status>0"));
|
|
int count4 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=12101 and F_Status>0"));
|
|
int count5 = CStaticClass.GetDevicePhotoelectric(12103, 6);//ר»úÊÇ·ñ¿ÉÓÃ
|
|
int count6 = CStaticClass.GetDevicePhotoelectric(12101, 6);//ר»úÊÇ·ñ¿ÉÓÃ
|
|
if (arrow == 12103)
|
|
{
|
|
if (count1 + count3 > 0 || count5 == 0)
|
|
{
|
|
if (count2 + count4 < 1 && count6 == 1)
|
|
{
|
|
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=12101 where F_MonitorIndex=" + minMidx);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
if (arrow == 12101)
|
|
{
|
|
if (count2 + count4 > 0 || count6 == 0)
|
|
{
|
|
if (count1 + count3 < 1 && count5 == 1)
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=12103 where F_MonitorIndex=" + minMidx);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (idev == 62029)
|
|
{
|
|
int count1 = CStaticClass.GetDevicePhotoelectric(62030, 0);
|
|
int count2 = CStaticClass.GetDevicePhotoelectric(62034, 0);
|
|
int count3 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=62030 and F_Status>0"));
|
|
int count4 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=62034 and F_Status>0"));
|
|
if (arrow == 62030)
|
|
{
|
|
if (count1 + count3 > 0)
|
|
{
|
|
if (count2 + count4 < 1)
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=62034 where F_MonitorIndex=" + minMidx);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
if (arrow == 62034)
|
|
{
|
|
if (count2 + count4 > 0)
|
|
{
|
|
if (count1 + count3 < 1)
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_NumParam4=62030 where F_MonitorIndex=" + minMidx);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "µÈ´ý·ÖµÀ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ¼ì²âÖÕµãÈÎÎñÊýU
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "U")//¼ì²âF_NumParam1£¬F_NumParam4É豸ÎÞÕýÔÚÔËÐеÄÈÎÎñ
|
|
{
|
|
int endcount = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(AheadDetect[i].Trim().Substring(1)), 0) == 1 ? 1 : 0;
|
|
//int[] enddev;
|
|
//enddev = CStaticClass.GetDeviceState(Convert.ToInt32(AheadDetect[i].Trim().Substring(1)));
|
|
|
|
//if (enddev != null)
|
|
//{
|
|
// if (enddev[1] == 5 || enddev[1] == 0)
|
|
// {//20120409Ö»ÓÐÊäËÍ»úµÄÍê³É¿É×÷Ϊ¿ÕÏÐ
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
sql.Clear();
|
|
sql.Append(string.Format("SELECT count(fid) FROM T_manage_Task WHERE FENDDEVICE = {0} AND FStatus > 0 and fid<>{1} and fstartdevice like '1800%'", Convert.ToInt32(AheadDetect[i].Trim().Substring(1)), fid));
|
|
int count1 = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
|
sql.Clear();
|
|
sql.Append(string.Format("SELECT count(fid) FROM T_manage_Task WHERE FENDDEVICE = {0} and fid<>{1} and fstartdevice like '1200%'", Convert.ToInt32(AheadDetect[i].Trim().Substring(1)), fid));
|
|
int count2 = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
|
if (Convert.ToInt32(AheadDetect[i].Trim().Substring(1)) == 12042)
|
|
{
|
|
if (count1 + count2 + endcount >= 1)
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "ÖÕµãÈÎÎñ³¬¹ýÒ»¸ö£¡");
|
|
}
|
|
else
|
|
{
|
|
s = s + 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (count1 + count2 + endcount >= 2)
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "ÖÕµãÈÎÎñ³¬¹ýÁ½¸ö£¡");
|
|
}
|
|
else
|
|
{
|
|
s = s + 0;
|
|
}
|
|
}
|
|
|
|
|
|
continue;
|
|
}
|
|
#endregion
|
|
|
|
#region ¼ì²âÂë¶âλÖÃÊÇ·ñÓпÉÓÿÕÍÐÅÌM
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "M")
|
|
{
|
|
//»ñÈ¡µ±Ç°´«ÊäÏßÊÇ·ñÓлõ ÓлõΪ1ÎÞ»õΪ0 £¨ÓÐÎÞ»õ´ú±íÓÐûÓпÕÍÐÅÌ£©
|
|
int endcount = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5)), 0) == 1 ? 1 : 0;
|
|
if (endcount == 1)
|
|
{
|
|
//Èç¹ûÓÐÍÐÅÌÅжÏÊÇ·ñΪ¿ÉÓÃÍÐÅÌ Gflag = 0 Ϊ¿ÉÓÃ
|
|
sql.Clear();
|
|
sql.Append(string.Format("SELECT Gflag FROM [dbo].[ZH_pallet] where Device={0} and Gflag = 0 and GOODS_COUNT=0", Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5))));
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
s = s + 0;
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5)).ToString() + "ÍÐÅ̲»¿ÉÓã¡");
|
|
}
|
|
//int count1 = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
|
//if (count1 == 0)
|
|
//{
|
|
// s = s + 0;
|
|
//}
|
|
//else
|
|
//{
|
|
// s = s + 1;
|
|
// AheadDetectUnallow.Append(Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5)).ToString() + "ÍÐÅ̲»¿ÉÓã¡");
|
|
//}
|
|
|
|
}
|
|
else
|
|
{
|
|
int tempdevice = 0;
|
|
switch (Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5)))
|
|
{
|
|
case 12011:
|
|
tempdevice = 12015;
|
|
break;
|
|
case 12014:
|
|
tempdevice = 12015;
|
|
break;
|
|
case 12007:
|
|
tempdevice = 12016;
|
|
break;
|
|
case 12008:
|
|
tempdevice = 12016;
|
|
break;
|
|
}
|
|
//²éѯÓÐûÓпÕÍÐÅÌÈÎÎñ
|
|
sql.Clear();
|
|
sql.Append(string.Format("SELECT * FROM [dbo].[T_Manage_Task] where FSTARTDEVICE = {1} and FENDDEVICE={0}", AheadDetect[i].Trim().Substring(1, 5), tempdevice));
|
|
int count1 = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
|
sql.Clear();
|
|
sql.Append(string.Format("SELECT * FROM [dbo].[ZH_pallet] where Device={0}", Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5))));
|
|
int count3 = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
|
if (count1 == 0 && count3 == 0)
|
|
{
|
|
sql.Clear();
|
|
//sql.Append(string.Format("SELECT * FROM [dbo].[T_Manage_Task] where FID=(select F_ManageTaskIndex from T_Monitor_Task where F_DeviceIndex={0} and FENDDEVICE='{1}')", DeviceIdx, AheadDetect[i].Trim().Substring(1, 5)));
|
|
sql.Append(string.Format("SELECT * FROM [dbo].[T_Manage_Task] where FID in (select F_ManageTaskIndex from T_Monitor_Task where F_DeviceIndex={0} and F_NumParam4 ='{1}')", DeviceIdx, AheadDetect[i].Trim().Substring(1, 5)));
|
|
DataView dvIO = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
sql.Clear();
|
|
sql.Append(string.Format("INSERT INTO [dbo].[T_Manage_Task]([FID], [F_ManageTaskKindIndex], [FMANAGEID], [F_RELATIVECONTORLID],[FPALLETBARCODE], [FCONTROLTASKTYPE], [FTASKLEVEL], [FISRETURN], [FSTARTWAREHOUSE], [FSTARTDEVICE] , [FSTARTCELL], [FSTARTUCODE] , [FENDWAREHOUSE], [FENDDEVICE], [FENDCELL] , [FENDUCODE], [FSTATUS] , [FBEGTIME], [FENDTIME], [FIntoStepOK], [FLANEWAY], [FSTACK] , [FCurrentLocation], [FUseAwayFork], [FCONTORL_BATCH], [FLOGIC_AREA], [FStartCol], [FStartLayer], [FEndCol], [FEndLayer], [Work_Mode] , [BATTERY_TYPE], [BATTERY_BATCH],[FREMARK])VALUES({0},2 ,{4},-1,'B000001',4,1,0,'-','{1}','','0','-','{2}','','0',0,'{3}','-',0,0,0,0,0,'','',0,0,0,0,'2','0','0','{5}')", ccf.GetTempManageIdx(), tempdevice, AheadDetect[i].Trim().Substring(1, 5), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), dvIO[0]["FMANAGEID"].ToString(), dvIO[0]["FREMARK"].ToString()));
|
|
dbo.GetSingle(sql.ToString());
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5)).ToString() + "ûÓпÉÓÿÕÍÐÅÌ£¡");
|
|
}
|
|
else
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5)).ToString() + "µÈ´ýץȡ¿ÉÓÿÕÍÐÅÌ£¡");
|
|
}
|
|
}
|
|
|
|
continue;
|
|
}
|
|
#endregion
|
|
#region ¼ì²â»¯³É·ÖÈÝÉè±¸Æø¸×ÊÇ·ñµÍλQ£¨µÍλÊÇ¿ÉÓõģ©
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "Q")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
string cell = AheadDetect[i].Trim().Substring(1);
|
|
|
|
|
|
|
|
if (cell != null)
|
|
{
|
|
|
|
if (dboM.GetSingle("select cylinder_status from wms_dl_cell where cell_code='" + cell + "'").ToString() != "2")
|
|
{//20120207
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "»õÎ»Æø¸×²»ÔÚµÍλ£¡");
|
|
s = s + 1;
|
|
}
|
|
|
|
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²â»¯³É·ÖÈÝÉ豸ÊÇ·ñ¿ÉÓ㨶¦Á¦ÈÏΪֻÓÐÉè±¸ÕæÕý¿Õ³öÀ´²ÅÊÇ¿ÉÓÃK£©
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "K")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
string cell = AheadDetect[i].Trim().Substring(1);
|
|
|
|
|
|
|
|
if (cell != null)
|
|
{
|
|
|
|
if (dboM.GetSingle("select run_status_dl from wms_dl_cell where cell_code='" + cell + "'").ToString() != "Enable")
|
|
{//20120207
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "»õλ²»¿ÉÓã¡");
|
|
s = s + 1;
|
|
}
|
|
|
|
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²â»¯³É·ÖÈÝÉ豸ÊÇ·ñÓлõY
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "Y")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
string cell = AheadDetect[i].Trim().Substring(1);
|
|
|
|
|
|
|
|
if (cell != null)
|
|
{
|
|
|
|
if (dboM.GetSingle("select cell_status_dl from wms_dl_cell where cell_code='" + cell + "'").ToString() != "Full")
|
|
{//20120207
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "¶¦Á¦Éϱ¨»õλ²»ÊÇÓлõ״̬£¡");
|
|
s = s + 1;
|
|
}
|
|
|
|
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²â»¯³É·ÖÈÝÉ豸ÊÇ·ñÎÞ»õW
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "W")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
string cell = AheadDetect[i].Trim().Substring(1);
|
|
|
|
|
|
|
|
if (cell != null)
|
|
{
|
|
|
|
if (dboM.GetSingle("select cell_status_dl from wms_dl_cell where cell_code='" + cell + "'").ToString() != "Nohave")
|
|
{//20120207
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "¶¦Á¦Éϱ¨»õλ²»ÊÇÎÞ»õ״̬£¡");
|
|
s = s + 1;
|
|
}
|
|
|
|
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²â³ö¿âÈÎÎñ·Å»õλÖÃÓÐûÓÐÕýÔÚÖ´ÐеÄAGV·Å»õÈÎÎñJ
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "J")
|
|
{
|
|
int FENDDEVICE = Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5));
|
|
sql.Clear();
|
|
sql.Append(string.Format("SELECT * FROM T_Manage_Task WHERE FCONTROLTASKTYPE = 4 and (FENDDEVICE in (select FENDDEVICE from T_Manage_Task where fid = {0}))", fid));
|
|
dvdv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvdv.Count != 0)
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "ÓÐAGVÈë¿âÈÎÎñ£¡");
|
|
}
|
|
else
|
|
{
|
|
s = s + 0;
|
|
}
|
|
continue;
|
|
}
|
|
#endregion
|
|
#region ¼ì²âAGVÈÎÎñÓÐûÓÐͬ»õλµÄ³ö¿âÈÎÎñE
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "E")
|
|
{
|
|
int FENDDEVICE = Convert.ToInt32(AheadDetect[i].Trim().Substring(1, 5));
|
|
sql.Clear();
|
|
//sql.Append(string.Format("SELECT * FROM T_Manage_Task WHERE FCONTROLTASKTYPE = 2 and FSTATUS=1 and (FENDDEVICE in (select FENDDEVICE from T_Manage_Task where fid not in ({0})))", fid));
|
|
|
|
sql.Append(string.Format(" SELECT* FROM T_Manage_Task WHERE FCONTROLTASKTYPE = 2 and FSTATUS = 1 and FID != {0} and FID in (select distinct F_ManageTaskIndex from T_Monitor_Task where F_ManageTaskIndex = {0} and(F_NumParam4 = {1} or F_NumParam5 = {1})) ", fid, EndDevice));
|
|
|
|
dvdv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvdv.Count != 0)
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(FENDDEVICE + "ÓжѶâ»ú³ö¿âÈÎÎñ£¡");
|
|
}
|
|
else
|
|
{
|
|
s = s + 0;
|
|
}
|
|
continue;
|
|
}
|
|
#endregion
|
|
#region ¼ì²âÄÚ²àÈ¡»õʱÊÇ·ñÓжÔÍâ²à»õλµÄ²Ù×÷X
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "X")//¼ì²â»ý·ÅÏßÕýÔÚÖ´ÐÐÈÎÎñ¸öÊý£¨J12008,2£©
|
|
{
|
|
|
|
cc[0] = ',';
|
|
sp = AheadDetect[i].Trim().Substring(1).Split(cc);
|
|
if (sp.GetLength(0) == 3)
|
|
{
|
|
string z = sp[0].Length == 1 ? "0" + sp[0] : sp[0];
|
|
string x = sp[1].Length == 1 ? "0" + sp[1] : sp[1];
|
|
string y = sp[2].Length == 1 ? "0" + sp[2] : sp[2];
|
|
string kkk = z + "-" + x + "-" + y;
|
|
int count1 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where FSTATUS=0 and FSTARTCELL='" + kkk + "'"));
|
|
int count2 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam1=" + sp[0].ToString() + " and F_NumParam2=" + sp[1].ToString() + " and F_NumParam3=" + sp[2].ToString()));
|
|
|
|
if (count1 + count2 > 0)
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append("±ÜÈÃÍâ²àÈÎÎñ£¡");
|
|
}
|
|
else
|
|
{
|
|
s = s + 0;
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²âÍâ²àËÍ»õʱÊÇ·ñÓжÔÄÚ²à»õλµÄ²Ù×÷Y
|
|
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "Y")//¼ì²â»ý·ÅÏßÕýÔÚÖ´ÐÐÈÎÎñ¸öÊý£¨J12008,2£©
|
|
{
|
|
|
|
cc[0] = ',';
|
|
sp = AheadDetect[i].Trim().Substring(1).Split(cc);
|
|
if (sp.GetLength(0) == 3)
|
|
{
|
|
string z = sp[0].Length == 1 ? "0" + sp[0] : sp[0];
|
|
string x = sp[1].Length == 1 ? "0" + sp[1] : sp[1];
|
|
string y = sp[2].Length == 1 ? "0" + sp[2] : sp[2];
|
|
string kkk = z + "-" + x + "-" + y;
|
|
int count1 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where FSTATUS=0 and FENDCELL='" + kkk + "'"));
|
|
int count2 = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=" + sp[0].ToString() + " and F_NumParam5=" + sp[1].ToString() + " and F_NumParam6=" + sp[2].ToString()));
|
|
|
|
if (count1 + count2 > 0)
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append("±ÜÈÃÄÚ²àÈÎÎñ£¡");
|
|
}
|
|
else
|
|
{
|
|
s = s + 0;
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²âÉ豸ÊÇ·ñ±»¶Ñ¶â»úÔ¤Ô¼R
|
|
//20120409
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "R" && DeviceKind == 1)////20140309¼ì²âÉ豸ÊÇ·ñ±»¶Ñ¶â»úÔ¤Ô¼
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select F_ManTaskReserve from T_Base_Device where F_ManTaskReserve>0 and F_DeviceIndex=").Append(Convert.ToInt32(AheadDetect[i].Trim().Substring(1)));
|
|
object obr = dbo.GetSingle(sql.ToString());
|
|
if (obr != null)
|
|
{
|
|
if (obr.ToString() != (mti.ToString() + fid.ToString()))
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(AheadDetect[i].Trim().Substring(1) + "±»µ÷¶ÈÈÎÎñ:").Append(obr.ToString()).Append("Ô¤Ô¼£¡");
|
|
}
|
|
else
|
|
{
|
|
s = s + 0;
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²âÉ豸¹âµçÐźÅ
|
|
|
|
//¼ì²âÉ豸µÄ¹âµçÐźţºD-12001.0±íʾÊäËÍ»ú12001µÄÈë¿Ú¿ª¹ØÓÐÎD12001.1±íʾÊäËÍ»ú12001µÄÈë¿Ú¿ª¹ØÎÞÎï
|
|
//D-12001.2±íʾÊäËÍ»ú12001µÄ¶¥Éý¸ß루¸ßµ½Î»£©£»D12001.3±íʾÊäËÍ»ú12001µÄ¶¥Éý²»ÔÚµÍ루²»Êǵ͵½Î»£©
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "D")
|
|
{
|
|
int devicebyte = 0, devbit = 0;
|
|
DS = AheadDetect[i].Trim().Substring(1).Split(dd);
|
|
int.TryParse(DS[0], out devicebyte);
|
|
int.TryParse(DS[1], out devbit);
|
|
//ÅжÏÊÇ·ñ¼ì²â¸ºÊýË÷ÒýÖµ£¨¸ºÊý´ú±íÊÇ·ñÂú×㿪¹ØÁ¿£½£±µÄÖ´ÐÐǰÌᣩ
|
|
if (devicebyte < 0)
|
|
{
|
|
#region ¸ºÊý´ú±íֵΪ£±µÄ¿ª¹ØÁ¿¼ì²â
|
|
|
|
int fsn = CStaticClass.GetDevicePhotoelectric(-devicebyte, devbit);//20101124
|
|
|
|
if (fsn != 1)//20110505
|
|
{
|
|
|
|
StringBuilder kg = new StringBuilder();
|
|
switch (devbit)
|
|
{
|
|
case 0:
|
|
kg.Append(".0ÓÐÎï");
|
|
break;
|
|
case 1:
|
|
kg.Append(".1ÓÐÎï");
|
|
break;
|
|
case 2:
|
|
|
|
if (ccf.GetDeviceKindIdx(-devicebyte) == 31)
|
|
{
|
|
kg.Append("¸ßλ");
|
|
}
|
|
else
|
|
{
|
|
kg.Append(".2¸ßλ");
|
|
|
|
}
|
|
break;
|
|
case 3:
|
|
kg.Append(".3µÍλ");
|
|
|
|
break;
|
|
case 4:
|
|
kg.Append(".4¸ßλ");
|
|
break;
|
|
case 5:
|
|
kg.Append("ÓÐÎï");
|
|
break;
|
|
case 6:
|
|
kg.Append("¸ßλ");
|
|
break;
|
|
case 7:
|
|
kg.Append("µÍλ");
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
//if (Convert.ToInt32(dbo.GetSingle("select count(0) from T_NeedLock where f_deviceindex=" + (-devicebyte).ToString())) > 0 && devbit == 0)
|
|
//{
|
|
// int emptylock = Convert.ToInt32(dbo.GetSingle("select f_lock from T_NeedLock where f_deviceindex=" + (-devicebyte).ToString()));
|
|
// if (emptylock != 1)
|
|
// {
|
|
// dbo.ExceSQL("update T_NeedLock set f_lock=1 where f_deviceindex=" + (-devicebyte).ToString());
|
|
// }
|
|
//}
|
|
AheadDetectUnallow.Append(Convert.ToInt32((-devicebyte)).ToString() + kg.ToString() + "¹âµç¿ª¹Ø²»ÕÚµ²£¡");
|
|
}
|
|
fs = fs & fsn;
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{//
|
|
#region ÕýÊýÖµ²»ÄÜΪ£±µÄ¿ª¹ØÁ¿¼ì²â
|
|
|
|
int sssn = CStaticClass.GetDevicePhotoelectric(devicebyte, devbit);
|
|
|
|
if (sssn != 0)//20110505
|
|
{
|
|
StringBuilder kg = new StringBuilder();
|
|
switch (devbit)
|
|
{
|
|
case 0:
|
|
kg.Append(".0ÓÐÎï");
|
|
break;
|
|
case 1:
|
|
kg.Append(".1ÓÐÎï");
|
|
break;
|
|
case 2:
|
|
|
|
if (ccf.GetDeviceKindIdx(devicebyte) == 31)
|
|
{
|
|
kg.Append("¸ßλ");
|
|
}
|
|
else
|
|
{
|
|
kg.Append(".2¸ßλ");
|
|
|
|
}
|
|
break;
|
|
case 3:
|
|
kg.Append(".3µÍλ");
|
|
|
|
break;
|
|
case 4:
|
|
kg.Append(".4¸ßλ");
|
|
break;
|
|
case 5:
|
|
kg.Append("ÓÐÎï");
|
|
break;
|
|
case 6:
|
|
kg.Append("¸ßλ");
|
|
break;
|
|
case 7:
|
|
kg.Append("µÍλ");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
AheadDetectUnallow.Append(devicebyte.ToString() + kg.ToString() + "¹âµç¿ª¹ØÕÚµ²£¡");
|
|
}
|
|
s = s + sssn;
|
|
#endregion
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
#region ¼ì²âÉ豸ÊÇ·ñ±»AGVËø¶¨C
|
|
|
|
//20090803¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
if (AheadDetect[i].Trim().Substring(0, 1).ToUpper() == "C")//¼ì²âÉ豸ÊÇ·ñ¿ÕÏÐidle
|
|
{
|
|
|
|
int devicebyte = 0, devbit = 0;
|
|
DS = AheadDetect[i].Trim().Substring(1).Split(dd);
|
|
int.TryParse(DS[0], out devicebyte);
|
|
int.TryParse(DS[1], out devbit);
|
|
if (devicebyte < 0)
|
|
{
|
|
int fsn = CStaticClass.GetDevicePhotoelectric(-devicebyte, devbit);//20240228
|
|
if (fsn > 0 || fsn == -9999)
|
|
{
|
|
s = s + 1;
|
|
AheadDetectUnallow.Append(Convert.ToInt32((-devicebyte)).ToString() + ".2AGV»¥ËøµÈ´ý·Å»õÍê³É£¡");
|
|
}
|
|
s = s + 0;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
#region ·ÇÊÖ¹¤ÈÎÎñ£¬Èç¹ûÓÐÊÖ¹¤ÈÎÎñµÈ´ýÖ´ÐÐÏÈÖ´ÐÐÊÖ¹¤ÈÎÎñ
|
|
if (mti != 4)
|
|
{//20120405
|
|
if (DeviceHandTaskIfWaitRun(devinfo.DeviceIndex) == true)
|
|
{
|
|
AheadDetectUnallow.Append(devinfo.DeviceIndex.ToString() + "ÊÖ¹¤ÈÎÎñ»òÕß±ÜÈÃÈÎÎñµÈ´ýÔËÐУ¡");
|
|
s += 1;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region ¼ì²âÏò¹ÜÀíÉêÇëÈë¿âÈÎÎñÌõÂëºÍPLCASK¼Ç¼ÊÇ·ñÆ¥Åä
|
|
//20130709Ôö¼ÓÊäËÍվ̨Ïò¹ÜÀíÉêÇëÈë¿âÈÎÎñ£¬»òÕßÌõÂë±È¶ÔµÄÈÎÎñ£¬É¨ÃèºóÈ˹¤ËæÒâ°á×ßÏä×ӵı£»¤£¬Èë¿âÈÎÎñÌõÂëºÍPLCAsk¼Ç¼µÄ²»Ïàͬ²»ÔÙÖ´ÐÐÈÎÎñ
|
|
//if (DeviceKind == 1)//Äþ²¨µØÌú³ö¿â²»¼ì²â
|
|
//{
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("SELECT T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Base_PLC_Ask WHERE ( T_Base_Device.F_DeviceIndex = T_Base_PLC_Ask.F_DeviceIndex) and (T_Base_Device.F_DeviceKindIndex = 7) AND T_Base_PLC_Ask.F_BindingDevice = ").Append(devinfo.DeviceIndex);
|
|
// object obr1 = dbo.GetSingle(sql.ToString());
|
|
// if (obr1 != null)
|
|
// {
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("SELECT F_BarCode FROM T_Base_PLC_Ask where F_BindingDevice=").Append(devinfo.DeviceIndex);
|
|
// object obr = dbo.GetSingle(sql.ToString());
|
|
// if (obr != null)
|
|
// {
|
|
// if ((obr.ToString().IndexOf(ccf.GetBarCodeFromMonitor(minMidx)) < 0) && (ccf.GetBarCodeFromMonitor(minMidx).IndexOf(obr.ToString()) < 0))
|
|
// {
|
|
// s = s + 1;
|
|
// AheadDetectUnallow.Append(devinfo.DeviceIndex.ToString() + "¼Ç¼µÄÌõÂë:").Append(obr.ToString()).Append("£¬ºÍÈÎÎñÌõÂë").Append(ccf.GetBarCodeFromMonitor(minMidx)).Append("²»Æ¥Å䣡");
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
if ((s != 0) || (fs != 1))
|
|
{
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Óл¥³âÉ豸µÄ¶Ñ¶â»ú20111020
|
|
if (DeviceKind == 1 && devinfo.VirtualStack > 0)
|
|
{
|
|
int mutex = ccf.GetStackMutexDevice(DeviceIdx);
|
|
if (mutex > 0)
|
|
{//¼ì²é»¥³âÉ豸¿ÕÏÐʱµÄλÖúÍÔËÐеÄÄ¿±êλÖÃ
|
|
Model.MDevice mutexdev = Model.CGetInfo.GetDeviceInfo(mutex);
|
|
|
|
int mutexDeviceLockedState = ccf.GetDeviceLockedState(mutex);
|
|
if (mutexDeviceLockedState == -1) return true;//20120110
|
|
int mutexManTaskReserve = ccf.GetManTaskReserve(mutex);
|
|
if ((mutexdev.RunState == 0) && (mutexManTaskReserve <= 0) && (mutexDeviceLockedState == 0))
|
|
{//
|
|
#region mutex¿ÕÏС¢ÎÞÈÎÎñ¡¢ÎÞ¹ÜÀíÈÎÎñÔ¤Ô¼Ëø
|
|
|
|
int xcoor = Model.CGeneralFunction.GetXCoorFromMonitor(TaskIdx, DeviceIdx, ccf.GetDeviceOrderFromMonitor(TaskIdx));
|
|
int zcoor = Model.CGeneralFunction.GetZCoorFromMonitor(TaskIdx, DeviceIdx, ccf.GetDeviceOrderFromMonitor(TaskIdx));
|
|
int BCcoor = GetBarcodeCoor(xcoor, zcoor);
|
|
if (mutex > DeviceIdx)
|
|
{//mutex=35002
|
|
|
|
if ((BCcoor + StackMutexXCoor) >= mutexdev.XCoor)//mdev.XCoorÈç¹ûÊÇÌõÂë´øÖµÐèҪת»»ÎªÁÐÖµ
|
|
{
|
|
InsertStackMutexOrder(mutex, 2, (BCcoor + StackMutexXCoor), 5);
|
|
if (mutexdev.XCoor > 52000)//20120110
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (devinfo.XCoor <= mutexdev.XCoor - minStackMutexXCoor)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{//mutex35001
|
|
if (BCcoor >= (StackMutexXCoor + StackZeroXCoor))
|
|
{
|
|
BCcoor = (BCcoor - StackMutexXCoor);
|
|
}
|
|
else
|
|
{
|
|
return true;//¶Ô¿ª±¨¾¯°É£¬¹ÜÀíÏÂÈÎÎñ´íÁË£¬»òÕß·ÖÅä¶Ñ¶â»úÉ豸´íÎó
|
|
}
|
|
if (BCcoor <= mutexdev.XCoor)//mdev.XCoorÈç¹ûÊÇÌõÂë´øÖµÐèҪת»»ÎªÁÐÖµ
|
|
{
|
|
InsertStackMutexOrder(mutex, 2, BCcoor, 5);
|
|
if (mutexdev.XCoor < 4481)//20120110
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (devinfo.XCoor > mutexdev.XCoor + minStackMutexXCoor)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{//mutexÓÐÈÎÎñÔËÐÐ
|
|
int xcoor = Model.CGeneralFunction.GetXCoorFromMonitor(TaskIdx, DeviceIdx, ccf.GetDeviceOrderFromMonitor(TaskIdx));
|
|
int zcoor = Model.CGeneralFunction.GetZCoorFromMonitor(TaskIdx, DeviceIdx, ccf.GetDeviceOrderFromMonitor(TaskIdx));
|
|
int bccoor = GetBarcodeCoor(xcoor, zcoor);
|
|
int mutXcoor; int mutZcoor;
|
|
GetStackRunX_Zcoor(mutex, out mutXcoor, out mutZcoor);
|
|
if (mutXcoor > 0)
|
|
{
|
|
#region »¥³âÓÐÈÎÎñÕýÔÚÔËÐÐ
|
|
|
|
int mutbccoor = GetBarcodeCoor(mutXcoor, mutZcoor);
|
|
if (mutex > DeviceIdx)
|
|
{
|
|
if (mutbccoor <= (bccoor + StackMutexXCoor))
|
|
{
|
|
if (mutbccoor > 52000)
|
|
{//20120110
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{//mutexС
|
|
if (bccoor >= (StackMutexXCoor + StackZeroXCoor))
|
|
{
|
|
if (mutbccoor >= (bccoor - StackMutexXCoor))
|
|
{
|
|
|
|
if (mutbccoor < 4481)//20120110
|
|
{//20120110
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bccoor >= 52000)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{//ÓÐÈÎÎñ£¬±»Ô¤Ô¼£¬µ«Ã»ÔËÐÐÈÎÎñ,¿ÉÄܱ¨¾¯»òÕß´¥ÃþÆÁ¿ØÖÆ
|
|
if ((mutexdev.RunState > 0) || (mutexDeviceLockedState != 0))
|
|
{// ±¨¾¯»òÕß±»ÈÎÎñËø¶¨
|
|
#region »¥³âÉ豸²»¿ÕÏÐ
|
|
|
|
if (mutex > DeviceIdx)
|
|
{//mutex=35002
|
|
if (mutexdev.XCoor <= (bccoor + StackMutexXCoor))
|
|
{
|
|
return false;//»òÕß·ÅÐÐÖ±½Ó±¨¾¯
|
|
}
|
|
|
|
}
|
|
else
|
|
{//mutex=35001
|
|
if (bccoor >= (StackMutexXCoor + StackZeroXCoor))
|
|
{
|
|
if (mutexdev.XCoor >= (bccoor - StackMutexXCoor))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region mutex±»¹ÜÀíÈÎÎñÔ¤Ô¼ÁË£¬µ«ÊÇ»¹Ã»ÔËÐУ¨¡¾ËÍ»õ¡¿µÈ´ýÔËÐУ©
|
|
int deviceorder = GetDeviceOrderFromManTaskReserve(mutexManTaskReserve, mutex);
|
|
if (deviceorder == -1) return false;
|
|
GetStackRunReserveX_Zcoor(mutex, out mutXcoor, out mutZcoor);
|
|
if (mutex > DeviceIdx)
|
|
{
|
|
if (mutexdev.XCoor <= (bccoor + StackMutexXCoor))
|
|
{
|
|
//È¥»õλ¸ß¶ÈºÏÊÊλÖñÜÈ㬻òÕßµ½52ÁУ¨60000£©
|
|
InsertStackMutexOrder(mutex, deviceorder, (bccoor + StackMutexXCoor), GetLayerHigh(mutZcoor, mutXcoor));
|
|
if (mutexdev.XCoor > 52000)//20120110
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (devinfo.XCoor < mutexdev.XCoor - minStackMutexXCoor)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{//mutexС
|
|
if (bccoor >= (StackMutexXCoor + StackZeroXCoor))
|
|
{
|
|
if (mutexdev.XCoor >= (bccoor - StackMutexXCoor))
|
|
{
|
|
//È¥»õλ¸ß¶ÈºÏÊÊλÖñÜÈ㬻òÕßµ½0ÁУ¨2000£©
|
|
InsertStackMutexOrder(mutex, deviceorder, (bccoor - StackMutexXCoor), GetLayerHigh(mutZcoor, mutXcoor));
|
|
if (mutexdev.XCoor < 4481)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (devinfo.XCoor > mutexdev.XCoor + minStackMutexXCoor)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region ¶¥Éý»úÏÈ¿ØÖƽü²æÊäËÍ»úËͳö
|
|
////20111226
|
|
//string r1 = "12001,42001,32001,12009,42009,32009,12017,42017,32017";
|
|
//if ((r1.IndexOf(DeviceIdx.ToString()) >= 0) &&(devinfo.IfCorrelDoubleFork!="1"))
|
|
//{
|
|
// if (IFExitTopPriDeviceIdxTaskWait(DeviceIdx+1) == true)
|
|
// {
|
|
// return false;
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
int CONTROLTASKTYPE = ccf.GetFCONTROLTASKTYPEFromManageTask(mti, fid);
|
|
|
|
#region ¶¥Éý»ú¹¹×Ô¹ØÁªÈë¿âÈÎÎñµ¥¶À´¦Àí//20101011
|
|
|
|
//20100406Èë¿â¶¥Éýʱ±ØÒª¼ì²â£º1102ÄÚ̽Îï¡°-11021¡±£»1121µÍµ½Î»¡°-11212¡±£»ÓйØÁªÈÎÎñʱ£¬1102Íâ̽Îï¡°-11022¡±£»
|
|
if ((ccf.GetCorrel_DeviceIndex(devinfo.DeviceIndex, true) == "0") && (CONTROLTASKTYPE == 1) && (devinfo.IfCorrelDoubleFork == "1"))//¶¥ÉýÉ豸×Ô¹ØÁª£¬Èë¿âÈÎÎñ20101124Ôö¼Ó¶¥ÉýÉ豸ÊÇ·ñË«²æÅжÏ
|
|
{
|
|
string[] CorrelInfo = ccf.GetOwnCorrel_DeviceInfo(devinfo.DeviceIndex);
|
|
if (CorrelInfo == null)
|
|
{
|
|
//20110505
|
|
AheadDetectUnallow.Append("¶¥Éý»ú¹¹" + devinfo.DeviceIndex.ToString() + "ûÓÐ×Ô¹ØÁª£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
|
|
}
|
|
if ((CStaticClass.GetDevicePhotoelectric(CorrelInfo[5]) == 1) && (CStaticClass.GetDevicePhotoelectric(CorrelInfo[2]) == 1))//½üÏïµÀÓÐÎ¶¥ÉýµÍλ//20101124
|
|
{
|
|
#region µÈ´ý¹ØÁªÈÎÎñÅä¶Ô
|
|
//ÔÚCStaticClass.DoubleForkWaitTime¹æ¶¨Ê±¼äÄڵȴý£»1102£¨11027£©×ª¶¯µÈ´ý
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_TaskIndex,F_DeviceIndex,F_Remark FROM T_Base_PLC_Ask WHERE (F_TaskIndex =").Append(TaskIdx).Append(") AND (F_Remark <> '') AND (F_DeviceIndex=").Append(devinfo.DeviceIndex).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
|
|
//(Convert.ToDateTime(dv[0]["F_Remark"]).AddSeconds(Convert.ToInt32(CStaticClass.DoubleForkWaitTime)) > DateTime.Now) ||
|
|
if ((GetIOControlStatus(minMidx) != Model.CGeneralFunction.TASKSINGLEFORKRUN) ||
|
|
((CStaticClass.GetDevicePhotoelectric(CorrelInfo[6]) == 1) && (CStaticClass.GetDevicePhotoelectric(CorrelInfo[4]) == 0)))//20101124
|
|
{
|
|
if ((CStaticClass.GetDevicePhotoelectric(CorrelInfo[6]) == 1)
|
|
&& (CStaticClass.GetDevicePhotoelectric(CorrelInfo[4]) == 0))//Íâ̽ÎÔËÐÐ//20101124
|
|
{
|
|
//²éÕÒ±¾µØ¹ÜÀíÈÎÎñ×ö¶à²æ¹ØÁªÅä¶Ô£¬¹ØÁªÈÎÎñ·ÖÅä½ü²æ
|
|
int mfid = GetEnableDoubleForkManageTask(1, devinfo.DeviceIndex, fid);
|
|
if (mfid > 0)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(mfid).Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(fid);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FUseAwayFork='0',F_RELATIVECONTORLID=").Append(fid).Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(mfid);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_UseAwayFork='0' where F_ManageTASKKINDINDEX=").Append(mti).Append(" and F_ManageTaskIndex=").Append(mfid).Append("");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
//ÓÉÓÚÒѾ·ÖÅä·¾¶²»Ò»¶¨·ûºÏÔ¶½ü»õ²æµÄ·ÖÅäÔÔò£¬ÐèÒª¸ÄµÀ
|
|
AlterRoutePath(mti, mfid, CONTROLTASKTYPE, '0', devinfo.DeviceIndex);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
//20110505
|
|
AheadDetectUnallow.Append("¶¥Éý»ú¹¹" + devinfo.DeviceIndex.ToString() + "µÈ´ý¹ØÁªÈÎÎñ£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{//³¬¹ýµÈ´ýʱ¼ä»òÕß¹ÜÀíÇ¿ÖÆÖ´Ðе¥²æÈÎÎñ
|
|
if (CStaticClass.GetDevicePhotoelectric(CorrelInfo[4]) == 1)//20101124
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Base_PLC_Ask set F_Remark='").Append(dtime).Append("' where (F_DeviceIndex=").Append(devinfo.DeviceIndex).Append(")");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
//20110505
|
|
AheadDetectUnallow.Append("¶¥Éý»ú¹¹" + devinfo.DeviceIndex.ToString() + "µÈ´ý¹ØÁªÈÎÎñ£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Base_PLC_Ask set F_TaskIndex=0,F_Remark='' where (F_DeviceIndex=").Append(devinfo.DeviceIndex).Append(")");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
return true;
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_TaskIndex,F_DeviceIndex,F_Remark FROM T_Base_PLC_Ask WHERE (F_TaskIndex =0) AND (F_Remark = '') AND (F_DeviceIndex=").Append(devinfo.DeviceIndex).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Base_PLC_Ask set F_TaskIndex=").Append(TaskIdx).Append(",F_Remark='").Append(dtime).Append("' where (F_DeviceIndex=").Append(devinfo.DeviceIndex).Append(")");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_UseAwayFork='1' where F_ManageTASKKINDINDEX=").Append(mti).Append(" and F_ManageTaskIndex=").Append(fid).Append("");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FUseAwayFork='1' where F_ManageTASKKINDINDEX=").Append(mti).Append(" and FID=").Append(fid).Append("");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
//ÓÉÓÚÒѾ·ÖÅä·¾¶²»Ò»¶¨·ûºÏÔ¶½ü»õ²æµÄ·ÖÅäÔÔò£¬ÐèÒª¸ÄµÀ
|
|
AlterRoutePath(mti, fid, CONTROLTASKTYPE, '1', devinfo.DeviceIndex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
//20110505
|
|
AheadDetectUnallow.Append("¶¥Éý»ú¹¹" + devinfo.DeviceIndex.ToString() + "²»Âú×ã¹ØÁª×´Ì¬£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
//20101011
|
|
#region Ë«²æ¶Ñ¶â»úµÄÈ¡»õÈÎÎñÔÚ´ËÅжÏÊÇ·ñ¹ØÁªË«²æ¡¢Ñé֤˫²æÈÎÎñÊÇ·ñΪ˫²æ¼«ÏÞ»õλ
|
|
if ((devinfo.DeviceKind == 1) && (devinfo.IfCorrelDoubleFork == "1") && (ccf.GetDeviceOrderFromMonitor(minMidx) == 4))
|
|
{
|
|
string[] DevLanewayIOInfo = ccf.GetDeviceLaneGateInfoFromStackCoor(devinfo.DeviceIndex, minMidx);
|
|
if (DevLanewayIOInfo == null)
|
|
{
|
|
//²»ÊÇÏïµÀ¿ÚµÄÈ¡»õÈÎÎñ²»ÐèÒª¹ØÁª
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("µ¥²æÖ´ÐÐÔÒò", minMidx.ToString(), devinfo.DeviceIndex.ToString(), "²»ÊÇÏïµÀ¿ÚµÄÈ¡»õÈÎÎñ²»ÐèÒª¹ØÁª");
|
|
return true;
|
|
}
|
|
Dictionary<int, string[]> corrinfo = Model.CGeneralFunction.GetDoubleForkMonitorInfo(minMidx, devinfo.DeviceIndex);
|
|
|
|
if (corrinfo == null)//20110412û¹ØÁªÈÎÎñ
|
|
{
|
|
#region 20110412¶Ñ¶â»úÔÚ¶¥Éý»úÈ¡µ¥²æÈÎÎñ£¬ÑéÖ¤ÊÇ·ñÐèÒª»»»õ²æ
|
|
string ChangeForkCell = ccf.IfLimitCellChangeFork(minMidx, devinfo.DeviceIndex);
|
|
|
|
if (ChangeForkCell != "-")//Ö÷ÈÎÎñÐèÒªµ¹»»»õ²æ
|
|
{
|
|
ccf.ChangeEndCellCode(minMidx, ChangeForkCell, devinfo.DeviceIndex);
|
|
return false;//20140423richardÈç¹û²»·µ»Øfalse£¬»¹»áʹÓÃÔÀ´µÄ×ø±ê¼ÌÐø·¢ËÍ
|
|
}
|
|
#endregion
|
|
|
|
#region û¹ØÁªÈÎÎñ
|
|
|
|
//string IfCorrel = ccf.GetCorrel_DeviceIndex(minMidx);//20110505
|
|
//if (IfCorrel == "")//ÎÞ¹ØÁª
|
|
//{
|
|
//}
|
|
//else if (IfCorrel == "0")//×Ô¹ØÁª
|
|
//{
|
|
// //20110108
|
|
// dbo.ExecuteSql("update T_Monitor_Task set F_UseAwayFork='1' where F_ManageTASKKINDINDEX=" + mti + " and F_ManageTaskIndex=" + fid + "");
|
|
// dbo.ExecuteSql("update T_Manage_Task set FUseAwayFork='1' where F_ManageTASKKINDINDEX=" + mti + " and FID=" + fid + "");
|
|
|
|
// #region 20110412¶Ñ¶â»úÔÚ¶¥Éý»úÈ¡µ¥²æÈÎÎñ£¬ÑéÖ¤ÊÇ·ñÐèÒª»»»õ²æ
|
|
// string ChangeForkCell = ccf.IfLimitCellChangeFork(minMidx, devinfo.DeviceIndex);
|
|
|
|
// if (ChangeForkCell != "-")//Ö÷ÈÎÎñÐèÒªµ¹»»»õ²æ
|
|
// {
|
|
// ccf.ChangeEndCellCode(minMidx, ChangeForkCell, devinfo.DeviceIndex);
|
|
|
|
// }
|
|
// #endregion
|
|
//}
|
|
|
|
//else
|
|
//{//ÓйØÁªÕ¾Ì¨
|
|
// #region Ë«²æ¶ÔµÈվ̨µÄµ¥ÈÎÎñÔڴ˵ȴý¹ØÁª£¬Ë«²æ¼«ÏÞ»õλ²»¹ØÁª
|
|
|
|
// if ((CStaticClass.GetDevicePhotoelectric(DevLanewayIOInfo[3]) == 1) && (CStaticClass.GetDevicePhotoelectric(DevLanewayIOInfo[1]) == 1))//Óлõ£¬¶¥Éý¸ßλ
|
|
// {
|
|
// #region ¶¥Éý¸ßλÓлõ
|
|
// bool isend;
|
|
// return GetCorrManageTask(DevLanewayIOInfo, TaskIdx, CONTROLTASKTYPE, mti, fid, dtime,out isend);
|
|
|
|
// #endregion
|
|
// }
|
|
// else
|
|
// {
|
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("µ¥²æÖ´ÐÐÔÒò", minMidx.ToString(), devinfo.DeviceIndex.ToString(), "¶¥Éý¸ßλºÍÓÐÎïÐźŲ»Âú×ãÌõ¼þ");
|
|
// }
|
|
// #endregion
|
|
|
|
//}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region ÓйØÁªÈÎÎñÐÅÏ¢
|
|
#region ÅжÏÊÇ·ñ»¹ÓпɹØÁªµÄ¹ØÁªÕ¾Ì¨ÈÎÎñ20120906
|
|
//bool isend;
|
|
//GetCorrManageTask(DevLanewayIOInfo, TaskIdx, CONTROLTASKTYPE, mti, fid, dtime,out isend);
|
|
//if (isend == false) return false;
|
|
#endregion
|
|
foreach (int CorrTaskindex in corrinfo.Keys)
|
|
{
|
|
#region Ë«²æÈÎÎñÔÚ´ËÑéÖ¤£¬ÊÇ·ñΪ˫²æ¼«ÏÞ»õλ£¬Ë«¼«ÏÞ»õλʹÓÃË«²æµ¹¿â»õλÐÞ¸ÄÈÎÎñ
|
|
//°Ñµ¹¿â»õλ×÷Ϊȡ»õºÍËÍ»õ¶¯×÷µÄÄ¿±ê»õ룬Ôö¼ÓÈ¡»õºÍËÍ»õ¶¯×÷¶ÔÓÚµ¹¿â»õλµÄÂß¼ÓÐÎïµÄÌáǰ¼ì²â
|
|
//±¨¸æµ¹¿â»õλÍê³Éʱ£¬×·¼Óµ¹¿â»õλ---¡·ÐèÒª»»²æµÄ¼«ÏÞ»õλµÄÈ¡»õºÍËÍ»õÈÎÎñ
|
|
|
|
#region ¼ì²é¹ØÁªÈÎÎñ
|
|
string ChangeForkCell1 = ccf.IfLimitCellChangeFork(CorrTaskindex, devinfo.DeviceIndex);
|
|
|
|
#endregion
|
|
if (ChangeForkCell1 != "-") //¹ØÁªÈÎÎñÐèÒªµ¹»»»õ²æ
|
|
{
|
|
ccf.ChangeEndCellCode(CorrTaskindex, ChangeForkCell1, devinfo.DeviceIndex);
|
|
return false;//20140423richardÈç¹û²»·µ»Øfalse£¬»¹»áʹÓÃÔÀ´µÄ×ø±ê¼ÌÐø·¢ËÍ
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Ë«²æAGVµÄÈë¿âÈ¡»õÈÎÎñÔÚ´ËÅжÏÊÇ·ñ¹ØÁªË«²æ¡¢Ñé֤˫²æÈÎÎñÊÇ·ñΪ˫²æ¼«ÏÞ»õλ
|
|
if ((devinfo.DeviceKind == 6) && (devinfo.IfCorrelDoubleFork == "1") && (ccf.GetDeviceOrderFromMonitor(minMidx) == 2) && ((CONTROLTASKTYPE == 1) || (CONTROLTASKTYPE == 4)))
|
|
{
|
|
|
|
Dictionary<int, string[]> corrinfo = Model.CGeneralFunction.GetDoubleForkMonitorInfo(minMidx, devinfo.DeviceIndex);
|
|
|
|
if (corrinfo == null)
|
|
{
|
|
#region Ë«²æ¶ÔµÈվ̨µÄµ¥ÈÎÎñÔڴ˵ȴý¹ØÁª£¬Ë«²æ¼«ÏÞ»õλ²»¹ØÁª
|
|
if (GetIOControlStatus(TaskIdx) != Model.CGeneralFunction.TASKSINGLEFORKRUN)
|
|
{//Ã»Ç¿ÖÆµ¥²æÖ´ÐÐ
|
|
|
|
//²éÕÒ¹ØÁªÕ¾Ì¨
|
|
int agvCorrel = GetAGVCorrelIndex(TaskIdx);
|
|
if (agvCorrel != -1)
|
|
{
|
|
//²éÕÒ±¾µØ¹ÜÀíÈÎÎñ×ö¶à²æ¹ØÁªÅä¶Ô£¬¹ØÁªÈÎÎñ·ÖÅä»õ²æ
|
|
int mfid = GetAGVEnableDoubleForkManageTask(CONTROLTASKTYPE, agvCorrel, devinfo.DeviceIndex);
|
|
if (mfid > 0)
|
|
{
|
|
#region Ë«²æÍ¬ÎªÇ°¼«ÏÞºóÕߺó¼«ÏÞ²»¹ØÁª£¬µ¥¶ÀÖ´ÐÐ
|
|
if ((IfInSameLimitX(fid, mfid, mti) == true) && (mti == 1))
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(fid).Append(")");
|
|
dboM.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(mfid).Append(")");
|
|
dboM.ExecuteSql(sql.ToString());
|
|
return true;
|
|
}
|
|
#endregion
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(mfid).Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(fid);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(fid).Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(mfid);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
return true;
|
|
}
|
|
|
|
else
|
|
{
|
|
//20110505
|
|
AheadDetectUnallow.Append("Ë«²æAGVÔÚË«²æÐ£±íվ̨ȡ»õ" + "£¬µÈ´ý¶à²æ¹ØÁªÕ¾Ì¨" + agvCorrel.ToString() + "µÄÈÎÎñ£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
return true;
|
|
}
|
|
else
|
|
{//¹ÜÀíÇ¿ÖÆÖ´Ðе¥²æÈÎÎñ
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Ë«²æAGVµÄ³ö¿â¿ÚÊäËÍ»úÈ¡»õÈÎÎñÔÚ´ËÅжÏÊÇ·ñ¹ØÁªË«²æ20110412
|
|
if ((devinfo.DeviceKind == 6) && (devinfo.IfCorrelDoubleFork == "1") && ((ccf.GetDeviceOrderFromMonitor(minMidx) == 2)
|
|
|| (ccf.GetDeviceOrderFromMonitor(minMidx) == 4)) && (CONTROLTASKTYPE == 2))
|
|
{
|
|
|
|
Dictionary<int, string[]> corrinfo = Model.CGeneralFunction.GetDoubleForkMonitorInfo(minMidx, devinfo.DeviceIndex);
|
|
|
|
if (corrinfo == null)
|
|
{
|
|
#region Ë«²æ¶ÔµÈվ̨µÄµ¥ÈÎÎñÔڴ˵ȴý¹ØÁª£¬Ë«²æ¼«ÏÞ»õλ²»¹ØÁª
|
|
if (GetIOControlStatus(TaskIdx) != Model.CGeneralFunction.TASKSINGLEFORKRUN)//20110429²âÊÔÓ¦¸ÃΪGetIOControlStatus(TaskIdx)£¡=
|
|
{//Ã»Ç¿ÖÆµ¥²æÖ´ÐÐ
|
|
|
|
//²éÕÒ¹ØÁªÕ¾Ì¨
|
|
int agvCorrel = GetAGVCorrelConveyorIndex(TaskIdx);
|
|
if (agvCorrel != -1)
|
|
{
|
|
#region ²éÕÒ¶ÓÁÐÖÐÊÇ·ñÓÐagvCorrelµÄÈÎÎñ£ºÈç¹ûûÓУ¬²»Ôٵȴý£¬µ¥²æÖ´ÐУ»
|
|
|
|
if (GetAGVEnableDoubleForkManageTask(2, agvCorrel, devinfo.DeviceIndex) <= 0)//ûÓÐÄܹØÁªµÄÈÎÎñ£¬²»Ôٵȴý£¬µ¥²æÖ´ÐÐ
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(fid).Append(")");
|
|
dboM.ExecuteSql(sql.ToString());
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
#region 20110412ÓÐÄܹØÁªµÄÈÎÎñ£¬ÅжÏagvCorrelÊÇ·ñÓÐÎï¶øÇÒÈÎÎñÒѾµ½È¡»õ״̬
|
|
int[] cstates = CStaticClass.GetDeviceState(agvCorrel);
|
|
int cssstate = -1;
|
|
if (cstates != null)
|
|
{
|
|
cssstate = cstates[1];
|
|
}
|
|
if ((cssstate != 0) || (CStaticClass.GetDevicePhotoelectric(agvCorrel - 2, 0) != 1) || (CStaticClass.GetDevicePhotoelectric(agvCorrel, 2) != 1))//20110412¶¥Éý»ú¿ÕÏС¢Óлõ¡¢µÍλ
|
|
{
|
|
//20110505
|
|
AheadDetectUnallow.Append("Ë«²æAGVÔÚË«²æÐ£±íվ̨ȡ»õ" + "£¬µÈ´ý¶à²æ¹ØÁªÕ¾Ì¨" + agvCorrel.ToString() + "µÄÈÎÎñ£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
#endregion
|
|
//²éÕÒ±¾µØ¹ÜÀíÈÎÎñ×öË«²æÔÚÊäËÍ»úÈ¡»õÈÎÎñ¹ØÁªÅä¶Ô£¬¹ØÁªÈÎÎñ·ÖÅä»õ²æ
|
|
int mfid = GetAGVFromConveyorDoubleForkGetGoodManageTask(2, agvCorrel, devinfo.DeviceIndex);
|
|
if (mfid > 0)
|
|
{
|
|
#region Öյ㲻Ïàͬ£¬µ¥²æ·Ö±ðÖ´ÐÐ
|
|
if (IFHaveSameEndDevice(fid, mfid, mti) == false)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(fid).Append(")");
|
|
dboM.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(mfid).Append(")");
|
|
dboM.ExecuteSql(sql.ToString());
|
|
return true;
|
|
}
|
|
#endregion
|
|
#region Ë«²æÍ¬ÎªÇ°¼«ÏÞºóÕߺó¼«ÏÞ²»¹ØÁª£¬µ¥¶ÀÖ´ÐÐ
|
|
//if ((IfInSameLimitX(fid, mfid, mti) == true) && (mti == 1))
|
|
//{
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(fid).Append(")");
|
|
// dboM.ExecuteSql(sql.ToString());
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(mfid).Append(")");
|
|
// dboM.ExecuteSql(sql.ToString());
|
|
// return true;
|
|
//}
|
|
#endregion
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(mfid).Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(fid);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(fid).Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(mfid);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
return true;
|
|
}
|
|
|
|
else
|
|
{
|
|
//20110505
|
|
AheadDetectUnallow.Append("Ë«²æAGVÔÚÊäËÍ»úÈ¡»õ" + "£¬Ã»ÕÒµ½¶à²æ¹ØÁªÈÎÎñ£¬¹ØÁªÕ¾Ì¨" + agvCorrel.ToString() + "ÓÐÒì³£ÎïÌåÕÚµ²¿ª¹Ø£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
return true;
|
|
}
|
|
else
|
|
{//¹ÜÀíÇ¿ÖÆÖ´Ðе¥²æÈÎÎñ
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region »úеÊÖÂë¶âÈÎÎñ Ìõ¼þ¼ì²â yy add
|
|
|
|
if (DeviceKind == 17)
|
|
{
|
|
sql.Clear();
|
|
//ÖÕµãλÖÃÊÇ·ñÂú¶â
|
|
sql.Append($" select Device from ZH_pallet where GOODS_COUNT = 1 and Device = {EndDevice} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + EndDevice + "ÒÔÂú¶â£¬µÈ´ýËͳö£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
//ÅжϻúеÊÖÆðµã»òÖÕµã״̬
|
|
|
|
//ÊÇ·ñ´æ£¬×âÅÌÒÑÂúµÈ´ýÀ뿪µÄÈÎÎñ£¬ÊÇ·ñ´æÔÚ¹©¸ø¿ÕÍÐÅÌÈÎÎñ
|
|
int tempDevice = StartDevice == 12041 ? 12015 : 12016;
|
|
sql.Clear();
|
|
sql.Append($" select F_ManageTaskIndex from T_Monitor_Task where F_NumParam1 = {tempDevice} and F_NumParam4 = {EndDevice} and F_MonitorIndex !={minMidx} ");
|
|
//ÅжÏÏàͬÖÕµãÊÇ·ñ´æÔÚ²ðÅÌÈÎÎñ
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + EndDevice + "´æÔÚ¹©¸ø¿ÕÍÐÅÌÈÎÎñ£¬µÈ´ý²ðÅÌÍê³É£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
Model.MDevice tempDevinfo = Model.CGetInfo.GetDeviceInfo(EndDevice);//·Å»õվ̨
|
|
if (tempDevinfo.RunState != 0)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + EndDevice + "²»¿ÕÏС£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
if (new int[] { 12015, 12016 }.Contains(StartDevice) && tempDevinfo.SplitByte_0 == 1)
|
|
{
|
|
AheadDetectUnallow.Append("²ðÍÐÅÌÈÎÎñ·Å»õվ̨" + EndDevice + "Óлõ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
sql.Clear();
|
|
sql.Append($" select F_ManageTaskIndex from T_Monitor_Task where F_DeviceIndex = {DeviceIdx} and F_Status > 0 ");
|
|
//ÅжÏÏàͬÖÕµãÊÇ·ñ´æÔÚ²ðÅÌÈÎÎñ
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("»úеÊÖ" + DeviceIdx + "´æÔÚÖ´ÐÐÖеÄÈÎÎñ£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
Model.MDevice AGVDevinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);//·Å»õվ̨
|
|
if (AGVDevinfo.RunState > 0)
|
|
{
|
|
AheadDetectUnallow.Append("»úеÊÖ" + DeviceIdx + "·Ç¿ÕÏУ»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
sql.Clear();
|
|
//ÖÕµãλÖÃÊÇ·ñ´æÔÚÖØ¸´ÌõÂëÐÅÏ¢
|
|
sql.Append($" select * from ZH_pallet where Device = {EndDevice} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
List<string> code = dv[0]["SN"].ToString().Split(',').ToList();
|
|
if (code.Count != code.Distinct().Count())
|
|
{
|
|
string repeatCode = "";
|
|
foreach (var item in code)
|
|
{
|
|
if (code.Contains(item))
|
|
{
|
|
repeatCode = item;
|
|
break;
|
|
}
|
|
}
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + EndDevice + "´æÔÚÖØ¸´ÌõÂë " + repeatCode);
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ³ö¿âÏÞÖÆ£¬Î´·¢ËÍAGV ÈÎÎñÔò³ö¿â£¬ÒÑ·¢ËÍ£¬ÏÈÈëºó³ö yy add
|
|
|
|
if (mti != 4 && DeviceKind == 1 && order == 4)
|
|
{
|
|
sql.Clear();
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FID = {fid} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0 && Convert.ToInt32(dv[0]["FCONTROLTASKTYPE"]) != 3)
|
|
{
|
|
//»ñÈ¡Ö÷ÈÎÎñµÄ ÖÕµ½Î»
|
|
string tempFENDDEVICE = dv[0]["FENDDEVICE"].ToString();
|
|
//»ñÈ¡Ö÷ÈÎÎñµÄ Ö´ÐÐÏïµÀ
|
|
string tempFSTARTDEVICE = dv[0]["FSTARTDEVICE"].ToString();
|
|
//¸ù¾ÝÖÕµ½Î»»ñȡִÐÐÉ豸
|
|
dvdv = dbo.ExceSQL($" select F_LaneGateDeviceIndex from T_Base_Lane_Gate where F_ZXY like '%{tempFENDDEVICE.Substring(0, 1).PadLeft(2, '0')}' and F_LaneIndex = '{tempFSTARTDEVICE}'").Tables[0].DefaultView;
|
|
if (dvdv.Count > 0)
|
|
{
|
|
int F_LaneGateDeviceIndex = Convert.ToInt32(dvdv[0]["F_LaneGateDeviceIndex"]);
|
|
|
|
int[] arr = new int[] { };//µÚһλ·Å»õ룬µÚ¶þλ´«ÊäÏßÖÕµ½Î»
|
|
switch (F_LaneGateDeviceIndex)
|
|
{
|
|
case 12001:
|
|
arr = new int[] { 12001, 12002 };
|
|
break;
|
|
case 12003:
|
|
arr = new int[] { 12003, 12004 };
|
|
break;
|
|
case 22001:
|
|
arr = new int[] { 22001, 22002 };
|
|
break;
|
|
case 22003:
|
|
arr = new int[] { 22003, 22004 };
|
|
break;
|
|
case 32002:
|
|
arr = new int[] { 32002, 32001 };
|
|
if (_AheadDetect.Contains("32004"))
|
|
{
|
|
string NewAheadDetect = _AheadDetect + ";D32003.0;I32003;I32003;D32003.0";
|
|
sql.Clear();
|
|
sql.AppendLine($" update T_Monitor_Task set F_AheadDetect ='{NewAheadDetect}' where F_ManageTaskIndex = {fid} and F_MonitorIndex = {TaskIdx} ;");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
}
|
|
break;
|
|
}
|
|
|
|
Model.MDevice tempDevinfo = Model.CGetInfo.GetDeviceInfo(arr[1]);//·Å»õվ̨
|
|
if (tempDevinfo.RunState != 0 || tempDevinfo.SplitByte_0 == 1)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + F_LaneGateDeviceIndex + "ÉÏÓÐÎï»ò²»¿ÕÏС£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
//һ¥±ÜÃâ»Ø¿â¶ÂµôÈë¿âͨµÀÅжÏ
|
|
if (new int[] { 19002, 19003 }.Contains(Convert.ToInt32(tempFENDDEVICE)))
|
|
{
|
|
tempDevinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(tempFENDDEVICE));//·Å»õվ̨
|
|
if (tempDevinfo.SplitByte_0 == 1)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + tempFENDDEVICE + "ÉÏÓÐÎï»ò²»¿ÕÏС£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FSTATUS > 0 and FCONTROLTASKTYPE = 2 and FID !={fid} and FENDDEVICE={Convert.ToInt32(tempFENDDEVICE)} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Base_TaskCount where F_EXECUTIONCOUNT > 0 and F_DeviceIndex = {EndDevice} ");
|
|
dvdv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
int EXECUTIONCOUNT01 = dvdv.Count > 0 ? Convert.ToInt32(dvdv[0]["F_EXECUTIONCOUNT"]) : 0;
|
|
EXECUTIONCOUNT01 = EXECUTIONCOUNT01 > 0 ? EXECUTIONCOUNT01 - 1 : 0;
|
|
if (dv.Count > EXECUTIONCOUNT01)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + tempFENDDEVICE + "ÉÏÓгö¿âÈÎÎñÕýÔÚÖ´ÐС£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
dvdv = dbo.ExceSQL($" select * from T_Monitor_Task where F_Status > 0 and F_NumParam5 in ({string.Join(",", arr)})").Tables[0].DefaultView;
|
|
if (dvdv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("³ö¿âվ̨" + arr[1] + "£¬´æÔÚδÍê³ÉµÄAGV·Å»õ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
dvdv = dbo.ExceSQL($" select * from T_Manage_Task where FSTATUS > 0 and FENDDEVICE in ({string.Join(",", arr)})").Tables[0].DefaultView;
|
|
if (dvdv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("³ö¿âվ̨" + arr[1] + "£¬´æÔÚδÍê³É" + dvdv[0]["FID"] + "µÄµ÷¶ÈÈÎÎñ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
//Model.MDevice tempDevinfo = Model.CGetInfo.GetDeviceInfo(next_NumParam1);//·Å»õվ̨
|
|
//if (tempDevinfo.RunState != 0 || tempDevinfo.SplitByte_0 == 1)
|
|
//{
|
|
// AheadDetectUnallow.Append("·Å»õվ̨" + next_NumParam1 + "ÉÏÓÐÎï¡£");
|
|
// UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
// return false;
|
|
//}
|
|
}
|
|
}
|
|
|
|
if (EndDevice == 39003)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FSTATUS > 0 and FSTARTDEVICE = 39003 ");
|
|
//ÅжÏÏàͬÖÕµãÊÇ·ñ´æÔÚ²ðÅÌÈÎÎñ
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("´æÔÚ 39003 վ̨»Ø¿âÈÎÎñ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
if (CStaticClass.GetDevicePhotoelectric(39003, 0) > 0)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨39003Óлõ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//¿ØÖÆ ÖÕµã Ϊ29008 µÄÈÎÎñÊý¡£
|
|
if (EndDevice == 29008)
|
|
{
|
|
dv = dbo.ExceSQL("SELECT * FROM T_Base_Device where F_DeviceIndex = 29008").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
string[] trayList = dv[0]["F_PALLETBARCODE"].ToString().Trim() == "-" ? new string[] { } : dv[0]["F_PALLETBARCODE"].ToString().Split(',');
|
|
trayList = trayList.Distinct().Where(c => !string.IsNullOrEmpty(c)).ToArray();
|
|
dv = dbo.ExceSQL($"select * from T_Manage_Task where FSTATUS > 0 and FENDDEVICE = 29008 and FID != {fid}").Tables[0].DefaultView;
|
|
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Base_TaskCount where F_EXECUTIONCOUNT > 0 and F_DeviceIndex = {EndDevice} ");
|
|
dvdv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvdv.Count > 0)
|
|
{
|
|
int taskNum = Convert.ToInt32(dvdv[0]["F_EXECUTIONCOUNT"]);
|
|
if ((trayList.Length + dv.Count) >= taskNum)
|
|
{
|
|
AheadDetectUnallow.Append("29008×Ô¶¯´«ÊäÏßÈÎÎñ£¬ÊýÁ¿ÀۼƴóÓÚµÈÓÚ¿ÉÖ´ÐÐÈÎÎñÊýÁ¿ " + taskNum);
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
#region AGV վ̨¿É·¢ËÍÈÎÎñÊýÁ¿
|
|
if (mti != 4)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select distinct FID from T_Manage_Task where FSTATUS > 0 and FENDDEVICE = {EndDevice} and FID != { fid} ");
|
|
EXECUTIONCOUNT = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count;
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Base_TaskCount where F_EXECUTIONCOUNT > 0 and F_DeviceIndex = {EndDevice} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (EXECUTIONCOUNT >= Convert.ToInt32(dv[0]["F_EXECUTIONCOUNT"]))
|
|
{
|
|
AheadDetectUnallow.Append("ÖÕµãվ̨" + EndDevice + "´æÔÚ" + EXECUTIONCOUNT + "ÌõδÍê³ÉÈÎÎñ£¬µÈ´ýÖ´ÐÐÍê³É£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
//µ±·Å»õµãÈÎÎñÊýΪ 1 ʱ£¬Ñé֤վ̨ÊÇ·ñÓлõ
|
|
if (Convert.ToInt32(dv[0]["F_EXECUTIONCOUNT"]) == 1)
|
|
{
|
|
int[] arr = new int[] { EndDevice };//µÚһλ·Å»õ룬µÚ¶þλ´«ÊäÏßÖÕµ½Î»
|
|
switch (EndDevice)
|
|
{
|
|
case 12001:
|
|
case 12002:
|
|
arr = new int[] { 12001, 12002 };
|
|
break;
|
|
case 12003:
|
|
case 12004:
|
|
arr = new int[] { 12003, 12004 };
|
|
break;
|
|
case 22001:
|
|
case 22002:
|
|
arr = new int[] { 22001, 22002 };
|
|
break;
|
|
case 22003:
|
|
case 22004:
|
|
arr = new int[] { 22003, 22004 };
|
|
break;
|
|
case 32002:
|
|
arr = new int[] { 32001, 32002, 32003, 32004 };
|
|
break;
|
|
default:
|
|
arr = new int[] { EndDevice };
|
|
break;
|
|
}
|
|
//AGVÈÎÎñ ÆðµãÖյ㲻ÔÚµ±Ç°Êý×éÖÐÔòΪ´«ÊäÏß»ØÍË/Õýת
|
|
if (!arr.Contains(StartDevice) && !arr.Contains(EndDevice))
|
|
{
|
|
for (int i = 0; i < arr.Length; i++)
|
|
{
|
|
Model.MDevice tempDevinfo = Model.CGetInfo.GetDeviceInfo(arr[i]);//·Å»õվ̨
|
|
if (tempDevinfo.DeviceKind == 9)
|
|
{
|
|
if (tempDevinfo.SplitByte_0 == 1)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + arr[i] + "ÉÏÓÐÎï¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (tempDevinfo.RunState != 0 || tempDevinfo.SplitByte_0 == 1)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + arr[i] + "ÉÏÓÐÎï»ò²»¿ÕÏС£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region AGV ÈÎÎñÏÞÖÆ ·Å»õÖÕµã´æÔÚÆäËüÒÔ·¢Ë͵Ķâ»úÈÎÎñÔò²»·¢Ë͵±Ç°AGV ÈÎÎñ yy add
|
|
//3¥վֻ̨ÄÜÓÐÒ»¸öÕýÔÚÖ´ÐеÄÈÎÎñÆô¶¯
|
|
if (new int[] { 15001, 35001 }.Contains(DeviceIdx))
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Monitor_Task where F_MonitorIndex ={minMidx} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
int tempDevice = Convert.ToInt32(dv[0]["F_NumParam5"]);
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FSTATUS > 0 and FCONTROLTASKTYPE = 2 and FID != {fid} and FID in ( select distinct F_ManageTaskIndex from T_Monitor_Task where (F_NumParam1 = {tempDevice} or F_NumParam2 = {tempDevice} or F_NumParam4 = {tempDevice} or F_NumParam5 = {tempDevice} ) ) ");
|
|
//ÅжÏÏàͬÖÕµãÊÇ·ñ´æÔÚ²ðÅÌÈÎÎñ
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//AheadDetectUnallow.Append("AGVµ±Ç°ÈÎÎñ·Å»õվ̨" + EndDevice + "´æÔÚÖ´ÐÐÖеÄÈÎÎñ£»");
|
|
//UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
//return false;
|
|
if (dv.Count == 1)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from AGV_TASK where FID in ({dv[0]["FID"]}) and AGV_TASK_STATUS < 2 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//AGV È¡»õÍê³ÉÊÇ·ñ´óÓÚ ÒªÖ´ÐÐÊý
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("AGVµ±Ç°ÈÎÎñ·Å»õվ̨" + EndDevice + "´æÔÚδȡ»õµÄÈÎÎñ£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
//Ôò²»¸øAGV·¢ÈÎÎñ
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AheadDetectUnallow.Append("AGVµ±Ç°ÈÎÎñ·Å»õվ̨" + EndDevice + "´æÔÚÖ´ÐÐÖеÄÈÎÎñ£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//if (DeviceIdx == 15001)
|
|
if (DeviceIdx == 15001 && ccf.GetDeviceKindIdx(tempDevice) == 2)
|
|
{
|
|
//if (CStaticClass.GetDevicePhotoelectric(tempDevice, 0) > 0)
|
|
//{
|
|
// AheadDetectUnallow.Append("·Å»õվ̨" + tempDevice + "Óлõ¡£");
|
|
// UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
// return false;
|
|
//}
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FCONTROLTASKTYPE = 2 and FID != {fid} and FID in ( select distinct F_ManageTaskIndex from T_Monitor_Task where (F_NumParam1 = {tempDevice} or F_NumParam2 = {tempDevice} or F_NumParam4 = {tempDevice} or F_NumParam5 = {tempDevice} ) ) ");
|
|
//ÅжÏÏàͬÖÕµãÊÇ·ñ´æÔÚ²ðÅÌÈÎÎñ
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("AGVµ±Ç°ÈÎÎñ·Å»õվ̨" + EndDevice + "´æÔÚ³ö¿âµÄÈÎÎñ£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
if (StartDevice == 39003)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FSTATUS > 0 and FENDDEVICE = 39003 ");
|
|
//ÅжÏÏàͬÖÕµãÊÇ·ñ´æÔÚ²ðÅÌÈÎÎñ
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("39003վ̨£¬´æÔÚÖ´ÐÐÖÐÈÎÎñ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
//1¥վ̨ºÍ¶þ¥վ̨ Ö»ÒªAGV½Óµ½ÈÎÎñ²¢ÇÒÈ¡»õÍê³ÉÔò¿ÉÒÔÏ·¢Í¬Õ¾Ì¨µÄÈë¿âÈÎÎñ
|
|
if (new int[] { 25001 }.Contains(DeviceIdx) && EndDevice != 22006)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Monitor_Task where F_MonitorIndex ={minMidx} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
int tempDevice = Convert.ToInt32(dv[0]["F_NumParam5"]);
|
|
sql.Clear();
|
|
sql.Append($"select fid from T_Manage_Task where FSTATUS > 0 and FCONTROLTASKTYPE = 2 and FID in ( select distinct F_ManageTaskIndex from T_Monitor_Task where (F_NumParam1 = {tempDevice} or F_NumParam2 = {tempDevice} or F_NumParam4 = {tempDevice} or F_NumParam5 = {tempDevice} ) )");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//Èç¹ûÓÐÕýÔÚÖ´ÐеÄͬվ̨³ö¿âÈÎÎñ
|
|
if (dv.Count > 0)
|
|
{
|
|
List<int> arr = new List<int>();
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
arr.Add(Convert.ToInt32(dv[i]["FID"]));
|
|
}
|
|
sql.Clear();
|
|
sql.Append($" select * from AGV_TASK where FID in ({ string.Join(",", arr)}) and AGV_TASK_STATUS < 2 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//AGV È¡»õÍê³ÉÊÇ·ñ´óÓÚ ÒªÖ´ÐÐÊý
|
|
if (dv.Count > 0)
|
|
{
|
|
if (dv.Count < arr.Count)
|
|
{
|
|
AheadDetectUnallow.Append("AGVµ±Ç°ÈÎÎñ·Å»õվ̨" + tempDevice + "´æÔÚÖ´ÐÐÖеÄÈÎÎñ£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
//Ôò²»¸øAGV·¢ÈÎÎñ
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//sql.Clear();
|
|
//sql.Append($" select * from AGV_TASK where FID ={Convert.ToInt32(dv[0]["FID"])}");
|
|
//dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
////²¢ÇÒAGVÈÎÎñûÓÐÈ¡»õÍê³É
|
|
//if (dv.Count > 0)
|
|
//{
|
|
// if (Convert.ToInt32(dv[0]["AGV_TASK_STATUS"]) < 3)
|
|
// {
|
|
// AheadDetectUnallow.Append("AGVµ±Ç°ÈÎÎñ·Å»õվ̨" + EndDevice + "´æÔÚÖ´ÐÐÖеÄÈÎÎñ£»");
|
|
// UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
// //Ôò²»¸øAGV·¢ÈÎÎñ
|
|
// return false;
|
|
|
|
// }
|
|
|
|
//}
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region AGVÆðµãÈÎÎñ£¬´æÔÚδȡ»õÈÎÎñÔò²»ÔÚ¼ÌÐø·¢ËÍAGVվ̨ȡ»õÈÎÎñ
|
|
if (DeviceKind == 6)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select F_ManageTaskIndex from T_Monitor_Task where F_NumParam2 = {StartDevice} and F_Status > 0 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($"select * from AGV_TASK where AGV_TASK_STATUS >= 3 and FID in (select F_ManageTaskIndex from T_Monitor_Task where F_NumParam2 = {StartDevice} and F_Status > 0 ) ");
|
|
dvdv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvdv.Count <= 0)
|
|
{
|
|
AheadDetectUnallow.Append("È¡»õվ̨" + StartDevice + "´æÔÚÈ¡»õδÍê³ÉµÄÈÎÎñ " + dv[dv.Count - 1]["F_ManageTaskIndex"] + "¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
if (dv.Count != dvdv.Count)
|
|
{
|
|
AheadDetectUnallow.Append("È¡»õվ̨" + StartDevice + "´æÔÚÈ¡»õδÍê³ÉµÄÈÎÎñ " + dv[dv.Count - 1]["F_ManageTaskIndex"] + "¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 12021-12024 ÌõÂëÑéÖ¤ ¶â»úÈë¿âÌõÂëÑéÖ¤
|
|
if (mti == 1 && StartDevice == 12024)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Base_PLC_Ask where F_BindingDevice = 12024 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//F_TxtParam
|
|
if (dv[0]["F_BarCode"].ToString().Trim() != barcode)
|
|
{
|
|
AheadDetectUnallow.Append("12024´«ÊäÏßÈÎÎñÌõÂëÓë16001ɨÂë²»Ò»Ö£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
//µ÷¶ÈÈÎÎñ¡¢Èë¿â¡¢¶â»úÈ¡»õ ÅÐ¶Ï ÌõÂëɨÃèÆ÷
|
|
if (mti == 1 && CONTROLTASKTYPE == 1 && DeviceKind == 1 && order == 4)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Base_PLC_Ask where F_BindingDevice = {StartDevice} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//F_TxtParam
|
|
if (dv[0]["F_BarCode"].ToString().Trim() != barcode)
|
|
{
|
|
AheadDetectUnallow.Append(StartDevice + " ´«ÊäÏßÈÎÎñÌõÂëÓëÌõÂëɨÂë²»Ò»Ö£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region ÑéÖ¤³ö¿âÊÇ·ñ˳ÐòÖ´ÐÐ WMS_TASKTYPE
|
|
if (mti != 4 && DeviceKind == 1 && order == 4)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FENDDEVICE = {EndDevice} and WMS_TASKTYPE > (select distinct max( COALESCE( WMS_TASKTYPE,0)) as WMS_TASKTYPE from T_Manage_Task where FID = {fid})");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("ÖÕµãվ̨" + EndDevice + "´æÔÚ¸ß˳ÐòÖ´ÐÐ" + dv[0]["WMS_TASKTYPE"] + "δÍê³ÉÈÎÎñ£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region µþÅÌ»ú ³öÈëÈÎÎñÌõ¼þ¼ì²â
|
|
if (new int[] { 22005 }.Contains(StartDevice) && EndDevice == 22006)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FENDDEVICE = 22006 and FSTARTDEVICE not in(22007,22005) and FSTATUS > 0 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + EndDevice + "´æÔÚÖ´ÐÐÖеÄÈÎÎñ£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
if (CStaticClass.GetDevicePhotoelectric(22006, 0) > 0)
|
|
{
|
|
AheadDetectUnallow.Append("·Å»õվ̨22006Óлõ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
if (StartDevice != 22005 && EndDevice == 22006)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FENDDEVICE = 22006 and FSTARTDEVICE in(22005)");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("22006վ̨´æÔÚÂú¶âÈÎÎñµÄÈÎÎñ£»");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (StartDevice == 22006 && EndDevice != 22005)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Monitor_Task where F_MonitorIndex ={minMidx} and F_NumParam2 = 22006 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
int deviceTemp = Convert.ToInt32(dv[0]["F_NumParam5"]);
|
|
if (CStaticClass.GetDevicePhotoelectric(deviceTemp, 0) > 0 || CStaticClass.GetDeviceState(deviceTemp)[1] > 0)
|
|
{
|
|
//AGVÈÎÎñÑé֤վ̨ÊÇ·ñÓлõ
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + deviceTemp + "Óлõ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
if (CStaticClass.GetDevicePhotoelectric(EndDevice, 0) > 0 || CStaticClass.GetDeviceState(EndDevice)[1] > 0)
|
|
{
|
|
//AGVÈÎÎñÑé֤վ̨ÊÇ·ñÓлõ
|
|
AheadDetectUnallow.Append("·Å»õվ̨" + EndDevice + "Óлõ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region µþÅÌ»ú ÈÎÎñ¼ÆÊý
|
|
if (new int[] { 22007, 22006, 22005 }.Contains(StartDevice) == false && (EndDevice == 22006 || EndDevice == 29007))
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Monitor_Task where F_NumParam1 = 22006 or F_NumParam2 = 22006 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//if (dv[0]["F_NumParam5"].ToString() == "22005")
|
|
//{
|
|
AheadDetectUnallow.Append("Æðµã22006»òÖÕµã22005´æÔÚδÍê³ÉµÄÈÎÎñ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
//}
|
|
//sql.Clear();
|
|
//sql.Append($" select * from AGV_TASK where FID in ({dv[0]["F_ManageTaskIndex"]}) and AGV_TASK_STATUS < 2 ");
|
|
//dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
////AGV È¡»õÍê³ÉÊÇ·ñ´óÓÚ ÒªÖ´ÐÐÊý
|
|
//if (dv.Count > 0)
|
|
//{
|
|
// AheadDetectUnallow.Append("AGVµ±Ç°ÈÎÎñ·Å»õվ̨" + EndDevice + "´æÔÚδȡ»õµÄÈÎÎñ£»");
|
|
// UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
// //Ôò²»¸øAGV·¢ÈÎÎñ
|
|
// return false;
|
|
//}
|
|
}
|
|
if (CStaticClass.GetDevicePhotoelectric(22006, 0) > 0)
|
|
{
|
|
if (mti != 4 && DeviceKind == 1 && order == 4)
|
|
{
|
|
//AGVÈÎÎñÑé֤վ̨ÊÇ·ñÓлõ
|
|
AheadDetectUnallow.Append("·Å»õվ̨22006Óлõ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
Model.MDevice tempDevinfo = Model.CGetInfo.GetDeviceInfo(29001);//µþÅÌ»ú
|
|
if (tempDevinfo.RunState != 0)
|
|
{
|
|
AheadDetectUnallow.Append("µþÅÌ»ú·Ç¿ÕÏС£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
|
|
Model.MDevice tempDevinfo22005 = Model.CGetInfo.GetDeviceInfo(22005);//µþÅÌ»úÏ´«ÊäÏß
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FENDDEVICE in( 22006,29007) and FSTATUS > 0");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count == 0)
|
|
{
|
|
//µ±Ã»ÓÐÒÑ·¢Ë͵½ 22006 µÄÈÎÎñʱ Çå¿Õ 22006 ¼´½«µ½´ïÐÅÏ¢
|
|
dbo.ExceSQL($"update T_Base_Device set F_PALLETBARCODE = '' where F_DeviceIndex = 22006 ");
|
|
}
|
|
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FSTARTDEVICE = 22005 and FENDDEVICE = 22006 ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//ûÓÐ 22005 µÄÈÎÎñ£¬²¢ÇÒ µúÅÌ»ú¿ÕÏУ¬22005´«ÊäÏß¿ÕÏÐÎÞ»õ£¬22006´«ÊäÏß¿ÕÏÐÎÞ»õ£¬Ã»ÓÐÆðµã
|
|
if (dv.Count == 0 && tempDevinfo.RunState == 0 && tempDevinfo22005.RunState == 0 && tempDevinfo22005.SplitByte_0 == 0 && CStaticClass.GetDevicePhotoelectric(22006, 0) == 0)
|
|
{
|
|
dbo.ExceSQL($"update T_Base_Device set F_PALLETBARCODE = '' where F_DeviceIndex = 22005 ");
|
|
}
|
|
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FID = {fid} ");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (Convert.ToInt32(dv[0]["FSTATUS"]) == 0)
|
|
{
|
|
dvdv = dbo.ExceSQL("select F_PALLETBARCODE from T_Base_Device where F_DeviceIndex = 22005").Tables[0].DefaultView;
|
|
string[] tray22005 = dvdv[0]["F_PALLETBARCODE"].ToString().Split(',');
|
|
|
|
dvdv = dbo.ExceSQL("select F_PALLETBARCODE from T_Base_Device where F_DeviceIndex = 22006").Tables[0].DefaultView;
|
|
string[] tray22006 = dvdv[0]["F_PALLETBARCODE"].ToString().Split(',');
|
|
|
|
string[] tempArr = tray22005.Union(tray22006).Where(c => !string.IsNullOrEmpty(c)).ToArray();
|
|
//´«ÊäÏß 22005 ºÍ 22006 ¼Ç¼ÍÐÅÌСÓÚ 4 Ôò¿É·¢ËͽøµþÅÌ»úÈÎÎñ
|
|
if (tempArr.Length < 4)
|
|
{
|
|
string[] newTray = dv[0]["FPALLETBARCODE"].ToString().Split(',');
|
|
if ((tempArr.Length + newTray.Length) <= 4)
|
|
{
|
|
string[] arrTray = tray22006.Union(newTray).Distinct().Where(c => !string.IsNullOrEmpty(c)).ToArray();
|
|
//¼Ç¼¼´½«µ½´ï22006 µÄÍÐÅ̺Å
|
|
dbo.ExceSQL($"update T_Base_Device set F_PALLETBARCODE = '{string.Join(",", arrTray)}' where F_DeviceIndex = 22006 ");
|
|
}
|
|
else
|
|
{
|
|
//µ±Ç°ÈÎÎñÍÐÅÌÊý×飬´óÓÚ1
|
|
if (newTray.Length > 1)
|
|
{
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FSTATUS > 0 and FENDDEVICE = 22006 ");
|
|
dvdv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvdv.Count <= 0)
|
|
{
|
|
if ((tempArr.Length + newTray.Length) <= 6)
|
|
{
|
|
string[] arrTray = tray22006.Union(newTray).Distinct().Where(c => !string.IsNullOrEmpty(c)).ToArray();
|
|
//¼Ç¼¼´½«µ½´ï22006 µÄÍÐÅ̺Å
|
|
dbo.ExceSQL($"update T_Base_Device set F_PALLETBARCODE = '{string.Join(",", arrTray)}' where F_DeviceIndex = 22006 ");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AheadDetectUnallow.Append("Ô¤´æÍÐÅÌÊýÓ뵱ǰÈÎÎñÀۼƴóÓÚ4¸ö£¬µÈ´ýÉÏÒ»ÈÎÎñÖ´ÐÐÍê³É¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AheadDetectUnallow.Append("Ô¤´æÍÐÅÌÊýÓ뵱ǰÈÎÎñÀۼƴóÓÚ4¸ö£¬µÈ´ýÉÏÒ»ÈÎÎñÖ´ÐÐÍê³É¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
sql.Clear();
|
|
sql.Append($" select * from T_Manage_Task where FSTARTDEVICE in(22005,22006,22007)");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
AheadDetectUnallow.Append("µþÅÌ»ú´æÔÚÏà¹Ø³öµþÅÌ»úÈÎÎñ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
if (CStaticClass.GetDevicePhotoelectric(22006, 0) > 0)
|
|
{
|
|
//AGVÈÎÎñÑé֤վ̨ÊÇ·ñÓлõ
|
|
AheadDetectUnallow.Append("·Å»õվ̨22006Óлõ¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AheadDetectUnallow.Append("µþÅÌ»úÔ¤´æÍÐÅÌÊý´óÓÚµÈÓÚ4¸öÍÐÅÌ£¬µÈ´ýµþÅÌÈë¿â¡£");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, minMidx);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "·¢ËÍÖ¸ÁîÌáǰ¼ì²âʱ·¢Éú´íÎó£º" + ex.StackTrace + ex.Message);
|
|
OnRefreshMonitor(rme);
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dvdv.Dispose();
|
|
}
|
|
}
|
|
|
|
private bool IFExitTopPriDeviceIdxTaskWait(int DeviceIdx)
|
|
{
|
|
sql.Clear();
|
|
DataView dv0 = new DataView(); DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Append(string.Format("SELECT F_ManageTaskIndex, F_ManageTASKKINDINDEX FROM T_Monitor_Task WHERE (F_DeviceIndex = {0})", DeviceIdx));
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
sql.Clear();
|
|
sql.Append(string.Format("SELECT top 1 F_DeviceIndex,F_Status FROM T_Monitor_Task WHERE (F_ManageTASKKINDINDEX = {0}) and F_ManageTaskIndex={1} order by F_MonitorIndex asc", Convert.ToInt32(dv[i]["F_ManageTASKKINDINDEX"]), Convert.ToInt32(dv[i]["F_ManageTASKINDEX"])));
|
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
if ((dv0[0]["F_DeviceIndex"].ToString() == DeviceIdx.ToString()) && (dv0[0]["F_Status"].ToString() == "0"))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv0.Dispose();
|
|
}
|
|
}
|
|
|
|
private int GetBarcodeCoor(int xcoor, int zcoor)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT BarcodeCoor FROM T_Base_BarcodeCoor WHERE (XCoor = {0}) AND (ZCoor = {1})", xcoor, zcoor)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0][0]);
|
|
}
|
|
else
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT BarcodeCoor FROM T_Base_BarcodeCoor WHERE (XCoor1 = {0}) AND (ZCoor1 = {1})", xcoor, zcoor)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0][0]);
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// »ñµÃ·¢ËÍÐÅÏ¢
|
|
/// </summary>
|
|
/// <param name="minMidx">É豸ָÁîË÷Òý</param>
|
|
public bool GetSendInfo(int minMidx)
|
|
{
|
|
DataView dvD = new DataView();
|
|
try
|
|
{
|
|
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_DeviceKindIndex,F_NumParam1,F_NumParam2,F_NumParam3,F_NumParam4,").Append(
|
|
"F_NumParam5,F_NumParam6,F_TxtParam,F_AheadDetect,F_ManTaskReserve,F_LockedState,").Append(
|
|
"F_Associate,F_SerialNumber,F_RouteID,F_DeviceIndex,F_DeviceCommandIndex,").Append(
|
|
"F_MonitorIndex,F_ManageTaskIndex,F_ManageTaskKindIndex,F_OutsideAltDevice,").Append(
|
|
"F_InsideAltDevice,F_StartDevice,F_EndDevice,F_RouteKind,F_UseAwayFork,F_AgvNo ").Append(
|
|
" FROM V_Monitor_Route_Device where F_MonitorIndex=").Append(minMidx);
|
|
|
|
dvD = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
|
|
if (dvD.Count > 0)
|
|
{
|
|
if (dvD[0]["F_AheadDetect"] != DBNull.Value)
|
|
{
|
|
_AheadDetect = dvD[0]["F_AheadDetect"].ToString();
|
|
}
|
|
else
|
|
{
|
|
_AheadDetect = "";
|
|
}
|
|
if (dvD[0]["F_ManTaskReserve"] != DBNull.Value)
|
|
{
|
|
_ManTaskReserve = Convert.ToInt32(dvD[0]["F_ManTaskReserve"]);
|
|
}
|
|
else
|
|
{
|
|
_ManTaskReserve = 0;
|
|
}
|
|
if (dvD[0]["F_Associate"] != DBNull.Value)
|
|
{
|
|
_Associate = Convert.ToInt32(dvD[0]["F_Associate"]);
|
|
}
|
|
else
|
|
{
|
|
_Associate = 0;
|
|
}
|
|
if (dvD[0]["F_LockedState"] != DBNull.Value)
|
|
{
|
|
_LockedState = Convert.ToInt32(dvD[0]["F_LockedState"]);
|
|
}
|
|
else
|
|
{
|
|
_LockedState = 0;
|
|
}
|
|
if (dvD[0]["F_NumParam1"] != DBNull.Value)
|
|
{
|
|
_NumParam1 = Convert.ToInt32(dvD[0]["F_NumParam1"]);
|
|
}
|
|
else
|
|
{
|
|
_NumParam1 = 0;
|
|
}
|
|
if (dvD[0]["F_NumParam2"] != DBNull.Value)
|
|
{
|
|
_NumParam2 = Convert.ToInt32(dvD[0]["F_NumParam2"]);
|
|
}
|
|
else
|
|
{
|
|
_NumParam2 = 0;
|
|
}
|
|
if (dvD[0]["F_NumParam3"] != DBNull.Value)
|
|
{
|
|
_NumParam3 = Convert.ToInt32(dvD[0]["F_NumParam3"]);
|
|
}
|
|
else
|
|
{
|
|
_NumParam3 = 0;
|
|
}
|
|
if (dvD[0]["F_NumParam4"] != DBNull.Value)
|
|
{
|
|
_NumParam4 = Convert.ToInt32(dvD[0]["F_NumParam4"]);
|
|
}
|
|
else
|
|
{
|
|
_NumParam4 = 0;
|
|
}
|
|
if (dvD[0]["F_NumParam5"] != DBNull.Value)
|
|
{
|
|
_NumParam5 = Convert.ToInt32(dvD[0]["F_NumParam5"]);
|
|
}
|
|
else
|
|
{
|
|
_NumParam5 = 0;
|
|
}
|
|
if (dvD[0]["F_NumParam6"] != DBNull.Value)
|
|
{
|
|
_NumParam6 = Convert.ToInt32(dvD[0]["F_NumParam6"]);
|
|
}
|
|
else
|
|
{
|
|
_NumParam6 = 0;
|
|
}
|
|
if (dvD[0]["F_TxtParam"] != DBNull.Value)
|
|
{
|
|
_TxtParam = dvD[0]["F_TxtParam"].ToString();
|
|
}
|
|
else
|
|
{
|
|
_TxtParam = "-";
|
|
}
|
|
_serialNumber = Convert.ToInt32(dvD[0]["F_SerialNumber"]);
|
|
_routeID = Convert.ToInt32(dvD[0]["F_RouteID"]);
|
|
_DeviceIdx = Convert.ToInt32(dvD[0]["F_DeviceIndex"]);
|
|
_DeviceOrder = Convert.ToInt32(dvD[0]["F_DeviceCommandIndex"]);
|
|
_ManageKindIdx = Convert.ToInt32(dvD[0]["F_ManageTaskKindIndex"]);
|
|
_ManageTaskIdx = Convert.ToInt32(dvD[0]["F_ManageTaskIndex"]);
|
|
_DeviceKind = Convert.ToInt32(dvD[0]["F_DeviceKindIndex"]);
|
|
if (dvD[0]["F_OutsideAltDevice"] != DBNull.Value)
|
|
{
|
|
_OutsideAltDevice = Convert.ToInt32(dvD[0]["F_OutsideAltDevice"]);
|
|
}
|
|
else
|
|
{
|
|
_OutsideAltDevice = 0;
|
|
}
|
|
if (dvD[0]["F_InsideAltDevice"] != DBNull.Value)
|
|
{
|
|
_InsideAltDevice = Convert.ToInt32(dvD[0]["F_InsideAltDevice"]);
|
|
}
|
|
else
|
|
{
|
|
_InsideAltDevice = 0;
|
|
}
|
|
_StartDevice = Convert.ToInt32(dvD[0]["F_StartDevice"]);
|
|
_EndDevice = Convert.ToInt32(dvD[0]["F_EndDevice"]);
|
|
_RouteKind = Convert.ToInt32(dvD[0]["F_RouteKind"]);
|
|
|
|
if (dvD[0]["F_AgvNo"] != DBNull.Value)
|
|
{
|
|
_AgvNo = Convert.ToInt32(dvD[0]["F_AgvNo"]);
|
|
}
|
|
else
|
|
{
|
|
_AgvNo = 65535;
|
|
}
|
|
return true;
|
|
}
|
|
else
|
|
{//20120420
|
|
CControlError = string.Format("·¢ËÍÃüÁîµ÷ÓÃGetSendInfoʱ£ºÂ·¾¶±íÀ{0}¡¿É豸Ë÷Òý²»´æÔÚ£¡", GetDeviceFromMonitor(minMidx).ToString());
|
|
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dvD.Dispose();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ·¢ËÍÖ¸¶¨µ÷¶ÈÈÎÎñºÅµÄÃüÁî
|
|
/// </summary>
|
|
/// <param name="MonitorIndex"></param>
|
|
/// <returns></returns>
|
|
public bool SendMonitorTask(int MonitorIndex)
|
|
{
|
|
|
|
try
|
|
{
|
|
lock (thisLock)
|
|
{
|
|
char[] sep = new char[1] { '-' };
|
|
int msgIdx = 0;//ÏûÏ¢±àºÅ
|
|
bool sendok;
|
|
|
|
#region ¶à²æ¹ØÁªÉ豸ָÁÈç¹û²»ÄÜͬ²½Ö´ÐУ¬·¢Ë;àÀë¶Ñ¶â»úµ±Ç°Î»ÖýüµÄÉ豸ָÁî
|
|
MonitorIndex = GetDoubleForkMinRouteTask(MonitorIndex);
|
|
if (MonitorIndex == -1) { return false; }
|
|
#endregion
|
|
|
|
//»ñµÃÒª·¢Ë͵ÄÐÅÏ¢
|
|
if (GetSendInfo(MonitorIndex) == false) { return false; }
|
|
int deviceIdx = _DeviceIdx;
|
|
int deviceKind = _DeviceKind;
|
|
int deviceOrder = _DeviceOrder;
|
|
int manageKindIdx = ccf.GetManageTaskKindIndexFromMonitor(MonitorIndex);
|
|
int manageTaskIdx = ccf.GetManageTaskIndexfromMonitor(MonitorIndex);
|
|
int EndDevice = ccf.GetEndDeviceFromManage(manageKindIdx, manageTaskIdx);
|
|
string Batch = dbo.GetSingle("select BATTERY_BATCH from t_manage_task where fid=" + manageTaskIdx).ToString();
|
|
int BatteryType = Convert.ToInt32(dbo.GetSingle("select BATTERY_TYPE from t_manage_task where fid=" + manageTaskIdx));
|
|
if (BatteryType == 18650)
|
|
{
|
|
BatteryType = 1;
|
|
}
|
|
if (BatteryType == 21700)
|
|
{
|
|
BatteryType = 2;
|
|
}
|
|
string barcode = ccf.GetBarCodeFromManageTask(manageTaskIdx, manageKindIdx);
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(deviceIdx);
|
|
if (((deviceKind == 1 && (devinfo.YCoor == 0 && devinfo.XCoor == 0)) || (deviceKind == 4) && (devinfo.XCoor == 0) && (devinfo.YCoor == 0)) && (devinfo.VirtualStack != deviceIdx))//20130510
|
|
{
|
|
AheadDetectUnallow.Clear();
|
|
AheadDetectUnallow.Append(_DeviceIdx.ToString() + "µÄ¹âͨѶ±»ÕÚµ²£¬»òÕßûÉϵ磡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, MonitorIndex);
|
|
return false;
|
|
}
|
|
|
|
|
|
if (ccf.GetManageTaskKindIndexFromMonitor(MonitorIndex) == 4)
|
|
{
|
|
#region ÊÖ¹¤ÈÎÎñ
|
|
string ah = "I" + deviceIdx.ToString();
|
|
if ((deviceKind != 1) && ((deviceKind != 4)))
|
|
{
|
|
ah = "";
|
|
}
|
|
if (AheadDetectOK(MonitorIndex, ah) == false) //²»·ûºÏÔËÐÐÌõ¼þccf.GetBeDetectedDevices(_DeviceIdx))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//CStaticClass.MessageIndex++;
|
|
CStaticClass.MessageIndex = 1;
|
|
msgIdx = (CStaticClass.MessageIndex);
|
|
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(deviceIdx);
|
|
|
|
int[] gc = new int[6] { _NumParam2, _NumParam3, _NumParam1, _NumParam5, _NumParam6, _NumParam4 };
|
|
|
|
if ((deviceKind == 1))
|
|
{
|
|
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder,
|
|
deviceIdx, gc[0], gc[1], gc[2], gc[3], gc[4], gc[5]);
|
|
|
|
}
|
|
else if (deviceKind == 6)
|
|
{
|
|
DataView dv = dbo.ExceSQL(string.Format("select * from T_Monitor_Task where F_DeviceCommandIndex = 2 and F_MonitorIndex={0}", MonitorIndex)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
DataRowView drv = dv[0];
|
|
//string sbs = string.Format("INSERT INTO [dbo].[AGV_TASK]([FID],[AGV_TASK_LEVEL],[PALLET_BARCODE],[PALLET_TYPE],[START_DEVICE_CODE],[FINISH_DEVICE_CODE],[AGV_TASK_STATUS],[AGV_CODE],[INSERT_TIME])VALUES({0},{1},'','',{2},{3},0,0,{4})", drv["F_ManageTaskIndex"].ToString(), drv["F_MonitorTaskLevel"].ToString(), drv["F_NumParam2"].ToString(), drv["F_NumParam5"].ToString(), DateTime.Now.ToString("yyyyMMddHHmmss"));
|
|
//int rc = dbo.ExecuteSql(sbs.ToString());
|
|
|
|
//TODO AGV µ½À¬»øÕ¾Ì¨ÈÎÎñ
|
|
//Ìí¼ÓAGVÈÎÎñÀàÐÍ ÖÕµãΪ 29007 ʱ£¬ÐÞ¸ÄÖÕµ½Î» Ϊ22006 £¬Öмäµã29007£¬ÀàÐÍ Îª 3 1--Õý³£µãµ½µãÈ¡ËÍ£¬ 2--´æÔÚÎïÁÏ˳ÐòµÄÈÎÎñ×éÈ¡ËÍÈÎÎñ£¬ 3--·ÏÁÏÈÎÎñ 4....´ý¶¨
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append(" INSERT INTO AGV_TASK (");
|
|
sql.Append(" FID,AGV_TASK_LEVEL,PALLET_BARCODE,PALLET_TYPE,START_DEVICE_CODE");
|
|
sql.Append(" ,FINISH_DEVICE_CODE,AGV_TASK_STATUS,AGV_CODE,INSERT_TIME");
|
|
sql.Append(" ,TASKTYPE,MIDDLE");
|
|
sql.Append(" ) VALUES ( ");
|
|
if (dv[0]["F_NumParam5"].ToString() == "29007")
|
|
{
|
|
sql.Append($" {drv["F_ManageTaskIndex"].ToString()},{drv["F_MonitorTaskLevel"].ToString()},'{drv["F_TxtParam"].ToString()}','',{ drv["F_NumParam2"].ToString()}");
|
|
sql.Append($" ,{22006},0,0,{DateTime.Now.ToString("yyyyMMddHHmmss")}");
|
|
sql.Append($" ,{3},{29007} ");
|
|
}
|
|
else
|
|
{
|
|
sql.Append($" {drv["F_ManageTaskIndex"].ToString()},{drv["F_MonitorTaskLevel"].ToString()},'{drv["F_TxtParam"].ToString()}','',{ drv["F_NumParam2"].ToString()}");
|
|
sql.Append($" ,{drv["F_NumParam5"].ToString()},0,0,{DateTime.Now.ToString("yyyyMMddHHmmss")}");
|
|
sql.Append($" ,1,'' ");
|
|
}
|
|
|
|
sql.Append(" ) ");
|
|
|
|
int rc = dbo.ExecuteSql(sql.ToString());
|
|
if (rc == 0)
|
|
{
|
|
sendok = false;
|
|
}
|
|
else
|
|
{
|
|
sendok = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendok = false;
|
|
}
|
|
|
|
}
|
|
else if (deviceKind == 4)
|
|
{
|
|
if (ccf.NeedOptimize(deviceIdx) == true)
|
|
{
|
|
ccf.InsertMonitorOptimizeChildTask(MonitorIndex);
|
|
sendok = true;
|
|
}
|
|
else
|
|
{
|
|
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, gc[2]);
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, gc[5]);
|
|
}
|
|
if (sendok == false)
|
|
{
|
|
if (sdo.CommLayerError != null)
|
|
{
|
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", sdo.CommLayerError);
|
|
OnRefreshMonitor(rmea);
|
|
}
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
//////////////////////////
|
|
ccf.SendOrderSuccess(manageKindIdx, manageTaskIdx, MonitorIndex, deviceIdx, _routeID);
|
|
#region ¶à²æ¹ØÁªÈÎÎñ£¬ÄÜͬ²½µÄͬʱ±¨¸æ·¢ËÍÃüÁî³É¹¦
|
|
//20100323
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(deviceIdx);
|
|
if (devinfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
int[] mforkMoninfo = Model.CGeneralFunction.MutiForkIfSync(MonitorIndex, deviceIdx, deviceKind);
|
|
if (mforkMoninfo != null)
|
|
{
|
|
Dictionary<int, string[]> corr = Model.CGeneralFunction.GetDoubleForkMonitorInfo(MonitorIndex, deviceIdx);
|
|
for (int i = 0; i < mforkMoninfo.GetLength(0); i++)
|
|
{
|
|
ccf.SendOrderSuccess(ccf.GetManageTaskKindIndexFromMonitor(mforkMoninfo[i]), ccf.GetManageTaskIndexfromMonitor(mforkMoninfo[i]), mforkMoninfo[i], Convert.ToInt32(corr[mforkMoninfo[i]][2]), Convert.ToInt32(corr[mforkMoninfo[i]][3]));
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
return true;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
#region ×Ô¶¯ÃüÁî(taskkind == 1£¬2)
|
|
//(taskkind == 1£¬2)×Ô¶¯ÃüÁîºÍÁÙʱ¹ÜÀí¹ÜÀíÃüÁî
|
|
///////////////////////////////////////
|
|
//2--6Ó¦¸Ã×öµÝ¹éµ÷Óú¯Êý
|
|
///////////////////////////////////////
|
|
/////////////////////
|
|
//20100208
|
|
#region »·Ðδ©Ëó³µRGV·ÖÅä³µºÅÐÞ¸ÄÌáǰ¼ì²â
|
|
|
|
#endregion
|
|
////////////////////
|
|
|
|
|
|
//2£ºÌáȡÿ¸ö¹ÜÀíµ¥¾ÝµÄµÚÒ»¸öÉ豸״̬
|
|
|
|
if (GetFirstDeviceIFLocked(MonitorIndex, true) == false)//ûÓб»Ëø¶¨£¬¿ÕÏÐ
|
|
{
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(deviceIdx);
|
|
//7£º·¢ËÍ´ËÉ豸ÃüÁî
|
|
//CStaticClass.MessageIndex++;
|
|
CStaticClass.MessageIndex = 1;
|
|
msgIdx = (CStaticClass.MessageIndex);
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(deviceIdx);
|
|
//ÅжÏÉ豸ÊÇ·ñΪ¶Ñ¶â»úRGVºÍ£Á£Ç£Ö
|
|
int[] gc = new int[6] { _NumParam2, _NumParam3, _NumParam1, _NumParam5, _NumParam6, _NumParam4 };//»ñµÃ×ø±ê
|
|
if (gc == null)
|
|
{
|
|
this.CControlError += string.Format("·¢ËÍÃüÁîʱ²»ÄÜÈ¡µÃÉè±¸×ø±ê£¡");
|
|
return false;
|
|
}
|
|
if (deviceKind == 1)
|
|
{
|
|
|
|
//1£º¶Ñ¶â»ú£»4£ºRGV£»6£ºAGVÈç¹ûÐèÒªÓÅ»¯µ÷¶È£¨É豸±íµÄF_NeedOptimize='1'£©
|
|
//Ö±½ÓдÈë±í£ºT_Monitor_Task_Child£¬²»·¢ËÍÃüÁî
|
|
if (deviceOrder == 10)//¶Ñ¶â»úµÄÈ˹¤¹Û²âÖ¸Áî²»·¢ËÍ
|
|
{
|
|
sendok = false;
|
|
}
|
|
if (ccf.NeedOptimize(deviceIdx) == true)
|
|
{
|
|
ccf.InsertMonitorOptimizeChildTask(MonitorIndex);
|
|
sendok = true;
|
|
}
|
|
else
|
|
{
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder,
|
|
deviceIdx, gc[0], gc[1], gc[2], gc[3], gc[4], gc[5]);
|
|
}
|
|
#region Ë«Ïò³öÈë¿ÚÈÎÎñ±ÜÅö
|
|
//int enddev = Convert.ToInt32(dbo.GetSingle("select FENDDEVICE from T_Manage_Task where FID=" + manageTaskIdx));
|
|
//if (deviceOrder == 4 && (_NumParam5 == 1 && _NumParam6 == 1) )
|
|
//{
|
|
// //¶Ñ¶â»úÈ¡»õÖ¸Á¶øÇÒÄ¿µÄµØÖ·µÄÁÐÊýΪ1£¨Õ¾Ì¨£©
|
|
|
|
// Model.MDevice devinfo_light = new Model.MDevice();
|
|
// switch (enddev)
|
|
// {
|
|
// case 12001:
|
|
// devinfo_light = Model.CGetInfo.GetDeviceInfo(17001);
|
|
// break;
|
|
// case 12002:
|
|
// devinfo_light = Model.CGetInfo.GetDeviceInfo(17002);
|
|
// break;
|
|
// case 12003:
|
|
// devinfo_light = Model.CGetInfo.GetDeviceInfo(17003);
|
|
// break;
|
|
// case 12004:
|
|
// devinfo_light = Model.CGetInfo.GetDeviceInfo(17004);
|
|
// break;
|
|
|
|
// }
|
|
|
|
|
|
// StringBuilder[] wv = { new StringBuilder("2") };
|
|
// StringBuilder[] witemnames = { new StringBuilder("") };
|
|
// witemnames[0].Clear();
|
|
// witemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(devinfo_light.Dbw1Address + 0)).Append(",b");//20130510
|
|
// wv[0].Clear();
|
|
// wv[0].Append("0");
|
|
|
|
// sdo = CommModeCreate.CreateSendDeviceOrder(devinfo_light.DeviceIndex);
|
|
// sdo.WriteDBData(witemnames, wv, devinfo_light.S7Connection);
|
|
|
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "³öÈë¿âģʽ", devinfo_light.DeviceIndex.ToString(), "´æÔÚÖ´ÐÐÖеijö¿âÈÎÎñ£¡");
|
|
//}
|
|
#endregion
|
|
|
|
}
|
|
else if (deviceKind == 6)
|
|
{
|
|
DataView dv = dbo.ExceSQL(string.Format("select * from T_Monitor_Task where F_DeviceCommandIndex = 4 and F_MonitorIndex={0}", MonitorIndex)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
|
|
DataRowView drv = dv[0];
|
|
//string sbs;
|
|
//sbs = string.Format("INSERT INTO [dbo].[AGV_TASK]([FID],[AGV_TASK_LEVEL],[PALLET_BARCODE],[PALLET_TYPE],[START_DEVICE_CODE],[FINISH_DEVICE_CODE],[AGV_TASK_STATUS],[AGV_CODE],[INSERT_TIME])VALUES({0},{1},'','',{2},{3},0,0,{4})", drv["F_ManageTaskIndex"].ToString(), drv["F_MonitorTaskLevel"].ToString(), drv["F_NumParam2"].ToString(), drv["F_NumParam5"].ToString(), DateTime.Now.ToString("yyyyMMddHHmmss"));
|
|
|
|
//int rc = dbo.ExecuteSql(sbs.ToString());
|
|
|
|
//Ìí¼ÓAGVÈÎÎñÀàÐÍ ÖÕµãΪ 29007 ʱ£¬ÐÞ¸ÄÖÕµ½Î» Ϊ22006 £¬Öмäµã29007£¬ÀàÐÍ Îª 3 1--Õý³£µãµ½µãÈ¡ËÍ£¬ 2--´æÔÚÎïÁÏ˳ÐòµÄÈÎÎñ×éÈ¡ËÍÈÎÎñ£¬ 3--·ÏÁÏÈÎÎñ 4....´ý¶¨
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append(" INSERT INTO AGV_TASK (");
|
|
sql.Append(" FID,AGV_TASK_LEVEL,PALLET_BARCODE,PALLET_TYPE,START_DEVICE_CODE");
|
|
sql.Append(" ,FINISH_DEVICE_CODE,AGV_TASK_STATUS,AGV_CODE,INSERT_TIME");
|
|
sql.Append(" ,TASKTYPE,MIDDLE");
|
|
sql.Append(" ) VALUES ( ");
|
|
if (dv[0]["F_NumParam5"].ToString() == "29007")
|
|
{
|
|
sql.Append($" {drv["F_ManageTaskIndex"].ToString()},{drv["F_MonitorTaskLevel"].ToString()},'{drv["F_TxtParam"].ToString()}','',{ drv["F_NumParam2"].ToString()}");
|
|
sql.Append($" ,{22006},0,0,{DateTime.Now.ToString("yyyyMMddHHmmss")}");
|
|
sql.Append($" ,{3},{29007} ");
|
|
}
|
|
else
|
|
{
|
|
sql.Append($" {drv["F_ManageTaskIndex"].ToString()},{drv["F_MonitorTaskLevel"].ToString()},'{drv["F_TxtParam"].ToString()}','',{ drv["F_NumParam2"].ToString()}");
|
|
sql.Append($" ,{drv["F_NumParam5"].ToString()},0,0,{DateTime.Now.ToString("yyyyMMddHHmmss")}");
|
|
sql.Append($" ,1,'' ");
|
|
}
|
|
|
|
sql.Append(" )");
|
|
int rc = dbo.ExecuteSql(sql.ToString());
|
|
if (rc == 0)
|
|
{
|
|
sendok = false;
|
|
}
|
|
else
|
|
{
|
|
sendok = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendok = false;
|
|
}
|
|
|
|
}
|
|
else if (_DeviceKind == 4)
|
|
{
|
|
if (ccf.NeedOptimize(deviceIdx) == true)
|
|
{
|
|
ccf.InsertMonitorOptimizeChildTask(MonitorIndex);
|
|
sendok = true;
|
|
}
|
|
else
|
|
{
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, gc[2]);
|
|
}
|
|
|
|
}
|
|
else if (_DeviceKind == 7)
|
|
{
|
|
int ControlType = ccf.GetFCONTROLTASKTYPEFromManageTask(_ManageKindIdx, _ManageTaskIdx);
|
|
#region ÌõÂëÉ豸ֱ½Ó±È¶Ô
|
|
DataView dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Base_PLC_Ask ,T_Monitor_Task WHERE T_Base_PLC_Ask.F_DeviceIndex = T_Monitor_Task.F_DeviceIndex AND T_Base_PLC_Ask.F_BarCode = T_Monitor_Task.F_TxtParam and (T_Monitor_Task.F_MonitorIndex = {0})", MonitorIndex)).Tables[0].DefaultView;
|
|
if ((dv.Count > 0) || (ControlType != 1))
|
|
{//±È¶ÔÕýÈ·
|
|
object[] obj = new object[3] { _ManageKindIdx, _ManageTaskIdx, Model.CGeneralFunction.TASKABEND };
|
|
dbo.ExecuteSql(string.Format("UPDATE T_Manage_Task SET FExceptionNO=NULL WHERE (F_ManageTaskKindIndex ={0}) AND (FID ={1}) and FExceptionNO={2}", obj));
|
|
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 0);
|
|
}
|
|
else
|
|
{//±È¶Ô´íÎ󣬸ĵÀÒì³£´¦Àí¿Ú
|
|
//ÐÞ¸ÄÄ¿±êλÖÃÖÁÒì³£¿Ú
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_Remark,F_BindingDevice,F_BarCode FROM T_Base_PLC_Ask WHERE T_Base_PLC_Ask.F_DeviceIndex = {0}", deviceIdx)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if ((CStaticClass.DeviceErrorAutoModifyRoutePath == "1") && (dv[0]["F_BarCode"].ToString() != "1111111"))
|
|
{
|
|
object[] obj = new object[5] { _ManageKindIdx, _ManageTaskIdx, Convert.ToInt32(dv[0]["F_Remark"]), Model.CGeneralFunction.TASKABEND, Convert.ToInt32(dv[0]["F_BindingDevice"]) };
|
|
dbo.ExecuteSql(string.Format("UPDATE T_Manage_Task SET FExceptionNO={3},FSTARTDEVICE ={4}, FSTARTCELL ='-',FENDDEVICE ={2}, FENDCELL ='-', FENDUCODE =0 WHERE (F_ManageTaskKindIndex ={0}) AND (FID ={1})", obj));
|
|
ccf.GetUseableRouteIDSubAndModifyRoute(_ManageTaskIdx, _ManageKindIdx, Convert.ToInt32(dv[0]["F_BindingDevice"]));
|
|
}
|
|
else
|
|
{
|
|
Model.MError me;
|
|
if (dv[0]["F_BarCode"].ToString() == "-")//ɨÃèÆ÷δ¶ÁÌõÂë
|
|
{
|
|
me = null;
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 0);
|
|
//me = Model.CGetInfo.GetErrorInfo(732);
|
|
//dbo.ExecuteSql(string.Format("update T_Monitor_Task set F_Status=32 WHERE (T_Monitor_Task.F_MonitorIndex = {0})", MonitorIndex));
|
|
}
|
|
else if (dv[0]["F_BarCode"].ToString().IndexOf("1111111") >= 0)
|
|
{//"1111111111"ÌõÂëδ¶Áµ½
|
|
object[] obj = new object[3] { _ManageKindIdx, _ManageTaskIdx, Model.CGeneralFunction.TASKABEND };
|
|
dbo.ExecuteSql(string.Format("UPDATE T_Manage_Task SET FExceptionNO={2} WHERE (F_ManageTaskKindIndex ={0}) AND (FID ={1})", obj));
|
|
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 0);
|
|
//dbo.ExecuteSql(string.Format("update T_Monitor_Task set F_Status=30 WHERE (T_Monitor_Task.F_MonitorIndex = {0})", MonitorIndex));
|
|
me = Model.CGetInfo.GetErrorInfo(730);
|
|
|
|
}
|
|
else
|
|
{//ÌõÂë²»ÕýÈ·
|
|
object[] obj = new object[3] { _ManageKindIdx, _ManageTaskIdx, Model.CGeneralFunction.TASKABEND };
|
|
dbo.ExecuteSql(string.Format("UPDATE T_Manage_Task SET FExceptionNO={2} WHERE (F_ManageTaskKindIndex ={0}) AND (FID ={1})", obj));
|
|
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 0);
|
|
// dbo.ExecuteSql(string.Format("update T_Monitor_Task set F_Status=31 WHERE (T_Monitor_Task.F_MonitorIndex = {0})", MonitorIndex));
|
|
me = Model.CGetInfo.GetErrorInfo(731);
|
|
|
|
}
|
|
if (me != null)
|
|
{
|
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("notifyIcon1", "¾¯¸æ:" + devinfo.DeviceName + "," + deviceIdx + "·¢Éú¹ÊÕÏ£º" + me.ErrorName);
|
|
OnRefreshMonitor(rmea);
|
|
}
|
|
}
|
|
if (_ManageKindIdx == 1)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update IO_Control set ERROR_TEXT='").Append(devinfo.DeviceName).Append(",").Append(deviceIdx).Append("ÌõÂë²»ÕýÈ·£¡").Append("' where CONTROL_ID=").Append(manageTaskIdx);
|
|
dboM.ExceSQL(sql.ToString());
|
|
}
|
|
}
|
|
}
|
|
//20130709 dbo.ExecuteSql(string.Format("UPDATE T_Base_PLC_Ask SET F_BarCode = '-' WHERE (F_DeviceIndex = {0}) ", deviceIdx));
|
|
|
|
#endregion
|
|
return true;
|
|
}
|
|
else if (_DeviceKind == 17)
|
|
{
|
|
if (deviceOrder == 4)
|
|
{
|
|
sendok = false;
|
|
}
|
|
else
|
|
{
|
|
|
|
string ng = Convert.ToString(dbo.GetSingle("select NG_BATTERY from t_manage_task where fid=" + manageTaskIdx));
|
|
string FENDDEVICE = Convert.ToString(dbo.GetSingle("select FENDDEVICE from t_manage_task where fid=" + manageTaskIdx).ToString());
|
|
msgIdx = Convert.ToInt32(dbo.GetSingle("select FSTARTDEVICE from t_manage_task where fid=" + manageTaskIdx));
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, FENDDEVICE, ng.ToString());
|
|
//ÐÞ¸Ä 20240325
|
|
//int RunState = Convert.ToInt32(dbo.GetSingle("select F_STATE from T_Base_Device where F_DeviceIndex=" + deviceIdx));
|
|
//StringBuilder sss = new StringBuilder();
|
|
//sss.Append("**¶Á±êÖ¾»úеÊÖ"+deviceIdx).Append("**״̬" + devinfo.RunState);
|
|
//CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "ÊÕµ½»úеÊÖ״̬", deviceIdx.ToString(), sss.ToString());
|
|
//if (RunState == 0)//»úеÊÖ״̬±êʶΪ¿ÕÏÐʱ£¬·¢ËÍÏÂÒ»¸öÂë¶âÖ¸Áî
|
|
//{
|
|
// sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, FENDDEVICE, ng.ToString());
|
|
//}
|
|
//else
|
|
//{
|
|
// sendok = false;
|
|
//}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
if (deviceKind == 2 && deviceOrder == 8)//ºáµê¶«´Å·ÖÅäÔ¤³ä
|
|
{
|
|
DataView ProCharge = dbo.ExceSQL("select T_ProCharge.*,F_LockedState from T_ProCharge,T_Base_Device where F_ArrowIndex=T_Base_Device.F_DeviceIndex and F_LockedState<>-1 and T_ProCharge.F_DeviceIndex=" + deviceIdx).Tables[0].DefaultView;
|
|
if (ProCharge.Count > 0)
|
|
{
|
|
for (int i = 0; i < ProCharge.Count; i++)
|
|
{
|
|
int ProChargeDevice = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(ProCharge[i]["f_arrowindex"]), 2) == 0 ? 1 : 0;
|
|
int CurDevice = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(ProCharge[i]["f_arrowindex"]), 0);
|
|
int taskcount = Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where fstartdevice=" + deviceIdx + " and fenddevice=" + ProCharge[i]["f_arrowindex"]));
|
|
if (ProChargeDevice + taskcount + CurDevice == 0)
|
|
{
|
|
|
|
Model.AutoTask at = new Model.AutoTask(4, barcode, deviceIdx.ToString(), "-", ProCharge[i]["f_arrowindex"].ToString(), "-", false, false, 0, 0);
|
|
string error = string.Empty;
|
|
if (BuildAutoTask(at, out error))
|
|
{
|
|
//cgs.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
}
|
|
if (i == ProCharge.Count - 1)
|
|
{
|
|
for (int j = 0; j < ProCharge.Count; j++)
|
|
{
|
|
ProChargeDevice = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(ProCharge[j]["f_arrowindex"]), 2) == 0 ? 1 : 0;
|
|
CurDevice = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(ProCharge[j]["f_arrowindex"]), 0);
|
|
taskcount = Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where fstartdevice=" + deviceIdx + " and fenddevice=" + ProCharge[j]["f_arrowindex"]));
|
|
if (ProChargeDevice + taskcount + CurDevice == 1)
|
|
{
|
|
|
|
Model.AutoTask at = new Model.AutoTask(4, barcode, deviceIdx.ToString(), "-", ProCharge[j]["f_arrowindex"].ToString(), "-", false, false, 0, 0);
|
|
string error = string.Empty;
|
|
if (BuildAutoTask(at, out error))
|
|
{
|
|
//cgs.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sendok = false;
|
|
}
|
|
else if (deviceKind == 2 && deviceOrder == 10)
|
|
{
|
|
sendok = false;
|
|
DataView dvv = dbo.ExceSQL("select t_dispallet.* from t_dispallet,t_base_device where f_enddevice=f_deviceindex and F_LockedState<>-1 and f_startdevice=" + deviceIdx).Tables[0].DefaultView;
|
|
if (dvv.Count > 0)
|
|
{
|
|
for (int i = 0; i < dvv.Count; i++)
|
|
{
|
|
int dispallet = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(dvv[i]["f_enddevice"]), 1);
|
|
int havegoods = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(dvv[i]["f_enddevice"]), 0);
|
|
int taskcount = Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where fstartdevice=" + dvv[i]["f_startdevice"] + " and fenddevice=" + dvv[i]["f_enddevice"]));
|
|
if (taskcount + (havegoods + dispallet > 0 ? 1 : 0) == 0)
|
|
{
|
|
Model.AutoTask at = new Model.AutoTask(4, barcode, deviceIdx.ToString(), "-", dvv[i]["f_enddevice"].ToString(), "-", false, false, 0, 0);
|
|
string error = string.Empty;
|
|
if (Convert.ToInt32(dbo.GetSingle("select count(0) from T_DisPallet where f_enddevice=" + EndDevice)) > 0)
|
|
{
|
|
dbo.ExceSQL("delete t_monitor_task where F_MonitorIndex=" + MonitorIndex);
|
|
dbo.ExceSQL("update t_manage_task set FIntoStepOK='0',FSTATUS=0,fstartdevice=" + deviceIdx + ",fenddevice=" + dvv[i]["f_enddevice"] + " where fid=" + manageTaskIdx);
|
|
//dboM.ExceSQL("update io_control set END_DEVICE_CODE='" + dvv[i]["f_enddevice"].ToString() + "' where CONTROL_ID=" + manageTaskIdx);
|
|
}
|
|
else
|
|
{
|
|
if (BuildAutoTask(at, out error))
|
|
{
|
|
//cgs.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
if (i == dvv.Count - 1)
|
|
{
|
|
for (int j = 0; j < dvv.Count; j++)
|
|
{
|
|
dispallet = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(dvv[j]["f_enddevice"]), 1);
|
|
havegoods = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(dvv[j]["f_enddevice"]), 0);
|
|
taskcount = Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where fstartdevice=" + dvv[j]["f_startdevice"] + " and fenddevice=" + dvv[j]["f_enddevice"]));
|
|
if (taskcount + (havegoods + dispallet > 0 ? 1 : 0) < Convert.ToInt32(dvv[j]["f_count"]))
|
|
{
|
|
if (deviceIdx == 32077 || deviceIdx == 32047 || deviceIdx == 32062)//OVC1ºó·½ÓÐÀ´ÍÐÅÌÔÙ·ÖÅä·ñÔòµÈ´ý
|
|
{
|
|
int temp = Convert.ToInt32(dbo.GetSingle("select count(0) from t_monitor_task where F_NumParam4=" + deviceIdx + " and F_ManageTaskIndex<>" + manageTaskIdx));
|
|
if (temp < 1)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
Model.AutoTask at = new Model.AutoTask(4, barcode, deviceIdx.ToString(), "-", dvv[j]["f_enddevice"].ToString(), "-", false, false, 0, 0);
|
|
string error = string.Empty;
|
|
//dbo.ExceSQL("update t_manage_task set F_ManageTaskKindIndex=2 where F_ManageTaskKindIndex=1 and fid=" + manageTaskIdx);
|
|
if (Convert.ToInt32(dbo.GetSingle("select count(0) from T_DisPallet where f_enddevice=" + EndDevice)) > 0)
|
|
{
|
|
dbo.ExceSQL("delete t_monitor_task where F_MonitorIndex=" + MonitorIndex);
|
|
dbo.ExceSQL("update t_manage_task set FIntoStepOK='0',FSTATUS=0,fstartdevice=" + deviceIdx + ",fenddevice=" + dvv[i]["f_enddevice"] + " where fid=" + manageTaskIdx);
|
|
//dboM.ExceSQL("update io_control set END_DEVICE_CODE='" + dvv[i]["f_enddevice"].ToString() + "' where CONTROL_ID=" + manageTaskIdx);
|
|
}
|
|
else
|
|
{
|
|
if (BuildAutoTask(at, out error))
|
|
{
|
|
//cgs.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
else if (deviceKind == 2 && deviceOrder == 9)//ÐèÒª·ÖµþÅÌ»ú
|
|
{
|
|
sendok = false;
|
|
if (Batch == "0")
|
|
{
|
|
DataView batterydata = dboM.ExceSQL("select goods_property1 from STORAGE_LIST with(nolock) where goods_property2='" + barcode.ToString() + "'").Tables[0].DefaultView;
|
|
if (batterydata.Count > 0)
|
|
{
|
|
if (!string.IsNullOrEmpty(batterydata[0]["goods_property1"].ToString()))
|
|
{
|
|
Batch = batterydata[0]["goods_property1"].ToString();
|
|
}
|
|
}
|
|
|
|
}
|
|
if (Batch == "0")
|
|
{
|
|
AheadDetectUnallow.Clear();
|
|
AheadDetectUnallow.Append("δ֪µç³ØÅú´Î£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, MonitorIndex);
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
int arrow = 0;
|
|
FindStackPallet(deviceIdx, Batch, out arrow);
|
|
if (arrow != 0)
|
|
{
|
|
Model.AutoTask at = new Model.AutoTask(4, barcode, deviceIdx.ToString(), "-", arrow.ToString(), "-", false, false, 0, 0);
|
|
string error = string.Empty;
|
|
if (BuildAutoTask(at, out error))
|
|
{
|
|
//cgs.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
Model.CGeneralFunction.ActionComplete(deviceIdx, MonitorIndex, 1);
|
|
dbo.ExceSQL("update t_manage_task set BATTERY_BATCH='" + Batch + "' where FPALLETBARCODE='" + barcode + "' and fstartdevice=" + deviceIdx + " and fenddevice=" + arrow);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
AheadDetectUnallow.Clear();
|
|
AheadDetectUnallow.Append("ÉÐÎÞµþÅÌ»ú¿É·Ö£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, MonitorIndex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
else if (deviceKind == 2 && devinfo.Dbw2Getlength > 10 && deviceOrder == 6 && ((deviceIdx > 32130 || deviceIdx < 32105) || (deviceIdx >= 32105 && deviceIdx <= 32130 && deviceIdx == gc[5])))//OCV4µþÅÌ»ú¶Ô½ÓOCVÉ豸ÐèÒªÌØÊâÅжÏ
|
|
{
|
|
string nowbatch = dbo.GetSingle("select F_BATCH from T_STACKPALLET where F_ENDDEVICE=" + ccf.GetEndDeviceFromManage(manageKindIdx, manageTaskIdx)).ToString();
|
|
if (nowbatch == Batch || nowbatch == "0")
|
|
{
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, gc[5], BatteryType, barcode);
|
|
if (nowbatch == "0")
|
|
{
|
|
dbo.ExceSQL("update T_STACKPALLET set F_BATCH='" + Batch + "' where F_ENDDEVICE=" + ccf.GetEndDeviceFromManage(manageKindIdx, manageTaskIdx));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dbo.ExceSQL("update t_monitor_task set F_DeviceCommandIndex=7 where F_MonitorIndex=" + MonitorIndex);
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, 7, deviceIdx, gc[5], BatteryType, barcode);
|
|
dbo.ExceSQL("update T_STACKPALLET set F_BATCH='" + Batch + "' where F_ENDDEVICE=" + ccf.GetEndDeviceFromManage(manageKindIdx, manageTaskIdx));
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
if (deviceKind == 2 && devinfo.Dbw2Getlength > 10 && ((deviceIdx > 32130 || deviceIdx < 32105) || (deviceIdx >= 32105 && deviceIdx <= 32130 && deviceIdx == gc[5])))//OCV4µþÅÌ»ú¶Ô½ÓOCVÉ豸ÐèÒªÌØÊâÅжÏ
|
|
{
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, gc[5], BatteryType, barcode);
|
|
}
|
|
else
|
|
{
|
|
if (deviceIdx != 12024)//czÁÙʱÐ޸ı£Ö¤Ö»ÓÐÒ»ÌõÈÎÎñÆô¶¯
|
|
{
|
|
string sql2 = string.Format("select * from T_Monitor_Task where F_NumParam1 in ({0}) and F_Status > 0 ", deviceIdx);
|
|
DataView dvIO = dbo.ExceSQL(sql2).Tables[0].DefaultView;
|
|
if (dvIO.Count == 0)
|
|
//if (dvIO.Count <= 1)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select * from IO_Control where taskflag=1").Append(" and CONTROL_ID=(select F_ManageTaskIndex from T_Monitor_Task where F_MonitorIndex= ").Append(MonitorIndex).Append(")");
|
|
DataView dvPlcAsk = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvPlcAsk.Count == 1)
|
|
{
|
|
//Èç¹ûÎïÁÏÌõÂë²»ÊǿղŴòÓ¡ÌõÂë
|
|
if (!string.IsNullOrEmpty(dvPlcAsk[0]["STOCK_BARCODE"].ToString()))
|
|
{
|
|
#region ·¢ËÍÌùÂëÐÅÏ¢
|
|
//TODO ÌõÂë´òÓ¡
|
|
|
|
socketSendPrint201 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
socketSendPrint201.SendTimeout = 100;
|
|
socketSendPrint201.ReceiveTimeout = 100;
|
|
socketSendPrint201.Connect("10.0.27.124", Convert.ToInt32("9100"));
|
|
|
|
|
|
string printTxt = dvPlcAsk[0]["STOCK_BARCODE"].ToString();
|
|
//string input = "#041C1E1Q1^D " + dvPlcAsk[0]["STOCK_BARCODE"].ToString() + "??]";
|
|
//string input = "#041C1E1Q1^D " + printTxt + "??]";
|
|
string input = "#041C1E1Q1^D" + printTxt + "??]";
|
|
byte[] utf8Bytes = Encoding.UTF8.GetBytes(input);
|
|
socketSendPrint201.Send(utf8Bytes);
|
|
socketSendPrint201.Disconnect(true);
|
|
|
|
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "rÈÎÎñºÅ:" + MonitorIndex, "·¢ËÍÌù±ê»úÌõÂëÐÅÏ¢", "ÌõÂë:" + dvPlcAsk[0]["STOCK_BARCODE"].ToString());
|
|
#endregion ·¢ËÍÌùÂëÐÅÏ¢
|
|
}
|
|
|
|
|
|
// System.Threading.Thread.Sleep(3000);
|
|
}
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, gc[5], BatteryType);
|
|
}
|
|
else
|
|
{
|
|
sendok = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
sendok = sdo.SendDeviceOrder(msgIdx, MonitorIndex, deviceOrder, deviceIdx, gc[5], BatteryType);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (sendok == false)
|
|
{
|
|
if (sdo.CommLayerError != null)
|
|
{
|
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", sdo.CommLayerError);
|
|
OnRefreshMonitor(rmea);
|
|
}
|
|
return false;
|
|
}
|
|
else//·¢ËÍÃüÁî³É¹¦
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_SendFlag='1' where F_MonitorIndex=").Append(MonitorIndex);
|
|
dbo.ExecuteSql(sql.ToString());//20100905Ö»ÖØ·¢Ö÷ÈÎÎñ
|
|
|
|
ccf.SendOrderSuccess(manageKindIdx, manageTaskIdx, MonitorIndex, deviceIdx, _routeID);
|
|
if (deviceIdx >= 32105 && deviceIdx <= 32130 && EndDevice != deviceIdx)//OCV4ÌØÊâ´¦ÀíÔÚµþÅÌÈë¿âºó½«ºóÃæÒªÈ¥µþÅ̵ÄÈÎÎñÖØ·¢
|
|
{
|
|
DataView needresend = dbo.ExceSQL("select * from t_manage_task where FSTATUS>0 and F_ManageTaskKindIndex=1 and FStartDevice=" + deviceIdx + " and FEndDevice=" + deviceIdx + " order by fid desc").Tables[0].DefaultView;
|
|
if (needresend.Count > 0)
|
|
{
|
|
string LastGroupBarcode = dbo.GetSingle("select F_BarCode from T_Base_PLC_Ask where F_BindingDevice=" + deviceIdx).ToString();
|
|
if (!string.IsNullOrEmpty(LastGroupBarcode))
|
|
{
|
|
if (LastGroupBarcode.IndexOf(needresend[0]["FPALLETBARCODE"].ToString()) >= 0)
|
|
{
|
|
dbo.ExceSQL("update t_monitor_task set F_Status=0 where F_ManageTaskIndex=" + needresend[0]["fid"]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#region ¶à²æ¹ØÁªÈÎÎñ£¬ÄÜͬ²½µÄͬʱ±¨¸æ·¢ËÍÃüÁî³É¹¦
|
|
//20100323
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(deviceIdx);
|
|
if (devinfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
int[] corrtask = Model.CGeneralFunction.MutiForkIfSync(MonitorIndex, deviceIdx, deviceKind);
|
|
if (corrtask != null)
|
|
{
|
|
int rfid = 0, rmankind = 0, rdev = 0;
|
|
for (int i = 0; i < corrtask.GetLength(0); i++)
|
|
{
|
|
rfid = ccf.GetManageTaskIndexfromMonitor(corrtask[i]);
|
|
rmankind = ccf.GetManageTaskKindIndexFromMonitor(corrtask[i]);
|
|
rdev = ccf.GetDeviceindexFromMonitor(corrtask[i]);
|
|
ccf.SendOrderSuccess(rmankind, rfid, corrtask[i], rdev, 0);
|
|
if (rdev.ToString().IndexOf("12064") >= 0 || rdev.ToString().IndexOf("12065") >= 0 || rdev.ToString().IndexOf("12066") >= 0 || rdev.ToString().IndexOf("12067") >= 0)
|
|
{
|
|
Model.CGeneralFunction.ActionComplete(rdev, corrtask[i], 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{//20110608
|
|
CControlError = string.Format("·¢ËÍÃüÁîµ÷ÓÃSendMonitorTaskʱ£º{0}", ex.StackTrace + ex.Message);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
int GetDeviceFromMonitor(int monitorIndex)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_MonitorIndex, F_DeviceIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(monitorIndex).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// »ñÈ¡¿ÉÓõÄÄ¿±êλÖãºÈë¿âµÄÏïµÀ»òÕß³ö¿âվ̨
|
|
/// </summary>
|
|
/// <param name="manageTaskIdx">µ÷¶ÈÈÎÎñË÷Òý</param>
|
|
/// <param name="manageKindIdx">µ÷¶ÈÈÎÎñÀà±ð</param>
|
|
/// <returns></returns>
|
|
bool GetUsableDestination(int manageTaskIdx, int manageKindIdx)
|
|
{
|
|
//20100610²éÕÒÒ»¸ö·¾¶¿ÉÓã¬ÈÎÎñÊý×îÉÙµÄÖÕµãÉ豸
|
|
Dictionary<int, int> advDev = new Dictionary<int, int>();
|
|
object ob;
|
|
DataView dv = new DataView();
|
|
DataRowView dr = null;
|
|
DataView dvIO = new DataView();
|
|
DataTable dtd = new DataTable();
|
|
DataTable dt = new DataTable();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FID = ").Append(manageTaskIdx).Append(") AND (F_ManageTaskKindIndex = ").Append(manageKindIdx).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count <= 0)
|
|
{
|
|
return false;
|
|
}
|
|
dr = dv[0];
|
|
|
|
//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)
|
|
{
|
|
//Ö»ÐÞÉêÇë¸Äµ÷¶ÈÈÎÎñµÄ·¾¶£¬²»Ð޸ĵ÷¶È×Ô¶¯ÈÎÎñ·¾¶
|
|
if (dr["F_ManageTaskKindIndex"].ToString() != "1") return false;
|
|
|
|
string adviceDev = "";
|
|
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();
|
|
return false;
|
|
}
|
|
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)");
|
|
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 break;
|
|
}
|
|
}
|
|
if (advDev.Count == 0)//20100610
|
|
{
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
else
|
|
{//20100610
|
|
int mincount = 9999;
|
|
foreach (int aaa in advDev.Keys)
|
|
{
|
|
if (advDev[aaa] < mincount)
|
|
{
|
|
mincount = advDev[aaa];
|
|
adviceDev = aaa.ToString();
|
|
}
|
|
}
|
|
if (adviceDev == "")
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{//20100610
|
|
return false;
|
|
}
|
|
}
|
|
|
|
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"]).Append("");
|
|
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"]).Append(",2,'").Append(dr["FENDWAREHOUSE"]).Append("','").Append(dr["FPALLETBARCODE"]).Append("','").Append(adviceDev).Append("',0,'").Append(dtime).Append("',null)");
|
|
|
|
|
|
dboM.ExceSQL(sql.ToString());
|
|
dboM.TransCommit();
|
|
//°ÑManageTaskIdx£¬ManageKindIdx µÄµ÷¶ÈÈÎÎñÈ«²¿ÉêÇë¸ÄµÀ
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("UPDATE T_Monitor_Task SET F_Status = 3 WHERE (F_ManageTaskIndex = ").Append(manageTaskIdx).Append(") AND (F_ManageTASKKINDINDEX =").Append(manageKindIdx).Append(")");
|
|
dbo.ExceSQL(sql.ToString());
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CControl.GetUsableDestination", "¶Ñ¶â»úÈë¿âÄ¿±êλÖ÷¢Éú¸ÄµÀ", "¹ÜÀíÈÎÎñ£º" +
|
|
manageKindIdx.ToString() + "-" + manageTaskIdx.ToString(), "ÌõÂ룺" + dr["FPALLETBARCODE"].ToString().ToUpper());
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = string.Format("·¢ËÍÖ¸ÁÉêÇë¸ÄµÀʱ£º{0}", ex.StackTrace + ex.Message);
|
|
dboM.TransRollback();
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dt.Dispose();
|
|
dtd.Dispose();
|
|
dv.Dispose();
|
|
dvIO.Dispose();
|
|
dr = null;
|
|
}
|
|
}
|
|
|
|
bool GetRGVIdleDestination(int manageTaskIdx, int manageKindIdx, int RGVGateDevice, bool IfUseNegativeDevice)
|
|
{
|
|
|
|
//20100610 t_Base_device ±íF_UsableEndDevice×ֶδæ·ÅÈë¿â»òÕß³ö¿â¶ÔµÈµÄÉ豸Ë÷Òý×飨ÒԷֺŸô¿ª£©£º
|
|
//¸ºÊý´ú±íλÓÚµ±Ç°Éè±¸Ç°Ãæ£¨»·ÐÎRGVÐÐ×ß·½ÏòµÄ·´·½Ïò£©£¬Ö»ÔÊÐíÔÚ·¢ËÍRGVÈ¡»õºÍµÚÒ»¡¢¶þ¸öÔ˶¯Ê±Ê¹Óã»
|
|
//ÕýÊý´ú±íµ±Ç°É豸ºóÃæµÄÉ豸£¬¿ÉÒÔÔÚ·¢ËÍËÍ»õºÍ֮ǰµÄËùÓÐÃüÁîʹÓÃ.Ö±µÀRGV¶¼ÊÇÕýÊý¡£
|
|
//T_Base_RGV_GateÐÂÔö×ֶΡ°F_EndDevice¡±ÓÃÓÚ¼ÇÔØÈë¿âʱ¿¿½üÏïµÀÒ»²àµÄRGV³öÈë¿ÚÊäËÍ»úµÄ¶ÔÓ¦µÄÏïµÀÉ豸Ë÷Òý
|
|
//»òÕß³ö¿âʱ¿¿½ü³ö¿âվ̨һ²àµÄÊäËÍ»ú¶ÔÓ¦µÄ³ö¿âվ̨Ë÷Òý
|
|
|
|
//¿É±ä¸üÄ¿±êλÖõÄÑ¡ÔñÔÔò£ºRGVÄ¿±êλÖÿÕÏС¢ÎÞÎĿ±êλÖòÎÓëµÄÕýÔÚÖ´Ðеĵ÷¶ÈÈÎÎñÊý×îÉÙ
|
|
|
|
DataView dv = new DataView();
|
|
DataRowView dr = null;
|
|
|
|
string adviceDev = "";
|
|
char[] cc = new char[1] { ';' };
|
|
string[] sp;
|
|
DataView dvIO = new DataView();
|
|
Dictionary<int, int> advDev = new Dictionary<int, int>();
|
|
object ob;
|
|
DataView dvu = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FID = ").Append(manageTaskIdx).Append(") AND (F_ManageTaskKindIndex = ").Append(manageKindIdx).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count <= 0)
|
|
{
|
|
return false;
|
|
}
|
|
dr = dv[0];
|
|
//Ö»ÐÞÉêÇë¸Äµ÷¶ÈÈÎÎñµÄ·¾¶£¬²»Ð޸ĵ÷¶È×Ô¶¯ÈÎÎñ·¾¶
|
|
if (dr["F_ManageTaskKindIndex"].ToString() != "1") return false;
|
|
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.TASKCANCEL).Append(") or(CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKALTERROUTEREPLY).Append("))");
|
|
dvIO = dboM.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvIO.Count <= 0)
|
|
{
|
|
|
|
#region ¸ù¾ÝT_Base_Device±íµÄF_UsableEndDevice²éÕÒ¿ÉÓÃÖÕµãÉ豸
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select F_UsableEndDevice from T_Base_Device where F_UsableEndDevice is not null and F_DeviceIndex=").Append(RGVGateDevice).Append("");
|
|
dvu = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvu.Count > 0)
|
|
{
|
|
int enddv = 0, DESTINATION = 0;
|
|
sp = dvu[0]["F_UsableEndDevice"].ToString().Split(cc);
|
|
|
|
for (int i = sp.GetLowerBound(0); i <= sp.GetUpperBound(0); i++)
|
|
{
|
|
if (int.TryParse(sp[i], out enddv) == false) continue;
|
|
enddv = Convert.ToInt32(sp[i]);
|
|
if (enddv < 0)
|
|
{
|
|
//¸ºÊý´ú±íµ±Ç°Éè±¸Ç°ÃæµÄÉ豸£¨»·ÐÎRGVÐÐ×ß·½ÏòµÄ·´·½Ïò£©
|
|
if (IfUseNegativeDevice == true)
|
|
{
|
|
enddv = -(enddv);
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(enddv);
|
|
if ((devinfo.HaveGoods == true) || (devinfo.RunState == 2))
|
|
{//Ä¿±êλÖñ»Õ¼ÓûòÕß¹ÊÕÏ
|
|
continue;
|
|
}
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_EndDevice FROM T_Base_RGV_Gate WHERE (F_RGVGateDeviceIndex = ").Append(enddv).Append(") AND (F_EndDevice IS NOT NULL)");
|
|
ob = dbo.GetSingle(sql.ToString());
|
|
if (ob == null) continue;
|
|
DESTINATION = Convert.ToInt32(ob);
|
|
if (CDisassembleTask.MinRouteID(Convert.ToInt32(dr["FSTARTDEVICE"]), DESTINATION, dr["FUseAwayFork"]) != -1)
|
|
{
|
|
//20100609ͳ¼Æµ½ÖÕµãÉ豸ÕýÔÚÖ´ÐеÄÈÎÎñÊý
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT count(FENDDEVICE) as counts FROM T_Manage_Task where FENDDEVICE='").Append(DESTINATION).Append("' and fstatus>0");
|
|
ob = dbo.GetSingle(sql.ToString());
|
|
advDev.Add(DESTINATION, Convert.ToInt32(ob));
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (advDev.Count <= 0)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
int mincount = 9999;
|
|
foreach (int aaa in advDev.Keys)
|
|
{
|
|
if (advDev[aaa] < mincount)
|
|
{
|
|
mincount = advDev[aaa];
|
|
adviceDev = aaa.ToString();
|
|
}
|
|
}
|
|
if (adviceDev == "")
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
//20101108int fid = dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
|
string dtime = DateTime.Now.ToString("u");
|
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
|
|
|
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"]).Append(" and CONTROL_STATUS<>").Append(Model.CGeneralFunction.TASKCANCEL).Append("");
|
|
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, WAREHOUSE_CODE, STOCK_BARCODE, DEVICE_CODE, APPLY_TASK_STATUS, CREATE_TIME,CONTROL_APPLY_REMARK)").Append(
|
|
"VALUES (").Append(appid).Append(",").Append(dr["FID"]).Append(",'").Append(dr["FENDWAREHOUSE"]).Append("','").Append(dr["FPALLETBARCODE"]).Append("','").Append(adviceDev).Append("',0,'").Append(dtime).Append("',null)");
|
|
|
|
dboM.ExceSQL(sql.ToString());
|
|
dboM.TransCommit();
|
|
//°ÑManageTaskIdx£¬ManageKindIdx µÄµ÷¶ÈÈÎÎñÈ«²¿ÉêÇë¸ÄµÀ
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("UPDATE T_Monitor_Task SET F_Status = 3 WHERE (F_ManageTaskIndex = ").Append(manageTaskIdx).Append(") AND (F_ManageTASKKINDINDEX =").Append(manageKindIdx).Append(")");
|
|
dbo.ExceSQL(sql.ToString());
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("CControl.GetRGVIdleDestination", "´©Ëó³µÄ¿±êλÖ÷¢Éú¸ÄµÀ", "¹ÜÀíÈÎÎñ£º" +
|
|
manageKindIdx.ToString() + "-" + manageTaskIdx.ToString(), "ÌõÂ룺" + dr["FPALLETBARCODE"].ToString().ToUpper());
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
dboM.TransRollback();
|
|
CControlError = string.Format("·¢ËÍÖ¸ÁÉêÇë¸ÄµÀʱ£º{0}", ex.StackTrace + ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = string.Format("·¢ËÍÖ¸ÁÉêÇë¸ÄµÀʱ£º{0}", ex.StackTrace + ex.Message);
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dr = null;
|
|
cc = null;
|
|
sp = null;
|
|
dvIO.Dispose();
|
|
dvu.Dispose();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ·µ»ØÔÚ¶¥Éý´¦Èë¿âÈÎÎñ¿ÉÒÔ¶à²æ¹ØÁªµÄµ÷¶ÈÈÎÎñË÷Òý
|
|
/// </summary>
|
|
/// <param name="controlTaskType">¿ØÖÆÈÎÎñÀàÐÍ</param>
|
|
/// <param name="devindex">É豸Ë÷Òý</param>
|
|
/// <returns></returns>
|
|
int GetEnableDoubleForkManageTask(int controlTaskType, int devindex, int FID)
|
|
{
|
|
DataView dv0 = new DataView(); DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_MonitorIndex,T_Monitor_Task.F_ManageTaskIndex,T_Monitor_Task.F_ManageTASKKINDINDEX FROM T_Monitor_Task ,T_Manage_Task where T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID AND T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex AND F_DeviceIndex=").Append(devindex).Append(" and FCONTROLTASKTYPE=").Append(controlTaskType);
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select min(F_MonitorIndex) as mm from T_Monitor_Task where F_ManageTaskIndex=").Append(dv[i]["F_ManageTaskIndex"]).Append(" and F_ManageTASKKINDINDEX=").Append(dv[i]["F_ManageTASKKINDINDEX"]);
|
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
if (dv0[0]["mm"].ToString() == dv[i]["F_MonitorIndex"].ToString())
|
|
{
|
|
if (FID != Convert.ToInt32(dv[i]["F_ManageTaskIndex"]))
|
|
{
|
|
return Convert.ToInt32(dv[i]["F_ManageTaskIndex"]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv0.Dispose();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// »ñµÃ¶Ñ¶â»úÔÚ¶ÔµÈվ̨ȡ»õµÄ¶à²æ¹ØÁªÈÎÎñ
|
|
/// </summary>
|
|
/// <param name="controlTaskType">¿ØÖÆÈÎÎñÀàÐÍ</param>
|
|
/// <param name="Stackdevindex">¶Ñ¶â»úÉ豸Ë÷Òý</param>
|
|
/// <param name="StationDevice">վ̨É豸Ë÷Òý</param>
|
|
/// <param name="FID">µ÷¶ÈÈÎÎñË÷Òý</param>
|
|
/// <returns></returns>
|
|
int GetEnableDoubleForkManageTask(int controlTaskType, int Stackdevindex, int StationDevice, int FID)
|
|
{
|
|
DataView dv1 = new DataView();
|
|
DataView dv0 = new DataView();
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_ZXY FROM T_Base_Lane_Gate,T_Base_LaneInfo WHERE ").Append(
|
|
"(T_Base_Lane_Gate.F_LaneIndex = T_Base_LaneInfo.F_LaneDeviceIndex) and (T_Base_LaneInfo.F_StackIndex = ").Append(
|
|
Stackdevindex).Append(") and (F_LaneGateDeviceIndex=").Append(StationDevice).Append(")");
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count <= 0) return -1;
|
|
char[] cc = new char[1] { '-' };
|
|
string[] zxy = dv1[0]["F_ZXY"].ToString().Split(cc);
|
|
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_MonitorIndex,T_Monitor_Task.F_ManageTaskIndex,T_Monitor_Task.F_ManageTASKKINDINDEX ").Append(
|
|
" FROM T_Monitor_Task ,T_Manage_Task where T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID AND ").Append(
|
|
"T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex AND F_DeviceIndex=").Append(
|
|
Stackdevindex).Append(" and FCONTROLTASKTYPE=").Append(controlTaskType).Append(" and F_NumParam1=").Append(zxy[0]).Append(
|
|
" and F_NumParam2=").Append(zxy[1]).Append(" and F_NumParam3=").Append(zxy[2]).Append(" and F_RELATIVECONTORLID<>").Append(FID);
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select min(F_MonitorIndex) as mm from T_Monitor_Task where F_ManageTaskIndex=").Append(dv[i]["F_ManageTaskIndex"]).Append(" and F_ManageTASKKINDINDEX=").Append(dv[i]["F_ManageTASKKINDINDEX"]).Append(" ");
|
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
if (dv0[0]["mm"].ToString() == dv[i]["F_MonitorIndex"].ToString())
|
|
{
|
|
if (FID != Convert.ToInt32(dv[i]["F_ManageTaskIndex"]))
|
|
{
|
|
return Convert.ToInt32(dv[i]["F_ManageTaskIndex"]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv0.Dispose();
|
|
dv1.Dispose();
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="Mankind">µ÷¶ÈÈÎÎñÀàÐÍË÷Òý</param>
|
|
/// <param name="FID">µ÷¶ÈÈÎÎñË÷Òý</param>
|
|
/// <param name="ControlTaskType">µ÷¶ÈÈÎÎñÀàÐÍ</param>
|
|
/// <param name="UseAwayFork">×îºó·ÖÅäµÄÔ¶¡¢½ü»õ²æ</param>
|
|
void AlterRoutePath(int Mankind, int FID, int ControlTaskType, char UseAwayFork, int NowDevice)
|
|
{
|
|
DataView dv = new DataView(); DataView dv1 = new DataView(); DataView dvnew = new DataView();
|
|
|
|
//ÏÈÕÒµ½ÒÔǰµÄ·¾¶ÊÇ·ñÓë×îºó·ÖÅäµÄ»õ²æÆ¥Å䣬²»Æ¥ÅäµÄ¸ÄµÀ
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT T_Monitor_Task.F_MonitorIndex,T_Monitor_Task.F_DeviceIndex FROM T_Monitor_Task,T_Base_Route_Device where ").Append(
|
|
" T_Monitor_Task.F_RouteID = T_Base_Route_Device.F_RouteIDSub AND T_Monitor_Task.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and T_Monitor_Task.F_ManageTaskIndex=").Append(
|
|
FID).Append(" and T_Monitor_Task.F_ManageTASKKINDINDEX=").Append(Mankind).Append(" and T_Base_Route_Device.F_UseAwayFork<>'").Append(UseAwayFork).Append("'");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select * from T_Manage_Task where F_ManageTaskKindIndex=").Append(Mankind).Append(" and FID=").Append(FID);
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//20100702
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT T_Base_Route_Device.F_RouteIDSub FROM T_Base_Route,T_Base_Route_Device where T_Base_Route.F_RouteID = T_Base_Route_Device.F_RouteID ").Append(
|
|
" and (T_Base_Route_Device.F_UseAwayFork = '").Append(UseAwayFork).Append("') AND (T_Base_Route_Device.F_DeviceIndex = ").Append(NowDevice).Append(") AND (T_Base_Route.F_StartDevice = ").Append(
|
|
dv[0]["FSTARTDEVICE"]).Append(") AND (T_Base_Route.F_EndDevice = ").Append(dv[0]["FENDDEVICE"]).Append(" and F_RouteKind=").Append(ControlTaskType).Append(")");
|
|
;
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
int routeidNew = Convert.ToInt32(dv1[0][0]);
|
|
//ɾ³ýÔÀ´µÄÉêÇëÐ޸ķ¾¶ÈÎÎñ£¬²ð·ÖеÄÈÎÎñ²¢ÇÒÖ»±£ÁôÏÖÓÐÉ豸¿ªÊ¼µÄÈÎÎñ
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("DELETE FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(FID).Append(") AND (F_ManageTASKKINDINDEX =").Append(Mankind).Append(")");
|
|
dbo.ExceSQL(sql.ToString());
|
|
if (CDisassembleTask.CreateMonitor(Mankind, FID, routeidNew, dv[0], 3) > 0)
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("µ÷Óòð·ÖÈÎÎñ", "µ÷Óòð·ÖÈÎÎñ", "λÖÃ", "2");
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(
|
|
FID).Append(") AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_DeviceIndex = ").Append(
|
|
NowDevice).Append(") AND (F_RouteID = ").Append(routeidNew).Append(
|
|
") AND (F_Status = 3) ");
|
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvnew.Count > 0)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<").Append(dvnew[0]["F_MonitorIndex"]).Append(" and (F_ManageTaskIndex = ").Append(
|
|
FID).Append(") AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_Status = 3)");
|
|
dbo.ExceSQL(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = ").Append(
|
|
FID).Append(") AND (F_ManageTASKKINDINDEX = ").Append(Mankind).Append(") AND (F_Status = 3)");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv1.Dispose();
|
|
dvnew.Dispose();
|
|
}
|
|
}
|
|
int GetDoubleForkMinRouteTask(int taskno)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
|
|
//²»ÊÇË«²æµÄÖ±½Ó·µ»Øtaskno£»ÊÇË«²æµ«ÊÇ¿ÉÒÔͬ²½µÄÖ±½Ó·µ»Øtaskno
|
|
//Ë«²æ²»ÄÜͬ²½µÄ·´À¡¾àÀ뵱ǰ¶Ñ¶â»úλÖÃ×î¶ÌµÄtaskno
|
|
|
|
int manKind = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(taskno);
|
|
int manFid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(taskno);
|
|
int deviceindex = Model.CGeneralFunction.GetDeviceIndexFromMonitor(taskno);
|
|
int devKind = Model.CGeneralFunction.GetDeviceKindIdx(deviceindex);
|
|
int devOrder = Model.CGeneralFunction.GetDeviceOrderFromMonitor(taskno);
|
|
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(deviceindex);
|
|
|
|
int nX = Model.CGeneralFunction.GetXCoorFromMonitor(taskno, deviceindex, devOrder);
|
|
int nY = Model.CGeneralFunction.GetYCoorFromMonitor(taskno, deviceindex, devOrder);
|
|
double nXY = 0, doubleXY = 0, doubleX = 0, doubleY = 0;
|
|
nXY = Math.Pow((double)(nX - devinfo.XCoor), 2) + (Math.Pow((double)(nY - devinfo.YCoor), 2));
|
|
|
|
if (devinfo.IfCorrelDoubleFork == "1")
|
|
{
|
|
Dictionary<int, string[]> df = Model.CGeneralFunction.GetDoubleForkMonitorInfo(taskno, deviceindex);
|
|
if (df == null) return taskno;
|
|
if (Model.CGeneralFunction.MutiForkIfSync(taskno, deviceindex, devKind) == null)
|
|
{
|
|
#region ±éÀúÿ¸ö¹ØÁªÈÎÎñ
|
|
|
|
foreach (int cortask in df.Keys)
|
|
{
|
|
//20120906
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_MonitorIndex FROM dbo.T_Monitor_Task WHERE (F_MonitorIndex = ").Append(cortask).Append(") AND (F_status = 0)");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count <= 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
#region ¹ØÁªÖ¸Áî²»ÊǵÚÒ»¸öÖ¸Áî²»ÄÜ·¢ËÍ
|
|
int rmankind = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(cortask);
|
|
int rman = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(cortask);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(rman).Append(") AND (F_ManageTASKKINDINDEX = ").Append(rmankind).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if ((dv[0]["mmi"] != DBNull.Value) && (dv[0]["mmi"].ToString() != cortask.ToString()))
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
#endregion
|
|
if (devKind == 1)//¶Ñ¶â»ú
|
|
{//Èç¹û´æÔÚµ¹¿â»õ룬ÔòºóÖ´ÐиÃÈÎÎñ20120906¼ÎÐ˵çÁ¦¸Ä½ø£¬µ¹¿â»õλµÄÈ¡»õÃüÁî¼ì²â¶Ñ¶â»ú»õ²æ¶ÔÓ¦¿ª¹ØÊÇ·ñÓлõ
|
|
//if (devOrder == 5)//ËÍ»õÖ¸ÁîʱÅжÏ20110505
|
|
//{
|
|
|
|
// if (true == IfChangeForkCell_LastRun(cortask))
|
|
// {
|
|
// continue;
|
|
// }
|
|
|
|
//}
|
|
doubleX = Model.CGeneralFunction.GetXCoorFromMonitor(cortask, deviceindex, devOrder);
|
|
doubleY = Model.CGeneralFunction.GetYCoorFromMonitor(cortask, deviceindex, devOrder);
|
|
doubleXY = Math.Pow((double)(doubleX - devinfo.XCoor), 2) + (Math.Pow((double)(doubleY - devinfo.YCoor), 2));
|
|
if (nXY > doubleXY)
|
|
{
|
|
nXY = doubleXY;
|
|
taskno = cortask;
|
|
}
|
|
|
|
}
|
|
else if (devKind == 6)//AGV
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_Sequence FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = ").Append(nX).Append(")");
|
|
nXY = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_Sequence FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = ").Append(doubleX).Append(")");
|
|
doubleXY = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
|
if (nXY < doubleXY)
|
|
{
|
|
return taskno;
|
|
}
|
|
else
|
|
{
|
|
return Convert.ToInt32(df[0]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return taskno;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
//·µ»Ø×îСֵµÄÈÎÎñºÅ
|
|
return taskno;
|
|
|
|
}
|
|
else
|
|
{
|
|
#region ±éÀúÿ¸ö¹ØÁªÈÎÎñ
|
|
|
|
foreach (int cortask in df.Keys)
|
|
{
|
|
|
|
#region ¹ØÁªÖ¸Áî²»ÊǵÚÒ»¸öÖ¸Áî²»ÄÜ·¢ËÍ
|
|
int rmankind = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(cortask);
|
|
int rman = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(cortask);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(rman).Append(") AND (F_ManageTASKKINDINDEX = ").Append(rmankind).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if ((dv[0]["mmi"] != DBNull.Value) && (dv[0]["mmi"].ToString() != cortask.ToString()))
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
return taskno;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
return taskno;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = string.Format("·¢ËÍÃüÁîµ÷ÓÃGetDoubleForkMinRouteTaskʱ£º{0},{1}", sql.ToString(), ex.StackTrace + ex.Message);
|
|
return taskno;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
bool IFAGVGate(int devIndex)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_AGVGateDeviceIndex FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = ").Append(devIndex).Append(")");
|
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ͬ¹ìÁ½¸ö¶Ñ¶â»ú×éºÏ×÷Òµ£¬Í¨¹ýÖÐת»õλ½»Ìæ×÷Òµ
|
|
/// </summary>
|
|
/// <param name="taskindex"></param>
|
|
/// <param name="ChangeStackCell"></param>
|
|
/// <param name="StackIndex"></param>
|
|
void ChangeStackCellCode(int taskindex, string ChangeStackCell, int StackIndex)
|
|
{//20120820
|
|
int[] zxy = ccf.GetCoordinatesFromMonitorTask(taskindex);
|
|
StringBuilder zxystr = new StringBuilder();
|
|
DataView dvl = new DataView(); DataView dv = new DataView();
|
|
if (zxy != null)
|
|
{
|
|
zxystr.Append((zxy[3].ToString().Length == 1 ? "0" + zxy[3].ToString() : zxy[3].ToString())).Append("-").Append(
|
|
((zxy[4].ToString().Length == 1) ? ("0" + zxy[4].ToString()) : (zxy[4].ToString()))).Append("-").Append(
|
|
((zxy[5].ToString().Length == 1) ? ("0" + zxy[5].ToString()) : (zxy[5].ToString())));
|
|
}
|
|
int laneway = 0;
|
|
dvl = dbo.ExceSQL(string.Format("SELECT F_LaneDeviceIndex FROM T_Base_LaneInfo WHERE (F_StackIndex = {0})", StackIndex)).Tables[0].DefaultView;
|
|
if (dvl.Count > 0)
|
|
{
|
|
laneway = Convert.ToInt32(dvl[0]["F_LaneDeviceIndex"]);
|
|
}
|
|
else
|
|
return;
|
|
|
|
char[] cc = new char[1] { '-' };
|
|
string[] endCell = ChangeStackCell.Split(cc);
|
|
int fid = ccf.GetManageTaskIndexfromMonitor(taskindex);
|
|
int Mankind = ccf.GetManageTaskKindIndexFromMonitor(taskindex);
|
|
//dbo.TransBegin();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate,T_Base_Device WHERE (T_Base_Lane_Gate.F_LaneGateDeviceIndex = T_Base_Device.F_DeviceIndex) and (F_ZXY = '").Append(ChangeStackCell).Append("') and F_LaneIndex=").Append(laneway);
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
sql.Remove(0, sql.Length);//20120420
|
|
sql.Append("update T_Monitor_Task set F_AheadDetect=F_AheadDetect+'").Append(";N").Append(dv[0]["F_LaneGateDeviceIndex"].ToString()).Append(";R").Append(dv[0]["F_LaneGateDeviceIndex"].ToString())
|
|
.Append("', F_NumParam4=").Append(endCell[0]).Append(",F_NumParam5=").Append(endCell[1]).Append(",F_ChangeStackCell='").Append(laneway.ToString() + "," + ChangeStackCell
|
|
).Append("',F_NumParam6=").Append(endCell[2]).Append(" where F_ManageTaskIndex=").Append(fid).Append(" and F_ManageTASKKINDINDEX=").Append(Mankind).Append(" and F_DeviceIndex=").Append(StackIndex);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set FREMARK='").Append(zxystr.ToString()).Append("',FExceptionNO=").Append(Model.CGeneralFunction.TASKCHANGESTACK).Append(" where FID=").Append(fid).Append(" and F_ManageTaskKindIndex=").Append(Mankind);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
}
|
|
//dbo.TransCommit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
//dbo.TransRollback();
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dvl.Dispose();
|
|
}
|
|
}
|
|
int GetIOControlStatus(int TaskIndex)
|
|
{
|
|
int mankind = ccf.GetManageTaskKindIndexFromMonitor(TaskIndex);
|
|
int Fid = ccf.GetManageTaskIndexfromMonitor(TaskIndex);
|
|
if (mankind == 1)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT CONTROL_STATUS FROM IO_CONTROL WHERE (CONTROL_ID = ").Append(Fid).Append(")");
|
|
object ob = dboM.GetSingle(sql.ToString());
|
|
if (ob != null)
|
|
{
|
|
return Convert.ToInt32(ob);
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ·µ»ØAGVË«²æµÄ¹ØÁªÕ¾Ì¨,¡°-1¡±´ú±íûÓйØÁª
|
|
/// </summary>
|
|
/// <param name="taskindex">É豸ָÁîË÷Òý</param>
|
|
/// <returns></returns>
|
|
int GetAGVCorrelIndex(int taskindex)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_NumParam2 FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(taskindex).Append(")");
|
|
object ob = dbo.GetSingle(sql.ToString());
|
|
if (ob != null)
|
|
{
|
|
int cs = Convert.ToInt32(ob);
|
|
if (cs % 2 == 0)
|
|
{
|
|
return (cs - 1);
|
|
}
|
|
else
|
|
{
|
|
return (cs + 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
int GetAGVCorrelConveyorIndex(int taskindex)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_NumParam2 FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(taskindex).Append(")");
|
|
object ob = dbo.GetSingle(sql.ToString());
|
|
if (ob != null)
|
|
{
|
|
int cs = Convert.ToInt32(ob);
|
|
if (cs % 2 == 0)
|
|
{
|
|
return (cs + 1);
|
|
}
|
|
else
|
|
{
|
|
return (cs - 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ·µ»ØAGVÔÚ´Ëվ̨ȡ»õµÄµ÷¶ÈÈÎÎñË÷Òý
|
|
/// </summary>
|
|
/// <param name="controltype">¿ØÖÆÈÎÎñÀàÐÍ</param>
|
|
/// <param name="stationIndex">AGVվ̨Ë÷Òý</param>
|
|
/// <returns></returns>
|
|
int GetAGVEnableDoubleForkManageTask(int controltype, int stationIndex, int agv)
|
|
{//20110412
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_MonitorIndex,T_Monitor_Task.F_ManageTaskIndex,T_Monitor_Task.F_ManageTASKKINDINDEX ").Append(
|
|
" FROM T_Monitor_Task ,T_Manage_Task where T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID AND ").Append(
|
|
"T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex and FCONTROLTASKTYPE=").Append(
|
|
controltype).Append(" and F_NumParam2=").Append(stationIndex).Append(" and F_DeviceIndex=").Append(agv).Append(" and F_Status=0 and F_DeviceCommandIndex=2");
|
|
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_ManageTaskIndex"]);
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
bool IfInSameLimitX(int fid, int mfid, int manKind)
|
|
{
|
|
DataView dv = new DataView(); DataView dv1 = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_ForwardLimitX,F_BackLimitX,FEndCol FROM T_Manage_Task,T_Base_LaneInfo WHERE T_Manage_Task.FLANEWAY = T_Base_LaneInfo.F_LaneDeviceIndex and (F_ManageTaskKindIndex = ").Append(manKind).Append(") AND (FID = ").Append(fid).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_ForwardLimitX,F_BackLimitX,FEndCol FROM T_Manage_Task,T_Base_LaneInfo WHERE T_Manage_Task.FLANEWAY = T_Base_LaneInfo.F_LaneDeviceIndex and (F_ManageTaskKindIndex = ").Append(manKind).Append(") AND (FID = ").Append(mfid).Append(")");
|
|
dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv1.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
if ((dv[0]["FEndCol"].ToString() == dv[0]["F_ForwardLimitX"].ToString()) && (dv1[0]["F_ForwardLimitX"].ToString() == dv1[0]["FEndCol"].ToString()))
|
|
{
|
|
return true;
|
|
}
|
|
if ((dv[0]["FEndCol"].ToString() == dv[0]["F_BackLimitX"].ToString()) && (dv1[0]["F_BackLimitX"].ToString() == dv1[0]["FEndCol"].ToString()))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv1.Dispose();
|
|
}
|
|
}
|
|
int GetAGVFromConveyorDoubleForkGetGoodManageTask(int controltype, int stationIndex, int agv)
|
|
{
|
|
DataView dv0 = new DataView();
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT T_Monitor_Task.F_ManageTaskIndex,F_MonitorIndex,T_Manage_Task.F_ManageTaskKindIndex ").Append(
|
|
" FROM T_Monitor_Task ,T_Manage_Task where T_Monitor_Task.F_ManageTaskIndex = T_Manage_Task.FID AND ").Append(
|
|
"T_Monitor_Task.F_ManageTASKKINDINDEX = T_Manage_Task.F_ManageTaskKindIndex and FCONTROLTASKTYPE=").Append(
|
|
controltype).Append(" and F_NumParam2=").Append(stationIndex).Append(" and F_DeviceIndex=").Append(agv).Append(" and F_Status=0 and F_DeviceCommandIndex=2 order by F_MonitorIndex asc");//20110412
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT top 1 F_MonitorIndex ").Append(" FROM T_Monitor_Task where T_Monitor_Task.F_ManageTaskIndex = ")
|
|
.Append(dv[i]["F_ManageTaskIndex"].ToString()).Append(
|
|
" and F_ManageTASKKINDINDEX = ").Append(dv[i]["F_ManageTaskKindIndex"].ToString()).Append(" order by F_MonitorIndex asc");
|
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv0[0]["F_MonitorIndex"].ToString() == dv[i]["F_MonitorIndex"].ToString())
|
|
{
|
|
|
|
return Convert.ToInt32(dv[i]["F_ManageTaskIndex"]);
|
|
}
|
|
}
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv0.Dispose();
|
|
}
|
|
}
|
|
bool IFHaveSameEndDevice(int fid, int CorrelFid, int mti)
|
|
{
|
|
DataView dv0 = new DataView(); DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FENDDEVICE, FENDCELL, FUseAwayFork FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = ").Append(mti).Append(") AND (FID = ").Append(fid).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FENDDEVICE, FENDCELL, FUseAwayFork FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = ").Append(mti).Append(") AND (FID = ").Append(CorrelFid).Append(")");
|
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
if ((dv[0]["FENDDEVICE"].ToString() == dv0[0]["FENDDEVICE"].ToString()) && (dv[0]["FENDDEVICE"].ToString() == "28001") && (Math.Abs(Convert.ToInt32(dv[0]["FENDCELL"]) - Convert.ToInt32(dv0[0]["FENDCELL"])) == 1))//20110412
|
|
{
|
|
if ((Convert.ToInt32(dv[0]["FENDCELL"]) > Convert.ToInt32(dv0[0]["FENDCELL"])) && (Convert.ToInt32(dv[0]["FUseAwayFork"]) > Convert.ToInt32(dv0[0]["FUseAwayFork"])))
|
|
{
|
|
return true;
|
|
}
|
|
if ((Convert.ToInt32(dv[0]["FENDCELL"]) < Convert.ToInt32(dv0[0]["FENDCELL"])) && (Convert.ToInt32(dv[0]["FUseAwayFork"]) < Convert.ToInt32(dv0[0]["FUseAwayFork"])))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
dv0.Dispose();
|
|
}
|
|
}
|
|
void UpdateAheadDetectUnallow(StringBuilder aheadUnallow, int taskindex)
|
|
{
|
|
#region 20110505Ôö¼ÓµÄÐÅÏ¢Ìáʾ
|
|
int rec = 0;
|
|
if (aheadUnallow.Length > 0)
|
|
{
|
|
rec = dbo.ExecuteSql(string.Format("UPDATE T_Monitor_Task SET F_ErrorCode ='{0}' WHERE F_MonitorIndex ={1} and F_ErrorCode <>'{0}'", aheadUnallow.ToString(), taskindex));
|
|
}
|
|
else
|
|
{
|
|
rec = dbo.ExecuteSql(string.Format("UPDATE T_Monitor_Task SET F_ErrorCode ='' WHERE F_MonitorIndex ={1} and F_ErrorCode <>''", aheadUnallow.ToString(), taskindex));
|
|
}
|
|
if (rec > 0)
|
|
{
|
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
|
OnDataChange("·¢ËÍÌáǰ¼ì²âʱ£¬Òì³£", cea);
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
/// <summary>
|
|
/// Èç¹ûÊǵ¹²æ»õ룬ÄÇËüºóÖ´ÐÐ
|
|
/// </summary>
|
|
/// <param name="TaskIndex"></param>
|
|
/// <returns></returns>
|
|
bool IfChangeForkCell_LastRun(int TaskIndex)
|
|
{//20110505
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
|
|
int laneway = ccf.GetLaneWayFromLaneInfo(ccf.GetDeviceindexFromMonitor(TaskIndex));
|
|
int[] zxy = ccf.GetCoordinatesFromMonitorTask(TaskIndex);
|
|
string zxystr = (zxy[3].ToString().Length == 1 ? "0" + zxy[0].ToString() : zxy[3].ToString()) + "-" +
|
|
((zxy[4].ToString().Length == 1) ? ("0" + zxy[4].ToString()) : (zxy[4].ToString())) + "-" +
|
|
((zxy[5].ToString().Length == 1) ? ("0" + zxy[5].ToString()) : (zxy[5].ToString()));
|
|
int lanedev = ccf.GetChangeCellStationFromLaneGate(laneway, zxystr);
|
|
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_ChangeForkCell FROM T_Base_LaneInfo WHERE F_LaneDeviceIndex={0} and (F_ChangeForkCell like '%{1}%' or F_ChangeForkCell like '%{2}%')", laneway, zxystr, lanedev)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)//µ¹¿â»õλµÄÈÎÎñºóÖ´ÐÐ
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// ·ÖÅäʵ¼Ê¹¤×÷µÄ¶Ñ¶â»úÉ豸Ë÷Òý20111020
|
|
/// </summary>
|
|
/// <param name="deviceIndex">ÐéÄâ¶Ñ¶â»úÉ豸Ë÷Òý</param>
|
|
/// <param name="taskIndex">É豸ָÁîË÷Òý</param>
|
|
/// <param name="manKind">µ÷¶ÈÈÎÎñÀàÐÍ</param>
|
|
/// <param name="fid">µ÷¶ÈÈÎÎñË÷Òý</param>
|
|
bool AssignStackNo(int deviceIndex, int taskIndex, int manKind, int fid)
|
|
{//20120820
|
|
DataView dv = new DataView();
|
|
Model.MDevice devinfo; int resDev = 0;
|
|
try
|
|
{
|
|
int Xcoor = Model.CGeneralFunction.GetXCoorFromMonitor(taskIndex, deviceIndex, ccf.GetDeviceOrderFromMonitor(taskIndex));
|
|
int Zcoor = Model.CGeneralFunction.GetZCoorFromMonitor(taskIndex, deviceIndex, ccf.GetDeviceOrderFromMonitor(taskIndex));
|
|
int XcoorS = Model.CGeneralFunction.GetXCoorFromMonitor(taskIndex, deviceIndex, 5);
|
|
int ZcoorS = Model.CGeneralFunction.GetZCoorFromMonitor(taskIndex, deviceIndex, 5);
|
|
int sno = 0; bool IfCombinedWork = false;
|
|
GetSpecialStackNo(deviceIndex, Zcoor, Xcoor, ZcoorS, XcoorS, out sno, out IfCombinedWork);
|
|
//ÏÈ¿¼ÂÇÌØÊâÇé¿ö20111226
|
|
if (IfCombinedWork == true)
|
|
{
|
|
//Á½¸ö¶Ñ¶â»ú×éºÏ½»Ìæ×÷Òµ
|
|
string ChangeStackCell = GetChangeStackCell(deviceIndex);
|
|
if (ChangeStackCell != "")
|
|
{
|
|
|
|
ChangeStackCellCode(taskIndex, ChangeStackCell, deviceIndex);
|
|
SetStackNo(deviceIndex, sno, manKind, fid);
|
|
return true;
|
|
}
|
|
else
|
|
{//20120820ûÓпÕÏеÄÁ½¸ö¶Ñ¶â»ú¹«ÓõĽ»½Ó»õλ
|
|
return false;
|
|
}
|
|
}
|
|
//È»ºóÆäÓàÇé¿ö¸ù¾Ý×ÜÁÐÊýÕÛÖзÖÅ䏸Á½¸ö¶Ñ¶â»ú
|
|
resDev = GetPRIStackNo(deviceIndex, Zcoor, Xcoor, ZcoorS, XcoorS);
|
|
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(resDev);
|
|
if (devinfo.RunState == 0 && ccf.GetManTaskReserve(resDev) <= 0 && ccf.GetDeviceLockedState(resDev) == 0)
|
|
{//¿ÕÏС¢ÎÞÈÎÎñÖ´ÐС¢ÎÞ¹ÜÀíÈÎÎñÔ¤Ô¼Ëø
|
|
SetStackNo(deviceIndex, resDev, manKind, fid);
|
|
return true;
|
|
}
|
|
else
|
|
{//¸ù¾Ý35001µ±Ç°Î»ÖúÍÕýÔÚÖ´ÐеÄÈÎÎñµÄÄ¿±êλÖÿ¼ÂÇÊÇ·ñ·ÖÅä35002
|
|
resDev = devinfo.MutexStack;
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(resDev);
|
|
if (devinfo.RunState == 0 && ccf.GetManTaskReserve(resDev) <= 0 && ccf.GetDeviceLockedState(resDev) == 0)
|
|
{
|
|
sql = new StringBuilder(string.Format("SELECT F_DeviceCommandIndex,F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4, F_NumParam5, F_NumParam6 FROM T_Monitor_Task WHERE (F_Status > 0) AND (F_DeviceIndex = {0})", devinfo.MutexStack));
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (dv[0]["F_DeviceCommandIndex"].ToString() == "4")//È¡»õ
|
|
{
|
|
if ((GetBarcodeCoor(Convert.ToInt32(dv[0]["F_NumParam2"]), Convert.ToInt32(dv[0]["F_NumParam1"])) + StackMutexXCoor) <= GetBarcodeCoor(Xcoor, Zcoor))
|
|
{
|
|
SetStackNo(deviceIndex, resDev, manKind, fid);
|
|
return true;
|
|
}
|
|
}
|
|
if (dv[0]["F_DeviceCommandIndex"].ToString() == "5")//ËÍ»õ
|
|
{
|
|
if ((GetBarcodeCoor(Convert.ToInt32(dv[0]["F_NumParam5"]), Convert.ToInt32(dv[0]["F_NumParam4"])) + StackMutexXCoor) <= GetBarcodeCoor(Xcoor, Zcoor))
|
|
{
|
|
SetStackNo(deviceIndex, resDev, manKind, fid);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{//(resDev - devinfo.MutexStack)É豸±àºÅСµÄÉ豸£¬Êµ¼ÊÐÐ×ßλÖõÄ×ø±êֵҲС
|
|
int xcMutex = (resDev - devinfo.MutexStack) * (GetBarcodeCoor(Xcoor, Zcoor) - Model.CGetInfo.GetDeviceInfo(devinfo.MutexStack).XCoor);//20120513
|
|
int xMutex = Math.Abs(GetBarcodeCoor(Xcoor, Zcoor) - Model.CGetInfo.GetDeviceInfo(devinfo.MutexStack).XCoor);
|
|
int xDev = Math.Abs(GetBarcodeCoor(Xcoor, Zcoor) - Model.CGetInfo.GetDeviceInfo(resDev).XCoor);
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(devinfo.MutexStack);//20120513
|
|
if ((xDev < xMutex) || ((devinfo.RunState >= 2) && (devinfo.RunState <= 4) && (xcMutex > StackMutexXCoor)))//20120513
|
|
{
|
|
SetStackNo(deviceIndex, resDev, manKind, fid);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
|
|
private string GetChangeStackCell(int stack)
|
|
{//20120820¸ù¾ÝÁ½¸ö¶Ñ¶â»úµÄ×éºÏÈÎÎñÅжÏÄĸö¸ü»»¶Ñ¶â»úվ̨¿ÕÏÐ
|
|
DataView dv = new DataView();
|
|
int fids = 0; string cell = ""; int minfids = int.MaxValue;
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_LaneDeviceIndex, F_ChangeStackCell FROM T_Base_LaneInfo where F_StackIndex={0}", stack)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
char[] cc = new char[1] { ';' };
|
|
string[] sp = dv[0]["F_ChangeStackCell"].ToString().Split(cc);
|
|
string ChangeStackCell = string.Empty;
|
|
int lanedev = 0;
|
|
for (int i = 0; i < sp.GetLength(0); i++)
|
|
{//T_Monitor_Task±íÐÂÔö F_ChangeStackCell "18001,01-30-02"
|
|
int.TryParse(sp[i], out lanedev);
|
|
if (lanedev > 0)
|
|
{//T_Base_LaneInfo±íµÄ F_ChangeStackCell ºÍF_ChangeForkCell×ֶοÉÒÔÌîдµ¹²æ»õλ¶ÔÓ¦ÐéÄâվ̨µÄÉ豸Ë÷Òý
|
|
sp[i] = ccf.GetChangeCellFromLaneGate(Convert.ToInt32(dv[0]["F_LaneDeviceIndex"]), lanedev);
|
|
}
|
|
ChangeStackCell = dv[0]["F_LaneDeviceIndex"].ToString() + "," + sp[i];
|
|
fids = Convert.ToInt32(dbo.GetSingle(string.Format("SELECT count(distinct F_ManageTaskIndex) as fids FROM T_Monitor_Task where F_ChangeStackCell='{0}'", ChangeStackCell)));
|
|
if (fids < minfids)
|
|
{
|
|
minfids = fids;
|
|
cell = sp[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
return cell;
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
void SetStackNo(int dummyStackno, int stackno, int manKind, int fid)
|
|
{
|
|
//20111226¿¼Âǵ÷ÕûÅäÌ×µÄվ̨ºÍÌáǰ¼ì²â£¬35001-32038£»35002-32036
|
|
if (StackIfExitTask(stackno) == true) return;
|
|
|
|
object[] ob = new object[4] { stackno, manKind, fid, dummyStackno };
|
|
dbo.ExecuteSql(string.Format("UPDATE T_Monitor_Task SET F_DeviceIndex ={0} WHERE (F_ManageTASKKINDINDEX = {1}) AND (F_ManageTaskIndex = {2}) AND (F_DeviceIndex = {3})", ob));
|
|
dbo.ExecuteSql(string.Format("UPDATE T_Monitor_Task SET F_AheadDetect =replace(F_AheadDetect,{3},{0}) WHERE (F_ManageTASKKINDINDEX = {1}) AND (F_ManageTaskIndex = {2}) ", ob));
|
|
}
|
|
void GetStackRunX_Zcoor(int StackdeviceIndex, out int Xcoor, out int Zcoor)
|
|
{//20111020
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
Xcoor = 0;
|
|
Zcoor = 1;
|
|
sql = new StringBuilder(string.Format("SELECT F_DeviceCommandIndex,F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4, F_NumParam5, F_NumParam6 FROM T_Monitor_Task WHERE (F_Status > 0) AND (F_DeviceIndex = {0})", StackdeviceIndex));
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if ((dv[0]["F_DeviceCommandIndex"].ToString() == "2") || (dv[0]["F_DeviceCommandIndex"].ToString() == "4"))//½«È¡£¬È¡»õ
|
|
{
|
|
Zcoor = Convert.ToInt32(dv[0]["F_NumParam1"]);
|
|
Xcoor = Convert.ToInt32(dv[0]["F_NumParam2"]);
|
|
}
|
|
else if (dv[0]["F_DeviceCommandIndex"].ToString() == "5")//ËÍ»õ
|
|
{
|
|
Zcoor = Convert.ToInt32(dv[0]["F_NumParam4"]);
|
|
Xcoor = Convert.ToInt32(dv[0]["F_NumParam5"]);
|
|
|
|
}
|
|
|
|
}
|
|
//else
|
|
//{
|
|
|
|
// int ManTaskReserve = ccf.GetManTaskReserve(StackdeviceIndex);
|
|
// if (ManTaskReserve > 0)
|
|
// {
|
|
// int mti =Convert.ToInt32( ManTaskReserve.ToString().Substring(0, 1));
|
|
// int fid = Convert.ToInt32(ManTaskReserve.ToString().Substring(1));
|
|
// sql = new StringBuilder(string.Format("SELECT F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4, F_NumParam5, F_NumParam6 FROM T_Monitor_Task WHERE (F_ManageTASKKINDINDEX={0}) AND (F_ManageTaskIndex = {1}) order by F_MonitorIndex asc", mti, fid));
|
|
// dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
// if (dv.Count > 0)
|
|
// {
|
|
// if (dv[0]["F_DeviceIndex"].ToString() == StackdeviceIndex.ToString())
|
|
// {
|
|
// if ((dv[0]["F_DeviceCommandIndex"].ToString() == "2") || (dv[0]["F_DeviceCommandIndex"].ToString() == "4"))//½«È¡£¬È¡»õ
|
|
// {
|
|
// Zcoor = Convert.ToInt32(dv[0]["F_NumParam1"]);
|
|
// Xcoor = Convert.ToInt32(dv[0]["F_NumParam2"]);
|
|
// }
|
|
// else if (dv[0]["F_DeviceCommandIndex"].ToString() == "5")//ËÍ»õ
|
|
// {
|
|
// Zcoor = Convert.ToInt32(dv[0]["F_NumParam4"]);
|
|
// Xcoor = Convert.ToInt32(dv[0]["F_NumParam5"]);
|
|
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
|
|
}
|
|
void GetStackRunReserveX_Zcoor(int StackdeviceIndex, out int Xcoor, out int Zcoor)
|
|
{//20111020
|
|
Xcoor = 0;
|
|
Zcoor = 1; DataView dv = new DataView();
|
|
try
|
|
{
|
|
int ManTaskReserve = ccf.GetManTaskReserve(StackdeviceIndex);
|
|
if (ManTaskReserve > 0)
|
|
{
|
|
int mti = Convert.ToInt32(ManTaskReserve.ToString().Substring(0, 1));
|
|
int fid = Convert.ToInt32(ManTaskReserve.ToString().Substring(1));
|
|
sql = new StringBuilder(string.Format("SELECT F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4, F_NumParam5, F_NumParam6 FROM T_Monitor_Task WHERE (F_ManageTASKKINDINDEX={0}) AND (F_ManageTaskIndex = {1}) order by F_MonitorIndex asc", mti, fid));
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (dv[0]["F_DeviceIndex"].ToString() == StackdeviceIndex.ToString())
|
|
{
|
|
if ((dv[0]["F_DeviceCommandIndex"].ToString() == "2") || (dv[0]["F_DeviceCommandIndex"].ToString() == "4"))//½«È¡£¬È¡»õ
|
|
{
|
|
Zcoor = Convert.ToInt32(dv[0]["F_NumParam1"]);
|
|
Xcoor = Convert.ToInt32(dv[0]["F_NumParam2"]);
|
|
}
|
|
else if (dv[0]["F_DeviceCommandIndex"].ToString() == "5")//ËÍ»õ
|
|
{
|
|
Zcoor = Convert.ToInt32(dv[0]["F_NumParam4"]);
|
|
Xcoor = Convert.ToInt32(dv[0]["F_NumParam5"]);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// ²åÈë±ÜÈÃÖ¸Áî
|
|
/// </summary>
|
|
/// <param name="stackno">±ÜÈöѶâ»ú</param>
|
|
/// <param name="order">Ö¸Áî</param>
|
|
/// <param name="Barcodecoor">±ÜÈõ½´ïµÄÌõÂë×ø±ê</param>
|
|
/// <param name="layerhigh">±ÜÈöѶâ»úµÄ»õÎï²ã¸ß¶È</param>
|
|
void InsertStackMutexOrder(int stackno, int order, int Barcodecoor, int layerhigh)
|
|
{//20111020
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL("SELECT MAX(BarcodeCoor) AS maxcoor, MIN(BarcodeCoor) AS mincoor FROM T_Base_BarcodeCoor").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (Barcodecoor > Convert.ToInt32(dv[0]["maxcoor"]))
|
|
{
|
|
Barcodecoor = Convert.ToInt32(dv[0]["maxcoor"]);
|
|
}
|
|
if (Barcodecoor < Convert.ToInt32(dv[0]["mincoor"]))
|
|
{
|
|
Barcodecoor = Convert.ToInt32(dv[0]["mincoor"]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
if (order == 2 || order == 4)
|
|
{
|
|
if (CStaticClass.GetDevicePhotoelectric(stackno, 0) == 0)//20120110
|
|
{
|
|
order = 2;
|
|
|
|
}
|
|
else
|
|
{
|
|
order = 1;
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
if (CStaticClass.GetDevicePhotoelectric(stackno, 0) == 1)//20120110
|
|
{
|
|
order = 3;
|
|
|
|
}
|
|
else
|
|
{
|
|
order = 1;
|
|
}
|
|
|
|
}
|
|
int zc = 0, xc = 0, yc = 0, zc1 = 0, xc1 = 0, yc1 = 0;
|
|
if (stackno == 35001)
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT TOP 1 ABS(MIN(BarcodeCoor - {0})) AS Expr1, XCoor, ZCoor FROM T_Base_BarcodeCoor where BarcodeCoor<={0} and layerhigh<={1} and (brorder=0 or brorder={2}) GROUP BY XCoor, ZCoor ORDER BY Expr1", Barcodecoor, layerhigh, order)).Tables[0].DefaultView;
|
|
}
|
|
else
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT TOP 1 ABS(MIN(BarcodeCoor - {0})) AS Expr1, XCoor, ZCoor FROM T_Base_BarcodeCoor where BarcodeCoor>={0} and layerhigh<={1} and (brorder=0 or brorder={2}) GROUP BY XCoor, ZCoor ORDER BY Expr1", Barcodecoor, layerhigh, order)).Tables[0].DefaultView;
|
|
|
|
}
|
|
|
|
if (dv.Count > 0)
|
|
{
|
|
|
|
if (order == 2)
|
|
{
|
|
zc = Convert.ToInt32(dv[0]["ZCoor"]);
|
|
xc = Convert.ToInt32(dv[0]["XCoor"]);
|
|
if (xc == 51) xc = 52;//20120110
|
|
if (xc <= 5)
|
|
{
|
|
zc = 2;
|
|
xc = 2;
|
|
}
|
|
yc = 1;
|
|
if (xc == 52) zc = 1;
|
|
}
|
|
else
|
|
{
|
|
zc1 = Convert.ToInt32(dv[0]["ZCoor"]);
|
|
xc1 = Convert.ToInt32(dv[0]["XCoor"]);
|
|
if (xc1 == 51) xc1 = 52;//20120110
|
|
if (xc1 <= 5)
|
|
{
|
|
zc1 = 2;
|
|
xc1 = 2;
|
|
}
|
|
yc1 = 1;
|
|
|
|
if (xc1 == 52) zc1 = 2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (order != 1)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
dv = dbo.ExceSQL(string.Format("select F_MonitorIndex from T_Monitor_Task where F_DeviceIndex={0} and F_TxtParam='brbrbr'", stackno)).Tables[0].DefaultView;
|
|
if (dv.Count <= 0)
|
|
{
|
|
int hidx = ccf.GetTempManageIdx();
|
|
int hmindx = ccf.GetMonitorIndex(hidx, 2);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("insert into T_Monitor_Task(F_MonitorTaskLevel,F_RouteID,F_ManageTaskIndex,F_ManageTaskKindIndex,F_MonitorIndex,").
|
|
Append("F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2,F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6,F_TxtParam,F_AheadDetect) ").
|
|
Append("values(2,").Append(ccf.GetRouteIDsub(stackno)).Append(",").
|
|
Append(hidx).Append(",4,").Append(hmindx).Append(",").Append(stackno).
|
|
Append(",").Append(order).Append(",").Append(zc).Append(",").Append(xc).Append(",").Append(yc).Append(",").Append(zc1).Append(",").Append(xc1).Append(",").Append(yc1).Append(",'brbrbr','-')");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = string.Format("²åÈ뻥³â¶Ñ¶â»ú±ÜÈÃÖ¸Áîʱ£º{0}", ex.StackTrace + ex.Message);
|
|
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
int GetNowDevice(int taskindex)
|
|
{
|
|
DataView dvb = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_NumParam1 FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(taskindex).Append(")");
|
|
dvb = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dvb.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dvb[0]["F_NumParam1"]);
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dvb.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// É豸ָÁî¶ÓÁÐÖÐÊÇ·ñ´æÔÚ¿ÉÒÔ¹ØÁª¶Ñ¶â»úµÄÈ¡»õÃüÁî
|
|
/// </summary>
|
|
/// <param name="Stackdev">¶Ñ¶â»ú</param>
|
|
/// <param name="zxy">È¡»õ»õλ</param>
|
|
/// <param name="Correlzxy">¹ØÁª»õλ</param>
|
|
/// <param name="nottaskindex">´Ë´ÎÉ豸ָÁîË÷Òý</param>
|
|
/// <returns></returns>
|
|
bool IFHaveStackCorrelGetCommand(int Stackdev, string zxy, string Correlzxy, int nottaskindex)
|
|
{
|
|
DataView dv = new DataView();
|
|
char[] cc = new char[1] { '-' };
|
|
string[] zxystr = zxy.Split(cc);
|
|
string[] zxystrCorrl = Correlzxy.Split(cc);
|
|
try
|
|
{
|
|
int laneway = ccf.GetLaneWayNoFromStack(Stackdev);
|
|
int corrdev = 0;
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate WHERE (F_LaneIndex = {0}) AND (F_ZXY = '{1}')", laneway, Correlzxy)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
corrdev = Convert.ToInt32(dv[0]["F_LaneGateDeviceIndex"]);
|
|
}
|
|
|
|
object[] ob = new object[8] { Stackdev, nottaskindex, Convert.ToInt32(zxystr[0]), Convert.ToInt32(zxystr[1]),Convert.ToInt32(zxystr[2]),
|
|
Convert.ToInt32(zxystrCorrl[0]),Convert.ToInt32(zxystrCorrl[1]),Convert.ToInt32(zxystrCorrl[2]) };
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_DeviceIndex = {0}) AND (F_DeviceCommandIndex =4) AND (F_MonitorIndex<>{1}) and (((F_NumParam1 = {2}) AND (F_NumParam2 = {3}) AND (F_NumParam3 = {4})) or ((F_NumParam1 = {5}) AND (F_NumParam2 = {6}) AND (F_NumParam3 = {7})))", ob)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{//20120906²»ÊÇÒѾµÈ´ý¶à²æ¹ØÁªÈÎÎñ
|
|
sql.Remove(0, sql.Length);//ÊäËÍ»úµÈ´ýË«²æÈÎÎñºÅµÈÓڶѶâ»úÈ¡»õTaskIdx
|
|
sql.Append("SELECT F_TaskIndex,F_DeviceIndex,F_Remark FROM T_Base_PLC_Ask WHERE (F_TaskIndex =").Append(Convert.ToInt32(dv[0]["F_MonitorIndex"])).Append(") AND (F_DeviceIndex=").Append(corrdev).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
cc = null;
|
|
zxystrCorrl = null;
|
|
zxystr = null;
|
|
}
|
|
}
|
|
int GetDeviceOrderFromManTaskReserve(int manTaskReserve, int deviceIndex)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
int mti = Convert.ToInt32(manTaskReserve.ToString().Substring(0, 1));
|
|
int fid = Convert.ToInt32(manTaskReserve.ToString().Substring(1));
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_DeviceIndex,F_DeviceCommandIndex FROM T_Monitor_Task WHERE (F_ManageTASKKINDINDEX = {0}) AND (F_ManageTaskIndex = {1}) order by F_MonitorIndex asc", mti, fid)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (deviceIndex == Convert.ToInt32(dv[0]["F_DeviceIndex"]))
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_DeviceCommandIndex"]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
int GetLayerHigh(int Zcoor, int Xcoor)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT LayerHigh FROM T_Base_BarcodeCoor WHERE (ZCoor = {0}) AND (XCoor = {1})", Zcoor, Xcoor)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0][0]);
|
|
|
|
}
|
|
else
|
|
{
|
|
return 3;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
void InsertUpDeviceUP(int updevice, int Mankind, int ManFID, int mindex)
|
|
{
|
|
DataRowView drv = null; DataView dv = new DataView();
|
|
try
|
|
{
|
|
|
|
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_MonitorTaskLevel, F_RouteID, F_TxtParam, F_UseAwayFork,F_PriorMonitor FROM T_Monitor_Task WHERE F_MonitorIndex={0}", mindex)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
mindex = Convert.ToInt32(dv[0]["F_PriorMonitor"]);
|
|
drv = dv[0];
|
|
}
|
|
else
|
|
return;
|
|
StringBuilder ah = new StringBuilder();
|
|
ah.Append("D-").Append(updevice).Append(".7;D").Append(updevice).Append(".0;I").Append(updevice);
|
|
if (DeviceAndOrderExitInMonitor(Mankind, ManFID, updevice, 9, 0) == false)
|
|
{
|
|
#region Éú³ÉÊäËÍ»úÃüÁî
|
|
|
|
|
|
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["F_MonitorTaskLevel"]
|
|
).Append(",").Append(updevice).Append(",").Append(9).Append(",").Append(drv["F_RouteID"]).Append(",").Append(0).Append(",").Append(updevice).Append("," + 0
|
|
).Append(",'").Append(ah).Append("','").Append(drv["F_TxtParam"]).Append("','").Append(drv["F_UseAwayFork"]).Append("')");
|
|
dbo.ExceSQL(sql.ToString());
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = "²åÈë¶¥Éý»úÉÏÉýÖ¸Áîʱ£º" + ex.StackTrace + ex.Message;
|
|
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
drv = null;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Åжϵ÷¶È±íT_Monitor_TaskÊÇ·ñ´æÔÚµ÷¶ÈÈÎÎñµÄÉ豸ºÍÃüÁî
|
|
/// </summary>
|
|
/// <param name="Mankind">µ÷¶ÈÈÎÎñÀàÐÍ</param>
|
|
/// <param name="ManFID">µ÷¶ÈÈÎÎñË÷Òý</param>
|
|
/// <param name="DeviceIndex">É豸ËùÒý</param>
|
|
/// <param name="Order">É豸ÃüÁî</param>
|
|
/// <returns></returns>
|
|
public 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)
|
|
{
|
|
CControlError = "ControlSystem.CControl.DeviceAndOrderExitInMonitor:" + ex.StackTrace + ex.Message;
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// ¶Ñ¶â»úÊÇ·ñ´æÔÚ±ÜÈÃÖ¸ÁîÕýÔÚÔËÐÐ
|
|
/// </summary>
|
|
/// <param name="DeviceIndex"></param>
|
|
/// <returns></returns>
|
|
bool DeviceHandTaskIfRun(int DeviceIndex)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Monitor_Task where F_ManageTASKKINDINDEX=4 and F_DeviceIndex={0} and F_Status>0", DeviceIndex)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// ¶Ñ¶â»úÊÇ·ñ´æÔÚ±ÜÈÃÖ¸ÁîµÈ´ýÔËÐÐ
|
|
/// </summary>
|
|
/// <param name="DeviceIndex"></param>
|
|
/// <returns></returns>
|
|
bool DeviceHandTaskIfWaitRun(int DeviceIndex)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Monitor_Task where F_ManageTASKKINDINDEX=4 and F_DeviceIndex={0} and F_Status=0", DeviceIndex)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
|
|
}
|
|
bool StackIfExitTask(int stackno)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Monitor_Task where F_DeviceIndex={0}", stackno)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
|
|
void GetSpecialStackNo(int virStack, int startZ, int startX, int endZ, int endX, out int stackno, out bool IfCombinedWork)
|
|
{
|
|
stackno = 0; IfCombinedWork = false;
|
|
int Getdevice = 0, Sendevice = 0;
|
|
char[] fcc = new char[1] { ';' };
|
|
char[] dcc = new char[1] { ',' };
|
|
char[] hcc = new char[1] { '-' };
|
|
DataView dv = new DataView();
|
|
string[] zxys; string[] zx_x; string[] x_x;
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT T_Base_StackInfo.F_StackIndex, T_Base_StackInfo.F_SpecialZXArea,T_Base_StackInfo.F_PRIZXArea FROM T_Base_StackInfo WHERE T_Base_StackInfo.F_Mutex IS NOT NULL and T_Base_StackInfo.F_VirtualStack={0}", virStack)).Tables[0].DefaultView;
|
|
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
zxys = dv[i]["F_SpecialZXArea"].ToString().Split(fcc);//1,0-2;2,0-5
|
|
|
|
for (int d = 0; d < zxys.GetLength(0); d++)
|
|
{
|
|
zx_x = zxys[d].Split(dcc);
|
|
if (zx_x.GetLength(0) > 1)
|
|
{
|
|
for (int h = 1; h < zx_x.GetLength(0); h++)
|
|
{
|
|
x_x = zx_x[h].Split(hcc);
|
|
|
|
if (x_x.GetLength(0) > 1)
|
|
{
|
|
if ((Convert.ToInt32(zx_x[0]) == startZ) && (startX >= Convert.ToInt32(x_x[0])) && (startX <= Convert.ToInt32(x_x[1])))
|
|
{
|
|
Getdevice = Convert.ToInt32(dv[i]["F_StackIndex"]);
|
|
}
|
|
if ((Convert.ToInt32(zx_x[0]) == endZ) && (endX >= Convert.ToInt32(x_x[0])) && (endX <= Convert.ToInt32(x_x[1])))
|
|
{
|
|
Sendevice = Convert.ToInt32(dv[i]["F_StackIndex"]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stackno = Getdevice;
|
|
if (Getdevice != Sendevice)
|
|
{
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(Getdevice);
|
|
if (Sendevice == devinfo.VirtualStack)
|
|
{
|
|
IfCombinedWork = true;
|
|
}
|
|
else
|
|
{
|
|
IfCombinedWork = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
IfCombinedWork = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = "·ÖÅä¶Ñ¶â»úºÅGetSpecialStackNo:" + ex.StackTrace + ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
int GetPRIStackNo(int virStack, int startZ, int startX, int endZ, int endX)
|
|
{
|
|
int Getdevice = 0;
|
|
char[] fcc = new char[1] { ';' };
|
|
char[] dcc = new char[1] { ',' };
|
|
char[] hcc = new char[1] { '-' };
|
|
DataView dv = new DataView();
|
|
|
|
string[] zxys; string[] zx_x; string[] x_x;
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL(string.Format("SELECT T_Base_StackInfo.F_StackIndex, T_Base_StackInfo.F_SpecialZXArea,T_Base_StackInfo.F_PRIZXArea FROM T_Base_StackInfo WHERE T_Base_StackInfo.F_Mutex IS NOT NULL and T_Base_StackInfo.F_VirtualStack={0}", virStack)).Tables[0].DefaultView;
|
|
|
|
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
zxys = dv[i]["F_PRIZXArea"].ToString().Split(fcc);//1,0-2;2,0-5
|
|
|
|
for (int d = 0; d < zxys.GetLength(0); d++)
|
|
{
|
|
zx_x = zxys[d].Split(dcc);
|
|
if (zx_x.GetLength(0) > 1)
|
|
{
|
|
for (int h = 1; h < zx_x.GetLength(0); h++)
|
|
{
|
|
x_x = zx_x[h].Split(hcc);
|
|
|
|
if (x_x.GetLength(0) > 1)
|
|
{
|
|
if ((Convert.ToInt32(zx_x[0]) == startZ) && (startX >= Convert.ToInt32(x_x[0])) && (startX <= Convert.ToInt32(x_x[1])))
|
|
{
|
|
Getdevice = Convert.ToInt32(dv[i]["F_StackIndex"]);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Getdevice;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = "·ÖÅä¶Ñ¶â»úºÅGetPRIStackNo:" + ex.StackTrace + ex.Message;
|
|
return Getdevice;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// »ñÈ¡¿É¹ØÁªµÄÈÎÎñ½øÐÐÅä¶à²æ¹ØÁª
|
|
/// </summary>
|
|
/// <param name="DevLanewayIOInfo">ÏïµÀ³öÈë¿ÚÐÅÏ¢</param>
|
|
/// <param name="TaskIdx">É豸ָÁîË÷Òý</param>
|
|
/// <param name="CONTROLTASKTYPE">¿ØÖÆÈÎÎñÀàÐÍ</param>
|
|
/// <param name="mti">¿ØÖÆÈÎÎñÀà±ð</param>
|
|
/// <param name="fid">¿ØÖÆÈÎÎñ±àºÅ</param>
|
|
/// <param name="dtime">µ±Ç°Ê±¼ä</param>
|
|
/// <returns></returns>
|
|
bool GetCorrManageTask(string[] DevLanewayIOInfo, int TaskIdx, int CONTROLTASKTYPE, int mti, int fid, string dtime, out bool IfCorrTaskEnd)
|
|
{
|
|
IfCorrTaskEnd = false;
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
sql.Remove(0, sql.Length);//ÊäËÍ»úµÈ´ýË«²æÈÎÎñºÅµÈÓڶѶâ»úÈ¡»õTaskIdx
|
|
sql.Append("SELECT F_TaskIndex,F_DeviceIndex,F_Remark FROM T_Base_PLC_Ask WHERE (F_TaskIndex =").Append(Convert.ToInt32(TaskIdx)).Append(") AND (F_Remark <> '') AND (F_DeviceIndex=").Append(DevLanewayIOInfo[0]).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
#region ÓÐÈÎÎñµÈ´ý¹ØÁªÈÎÎñ
|
|
|
|
string zxy = DevLanewayIOInfo[9];
|
|
int waitdevice = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
|
//DevLanewayIOInfo[8]°üº¬¶à¸ö¹ØÁªÉ豸ÐÅÏ¢ÖðÒ»¼ì²é20120906
|
|
char[] cc = new char[1] { ';' };
|
|
string[] CorrStations = DevLanewayIOInfo[8].Split(cc);
|
|
foreach (string cs in CorrStations)
|
|
{
|
|
DevLanewayIOInfo = ccf.GetLanewayDeviceInfoFromStackDev(devinfo.DeviceIndex, Convert.ToInt32(cs));//¹ØÁªÕ¾Ì¨µÄÐÅÏ¢
|
|
string Correlzxy = DevLanewayIOInfo[9];
|
|
DateTime dtq = Convert.ToDateTime(dv[0]["F_Remark"]).AddSeconds(Convert.ToInt32(CStaticClass.DoubleForkWaitTime));
|
|
if ((GetIOControlStatus(TaskIdx) != Model.CGeneralFunction.TASKSINGLEFORKRUN) && (dtq > DateTime.Now))
|
|
{
|
|
#region û³¬Ê±,²»Êǵ¥²æÔËÐÐ
|
|
|
|
//20111231û³¬Ê±,²»Êǵ¥²æÔËÐÐ
|
|
//²éÕÒ±¾µØ¹ÜÀíÈÎÎñ×ö¶à²æ¹ØÁªÅä¶Ô£¬¹ØÁªÈÎÎñ·ÖÅä»õ²æ
|
|
int mfid = GetEnableDoubleForkManageTask(CONTROLTASKTYPE, devinfo.DeviceIndex, int.Parse(DevLanewayIOInfo[0]), fid);
|
|
if (mfid > 0)
|
|
{
|
|
#region Ë«²æÍ¬ÎªÇ°¼«ÏÞºóÕߺó¼«ÏÞ²»¹ØÁª£¬µ¥¶ÀÖ´ÐÐ
|
|
if ((IfInSameLimitX(fid, mfid, mti) == true) && (mti == 1))
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(fid).Append(")");
|
|
dboM.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(mfid).Append(")");
|
|
dboM.ExecuteSql(sql.ToString());
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("µ¥²æÖ´ÐÐÔÒò", TaskIdx.ToString(), devinfo.DeviceIndex.ToString(), "Ë«²æÍ¬ÎªÇ°¼«ÏÞºóÕߺó¼«ÏÞ²»¹ØÁª£¬µ¥¶ÀÖ´ÐÐ");
|
|
IfCorrTaskEnd = true;
|
|
return true;
|
|
}
|
|
#endregion
|
|
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(fid).Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(fid);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=").Append(fid).Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(mfid);
|
|
dbo.ExecuteSql(sql.ToString());
|
|
//ÅжÏÊÇ·ñΪ1²æµÄ¹ØÁªÈÎÎñ:ÊÇ£¬Å䲿½áÊø
|
|
if (ccf.GetManageTaskStackFork(mti, mfid) == "1")
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Base_PLC_Ask set F_Remark='' where (F_TaskIndex=").Append(TaskIdx).Append(")");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
IfCorrTaskEnd = true;
|
|
}
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
//20110505
|
|
AheadDetectUnallow.Append(devinfo.DeviceIndex.ToString() + "Ë«²æ¶Ñ¶â»úµÈ´ý¶à²æ¹ØÁªÈ¡»õÈÎÎñ£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, TaskIdx);
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region 20111230µ¥²æÖ´Ðм«ÏÞ»õλÐèÒªµ¹»õ²æ
|
|
#region ¶Ñ¶â»úÔÚ¶¥Éý»úÈ¡µ¥²æÈÎÎñ£¬ÑéÖ¤ÊÇ·ñÐèÒª»»»õ²æ
|
|
string ChangeForkCell = ccf.IfLimitCellChangeFork(TaskIdx, devinfo.DeviceIndex);
|
|
|
|
if (ChangeForkCell != "-")//Ö÷ÈÎÎñÐèÒªµ¹»»»õ²æ
|
|
{
|
|
ccf.ChangeEndCellCode(TaskIdx, ChangeForkCell, devinfo.DeviceIndex);
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Base_PLC_Ask set F_TaskIndex=0,F_Remark='' where (F_DeviceIndex=").Append(waitdevice).Append(")");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("µ¥²æÖ´ÐÐÔÒò", TaskIdx.ToString(), devinfo.DeviceIndex.ToString(), "Ö÷ÈÎÎñÐèÒªµ¹»»»õ²æ");
|
|
IfCorrTaskEnd = true;
|
|
return true;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
if ((IFHaveStackCorrelGetCommand(devinfo.DeviceIndex, zxy, Correlzxy, TaskIdx) == true) && (GetIOControlStatus(TaskIdx) != Model.CGeneralFunction.TASKSINGLEFORKRUN))//20101124
|
|
{//¶ÓÁÐÖÐÓпÉÒÔ¹ØÁªµÄÈÎÎñ£¬ÖØÐ¼ÆÊ±
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Base_PLC_Ask set F_Remark='").Append(dtime).Append("' where (F_DeviceIndex=").Append(waitdevice).Append(")");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
//20110505
|
|
AheadDetectUnallow.Append(devinfo.DeviceIndex.ToString() + "Ë«²æ¶Ñ¶â»úÔÚË«²æ¶ÔµÈվ̨ȡ»õ" + "£¬µÈ´ý¶à²æ¹ØÁªÈÎÎñ£¡");
|
|
UpdateAheadDetectUnallow(AheadDetectUnallow, TaskIdx);
|
|
return false;
|
|
}
|
|
else
|
|
{//³¬Ê±»òÕß¹ÜÀíÇ¿ÖÆÖ´Ðе¥²æÈÎÎñ
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("update T_Base_PLC_Ask set F_TaskIndex=0,F_Remark='' where (F_DeviceIndex=").Append(waitdevice).Append(")");
|
|
dbo.ExecuteSql(sql.ToString());
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("µ¥²æÖ´ÐÐÔÒò", TaskIdx.ToString(), devinfo.DeviceIndex.ToString(), "³¬Ê±»òÕß¹ÜÀíÇ¿ÖÆÖ´Ðе¥²æÈÎÎñ");
|
|
IfCorrTaskEnd = true;
|
|
return true;
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CControlError = "»ñÈ¡¶Ñ¶â»ú¹ØÁªÅ䲿GetCorrManageTask:" + ex.StackTrace + ex.Message;
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
public bool BuildAutoTask(Model.AutoTask Autotask, out string Errtext)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
string Sql, _tasktype;
|
|
if ((Autotask._enableStartCell == true) && (ccf.GetDeviceKindIdx(Convert.ToInt32(Autotask._startDevice)) == 10))
|
|
{
|
|
|
|
|
|
if (dbo.Exists("SELECT FID FROM ST_CELL where FLaneWay=" + Autotask._startDevice + " and FCELLCODE='" + Autotask._startCell + "'") == false)
|
|
{
|
|
Errtext = "ÆðʼλÖÃºÍÆðʼ»õλ±àÂëÔÚÊý¾Ý¿âÖÐûÓмǼ£¡";
|
|
return false;
|
|
}
|
|
|
|
}
|
|
if ((Autotask._enableEndCell == true) && (ccf.GetDeviceKindIdx(Convert.ToInt32(Autotask._endDevice)) == 10))
|
|
{
|
|
|
|
if (dbo.Exists("SELECT FID FROM ST_CELL where FLaneWay=" + Autotask._endDevice + " and FCELLCODE='" + Autotask._endCell + "'") == false)
|
|
{
|
|
Errtext = "ÖÕµãλÖúÍÖÕµã»õλ±àÂëÔÚÊý¾Ý¿âÖÐûÓмǼ£¡";
|
|
return false;
|
|
}
|
|
}
|
|
#region AGVͨµÀ
|
|
|
|
if ((Autotask._enableStartCell == true) && (ccf.GetDeviceKindIdx(Convert.ToInt32(Autotask._startDevice)) == 11))
|
|
{
|
|
|
|
if (dbo.Exists("SELECT F_AGVGateDeviceIndex FROM T_Base_AGV_Gate WHERE (F_ChannelsIndex = " + Autotask._startDevice + ") AND (F_AGVGateDeviceIndex = " + Autotask._startCell + ")") == false)
|
|
{
|
|
Errtext = "AGVÕ¾µãÉ豸ÔÚÊý¾Ý¿âÖÐûÓмǼ£¡";
|
|
return false;
|
|
}
|
|
|
|
}
|
|
if ((Autotask._enableEndCell == true) && (ccf.GetDeviceKindIdx(Convert.ToInt32(Autotask._endDevice)) == 11))
|
|
{
|
|
|
|
if (dbo.Exists("SELECT F_AGVGateDeviceIndex FROM T_Base_AGV_Gate WHERE (F_ChannelsIndex = " + Autotask._endDevice + ") AND (F_AGVGateDeviceIndex = " + Autotask._endCell + ")") == false)
|
|
{
|
|
Errtext = "AGVÕ¾µãÉ豸ÔÚÊý¾Ý¿âÖÐûÓмǼ£¡";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
Sql = "SELECT F_RouteID FROM T_Base_Route WHERE (F_StartDevice = " + Autotask._startDevice + ") AND (F_EndDevice = " + Autotask._endDevice + ")";
|
|
dv = dbo.ExceSQL(Sql).Tables[0].DefaultView;
|
|
if (dv.Count <= 0)
|
|
{
|
|
Errtext = "ÆðʼλÖúͽáÊøÎ»Öò»ÔÚÓÐЧ·¾¶µÄ·¶Î§ÄÚ£¡";
|
|
return false;
|
|
}
|
|
|
|
|
|
_tasktype = Autotask._controlType.ToString();
|
|
string FSTARTCELL = Autotask._startCell, FENDCELL = Autotask._endCell, UseAwayFork = "-";
|
|
int FSTARTDEVICE = Convert.ToInt32(Autotask._startDevice); int FENDDEVICE = Convert.ToInt32(Autotask._endDevice);
|
|
Model.MDevice devinfo = Model.CGetInfo.GetDeviceInfo(FSTARTDEVICE);
|
|
int flaneway = 0;
|
|
int stackno = 0;
|
|
|
|
//dbo.TransBegin();
|
|
try
|
|
{
|
|
if (devinfo != null)
|
|
{
|
|
int uc = 0;
|
|
if (int.TryParse(FSTARTCELL, out uc) == true)
|
|
{
|
|
UseAwayFork = dbo.GetSingle("SELECT F_UseAwayFork FROM T_Base_AGV_Gate WHERE ( F_AGVGateDeviceIndex= " + uc + ")").ToString();
|
|
|
|
}
|
|
if ((UseAwayFork == "-") || (UseAwayFork == null))
|
|
{
|
|
UseAwayFork = devinfo.DoubleFork;
|
|
|
|
}
|
|
|
|
}
|
|
if ((UseAwayFork == "-") || (UseAwayFork == null))
|
|
{//20110412
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(FENDDEVICE);
|
|
if (devinfo != null)
|
|
{
|
|
int uc = 0;
|
|
if (int.TryParse(FENDCELL, out uc) == true)
|
|
{
|
|
UseAwayFork = dbo.GetSingle("SELECT F_UseAwayFork FROM T_Base_AGV_Gate WHERE ( F_AGVGateDeviceIndex= " + uc + ")").ToString();
|
|
}
|
|
|
|
if ((UseAwayFork == "-") || (UseAwayFork == null))
|
|
{
|
|
UseAwayFork = devinfo.DoubleFork;
|
|
}
|
|
|
|
}
|
|
}
|
|
StringBuilder sbs = new StringBuilder(); int FSTARTUCODE = 0; int FENDUCODE = 0;
|
|
sbs.Clear();
|
|
sbs.Append("SELECT FUCODE,FUCONVEYOR FROM ST_CELL where FCELLCODE='").Append(FSTARTCELL)
|
|
.Append("' and FLaneWay=").Append(FSTARTDEVICE).Append(" and FUCODE>0");
|
|
dv = dbo.ExceSQL(sbs.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
FSTARTUCODE = Convert.ToInt32(dv[0][0]);
|
|
FSTARTCELL = dv[0][1].ToString();
|
|
}
|
|
sbs.Clear();
|
|
sbs.Append("SELECT FUCODE,FUCONVEYOR FROM ST_CELL where FCELLCODE='").Append(FENDCELL)
|
|
.Append("' and FLaneWay=").Append(FENDDEVICE).Append(" and FUCODE>0");
|
|
dv = dbo.ExceSQL(sbs.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
FENDUCODE = Convert.ToInt32(dv[0][0]);
|
|
FENDCELL = dv[0][1].ToString();
|
|
}
|
|
string dtime = DateTime.Now.ToString("u");//20101028
|
|
dtime = dtime.Substring(0, dtime.Length - 1);//20101028
|
|
int AutoManageIdx = ccf.GetTempManageIdx();
|
|
//if (Convert.ToInt32(dbo.GetSingle("select count(0) from T_DisPallet where f_enddevice=" + FENDDEVICE)) > 0)
|
|
//{
|
|
// AutoManageIdx = Convert.ToInt32(dbo.GetSingle("select fid from t_manage_task where FPALLETBARCODE='" + Autotask._palletBarcode + "'"));
|
|
//}
|
|
|
|
//int AutoManageIdx = ccf.GetTempManageIdx();
|
|
//²åÈëÁÙʱµ÷¶ÈÈÎÎñT_Manage_Task(¼à¿ØÏµĵ÷¶ÈÈÎÎñ)£º
|
|
Sql = "insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL," +
|
|
"FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FSTARTUCODE,FENDUCODE,WORK_MODE) " +
|
|
"values(" + AutoManageIdx + ",'" + Autotask._palletBarcode + "','" + _tasktype + "',1,'" + ccf.GetWarehouseIndex(FSTARTDEVICE, FSTARTCELL) + "','" + FSTARTDEVICE + "','" + FSTARTCELL + "','" + ccf.GetWarehouseIndex(FENDDEVICE, FENDCELL) + "','"
|
|
+ FENDDEVICE + "','" + FENDCELL + "'," + flaneway + "," + stackno + ",'" + UseAwayFork + "','" + dtime + "'," + FSTARTUCODE + "," + FENDUCODE + "," + 0 + ")";//20101028
|
|
dbo.ExecuteSql(Sql);
|
|
//֪ͨ¿Í»§¶Ë¸üнçÃæ
|
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
|
OnDataChange("BuildAutoTask", cea);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Errtext = ex.StackTrace + ex.Message;
|
|
return false;
|
|
}
|
|
Errtext = string.Empty;
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
Errtext = ex.StackTrace + ex.Message;
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
public void FindStackPallet(int StartDevice, string Batch, out int Arrow)
|
|
{
|
|
Arrow = 0;
|
|
DataView ArrowDevice = dbo.ExceSQL("select T_STACKPALLET.*,F_LockedState from T_STACKPALLET,T_Base_Device where F_ENDDEVICE=T_Base_Device.F_DeviceIndex and F_LockedState<>-1 and T_STACKPALLET.F_STARTDEVICE=" + StartDevice + "order by f_GoAway asc").Tables[0].DefaultView;
|
|
int maxgoaway = Convert.ToInt32(dbo.GetSingle("select max(f_goaway) from T_STACKPALLET,T_Base_Device where F_ENDDEVICE=T_Base_Device.F_DeviceIndex and F_LockedState<>-1 and T_STACKPALLET.F_STARTDEVICE=" + StartDevice));
|
|
if (maxgoaway >= ArrowDevice.Count && maxgoaway != 0)
|
|
{
|
|
dbo.ExceSQL("update T_STACKPALLET set f_goaway=0 where F_STARTDEVICE=" + StartDevice);
|
|
ArrowDevice = dbo.ExceSQL("select T_STACKPALLET.*,F_LockedState from T_STACKPALLET,T_Base_Device where F_ENDDEVICE=T_Base_Device.F_DeviceIndex and F_LockedState<>-1 and T_STACKPALLET.F_STARTDEVICE=" + StartDevice + "order by f_GoAway asc").Tables[0].DefaultView;
|
|
}
|
|
if (ArrowDevice.Count > 0)
|
|
{
|
|
for (int i = 0; i < ArrowDevice.Count; i++)
|
|
{
|
|
if (Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where BATTERY_BATCH='" + Batch + "' and fenddevice=" + ArrowDevice[i]["F_ENDDEVICE"])) > 0)//ÏÈÕÒ·ÉÏÊÇ·ñÓÐͬÅú´ÎµÄ
|
|
{
|
|
Arrow = Convert.ToInt32(ArrowDevice[i]["F_ENDDEVICE"]);
|
|
return;
|
|
}
|
|
}
|
|
for (int i = 0; i < ArrowDevice.Count; i++)
|
|
{
|
|
if (Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where fenddevice=" + ArrowDevice[i]["F_ENDDEVICE"])) == 0)//·ÉÏûÓÐÇÒµ±Ç°µþÅÌ»úÅú´ÎÒ»ÖÂ
|
|
{
|
|
string nowbatch = dbo.GetSingle("select F_BATCH from T_STACKPALLET where F_ENDDEVICE=" + ArrowDevice[i]["F_ENDDEVICE"]).ToString();
|
|
if (nowbatch == Batch && nowbatch != "0")
|
|
{
|
|
Arrow = Convert.ToInt32(ArrowDevice[i]["F_ENDDEVICE"]);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
for (int i = 0; i < ArrowDevice.Count; i++)
|
|
{
|
|
if (Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where fenddevice=" + ArrowDevice[i]["F_ENDDEVICE"])) == 0)//·ÉÏûÓÐÇÒûÓÐÅú´ÎµÄ
|
|
{
|
|
string nowbatch = dbo.GetSingle("select F_BATCH from T_STACKPALLET where F_ENDDEVICE=" + ArrowDevice[i]["F_ENDDEVICE"]).ToString();
|
|
if (nowbatch == "0")
|
|
{
|
|
Arrow = Convert.ToInt32(ArrowDevice[i]["F_ENDDEVICE"]);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
for (int i = 0; i < ArrowDevice.Count; i++)
|
|
{
|
|
if (Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task where fenddevice=" + ArrowDevice[i]["F_ENDDEVICE"])) == 0)//·ÉÏûÓеÄ
|
|
{
|
|
if (ArrowDevice[i]["f_goaway"].ToString() == "0")
|
|
{
|
|
Arrow = Convert.ToInt32(ArrowDevice[i]["F_ENDDEVICE"]);
|
|
dbo.ExceSQL("update T_STACKPALLET set f_goaway=" + (maxgoaway + 1) + " where F_ENDDEVICE=" + ArrowDevice[i]["F_ENDDEVICE"]);
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|