using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;//.Tasks;
using System.Runtime.InteropServices;

namespace GcDevicePc.DevParam
{
    public struct stTemp
    {
      public ushort usCurTemp_Word1;
      public ushort usCurTemp_Word2;
    }

    [StructLayout(LayoutKind.Explicit, Size=8)]
    public struct  UNION_TEMP{
        [FieldOffset(0)]
	    public float fCurTemp;

        [FieldOffset(0)]
        public stTemp t; 
    }

    public class DevAux
    {
        #region "辅助加热区变量"
        public ushort u16AuxHeatArea1;		//辅助加热区1
        public bool fTemp_Enable1;          //加热器1升温开关
        public float fSetTemp_HeatArea1;	//加热器1温度设定值
        public float fActualTemp_HeatArea1;//加热器1温室实际值
        public ushort u16AuxHeatArea2;		//辅助加热区2
        public bool fTemp_Enable2;          //加热器2升温开关
        public float fSetTemp_HeatArea2;	//加热器2温度设定值
        public float fActualTemp_HeatArea2;//加热器2温室实际值
        #endregion
    }


    public class DevChromato
    {
        public ushort sChromSelect;		//选择的色谱柱
        public ushort u16ChromType;			//色谱柱模式
        public float fHigestTempSet;		//最高温度
        public float fLengthSet;			//长度设置
        public float fCalSet;					//口径设置
        public float fFilmThicknessSet;		//膜厚设置
        public string sDescribe;				//描述
        public float fPreSetValue;		        //压力设定值
        public float fPreActualValue;	//压力实际值
        public float fFlowSetValue;		//流量设定值
        public float fFlowActualValue;	//流量实际值
        public float fSetAverageLineSpeed;	//平均线速度
        public float fActualAverageLineSpeed;	//实际线速度
    }

    public class DevCol
    {
        public ushort u16KeyCol;			//柱箱开关
        public ushort u16ColProNum;         //程升阶段数
        public float fColTempSet;			//柱箱设定温度
        public float fColTempActual;		//柱箱实际温度
        public float fHigestTemp;			//柱箱最高温度
        public float fBalanceTime;			//平衡时间
        public float fSumProgramTime;		//总程序时间
        public float fBehindRunTemp;		//程升结束之后的运行温度
        public float fBehindRunTime;		//后运行时间
        public ushort u16FastColdTrap;		//快速冷阱
        public ushort u16StartTarp_Type;//启动冷阱（风扇）//  制冷剂
        public UNION_TEMP fCurTemp;			//实际温度

        public ushort uTcColStage;			//注箱进行程序升温的不同阶段
    }

    public class DevFid
    {
        public string sFid;		//Fid的位置
        public ushort u16SignalValve;	//信号值
        public ushort u16KeyFire;	//自动点火
        public ushort u16IsFire;    //是否已经点火
        public ushort u16Zero;		//调零
        public ushort u16Sensitive;	//灵敏度
        public ushort u16Polarity;	//极性
        public ushort u16KeyHeater;		//加热器开关
        public float fHeaterTempSet;  //加热器设定温度
        public float fHeaterActualTemp;//加热器实际温度
        public ushort u16KeyH2Flow;		//氢气流量开关
        public float fSetH2Flow;		//氢气流量设定值
        public float fActualH2Flow;	//氢气流量实际值
        public ushort u16KeyAirFlow;		//空气流量开关
        public float fAirFlowSet;			//空气流量设定值
        public float fAirFlowActual;		//空气流量实际值
        public ushort u16KeyTailGas;			//尾吹气开关
        public float fSetTailGas;			//尾吹气设定值
        public float fActualGasFlow;		//尾吹气实际
        public float fColumnFlowReference;//柱流量参考值
        public ushort u16SigDeduct;		//信号扣除

	  //  ushort u16FilterDepth;		//滤波深度
    }

    public class DevTcd
    {
        public string sTcdLoc;		        //TCD位置
        public float fSigValve;	        //信号值
        public ushort u16Electric;	        //桥流
        public ushort u16Polarity;	        //极性
	    public ushort u16AutoZeroSet;      //自动调零
	    public float fHeaterTempSet;		//加热器设定值
	    public float fHeaterTempActual;	//加热器实际值
	    public float fTaiGasSet;			//尾吹气设定值
	    public float fTaiGasActual;		//尾吹气实际值
	    public float fColumnFlowReference; //柱流量参考
	    public ushort u16SigDeduct;		//信号扣除
	    public ushort u16KeyBridgeFlow;    //桥流开关
	    public ushort u16FilterDepth;	    //滤波深度
        public ushort u16HeaterSel;	    //加热器
        public ushort u16TaiGasSel;	    //尾吹气
    };

