using BaseFunction;
using BR.AN.PviServices;
using CT_Motion_WinForm;
using HPC.Hamamatsu.MFX;
using iDetector;
using IndustrialCT.BaseUnit;
using IndustrialCT.ScanMode;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Threading;
using XLibWrapper;
using HxGNSecurity;
using System.Data;
using System.Windows.Input;

namespace IndustrialCT.Define
{
    public class InitParams
    {
        public static string configFilePath = Application.StartupPath + "\\File\\IndustrialCTConfig.ini";
        /// <summary>
        ///全局变量初始化函数
        /// </summary>
        public static void initParams()
        {
            // 读取配置文件
            CTDefine.PCLanguage = FileIni.ReadInt(configFilePath, "IndustrialCT", "Language");
            CTDefine.iAxisDirection = FileIni.ReadInt(configFilePath, "IndustrialCT", "AxisDirection");
            CTDefine.isUpload = FileIni.ReadBool(configFilePath, "IndustrialCT", "isUpload");
            CTDefine.bLicenseFlag = FileIni.ReadBool(configFilePath, "IndustrialCT", "License");
            CTDefine.ExhibitionFlag = FileIni.ReadInt(configFilePath, "IndustrialCT", "ExhibitionFlag");
            CTDefine.Xray1 = FileIni.ReadString(configFilePath, "XRay", "Xray1");
            CTDefine.Xray2 = FileIni.ReadString(configFilePath, "XRay", "Xray2");
            CTDefine.AreaDet = FileIni.ReadString(configFilePath, "Detector", "AreaDet");
            CTDefine.LineDet = FileIni.ReadString(configFilePath, "Detector", "LineDet");

            detectorInit();
            CTDefine.monitorLight = FileIni.ReadInt(configFilePath, "IndustrialCT", "monitorLight");
            CTDefine.isMultiAxis = FileIni.ReadInt(configFilePath, "IndustrialCT", "isMultiAxis");
            CTDefine.functionMode = FileIni.ReadInt(configFilePath, "IndustrialCT", "FunctionMode");
            CTDefine.password = HxGNSec.DecryptString(FileIni.ReadString(configFilePath, "IndustrialCT", "Pwd"));
            CTDefine.DC800 = FileIni.ReadBool(configFilePath, "Hardware", "DCMotion");
            CTDefine.isSaveParams = FileIni.ReadBool(configFilePath, "IndustrialCT", "isSaveParams");
            CTDefine.useXrayTime = FileIni.ReadDouble(configFilePath, "XRay", "useTimes") * 60;
            CTDefine.dFilamentTargetTime = FileIni.ReadDouble(configFilePath, "XRay", "FilamentTargetTime") * 60;
            CTDefine.dFilamentUseTime = FileIni.ReadDouble(configFilePath, "XRay", "FilamentUseTime");
            CTDefine.softwareMode = FileIni.ReadInt(configFilePath, "IndustrialCT", "mode");//0是单源单探，1是双源双探
            CTDefine.detType = FileIni.ReadInt(configFilePath, "Detector", "DetType");//0是IRay，1是Varex
            CTDefine.HProtate = FileIni.ReadInt(configFilePath, "Hardware", "HProtate");
            CTDefine.valuebinPath = Path.Combine(Application.StartupPath, "XploreInsight.bin");
            // 解密并从文件中读取
            //double[] decryptedValues = Encryption.DecryptFromFile(CTDefine.valuebinPath);

            XRayDfnComet225.xrayAdvancedSetPath = FileIni.ReadString(configFilePath, "XRay", "xrayAdvancedSetPath");
            XRayDfnComet225.isStartVacon = FileIni.ReadBool(configFilePath, "XRay", "isStartVacon");


            DetectorDfnArea.IrayDetectorPath = Path.Combine(Application.StartupPath, FileIni.ReadString(configFilePath, "Detector", "IrayDetectorPath"));
            DetectorDfnArea.iDetectorPath = FileIni.ReadString(configFilePath, "Detector", "iDetectorPath");
            DetectorDfnArea.varexBadPath1 = FileIni.ReadString(configFilePath, "Detector", "BadPixel1");
            DetectorDfnArea.varexBadPath2 = FileIni.ReadString(configFilePath, "Detector", "BadPixel2");
            DetectorDfnArea.varexBadPath3 = FileIni.ReadString(configFilePath, "Detector", "BadPixel3");
            DetectorDfnArea.varexBadPath4 = FileIni.ReadString(configFilePath, "Detector", "BadPixel4");
            CTDefine.iDetExternalTrigger = FileIni.ReadInt(configFilePath, "Detector", "ExternalTrigger");
            //MotionDfn.strConfigFile = Path.Combine(Application.StartupPath, FileIni.ReadString(configFilePath, "MotionControl", "strConfigFile"));
            PlcDfn450.plcIP = FileIni.ReadString(configFilePath, "TCP", "PLC_IP");
            PlcDfn.plcIP = FileIni.ReadString(configFilePath, "TCP", "PLC_IP");
            PlcDfn130.plcIP = FileIni.ReadString(configFilePath, "TCP", "PLC_IP");
            ReconDfn.reconPath = FileIni.ReadString(configFilePath, "Reconstruction", "reconPath");
            ReconDfn.transPath = Path.Combine(ReconDfn.reconPath, "HexagonCTData");

            CorrectParams.laser = FileIni.ReadInt(configFilePath, "Hardware", "Laser");

            CorrectParams.compensate = FileIni.ReadInt(configFilePath, "CorrectParams", "compensate");
            CorrectParams.compensateFDD = FileIni.ReadInt(configFilePath, "CorrectParams", "compensateFDD");
            CorrectParams.mappingYcenter = FileIni.ReadInt(configFilePath, "CorrectParams", "mappingYcenter");
            CorrectParams.mappingDetYcenter = FileIni.ReadInt(configFilePath, "CorrectParams", "mappingDetYcenter");
            //CorrectParams.Ycenter = decryptedValues[0];
            //CorrectParams.SDD = decryptedValues[1];
            //CorrectParams.k = decryptedValues[2];
            //CorrectParams.b = decryptedValues[3];
            //CorrectParams.kFDD = decryptedValues[4];
            //CorrectParams.bFDD = decryptedValues[5];


            CorrectParams.SDD = FileIni.ReadDouble(configFilePath, "CorrectParams", "FDD");
            CorrectParams.k = FileIni.ReadDouble(configFilePath, "CorrectParams", "kx ");
            CorrectParams.b = FileIni.ReadDouble(configFilePath, "CorrectParams", "kb");
            CorrectParams.kFDD = FileIni.ReadDouble(configFilePath, "CorrectParams", "kFDDx");
            CorrectParams.bFDD = FileIni.ReadDouble(configFilePath, "CorrectParams", "kFDDb");
            CorrectParams.Ycenter = FileIni.ReadDouble(configFilePath, "CorrectParams", "Ycenter");
            CorrectParams.DetYcenter = FileIni.ReadDouble(configFilePath, "CorrectParams", "DetYcenter");


            Encryption.WriteCorrectParamsInit();
            CorrectParams.detector_horizontal_offset = FileIni.ReadDouble(configFilePath, "CorrectParams", "Detector_Horizontal_Offset");
            CorrectParams.detector_rotation_offset = FileIni.ReadDouble(configFilePath, "CorrectParams", "Detector_Rotation_Offset");

            string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            XRayDfnComet225.XrayCsvPath = Path.Combine(Application.StartupPath, "XrayStaticTime.csv");

            HardWareDfn.camera1IP = FileIni.ReadString(configFilePath, "Camera", "camera1IP");
            HardWareDfn.camera2IP = FileIni.ReadString(configFilePath, "Camera", "camera2IP");
            HardWareDfn.cameraUser = FileIni.ReadString(configFilePath, "Camera", "cameraUser");
            HardWareDfn.cameraPwd = FileIni.ReadString(configFilePath, "Camera", "cameraPwd");
            HardWareDfn.reconIP = FileIni.ReadString(configFilePath, "Reconstruction", "reconIP");
            HardWareDfn.reconSocket = FileIni.ReadString(configFilePath, "Reconstruction", "reconComputerIP");
            HardWareDfn.comet225IP = FileIni.ReadString(configFilePath, "XRay", "Comet225IP");
        }
        public static void initParamsFromDBTable()
        {
            // 读取配置文件
            CTDefine.PCLanguage = int.Parse(DBTables.dtCTConfig.Rows[0]["Language"].ToString());
            CTDefine.bLicenseFlag = DBTables.dtCTConfig.Rows[0]["LicenseFlag"].ToString() == "0" ? false : true;
            CTDefine.isMultiAxis = int.Parse(DBTables.dtCTConfig.Rows[0]["MultiAxisFlag"].ToString());
            CTDefine.monitorLight = int.Parse(DBTables.dtCTConfig.Rows[0]["MonitorLightFlag"].ToString());
            CTDefine.softwareMode = int.Parse(DBTables.dtCTConfig.Rows[0]["SoftwareMode"].ToString());
            CTDefine.functionMode = int.Parse(DBTables.dtCTConfig.Rows[0]["FunctionMode"].ToString());
            CTDefine.iAxisDirection = int.Parse(DBTables.dtCTConfig.Rows[0]["AxisDirection"].ToString());
            CTDefine.ExhibitionFlag = int.Parse(DBTables.dtCTConfig.Rows[0]["ExhibitionFlag"].ToString());
            CTDefine.password = DBTables.dtCTConfig.Rows[0]["LoginPwd"].ToString();
            HardWareDfn.reconIP = DBTables.dtCTConfig.Rows[0]["ReconPCIP"].ToString();
            HardWareDfn.reconSocket = DBTables.dtCTConfig.Rows[0]["ReconPCIP"].ToString();
            PlcDfn450.plcIP = DBTables.dtCTConfig.Rows[0]["PLCIP"].ToString();
            PlcDfn.plcIP = DBTables.dtCTConfig.Rows[0]["PLCIP"].ToString();
            PlcDfn130.plcIP = DBTables.dtCTConfig.Rows[0]["PLCIP"].ToString();
            ReconDfn.reconPath = DBTables.dtCTConfig.Rows[0]["ReconPCPath"].ToString();
            ReconDfn.transPath = Path.Combine(ReconDfn.reconPath, "HexagonCTData");


            CTDefine.Xray1 = DBTables.dtXrayConfig.Rows[0]["Xray1Name"].ToString();
            CTDefine.Xray2 = DBTables.dtXrayConfig.Rows[0]["Xray2Name"].ToString();
            HardWareDfn.comet225IP = DBTables.dtXrayConfig.Rows[0]["Xray1IP"].ToString();
            CTDefine.useXrayTime = double.Parse(DBTables.dtXrayConfig.Rows[0]["Xray1RunTime"].ToString()) * 60;
            CTDefine.dFilamentTargetTime = double.Parse(DBTables.dtXrayConfig.Rows[0]["Filament1TargetTime"].ToString()) * 60;
            CTDefine.dFilamentUseTime = double.Parse(DBTables.dtXrayConfig.Rows[0]["Filament1UseTime"].ToString());
            XRayDfnComet225.xrayAdvancedSetPath = DBTables.dtXrayConfig.Rows[0]["Xray1EXEPath"].ToString();


            CTDefine.AreaDet = DBTables.dtDetConfig.Rows[0]["AreaDetName"].ToString();
            CTDefine.LineDet = DBTables.dtDetConfig.Rows[0]["LineDetName"].ToString();

            DetectorDfnArea.IrayDetectorPath = Path.Combine(Application.StartupPath, DBTables.dtDetConfig.Rows[0]["IRayDetWorkPath"].ToString());
            DetectorDfnArea.iDetectorPath = DBTables.dtDetConfig.Rows[0]["IRayDetEXEPath"].ToString();
            DetectorDfnArea.varexBadPath1 = DBTables.dtDetConfig.Rows[0]["VarexBadPixel1"].ToString();
            DetectorDfnArea.varexBadPath2 = DBTables.dtDetConfig.Rows[0]["VarexBadPixel2"].ToString();
            DetectorDfnArea.varexBadPath3 = DBTables.dtDetConfig.Rows[0]["VarexBadPixel3"].ToString();
            DetectorDfnArea.varexBadPath4 = DBTables.dtDetConfig.Rows[0]["VarexBadPixel4"].ToString();
            CTDefine.iDetExternalTrigger = int.Parse(DBTables.dtDetConfig.Rows[0]["ExternalTrigger"].ToString());
            CTDefine.detType = int.Parse(DBTables.dtDetConfig.Rows[0]["DetType"].ToString()); //0是IRay，1是Varex
            detectorInit();

            CorrectParams.laser = int.Parse(DBTables.dtCompenConfig.Rows[0]["LaserCompenFlag"].ToString()); 
            CorrectParams.compensate = int.Parse(DBTables.dtCompenConfig.Rows[0]["FODCompenFlag"].ToString()); 
            CorrectParams.compensateFDD = int.Parse(DBTables.dtCompenConfig.Rows[0]["FDDCompenFlag"].ToString()); 
            CorrectParams.mappingYcenter = int.Parse(DBTables.dtCompenConfig.Rows[0]["ObjYCenterCompenFlag"].ToString()); 
            CorrectParams.mappingDetYcenter = int.Parse(DBTables.dtCompenConfig.Rows[0]["DetYCenterCompenFlag"].ToString()); 
            CorrectParams.SDD = double.Parse(DBTables.dtCompenConfig.Rows[0]["FDD"].ToString()); 
            CorrectParams.detector_horizontal_offset = double.Parse(DBTables.dtCompenConfig.Rows[0]["DetHorizontalOffset"].ToString()); 
            CorrectParams.detector_rotation_offset = double.Parse(DBTables.dtCompenConfig.Rows[0]["DetRotationOffset"].ToString()); 

            CorrectParams.k = double.Parse(DBTables.dtCompenData.Rows[0]["FODkFactor"].ToString()); 
            CorrectParams.b = double.Parse(DBTables.dtCompenData.Rows[0]["FODbFactor"].ToString()); 
            CorrectParams.kFDD = double.Parse(DBTables.dtCompenData.Rows[0]["FDDkFactor"].ToString()); 
            CorrectParams.bFDD = double.Parse(DBTables.dtCompenData.Rows[0]["FDDAreaDetbFactor"].ToString()); 
            CorrectParams.Ycenter = double.Parse(DBTables.dtCompenData.Rows[0]["ObjYCenter"].ToString()); 
            CorrectParams.DetYcenter = double.Parse(DBTables.dtCompenData.Rows[0]["DetYCenter"].ToString()); 

            HardWareDfn.camera1IP = DBTables.dtCameraConfig.Rows[0]["Camera1IP"].ToString();
            HardWareDfn.camera2IP = DBTables.dtCameraConfig.Rows[0]["Camera2IP"].ToString();
            HardWareDfn.cameraUser = DBTables.dtCameraConfig.Rows[0]["CameraUser"].ToString();
            HardWareDfn.cameraPwd = DBTables.dtCameraConfig.Rows[0]["CameraPwd"].ToString();

            //SuperVolume 1V  Offset 补偿读取
            MotionDfn.dSV1VZOffset = float.Parse(DBTables.dtAxisOffsetConfig.Rows[0]["ZCompOffset"].ToString());
            MotionDfn.iXCompensationPos = double.Parse(DBTables.dtAxisOffsetConfig.Rows[0]["XCompOffset"].ToString());
            MotionDfn.iYCompensationPos = double.Parse(DBTables.dtAxisOffsetConfig.Rows[0]["YCompOffset"].ToString());
            MotionDfn.iDCompensationPos = double.Parse(DBTables.dtAxisOffsetConfig.Rows[0]["DCompOffset"].ToString());
            MotionDfn.strZ1Axes = DBTables.dtAxisOffsetConfig.Rows[0]["Z1AxisName"].ToString();
            MotionDfn.strZ2Axes = DBTables.dtAxisOffsetConfig.Rows[0]["Z2AxisName"].ToString();
            if (DBTables.dtAxisOffsetConfig.Rows[0]["HaveDetYFlag"].ToString()=="1")
            {
                MotionDfn.bHaveDetYFlag = true;
            }
            else
            {
                MotionDfn.bHaveDetYFlag = false;
            }

        }
        public static void detectorInit()
        {
            if (CTDefine.AreaDet == "Varex4343CT")
            {
                varex4343det();
            }
            else if (CTDefine.AreaDet == "IRay1717M")
            {
                DetectorDfnArea.detectorWidth = 0.139 * 3072;
                DetectorDfnArea.detectorHeight = 0.139 * 3072;
                DetectorDfnArea.pixel_distance = 0.139;
                DetectorDfnArea.Image_Width = 3072;
                DetectorDfnArea.Image_Height = 3072;
                ReconDfn.ROIx = 3072;
                ReconDfn.ROIy = 3072;
                ReconDfn.roixMax = 3072;
                ReconDfn.roiyMax = 3072;
                ReconDfn.roizMax = 3072;
                ReconDfn.roizMax1 = 3072;
                DetectorDfnArea.freq1_1 = 6;
                DetectorDfnArea.freq2_2 = 12;
                DetectorDfnArea.freq3_3 = 18;
                DetectorDfnArea.detConfigPath = Path.Combine(Application.StartupPath, "work_dir\\NDT1717M\\DynamicApplicationMode.ini");
                DetectorDfnArea.detConfigPathTime = Path.Combine(Application.StartupPath, "work_dir\\NDT1717M\\config.ini");
            }
            else if (CTDefine.AreaDet == "IRay1717M2")
            {
                DetectorDfnArea.detectorWidth = 0.139 * 3072;
                DetectorDfnArea.detectorHeight = 0.139 * 3060;
                DetectorDfnArea.pixel_distance = 0.139;
                DetectorDfnArea.Image_Width = 3072;
                DetectorDfnArea.Image_Height = 3060;
                ReconDfn.ROIx = 3072;
                ReconDfn.ROIy = 3060;
                ReconDfn.roixMax = 3072;
                ReconDfn.roiyMax = 3072;
                ReconDfn.roizMax = 3060;
                ReconDfn.roizMax1 = 3060;
                DetectorDfnArea.freq1_1 = 15;
                DetectorDfnArea.freq2_2 = 30;
                DetectorDfnArea.freq3_3 = 45;
                DetectorDfnArea.freq4_4 = 60;
                DetectorDfnArea.detConfigPath = Path.Combine(Application.StartupPath, "work_dir\\NDT1717M2\\DynamicApplicationMode.ini");
                DetectorDfnArea.detConfigPathTime = Path.Combine(Application.StartupPath, "work_dir\\NDT1717M2\\config.ini");
            }
            else if (CTDefine.AreaDet == "IRay1717X2")
            {
                DetectorDfnArea.detectorWidth = 0.1 * 4260;
                DetectorDfnArea.detectorHeight = 0.1 * 4260;
                DetectorDfnArea.pixel_distance = 0.1;
                DetectorDfnArea.Image_Width = 4260;
                DetectorDfnArea.Image_Height = 4260;
                ReconDfn.ROIx = 4260;
                ReconDfn.ROIy = 4260;
                ReconDfn.roixMax = 4260;
                ReconDfn.roiyMax = 4260;
                ReconDfn.roizMax = 4260;
                ReconDfn.roizMax1 = 4260;
                DetectorDfnArea.freq1_1 = 10;
                DetectorDfnArea.freq2_2 = 20;
                DetectorDfnArea.freq3_3 = 30;
                DetectorDfnArea.freq4_4 = 40;
                DetectorDfnArea.detConfigPath = Path.Combine(Application.StartupPath, "work_dir\\NDT1717X2\\DynamicApplicationMode.ini");
                DetectorDfnArea.detConfigPathTime = Path.Combine(Application.StartupPath, "work_dir\\NDT1717X2\\config.ini");
            }
            else if (CTDefine.AreaDet == "IRay1012HS")
            {
                DetectorDfnArea.detectorWidth = 0.1 * 3008;
                DetectorDfnArea.detectorHeight = 0.1 * 2496;
                DetectorDfnArea.pixel_distance = 0.1;
                DetectorDfnArea.Image_Width = 3008;
                DetectorDfnArea.Image_Height = 2496;
                ReconDfn.ROIx = 3008;
                ReconDfn.ROIy = 2496;
                ReconDfn.roixMax = 3008;
                ReconDfn.roiyMax = 2496;
                ReconDfn.roizMax = 3008;
                ReconDfn.roizMax1 = 3008;
                DetectorDfnArea.freq1_1 = 30;
                DetectorDfnArea.freq2_2 = 60;
                DetectorDfnArea.detConfigPath = Path.Combine(Application.StartupPath, "work_dir\\NDT1012HS\\DynamicApplicationMode.ini");
                DetectorDfnArea.detConfigPathTime = Path.Combine(Application.StartupPath, "work_dir\\NDT1012HS\\config.ini");
            }
            else if (CTDefine.AreaDet == "Varex4343N")
            {
                varex4343det();
                DetectorDfnArea.freq4_4 = 60;
            }
        }

