|
- using CCWin.SkinClass;
- using MaiMuControl.SysStatusMgr.UserMgr;
- using Models;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using ToolKits.Ini;
- using ToolKits.mAPI;
- using ToolKits.PLC;
-
- namespace MaiMuAOI.SysCtrl
- {
- #region 参数类型
- /// <summary>
- /// 图片保存参数
- /// </summary>
- [Serializable]
- public class ImageSaveParam
- {
- /// <summary>
- /// 保存路径
- /// </summary>
- public string SavePath { get; set; }
- /// <summary>
- /// 自动保存
- /// </summary>
- public bool AutoSave { get; set; }
- /// <summary>
- /// 自动删除
- /// </summary>
- public bool AutoDelete { get; set; }
- /// <summary>
- /// 自动删除日期
- /// </summary>
- 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;
- }
- }
- /// <summary>
- /// 镜头对应Z轴高度
- /// </summary>
- [Serializable]
- public class LensAxisZ
- {
- public double Z_0_58X { get; set; }
- //public double Z_0_6X { get; set; }
- public double Z_1_0X { get; set; }
- public double Z_1_5X { get; set; }
- public double Z_2_0X { get; set; }
- public double Z_2_5X { get; set; }
- public double Z_3_0X { get; set; }
- public double Z_3_5X { get; set; }
- public double Z_4_0X { get; set; }
- public double Z_4_5X { get; set; }
- public double Z_5_0X { get; set; }
- public double Z_5_5X { get; set; }
- public double Z_6_0X { get; set; }
- public double Z_6_5X { get; set; }
- public double Z_7_0X { get; set; }
- public double Z_7_5X { get; set; }
- public LensAxisZ()
- {
- Z_0_58X = 0;
- //Z_0_6X = 0;
- Z_1_0X = 0;
- Z_1_5X = 0;
- Z_2_0X = 0;
- Z_2_5X = 0;
- Z_3_0X = 0;
- Z_3_5X = 0;
- Z_4_0X = 0;
- Z_4_5X = 0;
- Z_5_0X = 0;
- Z_5_5X = 0;
- Z_6_0X = 0;
- Z_6_5X = 0;
- Z_7_0X = 0;
- Z_7_5X = 0;
- }
- }
- [Serializable]
- public class SysConfigParams
- {
- #region 缺陷图
- public string Defect_SrcSmall_SavePath { get; set; }
-
- public double Defect_SrcSmall_Thres { get; set; }
- /// <summary>
- /// 保存所有图片
- /// </summary>
- public bool SaveAllImg { get; set; }
- /// <summary>
- /// 缺陷大图
- /// </summary>
- public ImageSaveParam DefectBigImag { get; set; }
- /// <summary>
- /// 缺陷原始小图
- /// </summary>
- public ImageSaveParam DefectSrcSmallImag { get; set; }
- /// <summary>
- /// 缺陷小图
- /// </summary>
- public ImageSaveParam DefectSmallImag { get; set; }
- /// <summary>
- /// 修复台 缺陷图
- /// </summary>
- public ImageSaveParam DefectRepairImag { get; set; }
- /// <summary>
- /// 对比大图
- /// </summary>
- public ImageSaveParam SizeBigImag { get; set; }
- /// <summary>
- /// 对比未通过
- /// </summary>
- public ImageSaveParam SizeNGImag { get; set; }
- /// <summary>
- /// 修复台 对比图
- /// </summary>
- public ImageSaveParam SizeRepairImag { get; set; }
- #endregion
-
- #region 功能
- /// <summary>
- /// mark报警暂停
- /// </summary>
- public bool OpenMarkErrorStop { get; set; }
- /// <summary>
- /// 开启蜂鸣器
- /// </summary>
- public bool OpenBuzzer { get; set; }
- /// <summary>
- /// 开启门磁
- /// </summary>
- public bool OpenDoor { get; set; }
- /// <summary>
- /// 开启http日志
- /// </summary>
- public bool OpenHttpLog { get; set; }
- /// <summary>
- /// 开启软件开启自动回原
- /// </summary>
- public bool OpenAutoGoHome { get; set; }
- /// <summary>
- /// 启用缺陷分布功能
- /// </summary>
- public bool OpenFlawDistribution { get; set; }
- /// <summary>
- /// 启用X轴校准 2023-12-20
- /// </summary>
- public bool OpenAxisXCalibration { get; set; }
-
- /// <summary>
- /// 产品有无信号关闭
- /// </summary>
- public bool OpenPdtIsHave { get; set; }
-
- /// <summary>
- /// 开启查看功能
- /// </summary>
- public bool OpenDefectSanp { get; set; }
-
- /// <summary>
- /// 开启单边目数计算
- /// </summary>
- public bool OpenAsideDefect{ get; set; }
-
- /// <summary>
- /// 开启工单确认
- /// </summary>
- public bool OpenOredrCheck { get; set; }
- /// <summary>
- /// 开启工单数量确认
- /// </summary>
- public bool OpenOredrCntCheck { get; set; }
-
- /// <summary>
- /// 开启显示打标图片
- /// </summary>
- public bool OpenShowDB { get; set; }
-
- /// <summary>
- /// 开启彩色相机使用B通道
- /// </summary>
- public bool OpenColorB { get; set; }
-
- /// <summary>
- /// 开启比对和缺陷去重复
- /// </summary>
- public bool OpenRemoveDuplicates { get; set; }
-
- #endregion
-
- #region 硬件传感器通信
- /// <summary>
- /// 光源串口
- /// </summary>
- //public LightParams LightCfg { get; set; }
- public string LightCom { get; set; }
- /// <summary>
- /// 光源波特率
- /// </summary>
- public int LightComBaud { get; set; }
-
- /// <summary>
- /// 张力传感器串口
- /// </summary>
- public string TensionCom { get; set; }
- /// <summary>
- /// 张力传感器波特率
- /// </summary>
- public int TensionComBaud { get; set; }
- /// <summary>
- /// 张力偏移值
- /// </summary>
- public double Tension_Offset = 0;
-
- /// <summary>
- /// 镜头电机串口
- /// </summary>
- public string LensMotorCom { get; set; }
- /// <summary>
- /// 镜头电机波特率
- /// </summary>
- public int LensMotorComBaud { get; set; }
-
- /// <summary>
- /// 厚度传感器IP
- /// </summary>
- public string ThicknessIP { get; set; }
- /// <summary>
- /// 厚度传感器port
- /// </summary>
- public int ThicknessPort { get; set; }
- /// <summary>
- /// 测厚安全值
- /// </summary>
- public double ThicknessSafeValue { get; set; }
- /// <summary>
- /// 测厚调试偏移值
- /// </summary>
- public double Thickness_Offset = 0;
- #endregion
-
- #region IO/电机/相机
- /// <summary>
- /// IO驱动名称
- /// </summary>
- //public IOParams IOCfg { get; set; }
- public string IODevName { get; set; }
- /// <summary>
- /// IO配置文件路径
- /// </summary>
- public string IOCfgPath { get; set; }
-
- /// <summary>
- /// 电机配置文件路径
- /// </summary>
- public string MotionCfgPath { get; set; }
-
- /// <summary>
- /// 前部相机名称
- /// </summary>
- public string FrontCamName { get; set; }
- /// <summary>
- /// 前部相机配置文件路径
- /// </summary>
- public string FrontCamCfgPath { get; set; }
-
- /// <summary>
- /// 后部相机名称
- /// </summary>
- public string BackCamName { get; set; }
- /// <summary>
- /// 后部相机配置文件路径
- /// </summary>
- public string BackCamCfgPath { get; set; }
- #endregion
-
- #region 禁用
- public bool DisableX1 { get; set; }
- public bool DisableX2 { get; set; }
- public bool DisableY { get; set; }
- public bool DisableZ { get; set; }
- public bool DisableFrontCam { get; set; }
- public bool DisableBackCam { get; set; }
- public bool DisableLight { get; set; }
- public bool DisableTensor { get; set; }
- public bool DisableThickness { get; set; }
- public bool DisableLensMotor { get; set; }
- #endregion
-
- #region 系统
- public string ImageProcessPath { get; set; }
- public string ImageProcessDataPath { get; set; }
- public string AIModelPath { get; set; }
- public string ProductPath { get; set; }
- public string HttpServerIP { get; set; }
- public int HttpServerPort { get; set; }
- public string LogPath { get; set; }
- public bool AutoDeleteLog { get; set; }
- public double AutoDeleteLogData { get; set; }
-
- /// <summary>
- /// 调试:主界面显示复位按钮
- /// </summary>
- public bool ShowResetBtn { get; set; }
- /// <summary>
- /// 调试:主界面显示蜂鸣器控制
- /// </summary>
- public bool ShowBuzz { get; set; }
- /// <summary>
- /// 调试:主界面显示门磁报警控制
- /// </summary>
- public bool ShowDoorAlm { get; set; }
- /// <summary>
- /// 调试:显示分布
- /// </summary>
- public bool ShowDistribution { get; set; }
- /// <summary>
- /// 调试:显示尺寸检测禁用和启用
- /// </summary>
- public bool ShowSizeBtn { get; set; }
- /// <summary>
- /// 调试:显示缺陷检测禁用和启用
- /// </summary>
- public bool ShowDefectBtn { get; set; }
-
- /// <summary>
- /// 后部相机视野X
- /// </summary>
- public double DefectCamViewX { get; set; }
- /// <summary>
- /// 后部相机视野Y
- /// </summary>
- public double DefectCamViewY { get; set; }
- #endregion
-
- #region Http/MES
- /// <summary>
- /// 开启http上传
- /// </summary>
- public bool EnableHttp { get; set; }
- /// <summary>
- /// 上传Http地址
- /// </summary>
- public string HttpUrl { get; set; }
- /// <summary>
- /// 上传Json模板路径
- /// </summary>
- public string HttpTempPath { get; set; }
- /// <summary>
- /// 返回值Key
- /// </summary>
- public string HttpReturnKey{ get; set; }
- /// <summary>
- /// 返回成功value
- /// </summary>
- public string HttpReturnValue { get; set; }
- #endregion
-
- #region MQTT本地云/产品服务器
- /// <summary>
- /// 开启局域网云端
- /// </summary>
- 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; }
-
- /// <summary>
- /// 开启产品转发
- /// </summary>
- public bool OpenPdtServer { get; set; }
- public string PdtServerIP { get; set; }
- public int PdtServerPort { get; set; }
- /// <summary>
- /// 是否作为服务器还是客户端
- /// </summary>
- public bool IsPdtServer { get; set; }
- #endregion
-
- #region 聚焦
- /// <summary>
- /// 聚焦对应Z轴位置
- /// </summary>
- public LensAxisZ LensAxisZPos { get; set; }
- #endregion
-
- #region 缺陷分割
- //缺陷配置
- public Size Defect_CutSize { get; set; }
- public Size Defect_ReSize { get; set; }
- public float Defect_Thresholds { get; set; }
- #endregion
-
- #region BarTender
- /// <summary>
- /// 开启标签打印
- /// </summary>
- public bool EnableLabelPrint { get; set; }
- /// <summary>
- /// 打印机名称
- /// </summary>
- public string LabelPrinterName { get; set; }
- /// <summary>
- /// 打印模板路径
- /// </summary>
- public string LabelTempPath { get; set; }
- /// <summary>
- /// 打印信息
- /// </summary>
- public Dictionary<string, string> LabelData { get; set; }
- #endregion
-
- #region Excel
- /// <summary>
- /// 开启Excel打印
- /// </summary>
- public bool EnableExcelPrint { get; set; }
- /// <summary>
- /// 打印机名称
- /// </summary>
- public string ExcelPrinterName { get; set; }
- /// <summary>
- /// 打印模板路径
- /// </summary>
- public string ExcelTempPath { get; set; }
- /// <summary>
- /// 打印信息
- /// </summary>
- public Dictionary<string, string> ExcelData { get; set; }
- #endregion
-
- #region 老流程PT线宽补偿
- public double Pt_offset { get; set; }
- public double Line_offset { get; set; }
- #endregion
-
- #region 左上角比例调整
- public double X_per{ get; set; }
- public double Y_per { get; set; }
- #endregion
-
- #region 缺陷查看
- public int LightCH { get; set; }
- public int LightLut { get; set; }
- public int CamExposureTime { get; set; }
- #endregion
-
- #region 其他
- /// <summary>
- /// 光源通道
- /// </summary>
- public int LightChannelCnt { get; set; }
- /// <summary>
- /// 客户名称,不同客户可能存在差异
- /// </summary>
- public string CustomerName { get; set; }
- /// <summary>
- /// 缺陷相机分辨率
- /// </summary>
- public double DefectCamPixel { get; set; }
-
-
- #endregion
- public SysConfigParams()
- {
- DefectBigImag = new ImageSaveParam("D:\\Image\\缺陷图");
- DefectSrcSmallImag = new ImageSaveParam("D:\\Image\\缺陷原始小图");
- DefectSmallImag = new ImageSaveParam("D:\\Image\\缺陷小图");
- DefectRepairImag = new ImageSaveParam("D:\\Image\\修复台复现图片");
- SizeBigImag = new ImageSaveParam("D:\\Image\\尺寸图");
- SizeNGImag = new ImageSaveParam("D:\\Image\\未通过图片");
- SizeRepairImag = new ImageSaveParam("D:\\Image\\打标未通过图片");
- OpenMarkErrorStop = true;
- OpenBuzzer = true;
- OpenDoor = true;
- OpenHttpLog = false;
- OpenPdtIsHave = true;
- OpenDefectSanp = false;
- OpenAsideDefect = true;
- OpenOredrCheck = false;
- OpenOredrCntCheck = false;
- OpenShowDB = false;
-
- //LightCfg = new LightParams();
- //IOCfg = new IOParams();
- IODevName = "PCI-1730,BID#0";
- IOCfgPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\IOCard_default.xml"); ;
- LightCom = "COM2";
- LightComBaud = 9600;
- LensMotorCom = "COM1";
- LensMotorComBaud = 9600;
- TensionCom = "COM3";
- TensionComBaud = 2400;
- ThicknessIP = "192.168.0.50";
- ThicknessPort = 64000;
- ThicknessSafeValue = 10;
- FrontCamCfgPath = "";
- BackCamCfgPath = "C:\\Program Files (x86)\\Common Files\\MVS\\Runtime\\Win64_x64\\MvFGProducerCXP.cti";
- MotionCfgPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\Axis_default.cfg"); ;
-
- SaveAllImg = true;
- DisableX1 = false;
- DisableX2 = false;
- DisableY = false;
- DisableZ = false;
- DisableFrontCam = false;
- DisableBackCam = false;
- DisableLight = false;
- DisableLensMotor = false;
- DisableTensor = false;
- DisableThickness = false;
-
- ImageProcessPath = "C:\\Users\\user\\AppData\\Local\\Programs\\MVTec\\HALCON-21.05-Progress\\procedures\\general";
- ImageProcessDataPath = "C:\\Users\\PC\\AppData\\Local\\Programs\\MVTec\\HALCON-21.05-Progress\\procedures\\User_Data\\HomMat2D1M2CCDpose";
- AIModelPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\onnxFiles");
- ProductPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\Project");
- HttpServerIP = "192.168.123.100";
- HttpServerPort = 18082;
- LogPath = Path.Combine(Directory.GetCurrentDirectory(), "LogFiles");
- AutoDeleteLog = false;
- AutoDeleteLogData = 0;
-
- ShowResetBtn = true;
- ShowBuzz = false;
- ShowDoorAlm = false;
- ShowDistribution = false;
- ShowSizeBtn = false;
- ShowDefectBtn = false;
-
- DefectCamViewX = 35.5;
- DefectCamViewY = 26.5;
-
- EnableHttp = false;
- HttpUrl = "";
- HttpTempPath = "";
- HttpReturnKey = "";
- HttpReturnValue = "";
-
- LensAxisZPos = new LensAxisZ();
- //缺陷配置
- Defect_CutSize = new Size(592, 532);
- Defect_ReSize = new Size(224, 224);
- Defect_Thresholds = 0.4f;
-
- EnableLabelPrint = false;
- LabelPrinterName = "";
- LabelTempPath = "";
- LabelData = new Dictionary<string, string>();
-
- EnableExcelPrint = false;
- ExcelPrinterName = "";
- ExcelTempPath = "";
- ExcelData = new Dictionary<string, string>();
-
- OpenCloud = false;
- CloudThisName = "Test";
- CloudServerIP = "127.0.0.1";
- CloudServerPort = 1883;
- CloudUser = "";
- CloudPassword = "";
-
- OpenPdtServer = false;
- PdtServerIP = "127.0.0.1";
- PdtServerPort = 10573;
- IsPdtServer = true;
-
- Pt_offset = 0;
- Line_offset = 0;
-
- X_per = 0.1;
- Y_per = 0.1;
-
- LightCH = 2;
- LightLut = 255;
- CamExposureTime = 8000;
-
- LightChannelCnt = 4;
- CustomerName = "";
- DefectCamPixel = 0.002515;
- }
- }
- #endregion
-
- #region 尺寸检测参数
- public class SizeItemParam
- {
- /// <summary>
- /// 名称
- /// </summary>
- public string Name { get; set; }
- /// <summary>
- /// 代码
- /// </summary>
- public string Code { get; set; }
- /// <summary>
- /// 测试点数
- /// </summary>
- public int PointCnt { get; set; }
- /// <summary>
- /// 处理代码
- /// </summary>
- public int[] DefectIndex { get; set; }
- /// <summary>
- /// RGB颜色代码
- /// </summary>
- public int[] RGBcolor { get; set; }
- /// <summary>
- /// 显示单位 0:程序默认 1:mm 2:um
- /// </summary>
- public int mmOrum { get; set; }
- /// <summary>
- /// 显示小数点后位数 0:默认4位。
- /// </summary>
- public int dataLen { get; set; }
-
- }
- #endregion
-
- #region 缺陷检测参数
- public class DefectItemParam
- {
- /// <summary>
- /// 名称
- /// </summary>
- public string Name { get; set; }
- /// <summary>
- /// 代码
- /// </summary>
- public string Code { get; set; }
- /// <summary>
- /// 序号
- /// </summary>
- public int Index { get; set; }
- /// <summary>
- /// 默认分值
- /// </summary>
- public double Threshold { get; set; }
- /// <summary>
- /// RGB颜色代码
- /// </summary>
- public int[] RGBcolor { get; set; }
- /// <summary>
- /// 对应类型
- /// </summary>
- public string Type { get; set; }
- /// <summary>
- /// 尺寸
- /// </summary>
- public float Size { get; set; }
- /// <summary>
- /// 最大允许缺陷数量
- /// </summary>
- public int MaxDefectCount { get; set; }
- /// <summary>
- /// 显示
- /// </summary>
- public int Show { get; set; }
-
- }
- #endregion
-
- /// <summary>
- /// 设备参数
- /// </summary>
- public class ConfMgr
- {
- #region 实例化
- /// <summary>
- /// 实例
- /// </summary>
- 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;
- private readonly string _pointsPath;
- private readonly string _markPicPath;
- private readonly string _sizeItemsPath;
- private readonly string _defectItemsPath;
- private readonly string _sizeCompItemsPath;
- #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");
- _pointsPath = Path.Combine(_rootPath, "PointsConfig.ini");
- _markPicPath = Path.Combine(_rootPath, "MarkPic");
- _specificationPath = Path.Combine(_rootPath, "版博士软件操作说明.docx");
- _sizeItemsPath = Path.Combine(_rootPath, "尺寸测试项.json");
- _defectItemsPath = Path.Combine(_rootPath, "缺陷测试项.json");
- _sizeCompItemsPath = Path.Combine(_rootPath, "比对测试项.json");
-
- DBConStr = "server = localhost; Database = ProductionDB; Uid = root; Pwd = " + ConteolUserDB.GetSqlDBCode() + "; AllowLoadLocalInfile = true;";
- }
-
- #region 公开字段
- //DB
- //有些服务器防火墙有问题需要加上 min pool size=1 避免认为是恶意请求
- //如果用到bulkCopy需要加: AllowLoadLocalInfile=true
- //public static string dbMysqlCon = "server=localhost;Database=ProductionDB;Uid=root;Pwd=123456;";
- public string DBConStr = "server=localhost;Database=ProductionDB;Uid=root;Pwd=123456; AllowLoadLocalInfile=true";
- /// <summary>
- /// 系统配置参数
- /// </summary>
- public SysConfigParams SysConfigParams { get; set; }
-
- private string _devConfigPath;
- /// <summary>
- /// 获取驱动配制文件路径
- /// </summary>
- public string DevConfigPath { get { return _devConfigPath; } }
-
- //public string ProjectDir { get { return _projectDir; } }
- public string ProjectDir { get { return SysConfigParams.ProductPath; } }
-
- public string MarkPicPath { get { return _markPicPath; } }
-
- /// <summary>
- /// 说明书路径
- /// </summary>
- public string SpecificationPath { get { return _specificationPath; } }
- private string _specificationPath;
-
- /// <summary>
- /// 上料位X1
- /// </summary>
- public double LoadPoint_X1 { get; set; }
- /// <summary>
- /// 上料位X2
- /// </summary>
- public double LoadPoint_X2 { get; set; }
- /// <summary>
- /// 上料位Y
- /// </summary>
- public double LoadPoint_Y { get; set; }
- /// <summary>
- /// 上料位Z
- /// </summary>
- public double LoadPoint_Z { get; set; }
-
- /// <summary>
- /// 测厚气缸到位等待时间
- /// </summary>
- public int HeightDoWait { get; set; }
- /// <summary>
- /// 加紧气缸到位等待时间
- /// </summary>
- public int ProductDoWait { get; set; }
- #endregion
-
- #region 公开文件操作
-
- #region 点位配置
- public void WritePointsAndTime(double x1, double x2, double y, double z, int ht, int pt)
- {
-
- //XmlHelper.Serialize<SysConfParams>(_configFile, sysConfParams);
- IniHelper iniHelper = new IniHelper(_pointsPath);
-
-
- iniHelper.WriteDouble("LoadPoint", "X1", x1);
- iniHelper.WriteDouble("LoadPoint", "X2", x2);
- iniHelper.WriteDouble("LoadPoint", "Y", y);
- iniHelper.WriteDouble("LoadPoint", "Z", z);
-
- iniHelper.WriteInteger("WaitTime", "HeightDoWait", ht);
- iniHelper.WriteInteger("WaitTime", "ProductDoWait", pt);
-
- LoadPoint_X1 = x1;
- LoadPoint_X2 = x2;
- LoadPoint_Y = y;
- LoadPoint_Z = z;
-
- HeightDoWait = ht;
- ProductDoWait = pt;
- }
- public void ReadPointsAndTime()
- {
- IniHelper iniHelper = new IniHelper(_pointsPath);
- double dValue = 0;
- int iValue = 0;
-
- iniHelper.ReadDouble("LoadPoint", "X1", out dValue);
- LoadPoint_X1 = dValue;
- iniHelper.ReadDouble("LoadPoint", "X2", out dValue);
- LoadPoint_X2 = dValue;
- iniHelper.ReadDouble("LoadPoint", "Y", out dValue);
- LoadPoint_Y = dValue;
- iniHelper.ReadDouble("LoadPoint", "Z", out dValue);
- LoadPoint_Z = dValue;
-
- iniHelper.ReadInteger("WaitTime", "HeightDoWait", out iValue);
- HeightDoWait = iValue;
- iniHelper.ReadInteger("WaitTime", "ProductDoWait", out iValue);
- ProductDoWait = iValue;
-
-
- }
- #endregion
-
- #region 系统配置参数
- /// <summary>
- /// 写入ini
- /// </summary>
- /// <param name="SocketParams"></param>
- public void WriteSysConfParams(SysConfigParams SysParams)
- {
-
- //XmlHelper.Serialize<SysConfParams>(_configFile, sysConfParams);
- IniHelper iniHelper = new IniHelper(_configFile);
-
- iniHelper.WriteString("DefectSrcSmallImag", "Defect_SrcSmall_SavePath", SysParams.Defect_SrcSmall_SavePath);
- iniHelper.WriteDouble("DefectSrcSmallImag", "Defect_SrcSmall_Thres", SysParams.Defect_SrcSmall_Thres);
-
- iniHelper.WriteBool("SaveAllImg", "SaveAllImg", SysParams.SaveAllImg);
-
- iniHelper.WriteString("DefectBigImag", "SavePath", SysParams.DefectBigImag.SavePath);
- iniHelper.WriteBool("DefectBigImag", "AutoSave", SysParams.DefectBigImag.AutoSave);
- iniHelper.WriteBool("DefectBigImag", "AutoDelete", SysParams.DefectBigImag.AutoDelete);
- iniHelper.WriteDouble("DefectBigImag", "AutoDeleteDays", SysParams.DefectBigImag.AutoDeleteDays);
-
- iniHelper.WriteString("DefectSrcSmallImag", "SavePath", SysParams.DefectSrcSmallImag.SavePath);
- iniHelper.WriteBool("DefectSrcSmallImag", "AutoSave", SysParams.DefectSrcSmallImag.AutoSave);
- iniHelper.WriteBool("DefectSrcSmallImag", "AutoDelete", SysParams.DefectSrcSmallImag.AutoDelete);
- iniHelper.WriteDouble("DefectSrcSmallImag", "AutoDeleteDays", SysParams.DefectSrcSmallImag.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("DefectRepairImag", "SavePath", SysParams.DefectRepairImag.SavePath);
- iniHelper.WriteBool("DefectRepairImag", "AutoSave", SysParams.DefectRepairImag.AutoSave);
- iniHelper.WriteBool("DefectRepairImag", "AutoDelete", SysParams.DefectRepairImag.AutoDelete);
- iniHelper.WriteDouble("DefectRepairImag", "AutoDeleteDays", SysParams.DefectRepairImag.AutoDeleteDays);
-
- iniHelper.WriteString("SizeBigImag", "SavePath", SysParams.SizeBigImag.SavePath);
- iniHelper.WriteBool("SizeBigImag", "AutoSave", SysParams.SizeBigImag.AutoSave);
- iniHelper.WriteBool("SizeBigImag", "AutoDelete", SysParams.SizeBigImag.AutoDelete);
- iniHelper.WriteDouble("SizeBigImag", "AutoDeleteDays", SysParams.SizeBigImag.AutoDeleteDays);
-
- iniHelper.WriteString("SizeNGImag", "SavePath", SysParams.SizeNGImag.SavePath);
- iniHelper.WriteBool("SizeNGImag", "AutoSave", SysParams.SizeNGImag.AutoSave);
- iniHelper.WriteBool("SizeNGImag", "AutoDelete", SysParams.SizeNGImag.AutoDelete);
- iniHelper.WriteDouble("SizeNGImag", "AutoDeleteDays", SysParams.SizeNGImag.AutoDeleteDays);
-
- iniHelper.WriteString("SizeRepairImag", "SavePath", SysParams.SizeRepairImag.SavePath);
- iniHelper.WriteBool("SizeRepairImag", "AutoSave", SysParams.SizeRepairImag.AutoSave);
- iniHelper.WriteBool("SizeRepairImag", "AutoDelete", SysParams.SizeRepairImag.AutoDelete);
- iniHelper.WriteDouble("SizeRepairImag", "AutoDeleteDays", SysParams.SizeRepairImag.AutoDeleteDays);
-
- iniHelper.WriteString("Log", "SavePath", SysParams.LogPath);
- iniHelper.WriteBool("Log", "AutoDelete", SysParams.AutoDeleteLog);
- iniHelper.WriteDouble("Log", "AutoDeleteDays", SysParams.AutoDeleteLogData);
-
- iniHelper.WriteBool("SysFunction", "OpenMarkErrorStop", SysParams.OpenMarkErrorStop);
- iniHelper.WriteBool("SysFunction", "OpenBuzzer", SysParams.OpenBuzzer);
- iniHelper.WriteBool("SysFunction", "OpenDoor", SysParams.OpenDoor);
- iniHelper.WriteBool("SysFunction", "OpenHttpLog", SysParams.OpenHttpLog);
- iniHelper.WriteBool("SysFunction", "OpenAutoGoHome", SysParams.OpenAutoGoHome);
- iniHelper.WriteBool("SysFunction", "OpenFlawDistribution", SysParams.OpenFlawDistribution);
- iniHelper.WriteBool("SysFunction", "OpenAxisXCalibration", SysParams.OpenAxisXCalibration);
- iniHelper.WriteBool("SysFunction", "OpenPdtIsHave", SysParams.OpenPdtIsHave);
- iniHelper.WriteBool("SysFunction", "OpenDefectSanp", SysParams.OpenDefectSanp);
- iniHelper.WriteBool("SysFunction", "OpenAsideDefect", SysParams.OpenAsideDefect);
- iniHelper.WriteBool("SysFunction", "OpenOredrCheck", SysParams.OpenOredrCheck);
- iniHelper.WriteBool("SysFunction", "OpenOredrCntCheck", SysParams.OpenOredrCntCheck);
- iniHelper.WriteBool("SysFunction", "OpenShowDB", SysParams.OpenShowDB);
- iniHelper.WriteBool("SysFunction", "OpenColorB", SysParams.OpenColorB);
- iniHelper.WriteBool("SysFunction", "OpenRemoveDuplicates", SysParams.OpenRemoveDuplicates);
-
- iniHelper.WriteString("Dev", "LightCom", SysParams.LightCom);
- iniHelper.WriteInteger("Dev", "LightComBaud", SysParams.LightComBaud);
- iniHelper.WriteString("Dev", "TensionCom", SysParams.TensionCom);
- iniHelper.WriteInteger("Dev", "TensionComBaud", SysParams.TensionComBaud);
- iniHelper.WriteDouble("Dev", "Tension_Offset", SysParams.Tension_Offset);
- iniHelper.WriteString("Dev", "LensMotorCom", SysParams.LensMotorCom);
- iniHelper.WriteInteger("Dev", "LensMotorComBaud", SysParams.LensMotorComBaud);
- iniHelper.WriteString("Dev", "ThicknessIP", SysParams.ThicknessIP);
- iniHelper.WriteInteger("Dev", "ThicknessPort", SysParams.ThicknessPort);
- iniHelper.WriteDouble("Dev", "ThicknessSafeValue", SysParams.ThicknessSafeValue);
- iniHelper.WriteDouble("Dev", "Thickness_Offset", SysParams.Thickness_Offset);
- iniHelper.WriteString("Dev", "IODevName", SysParams.IODevName);
- iniHelper.WriteString("Dev", "IOCfgPath", SysParams.IOCfgPath);
- iniHelper.WriteString("Dev", "MotionCfgPath", SysParams.MotionCfgPath);
- iniHelper.WriteString("Dev", "FrontCamName", SysParams.FrontCamName);
- iniHelper.WriteString("Dev", "FrontCamCfgPath", SysParams.FrontCamCfgPath);
- iniHelper.WriteString("Dev", "BackCamName", SysParams.BackCamName);
- iniHelper.WriteString("Dev", "BackCamCfgPath", SysParams.BackCamCfgPath);
-
- iniHelper.WriteBool("Disable", "DisableX1", SysParams.DisableX1);
- iniHelper.WriteBool("Disable", "DisableX2", SysParams.DisableX2);
- iniHelper.WriteBool("Disable", "DisableY", SysParams.DisableY);
- iniHelper.WriteBool("Disable", "DisableZ", SysParams.DisableZ);
- iniHelper.WriteBool("Disable", "DisableFrontCam", SysParams.DisableFrontCam);
- iniHelper.WriteBool("Disable", "DisableBackCam", SysParams.DisableBackCam);
- iniHelper.WriteBool("Disable", "DisableLight", SysParams.DisableLight);
- iniHelper.WriteBool("Disable", "DisableThickness", SysParams.DisableThickness);
- iniHelper.WriteBool("Disable", "DisableTensor", SysParams.DisableTensor);
- iniHelper.WriteBool("Disable", "DisableLensMotor", SysParams.DisableLensMotor);
-
- iniHelper.WriteString("Sys", "ImageProcessPath", SysParams.ImageProcessPath);
- iniHelper.WriteString("Sys", "ImageProcessDataPath", SysParams.ImageProcessDataPath);
- iniHelper.WriteString("Sys", "AIModelPath", SysParams.AIModelPath);
- iniHelper.WriteString("Sys", "ProductPath", SysParams.ProductPath);
- iniHelper.WriteString("Sys", "HttpServerIP", SysParams.HttpServerIP);
- iniHelper.WriteInteger("Sys", "HttpServerPort", SysParams.HttpServerPort);
-
- iniHelper.WriteBool("ShowMainWin", "ShowResetBtn", SysParams.ShowResetBtn);
- iniHelper.WriteBool("ShowMainWin", "ShowBuzz", SysParams.ShowBuzz);
- iniHelper.WriteBool("ShowMainWin", "ShowDoorAlm", SysParams.ShowDoorAlm);
- iniHelper.WriteBool("ShowMainWin", "ShowDistribution", SysParams.ShowDistribution);
- iniHelper.WriteBool("ShowMainWin", "ShowSizeBtn", SysParams.ShowSizeBtn);
- iniHelper.WriteBool("ShowMainWin", "ShowDefectBtn", SysParams.ShowDefectBtn);
-
- iniHelper.WriteDouble("CamView", "DefectCamViewX", SysParams.DefectCamViewX);
- iniHelper.WriteDouble("CamView", "DefectCamViewY", SysParams.DefectCamViewY);
-
- iniHelper.WriteBool("CloudAndMES", "EnableHttp", SysParams.EnableHttp);
- iniHelper.WriteString("CloudAndMES", "HttpUrl", SysParams.HttpUrl);
- iniHelper.WriteString("CloudAndMES", "HttpTempPath", SysParams.HttpTempPath);
- iniHelper.WriteString("CloudAndMES", "HttpReturnKey", SysParams.HttpReturnKey);
- iniHelper.WriteString("CloudAndMES", "HttpReturnValue", SysParams.HttpReturnValue);
-
- 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.WriteDouble("LensZ", "Z_0_58X", SysParams.LensAxisZPos.Z_0_58X);
- //iniHelper.WriteDouble("LensZ", "Z_0_6X", SysParams.LensAxisZPos.Z_0_6X);
- iniHelper.WriteDouble("LensZ", "Z_1_0X", SysParams.LensAxisZPos.Z_1_0X);
- iniHelper.WriteDouble("LensZ", "Z_1_5X", SysParams.LensAxisZPos.Z_1_5X);
- iniHelper.WriteDouble("LensZ", "Z_2_0X", SysParams.LensAxisZPos.Z_2_0X);
- iniHelper.WriteDouble("LensZ", "Z_2_5X", SysParams.LensAxisZPos.Z_2_5X);
- iniHelper.WriteDouble("LensZ", "Z_3_0X", SysParams.LensAxisZPos.Z_3_0X);
- iniHelper.WriteDouble("LensZ", "Z_3_5X", SysParams.LensAxisZPos.Z_3_5X);
- iniHelper.WriteDouble("LensZ", "Z_4_0X", SysParams.LensAxisZPos.Z_4_0X);
- iniHelper.WriteDouble("LensZ", "Z_4_5X", SysParams.LensAxisZPos.Z_4_5X);
- iniHelper.WriteDouble("LensZ", "Z_5_0X", SysParams.LensAxisZPos.Z_5_0X);
- iniHelper.WriteDouble("LensZ", "Z_5_5X", SysParams.LensAxisZPos.Z_5_5X);
- iniHelper.WriteDouble("LensZ", "Z_6_0X", SysParams.LensAxisZPos.Z_6_0X);
- iniHelper.WriteDouble("LensZ", "Z_6_5X", SysParams.LensAxisZPos.Z_6_5X);
- iniHelper.WriteDouble("LensZ", "Z_7_0X", SysParams.LensAxisZPos.Z_7_0X);
- iniHelper.WriteDouble("LensZ", "Z_7_5X", SysParams.LensAxisZPos.Z_7_5X);
-
- iniHelper.WriteBool("LabelPrint", "EnableLabelPrint", SysParams.EnableLabelPrint);
- iniHelper.WriteString("LabelPrint", "LabelPrinterName", SysParams.LabelPrinterName);
- iniHelper.WriteString("LabelPrint", "LabelTempPath", SysParams.LabelTempPath);
- iniHelper.WriteString("LabelPrint", "LabelData", JsonConvert.SerializeObject(SysParams.LabelData));
-
- iniHelper.WriteBool("ExcelPrint", "EnableExcelPrint", SysParams.EnableExcelPrint);
- iniHelper.WriteString("ExcelPrint", "ExcelPrinterName", SysParams.ExcelPrinterName);
- iniHelper.WriteString("ExcelPrint", "ExcelTempPath", SysParams.ExcelTempPath);
- iniHelper.WriteString("ExcelPrint", "ExcelData", JsonConvert.SerializeObject(SysParams.ExcelData));
-
- iniHelper.WriteDouble("Offset", "Pt_offset", SysParams.Pt_offset);
- iniHelper.WriteDouble("Offset", "Line_offset", SysParams.Line_offset);
-
- iniHelper.WriteDouble("Offset", "X_per", SysParams.X_per);
- iniHelper.WriteDouble("Offset", "Y_per", SysParams.Y_per);
-
- iniHelper.WriteInteger("DefectSnap", "LightCH", SysParams.LightCH);
- iniHelper.WriteInteger("DefectSnap", "LightLut", SysParams.LightLut);
- iniHelper.WriteInteger("DefectSnap", "CamExposureTime", SysParams.CamExposureTime);
-
- iniHelper.WriteInteger("SysOther", "LightChannelCnt", SysParams.LightChannelCnt);
- iniHelper.WriteString("SysOther", "CustomerName", SysParams.CustomerName);
- iniHelper.WriteDouble("SysOther", "DefectCamPixel", SysParams.DefectCamPixel);
-
- SysConfigParams = SysParams;
- }
- /// <summary>
- /// 读取ini
- /// </summary>
- /// <returns></returns>
- public SysConfigParams ReadSysConfParams()
- {
-
- //return XmlHelper.Deserialize<SysConfParams>(_configFile);
- SysConfigParams sysParams = new SysConfigParams();
- IniHelper iniHelper = new IniHelper(_configFile);
- string sValue = "";
- int iValue = 0;
- double dValue = 0;
- bool bValue = false;
-
- iniHelper.ReadString("DefectSrcSmallImag", "Defect_SrcSmall_SavePath", out sValue);
- sysParams.Defect_SrcSmall_SavePath = sValue;
-
- iniHelper.ReadDouble("DefectSrcSmallImag", "Defect_SrcSmall_Thres", out dValue);
- sysParams.Defect_SrcSmall_Thres = dValue;
-
- iniHelper.ReadBool("SaveAllImg", "SaveAllImg", out bValue);
- sysParams.SaveAllImg = bValue;
-
- iniHelper.ReadString("DefectBigImag", "SavePath", out sValue);
- sysParams.DefectBigImag.SavePath = sValue.Replace("\0", "");
- iniHelper.ReadBool("DefectBigImag", "AutoSave", out bValue);
- sysParams.DefectBigImag.AutoSave = bValue;
- iniHelper.ReadBool("DefectBigImag", "AutoDelete", out bValue);
- sysParams.DefectBigImag.AutoDelete = bValue;
- iniHelper.ReadDouble("DefectBigImag", "AutoDeleteDays", out dValue);
- sysParams.DefectBigImag.AutoDeleteDays = dValue;
-
- iniHelper.ReadString("DefectSrcSmallImag", "SavePath", out sValue);
- sysParams.DefectSrcSmallImag.SavePath = sValue.Replace("\0", "");
- iniHelper.ReadBool("DefectSrcSmallImag", "AutoSave", out bValue);
- sysParams.DefectSrcSmallImag.AutoSave = bValue;
- iniHelper.ReadBool("DefectSrcSmallImag", "AutoDelete", out bValue);
- sysParams.DefectSrcSmallImag.AutoDelete = bValue;
- iniHelper.ReadDouble("DefectSrcSmallImag", "AutoDeleteDays", out dValue);
- sysParams.DefectSrcSmallImag.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("DefectRepairImag", "SavePath", out sValue);
- sysParams.DefectRepairImag.SavePath = sValue.Replace("\0", "");
- iniHelper.ReadBool("DefectRepairImag", "AutoSave", out bValue);
- sysParams.DefectRepairImag.AutoSave = bValue;
- iniHelper.ReadBool("DefectRepairImag", "AutoDelete", out bValue);
- sysParams.DefectRepairImag.AutoDelete = bValue;
- iniHelper.ReadDouble("DefectRepairImag", "AutoDeleteDays", out dValue);
- sysParams.DefectRepairImag.AutoDeleteDays = dValue;
-
- iniHelper.ReadString("SizeBigImag", "SavePath", out sValue);
- sysParams.SizeBigImag.SavePath = sValue.Replace("\0", "");
- iniHelper.ReadBool("SizeBigImag", "AutoSave", out bValue);
- sysParams.SizeBigImag.AutoSave = bValue;
- iniHelper.ReadBool("SizeBigImag", "AutoDelete", out bValue);
- sysParams.SizeBigImag.AutoDelete = bValue;
- iniHelper.ReadDouble("SizeBigImag", "AutoDeleteDays", out dValue);
- sysParams.SizeBigImag.AutoDeleteDays = dValue;
-
- iniHelper.ReadString("SizeNGImag", "SavePath", out sValue);
- sysParams.SizeNGImag.SavePath = sValue.Replace("\0", "");
- iniHelper.ReadBool("SizeNGImag", "AutoSave", out bValue);
- sysParams.SizeNGImag.AutoSave = bValue;
- iniHelper.ReadBool("SizeNGImag", "AutoDelete", out bValue);
- sysParams.SizeNGImag.AutoDelete = bValue;
- iniHelper.ReadDouble("SizeNGImag", "AutoDeleteDays", out dValue);
- sysParams.SizeNGImag.AutoDeleteDays = dValue;
-
- iniHelper.ReadString("SizeRepairImag", "SavePath", out sValue);
- sysParams.SizeRepairImag.SavePath = sValue.Replace("\0", "");
- iniHelper.ReadBool("SizeRepairImag", "AutoSave", out bValue);
- sysParams.SizeRepairImag.AutoSave = bValue;
- iniHelper.ReadBool("SizeRepairImag", "AutoDelete", out bValue);
- sysParams.SizeRepairImag.AutoDelete = bValue;
- iniHelper.ReadDouble("SizeRepairImag", "AutoDeleteDays", out dValue);
- sysParams.SizeRepairImag.AutoDeleteDays = dValue;
-
- 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("SysFunction", "OpenMarkErrorStop", out bValue);
- sysParams.OpenMarkErrorStop = bValue;
- iniHelper.ReadBool("SysFunction", "OpenBuzzer", out bValue);
- sysParams.OpenBuzzer = bValue;
- iniHelper.ReadBool("SysFunction", "OpenDoor", out bValue);
- sysParams.OpenDoor = bValue;
- iniHelper.ReadBool("SysFunction", "OpenHttpLog", out bValue);
- sysParams.OpenHttpLog = bValue;
- iniHelper.ReadBool("SysFunction", "OpenAutoGoHome", out bValue);
- sysParams.OpenAutoGoHome = bValue;
- iniHelper.ReadBool("SysFunction", "OpenFlawDistribution", out bValue);
- sysParams.OpenFlawDistribution = bValue;
- iniHelper.ReadBool("SysFunction", "OpenAxisXCalibration", out bValue);
- sysParams.OpenAxisXCalibration = bValue;
- iniHelper.ReadBool("SysFunction", "OpenPdtIsHave", out bValue);
- sysParams.OpenPdtIsHave = bValue;
- iniHelper.ReadBool("SysFunction", "OpenDefectSanp", out bValue);
- sysParams.OpenDefectSanp = bValue;
- iniHelper.ReadBool("SysFunction", "OpenAsideDefect", out bValue);
- sysParams.OpenAsideDefect = bValue;
- iniHelper.ReadBool("SysFunction", "OpenOredrCheck", out bValue);
- sysParams.OpenOredrCheck = bValue;
- iniHelper.ReadBool("SysFunction", "OpenOredrCntCheck", out bValue);
- sysParams.OpenOredrCntCheck = bValue;
- iniHelper.ReadBool("SysFunction", "OpenShowDB", out bValue);
- sysParams.OpenShowDB = bValue;
- iniHelper.ReadBool("SysFunction", "OpenColorB", out bValue);
- sysParams.OpenColorB = bValue;
- iniHelper.ReadBool("SysFunction", "OpenRemoveDuplicates", out bValue);
- sysParams.OpenRemoveDuplicates = bValue;
-
- iniHelper.ReadString("Dev", "LightCom", out sValue);
- sysParams.LightCom = sValue.Replace("\0", "");
- iniHelper.ReadInteger("Dev", "LightComBaud", out iValue);
- sysParams.LightComBaud = iValue;
-
- iniHelper.ReadString("Dev", "TensionCom", out sValue);
- sysParams.TensionCom = sValue.Replace("\0", "");
- iniHelper.ReadInteger("Dev", "TensionComBaud", out iValue);
- sysParams.TensionComBaud = iValue;
- iniHelper.ReadDouble("Dev", "Tension_Offset", out dValue);
- sysParams.Tension_Offset = dValue;
- iniHelper.ReadString("Dev", "LensMotorCom", out sValue);
- sysParams.LensMotorCom = sValue.Replace("\0", "");
- iniHelper.ReadInteger("Dev", "LensMotorComBaud", out iValue);
- sysParams.LensMotorComBaud = iValue;
- iniHelper.ReadString("Dev", "ThicknessIP", out sValue);
- sysParams.ThicknessIP = sValue.Replace("\0", "");
- iniHelper.ReadInteger("Dev", "ThicknessPort", out iValue);
- sysParams.ThicknessPort = iValue;
- iniHelper.ReadDouble("Dev", "ThicknessSafeValue", out dValue);
- sysParams.ThicknessSafeValue = dValue;
- iniHelper.ReadDouble("Dev", "Thickness_Offset", out dValue);
- sysParams.Thickness_Offset = dValue;
-
- 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", "FrontCamName", out sValue);
- sysParams.FrontCamName = sValue.Replace("\0", "");
- iniHelper.ReadString("Dev", "FrontCamCfgPath", out sValue);
- sysParams.FrontCamCfgPath = sValue.Replace("\0", "");
- iniHelper.ReadString("Dev", "BackCamName", out sValue);
- sysParams.BackCamName = sValue.Replace("\0", "");
- iniHelper.ReadString("Dev", "BackCamCfgPath", out sValue);
- sysParams.BackCamCfgPath = sValue.Replace("\0", "");
- iniHelper.ReadString("Dev", "MotionCfgPath", out sValue);
- sysParams.MotionCfgPath = sValue.Replace("\0", "");
-
- iniHelper.ReadBool("Disable", "DisableX1", out bValue);
- sysParams.DisableX1 = bValue;
- iniHelper.ReadBool("Disable", "DisableX2", out bValue);
- sysParams.DisableX2 = bValue;
- iniHelper.ReadBool("Disable", "DisableY", out bValue);
- sysParams.DisableY = bValue;
- iniHelper.ReadBool("Disable", "DisableZ", out bValue);
- sysParams.DisableZ = bValue;
- iniHelper.ReadBool("Disable", "DisableFrontCam", out bValue);
- sysParams.DisableFrontCam = bValue;
- iniHelper.ReadBool("Disable", "DisableBackCam", out bValue);
- sysParams.DisableBackCam = bValue;
- iniHelper.ReadBool("Disable", "DisableLight", out bValue);
- sysParams.DisableLight = bValue;
- iniHelper.ReadBool("Disable", "DisableTensor", out bValue);
- sysParams.DisableTensor = bValue;
- iniHelper.ReadBool("Disable", "DisableThickness", out bValue);
- sysParams.DisableThickness = bValue;
- iniHelper.ReadBool("Disable", "DisableLensMotor", out bValue);
- sysParams.DisableLensMotor = bValue;
-
- iniHelper.ReadString("Sys", "ImageProcessPath", out sValue);
- sysParams.ImageProcessPath = sValue.Replace("\0", "");
- iniHelper.ReadString("Sys", "ImageProcessDataPath", out sValue);
- sysParams.ImageProcessDataPath = sValue.Replace("\0", "");
- iniHelper.ReadString("Sys", "AIModelPath", out sValue);
- sysParams.AIModelPath = sValue.Replace("\0", "");
- iniHelper.ReadString("Sys", "ProductPath", out sValue);
- sysParams.ProductPath = sValue.Replace("\0", "");
- iniHelper.ReadString("Sys", "HttpServerIP", out sValue);
- sysParams.HttpServerIP = sValue.Replace("\0", "");
- iniHelper.ReadInteger("Sys", "HttpServerPort", out iValue);
- sysParams.HttpServerPort = iValue;
-
- 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("ShowMainWin", "ShowDistribution", out bValue);
- sysParams.ShowDistribution = bValue;
- iniHelper.ReadBool("ShowMainWin", "ShowSizeBtn", out bValue);
- sysParams.ShowSizeBtn = bValue;
- iniHelper.ReadBool("ShowMainWin", "ShowDefectBtn", out bValue);
- sysParams.ShowDefectBtn = bValue;
-
- iniHelper.ReadDouble("CamView", "DefectCamViewX", out dValue);
- sysParams.DefectCamViewX = dValue;
- iniHelper.ReadDouble("CamView", "DefectCamViewY", out dValue);
- sysParams.DefectCamViewY = dValue;
-
- iniHelper.ReadBool("CloudAndMES", "EnableHttp", out bValue);
- sysParams.EnableHttp = bValue;
- iniHelper.ReadString("CloudAndMES", "HttpUrl", out sValue);
- sysParams.HttpUrl = sValue;
- iniHelper.ReadString("CloudAndMES", "HttpTempPath", out sValue);
- sysParams.HttpTempPath = sValue;
- iniHelper.ReadString("CloudAndMES", "HttpReturnKey", out sValue);
- sysParams.HttpReturnKey = sValue;
- iniHelper.ReadString("CloudAndMES", "HttpReturnValue", out sValue);
- sysParams.HttpReturnValue = sValue;
-
- 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.ReadDouble("LensZ", "Z_0_58X", out dValue);
- sysParams.LensAxisZPos.Z_0_58X = dValue;
- //iniHelper.ReadDouble("LensZ", "Z_0_6X", out dValue);
- //sysParams.LensAxisZPos.Z_0_6X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_1_0X", out dValue);
- sysParams.LensAxisZPos.Z_1_0X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_1_5X", out dValue);
- sysParams.LensAxisZPos.Z_1_5X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_2_0X", out dValue);
- sysParams.LensAxisZPos.Z_2_0X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_2_5X", out dValue);
- sysParams.LensAxisZPos.Z_2_5X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_3_0X", out dValue);
- sysParams.LensAxisZPos.Z_3_0X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_3_5X", out dValue);
- sysParams.LensAxisZPos.Z_3_5X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_4_0X", out dValue);
- sysParams.LensAxisZPos.Z_4_0X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_4_5X", out dValue);
- sysParams.LensAxisZPos.Z_4_5X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_5_0X", out dValue);
- sysParams.LensAxisZPos.Z_5_0X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_5_5X", out dValue);
- sysParams.LensAxisZPos.Z_5_5X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_6_0X", out dValue);
- sysParams.LensAxisZPos.Z_6_0X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_6_5X", out dValue);
- sysParams.LensAxisZPos.Z_6_5X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_7_0X", out dValue);
- sysParams.LensAxisZPos.Z_7_0X = dValue;
- iniHelper.ReadDouble("LensZ", "Z_7_5X", out dValue);
- sysParams.LensAxisZPos.Z_7_5X = dValue;
-
- iniHelper.ReadBool("LabelPrint", "EnableLabelPrint", out bValue);
- sysParams.EnableLabelPrint = bValue;
- iniHelper.ReadString("LabelPrint", "LabelPrinterName", out sValue);
- sysParams.LabelPrinterName = sValue;
- iniHelper.ReadString("LabelPrint", "LabelTempPath", out sValue);
- sysParams.LabelTempPath = sValue;
- iniHelper.ReadString("LabelPrint", "LabelData", out sValue);
- if (string.IsNullOrEmpty(sValue))
- sysParams.LabelData = new Dictionary<string, string>();
- else
- sysParams.LabelData = JsonConvert.DeserializeObject<Dictionary<string, string>>(sValue);
-
- iniHelper.ReadBool("ExcelPrint", "EnableExcelPrint", out bValue);
- sysParams.EnableExcelPrint = bValue;
- iniHelper.ReadString("ExcelPrint", "ExcelPrinterName", out sValue);
- sysParams.ExcelPrinterName = sValue;
- iniHelper.ReadString("ExcelPrint", "ExcelTempPath", out sValue);
- sysParams.ExcelTempPath = sValue;
- iniHelper.ReadString("ExcelPrint", "ExcelData", out sValue);
- if (string.IsNullOrEmpty(sValue))
- sysParams.ExcelData = new Dictionary<string, string>();
- else
- sysParams.ExcelData = JsonConvert.DeserializeObject<Dictionary<string, string>>(sValue);
-
- iniHelper.ReadDouble("Offset", "Pt_offset", out dValue);
- sysParams.Pt_offset = dValue;
- iniHelper.ReadDouble("Offset", "Line_offset", out dValue);
- sysParams.Line_offset = dValue;
-
- iniHelper.ReadDouble("Offset", "X_per", out dValue);
- if (dValue > 1)
- sysParams.X_per = 0.9;
- else if (dValue <= 0)
- sysParams.X_per = 0.1;
- else
- sysParams.X_per = dValue;
- iniHelper.ReadDouble("Offset", "Y_per", out dValue);
- if (dValue > 1)
- sysParams.Y_per = 0.9;
- else if (dValue <= 0)
- sysParams.Y_per = 0.1;
- else
- sysParams.Y_per = dValue;
-
- iniHelper.ReadInteger("DefectSnap", "LightCH", out iValue);
- sysParams.LightCH = iValue;
- iniHelper.ReadInteger("DefectSnap", "LightLut", out iValue);
- sysParams.LightLut = iValue;
- iniHelper.ReadInteger("DefectSnap", "CamExposureTime", out iValue);
- sysParams.CamExposureTime = iValue;
-
- iniHelper.ReadInteger("SysOther", "LightChannelCnt", out iValue);
- sysParams.LightChannelCnt = iValue;
- iniHelper.ReadString("SysOther", "CustomerName", out sValue);
- sysParams.CustomerName = sValue;
- iniHelper.ReadDouble("SysOther", "DefectCamPixel", out dValue);
- sysParams.DefectCamPixel = dValue;
-
- if(sysParams.DefectCamPixel == 0)
- sysParams.DefectCamPixel = 0.002515;
-
- SysConfigParams = sysParams;
- return sysParams;
- }
- /// <summary>
- /// 写入系统默认配置
- /// </summary>
- public void WriteDefaultSystemConfig()
- {
- SysConfigParams = new SysConfigParams();
-
- WriteSysConfParams(SysConfigParams);
- }
-
- /// <summary>
- /// 加载系统配置
- /// </summary>
- /// <returns></returns>
- public bool LoadSystemConfig()
- {
- bool ret = false;
-
- if (!Directory.Exists(_rootPath))
- {
- Directory.CreateDirectory(_rootPath);
- }
-
- if (!Directory.Exists(_projectDir))
- {
- Directory.CreateDirectory(_projectDir);
- }
-
- if (File.Exists(_pointsPath))
- {
- ReadPointsAndTime();
- }
- else
- {
- // write default value
- WritePointsAndTime(0, 0, 0, 0, 1000, 1000);
- ret = true;
- }
- if (File.Exists(_configFile))
- {
- SysConfigParams = ReadSysConfParams();
- if (null != SysConfigParams)
- {
- ret = true;
- }
- }
- else
- {
- // write default value
- WriteDefaultSystemConfig();
- ret = true;
- }
-
- return ret;
- }
- #endregion
-
- #region 文件选择
- /// <summary>
- /// 选择目录
- /// </summary>
- /// <returns></returns>
- 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 "";
- }
- /// <summary>
- /// 选择文件
- /// </summary>
- /// <param name="filter">如 图像文件|*.jpg|图像文件|*.png|所有文件|*.*</param>
- /// <returns></returns>
- 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 "";
- }
- /// <summary>
- /// 删除指定目录下文件
- /// </summary>
- /// <param name="defaultPath"></param>
- /// <param name="fileExtend"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 另存为
- /// </summary>
- /// <param name="defaultFileName">默认文件名</param>
- /// <param name="filter">如 图像文件|*.jpg|图像文件|*.png|所有文件|*.*</param>
- /// <returns></returns>
- 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<T>()
- {
- 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 尺寸检测项
- public List<SizeItemParam> SizeItemParamsList = new List<SizeItemParam>();
-
- public void ReadSizeDefectItems()
- {
- string str = File.ReadAllText(_sizeItemsPath);
- SizeItemParamsList = JsonConvert.DeserializeObject<List<SizeItemParam>>(str);
-
- }
- #endregion
-
- #region 缺陷检测项
- public List<DefectItemParam> DefectItemParamsList = new List<DefectItemParam>();
-
- public void ReadDefectItems()
- {
- string str = File.ReadAllText(_defectItemsPath);
- DefectItemParamsList = JsonConvert.DeserializeObject<List<DefectItemParam>>(str);
-
- }
- #endregion
-
- #region 比对检测项
- public List<DefectItemParam> SizeCompItemParamsList = new List<DefectItemParam>();
-
- public void ReadSizeCompItems()
- {
- if (File.Exists(_sizeCompItemsPath))
- {
- string str = File.ReadAllText(_sizeCompItemsPath);
- SizeCompItemParamsList = JsonConvert.DeserializeObject<List<DefectItemParam>>(str);
- }
- else
- {
- SizeCompItemParamsList.Add(new DefectItemParam()
- {
- Code = "wtg",
- Name = "未通过",
- Show = 1,
- Type = "0",
- });
- }
-
- }
- #endregion
- #endregion
- }
- }
|