Commit ed527de1 LN

成都料仓条码解析修改

1 个父辈 33be90da
此文件类型无法预览
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<!--流水线地址和端口配置--> <!--流水线地址和端口配置-->
<add key="LineServerIp" value="192.168.200.69"/> <add key="LineServerIp" value="192.168.200.69"/>
<add key="LineServerPort" value="1234"/> <add key="LineServerPort" value="1234"/>
<!--解码方式,0=halcon 解码,1=使用zxing解码--> <!--解码方式,0=halcon 解码,1=西安料仓 使用zxing解码,2=成都料仓-->
<add key="DeCodeType" value="1"/> <add key="DeCodeType" value="1"/>
<add key ="DefaultPWD" value ="123456"/> <add key ="DefaultPWD" value ="123456"/>
</appSettings> </appSettings>
......
...@@ -83,3 +83,6 @@ PRO,特殊二维码尺寸配置,CodeSizeConfig,XA=13x48#XB=13x32#FA=7x32,,,,,,, ...@@ -83,3 +83,6 @@ PRO,特殊二维码尺寸配置,CodeSizeConfig,XA=13x48#XB=13x32#FA=7x32,,,,,,,
20190920修改: 20190920修改:
1.密码默认值改为配置值。 1.密码默认值改为配置值。
2.相机名称 未配置时可以自动默认配置。 2.相机名称 未配置时可以自动默认配置。
DeCodeType=解码类型,0=halcon,1=zxing解码 西安料仓解析方式。2=成都料仓 PN;RI;
\ No newline at end of file \ No newline at end of file
...@@ -86,7 +86,7 @@ namespace OnlineStore.Common ...@@ -86,7 +86,7 @@ namespace OnlineStore.Common
public static string HumitureControllerType = "HumitureControllerType"; public static string HumitureControllerType = "HumitureControllerType";
/// <summary> /// <summary>
/// 解码类型,0=halcon,1=zxing解码 /// 解码类型,0=halcon,1=zxing解码 西安料仓解析方式。2=成都料仓 PN;RI;
/// </summary> /// </summary>
public static string DeCodeType = "DeCodeType"; public static string DeCodeType = "DeCodeType";
public static string DefaultPWD = "DefaultPWD"; public static string DefaultPWD = "DefaultPWD";
......
...@@ -1495,8 +1495,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -1495,8 +1495,9 @@ namespace OnlineStore.DeviceLibrary
DateTime date = DateTime.Now; DateTime date = DateTime.Now;
//scanTimer.Enabled = false; //scanTimer.Enabled = false;
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH); KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
string outMsg = ""; // string outMsg = "";
string message = ""; string message = "";
bool hasSpecialCode = false;
List<string> codeList = CodeManager.CameraScan(); List<string> codeList = CodeManager.CameraScan();
if (codeList.Count <= 0) if (codeList.Count <= 0)
{ {
...@@ -1514,18 +1515,25 @@ namespace OnlineStore.DeviceLibrary ...@@ -1514,18 +1515,25 @@ namespace OnlineStore.DeviceLibrary
//无固定尺寸,判断宽度是否是固定,如果不是固定,直接获取当前高度宽度 //无固定尺寸,判断宽度是否是固定,如果不是固定,直接获取当前高度宽度
codeSize = GetSize() + "x" + GetHeight(); codeSize = GetSize() + "x" + GetHeight();
} }
else
{
hasSpecialCode = true;
}
if (str.Trim().ToUpper().StartsWith("XA"))//西安料仓 if (str.Trim().ToUpper().StartsWith("XA"))//西安料仓
{ {
hasSpecialCode = true;
code = "=1+0x0-13x48" + "=" + str.Trim(); code = "=1+0x0-13x48" + "=" + str.Trim();
} }
else if (str.Trim().ToUpper().StartsWith("XB"))//西安料仓 else if (str.Trim().ToUpper().StartsWith("XB"))//西安料仓
{ {
hasSpecialCode = true;
code = "=1+0x0-13x32" + "=" + str.Trim(); code = "=1+0x0-13x32" + "=" + str.Trim();
} }
else if (str.ToUpper().StartsWith("FA"))//孝感料仓 else if (str.ToUpper().StartsWith("FA"))//孝感料仓
{ {
code = "=1+0x0-7x32" + "=" + code; hasSpecialCode = true;
code = "=1+0x0-7x32" + "=" + str.Trim();
} }
if (CodeManager.DeCodeType.Equals(1)) if (CodeManager.DeCodeType.Equals(1))
{ {
...@@ -1542,19 +1550,28 @@ namespace OnlineStore.DeviceLibrary ...@@ -1542,19 +1550,28 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
code = "=1+0x0-" + codeSize + "=" + code; code = "=1+0x0-" + codeSize + "=" + str.Trim();
} }
if (!String.IsNullOrEmpty(code)) if (!String.IsNullOrEmpty(code))
{ {
message = message + code + spiltStr; message = message + code + spiltStr;
} }
} }
if (!outMsg.Equals("")) //成都料仓条码处理
if ((!hasSpecialCode) && CodeManager.DeCodeType.Equals(2) && codeList.Count > 0)
{
string code = CodeManager.ProcessChengDuCode(codeList);
if (!String.IsNullOrEmpty(code))
{ {
CodeMsg = "盘尺寸错误,清理二维码【" + message + "】"; message = "=1+0x0-" + GetSize() + "x" + GetHeight() + "=" + code;
LogUtil.error("盘尺寸错误,清理二维码【" + message + "】"); }
message = "";
} }
//if (!outMsg.Equals(""))
//{
// CodeMsg = "盘尺寸错误,清理二维码【" + message + "】";
// LogUtil.error("盘尺寸错误,清理二维码【" + message + "】");
// message = "";
//}
KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW); KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
onCodeReceived(message); onCodeReceived(message);
......
...@@ -74,29 +74,51 @@ namespace OnlineStore.DeviceLibrary ...@@ -74,29 +74,51 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("解析摄像机配置出错:" + ex.ToString()); LogUtil.error("解析摄像机配置出错:" + ex.StackTrace);
} }
} }
private static void LoadCamera(bool isReLoad) private static void LoadCamera(bool isReLoad)
{ {
if (isReLoad) if (isReLoad)
{ {
try
{
CodeLibrary.HIKCamera.Instance.Load(); CodeLibrary.HIKCamera.Instance.Load();
}
catch (Exception ex)
{
LogUtil.error("加载HIK相机出错:" + ex.ToString());
}
try
{
CodeLibrary.BaslerCamera.Instance.Load(); CodeLibrary.BaslerCamera.Instance.Load();
} }
catch (Exception ex)
{
LogUtil.error("加载Basler相机出错:" + ex.ToString());
}
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName; string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
if (names != null)
{
hikNameList.AddRange(names); hikNameList.AddRange(names);
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
foreach (string name in hikNameList) foreach (string name in hikNameList)
{ {
LogUtil.info("加载到HIK相机:" + name); LogUtil.info("加载到HIK相机:" + name);
} }
}
names = CodeLibrary.BaslerCamera.Instance.CameraName;
if (names != null)
{
balserNameList.AddRange(names);
foreach (string name in balserNameList) foreach (string name in balserNameList)
{ {
LogUtil.info("加载到Balser相机:" + name); LogUtil.info("加载到Balser相机:" + name);
} }
} }
}
public static void CloseCamera() public static void CloseCamera()
{ {
BaslerCamera.Instance.Close(); BaslerCamera.Instance.Close();
...@@ -248,6 +270,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -248,6 +270,9 @@ namespace OnlineStore.DeviceLibrary
return ""; return "";
} }
} }
/// <summary>
/// 西安料仓二维码解析处理
/// </summary>
public static string GetBarcode(string codeStr) public static string GetBarcode(string codeStr)
{ {
if (!string.IsNullOrEmpty(codeStr)) if (!string.IsNullOrEmpty(codeStr))
...@@ -280,5 +305,51 @@ namespace OnlineStore.DeviceLibrary ...@@ -280,5 +305,51 @@ namespace OnlineStore.DeviceLibrary
} }
return ""; return "";
} }
public static string ProcessChengDuCode(List<string> codeList)
{
string split = ";";
string result = "";
try
{
List<string> rCodes = new List<string>();
rCodes.Add(GetCodeByStart(codeList, "RI"));
rCodes.Add(GetCodeByStart(codeList, "PN"));
//P条码改为 P;H;Q或者 D;H;Q的格式
foreach (string s in rCodes)
{
if (!s.Equals(""))
{
if (result.Equals(""))
{
result = s;
}
else
{
result = result + split + s;
}
}
}
return result;
}
catch (Exception ex)
{
LogUtil.error("处理二维码出错:" + ex.ToString());
}
return result;
}
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)
{
return pCode[0].Substring(1, pCode[0].Length - 1);
}
return "";
}
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!