using MaiMuControl.SysStatusMgr.UserMgr; using Newtonsoft.Json.Linq; using SqlSugar; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ToolKits.Ini; using ToolKits.mAPI; namespace GeBoShi.SysCtrl { /// /// 设备参数 /// public class ConfMgr { #region 实例化 /// /// 实例 /// private static ConfMgr _instance; private static readonly object _lock = new object(); public static ConfMgr Instance { get { if (_instance == null) { lock (_lock) { if (_instance == null) { _instance = new ConfMgr(); } } } return _instance; } } #endregion #region 私有字段 private readonly string _rootPath; private readonly string _configFile; private readonly string _projectDir; #endregion private ConfMgr() { _rootPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles"); _configFile = Path.Combine(_rootPath, "SysParamsConfig.ini"); _devConfigPath = Path.Combine(_rootPath, "DevParamsConfig.ini"); _projectDir = Path.Combine(_rootPath, "Project"); _specificationPath = Path.Combine(_rootPath, "革博士软件操作说明.docx"); DBConStr = "server = localhost; Database = LeatherDB; Uid = root; Pwd = " + ConteolUserDB.GetSqlDBCode() + "; AllowLoadLocalInfile = true;"; } #region 公开字段 //DB //有些服务器防火墙有问题需要加上 min pool size=1 避免认为是恶意请求 //如果用到bulkCopy需要加: AllowLoadLocalInfile=true public string DBConStr = "server=localhost;Database=LeatherDB;Uid=root;Pwd=123456; AllowLoadLocalInfile=true"; /// /// 系统配置参数 /// public SysConfigParams SysConfigParams { get; set; } private string _devConfigPath; /// /// 获取驱动配制文件路径 /// public string DevConfigPath { get { return _devConfigPath; } } //public string ProjectDir { get { return _projectDir; } } public string ProjectDir { get { return SysConfigParams.ProductPath; } } /// /// 配置文件根路径 /// public string ConfigDir { get { return _rootPath; } } /// /// 说明书路径 /// public string SpecificationPath { get { return _specificationPath; } } private string _specificationPath; #endregion #region 公开文件操作 #region 系统配置参数 /// /// 写入ini /// /// public void WriteSysConfParams(SysConfigParams SysParams) { //XmlHelper.Serialize(_configFile, sysConfParams); IniHelper iniHelper = new IniHelper(_configFile); //iniHelper.WriteBool("SaveAllImg", "SaveAllImg", SysParams.SaveAllImg); iniHelper.WriteString("DefectSrcImag", "SavePath", SysParams.DefectSrcImag.SavePath); iniHelper.WriteBool("DefectSrcImag", "AutoSave", SysParams.DefectSrcImag.AutoSave); iniHelper.WriteBool("DefectSrcImag", "AutoDelete", SysParams.DefectSrcImag.AutoDelete); iniHelper.WriteDouble("DefectSrcImag", "AutoDeleteDays", SysParams.DefectSrcImag.AutoDeleteDays); iniHelper.WriteString("DefectSmallImag", "SavePath", SysParams.DefectSmallImag.SavePath); iniHelper.WriteBool("DefectSmallImag", "AutoSave", SysParams.DefectSmallImag.AutoSave); iniHelper.WriteBool("DefectSmallImag", "AutoDelete", SysParams.DefectSmallImag.AutoDelete); iniHelper.WriteDouble("DefectSmallImag", "AutoDeleteDays", SysParams.DefectSmallImag.AutoDeleteDays); iniHelper.WriteString("DefectSplicImag", "SavePath", SysParams.DefectSplicImag.SavePath); iniHelper.WriteBool("DefectSplicImag", "AutoSave", SysParams.DefectSplicImag.AutoSave); iniHelper.WriteBool("DefectSplicImag", "AutoDelete", SysParams.DefectSplicImag.AutoDelete); iniHelper.WriteDouble("DefectSplicImag", "AutoDeleteDays", SysParams.DefectSplicImag.AutoDeleteDays); iniHelper.WriteString("Log", "SavePath", SysParams.LogPath); iniHelper.WriteBool("Log", "AutoDelete", SysParams.AutoDeleteLog); iniHelper.WriteDouble("Log", "AutoDeleteDays", SysParams.AutoDeleteLogData); iniHelper.WriteBool("SysFunction", "OpenBuzzer", SysParams.OpenBuzzer); iniHelper.WriteBool("SysFunction", "OpenDoor", SysParams.OpenDoor); iniHelper.WriteBool("SysFunction", "OpenIO", SysParams.OpenIO); iniHelper.WriteBool("SysFunction", "OpenPLC", SysParams.OpenPLC); iniHelper.WriteString("Dev", "LightCom", SysParams.LightCom); iniHelper.WriteInteger("Dev", "LightComBaud", SysParams.LightComBaud); iniHelper.WriteString("Dev", "IODevName", SysParams.IODevName); iniHelper.WriteString("Dev", "IOCfgPath", SysParams.IOCfgPath); iniHelper.WriteString("Dev", "PLC_IP", SysParams.PLC_IP); iniHelper.WriteInteger("Dev", "PLC_Rack", SysParams.PLC_Rack); iniHelper.WriteInteger("Dev", "PLC_Solt", SysParams.PLC_Solt); iniHelper.WriteString("Dev", "CamPath_1", SysParams.CamPath_1); iniHelper.WriteInteger("Dev", "CamDev_1", SysParams.CamDev_1); iniHelper.WriteInteger("Dev", "CamIndex_1", SysParams.CamIndex_1); iniHelper.WriteString("Dev", "CamPath_2", SysParams.CamPath_2); iniHelper.WriteInteger("Dev", "CamDev_2", SysParams.CamDev_2); iniHelper.WriteInteger("Dev", "CamIndex_2", SysParams.CamIndex_2); iniHelper.WriteString("Sys", "AIModelPath", SysParams.AIModelPath); iniHelper.WriteString("Sys", "ProductPath", SysParams.ProductPath); iniHelper.WriteBool("ShowMainWin", "ShowResetBtn", SysParams.ShowResetBtn); iniHelper.WriteBool("ShowMainWin", "ShowBuzz", SysParams.ShowBuzz); iniHelper.WriteBool("ShowMainWin", "ShowDoorAlm", SysParams.ShowDoorAlm); iniHelper.WriteBool("CloudAndMES", "OpenCloud", SysParams.OpenCloud); iniHelper.WriteString("CloudAndMES", "CloudThisName", SysParams.CloudThisName); iniHelper.WriteString("CloudAndMES", "CloudServerIP", SysParams.CloudServerIP); iniHelper.WriteInteger("CloudAndMES", "CloudServerPort", SysParams.CloudServerPort); iniHelper.WriteString("CloudAndMES", "CloudUser", SysParams.CloudUser); iniHelper.WriteString("CloudAndMES", "CloudPassword", SysParams.CloudPassword); iniHelper.WriteBool("CloudAndMES", "OpenPdtServer", SysParams.OpenPdtServer); iniHelper.WriteString("CloudAndMES", "PdtServerIP", SysParams.PdtServerIP); iniHelper.WriteInteger("CloudAndMES", "PdtServerPort", SysParams.PdtServerPort); iniHelper.WriteBool("CloudAndMES", "IsPdtServer", SysParams.IsPdtServer); iniHelper.WriteBool("LabelPrint", "EnableLabelPrint", SysParams.EnableLabelPrint); iniHelper.WriteString("LabelPrint", "LabelPrinterName", SysParams.LabelPrinterName); iniHelper.WriteBool("ExcelPrint", "EnableExcelPrint", SysParams.EnableExcelPrint); iniHelper.WriteString("ExcelPrint", "ExcelPrinterName", SysParams.ExcelPrinterName); iniHelper.WriteString("ERP", "ErpDBConStr", SysParams.ErpDBConStr); iniHelper.WriteString("ERP", "ErpSql", SysParams.ErpSql); iniHelper.WriteString("Customer", "CustomerName", SysParams.CustomerName); iniHelper.WriteBool("FLIP", "Cam1_flipX", SysParams.Cam1_flipX); iniHelper.WriteBool("FLIP", "Cam1_flipY", SysParams.Cam1_flipY); iniHelper.WriteBool("FLIP", "Cam2_flipX", SysParams.Cam2_flipX); iniHelper.WriteBool("FLIP", "Cam2_flipY", SysParams.Cam2_flipY); iniHelper.WriteInteger("CMPX", "Cm2px_x", SysParams.Cm2px_x); iniHelper.WriteInteger("CMPX", "Cm2px_y", SysParams.Cm2px_y); iniHelper.WriteInteger("CMPX", "MidCoin", SysParams.MidCoin); iniHelper.WriteInteger("CMPX", "HolePx", SysParams.HolePx); iniHelper.WriteInteger("CMPX", "LCrop", SysParams.LCrop); iniHelper.WriteInteger("CMPX", "RCrop", SysParams.RCrop); iniHelper.WriteInteger("CMPX", "Expand_pixel", SysParams.Expand_pixel); SysConfigParams = SysParams; } /// /// 读取ini /// /// public SysConfigParams ReadSysConfParams() { //return XmlHelper.Deserialize(_configFile); SysConfigParams sysParams = new SysConfigParams(); IniHelper iniHelper = new IniHelper(_configFile); string sValue = ""; int iValue = 0; double dValue = 0; bool bValue = false; //iniHelper.ReadBool("SaveAllImg", "SaveAllImg", out bValue); //sysParams.SaveAllImg = bValue; iniHelper.ReadBool("SysFunction", "OpenBuzzer", out bValue); sysParams.OpenBuzzer = bValue; iniHelper.ReadBool("SysFunction", "OpenDoor", out bValue); sysParams.OpenDoor = bValue; iniHelper.ReadBool("SysFunction", "OpenIO", out bValue); sysParams.OpenIO = bValue; iniHelper.ReadBool("SysFunction", "OpenPLC", out bValue); sysParams.OpenPLC = bValue; iniHelper.ReadString("Dev", "LightCom", out sValue); sysParams.LightCom = sValue.Replace("\0", ""); iniHelper.ReadInteger("Dev", "LightComBaud", out iValue); sysParams.LightComBaud = iValue; iniHelper.ReadString("Dev", "IODevName", out sValue); sysParams.IODevName = sValue.Replace("\0", ""); iniHelper.ReadString("Dev", "IOCfgPath", out sValue); sysParams.IOCfgPath = sValue.Replace("\0", ""); iniHelper.ReadString("Dev", "PLC_IP", out sValue); sysParams.PLC_IP = sValue.Replace("\0", ""); iniHelper.ReadInteger("Dev", "PLC_Rack", out iValue); sysParams.PLC_Rack = iValue; iniHelper.ReadInteger("Dev", "PLC_Solt", out iValue); sysParams.PLC_Solt = iValue; iniHelper.ReadString("Dev", "CamPath_1", out sValue); sysParams.CamPath_1 = sValue.Replace("\0", ""); iniHelper.ReadInteger("Dev", "CamDev_1", out iValue); sysParams.CamDev_1 = iValue; iniHelper.ReadInteger("Dev", "CamIndex_1", out iValue); sysParams.CamIndex_1 = iValue; iniHelper.ReadString("Dev", "CamPath_2", out sValue); sysParams.CamPath_2 = sValue.Replace("\0", ""); iniHelper.ReadInteger("Dev", "CamDev_2", out iValue); sysParams.CamDev_2 = iValue; iniHelper.ReadInteger("Dev", "CamIndex_2", out iValue); sysParams.CamIndex_2 = iValue; iniHelper.ReadBool("CloudAndMES", "OpenCloud", out bValue); sysParams.OpenCloud = bValue; iniHelper.ReadString("CloudAndMES", "CloudThisName", out sValue); sysParams.CloudThisName = sValue.Replace("\0", string.Empty); iniHelper.ReadString("CloudAndMES", "CloudServerIP", out sValue); sysParams.CloudServerIP = sValue; iniHelper.ReadInteger("CloudAndMES", "CloudServerPort", out iValue); sysParams.CloudServerPort = iValue; iniHelper.ReadString("CloudAndMES", "CloudUser", out sValue); sysParams.CloudUser = sValue; iniHelper.ReadString("CloudAndMES", "CloudPassword", out sValue); sysParams.CloudPassword = sValue; iniHelper.ReadBool("CloudAndMES", "OpenPdtServer", out bValue); sysParams.OpenPdtServer = bValue; iniHelper.ReadString("CloudAndMES", "PdtServerIP", out sValue); sysParams.PdtServerIP = sValue; iniHelper.ReadInteger("CloudAndMES", "PdtServerPort", out iValue); sysParams.PdtServerPort = iValue; iniHelper.ReadBool("CloudAndMES", "IsPdtServer", out bValue); sysParams.IsPdtServer = bValue; iniHelper.ReadString("DefectSrcImag", "SavePath", out sValue); sysParams.DefectSrcImag.SavePath = sValue.Replace("\0", ""); iniHelper.ReadBool("DefectSrcImag", "AutoSave", out bValue); sysParams.DefectSrcImag.AutoSave = bValue; iniHelper.ReadBool("DefectSrcImag", "AutoDelete", out bValue); sysParams.DefectSrcImag.AutoDelete = bValue; iniHelper.ReadDouble("DefectSrcImag", "AutoDeleteDays", out dValue); sysParams.DefectSrcImag.AutoDeleteDays = dValue; iniHelper.ReadString("DefectSmallImag", "SavePath", out sValue); sysParams.DefectSmallImag.SavePath = sValue.Replace("\0", ""); iniHelper.ReadBool("DefectSmallImag", "AutoSave", out bValue); sysParams.DefectSmallImag.AutoSave = bValue; iniHelper.ReadBool("DefectSmallImag", "AutoDelete", out bValue); sysParams.DefectSmallImag.AutoDelete = bValue; iniHelper.ReadDouble("DefectSmallImag", "AutoDeleteDays", out dValue); sysParams.DefectSmallImag.AutoDeleteDays = dValue; iniHelper.ReadString("DefectSplicImag", "SavePath", out sValue); sysParams.DefectSplicImag.SavePath = sValue.Replace("\0", ""); iniHelper.ReadBool("DefectSplicImag", "AutoSave", out bValue); sysParams.DefectSplicImag.AutoSave = bValue; iniHelper.ReadBool("DefectSplicImag", "AutoDelete", out bValue); sysParams.DefectSplicImag.AutoDelete = bValue; iniHelper.ReadDouble("DefectSplicImag", "AutoDeleteDays", out dValue); sysParams.DefectSplicImag.AutoDeleteDays = dValue; iniHelper.ReadString("Sys", "AIModelPath", out sValue); sysParams.AIModelPath = sValue.Replace("\0", ""); iniHelper.ReadString("Sys", "ProductPath", out sValue); sysParams.ProductPath = sValue.Replace("\0", ""); iniHelper.ReadString("Log", "SavePath", out sValue); sysParams.LogPath = sValue.Replace("\0", ""); iniHelper.ReadBool("Log", "AutoDelete", out bValue); sysParams.AutoDeleteLog = bValue; iniHelper.ReadDouble("Log", "AutoDeleteDays", out dValue); sysParams.AutoDeleteLogData = dValue; iniHelper.ReadBool("ShowMainWin", "ShowResetBtn", out bValue); sysParams.ShowResetBtn = bValue; iniHelper.ReadBool("ShowMainWin", "ShowBuzz", out bValue); sysParams.ShowBuzz = bValue; iniHelper.ReadBool("ShowMainWin", "ShowDoorAlm", out bValue); sysParams.ShowDoorAlm = bValue; iniHelper.ReadBool("FLIP", "Cam1_flipX", out bValue); sysParams.Cam1_flipX = bValue; iniHelper.ReadBool("FLIP", "Cam1_flipY", out bValue); sysParams.Cam1_flipY = bValue; iniHelper.ReadBool("FLIP", "Cam2_flipX", out bValue); sysParams.Cam2_flipX = bValue; iniHelper.ReadBool("FLIP", "Cam2_flipY", out bValue); sysParams.Cam2_flipY = bValue; iniHelper.ReadInteger("CMPX", "Cm2px_x", out iValue); sysParams.Cm2px_x = iValue; iniHelper.ReadInteger("CMPX", "Cm2px_y", out iValue); sysParams.Cm2px_y = iValue; iniHelper.ReadInteger("CMPX", "MidCoin", out iValue); sysParams.MidCoin = iValue; iniHelper.ReadInteger("CMPX", "HolePx", out iValue); sysParams.HolePx = iValue; iniHelper.ReadInteger("CMPX", "LCrop", out iValue); sysParams.LCrop = iValue; iniHelper.ReadInteger("CMPX", "RCrop", out iValue); sysParams.RCrop = iValue; iniHelper.ReadInteger("CMPX", "Expand_pixel", out iValue); sysParams.Expand_pixel = iValue; iniHelper.ReadBool("LabelPrint", "EnableLabelPrint", out bValue); sysParams.EnableLabelPrint = bValue; iniHelper.ReadString("LabelPrint", "LabelPrinterName", out sValue); sysParams.LabelPrinterName = sValue; iniHelper.ReadBool("ExcelPrint", "EnableExcelPrint", out bValue); sysParams.EnableExcelPrint = bValue; iniHelper.ReadString("ExcelPrint", "ExcelPrinterName", out sValue); sysParams.ExcelPrinterName = sValue; iniHelper.ReadString("ERP", "ErpDBConStr", out sValue); sysParams.ErpDBConStr = sValue; iniHelper.ReadString("ERP", "ErpSql", out sValue); sysParams.ErpSql = sValue; iniHelper.ReadString("Customer", "CustomerName", out sValue); sysParams.CustomerName = sValue; iniHelper.ReadString("Material", "SuedeList", out sValue); if (!string.IsNullOrWhiteSpace(sValue)) sysParams.SuedeList = sValue.Split(new char[] { ',', ';' }); SysConfigParams = sysParams; return sysParams; } /// /// 写入系统默认配置 /// public void WriteDefaultSystemConfig() { SysConfigParams = new SysConfigParams(); WriteSysConfParams(SysConfigParams); } /// /// 加载系统配置 /// /// public bool LoadSystemConfig() { bool ret = false; if (!Directory.Exists(_rootPath)) { Directory.CreateDirectory(_rootPath); } if (!Directory.Exists(_projectDir)) { Directory.CreateDirectory(_projectDir); } if (File.Exists(_configFile)) { SysConfigParams = ReadSysConfParams(); if (null != SysConfigParams) { ret = true; } } else { // write default value WriteDefaultSystemConfig(); ret = true; } return ret; } #endregion #region 文件选择 /// /// 选择目录 /// /// public static string SelectFolder(string defaultPath = "") { FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.SelectedPath = (defaultPath != "" ? defaultPath : Path.GetFullPath(".")); if (dlg.ShowDialog() == DialogResult.OK) return dlg.SelectedPath; return ""; } /// /// 选择文件 /// /// 如 图像文件|*.jpg|图像文件|*.png|所有文件|*.* /// public static string SelectFile(string filter = "所有文件|*.*", string defaultPath = "") { OpenFileDialog fie = new OpenFileDialog(); fie.Title = "选择文件"; //fie.InitialDirectory = (defaultPath != "" ? defaultPath : Path.GetFullPath(".")); fie.Filter = filter; //设置文件类型 if (fie.ShowDialog() == DialogResult.OK) return fie.FileName; return ""; } /// /// 删除指定目录下文件 /// /// /// /// public static bool DelFilesInFolder(string FolderPath, string fileExtend = "*") { if (!Directory.Exists(FolderPath)) return false; string[] files = Directory.GetFiles(FolderPath, fileExtend, SearchOption.TopDirectoryOnly); foreach (string file in files) API.DeleteFile(file); return true; } /// /// 另存为 /// /// 默认文件名 /// 如 图像文件|*.jpg|图像文件|*.png|所有文件|*.* /// public static string SaveAsFile(string defaultFileName, string filter = "所有文件|*.*") { SaveFileDialog s = new SaveFileDialog(); s.Title = "保存文件"; s.Filter = filter; //"图像文件|*.jpg|图像文件|*.png|所有文件|*.*"; //s.DefaultExt = "图像文件|*.jpg"; //默认扩展名 //s.InitialDirectory = @"C:\Users\Administrator\Desktop"; //保存的初始目录 s.FileName = defaultFileName;//默认文件名 if (s.ShowDialog() == DialogResult.OK) return s.FileName; return ""; } #endregion #region json操作 //public static void addKey(JObject obj, string key, JToken value) //{ // if (obj.ContainsKey(key)) // obj[key] = value; // else // obj.Add(key, value); //} #endregion #region enum名称 public static ArrayList GetArrayList() { ArrayList list = new ArrayList(); Type type = typeof(T); //list.Add(new DictionaryEntry("start", "启动按钮")); foreach (int value in Enum.GetValues(type)) { string strName = Enum.GetName(type, value);//获取名称 list.Add(new DictionaryEntry(value, strName)); } return list; } #endregion #region 生产数据记录 public bool SetDailyOutputAdd(out int tDailyOutput) { bool ret = true; try { //读取数据 string tempFile = Path.Combine(_rootPath, "DailyOutput.ini"); IniHelper iniHelper = new IniHelper(tempFile); int iValue = 0; iniHelper.ReadInteger("TempData", "DailyOutput", out iValue); tDailyOutput = iValue; iniHelper.ReadInteger("TempData", "Date", out iValue); int dateNum = iValue; int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd")); if (dateNum == nowDateNum) { //同一天,生产数量+1 tDailyOutput++; } else if (dateNum < nowDateNum) { //昨天数据,为1 tDailyOutput = 1; } //重新记录 iniHelper.WriteInteger("TempData", "DailyOutput", tDailyOutput); iniHelper.WriteInteger("TempData", "Date", nowDateNum); } catch (Exception ex) { tDailyOutput = 0; ret = false; string tempFile = Path.Combine(_rootPath, "DailyOutput.ini"); IniHelper iniHelper = new IniHelper(tempFile); int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd")); //重新记录 iniHelper.WriteInteger("TempData", "DailyOutput", tDailyOutput); iniHelper.WriteInteger("TempData", "Date", nowDateNum); } return ret; } public bool GetDailyOutput(out int tDailyOutput) { bool ret = true; try { //读取数据 string tempFile = Path.Combine(_rootPath, "DailyOutput.ini"); IniHelper iniHelper = new IniHelper(tempFile); int iValue = 0; iniHelper.ReadInteger("TempData", "DailyOutput", out iValue); tDailyOutput = iValue; iniHelper.ReadInteger("TempData", "Date", out iValue); int dateNum = iValue; int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd")); if (dateNum == nowDateNum) { //同一天,生产数量+1 //tDailyOutput++; } else if (dateNum < nowDateNum) { //昨天数据,为1 tDailyOutput = 0; } } catch (Exception ex) { tDailyOutput = 0; ret = false; } return ret; } #endregion #region ERP数据库 private SqlSugarClient db; public SqlSugarClient getErpDBCon(SqlSugar.DbType dbType = SqlSugar.DbType.SqlServer) { if (string.IsNullOrEmpty(SysConfigParams.ErpDBConStr)) return null; if (db != null) return db; db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = SysConfigParams.ErpDBConStr, DbType = dbType, IsAutoCloseConnection = true }, db => { db.Aop.OnLogExecuting = (sql, pars) => { Console.WriteLine(sql);//输出sql,查看执行sql 性能无影响 //获取原生SQL推荐 5.1.4.63 性能OK //UtilMethods.GetNativeSql(sql,pars) //获取无参数化SQL 对性能有影响,特别大的SQL参数多的,调试使用 //UtilMethods.GetSqlString(DbType.SqlServer,sql,pars) }; }); return db; } public DataTable execSql(string sql, List parameters, SqlSugar.DbType dbType = SqlSugar.DbType.SqlServer) { //查询表的所有 var mydb = getErpDBCon(dbType); if (mydb == null) return null; if (!mydb.Ado.IsValidConnection()) mydb.Ado.Open(); return mydb.Ado.GetDataTable(sql, parameters); } #endregion #endregion } #region 参数类型 /// /// 图片保存参数 /// [Serializable] public class ImageSaveParam { /// /// 保存路径 /// public string SavePath { get; set; } /// /// 自动保存 /// public bool AutoSave { get; set; } /// /// 自动删除 /// public bool AutoDelete { get; set; } /// /// 自动删除日期 /// public double AutoDeleteDays { get; set; } public ImageSaveParam() { SavePath = "D:\\AllImageSave"; AutoSave = true; AutoDelete = true; AutoDeleteDays = 3; } public ImageSaveParam(string path) { SavePath = path; AutoSave = true; AutoDelete = true; AutoDeleteDays = 3; } } [Serializable] public class SysConfigParams { #region 缺陷图 /// /// 缺陷原大图 /// public ImageSaveParam DefectSrcImag { get; set; } /// /// 缺陷合并图 /// public ImageSaveParam DefectSplicImag { get; set; } /// /// 缺陷小图 /// public ImageSaveParam DefectSmallImag { get; set; } #endregion #region 功能 /// /// 开启蜂鸣器 /// public bool OpenBuzzer { get; set; } /// /// 开启门磁 /// public bool OpenDoor { get; set; } /// /// 开启IO /// public bool OpenIO { get; set; } /// /// 开启PLC /// public bool OpenPLC { get; set; } #endregion #region 硬件传感器通信 /// /// 光源串口 /// //public LightParams LightCfg { get; set; } public string LightCom { get; set; } /// /// 光源波特率 /// public int LightComBaud { get; set; } #endregion #region IO/电机/相机 /// /// 西门子PLC IP /// public string PLC_IP { get; set; } /// /// 西门子PLC 端口 /// public int PLC_Rack { get; set; } /// /// 西门子PLC 端口 /// public int PLC_Solt { get; set; } /// /// IO驱动名称 /// //public IOParams IOCfg { get; set; } public string IODevName { get; set; } /// /// IO配置文件路径 /// public string IOCfgPath { get; set; } /// /// 相机序号 /// public int CamIndex_1 { get; set; } /// /// 相机板卡序号 /// public int CamDev_1 { get; set; } /// /// 相机配置文件 /// public string CamPath_1 { get; set; } /// /// 相机序号 /// public int CamIndex_2 { get; set; } /// /// 相机板卡序号 /// public int CamDev_2 { get; set; } /// /// 相机配置文件 /// public string CamPath_2 { get; set; } #endregion #region 系统 public string AIModelPath { get; set; } public string ProductPath { get; set; } public string LogPath { get; set; } public bool AutoDeleteLog { get; set; } public double AutoDeleteLogData { get; set; } /// /// 调试:主界面显示复位按钮 /// public bool ShowResetBtn { get; set; } /// /// 调试:主界面显示蜂鸣器控制 /// public bool ShowBuzz { get; set; } /// /// 调试:主界面显示门磁报警控制 /// public bool ShowDoorAlm { get; set; } /// /// 1cm X方向像素 /// public int Cm2px_x = 1; /// /// 1cm Y方向像素 /// public int Cm2px_y = 1; /// /// 对比度范围阔算 /// public int Expand_pixel = 50; /// /// 中间重合像素 /// public int MidCoin = 100; /// /// 孔位 /// public int HolePx = 100; /// /// 左侧裁剪 /// public int LCrop = 0; /// /// 右侧裁剪 /// public int RCrop = 0; /// /// 相机1X翻转 /// public bool Cam1_flipX { get; set; } /// /// 相机1Y翻转 /// public bool Cam1_flipY { get; set; } /// /// 相机2X翻转 /// public bool Cam2_flipX { get; set; } /// /// 相机2Y翻转 /// public bool Cam2_flipY { get; set; } #endregion #region Http/MES #endregion #region MQTT本地云/产品服务器 /// /// 开启局域网云端 /// public bool OpenCloud { get; set; } public string CloudThisName { get; set; } public string CloudServerIP { get; set; } public int CloudServerPort { get; set; } public string CloudUser { get; set; } public string CloudPassword { get; set; } /// /// 开启产品转发 /// public bool OpenPdtServer { get; set; } public string PdtServerIP { get; set; } public int PdtServerPort { get; set; } /// /// 是否作为服务器还是客户端 /// public bool IsPdtServer { get; set; } #endregion #region BarTender /// /// 开启标签打印 /// public bool EnableLabelPrint { get; set; } /// /// 打印机名称 /// public string LabelPrinterName { get; set; } #endregion #region Excel /// /// 开启Excel打印 /// public bool EnableExcelPrint { get; set; } /// /// 打印机名称 /// public string ExcelPrinterName { get; set; } #endregion #region ERP /// /// 禾欣ERP数据库 /// public string ErpDBConStr { get; set; } /// /// 禾欣ERP数据读取 /// public string ErpSql { get; set; } #endregion #region 客户 /// /// 客户名 /// public string CustomerName { get; set; } #endregion #region 材质配合禾欣 //材质Material public string[] SuedeList = new string[0]; #endregion public SysConfigParams() { DefectSrcImag = new ImageSaveParam("D:\\Image\\DefectSrcImag"); DefectSmallImag = new ImageSaveParam("D:\\Image\\DefectSmallImag"); DefectSplicImag = new ImageSaveParam("D:\\Image\\DefectSplicImag"); OpenBuzzer = true; OpenDoor = true; OpenIO = true; OpenPLC = true; IODevName = ""; IOCfgPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\IOCard_default.xml"); ; LightCom = ""; LightComBaud = 9600; PLC_IP = "192.168.0.1"; PLC_Rack = 0; PLC_Solt = 1; CamIndex_1 = 0; CamIndex_2 = 0; CamDev_1 = 0; CamDev_2 = 1; CamPath_1 = ""; CamPath_2 = ""; AIModelPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\Models"); ProductPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\Project"); LogPath = Path.Combine(Directory.GetCurrentDirectory(), "LogFiles"); AutoDeleteLog = false; AutoDeleteLogData = 0; ShowResetBtn = true; ShowBuzz = false; ShowDoorAlm = false; EnableLabelPrint = false; LabelPrinterName = ""; EnableExcelPrint = false; ExcelPrinterName = ""; OpenCloud = false; CloudThisName = "Test"; CloudServerIP = "127.0.0.1"; CloudServerPort = 1883; CloudUser = ""; CloudPassword = ""; OpenPdtServer = false; PdtServerIP = "127.0.0.1"; PdtServerPort = 10573; IsPdtServer = true; ErpDBConStr = ""; ErpSql = ""; CustomerName = ""; Cam1_flipX = false; Cam1_flipY = false; Cam2_flipX = false; Cam2_flipY = false; } } #endregion }