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.
2263 lines
130 KiB
2263 lines
130 KiB
3 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
using System.Data;
|
||
|
using DBFactory;
|
||
|
using ICommLayer;
|
||
|
using CommLayerFactory;
|
||
|
using CommonLib;
|
||
|
namespace WcfControlMonitorLib
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu
|
||
|
///
|
||
|
/// һ����λ������λ�������ֳ����ƴ����������źţ�
|
||
|
/// 1-�ط���ǰ�豸ָ��
|
||
|
/// 2-�����ĵ�ǰ�豸��ִ��������Ŀ��λ��
|
||
|
/// 3-���浱ǰ�豸��ִ�е���������
|
||
|
/// 4-ɾ����ǰ�豸��ִ�е��������������ߣ�
|
||
|
/// ��������PLC�����Զ�������������
|
||
|
/// </summary>
|
||
|
public class CListenPLCAsk
|
||
|
{
|
||
|
char[] dd = new char[1] { '.' };//20101124
|
||
|
string[] DS;//20101124
|
||
|
string _listenPLCAskError="";
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
|
||
|
public string ListenPLCAskError
|
||
|
{
|
||
|
get { return _listenPLCAskError; }
|
||
|
set { _listenPLCAskError = value; }
|
||
|
}
|
||
|
DBOperator dboM =CStaticClass.dboM;
|
||
|
DBOperator dbo = CStaticClass.dbo;
|
||
|
CCommonFunction ccf = new CCommonFunction();
|
||
|
CGetState cgs = new CGetState();
|
||
|
ISendDeviceOrder sdo;
|
||
|
Model.MDevice devinfo;
|
||
|
public static event CDataSourceChangeEventHandler DataChange;
|
||
|
public static void OnDataChange(CDataChangeEventArgs e)
|
||
|
{
|
||
|
if (DataChange != null)
|
||
|
{
|
||
|
DataChange(null, e);
|
||
|
}
|
||
|
}
|
||
|
public static event RefreshMonitorEventHandler RefreshMonitor;
|
||
|
public static void OnRefreshMonitor(RefreshMonitorEventArgs e)
|
||
|
{
|
||
|
if (RefreshMonitor != null)
|
||
|
{
|
||
|
RefreshMonitor(e);
|
||
|
}
|
||
|
}
|
||
|
//20110331
|
||
|
//public ManageService.S_ManageService client = new ManageService.S_ManageService();
|
||
|
//public ManageService.S_ManageService clientOne = new ManageService.S_ManageService();
|
||
|
//public ManageService.S_ManageService clientApp = new ManageService.S_ManageService();
|
||
|
|
||
|
//20110331
|
||
|
public CListenPLCAsk()
|
||
|
{
|
||
|
//client.ManageStockCreateCompleteCompleted += new WcfControlMonitorLib.ManageService.ManageStockCreateCompleteCompletedEventHandler(client_ManageStockCreateCompleteCompleted);
|
||
|
//clientOne.ManageStockCreateCompleteCompleted += new WcfControlMonitorLib.ManageService.ManageStockCreateCompleteCompletedEventHandler(client_ManageStockCreateCompleteCompleted);
|
||
|
////client.ManageStockCreateApplyCompleted += new ControlSystem.ManageService.ManageStockCreateApplyCompletedEventHandler(client_ManageStockCreateApplyCompleted);
|
||
|
////clientApp.ManageStockCreateCompleteCompleted += new ControlSystem.ManageService.ManageStockCreateCompleteCompletedEventHandler(clientApp_ManageStockCreateCompleteCompleted);
|
||
|
//clientApp.ManageStockCreateApplyCompleted += new WcfControlMonitorLib.ManageService.ManageStockCreateApplyCompletedEventHandler(clientApp_ManageStockCreateApplyCompleted);
|
||
|
}
|
||
|
|
||
|
// public void client_ManageStockCreateCompleteCompleted(object sender, WcfControlMonitorLib.ManageService.ManageStockCreateCompleteCompletedEventArgs e)
|
||
|
// {
|
||
|
// //20110331
|
||
|
// if (e.Error != null)
|
||
|
// {
|
||
|
// _listenPLCAskError = DateTime.Now.ToString("u")+",CListenPLCAsk���������첽�ص������ӹ�����������ʱ����������" + e.Error.Message;
|
||
|
// return;
|
||
|
// }
|
||
|
// //20110505һ¥12035�ϵ�14001�������ɺ�����Ҫ�´�12035--12036���ͳ�����
|
||
|
|
||
|
// }
|
||
|
|
||
|
//public void clientApp_ManageStockCreateApplyCompleted(object sender, WcfControlMonitorLib.ManageService.ManageStockCreateApplyCompletedEventArgs e)
|
||
|
//{
|
||
|
// //20110331
|
||
|
// if (e.Error != null)
|
||
|
// {
|
||
|
// _listenPLCAskError = DateTime.Now.ToString("u") + ",CListenPLCAsk�������������첽�ص������ӹ�����������ʱ����������" + e.Error.Message;
|
||
|
// return;
|
||
|
// }
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("SELECT F_DBW2Address, T_Base_PLC_Ask.F_DeviceIndex,T_Base_PLC_Ask.F_BindingDevice, F_Askkind,F_TaskIndex,F_BarCode,F_Remark").Append(
|
||
|
// ",F_FirstProject,F_BoxBarcode,F_TempFirstProject FROM T_Base_Device,T_Base_PLC_Ask").Append(
|
||
|
// " where T_Base_Device.F_DeviceIndex=T_Base_PLC_Ask.F_DeviceIndex and T_Base_Device.F_DeviceIndex=").Append(Convert.ToInt32(e.sDeviceCode)).Append(
|
||
|
// " order by T_Base_Device.F_DeviceIndex desc");
|
||
|
|
||
|
// DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
// if (dv.Count == 0) return;
|
||
|
// int i = 0;
|
||
|
// int dcode = Convert.ToInt32(dv[i]["F_BindingDevice"]);
|
||
|
// string barcode = dv[i]["F_BarCode"].ToString();
|
||
|
|
||
|
// StringBuilder dtime = new StringBuilder(DateTime.Now.ToString("u"));
|
||
|
// dtime.Remove(dtime.Length - 1, 1);
|
||
|
|
||
|
|
||
|
// switch (e.ManageStockCreateApplyResult)
|
||
|
// { //F_BoxBarcode���̻����ͻ�22016��F_TempFirstProject������Ŀ�����ͻ�22018��F_Remark���̻�
|
||
|
|
||
|
// case 1://��ǰ������22015-22016
|
||
|
|
||
|
// //������ʱ��������T_Manage_Task(�����µĵ�������)��
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,").
|
||
|
// Append("FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME) ").
|
||
|
// Append("values(").Append(ccf.GetTempManageIdx()).Append(",'").Append(barcode).Append("',1,2,'").Append(ccf.GetWarehouseIndex()).Append("','").Append(dcode).Append("','-','").Append(ccf.GetWarehouseIndex()).Append("','"
|
||
|
// ).Append(dv[i]["F_BoxBarcode"]).Append("','-',0,0,'-','").Append(dtime).Append("')");//20101028
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
// break;
|
||
|
// case 2://��ǰ�䲻���̣�������22015-22018
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,").
|
||
|
// Append("FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME) ").
|
||
|
// Append("values(").Append(ccf.GetTempManageIdx()).Append(",'").Append(barcode).Append("',1,2,'").Append(ccf.GetWarehouseIndex()).Append("','").Append(dcode).Append("','-','").Append(ccf.GetWarehouseIndex()).Append("','"
|
||
|
// ).Append(dv[i]["F_TempFirstProject"]).Append("','-',0,0,'-','").Append(dtime).Append("')");//20101028
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
// break;
|
||
|
// case 3://���̻�������ǿ������22016-22018����ǰ������22015-22016
|
||
|
|
||
|
// ////////////////���̻�������ǿ������
|
||
|
// object ob = dbo.GetSingle("SELECT F_BarCode FROM T_Base_PLC_Ask WHERE (F_BarCode <> '-') and (F_DeviceIndex=" + dv[i]["F_Remark"] + ")");
|
||
|
// if (ob != null)
|
||
|
// {
|
||
|
// //20110505һ¥ǿ�Ƶ��������´��ڵ��̻�14001
|
||
|
// int dpjcode = 0;
|
||
|
// if (dv[i]["F_Remark"].ToString() == "14001")
|
||
|
// {
|
||
|
// dpjcode = 14001;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// dpjcode = Convert.ToInt32(dv[i]["F_BoxBarcode"]);
|
||
|
// }
|
||
|
// int hidx = ccf.GetTempManageIdx();
|
||
|
// int hmindx = ccf.GetMonitorIndex(hidx, 2);
|
||
|
// string ah = string.Format("D-{0}.0;D{1}.0;I{0};I{1}", dv[i]["F_Remark"].ToString(), dv[i]["F_BoxBarcode"].ToString());
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("insert into T_Monitor_Task(F_MonitorTaskLevel,F_RouteID,F_ManageTaskIndex,F_ManageTaskKindIndex,F_MonitorIndex,").
|
||
|
// Append("F_DeviceIndex,F_DeviceCommandIndex,F_UseAwayFork,F_AheadDetect,F_RunningLock,F_TxtParam) ").
|
||
|
// Append("values(2,").Append(GetRouteIDsub(Convert.ToInt32(dv[i]["F_BoxBarcode"]))).Append(",").Append(hidx).Append(",2,").Append(hmindx).Append(",").Append(dpjcode).
|
||
|
// Append(",8,'-','").Append(ah).Append("','").Append(dcode.ToString()).Append("','").Append(ob.ToString()).Append("')");
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("update T_Base_device set F_LockedState=").Append(hmindx).Append(
|
||
|
// " where F_DeviceIndex=").Append(dcode);
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,").
|
||
|
// Append("FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FIntoStepOK) ").
|
||
|
// Append("values(").Append(hidx).Append(",'").Append(ob.ToString()).Append("',1,2,'").Append(ccf.GetWarehouseIndex()).Append("','").Append(Convert.ToInt32(dv[i]["F_BoxBarcode"])).Append("','-','").Append(ccf.GetWarehouseIndex()).Append("','"
|
||
|
// ).Append(dv[i]["F_TempFirstProject"]).Append("','-',0,0,'-','").Append(dtime).Append("','1')");
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
// }
|
||
|
// ////////////////��ǰ������
|
||
|
// sql.Remove(0, sql.Length);
|
||
|
// sql.Append("insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,").
|
||
|
// Append("FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME) ").
|
||
|
// Append("values(").Append(ccf.GetTempManageIdx()).Append(",'").Append(barcode).Append("',1,2,'").Append(ccf.GetWarehouseIndex()).Append("','").Append(dcode).Append("','-','").Append(ccf.GetWarehouseIndex()).Append("','"
|
||
|
// ).Append(dv[i]["F_BoxBarcode"]).Append("','-',0,0,'-','").Append(dtime).Append("')");
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
// break;
|
||
|
// default:
|
||
|
// _listenPLCAskError = "���̻�ǰ�����ͻ���" + dcode.ToString() + "��ɨ����������������������ʱ�������������������Ĵ�����������ȷ��";
|
||
|
// return;
|
||
|
|
||
|
// }
|
||
|
|
||
|
|
||
|
|
||
|
//}
|
||
|
//20110331
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����PLC�����Զ�������������:1:��λ������λ�������ֳ����ƴ����������ź�;2�����̻��ϱ��������ɣ�
|
||
|
/// 3��PLC�������ɣ�4������ɨ������������������5�����̻�����������������
|
||
|
/// </summary>
|
||
|
public void DealwithPLCAsk()
|
||
|
{
|
||
|
//20091128
|
||
|
int[] bc;
|
||
|
StringBuilder[] wv = {new StringBuilder("2") };
|
||
|
StringBuilder[] witemnames ={ new StringBuilder("") };
|
||
|
|
||
|
DataView dv; DataView dvbc; DataView dvm;
|
||
|
DataView dplc; DataView dvma;
|
||
|
DataView dvp; DataView dvs;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT T_Base_PLC_Ask.F_DeviceIndex,T_Base_PLC_Ask.F_BindingDevice, F_Askkind,F_TaskIndex,F_BarCode,F_Remark" ).Append(
|
||
|
",F_FirstProject,F_BoxBarcode,F_TempFirstProject FROM T_Base_Device,T_Base_PLC_Ask").Append(
|
||
|
" where T_Base_Device.F_DeviceIndex=T_Base_PLC_Ask.F_DeviceIndex " ).Append(
|
||
|
" order by T_Base_Device.F_DeviceIndex desc");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
int deviceindex = Convert.ToInt32(dv[i]["F_DeviceIndex"]);
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(deviceindex);
|
||
|
witemnames[0].Remove(0, witemnames[0].Length);
|
||
|
witemnames[0] .Append(Model.CGeneralFunction.DBGet).Append(",byte").Append(Convert.ToString(devinfo.Dbw2Address + 0));
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(deviceindex);
|
||
|
#region ��λ������λ�������ֳ����ƴ����������ź�
|
||
|
if (dv[i]["F_Askkind"].ToString() == "1")//��λ������λ�������ֳ����ƴ����������ź�
|
||
|
{
|
||
|
//gds = CommModeCreate.CreateGetDeviceState(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
//bc = gds.GetDeviceState(Convert.ToInt32(dv[i]["F_DeviceIndex"]), 64777);
|
||
|
bc = CStaticClass.GetDeviceState(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
if (bc == null) continue;
|
||
|
//bc[3];//�豸��������ǰ�����豸��������
|
||
|
//bc[4];//�����ţ���Ҫ��Ŀ��λ�õ������ţ�
|
||
|
|
||
|
int bcz = 0;
|
||
|
string barcode = string.Empty;
|
||
|
for (int j = 5; j < 15; j++)
|
||
|
{
|
||
|
bcz = bcz + bc[j];
|
||
|
barcode += Convert.ToChar(bc[j]);
|
||
|
}
|
||
|
|
||
|
#region �����ط���ǰ�豸ָ��
|
||
|
|
||
|
if (bc[2] == 1)//������
|
||
|
{
|
||
|
//20090925
|
||
|
int fid = 0;
|
||
|
int mankind = 0;
|
||
|
if (bc[4] > 0)
|
||
|
{
|
||
|
//20091128
|
||
|
sql.Remove(0,sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," ).Append(
|
||
|
"F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6,F_RouteID FROM T_Monitor_Task WHERE F_MonitorIndex = '" ).Append(
|
||
|
bc[4] ).Append( "' order by F_MonitorIndex asc");
|
||
|
dvbc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{//20090925
|
||
|
fid = ccf.GetManageTaskIndexfromMonitor(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
mankind = ccf.GetManageTaskKindIndexFromMonitor(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
if (DeviceInRouteSub(bc[3], Convert.ToInt32(dvbc[0]["F_RouteID"])) == true)
|
||
|
{
|
||
|
|
||
|
RestoreDevice(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
|
||
|
//��¼������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_PLC_Ask set F_TaskIndex='" ).Append( bc[4]
|
||
|
).Append( "' where F_DeviceIndex=" ).Append( Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Manage_Task SET FCurrentLocation=" ).Append( bc[3] ).Append( " where FID=" ).Append( fid ).Append( " and F_ManageTaskKindIndex=" ).Append( mankind);
|
||
|
dbo.ExceSQL( sql.ToString());
|
||
|
//�ж��Ƿ���Ҫ�����������ĵ�����������·����������·���������þ���Ҫ�����������ĵ���������ѡ��һ�����õ���·�������иĵ�
|
||
|
//20091005
|
||
|
if (GetUseableRouteIDSub(fid, mankind, bc[3]) == false)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(fid, mankind);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (bcz > 0)
|
||
|
{// 20090928 and F_DeviceIndex=" + bc[3] + "
|
||
|
//ʹ��������ѯ���������ţ�������bc[3]�豸��������ǰ�����豸���������ط�����
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," ).Append(
|
||
|
"F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6,F_RouteID FROM T_Monitor_Task WHERE F_TxtParam = '" ).Append(
|
||
|
barcode ).Append( "' order by F_MonitorIndex asc");
|
||
|
dvbc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{//20090925
|
||
|
fid = ccf.GetManageTaskIndexfromMonitor(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
mankind = ccf.GetManageTaskKindIndexFromMonitor(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
if (DeviceInRouteSub(bc[3], Convert.ToInt32(dvbc[0]["F_RouteID"])) == true)
|
||
|
{
|
||
|
if (dvbc[0]["F_NumParam4"].ToString() == bc[3].ToString())
|
||
|
{
|
||
|
AssociateComplete(Convert.ToInt32(dvbc[0]["F_DeviceIndex"]), Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
RestoreDevice(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
|
||
|
//��¼������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_PLC_Ask set F_BarCode='" ).Append( barcode
|
||
|
).Append( "' where F_DeviceIndex=" ).Append( Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Manage_Task SET FCurrentLocation=" ).Append( bc[3] ).Append( " where FID=" ).Append( fid ).Append( " and F_ManageTaskKindIndex=" ).Append( mankind);
|
||
|
dbo.ExceSQL( sql.ToString());
|
||
|
//�ж��Ƿ���Ҫ�����������ĵ�����������·����������·���������þ���Ҫ�����������ĵ���������ѡ��һ�����õ���·�������иĵ�
|
||
|
//20091005
|
||
|
if (GetUseableRouteIDSub(fid, mankind, bc[3]) == false)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(fid, mankind);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0] .Append( "4");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region �����ĵ�ǰ�豸��ִ������Ŀ��λ��
|
||
|
|
||
|
else if (bc[2] == 2)//������
|
||
|
{
|
||
|
//20090925
|
||
|
int fid = 0;
|
||
|
int mankind = 0;
|
||
|
if (bc[4] > 0)
|
||
|
{ //20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," ).Append(
|
||
|
"F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_MonitorIndex = '" ).Append(
|
||
|
bc[4] ).Append( "' order by F_MonitorIndex asc");
|
||
|
dvbc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{
|
||
|
fid = ccf.GetManageTaskIndexfromMonitor(bc[4]);
|
||
|
mankind = ccf.GetManageTaskKindIndexFromMonitor(bc[4]);
|
||
|
}
|
||
|
}
|
||
|
else if (bcz > 0)
|
||
|
{
|
||
|
//ʹ��������ѯ���������ţ�������bc[3]�豸��������ǰ�����豸���������ط�����
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," ).Append(
|
||
|
"F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_TxtParam = '" ).Append(
|
||
|
barcode ).Append( "' order by F_MonitorIndex asc");
|
||
|
dvbc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{
|
||
|
|
||
|
fid = ccf.GetManageTaskIndexfromMonitor(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
mankind = ccf.GetManageTaskKindIndexFromMonitor(Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
////�����ĵ�ǰ�豸��ִ������Ŀ��λ�õ�F_TaskIndex�ظ�ʱ��������Ӧ����
|
||
|
//if (bc[4] == Convert.ToInt32(dv[i]["F_TaskIndex"]))
|
||
|
//{
|
||
|
// continue;
|
||
|
//}
|
||
|
//��¼�������豸����bc[3]������������FCurrentLocation;//�豸��������ǰ�����豸��������
|
||
|
//20090925
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Manage_Task SET FCurrentLocation=" ).Append( bc[3] ).Append( " where FID=" ).Append( fid ).Append( " and F_ManageTaskKindIndex=" ).Append( mankind);
|
||
|
dbo.ExceSQL( sql.ToString());
|
||
|
//�ж��Ƿ���Ҫ�����������ĵ�����������·����������·���������þ���Ҫ�����������ĵ���������ѡ��һ�����õ���·�������иĵ�
|
||
|
//20091005
|
||
|
if (GetUseableRouteIDSub(fid, mankind, bc[3]) == false)
|
||
|
{
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
GetUsableDestination(fid, mankind);
|
||
|
}
|
||
|
}
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("5");
|
||
|
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region PLC�ϱ�����
|
||
|
else if (bc[2] == 3)
|
||
|
{
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
//20090915
|
||
|
if (bc[4] > 0)
|
||
|
{
|
||
|
//20090915 and F_DeviceIndex=" + bc[3] + "
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," ).Append(
|
||
|
"F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_MonitorIndex = '" ).Append(
|
||
|
bc[4] ).Append( "' order by F_MonitorIndex asc");
|
||
|
dvbc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{
|
||
|
AssociateComplete(Convert.ToInt32(dvbc[0]["F_DeviceIndex"]), bc[4]);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else if (bcz > 0)
|
||
|
{
|
||
|
//ʹ��������ѯ����������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam1,F_NumParam2," ).Append(
|
||
|
"F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 FROM T_Monitor_Task WHERE F_TxtParam = '" ).Append(
|
||
|
barcode ).Append( "' order by F_MonitorIndex asc");
|
||
|
dvbc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{
|
||
|
if (dvbc[0]["F_NumParam4"].ToString() == bc[3].ToString())
|
||
|
{
|
||
|
AssociateComplete(Convert.ToInt32(dvbc[0]["F_DeviceIndex"]), Convert.ToInt32(dvbc[0]["F_MonitorIndex"]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("37");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//20090915
|
||
|
|
||
|
|
||
|
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ɾ����ǰ�豸��ִ�е�����(4)���������ߣ�
|
||
|
else if (bc[2] == 4)//������
|
||
|
{
|
||
|
//20090915
|
||
|
if (bc[4] > 0)
|
||
|
{
|
||
|
int fid = ccf.GetManageTaskIndexfromMonitor(bc[4]);
|
||
|
int mti = ccf.GetManageTaskKindIndexFromMonitor(bc[4]);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FExceptionNO=" ).Append( Model.CGeneralFunction.TASKDELETE ).Append( " where (F_ManageTaskKindIndex = " ).Append( mti ).Append( ") AND (FID = " ).Append( fid ).Append( ")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
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());
|
||
|
//֪ͨ��������ɾ��������������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTaskKindIndex, F_ManageTaskIndex,F_DeviceIndex,F_MonitorIndex " ).Append(
|
||
|
" FROM T_Monitor_Task Where F_ManageTaskIndex=" ).Append( fid ).Append( " and F_ManageTaskKindIndex= " ).Append(
|
||
|
mti);
|
||
|
dvm = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvm.Count > 0)
|
||
|
{
|
||
|
for (int ii = 0; ii < dvm.Count; ii++)
|
||
|
{
|
||
|
if (Convert.ToInt32(dv[ii]["F_Status"]) >= 1)
|
||
|
{
|
||
|
cgs.ActionComplete(Convert.ToInt32(dvm[ii]["F_DeviceIndex"]), Convert.ToInt32(dvm[ii]["F_MonitorIndex"]), 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cgs.ActionComplete(Convert.ToInt32(dvm[ii]["F_DeviceIndex"]), Convert.ToInt32(dvm[ii]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (bcz > 0)
|
||
|
{
|
||
|
|
||
|
//֪ͨ��������ɾ��������������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTaskKindIndex, F_ManageTaskIndex,F_DeviceIndex,F_MonitorIndex " ).Append(
|
||
|
" FROM T_Monitor_Task Where F_TxtParam ='" ).Append( barcode ).Append( "'");
|
||
|
dvm = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvm.Count > 0)
|
||
|
{
|
||
|
int fid = Convert.ToInt32(dvm[0]["F_ManageTaskIndex"]);
|
||
|
int mti = Convert.ToInt32(dvm[0]["F_ManageTaskKindIndex"]);
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Manage_Task set FExceptionNO=" ).Append( Model.CGeneralFunction.TASKDELETE ).Append( " where (F_ManageTaskKindIndex = " ).Append( mti ).Append( ") AND (FID = " ).Append( fid ).Append( ")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
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());
|
||
|
for (int ii = 0; ii < dvm.Count; ii++)
|
||
|
{
|
||
|
if (Convert.ToInt32(dv[ii]["F_Status"]) >= 1)
|
||
|
{
|
||
|
cgs.ActionComplete(Convert.ToInt32(dvm[ii]["F_DeviceIndex"]), Convert.ToInt32(dvm[ii]["F_MonitorIndex"]), 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
cgs.ActionComplete(Convert.ToInt32(dvm[ii]["F_DeviceIndex"]), Convert.ToInt32(dvm[ii]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("3");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
if (CStaticClass.DeviceErrorAutoModifyRoutePath == "1")
|
||
|
{//20091107
|
||
|
#region ��λ�������λ�����϶�����ͨ���Զ�����·��������һ�����������յ��ĸ������ͻ���
|
||
|
//F_Askkind=9
|
||
|
//����ijһ������������ʮ��·�ڴ�ͣ������30�룬���ȼ�������û���ϣ�Ȼ�������������������ͻ������Ѷ����Ƿ����ϣ�
|
||
|
//��������һ���豸�й��ϣ������ĵ���
|
||
|
//F_FirstProject�������ͻ��飻F_Remark�Ѷ�����F_BoxBarcode������F_BindingDevice����
|
||
|
if (dv[i]["F_Askkind"].ToString() == "9")
|
||
|
{
|
||
|
int[] state = CStaticClass.GetDeviceState(deviceindex);
|
||
|
int errCount = 0;
|
||
|
string[] sp; char[] cc = new char[1] { ';' };
|
||
|
if (state[1] >= 30)
|
||
|
{
|
||
|
//20091128
|
||
|
sp = null;
|
||
|
cc = null;
|
||
|
state = null;
|
||
|
continue;
|
||
|
}
|
||
|
if (state[2].ToString() == dv[i]["F_TaskIndex"].ToString())
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_PLC_Ask set F_BindingDevice=F_BindingDevice+1 where F_DeviceIndex=" ).Append( deviceindex);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_PLC_Ask set F_BindingDevice=0,F_TaskIndex=" ).Append( state[2] ).Append( " where F_DeviceIndex=" ).Append( deviceindex);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_BindingDevice from T_Base_PLC_Ask where F_DeviceIndex=" ).Append( deviceindex ).Append( " and F_BindingDevice>=100");
|
||
|
dplc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dplc.Count > 0)
|
||
|
{
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select FID, F_ManageTaskKindIndex,FENDDEVICE fromT_Manage_Task where F_ManageTaskKindIndex=" ).Append(
|
||
|
ccf.GetManageTaskKindIndexFromMonitor(state[2]) ).Append( " and fid=" ).Append( ccf.GetManageTaskIndexfromMonitor(state[2])
|
||
|
).Append( " and FENDDEVICE=" ).Append( dv[i]["F_BoxBarcode"] );
|
||
|
dvma = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvma.Count > 0)
|
||
|
{
|
||
|
|
||
|
int[] state1 = CStaticClass.GetDeviceState(Convert.ToInt32(dv[i]["F_Remark"]));
|
||
|
if (state1[1] >= 30)
|
||
|
{
|
||
|
errCount = 1;
|
||
|
}
|
||
|
sp = dv[i]["F_FirstProject"].ToString().Split(cc);
|
||
|
for (int jj = sp.GetLowerBound(0); jj <= sp.GetUpperBound(0); jj++)
|
||
|
{
|
||
|
state1 = CStaticClass.GetDeviceState(Convert.ToInt32(sp[jj]));
|
||
|
if (state1[1] >= 30)
|
||
|
{
|
||
|
errCount = 1;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (errCount > 0)
|
||
|
{
|
||
|
//bool havegoods = true;
|
||
|
//for (int jj = sp.GetLowerBound(0); jj <= sp.GetUpperBound(0); jj++)
|
||
|
//{
|
||
|
// devinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(sp[jj]));
|
||
|
// havegoods = (havegoods && devinfo.HaveGoods);
|
||
|
//}
|
||
|
//if (havegoods == true)
|
||
|
//{
|
||
|
//�����ĵ�
|
||
|
GetUsableDestination(ccf.GetManageTaskIndexfromMonitor(state[2]), ccf.GetManageTaskKindIndexFromMonitor(state[2]));
|
||
|
//}
|
||
|
}
|
||
|
//20091128
|
||
|
state1 = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
//20091128
|
||
|
sp = null;
|
||
|
cc = null;
|
||
|
state = null;
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#region ��ȡһ�Ź�������ϢF_Askkind=8
|
||
|
if (dv[i]["F_Askkind"].ToString() == "8")
|
||
|
{
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_FirstProject,F_BoxBarcode,F_HaveFirstProject, F_Askkind, F_BindingDevice FROM T_Base_PLC_Ask WHERE (F_Askkind = 8) AND (F_BindingDevice = " ).Append( dv[i]["F_BindingDevice"] ).Append( ")");
|
||
|
dvp = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvp.Count > 0)
|
||
|
{
|
||
|
//gds = CommModeCreate.CreateGetDeviceState(Convert.ToInt32(dvp[0]["F_DeviceIndex"]));
|
||
|
//string bcp = gds.GetStringData(Convert.ToInt32(dvp[0]["F_DeviceIndex"]), 64775);
|
||
|
string bcp = CStaticClass.GetStringData(Convert.ToInt32(dvp[0]["F_DeviceIndex"]));
|
||
|
if (bcp == null)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "CGetDeviceState", deviceindex.ToString(), bcp);
|
||
|
string bar1 = "", bar2 = "";
|
||
|
string ExceptionCode = "0";
|
||
|
|
||
|
bar1 = bcp.Substring(0, 16);
|
||
|
bar2 = bcp.Substring(16, 16);
|
||
|
|
||
|
if ((bar1 == "0000000000000000") || (bar1 == "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"))
|
||
|
{
|
||
|
|
||
|
if (dvp[0]["F_HaveFirstProject"].ToString() == "1")
|
||
|
{
|
||
|
ExceptionCode = "800";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ExceptionCode = "0";
|
||
|
}
|
||
|
bcp = "";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (dvp[0]["F_HaveFirstProject"].ToString() == "1")
|
||
|
{
|
||
|
ExceptionCode = "0";
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ExceptionCode = "800";
|
||
|
}
|
||
|
bcp = bar1;
|
||
|
}
|
||
|
if ((bar2 != "0000000000000000") && (bar2 != "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"))
|
||
|
{
|
||
|
if (dvp[0]["F_HaveFirstProject"].ToString() != "1")
|
||
|
{
|
||
|
ExceptionCode = "800";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ExceptionCode = "0";
|
||
|
}
|
||
|
bcp = bcp + ";" + bar2;
|
||
|
}
|
||
|
if (bcp.Length >= 1)
|
||
|
{
|
||
|
if (bcp.Substring(0, 1) == ";")
|
||
|
{
|
||
|
if (bcp.Length > 1)
|
||
|
{
|
||
|
bcp = bcp.Substring(1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
bcp = "";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (ExceptionCode == "800")
|
||
|
{
|
||
|
//�ж��Ƿ�Ϊ�����̣��������̲������쳣�룬�����쳣��
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Base_PLC_Ask SET F_Remark='" ).Append( ExceptionCode ).Append( "' WHERE (F_Askkind = 8) AND (F_BindingDevice = " ).Append( dvp[0]["F_BindingDevice"] ).Append( ")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
//��һ�Ź������ݴ�����ʱ�ֶ�
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Base_PLC_Ask SET F_TempFirstProject = '" ).Append( bcp ).Append( "' WHERE (F_Askkind = 8) AND (F_BindingDevice = " ).Append( dvp[0]["F_BindingDevice"] ).Append( ")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region ��Ʒ����������������������������
|
||
|
//������λ���ͻ����������룬һ�Ź�������Ϣ������������������������������������
|
||
|
//�����������롢һ�Ź�������Ϣ���쳣����ϢF_Remark
|
||
|
if (dv[i]["F_Askkind"].ToString() == "3")//��Ʒ����������������������������
|
||
|
{
|
||
|
int[] state = CStaticClass.GetDeviceState(Convert.ToInt32(dv[i]["F_BindingDevice"]));
|
||
|
if (state == null)
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
continue;
|
||
|
}
|
||
|
if (state[1] == 1)
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
continue;
|
||
|
}
|
||
|
if (CStaticClass.GetDevicePhotoelectric(ccf.GetBindingDeviceIndexOut(Convert.ToInt32(dv[i]["F_BindingDevice"]))) != 1)
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
continue;
|
||
|
}
|
||
|
//gds = CommModeCreate.CreateGetDeviceState(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
//bc = gds.GetDeviceState(Convert.ToInt32(dv[i]["F_DeviceIndex"]), 64774);
|
||
|
bc = CStaticClass.GetDeviceState(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
if (bc == null)
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
//bc[2]�����˶���:1-ȡ������;2-�Ż�����;3-������������
|
||
|
//bc[3]������������
|
||
|
if (bc[2] == 1)//ȡ������
|
||
|
{
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "CGetDeviceState", deviceindex.ToString(), dv[i]["F_BindingDevice"].ToString() + "ȡ������");
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Base_PLC_Ask SET F_FirstProject =F_FirstProject).Append(';').Append( F_TempFirstProject WHERE (F_Askkind = 8) AND (F_BindingDevice = " ).Append( dv[i]["F_BindingDevice"] ).Append( ") and (F_TempFirstProject<>'')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Base_PLC_Ask SET F_TempFirstProject='' WHERE (F_Askkind = 8) AND (F_BindingDevice = " ).Append( dv[i]["F_BindingDevice"] ).Append( ")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
if (bc[2] == 3)//���̽���
|
||
|
{
|
||
|
//20090915
|
||
|
if (state[1] >= 30)
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "CGetDeviceState", deviceindex.ToString(), dv[i]["F_BindingDevice"].ToString() + "���̽���");
|
||
|
//��ȡ�������룻
|
||
|
//gds = CommModeCreate.CreateGetDeviceState(Convert.ToInt32(dv[i]["F_BindingDevice"].ToString()+"6"));
|
||
|
//string barcode = gds.GetStringData(Convert.ToInt32(dv[i]["F_BindingDevice"].ToString() + "6"), 64773);
|
||
|
string barcode = CStaticClass.GetStringData(Convert.ToInt32(dv[i]["F_BindingDevice"].ToString() + "6"));
|
||
|
//20090915
|
||
|
if ((barcode == null) || (barcode == "\0\0\0\0\0\0\0\0\0\0"))
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
_listenPLCAskError = dv[i]["F_BindingDevice"].ToString() + ":ֻ�������̽�������û������Ӧ������������Ϣ������ʱ�䣺" + DateTime.Now.ToString("u");
|
||
|
continue;
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append( "SELECT FPALLETBARCODE,FSTARTDEVICE FROM T_Manage_Task where FSTARTDEVICE=" ).Append( dv[i]["F_BindingDevice"] ).Append( " AND FPALLETBARCODE='" ).Append( barcode ).Append( "'");
|
||
|
//20091128
|
||
|
dvs = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvs.Count > 0)
|
||
|
{
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
_listenPLCAskError = dv[i]["F_BindingDevice"].ToString() + "����ͨ������������:" + barcode + "���ظ��յ����̽����źţ�����ʱ�䣺" + DateTime.Now.ToString("u");
|
||
|
continue;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
//20090922
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT STOCK_BARCODE,START_DEVICE_CODE FROM IO_CONTROL where START_DEVICE_CODE=" ).Append( dv[i]["F_BindingDevice"] ).Append( " AND STOCK_BARCODE='" ).Append( barcode ).Append( "'");
|
||
|
dvs = dboM.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvs.Count > 0)
|
||
|
{
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
_listenPLCAskError = dv[i]["F_BindingDevice"].ToString() + "����ͨ������������:" + barcode + "���ظ��յ����̽����źţ�����ʱ�䣺" + DateTime.Now.ToString("u");
|
||
|
continue;
|
||
|
|
||
|
}
|
||
|
|
||
|
//һ�Ź�������Ϣ
|
||
|
string FirstProject = ""; string ExceptionCode = "0"; string BoxBarcode = "";
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_DeviceIndex, F_FirstProject,F_Remark,F_BoxBarcode,F_HaveFirstProject, F_Askkind, F_BindingDevice FROM T_Base_PLC_Ask WHERE (F_Askkind = 8) AND (F_BindingDevice = " ).Append( dv[i]["F_BindingDevice"] ).Append( ")");
|
||
|
dvp = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvp.Count > 0)
|
||
|
{
|
||
|
BoxBarcode = dvp[0]["F_BoxBarcode"].ToString();
|
||
|
FirstProject = dvp[0]["F_FirstProject"].ToString();
|
||
|
if (FirstProject.Length > 0)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (FirstProject.Substring(0, 1) == ";")
|
||
|
{
|
||
|
if (FirstProject.Length > 1)
|
||
|
{
|
||
|
FirstProject = FirstProject.Substring(1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
ExceptionCode = dvp[0]["F_Remark"].ToString();
|
||
|
}
|
||
|
int dcode = Convert.ToInt32(dv[i]["F_BindingDevice"]);
|
||
|
|
||
|
#region �������������̺���������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT DEVICE_CODE,STOCK_BARCODE FROM IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS=0 and DEVICE_CODE=" ).Append( dcode ).Append( " and (STOCK_BARCODE = '" ).Append( barcode ).Append( "')");
|
||
|
dvbc = dboM.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{
|
||
|
_listenPLCAskError = "������������������ʱ�������������Ѿ����ڣ�";
|
||
|
continue;
|
||
|
}
|
||
|
//������������������
|
||
|
//20091128
|
||
|
//20101108int fid = dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
||
|
string dtime = DateTime.Now.ToString("u");
|
||
|
dtime = dtime.Substring(0, dtime.Length - 1);
|
||
|
//20101108CONTROL_APPLY_ID," + fid + ",
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append("INSERT INTO IO_CONTROL_APPLY(CONTROL_APPLY_TYPE, DEVICE_CODE, STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME,CONTROL_APPLY_REMARK)VALUES " ).Append(
|
||
|
"(1," ).Append( dcode ).Append( ",'" ).Append( barcode ).Append( "',0,'" ).Append( dtime ).Append( "','" ).Append( BoxBarcode ).Append( ";" ).Append( FirstProject ).Append( ";" ).Append( bc[3].ToString() ).Append( ";" ).Append( ExceptionCode).Append(";1" ).Append( "')");//;
|
||
|
try
|
||
|
{
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Base_PLC_Ask SET F_FirstProject = '',F_Remark='' WHERE (F_Askkind = 8) AND (F_BindingDevice = " ).Append( dv[i]["F_BindingDevice"] ).Append( ")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_listenPLCAskError = "��������������������" + ex.Message;
|
||
|
continue;//20091218
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region ��������ͨ��
|
||
|
|
||
|
DataView md = dboM.ExceSQL("select * from v_fr_routwaysetting").Tables[0].DefaultView;
|
||
|
for (int a = 0; a < md.Count; a++)
|
||
|
{
|
||
|
string boxcode = "";
|
||
|
if (md[a]["fgoodscode"] == DBNull.Value)
|
||
|
{
|
||
|
boxcode = "0000000000000";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
boxcode = md[a]["fgoodscode"].ToString();
|
||
|
}
|
||
|
int devbind = Convert.ToInt32(md[a]["froutwayid"]);
|
||
|
string HaveFirstProject = md[a]["fbarcodeflag"].ToString();
|
||
|
bool IfHaveFirstProject = false;
|
||
|
if (HaveFirstProject == "1")
|
||
|
{
|
||
|
IfHaveFirstProject = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
IfHaveFirstProject = false;
|
||
|
}
|
||
|
for (int j = 0; j <= 12; j++)
|
||
|
{
|
||
|
if (boxcode.Length < 13)
|
||
|
{
|
||
|
boxcode += "0";
|
||
|
}
|
||
|
}
|
||
|
int devcount = 28;
|
||
|
if (md[a]["v_fullpalletqty"] != DBNull.Value)
|
||
|
{
|
||
|
devcount = Convert.ToInt32(md[a]["v_fullpalletqty"]);
|
||
|
}
|
||
|
int dev = Convert.ToInt32(md[a]["froutwayid"].ToString() + "11");
|
||
|
//����PLC����ͨ����froutwayid�����ͻ��豸���� fgoodscode�������� fbarcodeflag ������һ�Ź�������ʶ����5244�˹�����λͨ��
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(dev);
|
||
|
sdo.SendDeviceOrder(dev, boxcode, IfHaveFirstProject, false, devcount);
|
||
|
//��дT_Base_PLC_Ask����F_BindingDevice�����ͻ��豸���� F_BoxBarcode�������� F_HaveFirstProject ������һ�Ź�������ʶ��
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Base_PLC_Ask SET F_HaveFirstProject ='" ).Append( HaveFirstProject ).Append( "', F_BoxBarcode ='" ).Append( boxcode ).Append( "' WHERE (F_BindingDevice =" ).Append( devbind ).Append( ")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
//20091128
|
||
|
md = null;
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//20091128
|
||
|
#region ���ұ�������ͳ��
|
||
|
if (dv[i]["F_Askkind"].ToString() == "10")
|
||
|
{
|
||
|
CStaticClass.GetDeviceState(deviceindex);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//20100118
|
||
|
#region ��Ʒ����ͨ������ͳ��
|
||
|
if (dv[i]["F_Askkind"].ToString() == "11")
|
||
|
{
|
||
|
CStaticClass.GetDeviceState(deviceindex);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ����ɨ����������������
|
||
|
if (dv[i]["F_Askkind"].ToString() == "4")//����ɨ����������������
|
||
|
{
|
||
|
int[] state;
|
||
|
state = CStaticClass.GetDeviceState(Convert.ToInt32(dv[i]["F_BindingDevice"]));
|
||
|
if (state == null)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
if ((state[1] >= 30) || (state[1] == 1))
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
continue;
|
||
|
|
||
|
}
|
||
|
|
||
|
//20101118
|
||
|
DS = ccf.GetBindingDeviceIndexOut(Convert.ToInt32(dv[i]["F_BindingDevice"])).Split(dd);
|
||
|
int devicebyte = 0; int devbit = 0;
|
||
|
if (DS.GetLength(0) > 1)
|
||
|
{
|
||
|
int.TryParse(DS[0], out devicebyte);
|
||
|
int.TryParse(DS[1], out devbit);
|
||
|
if (CStaticClass.GetDevicePhotoelectric(devicebyte, devbit) != 1)
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{//20110510
|
||
|
_listenPLCAskError = "����ɨ����������������:" + dv[i]["F_BindingDevice"].ToString() + ",���ڿ���û��д��¼��";
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
//ɨ�������루ȫ�����㣩����¼�������벻���Ⱦ���Ϊ��������
|
||
|
//gds = CommModeCreate.CreateGetDeviceState(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
//string barcode = gds.GetStringData(Convert.ToInt32(dv[i]["F_DeviceIndex"]), 64777);
|
||
|
string barcode = CStaticClass.GetStringData(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
int dcode = Convert.ToInt32(dv[i]["F_BindingDevice"]);
|
||
|
if (barcode == null)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
if ((barcode == "\0\0\0\0\0\0\0\0\0\0") || (barcode == "?/////////") || (barcode == "1111111111"))
|
||
|
{
|
||
|
#region ûɨ�����ͳ���ָ��λ��//20101208
|
||
|
StringBuilder aheadDetect = new StringBuilder();
|
||
|
|
||
|
_listenPLCAskError = dcode.ToString() + ",ûɨ�����룡" + "ʱ��," + DateTime.Now.ToLongTimeString();
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("notifyIcon1", "����:" + _listenPLCAskError);
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", dcode.ToString(), "ûɨ�����룡");
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
|
||
|
continue;
|
||
|
//20110510
|
||
|
//}
|
||
|
//else if (dcode == 22003)//20110331
|
||
|
//{
|
||
|
// aheadDetect.Append("D-22003.0;I22003");
|
||
|
//}
|
||
|
//else//22016
|
||
|
//{
|
||
|
// aheadDetect.Append("D-22016.0;I22016");
|
||
|
//}
|
||
|
//sql.Remove(0, sql.Length);
|
||
|
//sql.Append("insert into T_Base_NoneBarcodeDealwith(F_FirstByte,F_MonitorIndex,F_OrderIndex,F_DeviceIndex,F_ArrowDevice,F_AheadDetect)values(")
|
||
|
// .Append("1,").Append(ccf.GetMonitorIndex(0, 0)).Append(",6,").Append(dcode).Append(",").Append(dv[i]["F_Remark"].ToString()).Append(",'").Append(aheadDetect.ToString()).Append("')");
|
||
|
//dbo.ExecuteSql(sql.ToString());
|
||
|
////sdo = CommModeCreate.CreateSendDeviceOrder(dcode);
|
||
|
////sdo.SendDeviceOrder(2, 0, 0, dcode, 0);
|
||
|
////sdo.SendDeviceOrder(1, ccf.GetMonitorIndex(0,0), 6, dcode, Convert.ToInt32(dv[i]["F_Remark"].ToString()));
|
||
|
//_listenPLCAskError = DateTime.Now.ToLongTimeString() +","+dcode.ToString()+ ",ûɨ�����룬�����Զ��ͳ����쳣��������";
|
||
|
//CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", dcode.ToString(), "ûɨ�����룬�����Զ��ͳ����쳣��������");
|
||
|
//wv[0].Remove(0, wv[0].Length);
|
||
|
//wv[0].Append("2");
|
||
|
//sdo.WriteDBData(witemnames, wv);
|
||
|
//continue;
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
|
||
|
//20091128
|
||
|
int bcz = 0;
|
||
|
for (int j = 0; j < 10; j++)
|
||
|
{
|
||
|
if (barcode.Substring(j, 1) != "0")
|
||
|
{
|
||
|
bcz = 1;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (bcz == 0)
|
||
|
{//20091128
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
continue;
|
||
|
}
|
||
|
//20101124һ¥16001ɨ�����Ĵ�����ɨ��ʱ����������¼�ֶ�F_BarCode��
|
||
|
//�����б��ع�������������λ���Ǵ����������豸���ñ��ع���������FSTATUS=0�����������DZȶԡ�
|
||
|
//����û�б��ع�������������������
|
||
|
//��ȡ����ʱ��������������������λ�������������豸����������λ��,�ֶ�F_BarCode��¼������������ƥ�䣬�ñ��ع���������FSTATUS=0���������á�FSTATUS=-1����
|
||
|
//������������������λ�ò������������豸���ñ��ع���������FSTATUS=0����
|
||
|
|
||
|
//20110331
|
||
|
|
||
|
if (dbo.GetSingle(string.Format("SELECT F_DeviceIndex FROM T_Base_PLC_Ask WHERE (F_DeviceIndex = {0}) AND (F_BarCode = '{1}')", deviceindex, barcode)) != null)//20101124
|
||
|
{
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (dbo.GetSingle(string.Format("select fid from T_Manage_Task where FPALLETBARCODE like '%{0}%'", barcode)) != null)
|
||
|
{
|
||
|
int uc = dbo.ExecuteSql(string.Format("update T_Manage_Task set FSTATUS=0 where FCONTROLTASKTYPE=1 and FSTARTDEVICE={0} and FPALLETBARCODE like '%{1}%'", dcode, barcode));
|
||
|
if (uc > 0)
|
||
|
{//20101208�ϴ�ûɨ����������ִ������ɨ��
|
||
|
dbo.ExecuteSql(string.Format("update T_Monitor_Task set F_Status=0 where F_DeviceIndex={0} and F_TxtParam like '%{1}%'", dcode, barcode));
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", dcode.ToString(), barcode + "���ϴ�PLC���˴���������ִ����������ɨ�裡");
|
||
|
continue;
|
||
|
}
|
||
|
else
|
||
|
{//�����ȶԺͱ�������
|
||
|
BarcodeConfirm(deviceindex, dcode, barcode, dv[i]["F_Remark"].ToString());
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region �ض��豸���뱨�����ɵģ�ɨ����,��û��������Ҫ����
|
||
|
|
||
|
//_listenPLCAskError = dcode.ToString() + ",ʱ��"+ DateTime.Now.ToLongTimeString() + ",ɨ����,��û���������˹����飡";
|
||
|
//RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("notifyIcon1", "����:" + _listenPLCAskError);
|
||
|
|
||
|
//CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", dcode.ToString(), "ɨ����,��û���������˹����飡");
|
||
|
//wv[0].Remove(0, wv[0].Length);
|
||
|
//wv[0].Append("2");
|
||
|
//sdo.WriteDBData(witemnames, wv);
|
||
|
//continue;
|
||
|
|
||
|
#endregion
|
||
|
#region ɨ����������
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
//20101124
|
||
|
|
||
|
#region ������������������
|
||
|
dvbc = dboM.ExceSQL(string.Format("SELECT DEVICE_CODE,STOCK_BARCODE FROM IO_CONTROL_APPLY WHERE APPLY_TASK_STATUS=0 and DEVICE_CODE={0} and (STOCK_BARCODE = '{1}')", dcode, barcode)).Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{//20091128
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
_listenPLCAskError = "���ͻ���" + dcode.ToString() + "��ɨ����������������������ʱ��������������ͬ�����̺ţ�" + barcode + "��δ������";
|
||
|
continue;
|
||
|
}
|
||
|
//������������������
|
||
|
//20100905 CONTROL_APPLY_TYPE=1
|
||
|
//20101108int fid = dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
||
|
|
||
|
//20101124
|
||
|
StringBuilder dtime =new StringBuilder( DateTime.Now.ToString("u"));
|
||
|
dtime.Remove(dtime.Length - 1,1);
|
||
|
//20110510
|
||
|
int apptype = 1;
|
||
|
if (deviceindex == 16004)
|
||
|
{
|
||
|
apptype = 2;
|
||
|
}
|
||
|
|
||
|
object[] ob = new object[7] {apptype,dcode,barcode,0, dtime,"",ccf.GetWarehouseIndex()};
|
||
|
try
|
||
|
{
|
||
|
dboM.ExecuteSql(string.Format("INSERT INTO IO_CONTROL_APPLY( 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}')", ob));
|
||
|
dbo.ExecuteSql(string.Format("UPDATE T_Base_PLC_Ask SET F_BarCode = '{0}' WHERE (F_DeviceIndex = {1})",barcode,deviceindex));
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
}
|
||
|
//20101124
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_listenPLCAskError = "��������������������" + ex.Message;
|
||
|
}
|
||
|
#endregion
|
||
|
//20110331
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", dcode.ToString(), barcode);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ������������
|
||
|
if (dv[i]["F_Askkind"].ToString() == "2")
|
||
|
{
|
||
|
|
||
|
//20110331�������� ���̻������ͻ�����ʱ�������̻�״̬
|
||
|
int[] sst = CStaticClass.GetDeviceState(Convert.ToInt32(dv[i]["F_BindingDevice"]));
|
||
|
if (sst == null)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (sst[1] != 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
sst = CStaticClass.GetDeviceState(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
if (sst != null)
|
||
|
{
|
||
|
|
||
|
//20110331��������
|
||
|
if (sst[1] == 2)
|
||
|
{//�ϱ�F_BarCode����һ����N������������;���̻���¼��������Ϣ����
|
||
|
#region ������������������
|
||
|
|
||
|
witemnames[0].Remove(0, witemnames[0].Length);
|
||
|
witemnames[0].Append(Model.CGeneralFunction.DBGet).Append(",byte").Append(Convert.ToString(devinfo.Dbw2Address + 1));
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("0");
|
||
|
StringBuilder dtime = new StringBuilder(DateTime.Now.ToString("u"));
|
||
|
dtime.Remove(dtime.Length - 1, 1);
|
||
|
try
|
||
|
{
|
||
|
//20110331
|
||
|
if (dv[i]["F_BarCode"].ToString() != "-")
|
||
|
{
|
||
|
//if (Convert.ToInt32(dv[i]["F_DeviceIndex"]) == 24002)
|
||
|
//{
|
||
|
// client.ManageStockCreateCompleteAsync(dv[i]["F_BindingDevice"].ToString(), dv[i]["F_BarCode"].ToString());
|
||
|
//}
|
||
|
//else
|
||
|
//{//14001
|
||
|
// clientOne.ManageStockCreateCompleteAsync(dv[i]["F_BindingDevice"].ToString(), dv[i]["F_BarCode"].ToString());
|
||
|
//}
|
||
|
}
|
||
|
dbo.ExecuteSql(string.Format("UPDATE T_Base_PLC_Ask SET F_BarCode = '-' WHERE (F_DeviceIndex = {0})", Convert.ToInt32(dv[i]["F_DeviceIndex"])));
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "��������", deviceindex.ToString(), dv[i]["F_BarCode"].ToString());
|
||
|
//20110331
|
||
|
}
|
||
|
|
||
|
catch (Exception ex)
|
||
|
{//20110602
|
||
|
_listenPLCAskError = DateTime.Now.ToString("u")+dv[i]["F_BindingDevice"].ToString()+"|"+dv[i]["F_BarCode"].ToString()+"��������,����ManageStockCreateCompleteAsyncʱ��" + ex.Message;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region ���̻�ǰ������ɨ����������������
|
||
|
if (dv[i]["F_Askkind"].ToString() == "7")//���̻�ǰ������ɨ����������������
|
||
|
{
|
||
|
int[] state;
|
||
|
state = CStaticClass.GetDeviceState(Convert.ToInt32(dv[i]["F_BindingDevice"]));
|
||
|
if (state == null)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
if ((state[1] >= 30) || (state[1] == 1))
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
continue;
|
||
|
|
||
|
}
|
||
|
|
||
|
//20101118
|
||
|
DS = ccf.GetBindingDeviceIndexOut(Convert.ToInt32(dv[i]["F_BindingDevice"])).Split(dd);
|
||
|
if (DS.GetLength(0) > 1)
|
||
|
{
|
||
|
int devicebyte = 0; int devbit = 0;
|
||
|
int.TryParse(DS[0], out devicebyte);
|
||
|
int.TryParse(DS[1], out devbit);
|
||
|
|
||
|
if (CStaticClass.GetDevicePhotoelectric(devicebyte, devbit) != 1)
|
||
|
{
|
||
|
//20091128
|
||
|
state = null;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{//20110510
|
||
|
_listenPLCAskError = "���̻�ǰ������ɨ����������������:" + dv[i]["F_BindingDevice"].ToString() + ",���ڿ���û��д��¼��";
|
||
|
continue;
|
||
|
}
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
|
||
|
//ɨ�������루ȫ�����㣩����¼�������벻���Ⱦ���Ϊ��������
|
||
|
string barcode = CStaticClass.GetStringData(Convert.ToInt32(dv[i]["F_DeviceIndex"]));
|
||
|
|
||
|
int dcode = Convert.ToInt32(dv[i]["F_BindingDevice"]);
|
||
|
if (barcode == null)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if ((barcode == "\0\0\0\0\0\0\0\0\0\0") || (barcode == "?/////////") || (barcode == "1111111111"))
|
||
|
{
|
||
|
//20110510
|
||
|
_listenPLCAskError = dcode.ToString() + ",ûɨ�����룡" + "ʱ��" + DateTime.Now.ToLongTimeString();
|
||
|
RefreshMonitorEventArgs rmea = new RefreshMonitorEventArgs("notifyIcon1", "����:" + _listenPLCAskError);
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "����ǰ������������", dcode.ToString(), "ûɨ�����룡");
|
||
|
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
continue;
|
||
|
|
||
|
}
|
||
|
//20110331�е�������û�����ɣ��ȴ��� F_BoxBarcode���̻����ͻ�22016��F_TempFirstProject������Ŀ�����ͻ�22018��F_Remark���̻�
|
||
|
if (dbo.GetSingle(string.Format("SELECT FID FROM T_Manage_Task WHERE (FSTARTDEVICE = '{0}')", dcode.ToString())) != null)
|
||
|
{
|
||
|
|
||
|
continue;
|
||
|
}
|
||
|
//20110331
|
||
|
if (dbo.GetSingle(string.Format("SELECT F_DeviceIndex FROM T_Base_PLC_Ask WHERE (F_DeviceIndex = {0}) AND (F_BarCode = '{1}')", deviceindex, barcode)) != null)//20101124
|
||
|
{
|
||
|
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
continue;
|
||
|
}
|
||
|
int bcz = 0;
|
||
|
for (int j = 0; j < 10; j++)
|
||
|
{
|
||
|
if (barcode.Substring(j, 1) != "0")
|
||
|
{
|
||
|
bcz = 1;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (bcz == 0)
|
||
|
{
|
||
|
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if (dbo.GetSingle(string.Format("SELECT F_DeviceIndex FROM T_Base_PLC_Ask WHERE (F_DeviceIndex = {0}) AND (F_BarCode = '{1}')", deviceindex, barcode)) != null)//20101124
|
||
|
{
|
||
|
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
|
||
|
#region ������������������
|
||
|
|
||
|
#region ��ȡ���̻�̽�̹��翪��ֵ
|
||
|
//1��PLC��Ϊ�У���λ����Ϊû�У��������˹����㣻2��PLC��Ϊû�У���λ����Ϊ�У�ֱ�ӰѼ�¼������
|
||
|
//F_Remark��¼���̻��豸���������̻���F_BarCode����¼�Ծ����õ�������"|"�ָ�
|
||
|
//20110331
|
||
|
int tw = CStaticClass.GetDevicePhotoelectric(Convert.ToInt32(dv[i]["F_Remark"]), 0);//���̻��Ƿ�����
|
||
|
object ob = dbo.GetSingle("SELECT F_BarCode FROM T_Base_PLC_Ask WHERE (F_BarCode <> '-') and (F_DeviceIndex=" + dv[i]["F_Remark"] + ")");
|
||
|
if (ob != null && tw == 0)//PLC��Ϊû��,��λ����Ϊ��
|
||
|
{
|
||
|
dbo.ExecuteSql(string.Format("UPDATE T_Base_PLC_Ask set F_BarCode = '-' WHERE (F_DeviceIndex={0})", Convert.ToInt32(dv[i]["F_Remark"])));
|
||
|
ob = null;//20110331
|
||
|
}
|
||
|
//20110331
|
||
|
else if (ob == null && tw == 1)//PLC��Ϊ��,��λ����Ϊû�У��������˹��ѵ��̻�����
|
||
|
{
|
||
|
wv[0].Remove(0, wv[0].Length);
|
||
|
wv[0].Append("2");
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
_listenPLCAskError = "���ͻ���" + dcode.ToString() + "��ɨ����������������������ʱ�����̻���Ϊ�����̣������ݿ���û�����������ļ��䣬���˹��˶Ե��̻�������!";
|
||
|
continue;
|
||
|
}
|
||
|
#endregion
|
||
|
//20110602���ӵ��̻�����(�ຣ�������볤��10�ľ�����������)������������
|
||
|
if (ob != null)
|
||
|
{
|
||
|
if (ob.ToString().Length > 10)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
StringBuilder dtime = new StringBuilder(DateTime.Now.ToString("u"));
|
||
|
dtime.Remove(dtime.Length - 1, 1);
|
||
|
string barcodeAll = string.Empty;
|
||
|
if (ob != null)//�������
|
||
|
{
|
||
|
barcodeAll = ob.ToString() + "|" + barcode;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
barcodeAll = barcode;
|
||
|
}
|
||
|
//ob = new object[7] { 2, dcode, barcode, 0, dtime, tw.ToString(), ccf.GetWarehouseIndex() };
|
||
|
try
|
||
|
{
|
||
|
//F_BoxBarcode���̻����ͻ�22016��F_TempFirstProject������Ŀ�����ͻ�22018��F_Remark���̻�
|
||
|
//20110331
|
||
|
//clientApp.ManageStockCreateApplyAsync(barcodeAll, deviceindex.ToString());
|
||
|
dbo.ExecuteSql(string.Format("UPDATE T_Base_PLC_Ask SET F_BarCode = '{0}' WHERE (F_DeviceIndex = {1})", barcode, deviceindex));
|
||
|
|
||
|
sdo.WriteDBData(witemnames, wv);
|
||
|
}
|
||
|
//20110602
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_listenPLCAskError = DateTime.Now.ToString("u")+","+barcodeAll+"���̻�ǰ����������������ManageStockCreateApplyAsyncʱ��" + ex.Message;
|
||
|
}
|
||
|
#endregion
|
||
|
//20110331
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���̻�ǰ��������������", dcode.ToString(), barcodeAll);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_listenPLCAskError = "����PLC����ʱ��" + ex.Message;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
bc=null;
|
||
|
|
||
|
wv = null;
|
||
|
witemnames = null;
|
||
|
dv=null;
|
||
|
dvbc=null;
|
||
|
dvm=null;
|
||
|
dplc=null;dvma=null;
|
||
|
dvp=null; dvs=null;
|
||
|
}
|
||
|
}
|
||
|
void RestoreDevice(int mindex)
|
||
|
{
|
||
|
int DeviceIdx, devKind;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_MonitorIndex,F_DeviceIndex from T_Monitor_Task where F_MonitorIndex=" ).Append( mindex);
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
//������������һ����λ
|
||
|
//����mindex������������f_associatemonitor�����ݣ����ȸ�λ����������������mindex�DZ����������ȸ�λ�Լ����ٸ�λ����������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceIndex,F_Associate from T_Monitor_Task where F_Associate IS NOT NULL and F_MonitorIndex=" ).Append( mindex);
|
||
|
DataView dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_MonitorIndex=" ).Append( Convert.ToInt32(dv1[0]["F_Associate"]));
|
||
|
DataView dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)//�й�������ȸ�λ��������
|
||
|
{
|
||
|
|
||
|
DeviceIdx = Convert.ToInt32(dv2[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ�����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ�����RGV
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" ).Append( Convert.ToInt32(dv2[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status=0 where F_MonitorIndex=" ).Append( Convert.ToInt32(dv2[0]["F_MonitorIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
//20091128
|
||
|
dv2 = null;
|
||
|
//�ٸ�λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" ).Append( Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status=0 where F_MonitorIndex=" ).Append( Convert.ToInt32(dv[0]["F_MonitorIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//�Լ��Ƿ���,�ȸ�λ�Լ����ٸ�λ������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_Associate ='" ).Append( mindex ).Append( "'");
|
||
|
DataView dv3 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv3.Count > 0)
|
||
|
{ //�ȸ�λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" ).Append( Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status=0 where F_MonitorIndex=" ).Append( mindex);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//�ٸ�λ������
|
||
|
DeviceIdx = Convert.ToInt32(dv3[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" ).Append( Convert.ToInt32(dv3[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status=0 where F_MonitorIndex=" ).Append( Convert.ToInt32(dv3[0]["F_MonitorIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//����������ֻ��λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" ).Append( Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status=0 where F_MonitorIndex=" ).Append( mindex);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
//20091128
|
||
|
dv3 = null;
|
||
|
}
|
||
|
//20091128
|
||
|
dv1 = null;
|
||
|
}
|
||
|
//20091128
|
||
|
dv = null;
|
||
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange(cea);
|
||
|
}
|
||
|
void AssociateComplete(int deviceIdx, int mindex)
|
||
|
{
|
||
|
int DeviceIdx = deviceIdx;
|
||
|
int devKind;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_MonitorIndex,F_DeviceIndex from T_Monitor_Task where F_MonitorIndex=" ).Append( mindex);
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
//������������һ����λ
|
||
|
//����mindex������������f_associatemonitor�����ݣ����ȸ�λ����������������mindex�DZ����������ȸ�λ�Լ����ٸ�λ����������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceIndex,F_Associate from T_Monitor_Task where F_Associate IS NOT NULL and F_MonitorIndex=" ).Append( mindex);
|
||
|
DataView dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_MonitorIndex=" ).Append( Convert.ToInt32(dv1[0]["F_Associate"]));
|
||
|
DataView dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)//�й�������ȸ�λ��������
|
||
|
{
|
||
|
|
||
|
DeviceIdx = Convert.ToInt32(dv2[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
cgs.ActionComplete(DeviceIdx,Convert.ToInt32( dv2[0]["F_MonitorIndex"]),1);
|
||
|
}
|
||
|
//20091128
|
||
|
dv2 = null;
|
||
|
//�ٸ�λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
cgs.ActionComplete(DeviceIdx,mindex,1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//�Լ��Ƿ���,�ȸ�λ�Լ����ٸ�λ������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_Associate ='" ).Append( mindex ).Append( "'");
|
||
|
DataView dv3 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv3.Count > 0)
|
||
|
{ //�ȸ�λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
cgs.ActionComplete(DeviceIdx,mindex,1);
|
||
|
//�ٸ�λ������
|
||
|
DeviceIdx = Convert.ToInt32(dv3[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
cgs.ActionComplete(DeviceIdx,Convert.ToInt32( dv3[0]["F_MonitorIndex"]),1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//����������ֻ��λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
cgs.ActionComplete(DeviceIdx, mindex,1);
|
||
|
}
|
||
|
//20091128
|
||
|
dv3 = null;
|
||
|
}
|
||
|
//20091128
|
||
|
dv1 = null;
|
||
|
}
|
||
|
//20091128
|
||
|
dv = null;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ��ȡ���õ�Ŀ��λ�ã��������������߳���վ̨
|
||
|
/// </summary>
|
||
|
/// <param name="manageTaskIdx">������������</param>
|
||
|
/// <param name="manageKindIdx">������������</param>
|
||
|
/// <returns></returns>
|
||
|
bool GetUsableDestination(int manageTaskIdx, int manageKindIdx)
|
||
|
{
|
||
|
//20091128
|
||
|
//DataView DV;
|
||
|
DataView dv;
|
||
|
DataRowView dr;
|
||
|
|
||
|
string adviceDev = "";
|
||
|
char[] cc = new char[1] { ';' };
|
||
|
string[] sp;
|
||
|
DataView dvIO;
|
||
|
|
||
|
|
||
|
try
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Manage_Task WHERE (FID = " ).Append( manageTaskIdx ).Append( ") AND (F_ManageTaskKindIndex = " ).Append( manageKindIdx ).Append( ")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count <= 0)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
dr = dv[0];
|
||
|
//ֻ�������ĵ���������·�������ĵ����Զ�����·��
|
||
|
if (dr["F_ManageTaskKindIndex"].ToString() != "1") return false;
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select CONTROL_ID, CONTROL_STATUS from IO_Control where (CONTROL_ID = " ).Append( Convert.ToInt32(dr["FID"]) ).Append( ") AND ((CONTROL_STATUS=" ).Append( Model.CGeneralFunction.TASKALTERROUTEAPPLY ).Append( ") or (CONTROL_STATUS=" ).Append( Model.CGeneralFunction.TASKCANCEL ).Append( ") or(CONTROL_STATUS=" ).Append( Model.CGeneralFunction.TASKALTERROUTEREPLY ).Append( "))");
|
||
|
dvIO = dboM.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvIO.Count <= 0)
|
||
|
{
|
||
|
|
||
|
#region ����T_Base_Device����F_UsableEndDevice���ҿ����յ��豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_UsableEndDevice from T_Base_Device where F_UsableEndDevice is not null and F_DeviceIndex=" ).Append( dr["FCurrentLocation"]);
|
||
|
DataView dvu = dbo.ExceSQL( sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvu.Count > 0)
|
||
|
{
|
||
|
sp = dvu[0]["F_UsableEndDevice"].ToString().Split(cc);
|
||
|
for (int i = sp.GetLowerBound(0); i <= sp.GetUpperBound(0); i++)
|
||
|
{
|
||
|
if (CDisassembleTask.MinRouteID(Convert.ToInt32(dr["FSTARTDEVICE"]), Convert.ToInt32(sp[i])) != -1)
|
||
|
{
|
||
|
adviceDev = sp[i];
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//20091128
|
||
|
dvu = null;
|
||
|
if (adviceDev == "")
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//DV = dboM.ExceSQL("select IO_CONTROL_APPLY_SEQ.NEXTVAL FROM DUAL").Tables[0].DefaultView;
|
||
|
//20101108int fid = dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
||
|
string dtime = DateTime.Now.ToString("u");
|
||
|
dtime = dtime.Substring(0,dtime.Length-1);
|
||
|
|
||
|
dboM.TransBegin();
|
||
|
try
|
||
|
{
|
||
|
#region ���������˵�����վ̨��Ҫ�ϱ�IO_CONTROL��FSTATUS=960
|
||
|
//3241;3249;3256;3257;3258
|
||
|
string[] outstation = new string[5] { "3241", "3249", "3256", "3257", "3258" };
|
||
|
if (ccf.GetFCONTROLTASKTYPEFromManageTask(manageKindIdx, manageTaskIdx) == 1)//��������
|
||
|
{
|
||
|
if (Array.IndexOf(outstation, dr["FCurrentLocation"].ToString()) >= 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update IO_Control set CONTROL_STATUS=" ).Append( Model.CGeneralFunction.TASKCANCEL ).Append( ",ERROR_TEXT='���������������˵�����վ̨��' where CONTROL_ID=" ).Append( manageTaskIdx);
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
|
||
|
}
|
||
|
}
|
||
|
//20091128
|
||
|
outstation = null;
|
||
|
#endregion
|
||
|
|
||
|
//20090918
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=" ).Append( Model.CGeneralFunction.TASKALTERROUTEAPPLY ).Append( " where CONTROL_ID=" ).Append( dr["FID"] ).Append( " and CONTROL_STATUS<>" ).Append( Model.CGeneralFunction.TASKCANCEL );
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
//����������������//20101108CONTROL_APPLY_ID," + fid + ",
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append( "INSERT INTO IO_CONTROL_APPLY ( CONTROL_ID, WAREHOUSE_CODE, STOCK_BARCODE, DEVICE_CODE, APPLY_TASK_STATUS, CREATE_TIME,CONTROL_APPLY_REMARK)" ).Append(
|
||
|
"VALUES (" ).Append( dr["FID"] ).Append( ",'" ).Append( dr["FENDWAREHOUSE"] ).Append( "','" ).Append( dr["FPALLETBARCODE"] ).Append( "','" ).Append( adviceDev ).Append( "',0,'" ).Append( dtime ).Append( "',null)");
|
||
|
dboM.ExceSQL(sql.ToString());
|
||
|
dboM.TransCommit();
|
||
|
//��ManageTaskIdx��ManageKindIdx �ĵ�������ȫ�������ĵ�
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_Status = 3 WHERE (F_ManageTaskIndex = " ).Append( manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX =" ).Append( manageKindIdx ).Append( ")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20090910
|
||
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange(cea);
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
dboM.TransRollback();
|
||
|
_listenPLCAskError = "����PLC�����ĵ�ʱ��" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_listenPLCAskError = "����PLC�����ĵ�ʱ��" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
//DV=null;
|
||
|
dv=null;
|
||
|
dr=null;
|
||
|
cc =null;
|
||
|
sp=null;
|
||
|
dvIO=null;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 20091005�ж��Ƿ����Ի��ÿ��õ�·����·��
|
||
|
/// </summary>
|
||
|
/// <param name="manageTaskIdx">������������</param>
|
||
|
/// <param name="manageKindIdx">������������</param>
|
||
|
/// <param name="curLocation">��ǰ�豸����</param>
|
||
|
/// <returns></returns>
|
||
|
bool GetUseableRouteIDSub(int manageTaskIdx, int manageKindIdx,int curLocation)
|
||
|
{
|
||
|
DataView dvmi;
|
||
|
DataView DMAN;
|
||
|
DataView dvnew;
|
||
|
try
|
||
|
{
|
||
|
|
||
|
//20091005
|
||
|
|
||
|
#region ������������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT * FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append( manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX =1) order by F_MonitorIndex asc");
|
||
|
dvmi = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvmi.Count > 0)
|
||
|
{//�Ѿ���ʼִ�е���Ҫ���ĵ�������
|
||
|
//�ж�������·���ĵ�һ������������
|
||
|
int monitorIndex = (int)dvmi[0]["F_MonitorIndex"];
|
||
|
int associateMonitor = -1;
|
||
|
if (dvmi[0]["F_Associate"] != DBNull.Value)
|
||
|
{
|
||
|
associateMonitor = Convert.ToInt32(dvmi[0]["F_Associate"]);
|
||
|
}
|
||
|
int devindex = Convert.ToInt32(dvmi[0]["F_DeviceIndex"]);
|
||
|
int devKind = ccf.GetDeviceKindIdx(Convert.ToInt32(dvmi[0]["F_DeviceIndex"]));
|
||
|
int devCommand = Convert.ToInt32(dvmi[0]["F_DeviceCommandIndex"]);
|
||
|
int routeID = Convert.ToInt32(dvmi[0]["F_RouteID"]);
|
||
|
int NumParam1 = Convert.ToInt32(dvmi[0]["F_NumParam1"]);
|
||
|
int NumParam4 = Convert.ToInt32(dvmi[0]["F_NumParam4"]);
|
||
|
string AheadDetect = dvmi[0]["F_AheadDetect"].ToString();
|
||
|
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select * from T_Manage_Task WHERE (FID = " ).Append( manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX =1)");
|
||
|
DMAN = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (DMAN.Count > 0)
|
||
|
{
|
||
|
|
||
|
|
||
|
//20091005
|
||
|
int routeidNew = CDisassembleTask.MinRouteID(Convert.ToInt32(DMAN[0]["FSTARTDEVICE"]), Convert.ToInt32(DMAN[0]["FENDDEVICE"]),curLocation);
|
||
|
|
||
|
if (routeidNew == -1)
|
||
|
{
|
||
|
//20091005
|
||
|
return false;
|
||
|
}
|
||
|
//20091005
|
||
|
//ɾ��ԭ����������·���������µ���������ֻ���������豸��ʼ������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("DELETE FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append( manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX =1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20090910
|
||
|
if (CDisassembleTask.CreateMonitor(1, manageTaskIdx, routeidNew, DMAN[0], 3) <= 0)
|
||
|
{
|
||
|
//��������������·������������
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql .Append("INSERT INTO T_Monitor_Task " ).Append(
|
||
|
"(F_ManageTaskIndex, F_ManageTASKKINDINDEX, F_MonitorIndex,F_MonitorTaskLevel," ).Append(
|
||
|
" F_DeviceIndex, F_DeviceCommandIndex, F_RouteID, F_Status,F_NumParam1, F_NumParam4," ).Append(
|
||
|
" F_AheadDetect,F_TxtParam)" ).Append(
|
||
|
"VALUES (" ).Append( manageTaskIdx ).Append( ",1," ).Append( monitorIndex ).Append( ",1," ).Append( devindex ).Append( "," ).Append( devCommand ).Append( "," ).Append( routeID ).Append( ",3," ).Append( NumParam1 ).Append( "," ).Append( NumParam4
|
||
|
).Append( ",'" ).Append( AheadDetect ).Append( "','" ).Append( DMAN[0]["FPALLETBARCODE"] ).Append( "')");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (devKind == 4)
|
||
|
{
|
||
|
if (devCommand == 7)
|
||
|
{
|
||
|
int RGVsn = ccf.GetSerialNumberFromRouteDevice(routeID, devindex);
|
||
|
int Consn = ccf.GetSerialNumberFromRouteDevice(routeID, NumParam1);
|
||
|
|
||
|
#region RGV�˶����ӻ���
|
||
|
if (RGVsn > Consn)
|
||
|
{
|
||
|
//ɾ��RGV�˶����ӻ���֮ǰ������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " ).Append(
|
||
|
devindex ).Append( ") AND (F_DeviceCommandIndex = 7) AND (F_RouteID = " ).Append( routeidNew ).Append(
|
||
|
") AND (F_NumParam1 = " ).Append( NumParam1 ).Append( ")");
|
||
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvnew.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<" ).Append( dvnew[0]["F_MonitorIndex"] ).Append( " and (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) ");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) ");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region RGV�˶����ͻ���
|
||
|
if (RGVsn < Consn)
|
||
|
{
|
||
|
//ɾ��RGV�˶����ͻ���֮ǰ������
|
||
|
//DataView dvnew = dbo.ExceSQL("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " +
|
||
|
// manageTaskIdx + ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " +
|
||
|
// devindex + ") AND (F_DeviceCommandIndex = 7) AND (F_RouteID = " + routeidNew +
|
||
|
// ") AND (F_Status = 3) AND (F_NumParam1 <> " + NumParam1 + ")").Tables[0].DefaultView;
|
||
|
int RGVsn1 = ccf.GetSerialNumberFromRouteDevice(routeidNew, devindex);
|
||
|
//�ҵ��ӻ����ͻ��豸����
|
||
|
List<int> nextcon = CDisassembleTask.GetNextDevice(routeidNew, RGVsn1);
|
||
|
int condev = nextcon[0];
|
||
|
//ɾ��RGV�˶����ͻ���֮ǰ������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " ).Append(
|
||
|
devindex ).Append( ") AND (F_DeviceCommandIndex = 7) AND (F_RouteID = " ).Append( routeidNew ).Append(
|
||
|
") AND (F_NumParam1 = " ).Append( condev ).Append( ")");
|
||
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvnew.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<" ).Append( dvnew[0]["F_MonitorIndex"] ).Append( " and (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#region RGV�ͻ�
|
||
|
|
||
|
if ((devCommand == 3) || (devCommand == 5))
|
||
|
{
|
||
|
int RGVsn = ccf.GetSerialNumberFromRouteDevice(routeidNew, devindex);
|
||
|
//�ҵ��ӻ����ͻ��豸����
|
||
|
List<int> nextcon = CDisassembleTask.GetNextDevice(routeidNew, RGVsn);
|
||
|
int condev = nextcon[0];
|
||
|
//ɾ��RGV�˶����ͻ���֮ǰ������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " ).Append(
|
||
|
devindex ).Append( ") AND (F_DeviceCommandIndex = 7) AND (F_RouteID = " ).Append( routeidNew ).Append(
|
||
|
") AND (F_NumParam1 = " ).Append( condev ).Append( ")");
|
||
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvnew.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<" ).Append( dvnew[0]["F_MonitorIndex"] ).Append( " and (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) ");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region RGV�ӻ�
|
||
|
if ((devCommand == 2) || (devCommand == 4))
|
||
|
{
|
||
|
int RGVsn = ccf.GetSerialNumberFromRouteDevice(routeidNew, devindex);
|
||
|
//�ҵ��ͻ����ͻ��豸����
|
||
|
List<int> priorcon = CDisassembleTask.GetPriorDevice(routeidNew, RGVsn);
|
||
|
int condev = priorcon[0];
|
||
|
//ɾ��RGV�˶����ӻ���֮ǰ������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " ).Append(
|
||
|
devindex ).Append( ") AND (F_DeviceCommandIndex = 7) AND (F_RouteID = " ).Append( routeidNew ).Append(
|
||
|
") AND (F_NumParam1 = " ).Append( condev ).Append( ")");
|
||
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvnew.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<" ).Append( dvnew[0]["F_MonitorIndex"] ).Append( " and (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
if (devKind == 2)
|
||
|
{
|
||
|
#region ���ͻ��ͻ�
|
||
|
if (devCommand == 3)
|
||
|
{
|
||
|
int consn = ccf.GetSerialNumberFromRouteDevice(routeidNew, devindex);
|
||
|
//�ҵ��ӻ�RGV�豸����
|
||
|
List<int> nextrgv = CDisassembleTask.GetNextDevice(routeidNew, consn);
|
||
|
int rgvdev = nextrgv[0];
|
||
|
|
||
|
//ɾ��RGV�˶����ӻ���֮ǰ������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " ).Append(
|
||
|
rgvdev ).Append( ") AND (F_DeviceCommandIndex = 7) AND (F_RouteID = " ).Append( routeidNew ).Append(
|
||
|
") AND (F_NumParam1 = " ).Append( devindex ).Append( ")");
|
||
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvnew.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<" ).Append( dvnew[0]["F_MonitorIndex"] ).Append( " and (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ���ͻ��Ľӻ�
|
||
|
|
||
|
if (devCommand == 4)
|
||
|
{
|
||
|
int consn = ccf.GetSerialNumberFromRouteDevice(routeID, devindex);
|
||
|
//�ҵ��ͻ�RGV�豸����
|
||
|
List<int> priorrgv = CDisassembleTask.GetPriorDevice(routeID, consn);
|
||
|
int rgvdev = priorrgv[0];
|
||
|
int rgvsn = ccf.GetSerialNumberFromRouteDevice(routeidNew, rgvdev);
|
||
|
List<int> nextdev = CDisassembleTask.GetNextDevice(routeidNew, rgvdev);
|
||
|
int condev = nextdev[0];
|
||
|
//ɾ��RGV�˶����ͻ���֮ǰ������
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " ).Append(
|
||
|
rgvdev ).Append( ") AND (F_DeviceCommandIndex = 7) AND (F_RouteID = " ).Append( routeidNew ).Append(
|
||
|
") AND (F_NumParam1 = " ).Append( condev ).Append( ")");
|
||
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvnew.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<" ).Append( dvnew[0]["F_MonitorIndex"] ).Append( " and (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region ���ͻ����ͳ�
|
||
|
if (devCommand == 6)
|
||
|
{
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " ).Append(
|
||
|
devindex ).Append( ") AND (F_DeviceCommandIndex = 6) AND (F_RouteID = " ).Append( routeidNew ).Append(
|
||
|
")");
|
||
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvnew.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<" ).Append( dvnew[0]["F_MonitorIndex"] ).Append( " and (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) ");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
int CurrentLocation = 0;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FCurrentLocation FROM T_Manage_Task where FID=" ).Append( manageTaskIdx ).Append( " and F_ManageTaskKindIndex=1");
|
||
|
DataView dvc = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvc.Count > 0)
|
||
|
{
|
||
|
CurrentLocation = Convert.ToInt32(dvc[0]["FCurrentLocation"]);
|
||
|
}
|
||
|
//20091128
|
||
|
dvc = null;
|
||
|
if (CurrentLocation == 0) return false;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_DeviceIndex=" ).Append( CurrentLocation ).Append( " where F_MonitorIndex=" ).Append( dvnew[0]["F_MonitorIndex"]);
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
//20090910�Ѿ����˵�CurrentLocation��F_NumParam4=CurrentLocation�� ɾ���ͳ�����
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_DeviceIndex=" ).Append( CurrentLocation ).Append( " and F_NumParam4=" ).Append( CurrentLocation );
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
#region �Ѷ������ͻ���
|
||
|
if (devKind == 1)
|
||
|
{//�Ѷ������ͻ��أ�ֻ�����Ѷ������ͻ�����
|
||
|
|
||
|
//20091128
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) AND (F_DeviceIndex = " ).Append(
|
||
|
devindex ).Append( ") AND (F_DeviceCommandIndex = 5) AND (F_RouteID = " ).Append( routeidNew ).Append(
|
||
|
")");
|
||
|
dvnew = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvnew.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("delete from T_Monitor_Task where F_MonitorIndex<" ).Append( dvnew[0]["F_MonitorIndex"] ).Append( " and (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1)");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" ).Append( devindex);
|
||
|
dbo.ExceSQL( sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("update T_Monitor_Task set F_Status =0 where (F_ManageTaskIndex = " ).Append(
|
||
|
manageTaskIdx ).Append( ") AND (F_ManageTASKKINDINDEX = 1) ");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}//20090910
|
||
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange(cea);
|
||
|
return true;
|
||
|
}//20091005
|
||
|
#endregion
|
||
|
else
|
||
|
{//����������
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_listenPLCAskError = "CListenPLCAsk.GetUseableRouteIDSub:" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// �ж��豸�Ƿ�������·����
|
||
|
/// </summary>
|
||
|
/// <param name="deviceIdx">�豸����</param>
|
||
|
/// <param name="routeSub">��·��</param>
|
||
|
/// <returns></returns>
|
||
|
bool DeviceInRouteSub(int deviceIdx,int routeSub)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_RouteIDSub, F_DeviceIndex FROM T_Base_Route_Device Where F_RouteIDSub=" ).Append( routeSub ).Append( " and F_DeviceIndex=").Append(deviceIdx );
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int GetRouteIDsub(int device)
|
||
|
{
|
||
|
DataView 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;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �������������ȶԣ��������ͻ����ͳ���������
|
||
|
/// </summary>
|
||
|
/// <param name="Bardevice">�����豸</param>
|
||
|
/// <param name="BindDevice">�����豸�İ������ͻ�</param>
|
||
|
/// <param name="barcode">����</param>
|
||
|
/// <param name="AbendDevice">�쳣�������豸</param>
|
||
|
void BarcodeConfirm(int Bardevice,int BindDevice,string barcode,string AbendDevice)
|
||
|
{
|
||
|
|
||
|
#region ���������ȶԣ�����������������20110412
|
||
|
|
||
|
DataView dv = dbo.ExceSQL(string.Format("SELECT TOP 1 F_MonitorIndex, F_DeviceIndex, F_DeviceCommandIndex,F_ManageTaskIndex, F_ManageTASKKINDINDEX,F_NumParam4 FROM T_Monitor_Task WHERE (F_TxtParam like '%{0}%')", barcode)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
int mankind = Convert.ToInt32(dv[0]["F_ManageTASKKINDINDEX"]);
|
||
|
int FID = Convert.ToInt32(dv[0]["F_ManageTaskIndex"]);
|
||
|
if ((ccf.GetDeviceKindIdx(Convert.ToInt32(dv[0]["F_DeviceIndex"])) == 2) && (dv[0]["F_DeviceCommandIndex"].ToString() == "6"))
|
||
|
{
|
||
|
int ctype = ccf.GetFCONTROLTASKTYPEFromManageTask(mankind,FID);
|
||
|
if ((ctype != 1)&&(dv[0]["F_NumParam4"].ToString()==BindDevice.ToString()))
|
||
|
{//��ȷ
|
||
|
if (BindDevice == 22003)
|
||
|
{//�����յ���28001��ǰ��(����)��������ǰ�棨���棩�ȴ�������CONTROL_STATUS=Model.CGeneralFunction.TASKSINGLEFORKRUN
|
||
|
DriveOutSameFork(barcode);
|
||
|
}
|
||
|
cgs.ActionComplete(Convert.ToInt32(dv[0]["F_DeviceIndex"]), Convert.ToInt32(dv[0]["F_MonitorIndex"]), 0);
|
||
|
}
|
||
|
else
|
||
|
{//�쳣�����������������ڻ����յ㱨��990
|
||
|
if ((ctype != 1) && (dv[0]["F_NumParam4"].ToString() != BindDevice.ToString()))
|
||
|
{
|
||
|
_listenPLCAskError = DateTime.Now.ToLongTimeString() + ",���룺" + barcode + "��ɨ���Ѿ���������Ҫ�ظ�ɨ�裡";
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", BindDevice.ToString(), barcode + "��ɨ���Ѿ���������Ҫ�ظ�ɨ�裡");
|
||
|
}
|
||
|
|
||
|
else
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("DELETE FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = ").Append(mankind).Append(") AND (FID = ").Append(FID).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("DELETE FROM T_Monitor_Task WHERE (F_ManageTaskIndex = ").Append(FID).Append(") AND (F_ManageTASKKINDINDEX = ").Append(mankind).Append(")");
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
object[] ob = new object[17] { FID, mankind, barcode, 1, 2, 1, 1, ccf.GetWarehouseIndex(), ccf.GetWarehouseIndex(), "-", BindDevice, AbendDevice, "-", 0, DateTime.Now.ToString("u"), 0, Model.CGeneralFunction.TASKABEND };
|
||
|
dbo.ExceSQL(string.Format("INSERT INTO T_Manage_Task(FID, F_ManageTaskKindIndex,FPALLETBARCODE,FMANAGETASKTYPE,FCONTROLTASKTYPE, FTASKLEVEL, FISRETURN,FSTARTWAREHOUSE,FENDWAREHOUSE, FSTARTCELL, FSTARTDEVICE, FENDDEVICE, FENDCELL, FSTATUS, FBEGTIME, FIntoStepOK,FExceptionNO)VALUES({0},{1},'{2}',{3},{4},{5},{6},'{7}','{8}','{9}',{10},{11},'{12}',{13},'{14}','{15}',{16})", ob));
|
||
|
if ((ctype == 1) && (dv[0]["F_NumParam4"].ToString() != BindDevice.ToString()))
|
||
|
{//20110602
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", BindDevice.ToString(), barcode + "���Ѿ�������ɨ��������������û��ִ�����ɣ��ٴα�ɨ�裬�����Զ��ĵ����쳣�����ڣ������쳣���ɣ�");
|
||
|
}
|
||
|
else
|
||
|
{//20110602
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", BindDevice.ToString(), barcode + "�����������������ڣ������Զ��ĵ����쳣�����ڣ������쳣���ɣ�");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{//���벻���ڴ���
|
||
|
StringBuilder aheadDetect = new StringBuilder();
|
||
|
|
||
|
_listenPLCAskError =DateTime.Now.ToLongTimeString()+",���룺"+ barcode + "�����������в����ڣ���Ҫ�˹���Ԥ��";
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "������������", BindDevice.ToString(), barcode + "�����������������в����ڣ���Ҫ�˹���Ԥ��");
|
||
|
}
|
||
|
#endregion
|
||
|
CDataChangeEventArgs cea = new CDataChangeEventArgs(null, null);
|
||
|
OnDataChange(cea);
|
||
|
}
|
||
|
|
||
|
void DriveOutSameFork(string barcode)
|
||
|
{
|
||
|
DataView dv;
|
||
|
DataView dv0;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FUseAwayFork FROM T_Manage_Task WHERE FENDDEVICE = '28001' AND FPALLETBARCODE like '%").Append(barcode).Append("%'");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_ManageTaskKindIndex,FID FROM T_Manage_Task WHERE FENDDEVICE = '28001' AND FUseAwayFork = '").Append(dv[0]["FUseAwayFork"].ToString()).Append("' and FSTATUS>0");
|
||
|
dv0 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv0.Count > 0)
|
||
|
{
|
||
|
for (int i = 0; i < dv0.Count; i++)
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT TOP 1 F_DeviceIndex, F_DeviceCommandIndex FROM T_Monitor_Task where F_ManageTASKKINDINDEX=").Append(dv0[i]["F_ManageTaskKindIndex"].ToString()).Append(" and F_ManageTaskIndex=").Append(dv0[i]["FID"].ToString()).Append(" ORDER BY F_MonitorIndex ASC");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if ((((dv[0]["F_DeviceIndex"].ToString() == "1001") && (dv[0]["F_DeviceCommandIndex"].ToString() == "2")) || ((dv[0]["F_DeviceIndex"].ToString() == "22003") && (dv[0]["F_DeviceCommandIndex"].ToString() == "6"))) && (dv0[i]["F_ManageTaskKindIndex"].ToString() == "1"))//20110412
|
||
|
{
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append(" update IO_CONTROL set CONTROL_STATUS=").Append(Model.CGeneralFunction.TASKSINGLEFORKRUN).Append(" WHERE (CONTROL_ID = ").Append(dv0[i]["FID"].ToString()).Append(")");
|
||
|
dboM.ExecuteSql(sql.ToString());
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|