孝锋 徐 10 месяцев назад
Родитель
Сommit
097202d91d

+ 192 - 0
TeamAAS-VM/Core/Cameras/SRCSharpTools.cs

@@ -0,0 +1,192 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Drawing.Imaging;
+using System.Runtime.InteropServices;
+using System.Drawing;
+
+namespace SRCSharpDemo
+{
+    public class SRCSharpTools
+    {
+        private Dictionary<string, Dictionary<string, string>> translations = new Dictionary<string, Dictionary<string, string>>();
+        public string currentDir;
+        private string translateCountry;
+
+        public SRCSharpTools()
+        {
+        }
+
+        #region language
+        public void IniLanguageLoader(int translateMode)
+        {
+            SetTranslateMode(translateMode);
+            LoadTranslateIni();
+        }
+        public void SetTranslateMode(int translateMode)
+        {
+            if (translateMode == 0)
+            {
+                translateCountry = "CHINESE";
+            }
+            else if (translateMode == 2)
+            {
+                translateCountry = "KOREAN";
+            }
+            else
+            {
+                translateCountry = "ENGLISH";
+            }
+        }
+
+        private void LoadTranslateIni()
+        {
+            currentDir = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
+            string translateIniPath = currentDir + "//Language.ini";
+            if (!File.Exists(translateIniPath))
+            {
+                Console.WriteLine("Error: INI file not found!");
+                return;
+            }
+
+            string currentLanguage = null;
+
+            foreach (var line in File.ReadAllLines(translateIniPath))
+            {
+                string trimmed = line.Trim();
+                if (string.IsNullOrEmpty(trimmed) || trimmed.StartsWith(";")) continue;
+
+                if (trimmed.StartsWith("[") && trimmed.EndsWith("]"))
+                {
+                    currentLanguage = trimmed.Trim('[', ']');
+                    if (!translations.ContainsKey(currentLanguage))
+                    {
+                        translations[currentLanguage] = new Dictionary<string, string>();
+                    }
+                }
+                else if (currentLanguage != null && trimmed.Contains("="))
+                {
+                    int index = trimmed.IndexOf('=');
+                    if (index > 0)  //Make sure '=' exists
+                    {
+                        string key = trimmed.Substring(0, index).Trim();
+                        string value = trimmed.Substring(index + 1).Trim();
+                        translations[currentLanguage][key] = value;
+                    }
+                }
+            }
+        }
+
+        public string GetTranslationF(string key, string language = "ENGLISH", string defaultValue = "Translation not found")
+        {
+            if (translations.ContainsKey(language) && translations[language].ContainsKey(key))
+            {
+                return translations[language][key];
+            }
+            return defaultValue;
+        }
+        public string GetTranslation(string key, string defaultValue = "Translation not found")
+        {
+            if (translations.ContainsKey(translateCountry) && translations[translateCountry].ContainsKey(key))
+            {
+                return translations[translateCountry][key];
+            }
+            return defaultValue;
+        }
+        #endregion
+
+        #region show image
+
+        public Bitmap CreateBitmapFromChannels(byte[] pR, byte[] pG, byte[] pB, int width, int height)
+        {
+            int nTotalPoints = width * height;
+            byte[] pRGBData = new byte[width * height * 3]; // 24-bit RGB
+
+            // Merge R, G, B into RGB array
+            for (int i = 0; i < nTotalPoints; i++)
+            {
+                pRGBData[i * 3 + 0] = pB[i]; // Blue
+                pRGBData[i * 3 + 1] = pG[i]; // Green
+                pRGBData[i * 3 + 2] = pR[i]; // Red
+            }
+            
+            Bitmap bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
+            BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
+
+            // Copy data to Bitmap
+            Marshal.Copy(pRGBData, 0, bmpData.Scan0, pRGBData.Length);
+            bmp.UnlockBits(bmpData);
+            
+            return bmp;
+        }
+
+        public Bitmap ByteArrayToGrayBitmap(byte[] imageData, int width, int height)
+        {
+            Bitmap bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
+
+            // 获取 Bitmap 数据
+            BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height),
+                                              ImageLockMode.WriteOnly,
+                                              PixelFormat.Format8bppIndexed);
+
+            // 复制数据
+            IntPtr ptr = bmpData.Scan0;
+            int stride = bmpData.Stride;
+            byte[] newData = new byte[stride * height];
+
+            // 把数据按行复制到新数组
+            for (int y = 0; y < height; y++)
+            {
+                Array.Copy(imageData, y * width, newData, y * stride, width);
+            }
+
+            Marshal.Copy(newData, 0, ptr, newData.Length);
+            bmp.UnlockBits(bmpData);
+
+            // 调整颜色表,确保正确显示灰度图
+            ColorPalette palette = bmp.Palette;
+            for (int i = 0; i < 256; i++)
+            {
+                palette.Entries[i] = Color.FromArgb(i, i, i);
+            }
+            bmp.Palette = palette;
+
+            return bmp;
+        }
+
+        #endregion
+
+        #region SetSetting item
+        public List<string> GetSettingParams()
+        {
+            List<string> veParams = new List<string>();
+            veParams.Add(GetTranslation("SETTING_TRIG_MODE"));
+            veParams.Add(GetTranslation("SETTING_SAMPLED_CYCLE"));
+            veParams.Add(GetTranslation("SETTING_BATCH_ON_OFF"));
+            veParams.Add(GetTranslation("SETTING_ENCODER_TYPE"));
+            veParams.Add(GetTranslation("SETTING_ENCODER_INPUTMODE"));
+            veParams.Add(GetTranslation("SETTING_REFINING_POINTS"));
+            veParams.Add(GetTranslation("SETTING_BATCH_POINT"));
+            veParams.Add(GetTranslation("SETTING_CYCLICAL_PATTERN"));
+            veParams.Add(GetTranslation("SETTING_BATCH_OUTPUT"));
+            veParams.Add(GetTranslation("SETTING_Z_MEASURING_RANGE"));
+            veParams.Add(GetTranslation("SETTING_SENSITIVITY"));
+            veParams.Add(GetTranslation("SETTING_EXP_TIME"));
+            veParams.Add(GetTranslation("SETTING_LIGHT_CONTROL"));
+            veParams.Add(GetTranslation("SETTING_LIGHT_MAX"));
+            veParams.Add(GetTranslation("SETTING_LIGHT_MIN"));
+            veParams.Add(GetTranslation("SETTING_PEAK_SENSITIVITY"));
+            veParams.Add(GetTranslation("SETTING_PEAK_SELECT"));
+            veParams.Add(GetTranslation("SETTING_X_SAMPLING"));
+            veParams.Add(GetTranslation("SETTING_FILTER_X_MEDIAN"));
+            veParams.Add(GetTranslation("SETTING_FILTER_X_SMOOTH"));
+            veParams.Add(GetTranslation("SETTING_FILTER_Y_MEDIAN"));
+            veParams.Add(GetTranslation("SETTING_FILTER_Y_SMOOTH"));
+            veParams.Add(GetTranslation("SETTING_CHANGE_3D_25D"));
+            veParams.Add(GetTranslation("SETTING_X_PIXEL"));
+            veParams.Add(GetTranslation("SETTING_X_PITCH"));
+            return veParams;
+        }
+        #endregion
+    }
+}

+ 668 - 0
TeamAAS-VM/Core/Cameras/SSZNCamera.cs

