|
|
|
@ -29,12 +29,18 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MvCodeHelper));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 全局变量定义
|
|
|
|
|
public static MvCodeReader ShellDevice = null;
|
|
|
|
|
public static MvCodeReader ShellDevice = null;
|
|
|
|
|
public static MvCodeReader LinerDevice = null;
|
|
|
|
|
public static DateTime ShellLiveTime = DateTime.Now;
|
|
|
|
|
public static DateTime LinerLiveTime = DateTime.Now;
|
|
|
|
|
private static string ShellCode69 = string.Empty;
|
|
|
|
|
private static string ShellProductCode = string.Empty;
|
|
|
|
|
private static string LinerCode69 = string.Empty;
|
|
|
|
|
private static string LinerProductCode = string.Empty;
|
|
|
|
|
#endregion
|
|
|
|
|
#region 委托事件
|
|
|
|
|
|
|
|
|
@ -65,19 +71,19 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
|
|
|
|
|
public static void ShellImageCallbackFunc(IntPtr pData, IntPtr pstFrameInfoEx2, IntPtr pUser)
|
|
|
|
|
{
|
|
|
|
|
string Code69 = string.Empty;
|
|
|
|
|
string ProductCode = string.Empty;
|
|
|
|
|
|
|
|
|
|
var stFrameInfo = (MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2)Marshal.PtrToStructure(pstFrameInfoEx2, typeof(MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2));
|
|
|
|
|
|
|
|
|
|
MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2 stBcrResult = (MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2)Marshal.PtrToStructure(stFrameInfo.UnparsedBcrList.pstCodeListEx2, typeof(MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2));
|
|
|
|
|
//更新扫码器存活时间
|
|
|
|
|
ShellLiveTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
if (stBcrResult.nCodeNum <2)
|
|
|
|
|
if (stBcrResult.nCodeNum <=0)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(DateTime.Now + ":外侧--->No Read 处理");
|
|
|
|
|
Console.WriteLine(DateTime.Now + ":外侧--->No Read 处理,条码个数:"+ stBcrResult.nCodeNum);
|
|
|
|
|
log.Info(DateTime.Now + ":外侧--->No Read 处理");
|
|
|
|
|
|
|
|
|
|
ShellCode69 = string.Empty;
|
|
|
|
|
ShellProductCode = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -89,28 +95,32 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
|
|
|
|
|
Console.WriteLine(DateTime.Now + ":外侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
|
|
|
|
|
log.Info(DateTime.Now + ":外侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
|
|
|
|
|
if (strCode.Trim().TrimEnd('\0').Length == 20)
|
|
|
|
|
if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 20)
|
|
|
|
|
{
|
|
|
|
|
ProductCode = strCode;
|
|
|
|
|
// RefreshMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'), ShellScannerIp);
|
|
|
|
|
// 业务处理
|
|
|
|
|
ShellProductCode = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (strCode.Trim().TrimEnd('\0').Length == 13)
|
|
|
|
|
if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 13)
|
|
|
|
|
{
|
|
|
|
|
ShellCode69 = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
|
|
|
|
|
}
|
|
|
|
|
if(!string.IsNullOrEmpty(ShellProductCode)&& !string.IsNullOrEmpty(ShellCode69))
|
|
|
|
|
{
|
|
|
|
|
Code69 = strCode;
|
|
|
|
|
// RefreshMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'), ShellScannerIp);
|
|
|
|
|
// 业务处理
|
|
|
|
|
Console.WriteLine("69码:" + ShellCode69 + ";成品:" + ShellProductCode + "=====>业务处理");
|
|
|
|
|
RefreshMaterialCodeStrEvent?.Invoke(ShellProductCode, ShellCode69, ShellScannerIp);
|
|
|
|
|
ShellCode69 = string.Empty;
|
|
|
|
|
ShellProductCode = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine("69:" + Code69);
|
|
|
|
|
Console.WriteLine("成品:" + ProductCode);
|
|
|
|
|
RefreshMaterialCodeStrEvent?.Invoke(ProductCode,Code69, ShellScannerIp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -124,11 +134,12 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
//更新扫码器存活时间
|
|
|
|
|
LinerLiveTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
if (stBcrResult.nCodeNum < 2)
|
|
|
|
|
if (stBcrResult.nCodeNum <=0)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(DateTime.Now + ":内侧--->No Read 处理");
|
|
|
|
|
log.Info(DateTime.Now + ":内侧--->No Read 处理");
|
|
|
|
|
|
|
|
|
|
LinerCode69 = string.Empty;
|
|
|
|
|
LinerProductCode = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -141,24 +152,29 @@ namespace Aucma.Core.ProductOffLine.Business
|
|
|
|
|
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
|
|
|
|
|
Console.WriteLine(DateTime.Now + ":内侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
|
|
|
|
|
log.Info(DateTime.Now + ":内侧扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
|
|
|
|
|
// RefreshMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'), LinerScannerIp);
|
|
|
|
|
if (strCode.Trim().TrimEnd('\0').Length == 20)
|
|
|
|
|
if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 20)
|
|
|
|
|
{
|
|
|
|
|
LinerProductCode = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
|
|
|
|
|
}
|
|
|
|
|
if (strCode.Trim().TrimEnd('\0').Replace("\r\n", "").Length == 13)
|
|
|
|
|
{
|
|
|
|
|
ProductCode = strCode;
|
|
|
|
|
|
|
|
|
|
LinerCode69 = strCode.Trim().TrimEnd('\0').Replace("\r\n", "");
|
|
|
|
|
}
|
|
|
|
|
if (strCode.Trim().TrimEnd('\0').Length == 13)
|
|
|
|
|
if (!string.IsNullOrEmpty(LinerProductCode) && !string.IsNullOrEmpty(LinerCode69))
|
|
|
|
|
{
|
|
|
|
|
Code69 = strCode;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("69码:" + LinerCode69 + ";成品:" + LinerProductCode + "=====>业务处理");
|
|
|
|
|
RefreshMaterialCodeStrEvent?.Invoke(LinerProductCode, LinerCode69, LinerScannerIp);
|
|
|
|
|
LinerCode69 = string.Empty;
|
|
|
|
|
LinerProductCode = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine("69:" + Code69);
|
|
|
|
|
Console.WriteLine("成品:" + ProductCode);
|
|
|
|
|
RefreshMaterialCodeStrEvent?.Invoke(ProductCode,Code69, LinerScannerIp);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|