You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
6.1 KiB
C#

using Rs.Controls;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Entitys;
using Rs.MotionPlat.Flow.NormalFlow;
using Rs.MotionPlat.Flow.SafePosFlow;
using Rs.MotionPlat.Flow.SubFlow;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Rs.MotionPlat.SysConfig
{
public partial class SelectProductFrm : BaseFormHeader
{
string logInfo = string.Empty;
public SelectProductFrm()
{
InitializeComponent();
}
private void btnSelect_Click(object sender, EventArgs e)
{
if(!string.IsNullOrEmpty(txtSn.Text))
{
ThreePointLocationFlow.Instance.Location(ETrayType.ReTest);
}
SelectProduct();
}
/// <summary>
/// 挑料流程
/// </summary>
void SelectProduct()
{
this.dataGridView1.Rows.Clear();
Task.Run(() => {
string fileName = string.Empty;
string selectDir = $"d:\\Select\\{DateTime.Now.ToString("yyyyMMdd")}";
if (!Directory.Exists(selectDir))
{
Directory.CreateDirectory(selectDir);
}
//获取这个文件夹下面的所有文件
string[] files = Directory.GetFiles(selectDir);
if (files != null && files.Length > 0)
{
//List<int> fint = new List<int>();
//foreach (string file in files)
//{
// string fname = Path.GetFileName(file);
// string[] items = fname.Split('-');
// int index =int.Parse(Path.GetFileNameWithoutExtension(items[1]));
// fint.Add(index);
//}
fileName = $"{DateTime.Now.ToString("yyyyMMdd")}-{files.Length+1}.csv";
}
else
{
fileName = $"{DateTime.Now.ToString("yyyyMMdd")}-1.csv";
}
for (int i = 0; i < 256; i++)
{
bool exit = false;
while (!exit)
{
ProductLocationResult fixtureret = FixedGrabProductFlow.Instance.Grab(ETrayType.Grr, i+1,1);
if (fixtureret != null)
{
if (fixtureret.Result == EOneGrabSixteenResult.Ok)
{
logInfo = $"{i + 1},{fixtureret.SN}\r\n";
File.AppendAllText(Path.Combine(selectDir, fileName), logInfo);
Invoke(new Action(() => {
dataGridView1.Rows.Add(i + 1, fixtureret.SN);
}));
if(txtSn.Text.IndexOf(fixtureret.SN)>=0)
{
//ProductLocationResult ret = OneGrabSixteenManager.Instance.GetResultByIndex(0);
//ret.SlotIndex = i+1;
//ret.SN= fixtureret.SN;
//ret.OffsetX = fixtureret.OffsetX;
//ret.OffsetY = fixtureret.OffsetY;
StockTakeFlow.Instance.Take( ETrayType.Grr, i + 1, 1, fixtureret);
TraySlot slot = GlobalTray.RetestTray.GetSlot(Rs.Controls.ESlotStatus.NotHave);
StockPlaceFlow.Instance.Place(ETrayType.ReTest, slot.Index, 1);
}
exit = true;
}
else if (fixtureret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail)
{
EButtonType buttonSelect = Msgbox.ShowTipDialog(EButtonType.Retry | EButtonType.Skip, $"穴位{i + 1}扫码失败","scan fail",true);
if (buttonSelect == EButtonType.Skip)
{
logInfo = $"{i + 1},NG\r\n";
Invoke(new Action(() => {
dataGridView1.Rows.Add(i + 1, "NG");
}));
File.AppendAllText(Path.Combine(selectDir, fileName), logInfo);
exit = true;
}
}
else if (fixtureret.Result == EOneGrabSixteenResult.Slant)
{
EButtonType buttonSelect = Msgbox.ShowTipDialog(EButtonType.Retry | EButtonType.EndInput | EButtonType.Skip, $"穴位{i + 1}定位失败","location fail",true);
if (buttonSelect == EButtonType.EndInput)
{
DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
exit = true;
return;
}
else if (buttonSelect == EButtonType.Skip)
{
logInfo = $"{i + 1},\r\n";
Invoke(new Action(() => {
dataGridView1.Rows.Add(i + 1, "");
}));
File.AppendAllText(Path.Combine(selectDir, fileName), logInfo);
exit = true;
}
}
}
}
}
DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
});
}
}
}