BoardInfo.cs 7.6 KB
using TSA_V.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TSA_V.DeviceLibrary
{
    public class BoardInfo
    {

        /// <summary>
        /// 电路板ID
        /// </summary>
        public int boardId { get; set; }
        /// <summary>
        /// 元器件库名称
        /// </summary>
        public string bomName { get; set; }
        /// <summary>
        /// 电路板名称
        /// </summary>
        public string boardName { get; set; }
        /// <summary>
        /// 电路板条形码
        /// </summary>
        public string boardCode { get; set; }
        /// <summary>
        /// 宽度(显示的长度→)
        /// </summary>
        public int boardWidth { get; set; }
        /// <summary>
        /// 高度(显示的高度↑)
        /// </summary>
        public int boardLength { get; set; }
        /// <summary>
        /// 元器件列表
        /// </summary>
        public List<SMTPointInfo> smtList { get; set; }

        /// <summary>
        /// 基准点坐标X
        /// </summary>
        public double originX = 800;
        /// <summary>
        /// 基准点坐标Y
        /// </summary>
        public double originY = 800;
        /// <summary>
        /// 图片名称
        /// </summary>
        public string imgName { get; set; }

        /// <summary>
        /// 固定原点的位置,1=左上角,2=左下角,3=右上角,4=右下角
        /// </summary>
        public int orgType { get; set; }


        public double BaseX = 0;
        public double BaseY = 0;
        public double BaseImageX = 0;
        public double BaseImageY = 0;

        public string AOIProName = "";

        public Image myImage = null;
        public Image GetImage()
        {
            if (myImage == null)
            {
                string path = ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_PATH);
                string imagePath = Application.StartupPath + "/" + path + "/" + imgName;
                string defaultImg = ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_DEFAULT);
                if (imgName != null && File.Exists(imagePath))
                {
                    System.Drawing.Image img = System.Drawing.Image.FromFile(imagePath); 
                    myImage = new System.Drawing.Bitmap(img); 
                    img.Dispose();
                }
                else
                {
                    return BoardManager.defaultImage;
                }
            }
            if (myImage == null)
            {
                return BoardManager.defaultImage;
            }
            else
            {
                return myImage;
            }

        }
        public string GetDes( )
        {
            return  " "+ResourceControl.GetString(ResourceControl.Length,"长度")+":" + boardLength + ","+ ResourceControl.GetString(ResourceControl.Width, "宽度")+":" + boardWidth + ","+ ResourceControl.GetString(ResourceControl.InfoCount, "组件数量") + ":" + smtList.Count;
            //return "电路板名称:" + boardName + ",长度:" + boardLength + ",宽度:" + boardWidth + ",组装信息数量:" + pointList.Count;
        }

        public List<SMTPointInfo> GetSolderingSMTList()
        {
            List<SMTPointInfo> newList = (from m in smtList where m.NeedSoldering.Equals(true) select m).ToList<SMTPointInfo>();
            return newList;
        }
        public List<SMTPointInfo> GetCheckSMTList()
        {
            List<SMTPointInfo> newList = (from m in smtList where m.NeedCheck.Equals(true) select m).ToList<SMTPointInfo>();
            return newList;
        }

        public string GetAoiFileName()
        {
            string path = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig)+AOIProName;
            return path;
        }
    }

    /// <summary>
    ///组装信息信息
    /// </summary>
    public class SMTPointInfo
    {
        public SMTPointInfo()
        {
            PositionNum = "";
            pointNum = 0;
            pointName = "";
            PositionX = 0;
            PositionY = 0;
        }
        public SMTPointInfo(int num, string partNum, string name, double positionX, double positionY, string PositionNum, bool needs, bool needc, int sTemp, double
            sTime,int pointType,int pointSizex,int pointSizeY,int penWidth)
        {
            this.PartNum = partNum;
            this.pointNum = num;
            this.pointName = name;
            this.PositionX = positionX;
            this.PositionY = positionY;
            this.PositionNum = PositionNum;
            this.NeedCheck = needc;
            this.NeedSoldering = needs;
            this.WeldTemp = sTemp;
            this.WeldTime = sTime;
            this.PointType = pointType;
            this.PointSizeX = pointSizex;
            this.PointSizeY = pointSizeY;
            this.PenWidth = penWidth;
            this.ShowText = name;
        }
       
        /// <summary>
        ///组装信息编号
        /// </summary>
        public int pointNum { get; set; }

        /// <summary>
        /// 编号,与元器件库中的编号一致,不可以修改,作为关联关系
        /// </summary>
        public string PartNum { get; set; }

        /// <summary>
        /// 料格的位置信息
        /// </summary>
        public string PositionNum { get; set; }
        /// <summary>
        ///组装信息名字
        /// </summary>
        public string pointName { get; set; }

        /// <summary>
        /// 图片上显示的x坐标
        /// </summary>
        public double PositionX { get; set; }
        /// <summary>
        ///图片上显示的 y坐标
        /// </summary>
        public double PositionY { get; set; }


        private double nodePositionX;
        private double nodePositionY;
        /// <summary>
        /// X轴的移动坐标
        /// </summary>
        public double NodePositionX
        {
            get { return nodePositionX; }
            set
            {
                nodePositionX = Math.Round(value, 2);
            }
        }
        /// <summary>
        /// Y轴的移动坐标
        /// </summary>
        public double NodePositionY
        {
            get { return nodePositionY; }
            set
            {
                nodePositionY = Math.Round(value, 2);
            }
        }

        /// <summary>
        /// 是否需要焊接
        /// </summary>
        public bool NeedSoldering { get; set; }
        /// <summary>
        /// 焊接温度
        /// </summary>
        public int WeldTemp { get; set; }
        /// <summary>
        /// 焊接时间,秒,可以小数
        /// </summary>
        public double WeldTime { get; set; }
        /// <summary>
        /// 是否需要检测
        /// </summary>
        public bool NeedCheck { get; set; }

        /// <summary>
        /// 是否已经校准
        /// </summary>
        public bool CheckOK = false;

        public string  ToCSVStr()
        {
            string spilt = ",";
            return  pointName + spilt + "1" + spilt + "2" + spilt + PositionX + spilt + PositionY + spilt + "CRD" + spilt + NodePositionX + spilt + NodePositionY;
        }

        /// <summary>
        /// 点类型,1=点,2=+,3=|,3=-,4=方形,5=圆圈
        /// </summary>
        public int PointType = 1;
        /// <summary>
        /// 点大小
        /// </summary>
        public int PointSizeX = 1;
        public int PointSizeY = 1;

        public int PenWidth = 2;

        public string ShowText = "";
    }
}