Commit da49fff1 张东亮

使用料盘列表来记录对应料盘厚度,避免错乱

1 个父辈 a859c3a1
......@@ -223,7 +223,7 @@ namespace DeviceLibrary
g.FillEllipse(yeelow, new Rectangle(p2, pointsize));
g.Save();
g.Dispose();
string filepath =Application.StartupPath+ "\\image\\Labeling\\" ;
string filepath = Application.StartupPath + "\\image\\Labeling\\";
if (!Directory.Exists(filepath))
{
Directory.CreateDirectory(filepath);
......@@ -241,7 +241,7 @@ namespace DeviceLibrary
}
}
Bitmap bitmaps = (Bitmap)bitmap.Clone();
bitmaps.Save(filepath+ DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + DateTime.Now.Millisecond + ".jpg");
bitmaps.Save(filepath + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + DateTime.Now.Millisecond + ".jpg");
LabelResult?.Invoke(new LabelResult() { Bitmap = (Bitmap)bitmap.Clone() });
bitmap.Dispose();
return p2;
......@@ -463,7 +463,7 @@ namespace DeviceLibrary
// }
//}
labelAngle =GetPasteAngle(angles, angles[index]);
labelAngle = GetPasteAngle(angles, angles[index]);
widthOffset = (widthOffsets.Min() + widthOffsets.Max()) / 2;
LogUtil.info($"use widthOffset:{widthOffset},angle:{labelAngle}");
labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
......@@ -471,7 +471,7 @@ namespace DeviceLibrary
var p1 = PointWithAngle(org, labelAngle, widthOffset);
g.FillEllipse(tmpPlace, new Rectangle(p1, pointsize));
//判断如果是7寸料盘加60度
if (labelParam.PlateW==7)
if (labelParam.PlateW == 7)
{
labelAngle += 60;
}
......@@ -482,9 +482,9 @@ namespace DeviceLibrary
//贴标坐标
var p2 = PointWithAngle(org, labelAngle, widthOffset);
if (labelParam.PlateW == 7&&labelParam.codeInfos.Count!=1)
if (labelParam.PlateW == 7 && labelParam.codeInfos.Count != 1)
{
p2=new Point(p2.X-180,p2.Y-180);
p2 = new Point(p2.X - 180, p2.Y - 180);
}
//贴标偏移
var p3 = PointWithAngle(p2, labelAngle, Label_R_Offset);
......@@ -533,18 +533,18 @@ namespace DeviceLibrary
bitmap.Dispose();
return p2;
}
static IdWorker id = new IdWorker(1, 1);
public static IdWorker id = new IdWorker(1, 1);
static string[] pnreglist;
static string[] qtyreglist;
public static void LoadMatchList()
{
pnreglist = File.ReadAllLines(Application.StartupPath+"config\\pn.list").ToList().FindAll((s) => { return !string.IsNullOrWhiteSpace(s); }).ToArray();
qtyreglist = File.ReadAllLines(Application.StartupPath+"config\\qty.list").ToList().FindAll((s) => { return !string.IsNullOrWhiteSpace(s); }).ToArray();
pnreglist = File.ReadAllLines(Application.StartupPath + "config\\pn.list").ToList().FindAll((s) => { return !string.IsNullOrWhiteSpace(s); }).ToArray();
qtyreglist = File.ReadAllLines(Application.StartupPath + "config\\qty.list").ToList().FindAll((s) => { return !string.IsNullOrWhiteSpace(s); }).ToArray();
}
public static bool codeProcess(LabelParam labelParam, out string debugmsg)
{
string materid = ConfigHelper.Config.Get("MateRidName","RID");
if (labelParam.Keyword!=null)
string materid = ConfigHelper.Config.Get("MateRidName", "RID");
if (labelParam.Keyword != null)
{
if (labelParam.Keyword.TryGetValue(materid, out string value))
{
......@@ -745,7 +745,7 @@ namespace DeviceLibrary
/// <param name="centrality"></param>
/// <param name="angle"></param>
/// <returns></returns>
public static Point Overlaylabel(LabelParam labelParam,Point centrality,int idenx,out int angle)
public static Point Overlaylabel(LabelParam labelParam, Point centrality, int idenx, out int angle)
{
//标签位置
SolidBrush blue = new SolidBrush(Color.DarkBlue);
......@@ -769,32 +769,32 @@ namespace DeviceLibrary
//LogUtil.info($"识别结果选中:{string.Join(",", labelParam.AMatch)}");
//int idenx =Array.FindIndex(labelParam.AMatch, x=>x);
if (idenx<0)
if (idenx < 0)
{
idenx = 0;
}
int angles = (int)labelParam.codeInfos[idenx].Orientation;
LogUtil.info($"标签原角度{angles},索引{idenx}");
double rotationAngle = 83;
if (angles<0&&angles!=0)
if (angles < 0 && angles != 0)
{
angle = (int)(Math.Abs(angles) + rotationAngle);
}
else
{
if (angles<=83)
if (angles <= 83)
{
angle = (int)Math.Abs(angles - rotationAngle);
}
else
{
angle = 350-(int)(angles - rotationAngle);
angle = 350 - (int)(angles - rotationAngle);
}
}
angle += 90;
LogUtil.info($"计算完成角度{angle}");
if (angle>344)
if (angle > 344)
{
angle -= 344;
}
......@@ -821,7 +821,7 @@ namespace DeviceLibrary
int Xoffset = RobotManage.Config.Label_XOffset;
int Yoffset = RobotManage.Config.Label_YOffset;
newxy = new Point(newxy.X-Xoffset,newxy.Y-Yoffset);
newxy = new Point(newxy.X - Xoffset, newxy.Y - Yoffset);
LogUtil.info($"贴标偏移量坐标:{newxy.X},{newxy.Y};");
g.FillEllipse(yeelow, new Rectangle(newxy, pointsize));
g.Save();
......@@ -851,7 +851,7 @@ namespace DeviceLibrary
return newxy;
}
public static void RenderedImage(LabelParam labelParam, Point centrality,Point point)
public static void RenderedImage(LabelParam labelParam, Point centrality, Point point)
{
try
{
......@@ -878,7 +878,7 @@ namespace DeviceLibrary
int idnex = 0;
labelParam.NewXYAngle.TryGetValue("IsCodeUsed", out idnex);
Point CalPoint = new Point(point.X, point.Y);
if (idnex>=0)
if (idnex >= 0)
CalPoint = new Point(labelParam.codeInfos[idnex].X, labelParam.codeInfos[idnex].Y);
g.FillEllipse(blue, new Rectangle(CalPoint, pointsize));
g.FillEllipse(yeelow, new Rectangle(point, pointsize));
......@@ -917,7 +917,7 @@ namespace DeviceLibrary
}
public static Point Customlabeling(LabelParam labelParam, Point centrality, out int angle)
{
Point point=LabelingPosition.MultipleChoiceLabeling(labelParam, centrality, out angle,out Bitmap bit);
Point point = LabelingPosition.MultipleChoiceLabeling(labelParam, centrality, out angle, out Bitmap bit);
LabelResult?.Invoke(new LabelResult() { Bitmap = (Bitmap)bit.Clone() });
bit.Dispose();
return point;
......
......@@ -23,13 +23,15 @@ namespace DeviceLibrary
/// <param name="ngMsg">NG消息</param>
public LabelParam(string wareNo = "", int platew = 0, int plateh = 0, bool _IsNg = false, string ngMsg = "")
{
UID = Common.id.nextId();
WareCode = wareNo;
PlateW = platew;
PlateH = plateh;
IsNg = _IsNg;
NgMsg = ngMsg;
}
public long UID { get; set; }
public long PreUID { get; set; }
/// <summary>
/// 物品二维码信息
/// </summary>
......@@ -43,7 +45,8 @@ namespace DeviceLibrary
/// 料盘高度
/// </summary>
public int PlateH { get; set; }
public int PlwHight { get; set; }
public int RightPulseHeight { get; set; }
public int RightPlateHeight { get; set; }
/// <summary>
/// 料盘宽度
/// </summary>
......
......@@ -12,6 +12,52 @@ namespace DeviceLibrary
{
partial class MainMachine
{
List<LabelParam> runParams = new List<LabelParam>();
object paramLock = new object();
void addParam(LabelParam param)
{
lock(paramLock)
{
runParams.Add(param);
LogUtil.info($"参数新建【{JsonHelper.SerializeObject(param)}】");
}
}
void removeParam(long uid)
{
lock (paramLock)
{
var param = runParams.FirstOrDefault(p => p.UID == uid);
if(param != null)
{
runParams.Remove(param);
LogUtil.info($"参数删除【{JsonHelper.SerializeObject(param)}】");
}
}
}
LabelParam GetLabelParam(long uid)
{
lock (paramLock)
{
var param = runParams.FirstOrDefault(p => p.UID == uid);
return param;
}
}
//void setParamPlwHight(long uid,int PlwHight,int plateH)
//{
// lock (paramLock)
// {
// var param = runParams.FirstOrDefault(p => p.UID == uid);
// if (param != null)
// {
// param.RightPulseHeight = PlwHight;
// param.RightPlateHeight = plateH;
// LogUtil.info($"参数修改:PlwHight={PlwHight},plateH={plateH}【{JsonHelper.SerializeObject(param)}】");
// }
// }
//}
public void StopMove(bool ServoOff = false)
{
runStatus = RunStatus.Stop;
......
......@@ -67,7 +67,7 @@ namespace DeviceLibrary
if (enableCheck)
{
var aixH = 1f * Math.Abs(_leftBatchAxisPositionWhileTrayCheck - curPos) / Config.Left_Batch_ChangeValue;
float plateH = Math.Max(LeftMoveInfo.MoveParam.PlwHight / Config.Right_Batch_ChangeValue, LeftMoveInfo.MoveParam.PlateH);
float plateH = LeftMoveInfo.MoveParam.RightPlateHeight;
var canErrorMM = ConfigHelper.Config.Get("左侧料盘放料串检查厚度最大偏差值", 5);
if (Math.Abs(aixH - plateH) <= canErrorMM)
{
......@@ -113,15 +113,16 @@ namespace DeviceLibrary
LeftMoveInfo.NextMoveStep(MoveStep.L04);
int targetP1 = Left_Batch_Axis.GetAclPosition() - ConfigHelper.Config.Get("LeftAxisDownValue", 50) * Config.Left_Batch_ChangeValue;
int currpoint = Left_Batch_Axis.GetAclPosition();
if (PlwHight > 5000)
var param = GetLabelParam(LeftMoveInfo.MoveParam.UID);
if (param!=null && param.RightPlateHeight>0)
{
int countPleHight = PlwHight / Config.Right_Batch_ChangeValue * Config.Left_Batch_ChangeValue;
int countPleHight = param.RightPlateHeight * Config.Left_Batch_ChangeValue;
var target = currpoint - countPleHight + 5000;
if (target < targetP1)
{
targetP1 = target;
LeftMoveInfo.MoveParam.PlateH = countPleHight / Config.Left_Batch_ChangeValue;
LeftMoveInfo.log($"出料提升机构,获取到料盘高度脉冲{PlwHight},当前位置{currpoint},计算盘高{LeftMoveInfo.MoveParam.PlateH}");
LeftMoveInfo.log($"出料提升机构,获取到料盘高度脉冲{param.RightPlateHeight},当前位置{currpoint},计算盘高{LeftMoveInfo.MoveParam.PlateH}");
}
}
int targetSpeed = Config.Left_Batch_P1_speed;
......@@ -194,15 +195,30 @@ namespace DeviceLibrary
if (enableCheck)
{
//等待右侧测高完成
if ((RightMoveInfo.MoveStep > MoveStep.R04 && RightMoveInfo.MoveStep <= MoveStep.R10_WaitReelLeave) || RightMoveInfo.MoveStep == MoveStep.Wait)//测高完成
var param1 = GetLabelParam(RightMoveInfo.MoveParam.UID);
if (param1 == null)
{
LeftMoveInfo.MoveParam.PlwHight = PlwHight;
LeftMoveInfo.log($"右侧测高完成:PlwHight={PlwHight}");
LeftMoveInfo.NextMoveStep(MoveStep.L16);
LeftMoveInfo.log($"未查询到记录:{RightMoveInfo.MoveParam.UID},不检查");
return;
}
else
else //找到记录
{
if (param1.RightPlateHeight == 0)//测高未完成
{
LeftMoveInfo.NextMoveStep(MoveStep.L13);
LeftMoveInfo.log($"查询到记录:{RightMoveInfo.MoveParam.UID},但还未获取到高度,等待");
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
return;
}
else
{
LeftMoveInfo.MoveParam.RightPlateHeight = param1.RightPlateHeight;
LeftMoveInfo.MoveParam.RightPulseHeight = param1.RightPulseHeight;
LeftMoveInfo.log($"查询到记录:{RightMoveInfo.MoveParam.UID},RightPlateHeight={LeftMoveInfo.MoveParam.RightPlateHeight},RightPulseHeight={LeftMoveInfo.MoveParam.RightPulseHeight}");
}
}
}
var curPos = Left_Batch_Axis.GetAclPosition();
//判断当前料盘是否放到料串上
......@@ -235,11 +251,7 @@ namespace DeviceLibrary
LeftMoveInfo.log($"批量轴重新上升到P2位置,LeftStartMovePosition={LeftStartMovePosition}");
break;
case MoveStep.L16:
if (RightMoveInfo.MoveStep == MoveStep.Wait || RightShelfNoTray)
{
PlwHight = 0;
LeftMoveInfo.log($"右侧无料盘,PlwHight={PlwHight}");
}
removeParam(LeftMoveInfo.MoveParam.UID);
LeftBatchAxisPositionWhileTrayCheck = Left_Batch_Axis.GetAclPosition();
LeftMoveInfo.NextMoveStep(MoveStep.L20_WaitLabel);
break;
......@@ -257,7 +269,7 @@ namespace DeviceLibrary
}
else
{
if (PlwHight > 0)
if (LeftMoveInfo.MoveParam.RightPulseHeight > 0)
{
LeftMoveInfo.NextMoveStep(MoveStep.L03);
LeftBatchAxisToP2(Config.Left_Batch_P1, Config.Left_Batch_P1_speed, IO_VALUE.LOW);
......
......@@ -26,15 +26,15 @@ namespace DeviceLibrary
//如果右侧可取料那么那么移动轴到p2点,夹爪释放。获取右侧的标签信息,右侧标签信息复位,否则等待
if (RightMoveInfo.MoveStep == MoveStep.R10_WaitReelLeave)
{
//PlwHight = 0;
PlwHight = 0;
MiddleMoveInfo.NextMoveStep(MoveStep.M02);
Take_Middle_Axis.AbsMove(MiddleMoveInfo, Config.Take_Middle_P2, Config.Take_Middle_P2_speed);
Take_UpDown_Axis.AbsMove(MiddleMoveInfo, Config.Take_UpDown_P2, Config.Take_UpDown_P2_speed);
clampTool.Release();
//复制右侧料盘信息
MiddleMoveInfo.MoveParam = RightMoveInfo.MoveParam.clone();
RightMoveInfo.MoveParam = new LabelParam();
addParam(MiddleMoveInfo.MoveParam);
RightMoveInfo.MoveParam = new LabelParam() { PreUID = MiddleMoveInfo.MoveParam.UID};
MiddleMoveInfo.log($"右侧可以取料,旋转轴/上下轴转到P2点:{JsonConvert.SerializeObject(MiddleMoveInfo.MoveParam)}");
//MiddleMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.RightArm_Check, IO_VALUE.HIGH));
}
......
......@@ -47,7 +47,26 @@ namespace DeviceLibrary
PlwHight = Uplast - LastBatchAxisPosition;
if (PlwHight <= 0)
PlwHight = 5000;
RightMoveInfo.log($"批量轴上升到P2位置到位,当前位置:{Uplast}, PlwHight:{PlwHight}");
if (RightCount == 0)//第一次上升,不是测高的
{
RightMoveInfo.log($"RightCount={RightCount},新料串到位");
}
else
{
var param = GetLabelParam(RightMoveInfo.MoveParam.PreUID);
if (param != null)
{
param.RightPulseHeight = PlwHight;
param.RightPlateHeight = PlwHight / Config.Right_Batch_ChangeValue;
RightMoveInfo.log($"批量轴上升到P2位置到位,当前位置:{Uplast},uid={param.UID}, PlwHight:{param.RightPulseHeight},plateH:{param.RightPlateHeight}");
}
else
{
RightMoveInfo.log($"未找到UID:{RightMoveInfo.MoveParam.PreUID},无法设置高度");
}
}
break;
//如果定位上升并且特定中间步骤偶,开始扫码
case MoveStep.R04:
......@@ -132,7 +151,7 @@ namespace DeviceLibrary
{
RightMoveInfo.NextMoveStep(MoveStep.R20_reel_duplicate);
RightMoveInfo.MoveParam.IsNg = true;
RightMoveInfo.MoveParam.NgMsg = crc.GetString("Res0183.b7688c25","条码重复");
RightMoveInfo.MoveParam.NgMsg = crc.GetString("Res0183.b7688c25", "条码重复");
//duplicate = true;
RightMoveInfo.log($"条码重复:{result.overlapPercentage} > 50");
}
......@@ -179,7 +198,7 @@ namespace DeviceLibrary
}
break;
case MoveStep.R20_reel_duplicate:
Msg.add(crc.GetString("Res0184.4aa86524","条码出现重复,请分别取走左右料串顶层的料盘,然后按右侧按钮继续"), MsgLevel.alarm);
Msg.add(crc.GetString("Res0184.4aa86524", "条码出现重复,请分别取走左右料串顶层的料盘,然后按右侧按钮继续"), MsgLevel.alarm);
if (IOValue(IO_Type.GratingSignal_Check).Equals(IO_VALUE.LOW))
{
if (IOValue(IO_Type.Right_BTN).Equals(IO_VALUE.HIGH))
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!