Commit 6d2f5ddc LN

二维码更新

1 个父辈 8eb82344
此文件类型无法预览
......@@ -25,7 +25,7 @@ namespace OnlineStore.AutoInOutStore
private ConfigMoveAxis inout = null;
private ConfigMoveAxis auto = null;
private ConfigMoveAxis comp = null;
private int compress_Slv = 0;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmAxisDebug(AC_SA_BoxBean boxBean)
......@@ -52,7 +52,7 @@ namespace OnlineStore.AutoInOutStore
txtInOutSpeed.Text = (inout.TargetSpeed / 5).ToString();
txtUpDownSpeed.Text = (updown.TargetSpeed / 5).ToString();
txtAutoSpeed.Text = (auto.TargetSpeed / 5).ToString();
txtComSpeed.Text = (comp.TargetSpeed/2).ToString();
txtComSpeed.Text = (comp.TargetSpeed/5).ToString();
//timer1.Start();
UpdateMiddlePosition();
UpdateInOutPosition();
......@@ -469,6 +469,7 @@ namespace OnlineStore.AutoInOutStore
UpdateInOutPosition();
UpdateUpdownPosition();
UpdateAutoPosition();
UpdateCompPosition();
// txtComPosition.Text = ShuoKeControls.GetABSPosition(compress_Slv).ToString();
}
}
......
......@@ -493,7 +493,7 @@
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(765, 672);
this.button1.Location = new System.Drawing.Point(761, 672);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(115, 34);
this.button1.TabIndex = 254;
......@@ -508,7 +508,7 @@
this.chbAutoRead.Checked = true;
this.chbAutoRead.CheckState = System.Windows.Forms.CheckState.Checked;
this.chbAutoRead.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAutoRead.Location = new System.Drawing.Point(641, 677);
this.chbAutoRead.Location = new System.Drawing.Point(637, 677);
this.chbAutoRead.Name = "chbAutoRead";
this.chbAutoRead.Size = new System.Drawing.Size(75, 21);
this.chbAutoRead.TabIndex = 244;
......@@ -573,7 +573,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(971, 721);
this.ClientSize = new System.Drawing.Size(967, 721);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox4);
......
......@@ -93,5 +93,7 @@ namespace OnlineStore.Common
/// 单盘入库默认PosID
/// </summary>
public static string SinglePosId = "SinglePosId";
public static string DeCodeType = "DeCodeType";
}
}
using CodeLibrary;
using HalconDotNet;

