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.
3602 lines
201 KiB
3602 lines
201 KiB
11 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Text;
|
||
|
using ICommLayer;
|
||
|
using DBFactory;
|
||
|
using System.Data;
|
||
|
using Microsoft.VisualBasic;
|
||
|
namespace OPCClient
|
||
|
{
|
||
|
public class CSendDeviceOrder : ISendDeviceOrder
|
||
|
{
|
||
|
Model.MDevice devinfo;
|
||
|
string _commLayerError;
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
StringBuilder sss = new StringBuilder();
|
||
|
|
||
|
public string CommLayerError
|
||
|
{
|
||
|
get { return _commLayerError; }
|
||
|
set { _commLayerError = value; }
|
||
|
}
|
||
|
DBOperator dbo = CCommonOPCClient.dbo;
|
||
|
//Model.MDevice devinfo;
|
||
|
public CSendDeviceOrder()
|
||
|
{
|
||
|
dbo.Open();
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���û���
|
||
|
/// </summary>
|
||
|
/// <param name="monitorIndex"></param>
|
||
|
/// <returns></returns>
|
||
|
public int getOrderFromMonitor(int monitorIndex,int deviceIndex)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_deviceCommandIndex from T_MONITOR_TASK where F_monitorIndex=").Append(monitorIndex).Append("and F_deviceIndex=").Append(deviceIndex);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (dv[0]["F_deviceCommandIndex"] == DBNull.Value) return -1;
|
||
|
return Convert.ToInt32(dv[0]["F_deviceCommandIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100108
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
dv.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
//�¼ӿ���������
|
||
|
public int GetFCONTROLTASKTYPEFromManageTask(int taskKindIndex, int Managefid)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FID = ").Append(Managefid).Append(") AND (F_ManageTaskKindIndex = ").Append(taskKindIndex).Append(")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (dv[0]["FCONTROLTASKTYPE"] == DBNull.Value) return -1;
|
||
|
return Convert.ToInt32(dv[0]["FCONTROLTASKTYPE"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100108
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
dv.Dispose();
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���ͶѶ������� �Ѷ��� �����Ѷ��� �����Ѷ��� �Ѷ��� �Ѷ����ķ�������
|
||
|
/// </summary>
|
||
|
/// <param name="MessageIndex">��Ϣ����</param>
|
||
|
/// <param name="TaskIndex">��������</param>
|
||
|
/// <param name="Order">�Ѷ���������</param>
|
||
|
///1-��λ
|
||
|
///2-��ȡ
|
||
|
///3-����
|
||
|
///4-ȡ��
|
||
|
///5-��
|
||
|
///6-ȡ�Ż�
|
||
|
/// <param name="DeviceIndex">�豸����</param>
|
||
|
/// <param name="StartX">��ʼx���꣬��-�ع�������</param>
|
||
|
/// <param name="StartY">��ʼy���꣬��-�߶ȷ���</param>
|
||
|
/// <param name="StartZ">��ʼz���꣬��-�����Ѷ����������壬1-���࣬2-�Ҳ�</param>
|
||
|
/// <param name="EndX">Ŀ��x���꣬��-�ع�������</param>
|
||
|
/// <param name="EndY">Ŀ��y���꣬��-�߶ȷ���</param>
|
||
|
/// <param name="EndZ">Ŀ��z���꣬��-�����Ѷ����������壬1-���࣬2-�Ҳ�</param>
|
||
|
/// <returns>���ͶѶ��������Ƿ��ɹ�</returns>
|
||
|
public bool SendDeviceOrder(int MessageIndex, int TaskIndex, int Order, int DeviceIndex, int StartX, int StartY, int StartZ, int EndX, int EndY, int EndZ)
|
||
|
{//20120820
|
||
|
//return false;
|
||
|
string barcode = GetBarcodeFromMonitorIndex(TaskIndex);
|
||
|
int sn = 0; int UseAwayFork = 0;
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
|
||
|
//ɽ���»���ʶ�Dz���ͬ������
|
||
|
int sdxhmutitasks = 0;
|
||
|
//������ʱע��
|
||
|
if (devinfo.XCoor == 0) return false;//ceshi
|
||
|
try
|
||
|
{
|
||
|
int[] sendmes = new int[10] { MessageIndex, TaskIndex, Order, DeviceIndex, StartX, StartY, StartZ, EndX, EndY, EndZ };
|
||
|
devinfo.SendMessage = sendmes;
|
||
|
Model.CGetInfo.SetDeviceMessage(devinfo);
|
||
|
|
||
|
|
||
|
if (devinfo == null)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�������������豸����û�ҵ��豸������";
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (devinfo.DeviceKind != 1)
|
||
|
{//�Ѷ���ʹ�ô˷���
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�������Ѷ�����RGV�������豸ʹ�ô˷�������ȷ!";
|
||
|
return false;
|
||
|
}
|
||
|
#region �Ѷ���
|
||
|
|
||
|
if (devinfo.DeviceKind == 1)
|
||
|
{
|
||
|
int[] startz = new int[devinfo.ForkAmount];
|
||
|
int[] endz = new int[devinfo.ForkAmount];
|
||
|
if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
#region �����Ѷ���
|
||
|
//�Ѷ�����ԭ������
|
||
|
char[] sp = new char[1] { ',' };
|
||
|
string[] yd = devinfo.StackZeroColLayer.Split(sp);
|
||
|
int zeroXcoor = 0;
|
||
|
if (yd.GetLength(0) > 0)
|
||
|
{
|
||
|
zeroXcoor = Convert.ToInt32(yd[0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�������Ѷ�����ԭ������û����д!";
|
||
|
return false;
|
||
|
}
|
||
|
for (int i = 0; i < devinfo.ForkAmount; i++)
|
||
|
{
|
||
|
startz[i] = 0;
|
||
|
endz[i] = 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
#region �Ѷ�����˫��ȡ��ָ��ڴ˾����������桢ͬ�������첽����
|
||
|
//�Ѷ���ȡ��ʱ����������
|
||
|
if ((Order == 4) || (Order == 2))
|
||
|
{
|
||
|
|
||
|
EndX = 0; EndY = 0; EndZ = 0;
|
||
|
//��ȡ������������
|
||
|
int mti = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(TaskIndex);
|
||
|
//������
|
||
|
int fid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(TaskIndex);
|
||
|
//������������
|
||
|
int controlTaskType = GetFCONTROLTASKTYPEFromManageTask(mti, fid);
|
||
|
#region �������棬��·����˫���Թ���վ̨��Ϣ
|
||
|
|
||
|
//�������Ƕ�������������ST_CELL��FDoubleFork=0����������ʹ�ý����棬ż����ʹ��Զ���棻�������水��ST_CELL��FDoubleFork��ֵ
|
||
|
Dictionary<int, string[]> rr = Model.CGeneralFunction.GetDoubleForkMonitorInfo(TaskIndex, DeviceIndex);
|
||
|
if (rr == null)
|
||
|
{
|
||
|
#region ��������
|
||
|
|
||
|
//����F_UseAwayFork='0',�������棬�����Ѿ������û��������ٷ���
|
||
|
if (Model.CGeneralFunction.GetUseAwayFork(TaskIndex) == "0")
|
||
|
{
|
||
|
|
||
|
#region ע��qdsr
|
||
|
//if (devinfo != null)
|
||
|
//{
|
||
|
|
||
|
// //int stackno = 0;
|
||
|
// //if (devinfo.VirtualStack > 0)
|
||
|
// //{
|
||
|
// // stackno = devinfo.VirtualStack;
|
||
|
// //}
|
||
|
// //else
|
||
|
// //{
|
||
|
// // stackno = DeviceIndex;
|
||
|
// //}
|
||
|
|
||
|
// ////�����������ֲ� �ൺ˼��˫���Ѷ������������������� �ൺ˼��д��
|
||
|
// //if ( StartX == 3)
|
||
|
// //{
|
||
|
// // UseAwayFork = 1;
|
||
|
// //}
|
||
|
// //else if ( StartX == 26)
|
||
|
// //{
|
||
|
// // UseAwayFork = 2;
|
||
|
// //}
|
||
|
// //else
|
||
|
// //{
|
||
|
// // UseAwayFork = Model.CGeneralFunction.GetDoubleForkFromST_CELL(StartZ, StartX, StartY, Model.CGeneralFunction.GetWAREHOUSEFromSTCELL(stackno));
|
||
|
// //}
|
||
|
// int stackno = 0;
|
||
|
// if (devinfo.VirtualStack > 0)
|
||
|
// {
|
||
|
// stackno = devinfo.VirtualStack;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// stackno = DeviceIndex;
|
||
|
// }
|
||
|
|
||
|
// UseAwayFork = Model.CGeneralFunction.GetDoubleForkFromST_CELL(StartZ, StartX, StartY, Model.CGeneralFunction.GetWAREHOUSEFromSTCELL(stackno));
|
||
|
// if (UseAwayFork == 0)
|
||
|
// {
|
||
|
|
||
|
// #region ������λ�ж��Ƿ�Ϊ�����У��Լ�����Ϊ��������
|
||
|
// sql.Clear();
|
||
|
// sql.Append("SELECT F_ForwardLimitX,F_BackLimitX FROM T_Base_LaneInfo WHERE F_StackIndex = ").Append(stackno).Append(" and F_ForwardLimitX>0 and F_BackLimitX>0");
|
||
|
// DataView dvl = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
// if ((devinfo.IfCorrelDoubleFork == "1") && (dvl.Count > 0))
|
||
|
// {
|
||
|
|
||
|
// if (zeroXcoor < Convert.ToInt32(dvl[0]["F_ForwardLimitX"]))
|
||
|
// {//����ԭ��������С��ForwardLimitX������ForwardLimitX��ForwardLimitX+(n-2)��
|
||
|
// if ((StartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) >= 0) && ((StartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
// {
|
||
|
// UseAwayFork = (StartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) + 1);
|
||
|
// }
|
||
|
// else if ((EndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) >= 0) && ((EndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
// {
|
||
|
// UseAwayFork = (EndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) + 1);
|
||
|
// }
|
||
|
// }
|
||
|
// else if (zeroXcoor > Convert.ToInt32(dvl[0]["F_ForwardLimitX"]))
|
||
|
// {//����ԭ������������ForwardLimitX������ForwardLimitX��ForwardLimitX-(n-2).
|
||
|
// if ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - StartX >= 0) && ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - StartX <= (devinfo.ForkAmount - 2))))
|
||
|
// {
|
||
|
// UseAwayFork = (Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - StartX + 1);
|
||
|
// }
|
||
|
// else if ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - EndX >= 0) && ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - EndX <= (devinfo.ForkAmount - 2))))
|
||
|
// {
|
||
|
// UseAwayFork = (Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - EndX + 1);
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// if (zeroXcoor < Convert.ToInt32(dvl[0]["F_BackLimitX"]))
|
||
|
// {//����ԭ��������С��F_BackLimitX������F_BackLimitX��F_BackLimitX-(n-2)��
|
||
|
// if ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - StartX >= 0) && ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - StartX <= (devinfo.ForkAmount - 2))))
|
||
|
// {
|
||
|
// UseAwayFork = (devinfo.ForkAmount - (Convert.ToInt32(dvl[0]["F_BackLimitX"]) - StartX));
|
||
|
// }
|
||
|
// else if ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - EndX >= 0) && ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - EndX <= (devinfo.ForkAmount - 2))))
|
||
|
// {
|
||
|
// UseAwayFork = (devinfo.ForkAmount - (Convert.ToInt32(dvl[0]["F_BackLimitX"]) - EndX));
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
// else if (zeroXcoor > Convert.ToInt32(dvl[0]["F_BackLimitX"]))
|
||
|
// {//����ԭ������������F_BackLimitX������F_BackLimitX��F_BackLimitX+(n-2).
|
||
|
// if ((StartX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) >= 0) && ((StartX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
// {
|
||
|
// UseAwayFork = (devinfo.ForkAmount - (StartX - Convert.ToInt32(dvl[0]["F_BackLimitX"])));
|
||
|
// }
|
||
|
// else if ((EndX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) >= 0) && ((EndX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
// {
|
||
|
// UseAwayFork = (devinfo.ForkAmount - (EndX - Convert.ToInt32(dvl[0]["F_BackLimitX"])));
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
|
||
|
// }
|
||
|
// #endregion
|
||
|
// }
|
||
|
// if (UseAwayFork == 0)
|
||
|
// {
|
||
|
// //�Ի���ȡ����
|
||
|
// if ((StartX % devinfo.ForkAmount) == 0)
|
||
|
// {
|
||
|
// UseAwayFork = devinfo.ForkAmount;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// UseAwayFork = StartX % devinfo.ForkAmount;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
//FDoubleFork ������STCELL ����ָ������
|
||
|
UseAwayFork = Model.CGeneralFunction.GetDoubleForkFromST_CELL(StartZ, StartX, StartY, Model.CGeneralFunction.GetWAREHOUSEFromSTCELL(DeviceIndex));
|
||
|
if (UseAwayFork == 0)
|
||
|
{
|
||
|
#region CATL YB2
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
|
||
|
if (devinfo != null)
|
||
|
{
|
||
|
|
||
|
int stackno = 0;
|
||
|
if (devinfo.VirtualStack > 0)
|
||
|
{
|
||
|
stackno = devinfo.VirtualStack;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackno = DeviceIndex;
|
||
|
}
|
||
|
#region ������λ�ж��Ƿ�Ϊ�����У��Լ�����Ϊ��������
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT F_ForwardLimitX,F_BackLimitX FROM T_Base_LaneInfo WHERE F_StackIndex = ").Append(stackno).Append(" and F_ForwardLimitX>0 and F_BackLimitX>0");
|
||
|
DataView dvl = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if ((devinfo.IfCorrelDoubleFork == "1") && (dvl.Count > 0))
|
||
|
{
|
||
|
|
||
|
if (zeroXcoor < Convert.ToInt32(dvl[0]["F_ForwardLimitX"]))
|
||
|
{//����ԭ��������С��ForwardLimitX������ForwardLimitX��ForwardLimitX+(n-2)��
|
||
|
if ((StartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) >= 0) && ((StartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (StartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) + 1);
|
||
|
}
|
||
|
else if ((EndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) >= 0) && ((EndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (EndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) + 1);
|
||
|
}
|
||
|
}
|
||
|
else if (zeroXcoor > Convert.ToInt32(dvl[0]["F_ForwardLimitX"]))
|
||
|
{//����ԭ������������ForwardLimitX������ForwardLimitX��ForwardLimitX-(n-2).
|
||
|
if ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - StartX >= 0) && ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - StartX <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - StartX + 1);
|
||
|
}
|
||
|
else if ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - EndX >= 0) && ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - EndX <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - EndX + 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (zeroXcoor < Convert.ToInt32(dvl[0]["F_BackLimitX"]))
|
||
|
{//����ԭ��������С��F_BackLimitX������F_BackLimitX��F_BackLimitX-(n-2)��
|
||
|
if ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - StartX >= 0) && ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - StartX <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (devinfo.ForkAmount - (Convert.ToInt32(dvl[0]["F_BackLimitX"]) - StartX));
|
||
|
}
|
||
|
else if ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - EndX >= 0) && ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - EndX <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (devinfo.ForkAmount - (Convert.ToInt32(dvl[0]["F_BackLimitX"]) - EndX));
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (zeroXcoor > Convert.ToInt32(dvl[0]["F_BackLimitX"]))
|
||
|
{//����ԭ������������F_BackLimitX������F_BackLimitX��F_BackLimitX+(n-2).
|
||
|
if ((StartX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) >= 0) && ((StartX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (devinfo.ForkAmount - (StartX - Convert.ToInt32(dvl[0]["F_BackLimitX"])));
|
||
|
}
|
||
|
else if ((EndX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) >= 0) && ((EndX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (devinfo.ForkAmount - (EndX - Convert.ToInt32(dvl[0]["F_BackLimitX"])));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
if (UseAwayFork == 0)
|
||
|
{
|
||
|
if ((StartX % devinfo.ForkAmount) == 0)
|
||
|
{
|
||
|
UseAwayFork = devinfo.ForkAmount;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = StartX % devinfo.ForkAmount;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
if (UseAwayFork > devinfo.ForkAmount)
|
||
|
{
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���Ͷ����Ѷ�������", DeviceIndex.ToString(), barcode.ToCharArray() + "����������ʧ�ܣ��ţ�" + StartZ.ToString() + "�У�" + StartX.ToString() + "�㣺" + StartY.ToString() + "����������" + devinfo.ForkAmount.ToString() + "��������ʵ�ʻ���" + UseAwayFork.ToString());
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + barcode + "����������ʧ�ܣ��ţ�" + StartZ.ToString() + "�У�" + StartX.ToString() + "�㣺" + StartY.ToString() + "����������" + devinfo.ForkAmount.ToString() + "��������ʵ�ʻ���" + UseAwayFork.ToString();
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
//2220173-ʱ������ ���ӶѶ�������ǰ�����ж϶Ѷ��������Ƿ��� ����ʱ ���Ļ���
|
||
|
if (ChangeForkWhenEnableUsed(DeviceIndex) != 0)//˵���н��û��� ��������
|
||
|
{
|
||
|
//if (UseAwayFork == ChangeForkWhenEnableUsed(DeviceIndex))//���IJ� == ���õĻ���
|
||
|
//{
|
||
|
//�IJ� �������
|
||
|
//����λ�õĻ��� �Ǹ�����ֵ�ո����õ� ��û���¸����ݿ� �Ƚ�ȥ����һ�� ����һ���ǿ��õĻ��� �ڶ��η���ʱ ����usefork��=0 ȥ���ڸ���Ϊ���õ�
|
||
|
//���������ж� �Ƿ�==�����û��� ��Ҫ�ڴ˸������ݿ��л��� ͬʱҲ��Ҫ������ǰ��������
|
||
|
ChangForkForTask(fid, TaskIndex, UseAwayFork, DeviceIndex, mti);
|
||
|
return false;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
|
||
|
//}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// add for CATL YB2 �滻��ǰ������վ̨ ͬʱ���ǵ���·����ѡվ̨����ǰ����
|
||
|
bool rp = SetLaneGateReplace(mti, fid, DeviceIndex, TaskIndex, UseAwayFork);
|
||
|
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_UseAwayFork = '").Append(UseAwayFork).Append("' WHERE (F_ManageTaskIndex = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(") AND F_DeviceIndex = ").Append(DeviceIndex);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Manage_Task SET FUseAwayFork = '").Append(UseAwayFork).Append("' WHERE (FID = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(")");
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
if (rp == true) return false;//20120217
|
||
|
}
|
||
|
//// add for CATL YB2 �滻��ǰ������վ̨ ͬʱ���ǵ���·����ѡվ̨����ǰ����
|
||
|
//bool rp = SetLaneGateReplace(mti, fid, DeviceIndex, TaskIndex, UseAwayFork);
|
||
|
|
||
|
//sql.Clear();
|
||
|
//sql.Append("UPDATE T_Monitor_Task SET F_UseAwayFork = '").Append(UseAwayFork).Append("' WHERE (F_ManageTaskIndex = ")
|
||
|
// .Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
// .Append(mti).Append(") AND F_DeviceIndex = ").Append(DeviceIndex);
|
||
|
//dbo.ExecuteSql(sql.ToString());
|
||
|
//sql.Clear();
|
||
|
//sql.Append("UPDATE T_Manage_Task SET FUseAwayFork = '").Append(UseAwayFork).Append("' WHERE (FID = ")
|
||
|
// .Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
// .Append(mti).Append(")");
|
||
|
//dbo.ExecuteSql(sql.ToString());
|
||
|
//if (rp == true) return false;//20120217
|
||
|
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(TaskIndex));
|
||
|
if (UseAwayFork > devinfo.ForkAmount)
|
||
|
{
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���Ͷ����Ѷ�������", DeviceIndex.ToString(), barcode.ToCharArray() + "����ȡ����ʱ�����Ļ����������ţ�" + StartZ.ToString() + "�У�" + StartX.ToString() + "�㣺" + StartY.ToString() + "����������" + devinfo.ForkAmount.ToString() + "��������ʵ�ʻ���" + UseAwayFork.ToString());
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + barcode + "����ȡ����ʱ�����Ļ����������ţ�" + StartZ.ToString() + "�У�" + StartX.ToString() + "�㣺" + StartY.ToString() + "����������" + devinfo.ForkAmount.ToString() + "��������ʵ�ʻ���" + UseAwayFork.ToString();
|
||
|
return false;
|
||
|
}
|
||
|
//2220173-ʱ������ ���ӶѶ�������ǰ�����ж϶Ѷ��������Ƿ��� ����ʱ ���Ļ���
|
||
|
if (ChangeForkWhenEnableUsed(DeviceIndex) != 0)//˵���н��û��� ��������
|
||
|
{
|
||
|
if (UseAwayFork == ChangeForkWhenEnableUsed(DeviceIndex))//���IJ� == ���õĻ���
|
||
|
{
|
||
|
//�IJ� �������
|
||
|
ChangForkForTask(fid, TaskIndex, UseAwayFork, DeviceIndex, mti);
|
||
|
return false;
|
||
|
}
|
||
|
//else
|
||
|
//{
|
||
|
|
||
|
//}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// add for CATL YB2 �滻��ǰ������վ̨ ͬʱ���ǵ���·����ѡվ̨����ǰ����
|
||
|
bool rp = SetLaneGateReplace(mti, fid, DeviceIndex, TaskIndex, UseAwayFork);
|
||
|
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_UseAwayFork = '").Append(UseAwayFork).Append("' WHERE (F_ManageTaskIndex = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(") AND F_DeviceIndex = ").Append(DeviceIndex);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Manage_Task SET FUseAwayFork = '").Append(UseAwayFork).Append("' WHERE (FID = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(")");
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
if (rp == true) return false;//20120217
|
||
|
}
|
||
|
|
||
|
////ͬʱ���ǵ���·����ѡվ̨����ǰ���� add for CATL YB2 �������ͻ��յ�վ̨
|
||
|
//bool rp = SetLaneGateReplace(mti, fid, DeviceIndex, TaskIndex, UseAwayFork);//20120217
|
||
|
//sql.Clear();
|
||
|
//sql.Append("UPDATE T_Monitor_Task SET F_UseAwayFork = '").Append(UseAwayFork).Append("' WHERE (F_ManageTaskIndex = ")
|
||
|
// .Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
// .Append(mti).Append(") AND F_DeviceIndex = ").Append(DeviceIndex);
|
||
|
//dbo.ExecuteSql(sql.ToString());
|
||
|
//sql.Clear();
|
||
|
//sql.Append("UPDATE T_Manage_Task SET FUseAwayFork = '").Append(UseAwayFork).Append("' WHERE (FID = ")
|
||
|
// .Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
// .Append(mti).Append(")");
|
||
|
//dbo.ExecuteSql(sql.ToString());
|
||
|
//if (rp == true) return false;//20120217
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region �������
|
||
|
Dictionary<int, double> minzerodis = new Dictionary<int, double>();
|
||
|
Dictionary<int, string[]> rrnew = rr;
|
||
|
int mintask = 0; double minDist = 0; int[] tasks;
|
||
|
while (rrnew.Keys.Count > 0)
|
||
|
{
|
||
|
tasks = new int[rrnew.Keys.Count];
|
||
|
rrnew.Keys.CopyTo(tasks, 0);
|
||
|
//����������ԭ���ľ�����С�������� ����ԭ����С��Ϊ1�� ����Ϊ2�� stcell��Ҳ��FDOUBLEFORK ����
|
||
|
// T_BASE_STACKINFO ����ԭ����
|
||
|
Model.CGeneralFunction.GetMinZeroDistanceTask(tasks, devinfo, Order, out mintask, out minDist);
|
||
|
minzerodis.Add(mintask, minDist);
|
||
|
rrnew.Remove(mintask);
|
||
|
}
|
||
|
int forkno = 1; int tempStartX = 0, tempEndX = 0;
|
||
|
bool Ifreturn = false;
|
||
|
foreach (int task in minzerodis.Keys)
|
||
|
{
|
||
|
UseAwayFork = 0;
|
||
|
mti = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(task);
|
||
|
fid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(task);
|
||
|
|
||
|
if (Model.CGeneralFunction.GetUseAwayFork(task) == "0")
|
||
|
{
|
||
|
//δ�������棬�ж��Ƿ�Ϊ����λ��n�濼�Ǽ���λ��n-1�У�
|
||
|
#region ������λ�ж��Ƿ�Ϊ�����У��Լ�����Ϊ��������
|
||
|
int stackno = 0;
|
||
|
if (devinfo.VirtualStack > 0)
|
||
|
{
|
||
|
stackno = devinfo.VirtualStack;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
stackno = DeviceIndex;
|
||
|
}
|
||
|
//�����������жϼ���λ add for CATL YB2 �����ڼ���λ
|
||
|
if (controlTaskType != 2)
|
||
|
{
|
||
|
sql.Clear();
|
||
|
//�ж�ǰ������λ�Ƿ����ڲ��Ҷ��Ǵ���0��
|
||
|
sql.Append("SELECT F_ForwardLimitX,F_BackLimitX FROM T_Base_LaneInfo WHERE F_StackIndex = ").Append(stackno).Append(" and F_ForwardLimitX>0 and F_BackLimitX>0");
|
||
|
DataView dvl = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
#region ����λ�����ж�
|
||
|
if ((devinfo.IfCorrelDoubleFork == "1") && (dvl.Count > 0))
|
||
|
{
|
||
|
tempStartX = Model.CGeneralFunction.GetXCoorFromMonitor(task, DeviceIndex, 4);
|
||
|
tempEndX = Model.CGeneralFunction.GetXCoorFromMonitor(task, DeviceIndex, 5);
|
||
|
|
||
|
if (zeroXcoor < Convert.ToInt32(dvl[0]["F_ForwardLimitX"]))
|
||
|
{//����ԭ��������С��ForwardLimitX������ForwardLimitX��ForwardLimitX+(n-2)��
|
||
|
if ((tempStartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) >= 0) && ((tempStartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (tempStartX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) + 1);
|
||
|
}
|
||
|
else if ((tempEndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) >= 0) && ((tempEndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (tempEndX - Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) + 1);
|
||
|
}
|
||
|
}
|
||
|
else if (zeroXcoor > Convert.ToInt32(dvl[0]["F_ForwardLimitX"]))
|
||
|
{//����ԭ������������ForwardLimitX������ForwardLimitX��ForwardLimitX-(n-2).
|
||
|
if ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - tempStartX >= 0) && ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - tempStartX <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - tempStartX + 1);
|
||
|
}
|
||
|
else if ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - tempEndX >= 0) && ((Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - tempEndX <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (Convert.ToInt32(dvl[0]["F_ForwardLimitX"]) - tempEndX + 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (zeroXcoor < Convert.ToInt32(dvl[0]["F_BackLimitX"]))
|
||
|
{//����ԭ��������С��F_BackLimitX������F_BackLimitX��F_BackLimitX-(n-2)��
|
||
|
if ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - tempStartX >= 0) && ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - tempStartX <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (devinfo.ForkAmount - (Convert.ToInt32(dvl[0]["F_BackLimitX"]) - tempStartX));
|
||
|
}
|
||
|
else if ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - tempEndX >= 0) && ((Convert.ToInt32(dvl[0]["F_BackLimitX"]) - tempEndX <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (devinfo.ForkAmount - (Convert.ToInt32(dvl[0]["F_BackLimitX"]) - tempEndX));
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (zeroXcoor > Convert.ToInt32(dvl[0]["F_BackLimitX"]))
|
||
|
{//����ԭ������������F_BackLimitX������F_BackLimitX��F_BackLimitX+(n-2).
|
||
|
if ((tempStartX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) >= 0) && ((tempStartX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (devinfo.ForkAmount - (tempStartX - Convert.ToInt32(dvl[0]["F_BackLimitX"])));
|
||
|
}
|
||
|
else if ((tempEndX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) >= 0) && ((tempEndX - Convert.ToInt32(dvl[0]["F_BackLimitX"]) <= (devinfo.ForkAmount - 2))))
|
||
|
{
|
||
|
UseAwayFork = (devinfo.ForkAmount - (tempEndX - Convert.ToInt32(dvl[0]["F_BackLimitX"])));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
//�ͶѶ���ԭ����������ȡ����ֵ��ֵ��С����1�棬�����Ѿ��������IJ�Ҫ�ظ�
|
||
|
//����������
|
||
|
if (UseAwayFork == 0)
|
||
|
{
|
||
|
//ԭ����������
|
||
|
//UseAwayFork = forkno;
|
||
|
//�ൺ˼���µķ������� ������������ ������С�ķ��䵽2�� �����Ŵ��ķ��䵽1
|
||
|
//�������� ��һ�������ǵ��������� ����ֱ�ӷ����˷��͵Ļ���
|
||
|
//�����dz�������
|
||
|
// UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(task, DeviceIndex, Order));
|
||
|
UseAwayFork = forkno;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(task));
|
||
|
}
|
||
|
#region ���������Ѿ�����������ռ�ã������л����֣���Ҫ��������ϵ
|
||
|
if (IfDeleteRelative(mti, fid, task, UseAwayFork) == true)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
#endregion
|
||
|
#region �������ݿ����л���������������ʾ
|
||
|
if (UseAwayFork > devinfo.ForkAmount)
|
||
|
{
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���Ͷ����Ѷ�������", DeviceIndex.ToString(), barcode.ToCharArray() + "�������������������������ţ�" + StartZ.ToString() + "�У�" + StartX.ToString() + "�㣺" + StartY.ToString() + "����������" + devinfo.ForkAmount.ToString() + "��������ʵ�ʻ���" + UseAwayFork.ToString());
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + barcode + "�������������������������ţ�" + StartZ.ToString() + "�У�" + StartX.ToString() + "�㣺" + StartY.ToString() + "����������" + devinfo.ForkAmount.ToString() + "��������ʵ�ʻ���" + UseAwayFork.ToString();
|
||
|
|
||
|
dbo.ExecuteSql(string.Format("UPDATE T_Manage_Task SET F_RELATIVECONTORLID = - 1 WHERE (F_ManageTaskKindIndex = {0}) AND (FID = {1})", mti, fid));
|
||
|
return false;
|
||
|
}
|
||
|
#endregion
|
||
|
//ԭ���� ���ൺ˼����
|
||
|
forkno = UseAwayFork;
|
||
|
//�ൺ˼��
|
||
|
//if (controlTaskType != 2)
|
||
|
//{
|
||
|
// forkno = UseAwayFork;
|
||
|
//}
|
||
|
|
||
|
//2220173-ʱ������ ���ӶѶ�������ǰ�����ж϶Ѷ��������Ƿ��� ����ʱ ���Ļ���
|
||
|
//UseAwayFork = ChangeForkWhenEnableUsed(DeviceIndex, UseAwayFork);
|
||
|
|
||
|
//20111226ͬʱ���ǵ���·����ѡվ̨����ǰ����
|
||
|
//20200318������һ����ǰ����
|
||
|
bool rp = SetLaneGateReplace(mti, fid, DeviceIndex, task, UseAwayFork);//20120217
|
||
|
if (rp == true) Ifreturn = true;
|
||
|
// ����˫�����������ֲ�
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_UseAwayFork = '").Append(UseAwayFork).Append("' WHERE (F_ManageTaskIndex = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(") AND F_DeviceIndex = ").Append(DeviceIndex);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Manage_Task SET FUseAwayFork = '").Append(UseAwayFork).Append("' WHERE (Fid = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(") ");
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
//ԭ�����Ĵ���
|
||
|
forkno++;
|
||
|
}
|
||
|
if (Ifreturn == true) return false;
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ͬ�������첽����
|
||
|
|
||
|
|
||
|
int[] mutitasks = Model.CGeneralFunction.MutiForkIfSync(TaskIndex, DeviceIndex, devinfo.DeviceKind);
|
||
|
if (mutitasks != null)
|
||
|
{
|
||
|
#region ע��
|
||
|
//foreach (int temptask in mutitasks)
|
||
|
//{
|
||
|
// UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(temptask));
|
||
|
// if (temptask == TaskIndex)
|
||
|
// {
|
||
|
// //ɽ���»������ ���ߵ������� ���� 2����Ӧ���в���1
|
||
|
// if (StartX > zeroXcoor)
|
||
|
// {
|
||
|
// StartX = StartX - (UseAwayFork - 1);
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// StartX = StartX + (UseAwayFork - 1);
|
||
|
// }
|
||
|
// }
|
||
|
// startz[UseAwayFork - 1] = Model.CGeneralFunction.GetZCoorFromMonitor(temptask, DeviceIndex, Order);
|
||
|
// if (startz[UseAwayFork - 1] != 0)
|
||
|
// {
|
||
|
// if (startz[UseAwayFork - 1] % 2 == 0)
|
||
|
// {
|
||
|
// startz[UseAwayFork - 1] = 2;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// startz[UseAwayFork - 1] = 1;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
foreach (int temptask in mutitasks)
|
||
|
{
|
||
|
UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(temptask));
|
||
|
if (temptask == TaskIndex)
|
||
|
{
|
||
|
if (StartX > zeroXcoor)
|
||
|
{
|
||
|
StartX = StartX - (UseAwayFork - 1);//��1�涨λ
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
StartX = StartX + (UseAwayFork - 1);
|
||
|
}
|
||
|
}
|
||
|
startz[UseAwayFork - 1] = Model.CGeneralFunction.GetZCoorFromMonitor(temptask, DeviceIndex, Order);
|
||
|
if (startz[UseAwayFork - 1] != 0)
|
||
|
{
|
||
|
// 2220173-ʱ������
|
||
|
if (DeviceIndex == 10001)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 1:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 2:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10002)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 2:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 3:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10003)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 3:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 4:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10004)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 5:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 6:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10005)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 6:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 7:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10006)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 7:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 8:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
//if (startz[UseAwayFork - 1] % 2 == 0)
|
||
|
//{
|
||
|
// startz[UseAwayFork - 1] = 2;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// startz[UseAwayFork - 1] = 1;
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(TaskIndex));
|
||
|
if (StartX > zeroXcoor)
|
||
|
{
|
||
|
StartX = StartX - (UseAwayFork - 1);
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
StartX = StartX + (UseAwayFork - 1);
|
||
|
}
|
||
|
|
||
|
startz[UseAwayFork - 1] = StartZ;
|
||
|
if (startz[UseAwayFork - 1] != 0)
|
||
|
{
|
||
|
// 2220173-ʱ������
|
||
|
if (DeviceIndex == 10001)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 1:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 2:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10002)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 2:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 3:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10003)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 3:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 4:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10004)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 5:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 6:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10005)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 6:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 7:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10006)
|
||
|
{
|
||
|
switch (startz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 7:
|
||
|
startz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 8:
|
||
|
startz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
//if (startz[UseAwayFork - 1] % 2 == 0)
|
||
|
//{
|
||
|
// startz[UseAwayFork - 1] = 2;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// startz[UseAwayFork - 1] = 1;
|
||
|
//}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �Ѷ�����˫���ͻ�ָ��ڴ˾���ͬ�������첽����
|
||
|
|
||
|
if ((Order == 5) || (Order == 3))
|
||
|
{
|
||
|
UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(TaskIndex));
|
||
|
if (UseAwayFork == 0)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�������Ѷ�������δ���䣡������" + TaskIndex;
|
||
|
return false;
|
||
|
}
|
||
|
#region ͬ�������첽����
|
||
|
int[] mutitasks = Model.CGeneralFunction.MutiForkIfSync(TaskIndex, DeviceIndex, devinfo.DeviceKind);
|
||
|
if (mutitasks != null)
|
||
|
{
|
||
|
#region ע��
|
||
|
//foreach (int temptask in mutitasks)
|
||
|
//{
|
||
|
// UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(temptask));
|
||
|
// if (temptask == TaskIndex)
|
||
|
// {
|
||
|
// if (EndX > zeroXcoor)
|
||
|
// {
|
||
|
// if (EndX == 27 && UseAwayFork == 2)
|
||
|
// {
|
||
|
// EndX = 27;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// EndX = EndX - (UseAwayFork - 1);
|
||
|
// }
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// EndX = EndX + (UseAwayFork - 1);
|
||
|
// }
|
||
|
// }
|
||
|
// endz[UseAwayFork - 1] = Model.CGeneralFunction.GetZCoorFromMonitor(temptask, DeviceIndex, Order);
|
||
|
// if (endz[UseAwayFork - 1] != 0)
|
||
|
// {
|
||
|
// if (endz[UseAwayFork - 1] % 2 == 0)
|
||
|
// {
|
||
|
// endz[UseAwayFork - 1] = 2;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// endz[UseAwayFork - 1] = 1;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
//add for CATL YB2
|
||
|
foreach (int temptask in mutitasks)
|
||
|
{
|
||
|
UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(temptask));
|
||
|
if (temptask == TaskIndex)
|
||
|
{
|
||
|
if (EndX > zeroXcoor)
|
||
|
{
|
||
|
EndX = EndX - (UseAwayFork - 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
EndX = EndX + (UseAwayFork - 1);
|
||
|
}
|
||
|
}
|
||
|
endz[UseAwayFork - 1] = Model.CGeneralFunction.GetZCoorFromMonitor(temptask, DeviceIndex, Order);
|
||
|
if (endz[UseAwayFork - 1] != 0)
|
||
|
{
|
||
|
// 2220173-ʱ������
|
||
|
if (DeviceIndex == 10001)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 1:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 2:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10002)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 2:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 3:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10003)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 3:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 4:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10004)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 5:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 6:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10005)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 6:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 7:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10006)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 7:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 8:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
//if (endz[UseAwayFork - 1] % 2 == 0)
|
||
|
//{
|
||
|
// endz[UseAwayFork - 1] = 2;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// endz[UseAwayFork - 1] = 1;
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region ע��
|
||
|
//if (EndX > zeroXcoor)
|
||
|
//{
|
||
|
// if (UseAwayFork == 2 && EndX == 27)
|
||
|
// {
|
||
|
// EndX = 27;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// EndX = EndX - (UseAwayFork - 1);
|
||
|
// }
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// EndX = EndX + (UseAwayFork - 1);
|
||
|
//}
|
||
|
|
||
|
//endz[UseAwayFork - 1] = EndZ;
|
||
|
//if (endz[UseAwayFork - 1] != 0)
|
||
|
//{
|
||
|
// if (endz[UseAwayFork - 1] % 2 == 0)
|
||
|
// {
|
||
|
// endz[UseAwayFork - 1] = 2;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// endz[UseAwayFork - 1] = 1;
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
if (EndX > zeroXcoor)
|
||
|
{
|
||
|
EndX = EndX - (UseAwayFork - 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
EndX = EndX + (UseAwayFork - 1);
|
||
|
}
|
||
|
|
||
|
endz[UseAwayFork - 1] = EndZ;
|
||
|
if (endz[UseAwayFork - 1] != 0)
|
||
|
{
|
||
|
// 2220173-ʱ������
|
||
|
if (DeviceIndex == 10001)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 1:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 2:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10002)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 2:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 3:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10003)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 3:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 4:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10004)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 5:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 6:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10005)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 6:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 7:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10006)
|
||
|
{
|
||
|
switch (endz[UseAwayFork - 1])
|
||
|
{
|
||
|
case 7:
|
||
|
endz[UseAwayFork - 1] = 1;
|
||
|
break;
|
||
|
case 8:
|
||
|
endz[UseAwayFork - 1] = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
//if (endz[UseAwayFork - 1] % 2 == 0)
|
||
|
//{
|
||
|
// endz[UseAwayFork - 1] = 2;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// endz[UseAwayFork - 1] = 1;
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
//9,11,13
|
||
|
int arrAmout = 9 + (devinfo.ForkAmount - 1) * 2;
|
||
|
int arrsn = 0; StringBuilder strap = new StringBuilder();
|
||
|
StringBuilder[] itemnames = new StringBuilder[arrAmout];
|
||
|
StringBuilder[] itemvalues = new StringBuilder[arrAmout];
|
||
|
for (int i = 0; i < arrAmout; i++)
|
||
|
{
|
||
|
itemnames[i] = new StringBuilder();
|
||
|
itemvalues[i] = new StringBuilder();
|
||
|
}
|
||
|
#region ע��
|
||
|
//�ж���ͬ�����Dz���ͬ������ͬ������ͬ����ʶ3
|
||
|
//����ͬ���жϵ�ǰ���������Ļ��� ������2������Ҫ��ȡ�����ͻ����м�1 ���ڻ������ֶ�д2
|
||
|
//������1�� ���ڻ������ֶ�д 1
|
||
|
//if (sdxhmutitasks == 1)
|
||
|
//{
|
||
|
// //ɽ������ ������ʶλ
|
||
|
// sdxhmutitasks = 3;
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// //������1�� ������ʶ�ͷ�1
|
||
|
// if (UseAwayFork == 1)
|
||
|
// {
|
||
|
// sdxhmutitasks = 1;
|
||
|
// }
|
||
|
// else if (UseAwayFork == 2)
|
||
|
// {
|
||
|
// //������2���Ļ� ȡ�ͻ��ж�Ҫ��1
|
||
|
// StartX += 1;
|
||
|
// EndX += 1;
|
||
|
// sdxhmutitasks = 2;
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
#endregion
|
||
|
//�����Ѷ��� ������ȥ15��ȡ�� ���ǽ���ͣ��15��
|
||
|
sn = devinfo.Dbw1Address;
|
||
|
//˫���Ѷ��� ��һ�ֽڶ�д��־λ ��һ������ͷ��������
|
||
|
//itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
//itemvalues[0].Append("0");
|
||
|
////�ڶ��ֽ� ������ ��һ������ͷ��������
|
||
|
//itemnames[1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
//itemvalues[1].Append("0");
|
||
|
//��3��4�ֽ��������� ʹ��int ���� �����ֽ� ���ܴ���30000
|
||
|
itemnames[2].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2)).Append(",i");
|
||
|
itemvalues[2].Append(TaskIndex.ToString());
|
||
|
//��5�ֽ� ȡ����X�����ع�������
|
||
|
itemnames[3].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 4)).Append(",b");
|
||
|
itemvalues[3].Append(StartX.ToString());
|
||
|
//��6�ֽ� ȡ���� Y ����
|
||
|
itemnames[4].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 5)).Append(",b");
|
||
|
itemvalues[4].Append(StartY.ToString());
|
||
|
//��7��8�ֽ� ȡ���� z[i] ���� ˫��������Զ��������
|
||
|
for (int i = 1; i <= devinfo.ForkAmount; i++)
|
||
|
{
|
||
|
itemnames[4 + i].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 5 + i)).Append(",b");
|
||
|
itemvalues[4 + i].Append(startz[i - 1].ToString());
|
||
|
strap.Append(i.ToString()).Append("��ȡ��Z:").Append(startz[i - 1].ToString()).Append(";");
|
||
|
}
|
||
|
arrsn = 4 + devinfo.ForkAmount;
|
||
|
//��9�ֽ� �ͻ���X����
|
||
|
itemnames[arrsn + 1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + arrsn + 2)).Append(",b");
|
||
|
itemvalues[arrsn + 1].Append(EndX.ToString());
|
||
|
//��10�ֽ� �ͻ���Y����
|
||
|
itemnames[arrsn + 2].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + arrsn + 3)).Append(",b");
|
||
|
itemvalues[arrsn + 2].Append(EndY.ToString());
|
||
|
//��11��12�ֽ��ͻ�λ��Z[1] �� Z[2]
|
||
|
for (int i = 1; i <= devinfo.ForkAmount; i++)
|
||
|
{
|
||
|
itemnames[arrsn + 2 + i].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + arrsn + 3 + i)).Append(",b");
|
||
|
itemvalues[arrsn + 2 + i].Append(endz[i - 1].ToString());
|
||
|
strap.Append(i.ToString()).Append("������Z:").Append(endz[i - 1].ToString()).Append(";");
|
||
|
}
|
||
|
//��13�ֽ��ǻ�����ʶ 1��1�� 2��2�� 3��ͬ������ ɽ������
|
||
|
//itemnames[12].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 12 )).Append(",b");
|
||
|
//itemvalues[12].Append(sdxhmutitasks.ToString());
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[0].Append(MessageIndex.ToString());
|
||
|
itemnames[1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
itemvalues[1].Append(Order.ToString());
|
||
|
|
||
|
//itemnames[arrsn + 3 + devinfo.ForkAmount].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
//itemvalues[arrsn + 3 + devinfo.ForkAmount].Append(Order.ToString());
|
||
|
//itemnames[arrsn + 3 + devinfo.ForkAmount + 1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
//itemvalues[arrsn + 3 + devinfo.ForkAmount + 1].Append(MessageIndex.ToString());
|
||
|
|
||
|
//OPC Server�Ļ������ƻ���IP��ַ
|
||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
|
||
|
//OPC Server�ij�����ʶ�����磺OPC.SimaticNET
|
||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
||
|
// ����PLC���ӵ�ID�����磺"S7:[S7 connection_1]"
|
||
|
CCommonOPCClient.PlcConnectionID = devinfo.S7Connection;
|
||
|
// add for CATL YB2 �첽���� AWriteAllItemValue SyncWriteAllItemValue(itemnames, itemvalues)
|
||
|
// //ȥ��ԭ�е�"��д�������ֽ�, ��д����Ϣͷ"��дOPC������, ��Ϊ"ÿ��ͨ��ֻд��һ��OPC����"
|
||
|
if (CCommonOPCClient.AWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + CCommonOPCClient.OpcError;
|
||
|
return false;
|
||
|
}
|
||
|
//itemvalues[0].Remove(0, itemvalues[0].Length);
|
||
|
//itemvalues[0].Append(MessageIndex.ToString());
|
||
|
//itemvalues[1].Remove(0, itemvalues[1].Length);
|
||
|
//itemvalues[1].Append(Order.ToString());
|
||
|
//// add for CATL YB2 �첽���� AWriteAllItemValue SyncWriteAllItemValue(itemnames, itemvalues)
|
||
|
//if (CCommonOPCClient.AWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
//{
|
||
|
// _commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + CCommonOPCClient.OpcError;
|
||
|
// return false;
|
||
|
//}
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("���룺").Append(barcode).Append("**д��־").Append(MessageIndex.ToString()).Append("**������" + Order.ToString()).Append("**������" + TaskIndex.ToString())
|
||
|
.Append("**��ʼ��" + StartZ.ToString()).Append("**��ʼ��" + StartX.ToString()).Append("**��ʼ��" + StartY.ToString())
|
||
|
.Append("**��ֹ��" + EndZ.ToString()).Append("**��ֹ��" + EndX.ToString()).Append("**��ֹ��" + EndY.ToString())
|
||
|
.Append(";").Append(strap).Append("**����" + sdxhmutitasks.ToString());
|
||
|
|
||
|
// add for CATL YB2 ���ƺ�ϻ��д����
|
||
|
if (MessageIndex == 0 || MessageIndex == 1 || MessageIndex == 2 || MessageIndex == 4)
|
||
|
{
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���ͶѶ�������", DeviceIndex.ToString(), sss.ToString());
|
||
|
}
|
||
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���Ͷ����Ѷ�������", DeviceIndex.ToString(), sss.ToString());
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region �����Ѷ��� DB1дֵ
|
||
|
//֪ͨ�Ѷ�����������
|
||
|
StringBuilder[] itemnames = { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") };
|
||
|
StringBuilder[] itemvalues = { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") };
|
||
|
#region ת����Z��������
|
||
|
int a = 2;
|
||
|
int Z = 0;
|
||
|
//StackReach ��ʾ������
|
||
|
//if (devinfo.StackReach == 2)
|
||
|
//{
|
||
|
// a = 4;
|
||
|
//}
|
||
|
//if (DeviceIndex == 11001)
|
||
|
//{
|
||
|
// #region ˫���Ѷ��� 134��
|
||
|
// if (StartZ != 0)
|
||
|
// {
|
||
|
// Z = StartZ % a;
|
||
|
// if (Z == 0)
|
||
|
// {
|
||
|
// StartZ = a;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// StartZ = Z;
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
// if (EndZ != 0)
|
||
|
// {
|
||
|
// Z = EndZ % a;
|
||
|
// if (Z == 0)
|
||
|
// {
|
||
|
// EndZ = a;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// EndZ = Z;
|
||
|
// }
|
||
|
// }
|
||
|
// #endregion
|
||
|
//}
|
||
|
//else if (DeviceIndex == 11002 || DeviceIndex == 11003)
|
||
|
//{
|
||
|
// a = 3;
|
||
|
// if (StartZ != 0)
|
||
|
// {
|
||
|
// Z = StartZ % a;
|
||
|
// if (Z == 2)
|
||
|
// {
|
||
|
// StartZ = 1;
|
||
|
// }
|
||
|
// else if (Z == 0)
|
||
|
// {
|
||
|
// StartZ = 3;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// StartZ = 4;
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
// if (EndZ != 0)
|
||
|
// {
|
||
|
// Z = EndZ % a;
|
||
|
// if (Z == 2)
|
||
|
// {
|
||
|
// EndZ = 1;
|
||
|
// }
|
||
|
// else if (Z == 0)
|
||
|
// {
|
||
|
// EndZ = 3;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// EndZ = 4;
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
|
||
|
#region ��˫���Ѷ����� Z ת��
|
||
|
|
||
|
// 2220173-ʱ������
|
||
|
//10001--1/2 10002--2/3 10003--3/4
|
||
|
//10004--5/6 10005--6/7 10006--7/8
|
||
|
//StartZ
|
||
|
if (DeviceIndex == 10001)
|
||
|
{
|
||
|
if (StartZ != 0)
|
||
|
{
|
||
|
switch (StartZ)
|
||
|
{
|
||
|
case 1:
|
||
|
StartZ = 1;
|
||
|
break;
|
||
|
case 2:
|
||
|
StartZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10002)
|
||
|
{
|
||
|
if (StartZ != 0)
|
||
|
{
|
||
|
switch (StartZ)
|
||
|
{
|
||
|
case 2:
|
||
|
StartZ = 1;
|
||
|
break;
|
||
|
case 3:
|
||
|
StartZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10003)
|
||
|
{
|
||
|
if (StartZ != 0)
|
||
|
{
|
||
|
switch (StartZ)
|
||
|
{
|
||
|
case 3:
|
||
|
StartZ = 1;
|
||
|
break;
|
||
|
case 4:
|
||
|
StartZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10004)
|
||
|
{
|
||
|
if (StartZ != 0)
|
||
|
{
|
||
|
switch (StartZ)
|
||
|
{
|
||
|
case 5:
|
||
|
StartZ = 1;
|
||
|
break;
|
||
|
case 6:
|
||
|
StartZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10005)
|
||
|
{
|
||
|
if (StartZ != 0)
|
||
|
{
|
||
|
switch (StartZ)
|
||
|
{
|
||
|
case 6:
|
||
|
StartZ = 1;
|
||
|
break;
|
||
|
case 7:
|
||
|
StartZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10006)
|
||
|
{
|
||
|
if (StartZ != 0)
|
||
|
{
|
||
|
switch (StartZ)
|
||
|
{
|
||
|
case 7:
|
||
|
StartZ = 1;
|
||
|
break;
|
||
|
case 8:
|
||
|
StartZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//EndZ
|
||
|
if (DeviceIndex == 10001)
|
||
|
{
|
||
|
if (EndZ != 0)
|
||
|
{
|
||
|
switch (EndZ)
|
||
|
{
|
||
|
case 1:
|
||
|
EndZ = 1;
|
||
|
break;
|
||
|
case 2:
|
||
|
EndZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10002)
|
||
|
{
|
||
|
if (EndZ != 0)
|
||
|
{
|
||
|
switch (EndZ)
|
||
|
{
|
||
|
case 2:
|
||
|
EndZ = 1;
|
||
|
break;
|
||
|
case 3:
|
||
|
EndZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10003)
|
||
|
{
|
||
|
if (EndZ != 0)
|
||
|
{
|
||
|
switch (EndZ)
|
||
|
{
|
||
|
case 3:
|
||
|
EndZ = 1;
|
||
|
break;
|
||
|
case 4:
|
||
|
EndZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10004)
|
||
|
{
|
||
|
if (EndZ != 0)
|
||
|
{
|
||
|
switch (EndZ)
|
||
|
{
|
||
|
case 5:
|
||
|
EndZ = 1;
|
||
|
break;
|
||
|
case 6:
|
||
|
EndZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10005)
|
||
|
{
|
||
|
if (EndZ != 0)
|
||
|
{
|
||
|
switch (EndZ)
|
||
|
{
|
||
|
case 6:
|
||
|
EndZ = 1;
|
||
|
break;
|
||
|
case 7:
|
||
|
EndZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else if (DeviceIndex == 10006)
|
||
|
{
|
||
|
if (EndZ != 0)
|
||
|
{
|
||
|
switch (EndZ)
|
||
|
{
|
||
|
case 7:
|
||
|
EndZ = 1;
|
||
|
break;
|
||
|
case 8:
|
||
|
EndZ = 2;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//if (StartZ != 0)
|
||
|
//{
|
||
|
// //�����Ѷ�����2ȡ�� ����Ϊ0 ����Z ����2 �� ������Ϊ0 ����Z ����1
|
||
|
// //�Ѷ�����1 �� 2
|
||
|
// Z = StartZ % a;
|
||
|
// if (Z == 0)
|
||
|
// {
|
||
|
// StartZ = 2;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// StartZ = 1;
|
||
|
// }
|
||
|
//}
|
||
|
//if (EndZ != 0)
|
||
|
//{
|
||
|
// Z = EndZ % a;
|
||
|
// if (Z == 0)
|
||
|
// {
|
||
|
// EndZ = 2;
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// EndZ = 1;
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
//int Pallettype = GetGoodsTypeFromManageTask(TaskIndex);
|
||
|
|
||
|
//sn ��ȡ Dbw1Address ����ʼ��ַ
|
||
|
sn = Convert.ToInt32(devinfo.Dbw1Address);
|
||
|
//�������ֽ��������� B ���ֽ� D��˫�� i ��int R��ʵ�� ����3��4�ֽ�
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2)).Append(",i");
|
||
|
itemvalues[0].Append(TaskIndex.ToString());//������
|
||
|
//��5�ֽ� ȡ��λX����
|
||
|
itemnames[1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 4)).Append(",b");
|
||
|
itemvalues[1].Append((StartX).ToString());
|
||
|
//��6�ֽ� ȡ��λ Y ����
|
||
|
itemnames[2].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 5)).Append(",b");
|
||
|
itemvalues[2].Append(StartY.ToString());
|
||
|
//��7�ֽ� ȡ��λZ ����
|
||
|
itemnames[3].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 6)).Append(",b");
|
||
|
itemvalues[3].Append(StartZ.ToString());
|
||
|
//��8�ֽ� �ͻ�λ X ����
|
||
|
itemnames[4].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 7)).Append(",b");
|
||
|
itemvalues[4].Append((EndX).ToString());
|
||
|
//��9�ֽ� �ͻ�λ Y ����
|
||
|
itemnames[5].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 8)).Append(",b");
|
||
|
itemvalues[5].Append(EndY.ToString());
|
||
|
//��10���ֽ� �ͻ�λ�� Z ����
|
||
|
itemnames[6].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 9)).Append(",b");
|
||
|
itemvalues[6].Append(EndZ.ToString());
|
||
|
//��һ�ֽ� ��д��־λ 0����λ���� �Ѷ�����������Ӧ�� 1-�´�������ʶ 2-��λ������λ���ϱ�����״̬��Ӧ�� 4- ��λ
|
||
|
itemnames[7].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[7].Append("0");
|
||
|
//�ڶ����ֽ� ָ�� 1 �ٻ� 2 3 4 5 6
|
||
|
itemnames[8].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
itemvalues[8].Append("0");//������
|
||
|
|
||
|
//��������
|
||
|
//itemnames[9].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 10)).Append(",b");
|
||
|
//itemvalues[9].Append(Pallettype.ToString());
|
||
|
|
||
|
|
||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
|
||
|
// OPC Server�ij�����ʶ�����磺OPC.SimaticNET
|
||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
||
|
// ����PLC���ӵ�ID�����磺"S7:[S7 connection_1]"
|
||
|
CCommonOPCClient.PlcConnectionID = devinfo.S7Connection;
|
||
|
if (CCommonOPCClient.SyncWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + CCommonOPCClient.OpcError;
|
||
|
return false;
|
||
|
}
|
||
|
//ÿ����DB1д����ʱ������ͷ������ ����֮����д
|
||
|
itemvalues[7].Remove(0, itemvalues[7].Length);
|
||
|
itemvalues[7].Append(MessageIndex.ToString());
|
||
|
itemvalues[8].Remove(0, itemvalues[8].Length);
|
||
|
itemvalues[8].Append(Order.ToString());
|
||
|
//ͬ��д�����е���Ŀֵ
|
||
|
if (CCommonOPCClient.SyncWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + CCommonOPCClient.OpcError;
|
||
|
return false;
|
||
|
}
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("���룺").Append(barcode).Append("**д��־").Append(MessageIndex.ToString()).Append("**������" + Order.ToString()).Append("**������" + TaskIndex.ToString())
|
||
|
.Append("**��ʼ��" + StartZ.ToString()).Append("**��ʼ��" + StartX.ToString()).Append("**��ʼ��" + StartY.ToString())
|
||
|
.Append("**��ֹ��" + EndZ.ToString()).Append("**��ֹ��" + EndX.ToString()).Append("**��ֹ��" + EndY.ToString());
|
||
|
//.Append("**��ֹ��" + EndZ.ToString()).Append("**��ֹ��" + EndX.ToString()).Append("**��ֹ��" + EndY.ToString()).Append("**��������" + Pallettype.ToString());
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "���ͶѶ�������:", DeviceIndex.ToString(), sss.ToString());
|
||
|
//if (WriteBarcode(DeviceIndex, TaskIndex) == false)
|
||
|
//{
|
||
|
// return false;
|
||
|
//}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
if (WriteBarcode(DeviceIndex, TaskIndex) == false)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
}
|
||
|
}
|
||
|
bool IfDeleteRelative(int mti, int fid, int moniTask,int useawayfork)
|
||
|
{
|
||
|
DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
int relfid= Model.CGeneralFunction.GetRelativeControlID(mti, fid);
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT DISTINCT T_Manage_Task.FID FROM T_Manage_Task,T_Monitor_Task where ")
|
||
|
.Append(" T_Manage_Task.F_ManageTaskKindIndex = T_Monitor_Task.F_ManageTASKKINDINDEX ")
|
||
|
.Append(" AND T_Manage_Task.FID = T_Monitor_Task.F_ManageTaskIndex and ")
|
||
|
.Append(" (T_Manage_Task.F_RELATIVECONTORLID = ").Append(relfid).Append(") AND (T_Monitor_Task.F_UseAwayFork = '").Append(useawayfork).Append("') ")
|
||
|
.Append(" AND (T_Monitor_Task.F_ManageTASKKINDINDEX = ").Append(mti).Append(") AND (T_Monitor_Task.F_ManageTaskIndex <> ").Append(fid).Append(")");
|
||
|
|
||
|
dv=dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
dbo.ExecuteSql(string .Format("UPDATE T_Manage_Task SET F_RELATIVECONTORLID = - 1 WHERE (F_ManageTaskKindIndex = {0}) AND (FID = {1})",mti,fid));
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
private void GetLaneGateDeviceZXY(int StackIndex, int laneGate, out string DeviceZXY)
|
||
|
{
|
||
|
|
||
|
DeviceZXY = string.Empty;
|
||
|
sql.Clear();
|
||
|
sql.Append(string.Format("SELECT T_Base_Lane_Gate.F_ZXY FROM T_Base_Lane_Gate,T_Base_LaneInfo where T_Base_Lane_Gate.F_LaneIndex = T_Base_LaneInfo.F_LaneDeviceIndex and T_Base_LaneInfo.F_StackIndex={0} and T_Base_Lane_Gate.F_LaneGateDeviceIndex={1}", StackIndex, laneGate));
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
DeviceZXY = dv[0][0].ToString();
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ʹ������ͻ��豸���� ���ͻ� ������ ���ͻ� ������ ���ͻ� ������ ���ͻ� ������ �ķ�������DB1
|
||
|
/// </summary>
|
||
|
/// <param name="MessageIndex">��Ϣ����</param>
|
||
|
/// <param name="TaskIndex">��������</param>
|
||
|
/// <param name="Order">������</param>
|
||
|
/// �����������֣�
|
||
|
///1-��λ
|
||
|
///2-���ӻ�
|
||
|
///3-���ͻ�
|
||
|
///4-�ҽӻ�
|
||
|
///5-���ͻ�
|
||
|
///6-ֹͣ
|
||
|
///7-�˶����˶�����4��5�ֽ�ָ����Ŀ���豸������
|
||
|
///���ͻ������֣�
|
||
|
///1-���⣨�����⣩
|
||
|
///2-���⣨�����⣩
|
||
|
///3-�ͻ�
|
||
|
///4-�ӻ�
|
||
|
///5-ֹͣ
|
||
|
/// <param name="DeviceIndex">�豸����</param>
|
||
|
///<param name="ArrowDeviceIndex">�������ͻ���������Ŀ���豸������
|
||
|
/// 0-������һ�豸���ƣ���Ŀ���豸������1��65535����Ŀ���豸�������յ����ͻ����豸������</param>
|
||
|
/// <returns>���ʹ������ͻ��豸�����Ƿ��ɹ�</returns>
|
||
|
public bool SendDeviceOrder(int MessageIndex, int TaskIndex, int Order, int DeviceIndex, int ArrowDeviceIndex)
|
||
|
{
|
||
|
|
||
|
StringBuilder[] itemnames;
|
||
|
StringBuilder[] itemvalues;
|
||
|
StringBuilder strTask=new StringBuilder();
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
|
||
|
if (devinfo.XCoor == 0 && devinfo.YCoor == 0 && devinfo.DeviceKind == 4) return false;//20130510
|
||
|
// ˫����2���յ�λ�� add for CATL YB2
|
||
|
int ArrowDeviceIndex2 = 0;
|
||
|
int taskindex1 = 0;
|
||
|
int taskindex2 = 0;
|
||
|
string barcode = GetBarcodeFromMonitorIndex(TaskIndex);
|
||
|
try
|
||
|
{
|
||
|
#region add for CATL YB2 �ж�վ̨�Dz���˫����վ̨ ���������ź��յ�λ��
|
||
|
// add for CATL YB2 ���ӹ��������жϣ��жϵ�ǰ�����Dz��ǹ����������ǹ�������Ҫȡ���������ź������յ�λ��
|
||
|
//��������
|
||
|
int kindIndex = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(TaskIndex);
|
||
|
//������
|
||
|
int manageTaskIndexYB = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(TaskIndex);
|
||
|
//������������
|
||
|
int dcontrolTaskType = GetFCONTROLTASKTYPEFromManageTask(kindIndex, manageTaskIndexYB);
|
||
|
// add for CATL YB2 ��ȡ����������
|
||
|
string doubleRel = "-1";
|
||
|
// �жϹ��������� �������������� ��ȡ���������� || dcontrolTaskType == 4
|
||
|
// 4����֮ǰ�Ѷ������� �� �ֳ����Ա���Ϊ������������ 2 ��������˫���������� || dcontrolTaskType == 4
|
||
|
if (dcontrolTaskType == 2 )
|
||
|
{
|
||
|
doubleRel = GetRativeControlId(TaskIndex);
|
||
|
}
|
||
|
|
||
|
// �ж��Dz��ǹ����������ң��Dz���˫������վ̨
|
||
|
// ��Ҫ������ ����С������ �����յ�λ�� �Ͷ�Ӧ�Ļ���
|
||
|
if (Convert.ToInt32(doubleRel) != -1 && devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
// ���ж�����˫����������������˫����վ̨��ʱ�� ���������ź�Ŀ���豸վ̨��
|
||
|
// ȡ�������������õ� ���������Ĵ������źͻ�����
|
||
|
int[] taskFork = Model.CGeneralFunction.DoubleMinMonitorIndex(Convert.ToInt32(doubleRel));
|
||
|
// ��������˫���� ��Ҫ��ȡ�����յ�λ��
|
||
|
// ȡ������ �յ�λ�� 1���ĸ�ֵ�� ArrowDeviceIndex��2�渳ֵ��ArrowDeviceIndex2 2���ȷ�
|
||
|
// ȡ�� ���������� ��Ӧ�� �յ�λ�� С������ ������ ������ ����ֵ ���� null
|
||
|
int[] station1 = GetDouArrowDeviceIndex(taskFork[0], taskFork[1]);
|
||
|
int[] station2 = GetDouArrowDeviceIndex(taskFork[2], taskFork[3]);
|
||
|
#region վ̨1 ��Ӧ��һ��������
|
||
|
if (station1 != null)
|
||
|
{
|
||
|
if (station1[2] == 2)
|
||
|
{
|
||
|
// �յ�2��վ̨
|
||
|
ArrowDeviceIndex2 = station1[0];
|
||
|
taskindex2 = station1[1];
|
||
|
}
|
||
|
else //if (station1[2] == 1)
|
||
|
{
|
||
|
ArrowDeviceIndex = station1[0];
|
||
|
taskindex1 = station1[1];
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
#region վ̨2 ��Ӧ�ڶ���������
|
||
|
if (station2 != null)
|
||
|
{
|
||
|
if (station2[2] == 2)
|
||
|
{
|
||
|
// �յ�2��վ̨
|
||
|
ArrowDeviceIndex2 = station2[0];
|
||
|
taskindex2 = station2[1];
|
||
|
}
|
||
|
else //if (station1[2] == 1)
|
||
|
{
|
||
|
ArrowDeviceIndex = station2[0];
|
||
|
taskindex1 = station2[1];
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
// ���ǹ������� ������˫����վ̨
|
||
|
else if (Convert.ToInt32(doubleRel) == -1 && devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
// �������ǹ������� ������˫������վ̨��Ҳ��Ҫ�ж����ĸ������Ͷ�Ӧλ�õ�������
|
||
|
// ���ĸ����� �ͷ�����Ӧ������DB��
|
||
|
// ��ȡ��ǰ������Ӧ�����Ļ��� Ϊ�ĸ���
|
||
|
int useAwayForksin = Model.CGeneralFunction.GetUseAwayForkFromManagetask(manageTaskIndexYB);
|
||
|
// ���ݵ�ǰ�����ŷ��� ������ֵ���յ�վֵ̨
|
||
|
if (useAwayForksin == 1)
|
||
|
{
|
||
|
ArrowDeviceIndex = Convert.ToInt32(ArrowDeviceIndex.ToString().Substring(0, 5));
|
||
|
taskindex1 = TaskIndex;
|
||
|
}
|
||
|
else if (useAwayForksin == 2)
|
||
|
{
|
||
|
ArrowDeviceIndex2 = Convert.ToInt32(ArrowDeviceIndex.ToString().Substring(0, 5));
|
||
|
taskindex2 = TaskIndex;
|
||
|
// ������2�淢��ʱ�� һ��Ŀ����ַΪ 0 add for CATL YB2
|
||
|
ArrowDeviceIndex = 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// ������������Ӧ�ò�������
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�յ�����";
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else // �������ͻ�
|
||
|
{
|
||
|
// ����˫���� ������ȡ�յ�λ�� ���͵�DB��Ҳ����˫������ Ϊ������
|
||
|
if (ArrowDeviceIndex.ToString().Length > 5)
|
||
|
{
|
||
|
ArrowDeviceIndex = Convert.ToInt32(ArrowDeviceIndex.ToString().Substring(0, 5));
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
int[] sendmes = new int[5] { MessageIndex, TaskIndex, Order, DeviceIndex, ArrowDeviceIndex };
|
||
|
devinfo.SendMessage = sendmes;
|
||
|
Model.CGetInfo.SetDeviceMessage(devinfo);
|
||
|
int sn = 0;
|
||
|
string JPINFO = "";
|
||
|
if (devinfo == null)
|
||
|
{
|
||
|
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�����������豸����������!";
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//if (devinfo.DeviceKind == 7)
|
||
|
//{
|
||
|
// return true;
|
||
|
//}
|
||
|
if (devinfo.DeviceKind == 1)
|
||
|
{//�Ѷ���������ʹ�ô˷���
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�������Ѷ���������ʹ�ô˷���!";
|
||
|
return false;
|
||
|
}
|
||
|
sn = Convert.ToInt32(devinfo.Dbw1Address);
|
||
|
strTask.Append(TaskIndex.ToString());
|
||
|
if (devinfo.DeviceKind == 31)
|
||
|
{
|
||
|
#region �߶�����
|
||
|
int reSendFlag = 0, HMISendDb1Address = 0;
|
||
|
GetHMISendInfo(out reSendFlag, out HMISendDb1Address, TaskIndex);//�������������·���20120220
|
||
|
int inworkbench = IfInworkBench(TaskIndex);
|
||
|
if (MessageIndex == 2)
|
||
|
{
|
||
|
barcode = "000000";
|
||
|
inworkbench = 0;
|
||
|
}
|
||
|
byte[] barbyte = new byte[6];
|
||
|
if (barcode.Length == 6)
|
||
|
{
|
||
|
barbyte = ASCIIEncoding.ASCII.GetBytes(barcode);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�������߶˹�λ���ͻ����벻�Ϸ�!";
|
||
|
return false;
|
||
|
}
|
||
|
if (reSendFlag == 2)//�������������·���20120220devinfo.UseCommonDB == "1"
|
||
|
{
|
||
|
sn = HMISendDb1Address;
|
||
|
itemnames = new StringBuilder[10]
|
||
|
{ new StringBuilder(""), new StringBuilder(""), new StringBuilder(""),
|
||
|
new StringBuilder(""), new StringBuilder(""), new StringBuilder(""),
|
||
|
new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
itemvalues = new StringBuilder[10]
|
||
|
{ new StringBuilder(""), new StringBuilder(""), new StringBuilder(""),
|
||
|
new StringBuilder(""), new StringBuilder(""), new StringBuilder(""),
|
||
|
new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[0].Append("0");
|
||
|
|
||
|
for (int i = 1; i <= 6; i++)
|
||
|
{
|
||
|
|
||
|
itemnames[i].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + i)).Append(",b");
|
||
|
itemvalues[i].Append(barbyte[i - 1]);
|
||
|
}
|
||
|
|
||
|
itemnames[7].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 7)).Append(",b");
|
||
|
|
||
|
itemvalues[7].Append(inworkbench);
|
||
|
itemnames[8].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 8)).Append(",i");
|
||
|
//20120207
|
||
|
StringBuilder a1 = new StringBuilder(devinfo.DeviceIndex.ToString().Substring(0, 1));
|
||
|
if (devinfo.DeviceIndex > 0)
|
||
|
{//�������ڵĵ�ǰ�豸����
|
||
|
StringBuilder a2 = new StringBuilder(devinfo.DeviceIndex.ToString().Substring(2));
|
||
|
a1.Append(a2);
|
||
|
}
|
||
|
itemvalues[8].Append(a1.ToString());//�������ڵĵ�ǰ�豸����
|
||
|
itemnames[9].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 10)).Append(",i");
|
||
|
itemvalues[9].Append(ArrowDeviceIndex.ToString());
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
itemnames = new StringBuilder[9]
|
||
|
{ new StringBuilder(""), new StringBuilder(""), new StringBuilder(""),
|
||
|
new StringBuilder(""), new StringBuilder(""), new StringBuilder(""),
|
||
|
new StringBuilder(""), new StringBuilder(""), new StringBuilder("")}; ;
|
||
|
itemvalues = new StringBuilder[9]
|
||
|
{ new StringBuilder(""), new StringBuilder(""), new StringBuilder(""),
|
||
|
new StringBuilder(""), new StringBuilder(""), new StringBuilder(""),
|
||
|
new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[0].Append("0");
|
||
|
|
||
|
for (int i = 1; i <= 6; i++)
|
||
|
{
|
||
|
|
||
|
itemnames[i].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + i)).Append(",b");
|
||
|
itemvalues[i].Append(barbyte[i - 1]);
|
||
|
}
|
||
|
|
||
|
itemnames[7].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 7)).Append(",b");
|
||
|
itemvalues[7].Append(inworkbench);
|
||
|
itemnames[8].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 8)).Append(",i");
|
||
|
itemvalues[8].Append(ArrowDeviceIndex.ToString());
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
else if (devinfo.DeviceKind == 40)
|
||
|
{
|
||
|
//��ȫ��ͣ ���������� ����ͣ��
|
||
|
itemnames = new StringBuilder[1] { new StringBuilder("") };
|
||
|
itemvalues = new StringBuilder[1] { new StringBuilder("") };
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[0].Append(Order.ToString());
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("��λ�����ͽ���ͣ����").Append(DeviceIndex).Append("***ָ��").Append(Order.ToString());
|
||
|
}
|
||
|
else if (devinfo.DeviceKind == 7)
|
||
|
{
|
||
|
itemnames = new StringBuilder[1] { new StringBuilder("") };
|
||
|
itemvalues = new StringBuilder[1] { new StringBuilder("") };
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBGet).Append(".").Append(Convert.ToString(devinfo.Dbw2Address + 0)).Append(",b");
|
||
|
itemvalues[0].Append("2");
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("�ֶ�����ɨ����Ӧ��").Append(DeviceIndex).Append("***ָ��").Append("2");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region �������ͻ�
|
||
|
#region devinfo.UseCommonDB == "1"
|
||
|
if (devinfo.UseCommonDB == "1")
|
||
|
{
|
||
|
|
||
|
itemnames = new StringBuilder[5] { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
itemvalues = new StringBuilder[5] { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
//��1�ֽڣ���д��־λ
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[0].Append("0");//���ͻ�ͷ
|
||
|
//��2�ֽ� ������
|
||
|
itemnames[1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
itemvalues[1].Append(Order.ToString());//����
|
||
|
//��3��4�ֽ�������
|
||
|
itemnames[2].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2)).Append(",i");
|
||
|
itemvalues[2].Append(TaskIndex.ToString());//������
|
||
|
//��5��6��7��8 �ֽڱ�ʾĿ���豸����
|
||
|
itemnames[3].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 4)).Append(",i");
|
||
|
itemvalues[3].Append(DeviceIndex.ToString());//��ʼ�豸���ţ���ǰ�豸���ţ�
|
||
|
//Ŀ���յ��豸
|
||
|
itemnames[4].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 6)).Append(",i");
|
||
|
itemvalues[4].Append(ArrowDeviceIndex.ToString());
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("���룺").Append(barcode).Append("**д��־").Append(MessageIndex.ToString()).Append("**������" + Order.ToString()).Append("**������" + strTask.ToString())
|
||
|
.Append("**Ŀ��λ��" + ArrowDeviceIndex.ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
else
|
||
|
{
|
||
|
#region ˫��������վ̨���Է�������
|
||
|
// T_Base_Device ��F_IFCORRELDOUBLEFORK �ֶ�Ϊ1 ��������˫����վ̨����
|
||
|
if (devinfo.IfCorrelDoubleFork == "1")
|
||
|
{
|
||
|
#region ��������վ̨����
|
||
|
#region ע��
|
||
|
// int TaskIndexDB23 = 0; int TaskIndexDB45 = 0;
|
||
|
//// int reltaskindex = Model.CGeneralFunction.GetDoubleLiftInfo(TaskIndex, DeviceIndex);
|
||
|
|
||
|
// strTask.Clear();
|
||
|
// int devicestrcount = DeviceIndex.ToString().Length;
|
||
|
// string row = DeviceIndex.ToString().Substring(devicestrcount - 1, 1);
|
||
|
// if (row == "1")//һ�н���
|
||
|
// {
|
||
|
// TaskIndexDB23 = TaskIndex;
|
||
|
// // TaskIndexDB45 = reltaskindex;
|
||
|
// }
|
||
|
// else
|
||
|
// if (row == "2")//2��Զ��
|
||
|
// {
|
||
|
// // TaskIndexDB23 = reltaskindex;//1�����뿪
|
||
|
// TaskIndexDB45 = TaskIndex; //2�к��뿪���ͻ�
|
||
|
// }
|
||
|
|
||
|
// strTask.Append("1��������:" + TaskIndexDB23.ToString()).Append("һ�����룺").Append(GetBarcodeFromMonitorIndex(TaskIndexDB23));
|
||
|
// strTask.Append(";2��������:" + TaskIndexDB45.ToString()).Append("�������룺").Append(GetBarcodeFromMonitorIndex(TaskIndexDB45));
|
||
|
#endregion
|
||
|
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
|
||
|
sn = Convert.ToInt32(devinfo.Dbw1Address);
|
||
|
|
||
|
//itemnames = new StringBuilder[6] { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
//itemvalues = new StringBuilder[6] { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
//itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
//itemvalues[0].Append("0");
|
||
|
//itemnames[1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
//itemvalues[1].Append(Order.ToString());
|
||
|
|
||
|
#region �г��ķ� ע��
|
||
|
//int taskindex1 = 0;
|
||
|
//int taskindex2 = 0;
|
||
|
//int[] mutitasks = Model.CGeneralFunction.MutiForkIfSync(TaskIndex, DeviceIndex, devinfo.DeviceKind);
|
||
|
//if (mutitasks != null)
|
||
|
//{
|
||
|
// foreach (int temptask in mutitasks)
|
||
|
// {
|
||
|
// int UseAwayFork = Convert.ToInt32(Model.CGeneralFunction.GetUseAwayFork(temptask));
|
||
|
// if (UseAwayFork == 0)
|
||
|
// {
|
||
|
// taskindex2 = temptask;
|
||
|
// }
|
||
|
// else if (UseAwayFork == 1)
|
||
|
// {
|
||
|
// taskindex2 = temptask;
|
||
|
// }
|
||
|
// else if (UseAwayFork == 2)
|
||
|
// {
|
||
|
// taskindex1 = temptask;
|
||
|
// }
|
||
|
// }
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// taskindex2 = TaskIndex;
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
// add for CATL YB2 ����ʵ���˲�ͬ�յ�����˫���������������´��������յ� д�����յ� ˫����վ̨��14�� �ֽ�
|
||
|
// �˴�����Ҫ��������˫�����ϵ�������һ����ǰ���ⲻͨ�� ��һ��Ҳ���ܷ���
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(DeviceIndex.ToString().Substring(0, 5)));
|
||
|
sn = Convert.ToInt32(devinfo.Dbw1Address);
|
||
|
//����һ��new StringBuilder("") YB2
|
||
|
itemnames = new StringBuilder[6] { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
itemvalues = new StringBuilder[6] { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") }; ;
|
||
|
|
||
|
// MessageIndex
|
||
|
//��1�ֽڣ� ������
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
itemvalues[0].Append(Order.ToString());
|
||
|
//��2��3�ֽڣ� ������1 ��Ӧ�Ѷ�������1λ�������ţ�Զ�棩
|
||
|
itemnames[1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2)).Append(",i");
|
||
|
itemvalues[1].Append(taskindex1);
|
||
|
//��4��5�ֽ�; ������2 ��Ӧ�Ѷ�������2λ�������ţ����棩
|
||
|
itemnames[2].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 4)).Append(",i");
|
||
|
itemvalues[2].Append(taskindex2);
|
||
|
//��6��7��8��9�ֽ� ��ʾĿ���豸����1 ��Ӧһ�� YB2
|
||
|
itemnames[3].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 6)).Append(",dw");
|
||
|
itemvalues[3].Append(ArrowDeviceIndex.ToString());
|
||
|
//��10��11��12��13�ֽ� ��ʾĿ���豸����2 ��Ӧ���� YB2
|
||
|
itemnames[4].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 10)).Append(",dw");
|
||
|
itemvalues[4].Append(ArrowDeviceIndex2.ToString());
|
||
|
//��0�ֽڣ� ��д��־λ
|
||
|
itemnames[5].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[5].Append(MessageIndex);
|
||
|
|
||
|
// add for CATL YB2
|
||
|
//���������ŵ�����¼
|
||
|
JPINFO = ",һ��(����)������:" + taskindex1.ToString() + ",����(Զ��)������:" + taskindex2.ToString();
|
||
|
//һ������������
|
||
|
string firstBarcode = GetBarcodeFromMonitorIndex(taskindex1);
|
||
|
//������������
|
||
|
string secondBarcode = GetBarcodeFromMonitorIndex(taskindex2);
|
||
|
string doubleBarcodeInfo = "";
|
||
|
doubleBarcodeInfo = ",һ��(����)����:" + firstBarcode.ToString() + ",����(Զ��)����:" + secondBarcode.ToString();
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("���룺").Append(barcode).Append("**д��־").Append(MessageIndex.ToString()).Append("**������" + Order.ToString()).Append("**������" + strTask.ToString())
|
||
|
.Append("**Ŀ��λ��1:" + ArrowDeviceIndex.ToString()).Append("**Ŀ��λ��2:" + ArrowDeviceIndex2.ToString()).Append("**������¼˫������������Զ��������" + JPINFO).Append("**����������˫�����ţ�" + doubleBarcodeInfo);
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
else
|
||
|
if (devinfo.DeviceKind == 17)
|
||
|
{
|
||
|
//�ڷ��Ͳ���ָ��ǰ���жϹ��������Ƿ�Ҫ�������������������Ͳ���ָ��
|
||
|
int mti = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(TaskIndex);
|
||
|
if (mti == 1)
|
||
|
{
|
||
|
int fid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(TaskIndex);
|
||
|
int flag = Model.CGeneralFunction.GetBackFlagFromIOControl(fid);
|
||
|
if (1 == flag)//����
|
||
|
{
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�������ȴ�����", devinfo.DeviceIndex.ToString(), fid.ToString());
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//��������ֵ
|
||
|
#region ����������
|
||
|
string goodsbarcode = GetGoodsBarcodeFromManageTask(TaskIndex);
|
||
|
goodsbarcode = goodsbarcode.TrimStart(';').TrimEnd(';').Trim();
|
||
|
int count = goodsbarcode.Length;//�ַ���
|
||
|
|
||
|
|
||
|
char[] cc = new char[1] { ';' };
|
||
|
string[] code = goodsbarcode.Split(cc);
|
||
|
int goodscount = code.Length;//������
|
||
|
|
||
|
int length = devinfo.Dbw1SendLength - 1;//д����������//TaskIndex���֣��˴���һ
|
||
|
|
||
|
itemnames = new StringBuilder[length];//length������д���������ֽڵĸ��������������еĸ���
|
||
|
itemvalues = new StringBuilder[length];//TaskIndex���֣��˴���һ
|
||
|
byte[] barbyte = new byte[count];
|
||
|
barbyte = ASCIIEncoding.ASCII.GetBytes(goodsbarcode);
|
||
|
|
||
|
itemnames[0] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[0] = new StringBuilder("0");
|
||
|
itemnames[1] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
itemvalues[1] = new StringBuilder(Order.ToString());
|
||
|
itemnames[2] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2)).Append(",i");
|
||
|
itemvalues[2] = new StringBuilder(TaskIndex.ToString());
|
||
|
itemnames[3] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 4)).Append(",b");
|
||
|
itemvalues[3] = new StringBuilder(ArrowDeviceIndex.ToString());//��������ͬ������
|
||
|
|
||
|
itemnames[4] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 5)).Append(",b");
|
||
|
itemvalues[4] = new StringBuilder(goodscount.ToString());//������Ͳ��������
|
||
|
|
||
|
//�ֺŵ�ascII����59
|
||
|
for (int i = 0, j = 5; j < length; i++) //��������
|
||
|
{
|
||
|
if (i < count)
|
||
|
{
|
||
|
if (barbyte[i] != 59)//�ֺŲ�����
|
||
|
{
|
||
|
|
||
|
itemnames[j] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1 + j)).Append(",b");
|
||
|
itemvalues[j] = new StringBuilder(barbyte[i].ToString());
|
||
|
j++;
|
||
|
}
|
||
|
}
|
||
|
else//����λ���Զ�����0
|
||
|
{
|
||
|
itemnames[j] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1 + j)).Append(",b");
|
||
|
itemvalues[j] = new StringBuilder("0");
|
||
|
j++;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("���룺").Append(barcode).Append("**д��־").Append(MessageIndex.ToString()).Append("**������" + Order.ToString()).Append("**������" + strTask.ToString())
|
||
|
.Append("**����" + ArrowDeviceIndex.ToString()).Append("**����" + goodscount.ToString()).Append("**��������" + goodsbarcode.ToString());
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{//��ͨ���ͻ�
|
||
|
|
||
|
|
||
|
if (devinfo.Dbw1SendLength >= 21)//��ͬ���������ͻ� 11000,11001,11025,13001
|
||
|
{
|
||
|
#region ��ͬ���������ͻ�
|
||
|
int length = devinfo.Dbw1SendLength - 2;//д����������//TaskIndex��ArrowDeviceIndex���֣��˴�����
|
||
|
int type = GetGoodsTypeFromManageTask(TaskIndex);
|
||
|
|
||
|
itemnames = new StringBuilder[length];//TaskIndex��ArrowDeviceIndex���֣��˴�����
|
||
|
itemvalues = new StringBuilder[length];//
|
||
|
int count = barcode.Length;//������ͬ�������������ַ���
|
||
|
byte[] barbyte = new byte[count];
|
||
|
barbyte = ASCIIEncoding.ASCII.GetBytes(barcode.Trim());
|
||
|
|
||
|
itemnames[0] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[0] = new StringBuilder("0");
|
||
|
itemnames[1] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
itemvalues[1] = new StringBuilder(Order.ToString());
|
||
|
itemnames[2] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2)).Append(",i");
|
||
|
itemvalues[2] = new StringBuilder(TaskIndex.ToString());
|
||
|
itemnames[3] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 4)).Append(",i");
|
||
|
itemvalues[3] = new StringBuilder(ArrowDeviceIndex.ToString());
|
||
|
itemnames[4] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 6)).Append(",b");
|
||
|
itemvalues[4] = new StringBuilder(type.ToString());//������Ͳ��������
|
||
|
|
||
|
//�ֺŵ�ascII����59
|
||
|
for (int i = 0, j = 5; j < length; i++) //��������
|
||
|
{
|
||
|
if (i < count)
|
||
|
{
|
||
|
|
||
|
|
||
|
itemnames[j] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2 + j)).Append(",b");
|
||
|
itemvalues[j] = new StringBuilder(barbyte[i].ToString());
|
||
|
j++;
|
||
|
}
|
||
|
else//����λ���Զ�����0
|
||
|
{
|
||
|
itemnames[j] = new StringBuilder(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2 + j)).Append(",b");
|
||
|
itemvalues[j] = new StringBuilder("0");
|
||
|
j++;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("���룺").Append(barcode).Append("**д��־").Append(MessageIndex.ToString()).Append("**������" + Order.ToString()).Append("**������" + strTask.ToString())
|
||
|
.Append("**Ŀ��λ��" + ArrowDeviceIndex.ToString()).Append("**����" + type.ToString()).Append("**��������" + barcode.ToString());
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region ��ͨ���ͻ� ����Э�� ˫�� ˫�� kkkkkkkkk
|
||
|
//int Pallettype = GetGoodsTypeFromManageTask(TaskIndex);
|
||
|
//plc ��i �� int ������ di ��Dint ˫���� r �� REAL ������
|
||
|
itemnames = new StringBuilder[4] { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") };
|
||
|
itemvalues = new StringBuilder[4] { new StringBuilder(""), new StringBuilder(""), new StringBuilder(""), new StringBuilder("") };
|
||
|
|
||
|
// ��2�ֽ� ������
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 1)).Append(",b");
|
||
|
itemvalues[0].Append(Order.ToString());
|
||
|
//��3��4�ֽ� ������
|
||
|
itemnames[1].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 2)).Append(",i");
|
||
|
itemvalues[1].Append(TaskIndex.ToString());
|
||
|
//��Э�� Ŀ��λ����4���ֽڣ� ��4��5��6��7�ֽ� ˫��
|
||
|
itemnames[2].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 4)).Append(",dw");
|
||
|
//itemnames[3].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 4)).Append(",i");
|
||
|
itemvalues[2].Append(ArrowDeviceIndex.ToString());
|
||
|
//itemnames[4].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 8)).Append(",b");
|
||
|
//itemvalues[4].Append(Pallettype.ToString());
|
||
|
//��1�ֽ� ͷ
|
||
|
itemnames[3].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[3].Append(MessageIndex);
|
||
|
|
||
|
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("���ͻ���������**���룺").Append(barcode).Append("**д��־").Append(MessageIndex.ToString()).Append("**������" + Order.ToString()).Append("**������" + strTask.ToString())
|
||
|
.Append("**Ŀ��λ��" + ArrowDeviceIndex.ToString());
|
||
|
//.Append("**Ŀ��λ��" + ArrowDeviceIndex.ToString()).Append("**��������" + Pallettype.ToString()); ;
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|
||
|
|
||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
|
||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
||
|
CCommonOPCClient.PlcConnectionID = devinfo.S7Connection;//20110216
|
||
|
// .SyncWriteAllItemValue(itemnames, itemvalues) == false add for CATL YB2 ��Ϊ�첽����
|
||
|
if (CCommonOPCClient.AWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + CCommonOPCClient.OpcError;
|
||
|
return false;
|
||
|
}
|
||
|
//itemnames[0].Remove(0, itemnames[0].Length);
|
||
|
//itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
//itemvalues[0].Remove(0, itemvalues[0].Length);
|
||
|
//itemvalues[0].Append(MessageIndex);
|
||
|
//if (CCommonOPCClient.AWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
//{
|
||
|
// _commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + CCommonOPCClient.OpcError;
|
||
|
// return false;
|
||
|
//}
|
||
|
|
||
|
//sss.Remove(0, sss.Length);
|
||
|
//sss.Append("���룺").Append(barcode).Append("**д��־").Append(MessageIndex.ToString()).Append("**������" + Order.ToString()).Append("**������" + strTask.ToString())
|
||
|
// .Append("**Ŀ��λ��" + ArrowDeviceIndex.ToString());
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "����ָ��", devinfo.DeviceIndex.ToString(), sss.ToString());
|
||
|
//if (MessageIndex == 1)
|
||
|
//{
|
||
|
// if (WriteBarcode(DeviceIndex, TaskIndex) == false)
|
||
|
// {
|
||
|
// return false;
|
||
|
// }
|
||
|
//}
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
itemnames = null;
|
||
|
itemvalues = null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// //2220173-ʱ������ ���ӻ������ù���
|
||
|
/// ��Ҫ�Ľӿ�ISendDeviceOrder ͬʱ�ڸ���ʵ�������������������� ֱ��return true
|
||
|
/// </summary>
|
||
|
/// <param name="fork"></param>
|
||
|
/// <param name="DeviceIndex"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool SendDeviceOrder(int fork, int DeviceIndex)
|
||
|
{
|
||
|
StringBuilder[] itemnames;
|
||
|
StringBuilder[] itemvalues;
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
|
||
|
//return true;//ceshi
|
||
|
int[] sendmes = new int[2] { fork, DeviceIndex };
|
||
|
devinfo.SendMessage = sendmes;
|
||
|
Model.CGetInfo.SetDeviceMessage(devinfo);
|
||
|
int sn = 0;
|
||
|
if (devinfo == null)
|
||
|
{
|
||
|
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�����������豸����������!";
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (devinfo.DeviceKind != 1)
|
||
|
{//�Ѷ���������ʹ�ô˷���
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������ֻ�жѶ������û���ʹ�ô˷���!";
|
||
|
return false;
|
||
|
}
|
||
|
//if (fork == 1 || fork == 2)
|
||
|
//{
|
||
|
// fork = 1;//���ý��� �������ߵ�����������
|
||
|
//}
|
||
|
//else
|
||
|
//{
|
||
|
// fork = 0;//��������
|
||
|
//}
|
||
|
sn = Convert.ToInt32(devinfo.Dbw1Address);
|
||
|
itemnames = new StringBuilder[1] { new StringBuilder("") };
|
||
|
itemvalues = new StringBuilder[1] { new StringBuilder("") };
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 18)).Append(",b");
|
||
|
itemvalues[0].Append(fork.ToString());//��ʱ������ֻ��1 ��Ϊ���� ������������
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("��λ�����öѶ������棺").Append(DeviceIndex).Append("***����").Append(fork.ToString());
|
||
|
|
||
|
}
|
||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");
|
||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
||
|
CCommonOPCClient.PlcConnectionID = devinfo.S7Connection;
|
||
|
if (CCommonOPCClient.AWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + CCommonOPCClient.OpcError;
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "����ָ��", devinfo.DeviceIndex.ToString(), sss.ToString());
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
itemnames = null;
|
||
|
itemvalues = null;
|
||
|
}
|
||
|
}
|
||
|
private void GetHMISendInfo(out int reSendFlag, out int HMISendDb1Address, int taskindex)
|
||
|
{//20120220
|
||
|
reSendFlag = 0;
|
||
|
HMISendDb1Address = 0;
|
||
|
try
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL(string.Format("SELECT F_NumParam2, F_SendFlag FROM T_Monitor_Task where F_MonitorIndex={0}", taskindex)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
reSendFlag = Convert.ToInt32(dv[0]["F_SendFlag"]);
|
||
|
HMISendDb1Address = Convert.ToInt32(dv[0]["F_NumParam2"]);//������F_DBW1Address
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.GetHMISendInfo����������" + ex.Message;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��λ������λ���������䰴Ʒ�����ֵ���Ϣ��15�ֽ�,������ʱд��ʵ�����ݣ�����ȫ��д��
|
||
|
/// </summary>
|
||
|
/// <param name="DeviceIndex">����λ�豸������</param>
|
||
|
/// <param name="TobaccoCode">��3--15�ֽ�,������</param>
|
||
|
/// <param name="HaveFirstProjectCode">��1�ֽ�,1-��һ�Ź�����,0-��һ�Ź�����</param>
|
||
|
/// <param name="IfSmallTobacco">��2�ֽ�,1-��������,0-��������</param>
|
||
|
/// <returns>�������䰴Ʒ�����ֵ���Ϣ�Ƿ��ɹ�</returns>
|
||
|
public bool SendDeviceOrder(int DeviceIndex, string TobaccoCode, bool HaveFirstProjectCode, bool IfSmallTobacco, int Count)
|
||
|
{
|
||
|
StringBuilder[] itemnames = new StringBuilder[16];
|
||
|
StringBuilder[] itemvalues = new StringBuilder[16];
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
|
||
|
try
|
||
|
{
|
||
|
|
||
|
int sn = 0;
|
||
|
|
||
|
if (devinfo == null)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder�����������豸����������!";
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sn = Convert.ToInt32(devinfo.Dbw1Address);
|
||
|
|
||
|
itemnames[0].Append(Model.CGeneralFunction.DBSend).Append(".").Append((sn + 0).ToString()).Append(",b");
|
||
|
if (HaveFirstProjectCode == true)
|
||
|
{
|
||
|
itemvalues[0].Append("1");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
itemvalues[0].Append("0");
|
||
|
}
|
||
|
itemnames[1].Append(Model.CGeneralFunction.DBSend).Append(".").Append((sn + 1).ToString()).Append(",b");
|
||
|
if (IfSmallTobacco == true)
|
||
|
{
|
||
|
itemvalues[1].Append("1");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
itemvalues[1].Append("0");
|
||
|
}
|
||
|
for (int i = 2; i <= 14; i++)
|
||
|
{
|
||
|
itemnames[i].Append(Model.CGeneralFunction.DBSend).Append(".").Append((sn + i).ToString()).Append(",b");
|
||
|
itemvalues[i].Append(Strings.Asc(TobaccoCode.Substring(i - 2, 1)).ToString());
|
||
|
}
|
||
|
itemnames[15].Append(Model.CGeneralFunction.DBSend).Append(".").Append((sn + 15).ToString()).Append(",b");
|
||
|
itemvalues[15].Append(Count.ToString());
|
||
|
|
||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
|
||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
||
|
CCommonOPCClient.PlcConnectionID = devinfo.S7Connection;//20110216
|
||
|
if (CCommonOPCClient.SyncWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
itemnames = null;
|
||
|
itemvalues = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public bool WriteBarcode(int deviceindex, int taskindex)
|
||
|
{
|
||
|
Model.MDevice devinfo;
|
||
|
StringBuilder[] itemnames = new StringBuilder[11];
|
||
|
StringBuilder[] itemvalues = new StringBuilder[11];
|
||
|
|
||
|
int sn = 0;
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(deviceindex);
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("SELECT F_MonitorIndex, F_TxtParam FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(taskindex).Append(")");
|
||
|
DataView dvb = dbo.ExceSQL(sss.ToString()).Tables[0].DefaultView;
|
||
|
if (dvb.Count > 0)
|
||
|
{
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append(dvb[0]["F_TxtParam"].ToString());
|
||
|
|
||
|
if ((sss.ToString() == "-") || (sss.ToString() == "")) return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������д�븽������ʱ�ڵ�����������û�ҵ�����!";
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (devinfo.AppendBarcode > 0)
|
||
|
{
|
||
|
Model.MDevice devinfo1 = Model.CGetInfo.GetDeviceInfo(devinfo.AppendBarcode);
|
||
|
if (devinfo1.DeviceIndex == 0)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.SendDeviceOrder����������д�븽������ʱ�豸����������!";
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
//byte0,byte1,byte2,byte3,byte4
|
||
|
// int1 int3
|
||
|
//int0(byte0,byte1);int1(byte1,byte2);int2(byte2,byte3);int3(byte3,byte4)
|
||
|
sn = Convert.ToInt32(devinfo1.Dbw1Address);
|
||
|
devinfo1 = null;
|
||
|
for (int i = 0; i <= 9; i++)
|
||
|
{
|
||
|
itemnames[i].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + i + 1)).Append(",b");
|
||
|
itemvalues[i].Append(Strings.Asc(sss.ToString().Substring((i), 1)).ToString());
|
||
|
}
|
||
|
itemnames[10].Append(Model.CGeneralFunction.DBSend).Append(".").Append(Convert.ToString(sn + 0)).Append(",b");
|
||
|
itemvalues[10].Append("1");
|
||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
|
||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
||
|
CCommonOPCClient.PlcConnectionID = devinfo.S7Connection;//20110216
|
||
|
if (CCommonOPCClient.SyncWriteAllItemValue(itemnames, itemvalues) == false)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "SendDeviceOrder", deviceindex.ToString(), sss.ToString());
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return true; ;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.WriteBarcode����������" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
devinfo = null;
|
||
|
itemnames = null;
|
||
|
itemvalues = null;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��PLC��DB�������
|
||
|
/// </summary>
|
||
|
/// <param name="ItemNames">��ǩ������������</param>
|
||
|
/// <param name="ItemValues">��ǩֵ����</param>
|
||
|
/// <returns></returns>
|
||
|
public bool WriteDBData(StringBuilder[] ItemNames, StringBuilder[] ItemValues)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (CCommonOPCClient.SyncWriteAllItemValue(ItemNames, ItemValues) == false)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("**" + ItemNames[0].ToString() + "**" + ItemValues[0].ToString());
|
||
|
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "����Ӧ����־", "----", sss.ToString());
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.WriteDBData����������" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
ItemNames = null;
|
||
|
ItemValues = null;
|
||
|
}
|
||
|
}
|
||
|
public bool WriteDBData(StringBuilder[] ItemNames, StringBuilder[] ItemValues, string PLCconnectionID)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
|
||
|
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
|
||
|
CCommonOPCClient.PlcConnectionID = PLCconnectionID;
|
||
|
// SyncWriteAllItemValue
|
||
|
if (CCommonOPCClient.AWriteAllItemValue(ItemNames, ItemValues) == false)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sss.Remove(0, sss.Length);
|
||
|
for (int i = 0; i < ItemNames.Length; i++)
|
||
|
{
|
||
|
sss.Append("**" + ItemNames[i].ToString() + "**" + ItemValues[i].ToString());
|
||
|
}
|
||
|
CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "����Ӧ����־", "----", sss.ToString());
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.WriteDBData����������" + ex.Message;
|
||
|
return false;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
ItemNames = null;
|
||
|
ItemValues = null;
|
||
|
}
|
||
|
}
|
||
|
string GetBarcodeFromMonitorIndex(int taskindex)
|
||
|
{
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("SELECT F_TxtParam FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(taskindex).Append(")");
|
||
|
DataView dvb = dbo.ExceSQL(sss.ToString()).Tables[0].DefaultView;
|
||
|
if (dvb.Count > 0)
|
||
|
{
|
||
|
return dvb[0]["F_TxtParam"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "-";
|
||
|
}
|
||
|
}
|
||
|
// add for CATL YB2 ��ȡ��������ID
|
||
|
string GetRativeControlId(int taskindex)
|
||
|
{
|
||
|
int fid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(taskindex);
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("SELECT F_RELATIVECONTORLID FROM T_MANAGE_TASK WHERE (FID = ").Append(fid).Append(")");
|
||
|
DataView dvb = dbo.ExceSQL(sss.ToString()).Tables[0].DefaultView;
|
||
|
if (dvb.Count > 0)
|
||
|
{
|
||
|
return dvb[0]["F_RELATIVECONTORLID"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "-1";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
// ArrowDeviceIndex
|
||
|
// add for CATL YB2 ��ȡ�����������յ�λ��
|
||
|
int[] GetDouArrowDeviceIndex(int Fid, int useAwayFork)
|
||
|
{
|
||
|
DataView dvb = new DataView();
|
||
|
int[] rr = new int[3];
|
||
|
try
|
||
|
{
|
||
|
sss.Remove(0, sss.Length);
|
||
|
// �� ��SELECT t.F_NUMPARAM4,t.F_MonitorIndex FROM T_MONITOR_TASK t,T_BASE_DEVICE s WHERE t.F_MANAGETASKINDEX = 70013 and t.f_Deviceindex = s.F_DEVICEINDEX AND s.F_IFCORRELDOUBLEFORK = 1
|
||
|
// ����˫���������ͳ����յ��������� û��������order by�Ӳ�ѯ ��������������ʱ�䳤
|
||
|
sss.Append("SELECT t.F_NUMPARAM4,t.F_MonitorIndex FROM T_MONITOR_TASK t,T_BASE_DEVICE s WHERE t.F_MANAGETASKINDEX = ").Append(Fid).Append(" and t.f_Deviceindex = s.F_DEVICEINDEX AND s.F_IFCORRELDOUBLEFORK = 1");
|
||
|
dvb = dbo.ExceSQL(sss.ToString()).Tables[0].DefaultView;
|
||
|
if (dvb.Count > 0)
|
||
|
{
|
||
|
// �յ�λ��
|
||
|
rr[0] = Convert.ToInt32(dvb[0]["F_NUMPARAM4"]);
|
||
|
// ������
|
||
|
rr[1] = Convert.ToInt32(dvb[0]["F_MonitorIndex"]);
|
||
|
// ������
|
||
|
rr[2] = useAwayFork;
|
||
|
return rr;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.GetDouArrowDeviceIndexʱ��������:" + ex.Message;
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dvb.Dispose();
|
||
|
sql = null;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
//��������������Ϣ
|
||
|
public string GetGoodsBarcodeFromManageTask(int TaskIndex)//20130107
|
||
|
{
|
||
|
//20100108
|
||
|
string sql;
|
||
|
string goodsbarcode = string.Empty;
|
||
|
try
|
||
|
{
|
||
|
int mti = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(TaskIndex);
|
||
|
int fid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(TaskIndex);
|
||
|
//20100108
|
||
|
sql = string.Format("SELECT GOODS_BARCODE FROM T_Manage_Task WHERE (FID = {0}) AND (F_ManageTaskKindIndex ={1})", fid, mti);
|
||
|
object ob = dbo.GetSingle(sql);
|
||
|
if (ob != null)
|
||
|
{
|
||
|
goodsbarcode = Convert.ToString(ob);
|
||
|
}
|
||
|
|
||
|
return goodsbarcode;
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100108
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.GetGoodsBarcodeFromManageTaskʱ��������:" + ex.Message;
|
||
|
return "";
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
sql = null;
|
||
|
}
|
||
|
}
|
||
|
//������������
|
||
|
public int GetGoodsTypeFromManageTask(int TaskIndex)//20130107
|
||
|
{
|
||
|
//20100108
|
||
|
string sql;
|
||
|
int type = 0;
|
||
|
try
|
||
|
{
|
||
|
int mti = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(TaskIndex);
|
||
|
int fid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(TaskIndex);
|
||
|
//20100108
|
||
|
sql = string.Format("SELECT GOODS_NUM FROM T_Manage_Task WHERE (FID = {0}) AND (F_ManageTaskKindIndex ={1})", fid, mti);
|
||
|
object ob = dbo.GetSingle(sql);
|
||
|
if (ob != null)
|
||
|
{
|
||
|
type = Convert.ToInt32(ob);
|
||
|
}
|
||
|
|
||
|
return type;
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{//20100108
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.GetGoodsTypeFromManageTaskʱ��������:" + ex.Message;
|
||
|
return 0;
|
||
|
}
|
||
|
finally
|
||
|
{//20100108
|
||
|
sql = null;
|
||
|
}
|
||
|
}
|
||
|
int GetNowDevice(int taskindex)
|
||
|
{
|
||
|
sss.Remove(0, sss.Length);
|
||
|
sss.Append("SELECT F_NumParam1 FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(taskindex).Append(")");
|
||
|
DataView dvb = dbo.ExceSQL(sss.ToString()).Tables[0].DefaultView;
|
||
|
if (dvb.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dvb[0]["F_NumParam1"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
int IfInworkBench(int taskindex)
|
||
|
{
|
||
|
int fid = Model.CGeneralFunction.GetManageTaskIndexfromMonitor(taskindex);
|
||
|
int mti = Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(taskindex);
|
||
|
object ob = dbo.GetSingle(string.Format("SELECT WORK_MODE FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = {0}) AND (FID = {1})", mti, fid));
|
||
|
if (ob != null)
|
||
|
{
|
||
|
return Convert.ToInt32(ob);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 2;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
List<int> GetNextDevice(int CurRouteIDSub, int CurSerialNumber)
|
||
|
{
|
||
|
List<int> keyDevice = new List<int>(); DataView dvRoute;
|
||
|
try
|
||
|
{
|
||
|
//Ȼ�������жϺ����豸�������豸
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT T_Base_Route_Device.F_DeviceIndex,F_DeviceOrder, T_Base_Route_Device.F_SerialNumber, ").Append(
|
||
|
"T_Base_Device_Command.F_DeviceCommandIndex,T_Base_Device.F_DeviceKindIndex FROM T_Base_Device_Command ").Append(
|
||
|
",T_Base_Device,T_Base_Route_Device where T_Base_Device_Command.F_DeviceKindIndex = T_Base_Device.F_DeviceKindIndex").Append(
|
||
|
" and T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and F_RouteIDSub=").Append(
|
||
|
CurRouteIDSub).Append(" and F_SerialNumber > ").Append(CurSerialNumber).Append(" order by F_SerialNumber asc ");
|
||
|
dvRoute = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvRoute.Count > 0)
|
||
|
{
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceKindIndex"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_SerialNumber"]));
|
||
|
keyDevice.Add(Convert.ToInt32(dvRoute[0]["F_DeviceOrder"]));
|
||
|
|
||
|
}
|
||
|
return keyDevice;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.GetNextDevice:" + ex.Message;
|
||
|
return null;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
keyDevice = null;
|
||
|
dvRoute = null;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int GetNextDeviceFromTaskDevice(int TaskIndex, int DeviceIndex)
|
||
|
{//20111226
|
||
|
int RouteIDSub = 0; int sn = 0;
|
||
|
DataView dv = dbo.ExceSQL(string.Format("SELECT F_RouteID FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", TaskIndex)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
RouteIDSub = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
try
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_SerialNumber FROM T_Base_Route_Device WHERE (F_RouteIDSub = ").Append(RouteIDSub).Append(") AND (F_DeviceIndex = ").Append(DeviceIndex).Append(")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
sn = (int)dv[0]["F_SerialNumber"];
|
||
|
List<int> nd = GetNextDevice(RouteIDSub, sn);
|
||
|
if (nd != null)
|
||
|
{
|
||
|
return nd[0];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ݶѶ����������ã���˫���Եȹ���վ̨�ģ�վ̨�豸����
|
||
|
/// </summary>
|
||
|
/// <param name="stackdeviceindex"></param>
|
||
|
/// <param name="stackzxy"></param>
|
||
|
/// <returns></returns>
|
||
|
int GetDeviceLaneGateInfoFromStackCoor(int stackdeviceindex, string stackzxy, out int useawayfork)
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(stackdeviceindex);
|
||
|
if (devinfo != null)
|
||
|
{
|
||
|
if (devinfo.VirtualStack > 0)
|
||
|
{
|
||
|
stackdeviceindex = devinfo.VirtualStack;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
int laneway = 0; useawayfork = 0;
|
||
|
DataView dvl = dbo.ExceSQL(string.Format("SELECT F_LaneDeviceIndex FROM T_Base_LaneInfo WHERE (F_StackIndex = {0})", stackdeviceindex)).Tables[0].DefaultView;
|
||
|
if (dvl.Count > 0)
|
||
|
{
|
||
|
laneway = Convert.ToInt32(dvl[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
// add for CATL YB2 oracle ��F_CorrelDeviceIndex<>'' F_LaneGateDeviceIndex �����صĽ������� F_CorrelDeviceIndex �ֶ� ������ F_LaneGateDeviceIndex
|
||
|
sql.Append("SELECT F_CorrelDeviceIndex,F_UseAwayFork FROM T_Base_Lane_Gate where F_CorrelDeviceIndex is not null and (F_LaneIndex=").Append(laneway).Append(" and T_Base_Lane_Gate.F_ZXY = '").Append(stackzxy).Append("')");
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
useawayfork = Convert.ToInt32(dv[0]["F_UseAwayFork"]);
|
||
|
// F_LaneGateDeviceIndex
|
||
|
return Convert.ToInt32(dv[0]["F_CorrelDeviceIndex"]);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
return -1;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ݶѶ����������ã���˫���Եȹ���վ̨�ģ�վ̨�豸����
|
||
|
/// </summary>
|
||
|
/// <param name="stackdeviceindex"></param>
|
||
|
/// <param name="stackzxy"></param>
|
||
|
/// <returns></returns>
|
||
|
int GetDeviceLaneGateInfoFromStackCoorlanegate(int stackdeviceindex, string stackzxy, out int useawayfork)
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(stackdeviceindex);
|
||
|
if (devinfo != null)
|
||
|
{
|
||
|
if (devinfo.VirtualStack > 0)
|
||
|
{
|
||
|
stackdeviceindex = devinfo.VirtualStack;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
int laneway = 0; useawayfork = 0;
|
||
|
DataView dvl = dbo.ExceSQL(string.Format("SELECT F_LaneDeviceIndex FROM T_Base_LaneInfo WHERE (F_StackIndex = {0})", stackdeviceindex)).Tables[0].DefaultView;
|
||
|
if (dvl.Count > 0)
|
||
|
{
|
||
|
laneway = Convert.ToInt32(dvl[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
sql.Remove(0, sql.Length);
|
||
|
// add for CATL YB2 oracle ��F_CorrelDeviceIndex<>'' F_LaneGateDeviceIndex �����صĽ������� F_CorrelDeviceIndex �ֶ� ������ F_LaneGateDeviceIndex
|
||
|
sql.Append("SELECT F_LaneGateDeviceIndex,F_UseAwayFork FROM T_Base_Lane_Gate where F_CorrelDeviceIndex is not null and (F_LaneIndex=").Append(laneway).Append(" and T_Base_Lane_Gate.F_ZXY = '").Append(stackzxy).Append("')");
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
useawayfork = Convert.ToInt32(dv[0]["F_UseAwayFork"]);
|
||
|
// F_LaneGateDeviceIndex
|
||
|
return Convert.ToInt32(dv[0]["F_LaneGateDeviceIndex"]);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
return -1;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���»���
|
||
|
/// ���������
|
||
|
/// </summary>
|
||
|
/// <param name="fid"></param>
|
||
|
/// <param name="monitorIndex"></param>
|
||
|
/// <param name="forkIndex">��������</param>
|
||
|
/// <param name="deviceIndex"></param>
|
||
|
public void ChangForkForTask(int fid,int monitorIndex,int oldforkIndex,int deviceIndex,int mti)
|
||
|
{
|
||
|
string checkStr = "";
|
||
|
string checkReplaceStr = "";
|
||
|
int newFork = 0;
|
||
|
bool isOutPut = false;//1����ʱ������ ���������� �������ܵĶ��� ����Ҳ�� ����2����ʱ�� �����������ǿ������ܵ� ���͵�ʱ����-1 �����͵�λ�� ���� �ڷ������͵�ʱ�� ����λ�ò���
|
||
|
//int newFork = oldforkIndex == 1 ? 2 : 1;//ǰһ���ж���ֻ�е����û����ͷ����Ļ���һ�� �Ž��� ����֮��ֱ��ȡ�� ����ֻ��ʹ�õĻ���
|
||
|
//if (oldforkIndex == 1)
|
||
|
//{
|
||
|
// checkStr= deviceIndex.ToString() + ".0";
|
||
|
// checkReplaceStr = deviceIndex.ToString() + ".1";
|
||
|
// newFork = 2;
|
||
|
// isOutPut = true;
|
||
|
//}
|
||
|
//if (oldforkIndex == 2)
|
||
|
//{
|
||
|
// checkStr = deviceIndex.ToString() + ".1";
|
||
|
// checkReplaceStr = deviceIndex.ToString() + ".0";//�µļ����
|
||
|
// newFork = 1;
|
||
|
// //isOutPut = true;
|
||
|
//}
|
||
|
//if (oldforkIndex == 0)//Ӧ�����ò���
|
||
|
//{
|
||
|
newFork = ChangeForkWhenEnableUsed(deviceIndex) == 1 ? 2 : 1;
|
||
|
if (newFork == 1)
|
||
|
{
|
||
|
//����������2���� �ij�1��
|
||
|
checkStr = deviceIndex.ToString() + ".1";
|
||
|
checkReplaceStr = deviceIndex.ToString() + ".0";
|
||
|
}
|
||
|
if (newFork == 2)
|
||
|
{
|
||
|
checkStr = deviceIndex.ToString() + ".0";
|
||
|
checkReplaceStr = deviceIndex.ToString() + ".1";
|
||
|
isOutPut = true;
|
||
|
}
|
||
|
//}
|
||
|
|
||
|
if (isOutPut)
|
||
|
{
|
||
|
int manageKind = GetFCONTROLTASKTYPEFromManageTask(mti,fid);
|
||
|
//int order = getOrderFromMonitor(monitorIndex, deviceIndex);
|
||
|
if (manageKind == 2)//&& order==5
|
||
|
{
|
||
|
int[] zxy = GetCoordinatesFromMonitorTask(monitorIndex);//��ȡָ����ȡ�� ���ͻ� ����
|
||
|
StringBuilder zxystart = new StringBuilder();
|
||
|
StringBuilder zxyend = new StringBuilder();
|
||
|
|
||
|
if (zxy != null)
|
||
|
{
|
||
|
//zxyend.Append((zxy[3].ToString().Length == 1 ? "0" + zxy[3].ToString() : zxy[3].ToString())).Append("-").Append(
|
||
|
// ((zxy[4].ToString().Length == 1) ? ("0" + zxy[4].ToString()) : (zxy[4].ToString()))).Append("-").Append(
|
||
|
// ((zxy[5].ToString().Length == 1) ? ("0" + zxy[5].ToString()) : (zxy[5].ToString())));
|
||
|
//zxystart.Append((zxy[1].ToString().Length == 1 ? "0" + zxy[1].ToString() : zxy[1].ToString())).Append("-").Append(
|
||
|
// ((zxy[2].ToString().Length == 1) ? ("0" + zxy[2].ToString()) : (zxy[2].ToString()))).Append("-").Append(
|
||
|
// ((zxy[3].ToString().Length == 1) ? ("0" + zxy[3].ToString()) : (zxy[3].ToString())));
|
||
|
int n5 = zxy[4] + 1;//��1֮���ٷ���ʱ����1 ʱ������ �͵������� �������Ǵ��� ֻ������2���ͻ�������
|
||
|
//�ж��ͻ��յ��Dz���վ̨
|
||
|
|
||
|
//�ĶѶ����ͻ�����
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_NumParam5=").Append(n5).Append(" WHERE (F_ManageTaskIndex = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(")").Append(" AND F_DeviceIndex = ").Append(deviceIndex);//.Append(" and F_deviceCommandIndex=5")
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
//���������� ͨ������ȡ����
|
||
|
//if (controlTaskType == 1 || controlTaskType == 3)
|
||
|
//{
|
||
|
//�����㶼�ǿ�������λ�� ����ʱ�� վ̨�ļ��������Dz���Ҫ�ı��� ֻ��Ҫ�ĶѶ���̽������
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_AheadDetect=Replace(F_AheadDetect,'")
|
||
|
.Append(checkStr).Append("','").Append(checkReplaceStr).Append("') WHERE F_ManageTaskIndex = ")
|
||
|
.Append(fid).Append(" AND F_DeviceIndex = ").Append(deviceIndex);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_UseAwayFork = '").Append(newFork).Append("' WHERE (F_ManageTaskIndex = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(") AND F_DeviceIndex = ").Append(deviceIndex);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Manage_Task SET FUseAwayFork = '").Append(newFork).Append("' WHERE (FID = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(")");
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
//}
|
||
|
//�����dz��� �ͻ�λ ����
|
||
|
//if (controlTaskType == 2)
|
||
|
//{
|
||
|
|
||
|
//}
|
||
|
//����
|
||
|
//if (controlTaskType == 3)
|
||
|
//{
|
||
|
|
||
|
//}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �ж��Ƿ��н��û���
|
||
|
/// </summary>
|
||
|
/// <param name="deviceIndex"></param>
|
||
|
/// <param name="fork"></param>
|
||
|
/// <returns></returns>
|
||
|
public int ChangeForkWhenEnableUsed(int deviceIndex)
|
||
|
{
|
||
|
int returnFork = 0;
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_stackindex,F_ENABLEUSED from T_BASE_STACKINFO where F_stackindex=").Append(deviceIndex);
|
||
|
DataView dw = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dw.Count > 0)
|
||
|
{
|
||
|
if (Convert.ToInt32(dw[0]["F_ENABLEUSED"]) != 0)
|
||
|
{
|
||
|
//if (Convert.ToInt32(dw[0]["F_ENABLEUSED"]) == 1)//1������
|
||
|
//{
|
||
|
// returnFork = 2;
|
||
|
//}
|
||
|
//if (Convert.ToInt32(dw[0]["F_ENABLEUSED"]) == 2)//2������
|
||
|
//{
|
||
|
// returnFork = 1;
|
||
|
//}
|
||
|
returnFork = Convert.ToInt32(dw[0]["F_ENABLEUSED"]);
|
||
|
}
|
||
|
}
|
||
|
return returnFork;
|
||
|
}
|
||
|
//ÿ�η�������ǰִ��·������ T_Base_Lane_Gate ��lane gate �� ����ǰ���� add for CATL YB2 �滻��ǰ����
|
||
|
public bool SetLaneGateReplace(int mti, int fid, int DeviceIndex, int TaskIndex, int UseAwayFork)
|
||
|
{//20120820
|
||
|
//201112231ͬʱ���ǵ���·����ѡվ̨����ǰ����������
|
||
|
if (UseAwayFork > 0)
|
||
|
{
|
||
|
int[] zxy = GetCoordinatesFromMonitorTask(TaskIndex);
|
||
|
StringBuilder zxystr = new StringBuilder();
|
||
|
if (zxy != null)
|
||
|
{
|
||
|
zxystr.Append((zxy[3].ToString().Length == 1 ? "0" + zxy[3].ToString() : zxy[3].ToString())).Append("-").Append(
|
||
|
((zxy[4].ToString().Length == 1) ? ("0" + zxy[4].ToString()) : (zxy[4].ToString()))).Append("-").Append(
|
||
|
((zxy[5].ToString().Length == 1) ? ("0" + zxy[5].ToString()) : (zxy[5].ToString())));
|
||
|
}
|
||
|
int LaneGateDevice = 0; int oldawayfork = 0; int LaneGateDevicetrue = 0;
|
||
|
//oNextDevice ·�����Ѿ����ֳ��ij���վ̨���ţ�1�л�2�ж�Ӧ���豸���ţ� oldawayfork ����ֵ��Զ��1 2��ֵ��ֵ��1
|
||
|
int oNextDevice = GetDeviceLaneGateInfoFromStackCoor(DeviceIndex, zxystr.ToString(), out oldawayfork);
|
||
|
// add for CATL YB2 ������ʵ��F_LaneGateDeviceIndex
|
||
|
int oNextDevicetrue = GetDeviceLaneGateInfoFromStackCoorlanegate(DeviceIndex, zxystr.ToString(), out oldawayfork);
|
||
|
if (oNextDevice > 0)
|
||
|
{
|
||
|
// �ͻ���ֵCATL
|
||
|
int n5 = zxy[4]; //Convert.ToInt32(sp[1]);
|
||
|
|
||
|
if (UseAwayFork == oldawayfork || oldawayfork==0)//����Ҫָ������
|
||
|
{
|
||
|
//������
|
||
|
return false;//20120217
|
||
|
}
|
||
|
else//��oldawayfork�滻ΪUseAwayFork
|
||
|
{
|
||
|
//�Ѷ�����ԭ������
|
||
|
char[] cc = new char[1] { ',' };
|
||
|
string[] lc = devinfo.StackZeroColLayer.Split(cc);
|
||
|
// add for CATL YB2 ��stackinfo ������ F_ZeroColLayer �ֶ����öѶ������� 0,1 ԭ��Ϊ0��1 ���������ó�40��1ԭ�����Ǵ�
|
||
|
// 40,1 �ݼ� ȷ���Ѷ����������ⷽ�� �ǵ�����1��2 ���ǵݼ���2��1
|
||
|
if (Convert.ToInt32(lc[0]) < n5)//��������������˳���ź���˳������ͬ
|
||
|
{
|
||
|
n5 = n5 + (UseAwayFork - oldawayfork);
|
||
|
}
|
||
|
else
|
||
|
{//˫�Ѷ�����ԭ���������еĻ���˳���ź���˳�����෴
|
||
|
n5 = n5 - (UseAwayFork - oldawayfork);
|
||
|
}
|
||
|
zxystr.Clear();
|
||
|
zxystr.Append((zxy[3].ToString().Length == 1 ? "0" + zxy[3].ToString() : zxy[3].ToString())).Append("-").Append(
|
||
|
((n5.ToString().Length == 1) ? ("0" + n5.ToString()) : (n5.ToString()))).Append("-").Append(
|
||
|
((zxy[5].ToString().Length == 1) ? ("0" + zxy[5].ToString()) : (zxy[5].ToString())));
|
||
|
LaneGateDevice = GetDeviceLaneGateInfoFromStackCoor(DeviceIndex, zxystr.ToString(), out oldawayfork);
|
||
|
// add for CATL YB2
|
||
|
LaneGateDevicetrue = GetDeviceLaneGateInfoFromStackCoorlanegate(DeviceIndex, zxystr.ToString(), out oldawayfork);
|
||
|
//�滻·�� add for CATL YB2 ���Ӹ�����ǰ�����ͻ�ʱ�� ���ĸ���������ǰ��������
|
||
|
// �ͳ����ͻ�վ̨û������Զ�� ��ҪҪ����������Զ˫���� �ĸ�λ���л� �ֱ��ϱ���.2 �� .0 ��
|
||
|
|
||
|
|
||
|
//�ĶѶ�����ǰ���⣬RunLock
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_RunningLock='").Append(LaneGateDevice).Append("', F_AheadDetect=Replace(F_AheadDetect,'")
|
||
|
.Append(oNextDevice).Append("','").Append(LaneGateDevice).Append("') WHERE (F_ManageTaskIndex = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(") AND F_DeviceIndex = ").Append(DeviceIndex);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
//�ĶѶ����ͻ�����
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_NumParam5=").Append(n5).Append(" WHERE (F_ManageTaskIndex = ")
|
||
|
.Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(")").Append(" AND F_DeviceIndex = ").Append(DeviceIndex);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
//�����ͻ�����ǰ���⣬RunLock,F_NumParam1
|
||
|
//add for CATL YB2 �ĶѶ�����������ǰ���� ������ lane_gate ���� F_NearDetect �ֶ� ��������5��
|
||
|
string[] cdiold = GetLanewayDeviceInfoFromStackDev(DeviceIndex, oNextDevicetrue);
|
||
|
string[] cdinew = GetLanewayDeviceInfoFromStackDev(DeviceIndex, LaneGateDevicetrue);
|
||
|
if (cdiold != null && cdinew != null)
|
||
|
{
|
||
|
//add for CATL YB2 �ĶѶ����ͳ���ȡ���Ļ������� ������Lange_Gate ���� F_NearDetect �ֶ�
|
||
|
sql.Clear();
|
||
|
sql.Append("UPDATE T_Monitor_Task SET F_AheadDetect=Replace(F_AheadDetect,'").Append(cdiold[5]).Append("','").Append(cdinew[5])
|
||
|
.Append("') WHERE (F_ManageTaskIndex = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
.Append(mti).Append(") AND F_DeviceIndex = ").Append(DeviceIndex);
|
||
|
dbo.ExecuteSql(sql.ToString());
|
||
|
}
|
||
|
|
||
|
#region ��ͨ��д�� ע��
|
||
|
//if (UseAwayFork == 1)
|
||
|
//{
|
||
|
// sql.Clear();
|
||
|
// sql.Append("UPDATE T_Monitor_Task SET F_AheadDetect=Replace(F_AheadDetect,'").Append(oNextDevice.ToString().Substring(0, 5) + ".1").Append("','").Append(LaneGateDevice.ToString().Substring(0, 5) + ".0")
|
||
|
// .Append("') WHERE (F_ManageTaskIndex = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
// .Append(mti).Append(") AND F_DeviceIndex = ").Append(oNextDevice);
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
|
||
|
//}
|
||
|
//if (UseAwayFork == 2)
|
||
|
//{
|
||
|
// sql.Clear();
|
||
|
// sql.Append("UPDATE T_Monitor_Task SET F_AheadDetect=Replace(F_AheadDetect,'").Append(oNextDevice.ToString().Substring(0, 5) + ".0").Append("','").Append(LaneGateDevice.ToString().Substring(0, 5) + ".1")
|
||
|
// .Append("') WHERE (F_ManageTaskIndex = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
// .Append(mti).Append(") AND F_DeviceIndex = ").Append(oNextDevice);
|
||
|
// dbo.ExecuteSql(sql.ToString());
|
||
|
//}
|
||
|
#endregion
|
||
|
// add for CATL YB2 ע��
|
||
|
// sql.Clear();
|
||
|
//sql.Append("UPDATE T_Monitor_Task SET F_RouteID=").Append(GetRouteIDsub(LaneGateDevice))
|
||
|
// .Append(",F_DeviceIndex=").Append(LaneGateDevice).Append(", F_NumParam1=").Append(LaneGateDevice)
|
||
|
// .Append(", F_AheadDetect=Replace(F_AheadDetect,'").Append(oNextDevice).Append("','").Append(LaneGateDevice)
|
||
|
// .Append("') WHERE (F_ManageTaskIndex = ").Append(fid).Append(") AND (F_ManageTASKKINDINDEX = ")
|
||
|
// .Append(mti).Append(") AND F_DeviceIndex = ").Append(oNextDevice);
|
||
|
//dbo.ExecuteSql(sql.ToString());
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return false;//20120217
|
||
|
}
|
||
|
}
|
||
|
int GetGoodsHigh(int taskindex)
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL(string.Format("SELECT CELL_MODEL FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = {0}) AND (FID = {1})", Model.CGeneralFunction.GetManageTaskKindIndexFromMonitor(taskindex), Model.CGeneralFunction.GetManageTaskIndexfromMonitor(taskindex))).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
int gh = 1;
|
||
|
//P��װ��,B��,G��λ,D����λ
|
||
|
switch (dv[0][0].ToString().ToUpper())
|
||
|
{
|
||
|
case "P":
|
||
|
gh = 3;
|
||
|
break;
|
||
|
case "B":
|
||
|
gh = 2;
|
||
|
break;
|
||
|
case "G":
|
||
|
gh = 1;
|
||
|
break;
|
||
|
//case "D":
|
||
|
// gh = 4;
|
||
|
// break;
|
||
|
default:
|
||
|
gh = 1;
|
||
|
break;
|
||
|
}
|
||
|
return gh;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 1;
|
||
|
}
|
||
|
}
|
||
|
int MinRouteID(int startdevice, int enddevice, int nowdevice, object useAwayfork)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
StringBuilder dff = new StringBuilder();
|
||
|
if (useAwayfork.ToString() == "-")
|
||
|
{
|
||
|
dff.Append("F_UseAwayFork<>'n'");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
dff.Append("(F_UseAwayFork='").Append(useAwayfork).Append("' or F_UseAwayFork='-' )");//20101028
|
||
|
}
|
||
|
//ѡ�����̵���·�������жϴ�·�����Ƿ����豸��������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT distinct(T_Base_Route_Device.F_RouteIDSub) FROM T_Base_Device,T_Base_Route_Device,").Append(
|
||
|
"T_Base_Route where T_Base_Route_Device.F_RouteID = T_Base_Route.F_RouteID and ").Append(
|
||
|
" T_Base_Route_Device.F_DeviceIndex = T_Base_Device.F_DeviceIndex and ").Append(
|
||
|
" F_StartDevice=").Append(startdevice).Append(" and F_EndDevice=").Append(enddevice).Append(" and F_Status=1 and T_Base_Device.F_DeviceIndex =").Append(nowdevice).Append(" and ").Append(dff.ToString());
|
||
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
List<double> minroute = new List<double>();//0,routIDSub��1��·����Сֵ
|
||
|
if (dv.Count == 0)
|
||
|
{
|
||
|
//RefreshMonitorEventArgs rme = new RefreshMonitorEventArgs("tsStatus", "�����豸��" + startdevice + "���յ��豸��" + enddevice + "֮��·�������ã�");
|
||
|
//OnRefreshMonitor(rme);
|
||
|
return -1;
|
||
|
}
|
||
|
for (int i = 0; i < dv.Count; i++)
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT F_RouteIDSub, F_LockedState FROM T_Base_Device,T_Base_Route_Device WHERE ").Append(
|
||
|
" T_Base_Device.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex and (T_Base_Route_Device.F_RouteIDSub = ").Append(
|
||
|
dv[i]["F_RouteIDSub"]).Append(") AND (T_Base_Device.F_LockedState = - 1)");
|
||
|
DataView dvd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dvd.Count > 0)
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
List<double> route = new List<double>();//0,routIDSub��1,������2��·��ʹ��Ƶ�ʣ�3��·���豸������
|
||
|
//·���������豸���������̣�Ȩ��0.3����·��ʹ��Ƶ����С��Ȩ��0.3����·����·���豸��������Ȩ��0.3��
|
||
|
|
||
|
route.Add(Convert.ToDouble(dv[i]["F_RouteIDSub"]));//RouteIDSub
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select count(F_DeviceIndex) as steps from T_Base_Route_Device where F_RouteIDSub="
|
||
|
).Append(dv[i]["F_RouteIDSub"]);
|
||
|
DataView dv1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv1[0]["steps"]));//����
|
||
|
//route.Add(0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
//·��ʹ��Ƶ�ʣ�·��ִ�е�������������
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(DISTINCT F_ManageTaskIndex) AS ManCount FROM T_Monitor_Task GROUP BY F_RouteID HAVING (F_RouteID = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
DataView dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["ManCount"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv2[0]["ManCount"]));//·��ʹ��Ƶ��
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·��ʹ��Ƶ��
|
||
|
}
|
||
|
//·���豸������
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("SELECT COUNT(T_Monitor_Task.F_MonitorIndex) AS mtask FROM T_Monitor_Task ,T_Base_Route_Device where (T_Monitor_Task.F_DeviceIndex = T_Base_Route_Device.F_DeviceIndex) and (T_Base_Route_Device.F_RouteIDSub = ").Append(dv[i]["F_RouteIDSub"]).Append(")");
|
||
|
dv2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)
|
||
|
{
|
||
|
double a = 0;
|
||
|
if (double.TryParse(dv2[0]["mtask"].ToString(), out a) == true)
|
||
|
{
|
||
|
route.Add(Convert.ToDouble(dv2[0]["mtask"]));//·���豸������
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
route.Add(0);//·���豸������
|
||
|
}
|
||
|
|
||
|
//������·������·������*0.3+·��ʹ��Ƶ��*0.3+�豸ռ����*0.3������Сֵ��
|
||
|
if (minroute.Count == 0)
|
||
|
{
|
||
|
minroute.Add(route[0]);
|
||
|
minroute.Add(route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (minroute[1] > (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3))
|
||
|
{
|
||
|
minroute[0] = route[0];
|
||
|
minroute[1] = (route[1] * 0.3 + route[2] * 0.3 + route[3] * 0.3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (minroute.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(minroute[0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
|
||
|
_commLayerError = "OPCClient.CSendDeviceOrder.MinRouteIDʱ��������:" + ex.Message;
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
int[] GetCoordinatesFromMonitorTask(int TaskIdx)
|
||
|
{
|
||
|
//20100108
|
||
|
DataView dv;
|
||
|
int[] gc;
|
||
|
try
|
||
|
{
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
sql.Append("select F_NumParam1,F_NumParam2,F_NumParam3,F_NumParam4,F_NumParam5,F_NumParam6 from T_Monitor_Task where F_MonitorIndex=").Append(TaskIdx);
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
gc = new int[6];
|
||
|
|
||
|
|
||
|
//F_NumParam1--z,x--2,y--3;F_NumParam4--z,5--x,6--y
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
gc[0] = Convert.ToInt32(dv[0]["F_NumParam1"]);
|
||
|
gc[1] = Convert.ToInt32(dv[0]["F_NumParam2"]);
|
||
|
gc[2] = Convert.ToInt32(dv[0]["F_NumParam3"]);
|
||
|
gc[3] = Convert.ToInt32(dv[0]["F_NumParam4"]);
|
||
|
gc[4] = Convert.ToInt32(dv[0]["F_NumParam5"]);
|
||
|
gc[5] = Convert.ToInt32(dv[0]["F_NumParam6"]);
|
||
|
return gc;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv = null;
|
||
|
gc = null;
|
||
|
}
|
||
|
}
|
||
|
string GetUseAwayForkFromLaneGate(int device)
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL(string.Format("SELECT F_UseAwayFork FROM T_Base_Lane_Gate where F_LaneGateDeviceIndex={0}", device)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return dv[0][0].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "-";
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ݶѶ������豸���������豸������������Ϣ����0���豸������1��������λ���⡾2��������λ����
|
||
|
/// ��3���������⡾4�����м��⡾5���������������⡾6��Զ�����������⡾7���Ƿ�ʹ��Զ���桾8�������豸������9����λ����
|
||
|
/// </summary>
|
||
|
/// <param name="stack"></param>
|
||
|
/// <param name="device"></param>
|
||
|
/// <returns></returns>
|
||
|
public string[] GetLanewayDeviceInfoFromStackDev(int stack, int device)
|
||
|
{
|
||
|
DataView dvl = new DataView(); DataView dv = new DataView();
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(stack);
|
||
|
if (devinfo!=null)
|
||
|
{
|
||
|
if (devinfo.VirtualStack > 0)
|
||
|
{
|
||
|
stack = devinfo.VirtualStack;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int laneway = 0;
|
||
|
dvl = dbo.ExceSQL(string.Format("SELECT F_LaneDeviceIndex FROM T_Base_LaneInfo WHERE (F_StackIndex = {0})", stack)).Tables[0].DefaultView;
|
||
|
if (dvl.Count > 0)
|
||
|
{
|
||
|
laneway = Convert.ToInt32(dvl[0][0]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
string[] rr = new string[10];
|
||
|
|
||
|
//20101124
|
||
|
sql.Remove(0, sql.Length);
|
||
|
//add for CATL YB2
|
||
|
sql.Append("SELECT * FROM T_Base_Lane_Gate where F_CorrelDeviceIndex is not null and (F_LaneIndex=").Append(laneway).Append(" and T_Base_Lane_Gate.F_LaneGateDeviceIndex = ").Append(device).Append(")");
|
||
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
rr[0] = dv[0]["F_LaneGateDeviceIndex"].ToString();
|
||
|
rr[1] = dv[0]["F_HighDetect"].ToString();
|
||
|
rr[2] = dv[0]["F_LowDetect"].ToString();
|
||
|
rr[3] = dv[0]["F_HavingDetect"].ToString();
|
||
|
rr[4] = dv[0]["F_RunDetect"].ToString();
|
||
|
rr[5] = dv[0]["F_NearDetect"].ToString();
|
||
|
rr[6] = dv[0]["F_FarDetect"].ToString();
|
||
|
rr[7] = dv[0]["F_UseAwayFork"].ToString();
|
||
|
rr[8] = dv[0]["F_CorrelDeviceIndex"].ToString();
|
||
|
rr[9] = dv[0]["F_zxy"].ToString();
|
||
|
return rr;
|
||
|
}
|
||
|
else
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
finally
|
||
|
{
|
||
|
dv.Dispose();
|
||
|
dvl.Dispose();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|