Commit 6d2f5ddc LN

二维码更新

1 个父辈 8eb82344
此文件类型无法预览
...@@ -25,7 +25,7 @@ namespace OnlineStore.AutoInOutStore ...@@ -25,7 +25,7 @@ namespace OnlineStore.AutoInOutStore
private ConfigMoveAxis inout = null; private ConfigMoveAxis inout = null;
private ConfigMoveAxis auto = null; private ConfigMoveAxis auto = null;
private ConfigMoveAxis comp = null; private ConfigMoveAxis comp = null;
private int compress_Slv = 0;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmAxisDebug(AC_SA_BoxBean boxBean) public FrmAxisDebug(AC_SA_BoxBean boxBean)
...@@ -52,7 +52,7 @@ namespace OnlineStore.AutoInOutStore ...@@ -52,7 +52,7 @@ namespace OnlineStore.AutoInOutStore
txtInOutSpeed.Text = (inout.TargetSpeed / 5).ToString(); txtInOutSpeed.Text = (inout.TargetSpeed / 5).ToString();
txtUpDownSpeed.Text = (updown.TargetSpeed / 5).ToString(); txtUpDownSpeed.Text = (updown.TargetSpeed / 5).ToString();
txtAutoSpeed.Text = (auto.TargetSpeed / 5).ToString(); txtAutoSpeed.Text = (auto.TargetSpeed / 5).ToString();
txtComSpeed.Text = (comp.TargetSpeed/2).ToString(); txtComSpeed.Text = (comp.TargetSpeed/5).ToString();
//timer1.Start(); //timer1.Start();
UpdateMiddlePosition(); UpdateMiddlePosition();
UpdateInOutPosition(); UpdateInOutPosition();
...@@ -469,6 +469,7 @@ namespace OnlineStore.AutoInOutStore ...@@ -469,6 +469,7 @@ namespace OnlineStore.AutoInOutStore
UpdateInOutPosition(); UpdateInOutPosition();
UpdateUpdownPosition(); UpdateUpdownPosition();
UpdateAutoPosition(); UpdateAutoPosition();
UpdateCompPosition();
// txtComPosition.Text = ShuoKeControls.GetABSPosition(compress_Slv).ToString(); // txtComPosition.Text = ShuoKeControls.GetABSPosition(compress_Slv).ToString();
} }
} }
......
...@@ -493,7 +493,7 @@ ...@@ -493,7 +493,7 @@
// button1 // button1
// //
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.Name = "button1";
this.button1.Size = new System.Drawing.Size(115, 34); this.button1.Size = new System.Drawing.Size(115, 34);
this.button1.TabIndex = 254; this.button1.TabIndex = 254;
...@@ -508,7 +508,7 @@ ...@@ -508,7 +508,7 @@
this.chbAutoRead.Checked = true; this.chbAutoRead.Checked = true;
this.chbAutoRead.CheckState = System.Windows.Forms.CheckState.Checked; 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.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.Name = "chbAutoRead";
this.chbAutoRead.Size = new System.Drawing.Size(75, 21); this.chbAutoRead.Size = new System.Drawing.Size(75, 21);
this.chbAutoRead.TabIndex = 244; this.chbAutoRead.TabIndex = 244;
...@@ -573,7 +573,7 @@ ...@@ -573,7 +573,7 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.button1);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox4);
......
...@@ -93,5 +93,7 @@ namespace OnlineStore.Common ...@@ -93,5 +93,7 @@ namespace OnlineStore.Common
/// 单盘入库默认PosID /// 单盘入库默认PosID
/// </summary> /// </summary>
public static string SinglePosId = "SinglePosId"; public static string SinglePosId = "SinglePosId";
public static string DeCodeType = "DeCodeType";
} }
} }
using CodeLibrary; 
using HalconDotNet;
using OnlineStore.Common; using OnlineStore.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -9,11 +8,12 @@ using System.Linq; ...@@ -9,11 +8,12 @@ using System.Linq;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using CodeLibrary;
namespace OnlineStore.DeviceLibrary 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> cameraNameList = new List<string>();
public static List<string> codeTypeList = new List<string>(); public static List<string> codeTypeList = new List<string>();
...@@ -31,6 +31,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -31,6 +31,7 @@ namespace OnlineStore.DeviceLibrary
{ {
cameraNameList = new List<string>(); cameraNameList = new List<string>();
codeTypeList = new List<string>(); codeTypeList = new List<string>();
HDLogUtil.LogName = "RollingLogFileAppender";
try try
{ {
string[] nameArray = nameStr.Split(spiltChar); string[] nameArray = nameStr.Split(spiltChar);
...@@ -46,9 +47,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -46,9 +47,9 @@ namespace OnlineStore.DeviceLibrary
codeTypeList.Add(str.Trim()); codeTypeList.Add(str.Trim());
} }
LoadCamera(false ); LoadCamera(false);
CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr); CodeLibrary.HDCodeLearnHelper.LoadConfig(nameStr, codeStr);
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -75,28 +76,58 @@ namespace OnlineStore.DeviceLibrary ...@@ -75,28 +76,58 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info("加载到Balser相机:" + name); LogUtil.info("加载到Balser相机:" + name);
} }
} }
public static void CloseCamera()
{
BaslerCamera.Instance.Close();
HIKCamera.Instance.Close();
}
public static Bitmap GetCamerImage(string cameraName) public static Bitmap GetCamerImage(string cameraName)
{ {
Bitmap bitm = null; Bitmap bitm = null;
try
{
if (balserNameList.Contains(cameraName)) if (balserNameList.Contains(cameraName))
{ {
BaslerCamera.Instance.Open(cameraName); bool result = BaslerCamera.Instance.IsOpen;
if (!result)
{
result = BaslerCamera.Instance.Open(cameraName);
LogUtil.info("打开相机:" + cameraName + "(" + result + ")");
}
if (result)
{
BaslerCamera.Instance.GrabOne(); BaslerCamera.Instance.GrabOne();
bitm = BaslerCamera.Instance.Image; bitm = BaslerCamera.Instance.Image;
BaslerCamera.Instance.Close(); //BaslerCamera.Instance.Close();
}
else
{
LogUtil.error("相机【" + cameraName + "】打开失败:" + BaslerCamera.Instance.ErrInfo);
}
} }
else if (hikNameList.Contains(cameraName)) else if (hikNameList.Contains(cameraName))
{ {
HIKCamera.Instance.Open(cameraName); bool result = HIKCamera.Instance.IsOpen;
if (!result)
{
result = HIKCamera.Instance.Open(cameraName);
LogUtil.info("打开相机:" + cameraName + "(" + result + ")");
}
if (result)
{
HIKCamera.Instance.GrabOne(); HIKCamera.Instance.GrabOne();
bitm = HIKCamera.Instance.Image; bitm = HIKCamera.Instance.Image;
HIKCamera.Instance.Close(); //HIKCamera.Instance.Close();
}
else
{
LogUtil.error("相机【" + cameraName + "】打开失败:" + HIKCamera.Instance.ErrInfo);
}
} }
else else
{ {
LogUtil.info("未找到摄像机【" + cameraName + "】无法获取图片"); LogUtil.info("未找到相机【" + cameraName + "】无法获取图片");
//若未加载到相机,需要重新加载相机 //若未加载到相机,需要重新加载相机
if (balserNameList.Count <= 0 && hikNameList.Count <= 0) if (balserNameList.Count <= 0 && hikNameList.Count <= 0)
{ {
...@@ -104,13 +135,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -104,13 +135,19 @@ namespace OnlineStore.DeviceLibrary
LoadCamera(true); LoadCamera(true);
} }
} }
}
catch (Exception ex)
{
LogUtil.error("从相机【" + cameraName + "】获取图片出错:" + ex.ToString());
}
return bitm; return bitm;
} }
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan() public static List<string> CameraScan()
{ {
List<string> codeList = new List<string>(); List<string> codeList = new List<string>();
List<CodeInfo> allCodeList = new List<CodeInfo>(); //List<CodeInfo> allCodeList = new List<CodeInfo>();
try try
{ {
...@@ -120,13 +157,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -120,13 +157,16 @@ namespace OnlineStore.DeviceLibrary
{ {
if (bitmap == null) if (bitmap == null)
{ {
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败"); LogUtil.error(" 摄像机【" + cameraName + "】获取图片失败,关闭相机");
CloseCamera();
continue; continue;
} }
LogUtil.debug(" 摄像机【" + cameraName + "】获取图片完成"); LogUtil.debug(" 摄像机【" + cameraName + "】获取图片完成");
System.Threading.Thread.Sleep(1); System.Threading.Thread.Sleep(1);
HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap); if (DeCodeType.Equals(0))
{
HalconDotNet.HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
LogUtil.debug(" 摄像机【" + cameraName + "】转换图片完成,开始扫码"); LogUtil.debug(" 摄像机【" + cameraName + "】转换图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>(); List<CodeInfo> cc = new List<CodeInfo>();
foreach (string codeType in codeTypeList) foreach (string codeType in codeTypeList)
...@@ -140,8 +180,22 @@ namespace OnlineStore.DeviceLibrary ...@@ -140,8 +180,22 @@ namespace OnlineStore.DeviceLibrary
{ {
cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType); cc = HDCodeHelper.DecodeCode(ho_Image, 1, GetCodeParamFilePath(codeType), codeType);
} }
//LogUtil.info(" 摄像机【" + cameraName + "】【"+ codeType + "】扫码完成"); if (cc.Count > 0)
allCodeList.AddRange(cc); {
string r = "";
foreach (CodeInfo c in cc)
{
codeList.Add(c.CodeStr);
r = r + "##" + c.CodeStr;
}
LogUtil.info(" 【" + cameraName + "】【" + codeType + "】扫码完成:" + r);
}
}
}
else
{
List<string> result = CodeLibrary.ZXingCodeHelper.DecodeQRCodes(bitmap);
return result;
} }
} }
} }
...@@ -155,10 +209,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -155,10 +209,6 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error("扫码出错:" + ex.ToString()); LogUtil.error("扫码出错:" + ex.ToString());
} }
foreach (CodeInfo info in allCodeList)
{
codeList.Add(info.CodeStr);
}
return codeList; return codeList;
} }
...@@ -177,6 +227,5 @@ namespace OnlineStore.DeviceLibrary ...@@ -177,6 +227,5 @@ namespace OnlineStore.DeviceLibrary
return ""; return "";
} }
} }
} }
} }
...@@ -1058,6 +1058,11 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -1058,6 +1058,11 @@ namespace OnlineStore.LoadCSVLibrary
Config.InOut_Axis.DefaultPosition = Config.InOutAxis_P1_Position; Config.InOut_Axis.DefaultPosition = Config.InOutAxis_P1_Position;
Config.UpDown_Axis.DefaultPosition = Config.UpDownAxis_Door_P7; Config.UpDown_Axis.DefaultPosition = Config.UpDownAxis_Door_P7;
Config.Comp_Axis.DefaultPosition = Config.CompressAxis_P1_Position; 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!