Commit 64d60b01 刘韬

1

1 个父辈 d76580cd
...@@ -10,7 +10,7 @@ namespace OnlineStore.Common ...@@ -10,7 +10,7 @@ namespace OnlineStore.Common
{ {
public class SMF public class SMF
{ {
public static string DeviceType = "MIMO"; public static string DeviceType = "20117";
static string _server = Setting_Init.Device_Server_Address; static string _server = Setting_Init.Device_Server_Address;
static string server static string server
{ {
......
...@@ -182,7 +182,7 @@ namespace DeviceLibrary ...@@ -182,7 +182,7 @@ namespace DeviceLibrary
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
public static List<CodeInfo> CameraScan(List<string> cameraNameList) public static (List<CodeInfo>, string) CameraScan(List<string> cameraNameList)
{ {
HashSet<string> codestr = new HashSet<string>(); HashSet<string> codestr = new HashSet<string>();
List<CodeInfo> codeList = new List<CodeInfo>(); List<CodeInfo> codeList = new List<CodeInfo>();
...@@ -249,16 +249,16 @@ namespace DeviceLibrary ...@@ -249,16 +249,16 @@ namespace DeviceLibrary
{ {
lock (codeList) lock (codeList)
{ {
LogUtil.info("返回条码:" + string.Join("#" , cc.Select(c => { return c.CodeStr; }).ToArray())); LogUtil.info("返回条码:" + string.Join("#" , cc.Select(c => { return c.CodeType+":"+c.CodeStr; }).ToArray()));
cc.ForEach((c) => cc.ForEach((c) =>
{ {
//c.CodeStr = CodeManager.ReplaceCode(c.CodeStr); //c.CodeStr = CodeManager.ReplaceCode(c.CodeStr);
if (c.CodeStr.StartsWith("S20") || c.CodeStr.StartsWith("AT")) //if ((c.CodeStr.StartsWith("S20") && c.CodeType== "Data Matrix ECC 200") || c.CodeStr.StartsWith("AT"))
{ {
if (!codestr.Contains(c.CodeStr)) //if (!codestr.Contains(c.CodeStr))
{ {
codeList.Add(c); codeList.Add(c);
codestr.Add(c.CodeStr); //codestr.Add(c.CodeStr);
r += "##" + c.CodeStr; r += "##" + c.CodeStr;
} }
} }
...@@ -273,7 +273,7 @@ namespace DeviceLibrary ...@@ -273,7 +273,7 @@ namespace DeviceLibrary
} }
} }
} }
if (!hasRightCode) //if (!hasRightCode)
{ {
bitmapfilename = SaveImageToFile("mimo", cameraName, bmp); bitmapfilename = SaveImageToFile("mimo", cameraName, bmp);
} }
...@@ -320,7 +320,7 @@ namespace DeviceLibrary ...@@ -320,7 +320,7 @@ namespace DeviceLibrary
LogUtil.error( " 扫码出错:" + ex.ToString()); LogUtil.error( " 扫码出错:" + ex.ToString());
//throw new Exception("扫码出错"); //throw new Exception("扫码出错");
} }
return codeList; return (codeList, bitmapfilename);
} }
/// <summary> /// <summary>
......
...@@ -113,11 +113,11 @@ namespace DeviceLibrary ...@@ -113,11 +113,11 @@ namespace DeviceLibrary
Pen Greenpen = new Pen(Color.Green, 10); Pen Greenpen = new Pen(Color.Green, 10);
Bitmap srcbitmap; Bitmap srcbitmap;
//if (File.Exists(labelParam.bitmapfilename)) if (File.Exists(labelParam.bitmapfilename))
//{ {
// srcbitmap = new Bitmap(labelParam.bitmapfilename); srcbitmap = new Bitmap(labelParam.bitmapfilename);
//} }
//else else
{ {
srcbitmap = new Bitmap(3648, 3648); srcbitmap = new Bitmap(3648, 3648);
} }
...@@ -135,72 +135,113 @@ namespace DeviceLibrary ...@@ -135,72 +135,113 @@ namespace DeviceLibrary
Size pointsize = new Size(30, 30); Size pointsize = new Size(30, 30);
int widthOffset = 0; int widthOffset = 0;
//Point Right_Batch_Point = new Point(RobotManage.Config.Right_Batch_X, RobotManage.Config.Right_Batch_Y); g.FillEllipse(blue, new Rectangle(org, pointsize));
Point Right_Batch_Point = org;
g.FillEllipse(blue, new Rectangle(Right_Batch_Point, pointsize));
List<int> angles = new List<int>(); List<int> angles = new List<int>();
CodeInfo rightcode=null;
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")
return;
Point op = new Point(c.X, c.Y);
var a = (int)getAngle(org, op);
LogUtil.info($"{c.CodeType},{c.CodeStr},angles:{a}");
angles.Add(a);
if (c.CodeStr.Contains(labelParam.ReeID) && c.CodeType== "Data Matrix ECC 200")
{
rightcode = c;
}
});
//var x = c.Y;
//var y = srcbitmap_Width - c.X; if (rightcode != null)
//c.X = x;
//c.Y = y;
if (c.CodeStr.Contains(labelParam.ReeID))
{ {
Point op = new Point(c.X, c.Y); Point op = new Point(rightcode.X, rightcode.Y);
g.FillEllipse(blue, new Rectangle(op, pointsize)); g.FillEllipse(blue, new Rectangle(op, pointsize));
var a = (int)getAngle(Right_Batch_Point, op); var a = (int)getAngle(org, op);
a = a < 0 ? 360 + a : a; a = a < 0 ? 360 + a : a;
//g.FillEllipse(red, new Rectangle(PointRotate(org, op, a), pointsize)); //g.FillEllipse(red, new Rectangle(PointRotate(org, op, a), pointsize));
angles.Add(a); //angles.Add(a);
widthOffset = (int)Common.distance(org, op); widthOffset = (int)Common.distance(org, op);
LogUtil.info($"angles:{a}, widthOffset:{widthOffset}"); LogUtil.info($"angles:{a}, widthOffset:{widthOffset}");
rightangle = a;
} }
else {
});
if (angles.Count == 0)
{
labelAngle = 0; labelAngle = 0;
return Point.Empty; return Point.Empty;
} }
var angleset = GetAnglesDistribution(angles, 40);
LogUtil.info($"rightangle:{rightangle},angleset:{string.Join(",", angleset)}");
if (labelParam.PlateW == 15) if (labelParam.PlateW == 15)
{ {
labelAngle = angles[0] + 120; labelAngle = rightangle + 120;
} }
else if (labelParam.PlateW == 13) else if (labelParam.PlateW == 13)
{ {
labelAngle = angles[0] + 120; labelAngle = rightangle + 120;
} }
else else
{ {
//labelAngle = bigangles + biglen / 2; labelAngle = rightangle + 180;
labelAngle = angles[0] + 180; }
if (angleset.Count > 1 && labelParam.PlateW >= 13)
{
var ass = angleset.Select(x => x < 0 ? 360 + x : x).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)
{
minangle = Math.Abs(ass[i] - rightangle);
minindex = i;
}
}
labelAngle = ass[minindex];
LogUtil.info($"选择贴标角度:{labelAngle}");
} }
labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle; labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
LogUtil.info($"labelAngle1:{labelAngle}"); //labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
//匹配照片角度与贴标旋转轴的角度差 LogUtil.info($"图像贴标角度:{labelAngle}");
labelAngle += 83;
LogUtil.info($"labelAngle2:{labelAngle}");
//g.FillEllipse(red, new Rectangle(PointRotate(org, op, labelAngle), pointsize));
labelAngle = labelAngle + 180;
labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
LogUtil.info($"实际贴标角度:+180={labelAngle}");
//贴标坐标 //贴标坐标
var p2 = PointWithAngle(org, labelAngle, widthOffset); var p2 = PointWithAngle(org, labelAngle, widthOffset);
//贴标偏移 //贴标偏移
var p3 = PointWithAngle(p2, labelAngle, Label_R_Offset); var p3 = p2;// PointWithAngle(p2, labelAngle, Label_R_Offset);
g.FillEllipse(red, new Rectangle(p3, pointsize));
labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
labelAngle = 360 - labelAngle;
LogUtil.info($"labelAngle4:{labelAngle}");
labelAngle += Label_R_Angle_Diff; //匹配照片角度与贴标旋转轴的角度差
labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle; labelAngle += Label_R_Offset;
LogUtil.info($"labelAngle5:{labelAngle}"); LogUtil.info($"贴标角度差:+{labelAngle}={labelAngle}");
g.FillEllipse(red, new Rectangle(p3, pointsize));
labelAngle = Math.Abs(labelAngle - 180);
LogUtil.info($"最终贴标角度:{labelAngle}");
//labelAngle += Label_R_Angle_Diff;
//labelAngle = labelAngle > 360 ? labelAngle - 360 : labelAngle;
//LogUtil.info($"labelAngle5:{labelAngle}");
g.Save(); g.Save();
g.Dispose(); g.Dispose();
string dir = "/image/labeldebug/"; string dir = "/image/labeldebug/";
...@@ -211,6 +252,56 @@ namespace DeviceLibrary ...@@ -211,6 +252,56 @@ namespace DeviceLibrary
return p3; return p3;
} }
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;
bool lastsame = false;
for (int i = 0; i < angles.Count; i++)
{
int ad = 0;
if (i == angles.Count - 1)
{
ad = 360 - angles[angles.Count - 1] - angles[0];
}
else
{
ad = angles[i + 1] - angles[i];
}
//Console.WriteLine(ad);
if (angleGroup.Count < groupid + 1)
{
angleGroup.Add(new List<int>());
}
angleGroup[groupid].Add(angles[i]);
if (ad <= AngleDiff)
{
if (i == angles.Count - 1)
lastsame = true;
}
else
{
groupid++;
}
}
if (lastsame && angleGroup.Count > 1)
{
angleGroup[0].AddRange(angleGroup[angleGroup.Count - 1].Select(a => a-360));
angleGroup[angleGroup.Count - 1].AddRange(angleGroup[0].Select(a=>a+360));
};
angleGroup.ForEach(ag => { LogUtil.info(string.Join(",", ag)); });
var angleset = angleGroup.Select(ag => { return ag.Min() + (ag.Max() - ag.Min()) / 2; }).ToList();
LogUtil.info(string.Join(",", angleset));
return angleset;
}
static IdWorker id = new IdWorker(1, 1); static IdWorker id = new IdWorker(1, 1);
static string[] pnreglist; static string[] pnreglist;
static string[] qtyreglist; static string[] qtyreglist;
......
...@@ -49,6 +49,7 @@ namespace DeviceLibrary ...@@ -49,6 +49,7 @@ namespace DeviceLibrary
_WareCode = value; _WareCode = value;
} }
} }
public string bitmapfilename = "";
public string ReeID { get; set; } public string ReeID { get; set; }
public string PN { get; set; } public string PN { get; set; }
public string Algo { get; set; } public string Algo { get; set; }
...@@ -114,6 +115,34 @@ namespace DeviceLibrary ...@@ -114,6 +115,34 @@ namespace DeviceLibrary
return $"{PN},{PlateW}inch,{NgMsg},{QTY}"; return $"{PN},{PlateW}inch,{NgMsg},{QTY}";
} }
bool islog = false; bool islog = false;
public void logresult(string xrayfile = "", string resultfile = "")
{
if (!islog)
{
islog = true;
var datetime = DateTime.Now;
string countfile = $"\\XrayLogs\\{datetime:yyyyMMdd_HHmmss}_{QTY}.csv";
Directory.CreateDirectory("\\XrayLogs\\");
if (!File.Exists(countfile))
{
StreamWriter sw1 = new StreamWriter(countfile, true, Encoding.GetEncoding("GB2312"));
sw1.WriteLine($"ReelId,Quantity,DateCode,XFile,Operator");
sw1.Close();
sw1.Dispose();
}
var sw = new StreamWriter(countfile, true, Encoding.GetEncoding("GB2312"));
//var sw = File.Open(countfile, FileMode.Append, FileAccess.Write);
// string s = $"\r\n{ReeID},{PN},{PlateW}x{PlateH},{ReelDest},{NgMsg},{QTY},{WareCode}";
//var b = Encoding.GetEncoding("gb2312").GetBytes(s);
//sw.Write(b, 0, b.Length);
sw.WriteLine($"{ReeID},{QTY},{datetime:yyyy/MM/dd HH:mm:ss},{xrayfile},");
sw.Close();
sw.Dispose();
}
databaseProc.Current.InsertOrUpdateRI(UID, PN, ReeID, IsNg, NgMsg, QTY, LabelState, Algo, WareCode, xrayfile, resultfile);
}
/*
public void logresult(string xrayfile="",string resultfile="") public void logresult(string xrayfile="",string resultfile="")
{ {
if (!islog) if (!islog)
...@@ -139,7 +168,7 @@ namespace DeviceLibrary ...@@ -139,7 +168,7 @@ namespace DeviceLibrary
sw.Dispose(); sw.Dispose();
} }
databaseProc.Current.InsertOrUpdateRI(UID, PN, ReeID, IsNg, NgMsg, QTY, LabelState, Algo, WareCode,xrayfile,resultfile); databaseProc.Current.InsertOrUpdateRI(UID, PN, ReeID, IsNg, NgMsg, QTY, LabelState, Algo, WareCode,xrayfile,resultfile);
} }*/
public string GetImgName() public string GetImgName()
{ {
string timeName = "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png"; string timeName = "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
......
...@@ -123,9 +123,10 @@ namespace DeviceLibrary ...@@ -123,9 +123,10 @@ namespace DeviceLibrary
{ {
AxisBean axisBean = AxisBean.List.Find(a => a.Config.GetAxisValue() == wait.AxisInfo.GetAxisValue()); AxisBean axisBean = AxisBean.List.Find(a => a.Config.GetAxisValue() == wait.AxisInfo.GetAxisValue());
//等待信号亮或者走到绝对位置才停止 //等待信号亮或者走到绝对位置才停止
if (axisBean.TargetIoType.Where(io=> { return IOValue(io).Equals(axisBean.TargetIoValue); }).Count()>0) var tio = axisBean.TargetIoType.Where(io => { return IOValue(io).Equals(axisBean.TargetIoValue); });
if (tio.Count()>0)
{ {
LogUtil.info(Name + "CheckWaitResult 检测到" + axisBean.TargetIoType + "=" + axisBean.TargetIoValue + ",停止运行"); LogUtil.info(Name + "CheckWaitResult 检测到" + string.Join(",",tio.ToArray()) + "=" + axisBean.TargetIoValue + ",停止运行");
axisBean.StopAxisCheckMove(); axisBean.StopAxisCheckMove();
if (AxisManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(1)) if (AxisManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(1))
{ {
......
...@@ -353,7 +353,7 @@ namespace DeviceLibrary ...@@ -353,7 +353,7 @@ namespace DeviceLibrary
CylinderMove(ResetMoveInfo, IO_Type.Counting_ExitDoor_Close, IO_Type.Counting_ExitDoor_Open, IO_VALUE.LOW); CylinderMove(ResetMoveInfo, IO_Type.Counting_ExitDoor_Close, IO_Type.Counting_ExitDoor_Open, IO_VALUE.LOW);
if (IOValue(IO_Type.Counting_Reel_Check).Equals(IO_VALUE.HIGH)) if (IOValue(IO_Type.Counting_Reel_Check).Equals(IO_VALUE.HIGH))
{ {
CountMoveInfo.NewMove(MoveStep.Count_02); CountMoveInfo.NewMove(MoveStep.Count_01);
//CountMoveInfo.MoveParam.IsNg = true; //CountMoveInfo.MoveParam.IsNg = true;
//CountMoveInfo.MoveParam.NgMsg = "回原时发现无信息料"; //CountMoveInfo.MoveParam.NgMsg = "回原时发现无信息料";
CountMoveInfo.log("点料区有料直接开始点料"); CountMoveInfo.log("点料区有料直接开始点料");
...@@ -384,15 +384,12 @@ namespace DeviceLibrary ...@@ -384,15 +384,12 @@ namespace DeviceLibrary
bool SafeCheck() { bool SafeCheck() {
bool ok = true; bool ok = true;
var ignorestring = "[" + crc.GetString(L.ignored, "已忽略") + "]"; var ignorestring = "[" + crc.GetString(L.ignored, "已忽略") + "]";
//if (IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.AutoRun_Single).Equals(IO_VALUE.LOW))
//{ {
// if (!IgnoreSafecheck)// && IOValue(IO_Type.NGDoor_Open).Equals(IO_VALUE.HIGH)) ok = false;
// { DeviceSuddenStop();
// ok = false; Msg.add("运行开关未打开", MsgLevel.warning);
// DeviceSuddenStop(); }
// }
// Msg.add(crc.GetString(L.SafetyLight_is_block, "安全光栅被遮挡") + (ok ? ignorestring : ""), MsgLevel.warning);
//}
if (IOValue(IO_Type.Loading_SafeDoor_Check).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.Loading_SafeDoor_Check).Equals(IO_VALUE.LOW))
{ {
if (!IgnoreSafecheck) if (!IgnoreSafecheck)
...@@ -514,6 +511,13 @@ namespace DeviceLibrary ...@@ -514,6 +511,13 @@ namespace DeviceLibrary
+ crc.GetString(L.motion_alarm, "运动报警"), MsgLevel.alarm, ErrInfo.SuddenStop); + crc.GetString(L.motion_alarm, "运动报警"), MsgLevel.alarm, ErrInfo.SuddenStop);
ButtenEvent?.Invoke(null, ErrInfo.SuddenStop); ButtenEvent?.Invoke(null, ErrInfo.SuddenStop);
} }
var errcode = HuichuanLibrary.HCBoardManager.GetAxErrCode(configMoveAxis.GetAxisValue());
var errcodebyte = BitConverter.GetBytes(errcode).ToList();
errcodebyte.Reverse();
HuichuanLibrary.HCBoardManager.GetSdo((ushort)configMoveAxis.GetAxisValue(), 0x203f, 0, out byte[] data, out uint datalen);
var errdatabyte = data.ToList();
errdatabyte.Reverse();
LogUtil.error(configMoveAxis.GetAxisValue() + "," + configMoveAxis.Explain + " errcode " + BitConverter.ToString(errcodebyte.ToArray())+","+ BitConverter.ToString(errdatabyte.ToArray()));
ok = false; ok = false;
......
...@@ -10,6 +10,7 @@ using System.IO; ...@@ -10,6 +10,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
...@@ -46,11 +47,13 @@ namespace DeviceLibrary ...@@ -46,11 +47,13 @@ namespace DeviceLibrary
{ {
CountMoveInfo.MoveParam.PlateH = Setting_Init.Temp_Last_Reel_Height; CountMoveInfo.MoveParam.PlateH = Setting_Init.Temp_Last_Reel_Height;
CountMoveInfo.MoveParam.PlateW = Setting_Init.Temp_Last_Reel_Width; CountMoveInfo.MoveParam.PlateW = Setting_Init.Temp_Last_Reel_Width;
CountMoveInfo.log($"读取到存储的料盘尺寸:{CountMoveInfo.MoveParam.PlateW}x{CountMoveInfo.MoveParam.PlateH}");
} }
else if (Setting_Init.Temp_Last_Reel_Height > 0) else if (CountMoveInfo.MoveParam.PlateH > 0)
{ {
Setting_Init.Temp_Last_Reel_Height = CountMoveInfo.MoveParam.PlateH; Setting_Init.Temp_Last_Reel_Height = CountMoveInfo.MoveParam.PlateH;
Setting_Init.Temp_Last_Reel_Width = CountMoveInfo.MoveParam.PlateW; Setting_Init.Temp_Last_Reel_Width = CountMoveInfo.MoveParam.PlateW;
} }
else else
{ {
...@@ -70,25 +73,36 @@ namespace DeviceLibrary ...@@ -70,25 +73,36 @@ namespace DeviceLibrary
break; break;
case MoveStep.Count_03: case MoveStep.Count_03:
CountMoveInfo.NextMoveStep(MoveStep.Count_04); CountMoveInfo.NextMoveStep(MoveStep.Count_04);
int retrytime = 0;
retry:
if (RobotManage.XRay.Start()) if (RobotManage.XRay.Start())
{ {
CountMoveInfo.log($"打开X光"); CountMoveInfo.log($"打开X光");
CountMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(Setting_Init.XRay_Light_Delay)); CountMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(Setting_Init.XRay_Light_Delay));
} }
else { else {
Msg.add("X光打开失败",MsgLevel.warning); CountMoveInfo.log($"X光打开失败");
retrytime++;
RobotManage.XRay.Close();
if (!RobotManage.XRay.Open(Setting_Init.XRay_Port, string.Format("{0:yyyy-MM-dd}", DateTime.Now)))
{
Msg.add("X光打开失败", MsgLevel.warning);
RobotManage.UserPause("X光打开失败");
}
else {
if (retrytime < 3)
goto retry;
else {
Msg.add("X光打开失败", MsgLevel.warning);
RobotManage.UserPause("X光打开失败"); RobotManage.UserPause("X光打开失败");
} }
}
}
break; break;
case MoveStep.Count_04: case MoveStep.Count_04:
CountMoveInfo.NextMoveStep(MoveStep.Count_05);
GrabImageTask = GrabImageEX();
CountMoveInfo.log($"X光开始成像");
break;
case MoveStep.Count_05:
if (ScanTask.IsCompleted) if (ScanTask.IsCompleted)
{ {
var x = ScanTask.Result; var (x,s) = ScanTask.Result;
if (x.Count == 0) if (x.Count == 0)
{ {
CountMoveInfo.NextMoveStep(MoveStep.Count_ReadyOut); CountMoveInfo.NextMoveStep(MoveStep.Count_ReadyOut);
...@@ -99,9 +113,10 @@ namespace DeviceLibrary ...@@ -99,9 +113,10 @@ namespace DeviceLibrary
} }
else else
{ {
CountMoveInfo.NextMoveStep(MoveStep.Count_06); CountMoveInfo.NextMoveStep(MoveStep.Count_05);
CountMoveInfo.MoveParam.IsNg = false; CountMoveInfo.MoveParam.IsNg = false;
CountMoveInfo.MoveParam.codeInfos = x; CountMoveInfo.MoveParam.codeInfos = x;
CountMoveInfo.MoveParam.bitmapfilename = s;
var cc = x.Select((a) => a.CodeType+":"+a.CodeStr); var cc = x.Select((a) => a.CodeType+":"+a.CodeStr);
LastCode = String.Join("##", cc); LastCode = String.Join("##", cc);
CountMoveInfo.log("已完成扫码 Code:" + LastCode); CountMoveInfo.log("已完成扫码 Code:" + LastCode);
...@@ -109,12 +124,17 @@ namespace DeviceLibrary ...@@ -109,12 +124,17 @@ namespace DeviceLibrary
CountMoveInfo.MoveParam.WareCode = CountMoveInfo.MoveParam.codeInfos.Where(c=>c.CodeStr.StartsWith("S20")).FirstOrDefault().CodeStr; CountMoveInfo.MoveParam.WareCode = CountMoveInfo.MoveParam.codeInfos.Where(c=>c.CodeStr.StartsWith("S20")).FirstOrDefault().CodeStr;
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;
var xx = CountMoveInfo.MoveParam.codeInfos.Find(c=> { return c.CodeStr.StartsWith("S20") && c.CodeType == "barcode"; }); if (string.IsNullOrWhiteSpace(CountMoveInfo.MoveParam.PN)) {
if (xx != null) 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.codeInfos.Remove(xx); CountMoveInfo.MoveParam.PN = pn;
CountMoveInfo.log("移除了一个点料标签上的reelid");
} }
//var xx = CountMoveInfo.MoveParam.codeInfos.Find(c=> { return c.CodeStr.StartsWith("S20") && c.CodeType == "barcode"; });
//if (xx != null)
//{
// CountMoveInfo.MoveParam.codeInfos.Remove(xx);
// CountMoveInfo.log("移除了一个点料标签上的reelid");
//}
CountMoveInfo.log("codeProcess:" + CountMoveInfo.MoveParam.ReeID+";"+CountMoveInfo.MoveParam.PN); CountMoveInfo.log("codeProcess:" + CountMoveInfo.MoveParam.ReeID+";"+CountMoveInfo.MoveParam.PN);
} }
} }
...@@ -131,11 +151,16 @@ namespace DeviceLibrary ...@@ -131,11 +151,16 @@ namespace DeviceLibrary
{ {
CountMoveInfo.NextMoveStep(MoveStep.Count_ReadyOut); CountMoveInfo.NextMoveStep(MoveStep.Count_ReadyOut);
CountMoveInfo.MoveParam.IsNg = false; CountMoveInfo.MoveParam.IsNg = false;
CountMoveInfo.MoveParam.NgMsg = crc.GetString(L.scan_code_timeout, "扫码超时"); CountMoveInfo.MoveParam.NgMsg = "扫码超时";
CountMoveInfo.log($"等待扫码超时,NG口送出"); CountMoveInfo.log($"等待扫码超时,NG口送出");
} }
} }
break; break;
case MoveStep.Count_05:
CountMoveInfo.NextMoveStep(MoveStep.Count_06);
GrabImageTask = GrabImageEX();
CountMoveInfo.log($"X光开始成像");
break;
case MoveStep.Count_06: case MoveStep.Count_06:
if (GrabImageTask.IsCompleted) if (GrabImageTask.IsCompleted)
{ {
...@@ -233,19 +258,18 @@ namespace DeviceLibrary ...@@ -233,19 +258,18 @@ namespace DeviceLibrary
/// <summary> /// <summary>
/// 扫码线程 /// 扫码线程
/// </summary> /// </summary>
Task<List<CodeInfo>> ScanTask; Task<(List<CodeInfo>, string)> ScanTask;
public void ScanCode() { public void ScanCode() {
CountMoveInfo.log("开始扫码"); CountMoveInfo.log("开始扫码");
try try
{ {
ScanTask = Task.Run(new Func<List<CodeInfo>>(()=> ScanTask = Task.Run(new Func<(List<CodeInfo>, string)>(() =>
{ {
IOMove(IO_Type.Counting_Camera_Led, IO_VALUE.HIGH); IOMove(IO_Type.Counting_Camera_Led, IO_VALUE.HIGH);
List<CodeInfo> LastCodeList; var (LastCodeList, filename) = CodeManager.CameraScan(CodeManager.hikNameList);
LastCodeList = CodeManager.CameraScan(CodeManager.hikNameList);
return LastCodeList; return (LastCodeList, filename);
})); }));
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -134,9 +134,9 @@ namespace DeviceLibrary ...@@ -134,9 +134,9 @@ namespace DeviceLibrary
return; return;
} }
if (!innewreel) //if (!innewreel)
SetReelHeight(GetHeight(InCarMoveInfo)); // SetReelHeight(GetHeight(InCarMoveInfo));
innewreel = false; //innewreel = false;
break; break;
case MoveStep.InCarReadyGet: case MoveStep.InCarReadyGet:
Msg.add("入口料串取料准备就绪", MsgLevel.info); Msg.add("入口料串取料准备就绪", MsgLevel.info);
...@@ -258,6 +258,7 @@ namespace DeviceLibrary ...@@ -258,6 +258,7 @@ namespace DeviceLibrary
moveInfo.TimeOutSeconds = 200; moveInfo.TimeOutSeconds = 200;
moveInfo.CanWhileCount = 0; moveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服 // 需要增加定时器,获取验证信号并停止伺服
if (axisBean== Loading_Batch_Axis)
StartMovePosition = axisBean.GetAclPosition(); StartMovePosition = axisBean.GetAclPosition();
moveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxisMove(axisBean.Config, targetP2, targetSpeed)); moveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxisMove(axisBean.Config, targetP2, targetSpeed));
axisBean.Config.TargetPosition = targetP2; axisBean.Config.TargetPosition = targetP2;
...@@ -285,8 +286,6 @@ namespace DeviceLibrary ...@@ -285,8 +286,6 @@ namespace DeviceLibrary
string LastCode = ""; string LastCode = "";
private int GetHeight(MoveInfo moveInfo) private int GetHeight(MoveInfo moveInfo)
{ {
int LastHeight = 0; int LastHeight = 0;
int AxisChangeValue = Config.Loading_Batch_Axis_MMtoPOS; int AxisChangeValue = Config.Loading_Batch_Axis_MMtoPOS;
//计算高度 //计算高度
...@@ -303,6 +302,8 @@ namespace DeviceLibrary ...@@ -303,6 +302,8 @@ namespace DeviceLibrary
if (LastHeight <= 8) { LastHeight = 8; } if (LastHeight <= 8) { LastHeight = 8; }
string msg = Name + " 计算盘高:上升前 [" + StartMovePosition + "]实时[ " + EndMovePosition + "]差值[" + (EndMovePosition - StartMovePosition) + "]系数[" + AxisChangeValue + "] 计算后" + buchongStr + "[" + height + "]" + ",归类为【" + LastHeight + "mm】条码【" + LastCode + "】"; string msg = Name + " 计算盘高:上升前 [" + StartMovePosition + "]实时[ " + EndMovePosition + "]差值[" + (EndMovePosition - StartMovePosition) + "]系数[" + AxisChangeValue + "] 计算后" + buchongStr + "[" + height + "]" + ",归类为【" + LastHeight + "mm】条码【" + LastCode + "】";
LogUtil.info(msg); LogUtil.info(msg);
if (LastHeight > 80)
LastHeight = 80;
return LastHeight; return LastHeight;
if (moveInfo.MoveParam.PlateW == 15) if (moveInfo.MoveParam.PlateW == 15)
......
...@@ -40,7 +40,7 @@ namespace DeviceLibrary ...@@ -40,7 +40,7 @@ namespace DeviceLibrary
InMoveInfo.MoveParam = InCarMoveInfo.MoveParam.clone(); InMoveInfo.MoveParam = InCarMoveInfo.MoveParam.clone();
var frompos = "Loading_T" + InCurrentStringNum; var frompos = "Loading_T" + InCurrentStringNum;
InFromPos = RobotManage.InCarReelPostion[frompos]; InFromPos = RobotManage.InCarReelPostion[frompos];
InToPos= RobotManage.InCarReelPostion["Loading_Counting"]; InToPos= RobotManage.InCarReelPostion["Loading_Counting_T" + InCurrentStringNum];
InMoveInfo.log($"料盘已经准备好:{frompos}"); InMoveInfo.log($"料盘已经准备好:{frompos}");
} }
break; break;
......
...@@ -30,17 +30,17 @@ namespace DeviceLibrary ...@@ -30,17 +30,17 @@ namespace DeviceLibrary
Label_Y_Axis.AbsMove(LabelMoveInfo, Config.Label_Y_P1, Config.Label_Y_P1_speed); Label_Y_Axis.AbsMove(LabelMoveInfo, Config.Label_Y_P1, Config.Label_Y_P1_speed);
Label_Z_Axis.AbsMove(LabelMoveInfo, Config.Label_Z_P1, Config.Label_Z_P2_speed); Label_Z_Axis.AbsMove(LabelMoveInfo, Config.Label_Z_P1, Config.Label_Z_P2_speed);
LabelMoveInfo.log("xy待机点"); LabelMoveInfo.log("xy待机点");
if (OutMoveInfo.MoveStep == MoveStep.Out_WaitForLabel)
{
OutMoveInfo.NextMoveStep(MoveStep.Out_LabelFinished);
LabelMoveInfo.log("通知OutMoveInfo贴标完成");
}
break; break;
case MoveStep.Lbl_01: case MoveStep.Lbl_01:
LabelMoveInfo.NextMoveStep(MoveStep.Lbl_02); LabelMoveInfo.NextMoveStep(MoveStep.Lbl_02);
Label_R_Axis.AbsMove(LabelMoveInfo, Config.Label_R_P2, Config.Label_Z_P2_speed); Label_R_Axis.AbsMove(LabelMoveInfo, Config.Label_R_P2, Config.Label_Z_P2_speed);
LabelMoveInfo.log("Label_R转到取标点"); LabelMoveInfo.log("Label_R转到取标点");
if (OutMoveInfo.MoveStep == MoveStep.Out_WaitForLabel)
{
OutMoveInfo.NextMoveStep(MoveStep.Out_LabelFinished);
LabelMoveInfo.log("通知OutMoveInfo贴标完成");
}
break; break;
case MoveStep.Lbl_02: case MoveStep.Lbl_02:
LabelMoveInfo.NextMoveStep(MoveStep.Lbl_03); LabelMoveInfo.NextMoveStep(MoveStep.Lbl_03);
...@@ -69,7 +69,7 @@ namespace DeviceLibrary ...@@ -69,7 +69,7 @@ namespace DeviceLibrary
break; break;
case MoveStep.Lbl_05: case MoveStep.Lbl_05:
LabelMoveInfo.NextMoveStep(MoveStep.Lbl_06); LabelMoveInfo.NextMoveStep(MoveStep.Lbl_06);
LabelMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500)); LabelMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
break; break;
case MoveStep.Lbl_06: case MoveStep.Lbl_06:
LabelMoveInfo.NextMoveStep(MoveStep.Lbl_07); LabelMoveInfo.NextMoveStep(MoveStep.Lbl_07);
...@@ -89,18 +89,37 @@ namespace DeviceLibrary ...@@ -89,18 +89,37 @@ namespace DeviceLibrary
case MoveStep.Lbl_10: case MoveStep.Lbl_10:
//照片中料盘中心点像素位置 //照片中料盘中心点像素位置
Point Pixel_Center_Point = new Point(Config.Graphe_Center_X, Config.Graphe_Center_Y); Point Pixel_Center_Point = new Point(Config.Graphe_Center_X, Config.Graphe_Center_Y);
var cc = RobotManage.LabellingPostion["Labelling_T"+ LabelMoveInfo.MoveParam.CurrentStringNum]; var cc = RobotManage.LabellingPostion["Labelling_T"+ LabelMoveInfo.MoveParam.CurrentStringNum];
LabelMoveInfo.log("贴标盘位:"+ "Labelling_T" + LabelMoveInfo.MoveParam.CurrentStringNum);
Point Axis_Center_Point = new Point(cc.X_Base, cc.Y_Base); Point Axis_Center_Point = new Point(cc.X_Base, cc.Y_Base);
//计算照片中贴标的像素位置 //计算照片中贴标的像素位置
Point p = Common.CalcLabelPoint(LabelMoveInfo.MoveParam, Pixel_Center_Point, 0, 0, out int labelAngle); Point p = Common.CalcLabelPoint(LabelMoveInfo.MoveParam, Pixel_Center_Point, (int)cc.Label_R_Offset_Angle, 0, out int labelAngle);
LabelMoveInfo.log($"源坐标:{p}");
var x = p.X;
var y = p.Y;
p.Y= 5472 - x;
p.X = y;
LabelMoveInfo.log($"变换坐标:{p}");
labelAngle = 360 - labelAngle;
LabelMoveInfo.log($"贴标逆时针角度:{labelAngle}");
if (labelAngle > 180)
labelAngle-= 180;
LabelMoveInfo.log($"贴标逆时针角度:-180={labelAngle}");
if (labelAngle > 350) labelAngle += 90;
labelAngle = 350; if (labelAngle > 180)
labelAngle -= 180;
Pixel_Center_Point = new Point(Config.Graphe_Center_Y, 5472 - Config.Graphe_Center_X);
//计算贴标角度的脉冲值 //计算贴标角度的脉冲值
int labelAxisPos = Config.Label_R_360 / 350 * labelAngle; int labelAxisPos = Config.Label_R_360 / 180 * labelAngle;
//计算像素点位与中心点的差 //计算像素点位与中心点的差
Label_p3 = new Point(p.X - Pixel_Center_Point.X , p.Y - Pixel_Center_Point.Y); Label_p3 = new Point(p.X - Pixel_Center_Point.X , p.Y - Pixel_Center_Point.Y);
//计算像素*脉冲像素比得到脉冲值+中心点基准脉冲 //计算像素*脉冲像素比得到脉冲值+中心点基准脉冲
......
...@@ -102,6 +102,24 @@ namespace DeviceLibrary ...@@ -102,6 +102,24 @@ namespace DeviceLibrary
BatchAxisToP2(OutCarMoveInfo, Unloading_Batch_Axis, OutGetReelCheckIOList(), IO_VALUE.LOW, Config.Unloading_Batch_Axis_P1, Config.Unloading_Batch_Axis_P1_speed); BatchAxisToP2(OutCarMoveInfo, Unloading_Batch_Axis, OutGetReelCheckIOList(), IO_VALUE.LOW, Config.Unloading_Batch_Axis_P1, Config.Unloading_Batch_Axis_P1_speed);
break; break;
case MoveStep.OutCar_07: case MoveStep.OutCar_07:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_08);
OutCurrentStringNum = GetBottomStringNum(OutGetLowReelCheckIOList());
OutCarMoveInfo.log($"第一次检测到最低料串为:{OutCurrentStringNum}");
OutCarMoveInfo.log($"批量轴下降1mm再次检测");
Unloading_Batch_Axis.AbsMove(OutCarMoveInfo,Unloading_Batch_Axis.GetAclPosition()-Config.Unloading_UpDown_Axis_MMtoPOS, Config.Unloading_UpDown_Axis_P1_speed);
break;
case MoveStep.OutCar_08:
var cur = GetBottomStringNum(OutGetLowReelCheckIOList());
OutCarMoveInfo.log($"当前low={cur},上次low={OutCurrentStringNum}");
if (cur != OutCurrentStringNum)
{
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_06);
}
else {
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_09);
}
break;
case MoveStep.OutCar_09:
if (Unloading_Batch_Axis.IsInPosition(Config.Unloading_Batch_Axis_P1)) if (Unloading_Batch_Axis.IsInPosition(Config.Unloading_Batch_Axis_P1))
{ {
OutCarMoveInfo.NextMoveStep(MoveStep.OutCarOut_01); OutCarMoveInfo.NextMoveStep(MoveStep.OutCarOut_01);
......
...@@ -16,6 +16,7 @@ namespace DeviceLibrary ...@@ -16,6 +16,7 @@ namespace DeviceLibrary
{ {
OutCarReelPostion OutFromPos; OutCarReelPostion OutFromPos;
OutCarReelPostion OutToPos; OutCarReelPostion OutToPos;
int takeretry = 0;
void OutMoveProcess() void OutMoveProcess()
{ {
if (CheckWait(OutMoveInfo)) if (CheckWait(OutMoveInfo))
...@@ -29,6 +30,8 @@ namespace DeviceLibrary ...@@ -29,6 +30,8 @@ namespace DeviceLibrary
OutMoveInfo.MoveParam = CountMoveInfo.MoveParam.clone(); OutMoveInfo.MoveParam = CountMoveInfo.MoveParam.clone();
OutFromPos = RobotManage.OutCarReelPostion["Unloading_Counting"]; OutFromPos = RobotManage.OutCarReelPostion["Unloading_Counting"];
OutMoveInfo.log($"点料区料盘已经准备好:"+OutMoveInfo.MoveParam.ToDetailStr()); OutMoveInfo.log($"点料区料盘已经准备好:"+OutMoveInfo.MoveParam.ToDetailStr());
var cc = OutMoveInfo.MoveParam.codeInfos.Select((a) => a.CodeType + ":" + a.CodeStr);
OutMoveInfo.log(String.Join("##", cc));
} }
break; break;
case MoveStep.Out_01: case MoveStep.Out_01:
...@@ -51,10 +54,13 @@ namespace DeviceLibrary ...@@ -51,10 +54,13 @@ namespace DeviceLibrary
OutMoveInfo.NextMoveStep(MoveStep.Out_05); OutMoveInfo.NextMoveStep(MoveStep.Out_05);
Unloading_InOut_Axis.AbsMove(OutMoveInfo, OutFromPos.InOut_P2, Config.Unloading_InOut_Axis_P1_speed); Unloading_InOut_Axis.AbsMove(OutMoveInfo, OutFromPos.InOut_P2, Config.Unloading_InOut_Axis_P1_speed);
OutMoveInfo.log($"进出轴达取料p2点"); OutMoveInfo.log($"进出轴达取料p2点");
takeretry = 0;
break; break;
case MoveStep.Out_05: case MoveStep.Out_05:
OutMoveInfo.NextMoveStep(MoveStep.Out_06); OutMoveInfo.NextMoveStep(MoveStep.Out_06);
var pos = OutFromPos.UpDown_P3 - (OutMoveInfo.MoveParam.PlateH - 8) * Config.Unloading_UpDown_Axis_MMtoPOS; var pos = OutFromPos.UpDown_P3 - (OutMoveInfo.MoveParam.PlateH - 8) * Config.Unloading_UpDown_Axis_MMtoPOS;
if (pos < 0)
pos = 0;
Unloading_UpDown_Axis.AbsMove(OutMoveInfo, pos, Config.Unloading_UpDown_Axis_P1_speed); Unloading_UpDown_Axis.AbsMove(OutMoveInfo, pos, Config.Unloading_UpDown_Axis_P1_speed);
OutMoveInfo.log($"升降轴到达取料p3点,pos:{pos},PlateH:{OutMoveInfo.MoveParam.PlateH}"); OutMoveInfo.log($"升降轴到达取料p3点,pos:{pos},PlateH:{OutMoveInfo.MoveParam.PlateH}");
break; break;
...@@ -78,9 +84,19 @@ namespace DeviceLibrary ...@@ -78,9 +84,19 @@ namespace DeviceLibrary
} }
else else
{ {
takeretry++;
OutMoveInfo.MoveParam.PlateH--;
OutMoveInfo.log($"未取到料盘");
if (takeretry < 3)
{
OutMoveInfo.NextMoveStep(MoveStep.Out_05);
OutMoveInfo.log($"重试取盘:"+ OutMoveInfo.MoveParam.PlateH);
}
else
{
Msg.add("出口取盘失败", MsgLevel.alarm); Msg.add("出口取盘失败", MsgLevel.alarm);
RobotManage.UserPause("出口取盘失败"); RobotManage.UserPause("出口取盘失败");
OutMoveInfo.log($"未取到料盘"); }
} }
break; break;
case MoveStep.Out_09: case MoveStep.Out_09:
...@@ -109,7 +125,7 @@ namespace DeviceLibrary ...@@ -109,7 +125,7 @@ namespace DeviceLibrary
{ {
CountList.Remove(OutMoveInfo.MoveParam.ReeID); CountList.Remove(OutMoveInfo.MoveParam.ReeID);
} }
if (OutMoveInfo.MoveParam.QTY > 0) if (OutMoveInfo.MoveParam.QTY >= 0)
SetPrintJob(OutMoveInfo); SetPrintJob(OutMoveInfo);
else { else {
OutMoveInfo.MoveParam.IsNg = true; OutMoveInfo.MoveParam.IsNg = true;
...@@ -177,8 +193,13 @@ namespace DeviceLibrary ...@@ -177,8 +193,13 @@ namespace DeviceLibrary
break; break;
case MoveStep.Out_22: case MoveStep.Out_22:
OutMoveInfo.NextMoveStep(MoveStep.Out_23); OutMoveInfo.NextMoveStep(MoveStep.Out_23);
Unloading_UpDown_Axis.AbsMove(OutMoveInfo, OutToPos.UpDown_P3, Config.Unloading_UpDown_Axis_P1_speed); var pos1 = OutToPos.UpDown_P3 - (OutMoveInfo.MoveParam.PlateH - 8) * Config.Unloading_UpDown_Axis_MMtoPOS;
OutMoveInfo.log($"升降轴到达p3点"); if (pos1 < 0)
pos1 = 0;
Unloading_UpDown_Axis.AbsMove(OutMoveInfo, pos1, Config.Unloading_UpDown_Axis_P1_speed);
OutMoveInfo.log($"升降轴到达放料p3点,pos:{pos1},PlateH:{OutMoveInfo.MoveParam.PlateH}");
//Unloading_UpDown_Axis.AbsMove(OutMoveInfo, OutToPos.UpDown_P3, Config.Unloading_UpDown_Axis_P1_speed);
//OutMoveInfo.log($"升降轴到达p3点");
break; break;
case MoveStep.Out_23: case MoveStep.Out_23:
OutMoveInfo.NextMoveStep(MoveStep.Out_24); OutMoveInfo.NextMoveStep(MoveStep.Out_24);
...@@ -212,18 +233,29 @@ namespace DeviceLibrary ...@@ -212,18 +233,29 @@ namespace DeviceLibrary
Unloading_Middle_Axis.AbsMove(OutMoveInfo, Config.Unloading_Middle_Axis_P1, Config.Unloading_Middle_Axis_P1_speed); Unloading_Middle_Axis.AbsMove(OutMoveInfo, Config.Unloading_Middle_Axis_P1, Config.Unloading_Middle_Axis_P1_speed);
Unloading_UpDown_Axis.AbsMove(OutMoveInfo, Config.Unloading_UpDown_Axis_P1, Config.Unloading_UpDown_Axis_P1_speed); Unloading_UpDown_Axis.AbsMove(OutMoveInfo, Config.Unloading_UpDown_Axis_P1, Config.Unloading_UpDown_Axis_P1_speed);
OutMoveInfo.log($"旋转轴,升降轴到达p1点,完成出口放料"); OutMoveInfo.log($"旋转轴,升降轴到达p1点,完成出口放料");
//
Unloading_Batch_Axis.RelMove(OutMoveInfo.MoveParam.PlateH * Config.Unloading_UpDown_Axis_MMtoPOS*-1, Config.Unloading_UpDown_Axis_P1_speed);
OutMoveInfo.log($"批量轴高速下降:{OutMoveInfo.MoveParam.PlateH * Config.Unloading_UpDown_Axis_MMtoPOS * -1}");
break; break;
case MoveStep.Out_28: case MoveStep.Out_28:
if (!Unloading_Batch_Axis.IsBusy) OutMoveInfo.NextMoveStep(MoveStep.Out_29);
{ var pos3 = Unloading_Batch_Axis.GetAclPosition();
OutMoveInfo.NextMoveStep(MoveStep.Out_WaitForLabel); pos3 = pos3 - Config.Unloading_UpDown_Axis_MMtoPOS * 30;
if (pos3 < 0)
pos3 = 0;
Unloading_Batch_Axis.AbsMove(OutMoveInfo, pos3, Config.Unloading_Batch_Axis_P1_speed);
//Unloading_Batch_Axis.RelMove(OutMoveInfo.MoveParam.PlateH/2 * Config.Unloading_UpDown_Axis_MMtoPOS*-1, Config.Unloading_UpDown_Axis_P1_speed);
OutMoveInfo.log($"批量轴高速下降:{pos3}");
break;
case MoveStep.Out_29:
OutMoveInfo.NextMoveStep(MoveStep.Out_30);
BatchAxisToP2(OutMoveInfo, Unloading_Batch_Axis, OutGetReelCheckIOList(OutCurrentStringNum), IO_VALUE.LOW, Config.Unloading_Batch_Axis_P1, Config.Unloading_Batch_Axis_P1_speed); BatchAxisToP2(OutMoveInfo, Unloading_Batch_Axis, OutGetReelCheckIOList(OutCurrentStringNum), IO_VALUE.LOW, Config.Unloading_Batch_Axis_P1, Config.Unloading_Batch_Axis_P1_speed);
OutMoveInfo.log($"批量轴高速下降到检测点灭"); OutMoveInfo.log($"批量轴快速下降到监测点灭");
} break;
case MoveStep.Out_30:
OutMoveInfo.NextMoveStep(MoveStep.Out_31);
BatchAxisToP2(OutMoveInfo, Unloading_Batch_Axis, OutGetReelCheckIOList(OutCurrentStringNum), IO_VALUE.HIGH, Config.Unloading_Batch_Axis_P2, Config.Unloading_Batch_Axis_P2_speed);
OutMoveInfo.log($"批量轴慢速上升到检测点亮");
break;
case MoveStep.Out_31:
OutMoveInfo.NextMoveStep(MoveStep.Out_WaitForLabel);
break; break;
case MoveStep.Out_WaitForLabel: case MoveStep.Out_WaitForLabel:
Msg.add("等待贴标", MsgLevel.info); Msg.add("等待贴标", MsgLevel.info);
......
...@@ -17,6 +17,9 @@ namespace DeviceLibrary ...@@ -17,6 +17,9 @@ namespace DeviceLibrary
void SetPrintJob(MoveInfo reel) { void SetPrintJob(MoveInfo reel) {
reel.log("设置打印任务:"+reel.MoveParam.ToDetailStr()); reel.log("设置打印任务:"+reel.MoveParam.ToDetailStr());
PrintJob = reel.MoveParam.clone(); PrintJob = reel.MoveParam.clone();
var cc = PrintJob.codeInfos.Select((a) => a.CodeType + ":" + a.CodeStr);
CountMoveInfo.log("打印时 Code:" + String.Join("##", cc));
} }
readonly MoveInfo PrintMoveInfo = new MoveInfo("", false); readonly MoveInfo PrintMoveInfo = new MoveInfo("", false);
...@@ -52,6 +55,7 @@ namespace DeviceLibrary ...@@ -52,6 +55,7 @@ namespace DeviceLibrary
if (result) if (result)
{ {
PrintMoveInfo.NextMoveStep(MoveStep.Print_04); PrintMoveInfo.NextMoveStep(MoveStep.Print_04);
PrintMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
PrintMoveInfo.log("打印成功,等待标签被取走"); PrintMoveInfo.log("打印成功,等待标签被取走");
} }
else else
......
...@@ -101,6 +101,7 @@ namespace DeviceLibrary ...@@ -101,6 +101,7 @@ namespace DeviceLibrary
OutCar_06, OutCar_06,
OutCar_07, OutCar_07,
OutCar_08, OutCar_08,
OutCar_09,
OutCarReadyPut, OutCarReadyPut,
OutCarReelPut, OutCarReelPut,
OutCarOut_01, OutCarOut_01,
...@@ -141,6 +142,8 @@ namespace DeviceLibrary ...@@ -141,6 +142,8 @@ namespace DeviceLibrary
Out_27, Out_27,
Out_28, Out_28,
Out_29, Out_29,
Out_30,
Out_31,
Out_WaitForLabel, Out_WaitForLabel,
Out_LabelFinished, Out_LabelFinished,
......
...@@ -155,10 +155,17 @@ namespace DeviceLibrary ...@@ -155,10 +155,17 @@ namespace DeviceLibrary
if (!IsConfigMode) if (!IsConfigMode)
return; return;
} }
lock (mainMachine)
{
if (isRunning)
{
LogUtil.info("系统已经在运行");
return;
}
isRunning = true;
mainThread = new Thread(new ThreadStart(mainMachine.Start)); mainThread = new Thread(new ThreadStart(mainMachine.Start));
mainThread.Start(); mainThread.Start();
}
isRunning = true;
GC.KeepAlive(mainThread); GC.KeepAlive(mainThread);
Task.Run(()=> { Task.Run(()=> {
AxisBean.List.ForEach((x) => { AxisManager.AlarmClear(x.Config.DeviceName, x.Config.GetAxisValue()); }); AxisBean.List.ForEach((x) => { AxisManager.AlarmClear(x.Config.DeviceName, x.Config.GetAxisValue()); });
......
位置,备注,旋转轴位置P2,升降轴高点P2,升降轴低点P3,进出轴库取料点P2 位置,备注,旋转轴位置P2,升降轴高点P2,升降轴低点P3,进出轴库取料点P2
Loading_T1,入口料车7寸放料点,219347,31048,20240,236990 Loading_T1,入口料车7寸放料点,22185,0,140000,494559
Loading_T2,入口料车7寸放料点,219347,60595,49787,236990 Loading_T2,入口料车7寸放料点,25964,0,140000,276000
Loading_T3,入口料车13/15寸放料点,219347,91377,80569,236990 Loading_T3,入口料车13/15寸放料点,13650,0,131000,369000
Loading_T4,入口料车7寸放料点,219347,121147,110339,236990 Loading_T4,入口料车7寸放料点,5596,0,140000,492403
Loading_T5,入口料车7寸放料点,219347,151889,141081,236990 Loading_T5,入口料车7寸放料点,2758,0,140000,276681
Loading_Counting,入口点料机放料点,219347,151889,141081,236990 Loading_Counting_T1,入口点料机放料点,193164,0,60000,489637
Loading_Counting_T2,入口点料机放料点,193164,0,60000,489637
Loading_Counting_T3,入口点料机放料点,193164,0,60000,489637
Loading_Counting_T4,入口点料机放料点,193164,0,60000,489637
Loading_Counting_T5,入口点料机放料点,193164,0,60000,489637
位置,备注,X轴基准点,Y轴基准点,Z轴贴标高点P4,Z轴贴标点P5,R轴偏转 位置,备注,X轴基准点,Y轴基准点,Z轴贴标高点P4,Z轴贴标点P5,R轴偏转
Labelling_T1,贴标点7寸,219347,31048,20240,236990,9 Labelling_T1,贴标点7寸,280326,427823,0,42500,9
Labelling_T2,贴标点7寸,219347,60595,49787,236990,11 Labelling_T2,贴标点7寸,54606,427823,0,40000,11
Labelling_T3,贴标点13/15寸,219347,91377,80569,236990,0 Labelling_T3,贴标点13/15寸,172667,323227,0,43000,0
Labelling_T4,贴标点7寸,219347,121147,110339,236990,11 Labelling_T4,贴标点7寸,54606,216008,0,43000,11
Labelling_T5,贴标点7寸,219347,151889,141081,236990,9 Labelling_T5,贴标点7寸,280326,216008,0,46000,9
位置,备注,旋转轴位置P2,升降轴高点P2,升降轴低点P3,进出轴库取料点P2 位置,备注,旋转轴位置P2,升降轴高点P2,升降轴低点P3,进出轴库取料点P2
Unloading_T1,出口料车7寸放料点,219347,182278,171470,236990 Unloading_T1,出口料车7寸放料点,26587,0,135000,254909
Unloading_T2,出口料车7寸放料点,219347,212452,201644,236990 Unloading_T2,出口料车7寸放料点,22539,0,135000,468256
Unloading_T3,出口料车13/15寸放料点,219347,242880,232072,236990 Unloading_T3,出口料车13/15寸放料点,14743,0,124000,365308
Unloading_T4,出口料车7寸放料点,219347,273824,263016,236990 Unloading_T4,出口料车7寸放料点,6492,0,135000,469143
Unloading_T5,出口料车7寸放料点,219347,303630,292822,236990 Unloading_T5,出口料车7寸放料点,2813,0,135000,254513
Unloading_Counting,出口点料机取料点,219347,151889,141081,236990 Unloading_Counting,出口点料机取料点,195571,0,100000,503410
Unloading_NgBox,出口NG料箱放料点,219347,151889,141081,236990 Unloading_NgBox,出口NG料箱放料点,284692,0,151761,146725
using ConfigHelper; using ConfigHelper;
using DeviceLibrary;
using log4net.Config; using log4net.Config;
using OnlineStore.Common; using OnlineStore.Common;
using System; using System;
...@@ -22,6 +23,34 @@ namespace TheMachine ...@@ -22,6 +23,34 @@ 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 = 360-34;
List<int> angleset = new List<int> { -137, -34, 15 };
var ass = angleset.Select(x => x < 0 ? 360 + x : x).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)
{
minangle = Math.Abs(ass[i] - rightangle);
minindex = i;
}
}
var labelAngle = ass[minindex];
_ = new Mutex(true, Application.ProductName, out bool ret); _ = new Mutex(true, Application.ProductName, out bool ret);
if (!ret) if (!ret)
......
...@@ -82,7 +82,7 @@ namespace TheMachine ...@@ -82,7 +82,7 @@ namespace TheMachine
void loadlabellist() { void loadlabellist() {
cb_labelselect.Items.Clear(); cb_labelselect.Items.Clear();
cb_labelselect.Items.AddRange(RobotManage.printerHelper.GetLabelList()); cb_labelselect.Items.AddRange(RobotManage.printerHelper.GetLabelList());
cb_labelselect.SelectedText = Setting_Init.Printer_Labelname; cb_labelselect.SelectedItem = Setting_Init.Printer_Labelname.Val;
} }
private void btn_Calibration_Click(object sender, EventArgs e) private void btn_Calibration_Click(object sender, EventArgs e)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!