        private static void varex4343det()
        {
            DetectorDfnArea.detectorWidth = 0.15 * 2880;
            DetectorDfnArea.detectorHeight = 0.15 * 2880;
            DetectorDfnArea.pixel_distance = 0.15;
            DetectorDfnArea.Image_Width = 2880;
            DetectorDfnArea.Image_Height = 2880;
            ReconDfn.ROIx = 2880;
            ReconDfn.ROIy = 2880;
            ReconDfn.roixMax = 2880;
            ReconDfn.roiyMax = 2880;
            ReconDfn.roizMax = 2880;
            ReconDfn.roizMax1 = 2880;
            DetectorDfnArea.freq1_1 = 15;
            DetectorDfnArea.freq2_2 = 30;
            DetectorDfnArea.freq3_3 = 45;
        }
    }

    public class DBTables
    {
        public static DataTable dtCompenConfig = new DataTable();
        public static DataTable dtCompenData = new DataTable();
        public static DataTable dtCTConfig = new DataTable();
        public static DataTable dtXrayConfig = new DataTable();
        public static DataTable dtDetConfig = new DataTable();
        public static DataTable dtCameraConfig = new DataTable();
        public static DataTable dtAlighCenterConfig = new DataTable();

        public static DataTable dtAxisDistanceConfig = new DataTable();
        public static DataTable dtAxisOffsetConfig = new DataTable();
    }

