143 lines
4.4 KiB
C#
143 lines
4.4 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using System.Data;
|
|||
|
using System.Threading;
|
|||
|
using Microsoft.VisualBasic;
|
|||
|
using DBFactory;
|
|||
|
using ICommLayer;
|
|||
|
|
|||
|
namespace Symbol3204
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// ʹ<><CAB9>SocketsUDP<44>Ŀͻ<C4BF><CDBB>˽<EFBFBD><CBBD><EFBFBD>ͨѶ
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>Richard.Liu
|
|||
|
/// </summary>
|
|||
|
public class CSendDeviceOrder: ISendDeviceOrder
|
|||
|
{
|
|||
|
string _commLayerError;
|
|||
|
|
|||
|
public string CommLayerError
|
|||
|
{
|
|||
|
get { return _commLayerError; }
|
|||
|
set { _commLayerError = value; }
|
|||
|
}
|
|||
|
DBOperator dbo = new DBOperator();
|
|||
|
public CSendDeviceOrder()
|
|||
|
{
|
|||
|
dbo.Open();
|
|||
|
}
|
|||
|
|
|||
|
public bool SendDeviceOrder(int MessageIndex, int TaskIndex, int Order, int DeviceIndex)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
CScan cs;
|
|||
|
//<2F><><EFBFBD><EFBFBD>DeviceIndex,<2C>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ںźͳ<C5BA>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
DataSet ds = dbo.ExceSQL("SELECT F_DeviceIndex, F_CommSettings, F_SerialPort FROM T_Base_Device where F_DeviceIndex=" + DeviceIndex);
|
|||
|
DataView dv = ds.Tables[0].DefaultView;
|
|||
|
|
|||
|
if (ds.Tables[0].DefaultView.Count > 0)
|
|||
|
{
|
|||
|
|
|||
|
cs = new CScan(Convert.ToInt16(dv[0]["F_SerialPort"]), Convert.ToString(dv[0]["F_CommSettings"]));
|
|||
|
if (Order == 1)//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>
|
|||
|
{
|
|||
|
if (cs.StartSession() == true)
|
|||
|
{
|
|||
|
cs.StopScan();
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
cs.StopScan();
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
else//ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
if (cs.StopSession() == true)
|
|||
|
{
|
|||
|
cs.StopScan();
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
cs.StopScan();
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
{
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_commLayerError = "Symbol3204<30><34>SendDeviceOrder---" + ex.Message;
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
public bool SendDeviceOrder(int MessageIndex, int TaskIndex, int Order, int DeviceIndex, int StartX, int StartY, int StartZ, int EndX, int EndY, int EndZ)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
CScan cs;
|
|||
|
//<2F><><EFBFBD><EFBFBD>DeviceIndex,<2C>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ںźͳ<C5BA>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
DataSet ds = dbo.ExceSQL("SELECT F_DeviceIndex, F_CommSettings, F_SerialPort FROM T_Base_Device where F_DeviceIndex=" + DeviceIndex);
|
|||
|
DataView dv = ds.Tables[0].DefaultView;
|
|||
|
|
|||
|
if (ds.Tables[0].DefaultView.Count > 0)
|
|||
|
{
|
|||
|
|
|||
|
cs = new CScan(Convert.ToInt16(dv[0]["F_SerialPort"]), Convert.ToString(dv[0]["F_CommSettings"]));
|
|||
|
if (Order == 1)//<2F><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>
|
|||
|
{
|
|||
|
if (cs.StartSession() == true)
|
|||
|
{
|
|||
|
cs.StopScan();
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
cs.StopScan();
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
else//ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
if (cs.StopSession() == true)
|
|||
|
{
|
|||
|
cs.StopScan();
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
cs.StopScan();
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
_commLayerError = "Symbol3204<30><34>SendDeviceOrder---" + ex.Message;
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|