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.

68 lines
2.0 KiB
C#

using Rs.DataAccess;
using Rs.Framework;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Commom
{
public class OffsetPoint
{
public double X { get; set; }
public double Y { get; set; }
public double A { get; set; }
public bool FindOK { get; set; } = false;
public void Reset()
{
X= 0; Y = 0; A = 0;
FindOK = false;
}
}
/// <summary>
/// 周转盘单个穴位偏移
/// </summary>
public static class TurnoverSlotOffset
{
static DataTable data = new DataTable();
static SqliteHelper db = new SqliteHelper();
public static void Init()
{
string querySql = $"select * from SlotOffset where recipename='{GlobalVar.CurRecipe}' and trayname='Turnover'";
data = db.GetDataTable(querySql);
}
public static void Reload()
{
data = new DataTable();
string querySql = $"select * from SlotOffset where recipename='{GlobalVar.CurRecipe}' and trayname='Turnover'";
data = db.GetDataTable(querySql);
}
public static OffsetPoint GetOffsetPoint(int slotIndex)
{
OffsetPoint offsetPoint = new OffsetPoint();
if (ObjectHelper.IsNotNullorEmpty(data))
{
List<DataRow> drList = data.AsEnumerable().Where(d => d.Field<int>("SlotIndex") == slotIndex).ToList();
if(drList!=null && drList.Count>0)
{
offsetPoint.FindOK= true;
offsetPoint.X = double.Parse(drList[0]["OffsetX"].ToString());
offsetPoint.Y = double.Parse(drList[0]["OffsetY"].ToString());
offsetPoint.A = double.Parse(drList[0]["OffsetA"].ToString());
return offsetPoint;
}
}
return offsetPoint;
}
}
}