    // 定义扫描模式枚举，覆盖你所有的业务场景
    public enum ScanModeEnum
    {
        // 无模式（默认值，可根据业务调整）
        None,
        // DR模式
        DRMode,
        // 探测器模式
        DetectorMode,
        // 高质量扫描
        HighScan,
        // 快速扫描
        QuickScan,
        // 螺旋扫描
        HelixScan,
        // 螺旋快速扫描
        HelixScanQuick,
        // 扩展快速
        ExtendQuick,
        // 扩展优质
        ExtendQuality,
        // 垂直快速
        VerticalQuick,
        // 垂直优质
        VerticalQuality,
        // 垂直扩展快速
        VerticalExtendQuick,
        // 垂直扩展优质
        VerticalExtendQuality,
        // 水平快速
        HorizontalQuick,
        // 水平优质
        HorizontalQuality,
        // 螺旋扩展扫描
        HelixExtendScan,
        // 螺旋扩展快速扫描
        HelixExtendScanQuick,
        // 线阵DR扫描
        LineDRScan,
        // 线阵螺旋优质扫描
        LineHelixQualityScan,
        // 线阵螺旋快速扫描
        LineHelixQuickScan,
        // 线阵圆周优质扫描
        LineCircleQualityScan,
        // 线阵圆周快速扫描
        LineCircleQuickScan
    }
    //CT定义参数
    public class CTDefine
    {

        // CT机型
        public static string ctModel = "225CT";
        // 连接状态
        public static bool isConnected_xRay225 = false;
        public static bool isConnected_xRay450 = false;
        public static bool isConnected_xRayWorx300 = false;
        public static bool isConnected_xRayViscom225 = false;
        public static bool isConnected_xRayViscom320 = false;
        public static bool isConnected_xRayHama130 = false;
        public static bool isConnected_xRayFineTec300 = false;
        public static bool isConnected_AreaDet = false;
        public static bool isConnected_DTDet = false;
        public static bool isConnected_mc = false;
        public static bool dataSaveThread = true;
        public static float cpuUsage;
        public static bool isUpload = false;
        public static string password = "HMQ";
        public static bool isSaveParams = false;//是否在软件关闭的时候保存当前界面的参数配置
        /// <summary>
        /// 0是单源单探225，1是双源双探BYD，2是双源单探Demo,3=EVE亿纬锂能项目(单源单探);4=SV1V小机器；5=300C（Viscom320）；只要不是0 1 3 4，其他的值都是commonBanner
        /// </summary>
        public static int functionMode = 0;//func的模式选择
        public static int AvgFrameNum = 1;
        public static bool isPlcConnect = false;
 
        // 单个变量控制所有扫描模式，替代原来的所有bool
        public static ScanModeEnum CurrentScanMode = ScanModeEnum.None;
        /// <summary>精细    Det水平拼接       <summary>  

        public static bool LineDRScanParamsOK = false;
        public static bool LineDRStartScanFlag = false;
        public static bool saveDataThread = true;
        public static int scanModeState = 0;
        public static int saveNum = 0;//存储图像，用于存储线程使用
        public static int acqNum = 0;//精细扫描、快速扫描存储张数
        public static int showNum = 0;
        public static int detectorShowNum = -1;
        public static string saveImgPath;
        public static string saveDRImgPath;
        public static int SkipNum = 0;
        public static int rotateDegree;
        public static int imgWidth;
        public static int imgHeight;
        /// <summary>
        /// 在图像显示中显示的全局图像变量
        /// </summary>
        public static short[] imgData;
        public static float[] imgDataGain;
        /// <summary>
        /// 0=DC800运动平台;    1=PLC多轴运动平台
        /// </summary>
        public static int isMultiAxis = 0;
        /// <summary>
        /// //0是单源单探，1是双源双探，2是双源单探，3是单源双探
        /// </summary>
        public static int monitorLight = 0;
        public static string Xray1 = "";
        public static string Xray2 = "";
        public static string AreaDet = "";
        public static string LineDet = "";
        public static double useXrayTime = 0;
        public static bool xrayTimeClick = false;
        public static DateTime startXrayTime;
        public static DateTime endXrayTime;
        public static bool imageAdjust = false;
        public static bool histAdjust = false;
        public static int histMin = 0;
        public static int histMax = 65535;
        public static int progressBarNum = 0;
        public static bool isDrawCrosshairs = false;
        public static bool qualityScanMode = false;
        /// <summary>
        ///探测器类型 iRay=0;Varex=1
        /// </summary>
        public static int detType = 0;
        public static bool DC800 = false;
        public static int HProtate = 0;
        /// <summary>
        /// 0=中文；1=英文
        /// </summary>
        public static int PCLanguage = 0;
        /// <summary>
        /// 机型结构模式：0=225CT架构；1=450CT双源双碳架构；2=SuperVolume1V CT架构
        /// </summary>
        public static int softwareMode = 0;
        public static string valuebinPath = "";
        public static bool autoScanCorrect = false;
        public static bool autoScanRecon = false;
        public static int autoScanCorrectTimes = 0;
        /// <summary>
        /// 射线源是否开启；True=开启
        /// </summary>
        public static bool isOpenXRay = false;
        public static bool limitedAngle = false;
        public static float limitedStartAngle = 0;
        public static int callbackImgNum = 0;
        public static float turntableStartAngle = 0;
        public static float turntableEndAngle = 0;
        public static int indexDoProcessBar = 0;
        public static string scanModeText;
        public static bool updateImg = false;
        public static bool qualityScanPause = false;
        public static bool twicebarshow = false;
        public static string ExpiredTime = "";
        /// <summary>
        /// DT线阵DR是否扫描完成
        /// </summary>
        public static bool bFinishLineDRScan = false;

