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.
203 lines
7.9 KiB
C#
203 lines
7.9 KiB
C#
using Rs.DataAccess;
|
|
using Rs.MotionPlat.Commom;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Rs.MotionPlat.Entitys.Trays
|
|
{
|
|
/// <summary>
|
|
/// 料盘的状态管理
|
|
/// </summary>
|
|
public static class TrayStatusManager
|
|
{
|
|
static SqliteHelper db = new SqliteHelper();
|
|
/// <summary>
|
|
/// 按traytype填充数据
|
|
/// </summary>
|
|
/// <param name="trayType"></param>
|
|
/// <returns></returns>
|
|
public static void Fill(ETrayType trayType)
|
|
{
|
|
Task.Run(() => {
|
|
string updateSql = $"update traystatus set status=1 where trayname='{trayType.ToString()}'";
|
|
db.ExecuteNonQuery(updateSql);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按traytype和slotindex填充数据
|
|
/// </summary>
|
|
/// <param name="trayType"></param>
|
|
/// <param name="slotIndex"></param>
|
|
/// <returns></returns>
|
|
public static void Fill(ETrayType trayType,int slotIndex)
|
|
{
|
|
Task.Run(() => {
|
|
string updateSql = $"update traystatus set status=1 where trayname='{trayType.ToString()}' and slotindex={slotIndex}";
|
|
db.ExecuteNonQuery(updateSql);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按照traytype清空有料状态
|
|
/// </summary>
|
|
/// <param name="trayType"></param>
|
|
/// <returns></returns>
|
|
public static void Clear(ETrayType trayType)
|
|
{
|
|
Task.Run(() => {
|
|
string updateSql = $"update traystatus set status=0 where trayname='{trayType.ToString()}'";
|
|
db.ExecuteNonQuery(updateSql);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按照traytype 和 slotindex 清空有料状态
|
|
/// </summary>
|
|
/// <param name="trayType"></param>
|
|
/// <param name="slotindex"></param>
|
|
/// <returns></returns>
|
|
public static void Clear(ETrayType trayType,int slotindex)
|
|
{
|
|
Task.Run(() => {
|
|
string updateSql = $"update traystatus set status=0 where trayname='{trayType.ToString()}' and slotindex={slotindex}";
|
|
db.ExecuteNonQuery(updateSql);
|
|
});
|
|
}
|
|
|
|
public static void Init(ETrayType trayType)
|
|
{
|
|
GlobalTray.GetTray(trayType).ChangeStatus(Controls.ESlotStatus.NotHave);
|
|
string selectSql = $"select * from traystatus where trayname='{trayType.ToString()}'";
|
|
DataTable dt=db.GetDataTable(selectSql);
|
|
if(dt!=null&&dt.Rows.Count>0)
|
|
{
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
if (row["status"].ToString()=="1")
|
|
{
|
|
GlobalTray.GetTray(trayType).ChangeStatus(int.Parse(row["slotindex"].ToString()), Controls.ESlotStatus.Have);
|
|
}
|
|
else
|
|
{
|
|
GlobalTray.GetTray(trayType).ChangeStatus(int.Parse(row["slotindex"].ToString()), Controls.ESlotStatus.NotHave);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 加载排料吸嘴状态
|
|
/// </summary>
|
|
public static void InitDischargeNozzle()
|
|
{
|
|
string selectSql = $"select * from traystatus where trayname='DischargeNozzle'";
|
|
DataTable dt = db.GetDataTable(selectSql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
if (row["status"].ToString() == "1")
|
|
{
|
|
int slotIndex = int.Parse(row["slotindex"].ToString());
|
|
GlobalTray.DischargeNozzle.ChangeStatus(slotIndex, Controls.ESlotStatus.Have);
|
|
Nozzle nozzle = NozzleManager.GetNozzle(slotIndex);
|
|
if(nozzle!=null)
|
|
{
|
|
NozzleManager.GetNozzle(slotIndex).FromType = TurnoverType.Turnover;
|
|
nozzle.FromIndex = slotIndex - 1;
|
|
NozzleManager.GetNozzle(slotIndex).ToType = TurnoverType.Multifunction;
|
|
nozzle.ToIndex = 0;
|
|
NozzleManager.GetNozzle(slotIndex).Status = ENozzleStatus.ToUnload;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载周转盘状态
|
|
/// </summary>
|
|
public static void InitTrunoverTray()
|
|
{
|
|
string selectSql = $"select * from traystatus where trayname='TurnoverTray'";
|
|
DataTable dt = db.GetDataTable(selectSql);
|
|
if(dt!=null &&dt.Rows.Count>0)
|
|
{
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
if (row["status"].ToString()=="1")
|
|
{
|
|
GlobalTray.TurnoverTray.ChangeStatus(int.Parse(row["slotindex"].ToString()), Controls.ESlotStatus.Have);
|
|
TurnoverTrayManager.Instance.Slot(int.Parse(row["slotindex"].ToString())).IsHasProduct = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载周转吸嘴状态
|
|
/// </summary>
|
|
public static void InitTurnoverNozzle()
|
|
{
|
|
string selectSql = $"select * from traystatus where trayname='TurnoverNozzle' and status=1";
|
|
DataTable dt = db.GetDataTable(selectSql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
int slotIndex = int.Parse(row["slotindex"].ToString());
|
|
GlobalTray.TurnoverNozzle.ChangeStatus(slotIndex, Controls.ESlotStatus.Have);
|
|
TransitNozzleManager.Instance.Nozzle(slotIndex).FromType = TurnoverType.Turnover;
|
|
TransitNozzleManager.Instance.Nozzle(slotIndex).FromIndex = slotIndex - 1;
|
|
TransitNozzleManager.Instance.Nozzle(slotIndex).ToType = TurnoverType.Multifunction;
|
|
TransitNozzleManager.Instance.Nozzle(slotIndex).ToIndex = (slotIndex <= 8 ? slotIndex + 8 : slotIndex + 16) - 1;
|
|
TransitNozzleManager.Instance.Nozzle(slotIndex).IsHasProduct = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载治具盘状态
|
|
/// </summary>
|
|
public static void InitFixtureTray()
|
|
{
|
|
string selectSql = $"select * from traystatus where trayname='FixtureTray'";
|
|
DataTable dt = db.GetDataTable(selectSql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
if (row["status"].ToString() == "1")
|
|
{
|
|
GlobalTray.TestTray.ChangeStatus(int.Parse(row["slotindex"].ToString()), Controls.ESlotStatus.Have);
|
|
TestTrayManager.Instance.Slot(int.Parse(row["slotindex"].ToString())).IsHasProduct = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void UpdateSlotAsync(string trayname, int slot, int status)
|
|
{
|
|
Task.Run(() => {
|
|
string updateSql = $"update traystatus set status={status} where trayname='{trayname}' and slotindex= {slot}";
|
|
db.ExecuteNonQuery(updateSql);
|
|
});
|
|
}
|
|
|
|
public static void UpdateMultiSlotAsync(string trayname,int[] slots,int status)
|
|
{
|
|
Task.Run(() => {
|
|
string slotindexs = string.Join(",", slots);
|
|
string updateSql = $"update traystatus set status={status} where trayname='{trayname}' and slotindex in({slotindexs})";
|
|
db.ExecuteNonQuery(updateSql);
|
|
});
|
|
}
|
|
}
|
|
}
|