    public class DevPort
    {
        public string sInjPortLoc;	//进样口位置
        public bool bHeater;			//加热器
        public float fHeaterSetTemp;	//加热器设定温度值
        public float fHeaterSetTempm;	//加热器modbus设定温度值
        public float fHeaterTempActual;//加热器实际温度值
        public float fSetPre;			//设定压力
        public float fPreActual;		//实际压力
        public float fSetSumFlow;		//总流量设定值
        public float fSumFlowActual;	//总流量实际值
        public float fSetPurgeFlow;	//隔垫吹扫流量设定值
        public float fPurgeFlowActual;	//隔垫吹扫流量实际值
        public float fSetColumnFlow;	//柱流量设定值
        public float fColumnFlowActual;	//柱流量实际值
        public string sWeatherShuntModel; //分流不分流模式
        public ushort u16SplitRatio;			//分流比
        public float fSplitFlow;			//分流流量
        public bool bCarrierGasSave;	    //载气节省开启
        public ushort u16CarrierGasSave;		//载气节省20ml/min
        public float fSaveGasTime;			//开始等待时间
    }

    public class DevInj
    {

        public string sSample;			//配备的进样器
        public float fSampleQuantity;	//进样量
        public float fInjectorSize;		//注射器尺寸
        public string sFrontSample;		//进样前样品
        public string sBSSolventA;		//进样前溶剂A
        public string sBSSolventB;		//进样前溶剂B
        public string sASSolventA;		//进样后溶剂A
        public string sASSolventB;		//进样后溶剂B
        public ushort u16PushPullTimes;		//推拉针芯次数

	    //其他参数
        //UNION_TEMP fCurTemp;			//进样室当前温度
        public float fSetTemp;			//进样室设定温度
    }

    public class DevValve
    {
        const int MAX_VALVE_NUM = 6;

        public bool[] bValveKey = new bool[MAX_VALVE_NUM];            //是否有阀存在
        public bool[] bHeaterKey = new bool[MAX_VALVE_NUM];           //是否有加热器
        public float[] fSetTemp = new float[MAX_VALVE_NUM];            //设定值
        public float[] fActualTemp = new float[MAX_VALVE_NUM];         //当前值
        public ushort[] u16ValveSetTime1 = new ushort[MAX_VALVE_NUM];
        public ushort[] u16ValveSetTime2 = new ushort[MAX_VALVE_NUM];
        public ushort[] u16ValveSetTime3 = new ushort[MAX_VALVE_NUM];
        public ushort[] u16ValveSetTime4 = new ushort[MAX_VALVE_NUM];
        public ushort[] u16ValveSetTime5 = new ushort[MAX_VALVE_NUM];
        public ushort[] u16ValveSetTime6 = new ushort[MAX_VALVE_NUM];
        public ushort[] u16ValveSetTime7 = new ushort[MAX_VALVE_NUM];
        public ushort[] u16ValveSetTime8 = new ushort[MAX_VALVE_NUM];

        public char[] ValveStatus = new char[MAX_VALVE_NUM];
    }

    public class DevRunTable
    {
        public ushort u16CycleTimes;	//循环次数
        public ushort u16WaitTime;	//等待时间
        //public string
    }


    public class DevSup
    {
        public float supActualTemp;
        public float supSetTemp;			//设定温度
    }

    public class DevSignal
    {
        public const int MAX_CHANNEL_NUM = 8;
        public ushort u16ChannelA; 	//A通道开关  0-关  1-开
        public ushort u16ChannelB; 	//B通道开关
        public ushort[] uDetA = new ushort[MAX_CHANNEL_NUM];	//A通道检测器
        public ushort[] uDetB = new ushort[MAX_CHANNEL_NUM];	//B通道检测器

        public ushort[] u16DetTimeLengthA = new ushort[MAX_CHANNEL_NUM];	//A/B第一时间段的检测时间
        public ushort[] u16DetTimeLengthB = new ushort[MAX_CHANNEL_NUM];	//A/B第二时间段的检测时间

        public ushort[] u16ZeroA = new ushort[MAX_CHANNEL_NUM];				//A/B第一时间段归零操作
        public ushort[] u16ZeroB = new ushort[MAX_CHANNEL_NUM];				//A/B第二时间段归零操作

