Commit f5dc9139 刘韬

1

1 个父辈 64d60b01
...@@ -78,7 +78,8 @@ ...@@ -78,7 +78,8 @@
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="X-Ray"> <Reference Include="X-Ray, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\X-Ray\X-Ray\bin\Debug\X-Ray.dll</HintPath> <HintPath>..\..\X-Ray\X-Ray\bin\Debug\X-Ray.dll</HintPath>
</Reference> </Reference>
<Reference Include="ZebraPrinterHelper"> <Reference Include="ZebraPrinterHelper">
......
...@@ -334,7 +334,7 @@ namespace DeviceLibrary ...@@ -334,7 +334,7 @@ namespace DeviceLibrary
{ {
axisCheckTimer = new System.Timers.Timer(); axisCheckTimer = new System.Timers.Timer();
axisCheckTimer.AutoReset = true; axisCheckTimer.AutoReset = true;
axisCheckTimer.Interval += 15; axisCheckTimer.Interval += 5;
axisCheckTimer.Elapsed += CheckTimer_Elapsed; axisCheckTimer.Elapsed += CheckTimer_Elapsed;
axisCheckTimer.Enabled = false; axisCheckTimer.Enabled = false;
} }
......
...@@ -14,8 +14,7 @@ namespace DeviceLibrary ...@@ -14,8 +14,7 @@ namespace DeviceLibrary
ZebraPrinterHelper.ZebraManger zebraManger; ZebraPrinterHelper.ZebraManger zebraManger;
string Port; string Port;
public PrinterHelper() { public PrinterHelper() {
print = new Asa.PrintLabel(Application.StartupPath + "\\Label",300);
print = new Asa.PrintLabel(Application.StartupPath + "\\Label");
} }
......
...@@ -140,10 +140,13 @@ namespace DeviceLibrary ...@@ -140,10 +140,13 @@ namespace DeviceLibrary
CodeInfo rightcode=null; CodeInfo rightcode=null;
int rightangle = 0; int rightangle = 0;
labelParam.codeInfos.ForEach((c) => { labelParam.codeInfos.ForEach((c) => {
if (c.CodeStr.Length<5 || c.CodeType== "2/5 Interleaved" || c.CodeType== "2/5 Industrial") if (c.CodeType== "2/5 Interleaved" || c.CodeType== "2/5 Industrial")
return;
if (c.CodeType != "Code 128" && c.CodeType != "Code 39" && c.CodeType != "Data Matrix ECC 200")
return; return;
Point op = new Point(c.X, c.Y); Point op = new Point(c.X, c.Y);
var a = (int)getAngle(org, op); var a = (int)getAngle(org, op);
a = a < 0 ? 360 + a : a;
LogUtil.info($"{c.CodeType},{c.CodeStr},angles:{a}"); LogUtil.info($"{c.CodeType},{c.CodeStr},angles:{a}");
angles.Add(a); angles.Add(a);
if (c.CodeStr.Contains(labelParam.ReeID) && c.CodeType== "Data Matrix ECC 200") if (c.CodeStr.Contains(labelParam.ReeID) && c.CodeType== "Data Matrix ECC 200")
...@@ -169,11 +172,11 @@ namespace DeviceLibrary ...@@ -169,11 +172,11 @@ namespace DeviceLibrary
labelAngle = 0; labelAngle = 0;
return Point.Empty; return Point.Empty;
} }
var angleset = GetAnglesDistribution(angles, 40); //var angleset = GetAnglesDistribution(angles, 40);
LogUtil.info($"rightangle:{rightangle},angleset:{string.Join(",", angleset)}"); LogUtil.info($"rightangle:{rightangle}");
if (labelParam.PlateW == 15) if (labelParam.PlateW == 15)
{ {
labelAngle = rightangle + 120; labelAngle = rightangle + 120;
...@@ -186,9 +189,10 @@ namespace DeviceLibrary ...@@ -186,9 +189,10 @@ namespace DeviceLibrary
{ {
labelAngle = rightangle + 180; labelAngle = rightangle + 180;
} }
if (angleset.Count > 1 && labelParam.PlateW >= 13) if (labelParam.PlateW >= 13)
{ {
var ass = angleset.Select(x => x < 0 ? 360 + x : x).ToList(); /*
var ass = angleset.ToList();
ass.AddRange(ass.Select(x => x + 360).ToArray()); ass.AddRange(ass.Select(x => x + 360).ToArray());
ass.Sort(); ass.Sort();
int minangle = 720; int minangle = 720;
...@@ -201,21 +205,29 @@ namespace DeviceLibrary ...@@ -201,21 +205,29 @@ namespace DeviceLibrary
minindex = i; minindex = i;
} }
} }
minangle = ass[minindex]; if (minindex < ass.Count - 1)
minangle = minangle > 360 ? minangle - 360 : minangle; minangle = ass[minindex + 1];
rightangle = minangle >= 180 ? minangle - 180 : minangle + 180; else
minangle = 720; minangle = ass[0];
for (int i = 0; i < ass.Count; i++) //minangle = minangle > 360 ? minangle - 360 : minangle;
{ //rightangle = minangle >= 180 ? minangle - 180 : minangle + 180;
if (Math.Abs(ass[i] - rightangle) < minangle) //minangle = 720;
//for (int i = 0; i < ass.Count; i++)
//{
// if (Math.Abs(ass[i] - rightangle) < minangle)
// {
// minangle = Math.Abs(ass[i] - rightangle);
// minindex = i;
// }
//}
labelAngle = minangle;*/
labelAngle = Common.GetPasteAngle(angles, rightangle);
if (labelAngle > 0)
{ {
minangle = Math.Abs(ass[i] - rightangle); labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
minindex = i;
}
}
labelAngle = ass[minindex];
LogUtil.info($"选择贴标角度:{labelAngle}"); LogUtil.info($"选择贴标角度:{labelAngle}");
} }
}
labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle; labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
//labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle; //labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
LogUtil.info($"图像贴标角度:{labelAngle}"); LogUtil.info($"图像贴标角度:{labelAngle}");
...@@ -236,8 +248,8 @@ namespace DeviceLibrary ...@@ -236,8 +248,8 @@ namespace DeviceLibrary
LogUtil.info($"贴标角度差:+{labelAngle}={labelAngle}"); LogUtil.info($"贴标角度差:+{labelAngle}={labelAngle}");
labelAngle = Math.Abs(labelAngle - 180); //labelAngle = Math.Abs(labelAngle - 180);
LogUtil.info($"最终贴标角度:{labelAngle}"); //LogUtil.info($"最终贴标角度:{labelAngle}");
//labelAngle += Label_R_Angle_Diff; //labelAngle += Label_R_Angle_Diff;
//labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle; //labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
...@@ -252,10 +264,73 @@ namespace DeviceLibrary ...@@ -252,10 +264,73 @@ namespace DeviceLibrary
return p3; return p3;
} }
public static int GetPasteAngle(List<int> angles,int rightangle) {
Dictionary<int, List<int>> angleblock = new Dictionary<int, List<int>>();
angleblock.Add(0, new List<int>());
angleblock.Add(120, new List<int>());
angleblock.Add(180, new List<int>());
angleblock.Add(240, new List<int>());
angles.ForEach(x => {
var a =rightangle - x;
if (a < 0)
a = a * -1;
else if (a>0)
a = 360 - a;
foreach (var k in angleblock.Keys)
{
if (a > k - 50 && a < k + 50)
{
angleblock[k].Add(x);
}
}
});
foreach (var k in angleblock.Keys)
{
LogUtil.info($"{k}: {string.Join(",", angleblock[k])}");
}
if (angleblock[0].Count>0)
rightangle= GetAngleAvg(angleblock[0]);
//angleblock.Remove(0);
if (angleblock[120].Count > 0 || angleblock[240].Count >0) {
if (angleblock[120].Count>0)
return GetAngleAvg(angleblock[120]);
else
return rightangle + 120;
} else if (angleblock[180].Count>0)
{
return GetAngleAvg(angleblock[240]);
}
else {
if (angleblock[180].Count==0)
return rightangle+180;
else
return GetAngleAvg(angleblock[180]);
}
}
public static int GetAngleAvg(List<int> list) {
if (list.Count() == 0)
return 0;
if (list.Count() == 1)
return list[0];
list.Sort();
int curagv= list[0];
for (int i = 0; i < list.Count()-1; i++) {
var a = list[i + 1] - list[i];
if (a > 180)
{
curagv = (curagv + 360 + list[i + 1]) / 2;
}
else {
curagv = (curagv + list[i + 1]) / 2;
}
}
return curagv;
}
public static List<int> GetAnglesDistribution(List<int> angles, int AngleDiff) { public static List<int> GetAnglesDistribution(List<int> angles, int AngleDiff) {
angles.Sort(); angles.Sort();
List<List<int>> angleGroup = new List<List<int>>(); List<List<int>> angleGroup = new List<List<int>>();
List<int> anglesnew = new List<int>(); List<int> anglesnew = new List<int>();
int groupid = 0; int groupid = 0;
...@@ -278,7 +353,7 @@ namespace DeviceLibrary ...@@ -278,7 +353,7 @@ namespace DeviceLibrary
angleGroup.Add(new List<int>()); angleGroup.Add(new List<int>());
} }
angleGroup[groupid].Add(angles[i]); angleGroup[groupid].Add(angles[i]);
if (ad <= AngleDiff) if (Math.Abs(ad) <= AngleDiff)
{ {
if (i == angles.Count - 1) if (i == angles.Count - 1)
lastsame = true; lastsame = true;
......
...@@ -81,22 +81,28 @@ namespace DeviceLibrary ...@@ -81,22 +81,28 @@ namespace DeviceLibrary
CountMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(Setting_Init.XRay_Light_Delay)); CountMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(Setting_Init.XRay_Light_Delay));
} }
else { else {
if (RobotManage.XRay.Start())
{
CountMoveInfo.log($"打开X光第2次");
CountMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(Setting_Init.XRay_Light_Delay));
return;
}
CountMoveInfo.log($"X光打开失败"); CountMoveInfo.log($"X光打开失败");
retryopen:
retrytime++; retrytime++;
RobotManage.XRay.Close(); RobotManage.XRay.Close();
Thread.Sleep(1000);
if (!RobotManage.XRay.Open(Setting_Init.XRay_Port, string.Format("{0:yyyy-MM-dd}", DateTime.Now))) if (!RobotManage.XRay.Open(Setting_Init.XRay_Port, string.Format("{0:yyyy-MM-dd}", DateTime.Now)))
{ {
if (retrytime > 3)
{
Msg.add("X光打开失败", MsgLevel.warning); Msg.add("X光打开失败", MsgLevel.warning);
RobotManage.UserPause("X光打开失败"); RobotManage.UserPause("X光打开失败");
} }
else { goto retryopen;
if (retrytime < 3)
goto retry;
else {
Msg.add("X光打开失败", MsgLevel.warning);
RobotManage.UserPause("X光打开失败");
}
} }
Thread.Sleep(1000);
goto retry;
} }
break; break;
case MoveStep.Count_04: case MoveStep.Count_04:
...@@ -125,7 +131,7 @@ namespace DeviceLibrary ...@@ -125,7 +131,7 @@ namespace DeviceLibrary
CountMoveInfo.MoveParam.ReeID = CountMoveInfo.MoveParam.WareCode; CountMoveInfo.MoveParam.ReeID = CountMoveInfo.MoveParam.WareCode;
CountMoveInfo.MoveParam.PN = CountMoveInfo.MoveParam.codeInfos.Where(c=>c.CodeStr.StartsWith("AT")).FirstOrDefault()?.CodeStr; CountMoveInfo.MoveParam.PN = CountMoveInfo.MoveParam.codeInfos.Where(c=>c.CodeStr.StartsWith("AT")).FirstOrDefault()?.CodeStr;
if (string.IsNullOrWhiteSpace(CountMoveInfo.MoveParam.PN)) { if (string.IsNullOrWhiteSpace(CountMoveInfo.MoveParam.PN)) {
var hc =CountMoveInfo.MoveParam.codeInfos.Where(c => Regex.IsMatch(c.CodeStr, "@@(AT\\w*)@@")).FirstOrDefault()?.CodeStr; var hc =CountMoveInfo.MoveParam.codeInfos.Where(c => Regex.IsMatch(c.CodeStr, @"(?:@@|-)(AT\w*)(?:@@|-)")).FirstOrDefault()?.CodeStr;
var pn = Regex.Match(hc, "@@(AT\\w*)@@").Groups[1].Value; var pn = Regex.Match(hc, "@@(AT\\w*)@@").Groups[1].Value;
CountMoveInfo.MoveParam.PN = pn; CountMoveInfo.MoveParam.PN = pn;
} }
......
...@@ -115,6 +115,7 @@ namespace DeviceLibrary ...@@ -115,6 +115,7 @@ namespace DeviceLibrary
OutMoveInfo.MoveParam.IsNg = true; OutMoveInfo.MoveParam.IsNg = true;
OutMoveInfo.MoveParam.NgMsg = "没有获得Reelid"; OutMoveInfo.MoveParam.NgMsg = "没有获得Reelid";
OutMoveInfo.NextMoveStep(MoveStep.Out_20); OutMoveInfo.NextMoveStep(MoveStep.Out_20);
return;
} }
if (CountList.ContainsKey(OutMoveInfo.MoveParam.ReeID)) if (CountList.ContainsKey(OutMoveInfo.MoveParam.ReeID))
{ {
......
...@@ -23,25 +23,20 @@ namespace TheMachine ...@@ -23,25 +23,20 @@ namespace TheMachine
[STAThread] [STAThread]
static void Main() static void Main()
{ {
var xxx= System.Text.RegularExpressions.Regex.Match("@@5023520500@@ATAA000024@@700@@2226@@000847768514@@BAYXE", "@@(AT\\w*)@@").Groups[1].Value; int rightangle = 239;
int rightangle = 360-34; List<int> angles = new List<int> { 10,112,239,124, 358 };
List<int> angleset = new List<int> { -137, -34, 15 }; List<int> xxxxx = new List<int> { 358,300,310,10,50,100,90,90,90 };
var ass = angleset.Select(x => x < 0 ? 360 + x : x).ToList();
var xxx = Common.GetAngleAvg(xxxxx);
var aaa = Common.GetPasteAngle(angles, rightangle);
var angleset = Common.GetAnglesDistribution(angles, 30);
var ass = angleset.ToList();
ass.AddRange(ass.Select(x => x + 360).ToArray()); ass.AddRange(ass.Select(x => x + 360).ToArray());
ass.Sort(); ass.Sort();
int minangle = 720; int minangle = 720;
int minindex = 0; int minindex = 0;
for (int i = 0; i < ass.Count; i++) {
if (Math.Abs(ass[i] - rightangle) < minangle)
{
minangle = Math.Abs(ass[i] - rightangle);
minindex = i;
}
}
minangle = ass[minindex];
minangle = minangle > 360 ? minangle - 360 : minangle;
rightangle = minangle>=180?minangle - 180:minangle+180;
minangle = 720;
for (int i = 0; i < ass.Count; i++) for (int i = 0; i < ass.Count; i++)
{ {
if (Math.Abs(ass[i] - rightangle) < minangle) if (Math.Abs(ass[i] - rightangle) < minangle)
...@@ -50,6 +45,10 @@ var xxx= System.Text.RegularExpressions.Regex.Match("@@5023520500@@ATAA000024@@7 ...@@ -50,6 +45,10 @@ var xxx= System.Text.RegularExpressions.Regex.Match("@@5023520500@@ATAA000024@@7
minindex = i; minindex = i;
} }
} }
if (minindex < ass.Count - 1)
minangle = ass[minindex + 1];
else
minangle = ass[0];
var labelAngle = ass[minindex]; var labelAngle = ass[minindex];
_ = new Mutex(true, Application.ProductName, out bool ret); _ = new Mutex(true, Application.ProductName, out bool ret);
......
...@@ -82,7 +82,10 @@ ...@@ -82,7 +82,10 @@
<Reference Include="UserFromControl"> <Reference Include="UserFromControl">
<HintPath>..\..\SO775-DUOStore\dll\UserFromControl.dll</HintPath> <HintPath>..\..\SO775-DUOStore\dll\UserFromControl.dll</HintPath>
</Reference> </Reference>
<Reference Include="X-Ray, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> <Reference Include="X-Ray, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\X-Ray\X-Ray\bin\Debug\X-Ray.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AboutBox1.cs"> <Compile Include="AboutBox1.cs">
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!