        /// <summary>
        /// 控制130kV机型移动轴的两个按钮 enable or disable
        /// </summary>
        public static int Control130kVMoveEnable = 0;
        public static int ExhibitionFlag = 0;
        public static int iCallBackCount = 0;
        /// <summary>
        /// IRay探测器触摸发模式：1=硬触发（外部触发） 2=软触发（内部触发） 默认=2
        /// </summary>
        public static int iDetectorTriggerModeFlag = 2;

        public static bool bLicenseFlag = false;
        public static List<string> listPLCError = new List<string>();
        public static List<string> listShowPLCError = new List<string>();

        /// <summary>
        /// 被测产品的半径 单位mm
        /// </summary>
        public static double dMeasureProductRadius = 0.0d;
        public static double dMeasureProductHeight = 0.0d;

        //轴方向
        public static int iAxisDirection = 1;
        public static string strProjectName = "";
        public static string strScanMode = "";
        public static float fStartLimitScanAngle = 0.0f;
        /// <summary>
        /// 探测器外触发标志位：1启用外触发；0=内触发
        /// </summary>
        public static int iDetExternalTrigger = 0;

        public static double dFilamentUseTime = 0;
        public static double dFilamentTargetTime = 0;

        /// <summary>
        /// 配置文件类型：0=ini文件配置；1=SQLCipher数据库配置
        /// </summary>
        public static int iConfigFileType = 0;
        //对中校准全局变量
        public static int iAutoAlignDRCount = 0;
        public static int iAutoAlignProcess = 0;
    }

    public class JitterParams
    {
        public static bool jitterScanMode = false;
        public static double jitterDetY = 0;
        public static double jitterDetYMove = 0;
        public static double jitterMove = 0.139 / 2;
        public static double jitterDetX;//扫描过程中位置不变
        public static double jitterDetZ;//扫描过程中位置不变
        public static double jitterRotateX;//扫描过程中位置不变
        public static double jitterRotateY;//扫描过程中位置不变
        public static double jitterXrayZ;//扫描过程中位置不变
        public static double jitterRotateDegree;
    }

    public class VirtualScanParams
    {
        public static bool virtualScanMode = false;
        public static double virtualRadius;
        public static double centerX;//记录虚拟轴中心x值
        public static double centerY;//记录虚拟轴中心y值
        public static double virtualDetY;//扫描过程中位置不变
        public static double virtualDetX;//扫描过程中位置不变
        public static double virtualDetZ;//扫描过程中位置不变
        public static double virtualRotateX;
        public static double virtualRotateY;
        public static double virtualRotateZ;//225kv
        public static double virtualXrayZ;//扫描过程中位置不变
        public static double virtualRotateDegree;
        public static List<VirtualCoordinate> coordinates = new List<VirtualCoordinate>();
    }

    public class ZoomScanParams
    {
        public static double Width;
        public static double Height;
        public static bool zoomScanMode = false;
        public static double zoomDetY;//扫描过程中位置不变
        public static double zoomDetX;//扫描过程中位置不变
        public static double zoomDetZ;//扫描过程中位置不变
        public static double zoomRotateX;
        public static double zoomRotateY;//扫描过程中位置不变
        public static double zoomRotateZ;//扫描过程中位置不变
        public static double zoomXrayZ;//扫描过程中位置不变
        public static double zoomRotateDegree;
        public static List<double> zoomFODs = new List<double>();
    }

    public class SpeedScanParams
    {
        public static bool speedScanMode = false;
        public static bool speedStateOK = false;
        public static float pos1Start;
        public static float pos2Start;
        public static float pos3Start;
        public static float pos4Start;
        public static float pos4End = 360;
        public static double speedDetY;//扫描过程中位置不变
        public static double speedDetX;//扫描过程中位置不变
        public static double speedDetZ;//扫描过程中位置不变
        public static double speedRotateX;//扫描过程中位置不变
        public static double speedRotateY;//扫描过程中位置不变
        public static double speedRotateZ;//扫描过程中位置不变
        public static double speedXrayZ;//扫描过程中位置不变
        public static double speedRotateDegree;
        public static double speedRotateSpeedSlow;
        public static double speedRotateSpeedFast;
        public static double speedRotateSpeedSlowNums;
        public static double speedRotateSpeedFastNums;
        public static int speedModeSelect = 0;
    }


    //射线源参数Comet 225
    public class XRayDfnComet225
    {
        public static bool isStartVacon = false;
        public static bool shutAdjust = false;
        public static bool isLockDoorActive = false;
        public static Service serviceX225;
        public static Cpu cpuX225;
        public static Variable varKVS, varKVR, varMAS, varMAR, varWarmUpS, varWarmUpR, varVaconS, varVaconR, varVaconRV, varInterLockR, varXonS, varXoffS, varXonR, varStartUpS, varStartUpR;
        public static Variable sysErrR, sysErrS, HSGErrR, HSGErrS, tubeErrR, tubeErrS, tubeACErrR, tubeACErrS, varWatchingDog;
        public static Variable CurrentKVAutoCenter, ALLKVCenter, FilamentAdjust, FilamentAdjustR, AutoCenterR;//当前电压自动定心，所有电压自动定心，灯丝校准
        public static string xrayAdvancedSetPath = @"C:\Program Files (x86)\Feinfocus\FXEControl_3.1.1.65\FXEControl.exe";
        public static string xrayWarmUp, xrayVacon, xraySatartUp, xrayFilamentAdjust, xrayKVcenter, xrayTXI, xrayMode, xrayLockDoor;
        public static Variable powerModeR, powerModeS, txiR, txiOpenS, txiCloseS;
        public static string watchDogText;
        public static string XrayCsvPath;
        public static float current;
        public static float voltage;
        public static int voltageAdjust;
        public static int currentAdjust;
        public static float Readcurrent;
        public static float Readvoltage;
        public static double ReadActualDvValue, ReadActualAnValue, SetDvValue, SetAnValue;
        public static int updateValue;
    }

    //射线源参数Comet 450
    public class XRayDfnComet450
    {
        public static float ReadActualDvValue, ReadActualAnValue, SetDvValue, SetAnValue;
        public static bool isOpenXRay = false;
        public static string focusMode = "450um";
        public static bool isXrayReady = false;
        public static int configCurrent;
    }

    //射线源参数Worx 300
    public class XRayDfnWorx300
    {
        public static float ReadActualDvValue, ReadActualAnValue, SetDvValue, SetAnValue;
        public static bool isOpenXRay = false;
    }
    public class XRayDfnFineTec300
    {
        public static int iPrevReadActualVoltage, ReadActualVoltage, ReadActualCurrent, SetVoltageValue, SetCurrentValue;
        public static ulong ulFineTecState1 = 0;
        public static ulong ulFineTecState2 = 0;
        public static string focusMode = "";
        public static string strVacuum = "";
    }
    public class XRayDfnHama130
    {
        public static int ReadActualVoltage, ReadActualCurrent, SetVoltageValue, SetCurrentValue;
        public static bool isOpenXRay = false;
        /// <summary>
        /// 焦斑模式：0=Samll；1=Middle；2=Large
        /// </summary>
        public static string focusMode = "Large";
        public static int iXrayReady = 0;
        public static bool bXrayRunFlag = false;
        public static string strXrayType = "";
        public static string strXrayBattery = "";
        public static string strXrayStatus = "";

        public static string strXrayPort = "";
        public static HamaMFX hamaMFX = new HamaMFX();
        // 不同焦斑模式下的最大功率值
        public static int[] powerMax;
        public static ComboBox cmb_MFXList = new ComboBox();
        public static bool bFocalSizeChangeEnable = false;
        public static int iMaxVoltage = 130;
        public static int iMaxCurrent = 300;
        //设备状态
        public static string strSTS = "";
        //硬件错误
        public static string strSER = "";
        //联锁状态
        public static string strSIN = "";
    }

    //射线源参数Viscom 225
    public class XRayDfnViscom225
    {
        public static int ReadActualDvValue, ReadActualAnValue, SetDvValue, SetAnValue;
        public static bool isLockDoorActive = false;
        public static bool isOpenXRay = false;
        public static string tubeVersion;
        public static string drvVersion;
        public static string dllVersion;
        public static int min_kv;
        public static int max_kv;
        public static int min_ua;
        public static int max_ua;
    }
    public class XRayDfnViscom320
    {
        public static int ReadActualDvValue, ReadActualAnValue, SetDvValue, SetAnValue;
        public static bool isLockDoorActive = false;
        public static bool isOpenXRay = false;
        public static string tubeVersion;
        public static string drvVersion;
        public static string dllVersion;
        public static int min_kv;
        public static int max_kv;
        public static int min_ua;
        public static int max_ua;
    }
    //线阵探测器DT H0104
    public class DetDfnDT
    {
        public static bool isDTConnected = false;
        public static int binMode = 0;
        public static int avgMode = 0;
        public static int frame_count = 0;
        public static int lost_line = 0;
        public static int inteTime = 0;
        public static uint cur_dm_index = 0;
        public static int lineNums = 32;
        public static int runPlc = 1;
        public static bool StartScan = false;
        public static int width = 2048;
        public static int height = 32;
        public static bool correctCheck;
        public static float pixel = 0.4f;
    }