        public ushort[] u16SaveA = new ushort[MAX_CHANNEL_NUM];				//A/B第一时间段保存操作
        public ushort[] u16SaveB = new ushort[MAX_CHANNEL_NUM];				//A/B第二时间段保存操作

    }

    public class DevSysPara
    {
        public string GCNum;        //仪器编号
        public string GCName;       //仪器名字
        public ushort u16Col;			//柱箱
        public ushort u16ColType;       //柱箱类型
        public ushort u16ColPTemp;       //柱箱保护温度
        public ushort u16ColCtl;		//柱箱控制方式
        public ushort u16InjPortNum;    //进样口数量
        public ushort u16InjPortFront;	//前进样口
        public ushort u16InjPortFPTemp;  //前进样口保护温度
        public ushort u16InjPortBehind;	//后进样口
        public ushort u16InjPortBPTemp;	//后进样口保护温度
        public ushort u16InjPortType_Front;		//前进样口类型
        public ushort u16InjPortCtlMode_Front; //前进样口控制方式
        public ushort u16InjPortLoadGas_Front; //前进样口载气
        public ushort u16InjPortType_Behind;		//前进样口类型
        public ushort u16InjPortCtlMode_Behind; //前进样口控制方式
        public ushort u16InjPortLoadGas_Behind; //前进样口载气

        public ushort u16ValveBox;      //阀箱
        public ushort u16ValveOne;		//阀1
        public ushort u16ValveOneCtl;   //阀1控制类型
        public ushort u16ValveTwo;		//阀2
        public ushort u16ValveThree;	//阀3
        public ushort u16ValveFour;		//阀4
        public ushort u16ValveFive;		//阀5
        public ushort u16ValveSix;		//阀6

        public ushort u16DetNum;        //检测器数量
        public ushort u16DetFront;		//前检测器
        public ushort u16DetFrontType;	//前检测器类型
        public ushort u16DetFrontPTemp;	//前检测器保护温度
        public ushort u16DetFrontAisle;	//前检测器通道
        public ushort u16DetInter;		//中检测器
        public ushort u16DetInterType;	//中检测器类型
        public ushort u16DetInterPTemp;	//中检测器保护温度
        public ushort u16DetInterAisle;	//中检测器通道
        public ushort u16DetBehind;		//后检测器
        public ushort u16DetBehindType;	//后检测器类型
        public ushort u16DetBehindPTemp;	//后检测器保护温度
        public ushort u16DetBehindAisle;	//后检测器通道

        public ushort u16SampleNum;      //进样器数量
        public ushort u16SampleFront;	//前进样器
        public ushort u16SampleBehind;	//后进样器

        public ushort u16AuxHeater;		//辅助加热器
        public ushort u16AuxHeaterNum;	//辅助加热数量
        public ushort u16AuxHeater1;	//辅助1
        public string u16AuxHeaterName1;	//辅助名字1
        public ushort u16AuxHeater2;	//辅助2
        public string u16AuxHeaterName2;	//辅助名字2

        public ushort u16ChromNum;	//色谱柱数量
        public ushort u16ChromFront;	//前色谱柱
        public ushort u16ChromFrontType; //前色谱柱类型
        public ushort u16ChromBehindType; //后色谱柱类型
        public ushort u16ChromBehind;	//后色谱柱
        public ushort u16StartType;		//启动方式
    }

    public class DevParamSet
    {
        public DevAux aux = new DevAux();
        public DevChromato [] chrom = new DevChromato[2];
        public DevCol col = new DevCol();
        public DevFid [] fid = new DevFid[3];
        public DevTcd [] tcd = new DevTcd[3];
        public DevPort [] port = new DevPort[2];
        public DevValve valve = new DevValve();
        public DevRunTable runtable = new DevRunTable();
        public DevSignal signal = new DevSignal();
        public DevSysPara syspara = new DevSysPara();
        public DevInj [] sample = new DevInj[2];
       // public DevSup [] devsup = new DevSup[2];

        public DevParamSet()
        {
            for (int i = 0; i < 2; i++)
            {
                chrom[i] = new DevChromato();
                fid[i] = new DevFid();
                tcd[i] = new DevTcd();
                port[i] = new DevPort();
                sample[i] = new DevInj();
            }
            fid[2] = new DevFid();
            tcd[2] = new DevTcd();

        }
    }

    public class Instrument
    {
        //int [10] pos = new int [10];
    }
}