@@ -0,0 +1,668 @@
+using Cognex.VisionPro;
+using Cognex.VisionPro.ToolBlock;
+using CSScripting;
+using Microsoft.Win32;
+using NPOI.SS.Formula.Functions;
+using SR7Link;
+using SRAPI;
+using SRCSharpDemo;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TeamAAS_VP.Enums;
+using TeamAAS_VP.Interfaces;
+using TeamAAS_VP.Models;
+
+namespace TeamAAS_VP.Core.Cameras
+{
+    public class SSZNCamera : ICamera, INotifyPropertyChanged
+    {
+        #region 字段
+        private Thread m_hReceiveThread;
+        // 用于序列化对同一相机实例的操作,防止同一实例被并发操作
+        private readonly SemaphoreSlim _operationSemaphore = new SemaphoreSlim(1, 1);
+        // 用于保护状态变量(例如 IsGrabbing)的并发访问
+        private readonly object _stateLock = new object();
+
+        private SR7ApiOneTimeCallbackImpl iSR7APi = new SR7ApiOneTimeCallbackImpl();
+        public SRCSharpTools srcsharpTools = new SRCSharpTools();
+        private SR7IFGetDataCallBack GetDataDelegate;
+        #endregion
+
+        #region define
+        private int lastTotalPoints = 0; // 记录上次的总点数 / Record the last total points
+        public int coutCallbackPoints;//统计总回调行数 / Count the total number of callback rows
+        public uint profile16Bits = 0;//0:32bit 1:16bit
+
+        //define
+        public const int INVALID_VALUE_MIN = -1000000000;
+        public const int INVALID_VALUE_MAX = 1000000000;
+        #endregion
+
+        #region Image cache variable
+        //image cache
+        public int[][] ImgBuff32;   // 32-bit height data
+        public short[][] ImgBuff16; // 16-bit height data
+        public byte[][] GrayBuff;    // Grayscale data
+        public int[][] Encoder;    // Encoder data
+        #endregion
+
+        #region 属性
+
+        public CameraBrand CameraBrand { get => CameraBrand.SSZN; }
+
+        public string Name { get; private set; }
+        public Guid ID { get; private set; }
+        public int Index { get; set; }
+        public string ManufacturerName { get; private set; }
+
+        public bool IsFindByIp { get; private set; }
+
+        public string ModelName { get; private set; }
+
+        public string SerialNumber { get; private set; }
+
+        public string CameraIp { get; private set; }
+
+        public CameraType CameraType { get; private set; }
+
+        public UInt32 ImageWidth { get; private set; }
+
+        public UInt32 ImageHeight { get; private set; }
+
+        private bool _IsGrabbing;
+
+        /// <summary>
+        /// 正在采集
+        /// </summary>
+        public bool IsGrabbing
+        {
+            get { return _IsGrabbing; }
+            private set { SetProperty(ref _IsGrabbing, value); }
+        }
+
+        private ICogImage _Image;
+
+        public ICogImage Image
+        {
+            get { return _Image; }
+            private set { SetProperty(ref _Image, value); }
+        }
+
+        public bool IsConnected { get; private set; }
+
+        /// <summary>
+        /// 采集用时
+        /// </summary>
+        public TimeSpan TotalTime { get; private set; }
+
+        /// <summary>
+        /// 错误信息
+        /// </summary>
+        public string ErrorMessage { get; private set; }
+        #endregion
+
+        #region 事件
+        public event Action<ICogImage, TimeSpan, string> ImageCallbackEvent;
+        public event Action<Guid, bool> CameraConnectChangedEvent;
+        #endregion
+
+        public SSZNCamera(Guid id, int index, string name, string serialNumber, string cameraip, bool isFindByIp)
+        {
+            ID = id;
+            Name = serialNumber;
+            Index = index;
+            CameraIp = cameraip;
+            SerialNumber = serialNumber;
+            IsFindByIp = isFindByIp;
+            IsConnected = false;
+        }
+
+        #region 方法
+
+        /// <summary>
+        /// 获取设备
+        /// </summary>
+        /// <returns></returns>
+        public static CameraInfo[] GetDevices()
+        {
+            List<CameraInfo> cameras = new List<CameraInfo>();
+            try
+            {
+                if (!CheckSoftwareInstalled().isInstalled)
+                {
+                    LogHelper.WriteLogInfo("未安装MVS");
+                    return cameras.ToArray();
+                }
+                SR7ApiOneTimeCallbackImpl sR7Api=new SR7ApiOneTimeCallbackImpl();
+                List<string> cameraIPs = new List<string>();
+                if (!sR7Api.SearchCameraIP(out cameraIPs))
+                {
+                    return cameras.ToArray();
+                }
+                else
+                {
+                    for (int i = 0; i < cameraIPs.Count; i++)
+                    {
+                        cameras.Add(new CameraInfo()
+                        {
+                            CameraNo = i + 1,
+                            CameraName = "SSZN_" + cameraIPs[i],
+                            CameraBrand = CameraBrand.SSZN,
+                            CameraType = CameraType.GIGE,
+                            ManufacturerName = "SSZN",
+                            Model = "SSZN_Model",
+                            SerialNumber = "SSZN_SerialNumber",
+                            CameraIp = cameraIPs[i],
+                            IsFindByIp = true,
+                        });
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("搜索深视3D相机列表时出错!", ex);
+            }
+
+            return cameras.ToArray();
+        }
+
+        /// <summary>
+        /// 检查相机软件是否安装
+        /// </summary>
+        /// <returns></returns>
+        public static (bool isInstalled, string version) CheckSoftwareInstalled()
+        {
+            return (true, "");
+        }
+
+        /// <summary>
+        /// 打开相机
+        /// </summary>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public bool OpenDevice()
+        {
+            _operationSemaphore.Wait();
+            try
+            {
+                if (!iSR7APi.CameraBOnline)
+                {
+                    SR7Link.ErrConnectCallBack ErrConnectDelegate = new SR7Link.ErrConnectCallBack(ErrConnectFunc);
+                    ErrConnectDelegate = new ErrConnectCallBack(ErrConnectFunc);
+                    int nOpenRet = iSR7APi.Open(0, CameraIp, 2000, ErrConnectDelegate);
+                    if (nOpenRet == (int)SR7Link.SR7IF_ERROR.SR7IF_OK)
+                    {
+                        //设置相机参数,否则无法取图 / Set the camera parameters, otherwise you will not be able to take pictures
+                        //一次回调和无限回调可以设置批处理测量On,批处理数据接收无和循环 / One-time callback and infinite callback can set batch measurement On, batch data receiving None and loop
+                        //异步回调必须在Ed软件中设置 / Asynchronous callbacks must be set in the EdgeImaging software
+                        int nReadBastchValue = -1;
+                        int nSetParamRet = -1;
+                        int getParamRet = iSR7APi.GetParams(0, -1, SR7IF_SETTING_ITEM.BATCH_ON_OFF, out nReadBastchValue);
+                        if (nReadBastchValue != 1)
+                        {
+                            nSetParamRet = iSR7APi.SetParams(0, (int)SAVEPOWEROFF.ESAPO_SAVE, -1, SR7IF_SETTING_ITEM.BATCH_ON_OFF, 1);
+                            LogHelper.WriteLogInfo($"Set Batch On Off: {nSetParamRet}");
+                        }
+                        nSetParamRet = iSR7APi.SetParams(0, (int)SAVEPOWEROFF.ESAPO_SAVE, -1, SR7IF_SETTING_ITEM.CYCLICAL_PATTERN, 0);
+                        int nSetParamRet1 = iSR7APi.SetParams(0, (int)SAVEPOWEROFF.ESAPO_SAVE, -1, SR7IF_SETTING_ITEM.SEGMENT_BUFER, 0);
+                        LogHelper.WriteLogInfo($"Set Batch Data Receive: {nSetParamRet1}{nSetParamRet1}");
+
+                        GetDataDelegate = new SR7IFGetDataCallBack(GetDataCallBack);
+                        iSR7APi.Init(0,0,2000, GetDataDelegate);
+                    }
+                    LogHelper.WriteLogInfo($"Connect Camera {nOpenRet} {GetSDKErrMsgByCode(nOpenRet)}");
+                }
+                
+                if (!IsConnected)
+                {
+                    if (iSR7APi.CameraBOnline)
+                    {
+                        CameraConnectChangedEvent?.Invoke(ID, true);
+                    }
+                }
+                IsConnected = iSR7APi.CameraBOnline;
+                return IsConnected;
+            }
+            finally
+            {
+                _operationSemaphore.Release();
+            }
+        }
+
+        /// <summary>
+        /// 打开相机异步
+        /// </summary>
+        /// <returns></returns>
+        public Task<bool> OpenDeviceAsync()
+        {
+            return Task.Run(() =>
+            {
+                return OpenDevice();
+            });
+        }
+
+        /// <summary>
+        /// 关闭相机
+        /// </summary>
+        public void CloseDevice()
+        {
+            // ch:关闭设备 | en:Close Device
+            _operationSemaphore.Wait();
+            try
+            {
+                if (iSR7APi==null)
+                {
+                    return;
+                }
+                int nRet = iSR7APi.Close();
+                LogHelper.WriteLogInfo($"Close Camera: {nRet}{GetSDKErrMsgByCode(nRet)}");
+            }
+            finally
+            {
+                _operationSemaphore.Release();
+            }
+        }
+
+        /// <summary>
+        /// 采集图像
+        /// </summary>
+        /// <returns></returns>
+        public ICogImage Grab()
+        {
+            _operationSemaphore.Wait();
+            try
+            {
+                return Image;
+            }
+            finally
+            {
+                _operationSemaphore.Release();
+            }
+        }
+
+        /// <summary>
+        /// 开始采集图像
+        /// </summary>
+        public void StartGrabbing()
+        {
+            lock (_stateLock)
+            {
+                if (IsGrabbing)
+                    return;
+                IsGrabbing = true;
+            }
+            m_hReceiveThread = new Thread(GetStreamThreadProc) { IsBackground = true };
+            m_hReceiveThread.Start();
+        }
+
+        /// <summary>
+        /// 停止采集图像
+        /// </summary>
+        public void StopGrabbing()
+        {
+            try
+            {
+                lock (_stateLock)
+                {
+                    IsGrabbing = false;
+                }
+                Thread.Sleep(1000);
+                if (m_hReceiveThread != null)
+                {
+                    m_hReceiveThread.Abort();
+                    m_hReceiveThread = null;
+                }
+            }
+            catch (Exception)
+            {
+
+            }
+        }
+
+        /// <summary>
+        /// 设置曝光时间
+        /// </summary>
+        /// <param name="ExposureTime"></param>
+        /// <returns></returns>
+        public bool SetExposureTime(float ExposureTime)
+        {
+            //_operationSemaphore.Wait();
+            //try
+            //{
+            //    if (!mvCameraAcq.bIsOpened)
+            //        return false;
+            //    mvCameraAcq.ExposureTime = (double)ExposureTime;
+            //    return true;
+            //}
+            //finally
+            //{
+            //    _operationSemaphore.Release();
+            //}
+            return true;
+        }
+
+        /// <summary>
+        /// 获取曝光时间
+        /// </summary>
+        /// <returns></returns>
+        public float GetExposureTime()
+        {
+            //_operationSemaphore.Wait();
+            //try
+            //{
+            //    if (!mvCameraAcq.bIsOpened)
+            //        return 0;
+            //    return (float)mvCameraAcq.ExposureTime;
+            //}
+            //finally
+            //{
+            //    _operationSemaphore.Release();
+            //}
+            return 0;
+        }
+
+        /// <summary>
+        /// 设置增益
+        /// </summary>
+        /// <param name="Gain"></param>
+        /// <returns></returns>
+        public bool SetGain(float Gain)
+        {
+            //_operationSemaphore.Wait();
+            //try
+            //{
+            //    if (!mvCameraAcq.bIsOpened)
+            //        return false;
+            //    mvCameraAcq.AnalogGain = (double)Gain;
+            //    return true;
+            //}
+            //finally
+            //{
+            //    _operationSemaphore.Release();
+            //}
+            return true;
+        }
+
+        /// <summary>
+        /// 获取增益
+        /// </summary>
+        /// <returns></returns>
+        public float GetGain()
+        {
+            //_operationSemaphore.Wait();
+            //try
+            //{
+            //    if (!mvCameraAcq.bIsOpened)
+            //        return 0;
+            //    return (float)mvCameraAcq.AnalogGain;
+            //}
+            //finally
+            //{
+            //    _operationSemaphore.Release();
+            //}
+            return 0;
+        }
+
+        private void GetStreamThreadProc()
+        {
+            //while (IsGrabbing)
+            //{
+            //    try
+            //    {
+            //        Grab();
+            //        ImageCallbackEvent?.Invoke(Image, TotalTime, ErrorMessage);
+            //    }
+            //    catch (Exception)
+            //    {
+
+            //    }
+            //    Thread.Sleep(10);
+            //}
+            IsGrabbing = false;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="nProfileWidth">单条轮廓宽度数据 / Returns a single contour width data</param>
+        /// <param name="nHighlen">返回的批处理行数 / The number of rows in the batch returned</param>
+        /// <param name="nFlag">回调函数执行状态,根据不同模式自定义 / Callback function execution status, customized according to different modes</param>
+        /// <param name="nStatusCode">错误码,0无错误 / Error code, 0 no error</param>
+        /// <param name="ProfileBits">Sync callback 0:32bit data, 1:16bit data</param>
+        private void GetDataCallBack(int nProfileWidth, int nHighlen, int nFlag, int nStatusCode, int ProfileBits)
+        {
+            profile16Bits = (uint)ProfileBits;
+            if (nStatusCode == 0)
+            {
+                //Log($"Into GetDataFunc W:{nProfileWidth},H:{nHighlen},ErrCode:{nStatusCode}({GetSDKErrMsgByCode(nStatusCode)})");
+                //这里拿到相机数据做显示,可以根据其他具体业务实现自己的逻辑
+                //The camera data is obtained here for display, and you can implement your own logic according to other specific businesses
+                int nTempWidth = nProfileWidth;// iSR7APi.GetProfileDataWidth();
+                //双相机时,一次回调和异步回调nProfileWidth=3200,无限循环回调nProfileWidth=6400
+                //For dual cameras, nProfileWidth=3200 for one-time callback and asynchronous callback, and nProfileWidth=6400 for infinite loop callback
+                //if (iSR7APi.CameraBOnline && m_callbackMode == 2)//双相机 / dual camera
+                //    nTempWidth /= 2;
+
+                int offset = coutCallbackPoints * nTempWidth;
+                //iSR7APi.BatchPoints = nHighlen;
+                SImagePro.SPointCloudHead pcHead = new SImagePro.SPointCloudHead(0, 0, 0, 0, 0);
+                pcHead.width = (uint)nTempWidth;
+                pcHead.height = (uint)iSR7APi.BatchPoints;
+                pcHead.xInterval = iSR7APi.GetProfileData_XPitch();
+                pcHead.yInterval = iSR7APi.GetProfileData_XPitch();
+
+                if (ProfileBits == 0)
+                {
+                    int[] tempHeightDataA = new int[nTempWidth * nHighlen];
+                    byte[] tempGrayDataA = new byte[nTempWidth * nHighlen];
+                    iSR7APi.GetData(tempHeightDataA, tempGrayDataA, Encoder[0], (int)pcHead.width, (int)nHighlen, 0);
+                    Array.Copy(tempHeightDataA, 0, ImgBuff32[0], offset, nTempWidth * nHighlen);
+                    Array.Copy(tempGrayDataA, 0, GrayBuff[0], offset, nTempWidth * nHighlen);
+                    //if (ImgBuff32 != null && ImgBuff32.Length != 0 && ImgBuff32[0] != null)
+                    //{
+                    //    ShowRGBImage(ImgBuff32[0], pcHead, pictureBoxA);
+                    //}
+                    CogImage16Range cogImage16Range = SSZNCognexParser.SSZNParser.LoadSSZN3DImage(ImgBuff32[0], (int)pcHead.width, (int)pcHead.height, pcHead.xInterval, pcHead.yInterval);
+                    Image= cogImage16Range;
+                    ImageCallbackEvent?.Invoke(Image, TotalTime, ErrorMessage);
+                }
+                else
+                {
+                    short[] temp16bitDataA = new short[nTempWidth * nHighlen];
+                    byte[] tempGrayDataA = new byte[nTempWidth * nHighlen];
+                    iSR7APi.GetData(temp16bitDataA, tempGrayDataA, Encoder[0], (int)pcHead.width, (int)nHighlen, 0);
+                    Array.Copy(temp16bitDataA, 0, ImgBuff16[0], offset, nTempWidth * nHighlen);
+                    Array.Copy(tempGrayDataA, 0, GrayBuff[0], offset, nTempWidth * nHighlen);
+
+                    CogImage16Range cogImage16Range = SSZNCognexParser.SSZNParser.LoadSSZN3DImage(ImgBuff32[0], (int)pcHead.width, (int)pcHead.height, pcHead.xInterval, pcHead.yInterval);
+                    Image = cogImage16Range;
+                    ImageCallbackEvent?.Invoke(Image, TotalTime, ErrorMessage);
+                    //int[] showtemp16bitDataA = new int[pcHead.width * pcHead.height];
+                    //ShowTiff16Data(ImgBuff16[0], showtemp16bitDataA);
+
+                    //if (ImgBuff16 != null && ImgBuff16.Length != 0 && ImgBuff16[0] != null)
+                    //{
+                    //    ShowRGBImage(showtemp16bitDataA, pcHead, pictureBoxA);
+                    //}
+                }
+
+                //if (iSR7APi.CameraBOnline && ImgBuff32[1] != null)
+                //{
+                //    if (ProfileBits == 0)
+                //    {
+                //        int[] tempHeightDataB = new int[nTempWidth * nHighlen];
+                //        byte[] tempGrayDataB = new byte[nTempWidth * nHighlen];
+                //        iSR7APi.GetData(tempHeightDataB, tempGrayDataB, Encoder[1], (int)pcHead.width, (int)nHighlen, 1);
+                //        Array.Copy(tempHeightDataB, 0, ImgBuff32[1], offset, nTempWidth * nHighlen);
+                //        Array.Copy(tempGrayDataB, 0, GrayBuff[1], offset, nTempWidth * nHighlen);
+                //        //ShowRGBImage(ImgBuff32[1], pcHead, pictureBoxB);
+                //    }
+                //    else
+                //    {
+                //        short[] tempHeightDataB = new short[nTempWidth * nHighlen];
+                //        byte[] tempGrayDataB = new byte[nTempWidth * nHighlen];
+                //        iSR7APi.GetData(tempHeightDataB, tempGrayDataB, Encoder[1], (int)pcHead.width, (int)nHighlen, 1);
+                //        Array.Copy(tempHeightDataB, 0, ImgBuff16[1], offset, nTempWidth * nHighlen);
+                //        Array.Copy(tempGrayDataB, 0, GrayBuff[1], offset, nTempWidth * nHighlen);
+
+                //        int[] showtemp16bitDataB = new int[pcHead.width * pcHead.height];
+
+                //        //ShowTiff16Data(ImgBuff16[1], showtemp16bitDataB);
+
+                //        //ShowRGBImage(showtemp16bitDataB, pcHead, pictureBoxB);
+                //    }
+
+                //}
+                coutCallbackPoints += nHighlen;
+            }
+            else
+            {
+                LogHelper.WriteLogInfo($"Data CallBack Exception:{nStatusCode}({GetSDKErrMsgByCode(nStatusCode)})");
+                //callbackEvent.Set();
+            }
+        }
+
+        public void ErrConnectFunc(int dwDeviceId, int nErrCode)
+        {
+            LogHelper.WriteLogInfo($"Into ConnectExceptionCallback  Error Code: {nErrCode}{GetSDKErrMsgByCode(nErrCode)}");
+            iSR7APi.CameraAOnline = false;
+            iSR7APi.CameraBOnline = false;
+            //:1:Data overflow,3:Disconnect, 4:Wrong version
+            //Non-asynchronous mode: -1 represents a general error, such as link failure, setup failure, data acquisition failure, etc., -1000;
+            switch (nErrCode)
+            {
+                case 1:
+                    LogHelper.WriteLogInfo($"Into ConnectExceptionCallback  Error Code: {nErrCode}{srcsharpTools.GetTranslation("CAMERA_EXCEPTION_1")}");
+                    break;
+                case 3:
+                    LogHelper.WriteLogInfo($"Into ConnectExceptionCallback  Error Code: {nErrCode}{srcsharpTools.GetTranslation("CAMERA_EXCEPTION_3")}");
+                    break;
+                case 4:
+                    LogHelper.WriteLogInfo($"Into ConnectExceptionCallback  Error Code: {nErrCode}{srcsharpTools.GetTranslation("CAMERA_EXCEPTION_3")}");
+                    break;
+                case -1:
+                    LogHelper.WriteLogInfo($"Into ConnectExceptionCallback  Error Code: {nErrCode}{srcsharpTools.GetTranslation("CAMERA_EXCEPTION_N1")}");
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        public string GetSDKErrMsgByCode(int nErrCode)
+        {
+            string strErrMsg;
+            switch ((SR7Link.SR7IF_ERROR)nErrCode)
+            {
+                case SR7IF_ERROR.SR7IF_ERROR_NOT_FOUND: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_NOT_FOUND"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_COMMAND: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_COMMAND"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_PARAMETER: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_PARAMETER"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_UNIMPLEMENTED: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_UNIMPLEMENTED"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_HANDLE: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_HANDLE"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_MEMORY: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_MEMORY"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_TIMEOUT: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_TIMEOUT"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_DATABUFFER: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_DATABUFFER"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_STREAM: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_STREAM"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_CLOSED: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_CLOSED"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_VERSION: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_VERSION"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_ABORT: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_ABORT"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_ALREADY_EXISTS: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_ALREADY_EXISTS"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_FRAME_LOSS: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_FRAME_LOSS"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_ROLL_DATA_OVERFLOW: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_ROLL_DATA_OVERFLOW"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_ROLL_BUSY: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_ROLL_BUSY"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_MODE: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_MODE"); break;
+                case SR7IF_ERROR.SR7IF_ERROR_CAMERA_NOT_ONLINE: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR_CAMERA_NOT_ONLINE"); break;
+                case SR7IF_ERROR.SR7IF_ERROR: strErrMsg = srcsharpTools.GetTranslation("SR7IF_ERROR"); break;
+                case SR7IF_ERROR.SR7IF_NORMAL_STOP: strErrMsg = srcsharpTools.GetTranslation("SR7IF_NORMAL_STOP"); break;
+                case SR7IF_ERROR.SR7IF_OK: strErrMsg = ""; break;
+                default:
+                    strErrMsg = "";
+                    break;
+            }
+            return strErrMsg;
+        }
+        #endregion
+
+        #region 属性通知
+        /// <summary>
+        /// Occurs when a property value changes.
+        /// </summary>
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        /// <summary>
+        /// Checks if a property already matches a desired value. Sets the property and
+        /// notifies listeners only when necessary.
+        /// </summary>
+        /// <typeparam name="T">Type of the property.</typeparam>
+        /// <param name="storage">Reference to a property with both getter and setter.</param>
+        /// <param name="value">Desired value for the property.</param>
+        /// <param name="propertyName">Name of the property used to notify listeners. This
+        /// value is optional and can be provided automatically when invoked from compilers that
+        /// support CallerMemberName.</param>
+        /// <returns>True if the value was changed, false if the existing value matched the
+        /// desired value.</returns>
+        protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
+        {
+            if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
+
+            storage = value;
+            RaisePropertyChanged(propertyName);
+
+            return true;
+        }
+
+        /// <summary>
+        /// Checks if a property already matches a desired value. Sets the property and
+        /// notifies listeners only when necessary.
+        /// </summary>
+        /// <typeparam name="T">Type of the property.</typeparam>
+        /// <param name="storage">Reference to a property with both getter and setter.</param>
+        /// <param name="value">Desired value for the property.</param>
+        /// <param name="propertyName">Name of the property used to notify listeners. This
+        /// value is optional and can be provided automatically when invoked from compilers that
+        /// support CallerMemberName.</param>
+        /// <param name="onChanged">Action that is called after the property value has been changed.</param>
+        /// <returns>True if the value was changed, false if the existing value matched the
+        /// desired value.</returns>
+        protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null)
+        {
+            if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
+
+            storage = value;
+            onChanged?.Invoke();
+            RaisePropertyChanged(propertyName);
+
+            return true;
+        }
+
+        /// <summary>
+        /// Raises this object's PropertyChanged event.
+        /// </summary>
+        /// <param name="propertyName">Name of the property used to notify listeners. This
+        /// value is optional and can be provided automatically when invoked from compilers
+        /// that support <see cref="CallerMemberNameAttribute"/>.</param>
+        protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
+        {
+            OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
+        }
+
+        /// <summary>
+        /// Raises this object's PropertyChanged event.
+        /// </summary>
+        /// <param name="args">The PropertyChangedEventArgs</param>
+        protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
+        {
+            PropertyChanged?.Invoke(this, args);
+        }
+        #endregion
+    }
+}

+ 1489 - 0
TeamAAS-VM/Core/Cameras/simagepro.cs

@@ -0,0 +1,1489 @@
+using SImagePro;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.NetworkInformation;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace SImagePro
+{
+
+    #region SR7Link
+    //相机IP
+    public struct SR7IF_ETHERNET_CONFIG
+    {
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
+        public byte[] abyIpAddress;
+    }
+    #endregion
+
+    #region 函数返回值
+    public enum RTNCODE
+    {
+        RTN_CODE_OK = 0,                     //成功
+        RTN_CODE_ERROR = -1,                 //一般性错误
+        RTN_CODE_CAMERA_NOT_ONLINE = -999,   //相机未连接.
+        RTN_CODE_NULL_PTR = -998,            //参数指针为null.
+        RTN_CODE_ERROR_PARAMETER = -997,     //参数错误.
+        RTN_CODE_ERROR_MEMORY = -996,        //内存(溢出/定义)错误.
+        RTN_CODE_ERROR_TIMEOUT = -995,       //计算超时.
+        RTN_CODE_ERROR_ROI = -994,           //roi错误
+        RTN_CODE_ERROR_INIT = -993,      //内存申请错误         
+    }
+    #endregion
+
+    #region SCVTYPE
+    //旋转参数
+    public enum ROTATE_TYPE
+    {
+        ONE_VERTICAL_ROTATE = 0x0000,       //顺时针转90°
+        TWO_VERTICAL_ROTATE,                //顺时针旋转180°
+        THREE_VERTICAL_ROTATE,              //顺时针旋转270°
+        LR_MIRROR_ROTATE,                   //左右镜像翻转
+        UD_MIRROR_ROTATE,                   //上下镜像翻转
+        CENTER_ROTATE,                      //中心对称反转
+    }
+
+    //平面点结构
+    public struct SPoint2D
+    {
+        public double x;
+        public double y;
+        public SPoint2D(double x, double y)
+        {
+            this.x = x;
+            this.y = y;
+        }
+    };
+
+    //像素点结构
+    public struct SPoint2DPix
+    {
+        public int x;
+        public int y;
+        public SPoint2DPix(int x, int y)
+        {
+            this.x = x;
+            this.y = y;
+        }
+    };
+
+    //空间结构
+    public struct SPoint3D
+    {
+        public double x;
+        public double y;
+        public double z;
+        public SPoint3D(double x, double y, double z)
+        {
+            this.x = x;
+            this.y = y;
+            this.z = z;
+        }
+    };
+
+    //2D直线方程:a*x+b*y+c=0
+    public struct SLine2D
+    {
+        public double a;
+        public double b;
+        public double c;
+        public SLine2D(double a, double b, double c)
+        {
+            this.a = a;
+            this.b = b;
+            this.c = c;
+        }
+    };
+
+    //3D直线
+    public struct SLine3D
+    {
+        public float a;
+        public float b;
+        public float c;
+        public SPoint3D pt;
+        public SLine3D(float a, float b, float c, SPoint3D pt)
+        {
+            this.a = a;
+            this.b = b;
+            this.c = c;
+            this.pt = pt;
+        }
+    };
+
+    //线段
+    public struct SLineSegment2D
+    {
+        public SPoint2D startPoint;
+        public SPoint2D endPoint;
+        public SLineSegment2D(SPoint2D startPoint, SPoint2D endPoint)
+        {
+            this.startPoint = startPoint;
+            this.endPoint = endPoint;
+        }
+    };
+
+    //平面方程:a*x+b*y+c*z+d=0
+    public struct SPlane
+    {
+        public double a;
+        public double b;
+        public double c;
+        public double d;
+        public SPlane(double a, double b, double c, double d)
+        {
+            this.a = a;
+            this.b = b;
+            this.c = c;
+            this.d = d;
+        }
+    };
+
+    //圆结构
+    public struct SCircle2D
+    {
+        public SPoint2D center; //圆心
+        public double radius;   //半径
+    };
+
+    //圆环结构
+    public struct SRing2D
+    {
+        public SPoint2D center; //圆心
+        public double maxR;   //外径
+        public double minR;   //内径
+    };
+
+    //椭圆结构
+    public struct SEllipse2D
+    {
+        public SPoint2D center; //中心点
+        public double width;    //宽度
+        public double height;   //高度
+        public double angle;    //角度
+    };
+
+    //圆弧结构
+    public struct SArc2D
+    {
+        public SCircle2D Circle;  //圆形
+        public double startAngle; //圆弧起始角度
+        public double arcAngle;   //逆时针方向圆弧角度
+    };
+
+    //矩形
+    public struct SRect
+    {
+        public SPoint2D center;  //中心坐标
+        public double angle;     //角度
+        public double width;     //矩形宽度
+        public double height;    //矩形高度
+    };
+
+    //无角度矩形
+    public struct SURect
+    {
+        public double leftX;  //左下角X坐标
+        public double leftY;  //左下角Y坐标
+        public double width;  //矩形宽度
+        public double height; //矩形高度
+    };
+
+    //球体结构
+    public struct SSphere
+    {
+        public SPoint3D center; //球心
+        public double radius;   //半径
+    };
+
+    //空间矩形
+    public struct SClipBox
+    {
+        public SPoint3D center; //中心点坐标
+        public double lengthX;  //X方向宽度
+        public double lengthY;  //Y方向宽度
+        public double lengthZ;  //Z方向宽度
+        public double angleX;   //绕X轴角度
+        public double angleY;   //绕Y轴角度
+        public double angleZ;   //绕Z轴角度
+        public SClipBox(SPoint3D center, double lengthX, double lengthY, double lengthZ, double angleX, double angleY, double angleZ)
+        {
+            this.center = center;
+            this.lengthX = lengthX;
+            this.lengthY = lengthY;
+            this.lengthZ = lengthZ;
+            this.angleX = angleX;
+            this.angleY = angleY;
+            this.angleZ = angleZ;
+        }
+    };
+
+    //3D变换参数
+    public struct S3DAngle
+    {
+        public double x;
+        public double y;
+        public double z;
+        public double angleX;
+        public double angleY;
+        public double angleZ;
+        public double scale;
+        public S3DAngle(double x, double y, double z, double angleX, double angleY, double angleZ, double scale)
+        {
+            this.x = x;
+            this.y = y;
+            this.z = z;
+            this.angleX = angleX;
+            this.angleY = angleY;
+            this.angleZ = angleZ;
+            this.scale = scale;
+        }
+    };
+
+    //矩形卡尺
+    public struct SRectCaliper
+    {
+        public double calspacing;  //卡尺间距
+        public double calheight;   //高度为矩形高度
+        public double calwidth;    //卡尺宽度(高度为矩形高度)
+        public SRect rect;        //矩形
+    };
+
+    //腰形卡尺
+    public struct SWaistCaliper
+    {
+        public double calspacing;  //卡尺间距
+        public double calheight;   //高度为矩形高度
+        public double calwidth;    //卡尺宽度(高度为矩形高度)
+        public SRect rect;        //矩形
+    };
+
+    //圆形卡尺
+    public struct SCircleCaliper
+    {
+        public double calspacing;  //卡尺间距
+        public double calheight;   //高度为矩形高度
+        public double calwidth;    //卡尺宽度
+        public double startAngle;  //圆弧开始角度 单位:度
+        public double endAngle;    //圆弧终止角度 单位:度
+        public SCircle2D Circle;    //圆形
+    };
+
+    //拟合表面缺陷检测参数
+    public struct SPlaneFlawsParm
+    {
+        public double humpHeightCheck;    //凸起高度阈值
+        public double humpAreaCheck;      //凸起面积阈值
+        public double sunkenDepthCheck;   //凹陷深度阈值
+        public double sunkenAreaCheck;    //凹陷面积阈值
+        public double blockBorderPhy;     //计算点块边长
+    };
+
+    //拟合表面缺陷检测参数
+    public struct SSurfaceFlawsParm
+    {
+        public double humpHeightCheck;    //凸起高度阈值
+        public double humpAreaCheck;      //凸起面积阈值
+        public double sunkenDepthCheck;   //凹陷深度阈值
+        public double sunkenAreaCheck;    //凹陷面积阈值
+        public double blockBorderPhy;     //计算点块边长
+        public double fitBorderPhyX;      //拟合区域块X长度
+        public double fitBorderPhyY;      //拟合区域块Y长度
+        public double fitExcluding;       //异常值剔除比率
+        public int blockSample;           //计算点降采样倍率
+        public int fitSample;             //拟合点降采样倍率
+        public int fitSurfaceN;           //曲面拟合次数
+        public int fitMethod;             //拟合模式 0:曲面, 1:平面
+    };
+
+    //规则面(拟合线)缺陷测参数
+    public struct SRuleFlawsParm
+    {
+        public double humpHeightCheck;    //凸起高度阈值
+        public double humpAreaCheck;      //凸起面积阈值
+        public double sunkenDepthCheck;   //凹陷深度阈值
+        public double sunkenAreaCheck;    //凹陷面积阈值
+        public int fitMethod;             //0: 曲线 1:直线
+        public int fitCurveMaxIndex;      //拟合曲线最大指数
+        public double outlieDelRate;      //异常值剔除比率
+        public double blockLength;        //分段长
+        public double deleteRate;         //线拟合剔除比率
+        public double minValidRate;       //有效的点最少占比
+        public double Samplewidth;        //采样宽度
+    };
+
+    //ROI类型
+    public enum ROI_TYPE
+    {
+        RECT,              //矩形
+        CIRCLE,            //圆形
+        RING,              //圆环
+        POLYGON,           //多边形
+        ELLIPSE,           //椭圆
+        ELLIPSP_RING,      //椭圆环
+        CALLIPERS_RECT,    //矩形卡尺
+        CALLIPERS_CIRCULAR,//圆形卡尺
+    }
+
+    //ROI
+    public struct SRoi
+    {
+        public ROI_TYPE RoiType;      //roi类型
+        public SRect RectRoi;         //常规矩形
+        public SCircle2D CircleRoi;   //圆
+        public SRing2D RingRoi;    //圆环
+        public SPoint2D[] PointsRoi;   //任意多边形
+        public uint PointsSize;
+    };
+
+    //平面度结果
+    public struct FlatnessParam
+    {
+        public SPlane plane;       //平面方程
+        public double minDis;      //点到平面最小距离
+        public double maxDis;      //点到平面最大距离
+        public SPoint3D maxPt;     //到平面最小距离点
+        public SPoint3D minPt;     //到平面最小距离点
+    };
+
+    //边界
+    public struct SBorder
+    {
+        public double minX;
+        public double maxX;
+        public double minY;
+        public double maxY;
+    };
+
+    //点云头结构(zInterval初始化为 1e-5)
+    public struct SPointCloudHead
+    {
+        public uint height; //点云行数
+        public uint width;  //点云列数
+        public double xInterval;    //点云列间距
+        public double yInterval;    //点云行间距
+        public double zInterval;    //点云z方向分辨率系数
+
+        public SPointCloudHead(uint height, uint width, double xInterval, double yInterval, double zInterval)
+        {
+            this.height = height;
+            this.width = width;
+            this.xInterval = xInterval;
+            this.yInterval = yInterval;
+            this.zInterval = zInterval;
+        }
+    };
+
+    //TIF文件信息
+    public struct STifField
+    {
+        public uint height;    //行数
+        public uint width;     //列数
+        public uint bitDepth;  //位宽
+        public uint channels;  //通道数
+        public int type;               //数据类型 1是signed 2是unsigned
+    };
+
+    //3D显示点结构
+    public struct SPoint3DRGB
+    {
+        public SPoint3D point3D;
+        public byte r;
+        public byte g;
+        public byte b;
+    };
+
+    //缺陷检测结果
+    public struct FlawsData
+    {
+        public SPoint2D[] flawsContours;                //缺陷轮廓
+        public int contoursNum;                        //缺陷轮廓点数
+        public double flawsAreas;                      //缺陷面积
+        public double flawsHeight;                     //缺陷最深
+        public SRect flawsRects;                       //缺陷矩形框
+    };
+
+    public struct CalData
+    {
+        public SPoint3D[] fitPoints;
+        public int pointsNum;
+    };
+
+    //空间显示点结构
+    public struct SDisplay3DPoint
+    {
+        public double x;
+        public double y;
+        public double z;
+        public byte r;
+        public byte g;
+        public byte b;
+        public int AdaptiveRGB;
+
+        public SDisplay3DPoint(double x, double y, double z, byte r, byte g, byte b, int AdaptiveRGB)
+        {
+            this.x = x;
+            this.y = y;
+            this.z = z;
+            this.r = r;
+            this.g = g;
+            this.b = b;
+            this.AdaptiveRGB = AdaptiveRGB;
+        }
+    };
+    #endregion
+
+    internal class SCV
+    {
+        #region 常量
+        public const double INVALID_VALUE_MIN = -1000000000;
+        public const double INVALID_VALUE_MAX = 1000000000;
+        #endregion
+
+        #region SR7Link
+        ///<summary>
+        /// 通信连接------与相机连接
+        /// </summary>
+        /// <param name="lDeviceId"></param>          设备ID号,范围为0-3
+        /// <param name="pEthernetConfig"></param>   (网口)通信设定
+        /// <returns></returns>                       0:成功; 小于0:失败
+        /// <remarks></remarks>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_EthernetOpen(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig);
+        #endregion
+
+        #region 3D计算相关算法
+        /*************************************************
+            Function:       PointPlaneDistance(区分正负)
+            Description:    点到平面距离
+            Input:          @point		3D点
+                            @plane		平面方程
+            Output:         @distance	输出距离
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PointPlaneDistance(SPoint3D point, SPlane plane, ref double distance);
+
+        /*************************************************
+		    Function:       VolumeMeasurement
+		    Description:    体积测量
+		    Input:          @HeightData		高度图
+						    @pcHead			高度头文件
+						    @ROI			ROI
+						    @plane			平面方程
+						    @upper、lower	高度上下限制
+		    Output:         @volume			输出体积MM^3
+		    Return:         <0: 失败.
+						    =0: 成功
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int VolumeMeasurement(int[] HeightData, SPointCloudHead pcHead, SRoi ROI, SPlane plane, double upper, double lower, ref double volume);
+
+        /*************************************************
+		    Function:       ThreePointHeightDiff
+		    Description:    三点高度差
+		    Input:          @sPt:开始点   ePt:结束点   cPt:中间点
+		    Output:         @distance		输出三点高度差
+		    Return:         <0: 失败.
+						    =0: 成功
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int ThreePointHeightDiff(SPoint3D sPt, SPoint3D ePt, SPoint3D cPt, ref double distance);
+
+        /*************************************************
+		    Function:       FitPlane
+		    Description:    平面拟合
+		    Input:          @points		用于拟合的点
+						    @ptSize		拟合点数量
+		    Output:         @plane		输出平面方程
+		    Return:         <0: 失败.
+						    =0: 成功
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int FitPlane(SPoint3D[] points, int ptSize, ref SPlane plane);
+
+        /*************************************************
+            Function:       PlanePlaneAngle
+            Description:    平面角度
+            Input:          @plane1		输入平面1
+                            @plane2		输入平面2
+            Output:         @angle		角度
+            Return:         <0: 失败.
+                                =0: 成功.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PlanePlaneAngle(SPlane plane1, SPlane plane2, ref double angle);
+
+        /*************************************************
+		    Function:       PlanePlaneLin
+		    Description:    平面交线
+		    Input:          @plane1			输入平面1
+						    @plane2			输入平面2
+		    Output:         @dstLine		交线
+		    Return:         <0: 失败.
+						    =0: 成功.
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PlanePlaneLine(SPlane plane1, SPlane plane2, ref SLine3D dstLine);
+
+        /*************************************************
+		    Function:       Line3DIntersection
+		    Description:    空间直线交点
+		    Input:          @line1			空间直线1
+						    @line2			空间直线2
+		    Output:         @dstPoint		交点
+		    Return:         <0: 失败.
+						    =0: 成功.
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Line3DIntersection(SLine3D line1, SLine3D line2, ref SPoint3D dstPoint);
+
+        /*************************************************
+		    Function:       Point3dDistance
+		    Description:    3D点距离
+		    Input:          @point1			空间点1
+						    @point2			空间点2
+		    Output:         @distance		交点
+		    Return:         <0: 失败.
+						    =0: 成功.
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Point3dDistance(SPoint3D point1, SPoint3D point2, ref double distance);
+
+        /*************************************************
+		    Function:       FitLine3D
+		    Description:    3D点距离
+		    Input:          @point1			空间点1
+						    @point2			空间点2
+		    Output:         @distance		距离
+		    Return:         <0: 失败.
+						    =0: 成功.
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int FitLine3D(SPoint3D[] points, int pointnum, ref SLine3D line);
+
+        /*************************************************
+		    Function:       PointToLine3dDistance
+		    Description:    3D点到直线距离
+		    Input:          @poin			空间点
+						    @line			空间直线
+		    Output:         @distance		距离
+		    Return:         <0: 失败.
+						    =0: 成功.
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PointToLine3dDistance(SPoint3D point, SLine3D line, ref double distance);
+
+        /*************************************************
+		    Function:       PlaneIntersection
+		    Description:    三平面交点
+		    Input:          @planes			平面,lanes[0]为标定块顶面或底面,planes[1]和planes[2]均为侧面
+		    Output:         @dstPt			交点
+		    Return:         <0: 失败.
+						    =0: 成功.
+		    Others:         无
+	    *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PlaneIntersection(SPlane[] planes, ref SPoint3D dstPt);
+
+        /*************************************************
+            Function:       MedianFiltering
+            Description:    中值滤波
+            Input:          @srcHeightImage		原始点云
+                            @pcHead				点云头
+                            @hThreshold			高度阈值
+                            @wThreshold			窗口大小
+                            @ACC				加速率
+            Output:			@dstHeightImage		滤波后点云
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int MedianFiltering(int[] srcHeightImage, int[] dstHeightImage, ref SPointCloudHead pcHead, double hThreshold, uint Wthreshold, uint ACC);
+
+        /*************************************************
+            Function:       PointCloudFiltering
+            Description:    图像滤波(点云滤波),支持ROI
+            Input:          @srcHeightImage	原始点云数据
+                            @pcHead			点云头文件
+                            @rois			roi(如果ROI为null或者数量为0,那么就对全图进行滤波)
+                            @RoiSize		Roi数量
+                            @distanceRate	点与点之间的有效距离比,值越大认为两点之间的联系关系越强(范围0~1), 默认值为0.5
+                            @minValidArea	最小有效关联点,如果区域内关联点的个数小于此值,则这个区域会被去掉,默认值为200
+            Output:         @dstHeightImage	滤波后云数据
+            Return:         <0 失败.
+                            =  成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PointCloudFiltering(
+                int[] srcHeightImage,
+                int[] dstHeightImaget,
+                SPointCloudHead pcHead,
+                SRoi[] rois,
+                int RoiSize,
+                float distanceRate,
+                int minValidArea);
+
+        /*************************************************
+            Function:       HeightFiltering
+            Description:    图像滤波(高度滤波),支持ROI
+            Input:          @srcHeightImage	原始点云数据
+                            @pcHead			点云头文件
+                            @rois			roi(如果ROI为null或者数量为0,那么就对全图进行滤波)
+                            @RoiSize			Roi数量
+                            @maxValidDis	高度阈值,单位:mm
+                            @minValidArea	面积阈值,单位:像素
+            Output:         @dstHeightImage	滤波后云数据
+            Return:         <0 失败.
+                            =  成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int HeightFiltering(
+                int[] srcHeightImage,
+                int[] dstHeightImaget,
+                SPointCloudHead pcHead,
+                SRoi[] rois,
+                int RoiSize,
+                double maxValidDis,
+                int minValidArea);
+
+        /*************************************************
+            Function:       ImageComplements
+            Description:    图像补点
+            Input:          @heightImage		补点图像图像
+                            @pcHead				点云头
+                            @mode				模式: 0:只补X ,1:只补Y,2:两个方向都补
+                            @complementsNum		补点数量
+                            @angle				补点角度,超过该角度以后补水平直线
+            Output:			@heightImage		补点图像图像
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int ImageComplements(int[] heightImage, SPointCloudHead pcHead, int mode, int complementsNum, double angle);
+
+        /*************************************************
+            Function:       CalFlatnessOfRegion
+            Description:    按区域拟合,计算平面度
+            Input:          @heightImage			原始高度值
+                            @RoiMaskImage			ROI区域Mask图
+                            @pcHead					点云头
+                            @xRoiPixs,yRoiPixs		拟合区域单位分块大小
+                            @Plane3D				基准平面(没有就填NULL)
+            Output:			@FlatnessParam			返回平面方程,最大最小点的距离
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int CalFlatnessOfRegion(
+            int[] heightImage,
+            byte[] RoiMaskImage,
+            SPointCloudHead pcHead,
+            int xRoiPixs,
+            int yRoiPixs,
+            SPlane[] basePlane,
+            ref FlatnessParam FlatnessPlne);
+        #endregion
+
+        #region 标定校正相关算法
+        /*************************************************
+            Function:       GetShakeCalibData
+            Description:    获取图像校正数据(校正机构抖动)
+            Input:          @heightImage	输入原始图像数据
+                            @width			图像宽度
+                            @height			图像高度
+                            @fStepX			X间距
+                            @fStepY			Y间距
+                            @plane			基准平面
+                            @rectROI		基准校正区域
+            Output:         @outCalibData	校正数据申请内存 大小为 (nHeight* 10) 个字节,外部申请内存
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetShakeCalibData(
+            int[] heightImage,
+            int width,
+            int height,
+            float fStepX,
+            float fStepY,
+            SPlane plane,
+            SRect rectROI,
+            IntPtr outCalibData);
+
+        /*************************************************
+            Function:       GenShakeCalibImage
+            Description:    校正图像(校正机构抖动)
+            Input:          @heightImage	输入原始图像数据
+                            @width			图像宽度
+                            @height		    图像高度
+                            @Data			输入校正数据
+            Output:         @outHeightImage	校正后图像数据,pDstData存储大小和pSrcData一致
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GenShakeCalibImage(int[] heightImage, int width, int height, IntPtr Data, int[] outHeightImage);
+
+        /*************************************************
+            Function:       GetRouletteCalibData
+            Description:    获取圆盘标定数
+            Input:          @imagePointXYs[18],         棋盘格的9个点在原始灰度图像像素里的坐标, 格式为{x1,y1,x2,y2,x3,...,x9,y9}
+                            @pixelSizeBeforeTransform,  X方向像素大小
+                            @pixelSizeAfterTransform,   转换后像素大小
+                            @leftRealX,                 左边点X真实坐标
+                            @rightRealX,                右边点X真实坐标
+                            @upRealY,                   上面点X真实坐标
+                            @downRealY,                 下面点Y真实坐标
+            Output:         @outCalibData,              输出的标定数据结果
+                            @outMessage[256]            输出信息提示
+            Return:         <0 失败.
+                            =  成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetRouletteCalibData(
+            SPoint2D[] imagePointXY,
+            double pixelSizeBeforeTransform,
+            double pixelSizeAfterTransform,
+            double leftRealX,
+            double rightRealX,
+            double upRealY,
+            double downRealY,
+            IntPtr outCalibData,
+            ref double outMessage);
+
+        /*************************************************
+            Function:       GenRouletteCalibImage
+            Description:    圆盘标定校正图像
+            Input:          @heightImage,       原始深度图
+                            @pointsWidth,       点云宽度
+                            @int pointsHeight,  点云高度
+                            @calibData,         标定数据
+                            @int imageWidth,    转换后图像宽度
+                            @int imageHeight,   转换后图像高度
+                            @centerX,           裁剪中心X
+                            @centerY,           裁剪中心Y
+                            @ centerZ,          裁剪中心Z
+                            @ ratioMMPerPixel,  转换后像素大小
+            Output:         @dst,               转换后3D数据
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GenRouletteCalibImage(
+            int[] heightImage,
+            int pointsWidth,
+            int pointsHeight,
+            IntPtr calibData,
+            int[] dstHeightImage,
+            int imageWidth,
+            int imageHeight,
+            double centerX,
+            double centerY,
+            double centerZ,
+            double ratioMMPerPixel);
+
+        /*************************************************
+            Function:       AffineTransMatrix3D
+            Description:    根据输入点求矩阵
+            Input:          @ptSeneor		原始点
+                            @ptPhysical		目标点
+                            @ptSize			点数
+            Output:         @dstMatrix		输出的变换矩阵
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int AffineTransMatrix3D(SPoint3D[] ptSeneor, SPoint3D[] ptPhysical, int nSize, double[] dstMatrix);
+
+        /*************************************************
+            Function:       AffineTransPoint3D
+            Description:    根据矩阵求变换后的坐标
+            Input:          @srcPt		转换前3D点
+                            @matrix		仿射变换4*4矩阵
+                            @dstPt		转换后3D点
+            Output:         @dstPt      转换后的3D点
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int AffineTransPoint3D(ref SPoint3D srcPt, double[] matrix, ref SPoint3D dstPt);
+
+        /*************************************************
+            Function:       AffineTransImage
+            Description:    点云变换
+            Input:          @heightImage				变化前高度图
+                            @grayImage					变化前亮度图(没有时可以为NULL)
+                            @pcHead						点云头
+                            @matrix						仿射变换4*4矩阵
+                            @newPcHead					变化点云头
+                            @centerX 、centerY、centerZ 转换后图像偏移
+                            @hMax、hMin					高度上下限
+            Output:         @newHeightImage				变化后高度图
+                            @newGrayImage				变化后灰度图
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int AffineTransImage(
+            int[] heightImage,
+            byte[] grayImage,
+            SPointCloudHead pcHead,
+            double[] matrix,
+            SPointCloudHead newPcHead,
+            double centerX,
+            double centerY,
+            double centerZ,
+            int[] newHeightImage,
+            byte[] newGrayImage,
+            double hMax = INVALID_VALUE_MAX,
+            double hMin = INVALID_VALUE_MIN);
+
+        /*************************************************
+            Function:      CorrectZAxisRotation
+            Description:    相机绕Z方向旋转校正
+            Input:          @heightImage				校正前高度图
+                            @grayImage					校正前亮度图(没有时可以为NULL)
+                            @pcHead						点云头
+                            @angle						旋转角度
+                            @centerX 、centerY、centerZ 转换后图像偏移
+                            @newPcHead					校正后头文件
+            Output:         @newHeightImage				校正后高度图
+                            @newGrayImage				校正后灰度图
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int CorrectZAxisRotation(
+            int[] heightImage,
+            byte[] grayImage,
+            ref SPointCloudHead pcHead,
+            double angle,
+            SPointCloudHead newPcHead,
+            double centerX,
+            double centerY,
+            double centerZ,
+            int[] newHeightImage,
+            byte[] newGrayImage);
+
+        /*************************************************
+            Function:       PoseToMatrix
+            Description:    根据角度求矩阵
+            Input:          @angleX			绕X轴旋转角度
+                            @angleY			绕Y轴旋转角度
+                            @angleZ			绕Z轴旋转角度
+                            @thetaXofPd		矫正角度
+                            @ceberX			X方向偏移值
+                            @ceberY			Y方向偏移值
+                            @ceberZ			Z方向偏移值
+            Output:         @matrix			计算得到的角度矩阵
+            Return:         <0: 失败.
+                            =0: 成功
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PoseToMatrix(double AngleX, double AngleY, double AngleZ, double thetaXofPd, double CeberX, double CeberY, double CeberZ, double[] matrix);
+
+        /*************************************************
+            Function:       GetMatrixFromPlane
+            Description:    通过平面方程计算旋转矩阵
+            Input:          @plane			平面方程
+            Output:         @matrix			计算得到的角度矩阵
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetMatrixFromPlane(ref SPlane plane, double[] matrix);
+
+        /*************************************************
+            Function:       CorrectXAxisRotation
+            Description:    矫正绕相机绕X旋转的角度
+            Input:          @heightData		原始图像
+                            @pcHead			点云头
+                            @anglex			X的角度
+                            @CeberY			Y方向偏移行数
+                            @isHeigh		是否偏移高度值
+            Output:         @dstheightData	偏移后原图像
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int CorrectXAxisRotation(int[] heightData, SPointCloudHead pcHead, double anglex, int CeberY, bool isHeigh, int[] dstheightData);
+
+        /*************************************************
+            Function:       ImageRotate
+            Description:    图像旋转
+            Input:          @heightData		原始图像
+                            @pcHead			点云头
+                            @rotateType		旋转方式
+            Output:         @dstheightData	偏移后原图像
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int ImageRotate(int[] heightData, int[] dstheightData, ref SPointCloudHead pcHead, ROTATE_TYPE rotateType);
+        #endregion
+
+        #region 工具类
+        /*************************************************
+            Function:       ArrayFilter
+            Description:    数组数据筛选
+            Input:          @data		输入数组
+                            @dataSize	数组大小
+                            @filterType	极值(0:正常,1:极大值,2:极小值)
+                            @valueType	结果计算方式(0:平均值,1:中位数)
+                            @delPara	阈值m,大于等于1按个数,小于1按比例
+                            @samPara	阈值n,大于等于1按个数,小于1按比例
+                            @upper		数值上限
+                            @lower		数值下限
+            Output:         @outValue	剔除后数值
+                            @outData	剔除后数组
+                            @outDataSize剔除后数组大小
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         正常:去除最大m个点,去除最小n个点;
+                            极大值:去除最大m个点;
+                            极小值:去除最小m个点;
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int ArrayFilter(
+            double[] data,
+            int dataSize,
+            int filterType,
+            int valueType,
+            double delPara,
+            double samPara,
+            double upper,
+            double lower,
+            ref double outValue,
+            double[] outData,
+            ref int outDataSize);
+
+        /*************************************************
+            Function:       RoiArea
+            Description:    求ROI面积大小,用于提取ROI内点时候申请内存
+            Input:          @roi	输入ROI
+            Output:
+            Return:         <0: 失败.
+                            >0: ROI像素面积.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int RoiArea(SRoi roiInfo);
+
+        /*************************************************
+            Function:       Point3DFilter
+            Description:    3D点数组数据筛选
+            Input:          @points		输入数组
+                            @ptSize		数组大小
+                            @filterType	极值(0:正常,1:极大值,2:极小值)
+                            @valueType	结果计算方式(0:平均值,1:中位数)
+                            @priorityType	优先级(0:X方向,1:Y方向,2:Z方向)
+                            @delPara	阈值m,大于等于1按个数,小于1按比例
+                            @samPara	阈值n,大于等于1按个数,小于1按比例
+                            @upper		数值上限
+                            @lower		数值下限
+            Output:         @outValue	剔除后数值
+                            @outPoints	剔除后数组
+                            @outPtSize	剔除后数组大小
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         正常:去除最大m个点,去除最小n个点;
+                            极大值:去除最大m个点;
+                            极小值:去除最小m个点;
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Point3DFilter(
+            SPoint3D[] points,
+            int ptSize,
+            int filterType,
+            int valueType,
+            int priorityType,
+            double delPara,
+            double samPara,
+            ref SPoint3D outValue,
+            SPoint3D[] outPoints,
+            ref int outPtSize,
+            double upper = INVALID_VALUE_MAX,
+            double lower = INVALID_VALUE_MIN);
+
+        /*************************************************
+            Function:       GetAllPointsFromRoi
+            Description:    ROI内点提取
+            Input:          @data		高度数据
+                            @pcHead		点云头结构
+                            @roiInfo	ROI
+                            @accelerate	降采样比率,默认填1
+            Output:         @roiData	输出ROI内3D点(SPoint3D[])
+                            @dstanum	3D点数组大小
+            Return:         <0: 失败.
+                            =0: 成功
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetAllPointsFromRoi(int[] heightImage, SPointCloudHead pcHead, SRoi roiInfo, IntPtr roiData, ref int dstanum, int accelerate = 1);
+
+        /*************************************************
+            Function:       GetFilteredPointFromROI
+            Description:    ROi获取单点高度
+            Input:          @heightImage高度数据
+                            @pcHead		点云头结构
+                            @roiInfo	ROI
+                            @accelerate	降采样比率,默认填1
+                            @filterType	极值(0:正常,1:极大值,2:极小值)
+                            @valueType	结果计算方式(0:平均值,1:中位数)
+                            @delPara	阈值m,大于等于1按个数,小于1按比例
+                            @samPara	阈值n,大于等于1按个数,小于1按比例
+                            @upper		数值上限
+                            @lower		数值下限
+            Output:         @outValue	剔除后数值
+                            @outPoints	剔除后数组
+                            @outPtSize	剔除后数组大小
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         正常:去除最大m个点,去除最小n个点;
+                            极大值:去除最大m个点;
+                            极小值:去除最小m个点;
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetFilteredPointFromROI(
+            int[] heightData,
+            SPointCloudHead pcHead,
+            SRoi roiInfo,
+            int filterType,
+            int valueType,
+            double delPara,
+            double samPara,
+            ref SPoint3D outValue,
+            IntPtr outPoints,
+            ref int outPtSize,
+            int accelerate = 1,
+            double upper = INVALID_VALUE_MAX,
+            double lower = INVALID_VALUE_MIN);
+
+        /*************************************************
+            Function:       GetFilteredPointFromROIOnBasePlane
+            Description:    ROi获取单点高度(基于平面)
+            Input:          @heightImage高度数据
+                            @pcHead		点云头结构
+                            @roiInfo	ROI
+                            @accelerate	降采样比率,默认填1
+                            @filterType	极值(0:正常,1:极大值,2:极小值)
+                            @valueType	结果计算方式(0:平均值,1:中位数)
+                            @delPara	阈值m,大于等于1按个数,小于1按比例
+                            @samPara	阈值n,大于等于1按个数,小于1按比例
+                            @upper		数值上限
+                            @lower		数值下限
+                            @plane		平面方程
+            Output:         @outValue	剔除后数值
+                            @outPoints	剔除后数组
+                            @outPtSize	剔除后数组大小
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         正常:去除最大m个点,去除最小n个点;
+                            极大值:去除最大m个点;
+                            极小值:去除最小m个点;
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetFilteredPointFromROIOnBasePlane(
+            int[] heightImage,
+            SPointCloudHead pcHead,
+            SRoi roiInfo,
+            int filterType,
+            int valueType,
+            double delPara,
+            double samPara,
+            SPlane plane,
+            ref double outValue,
+            IntPtr outPoints,
+            ref int outPtSize,
+            int accelerate = 1,
+            double upper = INVALID_VALUE_MAX,
+            double lower = INVALID_VALUE_MIN);
+
+        /*************************************************
+            Function:       GetMaskFromRoi
+            Description:    获取ROI区域Mask图
+            Input:          @Roi 输入ROI
+                            @pcHead  点云头
+            Output:         @mask 输出Mask图,大小与原始点云一样;
+            Return:         <0  失败.
+                            =0  成功
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetMaskFromRoi(SRoi Roi, SPointCloudHead pcHead, byte[] mask);
+
+        /*************************************************
+            Function:       GetMaskFromPoints
+            Description:    根据点坐标生成Mask图
+            Input:          @pt 输入点坐标
+                            @ptSize 点个数
+                            @width  图像宽度
+                            @height 图像高度
+            Output:         @mask 输出Mask图;
+            Return:         <0  失败.
+                            =0  成功
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetMaskFromPoints(SPoint2D[] inPt, int ptSize, int width, int height, byte[] mask);
+
+        /*************************************************
+            Function:       GenHeightImageFromMask
+            Description:    获取加掩膜以后的高度图图
+            Input:          @mask Mask图
+                            @pcHead  点云头
+                            @data 高度数据
+            Output:         @data 高度数据
+            Return:         <0  失败.
+            =0  成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GenHeightImageFromMask(SPointCloudHead pcHead, byte[] mask, int[] data);
+        #endregion
+
+        #region 图像转换类
+        /*************************************************
+            Function:       CalUpperAndLower
+            Description:    求图像上下限
+            Input:          @points			输入图像
+                            @width height	图像长宽
+            Output:         @upper lower	高度上下限,原始int高度,单位1/100000 mm
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int CalUpperAndLower(int[] points, uint hight, uint width, ref double upper, ref double lower);
+
+        /*************************************************
+           Function:       PointToGrayData
+           Description:    高度转灰度
+           Input:          @points			输入图像
+                           @width height	图像长宽
+                           @upper lower	高度上下限,原始int高度,单位1/100000 mm
+           Output:         @grayData		灰度图
+           Return:         <0: 失败.
+                           =0: 成功
+           Others:         无
+       *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PointToGrayData(int[] points, uint width, uint height, double upper, double lower, byte[] grayData);
+
+        /*************************************************
+            Function:		PointToRGBData
+            Description:    高度转RGB显示
+            Input:          @points			输入图像
+                            @width height	模式:0 只通过高度计算RGB,1、2 通过高度分布计算RGB
+                            @upper lower	高度上下限,原始int高度,单位1/100000 mm
+            Output:         @R、G、B		RBG颜色
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int PointToRGBData(int[] points, uint width, uint height, int mode, double upper, double lower, byte[] R, byte[] G, byte[] B);
+
+        /*************************************************
+            Function:		GetPointCloudHead
+            Description:    读取ECD头文件
+            Input:          @file			输入文件名
+            Output:         @pcHead			输出头文件
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetPointCloudHead(char[] file, ref SPointCloudHead pcHead);
+
+        /*************************************************
+            Function:		ReadEcd
+            Description:    读取ECD文件
+            Input:          @file			输入文件名
+            Output:         @pcHead			输出头文件
+                            @heightImage			高度数据
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int ReadEcd(char[] file, int[] heightImage, ref SPointCloudHead pcHead);
+
+        /*************************************************
+            Function:		WriteEcd
+            Description:    写入ECD头文件
+            Input:          @file			输入文件名
+            Output:         @pcHead			输出头文件
+                            @heightImage			高度数据
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int WriteEcd(char[] file, int[] heightImage, SPointCloudHead pcHead);
+
+        /*************************************************
+            Function:		WritePly
+            Description:    保存PLY
+            Input:          @file			输入文件名
+                            @points			点云数据
+                            @pointSize		3D点数量
+            Output:
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int WritePly(char[] file, SPoint3D[] points, int pointSize);
+
+        /*************************************************
+            Function:		SavePly
+            Description:    保存PLY
+            Input:          @file			输入文件名
+                            @pcHead			输出头文件
+                            @heightImage	高度数据
+            Output:
+            Return:         <0: 失败.
+                            =0: 成功
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SavePly(char[] file, int[] heightImage, SPointCloudHead pcHead);
+
+        /*************************************************
+            Function:       SavePcd
+            Description:    保存Ply格式
+            Input:          @file 文件名
+                            @heightImage 高度数据
+                            @PointCloudHead 头文件
+            Output:
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SavePcd(char[] file, int[] heightImage, SPointCloudHead pcHead);
+
+        /*************************************************
+            Function:       Save32Tif
+            Description:    保存32位Tiff格式
+            Input:          @file           文件名
+                            @heightImage    高度数据
+                            @PointCloudHead 头文件
+            Output:
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Save32Tif(char[] file, int[] heightImage, SPointCloudHead pcHead);
+
+        /*************************************************
+            Function:       Save16Tif
+            Description:    保存16位Tiff格式
+            Input:          @file           文件名
+                            @heightImage    高度数据
+                            @PointCloudHead 头文件
+                            @HeightMax、HeightMin 高度上下限区间(参考对应相机景深范围)
+            Output:			@z_scale 返回缩放比例
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Save16Tif(char[] file, int[] heightImage, SPointCloudHead pcHead, double HeightMax, double HeightMin, ref double z_scale);
+
+        /*************************************************
+            Function:       Save16Tif
+            Description:    保存16位Tiff格式
+            Input:          @file           文件名
+                            @heightImage    高度数据
+                            @PointCloudHead 头文件
+                            @z_scale        输入缩放比例
+            Output:			无
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Save16TifOfScale(char[] file, int[] heightImage, SPointCloudHead pcHead, double z_scale);
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Save16TifOfShort(char[] file, short[] heightImage, SPointCloudHead pcHead, double z_scale, int isSigned);
+
+        /*************************************************
+            Function:       GetTifField
+            Description:    获取tiff图片字段信息
+            Input:          @file       文件名
+            Output:         @tiffield   字段信息
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int GetTifField(char[] file, ref STifField tiffield);
+
+        /*************************************************
+            Function:       Read32Tif
+            Description:    读取32位tiff图片
+            Input:          @file 文件名
+            Output:         @data 高度信息
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Read32Tif(char[] file, int[] heightImage);
+
+        /*************************************************
+            Function:       Read32Tif
+            Description:    读取32位tiff图片
+            Input:          @file            文件名
+                            @zInterval       缩放比率
+            Output:         @dataheightImage 高度信息
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+        *************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Read16Tif(char[] file, double zInterval, int[] heightImage);
+		
+			
+		/*************************************************
+			Function:       ReadBmp
+			Description:    读取Bmp图片
+			Input:          @file            文件名
+			Output:         @imageData       图像数据
+							@width、height   图像长宽
+			Return:         <0: 失败.
+							=0: 成功.
+			Others:         无
+		*************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int ReadBmp(char[] file, byte[] imageData,ref int width,ref int height);
+
+		/*************************************************
+			Function:       SaveBmp
+			Description:    保存Bmp图片
+			Input:          @file            文件名
+							@imageData       图像数据
+							@width、height   图像长宽
+			Output:         无
+			Return:         <0: 失败.
+							=0: 成功.
+			Others:         无
+		*************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int SaveBmp(char[] file, byte[] imageData, int width, int height);
+
+        /*************************************************
+			Function:       Save24Bmp
+			Description:    保存3通道24bitBmp图片
+			Input:          @file            文件名
+							@DataR、DataG、DataR  图像rgb数据
+							@width、height   图像长宽
+			Output:         无
+			Return:         <0: 失败.
+							=0: 成功.
+			Others:         无
+		*************************************************/
+        [DllImport("SImagePro.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Save24Bmp(char[] file, byte[] DataR, byte[] DataG, byte[] DataB, int width, int height);
+		
+		
+        #endregion
+
+        #region 3D显示
+        /*************************************************
+            Function:       Show3DPoint
+            Description:    显示3D点
+            Input:          @Points			需要显示的点集 SDisplay3DPoint[]
+                            @PointsSize		每块点云数量
+                            @PointsNum			点云块数量
+                            @streamline		精简点数
+                            @width			窗口宽度
+                            @height			窗口高度
+                            @left			窗口左边距
+                            @top			窗口右边距
+            Output:         
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+            Author:         FYX
+            Date:           2024-05-31
+        *************************************************/
+        [DllImport("SShow3DImage.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Show3DPoint(
+            SDisplay3DPoint[] Points,
+            int[] PointsSize,
+            int PointsNum,
+            int streamline = 1,
+            int width = 960,
+            int height = 720,
+            int left = 50,
+            int top = 50);
+
+        /*************************************************
+            Function:       Show3DPoint
+            Description:    显示3D点
+            Input:          @Points			需要显示的点集
+                            @PointsSize		每块点云数量
+                            @Num			点云块数量
+                            @streamline		精简点数
+                            @width			窗口宽度
+                            @height			窗口高度
+                            @left			窗口左边距
+                            @top			窗口右边距
+            Output:
+            Return:         <0: 失败.
+                            =0: 成功.
+            Others:         无
+            Author:         FYX
+            Date:           2024-05-31
+        *************************************************/
+        [DllImport("SShow3DImage.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int Show3DImage(
+            int[] heightImage,
+            int ImageWidth,
+            int ImageHeight,
+            double ImageXinterval,
+            double ImageYinterval,
+            int streamline = 1,
+            int width = 960,
+            int height = 720,
+            int left = 50,
+            int top = 50);
+        #endregion
+    }
+}
+

+ 120 - 0
TeamAAS-VM/Core/Cameras/sr7apiclass/ISR7Api.cs

@@ -0,0 +1,120 @@
+using SR7Link;
+using System;
+using System.Runtime.InteropServices;
+
+namespace SRAPI
+{
+    /// <summary>
+    /// SR7IFGetDataCallBack
+    /// </summary>
+    /// <param name="nProfileWidth">返回单条轮廓宽度数据 / Returns a single contour width data</param>
+    /// <param name="nHighlen">返回的批处理行数 / The number of rows in the batch returned</param>
+    /// <param name="nFlag">回调函数执行状态,根据不同模式自定义 / Callback function execution status, customized according to different modes</param>
+    /// <param name="nStatusCode">错误码,0无错误 / Error code, 0 no error</param>
+    /// <param name="ProfileBits">Sync callback 0:32bit data, 1:16bit data</param>
+    public delegate void SR7IFGetDataCallBack(int nProfileWidth, int nHighlen, int nFlag, int nStatusCode, int ProfileBits);
+
+    /// <summary>
+    /// SR7 API 接口 / SR7 API
+    /// </summary>
+    public interface ISR7Api
+    {
+        /// <summary>
+        /// Open
+        /// </summary>
+        /// <param name="lDeviceId">设备 ID 号,范围 0-63. / Device ID, range: 0-63.</param>
+        /// <param name="strIP">相机IP / Camera IP</param>
+        /// <param name="timeout">搜索时间 (ms),最小值 100 / Search timeout (ms), minimum value: 100</param>
+        /// <param name="pfErrCallBack">掉线回调函数/Disconnection callback function</param>
+        /// <returns> <0:失败./Fail.  =0:成功./Success</returns>
+        int Open(int lDeviceId, string strIP, int timeout, ErrConnectCallBack pfErrCallBack);
+
+
+        /// <summary>
+        /// Init
+        /// </summary>
+        /// <param name="dwProfileCnt">指定行数返回数据 / Return the specified number of rows</param>
+        /// <param name="ProfileBits">0:返回32位高度数据。1:返回16位高度数据 / 0: Return 32-bit height data. 1: Return 16-bit height data.</param>
+        /// <param name="nTimeout">获取当次回调行数超时时间,单位ms   <0:关闭超时,用于无限循环回调初始化
+	    ///                       Get the timeout of the current callback row number, in ms < 0: turn off the timeout, used for infinite loop callback initialization</param>
+        /// <param name="pfGetDataCallBack">相机数据回调函数 / Camera data callback function</param>
+        /// <returns> <0:失败./Fail.  =0:成功./Success</returns>
+        int Init(int dwProfileCnt, uint ProfileBits, int nTimeout, SR7IFGetDataCallBack pfGetDataCallBack);
+
+        /// <summary>
+        /// Start 开始批处理/ Start batch processing
+        /// </summary>
+        /// <param name="bIOTrigger">是否硬触发;0:软触发,1:硬触发 / Whether it is hard trigger; 0: soft trigger, 1: hard trigger</param>
+        /// <param name="timeout">非循环获取时,超时时间(单位ms),-1为无限等待;循环模式该参数可设置为-1.
+        ///                       Timeout period (in ms) for non-cyclic acquisition. -1 means infinite waiting. For cyclic mode, this parameter can be set to -1.</param>
+        /// <returns> <0:失败./Fail.  =0:成功./Success</returns>
+        int Start(bool bIOTrigger, int timeout);
+
+        /// <summary>
+        /// Stop 停止批处理 / Stop batch processing
+        /// </summary>
+        /// <param name="instantStop">0:等数据传输完成  1:立即停止,抛弃剩余未传完数据. 用于高速回调
+        ///                           0: Wait for data transmission to complete 1: Stop immediately and discard the remaining untransmitted data. Used for high-speed callback</param>
+        /// <returns> <0:失败./Fail.  =0:成功./Success</returns>
+        int Stop(int instantStop);
+
+        /// <summary>
+        /// GetData 获取数据接口 / Get data interface
+        /// </summary>
+        /// <param name="pHighData">返回的高度数据 / height data returned</param>
+        /// <param name="pGrayData">返回的灰度数据. / The returned grayscale data.</param>
+        /// <param name="pEncoderData">返回的编码器数据 / Returned encoder data</param>
+        /// <param name="nProfileWidth">单条轮廓宽度数据,用于申请内存大小 / Single contour width data, used to apply for memory size</param>
+        /// <param name="nHighlen">批处理行数,用于申请内存大小 / The number of rows in a batch, used to apply for memory size</param>
+        /// <param name="ABCam">AB相机; 0:A相机; 1:B相机 / AB camera; 0:A camera; 1:B camera</param>
+        /// <returns> <0:失败./Fail.  =0:成功./Success</returns>
+        int GetData(int[] pHighData, byte[] pGrayData, int[] pEncoderData, int nProfileWidth, int nHighlen, int ABCam);
+        int GetData(short[] pHighData, byte[] pGrayData, int[] pEncoderData, int nProfileWidth, int nHighlen, int ABCam);
+    }
+
+    #region PinnedObject
+    public sealed class PinnedObject : IDisposable
+    {
+        private GCHandle _handle;      // Garbage collector handle
+        private bool _isDisposed;      // Track whether the object has been disposed
+        
+        /// <summary>
+        /// Gets the address of the pinned object.
+        /// </summary>
+        public IntPtr Pointer
+        {
+            get
+            {
+                if (_isDisposed)
+                    throw new ObjectDisposedException(nameof(PinnedObject), "The object has been disposed.");
+
+                return _handle.AddrOfPinnedObject();
+            }
+        }
+        
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="target">Target to protect from the garbage collector</param>
+        public PinnedObject(object target)
+        {
+            if (target == null)
+                throw new ArgumentNullException(nameof(target), "Target object cannot be null.");
+
+            _handle = GCHandle.Alloc(target, GCHandleType.Pinned);
+        }
+        
+        /// <summary>
+        /// Dispose method to free the resources held by GCHandle.
+        /// </summary>
+        public void Dispose()
+        {
+            if (_isDisposed) return;
+
+            _handle.Free();
+            _isDisposed = true;
+        }
+    }
+    #endregion
+
+}

+ 479 - 0
TeamAAS-VM/Core/Cameras/sr7apiclass/SR7ApiBase.cs

@@ -0,0 +1,479 @@
+
+/******************************************************************************
+ * @file    SR7ApiBase.h
+ * @brief   封装相机图API / Encapsulate camera image API
+ * @author  
+ * @date    2025-03-17
+ * @version 1.0.0.0
+ * @note    
+ *
+ * 封装取图API,使得调用相机库更简单、直观
+ * Encapsulate the image acquisition API to make calling the camera library simpler and more intuitive
+ * -查找相机 / Find camera
+ * -打开相机 / Open camera
+ * -初始化相机 / Initialize camera
+ * -获取数据 / Get data
+ * -设置相机参数 / Set camera parameters
+ * -关闭相机 / Turn off camera
+ *
+ * @history
+ * <Date>      <Author>    <Version>    <Description>
+ * 2025-04-01     GK         v1.0.0       初始版本/initial version
+ *
+ * @copyright Copyright (c) 2014-2025 SinceVision. All rights reserved.
+ ******************************************************************************/
+using SR7Link;
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace SRAPI
+{
+    public class SRAPIException : Exception
+    {
+        public SRAPIException(string message) : base(message) { }
+    }
+
+
+    // 定义用户数据指针
+    //using SR7IF_UserData = System.IntPtr;
+    /// <summary>
+    /// SR7 API 抽象基类
+    /// </summary>
+    public abstract class SR7ApiBase : ISR7Api
+    {
+        // 设备控制器ID,默认不可更改
+        public int ControllerID { get; set; } = 0;
+        //扫描行数 / Number of scan lines
+        public int BatchPoints { get; set; } = 0;
+        //无限循环回调行数 / Infinite loop callback line number
+        //public int CallBackPoints { get; set; } = 0;
+
+        public bool CameraAOnline { get; set; } = false;
+        public bool CameraBOnline { get; set; } = false;
+
+        //数据临时缓存 / Data temporary cache
+        public IntPtr[] ImgBuff32 = new IntPtr[2];
+        public IntPtr[] ImgBuff16 = new IntPtr[2];
+        public IntPtr[] GrayBuff = new IntPtr[2];
+        public IntPtr[] Encoder = new IntPtr[2];
+
+        public SR7IFGetDataCallBack GetDataCallBack;
+
+        //method
+        public abstract int Open(int lDeviceId, string strIP, int timeout, ErrConnectCallBack pfErrCallBack);
+
+        /// <summary>
+        /// 初始化设备
+        /// </summary>
+        public abstract int Init(int dwProfileCnt, uint ProfileBits, int nTimeout, SR7IFGetDataCallBack pfGetDataCallBack);
+
+        /// <summary>
+        /// 启动设备
+        /// </summary>
+        public abstract int Start(bool bIOTrigger, int timeout);
+
+        /// <summary>
+        /// 停止设备(提供默认参数的重载)
+        /// </summary>
+        public int Stop() => Stop(0);
+        public abstract int Stop(int instantStop);
+
+        /// <summary>
+        /// Close() 断开与相机的连接./Disconnect from the camera.
+        /// </summary>
+        /// <returns> <0:失败./Fail.  =0:成功./Success</returns>
+        public virtual int Close()
+        {
+            int nRet = Stop();
+            nRet = SR7LinkFunc.SR7IF_CommClose(ControllerID);
+            CameraAOnline = false;
+            CameraBOnline = false;
+            return nRet;
+        }
+
+        public virtual int GetData(int[] pHighData, byte[] pGrayData, int[] pEncoderData, int nProfileWidth, int nHighlen, int ABCam)
+        {
+            if (ABCam < 0 || ABCam >= 2)
+                return -1;
+
+            int totalPoints = nProfileWidth * nHighlen;
+
+            if (pHighData != null && ImgBuff32[ABCam] != IntPtr.Zero)
+                Marshal.Copy(ImgBuff32[ABCam], pHighData, 0, Math.Min(totalPoints, pHighData.Length));
+
+            if (pGrayData != null && GrayBuff[ABCam] != IntPtr.Zero)
+                Marshal.Copy(GrayBuff[ABCam], pGrayData, 0, Math.Min(totalPoints, pGrayData.Length));
+
+            if (pEncoderData != null && Encoder[ABCam] != IntPtr.Zero)
+                Marshal.Copy(Encoder[ABCam], pEncoderData, 0, Math.Min(nHighlen, pEncoderData.Length));
+
+            return 0;
+        }
+
+        public virtual int GetData(short[] pHighData, byte[] pGrayData, int[] pEncoderData, int nProfileWidth, int nHighlen, int ABCam)
+        {
+            if (ABCam < 0 || ABCam >= 2)
+                return -1;
+
+            int totalPoints = nProfileWidth * nHighlen;
+
+            if (pHighData != null && ImgBuff16[ABCam] != IntPtr.Zero)
+                Marshal.Copy(ImgBuff16[ABCam], pHighData, 0, Math.Min(totalPoints, pHighData.Length));
+
+            if (pGrayData != null && GrayBuff[ABCam] != IntPtr.Zero)
+                Marshal.Copy(GrayBuff[ABCam], pGrayData, 0, Math.Min(totalPoints, pGrayData.Length));
+
+            if (pEncoderData != null && Encoder[ABCam] != IntPtr.Zero)
+                Marshal.Copy(Encoder[ABCam], pEncoderData, 0, Math.Min(nHighlen, pEncoderData.Length));
+
+            return 0;
+        }
+        /// <summary>
+        /// 搜索可用摄像头IP(基类提供默认实现,但不强制子类实现)
+        /// </summary>
+        public virtual bool SearchCameraIP(out List<string> cameraIPs)
+        {
+            cameraIPs = new List<string>();
+            int[] readNum = new int[1];
+
+            try
+            {
+                // 使用传统的 using 语法
+                using (var pin = new PinnedObject(readNum))
+                {
+                    IntPtr str_Setting = SR7Link.SR7LinkFunc.SR7IF_SearchOnline(pin.Pointer, 3000);
+
+                    int deviceCount = readNum[0];
+                    if (deviceCount <= 0)
+                    {
+                        return false;
+                    }
+
+                    byte[][] ipAddressList = new byte[deviceCount][];
+
+                    for (int i = 0; i < deviceCount; i++)
+                    {
+                        byte[] ip = new byte[4];
+                        Marshal.Copy(str_Setting + 4 * i, ip, 0, 4);
+                        ipAddressList[i] = ip;
+                        cameraIPs.Add(string.Join(".", ip));
+                    }
+
+                    return true;
+                }
+            }
+            catch (Exception ex)
+            {
+                throw new SRAPIException($"Failed to search camera IPs: {ex.Message}");
+            }
+        }
+
+        public int GetProfileDataWidth()
+        {
+            return SR7LinkFunc.SR7IF_ProfileDataWidth(ControllerID, IntPtr.Zero);
+        }
+
+        public int GetProfilePointSetCount()
+        {
+            return SR7LinkFunc.SR7IF_ProfilePointSetCount(ControllerID, IntPtr.Zero);
+        }
+
+        public double GetProfileData_XPitch()
+        {
+            return SR7LinkFunc.SR7IF_ProfileData_XPitch(ControllerID, IntPtr.Zero);
+        }
+        public int SR7IFGet25DSingleProfile(int[] pHighData, uint[] pEncoder)
+        {
+            return SR7LinkFunc.SR7IF_GetSingleProfile((uint)ControllerID, pHighData, pEncoder);
+        }
+        public int SR7IFGet3DSingleProfile(int[] pHighData)
+        {
+            return SR7LinkFunc.SR7IF_GetSingleProfile3DMode((uint)ControllerID, pHighData);
+        }
+
+        ///
+		/// \brief SetParams  SetSetting.
+		/// \param nAB               [in]        相机A为0,B为1 / Camera A is 0, B is 1
+		/// \param nConfigNum        [in]        配方编号 -1:当前配方,0-63指定配方 / Recipe number -1: current recipe, 0-63 specifies the recipe
+		/// \param nParamItemEnums   [in]        参数项枚举,参考SRSettingHeader.h SR7IF_SETTING_ITEM中定义
+		///                                      Parameter item enumeration, refer to the definition in SR7IF_SETTING_ITEM in SRSettingHeader.h
+		/// \param nSetData          [in]        设置数据 / Set data
+		/// \return
+		///     <0:                     失败./Fail.
+		///     =0:                     成功./Success
+		///
+		public int SetParams(int nAB, int nSavePowerOff, int nConfigNum, SR7IF_SETTING_ITEM nParamItemEnums, int nSetData)
+        {
+            int nCategory = 0x00;
+            int nItem = 0x00;
+            int nDataSize = 1;
+            if (GetParamsCategory(nParamItemEnums,ref nCategory,ref nItem,ref nDataSize) != 0)
+            {
+                return -2;
+            }
+            if (nConfigNum != -1)
+                nConfigNum += 0x10;
+
+            //强制小端模式传数据 / Force little-endian mode to transfer data
+            byte[] pData = new byte[nDataSize];
+
+            for (int i = 0; i < nDataSize; i++)
+            {
+                pData[i] = (byte)((nSetData >> (i * 8)) & 0xFF);
+            }
+
+            int nRet = 0;
+            using (PinnedObject pin = new PinnedObject(pData))
+            {
+                nRet = SetParams(ControllerID, nSavePowerOff, nConfigNum, nCategory, nItem, nAB, pin, nDataSize);
+            }
+
+            
+            return nRet;
+        }
+        ///
+        /// \brief SetParams 设置参数 SetSetting.
+        /// \param nDeviceId      [in]        控制器ID. / Controller ID
+        /// \param nDepth         [in]        参数是否断电保存,0x01断电不保存,0x02断电保存
+        ///                                   Whether the parameters are saved when the power is off, 0x01 is not saved when the power is off, 0x02 is saved when the power is off
+        /// \param nFormulaNum    [in]        配方编号 -1:当前配方,0-63指定配方 / Recipe number -1: current recipe, 0-63 specifies the recipe
+        /// \param nCategory      [in]        对应Edgeimage软件中,指定参数页,0:触发设定页面;1:拍摄设定页面;2:轮廓设定页面
+        ///                                   Corresponding to the Edgeimage software, specify the parameter page, 0: trigger setting page; 1: shooting setting page; 2: contour setting page
+        /// \param nItem          [in]        指定发送 / 接收 nCategory 指定项中的设定项 / Specifies to send/receive the setting items in the specified item of nCategory
+        /// \param nAB            [in]        相机A为0,B为1 / Camera A is 0, B is 1
+        /// \param pData          [in]        写入数据 / Write data
+        /// \param nDataSize      [in]        写入数据的长度 / The length of the written data
+        /// \return
+        ///     <0:                     失败./Fail.
+        ///     =0:                     成功./Success
+        ///
+        public int SetParams(int nDeviceId, int nSavePowerOff, int nFormulaNum, int nCategory, int nItem, int nAB, PinnedObject pData, int nDataSize)
+        {
+            int[] arrayTarget = new int[4] { nAB, 0, 0, 0 };
+            int nRet = SR7LinkFunc.SR7IF_SetSetting((uint)ControllerID, nSavePowerOff, nFormulaNum, nCategory, nItem, arrayTarget, pData.Pointer, nDataSize);
+            return nRet;
+
+        }
+        ///
+        /// \brief GetParams 获取参数 GetSetting.
+        /// \param nABCamera            [in]        相机A为0,B为1 / Camera A is 0, B is 1
+        /// \param nConfigNum           [in]        配方编号 -1:当前配方,0-63指定配方 / Recipe number -1: current recipe, 0-63 specifies the recipe
+        /// \param nParamItemEnums      [in]        参数项枚举,参考SRSettingHeader.h SR7IF_SETTING_ITEM中定义
+        ///											Parameter item enumeration, refer to the definition in SR7IF_SETTING_ITEM in SRSettingHeader.h
+        /// \param nOutData             [out]       获取参数值. / Get parameter value.
+        /// \return
+        ///     <0:                     失败./Fail.
+        ///     =0:                     成功./Success
+        ///
+        public int GetParams(int nABCamera, int nConfigNum, SR7IF_SETTING_ITEM nParamItemEnums, out int nOutData)
+        {
+            nOutData = 0;
+            int nCategory = 0x00;
+            int nItem = 0x00;
+            int nDataSize = 1;
+            if (GetParamsCategory(nParamItemEnums,ref nCategory,ref nItem,ref nDataSize) != 0)
+            {
+                return -3;
+            }
+            if (nConfigNum != -1)
+                nConfigNum += 0x10;
+
+            int[] arrayTarget = new int[4] { nABCamera, 0, 0, 0 };
+            
+            byte[] pData = new byte[nDataSize];
+            using (PinnedObject pin = new PinnedObject(pData))
+            {
+                int nRet = SR7LinkFunc.SR7IF_GetSetting((uint)ControllerID, nConfigNum, nCategory, nItem, arrayTarget, pin.Pointer, nDataSize);
+
+                if (0 != nRet)
+                {
+                    return nRet;
+                }
+                //Get Data
+                for (int i = 0; i < pData.Length; i++)
+                {
+                    nOutData += pData[i] * (int)Math.Pow(256, i);
+                }
+            }
+            return 0;
+        }
+
+        public int GetParamsCategory(SR7IF_SETTING_ITEM nParamItemEnums, ref int nCategory, ref int nItem, ref int nDataSize)
+        {
+            switch (nParamItemEnums)
+            {
+                //00
+                case SR7IF_SETTING_ITEM.TRIG_MODE://触发模式 / Trigger mode
+                    nCategory = 0x00;
+                    nItem = 0x01;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.BATCH_OUTPUT://批处理输出 / Batch processing output
+                    nCategory = 0x00;
+                    nItem = 0x21;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.SAMPLED_CYCLE://采样周期 / Sampling cycle
+                    nCategory = 0x00;
+                    nItem = 0x02;
+                    nDataSize = 4;
+                    break;
+
+                case SR7IF_SETTING_ITEM.BATCH_ON_OFF://批处理开关 / Batch processing switch
+                    nCategory = 0x00;
+                    nItem = 0x03;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.ENCODER_TYPE://编码器类型 / Encoder type
+                    nCategory = 0x00;
+                    nItem = 0x0b;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.ENCODER_INPUTMODE://编码器输入模式 / Encoder input mode
+                    nCategory = 0x00;
+                    nItem = 0x07;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.REFINING_POINTS://细化点数(触发间隔) / Refining points
+                    nCategory = 0x00;
+                    nItem = 0x09;
+                    nDataSize = 2;
+                    break;
+
+                case SR7IF_SETTING_ITEM.BATCH_POINT://批处理点数 / Batch processing points
+                    nCategory = 0x00;
+                    nItem = 0x0a;
+                    nDataSize = 2;
+                    break;
+
+                case SR7IF_SETTING_ITEM.CYCLICAL_PATTERN://循环模式 0 关闭 1 打开 / Cyclical pattern (0: Off, 1: On)
+                    nCategory = 0x00;
+                    nItem = 0x10;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.SEGMENT_BUFER:// 分段存储 0 关闭 1 打开 / Segmented buffer (0: Off, 1: On)
+                    nCategory = 0x00;
+                    nItem = 0x11;
+                    nDataSize = 1;
+                    break;
+                //01
+                case SR7IF_SETTING_ITEM.Z_MEASURING_RANGE://Z方向测量范围 / Z-axis measuring range
+                    nCategory = 0x01;
+                    nItem = 0x03;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.SENSITIVITY://感光灵敏度 / Sensitivity
+                    nCategory = 0x01;
+                    nItem = 0x05;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.EXP_TIME://曝光时间 / Exposure time
+                    nCategory = 0x01;
+                    nItem = 0x06;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.LIGHT_CONTROL://光亮控制 / Light control
+                    nCategory = 0x01;
+                    nItem = 0x0B;
+                    nDataSize = 1;
+                    break;
+                case SR7IF_SETTING_ITEM.LIGHT_MAX://激光亮度上限 / Laser brightness upper limit
+                    nCategory = 0x01;
+                    nItem = 0x0C;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.LIGHT_MIN://激光亮度下限 / Laser brightness lower limit
+                    nCategory = 0x01;
+                    nItem = 0x0D;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.PEAK_SENSITIVITY://峰值灵敏度 / Peak sensitivity
+                    nCategory = 0x01;
+                    nItem = 0x0F;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.PEAK_SELECT://峰值选择 / Peak selection
+                    nCategory = 0x01;
+                    nItem = 0x11;
+                    nDataSize = 1;
+                    break;
+                //02
+                case SR7IF_SETTING_ITEM.X_SAMPLING://X轴压缩设定 / X-axis compression setting
+                    nCategory = 0x02;
+                    nItem = 0x02;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.FILTER_X_MEDIAN://X轴中位数滤波 / X-axis median filter
+                    nCategory = 0x02;
+                    nItem = 0x0A;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.FILTER_Y_MEDIAN://Y轴(时间轴)中位数滤波 / Y-axis (time axis) median filter
+                    nCategory = 0x02;
+                    nItem = 0x0C;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.FILTER_X_SMOOTH://X轴平滑滤波 / X-axis smooth filter
+                    nCategory = 0x02;
+                    nItem = 0x0B;
+                    nDataSize = 1;
+                    break;
+
+                case SR7IF_SETTING_ITEM.FILTER_Y_SMOOTH://Y轴平滑滤波(平均滤波) / Y-axis smooth filter (mean filter)
+                    nCategory = 0x02;
+                    nItem = 0x0D;
+                    nDataSize = 2;
+                    break;
+                //30
+                case SR7IF_SETTING_ITEM.CHANGE_3D_25D://3D/2.5D模式切换 / 3D/2.5D switch (In 2.5D mode, X-axis compression setting changes to default automatically)
+                    nCategory = 0x30;
+                    nItem = 0x00;
+                    nDataSize = 1;
+                    break;
+
+                default:
+                    nCategory = 0x00;
+                    nItem = 0x00;
+                    nDataSize = 1;
+                    return -1;
+
+            }
+            return 0;
+        }
+        ///
+        /// \brief SR7IF_Get16BitScale          获取16bit高度数据物理单位 / Get 16-bit height data in physical units
+        /// \param Scale				[out]	16bit高度数据 单位(mm) / 16bit height data Unit (mm)
+        /// \return
+        ///     <0:                     失败./Fail.
+        ///     =0:                     成功./Success
+        ///
+        public int Get16BitScale(out float Scale)
+        {
+            float[] scale1 = new float[1];
+            int ret = 0;
+            using (PinnedObject pin_size = new PinnedObject(scale1))
+            {
+                ret = SR7LinkFunc.SR7IF_Get16BitScale(0, pin_size.Pointer);
+            }
+            Scale = scale1[0];
+            return ret;
+        }
+    }
+}

+ 135 - 0
TeamAAS-VM/Core/Cameras/sr7apiclass/SR7ApiInfiniteLoopCallbackImpl.cs

@@ -0,0 +1,135 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using SR7Link;
+
+namespace SRAPI
+{
+    class SR7ApiInfiniteLoopCallbackImpl : SR7ApiBase
+    {
+        private SR7IF_RollDataCallback RollDataCallback;
+
+        public IntPtr LoopImgBuff32;
+        public IntPtr LoopImgBuff16;
+        public IntPtr LoopGrayBuff;
+        public IntPtr LoopEncoder;
+
+        public override int Open(int lDeviceId, string strIP, int timeout, ErrConnectCallBack pfErrCallBack)
+        {
+            ControllerID = lDeviceId;
+
+            string[] ipTmp = strIP.Split('.');
+            if (ipTmp.Length != 4)
+            {
+                throw new SRAPIException($"Failed to resolve IP ");
+            }
+
+            SR7IF_ETHERNET_CONFIG ethernetConfig;
+            ethernetConfig.abyIpAddress = new Byte[]
+            {
+                    Convert.ToByte(ipTmp[0]),
+                    Convert.ToByte(ipTmp[1]),
+                    Convert.ToByte(ipTmp[2]),
+                    Convert.ToByte(ipTmp[3])
+            };
+
+            int openRet = SR7LinkFunc.SR7IF_EthernetOpenExt(ControllerID, ref ethernetConfig, 2000, pfErrCallBack);
+            if (openRet != 0)
+                return openRet;
+            int nCameraB = SR7LinkFunc.SR7IF_GetOnlineCameraB(ControllerID);
+            CameraAOnline = true;
+            CameraBOnline = (nCameraB == 0);
+            return openRet;
+        }
+
+        public override int Init(int dwProfileCnt, uint ProfileBits, int nTimeout, SR7IFGetDataCallBack pfGetDataCallBack)
+        {
+            GetDataCallBack = pfGetDataCallBack;
+
+
+            RollDataCallback = new SR7IF_RollDataCallback(SR7IFRollDataCallback);
+            int ret = SR7LinkFunc.SR7IF_RollDataCallbackInitalize(ControllerID, RollDataCallback, dwProfileCnt,300000);
+            return ret;
+        }
+
+        public void SR7IFRollDataCallback(IntPtr pProfileBuffer, IntPtr pIntensityBuffer, IntPtr pEncoder, int dwSize, int dwCount, int dwRet, int dwDeviceId)
+        {
+            LoopImgBuff32 = pProfileBuffer;
+            LoopGrayBuff = pIntensityBuffer;
+            LoopEncoder = pEncoder;
+            GetDataCallBack(dwSize, dwCount, 1, dwRet,0);
+        }
+
+        public override int GetData(int[] pHighData, byte[] pGrayData, int[] pEncoderData, int nProfileWidth, int nHighlen, int ABCam)
+        {
+            if (LoopImgBuff32 == IntPtr.Zero || LoopGrayBuff == IntPtr.Zero || LoopEncoder == IntPtr.Zero)
+                return -1;
+
+            if (!CameraBOnline && ABCam == 0)//只有相机A取相机A的数据 / Only camera A can retrieve the data of camera A.
+            {
+                if (pHighData != null)
+                    Marshal.Copy(LoopImgBuff32, pHighData, 0, nProfileWidth * nHighlen);
+                if (pGrayData != null)
+                    Marshal.Copy(LoopGrayBuff, pGrayData, 0, nProfileWidth * nHighlen);
+            }
+            else if (CameraBOnline && ABCam == 0)//双相机取相机A的数据 / Dual cameras take data from camera A
+            {
+                int width = nProfileWidth;
+                for (int i = 0; i < nHighlen; i++)
+                {
+                    int new_start = i * width;
+                    int old_start = i * nProfileWidth*2;
+
+                    if (pHighData != null)
+                        Marshal.Copy(IntPtr.Add(LoopImgBuff32, old_start * sizeof(int)), pHighData, new_start, width);
+                    if (pGrayData != null)
+                        Marshal.Copy(IntPtr.Add(LoopGrayBuff, old_start), pGrayData, new_start, width);
+                }
+            }
+            else if (CameraBOnline && ABCam == 1) //双相机取相机B的数据 / Dual cameras get data from camera B
+            {
+                int width = nProfileWidth;
+                for (int i = 0; i < nHighlen; i++)
+                {
+                    int new_start = i * width;
+                    int old_start = i * nProfileWidth*2 + width;
+
+                    if (pHighData != null)
+                        Marshal.Copy(IntPtr.Add(LoopImgBuff32, old_start * sizeof(int)), pHighData, new_start, width);
+                    if (pGrayData != null)
+                        Marshal.Copy(IntPtr.Add(LoopGrayBuff, old_start), pGrayData, new_start, width);
+                }
+            }
+
+            if (pEncoderData != null)
+                Marshal.Copy(LoopEncoder, pEncoderData, 0, nHighlen);
+
+            return 0;
+        }
+
+        public override int Start(bool bIOTrigger, int timeout)
+        {
+            //设置无限循环终止行数 /  Set the infinite loop termination line number
+            int callbackPointRet = SR7LinkFunc.SR7IF_SetBatchRollProfilePoint(ControllerID, IntPtr.Zero, (uint)BatchPoints);
+            if (callbackPointRet != 0)
+            {
+                return callbackPointRet;
+            }
+            int ret = 0;
+            if (bIOTrigger)//hard trigger
+                ret = SR7LinkFunc.SR7IF_StartIOTriggerMeasure(ControllerID, timeout, 0);
+            else//Soft trigger
+                ret = SR7LinkFunc.SR7IF_StartMeasure(ControllerID, timeout);
+            return ret;
+        }
+
+        public override int Stop(int instantStop)
+        {
+            int ret = SR7LinkFunc.SR7IF_StopMeasure(ControllerID);
+            return ret;
+        }
+    }
+}

+ 102 - 0
TeamAAS-VM/Core/Cameras/sr7apiclass/SR7ApiOneTimeCallbackImpl.cs

@@ -0,0 +1,102 @@
+using SR7Link;
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace SRAPI
+{
+    /// <summary>
+    /// SR7 API 一次性回调实现 / SR7 API one-time callback implementation
+    /// </summary>
+    public class SR7ApiOneTimeCallbackImpl : SR7ApiBase
+    {
+        private SR7IF_BatchOneTimeCallBack BatchOneTimeDelegate; //一次回调
+
+        public override int Open(int lDeviceId, string strIP, int timeout, ErrConnectCallBack pfErrCallBack)
+        {
+            ControllerID = lDeviceId;
+
+            string[] ipTmp = strIP.Split('.');
+            if (ipTmp.Length != 4)
+            {
+                throw new SRAPIException($"Failed to resolve IP ");
+            }
+
+            SR7IF_ETHERNET_CONFIG ethernetConfig;
+            ethernetConfig.abyIpAddress = new Byte[]
+            {
+                    Convert.ToByte(ipTmp[0]),
+                    Convert.ToByte(ipTmp[1]),
+                    Convert.ToByte(ipTmp[2]),
+                    Convert.ToByte(ipTmp[3])
+            };
+
+            int openRet = SR7LinkFunc.SR7IF_EthernetOpenExt(ControllerID, ref ethernetConfig, 2000, pfErrCallBack);
+            if (openRet != 0)
+                return openRet;
+            int nCameraB = SR7LinkFunc.SR7IF_GetOnlineCameraB(ControllerID);
+            CameraAOnline = true;
+            CameraBOnline = (nCameraB==0);
+            return openRet; 
+        }
+        
+        public override int Init(int dwProfileCnt, uint ProfileBits, int nTimeout, SR7IFGetDataCallBack pfGetDataCallBack)
+        {
+            GetDataCallBack = pfGetDataCallBack;
+            BatchOneTimeDelegate = new SR7IF_BatchOneTimeCallBack(BatchOneTimeCallBack);
+            int ret = SR7LinkFunc.SR7IF_SetBatchOneTimeDataHandler(ControllerID, BatchOneTimeDelegate);
+            if (ret != 0)
+                return ret;
+
+            ret = SR7LinkFunc.SR7IF_StartMeasureWithCallback(ControllerID, 1);
+            return ret;
+        }
+        
+        public override int Start(bool bIOTrigger, int timeout)
+        {
+            int ret = 0;
+            if (!bIOTrigger)
+                ret = SR7LinkFunc.SR7IF_TriggerOneBatch(ControllerID);
+            return ret;
+        }
+        
+        public override int Stop(int instantStop)
+        {
+            int ret = SR7LinkFunc.SR7IF_StopMeasure(ControllerID);
+            return ret;
+        }
+
+        public SR7IF_STR_CALLBACK_INFO sR7IF_STR_CALLBACK;
+
+        /// <summary>
+        /// 一次回调函数 / One Time callback function
+        /// </summary>
+        /// <param name="info"></param>
+        /// <param name="data"></param>
+        public void BatchOneTimeCallBack(IntPtr info, IntPtr data)
+        {
+            Console.WriteLine("BatchOneTimeCallBack");
+            SR7IF_STR_CALLBACK_INFO sR7IF_STR_CALLBACK = new SR7IF_STR_CALLBACK_INFO();
+            sR7IF_STR_CALLBACK = (SR7IF_STR_CALLBACK_INFO)Marshal.PtrToStructure(info, typeof(SR7IF_STR_CALLBACK_INFO));
+
+            if (sR7IF_STR_CALLBACK.returnStatus == (int)SR7IF_ERROR.SR7IF_OK)
+            {
+                int camIndex = sR7IF_STR_CALLBACK.HeadNumber;//Number of cameras
+                for (int i = 0; i < camIndex; i++)
+                {
+                    ImgBuff32[i] = SR7LinkFunc.SR7IF_GetBatchProfilePoint(data, i);//获取相机32bit高度数据 / Get the camera's 32-bit height data
+
+                    GrayBuff[i] = SR7LinkFunc.SR7IF_GetBatchIntensityPoint(data, i);//获取相机灰度数据 / Get camera grayscale data
+
+                    Encoder[i] = SR7LinkFunc.SR7IF_GetBatchEncoderPoint(data, i);//获取相机编码器数据 / Get camera encoder data
+                }
+               GetDataCallBack(sR7IF_STR_CALLBACK.xPoints, sR7IF_STR_CALLBACK.BatchPoints, 1, sR7IF_STR_CALLBACK.returnStatus,0);
+            }
+            else
+            {
+                GetDataCallBack(0, 0, 1, sR7IF_STR_CALLBACK.returnStatus,0);
+            }
+        }
+
+    }
+}

+ 98 - 0
TeamAAS-VM/Core/Cameras/sr7apiclass/SR7ApiSyncCallbackImpl.cs

@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using SR7Link;
+
+namespace SRAPI
+{
+    class SR7ApiSyncCallbackImpl : SR7ApiBase
+    {
+        private ErrConnectCallBack ConnectErrCallBack;
+        private SR7IF_AsyncCALLBACK SyncDataCallBack;
+        private SR7IF_AsyncErrCallBack AsyncErrCallBack;
+
+        public override int Open(int lDeviceId, string strIP, int timeout, ErrConnectCallBack pfErrCallBack)
+        {
+            ControllerID = lDeviceId;
+
+            string[] ipTmp = strIP.Split('.');
+            if (ipTmp.Length != 4)
+            {
+                throw new SRAPIException($"Failed to resolve IP ");
+            }
+
+            SR7IF_ETHERNET_CONFIG ethernetConfig;
+            ethernetConfig.abyIpAddress = new Byte[]
+            {
+                    Convert.ToByte(ipTmp[0]),
+                    Convert.ToByte(ipTmp[1]),
+                    Convert.ToByte(ipTmp[2]),
+                    Convert.ToByte(ipTmp[3])
+            };
+            ConnectErrCallBack = pfErrCallBack;
+
+            AsyncErrCallBack = new SR7IF_AsyncErrCallBack(SR7IAsyncErrCallBack);
+            int openRet = SR7LinkFunc.SR7IF_AsyncEthernetOpen(ControllerID, ref ethernetConfig, 2000, AsyncErrCallBack);
+            if (openRet != 0)
+                return openRet;
+            int nCameraB = SR7LinkFunc.SR7IF_GetOnlineCameraB(ControllerID);
+            CameraAOnline = true;
+            CameraBOnline = (nCameraB == 0);
+            return openRet;
+        }
+
+        public void SR7IAsyncErrCallBack(int DeviciId, int ErrCode)
+        {
+            ConnectErrCallBack(DeviciId, ErrCode);
+        }
+
+        public override int Init(int dwProfileCnt, uint ProfileBits, int nTimeout, SR7IFGetDataCallBack pfGetDataCallBack)
+        {
+            GetDataCallBack = pfGetDataCallBack;
+
+            if (SyncDataCallBack == null)
+                SyncDataCallBack = new SR7IF_AsyncCALLBACK(SR7IFAsyncCallBack);
+            int ret = SR7LinkFunc.SR7IF_AsyncCallBackInitalize(ControllerID, SyncDataCallBack, IntPtr.Zero, ProfileBits, (uint)dwProfileCnt);
+            return ret;
+        }
+        public void SR7IFAsyncCallBack(IntPtr SR7IF_Data, IntPtr pUserData, uint state, int dwDeviceId)
+        {
+            AsyncCallBackInfo coninfo = new AsyncCallBackInfo();
+            coninfo = (AsyncCallBackInfo)Marshal.PtrToStructure(SR7IF_Data, typeof(AsyncCallBackInfo));
+
+             int camIndex = (coninfo.bCamB == 1  ? 2 : 1);
+             for (int i = 0; i < camIndex; i++)
+             {
+                 //Get height data
+                 if (coninfo.ProfileBits == 0)//32bit
+                     ImgBuff32[i] = SR7LinkFunc.SR7IF_GetAsyncProfilePointData(SR7IF_Data, i);
+                 else if (coninfo.ProfileBits == 1)//16bit
+                     ImgBuff16[i] = SR7LinkFunc.SR7IF_GetAsyncProfilePointData16Bit(SR7IF_Data, i);
+                 //Get grayscale data
+                 if (coninfo.bGray==1)
+                     GrayBuff[i] = SR7LinkFunc.SR7IF_GetAsyncIntensityContiuneData(SR7IF_Data, i);
+                 //Get encoder data
+                 Encoder[i] = SR7LinkFunc.SR7IF_GetAsyncEncoderContiune(SR7IF_Data, i);
+             }
+
+             GetDataCallBack(coninfo.profileWidth, coninfo.profileNum, 1, (int)state, coninfo.ProfileBits);
+        }
+
+        public override int Start(bool bIOTrigger, int timeout)
+        {
+            int ret = 0;
+            if (!bIOTrigger)
+                ret = SR7LinkFunc.SR7IF_AsyncSoftStartBatch(ControllerID);
+            return ret;
+        }
+
+        public override int Stop(int instantStop)
+        {
+            int ret = SR7LinkFunc.SR7IF_AsyncSoftStopBatch(ControllerID);
+            return ret;
+        }
+    }
+}

+ 260 - 0
TeamAAS-VM/Core/Cameras/sr7apiclass/SR7LinkEnum.cs

@@ -0,0 +1,260 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SR7Link
+{
+    #region public enum
+
+    /// <summary>
+    /// 接口函数返回值 / Interface function return value
+    /// </summary>
+    public enum SR7IF_ERROR
+    {
+        SR7IF_ERROR_NOT_FOUND = (-999),           // Item is not found.
+        SR7IF_ERROR_COMMAND = (-998),             // Command not recognized.
+        SR7IF_ERROR_PARAMETER = (-997),           // Parameter is invalid.
+        SR7IF_ERROR_UNIMPLEMENTED = (-996),       // Feature not implemented.
+        SR7IF_ERROR_HANDLE = (-995),              // Handle is invalid.
+        SR7IF_ERROR_MEMORY = (-994),              // Out of memory.
+        SR7IF_ERROR_TIMEOUT = (-993),             // Action timed out.
+        SR7IF_ERROR_DATABUFFER = (-992),          // Buffer not large enough for data.
+        SR7IF_ERROR_STREAM = (-991),              // Error in stream.
+        SR7IF_ERROR_CLOSED = (-990),              // Resource is no longer avaiable.
+        SR7IF_ERROR_VERSION = (-989),             // Invalid version number.
+        SR7IF_ERROR_ABORT = (-988),               // Operation aborted.
+        SR7IF_ERROR_ALREADY_EXISTS = (-987),      // Conflicts with existing item.
+        SR7IF_ERROR_FRAME_LOSS = (-986),          // Loss of frame.
+        SR7IF_ERROR_ROLL_DATA_OVERFLOW = (-985),  // Continue mode Data overflow.
+        SR7IF_ERROR_ROLL_BUSY = (-984),           // Read Busy.
+        SR7IF_ERROR_MODE = (-983),                // Err mode.
+        SR7IF_ERROR_CAMERA_NOT_ONLINE = (-982),   // Camera not online.
+        SR7IF_ERROR = (-1),                       // General error.
+        SR7IF_OK = (0),                           // Operation successful.
+        SR7IF_NORMAL_STOP = (-100)                //A normal stop caused by external IO or other causes
+
+    }
+    // SetSetting GetSetting
+    public enum SAVEPOWEROFF
+    {
+        ESAPO_NOSAVE = 1, // 1 掉电不保存 / No save after power off
+        ESAPO_SAVE   // 2 掉电保存 / Save after power off
+    };
+
+    public enum SR7IF_SETTING_ITEM
+    {
+        TRIG_MODE = 1,    // 触发模式 / Trigger mode
+        SAMPLED_CYCLE,    // 采样周期 / Sampling cycle
+        BATCH_ON_OFF,     // 批处理开关 / Batch processing switch
+        ENCODER_TYPE,     // 编码器类型 / Encoder type
+        ENCODER_INPUTMODE,// 编码器输入模式 / Encoder input mode
+
+        REFINING_POINTS,  // 细化点数 / Refining points
+        BATCH_POINT,      // 批处理点数 / Batch processing points
+
+        CYCLICAL_PATTERN, // 循环模式 0 关闭 1 打开 / Cyclical pattern (0: Off, 1: On)
+        SEGMENT_BUFER, // 分段存储 0 关闭 1 打开 / Segmented buffer (0: Off, 1: On)
+        BATCH_OUTPUT,     // 批处理输出 / Batch processing output
+        Z_MEASURING_RANGE,// Z 方向测量范围 / Z-axis measuring range
+
+        SENSITIVITY,      // 感光灵敏度 / Sensitivity
+        EXP_TIME,         // 曝光时间 / Exposure time
+        LIGHT_CONTROL,    // 光亮控制 / Light control
+        LIGHT_MAX,        // 激光亮度上限 / Laser brightness upper limit
+        LIGHT_MIN,        // 激光亮度下限 / Laser brightness lower limit
+        PEAK_SENSITIVITY, // 峰值灵敏度 / Peak sensitivity
+        PEAK_SELECT,      // 峰值选择 / Peak selection
+
+        X_SAMPLING,       // X 轴压缩设定 / X-axis compression setting
+
+        FILTER_X_MEDIAN,  // X 轴中位数滤波 / X-axis median filter
+        FILTER_X_SMOOTH,  // X 轴平滑滤波 / X-axis smooth filter
+        FILTER_Y_MEDIAN,  // Y 轴(时间轴)中位数滤波 / Y-axis (time axis) median filter
+        FILTER_Y_SMOOTH,  // Y 轴平滑滤波(平均滤波) / Y-axis smooth filter (mean filter)
+
+        CHANGE_3D_25D,    // 3D/2.5D 切换 2.5 模式下 X 轴压缩设定为自动变更默认值 / 3D/2.5D switch (In 2.5D mode, X-axis compression setting changes to default automatically)
+
+        X_PIXEL,          // X 数据宽度(单位像素) / X data width (unit: pixels)
+        X_PITCH           // X Resolution / X-axis resolution
+    };
+
+    // 触发模式 / Trigger mode
+    public enum SR7IF_TRIG_MODE
+    {
+        TM_CONTINUE = 0, // Continuous trigger
+        EXT_TRIGGER,     // External trigger
+        ENCODER,         // Encoder trigger
+    };
+
+    // 采集周期 / Sampling cycle
+    // 100 200 400 600 1000 1500 2000 2500
+
+    // 批处理开关 / Batch processing switch
+    public enum SR7IF_BATCH_ON_OFF
+    {
+        OFF = 0, // Off
+        ON       // On
+    };
+
+    // 编码器类型 / Encoder type
+    public enum SR7IF_ENCODER_TYPE
+    {
+        E_1_1 = 0, // 0:1 相 1 递增 / 1 phase, 1 increment
+        E_2_1,     // 1:2 相 1 递增 / 2 phase, 1 increment
+        E_2_2,     // 2:2 相 2 递增 / 2 phase, 2 increments
+        E_2_4      // 3:2 相 4 递增 / 2 phase, 4 increments
+    };
+
+    // 细化点数 1 --
+    // 批处理点数 1 --
+
+    // 循环模式 0 关闭 1 打开 / Cyclical pattern (0: Off, 1: On)
+    public enum SR7IF_CYCLICAL_PATTERN
+    {
+        CLOSE = 0, // Off
+        OPEN       // On
+    };
+
+    // Z 方向测量范围 注:只支持 SR8020/SR8060 / Z-axis measuring range (Note: Only supports SR8020/SR8060)
+    public enum SR7IF_Z_MEASURING_RANGE
+    {
+        Z840 = 0,
+        Z768,
+        Z512,
+        Z384,
+        Z256,
+        Z192,
+        Z128,
+        Z96,
+        Z64,
+        Z48,
+        Z32
+    };
+
+    // 感光灵敏度 / Sensitivity
+    public enum SR7IF_SENSITIVITY
+    {
+        HIGH = 0,      // High
+        HIGH_RANGE_1,  // High range 1
+        HIGH_RANGE_2,  // High range 2
+        HIGH_RANGE_3,  // High range 3
+        HIGH_RANGE_4,  // High range 4
+        CUSTOMIZATION  // Custom
+    };
+
+    // 曝光时间 / Exposure time
+    public enum SR7IF_EXP_TIME
+    {
+        T10US = 0, // 10µs
+        T15US,     // 15µs
+        T30US,     // 30µs
+        T60US,     // 60µs
+        T120US,    // 120µs
+        T240US,    // 240µs
+        T480US,    // 480µs
+        T960US,    // 960µs
+        T1920US,   // 1920µs
+        T2400US,   // 2400µs
+        T4900US,   // 4900µs
+        T9800US    // 9800µs
+    };
+
+    // 光亮控制 / Light control
+    public enum SR7IF_LIGHT_CONTROL
+    {
+        AUTO = 0, // Auto
+        MAN       // Manual
+    };
+
+    // 激光亮度上限 0-99 / Laser brightness upper limit 0-99
+    // 激光亮度下限 0-99 / Laser brightness lower limit 0-99
+
+    // 峰值灵敏度 / Peak sensitivity
+    public enum SR7IF_PEAK_SENSITIVITY
+    {
+        N_1 = 1,
+        N_2,
+        N_3,
+        N_4,
+        N_5
+    };
+
+    // 峰值选择 / Peak selection
+    public enum SR7IF_PEAK_SELECT
+    {
+        PS_STANDARD = 0, // Standard
+        PS_SRNEAR,       // SR Near
+        PS_SRFAR,        // SR Far
+        PS_BE_NULL,      // Be Null
+        PS_CONTINUE,     // Continue
+        PS_GLUE          // Glue
+    };
+
+    // X 轴压缩设定 注:2.5D 模式下不能设置 / X-axis compression setting (Note: Not configurable in 2.5D mode)
+    public enum SR7IF_X_SAMPLING
+    {
+        XS_OFF = 1,  // Off
+        XS_X2 = 2,   // X2
+        XS_X4 = 4,   // X4
+        XS_X8 = 8,   // X8
+        XS_X16 = 16  // X16
+    };
+
+    // X 轴中位数滤波 / X-axis median filter
+    public enum SR7IF_FILTER_X_MEDIAN
+    {
+        XM_OFF = 1,
+        XM_N3 = 3,
+        XM_N5 = 5,
+        XM_N7 = 7,
+        XM_N9 = 9
+    };
+
+    // Y 轴中位数滤波 / Y-axis median filter
+    public enum SR7IF_FILTER_Y_MEDIAN
+    {
+        YM_OFF = 1,
+        YM_N3 = 3,
+        YM_N5 = 5,
+        YM_N7 = 7,
+        YM_N9 = 9
+    };
+
+    // X 轴平滑滤波 / X-axis smooth filter
+    public enum SR7IF_FILTER_X_SMOOTH
+    {
+        N1 = 1,
+        N2 = 2,
+        N4 = 4,
+        N8 = 8,
+        N16 = 16,
+        N32 = 32,
+        N64 = 64
+    };
+
+    // Y 轴平滑滤波 / Y-axis smooth filter
+    public enum SR7IF_FILTER_Y_SMOOTH
+    {
+        YS_N1 = 1,
+        YS_N2 = 2,
+        YS_N4 = 4,
+        YS_N8 = 8,
+        YS_N16 = 16,
+        YS_N32 = 32,
+        YS_N64 = 64,
+        YS_N128 = 128,
+        YS_N256 = 256
+    };
+
+    // 3D/2.5D 切换 / 3D/2.5D switch
+    public enum SR7IF_CHANGE_3D_25D
+    {
+        T3D = 0,  // 3D mode
+        T25D = 1  // 2.5D mode
+    };
+
+    #endregion
+ 
+}

+ 1059 - 0
TeamAAS-VM/Core/Cameras/sr7apiclass/SR7LinkFunc.cs

@@ -0,0 +1,1059 @@
+/**************************************************************************
+ * File Name:    SR7LinkFunc.cs
+ * Created Date: 2025-04-01
+ * Version:      1.0.0
+ * Description:  将SR7lnik sdk库转成C#可用接口
+ *               Convert the SR7lnik SDK library into a C# usable interface
+ * 
+ * Change Log:
+ * Date         Author      Description
+ * ----------   ---------   ----------------------------------------------
+ * 2025-04-01   GK          Add
+ **************************************************************************/
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+
+namespace SR7Link
+{
+    #region Structure
+    /// <summary>
+    /// IP 结构体 / IP structure
+    /// </summary>
+    [StructLayout(LayoutKind.Sequential)]
+    public struct SR7IF_ETHERNET_CONFIG
+    {
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
+        public byte[] abyIpAddress;
+    }
+
+    /// <summary>
+    /// 目标设置结构体 / Target setting structure
+    /// </summary>
+    public struct SR_TARGET_SETTING
+    {
+        public byte byType;           // 类型 / Type
+        public byte byCategory;       // 类别 / Category
+        public byte byItem;           // 项目 / Item
+        public byte reserve;          // 保留 / Reserved
+        public byte byTarget1;        // 目标1 / Target 1
+        public byte byTarget2;        // 目标2 / Target 2
+        public byte byTarget3;        // 目标3 / Target 3
+        public byte byTarget4;        // 目标4 / Target 4
+    };
+
+    /// <summary>
+    /// 回调信息结构体 / Callback information structure
+    /// </summary>
+    public struct SR7IF_STR_CALLBACK_INFO
+    {
+        /// <summary>
+        ///  x方向数据数量 / Number of data points in x direction
+        /// </summary>
+        public int xPoints;           // x方向数据数量 / Number of data points in x direction
+        /// <summary>
+        /// 批处理数量 / Batch quantity
+        /// </summary>
+        public int BatchPoints;       // 批处理数量 / Batch quantity
+        /// <summary>
+        /// 批处理次数 / Number of batches
+        /// </summary>
+        public int BatchTimes;        // 批处理次数 / Number of batches
+        /// <summary>
+        /// x方向点间距 / Point spacing in x direction
+        /// </summary>
+        public double xPixth;         // x方向点间距 / Point spacing in x direction
+        /// <summary>
+        /// 批处理开始编码器值 / Batch start encoder value
+        /// </summary>
+        public int startEncoder;      // 批处理开始编码器值 / Batch start encoder value
+        /// <summary>
+        /// 相机头数量 / Number of camera heads
+        /// </summary>
+        public int HeadNumber;        // 相机头数量 / Number of camera heads
+        /// <summary>
+        /// 0:正常批处理 / 0: Normal batch processing
+        /// </summary>
+        public int returnStatus;      // 0:正常批处理 / 0: Normal batch processing
+    }
+
+    /// <summary>
+    /// 异步回调结构体 / Asynchronous callback structure
+    /// </summary>
+    public struct AsyncCallBackInfo
+    {
+        public int dev;               // 本次回调控制器编号 / The controller number of this callback
+        public int profileIndex;      // 本次回调起始行号 / The starting line number of this callback
+        public int profileNum;        // 本次回调帧数量 / The number of frames in this callback
+        public int profileWidth;      // 本次回调宽度 / The width of this callback
+        public uint BatchTimes;       // 本次回调批处理序号 / The batch number of this callback
+        public int bGray;             // 本次回调是否开启灰度 / Whether this callback is grayscale enabled
+        public int bCamB;             // 本次回调相机b是否在线 / Whether camera B is online in this callback
+        public int ProfileBits;       // 本次回调数据类型0:32bit;1:16bit / The data type of this callback is 0:32bit; 1:16bit
+
+        public IntPtr pProfileDataA;       // 相机a数据地址 / Camera A data address
+        public IntPtr pProfileDataB;       // 相机b数据地址 / Camera B data address
+        public IntPtr pProfileDataA16Bit;  // 相机A16Bit数据地址 / Camera A 16Bit data address
+        public IntPtr pProfileDataB16Bit;  // 相机B16Bit数据地址 / Camera B 16Bit data address
+        public IntPtr pGrayDataA;          // 相机A灰度图 / Camera A grayscale image
+        public IntPtr pGrayDataB;          // 相机B灰度图 / Camera B grayscale image
+        public IntPtr pEncoderDataA;       // 相机A编码器数据 / Camera A encoder data
+        public IntPtr pEncoderDataB;       // 相机B编码器数据 / Camera B encoder data
+    };
+    #endregion
+
+    #region Method
+    /// <summary>
+    /// 回调函数-高速数据通信的回调函数接口 / Callback function - callback function interface for high-speed data communication
+    /// </summary>
+    /// <param name="buffer">指向储存概要数据的缓冲区的指针 / Pointer to a buffer to store summary data</param>
+    /// <param name="size">每个单元(行)的字节数量 / The number of bytes per cell (row)</param>
+    /// <param name="count">存储在pBuffer中的内存的单元数量 / The number of cells of memory stored in pBuffer</param>
+    /// <param name="notify">中断或批量结束等中断的通知 / Notification of interruptions such as interruption or batch end</param>
+    /// <param name="user">用户自定义信息 / User-defined information</param>
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    public delegate void HighSpeedDataCallBack(IntPtr buffer, uint size, uint count, uint notify, uint user);
+
+    /// <summary>
+    /// 异步回调回调函数 / Asynchronous callback function
+    /// </summary>
+    /// <param name="info">保留 / Reserved</param>
+    /// <param name="SR7IF_Data">回调相关信息 / Callback related information</param>
+    /// <param name="pUserData">返回用户注册传入的指针 / Returns the pointer passed by user registration</param>
+    /// <param name="state">本次回调状态 / Current callback status
+    ///     (0x01 << 0) : 批处理批处理正常结束 / Batch processing ended normally
+    ///     (0x01 << 1) : 批处理软件溢出 / Batch software overflow
+    ///     (0x01 << 2) : 批处理硬件溢出 / Batch hardware overflow
+    ///     (0x01 << 3) : 网络异常,接收断开 / Network abnormality, reception disconnected
+    ///     (0x01 << 4) : 其他错误 / Other errors
+    /// </param>
+    /// <param name="dwDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+    /// <returns>
+    ///     &lt;0: 失败 / Fail
+    ///     =0: 成功 / Success
+    /// </returns>
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    public delegate void SR7IF_AsyncCALLBACK(IntPtr SR7IF_Data, IntPtr pUserData, uint state, int dwDeviceId);
+
+    /// <summary>
+    /// 异步错误回调 / Asynchronous error callback
+    /// </summary>
+    /// <param name="DeviciId">设备ID / Device ID</param>
+    /// <param name="ErrCode">错误码 / Error code</param>
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    public delegate void SR7IF_AsyncErrCallBack(int DeviciId, int ErrCode);
+
+    /// <summary>
+    /// 回调函数-无限循环回调函数接口 / Callback function - infinite loop callback function interface
+    /// </summary>
+    /// <param name="pProfileBuffer">返回轮廓数据 / Return contour data</param>
+    /// <param name="pIntensityBuffer">返回灰度数据 / Return grayscale data</param>
+    /// <param name="pEncoder">返回编码器数据 / Return encoder data</param>
+    /// <param name="dwSize">数据宽度 / Data width</param>
+    /// <param name="dwCount">批处理点数 / Batch points</param>
+    /// <param name="dwRet">返回值,待使用 / Return value, to be used</param>
+    /// <param name="dwDeviceId">相应的控制器(0-63) / Corresponding controller (0-63)</param>
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    public delegate void SR7IF_RollDataCallback(IntPtr pProfileBuffer, IntPtr pIntensityBuffer, IntPtr pEncoder, int dwSize, int dwCount, int dwRet, int dwDeviceId);
+
+    /// <summary>
+    /// 高速数据通信的回调函数接口 / Callback function interface for high-speed data communication
+    /// </summary>
+    /// <param name="data">指向储存概要数据的缓冲区的指针 / Pointer to the buffer where the summary data is stored</param>
+    /// <param name="ProfileCompressType">Ethernet 压缩类型0:32bit,1:16bit / Ethernet compression type 0:32bit, 1:16bit</param>
+    /// <param name="xPoints">一行轮廓的点数 / The number of points in a line of contours</param>
+    /// <param name="dwCount">当前回调返回行数 / The current callback returns the number of rows</param>
+    /// <param name="dwNotify">回调状态0:回调中,1:回调结束 / Callback status 0: callback in progress, 1: callback completed</param>
+    /// <param name="dwDeviceId">被调用函数DeviceID号 / DeviceID number of the called function</param>
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    public delegate void SR7IF_ProfileCALLBACK(IntPtr data, byte ProfileCompressType, int xPoints, int dwCount, int dwNotify, int dwDeviceId);
+
+    /// <summary>
+    /// 批处理一次性回调 / Batch one-time callback
+    /// </summary>
+    /// <param name="info">信息 / Information</param>
+    /// <param name="DataObj">数据对象 / Data object</param>
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    public delegate void SR7IF_BatchOneTimeCallBack(IntPtr info, IntPtr DataObj);
+
+    /// <summary>
+    /// 相机异常回调 / Camera exception callback
+    /// </summary>
+    /// <param name="dwDeviceId">设备ID / Device ID</param>
+    /// <param name="cmd">命令 / Command</param>
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    public delegate void ErrConnectCallBack(int dwDeviceId, int cmd);
+
+    /// <summary>
+    /// Function definitions 接口函数定义 / Interface function definition
+    /// </summary>
+    internal class SR7LinkFunc
+    {
+        internal static UInt32 ProgramSettingSize
+        {
+            get { return 10932; }
+        }
+
+        /// <summary>
+        /// 连接相机 / Connect camera
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="pEthernetConfig">(网口)通信设定 / (Network port) Communication settings</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_EthernetOpen(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig);
+
+        /// <summary>
+        /// 连接相机ext / Connect camera ext
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="pEthernetConfig">(网口)通信设定 / (Network port) Communication settings</param>
+        /// <param name="Timeout">超时时间,默认为2000ms / Timeout, default is 2000ms</param>
+        /// <param name="fun">TCP连接函数 / TCP connection function</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_EthernetOpenExt(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig, int Timeout = 2000, ErrConnectCallBack fun = null);
+
+        /// <summary>
+        /// 断开相机连接 / Disconnect the camera
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_CommClose(int lDeviceId);
+
+        /// <summary>
+        /// 开始批处理,立即执行批处理程序 / Start batch processing and execute the batch program immediately
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="Timeout">非循环获取时,超时时间(单位ms); 循环模式该参数可设置为-1 / Timeout in milliseconds for non-loop mode; set to -1 for loop mode</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_StartMeasure(int lDeviceId, int Timeout);
+
+        /// <summary>
+        /// 开始批处理,硬件IO触发开始批处理,具体查看硬件手册 / Start batch processing, triggered by hardware IO. Refer to the hardware manual for details.
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="Timeout">非循环获取时,超时时间(单位ms); 循环模式该参数可设置为-1 / Timeout in milliseconds for non-loop mode; set to -1 for loop mode</param>
+        /// <param name="restart">预留,设为0 / Reserved, set to 0</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_StartIOTriggerMeasure(int lDeviceId, int Timeout, int restart);
+
+        /// <summary>
+        /// 停止批处理---停止扫描 / Stop batch processing - stop scanning
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_StopMeasure(int lDeviceId);
+
+        /// <summary>
+        /// 阻塞方式获取数据---等待数据接收完成 / Get data in blocking mode - wait until data reception is complete
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="DataObj">返回数据指针 / Pointer to the returned data</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_ReceiveData(int lDeviceId, IntPtr DataObj);
+
+        /// <summary>
+        /// 获取当前编码器值 / Get the current encoder value
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="DataObj">返回数据指针 / Pointer to the returned data</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetCurrentEncoder(int lDeviceId, IntPtr DataObj);
+
+        /// <summary>
+        /// 获取当前批处理设定行数 / Get the number of preset lines for batch processing
+        /// </summary>
+        /// <param name="lDeviceId">设备号0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="DataObj">预留设置为null / Reserved, set to null</param>
+        /// <returns>
+        ///     返回实际批处理行数 / Returns the actual number of batch processing lines
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_ProfilePointSetCount(int lDeviceId, IntPtr DataObj);
+
+        /// <summary>
+        /// 获取批处理实际获取行数 / Get the actual number of lines obtained in batch processing
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <returns>
+        ///     返回实际批处理行数 / Returns the actual number of batch processing lines
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_ProfilePointCount(int lDeviceId, IntPtr DataObj);
+
+        /// <summary>
+        /// 获取数据宽度 / Get the data width
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID, ranging from 0 to 63</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <returns>
+        ///     返回数据宽度(单位像素) / Returns the data width (in pixels)
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_ProfileDataWidth(int lDeviceId, IntPtr DataObj);
+
+        /// <summary>
+        /// 本次上电后控制器运行的时间 / The running time of the controller since the last power-on
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="TimeStamp">返回运行的时间(单位秒) / Returns the running time (in seconds)</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetTimeStamp(int lDeviceId, IntPtr DataObj, int TimeStamp);
+
+        /// <summary>
+        /// 批处理状态查询 / Batch processing status query
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="Status">批处理状态 1:正在批处理 0:批处理结束 / Batch status 1: batch processing in progress 0: batch processing ended</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetBatchStatus(int lDeviceId, int Status);
+
+        /// <summary>
+        /// 设置控制器网络参数 / Set controller network parameters
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="ip">IP地址 / IP address</param>
+        /// <param name="netmask">子网掩码 / Subnet mask</param>
+        /// <param name="gateway">默认网关 / Default gateway</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_SetNetworkParam(int lDeviceId, IntPtr ip, IntPtr netmask, IntPtr gateway);
+
+        /// <summary>
+        /// 续传功能使能 / Resume function enable
+        /// 设置相机在一次批处理过程中,可以通过IO控制来暂停或继续批处理 / Set the camera to pause or resume batch processing through IO control during a batch process
+        /// IO控制使用控制器11脚和14脚配合使用,其中11脚开启电平控制模式,14脚控制暂停和继续批处理 / IO control uses pin 11 and pin 14 of the controller, where pin 11 enables level control mode and pin 14 controls pause and resume of batch processing
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Enable">功能使能0:关闭 1:使能 / Function enable 0: disable 1: enable</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_SetBatchCtrlByIO(int lDeviceId, IntPtr DataObj, int Enable);
+
+        /// <summary>
+        /// 获取z向测量范围上下限 / Get the upper and lower limits of the z-direction measurement range
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="up">上限(mm) / Upper limit (mm)</param>
+        /// <param name="down">下限(mm) / Lower limit (mm)</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetMeasuringRangeZ(int lDeviceId, double up, double down);
+
+        /// <summary>
+        /// 获取编码器值64bit / Get 64-bit encoder value
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Encoder">返回数据指针 / Return data pointer</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetBatchEncoder64Bit(int lDeviceId, IntPtr DataObj, IntPtr Encoder);
+
+        /// <summary>
+        /// 获取激光器宽度数据(仅支持SRI设备) / Get laser width data (only supports SRI devices)
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="widthData">返回数据指针,双相机为A/B行交替数据 / Return data pointer, dual cameras are A/B row alternate data</param>
+        /// <param name="GetCnt">获取数据长度 / Get data length</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetLaserWidthData(int lDeviceId, IntPtr DataObj, IntPtr widthData, int GetCnt = 0);
+
+        /// <summary>
+        /// 设置有效数据范围(获取数据模式:批处理一次回调一次) / Set valid data range (data acquisition mode: one callback per batch)
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="Left">左侧裁剪数量 / Number of left crops</param>
+        /// <param name="Right">右侧裁剪数量 / Number of right crops</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_SetBatchOneTimeDataValidRange(int lDeviceId, int Left, int Right);
+
+        /// <summary>
+        /// 获取数据x方向间距 / Get data x-direction spacing
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <returns>
+        ///     返回数据x方向间距(mm) / Returns the x-direction spacing of the data (mm)
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern double SR7IF_ProfileData_XPitch(int lDeviceId, IntPtr DataObj);
+
+        /// <summary>
+        /// 获取编码器值 / Get encoder value
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Encoder">返回数据指针 / Return data pointer</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetEncoder(int lDeviceId, IntPtr DataObj, IntPtr Encoder);
+
+        /// <summary>
+        /// 非阻塞方式获取编码器值 / Get encoder value in non-blocking mode
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Encoder">返回数据指针 / Return data pointer</param>
+        /// <param name="GetCnt">获取数据长度 / Get data length</param>
+        /// <returns>
+        ///     >=0: 实际返回的数据长度 小于0: 获取失败 / >=0: actual returned data length less than 0: failed to get
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetEncoderContiune(int lDeviceId, IntPtr DataObj, IntPtr Encoder, int GetCnt);
+
+        /// <summary>
+        /// 阻塞方式获取轮廓数据 / Get profile data in blocking mode
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Profile">返回数据指针 / Return data pointer</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetProfileData(int lDeviceId, IntPtr DataObj, IntPtr Profile);
+
+        /// <summary>
+        /// 非阻塞方式获取轮廓数据 / Get profile data in non-blocking mode
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Profile">返回数据指针 / Return data pointer</param>
+        /// <param name="GetCnt">获取数据长度 / Get data length</param>
+        /// <returns>
+        ///     >=0: 实际返回的数据长度 小于0: 获取失败 / >=0: actual returned data length less than 0: failed to get
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetProfileContiuneData(int lDeviceId, IntPtr DataObj, IntPtr Profile, int GetCnt);
+
+        /// <summary>
+        /// 无终止循环获取数据 / Get data in infinite loop mode
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Profile">返回轮廓数据指针 / Return profile data pointer</param>
+        /// <param name="Intensity">返回亮度数据指针 / Return intensity data pointer</param>
+        /// <param name="Encoder">返回编码器数据指针 / Return encoder data pointer</param>
+        /// <param name="FrameId">返回帧编号数据指针 / Return frame ID data pointer</param>
+        /// <param name="FrameLoss">返回批处理过快掉帧数量数据指针 / Return the number of frames lost due to too fast batch processing</param>
+        /// <param name="GetCnt">获取数据长度 / Get data length</param>
+        /// <returns>
+        ///     >=0: 实际返回的数据长度 小于0: 获取失败 / >=0: actual returned data length less than 0: failed to get
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetBatchRollData(int lDeviceId, IntPtr DataObj, IntPtr Profile, IntPtr Intensity, IntPtr Encoder, IntPtr FrameId, IntPtr FrameLoss, int GetCnt);
+
+        /// <summary>
+        /// 无终止循环设定终止行数(该设置断电不保存) / Set the termination line number for infinite loop (this setting is not saved after power off)
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="points">设定行数,范围(0:无终止循环。≥15000:设定终止行数,其他无效) / Set the number of lines, range (0: infinite loop. ≥15000: set termination line number, others invalid)</param>
+        /// <returns>
+        ///     =0: 设置成功 小于0: 设置失败 / =0: setting successful less than 0: setting failed
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_SetBatchRollProfilePoint(int lDeviceId, IntPtr DataObj, uint points);
+
+        /// <summary>
+        /// 无终止循环回调方式 / Infinite loop callback mode
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="pCallBack">回调函数 / Callback function</param>
+        /// <param name="dwProfileCnt">单次回调行数:范围0-15000 / Number of lines per callback: range 0-15000</param>
+        /// <param name="Timeout">获取档次回调行数超时时间,单位ms <0:关闭超时 / Timeout for getting callback lines, in ms <0: disable timeout</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_RollDataCallbackInitalize(int lDeviceId, SR7IF_RollDataCallback pCallBack, int dwProfileCnt, int Timeout);
+
+        /// <summary>
+        /// 阻塞方式获取亮度数据 / Get intensity data in blocking mode
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Intensity">返回数据指针 / Return data pointer</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetIntensityData(int lDeviceId, IntPtr DataObj, IntPtr Intensity);
+
+        /// <summary>
+        /// 非阻塞获取亮度数据 / Get intensity data in non-blocking mode
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="DataObj">预留,设置为NULL / Reserved, set to NULL</param>
+        /// <param name="Intensity">返回数据指针 / Return data pointer</param>
+        /// <param name="GetCnt">获取数据长度 / Get data length</param>
+        /// <returns>
+        ///     >=0: 实际返回的数据长度 小于0: 获取失败 / >=0: actual returned data length less than 0: failed to get
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetIntensityContiuneData(int lDeviceId, IntPtr DataObj, IntPtr Intensity, int GetCnt);
+
+        /// <summary>
+        /// 无终止循环获取数据异常计算值 / Get abnormal calculation value of infinite loop data
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="EthErrCnt">返回网络传输导致错误的数量 / Returns the number of errors caused by network transmission</param>
+        /// <param name="UserErrCnt">返回用户获取导致错误的数量 / Returns the number of errors caused by user acquisition</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetBatchRollError(int lDeviceId, IntPtr EthErrCnt, IntPtr UserErrCnt);
+
+        /// <summary>
+        /// 获取系统错误信息 / Get system error information
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="EthErrCnt">返回错误码数量 / Returns the number of error codes</param>
+        /// <param name="UserErrCnt">返回错误码指针 / Returns the error code pointer</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetError(int lDeviceId, IntPtr pbyErrCnt, IntPtr pwErrCode);
+
+        /// <summary>
+        /// 初始化以太网高速数据通信 / Initialize Ethernet high-speed data communication
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="pEthernetConfig">Ethernet 通信设定 / Ethernet communication settings</param>
+        /// <param name="wHighSpeedPortNo">Ethernet 通信端口设定 / Ethernet communication port settings</param>
+        /// <param name="pCallBack">高速通信中数据接收的回调函数 / Callback function for data reception in high-speed communication</param>
+        /// <param name="dwProfileCnt">回调函数被调用的频率. 范围1-256 / Frequency at which the callback function is called. Range 1-256</param>
+        /// <param name="dwThreadId">线程号 / Thread number</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_HighSpeedDataEthernetCommunicationInitalize(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig, int wHighSpeedPortNo,
+            HighSpeedDataCallBack pCallBack, uint dwProfileCnt, uint dwThreadId);
+
+        /// <summary>
+        /// 初始化以太网高速数据通信 / Initialize Ethernet high-speed data communication
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="pEthernetConfig">Ethernet 通信设定 / Ethernet communication settings</param>
+        /// <param name="pCallBack">回调函数 / Callback function</param>
+        /// <param name="dwProfileCnt">范围1-15000 / Range 1-15000</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_HighSpeedDataCallBackInitalize(int lDeviceId, [MarshalAs(UnmanagedType.LPStr)] string pEthernetConfig, SR7IF_ProfileCALLBACK pCallBack, int dwProfileCnt);
+
+        /// <summary>
+        /// 高速回调开始批处理 / High-speed callback start batch processing
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="ImmediateBatch">0:立即开始批处理 非0:等待外部开始批处理 / 0: start batch immediately non-zero: wait for external start batch</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_StartMeasureWithHighSpeedCallback(int lDeviceId, int ImmediateBatch);
+
+        /// <summary>
+        /// 高速回调停止批处理 / High-speed callback stop batch processing
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="instantStop">0:数据传输完成 1:立即停止,抛弃剩余未传完数据 / 0: data transmission completed 1: stop immediately, discard remaining untransmitted data</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_StopMeasureWithHighSpeedCallback(int lDeviceId, int instantStop);
+
+        /// <summary>
+        /// 高速回调获取32位高度数据 / High-speed callback get 32-bit height data
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
+        /// <param name="Profile">接收数据指针,单点数据大小为4Bytes / Receive data pointer, single point data size is 4Bytes</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetProfilePointData32bit(IntPtr DataObj, int head, int[] Profile);
+
+        /// <summary>
+        /// 高速回调获取16位高度数据 / High-speed callback get 16-bit height data
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
+        /// <param name="Profile">接收数据指针,单点数据大小为2Bytes / Receive data pointer, single point data size is 2Bytes</param>
+        /// <param name="Scale">压缩比例 / Compression ratio</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetProfilePointData16bit(IntPtr DataObj, int head, IntPtr Profile, double Scale);
+
+        /// <summary>
+        /// 高速回调获取灰度数据 / High-speed callback get grayscale data
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
+        /// <param name="Profile">接收数据指针 / Receive data pointer</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetHighSpeedIntensityData(IntPtr DataObj, int head, byte[] Intensity);
+
+        /// <summary>
+        /// 高速回调获取16位灰度图 / High-speed callback get 16-bit grayscale image
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
+        /// <param name="Profile">接收数据指针,单点数据大小为2Bytes / Receive data pointer, single point data size is 2Bytes</param>
+        /// <param name="Scale">压缩比例 / Compression ratio</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetGrayData16Bit(IntPtr DataObj, int head, IntPtr Profile, double Scale);
+
+        /// <summary>
+        /// 高速回调获取编码器数据 / High-speed callback get encoder data
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="pEncoder">接收数据指针 / Receive data pointer</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetHighSpeedEncoderContiune(IntPtr DataObj, int[] pEncoder);
+
+        /// <summary>
+        /// 获取库版本号 / Get library version number
+        /// </summary>
+        /// <returns>
+        ///     返回版本信息 / Returns version information
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetVersion();
+
+        /// <summary>
+        /// 获取相机型号 / Get camera model
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetModels(int lDeviceId);
+
+        /// <summary>
+        /// 获取相机头序列号 / Get camera head serial number
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="Head">0:相机头A 1:相机头B / 0: camera head A 1: camera head B</param>
+        /// <returns>
+        ///     成功:返回相机头序列号,失败:相机头不存在或参数错误 / Success: returns camera head serial number, failure: camera head does not exist or parameter error
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetHeaderSerial(int lDeviceId, int Head);
+
+        /// <summary>
+        /// 获取传感头B是否在线 / Get whether sensor head B is online
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <returns>
+        ///     0:在线; 小于0:不在线 / 0: online; less than 0: offline
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetOnlineCameraB(int lDeviceId);
+
+        /// <summary>
+        /// 切换相机配置的参数 / Switch camera configuration parameters
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="No">任务参数列表编号 0 - 63 / Task parameter list number 0 - 63</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_SwitchProgram(int lDeviceId, int No);
+
+        /// <summary>
+        /// 设置输出端口电平 / Set output port level
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="Port">输出端口号,范围为0-7 / Output port number, ranging from 0 to 7</param>
+        /// <param name="Level">输出电平值 / Output level value</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_SetOutputPortLevel(uint lDeviceId, uint Port, bool Level);
+
+        /// <summary>
+        /// 读取输入端口电平 / Read input port level
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="Port">输入端口号,范围为0-7 / Input port number, ranging from 0 to 7</param>
+        /// <param name="Level">读取输入电平 / Read input level</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetInputPortLevel(uint lDeviceId, uint Port, IntPtr Level);
+
+        /// <summary>
+        /// 参数设定 / Parameter setting
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="Depth">设置的值的级别 / Level of the value to be set</param>
+        /// <param name="Type">设置类型 / Setting type</param>
+        /// <param name="Category">设置种类 / Setting category</param>
+        /// <param name="Item">设置项目 / Setting item</param>
+        /// <param name="Target">根据发送/接收的设定,可能需要进行相应的指定。无需设定时,指定为0 / Depending on the send/receive settings, it may need to be specified accordingly. When no setting is needed, specify as 0</param>
+        /// <param name="pData">设置数据 / Setting data</param>
+        /// <param name="DataSize">设置数据的长度 / Length of setting data</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_SetSetting(uint lDeviceId, int Depth, int Type, int Category, int Item, int[] Target, IntPtr pData, int DataSize);
+
+        /// <summary>
+        /// 参数获取 / Parameter acquisition
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="Type">设置类型 / Setting type</param>
+        /// <param name="Category">设置种类 / Setting category</param>
+        /// <param name="Item">设置项目 / Setting item</param>
+        /// <param name="Target">根据发送/接收的设定,可能需要进行相应的指定。无需设定时,指定为0 / Depending on the send/receive settings, it may need to be specified accordingly. When no setting is needed, specify as 0</param>
+        /// <param name="pData">设置数据 / Setting data</param>
+        /// <param name="DataSize">设置数据的长度 / Length of setting data</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetSetting(uint lDeviceId, int Type, int Category, int Item, int[] Target, IntPtr pData, int DataSize);
+
+        /// <summary>
+        /// 获取当前一条轮廓(非批处理下) / Get current single profile (not in batch mode)
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="pProfileData">返回轮廓的指针 / Pointer to return profile</param>
+        /// <param name="pEncoder">返回编码器的指针 / Pointer to return encoder</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetSingleProfile(uint lDeviceId, [Out] int[] pProfileData, [Out] uint[] pEncoder);
+		///
+		/// \brief SR7IF_GetSingleProfile3DMode     获取一条轮廓数据(非批处理下 3D模式)
+		/// \param lDeviceId                        设备ID号,范围为0-63.
+		/// \param pProfileData                     返回轮廓的指针.
+		/// \return
+		///     <0:                                 失败.
+		///     =0:                                 成功.
+		///
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetSingleProfile3DMode(uint lDeviceId, [Out] int[] pProfileData);
+
+        /// <summary>
+        /// 将导出的参数导入到系统中 / Import exported parameters into the system
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="pSettingdata">导入参数表指针 / Pointer to import parameter table</param>
+        /// <param name="size">导入参数表的大小 / Size of import parameter table</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_LoadParameters(uint lDeviceId, IntPtr pSettingdata, UInt32 size);
+
+        /// <summary>
+        /// 返回产品剩余天数 / Return product remaining days
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号 / Device ID number</param>
+        /// <param name="RemainDay">返回剩余天数 / Returns remaining days</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_GetLicenseKey(uint lDeviceId, IntPtr RemainDay);
+
+        /// <summary>
+        /// 将系统参数导出,注意只导出当前任务的参数 / Export system parameters, note that only the parameters of the current task are exported
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="size">返回参数表的大小 / Returns the size of the parameter table</param>
+        /// <returns>
+        ///     NULL:失败. 其他:成功 / NULL: failure. Others: success
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_ExportParameters(int lDeviceId, IntPtr size);
+
+        /// <summary>
+        /// 3D显示 / 3D display
+        /// </summary>
+        /// <param name="_BatchData">批处理数据 / Batch data</param>
+        /// <param name="x_true_step">x方向间矩/mm / x-direction spacing/mm</param>
+        /// <param name="y_true_step">y方向间距/mm / y-direction spacing/mm</param>
+        /// <param name="x_Point_num">x方向数据个数 / Number of data points in x direction</param>
+        /// <param name="y_batchPoint_num">批处理行数 / Number of batch lines</param>
+        /// <param name="z_scale">z方向缩放系数 / z-direction scaling factor</param>
+        /// <param name="Ho">z方向最大值 / Maximum value in z direction</param>
+        /// <param name="Lo">z方向最小值 / Minimum value in z direction</param>
+        [DllImport("SR3dexe.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern void SR_3D_EXE_Show(IntPtr _BatchData,
+                                double x_true_step,
+                                double y_true_step,
+                                int x_Point_num,
+                                int y_batchPoint_num,
+                                double z_scale,
+                                double Ho,
+                                double Lo
+                                );
+
+        /// <summary>
+        /// 设置回调函数,建议获取数据后另外开启线程进行处理(批处理一次回调一次) / Set callback function, it is recommended to open another thread for processing after obtaining data (one callback per batch)
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="size">回调函数 / Callback function</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_SetBatchOneTimeDataHandler(int lDeviceId, SR7IF_BatchOneTimeCallBack CallFunc);
+
+        /// <summary>
+        /// 开始批处理 (批处理一次回调一次) / Start batch processing (one callback per batch)
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="ImmediateBatch">0:立即开始批处理 1:等待外部开始批处理 / 0: start batch immediately 1: wait for external start batch</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_StartMeasureWithCallback(int lDeviceId, int ImmediateBatch);
+
+        /// <summary>
+        /// 批处理软件触发开始(批处理一次回调一次) / Batch software trigger start (one callback per batch)
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <returns>
+        ///     0:成功; 小于0:失败 / 0: success; less than 0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_TriggerOneBatch(int lDeviceId);
+
+        /// <summary>
+        /// 批处理轮廓获取(批处理一次回调一次) / Batch profile acquisition (one callback per batch)
+        /// </summary>
+        /// <param name="DataObj">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="Head">0:相机头A 1:相机头B / 0: camera head A 1: camera head B</param>
+        /// <returns>
+        ///     返回数据指针 null:无数据或相应头不存在 / Returns data pointer null: no data or corresponding head does not exist
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetBatchProfilePoint(IntPtr DataObj, int Head);
+
+        /// <summary>
+        /// 批处理亮度获取(批处理一次回调一次) / Batch intensity acquisition (one callback per batch)
+        /// </summary>
+        /// <param name="DataObj">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="Head">0:相机头A 1:相机头B / 0: camera head A 1: camera head B</param>
+        /// <returns>
+        ///     返回数据指针 null:无数据或相应头不存在 / Returns data pointer null: no data or corresponding head does not exist
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetBatchIntensityPoint(IntPtr DataObj, int Head);
+
+        /// <summary>
+        /// 批处理编码器获取(批处理一次回调一次) / Batch encoder acquisition (one callback per batch)
+        /// </summary>
+        /// <param name="DataObj">设备ID号,范围为0-3 / Device ID number, ranging from 0 to 3</param>
+        /// <param name="Head">0:相机头A 1:相机头B / 0: camera head A 1: camera head B</param>
+        /// <returns>
+        ///     返回数据指针 null:无数据或相应头不存在 / Returns data pointer null: no data or corresponding head does not exist
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetBatchEncoderPoint(IntPtr DataObj, int Head);
+
+        /// <summary>
+        /// 查找在线设备 / Search for online devices
+        /// </summary>
+        /// <param name="ReadNum">搜索到的设备个数 / Number of devices found</param>
+        /// <param name="timeOut">搜索超时时间 / Search timeout</param>
+        /// <returns>
+        ///     返回已搜索到的设备的 IP 地址指针 / Returns the IP address pointer of the found devices
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_SearchOnline(IntPtr ReadNum, int timeOut);
+
+        /// <summary>
+        /// 异步回调连接函数 / Asynchronous callback connection function
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="pEthernetConfig">Ethernet 通信设定 / Ethernet communication settings</param>
+        /// <param name="timeOut">搜索时间(ms),最小值100 / Search time (ms), minimum 100</param>
+        /// <param name="fun">掉线回调函数 / Disconnection callback function</param>
+        /// <returns>
+        ///     &lt;0: 失败 / Fail
+        ///     =0: 成功 / Success
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_AsyncEthernetOpen(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig, int timeOut = 2000, SR7IF_AsyncErrCallBack errCallBackFunc = null);
+
+        /// <summary>
+        /// 初始化异步回调数据通信 / Initialize asynchronous callback data communication
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="pCallBack">回调函数 / Callback function</param>
+        /// <param name="pUserData">用户注册传入指针 / Pointer passed by user registration</param>
+        /// <param name="ProfileBits">0:返回32位高度数据。1:返回16位高度数据 / 0: return 32-bit height data. 1: return 16-bit height data</param>
+        /// <param name="mMaxLine">指定行数返回数据 / Specify the number of lines to return data</param>
+        /// <returns>
+        ///     &lt;0: 失败 / Fail
+        ///     =0: 成功 / Success
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_AsyncCallBackInitalize(int lDeviceId, SR7IF_AsyncCALLBACK pCallBack, IntPtr pUserData, uint ProfileBits = 0, uint mMaxLine = 0xFFFFFFFF);
+
+        /// <summary>
+        /// 异步回调软触发 / Asynchronous callback soft trigger
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <returns>
+        ///     &lt;0: 失败 / Fail
+        ///     =0: 成功 / Success
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_AsyncSoftStartBatch(int lDeviceId);
+
+        /// <summary>
+        /// 异步回调停止批处理 / Asynchronous callback stop batch processing
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <returns>
+        ///     &lt;0: 失败 / Fail
+        ///     =0: 成功 / Success
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_AsyncSoftStopBatch(int lDeviceId);
+
+        /// <summary>
+        /// 异步回调获取16位高度数据 / Asynchronous callback get 16-bit height data
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
+        /// <returns>
+        ///     数据指针 / Data pointer
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetAsyncProfilePointData16Bit(IntPtr DataObj, int Head);
+
+        /// <summary>
+        /// 异步回调获取32位高度数据 / Asynchronous callback get 32-bit height data
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
+        /// <returns>
+        ///     数据指针 / Data pointer
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetAsyncProfilePointData(IntPtr DataObj, int Head);
+
+        /// <summary>
+        /// 异步回调获取灰度数据 / Asynchronous callback get grayscale data
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
+        /// <returns>
+        ///     数据指针 / Data pointer
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetAsyncIntensityContiuneData(IntPtr DataObj, int Head);
+
+        /// <summary>
+        /// 异步回调获取编码器数据 / Asynchronous callback get encoder data
+        /// </summary>
+        /// <param name="DataObj">回调数据指针 / Callback data pointer</param>
+        /// <param name="head">0:相机A 1:相机B / 0: camera A 1: camera B</param>
+        /// <returns>
+        ///     数据指针 / Data pointer
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern IntPtr SR7IF_GetAsyncEncoderContiune(IntPtr DataObj, int Head);
+
+        /// <summary>
+        /// 获取16bit高度数据物理单位 / Get 16bit height data physical unit
+        /// </summary>
+        /// <param name="lDeviceId">设备ID号,范围为0-63 / Device ID number, ranging from 0 to 63</param>
+        /// <param name="Scale">单位(mm) / Unit (mm)</param>
+        /// <returns>
+        ///     0:成功,&lt;0: 失败 / 0: success, &lt;0: failure
+        /// </returns>
+        [DllImport("SR7Link.dll", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern int SR7IF_Get16BitScale(int lDeviceId, IntPtr Scale);
+
+        internal static int SR7IF_CommClose(uint controllerID)
+        {
+            throw new NotImplementedException();
+        }
+    }
+    #endregion
+
+}

+ 221 - 0
TeamAAS-VM/Core/Cameras/sr7apiclass/SRSettingHeader.h

@@ -0,0 +1,221 @@
+#pragma once
+namespace SR7API
+{
+	// SetSetting GetSetting
+	enum SAVEPOWEROFF
+	{
+		ESAPO_NOSAVE = 1, // 1 掉电不保存 / No save after power off
+		ESAPO_SAVE   // 2 掉电保存 / Save after power off
+	};
+
+	enum SR7IF_SETTING_ITEM
+	{
+		TRIG_MODE = 1,    // 触发模式 / Trigger mode
+		SAMPLED_CYCLE,    // 采样周期 / Sampling cycle
+		BATCH_ON_OFF,     // 批处理开关 / Batch processing switch
+		ENCODER_TYPE,     // 编码器类型 / Encoder type
+
+		REFINING_POINTS,  // 细化点数 / Refining points
+		BATCH_POINT,      // 批处理点数 / Batch processing points
+
+		CYCLICAL_PATTERN, // 循环模式 0 关闭 1 打开 / Cyclical pattern (0: Off, 1: On)
+		BATCH_OUTPUT,     // 批处理输出 / Batch processing output
+		Z_MEASURING_RANGE,// Z 方向测量范围 / Z-axis measuring range
+
+		SENSITIVITY,      // 感光灵敏度 / Sensitivity
+		EXP_TIME,         // 曝光时间 / Exposure time
+		LIGHT_CONTROL,    // 光亮控制 / Light control
+		LIGHT_MAX,        // 激光亮度上限 / Laser brightness upper limit
+		LIGHT_MIN,        // 激光亮度下限 / Laser brightness lower limit
+		PEAK_SENSITIVITY, // 峰值灵敏度 / Peak sensitivity
+		PEAK_SELECT,      // 峰值选择 / Peak selection
+
+		X_SAMPLING,       // X 轴压缩设定 / X-axis compression setting
+
+		FILTER_X_MEDIAN,  // X 轴中位数滤波 / X-axis median filter
+		FILTER_X_SMOOTH,  // X 轴平滑滤波 / X-axis smooth filter
+		FILTER_Y_MEDIAN,  // Y 轴(时间轴)中位数滤波 / Y-axis (time axis) median filter
+		FILTER_Y_SMOOTH,  // Y 轴平滑滤波(平均滤波) / Y-axis smooth filter (mean filter)
+
+		CHANGE_3D_25D,    // 3D/2.5D 切换 2.5 模式下 X 轴压缩设定为自动变更默认值 / 3D/2.5D switch (In 2.5D mode, X-axis compression setting changes to default automatically)
+
+		X_PIXEL,          // X 数据宽度(单位像素) / X data width (unit: pixels)
+		X_PITCH           // X Resolution / X-axis resolution
+	};
+
+	// 触发模式 / Trigger mode
+	enum SR7IF_TRIG_MODE
+	{
+		TM_CONTINUE = 0, // Continuous trigger
+		EXT_TRIGGER,     // External trigger
+		ENCODER,         // Encoder trigger
+	};
+
+	// 采集周期 / Sampling cycle
+	// 100 200 400 600 1000 1500 2000 2500
+
+	// 批处理开关 / Batch processing switch
+	enum SR7IF_BATCH_ON_OFF
+	{
+		OFF = 0, // Off
+		ON       // On
+	};
+
+	// 编码器类型 / Encoder type
+	enum SR7IF_ENCODER_TYPE
+	{
+		E_1_1 = 0, // 0:1 相 1 递增 / 1 phase, 1 increment
+		E_2_1,     // 1:2 相 1 递增 / 2 phase, 1 increment
+		E_2_2,     // 2:2 相 2 递增 / 2 phase, 2 increments
+		E_2_4      // 3:2 相 4 递增 / 2 phase, 4 increments
+	};
+
+	// 细化点数 1 --
+	// 批处理点数 1 --
+
+	// 循环模式 0 关闭 1 打开 / Cyclical pattern (0: Off, 1: On)
+	enum SR7IF_CYCLICAL_PATTERN
+	{
+		CLOSE = 0, // Off
+		OPEN       // On
+	};
+
+	// Z 方向测量范围 注:只支持 SR8020/SR8060 / Z-axis measuring range (Note: Only supports SR8020/SR8060)
+	enum SR7IF_Z_MEASURING_RANGE
+	{
+		Z840 = 0,
+		Z768,
+		Z512,
+		Z384,
+		Z256,
+		Z192,
+		Z128,
+		Z96,
+		Z64,
+		Z48,
+		Z32
+	};
+
+	// 感光灵敏度 / Sensitivity
+	enum SR7IF_SENSITIVITY
+	{
+		HIGH = 0,      // High
+		HIGH_RANGE_1,  // High range 1
+		HIGH_RANGE_2,  // High range 2
+		HIGH_RANGE_3,  // High range 3
+		HIGH_RANGE_4,  // High range 4
+		CUSTOMIZATION  // Custom
+	};
+
+	// 曝光时间 / Exposure time
+	enum SR7IF_EXP_TIME
+	{
+		T10US = 0, // 10µs
+		T15US,     // 15µs
+		T30US,     // 30µs
+		T60US,     // 60µs
+		T120US,    // 120µs
+		T240US,    // 240µs
+		T480US,    // 480µs
+		T960US,    // 960µs
+		T1920US,   // 1920µs
+		T2400US,   // 2400µs
+		T4900US,   // 4900µs
+		T9800US    // 9800µs
+	};
+
+	// 光亮控制 / Light control
+	enum SR7IF_LIGHT_CONTROL
+	{
+		AUTO = 0, // Auto
+		MAN       // Manual
+	};
+
+	// 激光亮度上限 0-99 / Laser brightness upper limit 0-99
+	// 激光亮度下限 0-99 / Laser brightness lower limit 0-99
+
+	// 峰值灵敏度 / Peak sensitivity
+	enum SR7IF_PEAK_SENSITIVITY
+	{
+		N_1 = 1,
+		N_2,
+		N_3,
+		N_4,
+		N_5
+	};
+
+	// 峰值选择 / Peak selection
+	enum SR7IF_PEAK_SELECT
+	{
+		PS_STANDARD = 0, // Standard
+		PS_SRNEAR,       // SR Near
+		PS_SRFAR,        // SR Far
+		PS_BE_NULL,      // Be Null
+		PS_CONTINUE,     // Continue
+		PS_GLUE          // Glue
+	};
+
+	// X 轴压缩设定 注:2.5D 模式下不能设置 / X-axis compression setting (Note: Not configurable in 2.5D mode)
+	enum SR7IF_X_SAMPLING
+	{
+		XS_OFF = 1,  // Off
+		XS_X2 = 2,   // X2
+		XS_X4 = 4,   // X4
+		XS_X8 = 8,   // X8
+		XS_X16 = 16  // X16
+	};
+
+	// X 轴中位数滤波 / X-axis median filter
+	enum SR7IF_FILTER_X_MEDIAN
+	{
+		XM_OFF = 1,
+		XM_N3 = 3,
+		XM_N5 = 5,
+		XM_N7 = 7,
+		XM_N9 = 9
+	};
+
+	// Y 轴中位数滤波 / Y-axis median filter
+	enum SR7IF_FILTER_Y_MEDIAN
+	{
+		YM_OFF = 1,
+		YM_N3 = 3,
+		YM_N5 = 5,
+		YM_N7 = 7,
+		YM_N9 = 9
+	};
+
+	// X 轴平滑滤波 / X-axis smooth filter
+	enum SR7IF_FILTER_X_SMOOTH
+	{
+		N1 = 1,
+		N2 = 2,
+		N4 = 4,
+		N8 = 8,
+		N16 = 16,
+		N32 = 32,
+		N64 = 64
+	};
+
+	// Y 轴平滑滤波 / Y-axis smooth filter
+	enum SR7IF_FILTER_Y_SMOOTH
+	{
+		YS_N1 = 1,
+		YS_N2 = 2,
+		YS_N4 = 4,
+		YS_N8 = 8,
+		YS_N16 = 16,
+		YS_N32 = 32,
+		YS_N64 = 64,
+		YS_N128 = 128,
+		YS_N256 = 256
+	};
+
+	// 3D/2.5D 切换 / 3D/2.5D switch
+	enum SR7IF_CHANGE_3D_25D
+	{
+		T3D = 0,  // 3D mode
+		T25D = 1  // 2.5D mode
+	};
+
+}

+ 8 - 1
TeamAAS-VM/Enums/CameraBrand.cs

@@ -57,6 +57,13 @@ namespace TeamAAS_VP.Enums
         /// </summary>
         [Description("奥普特(OPT Camera Viewer)")]
         [Localization(ResourceName = "CameraBrand_opt", ResourceType = typeof(Lang))]
-        Opt =5
+        Opt =5,
+
+        /// <summary>
+        /// 深视3D
+        /// </summary>
+        [Description("深视3D")]
+        [Localization(ResourceName = "CameraBrand_SSZN", ResourceType = typeof(Lang))]
+        SSZN = 6
     }
 }

+ 9 - 0
TeamAAS-VM/Resources/Languages/Lang.Designer.cs

@@ -132,6 +132,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 深视3D 的本地化字符串。
+        /// </summary>
+        public static string CameraBrand_SSZN {
+            get {
+                return ResourceManager.GetString("CameraBrand_SSZN", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 固定向下 的本地化字符串。
         /// </summary>

+ 3 - 0
TeamAAS-VM/Resources/Languages/Lang.resx

@@ -2120,4 +2120,7 @@
   <data name="相机焦距评价" xml:space="preserve">
     <value>相机焦距评价</value>
   </data>
+  <data name="CameraBrand_SSZN" xml:space="preserve">
+    <value>深视3D</value>
+  </data>
 </root>

BIN
TeamAAS-VM/Resources/SR7Link.dll


BIN
TeamAAS-VM/Resources/SSZNCognexParser.dll


BIN
TeamAAS-VM/Resources/SShow3DImage.dll


+ 4 - 0
TeamAAS-VM/Services/CameraService.cs

@@ -454,6 +454,10 @@ namespace TeamAAS_VP.Services
             {
                 camera = new OptCamera(id, cameraInfo.CameraNo, cameraInfo.CameraName, cameraInfo.SerialNumber, cameraInfo.CameraIp, cameraInfo.IsFindByIp);
             }
+            else if (cameraInfo.CameraBrand == Enums.CameraBrand.SSZN)
+            {
+                camera = new SSZNCamera(id, cameraInfo.CameraNo, cameraInfo.CameraName, cameraInfo.SerialNumber, cameraInfo.CameraIp, cameraInfo.IsFindByIp);
+            }
             else
             {
                 camera = new MvCamera(id, cameraInfo.CameraNo, cameraInfo.CameraName, cameraInfo.SerialNumber, cameraInfo.CameraIp, cameraInfo.IsFindByIp);

+ 18 - 0
TeamAAS-VM/TeamAAS-VP.csproj

@@ -336,6 +336,10 @@
     <Reference Include="SqlSugar, Version=5.1.4.207, Culture=neutral, processorArchitecture=MSIL">
       <HintPath>..\packages\SqlSugar.5.1.4.207\lib\SqlSugar.dll</HintPath>
     </Reference>
+    <Reference Include="SSZNCognexParser, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>Resources\SSZNCognexParser.dll</HintPath>
+    </Reference>
     <Reference Include="System.Buffers, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
     </Reference>
@@ -526,6 +530,16 @@
     <Compile Include="Controls\FeederSystemParam.xaml.cs">
       <DependentUpon>FeederSystemParam.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Core\Cameras\simagepro.cs" />
+    <Compile Include="Core\Cameras\sr7apiclass\ISR7Api.cs" />
+    <Compile Include="Core\Cameras\sr7apiclass\SR7ApiBase.cs" />
+    <Compile Include="Core\Cameras\sr7apiclass\SR7ApiInfiniteLoopCallbackImpl.cs" />
+    <Compile Include="Core\Cameras\sr7apiclass\SR7ApiOneTimeCallbackImpl.cs" />
+    <Compile Include="Core\Cameras\sr7apiclass\SR7ApiSyncCallbackImpl.cs" />
+    <Compile Include="Core\Cameras\sr7apiclass\SR7LinkEnum.cs" />
+    <Compile Include="Core\Cameras\sr7apiclass\SR7LinkFunc.cs" />
+    <Compile Include="Core\Cameras\SRCSharpTools.cs" />
+    <Compile Include="Core\Cameras\SSZNCamera.cs" />
     <Compile Include="Events\MainTabSwitchNotification.cs" />
     <Compile Include="Models\Feeder\ScrewFeederInfo.cs" />
     <Compile Include="Models\ScrewFeederBatchRecord.cs" />
@@ -1542,8 +1556,12 @@
     <Resource Include="Resources\Images\SaveAs.png" />
   </ItemGroup>
   <ItemGroup>
+    <Content Include="Core\Cameras\sr7apiclass\SRSettingHeader.h" />
     <Content Include="Resources\ddraw.dll" />
     <Content Include="Resources\SciCamera.Net.dll" />
+    <Content Include="Resources\SR7Link.dll" />
+    <Content Include="Resources\SShow3DImage.dll" />
+    <Content Include="Resources\SSZNCognexParser.dll" />
     <Resource Include="Resources\Images\MobileDown.png" />
     <Content Include="Resources\GxIAPINET.dll" />
     <Resource Include="Resources\Images\Feeder-反向.png" />

+ 8 - 0
TeamAAS-VM/ViewModels/SettingViewModel.cs

@@ -581,6 +581,10 @@ namespace TeamAAS_VP.ViewModels
                     softwarename = "OPT Camera Viewer";
                     result = OptCamera.CheckSoftwareInstalled();
                     break;
+                case CameraBrand.SSZN:
+                    softwarename = "OPT Camera Viewer";
+                    result = SSZNCamera.CheckSoftwareInstalled();
+                    break;
                 default:
                     break;
             }
@@ -683,6 +687,10 @@ namespace TeamAAS_VP.ViewModels
                     softwarename = "OPT Camera Viewer";
                     result = OptCamera.CheckSoftwareInstalled();
                     break;
+                case CameraBrand.SSZN:
+                    softwarename = "OPT Camera Viewer";
+                    result = SSZNCamera.CheckSoftwareInstalled();
+                    break;
                 default:
                     break;
             }