    //探测器参数
    public class DetectorDfnArea
    {
        public static string detConfigPath = Application.StartupPath + "\\work_dir\\NDT1717M2\\DynamicApplicationMode.ini";
        public static string detConfigPathTime = Application.StartupPath + "\\work_dir\\NDT1717M2\\config.ini";
        public static string varexBadPath1 = Application.StartupPath + "\\Varex\\4343#07290_b1_PxlMask.his";
        public static string varexBadPath2 = Application.StartupPath + "\\Varex\\4343#07290_b2_PxlMask.his";
        public static string varexBadPath3 = Application.StartupPath + "\\Varex\\4343#07290_b3_PxlMask.his";
        public static string varexBadPath4 = "";
        public static int m_nId = -1;
        public static IRayImage CurImage;
        public static DispatcherTimer ConnectStateTimer;
        public static int CorrectionOpt = 0;
        public static bool seqSave = false;
        public static Image image;
        public static bool isDetCreat = false;
        public static bool isDetConnect = false;
        public static bool isDetApplication = false;
        public static bool isDetOffset = false;
        public static bool isDetGainDefect = false;
        public static bool isStartAcq = false;
        public static string CorrectState;
        public static string IrayDetectorPath;
        public static string iDetectorPath;
        public static int binning;
        public static int PGA;
        public static float frame;
        public static int formerBinning;
        public static int formerPGA;
        public static float formerFrame;
        public static float SOD;
        public static float formerSOD;
        public static float current;
        public static float formerCurrent;
        public static float voltage;
        public static float formerVoltage;
        public static double detectorWidth = 0.139 * 3072;
        public static double detectorHeight = 0.139 * 3060;
        public static double pixel_distance = 0.139;
        public static int Image_Width = 3072;
        public static int Image_Height = 3060;
        public static int skipNums = 0;
        public static int scanIng = 0;
        public static int updateDet = 0;
        public static int mergeFrame = 0;
        public static int frameNo = 0;
        public static int runPlc = 1;
        public static int freq1_1 = 15;
        public static int freq2_2 = 30;
        public static int freq3_3 = 45;
        public static int freq4_4 = 60;
    }

    //运动控制参数 225
    public class MotionDfn
    {
        public static string strConfigFile = Application.StartupPath + "\\File\\config.ini";
        public static Def.HSI_STATUS rStatus = Def.HSI_STATUS.HSI_STATUS_INIT;
        public static bool stopRun = true;
        public static bool doneHome = false;

        //定义全局变量
        public static double iSpeed = 0; //速度
        public static double iSpeedMax = 100;//速度最大值
        public static int iRotaryIndex = 0; //轴号
        public static int iRotaryPos = 0; //轴位置
        public static double iXPos = 0; //定义X轴位置
        public static double iYPos = 0;
        public static double iDetYPos = 0;
        public static double iZPos = 0;
        public static double useXPos = 0; //定义X轴位置
        public static double useYPos = 0;
        public static double useZPos = 0;
        public static double useFDD = 0;
        public static double velocity = 0;
        public static float fdd = 0;
        public static double fdd2 = 0;
        //运动范围限制
        public static double iXMax = 1141;
        public static double iXMin = -19;
        public static double iYMax = 50;
        public static double iYMin = -250;
        public static double iDetYMax = 220;
        public static double iDetYMin = 0;
        public static double iZMax = 59;
        public static double iZMin = -541;
        public static double iFDDMax = 901;
        public static double iFDDMin = 524;
        public static double iZ2Max = 400;
        public static double iZ2Min = 0;
        public static double x_collide = 0;
        public static double y_collide = 0;
        public static double z_collide = 0;
        public static float AccRotate = (float)16.66;
        public static float AccDc800 = 100;
        public static float centerY = 151.86f;
        public static float centerY_offset = 0;
        public static float centerY_sddsod = 0;
        public static double deltaFod = 0;
        public static double deltaFdd = 0;
        public static bool ishome = false;
        public static bool isDetYHome = false;
        public static bool xyzStop = false;
        public static string strZ1Axes = "VIS";
        public static string strZ2Axes = "X1S";
        /// <summary>
        /// SuperVolume1V Z轴补偿值   该值根据每个机型 可以更改
        /// </summary>
        public static float dSV1VZOffset = -5;
        /// <summary>
        /// 定义X Y D轴的补偿值 小机器切轴时，有误差
        /// </summary>
        public static double iXCompensationPos = 0.514;
        public static double iYCompensationPos = 0.541;
        public static double iDCompensationPos = 0.477;
        public static bool bHaveDetYFlag = false;
    }

    //450kv 双源双探运动参数
    public class MotionDfn450
    {
        public static bool stopRun = true;
        public static bool XrayDetZ = false;
        public static float XrayStartZ = 0;
        public static float DetStartZ = 0;
        //定义全局变量
        public static double axisSpeedMin = 0; //速度最小值
        public static double axisSpeedMax = 100;//速度最大值

        public static double iRotateXPos = 0; //定义X轴位置
        public static double iRotateYPos = 0;
        public static double iXrayZPos = 0;
        public static double iDetZPos = 0;
        public static double iDetYPos = 0;
        public static double fod = 0;
        public static double fdd = 0;

        public static float AccRotate = (float)16.66;//单位：°/s^2
        public static float AccAxis = 100;//单位：mm/s^2
        public static float centerY = 151.542f;
        public static float FDD_Add = 0;

        //运动范围限制  
        public static double iRotateXMax = 1456;   //1000
        public static double iRotateXMin = 0;
        public static double iRotateYMax = 526;//360
        public static double iRotateYMin = 0;
        public static double iDetXMax = 1320; //1000
        public static double iDetXMin = 0;
        public static double iDetYMax = 542; //320
        public static double iDetYMin = 0;
        public static double iDetZMax = 1157.7; //450
        public static double iDetZMin = 0;
        public static double iXrayMax = 1155;  //450
        public static double iXrayMin = 0;
        public static float scanRotate = 0;

        //射线源切换改变值
        public static float xray1det1 = -6;
        public static float xray1det2 = -342;
        public static float xray2det1 = 327;
        public static float xray2det2 = -11.3f;
        public static float xray1det1fod = 0;
        public static float xray1det1fdd = 0;
        public static float xray2det1fod = 0;
        public static float xray2det1fdd = 0;
        /// <summary>
        /// 射线源Z轴 激光补偿的index 数组为[index k b PLCStart PLCEnd ]0-4五组数据数据
        /// </summary>
        public static Dictionary<int, double[]> dicXrayZ = new Dictionary<int, double[]>();
        /// <summary>
        /// 探测器X轴 激光补偿的index 数组为[index k b PLCStart PLCEnd ]0-4五组数据数据
        /// </summary>
        public static Dictionary<int, double[]> dicDetX = new Dictionary<int, double[]>();
        /// <summary>
        /// 探测器Y轴 激光补偿的index 数组为[index k b PLCStart PLCEnd ]0-4五组数据数据
        /// </summary>
        public static Dictionary<int, double[]> dicDetY = new Dictionary<int, double[]>();
        /// <summary>
        /// 探测器Z轴 激光补偿的index 数组为[index k b PLCStart PLCEnd ]0-4五组数据数据
        /// </summary>
        public static Dictionary<int, double[]> dicDetZ = new Dictionary<int, double[]>();
        /// <summary>
        /// 转台X轴 激光补偿的index 数组为[index k b PLCStart PLCEnd ]0-4五组数据数据
        /// </summary>
        public static Dictionary<int, double[]> dicRotateX = new Dictionary<int, double[]>();
        /// <summary>
        /// 转台Y轴 激光补偿的index 数组为[index k b PLCStart PLCEnd ]0-4五组数据数据
        /// </summary>
        public static Dictionary<int, double[]> dicRotateY = new Dictionary<int, double[]>();
        /// <summary>
        /// 450架构二次补偿参数 索引Worx300 or Comet450 ，数组为[Fod k,b,Fdd k,b,Object Y Center,Detector Y Center,探测器和射线源Z轴面阵差值，探测器和射线源Z轴线阵差值，线阵FDD b] 0-8的9组数据; EVE 架构 索引为FineTec300
        /// </summary>
        public static Dictionary<string, double[]> dicStructureComp = new Dictionary<string, double[]>();
        public static double laserDetx = 217.307865;//Eve第二台Fdd轴阈值增加设定，不适配第一台Eve设备，需要根据设备实际测量值进行调整
        /// <summary>
        /// PLC报错错误列表，索引为PLC错误码，值为错误描述 0=中文；1=英文
        /// </summary>
        public static Dictionary<int, string[]> dicPLCErrorList = new Dictionary<int, string[]>();
    }

