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.
3306 lines
175 KiB
3306 lines
175 KiB
3 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
using System.Data;
|
||
|
using System.Resources;
|
||
|
using CommonLib;
|
||
|
using DBFactory;
|
||
|
using ICommLayer;
|
||
|
using CommLayerFactory;
|
||
|
using System.Globalization;
|
||
|
using System.Net;
|
||
|
namespace WcfControlMonitorLib
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu
|
||
|
/// �����豸״̬��
|
||
|
///
|
||
|
/// ��Ҫ���Ĺ�����
|
||
|
/// 1.��λ������λ�������豸��������״̬��Ϣ������ִ��״̬���߱������豸��������·����F_SerialNumber��=��ǰֵ��
|
||
|
/// 2.��������������λ������λ������������Ϣ���������룬����һ�Ź����룩
|
||
|
/// 3.��������������λ������λ�������ֳ����ƴ����������źţ�1-�ط���ǰ�豸ָ��
|
||
|
/// 2-�����ĵ�ǰ�豸��ִ��������Ŀ��λ��
|
||
|
/// 4.���ٻ������е���λ�ã���������������ִ��ͬһ������������ȡ��̽����Ϊ��ǰλ�ã�
|
||
|
/// �����ж��Ƿ�������ǰ��������
|
||
|
/// 5.��ȡ�������������Ȳ����жϣ�����·�����ȣ�
|
||
|
/// ��������Я�����⣬��������Я��������
|
||
|
/// 6.�����Ŵ��ݵ���ǰ�豸ʱ���ѱ�·����ǰһ�豸��������������
|
||
|
/// ͬʱ�ѵ�ǰ�豸��������
|
||
|
/// 7.�����ݹ��ϵ㵥������������·���Ƿ����õķ����Լ����������з���
|
||
|
/// 8.�����������������Զ���������
|
||
|
/// 9.������ʾ�豸״̬
|
||
|
/// </summary>
|
||
|
public class CGetState
|
||
|
{
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
char[] dd = new char[1] { '.' };//20101124
|
||
|
//string[] DS;//20101124
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
Model.MError errs;
|
||
|
Model.MDevice devinfo;
|
||
|
ISendDeviceOrder sdo;
|
||
|
StringBuilder[] wv = { new StringBuilder("2") };
|
||
|
StringBuilder[] witemnames = { new StringBuilder("") };
|
||
|
IGetDeviceState gds;
|
||
|
CCommonFunction ccf = new CCommonFunction();
|
||
|
DBOperator dbo = CStaticClass.dbo;
|
||
|
DBOperator dboM =CStaticClass.dboM;
|
||
|
//20100108
|
||
|
CControl ccl = new CControl();
|
||
|
string _CGetStateError = "";//���ص���������˵��
|
||
|
public string CGetStateError
|
||
|
{
|
||
|
get { return _CGetStateError; }
|
||
|
set { _CGetStateError = value;
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", _CGetStateError);
|
||
|
OnRefreshMonitor(rmea);
|
||
|
}
|
||
|
}
|
||
|
public int[] _States;
|
||
|
int _fid;
|
||
|
int _mti;
|
||
|
//int _relativeFID;
|
||
|
//int _iotype=0;
|
||
|
//int _endnode=0;
|
||
|
/// <summary>
|
||
|
/// ������������ִ���豸��״̬
|
||
|
/// </summary>
|
||
|
public CGetState()
|
||
|
{
|
||
|
dbo.Open();
|
||
|
if (dboM.Open() == false)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", "���ӹ������ݿ�ʧ�ܣ�����");
|
||
|
OnRefreshMonitor(rmea);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���÷�����Ϣ
|
||
|
///�����������豸��"����"ʱ ɾ���豸ָ�� , �����豸��ռ��״̬F_LockedState=0��
|
||
|
///·����ϸ��F_LockedDeviceIndex�������ж�Ӧ�豸��������;
|
||
|
///
|
||
|
///�ж�������һ���豸ָ����? ��,��д��������IO_Control��FSTATUS=2��"��������";
|
||
|
/// T_Manage_Task������ִ��״̬FSTATUS=2 ��
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public void GetDeviceState()
|
||
|
{
|
||
|
DataView dv=new DataView();
|
||
|
|
||
|
DataView dvm = new DataView();
|
||
|
|
||
|
DataView dvmo = new DataView();
|
||
|
|
||
|
DataView dd = new DataView();
|
||
|
try
|
||
|
{
|
||
|
|
||
|
int devKind;
|
||
|
|
||
|
int DeviceIdx;
|
||
|
int TaskIdx = 0;
|
||
|
|
||
|
//20100617���Ӻ������������豸,����30
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex,F_DeviceKindIndex,F_MaxSendCount,F_SendInterval FROM T_Base_Device WHERE (F_DeviceKindIndex = 1) OR (F_DeviceKindIndex = 2) OR (F_DeviceKindIndex = 4) OR (F_DeviceKindIndex = 7) OR (F_DeviceKindIndex = 6) OR (F_DeviceKindIndex = 30)");
|
||
|
dd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int j = 0; j < dd.Count; j++)
|
||
|
{
|
||
|
|
||
|
DeviceIdx = Convert.ToInt32(dd[j]["F_DeviceIndex"]);
|
||
|
devKind = Convert.ToInt32(dd[j]["F_DeviceKindIndex"]);
|
||
|
//20100609
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
|
||
|
//20091107
|
||
|
#region ���ͺ��涨ʱ����û����ʼ���߶�ȡ���ݳɹ���Ҫ���г�ʱ�ط����ط�����ʱ����
|
||
|
if (devKind == 6) //�Ӽ��̳�ֻ��AGV��Ҫ���·���
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_MonitorIndex,F_DeviceIndex,F_SendCount,F_StartTime,F_Status,F_AgvNo from T_Monitor_Task where F_DeviceIndex=").Append(DeviceIdx).Append(" and f_status=1 and F_SendFlag='1'");
|
||
|
dvmo = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//20100905ֻ�ط�������
|
||
|
if (dvmo.Count > 0)
|
||
|
{//20110510
|
||
|
TaskIdx = Convert.ToInt32(dvmo[0]["F_MonitorIndex"]);
|
||
|
int scount = Convert.ToInt32(dvmo[0]["F_SendCount"]);
|
||
|
scount++;
|
||
|
if (scount > Convert.ToInt32(dd[j]["F_MaxSendCount"]))
|
||
|
{
|
||
|
//���ʹ������ޱ���
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status=999 where F_Status<>999 and F_MonitorIndex=").Append(TaskIdx);//20110505
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//DateTime.Now.AddMilliseconds
|
||
|
if (dvmo[0]["F_StartTime"].ToString() != "-")
|
||
|
{
|
||
|
if (Convert.ToDateTime(dvmo[0]["F_StartTime"].ToString().Substring(0, 19), CultureInfo.CurrentCulture).AddMilliseconds(Convert.ToDouble(dd[j]["F_SendInterval"])) <= DateTime.Now)
|
||
|
{
|
||
|
if (devKind == 2)
|
||
|
{
|
||
|
//20110510���ͻ���
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(0, 0, 0, DeviceIdx, 0);
|
||
|
|
||
|
}
|
||
|
if (dvmo[0]["F_AgvNo"] == DBNull.Value)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=").Append(DeviceIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_SendCount=").Append(scount).Append(",F_Status=0 where F_MonitorIndex=").Append(TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("GetDeviceState", "��ʱ�ط�", DeviceIdx.ToString(), "�豸ָ��������" + TaskIdx.ToString() + "���ͺ���һֱû�б���ִ�л������ɣ����·������");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ������
|
||
|
//if (devinfo.NeedOptimize.ToString() == "1" )
|
||
|
//{//���豸��Ҫ�Ż����ȣ�ֱ�ӵ�����T_Monitor_Task_Child�����豸״̬
|
||
|
// sqlNO = "SELECT F_MonitorIndex, F_DeviceIndex, F_Status FROM T_Monitor_Task_Child WHERE (F_Status = 1) AND (F_MonitorIndex = " + TaskIdx + ")";
|
||
|
// dvNO = dbo.ExceSQL(sqlNO).Tables[0].DefaultView ;
|
||
|
// if (dvNO.Count > 0)
|
||
|
// {
|
||
|
// DeviceIdx = Convert.ToInt32(dvNO[0]["F_DeviceIndex"]);
|
||
|
// GetKindDeviceState(TaskIdx, DeviceIdx,Convert.ToInt32( dv[i]["F_RouteID"]));
|
||
|
// continue;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// continue;
|
||
|
// }
|
||
|
|
||
|
//}
|
||
|
#endregion
|
||
|
//AGV //20100609
|
||
|
if ((dd[j]["F_DeviceKindIndex"].ToString() == "6") || (devinfo.SerialPort > 0)) continue;
|
||
|
//����ɨ���DZȶ�����ֵ;
|
||
|
if (dd[j]["F_DeviceKindIndex"].ToString() == "7")
|
||
|
{
|
||
|
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Monitor_Task where (F_DeviceIndex=").Append(DeviceIdx).Append(") and F_Status>=1");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
TaskIdx = Convert.ToInt32(dv[0]["F_MonitorIndex"]);
|
||
|
int FID = Convert.ToInt32(dv[0]["F_ManageTaskIndex"]);
|
||
|
int Taskind = Convert.ToInt32(dv[0]["F_ManageTASKKINDINDEX"]);
|
||
|
//string oldDevice = "1201";
|
||
|
//string oldCell = "-";
|
||
|
//int cno = 0;
|
||
|
//string cCell = "-";
|
||
|
|
||
|
#region �����ȶԴ���
|
||
|
// //gds = CommModeCreate.CreateGetDeviceState(DeviceIdx);
|
||
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
// witemnames[0] = "DB2,byte" + Convert.ToString((devinfo.Dbw2Address + 0));
|
||
|
// string gdata = CStaticClass.GetStringData(DeviceIdx);
|
||
|
// if (dv[0]["F_DeviceCommandIndex"].ToString() == "1")//�����ȶ�;
|
||
|
// {
|
||
|
// #region �����ȶ�
|
||
|
|
||
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "CGetDeviceState", DeviceIdx.ToString(), gdata);
|
||
|
// wv[0] = "2";
|
||
|
// sdo.WriteDBData(witemnames, wv);
|
||
|
// //������������gdata=="0000000000"���е���̨�������������͵�ԭ��λ
|
||
|
// if ((gdata == dv[0]["F_TxtParam"].ToString().ToUpper()) || (gdata == "\0\0\0\0\0\0\0\0\0\0"))
|
||
|
// {
|
||
|
// ActionComplete(DeviceIdx, TaskIdx,1);
|
||
|
// //ˢ�¼���������ʾ
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// if (FrmControlMonitor.FormInstance.GetObjectText("tsStatus").IndexOf("�豸����:" + DeviceIdx + ",�����ȶԴ����Ϸ���ʱ�䣺" + DateTime.Now.ToString("u")) < 0)
|
||
|
// {
|
||
|
// FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "�豸����:" + DeviceIdx + ",�����ȶԴ����Ϸ���ʱ�䣺" + DateTime.Now.ToString("u"), true);
|
||
|
|
||
|
// }
|
||
|
// ActionError(DeviceIdx, TaskIdx, 30);
|
||
|
// dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_LockedState=" + TaskIdx);
|
||
|
// //�ĵ��˹�������������1201������ס������������FID���ɵ�ǰλ�õ�1201,ͬʱ�ϱ�����ϵͳ�����룬�쳣���ɣ����ع�����FERRORCODE=990
|
||
|
//
|
||
|
// if (DeviceIdx == 1603)//���̻ؿ�
|
||
|
// {
|
||
|
// //����ɨ��ֱ�ӻؿ�
|
||
|
// ActionComplete(DeviceIdx, TaskIdx, 1);
|
||
|
// continue;
|
||
|
// }
|
||
|
// else if (DeviceIdx == 1604)//��̨���г���
|
||
|
// {
|
||
|
// cno = 1222;
|
||
|
// dvm = dbo.ExceSQL("SELECT FSTARTDEVICE, FSTARTCELL FROM T_Manage_Task WHERE (FID = " + FID + ") AND (F_ManageTaskKindIndex = " + Taskind + ")").Tables[0].DefaultView;
|
||
|
// if (dvm.Count > 0)
|
||
|
// {
|
||
|
// oldCell = dvm[0]["FSTARTCELL"].ToString();
|
||
|
// oldDevice = dvm[0]["FSTARTDEVICE"].ToString();
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// oldDevice = "1201";
|
||
|
// oldCell = "-";
|
||
|
// }
|
||
|
// }
|
||
|
// else if (DeviceIdx == 3604)
|
||
|
// {
|
||
|
// oldDevice = "3229";
|
||
|
// oldCell = "-";
|
||
|
// cno = 3272;
|
||
|
// }
|
||
|
// else if (DeviceIdx == 4601)
|
||
|
// {
|
||
|
// oldDevice = "3229";
|
||
|
// oldCell = "-";
|
||
|
// cno = 4218;
|
||
|
// }
|
||
|
|
||
|
// else
|
||
|
// {//����Ҫ��·����ֱ�ӱ����쳣����
|
||
|
// dbo.ExceSQL("update T_Manage_Task set FExceptionNO=" + Model.CGeneralFunction.TASKABEND + " where (F_ManageTaskKindIndex = " + Taskind + ") AND (FID = " + FID + ")");
|
||
|
// ActionComplete(DeviceIdx, TaskIdx, 1);
|
||
|
// continue;
|
||
|
|
||
|
// }
|
||
|
|
||
|
|
||
|
|
||
|
// dbo.ExceSQL("DELETE FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = "+Taskind+") AND (FID = "+FID+")");
|
||
|
// dbo.ExceSQL("DELETE FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " + FID + ") AND (F_ManageTASKKINDINDEX = " + Taskind + ")");
|
||
|
// //20090902�Ŀⷿ����ccf.GetWarehouseIndex()
|
||
|
// sql = "INSERT INTO T_Manage_Task" +
|
||
|
// "(FID, F_ManageTaskKindIndex,FPALLETBARCODE,FMANAGETASKTYPE,FCONTROLTASKTYPE, FTASKLEVEL, FISRETURN," +
|
||
|
// "FSTARTWAREHOUSE,FENDWAREHOUSE, FSTARTCELL, FSTARTDEVICE, FENDDEVICE, FENDCELL, " +
|
||
|
// "FSTATUS, FBEGTIME, FIntoStepOK,FExceptionNO)" +
|
||
|
// "VALUES (" + FID + "," + Taskind + ",'0000000000','1','1','1','1','" + ccf.GetWarehouseIndex() + "','" + ccf.GetWarehouseIndex() + "','-'," + cno + ",'" + oldDevice + "','" + oldCell + "','0','" + DateTime.Now.ToString("u") + "','0'," + Model.CGeneralFunction.TASKABEND + ")";
|
||
|
// dbo.ExceSQL(sql);
|
||
|
|
||
|
// continue;
|
||
|
// }
|
||
|
// #endregion
|
||
|
// }
|
||
|
// else if (dv[0]["F_DeviceCommandIndex"].ToString() == "2")//���̺�����ɨ����������;
|
||
|
// {
|
||
|
// #region ���̺�����ɨ����������
|
||
|
|
||
|
// if ((gdata == "\0\0\0\0\0\0\0\0\0\0") || (gdata == null))
|
||
|
// {
|
||
|
// gdata = "0000000000";
|
||
|
|
||
|
// }
|
||
|
// int dcode=0;
|
||
|
// if (DeviceIdx == 1603)
|
||
|
// {
|
||
|
// dcode = 1220;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// continue;
|
||
|
// }
|
||
|
// DataView dvbc = dboM.ExceSQL("SELECT DEVICE_CODE,STOCK_BARCODE FROM IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS=0 and DEVICE_CODE=" + dcode + " and (STOCK_BARCODE = '" + gdata + "')").Tables[0].DefaultView;
|
||
|
// if (dvbc.Count > 0)
|
||
|
// {
|
||
|
// continue;
|
||
|
// }
|
||
|
// //20090915
|
||
|
// string Sql = "SELECT STOCK_BARCODE from IO_CONTROL where STOCK_BARCODE='" + gdata + "' and CONTROL_STATUS<100";
|
||
|
// DataView dvs = dboM.ExceSQL(Sql).Tables[0].DefaultView;
|
||
|
// if (dvs.Count > 0)
|
||
|
// {
|
||
|
|
||
|
// continue;
|
||
|
// }
|
||
|
|
||
|
// //������������������
|
||
|
// int fid = dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
||
|
// string dtime = DateTime.Now.ToString("u");
|
||
|
// dtime = dtime.Substring(0, dtime.Length - 1);
|
||
|
// sql = "INSERT INTO IO_CONTROL_APPLY(CONTROL_APPLY_ID,CONTROL_APPLY_TYPE, DEVICE_CODE, STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME,CONTROL_APPLY_REMARK)VALUES " +
|
||
|
// "(" + fid + ",1," + dcode + ",'" + gdata + "',0,'" + dtime + "',2)";
|
||
|
// dboM.ExceSQL(sql);
|
||
|
// //20090918
|
||
|
// ActionComplete(DeviceIdx, TaskIdx, 1);
|
||
|
// wv[0] = "2";
|
||
|
// sdo.WriteDBData(witemnames, wv);
|
||
|
// #endregion
|
||
|
// }
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
else if (dd[j]["F_DeviceKindIndex"].ToString() == "30")
|
||
|
{//20100617���Ӻ������������豸,����30
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Monitor_Task where (F_DeviceIndex=").Append(DeviceIdx).Append(") and F_Status>=1");
|
||
|
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
TaskIdx = Convert.ToInt32(dv[0]["F_MonitorIndex"]);
|
||
|
gds = CommModeCreate.CreateGetDeviceState(DeviceIdx);
|
||
|
int[] states = gds.GetDeviceState(DeviceIdx, TaskIdx);
|
||
|
if (states != null)
|
||
|
{
|
||
|
if (states[1] == Model.CGeneralFunction.TASKOUTCONFIRM)
|
||
|
{
|
||
|
ActionComplete(DeviceIdx, TaskIdx, 0);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else//���������豸
|
||
|
{
|
||
|
|
||
|
GetKindDeviceState(TaskIdx, DeviceIdx, 0);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
//20090920
|
||
|
#region ������������
|
||
|
ActionDeadLock();
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", "��ȡ�豸״̬ʱ��" +ex.StackTrace+ ex.Message);
|
||
|
OnRefreshMonitor(rmea);
|
||
|
|
||
|
}
|
||
|
finally
|
||
|
{//20091107
|
||
|
dv.Dispose();
|
||
|
dvm.Dispose();
|
||
|
dvmo.Dispose();
|
||
|
dd.Dispose();
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �豸��������
|
||
|
/// </summary>
|
||
|
/// <param name="DeviceIdx"></param>
|
||
|
public void ActionIdle(int DeviceIdx)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ��������
|
||
|
///�����������豸��"����"ʱ ɾ���豸ָ�� , �����豸��ռ��״̬F_LockedState=0��
|
||
|
///·����ϸ��F_LockedDeviceIndex�������ж�Ӧ�豸��������
|
||
|
/// �Ļ�����������ԤԼ����
|
||
|
///�ж��Ƿ�Ϊ��������������һ���豸ָ���,��д��������IO_Control��Control_STATUS=999��"��������";
|
||
|
///ɾ��T_Manage_Task������ִ��״̬FSTATUS=2����������ST_CELL���Ļ�λ״̬ ��
|
||
|
/// </summary>
|
||
|
/// <param name="DeviceIdx">�豸����</param>
|
||
|
/// <param name="TaskIdx">�豸ָ������</param>
|
||
|
///<param name="ClearZero">�Ƿ����豸������������:1���㣻900������������������999�ֹ�����������������</param>
|
||
|
public void ActionComplete(int DeviceIdx,int TaskIdx,int ClearZero)
|
||
|
{
|
||
|
if (TaskIdx == 0) return;
|
||
|
devinfo=Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
int devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
//20100305
|
||
|
int[] zxy = ccf.GetCoordinatesFromMonitorTask(TaskIdx);
|
||
|
StringBuilder zxystr = new StringBuilder();
|
||
|
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 order = ccf.GetDeviceOrderFromMonitor(TaskIdx);
|
||
|
if (order == -1)
|
||
|
{
|
||
|
// CGetStateError =DeviceIdx+"�ϱ���������:"+TaskIdx+ "�ڵ���ϵͳ�Ѿ�û�м�¼��";
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (devKind == 4)//����
|
||
|
{
|
||
|
int result = ccf.GetRepeatDeviceindex(DeviceIdx, TaskIdx);
|
||
|
if (result == -1)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (GetManage_Kind(TaskIdx) == false) return;
|
||
|
int errrcode= ccf.GetExceptionNOFromManageTask(_fid,_mti );
|
||
|
int ControlType=ccf.GetFCONTROLTASKTYPEFromManageTask(_mti,_fid);
|
||
|
string useawayfork = Model.CGeneralFunction.GetUseAwayFork(TaskIdx);
|
||
|
string barcode = ccf.GetBarCodeFromMonitor(TaskIdx);
|
||
|
int enddevice = ccf.GetEndDeviceFromManage(_mti, _fid);
|
||
|
int nexttaskindex = ccf.GetNextMonitorTaskIndex(TaskIdx);
|
||
|
string controlbatch = ccf.GetControlBatchFromManageTask(_mti, _fid);
|
||
|
//20100710
|
||
|
int AgvNextDeviceKind = 0;
|
||
|
if ((devKind == 6)&&(order==2))
|
||
|
{
|
||
|
AgvNextDeviceKind = ccf.GetDeviceKindIdx(zxy[4]);
|
||
|
}
|
||
|
|
||
|
#region �ж����ͻ����������ź�
|
||
|
|
||
|
if (devKind == 2)
|
||
|
{//20120409�ж����ͻ����������ź�
|
||
|
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT T_Base_Device.F_DeviceIndex from T_Base_Device,T_Monitor_Task where T_Base_Device.F_DeviceIndex=T_Monitor_Task.F_DeviceIndex and F_DeviceKindIndex=2 AND F_MonitorIndex = ").Append(TaskIdx);
|
||
|
object obd=dbo.GetSingle(sql.ToString());
|
||
|
if (obd == null)
|
||
|
{//�������ͻ�����
|
||
|
return;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(obd)).S7Connection != devinfo.S7Connection)
|
||
|
{//����ͬ�����ͻ�����
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
//20100108
|
||
|
DataView dvman = new DataView();
|
||
|
DataView dv = new DataView();
|
||
|
DataView dvlane = new DataView();
|
||
|
DataView dvr = new DataView();
|
||
|
string dtime=string.Empty ;
|
||
|
|
||
|
|
||
|
#region ��������Я���������Ȳ��ԵĴ���������������Я���������Ȳ��ԵĴ����������⽻�棩
|
||
|
int Pri = ccf.SelectTaskPriPrecept();
|
||
|
//20091016
|
||
|
if (((Pri == 21) || (Pri == 12)) && (devKind == 1) && (ccf.GetFCONTROLTASKTYPEFromManageTask(_mti, _fid) == 2))//�Ѷ����������Ȳ���Я����������
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Manage_Task where FTASKLEVEL=10 and FSTACK = " ).Append( DeviceIdx ).Append( " AND (FCONTROLTASKTYPE = 1) AND (FIntoStepOK = '1') ");
|
||
|
|
||
|
//20100108
|
||
|
dvman=dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView ;
|
||
|
if (dvman.Count <= 0)
|
||
|
{//20130122���ȿ��Ƿ���ͬ��ͬ�����������Ѷ����ȴ�����
|
||
|
if (GetNearDeviceInputTask(DeviceIdx, zxystr.ToString()) == false)
|
||
|
{
|
||
|
//û���ˣ������Ҹ�����������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FID, F_ManageTaskKindIndex, FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FSTACK = ").Append(DeviceIdx).Append(") AND (FCONTROLTASKTYPE = 1) AND (FIntoStepOK = '1') order by FTASKLEVEL desc, F_ManageTaskKindIndex desc,FID asc");
|
||
|
|
||
|
dvman = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int ii = 0; ii < dvman.Count; ii++)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Monitor_Task where F_ManageTASKKINDINDEX=" + dvman[ii]["F_ManageTASKKINDINDEX"] + " and F_ManageTaskIndex=" + dvman[ii]["FID"] + " order by F_MonitorIndex asc");
|
||
|
|
||
|
//20100108
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
int stackkind = ccf.GetDeviceKindIdx(Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
if (stackkind == 1)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=10 where F_ManageTASKKINDINDEX=").Append(dvman[ii]["F_ManageTASKKINDINDEX"]).Append(" and F_ManageTaskIndex=").Append(dvman[ii]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FTASKLEVEL=10 where F_ManageTASKKINDINDEX=").Append(dvman[ii]["F_ManageTASKKINDINDEX"]).Append(" and FID=").Append(dvman[ii]["FID"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//dbo.TransBegin();
|
||
|
try
|
||
|
{
|
||
|
int tsorder = 0;
|
||
|
int fid = _fid;
|
||
|
int mti = _mti;
|
||
|
int relativeFID = ccf.GetRELATIVECONTORLIDFromManageTask(mti, fid);
|
||
|
if (relativeFID == -1) relativeFID = 0;
|
||
|
string cap;
|
||
|
|
||
|
|
||
|
//20101011
|
||
|
#region ������ԤԼ���Ľ������˵��������Ĵ��豸������һ��������Ҫ�������й��������ĸ�Ϊ��������ԤԼ��
|
||
|
|
||
|
if ((devKind == 1) || (devKind == 4))
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select count(F_MonitorIndex) as counts from T_Monitor_Task " ).Append(
|
||
|
" where F_ManageTaskIndex =" ).Append( fid ).Append( " and F_ManageTaskKindIndex= " ).Append( mti ).Append( " and F_DeviceIndex=" ).Append( DeviceIdx);
|
||
|
object ob = dbo.GetSingle(sql.ToString());
|
||
|
if (Convert.ToInt32(ob) == 1)
|
||
|
{
|
||
|
|
||
|
#region �й����������ڣ����ӹ�������ԤԼ��//20100710
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT T_Manage_Task.FID FROM T_Manage_Task ,T_Monitor_Task where T_Manage_Task.FID<>").Append(fid).Append(" and T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX AND T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex and (T_Manage_Task.F_RELATIVECONTORLID = ").Append(relativeFID).Append(") AND (T_Manage_Task.F_ManageTaskKindIndex = ").Append(mti).Append(") and F_DeviceIndex=").Append(DeviceIdx).Append("");
|
||
|
ob = dbo.GetSingle(sql.ToString());
|
||
|
if ((ob != null)&&(devinfo.IfCorrelDoubleFork=="1"))
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_ManTaskReserve=" ).Append( (mti.ToString() + ob.ToString()) ).Append( " where F_ManTaskReserve=" ).Append( (mti.ToString() + fid.ToString()) ).Append( " and F_DeviceIndex=" + DeviceIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_ManTaskReserve=0 where F_ManTaskReserve=" ).Append( (mti.ToString() + fid.ToString()) ).Append( " and F_DeviceIndex=" ).Append( DeviceIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
//sql.Append("update T_Manage_Task set F_RELATIVECONTORLID=-1").Append(" where F_ManageTaskKindIndex=").Append(mti).Append(" and (FID=").Append(fid).Append(" or F_RELATIVECONTORLID=").Append(fid).Append(")");
|
||
|
//dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
}
|
||
|
|
||
|
#region �Ѷ����ͻ������ͻ�����ԤԼ��
|
||
|
//20120409
|
||
|
int stackdev = 0;
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (devinfo.VirtualStack>0)
|
||
|
{//20111231
|
||
|
stackdev = devinfo.VirtualStack;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackdev = DeviceIdx;
|
||
|
#region add by lyj 20171021
|
||
|
if (stackdev==11001||stackdev==11002||stackdev==11003)
|
||
|
{
|
||
|
stackdev = 11000;
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT T_Base_Lane_Gate.F_LaneGateDeviceIndex from T_Base_Lane_Gate,T_Base_LaneInfo ").Append(
|
||
|
" where T_Base_Lane_Gate.F_LaneIndex = T_Base_LaneInfo.F_LaneDeviceIndex and T_Base_Lane_Gate.F_ZXY='").Append(zxystr).Append("' ").Append(
|
||
|
" and T_Base_LaneInfo.F_StackIndex=").Append(stackdev);
|
||
|
dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvlane.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_ManTaskReserve=0 where F_DeviceIndex=").Append(dvlane[0]["F_LaneGateDeviceIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
if ((errrcode == Model.CGeneralFunction.TASKCHANGESTACK) && (devinfo.VirtualStack > 0) && (order == 5))//20101011�����洦��
|
||
|
{//���������������Ѷ�����������������λȡ�����͵���ʵ��λ������������FExceptionNO==null
|
||
|
if (AppendStackMoveCellOperate(mti, fid, DeviceIdx, TaskIdx) == false) return;
|
||
|
}
|
||
|
|
||
|
//20100108
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select count(F_MonitorIndex) as counts from T_Monitor_Task " ).Append(
|
||
|
" where F_ManageTaskIndex =" ).Append( fid ).Append( " and F_ManageTaskKindIndex= " ).Append( mti);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
int rowco = 0;
|
||
|
|
||
|
|
||
|
#region ����һ�����������Ĵ���
|
||
|
|
||
|
if ((Convert.ToInt32(dv[0]["counts"]) == 1)) //20091016
|
||
|
{
|
||
|
|
||
|
#region 20210329_�Ϻ��ɵ�����������ִ��ִ�����ɣ��������Ĵ����弰��������F_ManTaskReserve״̬���� ����
|
||
|
|
||
|
if (ControlType == 5)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Base_Device SET F_ManTaskReserve = 0 WHERE F_ManTaskReserve = ")
|
||
|
.Append(mti.ToString() + fid.ToString());
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
//�̶�·��ģʽ
|
||
|
//����������fid������һ�����طֽ���������
|
||
|
|
||
|
if (mti == 1)
|
||
|
{
|
||
|
cap = "��������";
|
||
|
//����FSTATUS=999��970�Ѷ����ͻ��ع����쳣���ɣ�980�Ѷ���ȡ�չ����쳣���ɣ�990����ɨ���쳣���ɣ�
|
||
|
//���ȳ���ɾ����������900;950�͵����̻��IJ��ǿ�������;940�˹���ͣ��������
|
||
|
//20090902
|
||
|
if ((errrcode >= 900) || (ClearZero == Model.CGeneralFunction.TASKDELETE))//�쳣����
|
||
|
{
|
||
|
if(errrcode== Model.CGeneralFunction.TASKDELETE)
|
||
|
ClearZero = errrcode;
|
||
|
|
||
|
else if (errrcode == Model.CGeneralFunction.TASKREPEATINPUT)
|
||
|
{
|
||
|
errrcode = Model.CGeneralFunction.TASKREPEATINPUT;//�ij��ģ���ǰ��Model.CGeneralFunction.TASKFINISH
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("update IO_Control set ERROR_TEXT='�Ѷ������ͻ��ع����쳣����' where CONTROL_ID=").Append(fid);
|
||
|
//dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else if (errrcode == Model.CGeneralFunction.TASKEMPTYOUTPUT)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set ERROR_TEXT='�Ѷ���ȡ�չ����쳣����' where CONTROL_ID=").Append(fid);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else if (errrcode == Model.CGeneralFunction.TASKABEND)
|
||
|
{
|
||
|
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set ERROR_TEXT='�����ȶԴ����쳣����' where CONTROL_ID=").Append(fid);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else if (errrcode == Model.CGeneralFunction.TASKTYPEERROR)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set ERROR_TEXT='�͵����̻��IJ��ǿ�������' where CONTROL_ID=").Append(fid);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else if (errrcode == Model.CGeneralFunction.TASKSTOPOUTPUT)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set ERROR_TEXT='�˹���ͣ��������' where CONTROL_ID=").Append(fid);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else if (ClearZero == Model.CGeneralFunction.TASKDELETE)//20141201����֣�ɾ���豸ָ������ʱ��970����980��Ӱ�죬���ܸ�Ϊ900�����÷���if������������
|
||
|
errrcode = ClearZero;
|
||
|
//20100304
|
||
|
|
||
|
switch (CStaticClass.ManDBFactory)
|
||
|
{
|
||
|
case "OracleDBFactory":
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set CONTROL_END_TIME =sysdate, CONTROL_STATUS=").Append(errrcode).Append(" where CONTROL_ID=").Append(fid);
|
||
|
rowco=dboM.ExecuteSql(sql.ToString());
|
||
|
|
||
|
break;
|
||
|
case "SQLServerDBFactory":
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set CONTROL_END_TIME =GETDATE(), CONTROL_STATUS=" ).Append( errrcode ).Append( " where CONTROL_ID=" ).Append( fid);
|
||
|
rowco=dboM.ExecuteSql(sql.ToString());
|
||
|
break;
|
||
|
case "OleDBFactory":
|
||
|
dtime = DateTime.Now.ToString("u");
|
||
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set CONTROL_END_TIME ='" ).Append( dtime).Append( "', CONTROL_STATUS=" ).Append( errrcode ).Append( " where CONTROL_ID=" ).Append( fid);
|
||
|
rowco=dboM.ExecuteSql(sql.ToString());
|
||
|
break;
|
||
|
}
|
||
|
if (rowco > 0)
|
||
|
{
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("ActionComplete", "�������ϱ�����:" + errrcode.ToString(), ",����[" + barcode + "]", ",CONTROL_ID:" + fid);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//����FSTATUS=999
|
||
|
switch (CStaticClass.ManDBFactory)
|
||
|
{
|
||
|
case "OracleDBFactory":
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set CONTROL_END_TIME =sysdate, CONTROL_STATUS=" ).Append( Model.CGeneralFunction.TASKFINISH ).Append( " where CONTROL_ID=" ).Append( fid);
|
||
|
rowco=dboM.ExecuteSql(sql.ToString());
|
||
|
break;
|
||
|
case "SQLServerDBFactory":
|
||
|
|
||
|
#region 20210513_�Ϻ��ɵ����ּ����������������ڷּ���ǰһ��������λ�ñ����ɣ����Թ���������
|
||
|
|
||
|
if (DeviceIdx == 12012 || DeviceIdx == 12018 || DeviceIdx == 12025)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set CONTROL_END_TIME =GETDATE(), CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKFINISH).Append(" where CONTROL_ID=").Append(fid);
|
||
|
rowco = dboM.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
case "OleDBFactory":
|
||
|
dtime = DateTime.Now.ToString("u");
|
||
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set CONTROL_END_TIME ='" ).Append( dtime ).Append( "', CONTROL_STATUS=" ).Append( Model.CGeneralFunction.TASKFINISH ).Append( " where CONTROL_ID=" ).Append( fid);
|
||
|
rowco = dboM.ExecuteSql(sql.ToString());
|
||
|
break;
|
||
|
}
|
||
|
if (rowco > 0)
|
||
|
{
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("ActionComplete", "�������ϱ�����:" + Model.CGeneralFunction.TASKFINISH.ToString(), ",����[" + barcode + "]", ",CONTROL_ID:" + fid);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
#region ���� ����wms�ӿ� �ϱ�״̬������������/ɾ������3����(�������ڸ���������״̬����ɾ��)
|
||
|
if (ControlType != 5 && ControlType != 6)
|
||
|
{
|
||
|
int status = 0;
|
||
|
if (ClearZero == Model.CGeneralFunction.TASKDELETE)
|
||
|
{
|
||
|
status = 900;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (errrcode == 970)//�ͻ��غ���������
|
||
|
{
|
||
|
status = 970;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
status = 999;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
string dTime1 = DateTime.Now.ToString("u");
|
||
|
dtime = dTime1.Substring(0, dTime1.Length - 1);
|
||
|
|
||
|
object[] ob = new object[8] { fid, status, 0, barcode, status, dtime, "", 1.ToString() };
|
||
|
try
|
||
|
{
|
||
|
sql.Clear();
|
||
|
sql.Append("select * from io_control_apply where CONTROL_ID = ").Append(fid);
|
||
|
if (dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView.Count > 0)
|
||
|
|
||
|
{
|
||
|
sql.Clear();
|
||
|
sql.Append(" delete from io_control_apply where CONTROL_ID = ").Append(fid);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
dboM.ExecuteSql(string.Format("INSERT INTO IO_CONTROL_APPLY(CONTROL_ID,CONTROL_APPLY_TYPE,DEVICE_CODE, STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME,CONTROL_APPLY_REMARK,WAREHOUSE_CODE)VALUES ({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}')", ob));
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������ϱ�����״̬:", fid.ToString(), ",״̬��" + status.ToString() + "�����룺" + barcode.ToString().ToUpper() + "���������ͣ�" + status.ToString());
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", "�������ϱ�����״̬��" + ex.StackTrace + ex.Message);
|
||
|
OnRefreshMonitor(rmea);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������ϱ�����״̬:����", fid.ToString(), ",״̬��" + status.ToString() + "�����룺" + barcode.ToString().ToUpper() + "���������ͣ�" + status.ToString());
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
else if (mti == 4)
|
||
|
{
|
||
|
cap = "�ֹ�����";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cap = "��ʱ����";
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
if ((errrcode == Model.CGeneralFunction.TASKCHANGEFORK) && (devKind == 1) && (devinfo.IfCorrelDoubleFork == "1"))//20101011�����洦��
|
||
|
{//�����������������棬������������λȡ�����͵���ʵ��λ������������FExceptionNO==null
|
||
|
if (AppendMoveCellOperate(mti, fid, DeviceIdx, TaskIdx) == false) return;
|
||
|
}
|
||
|
else
|
||
|
{//20101011
|
||
|
//�������//20091128
|
||
|
if ((ClearZero == Model.CGeneralFunction.TASKDELETE) || (ClearZero == Model.CGeneralFunction.TASKSTOPOUTPUT))//���ȳ���ɾ����������900���˹���ͣ��������940
|
||
|
{
|
||
|
ReturnManageInfo(fid, mti, cap, false);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ReturnManageInfo(fid, mti, cap, true);
|
||
|
}
|
||
|
}
|
||
|
#region �Ϻ��ɵ��������������б����ɣ����ó����� ����
|
||
|
|
||
|
|
||
|
if (ControlType == 6)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Base_Device SET F_SwitchLock = ").Append(TaskIdx)
|
||
|
.Append(" WHERE F_DeviceIndex = ").Append(DeviceIdx);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#region �Ϻ��ɵ��������������������������ɣ���T_manage_task ��Ϊ10��Ϊ�˻���ʱ���ж�10��״̬ ����
|
||
|
|
||
|
|
||
|
if (ControlType == 2)
|
||
|
{
|
||
|
if ((devinfo.DeviceKind==1) && (order==3))//��������ͻ����ɣ���T_manage_task ��Ϊ10
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append(string.Format("update T_Manage_Task set F_OutStatus =10 WHERE (FID = {0} and F_ManageTaskKindIndex={1} )", fid, mti));
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
if (ControlType == 1)
|
||
|
{
|
||
|
if ((devinfo.DeviceIndex == 14001|| devinfo.DeviceIndex == 14002) && ( (order == 5)))//�������ͻ� ��������������ȡ����Ϊ20
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append(string.Format("update T_Manage_Task set F_OutStatus =20 WHERE (FID = {0} and F_ManageTaskKindIndex={1} )", fid, mti));
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
if (ControlType == 5)
|
||
|
{
|
||
|
if ((devinfo.DeviceIndex == 14005|| devinfo.DeviceIndex == 14006) && ((order == 4)|| (order == 5)))//������ ���� ����������Ϊ10 ����
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append(string.Format("update T_Manage_Task set F_ChangeStatus =10 WHERE (FID = {0} and F_ManageTaskKindIndex={1} )", fid, mti));
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
//�������������������豸ȫ������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_LockedState=" ).Append( TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//��������������������ȫ���
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=0 where F_HaveGoods=").Append(TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
#region add by lyj20180522�������ͻ�����ʱҪ������������ԤԼ��
|
||
|
|
||
|
if (devinfo.IsShuttleBorad == 1 && order==5)
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_ManTaskReserve=0 where F_ManTaskReserve=").Append(mti.ToString()+fid.ToString());
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
if ((ClearZero != Model.CGeneralFunction.TASKDELETE) && (errrcode != Model.CGeneralFunction.TASKDELETE))//20120102ɾ��������������������
|
||
|
{
|
||
|
#region �Ѷ����ӻ����ͻ�����ʱ����20100710
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate where F_LaneGateDeviceIndex=").Append(DeviceIdx);
|
||
|
dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvlane.Count > 0)
|
||
|
{
|
||
|
//if (zxy[3] == 0)//20110608
|
||
|
//{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=0 where F_HaveGoods=").Append(TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
}
|
||
|
else
|
||
|
{//AGV�ӻ����ͻ�����ʱ����20100710
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("SELECT F_AGVGateDeviceIndex FROM T_Base_AGV_Gate where F_AGVGateDeviceIndex=").Append(DeviceIdx);
|
||
|
//dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//if (dvlane.Count > 0)
|
||
|
//{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=0 where F_HaveGoods=").Append(TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �Ѷ����Ż���AGV��������ȡ���������½��Ĵ���;�����ͻ�ȡ���������ͻ�������20101011
|
||
|
|
||
|
if ((devKind == 1) && ((order == 2) || (order == 3) || (order == 6)))//20101011 �ɵ���Ϊ2 3
|
||
|
{
|
||
|
|
||
|
bool sh = false;//20101011
|
||
|
bool qh = false;//20101011
|
||
|
if (order == 3) sh = true;//20101011
|
||
|
if (order == 2) qh = true;//20101011
|
||
|
if (order == 6)//20101011
|
||
|
{
|
||
|
sh = true;
|
||
|
qh = true;
|
||
|
}
|
||
|
int stackdev = 0;
|
||
|
if (devinfo.VirtualStack > 0)
|
||
|
{//20111231
|
||
|
stackdev = devinfo.VirtualStack;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackdev = DeviceIdx;
|
||
|
}
|
||
|
if (sh == true)//20101011
|
||
|
{
|
||
|
//20090918���Ѷ����ͻ������ͻ�����������
|
||
|
////20100609��Ϊʹ������������
|
||
|
stackdev = 10000;//�ɵ�
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT T_Base_Lane_Gate.F_LaneGateDeviceIndex from T_Base_Lane_Gate,T_Base_LaneInfo ").Append(
|
||
|
" where T_Base_Lane_Gate.F_LaneIndex = T_Base_LaneInfo.F_LaneDeviceIndex and T_Base_Lane_Gate.F_ZXY='").Append(zxystr).Append("' ").Append(
|
||
|
" and T_Base_LaneInfo.F_StackIndex=").Append(stackdev);
|
||
|
dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvlane.Count > 0)
|
||
|
{
|
||
|
#region 20120518�����ǵ�����λnexttaskindexȡ�ȵ�ǰ����С�ĵ�һ������
|
||
|
if (ccf.IfChangeForkCell(stackdev, zxystr.ToString()) == true)
|
||
|
{
|
||
|
nexttaskindex = ccf.GetPriorMonitorTaskIndex(TaskIdx);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
sql.Remove(0, sql.Length);//20120409ֻ�����ͻ���Ϊ������
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=").Append(nexttaskindex).Append(" where F_DeviceKindIndex=2 and F_DeviceIndex=").Append(dvlane[0]["F_LaneGateDeviceIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
if (qh == true)//�����ͻ�ȡ���������ͻ�������//20101011
|
||
|
{
|
||
|
stackdev = 10000;//�ɵ�
|
||
|
zxystr.Remove(0, zxystr.Length);
|
||
|
zxystr.Append((zxy[0].ToString().Length == 1 ? "0" + zxy[0].ToString() : zxy[0].ToString())).Append("-").Append(
|
||
|
((zxy[1].ToString().Length == 1) ? ("0" + zxy[1].ToString()) : (zxy[1].ToString()))).Append("-").Append(
|
||
|
((zxy[2].ToString().Length == 1) ? ("0" + zxy[2].ToString()) : (zxy[2].ToString())));
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_LifterDown,F_ChangeForkCell,T_Base_Lane_Gate.F_LaneGateDeviceIndex from T_Base_Lane_Gate,T_Base_LaneInfo ").Append(
|
||
|
" where T_Base_Lane_Gate.F_LaneIndex = T_Base_LaneInfo.F_LaneDeviceIndex and T_Base_Lane_Gate.F_ZXY='").Append(zxystr).Append("' ").Append(
|
||
|
" and T_Base_LaneInfo.F_StackIndex=").Append(stackdev);
|
||
|
dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvlane.Count > 0)
|
||
|
{
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=0,F_ManTaskReserve=0,F_PALLETBARCODE='-' where F_DeviceIndex=").Append(dvlane[0]["F_LaneGateDeviceIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_PLC_Ask set F_TaskIndex=0,F_Remark='' where F_DeviceIndex=").Append(dvlane[0]["F_LaneGateDeviceIndex"]);
|
||
|
dbo.ExecuteSql(sql.ToString());//20101011
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
else if ((devKind == 6) && (order == 3) && (AgvNextDeviceKind == 2))//AGV�����ͻ��Ż�20100710
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=").Append(nexttaskindex).Append(" where F_DeviceIndex=").Append(zxy[4]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region ɾ���Ѷ���ȡ����ȡ����������
|
||
|
|
||
|
if ((devKind == 1) && (order == 4) )//20120312
|
||
|
{
|
||
|
int stackdev = 0;
|
||
|
if (devinfo.VirtualStack>0)
|
||
|
{//20111231
|
||
|
stackdev = devinfo.VirtualStack;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackdev = DeviceIdx;
|
||
|
}
|
||
|
zxystr.Remove(0, zxystr.Length);
|
||
|
zxystr.Append((zxy[0].ToString().Length == 1 ? "0" + zxy[0].ToString() : zxy[0].ToString())).Append("-").Append(
|
||
|
((zxy[1].ToString().Length == 1) ? ("0" + zxy[1].ToString()) : (zxy[1].ToString()))).Append("-").Append(
|
||
|
((zxy[2].ToString().Length == 1) ? ("0" + zxy[2].ToString()) : (zxy[2].ToString())));
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_LifterDown,F_ChangeForkCell,T_Base_Lane_Gate.F_LaneGateDeviceIndex from T_Base_Lane_Gate,T_Base_LaneInfo ").Append(
|
||
|
" where T_Base_Lane_Gate.F_LaneIndex = T_Base_LaneInfo.F_LaneDeviceIndex and T_Base_Lane_Gate.F_ZXY='").Append(zxystr).Append("' ").Append(
|
||
|
" and T_Base_LaneInfo.F_StackIndex=").Append(stackdev);
|
||
|
dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvlane.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_PLC_Ask set F_TaskIndex=0,F_Remark='' where F_TaskIndex=").Append(TaskIdx).Append(" and F_DeviceIndex=").Append(dvlane[0]["F_LaneGateDeviceIndex"]);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
|
||
|
#region ����AGV��RGV���Ѷ����Ӳ��ڵ����ͻ�������20140109
|
||
|
bool saveBarcode = false;
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT F_AGVGateDeviceIndex FROM T_Base_AGV_Gate where F_AGVGateDeviceIndex=").Append(DeviceIdx);
|
||
|
if (dbo.GetSingle(sql.ToString()) != null)
|
||
|
{
|
||
|
saveBarcode = true;
|
||
|
}
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT F_RGVGateDeviceIndex FROM T_Base_RGV_Gate where F_RGVGateDeviceIndex=").Append(DeviceIdx);
|
||
|
if (dbo.GetSingle(sql.ToString()) != null)
|
||
|
{
|
||
|
saveBarcode = true;
|
||
|
}
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate where F_LaneGateDeviceIndex=").Append(DeviceIdx);
|
||
|
if (dbo.GetSingle(sql.ToString()) != null)
|
||
|
{
|
||
|
saveBarcode = true;
|
||
|
}
|
||
|
if (saveBarcode == true && mti !=4)
|
||
|
{
|
||
|
dbo.ExecuteSql(string.Format("UPDATE T_Base_Device SET F_ManTaskReserve={2},F_PALLETBARCODE = '{0}' WHERE (F_DeviceIndex = {1})", barcode, DeviceIdx, Convert.ToInt32(mti.ToString()+fid.ToString())));//20140309
|
||
|
}
|
||
|
#endregion
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex=" ).Append( TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//dbo.TransCommit();
|
||
|
//��PLC����Ӧ��ͷ��2���������
|
||
|
//�����豸�����жϴ�������
|
||
|
|
||
|
|
||
|
//if (ClearZero == 1) ע�� by lyj 20180112 Ϊ�˽������������ϣ������ֹ����ɵ�����DB1
|
||
|
if (ClearZero == 1) //�ɵ�
|
||
|
{
|
||
|
if (mti == 1)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE IO_CONTROL SET ERROR_TEXT ='' WHERE CONTROL_ID=").Append(fid).Append(" and CONTROL_STATUS<900");
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
|
||
|
if ((devKind == 1) || (devKind == 6)) //�Ѷ�����AGV
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
else
|
||
|
{//���ͻ���RGV��������
|
||
|
//20130221���Ӷ�RGV��AGV��ȡ��վ̨��Ӧ�𱣻���ֻ��DeviceIdx�����л�ʱ��Ӧ��
|
||
|
//if (devKind == 2 && UnAccordResponse(DeviceIdx)==true ) { }
|
||
|
//else
|
||
|
//{
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
|
||
|
sdo.SendDeviceOrder(2, 0, tsorder, DeviceIdx, 0);
|
||
|
//}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
CDataChangeEventArgs dcea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange("ActionComplete",dcea);
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
//dbo.TransRollback();
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", string.Format("��������ʱ��{0}" ,DeviceIdx.ToString()+ ex.StackTrace+ ex.Message));
|
||
|
OnRefreshMonitor(rmea);
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
//dvman.Dispose() ;
|
||
|
//dv.Dispose();
|
||
|
//dvlane.Dispose() ;
|
||
|
//dvr.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private bool UnAccordResponse(int DeviceIdx)
|
||
|
{//20130221
|
||
|
DataView dv = new DataView();
|
||
|
bool ifCheckHaveGoods = false;
|
||
|
try
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_AGVGateDeviceIndex FROM T_Base_AGV_Gate WHERE (F_AGVGateDeviceIndex = {0})", DeviceIdx)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
ifCheckHaveGoods = true;
|
||
|
}
|
||
|
if (ifCheckHaveGoods == false)
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_RGVGateDeviceIndex FROM T_Base_RGV_Gate WHERE (F_RGVGateDeviceIndex = {0})", DeviceIdx)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
ifCheckHaveGoods = true;
|
||
|
}
|
||
|
}
|
||
|
if (ifCheckHaveGoods == true)
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (CStaticClass.GetDevicePhotoelectric(devinfo.BindingDeviceOut) != 1) return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", string.Format("��������,UnAccordResponseʱ��{0}", ex.StackTrace + ex.Message));
|
||
|
OnRefreshMonitor(rmea);
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private bool GetNearDeviceInputTask(int DeviceIdx, string zxystr)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
DataView dvm = new DataView();
|
||
|
DataView dm = new DataView();
|
||
|
try
|
||
|
{
|
||
|
int stackdev = 0;
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (devinfo.VirtualStack>0)
|
||
|
{//20111231
|
||
|
stackdev = devinfo.VirtualStack;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackdev = DeviceIdx;
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_LaneIndex, F_ZXY, F_NearDevice from T_Base_Lane_Gate,T_Base_LaneInfo ").Append(
|
||
|
" where T_Base_Lane_Gate.F_LaneIndex = T_Base_LaneInfo.F_LaneDeviceIndex and T_Base_Lane_Gate.F_ZXY='").Append(zxystr).Append("' ").Append(
|
||
|
" and T_Base_LaneInfo.F_StackIndex=").Append(stackdev);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_LaneIndex, F_ZXY, F_NearDevice from T_Base_Lane_Gate where F_LaneIndex={0} and F_NearDevice={1}",
|
||
|
Convert.ToInt32( dv[0]["F_LaneIndex"]),Convert.ToInt32( dv[0]["F_NearDevice"]))).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{//�Ѷ�������Щ��λ��ȡ�������Ƿ�Ϊ��һ���豸ָ��
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] sp; int z = 0, x = 0, y = 0;
|
||
|
object[] ob = new object[4];
|
||
|
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
sp = dv[i]["F_ZXY"].ToString().Split(cc);
|
||
|
z =Convert.ToInt32( sp[0]);
|
||
|
x = Convert.ToInt32(sp[1]);
|
||
|
y = Convert.ToInt32(sp[2]);
|
||
|
ob[0] = DeviceIdx;
|
||
|
ob[1] = z;
|
||
|
ob[2] = x;
|
||
|
ob[3] = y;
|
||
|
dvm = dbo.ExceSQL(string.Format("SELECT F_ManageTASKKINDINDEX, F_ManageTaskIndex, F_MonitorIndex FROM T_Monitor_Task WHERE (F_DeviceIndex = {0} and F_DeviceCommandIndex=4 and F_Status=0) AND (F_NumParam1 = {1}) AND (F_NumParam2 = {2}) AND (F_NumParam3 = {3}) order by F_MonitorIndex asc",ob)).Tables[0].DefaultView;
|
||
|
if (dvm.Count > 0)
|
||
|
{
|
||
|
dm = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex,F_ManageTASKKINDINDEX, F_ManageTaskIndex FROM T_Monitor_Task where F_ManageTASKKINDINDEX={0} and F_ManageTaskIndex={1} order by F_MonitorIndex asc",Convert.ToInt32( dvm[0]["F_ManageTASKKINDINDEX"]),Convert.ToInt32( dvm[0]["F_ManageTASKINDEX"]))).Tables[0].DefaultView;
|
||
|
if (dm.Count > 0)
|
||
|
{
|
||
|
if (dm[0]["F_MonitorIndex"].ToString() == dvm[0]["F_MonitorIndex"].ToString())
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_MonitorTaskLevel=10 where F_ManageTASKKINDINDEX=").Append(dvm[0]["F_ManageTASKKINDINDEX"]).Append(" and F_ManageTaskIndex=").Append(dvm[0]["F_ManageTaskIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FTASKLEVEL=10 where F_ManageTASKKINDINDEX=").Append(dvm[0]["F_ManageTASKKINDINDEX"]).Append(" and FID=").Append(dvm[0]["F_ManageTaskIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", string.Format("��������ʱ��{0}", ex.StackTrace + ex.Message));
|
||
|
OnRefreshMonitor(rmea);
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dvm.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private int ControlBatchAlterSendPLC(string conbatch, int DeviceIdx)
|
||
|
{//�������κŶ�Ӧ�豸��DeviceIdx+��5��
|
||
|
DataView dv = new DataView();
|
||
|
int order = 0;
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32( DeviceIdx.ToString()+"5"));
|
||
|
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_BoxBarcode, F_HaveFirstProject FROM T_Base_PLC_Ask WHERE (F_DeviceIndex = {0})",devinfo.DeviceIndex)).Tables[0].DefaultView;
|
||
|
if (dv.Count>0)
|
||
|
{//F_BoxBarcode�������������ţ�F_HaveFirstProject�ϴθ�PLCд����ֵ1,2
|
||
|
if (dv[0]["F_BoxBarcode"].ToString() != conbatch)
|
||
|
{//���Ų���ͬ
|
||
|
//witemnames = new StringBuilder[1] { new StringBuilder("DB1,byte" + devinfo.Dbw1Address.ToString()) };
|
||
|
//wv = new StringBuilder[1] { new StringBuilder("2") };
|
||
|
if (dv[0]["F_HaveFirstProject"].ToString() == "1")
|
||
|
{//�2
|
||
|
//wv[0].Clear();
|
||
|
//wv[0].Append("2");
|
||
|
order = 2;
|
||
|
//sdo = CommLayerFactory.CommModeCreate.CreateSendDeviceOrder(devinfo.DeviceIndex);
|
||
|
//if (sdo.WriteDBData(witemnames, wv) == true)
|
||
|
//{
|
||
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������κ�д��", DeviceIdx.ToString(), "���Σ�" + conbatch.ToString() + ",2");
|
||
|
|
||
|
dbo.ExceSQL(string.Format("update T_Base_PLC_Ask set F_BoxBarcode='{1}',F_HaveFirstProject = '2' WHERE (F_DeviceIndex = {0})", devinfo.DeviceIndex, conbatch));
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", string.Format("������������ControlBatchAlterSendPLCʱ��{0}", "�������κ�д��ʧ�ܣ�"));
|
||
|
// OnRefreshMonitor(rme);
|
||
|
//}
|
||
|
}
|
||
|
else
|
||
|
{//�1
|
||
|
//witemnames = new StringBuilder[1] { new StringBuilder("DB1,byte" + devinfo.Dbw1Address.ToString()) };
|
||
|
//wv = new StringBuilder[1] { new StringBuilder("1") };
|
||
|
//wv[0].Clear();
|
||
|
//wv[0].Append("1");
|
||
|
order = 1;
|
||
|
//sdo = CommLayerFactory.CommModeCreate.CreateSendDeviceOrder(devinfo.DeviceIndex);
|
||
|
//if (sdo.WriteDBData(witemnames, wv) == true)
|
||
|
//{
|
||
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������κ�д��", DeviceIdx.ToString(), "���Σ�" + conbatch.ToString() + ",1");
|
||
|
|
||
|
dbo.ExceSQL(string.Format("update T_Base_PLC_Ask set F_BoxBarcode='{1}',F_HaveFirstProject = '1' WHERE (F_DeviceIndex = {0})", devinfo.DeviceIndex, conbatch));
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", string.Format("������������ControlBatchAlterSendPLCʱ��{0}", "�������κ�д��ʧ�ܣ�"));
|
||
|
// OnRefreshMonitor(rme);
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{//������ͬ
|
||
|
//witemnames = new StringBuilder[1] { new StringBuilder("DB1,byte" + devinfo.Dbw1Address.ToString()) };
|
||
|
//wv = new StringBuilder[1] { new StringBuilder("1") };
|
||
|
//wv[0].Clear();
|
||
|
//wv[0].Append(dv[0]["F_HaveFirstProject"].ToString());
|
||
|
order = Convert.ToInt32(dv[0]["F_HaveFirstProject"]);
|
||
|
//sdo = CommLayerFactory.CommModeCreate.CreateSendDeviceOrder(devinfo.DeviceIndex);
|
||
|
//if (sdo.WriteDBData(witemnames, wv) == true)
|
||
|
//{
|
||
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������κ�д��", DeviceIdx.ToString(), "���Σ�" + conbatch.ToString() + ",1");
|
||
|
|
||
|
//dbo.ExceSQL(string.Format("update T_Base_PLC_Ask set F_BoxBarcode='{1}',F_HaveFirstProject = '1' WHERE (F_DeviceIndex = {0})", devinfo.DeviceIndex, conbatch));
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", string.Format("������������ControlBatchAlterSendPLCʱ��{0}", "�������κ�д��ʧ�ܣ�"));
|
||
|
// OnRefreshMonitor(rme);
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", string.Format("������������ControlBatchAlterSendPLCʱ��{0}", "�豸�����ڣ�"));
|
||
|
OnRefreshMonitor(rme);
|
||
|
|
||
|
}
|
||
|
return order;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", string.Format("������������ControlBatchAlterSendPLCʱ��{0}", ex.StackTrace + ex.Message));
|
||
|
OnRefreshMonitor(rme);
|
||
|
return 0;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
private void SendBarCodePLC(string barcode, int DeviceIdx)
|
||
|
{//�����������������Ŷ�Ӧ�豸��DeviceIdx+��6��
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
dbo.ExceSQL(string.Format("update T_Base_PLC_Ask set F_remark='{0}' WHERE (F_DeviceIndex = {1})",barcode, DeviceIdx));
|
||
|
//devinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(DeviceIdx.ToString() + "6"));
|
||
|
//witemnames = new StringBuilder[devinfo.Dbw1SendLength];
|
||
|
//wv = new StringBuilder[devinfo.Dbw1SendLength];
|
||
|
//byte[] bytebc = ASCIIEncoding.ASCII.GetBytes(barcode);
|
||
|
//for (int i = 0; i < devinfo.Dbw1SendLength; i++)
|
||
|
//{
|
||
|
// witemnames[i] = new StringBuilder("DB1,byte" + (devinfo.Dbw1Address + i).ToString());
|
||
|
// if (i < bytebc.Length)
|
||
|
// {
|
||
|
// wv[i] = new StringBuilder(bytebc[i].ToString());
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// wv[i] = new StringBuilder("0");
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
//sdo = CommLayerFactory.CommModeCreate.CreateSendDeviceOrder(devinfo.DeviceIndex);
|
||
|
//sdo.WriteDBData(witemnames, wv);
|
||
|
//CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�����ڵ�λ��������", DeviceIdx.ToString(), "���룺" + barcode.ToString());
|
||
|
|
||
|
//return;
|
||
|
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", string.Format("������������IFSameStartDeviceControlBatchLastBoxʱ��{0}", ex.StackTrace+ex.Message));
|
||
|
OnRefreshMonitor(rme);
|
||
|
return;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
private bool IFSameStartDeviceControlBatchLastBox(int mti, int fid, int endconveyor)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
string startdev=string.Empty ,conbatch=string.Empty;
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT FSTARTDEVICE, FCONTORL_BATCH FROM T_Manage_Task WHERE (F_ManageTaskKindIndex ={0}) AND (FID = {1})",mti,fid)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
startdev = dv[0]["FSTARTDEVICE"].ToString();
|
||
|
conbatch = dv[0]["FCONTORL_BATCH"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Manage_Task,T_Monitor_Task where T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX AND FID = F_ManageTaskIndex and (FSTARTDEVICE = '{0}') AND (FCONTORL_BATCH = '{1}') AND (T_Monitor_Task.F_NumParam4 = {2})",startdev,conbatch,endconveyor)).Tables[0].DefaultView;
|
||
|
if (dv.Count ==1)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", string.Format("������������IFSameStartDeviceControlBatchLastBoxʱ��{0}", ex.StackTrace+ex.Message ));
|
||
|
OnRefreshMonitor(rme);
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private int GetLaneGateDevice(int stackDevice, string zxy)
|
||
|
{//20120820
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(stackDevice);
|
||
|
if (devinfo.VirtualStack>0)
|
||
|
{
|
||
|
stackDevice = devinfo.VirtualStack;
|
||
|
}
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT T_Base_Lane_Gate.F_LaneGateDeviceIndex FROM T_Base_Lane_Gate ,T_Base_LaneInfo WHERE T_Base_Lane_Gate.F_LaneIndex = T_Base_LaneInfo.F_LaneDeviceIndex And (T_Base_LaneInfo.F_StackIndex = {0}) AND (T_Base_Lane_Gate.F_ZXY = '{1}')", stackDevice, zxy)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �������ڶ��̲߳���������SQL����
|
||
|
/// </summary>
|
||
|
public void ActionDeadLock()
|
||
|
{//20100108
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_DeadLock where f_flag=0 order by f_id asc");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
dbo.ExceSQL(dv[i]["f_SQL"].ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_DeadLock set f_flag=1 where f_id=" ).Append( dv[i]["f_id"] );
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
}//20100108
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��д�豸����״̬�֣�IO_Control,T_Manage_Task,T_Monitor_task��
|
||
|
/// </summary>
|
||
|
/// <param name="DeviceIdx">�豸����</param>
|
||
|
/// <param name="TaskIdx">�豸ָ������</param>
|
||
|
/// <param name="ErrId">��������</param>
|
||
|
public void ActionError(int DeviceIdx, int TaskIdx,int ErrId)
|
||
|
{
|
||
|
//dbo.TransBegin();
|
||
|
//20100108
|
||
|
DataView dvmon = new DataView();
|
||
|
DataTable dt = new DataTable();
|
||
|
DataView dv0 = new DataView();
|
||
|
DataView dvm = new DataView();
|
||
|
DataView dvIO = new DataView();
|
||
|
DataRowView dr = null ;
|
||
|
|
||
|
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
int devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
CDataChangeEventArgs dcea = new CDataChangeEventArgs(null, null);
|
||
|
//090915
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task where F_Status =1 and F_DeviceIndex =" ).Append( DeviceIdx);
|
||
|
|
||
|
//20100108
|
||
|
dvmon = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if ((dvmon.Count > 0) && (TaskIdx == 0))
|
||
|
{
|
||
|
TaskIdx = Convert.ToInt32(dvmon[0]["F_MonitorIndex"]);
|
||
|
}
|
||
|
|
||
|
if ((devKind == 1)) //�Ѷ��� �Ϻ��ɵ�
|
||
|
{
|
||
|
int[] sendmes = new int[10] { 0, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0 };
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (CStaticClass.IsEquals(devinfo.SendMessage, sendmes, 10) == false)
|
||
|
{
|
||
|
#region
|
||
|
//�Ϻ��ɵ���ʱ����Τ�ƾٲ���
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(0, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#region �й���¼�Ĺ����豸�������ţ������ظ�����
|
||
|
|
||
|
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 );
|
||
|
|
||
|
//20100108
|
||
|
dt = dbo.ExceSQL(sql.ToString()).Tables[0];
|
||
|
if (dt.Rows.Count >= 1)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status= ").Append(ErrId).Append(" where (F_MonitorIndex= ").Append(TaskIdx).Append(") and ((F_Status<> ").Append(ErrId).Append(") and (F_Status<> 3 and F_Status>0))");//20121203
|
||
|
int errc=dbo.ExecuteSql(sql.ToString());
|
||
|
if (errc > 0)//20110603
|
||
|
{
|
||
|
|
||
|
OnDataChange("ActionError",dcea);
|
||
|
}
|
||
|
int[] corrtaskindex=Model.CGeneralFunction.MutiForkIfSync(TaskIdx, DeviceIdx, devKind);
|
||
|
if ((corrtaskindex!=null ) && (CStaticClass.DeviceErrorAutoModifyRoutePath == "0"))
|
||
|
{//20120328
|
||
|
for (int i = 0; i < corrtaskindex.GetLength(0); i++)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status= ").Append(ErrId).Append(" where (F_MonitorIndex= ").Append(corrtaskindex[i]).Append(") and ((F_Status<> ").Append(ErrId).Append(") and (F_Status<> 3 and F_Status>0))");//20121203
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
}
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
if (GetManage_Kind(TaskIdx) == false) return;
|
||
|
int fid = _fid;
|
||
|
int mti = _mti;
|
||
|
if (fid <= 0) return;
|
||
|
|
||
|
#region ͨ�ù��ϴ���
|
||
|
string dtime = DateTime.Now.ToString("u");//20110603
|
||
|
|
||
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
||
|
errs = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(devKind.ToString() + ErrId.ToString()));
|
||
|
if (errs != null)
|
||
|
{
|
||
|
if (errs.ErrorIndex > 0)
|
||
|
{
|
||
|
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("notifyIcon1", string.Format("����:{0},{1},�������ϣ�{2}" , devinfo.DeviceName , DeviceIdx , errs.ErrorName));
|
||
|
OnRefreshMonitor(rmea);
|
||
|
|
||
|
if (mti == 1)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set ERROR_TEXT='").Append(devinfo.DeviceName).Append(",").Append(DeviceIdx).Append(errs.ErrorName).Append("' where CONTROL_ID=").Append(fid);
|
||
|
int roc= dboM.ExecuteSql(sql.ToString());
|
||
|
if (roc > 0)
|
||
|
{
|
||
|
#region ���� ����wms�ӿ� �ϱ�״̬��������
|
||
|
int ControlType = ccf.GetFCONTROLTASKTYPEFromManageTask(mti, fid);
|
||
|
if (ControlType != 5 && ControlType != 6)
|
||
|
{
|
||
|
int status = 30; //����
|
||
|
string errortext = devinfo.DeviceName + DeviceIdx.ToString() + errs.ErrorName;
|
||
|
if (status != 0)
|
||
|
{
|
||
|
string dTime1 = DateTime.Now.ToString("u");
|
||
|
dTime1 = dTime1.Substring(0, dTime1.Length - 1);
|
||
|
|
||
|
string barcode = ccf.GetBarCodeFromMonitor(TaskIdx);
|
||
|
|
||
|
|
||
|
object[] ob = new object[8] { fid, status, 0, barcode, status, dTime1, errortext, 1.ToString() };
|
||
|
try
|
||
|
{
|
||
|
|
||
|
dboM.ExecuteSql(string.Format("INSERT INTO IO_CONTROL_APPLY(CONTROL_ID,CONTROL_APPLY_TYPE,DEVICE_CODE, STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME,CONTROL_APPLY_PARAMETER,WAREHOUSE_CODE)VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", ob));
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������ϱ�����״̬:", fid.ToString(), ",״̬��" + status + "�����룺" + barcode.ToString().ToUpper() + "���������ͣ�" + 30.ToString());//
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
rmea = new RefreshMonitorEventArgs("tsStatus", "�������ϱ�����״̬��" + ex.StackTrace + ex.Message);
|
||
|
OnRefreshMonitor(rmea);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������ϱ�����״̬:����", fid.ToString(), ",״̬��" + 30 + "�����룺" + barcode.ToString().ToUpper() + "���������ͣ�" + 30.ToString());//
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
//20170111�����߳������������ϼ�¼
|
||
|
//20100108
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("SELECT F_DeviceIndex, F_ErrorIndex FROM T_Base_Device_Error_Log Where F_ManageTaskNo=").Append(fid).Append(" and F_DeviceIndex=").Append(DeviceIdx).Append(" and F_ErrorIndex=").Append(errs.ErrorIndex);
|
||
|
//dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//if (dv0.Count > 0)
|
||
|
//{//20091107
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("UPDATE T_Base_Device_Error_Log SET F_DateTime ='").Append(dtime).Append("' Where F_DeviceIndex=").Append(DeviceIdx).Append(" and F_ErrorIndex=").Append(errs.ErrorIndex).Append(" and F_ManageTaskNo=").Append(fid);
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("INSERT INTO T_Base_Device_Error_Log (F_ManageTaskNo,F_DeviceIndex, F_ErrorIndex, F_DateTime) VALUES (").Append(fid).Append(",").Append(DeviceIdx).Append(",").Append(errs.ErrorIndex).Append(",'").Append(dtime).Append("')");
|
||
|
//dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status= ").Append(ErrId).Append(" where F_MonitorIndex= ").Append(TaskIdx).Append(" and (F_Status<> 3 and F_Status>0)");//20121203
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//��¼�������ϵ��豸����ִ�е�������
|
||
|
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());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FERRORCODE='" ).Append( devinfo.DeviceName ).Append( "," ).Append( DeviceIdx ).Append( errs.ErrorName ).Append( "' where F_ManageTaskKindIndex=" ).Append( mti ).Append( " and FID=" ).Append( fid);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
//if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
if(true)
|
||
|
{//�����Զ��ĵ�����
|
||
|
|
||
|
#region �Ѷ����쳣������ȡ�պ����أ�
|
||
|
if ((devKind == 1) && (mti == 1||mti == 2))//�Ѷ���
|
||
|
{
|
||
|
int[] mforkMoninfo=Model.CGeneralFunction.MutiForkIfSync(TaskIdx, DeviceIdx, devKind);
|
||
|
StringBuilder rcontrolidstr=new StringBuilder();StringBuilder errusefork = new StringBuilder();
|
||
|
Model.MIOControlStatus mioc= Model.CGetInfo.GetIOControlStatus(ErrId);
|
||
|
if (mioc==null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
{//����
|
||
|
char[] cc = new char[1] { ',' };
|
||
|
|
||
|
string[] errforks = mioc.ForkNo.Split(cc);
|
||
|
for (int i = 0; i < errforks.GetLength(0); i++)
|
||
|
{
|
||
|
errusefork.Append(" FUseAwayFork='").Append(errforks[i]).Append("' or ");
|
||
|
}
|
||
|
errusefork.Remove(errusefork.Length - 3, 3);
|
||
|
int relcontrolid = ccf.GetRELATIVECONTORLIDFromManageTask(mti, fid);
|
||
|
rcontrolidstr.Clear();
|
||
|
if (relcontrolid > 0)
|
||
|
{//20130704
|
||
|
rcontrolidstr.Append(" F_RELATIVECONTORLID = ").Append(relcontrolid);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
rcontrolidstr.Append(" FID = ").Append(fid);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{//����
|
||
|
errusefork.Clear();
|
||
|
errusefork.Append(" 1=1 ");
|
||
|
rcontrolidstr.Append(" FID = ").Append(fid);
|
||
|
}
|
||
|
//if (mioc.StatusCode.IndexOf("STACKEMPTYOUTPUT") >= 0)//�Ѷ����ij���ȡ�մ���
|
||
|
if (ErrId== 36)
|
||
|
{
|
||
|
#region �Ѷ�����ȡ�մ���,ɾ����������;�쳣����980
|
||
|
//int[] zxy = ccf.GetCoordinatesFromMonitorTask(TaskIdx);
|
||
|
//StringBuilder zxystr = new StringBuilder();
|
||
|
//if (zxy != null)
|
||
|
//{
|
||
|
// //�Ѷ���ȡ������
|
||
|
// zxystr.Append((zxy[0].ToString().Length == 1 ? "0" + zxy[0].ToString() : zxy[0].ToString())).Append("-").Append(
|
||
|
// ((zxy[1].ToString().Length == 1) ? ("0" + zxy[1].ToString()) : (zxy[1].ToString()))).Append("-").Append(
|
||
|
// ((zxy[2].ToString().Length == 1) ? ("0" + zxy[2].ToString()) : (zxy[2].ToString())));
|
||
|
//}
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("SELECT F_ZXY FROM T_Base_Lane_Gate WHERE (F_ZXY = '").Append(zxystr).Append("')");
|
||
|
//dvIO = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//if (dvIO.Count > 0)
|
||
|
//{//�����ij��������ͻ���Ӧ�Ļ�λ������ȡ�ձ���
|
||
|
// return;
|
||
|
//}
|
||
|
//sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
//sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("SELECT FID FROM T_Manage_Task WHERE (").Append(rcontrolidstr.ToString()).Append(") AND (F_ManageTaskKindIndex = ").Append(mti).Append(") and (").Append(errusefork).Append(" )");
|
||
|
//dvm = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//for (int m = 0; m < dvm.Count; m++)
|
||
|
//{
|
||
|
// fid = Convert.ToInt32(dvm[m]["FID"]);
|
||
|
// //ɾ���������쳣����980
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("update T_Monitor_Task set F_STATUS=-1 where F_ManageTaskKindIndex=").Append(mti).Append(" and F_ManageTaskIndex=").Append(fid).Append(" and F_STATUS=0");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("update T_Manage_Task set FExceptionNO=").Append(Model.CGeneralFunction.TASKEMPTYOUTPUT).Append(" where (F_ManageTaskKindIndex = ").Append(mti).Append(") AND (FID = ").Append(fid).Append(")");
|
||
|
// dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("select * from T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX =").Append(mti).Append(")");
|
||
|
// dvIO = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
// for (int i = 0; i < dvIO.Count; i++)
|
||
|
// {
|
||
|
// ActionComplete(Convert.ToInt32(dvIO[i]["F_DeviceIndex"]), Convert.ToInt32(dvIO[i]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
#region �����������Ѿ�ȡ�����ɵ�����������
|
||
|
//if (mforkMoninfo != null && devinfo.IfCorrelDoubleFork == "1")
|
||
|
//{
|
||
|
// foreach (int rtask in mforkMoninfo)
|
||
|
// {
|
||
|
// ActionComplete(DeviceIdx, rtask, 1);
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
#endregion
|
||
|
}
|
||
|
//else if (mioc.StatusCode.IndexOf("STACKREPEATINPUT") >= 0)//�Ѷ����������ͻ���
|
||
|
else if (ErrId == 35)
|
||
|
{
|
||
|
#region �Ѷ������ͻ��أ���Ҫ��·������;�쳣����970
|
||
|
|
||
|
#region �Զ��ڿ��ڸ����»�λ
|
||
|
|
||
|
//#region �Ѷ������ͻ�����Ҫ��·������
|
||
|
////20091107
|
||
|
////20100108
|
||
|
//dvIO = dboM.ExceSQL("select CONTROL_ID, CONTROL_STATUS from IO_Control where (CONTROL_ID = " + fid + ") AND ((CONTROL_STATUS=" + Model.CGeneralFunction.TASKREPEATINPUT + ") or (CONTROL_STATUS=" + Model.CGeneralFunction.TASKALTERROUTEREPLY + "))").Tables[0].DefaultView;
|
||
|
//if (dvIO.Count <= 0)
|
||
|
//{
|
||
|
// //����������������
|
||
|
// //20100108
|
||
|
// dvm = dbo.ExceSQL("select * from T_Manage_Task WHERE (FID = " + fid + ") AND (F_ManageTASKKINDINDEX =" + mti + ")").Tables[0].DefaultView;
|
||
|
// if (dvm.Count > 0)
|
||
|
// {
|
||
|
// fwarehouse = dvm[0]["FWAREHOUSE"].ToString();
|
||
|
// flane = Convert.ToInt32(dvm[0]["FLANEWAY"]);
|
||
|
// fcode = dvm[0]["FENDCELL"].ToString();
|
||
|
// if (ccf.QueryCellIfExit(fwarehouse, flane, fcode) == true)
|
||
|
// {
|
||
|
// //20091128
|
||
|
// //20100108
|
||
|
// dr = dvm[0];
|
||
|
// //20100108
|
||
|
// //DV = dboM.ExceSQL("select IO_CONTROL_APPLY_SEQ.NEXTVAL FROM DUAL").Tables[0].DefaultView;
|
||
|
// int id = dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
||
|
|
||
|
// string dtime = DateTime.Now.ToString("u");
|
||
|
// dtime = dtime.Substring(0, dtime.Length - 1);
|
||
|
// dboM.TransBegin();
|
||
|
// try
|
||
|
// {
|
||
|
|
||
|
// if (CStaticClass.ManDBFactory == "OracleDBFactory")
|
||
|
// {
|
||
|
|
||
|
// dboM.ExceSQL("update IO_Control set CONTROL_STATUS=" + Model.CGeneralFunction.TASKREPEATINPUT + ",ERROR_TEXT='" + DeviceIdx + errs.ErrorName + ";ԭ��λ��" + "'||END_DEVICE_CODE where CONTROL_ID=" + fid);
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// dboM.ExceSQL("update IO_Control set CONTROL_STATUS=" + Model.CGeneralFunction.TASKREPEATINPUT + ",ERROR_TEXT='" + DeviceIdx + errs.ErrorName + ";ԭ��λ��" + "'+END_DEVICE_CODE where CONTROL_ID=" + fid);
|
||
|
// }
|
||
|
// string sql = "INSERT INTO IO_CONTROL_APPLY (CONTROL_APPLY_ID, CONTROL_ID,CONTROL_APPLY_TYPE, WAREHOUSE_CODE, STOCK_BARCODE, DEVICE_CODE,APPLY_TASK_STATUS, FCREATETIME, FREMARK)" +
|
||
|
// "VALUES (" + id + "," + dr["FID"] + ",2,'" + dr["FENDWAREHOUSE"] + "','" + dr["FPALLETBARCODE"] + "','" + dr["FENDDEVICE"] + "',0,'" + dtime + "',null)";
|
||
|
// dboM.ExceSQL(sql);
|
||
|
// dboM.TransCommit();
|
||
|
|
||
|
// dbo.ExceSQL("update T_Manage_Task set FExceptionNO=" + Model.CGeneralFunction.TASKREPEATINPUT + ",FERRORCODE='" + DeviceIdx + errs.ErrorName + ";ԭ��λ��" + "'+ FENDCELL where (F_ManageTaskKindIndex = " + mti + ") AND (FID = " + fid + ")");
|
||
|
// //��ManageTaskIdx��ManageKindIdx �ĵ�������ȫ�������ĵ�
|
||
|
// dbo.ExceSQL("UPDATE T_Monitor_Task SET F_Status = 3 WHERE (F_ManageTaskIndex = " + fid + ") AND (F_ManageTASKKINDINDEX =" + mti + ")");
|
||
|
|
||
|
|
||
|
|
||
|
// }
|
||
|
// catch (Exception ex)
|
||
|
// {
|
||
|
// _CGetStateError = "�Ѷ����ͻ�ʱ�������ع��ϣ��ĵ�ʱ��" + ex.Message;
|
||
|
// dboM.TransRollback();
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
//}//20091107
|
||
|
//#endregion
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �ͳ����˹�������
|
||
|
//�����㣬ɾ������������lockstate��Ȼ��ֱ�Ӹĵ�����
|
||
|
System.Threading.Thread.Sleep(2000);
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(4, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
//20100710
|
||
|
int[] zxy = ccf.GetCoordinatesFromMonitorTask(TaskIdx);
|
||
|
StringBuilder zxystr = new StringBuilder();
|
||
|
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())));
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ZXY FROM T_Base_Lane_Gate WHERE (F_ZXY = '").Append(zxystr.ToString()).Append("')");
|
||
|
dvIO = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvIO.Count > 0)
|
||
|
{//�����ij��������ͻ���Ӧ�Ļ�λ�������Ϳձ���
|
||
|
return;
|
||
|
}
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT FID FROM T_Manage_Task WHERE (").Append(rcontrolidstr.ToString()).Append(") AND (F_ManageTaskKindIndex = ").Append(mti).Append(") and (").Append(errusefork).Append(" )");
|
||
|
dvm = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int m = 0; m < dvm.Count; m++)
|
||
|
{
|
||
|
fid = Convert.ToInt32(dvm[m]["FID"]);
|
||
|
//�Ѷ������ͻ��أ�ֻ�����Ѷ������ͻ�����
|
||
|
//��Ӧ��վ̨����ԭ�����յ���Ϊ�����ĵ���Ӧ��վ̨
|
||
|
//int enddevice = devinfo.StackAbendOut;
|
||
|
int enddevice = 13004;//�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FCONTROLTASKTYPE=2,FSTARTDEVICE=FENDDEVICE,FSTARTCELL=FENDCELL,FENDDEVICE=").Append(enddevice
|
||
|
).Append(",FENDCELL='-',FExceptionNO=").Append(Model.CGeneralFunction.TASKREPEATINPUT).Append(" where (FID = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX =").Append(mti).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select FSTARTDEVICE from T_Manage_Task where (FID = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX =").Append(mti).Append(")");
|
||
|
int sdevice = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
||
|
sql.Remove(0, sql.Length);//���� ȡ��ʼ��λ
|
||
|
sql.Append("select FSTARTCELL from T_Manage_Task where (FID = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX =").Append(mti).Append(")");
|
||
|
string Scell = dbo.GetSingle(sql.ToString()).ToString();
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select FENDDEVICE from T_Manage_Task where (FID = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX =").Append(mti).Append(")");
|
||
|
int edevice = Convert.ToInt32(dbo.GetSingle(sql.ToString()));
|
||
|
|
||
|
//int routeidNew = CDisassembleTask.MinRouteID(sdevice, edevice, true, dvm);//20110331 ����
|
||
|
int routeidNew = CDisassembleTask.MinRouteID(sdevice, edevice, 0, Scell, "-", 2);
|
||
|
|
||
|
if (routeidNew == -1) return;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("DELETE FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX =").Append(mti).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Manage_Task where (FID = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX =").Append(mti).Append(")");
|
||
|
dvIO = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvIO.Count > 0)
|
||
|
{
|
||
|
dr = dvIO[0];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
CDisassembleTask.CreateMonitor(mti, fid, routeidNew, dr, 3);
|
||
|
|
||
|
//�������´�������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FSTACK=").Append(DeviceIdx.ToString()).Append(" where FID=").Append(fid);
|
||
|
int a = dbo.ExecuteSql(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_DeviceIndex=").Append(DeviceIdx.ToString()).Append(",F_AheadDetect=REPLACE(F_AheadDetect,'11000','").Append(DeviceIdx.ToString()).Append("') where F_DeviceIndex=11000 and F_ManageTaskIndex=").Append(fid);
|
||
|
int b = dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(fid
|
||
|
).Append(") AND (F_ManageTASKKINDINDEX = ").Append(mti).Append(") AND (F_DeviceIndex = ").Append(
|
||
|
DeviceIdx).Append(") AND (F_DeviceCommandIndex = 3) AND (F_RouteID = ").Append(routeidNew).Append( //����2��ȡ�� 3 ���ͻ� �ͻ�֮ǰ������ɾ����
|
||
|
") AND (F_Status = 3)");
|
||
|
dvIO = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvIO.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<").Append(dvIO[0]["F_MonitorIndex"]).Append(" and (F_ManageTaskIndex = ").Append(
|
||
|
fid).Append(") AND (F_ManageTASKKINDINDEX = ").Append(mti).Append(") AND (F_Status = 3)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=").Append(DeviceIdx);
|
||
|
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(mti).Append(") AND (F_Status = 3)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
#region �����������ѷ��͵��ͻ�������Ҫ���·���
|
||
|
if (mforkMoninfo != null && devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
foreach (int rtask in mforkMoninfo)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=").Append(DeviceIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where F_MonitorIndex=").Append(rtask);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �߶�����ɨ�費��ȷ������Ҫ�ĵ����쳣��
|
||
|
if ((devKind == 13 || devKind == 31)&&(ErrId==41))//40����δ������41���벻��ȷ
|
||
|
{
|
||
|
int abenddevice = 0, startdev = 40100, startucode =ccf.GetUCodeFromDeviceGD(DeviceIdx);
|
||
|
if (startucode > 40100)
|
||
|
{
|
||
|
abenddevice = 42037;
|
||
|
startdev = 40100;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
abenddevice = 32025;
|
||
|
if (startucode <= 30107)
|
||
|
{
|
||
|
startdev = 30100;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
startdev = 30200;
|
||
|
}
|
||
|
}
|
||
|
//�ȶԴ��ĵ��쳣������
|
||
|
//��Ŀ��λ�����쳣��
|
||
|
object[] obj = new object[7] { mti, fid, abenddevice, Model.CGeneralFunction.TASKABEND ,startdev,startucode,DeviceIdx };
|
||
|
dbo.ExecuteSql(string.Format("UPDATE T_Manage_Task SET FExceptionNO={3},FStartDEVICE ={4},FSTARTUCODE={5}, FStartCELL ='{6}',FENDDEVICE ={2}, FENDCELL ='-', FENDUCODE =0 WHERE (F_ManageTaskKindIndex ={0}) AND (FID ={1})", obj));
|
||
|
ccf.GetUseableRouteIDSubAndModifyRoute(fid, mti, startdev);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
if (devinfo.UseCommonDB == "1")
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
OnDataChange("ActionError",dcea);
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
//dbo.TransRollback();
|
||
|
RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", string.Format("�����������豸����ʱ��{0}" ,ex.StackTrace+ex.Message ));
|
||
|
OnRefreshMonitor(rme);
|
||
|
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
dvmon.Dispose();
|
||
|
dt.Dispose(); ;
|
||
|
dv0.Dispose();
|
||
|
dvm.Dispose();
|
||
|
dvIO.Dispose();
|
||
|
dr=null ;
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// �豸��ʼ���У�
|
||
|
/// 1�����������ź�̽�������ж�����ִ�е�λ�û�д���ع�����
|
||
|
/// 2����д�����������Ŀ�ʼִ��״̬
|
||
|
/// 3���ж��Ƿ�������ǰ��������
|
||
|
///
|
||
|
/// </summary>
|
||
|
/// <param name="DeviceIdx">�豸����</param>
|
||
|
/// <param name="TaskIdx">����������</param>
|
||
|
public void ActionStartRun(int DeviceIdx, int TaskIdx)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (TaskIdx <= 0)
|
||
|
{
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
int fid = ccf.GetManageTaskIndexfromMonitor(TaskIdx);
|
||
|
int mti = ccf.GetManageTaskKindIndexFromMonitor(TaskIdx);
|
||
|
int ControlType = ccf.GetFCONTROLTASKTYPEFromManageTask(mti, fid);//��
|
||
|
//dbo.TransBegin();
|
||
|
if (fid <= 0) return;
|
||
|
DataView dvlane = new DataView();
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
int devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
|
||
|
if (mti == 1)
|
||
|
{//20100714
|
||
|
int updatestatus = Model.CGeneralFunction.TASKRUN;
|
||
|
//if (devKind==1)
|
||
|
//{
|
||
|
// updatestatus = 11;
|
||
|
//}
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_CONTROL set CONTROL_STATUS=").Append(updatestatus).Append(" where CONTROL_STATUS <> ").Append(updatestatus).Append(" and CONTROL_ID=").Append(fid);
|
||
|
int res =dboM.ExecuteSql(sql.ToString());
|
||
|
if (res == 1)
|
||
|
{
|
||
|
#region ���� ����wms�ӿ� �ϱ�״̬����ִ���� 10ִ�� 30���� 999����
|
||
|
if (ControlType != 5 && ControlType != 6)
|
||
|
{
|
||
|
sql.Clear();
|
||
|
sql.Append(" select * from T_manage_task WHERE F_ManageTaskKindIndex = 1 and fstatus = 1 and fid = ").Append(fid);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
string dTime1 = DateTime.Now.ToString("u");
|
||
|
dTime1 = dTime1.Substring(0, dTime1.Length - 1);
|
||
|
|
||
|
string barcode = ccf.GetBarCodeFromMonitor(TaskIdx);
|
||
|
int status = 10; //ִ����
|
||
|
|
||
|
object[] ob = new object[8] { fid, status, 0, barcode, status, dTime1, "", 1.ToString() };
|
||
|
try
|
||
|
{
|
||
|
|
||
|
dboM.ExecuteSql(string.Format("INSERT INTO IO_CONTROL_APPLY(CONTROL_ID,CONTROL_APPLY_TYPE,DEVICE_CODE, STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME,CONTROL_APPLY_REMARK,WAREHOUSE_CODE)VALUES ({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}')", ob));
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������ϱ�����״̬:", fid.ToString(), ",״̬��" + status + "�����룺" + barcode.ToString().ToUpper() + "���������ͣ�" + 10.ToString());//20140218
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", "�������ϱ�����״̬��" + ex.StackTrace + ex.Message);
|
||
|
OnRefreshMonitor(rmea);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������ϱ�����״̬:����", fid.ToString(), ",״̬��" + status + "�����룺" + barcode.ToString().ToUpper() + "���������ͣ�" + 10.ToString());//20140218
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#region �ĵ�������״̬20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_ErrorCode='', F_Status=2 where F_MonitorIndex=" + TaskIdx);//20110505
|
||
|
//20110405
|
||
|
int urow=dbo.ExecuteSql(sql.ToString());
|
||
|
if (urow > 0)
|
||
|
{
|
||
|
//devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
//int devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
int order = ccf.GetDeviceOrderFromMonitor(TaskIdx);
|
||
|
if (((devKind == 2) && (devinfo.IfClearDB1 == "1")))//20121203|| (devKind == 4)
|
||
|
{//���ͻ���RGV DB1����
|
||
|
//int[] sendmes = new int[5] { 0, 0, 0, DeviceIdx, 0 };
|
||
|
//devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
//if (CStaticClass.IsEquals(devinfo.SendMessage, sendmes, 5) == false)
|
||
|
//{
|
||
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
// sdo.SendDeviceOrder(0, 0, 0, DeviceIdx, 0);
|
||
|
|
||
|
//}
|
||
|
}
|
||
|
//else if ((devKind == 4))
|
||
|
//{
|
||
|
// int[] sendmes = new int[5] { 0, 0, 0, DeviceIdx, 0 };
|
||
|
// devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
// if (CStaticClass.IsEquals(devinfo.SendMessage, sendmes, 5) == false)
|
||
|
// {
|
||
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
// sdo.SendDeviceOrder(0, 0, 0, DeviceIdx, 0);
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
else if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
int[] sendmes = new int[10] { 0, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0 };
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (CStaticClass.IsEquals(devinfo.SendMessage, sendmes, 10) == false)
|
||
|
{
|
||
|
#region
|
||
|
//�Ϻ��ɵ�
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(0, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
|
||
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange("ActionStartRun",cea);
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
|
||
|
}//20110405
|
||
|
|
||
|
|
||
|
#region ���������ź�̽�������ж�����ִ�е�λ�û�д���ع�����
|
||
|
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FCurrentLocation=" ).Append(
|
||
|
DeviceIdx ).Append( " where F_ManageTaskKindIndex=" ).Append( mti ).Append( " and FID=" ).Append( fid);
|
||
|
dbo.ExceSQL( sql.ToString());
|
||
|
//����������Ҳ��¼��ǰλ�ã���Ҫ�Ǹ����ͻ�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_CurrentLocation=" ).Append(
|
||
|
DeviceIdx ).Append( " where F_MonitorIndex=" ).Append( TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20120518�豸������
|
||
|
|
||
|
//20090918���Ѷ����ͻ������ͻ�����������F_HaveGoods=0
|
||
|
//20100108
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate where F_LaneGateDeviceIndex like '" ).Append( DeviceIdx).Append("%'");
|
||
|
//dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
//if (dvlane.Count > 0)
|
||
|
//{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=0 where F_HaveGoods=").Append(TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//}
|
||
|
//else
|
||
|
//{//20100710
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_AGVGateDeviceIndex FROM T_Base_AGV_Gate where F_AGVGateDeviceIndex=").Append(DeviceIdx);
|
||
|
dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvlane.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_HaveGoods=0 where F_HaveGoods=").Append(TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
//dbo.TransCommit();
|
||
|
//RefreshControlMonitor(DeviceIdx);
|
||
|
//20091107
|
||
|
if (CStaticClass.MovedDeviceAheadTrigger == "1")
|
||
|
{
|
||
|
#region �ж��Ƿ�������ǰ��������(�豸�ţ�����������)
|
||
|
//���豸����ʱ��������������������F_AheadTrigger
|
||
|
//20100108
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_AheadTrigger from T_Monitor_Task " ).Append(
|
||
|
"where F_MonitorIndex=" ).Append( TaskIdx ).Append( " and F_AheadTrigger like '" ).Append( DeviceIdx.ToString() ).Append( "-" ).Append( "%'");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
//������ǰ������������������
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] sp = dv[0]["F_AheadTrigger"].ToString().Split(cc);
|
||
|
if (sp.GetLength(0) > 0)
|
||
|
{
|
||
|
int TriTask = Convert.ToInt32(sp[1]);
|
||
|
if (ccl.SendMonitorTask(TriTask) == true)
|
||
|
{
|
||
|
//������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_AheadTrigger ='' where F_MonitorIndex=" ).Append( TaskIdx);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
//20161224
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
CGetStateError = string.Format("ControlSystem.CGetState.����ִ��ʱ����������{0}" , ex.StackTrace+ex.Message );
|
||
|
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
|
||
|
dvlane.Dispose();
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
public bool GetManage_Kind(int taskidx)
|
||
|
{//20100108
|
||
|
DataSet ds = new DataSet();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTaskIndex, F_ManageTaskKindIndex, F_MonitorIndex FROM T_Monitor_Task Where F_MonitorIndex=" ).Append( taskidx);
|
||
|
ds = dbo.ExceSQL(sql.ToString());
|
||
|
if (ds.Tables[0].DefaultView.Count > 0)
|
||
|
{
|
||
|
_fid = Convert.ToInt32(ds.Tables[0].DefaultView[0]["F_ManageTaskIndex"]);
|
||
|
_mti = Convert.ToInt32(ds.Tables[0].DefaultView[0]["F_ManageTaskKindIndex"]);
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
ds.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
public void ReturnManageInfo(int fid, int mti, string cap, bool IFOK)
|
||
|
{
|
||
|
string dtime = DateTime.Now.ToString("u");//20101028
|
||
|
dtime = dtime.Substring(0, dtime.Length - 1);//20101028
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] fcc;
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//200906240111���ӻ�λ��¼:����1-����λ���л�������2-��ʼλ����������3-��ʼλ����������λ���л�
|
||
|
//20100108
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(fid);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (IFOK == true)
|
||
|
{
|
||
|
|
||
|
switch (dv[0]["FCONTROLTASKTYPE"].ToString())
|
||
|
{
|
||
|
case "1":
|
||
|
if (dv[0]["FENDCELL"].ToString().IndexOf("-") > 0)//20100905
|
||
|
{
|
||
|
fcc = dv[0]["FENDCELL"].ToString().Split(cc);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FRUNSTATUS=0,FCELLSTATUS = 1,FPALLETBARCODE='").Append(dv[0]["FPALLETBARCODE"]).Append("' WHERE (FLaneWay=").Append(dv[0]["FENDDEVICE"]).Append(" and F_Z='").Append(
|
||
|
fcc[0]).Append("' and F_X='").Append(fcc[1]).Append("' and F_Y='").Append(fcc[2]).Append("')");
|
||
|
// dbo.ExceSQL(sql.ToString());����
|
||
|
}
|
||
|
break;
|
||
|
case "2":
|
||
|
|
||
|
if (dv[0]["FSTARTCELL"].ToString().IndexOf("-") > 0)//20100905
|
||
|
{
|
||
|
fcc = dv[0]["FSTARTCELL"].ToString().Split(cc);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FRUNSTATUS=0,FCELLSTATUS =0,FPALLETBARCODE='-' WHERE (FLaneWay=").Append(dv[0]["FSTARTDEVICE"]).Append(" and F_Z=").Append(
|
||
|
fcc[0]).Append(" and F_X=").Append(fcc[1]).Append(" and F_Y=").Append(fcc[2]).Append(")");
|
||
|
// dbo.ExceSQL(sql.ToString());����
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
case "3":
|
||
|
|
||
|
if (dv[0]["FENDCELL"].ToString().IndexOf("-") > 0)//20100905
|
||
|
{
|
||
|
fcc = dv[0]["FENDCELL"].ToString().Split(cc);//FRUNSTATUS=0,
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FRUNSTATUS=0,FCELLSTATUS = 1,FPALLETBARCODE='").Append(dv[0]["FPALLETBARCODE"]).Append("' WHERE (FLaneWay=").Append(dv[0]["FENDDEVICE"]).Append(" and F_Z=").Append(
|
||
|
fcc[0]).Append(" and F_X=").Append(fcc[1]).Append(" and F_Y=").Append(fcc[2]).Append(")");
|
||
|
// dbo.ExceSQL(sql.ToString()); ����
|
||
|
}
|
||
|
if (dv[0]["FSTARTCELL"].ToString().IndexOf("-") > 0)//20100905
|
||
|
{
|
||
|
fcc = dv[0]["FSTARTCELL"].ToString().Split(cc);//20160418 FRUNSTATUS=0,
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FRUNSTATUS=0,FCELLSTATUS =0,FPALLETBARCODE='-' WHERE (FLaneWay=").Append(dv[0]["FSTARTDEVICE"]).Append(" and F_Z=").Append(
|
||
|
fcc[0]).Append(" and F_X=").Append(fcc[1]).Append(" and F_Y=").Append(fcc[2]).Append(")");
|
||
|
// dbo.ExceSQL(sql.ToString()); ����
|
||
|
}
|
||
|
|
||
|
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (CStaticClass.StopTestLane == false && dv[0]["F_ManageTaskKindIndex"].ToString() != "1")
|
||
|
{
|
||
|
#region ����ʱ��������������ʱ���ɳ�������
|
||
|
if (dv[0]["FCONTROLTASKTYPE"].ToString() == "1" && CStaticClass.TestOutEnd == false)
|
||
|
{
|
||
|
int startdevice = Convert.ToInt32(dv[0]["FSTARTDEVICE"]);
|
||
|
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
#region ����ʱ���ƿ���������ʱ������������
|
||
|
if (dv[0]["FCONTROLTASKTYPE"].ToString() == "2" && CStaticClass.TestInEnd == false)
|
||
|
{
|
||
|
|
||
|
int enddevice;
|
||
|
int startdevice = Convert.ToInt32(dv[0]["FENDDEVICE"]);
|
||
|
|
||
|
|
||
|
if (startdevice >= 12007 && startdevice <= 12013)//���ɳ�������
|
||
|
{
|
||
|
string CellCode = ccf.GetAvailableCellCode(startdevice, "18"); //CStaticClass.SelectEmptyCell(Laneindex);
|
||
|
if (CellCode != "-")
|
||
|
{
|
||
|
string dtimes = DateTime.Now.ToString("u");//20101028
|
||
|
dtimes = dtimes.Substring(0, dtimes.Length - 1);//20101028
|
||
|
int Laneindex = ccf.GetLanewayFromCellCode(CellCode, 1);
|
||
|
if (Laneindex != -1)
|
||
|
{
|
||
|
enddevice = Laneindex;
|
||
|
int AutoManageIdx = ccf.GetTempManageIdx();//������������
|
||
|
string stack = "0";//�Ѷ���FSTACK
|
||
|
|
||
|
string barcodes = CStaticClass.GetCellBarCode(CellCode, Laneindex);//��������
|
||
|
|
||
|
int ifrevolve = 0;// ccf.GetIFRevolve(startdevice, string.Empty, enddevice, string.Empty);
|
||
|
int controltype = 1;//����
|
||
|
int boxtype = 2;
|
||
|
string sqlstr = string.Format("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FStartCol,FStartLayer) values ({0},'{1}',{2},{3},{4},{5},'{6}',{7},{8},'{9}',{10},{11},'{12}','{13}',{14},{15})", AutoManageIdx, barcodes, controltype, 2, 1, startdevice, "-", 1, enddevice, CellCode, Laneindex, stack, "-", dtimes, 0, 0);
|
||
|
|
||
|
dbo.ExceSQL(sqlstr);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�Զ�������������", startdevice.ToString(), AutoManageIdx.ToString());
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
//�����
|
||
|
#region ����� 20150126
|
||
|
int Lane = Convert.ToInt32(dv[0]["FLANEWAY"]);
|
||
|
|
||
|
if (CStaticClass.StopTest.ContainsKey(Lane) == true && !CStaticClass.StopTest[Lane] && dv[0]["F_ManageTaskKindIndex"].ToString() != "1")//����
|
||
|
{
|
||
|
int startdevice;
|
||
|
int enddevice;
|
||
|
string dtimes = DateTime.Now.ToString("u");//20101028
|
||
|
dtimes = dtimes.Substring(0, dtimes.Length - 1);//20101028
|
||
|
//�����������ƿ�������Ҫ�ҵ��ƿ��������յ�
|
||
|
//if (dv[0]["FCONTROLTASKTYPE"].ToString() == "2")
|
||
|
//{
|
||
|
// startdevice = Convert.ToInt32(dv[0]["FENDDEVICE"]);
|
||
|
// enddevice = ccf.GetLaneGate(startdevice, Lane);
|
||
|
|
||
|
|
||
|
|
||
|
// int AutoManageIdx = ccf.GetTempManageIdx();//������������
|
||
|
// string stack = "0";//�Ѷ���FSTACK
|
||
|
|
||
|
// string barcodes = AutoManageIdx.ToString();//��������
|
||
|
|
||
|
// int ifrevolve = 2;
|
||
|
// int controltype = 3;//�ƿ�
|
||
|
|
||
|
// int boxtype = Convert.ToInt32(dv[0]["BOX_TYPE"]);
|
||
|
|
||
|
// string sqlstr = string.Format("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FStartCol,FStartLayer,BOX_TYPE,IFRevolve) values ({0},'{1}',{2},{3},{4},{5},'{6}',{7},{8},'{9}',{10},{11},'{12}','{13}',{14},{15},{16},{17})", AutoManageIdx, barcodes, controltype, 2, 1, startdevice, "-", 1, enddevice, "-", Lane, stack, "-", dtimes, 0, 0, boxtype, ifrevolve);
|
||
|
|
||
|
// dbo.ExceSQL(sqlstr);
|
||
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�Զ������ƿ�����:" + AutoManageIdx.ToString(), startdevice.ToString(), enddevice.ToString());
|
||
|
|
||
|
|
||
|
//}
|
||
|
//else
|
||
|
if (dv[0]["FCONTROLTASKTYPE"].ToString() == "2" && CStaticClass.StopIn[Lane] == false)// 3�ƿ���������������
|
||
|
{
|
||
|
|
||
|
startdevice = Convert.ToInt32(dv[0]["FENDDEVICE"]);
|
||
|
if (startdevice == 12001 || startdevice == 12009)
|
||
|
{
|
||
|
if (CStaticClass.ContainAGV)
|
||
|
{
|
||
|
int sLaneindex = 18003;
|
||
|
int eLaneindex = 18003;
|
||
|
enddevice = 18003;
|
||
|
if (startdevice == 12009)//�������ɺ������ƿ����� 18003/12009 - 12002/-
|
||
|
{
|
||
|
sLaneindex = 18003;
|
||
|
eLaneindex = 12002;
|
||
|
enddevice = 0;
|
||
|
}
|
||
|
else
|
||
|
if (startdevice == 12001)//�������ɺ������ƿ����� 18003/12001 - 18003/12008
|
||
|
{
|
||
|
sLaneindex = 18003;
|
||
|
eLaneindex = 18003;
|
||
|
|
||
|
enddevice = 12008;
|
||
|
}
|
||
|
int AutoManageIdx = ccf.GetTempManageIdx();//������������
|
||
|
string stack = "0";//�Ѷ���FSTACK
|
||
|
|
||
|
string barcodes = AutoManageIdx.ToString();//��������
|
||
|
|
||
|
int controltype = 3;//�ƿ�
|
||
|
|
||
|
string sqlstr = string.Format("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FStartCol,FStartLayer) values ({0},'{1}',{2},{3},{4},{5},'{6}',{7},{8},'{9}',{10},{11},'{12}','{13}',{14},{15})", AutoManageIdx, barcodes, controltype, 2, 1, sLaneindex, startdevice, 1, eLaneindex, enddevice, Lane, stack, "-", dtimes, 0, 0);
|
||
|
|
||
|
dbo.ExceSQL(sqlstr);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�Զ�����AGV�ƿ�����", startdevice.ToString(), AutoManageIdx.ToString());
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
|
||
|
if (startdevice==22116)
|
||
|
{
|
||
|
string CellCode;
|
||
|
if (CStaticClass.TestKind == 1)
|
||
|
{
|
||
|
CellCode = ccf.GetAvailableCellCode(startdevice, "18");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
CellCode = ccf.GetNextCell(startdevice, Lane, 1);
|
||
|
}
|
||
|
|
||
|
if (CellCode != "-")
|
||
|
{
|
||
|
|
||
|
|
||
|
enddevice = Lane;
|
||
|
int AutoManageIdx = ccf.GetTempManageIdx();//������������
|
||
|
string stack = "0";//�Ѷ���FSTACK
|
||
|
|
||
|
string barcodes = AutoManageIdx.ToString();//��������
|
||
|
|
||
|
int ifrevolve = 2;
|
||
|
int controltype = 1;//����
|
||
|
//int boxtype = 2;
|
||
|
string sqlstr = string.Format("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FStartCol,FStartLayer) values ({0},'{1}',{2},{3},{4},{5},'{6}',{7},{8},'{9}',{10},{11},'{12}','{13}',{14},{15})", AutoManageIdx, barcodes, controltype, 2, 1, startdevice, "-", 1, enddevice, CellCode, Lane, stack, "-", dtimes, 0, 0);
|
||
|
|
||
|
dbo.ExceSQL(sqlstr);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�Զ�������������:" + AutoManageIdx.ToString(), startdevice.ToString(), enddevice.ToString() + ":" + CellCode);
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
if (dv[0]["FCONTROLTASKTYPE"].ToString() == "1"&&CStaticClass.StopOut[Lane]==false)//���������ɳ�������
|
||
|
{
|
||
|
enddevice = Convert.ToInt32(dv[0]["FSTARTDEVICE"]);// Convert.ToInt32(WcfControlMonitorLib.CStaticClass.TestEndDevice[Lane]);
|
||
|
if (enddevice==0)
|
||
|
{
|
||
|
string CellCode = CStaticClass.SelectGoodsCell(Lane, enddevice);
|
||
|
//string CellCode = Convert.ToString(dv[0]["FENDCELL"]);
|
||
|
if (CellCode != "-")
|
||
|
{
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
if (enddevice == 22134)
|
||
|
{
|
||
|
enddevice = 22116;
|
||
|
|
||
|
}
|
||
|
|
||
|
if (enddevice == 12002)
|
||
|
{
|
||
|
enddevice = 12001;
|
||
|
|
||
|
}
|
||
|
if (enddevice == 12008)
|
||
|
{
|
||
|
enddevice = 12009;
|
||
|
|
||
|
}
|
||
|
startdevice = Lane;
|
||
|
int AutoManageIdx = ccf.GetTempManageIdx(); //������������
|
||
|
//string stack = "0";//�Ѷ���FSTACK
|
||
|
string stack = dv[0]["FSTACK"].ToString(); //�Ѷ���FSTACK
|
||
|
string barcodes = AutoManageIdx.ToString(); //��������
|
||
|
|
||
|
//int ifrevolve = 2;
|
||
|
int controltype = 2; //����
|
||
|
//int boxtype = Convert.ToInt32(dv[0]["BOX_TYPE"]);
|
||
|
string sqlstr =
|
||
|
string.Format(
|
||
|
"insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FStartCol,FStartLayer,FLOGIC_AREA) values ({0},'{1}',{2},{3},{4},{5},'{6}',{7},{8},'{9}',{10},{11},'{12}','{13}',{14},{15},'{16}')",
|
||
|
AutoManageIdx, barcodes, controltype, 2, 1, startdevice,
|
||
|
CellCode, 1, enddevice, "-", Lane, stack, "0", dtime, 0, 0,
|
||
|
enddevice);
|
||
|
|
||
|
dbo.ExceSQL(sqlstr);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient",
|
||
|
"�Զ����ɳ�������:" + AutoManageIdx.ToString(),
|
||
|
startdevice.ToString() + ":" + CellCode, enddevice.ToString());
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
if (dv[0]["FCONTROLTASKTYPE"].ToString() == "3" && CStaticClass.StopIn[Lane] == false)//�������ƿ�����
|
||
|
{
|
||
|
startdevice = Lane ;
|
||
|
enddevice = Lane;
|
||
|
|
||
|
string CellCode;
|
||
|
string startcell = dv[0]["FENDCELL"].ToString();
|
||
|
CellCode = ccf.GetNextCell(startcell, Lane);
|
||
|
|
||
|
|
||
|
if (CellCode != "-")
|
||
|
{
|
||
|
|
||
|
|
||
|
|
||
|
int AutoManageIdx = ccf.GetTempManageIdx();//������������
|
||
|
string stack = dv[0]["FSTACK"].ToString(); //�Ѷ���FSTACK
|
||
|
|
||
|
string barcodes = AutoManageIdx.ToString();//��������
|
||
|
|
||
|
//int ifrevolve = 2;
|
||
|
int controltype = 3;//�ƿ�
|
||
|
//int boxtype = 2;
|
||
|
string sqlstr = string.Format("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FStartCol,FStartLayer) values ({0},'{1}',{2},{3},{4},{5},'{6}',{7},{8},'{9}',{10},{11},'{12}','{13}',{14},{15})", AutoManageIdx, barcodes, controltype, 2, 1, startdevice, startcell, 1, enddevice, CellCode, Lane, stack, "0", dtimes, 0, 0);
|
||
|
|
||
|
dbo.ExceSQL(sqlstr);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�Զ������ƿ�����:" + AutoManageIdx.ToString(), startdevice.ToString(), enddevice.ToString() + ":" + CellCode);
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
//20101028
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FSTATUS=999,FENDTIME='").Append(dtime).Append("' where FID=").Append(fid).Append(" and F_ManageTaskKindIndex= ").Append(mti);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
switch (dv[0]["FCONTROLTASKTYPE"].ToString())
|
||
|
{
|
||
|
case "1":
|
||
|
if (dv[0]["FENDCELL"].ToString().IndexOf("-") > 0)//20100905
|
||
|
{
|
||
|
fcc = dv[0]["FENDCELL"].ToString().Split(cc);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FRUNSTATUS=0,FPALLETBARCODE='' WHERE (FLaneWay=").Append(dv[0]["FENDDEVICE"]).Append(" and F_Z='").Append(
|
||
|
fcc[0]).Append("' and F_X='").Append(fcc[1]).Append("' and F_Y='").Append(fcc[2]).Append("')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
break;
|
||
|
case "2":
|
||
|
if (dv[0]["FSTARTCELL"].ToString().IndexOf("-") > 0)//20100905
|
||
|
{
|
||
|
fcc = dv[0]["FSTARTCELL"].ToString().Split(cc);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FRUNSTATUS=0,FPALLETBARCODE='").Append(dv[0]["FPALLETBARCODE"]).Append("' WHERE (FLaneWay=").Append(dv[0]["FSTARTDEVICE"]).Append(" and F_Z=").Append(
|
||
|
fcc[0]).Append(" and F_X=").Append(fcc[1]).Append(" and F_Y=").Append(fcc[2]).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
break;
|
||
|
case "3":
|
||
|
if (dv[0]["FENDCELL"].ToString().IndexOf("-") > 0)//20100905
|
||
|
{
|
||
|
fcc = dv[0]["FENDCELL"].ToString().Split(cc);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FRUNSTATUS=0,FPALLETBARCODE='' WHERE (FLaneWay=").Append(dv[0]["FENDDEVICE"]).Append(" and F_Z=").Append(
|
||
|
fcc[0]).Append(" and F_X=").Append(fcc[1]).Append(" and F_Y=").Append(fcc[2]).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
if (dv[0]["FSTARTCELL"].ToString().IndexOf("-") > 0)//20100905
|
||
|
{
|
||
|
fcc = dv[0]["FSTARTCELL"].ToString().Split(cc);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE ST_CELL SET FRUNSTATUS=0,FPALLETBARCODE='").Append(dv[0]["FPALLETBARCODE"]).Append("' WHERE (FLaneWay=").Append(dv[0]["FSTARTDEVICE"]).Append(" and F_Z=").Append(
|
||
|
fcc[0]).Append(" and F_X=").Append(fcc[1]).Append(" and F_Y=").Append(fcc[2]).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
//20101028
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FSTATUS=900,FENDTIME='").Append(dtime).Append("' where FID=").Append(fid).Append(" and F_ManageTaskKindIndex= ").Append(mti);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
//20101028
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Manage_Task_BAK SELECT * FROM T_Manage_Task where FID=").Append(fid).Append(" and F_ManageTaskKindIndex>=1");
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Manage_Task where FID=").Append(fid).Append(" and F_ManageTaskKindIndex= ").Append(mti);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange("ReturnManageInfo", cea);
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���������豸״̬
|
||
|
/// </summary>
|
||
|
/// <param name="TaskIdx">�豸ָ������</param>
|
||
|
/// <param name="DeviceIdx">�豸����</param>
|
||
|
/// <param name="State">�豸״̬</param>
|
||
|
public void GetKindDeviceState(int TaskIdx, int DeviceIdx, int State)
|
||
|
{
|
||
|
|
||
|
int fid = ccf.GetManageTaskIndexfromMonitor(TaskIdx);
|
||
|
int mti = ccf.GetManageTaskKindIndexFromMonitor(TaskIdx);
|
||
|
if (fid <= 0) return;
|
||
|
if (State >= 10)//����
|
||
|
{
|
||
|
//��д�豸����״̬�֣�IO_Control,T_Manage_Task,T_Monitor_task��
|
||
|
|
||
|
ActionError(DeviceIdx, TaskIdx, State);//
|
||
|
#region ��������������ͬ�����е�ͬʱ��������
|
||
|
//devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
//if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
//{
|
||
|
// if (Model.CGeneralFunction.DoubleForkIfSync(TaskIdx, DeviceIdx, 1) == true)
|
||
|
// {
|
||
|
// string[] df = Model.CGeneralFunction.GetDoubleForkMonitorInfo(TaskIdx, DeviceIdx);
|
||
|
// if (df != null)
|
||
|
// {
|
||
|
// ActionError(Convert.ToInt32(df[2]), Convert.ToInt32(df[0]), States[1]);
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
//ˢ�¼���������ʾ
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
switch (ccf.GetDeviceKindIdx(DeviceIdx))
|
||
|
{
|
||
|
//�������е��豸������̽������˵�������е����豸
|
||
|
//�����������ж��Ƿ�Ϊ��������дT_Manage_Task�ĵ�ǰλ��
|
||
|
//���������ź͵�ǰλ���ж��Ƿ�����ǰ��������
|
||
|
//�����Ŵ��ݵ���ǰ�豸ʱ���ѱ�·����ǰһ�豸��������������
|
||
|
//ͬʱ�ѵ�ǰ�豸��������
|
||
|
|
||
|
case 1://�Ѷ���:
|
||
|
//1-�������� 2-����;3-Ҫ�������ط�����;
|
||
|
//4-֪ͨ����ȡ����ǰ����;����ֵ��ʾ����
|
||
|
if (State == 1)//��ʼ����
|
||
|
{//�������е��豸������̽������˵�������е����豸
|
||
|
ActionStartRun(DeviceIdx, TaskIdx);
|
||
|
|
||
|
#region ����������������ͬ����ͬʱ��������
|
||
|
//20100323
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
int[] corrtasks=Model.CGeneralFunction.MutiForkIfSync(TaskIdx, DeviceIdx, 1);
|
||
|
if (corrtasks!=null )
|
||
|
{
|
||
|
Dictionary<int, string[]> df = Model.CGeneralFunction.GetDoubleForkMonitorInfo(TaskIdx, DeviceIdx);
|
||
|
if (df != null)
|
||
|
{
|
||
|
foreach (int corrtask in corrtasks)
|
||
|
{
|
||
|
ActionStartRun(Convert.ToInt32(df[corrtask][2]), corrtask);
|
||
|
//if (mti == 1)
|
||
|
//{//20100714
|
||
|
// fid = ccf.GetManageTaskIndexfromMonitor(corrtask);
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("update IO_CONTROL set CONTROL_STATUS=11 where CONTROL_ID=").Append(fid);
|
||
|
// dboM.ExecuteSql(sql.ToString());
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
//ˢ�¼���������ʾ
|
||
|
|
||
|
}
|
||
|
if (State == 2)//��������,Ӧ��Ҳ������
|
||
|
{//20120616
|
||
|
Dictionary<int, string[]> df = Model.CGeneralFunction.GetDoubleForkMonitorInfo(TaskIdx, DeviceIdx);
|
||
|
int[] snyc = Model.CGeneralFunction.MutiForkIfSync(TaskIdx, DeviceIdx, 1);
|
||
|
ActionComplete(DeviceIdx, TaskIdx, 1);
|
||
|
|
||
|
#region ����������������ͬ����ͬʱ�������ɣ��첽��ֱ��ִ�й���������
|
||
|
//20100323
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if ((devinfo.IfCorrelDoubleFork == "1") && (df != null))
|
||
|
{
|
||
|
|
||
|
if (snyc != null)//20100702
|
||
|
{
|
||
|
foreach (int cortask in snyc)
|
||
|
{
|
||
|
ActionComplete(DeviceIdx, cortask, 1);
|
||
|
df.Remove(cortask);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
case 2://���ͻ�
|
||
|
|
||
|
if (State == 1)//��ʼ����
|
||
|
{//�������е��豸������̽������˵�������е����豸
|
||
|
ActionStartRun(DeviceIdx, TaskIdx);
|
||
|
#region ����������������ͬ����ͬʱ��������
|
||
|
//20100323
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
int[] corrtasks= Model.CGeneralFunction.MutiForkIfSync(TaskIdx, DeviceIdx, 2);
|
||
|
if (corrtasks!=null)
|
||
|
{
|
||
|
Dictionary<int, string[]> df = Model.CGeneralFunction.GetDoubleForkMonitorInfo(TaskIdx, DeviceIdx);
|
||
|
if (df != null)
|
||
|
{
|
||
|
foreach (int i in corrtasks)
|
||
|
{
|
||
|
ActionStartRun(Convert.ToInt32(df[i][2]), i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
//ˢ�¼���������ʾ
|
||
|
|
||
|
}
|
||
|
if (State == 2)//��������
|
||
|
{//20120616
|
||
|
Dictionary<int, string[]> df = Model.CGeneralFunction.GetDoubleForkMonitorInfo(TaskIdx, DeviceIdx);
|
||
|
int[] snyc = Model.CGeneralFunction.MutiForkIfSync(TaskIdx, DeviceIdx, 2);
|
||
|
ActionComplete(DeviceIdx, TaskIdx, 1);
|
||
|
//ˢ�¼���������ʾ
|
||
|
#region ����������������ͬ����ͬʱ�������ɣ��첽��ֱ��ִ�й���������
|
||
|
//20100323
|
||
|
//devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
//if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
//{
|
||
|
|
||
|
// if ((devinfo.IfCorrelDoubleFork == "1") && (df != null))//20100702
|
||
|
// {
|
||
|
|
||
|
// if (snyc != null)
|
||
|
// {
|
||
|
// foreach (int corrtask in snyc)
|
||
|
// {
|
||
|
// ActionComplete(DeviceIdx, corrtask , 1);
|
||
|
// df.Remove(corrtask);
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
}
|
||
|
#region ���ͻ����ͳ�ʱ����������34//20110608
|
||
|
|
||
|
//string begintime = Model.CGeneralFunction.GetMonitorTaskBeginTime(TaskIdx);
|
||
|
//if (begintime != "-")
|
||
|
//{
|
||
|
// if (Convert.ToDateTime(begintime.Substring(0, 19), CultureInfo.CurrentCulture).AddMinutes(int.Parse(CStaticClass.TransportTimeout)) <= DateTime.Now)
|
||
|
// {
|
||
|
// ActionError(DeviceIdx, TaskIdx, 34);
|
||
|
// }
|
||
|
//}
|
||
|
//int moindex = ccf.GetMonitorTaskIndexFromRunTimeoutDevice(DeviceIdx);
|
||
|
//if (moindex > -1)
|
||
|
//{
|
||
|
// ActionError(DeviceIdx, moindex, 34);
|
||
|
//}
|
||
|
#endregion
|
||
|
break;
|
||
|
case 31://�߶�
|
||
|
if (State == 1)
|
||
|
{//�������е��豸������̽������˵�������е����豸
|
||
|
ActionStartRun(DeviceIdx, TaskIdx);
|
||
|
//ˢ�¼���������ʾ
|
||
|
|
||
|
}
|
||
|
if (State == 2)//��������
|
||
|
{
|
||
|
ActionComplete(DeviceIdx, TaskIdx, 1);
|
||
|
//ˢ�¼���������ʾ
|
||
|
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
case 4://������
|
||
|
if (State == 1)
|
||
|
{//�������е��豸������̽������˵�������е����豸
|
||
|
ActionStartRun(DeviceIdx, TaskIdx);
|
||
|
//ˢ�¼���������ʾ
|
||
|
|
||
|
}
|
||
|
if (State == 2)//��������
|
||
|
{
|
||
|
ActionComplete(DeviceIdx, TaskIdx, 1);
|
||
|
//ˢ�¼���������ʾ
|
||
|
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
case 5://���̻�
|
||
|
|
||
|
break;
|
||
|
case 6://AGV��
|
||
|
|
||
|
break;
|
||
|
case 7://����ɨ����:��Ҫ��IO_ControlDetail���ȶ�����ֵ
|
||
|
|
||
|
break;
|
||
|
case 8://�����豸����IO_ControlDetail��д������ֵ
|
||
|
|
||
|
break;
|
||
|
case 9://վ̨
|
||
|
|
||
|
break;
|
||
|
case 10://����
|
||
|
|
||
|
break;
|
||
|
case 11://�ּ���
|
||
|
|
||
|
break;
|
||
|
case 12://�����˵�
|
||
|
|
||
|
break;
|
||
|
case 13://���豸
|
||
|
|
||
|
break;
|
||
|
case 14://ȷ�ϰ�ť
|
||
|
|
||
|
break;
|
||
|
case 15://��ʱ��
|
||
|
|
||
|
break;
|
||
|
case 16://ָʾ��
|
||
|
|
||
|
break;
|
||
|
case 17://������
|
||
|
|
||
|
break;
|
||
|
case 18://�����
|
||
|
|
||
|
break;
|
||
|
|
||
|
#region add by lyj20180427������˫��������������
|
||
|
case 40:
|
||
|
|
||
|
if (State == 1)//��ʼ����
|
||
|
{//�������е��豸������̽������˵�������е����豸
|
||
|
ActionStartRun(DeviceIdx, TaskIdx);
|
||
|
#region ����������������ͬ����ͬʱ��������
|
||
|
//20100323
|
||
|
|
||
|
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
int[] corrtasks= Model.CGeneralFunction.MutiForkIfSync(TaskIdx, DeviceIdx, 40);
|
||
|
|
||
|
if (corrtasks!=null)
|
||
|
{
|
||
|
|
||
|
ActionStartRun(DeviceIdx, corrtasks[0]);
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
//ˢ�¼���������ʾ
|
||
|
|
||
|
}
|
||
|
if (State == 2)//��������
|
||
|
{
|
||
|
int[] snyc = Model.CGeneralFunction.MutiForkIfSync(TaskIdx, DeviceIdx,40);
|
||
|
|
||
|
ActionComplete(DeviceIdx, TaskIdx, 1);
|
||
|
//ˢ�¼���������ʾ
|
||
|
#region ����������������ͬ����ͬʱ�������ɣ��첽��ֱ��ִ�й���������
|
||
|
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
|
||
|
ActionComplete(DeviceIdx, snyc[0], 1);
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// �ӵ�����λ����ʵ�յ���λ��ȡ�����ͻ�ָ��
|
||
|
/// </summary>
|
||
|
/// <param name="mti">��������</param>
|
||
|
/// <param name="fid">������������</param>
|
||
|
/// <param name="device">�豸����</param>
|
||
|
/// <param name="monitorindex">�豸ָ������</param>
|
||
|
bool AppendMoveCellOperate(int mti, int fid, int device,int monitorindex)
|
||
|
{//20120820
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
string newuseawayfork = string.Empty;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FExceptionNO=NULL where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(fid);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_ManTaskReserve=").Append((mti.ToString() + fid.ToString())).Append(" where F_DeviceIndex=").Append(device);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//��ȡ���������ͻ����꣬��ǰ����������·�������룬���ȼ���Զ�����棬��ǰ����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FENDCELL FROM T_Manage_Task WHERE (FID = ").Append(fid).Append(") AND (F_ManageTaskKindIndex = ").Append(mti).Append(")");
|
||
|
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
string[] spcell = dbo.GetSingle(sql.ToString()).ToString().Split(cc);
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_NumParam4, F_NumParam5,F_NumParam6, F_RouteID,F_MonitorTaskLevel, F_UseAwayFork, F_TxtParam, F_AGVTask, F_AGVNextTask,F_ChangeStackCell from T_Monitor_Task where F_MonitorIndex=").Append(monitorindex);////20120820
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count <= 0) return false;
|
||
|
//��������ʱ����Ŀ��λ�ö�λ����newuseawayfork
|
||
|
newuseawayfork = "0";
|
||
|
int snextq = int.Parse(dv[0]["F_AGVTask"].ToString());//20120518
|
||
|
int snexts = int.Parse(dv[0]["F_AGVNextTask"].ToString());//20120518
|
||
|
int lev = int.Parse(dv[0]["F_MonitorTaskLevel"].ToString());
|
||
|
int routeid = int.Parse(dv[0]["F_RouteID"].ToString());
|
||
|
int fnp1 = int.Parse(dv[0]["F_NumParam4"].ToString());
|
||
|
int fnp2 = int.Parse(dv[0]["F_NumParam5"].ToString());
|
||
|
int fnp3 = int.Parse(dv[0]["F_NumParam6"].ToString());
|
||
|
string pcode = dv[0]["F_TxtParam"].ToString();
|
||
|
string ChangeStackCell = dv[0]["F_ChangeStackCell"].ToString();//20120820
|
||
|
StringBuilder aheaddet = new StringBuilder("I" + device.ToString());
|
||
|
//����Ŀ����λ���������Ƿ��л�
|
||
|
int forkno = Convert.ToInt32(ccf.GetLimitXForkNo(Convert.ToInt32(spcell[1]), ccf.GetLaneWayNoFromStack(device)));
|
||
|
if (forkno > 0)
|
||
|
{
|
||
|
newuseawayfork = forkno.ToString();//20140214��������
|
||
|
aheaddet.Append(";D").Append(device.ToString()).Append(".").Append(Convert.ToInt32(forkno - 1));
|
||
|
}
|
||
|
int mindex = snextq;//20120518
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task (F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex, F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4, F_NumParam5,").Append(
|
||
|
" F_NumParam6, F_TxtParam, F_AheadDetect, F_UseAwayFork,f_ChangeStackCell)VALUES ").Append(
|
||
|
"(").Append(fid).Append(",").Append(mti).Append(",").Append(mindex).Append(",").Append(lev).Append(",").Append(device).Append(",4,").Append(routeid).Append(",0,").Append(fnp1).Append(",").Append(fnp2).Append(",").Append(fnp3).Append(",").Append(
|
||
|
spcell[0]).Append(",").Append(spcell[1]).Append(",").Append(spcell[2]).Append(",'").Append(pcode).Append("','").Append(aheaddet.ToString()).Append("','").Append(newuseawayfork).Append("','").Append(ChangeStackCell).Append("')");//20120820
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
mindex = snexts;//20120518
|
||
|
aheaddet = new StringBuilder("I" + device.ToString());
|
||
|
if (forkno > 0)
|
||
|
{
|
||
|
aheaddet.Append(";D-").Append(device.ToString()).Append(".").Append(Convert.ToInt32(forkno - 1));
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task (F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex, F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4, F_NumParam5,").Append(
|
||
|
" F_NumParam6, F_TxtParam, F_AheadDetect, F_UseAwayFork)VALUES ").Append(
|
||
|
"(").Append(fid).Append(",").Append(mti).Append(",").Append(mindex).Append(",").Append(lev).Append(",").Append(device).Append(",5,").Append(routeid).Append(",0,").Append(fnp1).Append(",").Append(fnp2).Append(",").Append(fnp3).Append(",").Append(
|
||
|
spcell[0]).Append(",").Append(spcell[1]).Append(",").Append(spcell[2]).Append(",'").Append(pcode).Append("','").Append(aheaddet.ToString()).Append("','").Append(newuseawayfork).Append("')");//20120820
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", string.Format("��������ʱ��{0}", ex.StackTrace + ex.Message));
|
||
|
OnRefreshMonitor(rmea);
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
bool AppendStackMoveCellOperate(int mti, int fid, int device, int monitorindex)
|
||
|
{//20120820
|
||
|
string newuseawayfork=string.Empty;
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
DataView dvl = new DataView(); DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FExceptionNO=NULL where F_ManageTaskKindIndex=").Append(mti).Append(" and FID=").Append(fid);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
//��ȡ���������ͻ����꣬��ǰ����������·�������룬���ȼ���Զ�����棬��ǰ����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FREMARK FROM T_Manage_Task WHERE (FID = ").Append(fid).Append(") AND (F_ManageTaskKindIndex = ").Append(mti).Append(")");
|
||
|
object arrcell = dbo.GetSingle(sql.ToString());
|
||
|
if (arrcell == null) return false ;
|
||
|
string[] spcell = arrcell.ToString().Split(cc);
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_NumParam4, F_NumParam5,F_NumParam6, F_RouteID,F_MonitorTaskLevel, F_UseAwayFork, F_TxtParam,F_AheadDetect,F_PriorMonitor,F_AGVTask,F_AGVNextTask,F_ChangeStackCell from T_Monitor_Task where F_MonitorIndex=").Append(monitorindex);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count <= 0) return false ;
|
||
|
//��������ʱ����Ŀ��λ�ö�λ����newuseawayfork
|
||
|
newuseawayfork = "0";
|
||
|
int lev = int.Parse(dv[0]["F_MonitorTaskLevel"].ToString());
|
||
|
int routeid = int.Parse(dv[0]["F_RouteID"].ToString());
|
||
|
int fnp1 = int.Parse(dv[0]["F_NumParam4"].ToString());
|
||
|
int fnp2 = int.Parse(dv[0]["F_NumParam5"].ToString());
|
||
|
int fnp3 = int.Parse(dv[0]["F_NumParam6"].ToString());
|
||
|
string pcode = dv[0]["F_TxtParam"].ToString();
|
||
|
int lifterUp = int.Parse(dv[0]["F_PriorMonitor"].ToString());
|
||
|
int snextq = int.Parse(dv[0]["F_AGVTask"].ToString());
|
||
|
int snexts = int.Parse(dv[0]["F_AGVNextTask"].ToString());
|
||
|
string ChangeStackCell = dv[0]["F_ChangeStackCell"].ToString();
|
||
|
int olddev = device;
|
||
|
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(device);
|
||
|
int StackIndex = devinfo.VirtualStack;
|
||
|
device = devinfo.MutexStack;
|
||
|
StringBuilder aheaddet = new StringBuilder("I" + device.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"]);
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate WHERE (F_ZXY = '").Append(arrcell.ToString()).Append("') and F_LaneIndex=").Append(laneway);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{//20120420�߶˸�λ�ź���.2���������ͻ���λ�ź���.6
|
||
|
if (ccf.GetDeviceKindIdx(Convert.ToInt32(dv[0][0])) == 2)
|
||
|
{
|
||
|
aheaddet.Append(";D" + dv[0][0].ToString() + ".0;D-" + dv[0][0].ToString() + ".6;N" + dv[0][0].ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
aheaddet.Append(";D" + dv[0][0].ToString() + ".0;D-" + dv[0][0].ToString() + ".2;N" + dv[0][0].ToString());
|
||
|
}
|
||
|
}
|
||
|
StringBuilder aht = new StringBuilder(aheaddet.ToString());
|
||
|
int forkno = Convert.ToInt32(ccf.GetLimitXForkNo(Convert.ToInt32(spcell[1]), ccf.GetLaneWayNoFromStack(device)));
|
||
|
if (forkno > 0)
|
||
|
{
|
||
|
newuseawayfork = forkno.ToString();//20140214��������
|
||
|
aht.Append(";D").Append(device.ToString()).Append(".").Append(Convert.ToInt32(forkno - 1));
|
||
|
}
|
||
|
int mindex =snextq;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task (F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex, F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4, F_NumParam5,").Append(
|
||
|
" F_NumParam6, F_TxtParam, F_AheadDetect, F_UseAwayFork,F_PriorMonitor,ChangeStackCell)VALUES ").Append(
|
||
|
"(").Append(fid).Append(",").Append(mti).Append(",").Append(mindex).Append(",").Append(lev).Append(",").Append(device).Append(",4,").Append(routeid).Append(",0,").Append(fnp1).Append(",").Append(fnp2).Append(",").Append(fnp3).Append(",").Append(
|
||
|
spcell[0]).Append(",").Append(spcell[1]).Append(",").Append(spcell[2]).Append(",'").Append(pcode).Append("','").Append(aht).Append("','").Append(newuseawayfork).Append("',").Append(lifterUp).Append(",'").Append(ChangeStackCell).Append("')");
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
mindex = snexts;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("INSERT INTO T_Monitor_Task (F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex, F_MonitorTaskLevel,").Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4, F_NumParam5,").Append(
|
||
|
" F_NumParam6, F_TxtParam, F_AheadDetect, F_UseAwayFork,F_PriorMonitor)VALUES ").Append(
|
||
|
"(").Append(fid).Append(",").Append(mti).Append(",").Append(mindex).Append(",").Append(lev).Append(",").Append(device).Append(",5,").Append(routeid).Append(",0,").Append(fnp1).Append(",").Append(fnp2).Append(",").Append(fnp3).Append(",").Append(
|
||
|
spcell[0]).Append(",").Append(spcell[1]).Append(",").Append(spcell[2]).Append(",'").Append(pcode).Append("','").Append(aheaddet).Append("','").Append(newuseawayfork).Append("',").Append(lifterUp).Append(")");
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("tsStatus", string.Format("��������ʱ��{0}", ex.StackTrace + ex.Message));
|
||
|
OnRefreshMonitor(rmea);
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dvl.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
int GetRouteIDsub(int device)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
dv = dbo.ExceSQL("SELECT F_RouteIDSub, F_DeviceIndex, F_RouteID FROM T_Base_Route_Device where F_DeviceIndex=" + device + "").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_RouteIDSub"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
string GetUseAwayForkFromLaneGate(int device)
|
||
|
{//20120820
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
dv = dbo.ExceSQL(string.Format("SELECT F_UseAwayFork FROM T_Base_Lane_Gate WHERE (F_LaneGateDeviceIndex = {0}) ", device)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return dv[0]["F_UseAwayFork"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "0";
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
int GetStackGetXCoordinateFromLaneGate(int stackIndex, int devIndex)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
int LaneWay = ccf.GetLaneWayFromLaneInfo(stackIndex);
|
||
|
char[] cc = new char[1] { '-' };
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Base_Lane_Gate where F_LaneGateDeviceIndex=").Append(devIndex).Append(" and F_LaneIndex=").Append(LaneWay);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
|
||
|
return Convert.ToInt32(dv[0]["F_ZXY"].ToString().Split(cc)[1]);//��X
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
CGetStateError = "ControlSystem.CGetState.GetStackGetXCoordinateFromLaneGate:" +ex.StackTrace+ ex.Message;
|
||
|
return -1;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|