Commit f5dc9139 刘韬

1

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