Commit 1e8eff8b LN

扫码版本更新

1 个父辈 d87f6ae7
此文件类型无法预览
......@@ -1020,8 +1020,6 @@ namespace OnlineStore.DeviceLibrary
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
storeStatus = StoreStatus.StoreOnline;
LogInfo(" 【" + posId + "】 " + logName + " 整个出库流程结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
MoveEndToRuningStatus();
AutoInout.InOutEndProcess(this, StoreMoveType.OutStore);
if (!String.IsNullOrEmpty(MoveInfo.MoveParam.rfid))
{
if (StoreManager.Store.AutoShelfInstore)
......@@ -1031,6 +1029,9 @@ namespace OnlineStore.DeviceLibrary
StoreManager.Store.AutoShelfInstore = false;
}
}
MoveEndToRuningStatus();
AutoInout.InOutEndProcess(this, StoreMoveType.OutStore);
}
}
#endregion
......
......@@ -92,25 +92,11 @@ namespace OnlineStore.DeviceLibrary
Camera._cam.Close(cameraName);
}
public static void CloseAllCamera()
{
//BaslerCamera.Instance.Close();
//HIKCamera.Instance.Close();
{
Camera._cam.CloseAll();
}
public static Bitmap GetCamerImage(string cameraName)
{
Bitmap bitm = null;
try
{
bitm = Camera._cam.GrabOneImage(cameraName);
}
catch (Exception ex)
{
LogUtil.error(" 【" + cameraName + "】获取图片出错:"+ex.ToString());
}
return bitm;
}
private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount);
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan(List<string> cameraList, string deviceName, bool isSaveImg = false)
......@@ -134,21 +120,17 @@ namespace OnlineStore.DeviceLibrary
}
DateTime startTime = DateTime.Now;
LogUtil.info(deviceName + " 【" + cameraName + "】开始取图片");
using (Bitmap bitmap = GetCamerImage(cameraName))
HalconDotNet.HObject ho_Image = null;
try
{
if (bitmap == null)
ho_Image = Camera._cam.CaptureOnImage(cameraName);
if (ho_Image == null)
{
LogUtil.error(deviceName + " 【" + cameraName + "】取图片失败[" + Camera._cam.ErrInfo + "],关闭相机");
CloseCamera(cameraName);
continue;
}
LogUtil.info(deviceName + " 【" + cameraName + "】取图片完成,开始转换并扫码");
System.Threading.Thread.Sleep(1);
//转换托盘大概100-150ms,不打印日志
Bitmap bit = new Bitmap(bitmap);
HalconDotNet.HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bit);
// LogUtil.info(" 相机【" + cameraName + "】转换图片完成,开始扫码");
}
LogUtil.info(deviceName + " 【" + cameraName + "】取图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>();
string r = "";
foreach (string codeType in codeTypeList)
......@@ -171,31 +153,43 @@ namespace OnlineStore.DeviceLibrary
r = r + "##" + str;
}
}
// LogUtil.debug(" 相机【" + cameraName + "】【" + codeType + "】扫码完成:" + r);
}
if (String.IsNullOrEmpty(r))
{
SaveImageToFile(deviceName, cameraName, bit);
// SaveImageToFile(deviceName, cameraName, bit);
}
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】 :" + r);
}
catch (AccessViolationException e)
{
LogUtil.error(deviceName + " 扫码出现AccessViolationException异常,关闭相机【" + cameraName + "】:" + e.ToString());
Camera._cam.Close(cameraName);
// GC.Collect();
}
catch (Exception ex)
{
LogUtil.error(deviceName + " 扫码出错:" + ex.ToString());
}
finally
{
if (ho_Image != null)
{
ho_Image.Dispose();
}
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】:" + r);
bit.Dispose();
ho_Image.Dispose();
bitmap.Dispose();
}
}
}
catch (AccessViolationException e)
{
LogUtil.error(deviceName + " 扫码出现AccessViolationException异常:" + e.ToString());
GC.Collect();
// GC.Collect();
}
catch (Exception ex)
{
LogUtil.error(deviceName + " 扫码出错:"+ex.ToString());
LogUtil.error(deviceName + " 扫码出错:" + ex.ToString());
}
return codeList;
}
private static void SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap)
{
string date = DateTime.Now.ToString("HH-mm-ss-") + DateTime.Now.Millisecond;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!