    public class HardWareDfn
    {
        public static bool isXray225 = false;
        public static bool isXray450 = false;
        public static bool isXrayWorx300 = false;
        public static bool isXrayViscom225 = false;
        public static bool isXrayViscom320 = false;
        public static bool isXrayHama130 = false;
        public static bool isXrayFineTec300 = false;
        public static bool isDetIray = false;
        public static bool isDetDT = false;
        public static bool isDoorOk = false;//用于通讯测试监控plc的门状态
        public static bool isCameraOk = false;//监控状态
        public static bool isRotateOk = false;//用于通讯测试监控plc的状态状态
        public static bool isReconOk = false;//远程重构电脑正常连接
        public static bool isReconSoftOK = false;
        public static string camera1IP = "192.168.254.7";
        public static string camera2IP = "192.168.254.5";
        public static string cameraUser = "admin";
        public static string cameraPwd = "hexagon2023";
        public static string reconIP = "192.168.12.82";
        public static string reconSocket = "192.168.12.82";
        public static string comet225IP = "192.168.12.10";
        public static string DTIP = "192.168.1.11";

    }
    /// <summary>
    /// CT 225 PLC地址定义类
    /// </summary>
    public class PlcDfn
    {
        public static string plcIP;
        public static string plcDB;
        public static bool isPlcConnect = false;
        //plc地址与通讯协议:plc-->>pc
        public static string plcHeart = "DB31.200.0";//plc心跳
        public static string plcWarn = "DB31.200.1";//plc报警
        public static string plcXray = "DB31.200.2";//plc射线源上电
        public static string plcTrunTable = "DB31.200.3";//plc转台上电
        public static string plcDoor = "DB31.200.4";//plc门控上电
        public static string plcDC800 = "DB31.200.5";//DC800上电
        public static string plcDoorOpen = "DB31.201.0";//开门中
        public static string plcDoorClose = "DB31.201.1";//关门中
        public static string plcTurnTableClock = "DB31.201.4";//转台顺时针转
        public static string plcTurnTableUnclock = "DB31.201.5";//转台逆时针转
        public static string plcDoorState = "DB31.201.6";//门控状态
        public static string plcQualityScanbool = "DB31.203.0";//精细扫描开始采集
        public static string plcQuickScanbool = "DB31.203.1";//快速扫描开始采集
        public static string plcDRScanbool = "DB31.203.2";//DR扫描开始采集
        public static string plcQualityScanNums = "DB31.208.0";//扫描张数,精细扫描
        public static string plcArivePlace = "DB31.212.0";//到达位置
        public static string plcQuickScanNums = "DB31.236.0";//快速扫描张数
        public static string plcTurnTableAngle = "DB31.280.0";//转台角度
        public static string plcDetectorPosition = "DB31.288.0";

        //pc-->>plc
        public static string pcHeart = "DB31.0.0";
        public static string pcWarn = "DB31.0.1";
        public static string pcState = "DB31.0.2";
        public static string pcXRay = "DB31.0.3";
        public static string pcDetector = "DB31.0.4";
        public static string pcDC800 = "DB31.0.5";
        public static string pcOpenXRay = "DB31.0.6";
        public static string pcOpenDoor = "DB31.1.0";
        public static string pcCloseDoor = "DB31.1.1";
        public static string pcStopDoor = "DB31.1.2";
        public static string pcTurnTableClock = "DB31.1.3";
        public static string pcTurnTableUnclock = "DB31.1.4";
        public static string pcTurnTableZero = "DB31.1.5";
        public static string pcTurnTablePosition = "DB31.1.6";
        public static string pcTurnTableStop = "DB31.1.7";

        public static string pcDetectorScan = "DB31.2.0";
        public static string pcDetectorMove = "DB31.2.1";
        public static string pcDetectorStop = "DB31.2.2";

        public static string pcOpenQuality = "DB31.3.0";
        public static string pcStopQuality = "DB31.3.1";
        public static string pcOpenQuick = "DB31.3.2";
        public static string pcStopQuick = "DB31.3.3";
        public static string pcOpenDR = "DB31.3.4";
        public static string pcStopDR = "DB31.3.5";

        public static string pcQualityMode = "DB31.4.0";
        public static string pcQualityNums = "DB31.8.0";
        public static string pcQualityAvgs = "DB31.12.0";
        public static string pcQualityV = "DB31.16.0";
        public static string pcQualityRotate = "DB31.20.0";
        public static string pcQualityAchive = "DB31.24.0";

        public static string pcQuickMode = "DB31.32.0";
        public static string pcQuickNums = "DB31.36.0";
        public static string pcQuickImgNums = "DB31.40.0";
        public static string pcQuickTime = "DB31.44.0";
        public static string pcQuickV = "DB31.48.0";
        public static string pcQuickRotate = "DB31.52.0";
        public static string pcQuickIntegrate = "DB31.56.0";//直接写帧率，不写积分时间

        public static string pcDRMode = "DB31.60.0";
        public static string pcDRNums = "DB31.64.0";
        public static string pcDRDone = "DB31.68.0";

        public static string pcRotateAngle = "DB31.80.0";
        public static string pcRotateV = "DB31.84.0";
        public static string pcDetectorP = "DB31.88.0";
        public static string pcDetectorV = "DB31.92.0";

        //225测试硬触发 PLC角度
        public static string strDBNum = "DB22.";
        /// <summary> 锁存的位置数量总数 启动信号</summary>
        public static string plcAngleArrayCount = strDBNum + "346.0";

        public static string plcAngleTriggerCount = strDBNum + "238.0";
        //
        public static string plcAngleExploerCount = strDBNum + "240.0";
        /// <summary>角度起始地址 348.0</summary>
        public static string plcAngleArrayStartAddress = strDBNum + "348";
        /// <summary>角度数组前缀</summary>
        public static string plcAngleArrayPreAddress = strDBNum;

        /// <summary> 清空角度数组标志位 bool类型 true为清空</summary>
        public static string pcClearAngleArrayFlag = strDBNum + "3.5";

    }
    //450 PLC 地址
    public class PlcDfn450
    {
        public static string plcIP;
        public static string plcDB;
        public static bool doorLock = false;
        public static bool isPlcConnect = false;
        //plc地址与通讯协议:plc-->>pc   pc read plc address
        public static string plcFineTecXrayOn = "I13.0"; //仅EVE使用 true为XrayOn  false为XrayOff
        public static string plcHeart = "DB31.200.0";//plc心跳
        public static string plcWarn = "DB31.200.1";//plc报警
        public static string plcStop = "DB31.200.2";//plc急停
        public static string plcDoorSafe = "DB31.200.3";//plc安全门信号
        public static string plcDoorRepair = "DB31.200.4";//plc维修们信号
        public static string plcDoorRador = "DB31.200.5";//plc门雷达
        public static string plcDetectorRador = "DB31.200.6";//探测器雷达
        public static string plcXrayRador = "DB31.200.7";//射线源雷达

        public static string plcMotionElectric = "DB31.201.0";//运动控制上电
        public static string plcXray225Electric = "DB31.201.1";//225射线源上电
        public static string plcXray450Electric = "DB31.201.2";//450射线源上电
        /// <summary>
        /// plc 回原点运动中
        /// </summary>
        public static string plcSystemInitialRunning = "DB31.201.3";
        /// <summary>
        /// PLC回原点完成
        /// </summary>
        public static string plcSystemInitialFinish = "DB31.201.4";
        public static string plcXrayOnFlag = "DB31.201.5";//true方可开启射线，false不可开启 门锁 Enable方可开启射线源
        /// <summary>门开到位信号</summary>
        public static string plcDoorStateOpen = "DB31.201.6";
        /// <summary>门关到位信号true为关门</summary>
        public static string plcDoorStateClose = "DB31.201.7";

        public static string plcaxis1Achieve = "DB31.202.0";//运动状态
        public static string plcaxis2Achieve = "DB31.202.1";//运动状态
        public static string plcaxis3Achieve = "DB31.202.2";//运动状态
        public static string plcaxis4Achieve = "DB31.202.3";//运动状态
        public static string plcaxis5Achieve = "DB31.202.4";//运动状态
        public static string plcaxis6Achieve = "DB31.202.5";//运动状态
        public static string plcaxis7Achieve = "DB31.202.6";//运动状态

        public static string plcaxisAllAchieve = "DB31.202.7";//运动状态

        public static string plcaxis1Location = "DB31.203.0";//运动状态
        public static string plcaxis2Location = "DB31.203.1";//运动状态
        public static string plcaxis3Location = "DB31.203.2";//运动状态
        public static string plcaxis4Location = "DB31.203.3";//运动状态
        public static string plcaxis5Location = "DB31.203.4";//运动状态
        public static string plcaxis6Location = "DB31.203.5";//运动状态

        public static string plcaxisAllLocation = "DB31.203.7";//运动到位信号

        public static string plcRotateXSpd = "DB31.220.0";
        public static string plcRotateYSpd = "DB31.228.0";
        public static string plcRotateSpd = "DB31.236.0";
        public static string plcDetXSpd = "DB31.244.0";
        public static string plcDetYSpd = "DB31.252.0";
        public static string plcDetZSpd = "DB31.260.0";
        public static string plcXrayZSpd = "DB31.268.0";
        public static string plcDoorSpd = "DB31.276.0";

