Commit 07bacd1d 刘韬

贴标定位优化

1 个父辈 ca4d7705
......@@ -47,6 +47,7 @@ namespace DeviceLibrary
/// 料盘宽度
/// </summary>
public int PlateW { get; set; }
public string BitmapBase64 { get; set; }
/// <summary>
/// 是否是入料NG料
/// </summary>
......
......@@ -296,15 +296,15 @@ namespace DeviceLibrary
//计算贴标角度的脉冲值
int labelAxisPos = Config.Label_R_360 / 350 * labelAngle;
LogUtil.info($"贴标角度脉冲{labelAxisPos}");
LabelMoveInfo.log($"贴标角度脉冲{labelAxisPos}");
//计算像素点位与中心点的差
Label_p3 = new Point(p.X - Right_Batch_Point.X, p.Y - Right_Batch_Point.Y);
//计算像素*脉冲像素比得到脉冲值+中心点基准脉冲
int xDiff = (int)(Label_p3.X * Config.Cam_Pixel_X_Ratio);
int yDiff = (int)(Label_p3.Y * Config.Cam_Pixel_Y_Ratio);
LogUtil.info($"贴标XY脉冲差:X:{xDiff}={Label_p3.X}*{Config.Cam_Pixel_X_Ratio}, Y:{yDiff}={Label_p3.Y}*{Config.Cam_Pixel_Y_Ratio},");
if (LabelMoveInfo.MoveParam.PlateW == 7)
LabelMoveInfo.log($"贴标XY脉冲差:X:{xDiff}={Label_p3.X}*{Config.Cam_Pixel_X_Ratio}, Y:{yDiff}={Label_p3.Y}*{Config.Cam_Pixel_Y_Ratio},");
if (false && LabelMoveInfo.MoveParam.PlateW == 7)
{
LabelMoveInfo.log("当前盘为7寸");
double x = xDiff;
......
......@@ -71,6 +71,12 @@ namespace DeviceLibrary
RightMoveInfo.NextMoveStep(MoveStep.R11_NextReel);
MiddleMoveInfo.MoveParam.PlateW = GetTrayWidth();
MiddleMoveInfo.log($"通知右侧料串,料已取走,获取盘宽{MiddleMoveInfo.MoveParam.PlateW}");
//Task.Run(() => {
// CodeManager.NS100Service(MiddleMoveInfo, MiddleMoveInfo.MoveParam.BitmapBase64, MiddleMoveInfo.MoveParam.codeInfos, MiddleMoveInfo.MoveParam.PlateW);
//}).ContinueWith((t) => {
// MiddleMoveInfo.NextMoveStep(MoveStep.M06);
//});
}
else if (LeftMoveInfo.MoveStep == MoveStep.L10_WaitReelPut)
{
......@@ -104,6 +110,8 @@ namespace DeviceLibrary
}
break;
//NG料进入NG流程,正常入正常流程
case MoveStep.M06_Wait:
break;
case MoveStep.M06:
if (MiddleMoveInfo.MoveParam.IsNg)
{
......
......@@ -90,6 +90,7 @@ namespace DeviceLibrary
M03,
M04,
M05,
M06_Wait,
M06,
M07,
M_ReturnToP1,
......
......@@ -199,7 +199,7 @@ namespace DeviceLibrary
{
//RemoteDecodeHelper_mod.RemoteDecodeParam remoteDecodeParam = new RemoteDecodeHelper_mod.RemoteDecodeParam();
//webResult = RemoteDecodeHelper_mod.DecodeRequest(bmp, remoteDecodeParam);
webResult = NeoSacnRequest_ordinary(bmp, PlateW);
webResult = NeoSacnRequest_ordinary(BitmapToBase64(bmp), PlateW);
}
if (webResult == null)
{
......@@ -276,6 +276,70 @@ namespace DeviceLibrary
}
return (codeList, keyword, bitmapfilename, newpointanlge);
}
public static void NS100Service(MoveInfo moveInfo, string bitmapBase64, List<CodeLibrary.CodeInfo> codeInfos, int PlateW)
{
WebResultCode webResult;
List<CodeInfo> codeList = new List<CodeInfo>();
Dictionary<string, string> keyword = new Dictionary<string, string>();
Dictionary<string, int> newpointanlge = new Dictionary<string, int>();
if (iscode)
{
moveInfo.log($"开始请求ns100服务:识别条码为:{string.Join("##", codeInfos.Select(a => a.CodeStr + $"@@x:{a.X};y:{a.Y};角度{a.Orientation}"))}");
webResult = NeoSacnRequest(bitmapBase64, codeInfos, PlateW);
}
else
{
//RemoteDecodeHelper_mod.RemoteDecodeParam remoteDecodeParam = new RemoteDecodeHelper_mod.RemoteDecodeParam();
//webResult = RemoteDecodeHelper_mod.DecodeRequest(bmp, remoteDecodeParam);
webResult = NeoSacnRequest_ordinary(bitmapBase64, PlateW);
}
if (webResult == null)
{
moveInfo.log("调用NS100外部转码失败");
}
else if (webResult.ErrorCode != 0)
{
moveInfo.log("调用NS100转码错误:" + webResult.ErrorCode + "," + webResult.Msg);
}
else
{
foreach (var code in webResult.workCodeInfo)
{
CodeInfo codeInfo = new CodeInfo()
{
CodeStr = code.Text,
X = (int)code.Center.X,
Y = (int)code.Center.Y,
CodeType = code.CodeType,
Orientation = code.Angle,
};
codeList.Add(codeInfo);
}
foreach (var code in webResult.workCodeKeyword)
{
if (!keyword.ContainsKey(code.Key))
{
keyword.Add(code.Key, code.Value);
}
}
newpointanlge.Add("PointX", webResult.positionAngle.X);
newpointanlge.Add("PointY", webResult.positionAngle.Y);
newpointanlge.Add("Angle", webResult.positionAngle.Angle);
if (webResult.positionAngle.IsCodeUsed != null)
{
newpointanlge.Add("IsCodeUsed", Array.FindIndex(webResult.positionAngle.IsCodeUsed, x => x)); ;
}
LogUtil.info($"贴标数据X={webResult.positionAngle.X};Y={webResult.positionAngle.Y};角度={webResult.positionAngle.Angle}");
}
}
/// <summary>
///
/// </summary>
......
......@@ -154,16 +154,15 @@ public class RemoteDecodeHelper_mod
return resultCode;
}
public static WebResultCode NeoSacnRequest_ordinary(Bitmap bitmap,int PlateW)
public static WebResultCode NeoSacnRequest_ordinary(string bitmapBase64, int PlateW)
{
WebResultCode resultCode = null;
try
{
CheckAndRunServer();
BitmapData bitmapData = new BitmapData();
string iamgestr = BitmapToBase64(bitmap);
List<BarcodeInfos> barcodeInfos = new List<BarcodeInfos>();
bitmapData.ImageData = iamgestr;
bitmapData.ImageData = bitmapBase64;
bitmapData.BarCodeList = barcodeInfos;
bitmapData.X = RobotManage.Config.Right_Batch_X;
bitmapData.Y = RobotManage.Config.Right_Batch_Y;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!