Commit 5a451c88 夏萍

1

1 个父辈 595d6703
...@@ -368,6 +368,26 @@ namespace BLL ...@@ -368,6 +368,26 @@ namespace BLL
debounceHelper.HandleTextChanged((FaceComboBox)sender,txt); debounceHelper.HandleTextChanged((FaceComboBox)sender,txt);
} }
private Dictionary<string, string> UpdateLastKey( Dictionary<string, string> lastkey)
{
Dictionary<string, string> keyValues = new Dictionary<string, string>();
if (lastkey == null)
return null;
foreach(var temp in lastkey.Keys)
{
keyValues.Add(temp, lastkey[temp]);
if (temp.Contains(":"))
{
string date = temp.Split(':')[1];
if(int.TryParse(date, out int value)&&value==0&& int.TryParse(lastkey[temp], out int value2))
{
keyValues[temp] = value2.ToString($"D{date.Length}");
}
}
}
return keyValues;
}
private void PrintLabel(object sender, EventArgs e) private void PrintLabel(object sender, EventArgs e)
{ {
LogNet.log.Info("Enter PrintLabel Method"); LogNet.log.Info("Enter PrintLabel Method");
...@@ -383,6 +403,7 @@ namespace BLL ...@@ -383,6 +403,7 @@ namespace BLL
else else
lastkey.Add(extensions[i].Key, extensions[i].Control.Text); lastkey.Add(extensions[i].Key, extensions[i].Control.Text);
} }
lastkey= UpdateLastKey(lastkey);
LogNet.log.Info("lastkey:" + JsonConvert.SerializeObject(lastkey)); LogNet.log.Info("lastkey:" + JsonConvert.SerializeObject(lastkey));
#region 判断指定关键字是否存在内容 #region 判断指定关键字是否存在内容
List<string> strings = new List<string>(); List<string> strings = new List<string>();
......
...@@ -433,6 +433,7 @@ namespace BLL ...@@ -433,6 +433,7 @@ namespace BLL
aMatch.IsCodeUsed[j] = true; aMatch.IsCodeUsed[j] = true;
aMatch.Points= new Point((int)code[j].Center.X, (int)code[j].Center.Y); aMatch.Points= new Point((int)code[j].Center.X, (int)code[j].Center.Y);
aMatch.Angle = (int)code[j].Angle; aMatch.Angle = (int)code[j].Angle;
aMatch.CodeType = code[j].CodeType;
} }
MatchCodeIndex.Add(j); MatchCodeIndex.Add(j);
keyword.Add(key, matchKey[key]); keyword.Add(key, matchKey[key]);
...@@ -516,6 +517,7 @@ namespace BLL ...@@ -516,6 +517,7 @@ namespace BLL
//aMatch.IsCodeUsed[0] = true; //aMatch.IsCodeUsed[0] = true;
aMatch.Points = new Point((int)code[0].Center.X, (int)code[0].Center.Y); aMatch.Points = new Point((int)code[0].Center.X, (int)code[0].Center.Y);
aMatch.Angle = (int)code[0].Angle; aMatch.Angle = (int)code[0].Angle;
aMatch.CodeType = code[0].CodeType;
} }
return true; return true;
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -21,6 +22,11 @@ namespace Model ...@@ -21,6 +22,11 @@ namespace Model
/// 第一个匹配条码的角度 /// 第一个匹配条码的角度
/// </summary> /// </summary>
public int Angle { get; set; } = 0; public int Angle { get; set; } = 0;
//
// 摘要:
// 条码类型
[DataMember]
public string CodeType { get; set; }
} }
/// <summary> /// <summary>
......
...@@ -14,6 +14,7 @@ using System.Data; ...@@ -14,6 +14,7 @@ using System.Data;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
...@@ -259,7 +260,7 @@ namespace SmartScan.PlusSettingFrm ...@@ -259,7 +260,7 @@ namespace SmartScan.PlusSettingFrm
item.key = ""; item.key = "";
} }
} }
public static Point LabelingAngle(string keyvalue, AMatch aMatch, System.Drawing.Point centrality, bool isvaor, int PlateW, out int angle) public static Point LabelingAngle(string keyvalue, AMatch aMatch, System.Drawing.Point centrality, bool isvaor, int PlateW, out int angle,bool isQRCode)
{ {
Point lable = aMatch.Points; Point lable = aMatch.Points;
Point newpoint = aMatch.Points; Point newpoint = aMatch.Points;
...@@ -276,7 +277,7 @@ namespace SmartScan.PlusSettingFrm ...@@ -276,7 +277,7 @@ namespace SmartScan.PlusSettingFrm
//X += Data.X; Y += Data.Y; //X += Data.X; Y += Data.Y;
LogUtil.info($"关键字{Data.key}={Data.value};顺时针旋转角度={Data.ClockwiseAngle};xy偏移{Data.X};{Data.Y};标签角度:{Data.LabelAngle}"); LogUtil.info($"关键字{Data.key}={Data.value};顺时针旋转角度={Data.ClockwiseAngle};xy偏移{Data.X};{Data.Y};标签角度:{Data.LabelAngle}");
} }
newpoint = Overwritelabel(centrality, aMatch.Points, isvaor, PlateW, aMatch.Angle, RotateAngle, out angle); newpoint = Overwritelabel(centrality, aMatch.Points, isvaor, PlateW, aMatch.Angle, RotateAngle, out angle, isQRCode);
//if (Data != null&&Data.LabelAngle > 0) //if (Data != null&&Data.LabelAngle > 0)
//{ //{
// angle = Data.LabelAngle; // angle = Data.LabelAngle;
...@@ -291,13 +292,24 @@ namespace SmartScan.PlusSettingFrm ...@@ -291,13 +292,24 @@ namespace SmartScan.PlusSettingFrm
LogUtil.info($"处理后角度={angle};处理后贴标位置:{newpoint};标签变换角度:{Data.LabelAngle}"); LogUtil.info($"处理后角度={angle};处理后贴标位置:{newpoint};标签变换角度:{Data.LabelAngle}");
return new Point(newpoint.X, newpoint.Y); return new Point(newpoint.X, newpoint.Y);
} }
public static Point Overwritelabel(Point centrality, Point lable, bool isvaor, int PlateW, int Angle,int RotateAngle, out int angle) public static Point Overwritelabel(Point centrality, Point lable, bool isvaor, int PlateW, int Angle,int RotateAngle, out int angle,bool isQRCode)
{ {
Point Points = LabelingPosition.ClockwiseRotation(lable, centrality, RotateAngle); Point Points = LabelingPosition.ClockwiseRotation(lable, centrality, RotateAngle);
if (isvaor) if (isvaor)
{ {
if (isQRCode)
{
int deg = Angle;
deg += 90;
if (deg > 360)
deg = deg - 360;
angle = ScanningCameraAngle(deg, RotateAngle);
}
else
{
angle = ScanningCameraAngle(Angle, RotateAngle); angle = ScanningCameraAngle(Angle, RotateAngle);
} }
}
else else
{ {
angle = OldAngleAlgo(centrality, lable, PlateW); angle = OldAngleAlgo(centrality, lable, PlateW);
...@@ -309,7 +321,7 @@ namespace SmartScan.PlusSettingFrm ...@@ -309,7 +321,7 @@ namespace SmartScan.PlusSettingFrm
{ {
//ID MVS相机, 右侧为正角度, 左侧为负角度 //ID MVS相机, 右侧为正角度, 左侧为负角度
int angle; int angle;
int rotationAngle = RotateAngle+83;// 83; int rotationAngle = RotateAngle+80;// 83;
if (angles < 0) if (angles < 0)
{ {
angle = angles * -1 + rotationAngle; angle = angles * -1 + rotationAngle;
......
...@@ -26,9 +26,6 @@ namespace SmartScan ...@@ -26,9 +26,6 @@ namespace SmartScan
changed = true; changed = true;
Language.SetLanguage(this); Language.SetLanguage(this);
//var name = LblSplitPart.Text.Trim();
//LblSplitPart.Text= "Field";
//LblSplitPart.Text = "获取分割部分";
this.codeText = codeText; this.codeText = codeText;
this.codeType = codeType; this.codeType = codeType;
CboKeyword.Items.AddRange(BLLCommon.macroKey.ToArray()); CboKeyword.Items.AddRange(BLLCommon.macroKey.ToArray());
......
...@@ -168,6 +168,7 @@ namespace SmartScan ...@@ -168,6 +168,7 @@ namespace SmartScan
BLLCommon.mateEdit.CurrntBitmap?.Dispose(); BLLCommon.mateEdit.CurrntBitmap?.Dispose();
Bitmap bitmap = null; Bitmap bitmap = null;
MemoryStream stream = null; MemoryStream stream = null;
bool isQRCode = false;
try try
{ {
if (bitmapData == null) if (bitmapData == null)
...@@ -194,6 +195,7 @@ namespace SmartScan ...@@ -194,6 +195,7 @@ namespace SmartScan
{ {
return new WebResultCode() { ErrorCode = -1, Msg = "扫码相机未传来条码数据;" }; return new WebResultCode() { ErrorCode = -1, Msg = "扫码相机未传来条码数据;" };
} }
if (bitmapData.IsIDCamera) if (bitmapData.IsIDCamera)
{ {
bitmapData.BarCodeList.ForEach(barcode => bitmapData.BarCodeList.ForEach(barcode =>
...@@ -207,7 +209,14 @@ namespace SmartScan ...@@ -207,7 +209,14 @@ namespace SmartScan
CodeType = barcode.CodeType, CodeType = barcode.CodeType,
Distance = barcode.Distance, Distance = barcode.Distance,
}); });
//LogNet.log.Info($"条码数据类型为{barcode.CodeType}");
}); });
//LogNet.log.Info($"条码数据[0]类型为{bitmapData.BarCodeList[0].CodeType}");
//if (bitmapData.BarCodeList[0].CodeType== "QR Code")
//{
// isQRCode = true;
// LogNet.log.Info("条码数据为QR Code");
//}
} }
else else
{ {
...@@ -225,10 +234,17 @@ namespace SmartScan ...@@ -225,10 +234,17 @@ namespace SmartScan
LogNet.log.Info("模板匹配结果:" + rtn); LogNet.log.Info("模板匹配结果:" + rtn);
if (rtn) if (rtn)
{ {
if (aMatch.CodeType == "QR Code")
{
isQRCode = true;
LogNet.log.Info("条码数据为QR Code");
}
LogNet.log.Info($"条码数据类型为{aMatch.CodeType}");
string key = ConfigHelper.Config.Get("Label_Key", ""); string key = ConfigHelper.Config.Get("Label_Key", "");
workCodeKeyword.TryGetValue(key, out String Value); workCodeKeyword.TryGetValue(key, out String Value);
LogNet.log.Info("模板匹配结果:" + rtn + $";关键字{key}:{Value};匹配成功条码xy:X={aMatch.Points.X};Y={aMatch.Points.Y},中心点x={bitmapData.X};y={bitmapData.Y},角度={aMatch.Angle},料盘尺寸={bitmapData.PlateW};匹配成功条码:{string.Join(", ", aMatch.IsCodeUsed)}"); LogNet.log.Info("模板匹配结果:" + rtn + $";关键字{key}:{Value};匹配成功条码xy:X={aMatch.Points.X};Y={aMatch.Points.Y},中心点x={bitmapData.X};y={bitmapData.Y},角度={aMatch.Angle},料盘尺寸={bitmapData.PlateW};匹配成功条码:{string.Join(", ", aMatch.IsCodeUsed)}");
point = UsrKeywordlabeling.LabelingAngle(Value, aMatch, new Point(bitmapData.X, bitmapData.Y), bitmapData.IsIDCamera, bitmapData.PlateW, out angle); point = UsrKeywordlabeling.LabelingAngle(Value, aMatch, new Point(bitmapData.X, bitmapData.Y), bitmapData.IsIDCamera, bitmapData.PlateW, out angle, isQRCode);
//point =UsrCustomlabeling.LabelingAngle_New(mateName, aMatch, new Point(bitmapData.X, bitmapData.Y), bitmapData.IsIDCamera, bitmapData.PlateW, out angle); //point =UsrCustomlabeling.LabelingAngle_New(mateName, aMatch, new Point(bitmapData.X, bitmapData.Y), bitmapData.IsIDCamera, bitmapData.PlateW, out angle);
} }
Dictionary<string, string> keys = new Dictionary<string, string>(); Dictionary<string, string> keys = new Dictionary<string, string>();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!