        public static string plcRotateXPos = "DB31.300.0";
        public static string plcRotateYPos = "DB31.308.0";
        public static string plcRotateDegree = "DB31.316.0";
        public static string plcDetXPos = "DB31.324.0";
        public static string plcDetYPos = "DB31.332.0";
        public static string plcDetZPos = "DB31.340.0";
        public static string plcXrayZPos = "DB31.348.0";

        public static string plcDoorPos = "DB31.356.0";

        public static string plcWarns = "DB31.396.0";

        //圆周扫描
        public static string plcCircleScanOK = "DB32.200.0";
        /// <summary>
        /// 运行中标志位：true=运行中 false=未运行
        /// </summary>
        public static string plcCircleScanRunning = "DB32.200.1";
        public static string plcCircleQuickRun = "DB32.201.0";
        public static string plcCircleQuickSpdOK = "DB32.201.1";
        public static string plcCircleQualityRun = "DB32.202.0";
        public static string plcCircleQualityPosOK = "DB32.202.1";

        //螺旋扫描
        public static string plcHelixScanOK = "DB33.200.0";
        public static string plcHelixScanRunning = "DB33.200.1";
        public static string plcHelixQuickRun = "DB33.201.0";
        public static string plcHelixQuickSpdOK = "DB33.201.1";
        public static string plcHelixQualityRun = "DB33.202.0";
        public static string plcHelixQualityPosOK = "DB33.202.1";

        //线阵探测器DR采集plc-pc
        public static string plcLineDRScanReady = "";

        //线阵探测器螺旋采集plc-pc
        public static string plcLineHelixScanCondition = "DB34.200.0";
        public static string plcLineHelixScanRuning = "DB34.200.1";
        public static string plcLineHelixScanRun = "DB34.202.0";
        public static string plcLineHelixScanReady = "DB34.202.1";

        //----------------------------------------------------------------------------------------------------------------------------
        //pc-->>plc   // pc write plc address
        public static string pcHeart = "DB31.0.0";
        public static string pcWarn = "DB31.0.1";
        public static string pcXray225Open = "DB31.0.2";
        public static string pcXray450Open = "DB31.0.3";
        public static string pcDetectorLineRun = "DB31.0.4";
        public static string pcDetectorAreaRun = "DB31.0.5";
        //射线源和探测器的雷达屏蔽信号，默认为false不屏蔽， true为屏蔽
        public static string pcXaryRadar = "DB31.0.6";
        public static string pcDetectorRadar = "DB31.0.7";
        public static string pcMotionElectric = "DB31.1.0";
        public static string pcXray225Electric = "DB31.1.1";
        public static string pcXray450Electric = "DB31.1.2";

        //初始化回原点 写给PLC  true回原点
        public static string pcSystemInitial = "DB31.1.3";
        /// <summary>
        /// z轴绑定，true为绑定
        /// </summary>
        public static string pcSourceZBind = "DB31.1.4";
        public static string pcStopDoor = "DB31.1.5";
        public static string pcOpenDoor = "DB31.1.6";
        public static string pcCloseDoor = "DB31.1.7";

        public static string pcaxis1Zero = "DB31.2.0";
        public static string pcaxis2Zero = "DB31.2.1";
        public static string pcaxis3Zero = "DB31.2.2";
        public static string pcaxis4Zero = "DB31.2.3";
        public static string pcaxis5Zero = "DB31.2.4";
        public static string pcaxis6Zero = "DB31.2.5";
        public static string pcaxis7Zero = "DB31.2.6";
        public static string pcClearWarns = "DB31.2.7";

        public static string pcaxis1Location = "DB31.3.0";
        public static string pcaxis2Location = "DB31.3.1";
        public static string pcaxis3Location = "DB31.3.2";
        public static string pcaxis4Location = "DB31.3.3";
        public static string pcaxis5Location = "DB31.3.4";
        public static string pcaxis6Location = "DB31.3.5";

        public static string pcStopMove = "DB31.3.6";
        public static string pcStartMove = "DB31.3.7";

        public static string pcManualSpd = "DB31.4.0";
        public static string pcAutoSpd = "DB31.12.0";

        public static string pcRotateXSpd = "DB31.20.0";
        public static string pcRotateYSpd = "DB31.28.0";
        public static string pcRotateSpd = "DB31.36.0";
        public static string pcDetXSpd = "DB31.44.0";
        public static string pcDetYSpd = "DB31.52.0";
        public static string pcDetZSpd = "DB31.60.0";
        public static string pcXrayZSpd = "DB31.68.0";

        public static string pcRotateXPos = "DB31.100.0";
        public static string pcRotateYPos = "DB31.108.0";
        public static string pcRotateDegree = "DB31.116.0";
        public static string pcDetXPos = "DB31.124.0";
        public static string pcDetYPos = "DB31.132.0";
        public static string pcDetZPos = "DB31.140.0";
        public static string pcXrayZPos = "DB31.148.0";

        //雷达防撞 被测产品的半径和高度
        public static string pcMeasProRadius = "DB31.188.0";
        public static string pcMeasProHeight = "DB31.180.0";

        //圆周扫描
        public static string pcCircleScanStart = "DB32.0.0";
        public static string pcCircleScanStop = "DB32.0.1";
        public static string pcCircleQuick = "DB32.1.0";
        public static string pcCircleQuality = "DB32.2.0";
        public static string pcCircleQDOnceTime = "DB32.2.1";

        public static string pcCircleRotateXPos = "DB32.4.0";
        public static string pcCircleRotateYPos = "DB32.12.0";
        public static string pcCircleRotateDegree = "DB32.20.0";
        public static string pcCircleDetXPos = "DB32.28.0";
        public static string pcCircleDetYPos = "DB32.36.0";
        public static string pcCircleDetZPos = "DB32.44.0";
        public static string pcCircleXrayZPos = "DB32.52.0";

        public static string pcCircleRotateSpd = "DB32.60.0";
        public static string pcCircleRDOnceTime = "DB32.68.0";
        //写给PLC的采集角度地址
        public static string pcRotateAngle = "DB32.76.0";

        //精细螺旋扫描
        public static string pcHelixScanStart = "DB33.0.0";
        public static string pcHelixScanStop = "DB33.0.1";
        public static string pcHelixQuick = "DB33.1.0";
        public static string pcHelixQuality = "DB33.2.0";
        public static string pcHelixQualityOnceTime = "DB33.2.1";

        public static string pcHelixRotateXPos = "DB33.4.0";
        public static string pcHelixRotateYPos = "DB33.12.0";
        public static string pcHelixRotateDegree = "DB33.20.0";
        public static string pcHelixDetXPos = "DB33.28.0";
        public static string pcHelixDetYPos = "DB33.36.0";
        public static string pcHelixDetZPos = "DB33.44.0";
        public static string pcHelixXrayZPos = "DB33.52.0";

        public static string pcHelixDetEndZPos = "DB33.100.0";
        public static string pcHelixXrayEndZPos = "DB33.108.0";

        public static string pcHelixRotateSpd = "DB33.60.0";
        public static string pcHelixZSpd = "DB33.68.0";
        public static string pcHelixZPos = "DB33.76.0";
        public static string pcHelixRDOnceTime = "DB33.84.0";
        public static string pcHelixZPosChange = "DB33.92.0";

        //线阵探测器DR扫描
        public static string pcLineDRScan = "";

        //线阵探测器螺旋扫描
        public static string pcLineHelixScanStart = "DB34.0.0";
        public static string pcLineHelixScanStop = "DB34.0.1";
        public static string pcLineHelixScanQuality = "DB34.2.0";
        public static string pcLineHelixScanOnceDone = "DB34.2.1";
        public static string pcLineHelixScanCircleDone = "DB34.2.2";
        public static string pcLineHelixScanWholeDone = "DB34.2.3";

        public static string pcLineHelixRotateXPos = "DB34.4.0";
        public static string pcLineHelixRotateYPos = "DB34.12.0";
        public static string pcLineHelixRotateDegree = "DB34.20.0";
        public static string pcLineHelixDetXPos = "DB34.28.0";
        public static string pcLineHelixDetYPos = "DB34.36.0";
        public static string pcLineHelixDetZPos = "DB34.44.0";
        public static string pcLineHelixXrayZPos = "DB34.52.0";

        public static string pcLineHelixRotateSpd = "DB34.60.0";
        public static string pcLineHelixZSpd = "DB34.68.0";
        public static string pcLineHelixZPos = "DB34.76.0";
        public static string pcLineHelixRDOnceTime = "DB34.84.0";
        public static string pcLineHelixZPosChange = "DB34.92.0";

        //Error List
        public static string strErrorDBNum = "DB60.";
        /// <summary>PLC报错错误起始的字节地址</summary>
        public static int plcErrorStartAddr = 40;
        /// <summary>PLC报错错误的字节个数</summary>
        public static int plcErrorCount = 27;
    }
    //SV1V PLC地址
    public class PlcDfn130
    {
        public static string plcIP;
        public static string plcDB;
        public static bool doorLock = false;
        public static bool isPlcConnect = false;
        public static string strDBNum = "DB22.";

        #region 写入PLC PC Write PLC Address  [PC->PLC]
        public static string pcHeart = strDBNum + "0.0";
        public static string pcWarn = strDBNum + "0.1";
        public static string pcDC800 = strDBNum + "0.5";

