Commit 13676e4d 几米阳光

扫码修改

1 个父辈 91ea680b
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
<!--end one store config--> <!--end one store config-->
<!--摄像机名称列表配置,用#分割--> <!--摄像机名称列表配置,用#分割-->
<add key="CameraName" value="GigE:MV-CE100-30GC (00C69898483)" /> <add key="CameraName" value="GigE:MV-CE100-30GC (00C69898484)" />
<!--二维码类型列表配置,用#分割,一维码=Barcode。--> <!--二维码类型列表配置,用#分割,一维码=Barcode。-->
<add key="CodeType" value="Data Matrix ECC 200#Barcode" /> <add key="CodeType" value="Barcode" />
<!--<add key="CodeType" value="Data Matrix ECC 200"/>--> <!--<add key="CodeType" value="Data Matrix ECC 200"/>-->
<!--二维码参数文件所在路径,文件名与二维码类型名一样--> <!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="\CodeParam\" /> <add key="CodeParamPath" value="\CodeParam\" />
......
...@@ -162,6 +162,7 @@ ...@@ -162,6 +162,7 @@
this.扫码测试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.扫码测试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator();
this.学习二维码ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.学习二维码ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.扫码循环测试ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.配置信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.配置信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.轴运动配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.轴运动配置ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
...@@ -1774,55 +1775,55 @@ ...@@ -1774,55 +1775,55 @@
// 查看IOToolStripMenuItem // 查看IOToolStripMenuItem
// //
this.查看IOToolStripMenuItem.Name = "查看IOToolStripMenuItem"; this.查看IOToolStripMenuItem.Name = "查看IOToolStripMenuItem";
this.查看IOToolStripMenuItem.Size = new System.Drawing.Size(175, 26); this.查看IOToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.查看IOToolStripMenuItem.Text = "查看IO"; this.查看IOToolStripMenuItem.Text = "查看IO";
this.查看IOToolStripMenuItem.Click += new System.EventHandler(this.查看IOToolStripMenuItem_Click); this.查看IOToolStripMenuItem.Click += new System.EventHandler(this.查看IOToolStripMenuItem_Click);
// //
// toolStripSeparator5 // toolStripSeparator5
// //
this.toolStripSeparator5.Name = "toolStripSeparator5"; this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(172, 6); this.toolStripSeparator5.Size = new System.Drawing.Size(177, 6);
// //
// 料仓运转ONToolStripMenuItem // 料仓运转ONToolStripMenuItem
// //
this.料仓运转ONToolStripMenuItem.Name = "料仓运转ONToolStripMenuItem"; this.料仓运转ONToolStripMenuItem.Name = "料仓运转ONToolStripMenuItem";
this.料仓运转ONToolStripMenuItem.Size = new System.Drawing.Size(175, 26); this.料仓运转ONToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.料仓运转ONToolStripMenuItem.Text = "料仓运转ON"; this.料仓运转ONToolStripMenuItem.Text = "料仓运转ON";
this.料仓运转ONToolStripMenuItem.Click += new System.EventHandler(this.料仓运转ONToolStripMenuItem_Click); this.料仓运转ONToolStripMenuItem.Click += new System.EventHandler(this.料仓运转ONToolStripMenuItem_Click);
// //
// toolStripSeparator6 // toolStripSeparator6
// //
this.toolStripSeparator6.Name = "toolStripSeparator6"; this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(172, 6); this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6);
// //
// 料仓运转OFFToolStripMenuItem // 料仓运转OFFToolStripMenuItem
// //
this.料仓运转OFFToolStripMenuItem.Name = "料仓运转OFFToolStripMenuItem"; this.料仓运转OFFToolStripMenuItem.Name = "料仓运转OFFToolStripMenuItem";
this.料仓运转OFFToolStripMenuItem.Size = new System.Drawing.Size(175, 26); this.料仓运转OFFToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.料仓运转OFFToolStripMenuItem.Text = "料仓运转OFF"; this.料仓运转OFFToolStripMenuItem.Text = "料仓运转OFF";
this.料仓运转OFFToolStripMenuItem.Click += new System.EventHandler(this.料仓运转OFFToolStripMenuItem_Click); this.料仓运转OFFToolStripMenuItem.Click += new System.EventHandler(this.料仓运转OFFToolStripMenuItem_Click);
// //
// toolStripSeparator7 // toolStripSeparator7
// //
this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(172, 6); this.toolStripSeparator7.Size = new System.Drawing.Size(177, 6);
// //
// 打开舱门ToolStripMenuItem // 打开舱门ToolStripMenuItem
// //
this.打开舱门ToolStripMenuItem.Name = "打开舱门ToolStripMenuItem"; this.打开舱门ToolStripMenuItem.Name = "打开舱门ToolStripMenuItem";
this.打开舱门ToolStripMenuItem.Size = new System.Drawing.Size(175, 26); this.打开舱门ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.打开舱门ToolStripMenuItem.Text = "打开仓门"; this.打开舱门ToolStripMenuItem.Text = "打开仓门";
this.打开舱门ToolStripMenuItem.Click += new System.EventHandler(this.打开舱门ToolStripMenuItem_Click); this.打开舱门ToolStripMenuItem.Click += new System.EventHandler(this.打开舱门ToolStripMenuItem_Click);
// //
// toolStripSeparator8 // toolStripSeparator8
// //
this.toolStripSeparator8.Name = "toolStripSeparator8"; this.toolStripSeparator8.Name = "toolStripSeparator8";
this.toolStripSeparator8.Size = new System.Drawing.Size(172, 6); this.toolStripSeparator8.Size = new System.Drawing.Size(177, 6);
// //
// 关闭仓门ToolStripMenuItem // 关闭仓门ToolStripMenuItem
// //
this.关闭仓门ToolStripMenuItem.Name = "关闭仓门ToolStripMenuItem"; this.关闭仓门ToolStripMenuItem.Name = "关闭仓门ToolStripMenuItem";
this.关闭仓门ToolStripMenuItem.Size = new System.Drawing.Size(175, 26); this.关闭仓门ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.关闭仓门ToolStripMenuItem.Text = "关闭仓门"; this.关闭仓门ToolStripMenuItem.Text = "关闭仓门";
this.关闭仓门ToolStripMenuItem.Click += new System.EventHandler(this.关闭仓门ToolStripMenuItem_Click); this.关闭仓门ToolStripMenuItem.Click += new System.EventHandler(this.关闭仓门ToolStripMenuItem_Click);
// //
...@@ -1833,7 +1834,8 @@ ...@@ -1833,7 +1834,8 @@
this.toolStripSeparator9, this.toolStripSeparator9,
this.扫码测试ToolStripMenuItem, this.扫码测试ToolStripMenuItem,
this.toolStripSeparator10, this.toolStripSeparator10,
this.学习二维码ToolStripMenuItem}); this.学习二维码ToolStripMenuItem,
this.扫码循环测试ToolStripMenuItem});
this.设备调试ToolStripMenuItem.Name = "设备调试ToolStripMenuItem"; this.设备调试ToolStripMenuItem.Name = "设备调试ToolStripMenuItem";
this.设备调试ToolStripMenuItem.Size = new System.Drawing.Size(86, 25); this.设备调试ToolStripMenuItem.Size = new System.Drawing.Size(86, 25);
this.设备调试ToolStripMenuItem.Text = "设备调试"; this.设备调试ToolStripMenuItem.Text = "设备调试";
...@@ -1841,34 +1843,42 @@ ...@@ -1841,34 +1843,42 @@
// 轴卡点动ToolStripMenuItem // 轴卡点动ToolStripMenuItem
// //
this.轴卡点动ToolStripMenuItem.Name = "轴卡点动ToolStripMenuItem"; this.轴卡点动ToolStripMenuItem.Name = "轴卡点动ToolStripMenuItem";
this.轴卡点动ToolStripMenuItem.Size = new System.Drawing.Size(160, 26); this.轴卡点动ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.轴卡点动ToolStripMenuItem.Text = "轴卡点动"; this.轴卡点动ToolStripMenuItem.Text = "轴卡点动";
this.轴卡点动ToolStripMenuItem.Click += new System.EventHandler(this.轴卡点动ToolStripMenuItem_Click); this.轴卡点动ToolStripMenuItem.Click += new System.EventHandler(this.轴卡点动ToolStripMenuItem_Click);
// //
// toolStripSeparator9 // toolStripSeparator9
// //
this.toolStripSeparator9.Name = "toolStripSeparator9"; this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(157, 6); this.toolStripSeparator9.Size = new System.Drawing.Size(177, 6);
// //
// 扫码测试ToolStripMenuItem // 扫码测试ToolStripMenuItem
// //
this.扫码测试ToolStripMenuItem.Name = "扫码测试ToolStripMenuItem"; this.扫码测试ToolStripMenuItem.Name = "扫码测试ToolStripMenuItem";
this.扫码测试ToolStripMenuItem.Size = new System.Drawing.Size(160, 26); this.扫码测试ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.扫码测试ToolStripMenuItem.Text = "扫码测试"; this.扫码测试ToolStripMenuItem.Text = "扫码测试";
this.扫码测试ToolStripMenuItem.Click += new System.EventHandler(this.扫码测试ToolStripMenuItem_Click); this.扫码测试ToolStripMenuItem.Click += new System.EventHandler(this.扫码测试ToolStripMenuItem_Click);
// //
// toolStripSeparator10 // toolStripSeparator10
// //
this.toolStripSeparator10.Name = "toolStripSeparator10"; this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(157, 6); this.toolStripSeparator10.Size = new System.Drawing.Size(177, 6);
// //
// 学习二维码ToolStripMenuItem // 学习二维码ToolStripMenuItem
// //
this.学习二维码ToolStripMenuItem.Name = "学习二维码ToolStripMenuItem"; this.学习二维码ToolStripMenuItem.Name = "学习二维码ToolStripMenuItem";
this.学习二维码ToolStripMenuItem.Size = new System.Drawing.Size(160, 26); this.学习二维码ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.学习二维码ToolStripMenuItem.Text = "学习二维码"; this.学习二维码ToolStripMenuItem.Text = "学习二维码";
this.学习二维码ToolStripMenuItem.Click += new System.EventHandler(this.学习二维码ToolStripMenuItem_Click); this.学习二维码ToolStripMenuItem.Click += new System.EventHandler(this.学习二维码ToolStripMenuItem_Click);
// //
// 扫码循环测试ToolStripMenuItem
//
this.扫码循环测试ToolStripMenuItem.Name = "扫码循环测试ToolStripMenuItem";
this.扫码循环测试ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.扫码循环测试ToolStripMenuItem.Text = "开始循环扫码";
this.扫码循环测试ToolStripMenuItem.Visible = false;
this.扫码循环测试ToolStripMenuItem.Click += new System.EventHandler(this.扫码循环测试ToolStripMenuItem_Click);
//
// 配置信息ToolStripMenuItem // 配置信息ToolStripMenuItem
// //
this.配置信息ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.配置信息ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
...@@ -2428,6 +2438,7 @@ ...@@ -2428,6 +2438,7 @@
private System.Windows.Forms.ComboBox comboBoxPortName; private System.Windows.Forms.ComboBox comboBoxPortName;
private System.Windows.Forms.Label lblShuoKeMsg; private System.Windows.Forms.Label lblShuoKeMsg;
private System.Windows.Forms.CheckBox chbOnlyOut; private System.Windows.Forms.CheckBox chbOnlyOut;
private System.Windows.Forms.ToolStripMenuItem 扫码循环测试ToolStripMenuItem;
} }
} }
...@@ -1365,5 +1365,59 @@ namespace OnlineStore.ACSingleStore ...@@ -1365,5 +1365,59 @@ namespace OnlineStore.ACSingleStore
{ {
} }
private System.Timers.Timer scanTimer = new System.Timers.Timer();
private int count = 0;
private void 扫码循环测试ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (扫码循环测试ToolStripMenuItem.Text.Equals("开始循环扫码"))
{
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.HIGH);
count = 0;
scanTimer.Interval =3000;
scanTimer.AutoReset = true;
scanTimer.Elapsed += ScanTimer_Elapsed;
scanTimer.Start();
扫码循环测试ToolStripMenuItem.Text = "停止循环扫码";
LogUtil.info("开始循环扫码");
}
else
{
store.KNDIOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
scanTimer.Stop();
扫码循环测试ToolStripMenuItem.Text = "开始循环扫码";
LogUtil.info("停止循环扫码");
}
}
private object ScanLock = "";
private void ScanTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (Monitor.TryEnter(ScanLock))
{
try
{
count++;
string message = "";
List<string> codeList = CodeManager.CameraScan();
foreach (string str in codeList)
{
message = message + str + "##";
}
LogUtil.info("第【" + count + "】次扫码测试 :" + message);
}
catch (Exception ex)
{
LogUtil.error("扫码测试错误:" + ex.ToString());
}
finally
{
Monitor.Exit(ScanLock);
}
}
else
{
LogUtil.info("扫码测试未得到锁");
}
}
} }
} }
...@@ -100,7 +100,7 @@ namespace OnlineStore.Common ...@@ -100,7 +100,7 @@ namespace OnlineStore.Common
} }
public static void error(ILog log, string errorMsg) public static void error(ILog log, string errorMsg)
{ {
if (!lasErrorLogList.Contains(errorMsg)) //if (!lasErrorLogList.Contains(errorMsg))
{ {
log.Error(log.Logger.Name + " - " + errorMsg); log.Error(log.Logger.Name + " - " + errorMsg);
if (logBox == null) if (logBox == null)
...@@ -109,11 +109,11 @@ namespace OnlineStore.Common ...@@ -109,11 +109,11 @@ namespace OnlineStore.Common
} }
AddToBox(errorMsg, Color.Red); AddToBox(errorMsg, Color.Red);
} }
lasErrorLogList.Add(errorMsg); //lasErrorLogList.Add(errorMsg);
if (lasErrorLogList.Count > errCount) //if (lasErrorLogList.Count > errCount)
{ //{
lasErrorLogList.RemoveAt(0); // lasErrorLogList.RemoveAt(0);
} //}
} }
private static void AddToBox(string msg, Color color) private static void AddToBox(string msg, Color color)
{ {
......
...@@ -123,28 +123,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -123,28 +123,16 @@ namespace OnlineStore.DeviceLibrary
{ {
foreach (string cameraName in cameraNameList) foreach (string cameraName in cameraNameList)
{ {
Bitmap bitmap = GetCamerImage(cameraName); using (Bitmap bitmap = GetCamerImage(cameraName))
{
if (bitmap == null) if (bitmap == null)
{ {
LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败"); LogUtil.info(" 摄像机【" + cameraName + "】获取图片失败");
continue;
} }
else
{
LogUtil.info(" 摄像机【" + cameraName + "】获取图片完成"); LogUtil.info(" 摄像机【" + cameraName + "】获取图片完成");
//string path = Application.StartupPath + @"\CodeImage\"; System.Threading.Thread.Sleep(1);
//string filePath = path + @"code.png";
//if (File.Exists(filePath))
//{
// File.Delete(filePath);
//}
//if (!Directory.Exists(path))
//{
// Directory.CreateDirectory(path);
//}
//bitmap.Save(filePath);
//LogUtil.info(" 摄像机【" + cameraName + "】图片已保存到:"+filePath);
HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap); HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
LogUtil.info(" 摄像机【" + cameraName + "】转换图片完成,开始扫码"); LogUtil.info(" 摄像机【" + cameraName + "】转换图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>(); List<CodeInfo> cc = new List<CodeInfo>();
...@@ -159,7 +147,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -159,7 +147,7 @@ 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 + "】扫码完成"); //LogUtil.info(" 摄像机【" + cameraName + "】【"+ codeType + "】扫码完成");
} }
allCodeList.AddRange(cc); allCodeList.AddRange(cc);
} }
...@@ -168,6 +156,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -168,6 +156,7 @@ namespace OnlineStore.DeviceLibrary
catch (AccessViolationException e) catch (AccessViolationException e)
{ {
LogUtil.error("扫码出现AccessViolationException异常:" + e.ToString()); LogUtil.error("扫码出现AccessViolationException异常:" + e.ToString());
GC.Collect();
} }
catch (Exception ex) catch (Exception ex)
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!