using OnlineStore.Common;
using System;
using System.Collections.Generic;
......@@ -9,12 +8,13 @@ using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Windows.Forms;
using CodeLibrary;
namespace OnlineStore.DeviceLibrary
{
public class CodeManager
public class CodeManager
{
public static int DeCodeType = ConfigAppSettings.GetIntValue(Setting_Init.DeCodeType);
public static List<string> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>();
......@@ -31,8 +31,9 @@ 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)
{
......@@ -46,14 +47,14 @@ namespace OnlineStore.DeviceLibrary
codeTypeList.Add(str.Trim());
}
LoadCamera(false );
LoadCamera(false);
CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
}
}
}
private static void LoadCamera(bool isReLoad)
{
......@@ -75,42 +76,78 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info("加载到Balser相机:" + name);
}
}
public static void CloseCamera()
{
BaslerCamera.Instance.Close();
HIKCamera.Instance.Close();
}
public static Bitmap GetCamerImage(string cameraName)
{
Bitmap bitm = null;
if (balserNameList.Contains(cameraName))
{
BaslerCamera.Instance.Open(cameraName);
BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image;
BaslerCamera.Instance.Close();
}
else if (hikNameList.Contains(cameraName))
{
HIKCamera.Instance.Open(cameraName);
HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image;
HIKCamera.Instance.Close();
}
else
try
{
LogUtil.info("未找到摄像机【" + cameraName + "】无法获取图片");
//若未加载到相机,需要重新加载相机
if (balserNameList.Count <= 0 && hikNameList.Count <= 0)
if (balserNameList.Contains(cameraName))
{
bool result = BaslerCamera.Instance.IsOpen;
if (!result)
{
result = BaslerCamera.Instance.Open(cameraName);
LogUtil.info("打开相机:" + cameraName + "(" + result + ")");
}
if (result)
{
BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image;
//BaslerCamera.Instance.Close();
}
else
{
LogUtil.error("相机【" + cameraName + "】打开失败:" + BaslerCamera.Instance.ErrInfo);
}
}
else if (hikNameList.Contains(cameraName))
{
bool result = HIKCamera.Instance.IsOpen;
if (!result)
{
result = HIKCamera.Instance.Open(cameraName);
LogUtil.info("打开相机:" + cameraName + "(" + result + ")");
}
if (result)
{
HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image;
//HIKCamera.Instance.Close();
}
else
{
LogUtil.error("相机【" + cameraName + "】打开失败:" + HIKCamera.Instance.ErrInfo);
}
}
else
{
LogUtil.error("获取图片时发现未加载到相机,重新加载相机");
LoadCamera(true);
LogUtil.info("未找到相机【" + cameraName + "】无法获取图片");
//若未加载到相机,需要重新加载相机
if (balserNameList.Count <= 0 && hikNameList.Count <= 0)
{
LogUtil.error("获取图片时发现未加载到相机,重新加载相机");
LoadCamera(true);
}
}
}
catch (Exception ex)
{
LogUtil.error("从相机【" + cameraName + "】获取图片出错:" + ex.ToString());
}
return bitm;
}
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan()
{
List<string> codeList = new List<string>();
List<CodeInfo> allCodeList = new List<CodeInfo>();
//List<CodeInfo> allCodeList = new List<CodeInfo>();
try
{
......@@ -120,28 +157,45 @@ namespace OnlineStore.DeviceLibrary
{
if (bitmap == null)
{
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败");
LogUtil.error(" 摄像机【" + cameraName + "】获取图片失败,关闭相机");
CloseCamera();
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)
if (DeCodeType.Equals(0))
{
//判断是否是一维码
if (codeType.ToLower().Equals("barcode"))
{
cc = HDCodeHelper.DecodeBarCode(ho_Image);
}
else
HalconDotNet.HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
LogUtil.debug(" 摄像机【" + cameraName + "】转换图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList)
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
//判断是否是一维码
if (codeType.ToLower().Equals("barcode"))
{
cc = HDCodeHelper.DecodeBarCode(ho_Image);
}
else
{
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
}
if (cc.Count > 0)
{
string r = "";
foreach (CodeInfo c in cc)
{
codeList.Add(c.CodeStr);
r = r + "##" + c.CodeStr;
}
LogUtil.info(" 【" + cameraName + "】【" + codeType + "】扫码完成:" + r);
}
}
//LogUtil.info(" 摄像机【" + cameraName + "】【"+ codeType + "】扫码完成");
allCodeList.AddRange(cc);
}
else
{
List<string> result = CodeLibrary.ZXingCodeHelper.DecodeQRCodes(bitmap);
return result;
}
}
}
......@@ -155,10 +209,6 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.error("扫码出错:" + ex.ToString());
}
foreach (CodeInfo info in allCodeList)
{
codeList.Add(info.CodeStr);
}
return codeList;
}
......@@ -177,6 +227,5 @@ namespace OnlineStore.DeviceLibrary
return "";
}
}
}
}
......@@ -1058,6 +1058,11 @@ namespace OnlineStore.LoadCSVLibrary
Config.InOut_Axis.DefaultPosition = Config.InOutAxis_P1_Position;
Config.UpDown_Axis.DefaultPosition = Config.UpDownAxis_Door_P7;
Config.Comp_Axis.DefaultPosition = Config.CompressAxis_P1_Position;
Config.Comp_Axis.CanErrorCountMax = 1000;
Config.Comp_Axis.CanErrorCountMin = 10;
Config.Comp_Axis.PositionMin = 0;
Config.Comp_Axis.PositionMax = 0;
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!