        public static string pcTurnTableClock = strDBNum + "1.3";
        public static string pcTurnTableUnclock = strDBNum + "1.4";
        public static string pcTurnTableZero = strDBNum + "1.5";
        /// <summary> 转台停止 启动信号</summary>
        public static string pcTurnTablePosition = strDBNum + "1.6";
        /// <summary>转台停止 上升沿</summary>
        public static string pcTurnTableStop = strDBNum + "1.7";
        /// <summary> 10:关门；20=开门；30=停止</summary>
        public static string pcControlDoor = strDBNum + "2.0";
        public static string pcControlDC800Electric = strDBNum + "3.0";
        /// <summary> 清空角度数组标志位 bool类型 true为清空</summary>
        public static string pcClearAngleArrayFlag = strDBNum + "3.5";
        /// <summary> 控制探测器触发标记位</summary>
        public static string pcControlDetectorInFlag = strDBNum + "3.6";
        /// <summary>byte： 10=精细有限角扫描；11=精细完整扫描；20=快速有限角扫描；21=快速完整扫描</summary>
        public static string pcScanMode = strDBNum + "4.0";

        public static string pcQualityScanNum = strDBNum + "8.0";
        public static string pcQualityScanSpeed = strDBNum + "16.0";
        public static string pcQualityScanAngle = strDBNum + "20.0";
        /// <summary> 精细采集完成标记：10完成</summary>
        public static string pcQualityScanFinish = strDBNum + "24.0";
        public static string pcQuickScanSpeed = strDBNum + "48.0";
        /// <summary>
        /// 转台角度值
        /// </summary>
        public static string pcTurnTableAngle = strDBNum + "80.0";
        public static string pcTurnTableSpeed = strDBNum + "84.0";
        /// <summary> 写入PLC的探测器帧率Hz</summary>
        public static string pcDetectorFreq = strDBNum + "88.0";
        /// <summary> 写入PLC的探测器Y轴值 lreal</summary>
        public static string pcWriteDetYValue = strDBNum + "108";
        /// <summary> 写入PLC的探测器Y轴速度 lreal</summary>
        public static string pcDetYSpeed = strDBNum + "112";
        public static string pcDetYStop = strDBNum + "118.0";
        public static string pcDetYGoHome = strDBNum + "92.0";
        public static string pcDetYStart = strDBNum + "96.0";
        #endregion

        #region 读取PLC PC Read PLC Address [PLC->PC]  
        public static string plcHeart = strDBNum + "200.0";//plc心跳 bool
        public static string plcWarn = strDBNum + "292.0";//plc报警 int
        public static string plcXRay = strDBNum + "200.2";//XRay工作中
        public static string plcDC800ON = strDBNum + "200.3";//XRay工作中
        public static string plcDoorOpening = strDBNum + "201.0";
        public static string plcDoorClosing = strDBNum + "201.1";
        /// <summary>
        /// 转台状态：true=空闲
        /// </summary>
        public static string plcTurnIdle = strDBNum + "201.3";
        public static string plcTurnTablecw = strDBNum + "201.4";
        public static string plcTurnTableccw = strDBNum + "201.5";
        /// <summary>
        /// true:铅门开
        /// </summary>
        public static string plcDoorOpened = strDBNum + "201.6";
        /// <summary>
        /// true:铅门关
        /// </summary>
        public static string plcDoorClosed = strDBNum + "201.7";
        public static string plcQualityScanning = strDBNum + "203.0";
        public static string plcQuickScanning = strDBNum + "203.1";
        /// <summary>
        /// 0->10：转台到达精细扫描指定位置
        /// </summary>
        public static string plcQualityScanArivePlace = strDBNum + "212.0";
        /// <summary>
        /// 0->10：转台达到快速扫描预设速度
        /// </summary>
        public static string plcReachQuickScanSpeed = strDBNum + "236.0";
        /// <summary> 实时反馈转台角度</summary>
        public static string plcTurnTableAngle = strDBNum + "280.0";
        /// <summary> 实时反馈转台速度</summary>
        public static string plcTurnTableSpeed = strDBNum + "284.0";
        /// <summary> 锁存的位置数量总数 启动信号</summary>
        public static string plcAngleArrayCount = strDBNum + "346.0";
        public static string plcAngleTriggerCount = strDBNum + "238.0";
        public static string plcAngleExploerCount = strDBNum + "240.0";
        /// <summary>角度起始地址 348.0</summary>
        public static string plcAngleArrayStartAddress = strDBNum + "348";
        /// <summary>角度数组前缀</summary>
        public static string plcAngleArrayPreAddress = strDBNum;
        /// <summary>读取探测器Y轴数据 lReal</summary>
        public static string plcReadDetYValue = strDBNum+"330";
        /// <summary>读取探测器Y轴已回家 bool</summary>
        public static string plcDetYStatusHome = strDBNum + "202.0";
        /// <summary>读取探测器Y状态空闲  bool</summary>
        public static string plcDetYStatusFree = strDBNum + "202.1";
        #endregion
    }

    public class ReconDfn
    {
        public static string reconPath;
        public static string transPath;
        public static string saveReconPath;
        public static int saveReconNum;
        public static int ROIx = 3072;
        public static int ROIy = 3060;
        public static bool roiDraw = false;
        public static bool useROI = false;
        public static int roixMin = 0;
        public static int roiyMin = 0;
        public static int roizMin = 0;
        public static int roizMin1 = 0;
        public static int roixMax = 3072;
        public static int roiyMax = 3072;
        public static int roizMax = 3060;
        public static int roizMax1 = 3060;
        public static double totalSpace = 0;
        public static double freeSpace = 0;
        public static bool exitSpace = false;
    }

    public class CorrectParams
    {
        public static int laser = 0;
        public static int compensate = 0;
        public static int compensateFDD = 0;
        public static int mappingYcenter = 0;
        public static int mappingDetYcenter = 0;
        public static double Ycenter = 0;
        public static double DetYcenter = 0;
        public static double SDD = 1499.885f;
        public static double k = 1.00047389;
        public static double b = 6.6443787;
        public static double kFDD = 0;
        public static double bFDD = 0;
        public static double detector_horizontal_offset;
        public static double detector_rotation_offset;
    }

    public class AreaScanParams
    {
        public static float A1areaDetZ = 0;
        public static float A1areaDetOffsetY = 0;
        public static float A2areaDetZ = 0;
        public static float A2areaDetOffsetY = 0;
        public static float A3areaDetZ = 0;
        public static float A3areaDetOffsetY = 0;
        public static float A4areaDetZ = 0;
        public static float A4areaDetOffsetY = 0;
        public static int areaScanNums = 0;
        public static bool isOK = false;
        public static bool isAreaScan = false;
    }

    public class HelixParams
    {
        public static int pitch;
        public static float helixDetStartZ = 0;
        public static float helixDetStartZNew = 0;
        public static float helixDetEndZ = 0;
        public static float helixXrayStartZ = 0;
        public static float helixXrayStartZNew = 0;
        public static float helixXrayEndZ = 0;
        public static float helixStartZ = 2;
        public static float helixStartZNew = 0;
        public static float helixEndZ = 2;
        public static float offsetY = 0;
        public static double stepZ = 0;
        public static int lineHelixScanNums = 0;
        public static int lineHelixCircleNums = 0;
        public static float moveZ;
        public static bool isOK = false;
    }

    public class VerticalParams
    {
        public static float verticalDetStartZ = 0;
        public static float verticalDetEndZ = 0;
        public static float verticalXrayStartZ = 0;
        public static float verticalXrayEndZ = 0;
        public static bool isOK = false;
        public static bool VerticalisMode = false;
        public static double startRotate = 0;
        public static float startRotate1 = 0;
        public static double endRotate1 = 0;
        public static float startRotate2 = 0;
        public static double endRotate2 = 0;
        public static double dFeedRate = 0;
        public static bool multiScan = false;
    }

    public class ExtendScanParams
    {
        public static double offsetY = 0;
        public static float extendStartY = 0;
        public static float extendEndY = 0;
        public static float extendStartZ = 0;
        public static float extendEndZ = 0;
        public static float moveY;
        public static float moveZ;
        public static bool isOK = false;
        public static bool VerticalisOK = false;
        public static int position = 0;
        public static int rotateDegree = 360;
        public static float rotateDegreeStart = 0;
        public static float frameRate;
        public static float velocity;
        public static int extendNUM = 0;
        public static float startRotate1 = 0;
        public static double endRotate1 = 0;
        public static float startRotate2 = 0;
        public static double endRotate2 = 0;
    }
    public class GeoParams
    {
        public static int detWidth = 3072;
        public static int detHeight = 3060;
        public static double detPixelSize = 0.139;
        public static double FOD = 200;
        public static double FDD = 800;
        public static double deltaFOD = 0;
        public static List<double> xLocation = new List<double> { 30, 50 };    //采集位置
        public static double dCalibraDetZPos = 0;
        public static double dAcquireDetZPos = 0;
        public static double dAxisSpeed = 0;
    }
    public class OneBallCorrectParams
    {
        public static string centerPath;
        public static string rollPath;
        public static string distancePath;
        public static bool isRunCorrect = false;
        public static int saveImg = 0;
        public static int index = 0;
        public static int nameIndex = 0;
    }
}
