Commit 43eeaace 几米阳光

增加调试屏蔽功能

1 个父辈 d404a67a
......@@ -1472,5 +1472,30 @@ namespace OnlineStore.ACSingleStore
store.KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW);
store.KNDIOMove(IO_Type.Door_Down, IO_VALUE.HIGH);
}
private void DebugStatus(bool status)
{
if (status)
{
btnDebug.Text = "禁用调试";
}
else
{
btnDebug.Text = "启用调试";
}
groupAxis.Enabled = status;
groupComAxis.Enabled = status;
groupInout.Enabled = status;
}
private void btnDebug_Click(object sender, EventArgs e)
{
if (btnDebug.Text.Equals("启用调试"))
{
DebugStatus(true);
}
else
{
DebugStatus(false);
}
}
}
}
......@@ -66,7 +66,8 @@ statusBean.addServerData("needInAfterOut",needInAfterOut);
为true时,盘点出库后需要接着扫码入库
2.Data中增加数据:"inTimeout","alarm" 盘点入库超时报警
20190319
增加调试屏蔽的功能。
......
......@@ -12,9 +12,9 @@ using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class CodeManager
public class CodeManager
{
public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
......@@ -31,9 +31,8 @@ namespace OnlineStore.DeviceLibrary
{
cameraNameList = new List<string>();
codeTypeList = new List<string>();
HDLogUtil.LogName = "RollingLogFileAppender";
try
{
{
string[] nameArray = nameStr.Split(spiltChar);
foreach (string str in nameArray)
{
......@@ -47,30 +46,40 @@ namespace OnlineStore.DeviceLibrary
codeTypeList.Add(str.Trim());
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
foreach(string str in names)
{
LogUtil.info("加载到HIK相机:" + str.Trim());
}
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
foreach (string str in names)
{
LogUtil.info("加载到Balser相机:" + str.Trim());
}
LoadCamera();
CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
}
}
}
private static void LoadCamera()
{
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
foreach (string name in hikNameList)
{
LogUtil.info("加载到HIK相机:" + name);
}
foreach (string name in balserNameList)
{
LogUtil.info("加载到Balser相机:" + name);
}
}
public static Bitmap GetCamerImage(string cameraName)
{
Bitmap bitm = null;
//若未加载到相机,需要重新加载相机
if (balserNameList.Count <= 0 && hikNameList.Count <= 0)
{
LogUtil.error("获取图片时发现未加载到相机,重新加载相机");
LoadCamera();
}
if (balserNameList.Contains(cameraName))
{
BaslerCamera.Instance.Open(cameraName);
......@@ -78,7 +87,7 @@ namespace OnlineStore.DeviceLibrary
bitm = BaslerCamera.Instance.Image;
BaslerCamera.Instance.Close();
}
else if(hikNameList.Contains(cameraName))
else if (hikNameList.Contains(cameraName))
{
HIKCamera.Instance.Open(cameraName);
HIKCamera.Instance.GrabOne();
......@@ -87,10 +96,11 @@ namespace OnlineStore.DeviceLibrary
}
else
{
LogUtil.info("未找到摄像机【"+cameraName+"】无法获取图片");
LogUtil.info("未找到摄像机【" + cameraName + "】无法获取图片");
}
return bitm;
}
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan()
{
......@@ -101,14 +111,18 @@ namespace OnlineStore.DeviceLibrary
{
foreach (string cameraName in cameraNameList)
{
Bitmap bitmap = GetCamerImage(cameraName);
if (bitmap == null)
{
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败");
}
else
using (Bitmap bitmap = GetCamerImage(cameraName))
{
if (bitmap == null)
{
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败");
continue;
}
LogUtil.debug(" 摄像机【" + cameraName + "】获取图片完成");
System.Threading.Thread.Sleep(1);
HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
LogUtil.debug(" 摄像机【" + cameraName + "】转换图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
......@@ -121,10 +135,10 @@ namespace OnlineStore.DeviceLibrary
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
//LogUtil.info(" 摄像机【" + cameraName + "】【"+ codeType + "】扫码完成");
allCodeList.AddRange(cc);
}
allCodeList.AddRange(cc);
}
bitmap.Dispose();
}
}
catch (AccessViolationException e)
......@@ -142,7 +156,7 @@ namespace OnlineStore.DeviceLibrary
}
return codeList;
}
public static string GetCodeParamFilePath(string codePath)
{
......@@ -158,13 +172,13 @@ namespace OnlineStore.DeviceLibrary
return "";
}
}
public static string ProcessBarcode(List<string> codeList,int height)
public static string ProcessBarcode(List<string> codeList, int height)
{
// 条码前面字母去掉之后用分号分割,最后不加分号
//P; H; Q
//code = "=1+0x0-7x" + height + "=" + code;
string split = ";";
string split = ";";
string result = "";
try
{
......@@ -183,7 +197,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
result =result + split + s;
result = result + split + s;
}
}
}
......@@ -191,14 +205,15 @@ namespace OnlineStore.DeviceLibrary
{
return "=1+0x0-13x" + height + "=" + result;
}
}catch(Exception ex)
}
catch (Exception ex)
{
LogUtil.error("处理二维码出错:"+ex.ToString());
LogUtil.error("处理二维码出错:" + ex.ToString());
}
return result;
}
private static string GetCodeByStart(List<string> codeList, string start)
private static string GetCodeByStart(List<string> codeList, string start)
{
List<string> pCode = (from m in codeList where m.StartsWith(start) select m).ToList<string>();
if (pCode.Count > 0)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!