using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace GcDevicePc.GCBuffer
{
    class PCBuffer
    {
        public struct FolderInfo
        {
            public string DataFolder;        //数据保存目录
            public string RunFolder;         //当前程序运行目录
            public string MethodFolder;      //当前方法目录
            public string StatusFolder;      //当前配置目录
            public string SubStatusFolder;   //当前配置子目录
            public string RunTabFolder;      //当前运行表目录
            public string FwFolder;      //固件更新目录
            public string TmpFolder;      //TMPFile目录
            public string LogFolder;      //Log目录
        }

        public struct GCFileInfo
        {
            public string cur_MethodName;     //当前使用方法名
            public string cur_BATMethodName;     //当前批处理方法名
            public string new_MethodName;     //新建使用方法名
            public string cur_OpenMethodName; //当前打开方法名
            public string cur_StatusName;     //当前设备配置名
            public string cur_RunTab;         //当前运行表名
            public string config_RunTab;         //配置中运行表名
            public string cur_DataName;       //保存数据文件名
            public string show_MethodName;    //显示方法名
        }

        public struct WorkInfo
        {
            public bool system_Statue;  //系统开启状态
            public ushort work_Statue;  //系统工作状态
            public ushort RunType;  //运行类型  0 打开运行  1 智能运行 2 批处理
           // public bool sendtohw;
        }

        public struct ModuleInfo
        {
            public string ip;
            public string mask;
            public string gw;
        }


        public struct OutPutInfo
        {
            public byte port;
        }

        public struct ThreadInfo
        {
            public ushort HMI_Monitor_TH;   // 0 --线程结束  1--线程运行中
        }

        public struct PCInfo
        {
            public FolderInfo pcfolderinfo;
            public GCFileInfo pcfileinfo;
            public WorkInfo pcworkinfo;
            public ModuleInfo moduleinfo;
            public ThreadInfo pcthreadinfo;

            public OutPutInfo outputinfo;
        }

        public PCInfo gcpcinfo = new PCInfo();

        public PCBuffer()
        {
            gcpcinfo.pcfolderinfo.DataFolder = null;
            gcpcinfo.pcfolderinfo.RunFolder = null;
            gcpcinfo.pcfolderinfo.MethodFolder = null;
            gcpcinfo.pcfolderinfo.StatusFolder = null;
            gcpcinfo.pcfolderinfo.SubStatusFolder = null;
            gcpcinfo.pcfolderinfo.RunTabFolder = null;
            gcpcinfo.pcfolderinfo.FwFolder = null;
            gcpcinfo.pcfolderinfo.TmpFolder = null;
            gcpcinfo.pcfolderinfo.LogFolder = null;

            gcpcinfo.pcfileinfo.cur_MethodName = null;
            gcpcinfo.pcfileinfo.cur_BATMethodName = null;
            gcpcinfo.pcfileinfo.new_MethodName = null;
            gcpcinfo.pcfileinfo.cur_OpenMethodName = null;
            gcpcinfo.pcfileinfo.cur_StatusName = null;
            gcpcinfo.pcfileinfo.cur_RunTab = null;
            gcpcinfo.pcfileinfo.config_RunTab = null;
            gcpcinfo.pcfileinfo.cur_DataName = null;
            gcpcinfo.pcfileinfo.show_MethodName = null;

            gcpcinfo.pcworkinfo.system_Statue = false;
            gcpcinfo.pcworkinfo.work_Statue = 0;

            gcpcinfo.moduleinfo.ip = "";

            gcpcinfo.outputinfo.port = 0;

            string file = System.Windows.Forms.Application.StartupPath + "\\startup.ini";


            if (File.Exists(file))
            {
                INIOperation test = new INIOperation(file);
                string opensys = test.INIGetStringValue("StartUp", "打开系统", null);
                string runtype = test.INIGetStringValue("StartUp", "运行类型", null);

                string wtd624x_ip = test.INIGetStringValue("WTD624X", "IP", null);
                string wtd624x_mask = test.INIGetStringValue("WTD624X", "MASK", null);
                string wtd624x_gw = test.INIGetStringValue("WTD624X", "GW", null);


                string gc485 = test.INIGetStringValue("GC485", "COM", null);

                //string senddata = test.INIGetStringValue("StartUp", "SendData", null);

                if (Convert.ToInt32(opensys) == 1)
                {
                    gcpcinfo.pcworkinfo.RunType = Convert.ToUInt16(runtype);
                }

                if (!String.IsNullOrEmpty(wtd624x_ip))
                {
                    gcpcinfo.moduleinfo.ip = wtd624x_ip;
                }

                if (!String.IsNullOrEmpty(wtd624x_mask))
                {
                    gcpcinfo.moduleinfo.mask = wtd624x_mask;
                }

                if (!String.IsNullOrEmpty(wtd624x_gw))
                {
                    gcpcinfo.moduleinfo.gw = wtd624x_gw;
                }

                if (!String.IsNullOrEmpty(gc485))
                {
                    gcpcinfo.outputinfo.port = Convert.ToByte(gc485);
                }
            }
           
           // gcpcinfo.pcworkinfo.RunType = 0;   //运行类型  0 打开运行  1 智能运行 2 批处理

        }

    }
}
