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.
114 lines
4.4 KiB
C#
114 lines
4.4 KiB
C#
using Rs.Controls;
|
|
using Rs.DataAccess;
|
|
using Rs.Framework;
|
|
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 enum EPointType
|
|
{
|
|
/// <summary>
|
|
/// 基础点位
|
|
/// </summary>
|
|
BASE,
|
|
/// <summary>
|
|
/// 运行点位
|
|
/// </summary>
|
|
RUN
|
|
}
|
|
/// <summary>
|
|
/// 料盘点位管理
|
|
/// </summary>
|
|
public class TrayPointManager
|
|
{
|
|
static SqliteHelper db = new SqliteHelper();
|
|
static ConcurrentDictionary<string, SlotPoint> basePoints = new ConcurrentDictionary<string, SlotPoint>();
|
|
static ConcurrentDictionary<string, SlotPoint> runPoints = new ConcurrentDictionary<string, SlotPoint>();
|
|
public static void LoadPoint()
|
|
{
|
|
string querySql = "select * from TrayBasePoints";
|
|
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 (!basePoints.ContainsKey(key))
|
|
{
|
|
basePoints.TryAdd(key, new SlotPoint(x, y));
|
|
}
|
|
}
|
|
}
|
|
|
|
querySql = "select * from TrayRunPoints";
|
|
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 (!runPoints.ContainsKey(key))
|
|
{
|
|
runPoints.TryAdd(key, new SlotPoint(x, y));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取料盘的点位
|
|
/// </summary>
|
|
/// <param name="recipeName"></param>
|
|
/// <param name="trayName"></param>
|
|
/// <param name="slotIndex"></param>
|
|
/// <param name="pointType"></param>
|
|
/// <returns></returns>
|
|
public static SlotPoint GetSlotPoint(string recipeName,string trayName,int slotIndex, EPointType pointType= EPointType.BASE)
|
|
{
|
|
string key = $"{recipeName}-{trayName}-{slotIndex}";
|
|
if(pointType== EPointType.BASE && basePoints.ContainsKey(key))
|
|
{
|
|
return basePoints[key];
|
|
}
|
|
else if(pointType== EPointType.RUN && runPoints.ContainsKey(key))
|
|
{
|
|
return runPoints[key];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static SlotPoint GetDistToNozzle1(int nozzleIndex)
|
|
{
|
|
//先获取相机的中心位置
|
|
SlotPoint point = new SlotPoint();
|
|
double nozzle1ToCameraCenterX = SysConfigParam.GetValue<double>("InkpadX") - SysConfigParam.GetValue<double>("CameraInkpadX");
|
|
double nozzle1ToCameraCenterY = SysConfigParam.GetValue<double>("InkpadY") - SysConfigParam.GetValue<double>("CameraInkpadY");
|
|
|
|
//再加上指定吸嘴到吸嘴1的距离
|
|
double distToNozzle1X = SysConfigParam.GetValue<double>($"Nozzle{nozzleIndex}CenterX") - SysConfigParam.GetValue<double>($"Nozzle1CenterX");
|
|
double distToNozzle1Y = SysConfigParam.GetValue<double>($"Nozzle{nozzleIndex}CenterY") - SysConfigParam.GetValue<double>($"Nozzle1CenterY");
|
|
|
|
point.X = nozzle1ToCameraCenterX + distToNozzle1X;
|
|
point.Y = nozzle1ToCameraCenterY + distToNozzle1Y;
|
|
return point;
|
|
}
|
|
}
|
|
}
|