Commit 0aebf51b 刘韬

OCR贴标稳定版

1 个父辈 4a15362d
......@@ -93,10 +93,10 @@ namespace DeviceLibrary
MoveInfo.log($"计算结果,图像像素中心{Center_Pix_Point},二维码像素坐标{Label_Pix_Point},角度{angle},贴标角度{labelCenterAngle},贴标像素点位为{AxisPixPoint},轴点位为{p1},R轴{labelAxisPos},盘宽{MoveInfo.ReelParam.PlateW}");
if (saveLabelDebugBmp)
{
IOMove(IO_Label_Type.Camera_Led, IO_VALUE.HIGH);
Task.Delay(10).Wait();
//IOMove(IO_Label_Type.Camera_Led, IO_VALUE.HIGH);
//Task.Delay(10).Wait();
Bitmap bitmap = Camera._cam.GrabOneImage(Config.CameraName);
IOMove(IO_Label_Type.Camera_Led, IO_VALUE.LOW);
//IOMove(IO_Label_Type.Camera_Led, IO_VALUE.LOW);
bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
//Bitmap bitmap = new Bitmap("d:\\出料模块-20210424-043753-0162.bmp");
printLabelDebugBitmap(bitmap, Label_Pix_Point, Center_Pix_Point, AxisPixPoint, angle, p1, labelCenterAngle, labelAxisPos, labelCenter);
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CodeLibrary;
using OnlineStore.Common;
......@@ -34,6 +35,18 @@ namespace DeviceLibrary
//对射检测
//get=> IOValue(IO_Label_Type.Line_HasTray_Check);
}
/// <summary>
/// 0=扫码失败,1=打印与实际二维码不一致
/// </summary>
[Flags]
enum WaitCheckLabeltypeE
{
None = 0,
Scan_QRCode_Fail = 1,
Scan_Code_And_Print_are_different = 2,
Failed_to_extract_label = 4,
};
WaitCheckLabeltypeE WaitCheckLabeltype;
Task printTask = null;
int reelcount = 0;
void WorkProcess()
......@@ -168,8 +181,10 @@ namespace DeviceLibrary
CylinderMove(MoveInfo, IO_Label_Type.Label_Stop_Down, IO_Label_Type.Label_Stop_Up, IO_VALUE.HIGH);
break;
case MoveStep.Lbl_05_ScanCode:
MoveInfo.NextMoveStep(MoveStep.Lbl_06_Get_Reelinfo);
ScanTask = ScanCode();
//MoveInfo.NextMoveStep(MoveStep.Lbl_06_Get_Reelinfo);
MoveInfo.NextMoveStep(MoveStep.Lbl_Printted);
WaitCheckLabeltype = WaitCheckLabeltypeE.None;
ScanTask2 = ScanCode2();
break;
case MoveStep.Lbl_06_Get_Reelinfo:
if (ScanTask.IsCompleted)
......@@ -248,10 +263,39 @@ namespace DeviceLibrary
MoveInfo.log("等待.");
break;
case MoveStep.Lbl03:
MoveInfo.NextMoveStep(MoveStep.Lbl10);
MoveInfo.NextMoveStep(MoveStep.Lbl04);
Label_Z_Axis.AbsMove(MoveInfo, Config.Label_Z_P2, Config.Label_Z_P2_speed);
MoveInfo.log("标签打印完毕,取标气缸上升,取起标签.");
break;
case MoveStep.Lbl04:
Thread.Sleep(500);
if (IOValue(IO_Label_Type.Label_Cylinder_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.NextMoveStep(MoveStep.Lbl_WaitCheckLabel);
MoveInfo.log("吸标失败.");
WaitCheckLabeltype = WaitCheckLabeltypeE.Failed_to_extract_label;
}
else
MoveInfo.NextMoveStep(MoveStep.Lbl05);
break;
case MoveStep.Lbl05:
MoveInfo.NextMoveStep(MoveStep.Lbl06);
Label_X_Axis.AbsMove(MoveInfo, Config.Label_X_Base, Config.Label_X_Base_speed);
Label_Y_Axis.AbsMove(MoveInfo, Config.Label_Y_Base, Config.Label_X_Base_speed);
Label_Z_Axis.AbsMove(MoveInfo, Config.Label_Z_P4, Config.Label_Z_P4_speed);
MoveInfo.log("Label_XYZ转到贴标准备点.");
break;
case MoveStep.Lbl06:
if (ScanTask2.IsCompleted)
{
MoveInfo.NextMoveStep(MoveStep.Lbl10);
}
else if (MoveInfo.IsTimeOut(10))
{
MoveInfo.NextMoveStep(MoveStep.Lbl_04_LineStop);
MoveInfo.log($"等待扫码超时,重新扫码");
}
break;
case MoveStep.Lbl10:
MoveInfo.NextMoveStep(MoveStep.Lbl11_wait);
Label_X_Axis.AbsMove(MoveInfo, p1.X, Config.Label_X_Base_speed);
......@@ -285,9 +329,16 @@ namespace DeviceLibrary
MoveInfo.log("取标气缸上升.");
break;
case MoveStep.Lbl_WaitCheckLabel:
if ((WaitCheckLabeltype & WaitCheckLabeltypeE.Scan_QRCode_Fail)== WaitCheckLabeltypeE.Scan_QRCode_Fail)
Msg.add("未识别到有效二维码", MsgLevel.warning);
if ((WaitCheckLabeltype & WaitCheckLabeltypeE.Scan_Code_And_Print_are_different) == WaitCheckLabeltypeE.Scan_Code_And_Print_are_different)
Msg.add("扫描到的Reelid与发出打印的可能不一致", MsgLevel.warning);
if ((WaitCheckLabeltype & WaitCheckLabeltypeE.Failed_to_extract_label) == WaitCheckLabeltypeE.Failed_to_extract_label)
Msg.add("标签吸取失败", MsgLevel.warning);
if (IOValue(IO_Label_Type.Reset_BTN).Equals(IO_VALUE.HIGH)) {
MoveInfo.NextMoveStep(MoveStep.Lbl_BeginOut);
IOMove(IO_Label_Type.LabelCylinder_Work, IO_VALUE.LOW);
IOMove(IO_Label_Type.Line2_Run, IO_VALUE.HIGH);
MoveInfo.log("人工完成贴标.");
}
......
......@@ -81,6 +81,7 @@ namespace DeviceLibrary
/// 扫码线程
/// </summary>
Task<(List<CodeInfo>,Bitmap)> ScanTask;
Task<(Point, double, bool)> ScanTask2;
Task<(List<CodeInfo>, Bitmap)> ScanCode()
{
MoveInfo.log("开始贴标扫码线程");
......@@ -106,7 +107,72 @@ namespace DeviceLibrary
return (new List<CodeInfo>(),null);
}
}));
}
Task<(Point, double, bool)> ScanCode2()
{
MoveInfo.log("开始贴标扫码线程");
return Task.Run(new Func<(Point, double, bool)>(() =>
{
try
{
Bitmap bitmap;
List<CodeInfo> LastCodeList = CodeManager.CameraScan(new List<string> { Config.CameraName }, out bitmap);
if (LastCodeList.Count <= 0)
{
Task.Delay(500).Wait();
LastCodeList = CodeManager.CameraScan(new List<string> { Config.CameraName });
}
if (LastCodeList.Count == 0)
{
MoveInfo.NextMoveStep(MoveStep.Lbl_WaitCheckLabel);
MoveInfo.log($"未识别到有效二维码");
WaitCheckLabeltype = WaitCheckLabeltypeE.Scan_QRCode_Fail;
}
else
{
if (MoveInfo.ReelParam.WareCode != LastCodeList[0].CodeStr)
{
MoveInfo.NextMoveStep(MoveStep.Lbl_WaitCheckLabel);
Msg.add($"扫描到的Reelid与发出打印的不一致,系统:{MoveInfo.ReelParam.WareCode},实际:{LastCodeList[0].CodeStr}", MsgLevel.warning);
MoveInfo.log($"扫描到的Reelid与发出打印的不一致,系统:{MoveInfo.ReelParam.WareCode},实际:{LastCodeList[0].CodeStr}");
WaitCheckLabeltype = WaitCheckLabeltypeE.Scan_Code_And_Print_are_different;
//MoveInfo.ReelParam.IsNg = true;
//MoveInfo.ReelParam.NgMsg = "扫描到的Reelid与发出打印的不一致";
//MoveInfo.ReelParam.logresult();
}
else
{
//MoveInfo.NextMoveStep(MoveStep.Lbl_Printted);
MoveInfo.ReelParam.codeInfos = LastCodeList;
MoveInfo.log($"已完成扫码, Count={LastCodeList.Count}");
MoveInfo.ReelParam.logresult();
}
MoveInfo.ReelParam.logresult();
//标签坐标
Point Label_Pix_Point = new Point(MoveInfo.ReelParam.codeInfos[0].X, MoveInfo.ReelParam.codeInfos[0].Y);
//照片坐标反转180度
var x = 5472 - Label_Pix_Point.X;
var y = 3648 - Label_Pix_Point.Y;
Label_Pix_Point.X = x;
Label_Pix_Point.Y = y;
//图像也旋转180度
bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
(p1, labelRAxisPos, ReverseLabel) = ClacLabel2(Label_Pix_Point, bitmap, MoveInfo.ReelParam);
return (p1, labelRAxisPos, ReverseLabel);
}
return (Point.Empty, 0, false);
}
catch
{
return (Point.Empty, 0, false);
}
}));
}
}
}
......@@ -79,7 +79,7 @@ namespace DeviceLibrary
/// <summary>
/// 是否再报警中
/// </summary>
protected AlarmType alarmType = AlarmType.None;
public AlarmType alarmType = AlarmType.None;
protected DateTime LastAlarmTime = DateTime.Now;
protected DateTime checkAlarmTime = DateTime.Now;
protected void Alarm(AlarmType alarmType, string alarmMsg = "")
......
......@@ -45,6 +45,7 @@ namespace DeviceLibrary
Lbl03,
Lbl04,
Lbl05,
Lbl06,
Lbl10,
Lbl11_wait,
Lbl11,
......
......@@ -75,7 +75,7 @@ namespace DeviceLibrary
Thread.Sleep(500);
if (XRay.SetVC(ConfigHelper.Config.Get("XRay_Voltage"), ConfigHelper.Config.Get("XRay_Current")))
if (!XRay.SetVC(ConfigHelper.Config.Get("XRay_Voltage"), ConfigHelper.Config.Get("XRay_Current")))
{
msgs += $"X光电压电流设置失败:{ConfigHelper.Config.Get("XRay_Voltage")},{ConfigHelper.Config.Get("XRay_Current")}\n";
IsLoadOk = false;
......
......@@ -46,7 +46,7 @@ namespace DeviceLibrary
RunningLed.LedState = LedState.blink;
}
if (alarmType != AlarmType.None)
if (alarmType != AlarmType.None || RobotManage.filterMachine.alarmType != AlarmType.None)
{
AlarmLed.LedState = LedState.on;
}
......
......@@ -231,7 +231,11 @@ namespace DeviceLibrary
break;
case MoveStep.Shelf_17_EmptyIn_CheckLocation:
ShelfOutMoveInfo.log("计算料串中心位置");
var (Bitmap, distance, debugstring) = GetStringCenter(true);
bool isFirst = true;
if (Math.Abs(Config.BatchAxis_P2 - T_Batch_Axis.GetAclPosition()) > Config.BatchAxis_ChangeValue*4)
isFirst = false;
var (Bitmap, distance, debugstring) = GetStringCenter(isFirst);
Lastdistance = distance;
TrayStringLocation?.Invoke(this, Bitmap);
if (Lastdistance > Config.String_Offset_Range_Px)
......@@ -440,10 +444,10 @@ namespace DeviceLibrary
//创建扫描区域
EyemRect eyemRect = new EyemRect();
eyemRect.iXs = Config.String_Center_X - 200;
eyemRect.iYs = Config.String_Center_Y - 200;
eyemRect.iWidth = 400;
eyemRect.iHeight = 400;
eyemRect.iXs = Config.String_Center_X - 175;
eyemRect.iYs = Config.String_Center_Y - 175;
eyemRect.iWidth = 175*2;
eyemRect.iHeight = 175*2;
eyemlib.EyemOcsFXYR eyemOcsFXYR = new eyemlib.EyemOcsFXYR();
......@@ -462,10 +466,11 @@ namespace DeviceLibrary
graphics.DrawImage(bmap, new PointF(0, 0));
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen greenpen = new Pen(Color.Green, 15);
Pen redpen = new Pen(Color.FromArgb(255, Color.Red), 10);
int r = 102;
graphics.DrawEllipse(greenpen, Config.String_Center_X - r, Config.String_Center_Y - r, r * 2, r * 2);
graphics.DrawEllipse(greenpen, Config.String_Center_X - 8, Config.String_Center_Y - 8, 8 * 2, 8 * 2);
Pen redpen = new Pen(Color.FromArgb(255, Color.Red), 10);
graphics.DrawEllipse(redpen, eyemOcsFXYR.fX - eyemOcsFXYR.fR, eyemOcsFXYR.fY - eyemOcsFXYR.fR, eyemOcsFXYR.fR * 2, eyemOcsFXYR.fR * 2);
graphics.DrawEllipse(redpen, eyemOcsFXYR.fX - 5, eyemOcsFXYR.fY - 5, 5 * 2, 5 * 2);
......@@ -492,25 +497,28 @@ namespace DeviceLibrary
//return (null, 0, "调试屏蔽");
var centerpos = new Point(Config.String_Center_X, Config.String_Center_Y);
Bitmap bmap = Camera._cam.GrabOneImage(RobotManage.t1Machine.Config.String_Camera);
Bitmap newbitmap = new Bitmap(640, 640);
Graphics g = Graphics.FromImage(newbitmap);
Rectangle rectangle = new Rectangle(centerpos.X - newbitmap.Width / 2, centerpos.Y - newbitmap.Height / 2, newbitmap.Width, newbitmap.Height);
g.DrawImage(bmap, rectangle);
g.Save();g.Dispose();
Rectangle rectangle = new Rectangle(centerpos.X - 640 / 2, centerpos.Y - 640 / 2, 640, 640);
Bitmap newbitmap = Common.ImageCrop(bmap, rectangle);
bmap.Dispose();
string filename = "\\image\\TrayString\\" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".jpg";
newbitmap.Save(filename, ImageFormat.Jpeg);
//newbitmap.Dispose();
bmap.Dispose();
float fx = 0, fy = 0;
int r = centerDetector(filename, ref fx, ref fy);
LogUtil.info($"centerDetector r:{r},x:{fx},y:{fy}");
var debugtxt = $"centerDetector:\nresult:{r}\nfX:{fx}\nfY:{fy}";
var currpos = new Point((int)fx+ rectangle.X, (int)fy+ rectangle.Y);
var distance = (int)Common.distance(centerpos, currpos);
Pen greenpen = new Pen(Color.Green, 15);
Pen redpen = new Pen(Color.FromArgb(255, Color.Red), 10);
Graphics graphics = Graphics.FromImage(newbitmap);
graphics.DrawEllipse(greenpen, Config.String_Center_X - 8, Config.String_Center_Y - 8, 8 * 2, 8 * 2);
graphics.DrawEllipse(redpen, (int)fx - 5, (int)fy - 5, 5 * 2, 5 * 2);
graphics.Save();
return (newbitmap, distance, debugtxt);
}
[DllImport("yolov5.dll", CharSet = CharSet.None)]
[DllImport("yolov5.dll", CharSet = CharSet.Ansi)]
public static extern int centerDetector([MarshalAs(UnmanagedType.LPStr)] string filename, ref float x, ref float y);
}
}
......@@ -142,10 +142,10 @@ namespace DeviceLibrary
{
ScanTask = Task.Run(new Func<List<CodeInfo>>(() =>
{
IOMove(IO_XRay_Type.Camera_Led, IO_VALUE.HIGH);
Task.Delay(10).Wait();
//IOMove(IO_XRay_Type.Camera_Led, IO_VALUE.HIGH);
//Task.Delay(10).Wait();
List<CodeInfo> LastCodeList = CodeManager.CameraScan(new List<string> { Config.CameraName });
IOMove(IO_XRay_Type.Camera_Led, IO_VALUE.LOW);
//IOMove(IO_XRay_Type.Camera_Led, IO_VALUE.LOW);
return LastCodeList;
}));
}
......
......@@ -72,6 +72,17 @@ namespace DeviceLibrary
AlarmLed.LedState = LedState.on;
}
if (alarmType != AlarmType.None
|| RobotManage.labelMachine.alarmType != AlarmType.None
|| RobotManage.filterMachine.alarmType != AlarmType.None
|| RobotManage.t1Machine.alarmType != AlarmType.None)
{
AlarmBuzzer.ON();
}
else {
AlarmBuzzer.OFF();
}
Led.LedGroup[DeviceName].ForEach((x) => { x.run(); });
}
}
......
......@@ -53,7 +53,7 @@ namespace DeviceLibrary
LedProcessInit();
IOMonitor.RegisterIO(IO_XRay_Type.Exit_Open, Config, IO_VALUE.LOW, delegate () { XRayDoorOpen(); });
IOMonitor.RegisterIO(IO_XRay_Type.Entry_Open, Config, IO_VALUE.LOW, delegate () { XRayDoorOpen(); });
AlarmBuzzer.SetOnOffAction(() => { IOMove(IO_XRay_Type.Alarm_Buzzer, IO_VALUE.HIGH); }, () => { IOMove(IO_XRay_Type.Alarm_Buzzer, IO_VALUE.LOW); });
LogUtil.info(DeviceName + " init end");
}
catch (Exception e){
......
......@@ -98,6 +98,7 @@
<Compile Include="AutoScan\T1Machine.Ledprocess.cs" />
<Compile Include="AutoScan\XRayMachine.XRay.cs" />
<Compile Include="AutoScan\XRayMachine.Feeding.cs" />
<Compile Include="DeviceLibrary\AlarmBuzzer.cs" />
<Compile Include="DeviceLibrary\CodeManager.cs" />
<Compile Include="AutoScan\RobotManage.cs" />
<Compile Include="AutoScan\common\IRobot.cs" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class AlarmBuzzer
{
delegate void on();
static on ondelegate;
static on offdelegate;
static bool enable = false;
public static bool Enable { get => enable;set {
enable = value;
if (!value) {
OFF();
}
} }
static AlarmBuzzerState State = AlarmBuzzerState.OFF;
public static event EventHandler<bool> BuzzerStateChange;
public static void SetOnOffAction(Action ona, Action offa) {
ondelegate = new on(ona);
offdelegate = new on(offa);
}
public static void ON(bool force=false) {
if (!Enable)
return;
if (force || (State != AlarmBuzzerState.ON && State != AlarmBuzzerState.MuteOnce))
{
State = AlarmBuzzerState.ON;
ondelegate();
BuzzerStateChange?.Invoke(null, true);
}
}
public static void OFF()
{
State = AlarmBuzzerState.OFF;
offdelegate();
BuzzerStateChange?.Invoke(null, false);
}
public static void MuteOnce()
{
if (State == AlarmBuzzerState.ON)
{
State = AlarmBuzzerState.MuteOnce;
offdelegate();
BuzzerStateChange?.Invoke(null, false);
}
}
}
enum AlarmBuzzerState
{
ON,
OFF,
MuteOnce
}
}
......@@ -37,7 +37,7 @@ namespace DeviceLibrary
continue;
}
LogUtil.OutputDebugString($"IOMonitor: {timediff.TotalMilliseconds},{iOMonitorStrut.Interval},last_iO_VALUE:{iOMonitorStrut.last_iO_VALUE},IOVALUE:{current_iovalue},Need:{iOMonitorStrut.iO_VALUE}");
//LogUtil.OutputDebugString($"IOMonitor: {timediff.TotalMilliseconds},{iOMonitorStrut.Interval},last_iO_VALUE:{iOMonitorStrut.last_iO_VALUE},IOVALUE:{current_iovalue},Need:{iOMonitorStrut.iO_VALUE}");
if (timediff.TotalMilliseconds > iOMonitorStrut.Interval && iOMonitorStrut.last_iO_VALUE != current_iovalue && current_iovalue== iOMonitorStrut.iO_VALUE)
{
......
......@@ -41,6 +41,7 @@ namespace AutoCountMachine
this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.boxResetControl1 = new AutoCountMachine.BoxResetControl();
this.cmb_runmode = new System.Windows.Forms.ComboBox();
this.btn_releaseshelf = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
......@@ -50,12 +51,15 @@ namespace AutoCountMachine
this.btn_stop = new System.Windows.Forms.Button();
this.btn_run = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView();
this.boxResetControl1 = new AutoCountMachine.BoxResetControl();
this.btn_PauseBuzzer = new System.Windows.Forms.Button();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.cb_EnableBuzzer = new System.Windows.Forms.CheckBox();
this.menuStrip1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
......@@ -134,6 +138,7 @@ namespace AutoCountMachine
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabControl1.Location = new System.Drawing.Point(0, 90);
this.tabControl1.Name = "tabControl1";
......@@ -143,6 +148,7 @@ namespace AutoCountMachine
//
// tabPage1
//
this.tabPage1.Controls.Add(this.btn_PauseBuzzer);
this.tabPage1.Controls.Add(this.boxResetControl1);
this.tabPage1.Controls.Add(this.cmb_runmode);
this.tabPage1.Controls.Add(this.btn_releaseshelf);
......@@ -155,6 +161,15 @@ namespace AutoCountMachine
this.tabPage1.Text = "信息";
this.tabPage1.UseVisualStyleBackColor = true;
//
// boxResetControl1
//
this.boxResetControl1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.boxResetControl1.Location = new System.Drawing.Point(731, 202);
this.boxResetControl1.Margin = new System.Windows.Forms.Padding(5);
this.boxResetControl1.Name = "boxResetControl1";
this.boxResetControl1.Size = new System.Drawing.Size(264, 353);
this.boxResetControl1.TabIndex = 5;
//
// cmb_runmode
//
this.cmb_runmode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
......@@ -165,17 +180,17 @@ namespace AutoCountMachine
"MSD",
"PAPER",
"TOWER"});
this.cmb_runmode.Location = new System.Drawing.Point(783, 96);
this.cmb_runmode.Location = new System.Drawing.Point(767, 153);
this.cmb_runmode.Name = "cmb_runmode";
this.cmb_runmode.Size = new System.Drawing.Size(159, 29);
this.cmb_runmode.Size = new System.Drawing.Size(175, 29);
this.cmb_runmode.TabIndex = 4;
this.cmb_runmode.SelectedIndexChanged += new System.EventHandler(this.cmb_runmode_SelectedIndexChanged);
//
// btn_releaseshelf
//
this.btn_releaseshelf.Location = new System.Drawing.Point(783, 29);
this.btn_releaseshelf.Location = new System.Drawing.Point(767, 29);
this.btn_releaseshelf.Name = "btn_releaseshelf";
this.btn_releaseshelf.Size = new System.Drawing.Size(159, 37);
this.btn_releaseshelf.Size = new System.Drawing.Size(175, 37);
this.btn_releaseshelf.TabIndex = 3;
this.btn_releaseshelf.Text = "强制释放料架";
this.btn_releaseshelf.UseVisualStyleBackColor = true;
......@@ -264,14 +279,39 @@ namespace AutoCountMachine
this.listView1.TabIndex = 7;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// boxResetControl1
//
this.boxResetControl1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.boxResetControl1.Location = new System.Drawing.Point(731, 202);
this.boxResetControl1.Margin = new System.Windows.Forms.Padding(5);
this.boxResetControl1.Name = "boxResetControl1";
this.boxResetControl1.Size = new System.Drawing.Size(264, 353);
this.boxResetControl1.TabIndex = 5;
// btn_PauseBuzzer
//
this.btn_PauseBuzzer.BackColor = System.Drawing.Color.OrangeRed;
this.btn_PauseBuzzer.Location = new System.Drawing.Point(767, 88);
this.btn_PauseBuzzer.Name = "btn_PauseBuzzer";
this.btn_PauseBuzzer.Size = new System.Drawing.Size(175, 40);
this.btn_PauseBuzzer.TabIndex = 7;
this.btn_PauseBuzzer.Text = "本次暂停警报器响声";
this.btn_PauseBuzzer.UseVisualStyleBackColor = false;
this.btn_PauseBuzzer.Visible = false;
this.btn_PauseBuzzer.Click += new System.EventHandler(this.btn_PauseBuzzer_Click);
//
// tabPage2
//
this.tabPage2.Controls.Add(this.cb_EnableBuzzer);
this.tabPage2.Location = new System.Drawing.Point(4, 30);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(1000, 565);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "设置";
this.tabPage2.UseVisualStyleBackColor = true;
//
// cb_EnableBuzzer
//
this.cb_EnableBuzzer.AutoSize = true;
this.cb_EnableBuzzer.Location = new System.Drawing.Point(21, 44);
this.cb_EnableBuzzer.Name = "cb_EnableBuzzer";
this.cb_EnableBuzzer.Size = new System.Drawing.Size(109, 25);
this.cb_EnableBuzzer.TabIndex = 6;
this.cb_EnableBuzzer.Text = "使用蜂鸣器";
this.cb_EnableBuzzer.UseVisualStyleBackColor = true;
this.cb_EnableBuzzer.CheckedChanged += new System.EventHandler(this.cb_EnableBuzzer_CheckedChanged);
//
// Form1
//
......@@ -296,6 +336,8 @@ namespace AutoCountMachine
this.tabPage1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
......@@ -324,6 +366,9 @@ namespace AutoCountMachine
private System.Windows.Forms.Button btn_releaseshelf;
private System.Windows.Forms.ComboBox cmb_runmode;
private BoxResetControl boxResetControl1;
private System.Windows.Forms.Button btn_PauseBuzzer;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.CheckBox cb_EnableBuzzer;
}
}
using CodeLibrary;
using ConfigHelper;
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
......@@ -170,7 +171,9 @@ namespace AutoCountMachine
LogUtil.info("开始初始化");
cb_EnableBuzzer.Checked = Config.Get("EnableBuzzer", true);
AlarmBuzzer.BuzzerStateChange += AlarmBuzzer_BuzzerStateChange;
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
//RobotManage.Init();
......@@ -184,6 +187,10 @@ namespace AutoCountMachine
Device_ProcessMsgEvent(null, lm);
cmb_runmode.Text = "ONLINE";
}
private void AlarmBuzzer_BuzzerStateChange(object sender, bool e)
{
btn_PauseBuzzer.Visible = e;
}
private void listView_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
e.NewWidth = (sender as ListView).Columns[e.ColumnIndex].Width;
......@@ -347,7 +354,7 @@ namespace AutoCountMachine
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode();
frm.ShowDialog();
frm.Dispose();
IOManager.IOMove(IO_XRay_Type.Camera_Led, IO_VALUE.LOW, RobotManage.xrayMachine.Config);
//IOManager.IOMove(IO_XRay_Type.Camera_Led, IO_VALUE.LOW, RobotManage.xrayMachine.Config);
}
private void 点料算法匹配toolStripMenuItem_Click(object sender, EventArgs e)
......@@ -396,5 +403,17 @@ namespace AutoCountMachine
}
}
private void cb_EnableBuzzer_CheckedChanged(object sender, EventArgs e)
{
Config.Set("EnableBuzzer", cb_EnableBuzzer.Checked);
Config.SaveChange();
AlarmBuzzer.Enable = cb_EnableBuzzer.Checked;
}
private void btn_PauseBuzzer_Click(object sender, EventArgs e)
{
AlarmBuzzer.MuteOnce();
}
}
}
......@@ -16,6 +16,8 @@ namespace AutoCountMachine
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
......@@ -25,6 +27,7 @@ namespace AutoCountMachine
//OcrProcess.Run();
//ServerConn.inputCounterDataByXRayMachine("20.K0784.008-615313|1KQ-2111|5000|A2061531315212446|PANASONIC", 9);
//return;
_ = new Mutex(true, Application.ProductName, out bool ret);
if (!ret)
{
......
......@@ -31,6 +31,10 @@ namespace AutoCountMachine
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.btn_Full_Linestop = new System.Windows.Forms.Button();
this.btn_Full_Linerun = new System.Windows.Forms.Button();
this.btn_Empty_Linestop = new System.Windows.Forms.Button();
this.btn_Empty_Linerun = new System.Windows.Forms.Button();
this.btn_Reset = new System.Windows.Forms.Button();
this.btn_release = new System.Windows.Forms.Button();
this.btn_clamp = new System.Windows.Forms.Button();
......@@ -55,10 +59,7 @@ namespace AutoCountMachine
this.label_eyemMulFuncTool = new System.Windows.Forms.Label();
this.btn_eyemMulFuncTool = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.btn_Empty_Linerun = new System.Windows.Forms.Button();
this.btn_Empty_Linestop = new System.Windows.Forms.Button();
this.btn_Full_Linerun = new System.Windows.Forms.Button();
this.btn_Full_Linestop = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
......@@ -110,6 +111,46 @@ namespace AutoCountMachine
this.tabPage1.Text = "I/O控制";
this.tabPage1.UseVisualStyleBackColor = true;
//
// btn_Full_Linestop
//
this.btn_Full_Linestop.Location = new System.Drawing.Point(658, 249);
this.btn_Full_Linestop.Name = "btn_Full_Linestop";
this.btn_Full_Linestop.Size = new System.Drawing.Size(102, 34);
this.btn_Full_Linestop.TabIndex = 305;
this.btn_Full_Linestop.Text = "满料串线体关";
this.btn_Full_Linestop.UseVisualStyleBackColor = true;
this.btn_Full_Linestop.Click += new System.EventHandler(this.btn_Full_Linestop_Click);
//
// btn_Full_Linerun
//
this.btn_Full_Linerun.Location = new System.Drawing.Point(545, 249);
this.btn_Full_Linerun.Name = "btn_Full_Linerun";
this.btn_Full_Linerun.Size = new System.Drawing.Size(102, 34);
this.btn_Full_Linerun.TabIndex = 305;
this.btn_Full_Linerun.Text = "满料串线体开";
this.btn_Full_Linerun.UseVisualStyleBackColor = true;
this.btn_Full_Linerun.Click += new System.EventHandler(this.btn_Full_Linerun_Click);
//
// btn_Empty_Linestop
//
this.btn_Empty_Linestop.Location = new System.Drawing.Point(658, 209);
this.btn_Empty_Linestop.Name = "btn_Empty_Linestop";
this.btn_Empty_Linestop.Size = new System.Drawing.Size(102, 34);
this.btn_Empty_Linestop.TabIndex = 305;
this.btn_Empty_Linestop.Text = "空料串线体关";
this.btn_Empty_Linestop.UseVisualStyleBackColor = true;
this.btn_Empty_Linestop.Click += new System.EventHandler(this.btn_Empty_Linestop_Click);
//
// btn_Empty_Linerun
//
this.btn_Empty_Linerun.Location = new System.Drawing.Point(545, 209);
this.btn_Empty_Linerun.Name = "btn_Empty_Linerun";
this.btn_Empty_Linerun.Size = new System.Drawing.Size(102, 34);
this.btn_Empty_Linerun.TabIndex = 305;
this.btn_Empty_Linerun.Text = "空料串线体开";
this.btn_Empty_Linerun.UseVisualStyleBackColor = true;
this.btn_Empty_Linerun.Click += new System.EventHandler(this.btn_Empty_Linerun_Click);
//
// btn_Reset
//
this.btn_Reset.Location = new System.Drawing.Point(545, 475);
......@@ -347,6 +388,7 @@ namespace AutoCountMachine
// tabPage3
//
this.tabPage3.Controls.Add(this.label_eyemMulFuncTool);
this.tabPage3.Controls.Add(this.button1);
this.tabPage3.Controls.Add(this.btn_eyemMulFuncTool);
this.tabPage3.Controls.Add(this.pictureBox1);
this.tabPage3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
......@@ -360,7 +402,7 @@ namespace AutoCountMachine
//
// label_eyemMulFuncTool
//
this.label_eyemMulFuncTool.Location = new System.Drawing.Point(832, 71);
this.label_eyemMulFuncTool.Location = new System.Drawing.Point(831, 191);
this.label_eyemMulFuncTool.Name = "label_eyemMulFuncTool";
this.label_eyemMulFuncTool.Size = new System.Drawing.Size(128, 173);
this.label_eyemMulFuncTool.TabIndex = 2;
......@@ -370,9 +412,9 @@ namespace AutoCountMachine
//
this.btn_eyemMulFuncTool.Location = new System.Drawing.Point(831, 6);
this.btn_eyemMulFuncTool.Name = "btn_eyemMulFuncTool";
this.btn_eyemMulFuncTool.Size = new System.Drawing.Size(126, 40);
this.btn_eyemMulFuncTool.Size = new System.Drawing.Size(136, 40);
this.btn_eyemMulFuncTool.TabIndex = 1;
this.btn_eyemMulFuncTool.Text = "料串中心检测";
this.btn_eyemMulFuncTool.Text = "料串中心检测(无料盘)";
this.btn_eyemMulFuncTool.UseVisualStyleBackColor = true;
this.btn_eyemMulFuncTool.Click += new System.EventHandler(this.button1_Click);
//
......@@ -385,45 +427,15 @@ namespace AutoCountMachine
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// btn_Empty_Linerun
//
this.btn_Empty_Linerun.Location = new System.Drawing.Point(545, 209);
this.btn_Empty_Linerun.Name = "btn_Empty_Linerun";
this.btn_Empty_Linerun.Size = new System.Drawing.Size(102, 34);
this.btn_Empty_Linerun.TabIndex = 305;
this.btn_Empty_Linerun.Text = "空料串线体开";
this.btn_Empty_Linerun.UseVisualStyleBackColor = true;
this.btn_Empty_Linerun.Click += new System.EventHandler(this.btn_Empty_Linerun_Click);
//
// btn_Empty_Linestop
// button1
//
this.btn_Empty_Linestop.Location = new System.Drawing.Point(658, 209);
this.btn_Empty_Linestop.Name = "btn_Empty_Linestop";
this.btn_Empty_Linestop.Size = new System.Drawing.Size(102, 34);
this.btn_Empty_Linestop.TabIndex = 305;
this.btn_Empty_Linestop.Text = "空料串线体关";
this.btn_Empty_Linestop.UseVisualStyleBackColor = true;
this.btn_Empty_Linestop.Click += new System.EventHandler(this.btn_Empty_Linestop_Click);
//
// btn_Full_Linerun
//
this.btn_Full_Linerun.Location = new System.Drawing.Point(545, 249);
this.btn_Full_Linerun.Name = "btn_Full_Linerun";
this.btn_Full_Linerun.Size = new System.Drawing.Size(102, 34);
this.btn_Full_Linerun.TabIndex = 305;
this.btn_Full_Linerun.Text = "满料串线体开";
this.btn_Full_Linerun.UseVisualStyleBackColor = true;
this.btn_Full_Linerun.Click += new System.EventHandler(this.btn_Full_Linerun_Click);
//
// btn_Full_Linestop
//
this.btn_Full_Linestop.Location = new System.Drawing.Point(658, 249);
this.btn_Full_Linestop.Name = "btn_Full_Linestop";
this.btn_Full_Linestop.Size = new System.Drawing.Size(102, 34);
this.btn_Full_Linestop.TabIndex = 305;
this.btn_Full_Linestop.Text = "满料串线体关";
this.btn_Full_Linestop.UseVisualStyleBackColor = true;
this.btn_Full_Linestop.Click += new System.EventHandler(this.btn_Full_Linestop_Click);
this.button1.Location = new System.Drawing.Point(831, 52);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(136, 40);
this.button1.TabIndex = 1;
this.button1.Text = "料串中心检测(有料盘)";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// T1Control
//
......@@ -474,5 +486,6 @@ namespace AutoCountMachine
private System.Windows.Forms.Button btn_Full_Linerun;
private System.Windows.Forms.Button btn_Empty_Linestop;
private System.Windows.Forms.Button btn_Empty_Linerun;
private System.Windows.Forms.Button button1;
}
}
......@@ -78,7 +78,7 @@ namespace AutoCountMachine
private void button1_Click(object sender, EventArgs e)
{
var (bitmap, distance, debugtxt) = RobotManage.t1Machine.GetStringCenter();
var (bitmap, distance, debugtxt) = RobotManage.t1Machine.GetStringCenterA();
label_eyemMulFuncTool.Text = debugtxt + $"\ndistance:{distance}\nLocation:{(distance< RobotManage.t1Machine.Config.String_Offset_Range_Px?"OK":"NG")}";
......@@ -104,5 +104,14 @@ namespace AutoCountMachine
{
RobotManage.t1Machine.ShelfOutLine.LineStop("n");
}
private void button1_Click_1(object sender, EventArgs e)
{
var (bitmap, distance, debugtxt) = RobotManage.t1Machine.GetStringCenterB();
label_eyemMulFuncTool.Text = debugtxt + $"\ndistance:{distance}\nLocation:{(distance < RobotManage.t1Machine.Config.String_Offset_Range_Px ? "OK" : "NG")}";
pictureBox1.Image = bitmap;
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!