版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1642 lines
68 KiB

  1. using CCWin.SkinClass;
  2. using MaiMuControl.SysStatusMgr.UserMgr;
  3. using Models;
  4. using Newtonsoft.Json;
  5. using Newtonsoft.Json.Linq;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Drawing;
  10. using System.IO;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. using ToolKits.Ini;
  16. using ToolKits.mAPI;
  17. using ToolKits.PLC;
  18. namespace MaiMuAOI.SysCtrl
  19. {
  20. #region 参数类型
  21. /// <summary>
  22. /// 图片保存参数
  23. /// </summary>
  24. [Serializable]
  25. public class ImageSaveParam
  26. {
  27. /// <summary>
  28. /// 保存路径
  29. /// </summary>
  30. public string SavePath { get; set; }
  31. /// <summary>
  32. /// 自动保存
  33. /// </summary>
  34. public bool AutoSave { get; set; }
  35. /// <summary>
  36. /// 自动删除
  37. /// </summary>
  38. public bool AutoDelete { get; set; }
  39. /// <summary>
  40. /// 自动删除日期
  41. /// </summary>
  42. public double AutoDeleteDays { get; set; }
  43. public ImageSaveParam() {
  44. SavePath = "D:\\AllImageSave";
  45. AutoSave = true;
  46. AutoDelete = true;
  47. AutoDeleteDays = 3;
  48. }
  49. public ImageSaveParam(string path)
  50. {
  51. SavePath = path;
  52. AutoSave = true;
  53. AutoDelete = true;
  54. AutoDeleteDays = 3;
  55. }
  56. }
  57. /// <summary>
  58. /// 镜头对应Z轴高度
  59. /// </summary>
  60. [Serializable]
  61. public class LensAxisZ
  62. {
  63. public double Z_0_58X { get; set; }
  64. //public double Z_0_6X { get; set; }
  65. public double Z_1_0X { get; set; }
  66. public double Z_1_5X { get; set; }
  67. public double Z_2_0X { get; set; }
  68. public double Z_2_5X { get; set; }
  69. public double Z_3_0X { get; set; }
  70. public double Z_3_5X { get; set; }
  71. public double Z_4_0X { get; set; }
  72. public double Z_4_5X { get; set; }
  73. public double Z_5_0X { get; set; }
  74. public double Z_5_5X { get; set; }
  75. public double Z_6_0X { get; set; }
  76. public double Z_6_5X { get; set; }
  77. public double Z_7_0X { get; set; }
  78. public double Z_7_5X { get; set; }
  79. public LensAxisZ()
  80. {
  81. Z_0_58X = 0;
  82. //Z_0_6X = 0;
  83. Z_1_0X = 0;
  84. Z_1_5X = 0;
  85. Z_2_0X = 0;
  86. Z_2_5X = 0;
  87. Z_3_0X = 0;
  88. Z_3_5X = 0;
  89. Z_4_0X = 0;
  90. Z_4_5X = 0;
  91. Z_5_0X = 0;
  92. Z_5_5X = 0;
  93. Z_6_0X = 0;
  94. Z_6_5X = 0;
  95. Z_7_0X = 0;
  96. Z_7_5X = 0;
  97. }
  98. }
  99. [Serializable]
  100. public class SysConfigParams
  101. {
  102. #region 缺陷图
  103. public string Defect_SrcSmall_SavePath { get; set; }
  104. public double Defect_SrcSmall_Thres { get; set; }
  105. /// <summary>
  106. /// 保存所有图片
  107. /// </summary>
  108. public bool SaveAllImg { get; set; }
  109. /// <summary>
  110. /// 缺陷大图
  111. /// </summary>
  112. public ImageSaveParam DefectBigImag { get; set; }
  113. /// <summary>
  114. /// 缺陷原始小图
  115. /// </summary>
  116. public ImageSaveParam DefectSrcSmallImag { get; set; }
  117. /// <summary>
  118. /// 缺陷小图
  119. /// </summary>
  120. public ImageSaveParam DefectSmallImag { get; set; }
  121. /// <summary>
  122. /// 修复台 缺陷图
  123. /// </summary>
  124. public ImageSaveParam DefectRepairImag { get; set; }
  125. /// <summary>
  126. /// 对比大图
  127. /// </summary>
  128. public ImageSaveParam SizeBigImag { get; set; }
  129. /// <summary>
  130. /// 对比未通过
  131. /// </summary>
  132. public ImageSaveParam SizeNGImag { get; set; }
  133. /// <summary>
  134. /// 修复台 对比图
  135. /// </summary>
  136. public ImageSaveParam SizeRepairImag { get; set; }
  137. #endregion
  138. #region 功能
  139. /// <summary>
  140. /// mark报警暂停
  141. /// </summary>
  142. public bool OpenMarkErrorStop { get; set; }
  143. /// <summary>
  144. /// 开启蜂鸣器
  145. /// </summary>
  146. public bool OpenBuzzer { get; set; }
  147. /// <summary>
  148. /// 开启门磁
  149. /// </summary>
  150. public bool OpenDoor { get; set; }
  151. /// <summary>
  152. /// 开启http日志
  153. /// </summary>
  154. public bool OpenHttpLog { get; set; }
  155. /// <summary>
  156. /// 开启软件开启自动回原
  157. /// </summary>
  158. public bool OpenAutoGoHome { get; set; }
  159. /// <summary>
  160. /// 启用缺陷分布功能
  161. /// </summary>
  162. public bool OpenFlawDistribution { get; set; }
  163. /// <summary>
  164. /// 启用X轴校准 2023-12-20
  165. /// </summary>
  166. public bool OpenAxisXCalibration { get; set; }
  167. /// <summary>
  168. /// 产品有无信号关闭
  169. /// </summary>
  170. public bool OpenPdtIsHave { get; set; }
  171. /// <summary>
  172. /// 开启查看功能
  173. /// </summary>
  174. public bool OpenDefectSanp { get; set; }
  175. /// <summary>
  176. /// 开启单边目数计算
  177. /// </summary>
  178. public bool OpenAsideDefect{ get; set; }
  179. /// <summary>
  180. /// 开启工单确认
  181. /// </summary>
  182. public bool OpenOredrCheck { get; set; }
  183. /// <summary>
  184. /// 开启工单数量确认
  185. /// </summary>
  186. public bool OpenOredrCntCheck { get; set; }
  187. /// <summary>
  188. /// 开启显示打标图片
  189. /// </summary>
  190. public bool OpenShowDB { get; set; }
  191. /// <summary>
  192. /// 开启彩色相机使用B通道
  193. /// </summary>
  194. public bool OpenColorB { get; set; }
  195. /// <summary>
  196. /// 开启比对和缺陷去重复
  197. /// </summary>
  198. public bool OpenRemoveDuplicates { get; set; }
  199. #endregion
  200. #region 硬件传感器通信
  201. /// <summary>
  202. /// 光源串口
  203. /// </summary>
  204. //public LightParams LightCfg { get; set; }
  205. public string LightCom { get; set; }
  206. /// <summary>
  207. /// 光源波特率
  208. /// </summary>
  209. public int LightComBaud { get; set; }
  210. /// <summary>
  211. /// 张力传感器串口
  212. /// </summary>
  213. public string TensionCom { get; set; }
  214. /// <summary>
  215. /// 张力传感器波特率
  216. /// </summary>
  217. public int TensionComBaud { get; set; }
  218. /// <summary>
  219. /// 张力偏移值
  220. /// </summary>
  221. public double Tension_Offset = 0;
  222. /// <summary>
  223. /// 镜头电机串口
  224. /// </summary>
  225. public string LensMotorCom { get; set; }
  226. /// <summary>
  227. /// 镜头电机波特率
  228. /// </summary>
  229. public int LensMotorComBaud { get; set; }
  230. /// <summary>
  231. /// 厚度传感器IP
  232. /// </summary>
  233. public string ThicknessIP { get; set; }
  234. /// <summary>
  235. /// 厚度传感器port
  236. /// </summary>
  237. public int ThicknessPort { get; set; }
  238. /// <summary>
  239. /// 测厚安全值
  240. /// </summary>
  241. public double ThicknessSafeValue { get; set; }
  242. /// <summary>
  243. /// 测厚调试偏移值
  244. /// </summary>
  245. public double Thickness_Offset = 0;
  246. #endregion
  247. #region IO/电机/相机
  248. /// <summary>
  249. /// IO驱动名称
  250. /// </summary>
  251. //public IOParams IOCfg { get; set; }
  252. public string IODevName { get; set; }
  253. /// <summary>
  254. /// IO配置文件路径
  255. /// </summary>
  256. public string IOCfgPath { get; set; }
  257. /// <summary>
  258. /// 电机配置文件路径
  259. /// </summary>
  260. public string MotionCfgPath { get; set; }
  261. /// <summary>
  262. /// 前部相机名称
  263. /// </summary>
  264. public string FrontCamName { get; set; }
  265. /// <summary>
  266. /// 前部相机配置文件路径
  267. /// </summary>
  268. public string FrontCamCfgPath { get; set; }
  269. /// <summary>
  270. /// 后部相机名称
  271. /// </summary>
  272. public string BackCamName { get; set; }
  273. /// <summary>
  274. /// 后部相机配置文件路径
  275. /// </summary>
  276. public string BackCamCfgPath { get; set; }
  277. #endregion
  278. #region 禁用
  279. public bool DisableX1 { get; set; }
  280. public bool DisableX2 { get; set; }
  281. public bool DisableY { get; set; }
  282. public bool DisableZ { get; set; }
  283. public bool DisableFrontCam { get; set; }
  284. public bool DisableBackCam { get; set; }
  285. public bool DisableLight { get; set; }
  286. public bool DisableTensor { get; set; }
  287. public bool DisableThickness { get; set; }
  288. public bool DisableLensMotor { get; set; }
  289. #endregion
  290. #region 系统
  291. public string ImageProcessPath { get; set; }
  292. public string ImageProcessDataPath { get; set; }
  293. public string AIModelPath { get; set; }
  294. public string ProductPath { get; set; }
  295. public string HttpServerIP { get; set; }
  296. public int HttpServerPort { get; set; }
  297. public string LogPath { get; set; }
  298. public bool AutoDeleteLog { get; set; }
  299. public double AutoDeleteLogData { get; set; }
  300. /// <summary>
  301. /// 调试:主界面显示复位按钮
  302. /// </summary>
  303. public bool ShowResetBtn { get; set; }
  304. /// <summary>
  305. /// 调试:主界面显示蜂鸣器控制
  306. /// </summary>
  307. public bool ShowBuzz { get; set; }
  308. /// <summary>
  309. /// 调试:主界面显示门磁报警控制
  310. /// </summary>
  311. public bool ShowDoorAlm { get; set; }
  312. /// <summary>
  313. /// 调试:显示分布
  314. /// </summary>
  315. public bool ShowDistribution { get; set; }
  316. /// <summary>
  317. /// 调试:显示尺寸检测禁用和启用
  318. /// </summary>
  319. public bool ShowSizeBtn { get; set; }
  320. /// <summary>
  321. /// 调试:显示缺陷检测禁用和启用
  322. /// </summary>
  323. public bool ShowDefectBtn { get; set; }
  324. /// <summary>
  325. /// 后部相机视野X
  326. /// </summary>
  327. public double DefectCamViewX { get; set; }
  328. /// <summary>
  329. /// 后部相机视野Y
  330. /// </summary>
  331. public double DefectCamViewY { get; set; }
  332. #endregion
  333. #region Http/MES
  334. /// <summary>
  335. /// 开启http上传
  336. /// </summary>
  337. public bool EnableHttp { get; set; }
  338. /// <summary>
  339. /// 上传Http地址
  340. /// </summary>
  341. public string HttpUrl { get; set; }
  342. /// <summary>
  343. /// 上传Json模板路径
  344. /// </summary>
  345. public string HttpTempPath { get; set; }
  346. /// <summary>
  347. /// 返回值Key
  348. /// </summary>
  349. public string HttpReturnKey{ get; set; }
  350. /// <summary>
  351. /// 返回成功value
  352. /// </summary>
  353. public string HttpReturnValue { get; set; }
  354. #endregion
  355. #region MQTT本地云/产品服务器
  356. /// <summary>
  357. /// 开启局域网云端
  358. /// </summary>
  359. public bool OpenCloud { get; set; }
  360. public string CloudThisName { get; set; }
  361. public string CloudServerIP { get; set; }
  362. public int CloudServerPort { get; set; }
  363. public string CloudUser { get; set; }
  364. public string CloudPassword { get; set; }
  365. /// <summary>
  366. /// 开启产品转发
  367. /// </summary>
  368. public bool OpenPdtServer { get; set; }
  369. public string PdtServerIP { get; set; }
  370. public int PdtServerPort { get; set; }
  371. /// <summary>
  372. /// 是否作为服务器还是客户端
  373. /// </summary>
  374. public bool IsPdtServer { get; set; }
  375. #endregion
  376. #region 聚焦
  377. /// <summary>
  378. /// 聚焦对应Z轴位置
  379. /// </summary>
  380. public LensAxisZ LensAxisZPos { get; set; }
  381. #endregion
  382. #region 缺陷分割
  383. //缺陷配置
  384. public Size Defect_CutSize { get; set; }
  385. public Size Defect_ReSize { get; set; }
  386. public float Defect_Thresholds { get; set; }
  387. #endregion
  388. #region BarTender
  389. /// <summary>
  390. /// 开启标签打印
  391. /// </summary>
  392. public bool EnableLabelPrint { get; set; }
  393. /// <summary>
  394. /// 打印机名称
  395. /// </summary>
  396. public string LabelPrinterName { get; set; }
  397. /// <summary>
  398. /// 打印模板路径
  399. /// </summary>
  400. public string LabelTempPath { get; set; }
  401. /// <summary>
  402. /// 打印信息
  403. /// </summary>
  404. public Dictionary<string, string> LabelData { get; set; }
  405. #endregion
  406. #region Excel
  407. /// <summary>
  408. /// 开启Excel打印
  409. /// </summary>
  410. public bool EnableExcelPrint { get; set; }
  411. /// <summary>
  412. /// 打印机名称
  413. /// </summary>
  414. public string ExcelPrinterName { get; set; }
  415. /// <summary>
  416. /// 打印模板路径
  417. /// </summary>
  418. public string ExcelTempPath { get; set; }
  419. /// <summary>
  420. /// 打印信息
  421. /// </summary>
  422. public Dictionary<string, string> ExcelData { get; set; }
  423. #endregion
  424. #region 老流程PT线宽补偿
  425. public double Pt_offset { get; set; }
  426. public double Line_offset { get; set; }
  427. #endregion
  428. #region 左上角比例调整
  429. public double X_per{ get; set; }
  430. public double Y_per { get; set; }
  431. #endregion
  432. #region 缺陷查看
  433. public int LightCH { get; set; }
  434. public int LightLut { get; set; }
  435. public int CamExposureTime { get; set; }
  436. #endregion
  437. #region 其他
  438. /// <summary>
  439. /// 光源通道
  440. /// </summary>
  441. public int LightChannelCnt { get; set; }
  442. /// <summary>
  443. /// 客户名称,不同客户可能存在差异
  444. /// </summary>
  445. public string CustomerName { get; set; }
  446. #endregion
  447. public SysConfigParams()
  448. {
  449. DefectBigImag = new ImageSaveParam("D:\\AllImageSave\\DefectBigImag");
  450. DefectSrcSmallImag = new ImageSaveParam("D:\\AllImageSave\\DefectSrcSmallImag");
  451. DefectSmallImag = new ImageSaveParam("D:\\AllImageSave\\DefectSmallImag");
  452. DefectRepairImag = new ImageSaveParam("D:\\AllImageSave\\DefectRepairImag");
  453. SizeBigImag = new ImageSaveParam("D:\\AllImageSave\\SizeBigImag");
  454. SizeNGImag = new ImageSaveParam("D:\\AllImageSave\\SizeNGImag");
  455. SizeRepairImag = new ImageSaveParam("D:\\AllImageSave\\SizeRepairImag");
  456. OpenMarkErrorStop = true;
  457. OpenBuzzer = true;
  458. OpenDoor = true;
  459. OpenHttpLog = false;
  460. OpenPdtIsHave = true;
  461. OpenDefectSanp = false;
  462. OpenAsideDefect = true;
  463. OpenOredrCheck = false;
  464. OpenOredrCntCheck = false;
  465. OpenShowDB = false;
  466. //LightCfg = new LightParams();
  467. //IOCfg = new IOParams();
  468. IODevName = "";
  469. IOCfgPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\IOCard_default.xml"); ;
  470. LightCom = "";
  471. LightComBaud = 9600;
  472. LensMotorCom = "";
  473. LensMotorComBaud = 9600;
  474. TensionCom = "";
  475. TensionComBaud = 2400;
  476. ThicknessIP = "192.168.3.35";
  477. ThicknessPort = 8888;
  478. ThicknessSafeValue = 10;
  479. FrontCamCfgPath = "";
  480. BackCamCfgPath = "";
  481. MotionCfgPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\Axis_default.cfg"); ;
  482. SaveAllImg = false;
  483. DisableX1 = false;
  484. DisableX2 = false;
  485. DisableY = false;
  486. DisableZ = false;
  487. DisableFrontCam = false;
  488. DisableBackCam = false;
  489. DisableLight = false;
  490. DisableLensMotor = false;
  491. DisableTensor = false;
  492. DisableThickness = false;
  493. ImageProcessPath = "C:\\Users\\user\\AppData\\Local\\Programs\\MVTec\\HALCON-21.05-Progress\\procedures\\general";
  494. ImageProcessDataPath = "C:\\Users\\PC\\AppData\\Local\\Programs\\MVTec\\HALCON-21.05-Progress\\procedures\\User_Data\\HomMat2D1M2CCDpose";
  495. AIModelPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\onnxFiles");
  496. ProductPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\Project");
  497. HttpServerIP = "127.0.0.1";
  498. HttpServerPort = 18082;
  499. LogPath = Path.Combine(Directory.GetCurrentDirectory(), "LogFiles");
  500. AutoDeleteLog = false;
  501. AutoDeleteLogData = 0;
  502. ShowResetBtn = true;
  503. ShowBuzz = false;
  504. ShowDoorAlm = false;
  505. ShowDistribution = false;
  506. ShowSizeBtn = false;
  507. ShowDefectBtn = false;
  508. DefectCamViewX = 35.5;
  509. DefectCamViewY = 26.5;
  510. EnableHttp = false;
  511. HttpUrl = "";
  512. HttpTempPath = "";
  513. HttpReturnKey = "";
  514. HttpReturnValue = "";
  515. LensAxisZPos = new LensAxisZ();
  516. //缺陷配置
  517. Defect_CutSize = new Size(592, 532);
  518. Defect_ReSize = new Size(224, 224);
  519. Defect_Thresholds = 0.4f;
  520. EnableLabelPrint = false;
  521. LabelPrinterName = "";
  522. LabelTempPath = "";
  523. LabelData = new Dictionary<string, string>();
  524. EnableExcelPrint = false;
  525. ExcelPrinterName = "";
  526. ExcelTempPath = "";
  527. ExcelData = new Dictionary<string, string>();
  528. OpenCloud = false;
  529. CloudThisName = "Test";
  530. CloudServerIP = "127.0.0.1";
  531. CloudServerPort = 1883;
  532. CloudUser = "";
  533. CloudPassword = "";
  534. OpenPdtServer = false;
  535. PdtServerIP = "127.0.0.1";
  536. PdtServerPort = 10573;
  537. IsPdtServer = true;
  538. Pt_offset = 0;
  539. Line_offset = 0;
  540. X_per = 0.1;
  541. Y_per = 0.1;
  542. LightCH = 2;
  543. LightLut = 255;
  544. CamExposureTime = 8000;
  545. LightChannelCnt = 4;
  546. CustomerName = "";
  547. }
  548. }
  549. #endregion
  550. #region 尺寸检测参数
  551. public class SizeItemParam
  552. {
  553. /// <summary>
  554. /// 名称
  555. /// </summary>
  556. public string Name { get; set; }
  557. /// <summary>
  558. /// 代码
  559. /// </summary>
  560. public string Code { get; set; }
  561. /// <summary>
  562. /// 测试点数
  563. /// </summary>
  564. public int PointCnt { get; set; }
  565. /// <summary>
  566. /// 处理代码
  567. /// </summary>
  568. public int[] DefectIndex { get; set; }
  569. /// <summary>
  570. /// RGB颜色代码
  571. /// </summary>
  572. public int[] RGBcolor { get; set; }
  573. /// <summary>
  574. /// 显示单位 0:程序默认 1:mm 2:um
  575. /// </summary>
  576. public int mmOrum { get; set; }
  577. /// <summary>
  578. /// 显示小数点后位数 0:默认4位。
  579. /// </summary>
  580. public int dataLen { get; set; }
  581. }
  582. #endregion
  583. #region 缺陷检测参数
  584. public class DefectItemParam
  585. {
  586. /// <summary>
  587. /// 名称
  588. /// </summary>
  589. public string Name { get; set; }
  590. /// <summary>
  591. /// 代码
  592. /// </summary>
  593. public string Code { get; set; }
  594. /// <summary>
  595. /// 序号
  596. /// </summary>
  597. public int Index { get; set; }
  598. /// <summary>
  599. /// 默认分值
  600. /// </summary>
  601. public double Threshold { get; set; }
  602. /// <summary>
  603. /// RGB颜色代码
  604. /// </summary>
  605. public int[] RGBcolor { get; set; }
  606. /// <summary>
  607. /// 对应类型
  608. /// </summary>
  609. public string Type { get; set; }
  610. /// <summary>
  611. /// 尺寸
  612. /// </summary>
  613. public float Size { get; set; }
  614. /// <summary>
  615. /// 最大允许缺陷数量
  616. /// </summary>
  617. public int MaxDefectCount { get; set; }
  618. /// <summary>
  619. /// 显示
  620. /// </summary>
  621. public int Show { get; set; }
  622. }
  623. #endregion
  624. /// <summary>
  625. /// 设备参数
  626. /// </summary>
  627. public class ConfMgr
  628. {
  629. #region 实例化
  630. /// <summary>
  631. /// 实例
  632. /// </summary>
  633. private static ConfMgr _instance;
  634. private static readonly object _lock = new object();
  635. public static ConfMgr Instance
  636. {
  637. get
  638. {
  639. if (_instance == null)
  640. {
  641. lock (_lock)
  642. {
  643. if (_instance == null)
  644. {
  645. _instance = new ConfMgr();
  646. }
  647. }
  648. }
  649. return _instance;
  650. }
  651. }
  652. #endregion
  653. #region 私有字段
  654. private readonly string _rootPath;
  655. private readonly string _configFile;
  656. private readonly string _projectDir;
  657. private readonly string _pointsPath;
  658. private readonly string _markPicPath;
  659. private readonly string _sizeItemsPath;
  660. private readonly string _defectItemsPath;
  661. private readonly string _sizeCompItemsPath;
  662. #endregion
  663. private ConfMgr()
  664. {
  665. _rootPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles");
  666. _configFile = Path.Combine(_rootPath, "SysParamsConfig.ini");
  667. _devConfigPath = Path.Combine(_rootPath, "DevParamsConfig.ini");
  668. _projectDir = Path.Combine(_rootPath, "Project");
  669. _pointsPath = Path.Combine(_rootPath, "PointsConfig.ini");
  670. _markPicPath = Path.Combine(_rootPath, "MarkPic");
  671. _specificationPath = Path.Combine(_rootPath, "版博士软件操作说明.docx");
  672. _sizeItemsPath = Path.Combine(_rootPath, "尺寸测试项.json");
  673. _defectItemsPath = Path.Combine(_rootPath, "缺陷测试项.json");
  674. _sizeCompItemsPath = Path.Combine(_rootPath, "比对测试项.json");
  675. DBConStr = "server = localhost; Database = ProductionDB; Uid = root; Pwd = " + ConteolUserDB.GetSqlDBCode() + "; AllowLoadLocalInfile = true;";
  676. }
  677. #region 公开字段
  678. //DB
  679. //有些服务器防火墙有问题需要加上 min pool size=1 避免认为是恶意请求
  680. //如果用到bulkCopy需要加: AllowLoadLocalInfile=true
  681. //public static string dbMysqlCon = "server=localhost;Database=ProductionDB;Uid=root;Pwd=123456;";
  682. public string DBConStr = "server=localhost;Database=ProductionDB;Uid=root;Pwd=123456; AllowLoadLocalInfile=true";
  683. /// <summary>
  684. /// 系统配置参数
  685. /// </summary>
  686. public SysConfigParams SysConfigParams { get; set; }
  687. private string _devConfigPath;
  688. /// <summary>
  689. /// 获取驱动配制文件路径
  690. /// </summary>
  691. public string DevConfigPath { get { return _devConfigPath; } }
  692. //public string ProjectDir { get { return _projectDir; } }
  693. public string ProjectDir { get { return SysConfigParams.ProductPath; } }
  694. public string MarkPicPath { get { return _markPicPath; } }
  695. /// <summary>
  696. /// 说明书路径
  697. /// </summary>
  698. public string SpecificationPath { get { return _specificationPath; } }
  699. private string _specificationPath;
  700. /// <summary>
  701. /// 上料位X1
  702. /// </summary>
  703. public double LoadPoint_X1 { get; set; }
  704. /// <summary>
  705. /// 上料位X2
  706. /// </summary>
  707. public double LoadPoint_X2 { get; set; }
  708. /// <summary>
  709. /// 上料位Y
  710. /// </summary>
  711. public double LoadPoint_Y { get; set; }
  712. /// <summary>
  713. /// 上料位Z
  714. /// </summary>
  715. public double LoadPoint_Z { get; set; }
  716. /// <summary>
  717. /// 测厚气缸到位等待时间
  718. /// </summary>
  719. public int HeightDoWait { get; set; }
  720. /// <summary>
  721. /// 加紧气缸到位等待时间
  722. /// </summary>
  723. public int ProductDoWait { get; set; }
  724. #endregion
  725. #region 公开文件操作
  726. #region 点位配置
  727. public void WritePointsAndTime(double x1, double x2, double y, double z, int ht, int pt)
  728. {
  729. //XmlHelper.Serialize<SysConfParams>(_configFile, sysConfParams);
  730. IniHelper iniHelper = new IniHelper(_pointsPath);
  731. iniHelper.WriteDouble("LoadPoint", "X1", x1);
  732. iniHelper.WriteDouble("LoadPoint", "X2", x2);
  733. iniHelper.WriteDouble("LoadPoint", "Y", y);
  734. iniHelper.WriteDouble("LoadPoint", "Z", z);
  735. iniHelper.WriteInteger("WaitTime", "HeightDoWait", ht);
  736. iniHelper.WriteInteger("WaitTime", "ProductDoWait", pt);
  737. LoadPoint_X1 = x1;
  738. LoadPoint_X2 = x2;
  739. LoadPoint_Y = y;
  740. LoadPoint_Z = z;
  741. HeightDoWait = ht;
  742. ProductDoWait = pt;
  743. }
  744. public void ReadPointsAndTime()
  745. {
  746. IniHelper iniHelper = new IniHelper(_pointsPath);
  747. double dValue = 0;
  748. int iValue = 0;
  749. iniHelper.ReadDouble("LoadPoint", "X1", out dValue);
  750. LoadPoint_X1 = dValue;
  751. iniHelper.ReadDouble("LoadPoint", "X2", out dValue);
  752. LoadPoint_X2 = dValue;
  753. iniHelper.ReadDouble("LoadPoint", "Y", out dValue);
  754. LoadPoint_Y = dValue;
  755. iniHelper.ReadDouble("LoadPoint", "Z", out dValue);
  756. LoadPoint_Z = dValue;
  757. iniHelper.ReadInteger("WaitTime", "HeightDoWait", out iValue);
  758. HeightDoWait = iValue;
  759. iniHelper.ReadInteger("WaitTime", "ProductDoWait", out iValue);
  760. ProductDoWait = iValue;
  761. }
  762. #endregion
  763. #region 系统配置参数
  764. /// <summary>
  765. /// 写入ini
  766. /// </summary>
  767. /// <param name="SocketParams"></param>
  768. public void WriteSysConfParams(SysConfigParams SysParams)
  769. {
  770. //XmlHelper.Serialize<SysConfParams>(_configFile, sysConfParams);
  771. IniHelper iniHelper = new IniHelper(_configFile);
  772. iniHelper.WriteString("DefectSrcSmallImag", "Defect_SrcSmall_SavePath", SysParams.Defect_SrcSmall_SavePath);
  773. iniHelper.WriteDouble("DefectSrcSmallImag", "Defect_SrcSmall_Thres", SysParams.Defect_SrcSmall_Thres);
  774. iniHelper.WriteBool("SaveAllImg", "SaveAllImg", SysParams.SaveAllImg);
  775. iniHelper.WriteString("DefectBigImag", "SavePath", SysParams.DefectBigImag.SavePath);
  776. iniHelper.WriteBool("DefectBigImag", "AutoSave", SysParams.DefectBigImag.AutoSave);
  777. iniHelper.WriteBool("DefectBigImag", "AutoDelete", SysParams.DefectBigImag.AutoDelete);
  778. iniHelper.WriteDouble("DefectBigImag", "AutoDeleteDays", SysParams.DefectBigImag.AutoDeleteDays);
  779. iniHelper.WriteString("DefectSrcSmallImag", "SavePath", SysParams.DefectSrcSmallImag.SavePath);
  780. iniHelper.WriteBool("DefectSrcSmallImag", "AutoSave", SysParams.DefectSrcSmallImag.AutoSave);
  781. iniHelper.WriteBool("DefectSrcSmallImag", "AutoDelete", SysParams.DefectSrcSmallImag.AutoDelete);
  782. iniHelper.WriteDouble("DefectSrcSmallImag", "AutoDeleteDays", SysParams.DefectSrcSmallImag.AutoDeleteDays);
  783. iniHelper.WriteString("DefectSmallImag", "SavePath", SysParams.DefectSmallImag.SavePath);
  784. iniHelper.WriteBool("DefectSmallImag", "AutoSave", SysParams.DefectSmallImag.AutoSave);
  785. iniHelper.WriteBool("DefectSmallImag", "AutoDelete", SysParams.DefectSmallImag.AutoDelete);
  786. iniHelper.WriteDouble("DefectSmallImag", "AutoDeleteDays", SysParams.DefectSmallImag.AutoDeleteDays);
  787. iniHelper.WriteString("DefectRepairImag", "SavePath", SysParams.DefectRepairImag.SavePath);
  788. iniHelper.WriteBool("DefectRepairImag", "AutoSave", SysParams.DefectRepairImag.AutoSave);
  789. iniHelper.WriteBool("DefectRepairImag", "AutoDelete", SysParams.DefectRepairImag.AutoDelete);
  790. iniHelper.WriteDouble("DefectRepairImag", "AutoDeleteDays", SysParams.DefectRepairImag.AutoDeleteDays);
  791. iniHelper.WriteString("SizeBigImag", "SavePath", SysParams.SizeBigImag.SavePath);
  792. iniHelper.WriteBool("SizeBigImag", "AutoSave", SysParams.SizeBigImag.AutoSave);
  793. iniHelper.WriteBool("SizeBigImag", "AutoDelete", SysParams.SizeBigImag.AutoDelete);
  794. iniHelper.WriteDouble("SizeBigImag", "AutoDeleteDays", SysParams.SizeBigImag.AutoDeleteDays);
  795. iniHelper.WriteString("SizeNGImag", "SavePath", SysParams.SizeNGImag.SavePath);
  796. iniHelper.WriteBool("SizeNGImag", "AutoSave", SysParams.SizeNGImag.AutoSave);
  797. iniHelper.WriteBool("SizeNGImag", "AutoDelete", SysParams.SizeNGImag.AutoDelete);
  798. iniHelper.WriteDouble("SizeNGImag", "AutoDeleteDays", SysParams.SizeNGImag.AutoDeleteDays);
  799. iniHelper.WriteString("SizeRepairImag", "SavePath", SysParams.SizeRepairImag.SavePath);
  800. iniHelper.WriteBool("SizeRepairImag", "AutoSave", SysParams.SizeRepairImag.AutoSave);
  801. iniHelper.WriteBool("SizeRepairImag", "AutoDelete", SysParams.SizeRepairImag.AutoDelete);
  802. iniHelper.WriteDouble("SizeRepairImag", "AutoDeleteDays", SysParams.SizeRepairImag.AutoDeleteDays);
  803. iniHelper.WriteString("Log", "SavePath", SysParams.LogPath);
  804. iniHelper.WriteBool("Log", "AutoDelete", SysParams.AutoDeleteLog);
  805. iniHelper.WriteDouble("Log", "AutoDeleteDays", SysParams.AutoDeleteLogData);
  806. iniHelper.WriteBool("SysFunction", "OpenMarkErrorStop", SysParams.OpenMarkErrorStop);
  807. iniHelper.WriteBool("SysFunction", "OpenBuzzer", SysParams.OpenBuzzer);
  808. iniHelper.WriteBool("SysFunction", "OpenDoor", SysParams.OpenDoor);
  809. iniHelper.WriteBool("SysFunction", "OpenHttpLog", SysParams.OpenHttpLog);
  810. iniHelper.WriteBool("SysFunction", "OpenAutoGoHome", SysParams.OpenAutoGoHome);
  811. iniHelper.WriteBool("SysFunction", "OpenFlawDistribution", SysParams.OpenFlawDistribution);
  812. iniHelper.WriteBool("SysFunction", "OpenAxisXCalibration", SysParams.OpenAxisXCalibration);
  813. iniHelper.WriteBool("SysFunction", "OpenPdtIsHave", SysParams.OpenPdtIsHave);
  814. iniHelper.WriteBool("SysFunction", "OpenDefectSanp", SysParams.OpenDefectSanp);
  815. iniHelper.WriteBool("SysFunction", "OpenAsideDefect", SysParams.OpenAsideDefect);
  816. iniHelper.WriteBool("SysFunction", "OpenOredrCheck", SysParams.OpenOredrCheck);
  817. iniHelper.WriteBool("SysFunction", "OpenOredrCntCheck", SysParams.OpenOredrCntCheck);
  818. iniHelper.WriteBool("SysFunction", "OpenShowDB", SysParams.OpenShowDB);
  819. iniHelper.WriteBool("SysFunction", "OpenColorB", SysParams.OpenColorB);
  820. iniHelper.WriteBool("SysFunction", "OpenRemoveDuplicates", SysParams.OpenRemoveDuplicates);
  821. iniHelper.WriteString("Dev", "LightCom", SysParams.LightCom);
  822. iniHelper.WriteInteger("Dev", "LightComBaud", SysParams.LightComBaud);
  823. iniHelper.WriteString("Dev", "TensionCom", SysParams.TensionCom);
  824. iniHelper.WriteInteger("Dev", "TensionComBaud", SysParams.TensionComBaud);
  825. iniHelper.WriteDouble("Dev", "Tension_Offset", SysParams.Tension_Offset);
  826. iniHelper.WriteString("Dev", "LensMotorCom", SysParams.LensMotorCom);
  827. iniHelper.WriteInteger("Dev", "LensMotorComBaud", SysParams.LensMotorComBaud);
  828. iniHelper.WriteString("Dev", "ThicknessIP", SysParams.ThicknessIP);
  829. iniHelper.WriteInteger("Dev", "ThicknessPort", SysParams.ThicknessPort);
  830. iniHelper.WriteDouble("Dev", "ThicknessSafeValue", SysParams.ThicknessSafeValue);
  831. iniHelper.WriteDouble("Dev", "Thickness_Offset", SysParams.Thickness_Offset);
  832. iniHelper.WriteString("Dev", "IODevName", SysParams.IODevName);
  833. iniHelper.WriteString("Dev", "IOCfgPath", SysParams.IOCfgPath);
  834. iniHelper.WriteString("Dev", "MotionCfgPath", SysParams.MotionCfgPath);
  835. iniHelper.WriteString("Dev", "FrontCamName", SysParams.FrontCamName);
  836. iniHelper.WriteString("Dev", "FrontCamCfgPath", SysParams.FrontCamCfgPath);
  837. iniHelper.WriteString("Dev", "BackCamName", SysParams.BackCamName);
  838. iniHelper.WriteString("Dev", "BackCamCfgPath", SysParams.BackCamCfgPath);
  839. iniHelper.WriteBool("Disable", "DisableX1", SysParams.DisableX1);
  840. iniHelper.WriteBool("Disable", "DisableX2", SysParams.DisableX2);
  841. iniHelper.WriteBool("Disable", "DisableY", SysParams.DisableY);
  842. iniHelper.WriteBool("Disable", "DisableZ", SysParams.DisableZ);
  843. iniHelper.WriteBool("Disable", "DisableFrontCam", SysParams.DisableFrontCam);
  844. iniHelper.WriteBool("Disable", "DisableBackCam", SysParams.DisableBackCam);
  845. iniHelper.WriteBool("Disable", "DisableLight", SysParams.DisableLight);
  846. iniHelper.WriteBool("Disable", "DisableThickness", SysParams.DisableThickness);
  847. iniHelper.WriteBool("Disable", "DisableTensor", SysParams.DisableTensor);
  848. iniHelper.WriteBool("Disable", "DisableLensMotor", SysParams.DisableLensMotor);
  849. iniHelper.WriteString("Sys", "ImageProcessPath", SysParams.ImageProcessPath);
  850. iniHelper.WriteString("Sys", "ImageProcessDataPath", SysParams.ImageProcessDataPath);
  851. iniHelper.WriteString("Sys", "AIModelPath", SysParams.AIModelPath);
  852. iniHelper.WriteString("Sys", "ProductPath", SysParams.ProductPath);
  853. iniHelper.WriteString("Sys", "HttpServerIP", SysParams.HttpServerIP);
  854. iniHelper.WriteInteger("Sys", "HttpServerPort", SysParams.HttpServerPort);
  855. iniHelper.WriteBool("ShowMainWin", "ShowResetBtn", SysParams.ShowResetBtn);
  856. iniHelper.WriteBool("ShowMainWin", "ShowBuzz", SysParams.ShowBuzz);
  857. iniHelper.WriteBool("ShowMainWin", "ShowDoorAlm", SysParams.ShowDoorAlm);
  858. iniHelper.WriteBool("ShowMainWin", "ShowDistribution", SysParams.ShowDistribution);
  859. iniHelper.WriteBool("ShowMainWin", "ShowSizeBtn", SysParams.ShowSizeBtn);
  860. iniHelper.WriteBool("ShowMainWin", "ShowDefectBtn", SysParams.ShowDefectBtn);
  861. iniHelper.WriteDouble("CamView", "DefectCamViewX", SysParams.DefectCamViewX);
  862. iniHelper.WriteDouble("CamView", "DefectCamViewY", SysParams.DefectCamViewY);
  863. iniHelper.WriteBool("CloudAndMES", "EnableHttp", SysParams.EnableHttp);
  864. iniHelper.WriteString("CloudAndMES", "HttpUrl", SysParams.HttpUrl);
  865. iniHelper.WriteString("CloudAndMES", "HttpTempPath", SysParams.HttpTempPath);
  866. iniHelper.WriteString("CloudAndMES", "HttpReturnKey", SysParams.HttpReturnKey);
  867. iniHelper.WriteString("CloudAndMES", "HttpReturnValue", SysParams.HttpReturnValue);
  868. iniHelper.WriteBool("CloudAndMES", "OpenCloud", SysParams.OpenCloud);
  869. iniHelper.WriteString("CloudAndMES", "CloudThisName", SysParams.CloudThisName);
  870. iniHelper.WriteString("CloudAndMES", "CloudServerIP", SysParams.CloudServerIP);
  871. iniHelper.WriteInteger("CloudAndMES", "CloudServerPort", SysParams.CloudServerPort);
  872. iniHelper.WriteString("CloudAndMES", "CloudUser", SysParams.CloudUser);
  873. iniHelper.WriteString("CloudAndMES", "CloudPassword", SysParams.CloudPassword);
  874. iniHelper.WriteBool("CloudAndMES", "OpenPdtServer", SysParams.OpenPdtServer);
  875. iniHelper.WriteString("CloudAndMES", "PdtServerIP", SysParams.PdtServerIP);
  876. iniHelper.WriteInteger("CloudAndMES", "PdtServerPort", SysParams.PdtServerPort);
  877. iniHelper.WriteBool("CloudAndMES", "IsPdtServer", SysParams.IsPdtServer);
  878. iniHelper.WriteDouble("LensZ", "Z_0_58X", SysParams.LensAxisZPos.Z_0_58X);
  879. //iniHelper.WriteDouble("LensZ", "Z_0_6X", SysParams.LensAxisZPos.Z_0_6X);
  880. iniHelper.WriteDouble("LensZ", "Z_1_0X", SysParams.LensAxisZPos.Z_1_0X);
  881. iniHelper.WriteDouble("LensZ", "Z_1_5X", SysParams.LensAxisZPos.Z_1_5X);
  882. iniHelper.WriteDouble("LensZ", "Z_2_0X", SysParams.LensAxisZPos.Z_2_0X);
  883. iniHelper.WriteDouble("LensZ", "Z_2_5X", SysParams.LensAxisZPos.Z_2_5X);
  884. iniHelper.WriteDouble("LensZ", "Z_3_0X", SysParams.LensAxisZPos.Z_3_0X);
  885. iniHelper.WriteDouble("LensZ", "Z_3_5X", SysParams.LensAxisZPos.Z_3_5X);
  886. iniHelper.WriteDouble("LensZ", "Z_4_0X", SysParams.LensAxisZPos.Z_4_0X);
  887. iniHelper.WriteDouble("LensZ", "Z_4_5X", SysParams.LensAxisZPos.Z_4_5X);
  888. iniHelper.WriteDouble("LensZ", "Z_5_0X", SysParams.LensAxisZPos.Z_5_0X);
  889. iniHelper.WriteDouble("LensZ", "Z_5_5X", SysParams.LensAxisZPos.Z_5_5X);
  890. iniHelper.WriteDouble("LensZ", "Z_6_0X", SysParams.LensAxisZPos.Z_6_0X);
  891. iniHelper.WriteDouble("LensZ", "Z_6_5X", SysParams.LensAxisZPos.Z_6_5X);
  892. iniHelper.WriteDouble("LensZ", "Z_7_0X", SysParams.LensAxisZPos.Z_7_0X);
  893. iniHelper.WriteDouble("LensZ", "Z_7_5X", SysParams.LensAxisZPos.Z_7_5X);
  894. iniHelper.WriteBool("LabelPrint", "EnableLabelPrint", SysParams.EnableLabelPrint);
  895. iniHelper.WriteString("LabelPrint", "LabelPrinterName", SysParams.LabelPrinterName);
  896. iniHelper.WriteString("LabelPrint", "LabelTempPath", SysParams.LabelTempPath);
  897. iniHelper.WriteString("LabelPrint", "LabelData", JsonConvert.SerializeObject(SysParams.LabelData));
  898. iniHelper.WriteBool("ExcelPrint", "EnableExcelPrint", SysParams.EnableExcelPrint);
  899. iniHelper.WriteString("ExcelPrint", "ExcelPrinterName", SysParams.ExcelPrinterName);
  900. iniHelper.WriteString("ExcelPrint", "ExcelTempPath", SysParams.ExcelTempPath);
  901. iniHelper.WriteString("ExcelPrint", "ExcelData", JsonConvert.SerializeObject(SysParams.ExcelData));
  902. iniHelper.WriteDouble("Offset", "Pt_offset", SysParams.Pt_offset);
  903. iniHelper.WriteDouble("Offset", "Line_offset", SysParams.Line_offset);
  904. iniHelper.WriteDouble("Offset", "X_per", SysParams.X_per);
  905. iniHelper.WriteDouble("Offset", "Y_per", SysParams.Y_per);
  906. iniHelper.WriteInteger("DefectSnap", "LightCH", SysParams.LightCH);
  907. iniHelper.WriteInteger("DefectSnap", "LightLut", SysParams.LightLut);
  908. iniHelper.WriteInteger("DefectSnap", "CamExposureTime", SysParams.CamExposureTime);
  909. iniHelper.WriteInteger("SysOther", "LightChannelCnt", SysParams.LightChannelCnt);
  910. iniHelper.WriteString("SysOther", "CustomerName", SysParams.CustomerName);
  911. SysConfigParams = SysParams;
  912. }
  913. /// <summary>
  914. /// 读取ini
  915. /// </summary>
  916. /// <returns></returns>
  917. public SysConfigParams ReadSysConfParams()
  918. {
  919. //return XmlHelper.Deserialize<SysConfParams>(_configFile);
  920. SysConfigParams sysParams = new SysConfigParams();
  921. IniHelper iniHelper = new IniHelper(_configFile);
  922. string sValue = "";
  923. int iValue = 0;
  924. double dValue = 0;
  925. bool bValue = false;
  926. iniHelper.ReadString("DefectSrcSmallImag", "Defect_SrcSmall_SavePath", out sValue);
  927. sysParams.Defect_SrcSmall_SavePath = sValue;
  928. iniHelper.ReadDouble("DefectSrcSmallImag", "Defect_SrcSmall_Thres", out dValue);
  929. sysParams.Defect_SrcSmall_Thres = dValue;
  930. iniHelper.ReadBool("SaveAllImg", "SaveAllImg", out bValue);
  931. sysParams.SaveAllImg = bValue;
  932. iniHelper.ReadString("DefectBigImag", "SavePath", out sValue);
  933. sysParams.DefectBigImag.SavePath = sValue.Replace("\0", "");
  934. iniHelper.ReadBool("DefectBigImag", "AutoSave", out bValue);
  935. sysParams.DefectBigImag.AutoSave = bValue;
  936. iniHelper.ReadBool("DefectBigImag", "AutoDelete", out bValue);
  937. sysParams.DefectBigImag.AutoDelete = bValue;
  938. iniHelper.ReadDouble("DefectBigImag", "AutoDeleteDays", out dValue);
  939. sysParams.DefectBigImag.AutoDeleteDays = dValue;
  940. iniHelper.ReadString("DefectSrcSmallImag", "SavePath", out sValue);
  941. sysParams.DefectSrcSmallImag.SavePath = sValue.Replace("\0", "");
  942. iniHelper.ReadBool("DefectSrcSmallImag", "AutoSave", out bValue);
  943. sysParams.DefectSrcSmallImag.AutoSave = bValue;
  944. iniHelper.ReadBool("DefectSrcSmallImag", "AutoDelete", out bValue);
  945. sysParams.DefectSrcSmallImag.AutoDelete = bValue;
  946. iniHelper.ReadDouble("DefectSrcSmallImag", "AutoDeleteDays", out dValue);
  947. sysParams.DefectSrcSmallImag.AutoDeleteDays = dValue;
  948. iniHelper.ReadString("DefectSmallImag", "SavePath", out sValue);
  949. sysParams.DefectSmallImag.SavePath = sValue.Replace("\0", "");
  950. iniHelper.ReadBool("DefectSmallImag", "AutoSave", out bValue);
  951. sysParams.DefectSmallImag.AutoSave = bValue;
  952. iniHelper.ReadBool("DefectSmallImag", "AutoDelete", out bValue);
  953. sysParams.DefectSmallImag.AutoDelete = bValue;
  954. iniHelper.ReadDouble("DefectSmallImag", "AutoDeleteDays", out dValue);
  955. sysParams.DefectSmallImag.AutoDeleteDays = dValue;
  956. iniHelper.ReadString("DefectRepairImag", "SavePath", out sValue);
  957. sysParams.DefectRepairImag.SavePath = sValue.Replace("\0", "");
  958. iniHelper.ReadBool("DefectRepairImag", "AutoSave", out bValue);
  959. sysParams.DefectRepairImag.AutoSave = bValue;
  960. iniHelper.ReadBool("DefectRepairImag", "AutoDelete", out bValue);
  961. sysParams.DefectRepairImag.AutoDelete = bValue;
  962. iniHelper.ReadDouble("DefectRepairImag", "AutoDeleteDays", out dValue);
  963. sysParams.DefectRepairImag.AutoDeleteDays = dValue;
  964. iniHelper.ReadString("SizeBigImag", "SavePath", out sValue);
  965. sysParams.SizeBigImag.SavePath = sValue.Replace("\0", "");
  966. iniHelper.ReadBool("SizeBigImag", "AutoSave", out bValue);
  967. sysParams.SizeBigImag.AutoSave = bValue;
  968. iniHelper.ReadBool("SizeBigImag", "AutoDelete", out bValue);
  969. sysParams.SizeBigImag.AutoDelete = bValue;
  970. iniHelper.ReadDouble("SizeBigImag", "AutoDeleteDays", out dValue);
  971. sysParams.SizeBigImag.AutoDeleteDays = dValue;
  972. iniHelper.ReadString("SizeNGImag", "SavePath", out sValue);
  973. sysParams.SizeNGImag.SavePath = sValue.Replace("\0", "");
  974. iniHelper.ReadBool("SizeNGImag", "AutoSave", out bValue);
  975. sysParams.SizeNGImag.AutoSave = bValue;
  976. iniHelper.ReadBool("SizeNGImag", "AutoDelete", out bValue);
  977. sysParams.SizeNGImag.AutoDelete = bValue;
  978. iniHelper.ReadDouble("SizeNGImag", "AutoDeleteDays", out dValue);
  979. sysParams.SizeNGImag.AutoDeleteDays = dValue;
  980. iniHelper.ReadString("SizeRepairImag", "SavePath", out sValue);
  981. sysParams.SizeRepairImag.SavePath = sValue.Replace("\0", "");
  982. iniHelper.ReadBool("SizeRepairImag", "AutoSave", out bValue);
  983. sysParams.SizeRepairImag.AutoSave = bValue;
  984. iniHelper.ReadBool("SizeRepairImag", "AutoDelete", out bValue);
  985. sysParams.SizeRepairImag.AutoDelete = bValue;
  986. iniHelper.ReadDouble("SizeRepairImag", "AutoDeleteDays", out dValue);
  987. sysParams.SizeRepairImag.AutoDeleteDays = dValue;
  988. iniHelper.ReadString("Log", "SavePath", out sValue);
  989. sysParams.LogPath = sValue.Replace("\0", "");
  990. iniHelper.ReadBool("Log", "AutoDelete", out bValue);
  991. sysParams.AutoDeleteLog = bValue;
  992. iniHelper.ReadDouble("Log", "AutoDeleteDays", out dValue);
  993. sysParams.AutoDeleteLogData = dValue;
  994. iniHelper.ReadBool("SysFunction", "OpenMarkErrorStop", out bValue);
  995. sysParams.OpenMarkErrorStop = bValue;
  996. iniHelper.ReadBool("SysFunction", "OpenBuzzer", out bValue);
  997. sysParams.OpenBuzzer = bValue;
  998. iniHelper.ReadBool("SysFunction", "OpenDoor", out bValue);
  999. sysParams.OpenDoor = bValue;
  1000. iniHelper.ReadBool("SysFunction", "OpenHttpLog", out bValue);
  1001. sysParams.OpenHttpLog = bValue;
  1002. iniHelper.ReadBool("SysFunction", "OpenAutoGoHome", out bValue);
  1003. sysParams.OpenAutoGoHome = bValue;
  1004. iniHelper.ReadBool("SysFunction", "OpenFlawDistribution", out bValue);
  1005. sysParams.OpenFlawDistribution = bValue;
  1006. iniHelper.ReadBool("SysFunction", "OpenAxisXCalibration", out bValue);
  1007. sysParams.OpenAxisXCalibration = bValue;
  1008. iniHelper.ReadBool("SysFunction", "OpenPdtIsHave", out bValue);
  1009. sysParams.OpenPdtIsHave = bValue;
  1010. iniHelper.ReadBool("SysFunction", "OpenDefectSanp", out bValue);
  1011. sysParams.OpenDefectSanp = bValue;
  1012. iniHelper.ReadBool("SysFunction", "OpenAsideDefect", out bValue);
  1013. sysParams.OpenAsideDefect = bValue;
  1014. iniHelper.ReadBool("SysFunction", "OpenOredrCheck", out bValue);
  1015. sysParams.OpenOredrCheck = bValue;
  1016. iniHelper.ReadBool("SysFunction", "OpenOredrCntCheck", out bValue);
  1017. sysParams.OpenOredrCntCheck = bValue;
  1018. iniHelper.ReadBool("SysFunction", "OpenShowDB", out bValue);
  1019. sysParams.OpenShowDB = bValue;
  1020. iniHelper.ReadBool("SysFunction", "OpenColorB", out bValue);
  1021. sysParams.OpenColorB = bValue;
  1022. iniHelper.ReadBool("SysFunction", "OpenRemoveDuplicates", out bValue);
  1023. sysParams.OpenRemoveDuplicates = bValue;
  1024. iniHelper.ReadString("Dev", "LightCom", out sValue);
  1025. sysParams.LightCom = sValue.Replace("\0", "");
  1026. iniHelper.ReadInteger("Dev", "LightComBaud", out iValue);
  1027. sysParams.LightComBaud = iValue;
  1028. iniHelper.ReadString("Dev", "TensionCom", out sValue);
  1029. sysParams.TensionCom = sValue.Replace("\0", "");
  1030. iniHelper.ReadInteger("Dev", "TensionComBaud", out iValue);
  1031. sysParams.TensionComBaud = iValue;
  1032. iniHelper.ReadDouble("Dev", "Tension_Offset", out dValue);
  1033. sysParams.Tension_Offset = dValue;
  1034. iniHelper.ReadString("Dev", "LensMotorCom", out sValue);
  1035. sysParams.LensMotorCom = sValue.Replace("\0", "");
  1036. iniHelper.ReadInteger("Dev", "LensMotorComBaud", out iValue);
  1037. sysParams.LensMotorComBaud = iValue;
  1038. iniHelper.ReadString("Dev", "ThicknessIP", out sValue);
  1039. sysParams.ThicknessIP = sValue.Replace("\0", "");
  1040. iniHelper.ReadInteger("Dev", "ThicknessPort", out iValue);
  1041. sysParams.ThicknessPort = iValue;
  1042. iniHelper.ReadDouble("Dev", "ThicknessSafeValue", out dValue);
  1043. sysParams.ThicknessSafeValue = dValue;
  1044. iniHelper.ReadDouble("Dev", "Thickness_Offset", out dValue);
  1045. sysParams.Thickness_Offset = dValue;
  1046. iniHelper.ReadString("Dev", "IODevName", out sValue);
  1047. sysParams.IODevName = sValue.Replace("\0", "");
  1048. iniHelper.ReadString("Dev", "IOCfgPath", out sValue);
  1049. sysParams.IOCfgPath = sValue.Replace("\0", "");
  1050. iniHelper.ReadString("Dev", "FrontCamName", out sValue);
  1051. sysParams.FrontCamName = sValue.Replace("\0", "");
  1052. iniHelper.ReadString("Dev", "FrontCamCfgPath", out sValue);
  1053. sysParams.FrontCamCfgPath = sValue.Replace("\0", "");
  1054. iniHelper.ReadString("Dev", "BackCamName", out sValue);
  1055. sysParams.BackCamName = sValue.Replace("\0", "");
  1056. iniHelper.ReadString("Dev", "BackCamCfgPath", out sValue);
  1057. sysParams.BackCamCfgPath = sValue.Replace("\0", "");
  1058. iniHelper.ReadString("Dev", "MotionCfgPath", out sValue);
  1059. sysParams.MotionCfgPath = sValue.Replace("\0", "");
  1060. iniHelper.ReadBool("Disable", "DisableX1", out bValue);
  1061. sysParams.DisableX1 = bValue;
  1062. iniHelper.ReadBool("Disable", "DisableX2", out bValue);
  1063. sysParams.DisableX2 = bValue;
  1064. iniHelper.ReadBool("Disable", "DisableY", out bValue);
  1065. sysParams.DisableY = bValue;
  1066. iniHelper.ReadBool("Disable", "DisableZ", out bValue);
  1067. sysParams.DisableZ = bValue;
  1068. iniHelper.ReadBool("Disable", "DisableFrontCam", out bValue);
  1069. sysParams.DisableFrontCam = bValue;
  1070. iniHelper.ReadBool("Disable", "DisableBackCam", out bValue);
  1071. sysParams.DisableBackCam = bValue;
  1072. iniHelper.ReadBool("Disable", "DisableLight", out bValue);
  1073. sysParams.DisableLight = bValue;
  1074. iniHelper.ReadBool("Disable", "DisableTensor", out bValue);
  1075. sysParams.DisableTensor = bValue;
  1076. iniHelper.ReadBool("Disable", "DisableThickness", out bValue);
  1077. sysParams.DisableThickness = bValue;
  1078. iniHelper.ReadBool("Disable", "DisableLensMotor", out bValue);
  1079. sysParams.DisableLensMotor = bValue;
  1080. iniHelper.ReadString("Sys", "ImageProcessPath", out sValue);
  1081. sysParams.ImageProcessPath = sValue.Replace("\0", "");
  1082. iniHelper.ReadString("Sys", "ImageProcessDataPath", out sValue);
  1083. sysParams.ImageProcessDataPath = sValue.Replace("\0", "");
  1084. iniHelper.ReadString("Sys", "AIModelPath", out sValue);
  1085. sysParams.AIModelPath = sValue.Replace("\0", "");
  1086. iniHelper.ReadString("Sys", "ProductPath", out sValue);
  1087. sysParams.ProductPath = sValue.Replace("\0", "");
  1088. iniHelper.ReadString("Sys", "HttpServerIP", out sValue);
  1089. sysParams.HttpServerIP = sValue.Replace("\0", "");
  1090. iniHelper.ReadInteger("Sys", "HttpServerPort", out iValue);
  1091. sysParams.HttpServerPort = iValue;
  1092. iniHelper.ReadBool("ShowMainWin", "ShowResetBtn", out bValue);
  1093. sysParams.ShowResetBtn = bValue;
  1094. iniHelper.ReadBool("ShowMainWin", "ShowBuzz", out bValue);
  1095. sysParams.ShowBuzz = bValue;
  1096. iniHelper.ReadBool("ShowMainWin", "ShowDoorAlm", out bValue);
  1097. sysParams.ShowDoorAlm = bValue;
  1098. iniHelper.ReadBool("ShowMainWin", "ShowDistribution", out bValue);
  1099. sysParams.ShowDistribution = bValue;
  1100. iniHelper.ReadBool("ShowMainWin", "ShowSizeBtn", out bValue);
  1101. sysParams.ShowSizeBtn = bValue;
  1102. iniHelper.ReadBool("ShowMainWin", "ShowDefectBtn", out bValue);
  1103. sysParams.ShowDefectBtn = bValue;
  1104. iniHelper.ReadDouble("CamView", "DefectCamViewX", out dValue);
  1105. sysParams.DefectCamViewX = dValue;
  1106. iniHelper.ReadDouble("CamView", "DefectCamViewY", out dValue);
  1107. sysParams.DefectCamViewY = dValue;
  1108. iniHelper.ReadBool("CloudAndMES", "EnableHttp", out bValue);
  1109. sysParams.EnableHttp = bValue;
  1110. iniHelper.ReadString("CloudAndMES", "HttpUrl", out sValue);
  1111. sysParams.HttpUrl = sValue;
  1112. iniHelper.ReadString("CloudAndMES", "HttpTempPath", out sValue);
  1113. sysParams.HttpTempPath = sValue;
  1114. iniHelper.ReadString("CloudAndMES", "HttpReturnKey", out sValue);
  1115. sysParams.HttpReturnKey = sValue;
  1116. iniHelper.ReadString("CloudAndMES", "HttpReturnValue", out sValue);
  1117. sysParams.HttpReturnValue = sValue;
  1118. iniHelper.ReadBool("CloudAndMES", "OpenCloud", out bValue);
  1119. sysParams.OpenCloud = bValue;
  1120. iniHelper.ReadString("CloudAndMES", "CloudThisName", out sValue);
  1121. sysParams.CloudThisName = sValue.Replace("\0", string.Empty);
  1122. iniHelper.ReadString("CloudAndMES", "CloudServerIP", out sValue);
  1123. sysParams.CloudServerIP = sValue;
  1124. iniHelper.ReadInteger("CloudAndMES", "CloudServerPort", out iValue);
  1125. sysParams.CloudServerPort = iValue;
  1126. iniHelper.ReadString("CloudAndMES", "CloudUser", out sValue);
  1127. sysParams.CloudUser = sValue;
  1128. iniHelper.ReadString("CloudAndMES", "CloudPassword", out sValue);
  1129. sysParams.CloudPassword = sValue;
  1130. iniHelper.ReadBool("CloudAndMES", "OpenPdtServer", out bValue);
  1131. sysParams.OpenPdtServer = bValue;
  1132. iniHelper.ReadString("CloudAndMES", "PdtServerIP", out sValue);
  1133. sysParams.PdtServerIP = sValue;
  1134. iniHelper.ReadInteger("CloudAndMES", "PdtServerPort", out iValue);
  1135. sysParams.PdtServerPort = iValue;
  1136. iniHelper.ReadBool("CloudAndMES", "IsPdtServer", out bValue);
  1137. sysParams.IsPdtServer = bValue;
  1138. iniHelper.ReadDouble("LensZ", "Z_0_58X", out dValue);
  1139. sysParams.LensAxisZPos.Z_0_58X = dValue;
  1140. //iniHelper.ReadDouble("LensZ", "Z_0_6X", out dValue);
  1141. //sysParams.LensAxisZPos.Z_0_6X = dValue;
  1142. iniHelper.ReadDouble("LensZ", "Z_1_0X", out dValue);
  1143. sysParams.LensAxisZPos.Z_1_0X = dValue;
  1144. iniHelper.ReadDouble("LensZ", "Z_1_5X", out dValue);
  1145. sysParams.LensAxisZPos.Z_1_5X = dValue;
  1146. iniHelper.ReadDouble("LensZ", "Z_2_0X", out dValue);
  1147. sysParams.LensAxisZPos.Z_2_0X = dValue;
  1148. iniHelper.ReadDouble("LensZ", "Z_2_5X", out dValue);
  1149. sysParams.LensAxisZPos.Z_2_5X = dValue;
  1150. iniHelper.ReadDouble("LensZ", "Z_3_0X", out dValue);
  1151. sysParams.LensAxisZPos.Z_3_0X = dValue;
  1152. iniHelper.ReadDouble("LensZ", "Z_3_5X", out dValue);
  1153. sysParams.LensAxisZPos.Z_3_5X = dValue;
  1154. iniHelper.ReadDouble("LensZ", "Z_4_0X", out dValue);
  1155. sysParams.LensAxisZPos.Z_4_0X = dValue;
  1156. iniHelper.ReadDouble("LensZ", "Z_4_5X", out dValue);
  1157. sysParams.LensAxisZPos.Z_4_5X = dValue;
  1158. iniHelper.ReadDouble("LensZ", "Z_5_0X", out dValue);
  1159. sysParams.LensAxisZPos.Z_5_0X = dValue;
  1160. iniHelper.ReadDouble("LensZ", "Z_5_5X", out dValue);
  1161. sysParams.LensAxisZPos.Z_5_5X = dValue;
  1162. iniHelper.ReadDouble("LensZ", "Z_6_0X", out dValue);
  1163. sysParams.LensAxisZPos.Z_6_0X = dValue;
  1164. iniHelper.ReadDouble("LensZ", "Z_6_5X", out dValue);
  1165. sysParams.LensAxisZPos.Z_6_5X = dValue;
  1166. iniHelper.ReadDouble("LensZ", "Z_7_0X", out dValue);
  1167. sysParams.LensAxisZPos.Z_7_0X = dValue;
  1168. iniHelper.ReadDouble("LensZ", "Z_7_5X", out dValue);
  1169. sysParams.LensAxisZPos.Z_7_5X = dValue;
  1170. iniHelper.ReadBool("LabelPrint", "EnableLabelPrint", out bValue);
  1171. sysParams.EnableLabelPrint = bValue;
  1172. iniHelper.ReadString("LabelPrint", "LabelPrinterName", out sValue);
  1173. sysParams.LabelPrinterName = sValue;
  1174. iniHelper.ReadString("LabelPrint", "LabelTempPath", out sValue);
  1175. sysParams.LabelTempPath = sValue;
  1176. iniHelper.ReadString("LabelPrint", "LabelData", out sValue);
  1177. if (string.IsNullOrEmpty(sValue))
  1178. sysParams.LabelData = new Dictionary<string, string>();
  1179. else
  1180. sysParams.LabelData = JsonConvert.DeserializeObject<Dictionary<string, string>>(sValue);
  1181. iniHelper.ReadBool("ExcelPrint", "EnableExcelPrint", out bValue);
  1182. sysParams.EnableExcelPrint = bValue;
  1183. iniHelper.ReadString("ExcelPrint", "ExcelPrinterName", out sValue);
  1184. sysParams.ExcelPrinterName = sValue;
  1185. iniHelper.ReadString("ExcelPrint", "ExcelTempPath", out sValue);
  1186. sysParams.ExcelTempPath = sValue;
  1187. iniHelper.ReadString("ExcelPrint", "ExcelData", out sValue);
  1188. if (string.IsNullOrEmpty(sValue))
  1189. sysParams.ExcelData = new Dictionary<string, string>();
  1190. else
  1191. sysParams.ExcelData = JsonConvert.DeserializeObject<Dictionary<string, string>>(sValue);
  1192. iniHelper.ReadDouble("Offset", "Pt_offset", out dValue);
  1193. sysParams.Pt_offset = dValue;
  1194. iniHelper.ReadDouble("Offset", "Line_offset", out dValue);
  1195. sysParams.Line_offset = dValue;
  1196. iniHelper.ReadDouble("Offset", "X_per", out dValue);
  1197. if (dValue > 1)
  1198. sysParams.X_per = 0.9;
  1199. else if (dValue <= 0)
  1200. sysParams.X_per = 0.1;
  1201. else
  1202. sysParams.X_per = dValue;
  1203. iniHelper.ReadDouble("Offset", "Y_per", out dValue);
  1204. if (dValue > 1)
  1205. sysParams.Y_per = 0.9;
  1206. else if (dValue <= 0)
  1207. sysParams.Y_per = 0.1;
  1208. else
  1209. sysParams.Y_per = dValue;
  1210. iniHelper.ReadInteger("DefectSnap", "LightCH", out iValue);
  1211. sysParams.LightCH = iValue;
  1212. iniHelper.ReadInteger("DefectSnap", "LightLut", out iValue);
  1213. sysParams.LightLut = iValue;
  1214. iniHelper.ReadInteger("DefectSnap", "CamExposureTime", out iValue);
  1215. sysParams.CamExposureTime = iValue;
  1216. iniHelper.ReadInteger("SysOther", "LightChannelCnt", out iValue);
  1217. sysParams.LightChannelCnt = iValue;
  1218. iniHelper.ReadString("SysOther", "CustomerName", out sValue);
  1219. sysParams.CustomerName = sValue;
  1220. SysConfigParams = sysParams;
  1221. return sysParams;
  1222. }
  1223. /// <summary>
  1224. /// 写入系统默认配置
  1225. /// </summary>
  1226. public void WriteDefaultSystemConfig()
  1227. {
  1228. SysConfigParams = new SysConfigParams();
  1229. WriteSysConfParams(SysConfigParams);
  1230. }
  1231. /// <summary>
  1232. /// 加载系统配置
  1233. /// </summary>
  1234. /// <returns></returns>
  1235. public bool LoadSystemConfig()
  1236. {
  1237. bool ret = false;
  1238. if (!Directory.Exists(_rootPath))
  1239. {
  1240. Directory.CreateDirectory(_rootPath);
  1241. }
  1242. if (!Directory.Exists(_projectDir))
  1243. {
  1244. Directory.CreateDirectory(_projectDir);
  1245. }
  1246. if (File.Exists(_pointsPath))
  1247. {
  1248. ReadPointsAndTime();
  1249. }
  1250. else
  1251. {
  1252. // write default value
  1253. WritePointsAndTime(0, 0, 0, 0, 1000, 1000);
  1254. ret = true;
  1255. }
  1256. if (File.Exists(_configFile))
  1257. {
  1258. SysConfigParams = ReadSysConfParams();
  1259. if (null != SysConfigParams)
  1260. {
  1261. ret = true;
  1262. }
  1263. }
  1264. else
  1265. {
  1266. // write default value
  1267. WriteDefaultSystemConfig();
  1268. ret = true;
  1269. }
  1270. return ret;
  1271. }
  1272. #endregion
  1273. #region 文件选择
  1274. /// <summary>
  1275. /// 选择目录
  1276. /// </summary>
  1277. /// <returns></returns>
  1278. public static string SelectFolder(string defaultPath = "")
  1279. {
  1280. FolderBrowserDialog dlg = new FolderBrowserDialog();
  1281. dlg.SelectedPath = (defaultPath != "" ? defaultPath : Path.GetFullPath("."));
  1282. if (dlg.ShowDialog() == DialogResult.OK)
  1283. return dlg.SelectedPath;
  1284. return "";
  1285. }
  1286. /// <summary>
  1287. /// 选择文件
  1288. /// </summary>
  1289. /// <param name="filter">如 图像文件|*.jpg|图像文件|*.png|所有文件|*.*</param>
  1290. /// <returns></returns>
  1291. public static string SelectFile(string filter = "所有文件|*.*", string defaultPath = "")
  1292. {
  1293. OpenFileDialog fie = new OpenFileDialog();
  1294. fie.Title = "选择文件";
  1295. //fie.InitialDirectory = (defaultPath != "" ? defaultPath : Path.GetFullPath("."));
  1296. fie.Filter = filter; //设置文件类型
  1297. if (fie.ShowDialog() == DialogResult.OK)
  1298. return fie.FileName;
  1299. return "";
  1300. }
  1301. /// <summary>
  1302. /// 删除指定目录下文件
  1303. /// </summary>
  1304. /// <param name="defaultPath"></param>
  1305. /// <param name="fileExtend"></param>
  1306. /// <returns></returns>
  1307. public static bool DelFilesInFolder(string FolderPath, string fileExtend = "*")
  1308. {
  1309. if (!Directory.Exists(FolderPath))
  1310. return false;
  1311. string[] files = Directory.GetFiles(FolderPath, fileExtend, SearchOption.TopDirectoryOnly);
  1312. foreach (string file in files)
  1313. API.DeleteFile(file);
  1314. return true;
  1315. }
  1316. /// <summary>
  1317. /// 另存为
  1318. /// </summary>
  1319. /// <param name="defaultFileName">默认文件名</param>
  1320. /// <param name="filter">如 图像文件|*.jpg|图像文件|*.png|所有文件|*.*</param>
  1321. /// <returns></returns>
  1322. public static string SaveAsFile(string defaultFileName, string filter = "所有文件|*.*")
  1323. {
  1324. SaveFileDialog s = new SaveFileDialog();
  1325. s.Title = "保存文件";
  1326. s.Filter = filter; //"图像文件|*.jpg|图像文件|*.png|所有文件|*.*";
  1327. //s.DefaultExt = "图像文件|*.jpg"; //默认扩展名
  1328. //s.InitialDirectory = @"C:\Users\Administrator\Desktop"; //保存的初始目录
  1329. s.FileName = defaultFileName;//默认文件名
  1330. if (s.ShowDialog() == DialogResult.OK)
  1331. return s.FileName;
  1332. return "";
  1333. }
  1334. #endregion
  1335. #region json操作
  1336. public static void addKey(JObject obj, string key, JToken value)
  1337. {
  1338. if (obj.ContainsKey(key))
  1339. obj[key] = value;
  1340. else
  1341. obj.Add(key, value);
  1342. }
  1343. #endregion
  1344. #region enum名称
  1345. public static ArrayList GetArrayList<T>()
  1346. {
  1347. ArrayList list = new ArrayList();
  1348. Type type = typeof(T);
  1349. //list.Add(new DictionaryEntry("start", "启动按钮"));
  1350. foreach (int value in Enum.GetValues(type))
  1351. {
  1352. string strName = Enum.GetName(type, value);//获取名称
  1353. list.Add(new DictionaryEntry(value, strName));
  1354. }
  1355. return list;
  1356. }
  1357. #endregion
  1358. #region 生产数据记录
  1359. public bool SetDailyOutputAdd(out int tDailyOutput)
  1360. {
  1361. bool ret = true;
  1362. try
  1363. {
  1364. //读取数据
  1365. string tempFile = Path.Combine(_rootPath, "DailyOutput.ini");
  1366. IniHelper iniHelper = new IniHelper(tempFile);
  1367. int iValue = 0;
  1368. iniHelper.ReadInteger("TempData", "DailyOutput", out iValue);
  1369. tDailyOutput = iValue;
  1370. iniHelper.ReadInteger("TempData", "Date", out iValue);
  1371. int dateNum = iValue;
  1372. int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
  1373. if (dateNum == nowDateNum)
  1374. {
  1375. //同一天,生产数量+1
  1376. tDailyOutput++;
  1377. }
  1378. else if(dateNum < nowDateNum)
  1379. {
  1380. //昨天数据,为1
  1381. tDailyOutput = 1;
  1382. }
  1383. //重新记录
  1384. iniHelper.WriteInteger("TempData", "DailyOutput", tDailyOutput);
  1385. iniHelper.WriteInteger("TempData", "Date", nowDateNum);
  1386. }
  1387. catch (Exception ex)
  1388. {
  1389. tDailyOutput = 0;
  1390. ret = false;
  1391. string tempFile = Path.Combine(_rootPath, "DailyOutput.ini");
  1392. IniHelper iniHelper = new IniHelper(tempFile);
  1393. int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
  1394. //重新记录
  1395. iniHelper.WriteInteger("TempData", "DailyOutput", tDailyOutput);
  1396. iniHelper.WriteInteger("TempData", "Date", nowDateNum);
  1397. }
  1398. return ret;
  1399. }
  1400. public bool GetDailyOutput(out int tDailyOutput)
  1401. {
  1402. bool ret = true;
  1403. try
  1404. {
  1405. //读取数据
  1406. string tempFile = Path.Combine(_rootPath, "DailyOutput.ini");
  1407. IniHelper iniHelper = new IniHelper(tempFile);
  1408. int iValue = 0;
  1409. iniHelper.ReadInteger("TempData", "DailyOutput", out iValue);
  1410. tDailyOutput = iValue;
  1411. iniHelper.ReadInteger("TempData", "Date", out iValue);
  1412. int dateNum = iValue;
  1413. int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
  1414. if (dateNum == nowDateNum)
  1415. {
  1416. //同一天,生产数量+1
  1417. //tDailyOutput++;
  1418. }
  1419. else if (dateNum < nowDateNum)
  1420. {
  1421. //昨天数据,为1
  1422. tDailyOutput = 0;
  1423. }
  1424. }
  1425. catch (Exception ex)
  1426. {
  1427. tDailyOutput = 0;
  1428. ret = false;
  1429. }
  1430. return ret;
  1431. }
  1432. #endregion
  1433. #region 尺寸检测项
  1434. public List<SizeItemParam> SizeItemParamsList = new List<SizeItemParam>();
  1435. public void ReadSizeDefectItems()
  1436. {
  1437. string str = File.ReadAllText(_sizeItemsPath);
  1438. SizeItemParamsList = JsonConvert.DeserializeObject<List<SizeItemParam>>(str);
  1439. }
  1440. #endregion
  1441. #region 缺陷检测项
  1442. public List<DefectItemParam> DefectItemParamsList = new List<DefectItemParam>();
  1443. public void ReadDefectItems()
  1444. {
  1445. string str = File.ReadAllText(_defectItemsPath);
  1446. DefectItemParamsList = JsonConvert.DeserializeObject<List<DefectItemParam>>(str);
  1447. }
  1448. #endregion
  1449. #region 比对检测项
  1450. public List<DefectItemParam> SizeCompItemParamsList = new List<DefectItemParam>();
  1451. public void ReadSizeCompItems()
  1452. {
  1453. if (File.Exists(_sizeCompItemsPath))
  1454. {
  1455. string str = File.ReadAllText(_sizeCompItemsPath);
  1456. SizeCompItemParamsList = JsonConvert.DeserializeObject<List<DefectItemParam>>(str);
  1457. }
  1458. else
  1459. {
  1460. SizeCompItemParamsList.Add(new DefectItemParam()
  1461. {
  1462. Code = "wtg",
  1463. Name = "未通过",
  1464. Show = 1,
  1465. Type = "0",
  1466. });
  1467. }
  1468. }
  1469. #endregion
  1470. #endregion
  1471. }
  1472. }