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.
225 lines
6.6 KiB
C#
225 lines
6.6 KiB
C#
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json;
|
|
using Rs.Framework;
|
|
using Rs.MotionPlat.Commom;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Rs.DataAccess;
|
|
|
|
namespace Rs.MotionPlat.Entitys.Trays
|
|
{
|
|
public enum ETestTraySlotStatus
|
|
{
|
|
/// <summary>
|
|
/// 有产品
|
|
/// </summary>
|
|
Have,
|
|
/// <summary>
|
|
/// 无产品
|
|
/// </summary>
|
|
NotHave,
|
|
/// <summary>
|
|
/// 有产品且真空异常
|
|
/// </summary>
|
|
VacException,
|
|
/// <summary>
|
|
/// 光纤异常
|
|
/// </summary>
|
|
FiberException,
|
|
/// <summary>
|
|
/// 所有
|
|
/// </summary>
|
|
All
|
|
}
|
|
/// <summary>
|
|
/// 测试盘状态管理类
|
|
/// </summary>
|
|
public class TestTrayManager
|
|
{
|
|
/// <summary>
|
|
/// 测试盘层数
|
|
/// </summary>
|
|
public int Floor { get; set; } = 1;
|
|
private TestTraySlot[] slots;
|
|
|
|
public List<TestTraySlot> Slots
|
|
{
|
|
get
|
|
{
|
|
return slots.ToList();
|
|
}
|
|
}
|
|
|
|
private TestTrayManager()
|
|
{
|
|
slots = new TestTraySlot[16];
|
|
for (int i = 0; i < 16; i++)
|
|
{
|
|
slots[i] = new TestTraySlot()
|
|
{
|
|
Index = i + 1,
|
|
IsHasProduct = false,
|
|
SN = "",
|
|
FromIndex = 0,
|
|
SuckerNo = 0
|
|
};
|
|
}
|
|
}
|
|
private static TestTrayManager instance;
|
|
public static TestTrayManager Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = new TestTrayManager();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
public TestTraySlot Slot(int slotIndex)
|
|
{
|
|
return slots[slotIndex - 1];
|
|
}
|
|
|
|
public List<TestTraySlot> GetSlots(ETestTraySlotStatus status)
|
|
{
|
|
List<TestTraySlot> results = new List<TestTraySlot>();
|
|
switch (status)
|
|
{
|
|
case ETestTraySlotStatus.Have:
|
|
results= slots.Where(s => s.IsHasProduct).ToList();
|
|
break;
|
|
case ETestTraySlotStatus.NotHave:
|
|
results = slots.Where(s => s.IsHasProduct==false).ToList();
|
|
break;
|
|
case ETestTraySlotStatus.VacException:
|
|
results = slots.Where(s => s.IsHasProduct && s.IsVacException==true).ToList();
|
|
break;
|
|
case ETestTraySlotStatus.FiberException:
|
|
results = slots.Where(s => s.IsHasProduct && s.IsFiberException==true).ToList();
|
|
break;
|
|
case ETestTraySlotStatus.All:
|
|
results = slots.ToList();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return results;
|
|
}
|
|
|
|
|
|
|
|
public string GetNeedTestSlotStr(SchedulingMaterial m_schedulingMaterial)
|
|
{
|
|
TurnoverInfos infos = new TurnoverInfos();
|
|
infos.Instruction = EInstruction.LoadAndUnloadResult;
|
|
infos.GroupID = m_schedulingMaterial.GroupID;
|
|
infos.TurnoverID = m_schedulingMaterial.TurnoverID;
|
|
|
|
List<TurnoverInfo> testLoadTaskList = new List<TurnoverInfo>();
|
|
foreach (TestTraySlot slot in slots)
|
|
{
|
|
if(slot.IsHasProduct)
|
|
{
|
|
TurnoverInfo ti = new TurnoverInfo();
|
|
ti.GUID = GuidHelper.Create();
|
|
ti.FromType = slot.FromType;
|
|
ti.FromFloor = 1;
|
|
ti.FromIndex = slot.FromIndex;
|
|
ti.SN = slot.SN;
|
|
ti.ToType = TurnoverType.Tester;
|
|
ti.ToFloor = Floor++;
|
|
ti.ToIndex = slot.Index-1;
|
|
testLoadTaskList.Add(ti);
|
|
//ti.taskMode = taskMode;
|
|
//ti.Instruction = sm.Instruction;
|
|
//ti.GroupID = sm.GroupID;
|
|
//ti.TurnoverID = sm.TurnoverID;
|
|
}
|
|
}
|
|
infos.Infos = testLoadTaskList;
|
|
string content = JsonConvert.SerializeObject(infos, new StringEnumConverter());
|
|
return content;
|
|
}
|
|
|
|
|
|
public List<TestTraySlot> GetAll()
|
|
{
|
|
return slots.ToList();
|
|
}
|
|
/// <summary>
|
|
/// 重置测试治具穴位状态
|
|
/// </summary>
|
|
public void ResetStatus()
|
|
{
|
|
foreach (TestTraySlot slot in slots)
|
|
{
|
|
slot.IsHasProduct= false;
|
|
slot.FromIndex = 0;
|
|
slot.FromType = TurnoverType.Unknown;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class TestTraySlot:BaseTraySlot
|
|
{
|
|
/// <summary>
|
|
/// 真空是否异常
|
|
/// </summary>
|
|
public bool IsVacException { get; set; } = false;
|
|
/// <summary>
|
|
/// 光纤是否异常
|
|
/// </summary>
|
|
public bool IsFiberException { get; set; } = false;
|
|
|
|
public void AddProduct(TransitNozzle nozzle)
|
|
{
|
|
IsHasProduct = true;
|
|
SN = nozzle.SN;
|
|
FromIndex = nozzle.FromIndex;
|
|
FromType = nozzle.FromType;
|
|
SuckerNo = nozzle.NozzleIndex;
|
|
Task.Run(() => {
|
|
SqliteHelper db = new SqliteHelper();
|
|
string updateSql = $"update TrayStatus set status=1 where trayname='FixtureTray' and slotindex={Index}";
|
|
db.ExecuteNonQuery(updateSql);
|
|
});
|
|
}
|
|
|
|
public void ClearProduct()
|
|
{
|
|
IsHasProduct = false;
|
|
SN = "";
|
|
FromIndex = 0;
|
|
FromType = TurnoverType.Unknown;
|
|
SuckerNo = 0;
|
|
Task.Run(() => {
|
|
SqliteHelper db = new SqliteHelper();
|
|
string updateSql = $"update TrayStatus set status=0 where trayname='FixtureTray' and slotindex={Index}";
|
|
db.ExecuteNonQuery(updateSql);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通过真空判断穴位中是否有产品
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool HasProduct()
|
|
{
|
|
return Ops.IsOn($"测试{Index}号穴位真空吸检测");
|
|
}
|
|
|
|
public void ResetStatus()
|
|
{
|
|
IsHasProduct = false;
|
|
FromIndex = 0;
|
|
FromType = TurnoverType.Unknown;
|
|
}
|
|
}
|
|
}
|