Commit 1e8eff8b LN

扫码版本更新

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