using Rs.Controls; using Rs.DataAccess; using Rs.Framework; using Rs.MotionPlat.Flow; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Rs.MotionPlat.Commom { /// /// 料盘点位管理 /// public class TrayPointManager { static SqliteHelper db = new SqliteHelper(); static ConcurrentDictionary trayPoints = new ConcurrentDictionary(); public static void LoadPoint() { string querySql = "select * from TrayPoints"; DataTable dt = db.GetDataTable(querySql); if (ObjectHelper.IsNotNullorEmpty(dt)) { foreach (DataRow dataRow in dt.Rows) { string recipeName = dataRow["recipename"].ToString(); string trayName = dataRow["trayname"].ToString(); string slotIndex = dataRow["slotIndex"].ToString(); float x = float.Parse(dataRow["x"].ToString()); float y = float.Parse(dataRow["y"].ToString()); string key = $"{recipeName}-{trayName}-{slotIndex}"; if (!trayPoints.ContainsKey(key)) { trayPoints.TryAdd(key, new SlotPoint(x, y)); } } } } /// /// 获取料盘的点位 /// /// /// /// /// /// public static SlotPoint GetSlotPoint(ETrayType trayType,int slotIndex) { string key = $"{GlobalVar.CurRecipe}-{trayType}-{slotIndex}"; if(trayPoints.ContainsKey(key)) { return trayPoints[key]; } return null; } /// /// 获取异常料盘的点位 /// /// /// /// /// /// public static SlotPoint GetExceptionTrayPoint(int slotIndex) { string key = $"{GlobalVar.CurRecipe}-ExceptiontTray-{slotIndex}"; if (trayPoints.ContainsKey(key)) { return trayPoints[key]; } return null; } /// /// 获取测试治具测高的点位 /// /// /// /// /// /// public static SlotPoint GetTestFixtureTrayCheckHeighPoint(int slotIndex) { string key = $"{GlobalVar.CurRecipe}-CheckHeightTestTray-{slotIndex}"; if (trayPoints.ContainsKey(key)) { return trayPoints[key]; } return null; } /// /// 获取周转盘测高的点位 /// /// /// /// /// /// public static SlotPoint GetTurnoverTrayCheckHeighPoint(int slotIndex) { string key = $"{GlobalVar.CurRecipe}-CheckHeightTurnover-{slotIndex}"; if (trayPoints.ContainsKey(key)) { return trayPoints[key]; } return null; } /// /// 获取周转盘强力吸嘴的点位 /// /// /// /// /// /// public static SlotPoint GetTurnoverTrayForceNozzlePoint(int slotIndex) { string key = $"{GlobalVar.CurRecipe}-ForceNozzleTurnover-{slotIndex}"; if (trayPoints.ContainsKey(key)) { return trayPoints[key]; } return null; } /// /// 获取周转盘强力吸嘴的点位 /// /// /// /// /// /// public static SlotPoint GetExceptiontTrayPoint(int slotIndex) { string key = $"{GlobalVar.CurRecipe}-ExceptiontTray-{slotIndex}"; if (trayPoints.ContainsKey(key)) { return trayPoints[key]; } return null; } public static SlotPoint GetDistToNozzle1(int nozzleIndex) { //先获取相机的中心位置 SlotPoint point = new SlotPoint(); double nozzle1ToCameraCenterX = SysConfigParam.GetValue("InkpadX") - SysConfigParam.GetValue("CameraInkpadX"); double nozzle1ToCameraCenterY = SysConfigParam.GetValue("InkpadY") - SysConfigParam.GetValue("CameraInkpadY"); //再加上指定吸嘴到吸嘴1的距离 double distToNozzle1X = SysConfigParam.GetValue($"Nozzle{nozzleIndex}CenterX") - SysConfigParam.GetValue($"Nozzle1CenterX"); double distToNozzle1Y = SysConfigParam.GetValue($"Nozzle{nozzleIndex}CenterY") - SysConfigParam.GetValue($"Nozzle1CenterY"); point.X = nozzle1ToCameraCenterX + distToNozzle1X; point.Y = nozzle1ToCameraCenterY + distToNozzle1Y; return point; } } }