Commit 856fa861 刘韬

一些bug修正

1 个父辈 81789272
正在显示 25 个修改的文件 包含 830 行增加198 行删除
......@@ -510,7 +510,7 @@ namespace OnlineStore.AutoCountClient
{
equipBean.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
List<string> LastCodeList = CodeManager.CameraScan(equipBean.Name+"测试",equipBean.Config.LeftCamera );
string msg = CodeManager.GetValidCode(LastCodeList);
string msg = CodeManager.GetValidCode(LastCodeList,out _);
equipBean.IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
LogUtil.info(equipBean.Name + "[" + equipBean.Config.LeftCamera + "]扫码测试结果:\r\n" + msg);
MessageBox.Show(equipBean.Name + "[" + equipBean.Config.LeftCamera + "]扫码测试结果:" + msg);
......@@ -645,7 +645,7 @@ namespace OnlineStore.AutoCountClient
{
equipBean.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
List<string> LastCodeList = CodeManager.CameraScan(equipBean.Name+"测试",equipBean.Config.RightCamera );
string msg = CodeManager.GetValidCode(LastCodeList);
string msg = CodeManager.GetValidCode(LastCodeList,out _);
equipBean.IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
LogUtil.info(equipBean.Name + "[" + equipBean.Config.RightCamera + "]扫码测试结果:\r\n" + msg);
MessageBox.Show(equipBean.Name + "[" + equipBean.Config.RightCamera + "]扫码测试结果:" + msg);
......
......@@ -107,7 +107,7 @@ namespace OnlineStore.AutoCountClient
string filename = Path.GetFileNameWithoutExtension(fullFName);
string[] array = filename.Split('-');
string[] array = filename.Split(new char[] { '-', ';' });
CurrPN = array[0];
groupBox4.Text = "[" + CurrPN + "] 请选择参数:";
......
......@@ -64,6 +64,7 @@
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.chbStickingPos = new System.Windows.Forms.CheckBox();
this.btnShelfReset = new System.Windows.Forms.Button();
this.btnLabelReset = new System.Windows.Forms.Button();
this.btnMoveReset = new System.Windows.Forms.Button();
......@@ -157,7 +158,7 @@
this.lblName = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.chbMoveStop = new System.Windows.Forms.CheckBox();
this.chbStickingPos = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
......@@ -799,6 +800,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox6.Controls.Add(this.chbStickingPos);
this.groupBox6.Controls.Add(this.btnShelfReset);
this.groupBox6.Controls.Add(this.button1);
this.groupBox6.Controls.Add(this.btnLabelReset);
this.groupBox6.Controls.Add(this.btnMoveReset);
this.groupBox6.Controls.Add(this.lblAgvInfo);
......@@ -823,6 +825,18 @@
this.groupBox6.TabStop = false;
this.groupBox6.Text = "消息";
//
// chbStickingPos
//
this.chbStickingPos.AutoSize = true;
this.chbStickingPos.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbStickingPos.Location = new System.Drawing.Point(793, 70);
this.chbStickingPos.Name = "chbStickingPos";
this.chbStickingPos.Size = new System.Drawing.Size(140, 24);
this.chbStickingPos.TabIndex = 304;
this.chbStickingPos.Text = "启用标签位置判断";
this.chbStickingPos.UseVisualStyleBackColor = true;
this.chbStickingPos.CheckedChanged += new System.EventHandler(this.chbStickingPos_CheckedChanged);
//
// btnShelfReset
//
this.btnShelfReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
......@@ -2163,17 +2177,19 @@
this.chbMoveStop.UseVisualStyleBackColor = true;
this.chbMoveStop.CheckedChanged += new System.EventHandler(this.chbMoveStop_CheckedChanged);
//
// chbStickingPos
// button1
//
this.chbStickingPos.AutoSize = true;
this.chbStickingPos.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbStickingPos.Location = new System.Drawing.Point(793, 70);
this.chbStickingPos.Name = "chbStickingPos";
this.chbStickingPos.Size = new System.Drawing.Size(140, 24);
this.chbStickingPos.TabIndex = 304;
this.chbStickingPos.Text = "启用标签位置判断";
this.chbStickingPos.UseVisualStyleBackColor = true;
this.chbStickingPos.CheckedChanged += new System.EventHandler(this.chbStickingPos_CheckedChanged);
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.BackColor = System.Drawing.Color.White;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(1142, 108);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(126, 40);
this.button1.TabIndex = 302;
this.button1.Text = "复位打印机状态";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// FrmOutputEquip
//
......@@ -2358,6 +2374,7 @@
internal System.Windows.Forms.TextBox txtYP4;
private System.Windows.Forms.Button btnBsave2;
private System.Windows.Forms.CheckBox chbStickingPos;
private System.Windows.Forms.Button button1;
}
}
......@@ -422,7 +422,7 @@ namespace OnlineStore.AutoCountClient
txtMZP2.Text = equipBean.Config.GetMoveZP2(size).ToString();
txtMZP3.Text = equipBean.Config.GetMoveZP3(size).ToString();
btnMZP2.Text = "取料Z轴-取料点P2-" + size + "mm";
btnMZP3.Text = "取料Z轴-料点P3-" + size + "mm";
btnMZP3.Text = "取料Z轴-料点P3-" + size + "mm";
}
private void btnOpenAllAxis_Click(object sender, EventArgs e)
......@@ -846,6 +846,10 @@ namespace OnlineStore.AutoCountClient
}
}
private void button1_Click(object sender, EventArgs e)
{
RobotManager.LastPrintStatus = Asa.PrintLabel.PrinterStatus.Idle;
}
}
}
......
......@@ -91,6 +91,7 @@
this.启用贴标功能ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.lblXrayWork = new System.Windows.Forms.Label();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.CB_lookboard = new System.Windows.Forms.CheckBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.panWork.SuspendLayout();
......@@ -367,7 +368,7 @@
this.批量ToolStripMenuItem,
this.单盘ToolStripMenuItem});
this.元器件学习ToolStripMenuItem.Name = "元器件学习ToolStripMenuItem";
this.元器件学习ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.元器件学习ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.元器件学习ToolStripMenuItem.Text = "元器件学习";
this.元器件学习ToolStripMenuItem.Click += new System.EventHandler(this.元器件学习ToolStripMenuItem_Click);
//
......@@ -388,24 +389,24 @@
// toolStripSeparator17
//
this.toolStripSeparator17.Name = "toolStripSeparator17";
this.toolStripSeparator17.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator17.Size = new System.Drawing.Size(157, 6);
//
// 二维码学习ToolStripMenuItem
//
this.二维码学习ToolStripMenuItem.Name = "二维码学习ToolStripMenuItem";
this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.二维码学习ToolStripMenuItem.Text = "二维码学习";
this.二维码学习ToolStripMenuItem.Click += new System.EventHandler(this.二维码学习ToolStripMenuItem_Click);
//
// toolStripSeparator7
//
this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator7.Size = new System.Drawing.Size(157, 6);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 26);
this.toolStripMenuItem2.Size = new System.Drawing.Size(160, 26);
this.toolStripMenuItem2.Text = "AGV调试";
this.toolStripMenuItem2.Visible = false;
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
......@@ -413,13 +414,13 @@
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator6.Size = new System.Drawing.Size(157, 6);
this.toolStripSeparator6.Visible = false;
//
// 标签编辑ToolStripMenuItem
//
this.标签编辑ToolStripMenuItem.Name = "标签编辑ToolStripMenuItem";
this.标签编辑ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.标签编辑ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.标签编辑ToolStripMenuItem.Text = "标签编辑";
this.标签编辑ToolStripMenuItem.Click += new System.EventHandler(this.标签编辑ToolStripMenuItem_Click);
//
......@@ -442,19 +443,19 @@
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 26);
this.toolStripMenuItem3.Size = new System.Drawing.Size(144, 26);
this.toolStripMenuItem3.Text = "历史记录";
this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click);
//
// toolStripSeparator5
//
this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator5.Size = new System.Drawing.Size(141, 6);
//
// 元器件库ToolStripMenuItem
//
this.元器件库ToolStripMenuItem.Name = "元器件库ToolStripMenuItem";
this.元器件库ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.元器件库ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.元器件库ToolStripMenuItem.Text = "元器件库";
this.元器件库ToolStripMenuItem.Visible = false;
this.元器件库ToolStripMenuItem.Click += new System.EventHandler(this.元器件库ToolStripMenuItem_Click);
......@@ -462,37 +463,37 @@
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator16.Size = new System.Drawing.Size(141, 6);
this.toolStripSeparator16.Visible = false;
//
// 清空日志ToolStripMenuItem
//
this.清空日志ToolStripMenuItem.Name = "清空日志ToolStripMenuItem";
this.清空日志ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.清空日志ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.清空日志ToolStripMenuItem.Text = "清空日志";
this.清空日志ToolStripMenuItem.Click += new System.EventHandler(this.清空日志ToolStripMenuItem_Click);
//
// toolStripSeparator10
//
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator10.Size = new System.Drawing.Size(141, 6);
//
// 复制日志ToolStripMenuItem
//
this.复制日志ToolStripMenuItem.Name = "复制日志ToolStripMenuItem";
this.复制日志ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.复制日志ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.复制日志ToolStripMenuItem.Text = "复制日志";
this.复制日志ToolStripMenuItem.Click += new System.EventHandler(this.复制日志ToolStripMenuItem_Click);
//
// toolStripSeparator11
//
this.toolStripSeparator11.Name = "toolStripSeparator11";
this.toolStripSeparator11.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator11.Size = new System.Drawing.Size(141, 6);
//
// 版本号ToolStripMenuItem
//
this.版本号ToolStripMenuItem.Name = "版本号ToolStripMenuItem";
this.版本号ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.版本号ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.版本号ToolStripMenuItem.Text = "关于软件";
this.版本号ToolStripMenuItem.Click += new System.EventHandler(this.版本号ToolStripMenuItem_Click);
//
......@@ -609,11 +610,24 @@
this.lblXrayWork.Text = "警告:点料过程中,请勿开门";
this.lblXrayWork.Visible = false;
//
// CB_lookboard
//
this.CB_lookboard.AutoSize = true;
this.CB_lookboard.Checked = true;
this.CB_lookboard.CheckState = System.Windows.Forms.CheckState.Checked;
this.CB_lookboard.Location = new System.Drawing.Point(1190, 5);
this.CB_lookboard.Name = "CB_lookboard";
this.CB_lookboard.Size = new System.Drawing.Size(154, 24);
this.CB_lookboard.TabIndex = 198;
this.CB_lookboard.Text = "提交错误信息到看板";
this.CB_lookboard.UseVisualStyleBackColor = true;
//
// FrmRobotMain
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1350, 729);
this.Controls.Add(this.CB_lookboard);
this.Controls.Add(this.lblWarnMsg);
this.Controls.Add(this.lblXrayWork);
this.Controls.Add(this.tabControl1);
......@@ -706,6 +720,7 @@
private System.Windows.Forms.ToolStripMenuItem 启用贴标功能ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 批量ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 单盘ToolStripMenuItem;
private System.Windows.Forms.CheckBox CB_lookboard;
}
}
......@@ -473,13 +473,14 @@ namespace OnlineStore.AutoCountClient
LogUtil.error("LogM Error: ", ex);
}
}
private string AddMsg(string msg, string warmsg, AlarmType alarmType, DateTime lastTime)
private string AddMsg(string msg, string warmsg, AlarmType alarmType, DateTime lastTime, string modulename = "", string moduleid = "")
{
if (warmsg.Equals("").Equals(false))
{
if (alarmType.Equals(AlarmType.None).Equals(false))
{
msg += lastTime.ToLongTimeString() + " " + warmsg + "\r\n";
msglist.Add(new AlarmMsg(modulename, "doubleLine."+ moduleid, warmsg));
}
else
{
......@@ -488,6 +489,7 @@ namespace OnlineStore.AutoCountClient
}
return msg;
}
private void timer1_Tick(object sender, EventArgs e)
{
LogM();
......@@ -513,22 +515,25 @@ namespace OnlineStore.AutoCountClient
string canScanCode = "";
lblStatus.Text = robot.GetRunStr() + canScanCode;
string warnMsg = robot.WarnMsg;
msglist = new List<AlarmMsg>();
//foreach (EquipBase move in robot.equipsMap.Values)
//{
warnMsg = AddMsg(warnMsg, robot.outputEquip.WarnMsg, robot.outputEquip.alarmType, robot.outputEquip.LastAlarmTime);
warnMsg = AddMsg(warnMsg, robot.XrayBean.WarnMsg, robot.XrayBean.alarmType, robot.XrayBean.LastAlarmTime);
warnMsg = AddMsg(warnMsg, robot.inputEquip.WarnMsg, robot.inputEquip.alarmType, robot.inputEquip.LastAlarmTime);
warnMsg = AddMsg(warnMsg, robot.outputEquip.WarnMsg, robot.outputEquip.alarmType, robot.outputEquip.LastAlarmTime,"点料机-出料", "outputEquip");
warnMsg = AddMsg(warnMsg, robot.XrayBean.WarnMsg, robot.XrayBean.alarmType, robot.XrayBean.LastAlarmTime, "点料机-点料", "XrayBean");
warnMsg = AddMsg(warnMsg, robot.inputEquip.WarnMsg, robot.inputEquip.alarmType, robot.inputEquip.LastAlarmTime, "点料机-入料", "inputEquip");
//if (move is InputEquip)
//{
//BatchMoveBean bean = robot.inputEquip.LeftBatchMove;
warnMsg = AddMsg(warnMsg, robot.inputEquip.LeftBatchMove.WarnMsg, robot.inputEquip.LeftBatchMove.alarmType, robot.inputEquip.LeftBatchMove.LastAlarmTime);
warnMsg = AddMsg(warnMsg, robot.inputEquip.RightBatchMove.WarnMsg, robot.inputEquip.RightBatchMove.alarmType, robot.inputEquip.RightBatchMove.LastAlarmTime);
warnMsg = AddMsg(warnMsg, robot.inputEquip.LeftBatchMove.WarnMsg, robot.inputEquip.LeftBatchMove.alarmType, robot.inputEquip.LeftBatchMove.LastAlarmTime, "点料机-左批量轴", "LeftBatch");
warnMsg = AddMsg(warnMsg, robot.inputEquip.RightBatchMove.WarnMsg, robot.inputEquip.RightBatchMove.alarmType, robot.inputEquip.RightBatchMove.LastAlarmTime, "点料机-右批量轴", "RightBatch");
//}
//}
lblOutTray.Text = "XRay出口处料盘:" + robot.XrayBean.Out_ReelInfo.ToStr();
lblCurrTray.Text = "XRay扫描区料盘:" + robot.XrayBean.Work_ReelInfo.ToStr();
lblWarnMsg.Text = warnMsg;
updateDeviceAlarmMsg(msglist);
if (robot.runStatus > RobotRunStatus.Wait)
{
if (启动AToolStripMenuItem.Enabled.Equals(true))
......@@ -1061,6 +1066,89 @@ namespace OnlineStore.AutoCountClient
LogUtil.info(Name + " 点击:" + 启用贴标功能ToolStripMenuItem.Text);
}
private static string Addr_updateDeviceAlarmMsg = "http://10.85.199.25/myproject/rest/api/qisda/device/updateDeviceAlarmMsg";
List<AlarmMsg> msglist = new List<AlarmMsg>();
MyWebClient myWebClient = new MyWebClient(1000);
/// <summary>
/// 异常看板
/// </summary>
/// <param name="msgList"></param>
/// <returns></returns>
public string updateDeviceAlarmMsg(List<AlarmMsg> msgList)
{
if (msgList.Count == 0 || !CB_lookboard.Checked)
{
return "";
}
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
string msgListStr = JsonHelper.SerializeObject(msgList);
paramMap.Add("deviceAlarmList", msgListStr);
string param = GetAddr(paramMap);
//DateTime startTime = DateTime.Now;
if (string.IsNullOrEmpty(myWebClient.Headers["Content-Type"]))
{
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
}
myWebClient.UploadStringAsync(new Uri(Addr_updateDeviceAlarmMsg),"POST", param);
//string resultStr = HttpHelper.Post(Addr_updateDeviceAlarmMsg, param, 1000);
//LogUtil.debug("updateDeviceAlarmMsg " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
/*
RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
if (data == null)
{
return msg = " updateDeviceAlarmMsg 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
return msg = " updateDeviceAlarmMsg 【" + server + "】【" + resultStr + "】" + data.msg;
}
*/
return "";
}
catch (Exception ex)
{
LogUtil.error(" updateDeviceAlarmMsg Error: " + ex.ToString());
}
return msg;
}
private static string GetAddr( Dictionary<string, string> paramsMap)
{
string path="";
foreach (string paramName in paramsMap.Keys)
{
string par = System.Net.WebUtility.UrlEncode(paramsMap[paramName]);
path += paramName + "=" + par + "&";
}
path = path.Substring(0, path.Length - 1);
return path;
}
public class AlarmMsg
{
//>>>name : 异常位置名称
public string name = "";
//>>>msgKey : 异常信息唯一标识
public string msgKey = "";
//>>>msgValue : 异常信息
public string msgValue = "";
/// <summary>
/// 异常信息
/// </summary>
/// <param name="name">异常位置名称</param>
/// <param name="key">异常信息唯一标识</param>
/// <param name="value">异常信息</param>
public AlarmMsg(string name, string key, string value)
{
this.name = name;
this.msgKey = key;
this.msgValue = value;
}
}
}
}
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CodeLibrary</RootNamespace>
<AssemblyName>CodeLibrary</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
......@@ -34,6 +34,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Asa.CarerayImage">
<HintPath>..\..\..\..\CarerayImage\CarerayImage\bin\Debug\Asa.CarerayImage.dll</HintPath>
</Reference>
<Reference Include="Basler.Pylon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e389355f398382ab, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\GeneralClassLibrary\CodeLibraryProject\CodeLibrary\bin\Debug\Basler.Pylon.dll</HintPath>
......
......@@ -351,8 +351,11 @@ namespace CodeLibrary
return r;
}
static object cameralock = new object();
public override HObject CaptureOnImage(string name, out Bitmap bmp)
{
lock (cameralock)
{
HObject hoImage = null;
bmp = null;
int index = cameraName.FindIndex(s => s == name);
......@@ -396,50 +399,24 @@ namespace CodeLibrary
HDLogUtil.info(FrameInfo.stFrameInfo.enPixelType.ToString());
bmp = new Bitmap(FrameInfo.stFrameInfo.nWidth, FrameInfo.stFrameInfo.nHeight, FrameInfo.stFrameInfo.nWidth * 1, PixelFormat.Format8bppIndexed, FrameInfo.pBufAddr);
bmp = new Bitmap(FrameInfo.stFrameInfo.nWidth, FrameInfo.stFrameInfo.nHeight, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, FrameInfo.stFrameInfo.nWidth, FrameInfo.stFrameInfo.nHeight), System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat);
HDLogUtil.info("创建bitmapdata");
//System.Runtime.InteropServices.Marshal.Copy(FrameInfo.stFrameInfo., bmpData.Scan0,0, bmpData.Stride * FrameInfo.stFrameInfo.nHeight);
int PixelSize = Bitmap.GetPixelFormatSize(bmpData.PixelFormat) / 8;
CopyMemory(bmpData.Scan0, FrameInfo.pBufAddr, FrameInfo.stFrameInfo.nWidth * FrameInfo.stFrameInfo.nHeight * PixelSize);
HDLogUtil.info("复制bitmap数据");
bmp.UnlockBits(bmpData);
//bmp = new Bitmap(FrameInfo.stFrameInfo.nWidth, FrameInfo.stFrameInfo.nHeight, FrameInfo.stFrameInfo.nWidth * 1, PixelFormat.Format8bppIndexed, FrameInfo.pBufAddr);
ColorPalette pal = bmp.Palette;
for (int i = 0; i <= 255; i++)
{
pal.Entries[i] = Color.FromArgb(i, i, i);
}
bmp.Palette = pal;
/*
var width = FrameInfo.stFrameInfo.nWidth;
var height = FrameInfo.stFrameInfo.nHeight;
const int Alpha = 255;
IntPtr[] ptr = new IntPtr[2];
bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
ColorPalette pal = bmp.Palette;
for (int i = 0; i <= 255; i++)
{
pal.Entries[i] = Color.FromArgb(Alpha, i, i, i);
}
bmp.Palette = pal;
Rectangle rect = new Rectangle(0, 0, width, height);
BitmapData bitmapData = bmp.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
int PixelSize = Bitmap.GetPixelFormatSize(bitmapData.PixelFormat) / 8;
ptr[0] = bitmapData.Scan0;
ptr[1] = FrameInfo.pBufAddr;
//Marshal.Copy()
if (width % 4 == 0)
{
HDLogUtil.info("CopyMemory1");
CopyMemory((IntPtr)ptr[0], (IntPtr)ptr[1], width * height * PixelSize);
}
else
{
HDLogUtil.info("CopyMemory2");
for (int i = 0; i < height - 1; i++)
{
ptr[1] += width;
CopyMemory((IntPtr)ptr[0], (IntPtr)ptr[1], width * PixelSize);
ptr[0] += bitmapData.Stride;
}
}
bmp.UnlockBits(bitmapData);
HDLogUtil.debug("UnlockBits");
//bmp.Save(@"D:\image\"+DateTime.Now.Ticks.ToString() + "test.bmp");
*/
}
catch (Exception ex)
{
......@@ -481,6 +458,7 @@ namespace CodeLibrary
}
return hoImage;
}
}
[DllImport("Kernel32.dll")]
private static extern void CopyMemory(IntPtr dest, IntPtr source, int size);
......
......@@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Asa.eyemLib;
namespace CodeLibrary
{
......@@ -36,10 +37,12 @@ namespace CodeLibrary
eyemImage.ucpImage = bitmapData.Scan0;
eyemImage.iWidth = rect.Width;
eyemImage.iHeight = rect.Height;
eyemImage.iChannel = 0;
//eyemImage.iChannel = 0;
eyemImage.iChannels = 1;
eyemImage.iDepth = 0;
}
else {
eyemImageRead(file, 3, out eyemImage);
eyemImageRead(file, -1, out eyemImage);
}
//创建扫描区域
......@@ -74,7 +77,7 @@ namespace CodeLibrary
if (bitmapData!=null)
bmap.UnlockBits(bitmapData);
if (file != null)
eyemImageFree(eyemImage.ucpImage);
eyemImageFree(ref eyemImage);
//bmap.Dispose();
}
}
......@@ -85,6 +88,7 @@ namespace CodeLibrary
//eyemImageFree(eyemImage.ucpImage);
return codelist;
}
/*
//释放解码句柄
private class DataCodeHandle : SafeHandleZeroOrMinusOneIsInvalid
{
......@@ -112,7 +116,7 @@ namespace CodeLibrary
/// </summary>
/// <param name="ipImage"></param>
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern void eyemImageFree(IntPtr ipImage);
private static extern void eyemImageFree(ref EyemImage eyemImage);
//释放工具
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
......@@ -124,7 +128,9 @@ namespace CodeLibrary
public IntPtr ucpImage; // 地址
public int iWidth; // 图像内存 x 方向大小
public int iHeight; // 图像内存 y 方向大小
public int iChannel; // 图像通道数
public int iDepth;
public int iChannels; // 图像通道数
}
[StructLayout(LayoutKind.Sequential)]
public struct EyemRect
......@@ -142,7 +148,7 @@ namespace CodeLibrary
public int iCenterY; // y坐标
public IntPtr hType; // 码类型
public IntPtr hText; // 码内容
}
}*/
}
}
......@@ -54,6 +54,9 @@
<Reference Include="Asa.RFID">
<HintPath>..\..\dll\RFID\Asa.RFID.dll</HintPath>
</Reference>
<Reference Include="Asa.Signal">
<HintPath>..\..\..\..\到位\到位信号\Asa.Signal.dll</HintPath>
</Reference>
<Reference Include="Client, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\Client.dll</HintPath>
......@@ -96,6 +99,7 @@
<Compile Include="bean\BatchMoveBean_Partial.cs" />
<Compile Include="bean\BatchMoveBean.cs" />
<Compile Include="bean\OutputEquip_Shelf.cs" />
<Compile Include="deviceLibrary\TestPlate.cs" />
<Compile Include="manager\ParamManager.cs" />
<Compile Include="manager\RobotManager.cs" />
<Compile Include="bean\OutputEquip_Partial.cs" />
......
......@@ -189,11 +189,11 @@ namespace OnlineStore.DeviceLibrary
{
WorkLog("IB09_ScanCode");
MoveInfo.MoveParam = new WorkParam();
MoveInfo.MoveParam.WareCode = CodeManager.GetValidCode(LastCodeList);
MoveInfo.MoveParam.WareCode = CodeManager.GetValidCode(LastCodeList, out string msgs);
if (String.IsNullOrEmpty(MoveInfo.MoveParam.WareCode))
{
MoveInfo.MoveParam.IsNgReel = true;
MoveInfo.MoveParam.NgMsg = "无有效条码NG";
MoveInfo.MoveParam.NgMsg = msgs;
MoveInfo.MoveParam.TargetPosType = 1;
WorkLog(" 无有效条码,从XRay放到NG箱:" + MoveInfo.MoveParam.ToStr());
}
......@@ -215,6 +215,8 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.MoveParam.NgMsg = msg;
//RobotManager.robot.sQLite.Insert(MoveInfo.MoveParam.WareCode, MoveInfo.MoveParam.PlateW, MoveInfo.MoveParam.PlateH, 0, MoveInfo.MoveParam.NgMsg);
}
}
else {
MoveInfo.MoveParam.TargetPosType = 1;
......@@ -273,18 +275,25 @@ namespace OnlineStore.DeviceLibrary
#endregion
}
public void GetTrayOK()
public int GetTrayOK()
{
if (MoveInfo.MoveType.Equals(RobotMoveType.Working))
{
MoveInfo.NextMoveStep(StepEnum.IB11_TrayLeave);
WorkLog("当前料盘已离开,清理高度,准备开始测高");
LastHeight = 0;
if (SServerManager.GetReekinfo(MoveInfo.MoveParam.WareCode, out ReelResult reelResult))
{
WorkLog(" 获取到高度:" + reelResult.h);
return reelResult.h;
}
}
else
{
LogUtil.error(Name + "当前状态:" + MoveInfo.MoveType + ",GetTrayOK暂不处理");
}
return 0;
}
//internal string LCodeStr = "";
//internal string GetCurrCode()
......@@ -354,7 +363,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
LastCodeList = new List<string>(NextCodeList);
NextCodeList = new List<string>();
MoveInfo.MoveParam.WareCode = CodeManager.GetValidCode(LastCodeList);
MoveInfo.MoveParam.WareCode = CodeManager.GetValidCode(LastCodeList,out _);
MoveInfo.NextMoveStep(StepEnum.IB10_ScanOK);
WorkLog("料盘移栽 :使用预扫码【" + MoveInfo.MoveParam.WareCode + "】,等待取料机构来取料");
//WorkLog("料盘移栽 :上料横移取料端");
......@@ -502,7 +511,7 @@ namespace OnlineStore.DeviceLibrary
}
}
if (LastHeight <= 8) { LastHeight = 8; }
string code = CodeManager.GetValidCode(LastCodeList);
string code = CodeManager.GetValidCode(LastCodeList,out _);
string msg = Name + " 计算盘高:上升前 [" + StartMovePosition + "]实时[ " + EndMovePosition + "]差值[" + (EndMovePosition - StartMovePosition) + "]系数[" + AxisChangeValue + "] 计算后" + buchongStr + "[" + height + "]" + ",归类为【" + LastHeight + "mm】条码【" + code + "】";
LogUtil.info(msg);
return LastHeight;
......
......@@ -18,7 +18,10 @@ namespace OnlineStore.DeviceLibrary
public RobotMoveInfo SecMoveInfo = null;
public bool MoveStop = false;
protected int TimerMaxSeconds = 3;
/// <summary>
/// 手动报警
/// </summary>
public bool NeedAlarm = false;
protected void SetAllTimer(bool open)
{
......@@ -562,7 +565,7 @@ namespace OnlineStore.DeviceLibrary
{
try
{
DateTime time = DateTime.Now;
//DateTime time = DateTime.Now;
if (runStatus <= RobotRunStatus.Wait)
{
CloseLed();
......@@ -571,30 +574,25 @@ namespace OnlineStore.DeviceLibrary
bool isNeedAlarmLed = false;
bool isInOut = false;
bool yellowMove = false;
if (runStatus.Equals(RobotRunStatus.HomeMoving) || runStatus.Equals(RobotRunStatus.Reset))
{
yellowMove = true;
}
if (isInSuddenDown || isNoAirCheck || alarmType > AlarmType.AxisAlarm)
isNeedAlarmLed = NeedAlarm;
if (WarnMsg.IndexOf("OS_") > 0 && WarnMsg.IndexOf("OS_20_ShelfReady")>0)
{
isNeedAlarmLed = true;
}
else if (alarmType.Equals(AlarmType.None).Equals(false))
if (WarnMsg.IndexOf("_AxisTrayCheck") > 0)
{
yellowMove = true;
isNeedAlarmLed = true;
}
if (isNoAirCheck || isInSuddenDown || alarmType > AlarmType.AxisAlarm)
if (isNoAirCheck || isInSuddenDown || alarmType >= AlarmType.AxisAlarm)
{
isNeedAlarmLed = true;
}
else if (alarmType.Equals(AlarmType.None).Equals(false))
{
yellowMove = true;
}
if (MoveInfo.MoveType.Equals(RobotMoveType.Working) || MoveInfo.MoveType.Equals(RobotMoveType.Labelling))
{
isInOut = true;
//isInOut = true;
}
......@@ -603,37 +601,42 @@ namespace OnlineStore.DeviceLibrary
if (yellowMove)
{
//开机执行中时黄灯闪烁
if (IsDoValue(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH))
if (IsDoValue(IO_Type.RunSign_HddLed, IO_VALUE.HIGH))
{
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
}
else
{
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH);
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.HIGH);
}
}
else if (IsDoValue(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH))
else
{
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
CheckAndMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
}
//忙碌中,判断是否有移栽在出入库执行,绿灯闪烁
if (isInOut)
{
if (IsDoValue(IO_Type.RunSign_HddLed, IO_VALUE.LOW))
if (IsDoValue(IO_Type.AutoRun_HddLed, IO_VALUE.LOW))
{
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.HIGH);
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH);
}
else
{
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
}
}
else if (IsDoValue(IO_Type.RunSign_HddLed, IO_VALUE.LOW))
else if (isNeedAlarmLed)
{
CheckAndMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
}
else
{
//平常常亮绿灯
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.HIGH);
CheckAndMove(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH);
}
//严重报警中 ,红灯闪烁
if (isNeedAlarmLed)
{
......@@ -646,10 +649,11 @@ namespace OnlineStore.DeviceLibrary
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
}
}
else if (IsDoValue(IO_Type.Alarm_HddLed, IO_VALUE.HIGH))
else
{
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
CheckAndMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
}
if (isNeedAlarmLed && RobotManager.UseBuzzer)
{
CheckAndMove(IO_Type.Alarm_Buzzer, IO_VALUE.HIGH);
......@@ -658,13 +662,13 @@ namespace OnlineStore.DeviceLibrary
{
CheckAndMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW);
}
//Thread.Sleep(900);
}
catch (Exception ex)
{
LogUtil.error(Name + "灯处理定时器出错:", ex);
}
Thread.Sleep(5);
}
......
......@@ -115,7 +115,7 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.IsStep(StepEnum.IW03_MiddleToP2))
{
IW04_InoutToP2();
NeedAlarm = false;
}
else if (MoveInfo.IsStep(StepEnum.IW04_ReTry))
{
......@@ -159,6 +159,7 @@ namespace OnlineStore.DeviceLibrary
{
getretry = 0;
MoveInfo.NextMoveStep(StepEnum.IW08_WaitAxisCheck);
NeedAlarm = false;
}
else if (MoveInfo.IsTimeOut(4))
{
......@@ -168,6 +169,7 @@ namespace OnlineStore.DeviceLibrary
WorkLog("取料: 重试失败");
MoveInfo.NextMoveStep(StepEnum.IW08_WaitAxisCheck);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(it, IO_VALUE.LOW));
NeedAlarm = true;
}
else
{
......@@ -185,15 +187,16 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsStep(StepEnum.IW08_WaitAxisCheck))
{
NeedAlarm = false;
getretry = 0;
MoveInfo.NextMoveStep(StepEnum.IW11_GetTargetPosition);
if (MoveInfo.MoveParam.InPosType.Equals(1))
{
LeftBatchMove.GetTrayOK();
MoveInfo.MoveParam.PlateH=LeftBatchMove.GetTrayOK();
}
else
{
RightBatchMove.GetTrayOK();
MoveInfo.MoveParam.PlateH=RightBatchMove.GetTrayOK();
}
}
......@@ -316,6 +319,7 @@ namespace OnlineStore.DeviceLibrary
ClearTimeoutAlarm("测高结束超时");
//MoveInfo.NextMoveStep(StepEnum.IW10_SaveSize);
MoveInfo.NextMoveStep(StepEnum.IW23_InoutToP3);
if (MoveInfo.MoveParam.PlateH==0)
MoveInfo.MoveParam.PlateH = moveBean.LastHeight;
MoveInfo.MoveParam.PlateW = GetWidth();
WorkLog("测高结束, 记录尺寸【" + MoveInfo.MoveParam.PlateW + "X" + MoveInfo.MoveParam.PlateH + "】,开始下一盘预扫码", 1);
......
......@@ -159,13 +159,15 @@ namespace OnlineStore.DeviceLibrary
}
public void SecMoveReset()
{
SecMoveInfo.NextMoveStep(StepEnum.OLR01_LabelZHome);
SecMoveInfo.NewMove(RobotMoveType.Reset,StepEnum.OLR01_LabelZHome);
RobotManager.LastPrintStatus=Asa.PrintLabel.PrinterStatus.Unknown;
SecMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
SecWorkLog("贴标Z轴原点返回,标签吸码停止输出,贴标气缸后退");
LabelZAxis.HomeMove(SecMoveInfo);
IOMove(IO_Type.Nozzle_Work, IO_VALUE.LOW);
CylinderMove(SecMoveInfo, IO_Type.LablePaste_Forward, IO_Type.LablePaste_Back);
//SecMoveInfo.moveType = RobotMoveType.Reset;
}
protected override void ResetProcess()
......@@ -623,13 +625,18 @@ namespace OnlineStore.DeviceLibrary
return;
}
//若BOX和出料都没有在等待Io的过程中则此Io超时异常可能已经处理过
if ( MoveInfo.IsInWait.Equals(false) && SecMoveInfo.IsInWait.Equals(false)&&ShelfMoveInfo.IsInWait.Equals(false) && RobotManager.LastPrintStatus != Asa.PrintLabel.PrinterStatus.Printing)
if (MoveInfo.IsInWait.Equals(false) && SecMoveInfo.IsInWait.Equals(false) && ShelfMoveInfo.IsInWait.Equals(false) && RobotManager.LastPrintStatus != Asa.PrintLabel.PrinterStatus.Printing)
{
LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 ");
alarmType = AlarmType.None;
SetWarnMsg("");
NeedAlarm = false;
}
else {
NeedAlarm = true;
}
}else
NeedAlarm = false;
}
catch (Exception ex)
{
......
......@@ -190,9 +190,11 @@ namespace OnlineStore.DeviceLibrary
}
}
bool saveone = false;
bool doubleplate = false;
Task getPic=null;
private void OT05_GetImage()
{
if (MoveInfo.MoveParam.IsNgReel)
{
MoveInfo.NextMoveStep(StepEnum.OT07_MoveZToP2);
......@@ -213,22 +215,40 @@ namespace OnlineStore.DeviceLibrary
//var filename = "need";
CodeManager.CameraScan(Name, out cc, saveone, Config.CameraName);
saveone = true;
if (cc.Count == 0)
{
Task.Delay(1000).Wait();
if (cc.Count==0)
CodeManager.CameraScan(Name, out cc, saveone, Config.CameraName);
if (cc.Count > 0)
}
if (cc.Count == 1)
{
MoveInfo.MoveParam.codePointer.X = cc[0].X;
MoveInfo.MoveParam.codePointer.Y = cc[0].Y;
WorkLog("取料:识别到二维码位置:X:" + MoveInfo.MoveParam.codePointer.X + ",Y:" + MoveInfo.MoveParam.codePointer.Y, 1);
}
//else if (cc.Count > 1) {
// NeedAlarm = true;
//}
else
{
WorkLog("取料:2次没有识别到二维码", 1);
}
doubleplate = false;
/*bool[] hasplate = TestPlate.TestIt(Config.CameraName);
if (hasplate[0] && hasplate[1])
{
doubleplate = true;
}
else
{
doubleplate = false;
}*/
});
}
}
/// <summary>
/// 当前料串上的ReelID
......@@ -248,6 +268,7 @@ namespace OnlineStore.DeviceLibrary
if (MoveInfo.IsStep(StepEnum.OT01_WaitCheck))
{
OT02_MoveZToP1();
if (TakeReelRetay > 0)
IOMove(IO_Type.X_OLine_Run, IO_VALUE.LOW);
......@@ -258,6 +279,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsStep(StepEnum.OT03_MoveXToP2))
{
NeedAlarm = false;
if (TakeReelRetay > 0)
{
MoveInfo.NextMoveStep(StepEnum.OT05_GetImage);
......@@ -275,6 +297,21 @@ namespace OnlineStore.DeviceLibrary
return;
}
getPic = null;
if (TakeReelRetay == 0 && doubleplate)
{
NeedAlarm = true;
if (MoveInfo.IsTimeOut(3))
{
WorkLog("取料:发现存在2盘料, 再次拍照检测");
WarnMsg = MoveInfo.Name + "发现存在2盘料";
Alarm(AlarmType.IoSingleTimeOut);
OT05_GetImage();
}
return;
}
ClearTimeoutAlarm("发现存在2盘料");
MoveInfo.NextMoveStep(StepEnum.OT07_MoveZToP2);
WorkLog("取料:取料Z轴到P2 1 " + (TakeReelRetay > 0 ? TakeReelRetay - 1 : 0));
......@@ -339,13 +376,27 @@ namespace OnlineStore.DeviceLibrary
}
else
{
MoveInfo.NextMoveStep(StepEnum.OT08_3_Wait_Out_TrayCheck);
CylinderMove(MoveInfo, IO_Type.TakeT_Clamping_Work, IO_Type.TakeT_Clamping_Relax);
WarnMsg = MoveInfo.Name + "[取料:取料失败,已重试3次,请手动取走料盘]";
WorkLog(WarnMsg);
Alarm(AlarmType.IoSingleTimeOut);
CylinderMove(MoveInfo, IO_Type.TakeT_Clamping_Work, IO_Type.TakeT_Clamping_Relax);
}
}
}
else if (MoveInfo.IsStep(StepEnum.OT08_3_Wait_Out_TrayCheck))
{
if (IOValue(IO_Type.Out_TrayCheck).Equals(IO_VALUE.LOW))
{
ClearTimeoutAlarm("取料失败");
MoveInfo.NextMoveStep(StepEnum.OT25_NG_NGBack);
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Out_TrayCheck, IO_VALUE.LOW));
NeedAlarm = false;
}
else {
WarnMsg = MoveInfo.Name + "[取料:取料失败,已重试3次,请手动取走料盘]";
//WorkLog(WarnMsg);
Alarm(AlarmType.IoSingleTimeOut);
MoveInfo.NextMoveStep(StepEnum.OT08_3_Wait_Out_TrayCheck);
NeedAlarm = true;
}
}
else if (MoveInfo.IsStep(StepEnum.OT09_MoveZToP1))
......@@ -429,7 +480,7 @@ namespace OnlineStore.DeviceLibrary
if (shelfOk || debugOk)
{
ClearTimeoutAlarm("等待出料料串可放料");
MoveInfo.NextMoveStep(StepEnum.OT14_Clamping_Relax);
MoveInfo.NextMoveStep(StepEnum.OT14_a_Clamping_Clamp);
WorkLog("放料:取料气缸放松 ", 0);
CylinderMove(MoveInfo, IO_Type.TakeT_Clamping_Work, IO_Type.TakeT_Clamping_Relax);
CurrWareCode = MoveInfo.MoveParam.WareCode;
......@@ -442,6 +493,16 @@ namespace OnlineStore.DeviceLibrary
}
CheckStartLabel();
}
else if (MoveInfo.IsStep(StepEnum.OT14_a_Clamping_Clamp))
{
MoveInfo.NextMoveStep(StepEnum.OT14_b_Clamping_Relax);
CylinderMove(MoveInfo, IO_Type.TakeT_Clamping_Relax, IO_Type.TakeT_Clamping_Work);
}
else if (MoveInfo.IsStep(StepEnum.OT14_b_Clamping_Relax))
{
MoveInfo.NextMoveStep(StepEnum.OT14_Clamping_Relax);
CylinderMove(MoveInfo, IO_Type.TakeT_Clamping_Work, IO_Type.TakeT_Clamping_Relax);
}
else if (MoveInfo.IsStep(StepEnum.OT14_Clamping_Relax))
{
bool shelfOk = ShelfMoveInfo.MoveType.Equals(RobotMoveType.ShelfPro) && ShelfMoveInfo.IsStep(StepEnum.OS_22_WaitTray);
......@@ -519,6 +580,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsStep(StepEnum.OT25_NG_NGBack))
{
NeedAlarm = false;
TakeReelRetay = 0;
TimeSpan span = DateTime.Now - MoveInfo.MoveStartTime;
TickLog("出口NG,放料完成");
......@@ -568,6 +630,7 @@ namespace OnlineStore.DeviceLibrary
}
if (SecMoveInfo.IsStep(StepEnum.OL01_Paste_Back))
{
NeedAlarm = false;
SecMoveInfo.NextMoveStep(StepEnum.OL03_PrintLabel);
RobotManager.LastPrintStatus = Asa.PrintLabel.PrinterStatus.Unknown;
try
......@@ -598,7 +661,7 @@ namespace OnlineStore.DeviceLibrary
else if (SecMoveInfo.IsStep(StepEnum.OL03_PrintLabel))
{
bool isPrintOk = RobotManager.LastPrintStatus.Equals(Asa.PrintLabel.PrinterStatus.Idle);
bool isTimeOut = SecMoveInfo.IsTimeOut(120);
bool isTimeOut = SecMoveInfo.IsTimeOut(12000);
if (printTask == null || printTask.IsCompleted)
{
if (isPrintOk || isTimeOut || (!NeedPrint))
......@@ -607,23 +670,32 @@ namespace OnlineStore.DeviceLibrary
SecMoveInfo.NextMoveStep(StepEnum.OL05_TakeBack);
SecWorkLog("贴标: 打印结束[" + RobotManager.LastPrintStatus + "][" + (isTimeOut ? "超时120秒" : "") + "], ");
//CylinderMove(SecMoveInfo, IO_Type.TakeCode_Forward, IO_Type.TakeCode_Back);
NeedAlarm = false;
printTask = null;
SecMoveInfo.NextMoveStep(StepEnum.OL06_ZToP2);
SecWorkLog("贴标: Z轴到取标签点P2");
IOMove(IO_Type.Nozzle_Work, IO_VALUE.HIGH);
LabelZAxis.AbsMove(SecMoveInfo, Config.LabelZ_P2, Config.LabelZ_P2Speed);
}
else if (MoveInfo.IsTimeOut(20))
{
WarnMsg = SecMoveInfo.Name + "[" + SecMoveInfo.MoveStep + "]" + "等待 打印标签状态完成(OL03_PrintLabel) 超时[" + FormUtil.GetSpanStr(SecMoveInfo.StepSpan()) + "]";
LogUtil.error(WarnMsg, SecMoveInfo.ErrorLogType, SecMoveInfo.logSeconds());
Alarm(AlarmType.IoSingleTimeOut);
NeedAlarm = true;
}
}
else if (MoveInfo.IsTimeOut(120))
else if (MoveInfo.IsTimeOut(60))
{
WarnMsg = SecMoveInfo.Name + "[" + SecMoveInfo.MoveStep + "]" + "等待 打印标签完成(OL03_PrintLabel) 超时[" + FormUtil.GetSpanStr(SecMoveInfo.StepSpan()) + "]";
WarnMsg = SecMoveInfo.Name + "[" + SecMoveInfo.MoveStep + "]" + "等待 打印标签任务完成(OL03_PrintLabel) 超时[" + FormUtil.GetSpanStr(SecMoveInfo.StepSpan()) + "]";
LogUtil.error(WarnMsg, SecMoveInfo.ErrorLogType, SecMoveInfo.logSeconds());
Alarm(AlarmType.IoSingleTimeOut);
NeedAlarm = true;
}
}
else if (SecMoveInfo.IsStep(StepEnum.OL05_TakeBack))
{
NeedAlarm = false;
printTask = null;
SecMoveInfo.NextMoveStep(StepEnum.OL06_ZToP2);
SecWorkLog("贴标: Z轴到取标签点P2");
......@@ -632,6 +704,7 @@ namespace OnlineStore.DeviceLibrary
}
else if (SecMoveInfo.IsStep(StepEnum.OL06_ZToP2))
{
SecMoveInfo.NextMoveStep(StepEnum.OL07_Nozzle_Work);
SecWorkLog("贴标: 标签吸盘取码,等待吸盘信号到位 1.5s");
......
......@@ -48,6 +48,7 @@ namespace OnlineStore.DeviceLibrary
IsDebug = Config.IsDebug.Equals(1);
ledProcessTimer.Elapsed += LedProcessTimer_Elapsed;
List<string> ioList = new List<string>();
ioList = new List<string>(DeviceConfig.ProIOIpMap.Values);
......@@ -82,6 +83,7 @@ namespace OnlineStore.DeviceLibrary
IOManager.instance.ConnectionIOList(ioList);
Thread.Sleep(3000);
mainTimer.Enabled = true;
//ledProcessTimer.Enabled = true;
canStart = true;
AgvClient.Init();
string dataFile =Application.StartupPath+ ConfigAppSettings.GetValue(Setting_Init.DataPath);
......@@ -91,6 +93,127 @@ namespace OnlineStore.DeviceLibrary
});
}
private void LedProcessTimer_Elapsed(object sender, ElapsedEventArgs e)
{
try
{
//DateTime time = DateTime.Now;
if (runStatus <= RobotRunStatus.Wait)
{
CloseLed();
return;
}
bool isNeedAlarmLed = false;
bool isInOut = false;
bool yellowMove = true;
// {inputEquip,XrayBean,outputEquip};
bool NeedAlarm = inputEquip.NeedAlarm || XrayBean.NeedAlarm || outputEquip.NeedAlarm;
if (!NeedAlarm) {
if (outputEquip.WarnMsg.IndexOf("OS_") > 0) {
NeedAlarm = true;
}
}
isInOut = inputEquip.MoveInfo.MoveType == RobotMoveType.Working
|| XrayBean.MoveInfo.MoveType == RobotMoveType.Working
|| outputEquip.ShelfMoveInfo.MoveType == RobotMoveType.ShelfPro
|| outputEquip.MoveInfo.MoveType == RobotMoveType.Working
|| outputEquip.SecMoveInfo.MoveType == RobotMoveType.Labelling
;
if (!NeedAlarm)
{
NeedAlarm = inputEquip.alarmType >= AlarmType.AxisAlarm
|| XrayBean.alarmType >= AlarmType.AxisAlarm
|| outputEquip.alarmType >= AlarmType.AxisAlarm
;
}
//if (inputEquip.runStatus<3)
//{
// yellowMove = true;
////}
if (isNoAirCheck || isInSuddenDown || NeedAlarm)
{
isNeedAlarmLed = true;
}
//黄灯
if (yellowMove)
{
//开机执行中时黄灯闪烁
if (DOValue(IO_Type.AutoRun_HddLed).Equals(IO_VALUE.HIGH))
{
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
}
else
{
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.HIGH);
}
}
else if (DOValue(IO_Type.AutoRun_HddLed).Equals(IO_VALUE.HIGH))
{
IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
}
//忙碌中,判断是否有移栽在出入库执行,绿灯闪烁
if (isInOut)
{
if (DOValue(IO_Type.RunSign_HddLed).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.HIGH);
}
else
{
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
}
}
else if (DOValue(IO_Type.RunSign_HddLed).Equals(IO_VALUE.LOW))
{
//平常常亮绿灯
IOMove(IO_Type.RunSign_HddLed, IO_VALUE.HIGH);
}
//严重报警中 ,红灯闪烁
if (isNeedAlarmLed)
{
if (DOValue(IO_Type.Alarm_HddLed).Equals(IO_VALUE.LOW))
{
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.HIGH);
}
else
{
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
}
}
else if (DOValue(IO_Type.Alarm_HddLed).Equals(IO_VALUE.HIGH))
{
IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
}
if (isNeedAlarmLed && RobotManager.UseBuzzer)
{
CheckAndMove(IO_Type.Alarm_Buzzer, IO_VALUE.HIGH);
}
else
{
CheckAndMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW);
}
//Thread.Sleep(900);
}
catch (Exception ex)
{
LogUtil.error(Name + "灯处理定时器出错:", ex);
}
}
protected void CloseLed()
{
CheckAndMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
CheckAndMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
CheckAndMove(IO_Type.RunSign_HddLed, IO_VALUE.LOW);
CheckAndMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW);
}
#endregion
public string CanStart()
......
......@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary
public XRay xRay = null;
public CarerayImage carerayImage = null;
public XrayImage xrayImage = null;
public bool xRayCanStart = false;
public string LastXRayState = "未知";
......@@ -35,6 +35,7 @@ namespace OnlineStore.DeviceLibrary
private int ResultMinCount = -1;
private string path_XRAY = Application.StartupPath + @"\XRAY\";
private string path_XRAY_NGBck = Application.StartupPath + @"\XRAY\NGBck";
private string path1_tif = Application.StartupPath + @"\XRAY\tif";
private string path2_out = Application.StartupPath + @"\XRAY\out\";
//private string path3_area = Application.StartupPath + @"\XRAY\area.txt";
......@@ -68,8 +69,9 @@ namespace OnlineStore.DeviceLibrary
{
try
{
carerayImage = new CarerayImage("XRay");
bool cResult = carerayImage.Open();
xrayImage = new XrayImage("XRay",XrayImage.DeviceType.CARREY);
//xrayImage = new CarerayImage("XRay");
bool cResult = xrayImage.Open();
LogUtil.info(Name + "carerayImage.Open()=" + cResult);
carerayImageError = !cResult;
xRay = new XRay("XRay");
......@@ -86,13 +88,13 @@ namespace OnlineStore.DeviceLibrary
LastXRayState = "xRay.Open(" + Config.XRay_Port + "," + lastData + ")=" + xresult;
LogUtil.info(Name + "xRay.Open(" + Config.XRay_Port + "," + lastData + ")=" + xresult);
if (!System.IO.Directory.Exists(path1_tif))
if (!Directory.Exists(path1_tif))
{
System.IO.Directory.CreateDirectory(path1_tif);
Directory.CreateDirectory(path1_tif);
}
if (!System.IO.Directory.Exists(path2_out))
if (!Directory.Exists(path2_out))
{
System.IO.Directory.CreateDirectory(path2_out);
Directory.CreateDirectory(path2_out);
}
ParamManager.Init();
ResultMinCount = ConfigAppSettings.GetIntValue(Setting_Init.ResultMinCount);
......@@ -117,7 +119,7 @@ namespace OnlineStore.DeviceLibrary
}
if (xRay != null)
xRay.Close();
carerayImage.Close();
xrayImage.Close();
}
catch (Exception ex)
{
......
......@@ -56,9 +56,9 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(StepEnum.XW06_WaitTime);
WorkLog("扫描区有料[" + Work_ReelInfo.ToStr() + "],还未进行点料,开始处理");
//IOMove(IO_Type.X_InLine_Run, IO_VALUE.HIGH);
IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.X_ReelCheck, IO_VALUE.HIGH));
//IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.X_ReelCheck, IO_VALUE.HIGH));
}
else
{
......@@ -82,7 +82,8 @@ namespace OnlineStore.DeviceLibrary
}
public bool Out_TrayCheck_force = false;
bool saveone = false;
protected override void WorkingProcess()
{
if (MoveInfo.IsInWait)
......@@ -144,7 +145,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(StepEnum.XW07_InLineStop);
WorkLog("料盘处理:停止入口皮带线,中间皮带线");
IOMove(IO_Type.X_InLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH,700);//皮带延时,控制料盘位置
IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH, 600);//皮带延时,控制料盘位置
}
else if (MoveInfo.IsTimeOut(20))
{
......@@ -326,35 +327,47 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.IsStep(StepEnum.XW23_OutLineRun))
{
//if (IOValue(IO_Type.Out_TrayCheck).Equals(IO_VALUE.HIGH))
//{
MoveInfo.NextMoveStep(StepEnum.XW24_WaitOutCheck);
WorkLog("料盘处理:继续转动3秒后,等待出口皮带线检测到料盘", 1);
IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH);
IOMove(IO_Type.X_OLine_Run, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Out_TrayCheck, IO_VALUE.HIGH));
// }
//else if (MoveInfo.IsTimeOut(10)) {
// WorkLog("料盘处理:没有检测到料盘", 1);
// MoveInfo.NextMoveStep(StepEnum.XW24_WaitOutCheck);
//}
saveone = true;
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Out_TrayCheck, IO_VALUE.HIGH));
}
else if (MoveInfo.IsStep(StepEnum.XW24_WaitOutCheck))
{
if (IOValue(IO_Type.Out_TrayCheck).Equals(IO_VALUE.HIGH) || Out_TrayCheck_force)
{
MoveInfo.NextMoveStep(StepEnum.XW25_WaitTime);
//Out_ReelInfo = Work_ReelInfo.GetReelInfo();
//Work_ReelInfo = new ReelInfo();
WorkLog("料盘处理: 中间皮带线先停止,出口皮带线 再转动3秒,挡停先下降");
IOMove(IO_Type.X_MLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.X_OLine_Run, IO_VALUE.HIGH,3000);
IOMove(IO_Type.X_OLine_Run, IO_VALUE.HIGH, 3000);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Out_TrayCheck, IO_VALUE.HIGH));
//CylinderMove(null, IO_Type.X_OutDoor_Down, IO_Type.X_OutDoor_Up);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Out_TrayCheck, IO_VALUE.HIGH));
CylinderMove(null, IO_Type.X_StopCylinder_Up, IO_Type.X_StopCylinder_Down);
}
else if (MoveInfo.IsTimeOut(10))
{
MoveInfo.NextMoveStep(StepEnum.XW24_WaitOutCheck);
WorkLog("料盘处理:Out_TrayCheck X57没有检测到料盘");
var hasplate = TestPlate.TestIt(RobotManager.robot.outputEquip.Config.CameraName, saveone);
saveone = false;
if (!hasplate[0] && !hasplate[1])
{
WorkLog("料盘处理:图像没有检测到料盘,结束点料处理");
//IOMove(IO_Type.X_MLine_Run, IO_VALUE.LOW);
//IOMove(IO_Type.X_OLine_Run, IO_VALUE.LOW);
//CylinderMove(MoveInfo, IO_Type.X_OutDoor_Down, IO_Type.X_OutDoor_Up);
//CylinderMove(MoveInfo, IO_Type.X_StopCylinder_Up, IO_Type.X_StopCylinder_Down);
//MoveInfo.NextMoveStep(StepEnum.XW26_OutLineStop);
}
else {
WorkLog("料盘处理:图像检测到料盘,当作有料处理");
//Out_TrayCheck_force = true;
}
}
}
else if (MoveInfo.IsStep(StepEnum.XW25_WaitTime))
{
if (GetResultTask == null || GetResultTask.IsCompleted)
......@@ -414,6 +427,7 @@ namespace OnlineStore.DeviceLibrary
GetResultTask = Task.Factory.StartNew(delegate
{
try
{
if (xRay.IsRayOpen)
......@@ -435,7 +449,11 @@ namespace OnlineStore.DeviceLibrary
}
string fileP = path1_tif + @"\" + lastFileName;
count = GetCountResult(fileP, lastParam,out _);
count = GetCountResult(fileP, lastParam,out string resfile);
//eyemLib.EyemImage eyemImage = xrayImage.GetRawBufferHandle();
////WorkLog("获取到指针" + eyemImage.ucpImage.ToString());
//count = GetCountResult(eyemImage, fileP, lastParam, out string resfile);
//xrayImage.FreeRawBufferHandle();
if (count < ResultMinCount)
{
isNg = true;
......@@ -451,7 +469,7 @@ namespace OnlineStore.DeviceLibrary
{
// string msg = "暂不上传";
string factoryCode;
string msg = SServerManager.Return_Material(Name, Work_ReelInfo.WareCode, Work_ReelInfo.WareCount,out factoryCode);
string msg = SServerManager.Return_Material(Name, Work_ReelInfo.WareCode, Work_ReelInfo.WareCount, out factoryCode);
MoveInfo.MoveParam.FactoryCode = factoryCode;
Work_ReelInfo.FactoryCode = factoryCode;
if (!String.IsNullOrEmpty(msg))
......@@ -461,10 +479,13 @@ namespace OnlineStore.DeviceLibrary
NgMsg = msg;
}
}
if (isNg && Work_ReelInfo.WareCount > 0)
{
//BackNGImg(Work_ReelInfo.WareCode);
}
string outF = path2_out + lastFileName;
string outF = resfile;
if (!isNg)
{
ReadOutMsg(outF);
......@@ -485,6 +506,9 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.error("XW15_GetResult出错:" + ex.ToString());
}
finally {
}
});
//MoveInfo.EndStepWait();
}
......@@ -524,20 +548,20 @@ namespace OnlineStore.DeviceLibrary
ClearFilePath();
//取图失败关掉重开。
bool imgResult = carerayImage.GetImage(5,3000);
bool imgResult = xrayImage.GetImage(5,3000);
if (!imgResult)
{
bool closeR = carerayImage.Close();
bool closeR = xrayImage.Close();
if (!closeR)
LogUtil.error(Name + "carerayImage.GetImage 获取图片失败 = " + imgResult + ", carerayImage.Close 失败");
Thread.Sleep(500);
bool openR = carerayImage.Open();
bool openR = xrayImage.Open();
Thread.Sleep(500);
if (openR)
{
imgResult = carerayImage.GetImage(5, 3000);
imgResult = xrayImage.GetImage(5, 3000);
LogUtil.error(Name + "carerayImage.GetImage 第2次获取图片 = " + imgResult + "");
}
else {
......@@ -545,23 +569,24 @@ namespace OnlineStore.DeviceLibrary
}
}
carerayImageError = !imgResult;
carerayImage.WindowWidth = Config.WindowWidth;
carerayImage.WindowLevel = Config.WindowLevel;
xrayImage.WindowWidth = Config.WindowWidth;
xrayImage.WindowLevel = Config.WindowLevel;
if (imgResult)
{
Bitmap bmp = carerayImage.Get48bImage();
Bitmap bmp = xrayImage.Get48bImage();
if (bmp != null)
{
Get48bImageErrorCount = 0;
lastFileName = Work_ReelInfo.GetImgName();
string fileP = path1_tif + @"\" + lastFileName;
bmp.Save(fileP, System.Drawing.Imaging.ImageFormat.Png);
var n = DateTime.Now;
string backDir = Path.Combine(path_XRAY, "back", n.Year.ToString() + "-" + n.Month.ToString(), n.Day.ToString(), n.Hour.ToString());
Directory.CreateDirectory(backDir);
string backFile = Path.Combine(backDir, lastFileName);
try
{
bmp.Save(fileP, System.Drawing.Imaging.ImageFormat.Png);
bmp.Save(backFile, System.Drawing.Imaging.ImageFormat.Png);
}
catch (Exception ex)
......@@ -605,7 +630,80 @@ namespace OnlineStore.DeviceLibrary
}
return lastFileName;
}
public string CapImage2()
{
try
{
string lastData = DateTime.Now.ToString("yyyy-MM-dd");
if (ConfigAppSettings.GetValue(Setting_Init.XRay_Data) != lastData)
{
ConfigAppSettings.SaveValue(Setting_Init.XRay_Data, lastData);
}
//取图失败关掉重开。
bool imgResult = xrayImage.GetImage(5, 3000);
if (!imgResult)
{
bool closeR = xrayImage.Close();
if (!closeR)
LogUtil.error(Name + "carerayImage.GetImage 获取图片失败 = " + imgResult + ", carerayImage.Close 失败");
Thread.Sleep(500);
bool openR = xrayImage.Open();
Thread.Sleep(500);
if (openR)
{
imgResult = xrayImage.GetImage(5, 3000);
LogUtil.error(Name + "carerayImage.GetImage 第2次获取图片 = " + imgResult + "");
}
else
{
LogUtil.error(Name + "carerayImage.Open 第2次open = " + openR + "");
}
}
carerayImageError = !imgResult;
xrayImage.WindowWidth = Config.WindowWidth;
xrayImage.WindowLevel = Config.WindowLevel;
if (imgResult)
{
//eyemLib.EyemImage eyemImage = xrayImage.GetRawBufferHandle();
lastFileName = Work_ReelInfo.GetRawName();
var n = DateTime.Now;
string backDir = Path.Combine(path_XRAY, "back", n.Year.ToString() + "-" + n.Month.ToString(), n.Day.ToString(), n.Hour.ToString());
Directory.CreateDirectory(backDir);
string backFile = Path.Combine(backDir, lastFileName);
xrayImage.SaveRAW(backFile);
}
else
{
WorkLog("点料:获取X射线图形,获取图片失败,carerayImage.GetImage()=" + imgResult);
LogUtil.error(Name + " 获取图片失败,carerayImage.GetImage()=" + imgResult);
lastFileName = "";
Get48bImageErrorCount++;
if (Get48bImageErrorCount > 3)
carerayImageError = true;
}
bool result = xRay.Stop();
if (!result)
{
LogUtil.error(" xRay.Stop() 第一次失败,再次调用Stop");
result = xRay.Stop();
if (!result)
{
LogUtil.error(" xRay.Stop()失败:" + result);
}
}
}
catch (Exception ex)
{
LogUtil.error(" CapImage 出错:" + ex.ToString());
}
return lastFileName;
}
private void ClearFilePath()
{
try
......@@ -636,7 +734,7 @@ namespace OnlineStore.DeviceLibrary
string fileP = path1_tif + @"\" + lastFileName;
string backPath = ParamManager.NoConfigPath ;
string backFile = Path.Combine(backPath, pn + ".png");
string backFile = Path.Combine(backPath, pn + Path.GetExtension(lastFileName));
try
{
if (!Directory.Exists(backPath))
......@@ -654,7 +752,28 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("X图片备份到【" + backFile + "】错误:" + ex.ToString());
}
}
private void BackNGImg(string wearcode)
{
//将未找到料号配置的图片保存到新的文件夹
string fileP = path1_tif + @"\" + lastFileName;
string backFile = Path.Combine(path_XRAY_NGBck, wearcode + Path.GetExtension(lastFileName));
try
{
if (!Directory.Exists(path_XRAY_NGBck))
{
Directory.CreateDirectory(path_XRAY_NGBck);
}
if (!File.Exists(backFile))
{
System.IO.File.Copy(fileP, backFile);
LogUtil.info("BackNGImg 【" + fileP + "】 -> 【" + backFile + "】");
}
}
catch (Exception ex)
{
LogUtil.error("X图片备份到【" + backFile + "】错误:" + ex.ToString());
}
}
public int GetCountResult(string fileP, CountParam param, out string resfile)
{
......@@ -671,11 +790,11 @@ namespace OnlineStore.DeviceLibrary
int windowsize = param.WindowSize; ;
if (param.Sign == CountParam.SignType.AUTO)
{
result = carerayImage.GetLocalCount(fileP, threshold, windowsize, out countStr, out _);
result = XrayImage.GetLocalCount(fileP, 200, out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
}
else {
result = carerayImage.GetLocalCountIrregular(fileP, threshold, type.ToString(), windowsize, out countStr, out _);
result = XrayImage.GetLocalCountIrregular(fileP, 200, type.ToString(), out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
}
if (countStr != null)
......@@ -705,9 +824,59 @@ namespace OnlineStore.DeviceLibrary
}
return count;
}
public int GetCountResult(eyemLib.EyemImage eyemImage, string fileP, CountParam param, out string resfile)
{
//返回的数量是string类型,count = "4000,3000,3500,2000"
int count = 0;
resfile = "";
//tpDstImg = new API.EyemImage();
try
{
string countStr = "";
int result = 0;
CountParam.SignType type = param.Sign;
int threshold = param.Threshold;
int windowsize = param.WindowSize; ;
if (param.Sign == CountParam.SignType.AUTO)
{
result = XrayImage.GetLocalCount(eyemImage, 200,Path.GetFileNameWithoutExtension(fileP), out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
}
else
{
result = XrayImage.GetLocalCountIrregular(eyemImage, 200,Path.GetFileNameWithoutExtension(fileP), type.ToString(), out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
}
if (countStr != null)
{
string[] array = countStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
count = (from a in array where int.TryParse(a, out _) && int.Parse(a) > 0 select int.Parse(a)).FirstOrDefault();
}
else
{
count = 0;
}
if (result == 0)
{
string resfilename = Path.GetFileNameWithoutExtension(fileP) + "-Mark.png";
string root = Path.Combine(Application.StartupPath, "ResOut");
var n = DateTime.Now;
string destdir = Path.Combine(root, n.Year.ToString() + "-" + n.Month.ToString(), n.Day.ToString(), n.Hour.ToString());
Directory.CreateDirectory(destdir);
resfile = Path.Combine(destdir, resfilename);
if (File.Exists(resfile))
File.Delete(resfile);
Directory.Move(Path.Combine(root, resfilename), resfile);
}
}
catch (Exception ex)
{
LogUtil.error("GetCountResult 出错: " + ex.ToString());
}
return count;
}
public Bitmap ImgChange(Asa.API.EyemImage tpDstImg)
public Bitmap ImgChange(Asa.eyemLib.EyemImage tpDstImg)
{
Bitmap bit = null;
return bit;
......
using CodeLibrary;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class TestPlate
{
private static Asa.Signal signal;
static string deviceName = "出口相机";
static TestPlate() {
string path1 = @"backgroundimage.png";
signal = new Asa.Signal();
//signal.ExistChanged += Signal_ExistChanged;
bool rtn = signal.BgImage(path1);
LogUtil.info("出料图像识别背景图加载:" + rtn);
signal.RegionAdd(new Asa.Signal.EyemRegion() { X = 1773, Y = 1097, Width = 1125, Height = 337, Ratio = 0.2 });
signal.RegionAdd(new Asa.Signal.EyemRegion() { X = 1773, Y = 1889, Width = 1125, Height = 685, Ratio = 0.2 });
//cameraName = Config.CameraName;
}
[HandleProcessCorruptedStateExceptions]
public static bool[] TestIt(string cameraName, bool needsaveone = false)
{
HalconDotNet.HObject ho_Image = null;
Bitmap bmp=null;
try
{
ho_Image = Camera._cam.CaptureOnImage(cameraName, out bmp);
if (ho_Image == null)
{
LogUtil.error(deviceName + " 【" + cameraName + "】取图片失败[" + Camera._cam.ErrInfo + "],关闭相机");
Camera._cam.Close(cameraName);
Task.Delay(1000).Wait();
ho_Image = Camera._cam.CaptureOnImage(cameraName, out bmp);
if (ho_Image == null)
{
LogUtil.error(deviceName + " 【" + cameraName + "】第2次取图片失败[" + Camera._cam.ErrInfo + "],关闭相机");
return new bool[] { false, false };
}
}
LogUtil.info("开始图像识别料盘");
bool rtn = signal.Compare(bmp);
if (needsaveone)
{
CodeManager.SaveImageToFile("料盘识别", cameraName, bmp);
}
if (rtn)
{
LogUtil.error(deviceName + $" 图像匹配成功:[0]:{signal.IsExist[0]},[1]:{signal.IsExist[1]}");
return signal.IsExist;
}
else
{
LogUtil.error(deviceName + " 图像匹配失败");
return new bool[] { false, false };
}
}
catch (Exception e)
{
LogUtil.error(deviceName + " " + e.Message);
}
finally {
ho_Image.Dispose();
if (bmp != null) {
bmp.Dispose();
}
}
return new bool[] { false, false };
}
}
}
......@@ -27,6 +27,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public static void LoadConfig()
{
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
codeTypeList = new List<string>();
HDLogUtil.LogName = "RollingLogFileAppender";
......@@ -158,9 +159,9 @@ namespace OnlineStore.DeviceLibrary
if (!findRightCode)
{
findRightCode = HasRightCode(str);
if (findRightCode)
ccall.Add(code);
}
if (HasRightCode(str) && ccall.FindAll(x=> x.CodeStr == str).Count()==0)
ccall.Add(code);
}
}
......@@ -185,16 +186,14 @@ namespace OnlineStore.DeviceLibrary
{
codeList.Add(str);
r = r + "##Halcon|" + codeType + "|" + str;
if (!findRightCode)
{
findRightCode = HasRightCode(str);
if (findRightCode)
{
ccall.Add(c);
//if (codeType == "QR Code")
nosave = false;
}
}
//if (HasRightCode(str) && ccall.FindAll(x => x.CodeStr == str).Count() == 0)
}
}
}
......@@ -271,7 +270,7 @@ namespace OnlineStore.DeviceLibrary
}
return dire + iamgeName;
}
private static void SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap)
public static void SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap)
{
string date = deviceName.Trim().Replace('_', '-') + "-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "-" + DateTime.Now.Millisecond.ToString().PadLeft(4, '0');
string dire = @"D:\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\";
......@@ -374,9 +373,10 @@ namespace OnlineStore.DeviceLibrary
}
return ReplaceCode(code);
}
public static string GetValidCode(List<string> codeList)
public static string GetValidCode(List<string> codeList, out string msg)
{
string code = "";
msg = "";
List<string> targetCode = new List<string>();
foreach (string cc in codeList)
{
......@@ -427,10 +427,12 @@ namespace OnlineStore.DeviceLibrary
else if (targetCode.Count <= 0)
{
LogUtil.info("解析条码【" + code + "】失败:未找到有效条码");
msg = "无有效条码NG";
}
else
{
LogUtil.info("解析条码【" + code + "】失败:有多个(" + targetCode.Count + ")有效条码");
msg = "有(" + targetCode.Count + ")有效条码NG";
}
return "";
}
......
......@@ -216,7 +216,6 @@ namespace OnlineStore.DeviceLibrary
string labelName = ConfigAppSettings.GetValue(Setting_Init.LabelName);
PrintBean.LoadLabel(labelName);
PrintBean.Printer(PrintName, false);
LogUtil.info("PrintLabel 打印机初始化完成【" + labelName + "】【" + PrintName + "】");
System.Drawing.Printing.PrintDocument print = new System.Drawing.Printing.PrintDocument();
......
......@@ -163,6 +163,25 @@ namespace OnlineStore.DeviceLibrary
{
return !String.IsNullOrEmpty(server);
}
public static bool GetReekinfo(string codeStr, out ReelResult reelResult) {
string[] codeArray = codeStr.Split(';');
if (codeArray.Length != 2)
{
reelResult = null;
return false;
}
string resultStr = HttpHelper.Get("http://10.85.199.25/myproject/rest/api/qisda/device/resolveCode?code=" + codeArray[1], Encoding.UTF8,1000);
ServerResult serverResult = JsonHelper.DeserializeJsonToObject<ServerResult>(resultStr);
if (serverResult.code == 0) {
reelResult = serverResult.data;
return true;
} else {
reelResult = null;
return false;
}
}
}
// http://10.85.17.233/ESMTCommonInterface/CommonService.asmx/VMICheckRLC?reelID=R014212020051100876&partNum=6C.R0034.1D1
// {"data":{"IFneed":"需要","iftest":"未测值","component":"","msg":"未获取到测量RLC时间","status":1}}
......@@ -179,6 +198,19 @@ namespace OnlineStore.DeviceLibrary
public string msg { get; set; }
public int status { get; set; }
}
}
public class ServerResult {
public int code;
public string msg;
public ReelResult data;
}
public class ReelResult
{
public int qty;
public int w;
public int h;
public string pn;
}
}
......@@ -584,6 +584,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
OT08_Clamping_Work,
OT08_2_Wait_Out_TrayCheck,
OT08_3_Wait_Out_TrayCheck,
/// <summary>
/// 取料: 取料Z轴返回P1
/// </summary>
......@@ -605,6 +606,14 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 取料: 取料气缸放松
/// </summary>
OT14_a_Clamping_Clamp,
/// <summary>
/// 取料: 取料气缸放松
/// </summary>
OT14_b_Clamping_Relax,
/// <summary>
/// 取料: 取料气缸放松
/// </summary>
OT14_Clamping_Relax,
/// <summary>
/// 取料: 取料Z轴回到P1
......
......@@ -221,15 +221,20 @@ namespace OnlineStore.DeviceLibrary
string[] codeArray = WareCode.Split(';');
if (codeArray.Length == 2)
{
//string pnStr = codeArray[0];
//if (pnStr.Length >= 5)
//{
// pn = pnStr.Substring(0, 2) + pnStr.Substring(pnStr.Length - 3, 3);
//}
//else
//{
// pn = pnStr;
//}
pn = codeArray[0];
reald = codeArray[1];
}
return pn + "-" + reald + timeName;
}
public string GetRawName()
{
string pn = "";
string reald = "";
string timeName = "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".raw";
string[] codeArray = WareCode.Split(';');
if (codeArray.Length == 2)
{
pn = codeArray[0];
reald = codeArray[1];
}
......
......@@ -56,11 +56,11 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
public static string R_In_Start = "R_In_Start";
/// <summary>
/// DO,1,灯,,,,,,,,,,
/// DO,1,绿灯,,,,,,,,,,
/// </summary>
public static string AutoRun_HddLed = "AutoRun_HddLed";
/// <summary>
/// DO,1,绿灯,,,,,,,,,,
/// DO,1,灯,,,,,,,,,,
/// </summary>
public static string RunSign_HddLed = "RunSign_HddLed";
/// <summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!