|
|
|
@ -0,0 +1,88 @@
|
|
|
|
|
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 int Fill(ETrayType trayType,int slotIndex)
|
|
|
|
|
{
|
|
|
|
|
string updateSql = $"update traystatus set status=1 where trayname='{trayType.ToString()}' and slotindex={slotIndex}";
|
|
|
|
|
return db.ExecuteNonQuery(updateSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按照traytype清空有料状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="trayType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int Clear(ETrayType trayType)
|
|
|
|
|
{
|
|
|
|
|
string updateSql = $"update traystatus set status=0 where trayname='{trayType.ToString()}'";
|
|
|
|
|
return db.ExecuteNonQuery(updateSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按照traytype 和 slotindex 清空有料状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="trayType"></param>
|
|
|
|
|
/// <param name="slotindex"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int Clear(ETrayType trayType,int slotindex)
|
|
|
|
|
{
|
|
|
|
|
string updateSql = $"update traystatus set status=0 where trayname='{trayType.ToString()}' and slotindex={slotindex}";
|
|
|
|
|
return 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|