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.
 
 
 
 

1666 lines
69 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. /// <summary>
  447. /// 缺陷相机分辨率
  448. /// </summary>
  449. public double DefectCamPixel { get; set; }
  450. /// <summary>
  451. /// 自动计算步进偏移
  452. /// </summary>
  453. public double DefectAutoX { get; set; }
  454. /// <summary>
  455. /// 自动计算步进偏移
  456. /// </summary>
  457. public double DefectAutoY { get; set; }
  458. #endregion
  459. public SysConfigParams()
  460. {
  461. DefectBigImag = new ImageSaveParam("D:\\Image\\缺陷图");
  462. DefectSrcSmallImag = new ImageSaveParam("D:\\Image\\原始小图");
  463. DefectSmallImag = new ImageSaveParam("D:\\Image\\缺陷小图");
  464. DefectRepairImag = new ImageSaveParam("D:\\Image\\修复台复现图片");
  465. SizeBigImag = new ImageSaveParam("D:\\Image\\尺寸图");
  466. SizeNGImag = new ImageSaveParam("D:\\Image\\未通过图片");
  467. SizeRepairImag = new ImageSaveParam("D:\\Image\\打标未通过图片");
  468. OpenMarkErrorStop = true;
  469. OpenBuzzer = true;
  470. OpenDoor = true;
  471. OpenHttpLog = false;
  472. OpenPdtIsHave = true;
  473. OpenDefectSanp = false;
  474. OpenAsideDefect = true;
  475. OpenOredrCheck = false;
  476. OpenOredrCntCheck = false;
  477. OpenShowDB = false;
  478. //LightCfg = new LightParams();
  479. //IOCfg = new IOParams();
  480. IODevName = "PCI-1730,BID#0";
  481. IOCfgPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\IOCard_default.xml"); ;
  482. LightCom = "COM2";
  483. LightComBaud = 9600;
  484. LensMotorCom = "COM1";
  485. LensMotorComBaud = 9600;
  486. TensionCom = "COM3";
  487. TensionComBaud = 2400;
  488. ThicknessIP = "192.168.0.50";
  489. ThicknessPort = 64000;
  490. ThicknessSafeValue = 10;
  491. FrontCamCfgPath = "";
  492. BackCamCfgPath = "C:\\Program Files (x86)\\Common Files\\MVS\\Runtime\\Win64_x64\\MvFGProducerCXP.cti";
  493. MotionCfgPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\Axis_default.cfg"); ;
  494. SaveAllImg = false;
  495. DisableX1 = false;
  496. DisableX2 = false;
  497. DisableY = false;
  498. DisableZ = false;
  499. DisableFrontCam = false;
  500. DisableBackCam = false;
  501. DisableLight = false;
  502. DisableLensMotor = false;
  503. DisableTensor = false;
  504. DisableThickness = false;
  505. ImageProcessPath = "C:\\Users\\user\\AppData\\Local\\Programs\\MVTec\\HALCON-21.05-Progress\\procedures\\general";
  506. ImageProcessDataPath = "C:\\Users\\PC\\AppData\\Local\\Programs\\MVTec\\HALCON-21.05-Progress\\procedures\\User_Data\\HomMat2D1M2CCDpose";
  507. AIModelPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\onnxFiles");
  508. ProductPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles\\Project");
  509. HttpServerIP = "192.168.123.100";
  510. HttpServerPort = 18082;
  511. LogPath = Path.Combine(Directory.GetCurrentDirectory(), "LogFiles");
  512. AutoDeleteLog = false;
  513. AutoDeleteLogData = 0;
  514. ShowResetBtn = true;
  515. ShowBuzz = false;
  516. ShowDoorAlm = false;
  517. ShowDistribution = false;
  518. ShowSizeBtn = false;
  519. ShowDefectBtn = false;
  520. DefectCamViewX = 35.5;
  521. DefectCamViewY = 26.5;
  522. EnableHttp = false;
  523. HttpUrl = "";
  524. HttpTempPath = "";
  525. HttpReturnKey = "";
  526. HttpReturnValue = "";
  527. LensAxisZPos = new LensAxisZ();
  528. //缺陷配置
  529. Defect_CutSize = new Size(390, 350);
  530. Defect_ReSize = new Size(224, 224);
  531. Defect_Thresholds = 0.4f;
  532. EnableLabelPrint = false;
  533. LabelPrinterName = "";
  534. LabelTempPath = "";
  535. LabelData = new Dictionary<string, string>();
  536. EnableExcelPrint = false;
  537. ExcelPrinterName = "";
  538. ExcelTempPath = "";
  539. ExcelData = new Dictionary<string, string>();
  540. OpenCloud = false;
  541. CloudThisName = "Test";
  542. CloudServerIP = "127.0.0.1";
  543. CloudServerPort = 1883;
  544. CloudUser = "";
  545. CloudPassword = "";
  546. OpenPdtServer = false;
  547. PdtServerIP = "127.0.0.1";
  548. PdtServerPort = 10573;
  549. IsPdtServer = true;
  550. Pt_offset = 0;
  551. Line_offset = 0;
  552. X_per = 0.1;
  553. Y_per = 0.1;
  554. LightCH = 2;
  555. LightLut = 255;
  556. CamExposureTime = 8000;
  557. LightChannelCnt = 4;
  558. CustomerName = "";
  559. DefectCamPixel = 0.002515;
  560. }
  561. }
  562. #endregion
  563. #region 尺寸检测参数
  564. public class SizeItemParam
  565. {
  566. /// <summary>
  567. /// 名称
  568. /// </summary>
  569. public string Name { get; set; }
  570. /// <summary>
  571. /// 代码
  572. /// </summary>
  573. public string Code { get; set; }
  574. /// <summary>
  575. /// 测试点数
  576. /// </summary>
  577. public int PointCnt { get; set; }
  578. /// <summary>
  579. /// 处理代码
  580. /// </summary>
  581. public int[] DefectIndex { get; set; }
  582. /// <summary>
  583. /// RGB颜色代码
  584. /// </summary>
  585. public int[] RGBcolor { get; set; }
  586. /// <summary>
  587. /// 显示单位 0:程序默认 1:mm 2:um
  588. /// </summary>
  589. public int mmOrum { get; set; }
  590. /// <summary>
  591. /// 显示小数点后位数 0:默认4位。
  592. /// </summary>
  593. public int dataLen { get; set; }
  594. }
  595. #endregion
  596. #region 缺陷检测参数
  597. public class DefectItemParam
  598. {
  599. /// <summary>
  600. /// 名称
  601. /// </summary>
  602. public string Name { get; set; }
  603. /// <summary>
  604. /// 代码
  605. /// </summary>
  606. public string Code { get; set; }
  607. /// <summary>
  608. /// 序号
  609. /// </summary>
  610. public int Index { get; set; }
  611. /// <summary>
  612. /// 默认分值
  613. /// </summary>
  614. public double Threshold { get; set; }
  615. /// <summary>
  616. /// RGB颜色代码
  617. /// </summary>
  618. public int[] RGBcolor { get; set; }
  619. /// <summary>
  620. /// 对应类型
  621. /// </summary>
  622. public string Type { get; set; }
  623. /// <summary>
  624. /// 尺寸
  625. /// </summary>
  626. public float Size { get; set; }
  627. /// <summary>
  628. /// 最大允许缺陷数量
  629. /// </summary>
  630. public int MaxDefectCount { get; set; }
  631. /// <summary>
  632. /// 显示
  633. /// </summary>
  634. public int Show { get; set; }
  635. }
  636. #endregion
  637. /// <summary>
  638. /// 设备参数
  639. /// </summary>
  640. public class ConfMgr
  641. {
  642. #region 实例化
  643. /// <summary>
  644. /// 实例
  645. /// </summary>
  646. private static ConfMgr _instance;
  647. private static readonly object _lock = new object();
  648. public static ConfMgr Instance
  649. {
  650. get
  651. {
  652. if (_instance == null)
  653. {
  654. lock (_lock)
  655. {
  656. if (_instance == null)
  657. {
  658. _instance = new ConfMgr();
  659. }
  660. }
  661. }
  662. return _instance;
  663. }
  664. }
  665. #endregion
  666. #region 私有字段
  667. private readonly string _rootPath;
  668. private readonly string _configFile;
  669. private readonly string _projectDir;
  670. private readonly string _pointsPath;
  671. private readonly string _markPicPath;
  672. private readonly string _sizeItemsPath;
  673. private readonly string _defectItemsPath;
  674. private readonly string _sizeCompItemsPath;
  675. #endregion
  676. private ConfMgr()
  677. {
  678. _rootPath = Path.Combine(Directory.GetCurrentDirectory(), "ConfigFiles");
  679. _configFile = Path.Combine(_rootPath, "SysParamsConfig.ini");
  680. _devConfigPath = Path.Combine(_rootPath, "DevParamsConfig.ini");
  681. _projectDir = Path.Combine(_rootPath, "Project");
  682. _pointsPath = Path.Combine(_rootPath, "PointsConfig.ini");
  683. _markPicPath = Path.Combine(_rootPath, "MarkPic");
  684. _specificationPath = Path.Combine(_rootPath, "版博士软件操作说明.docx");
  685. _sizeItemsPath = Path.Combine(_rootPath, "尺寸测试项.json");
  686. _defectItemsPath = Path.Combine(_rootPath, "缺陷测试项.json");
  687. _sizeCompItemsPath = Path.Combine(_rootPath, "比对测试项.json");
  688. DBConStr = "server = localhost; Database = ProductionDB; Uid = root; Pwd = " + ConteolUserDB.GetSqlDBCode() + "; AllowLoadLocalInfile = true;";
  689. }
  690. #region 公开字段
  691. //DB
  692. //有些服务器防火墙有问题需要加上 min pool size=1 避免认为是恶意请求
  693. //如果用到bulkCopy需要加: AllowLoadLocalInfile=true
  694. //public static string dbMysqlCon = "server=localhost;Database=ProductionDB;Uid=root;Pwd=123456;";
  695. public string DBConStr = "server=localhost;Database=ProductionDB;Uid=root;Pwd=123456; AllowLoadLocalInfile=true";
  696. /// <summary>
  697. /// 系统配置参数
  698. /// </summary>
  699. public SysConfigParams SysConfigParams { get; set; }
  700. private string _devConfigPath;
  701. /// <summary>
  702. /// 获取驱动配制文件路径
  703. /// </summary>
  704. public string DevConfigPath { get { return _devConfigPath; } }
  705. //public string ProjectDir { get { return _projectDir; } }
  706. public string ProjectDir { get { return SysConfigParams.ProductPath; } }
  707. public string MarkPicPath { get { return _markPicPath; } }
  708. /// <summary>
  709. /// 说明书路径
  710. /// </summary>
  711. public string SpecificationPath { get { return _specificationPath; } }
  712. private string _specificationPath;
  713. /// <summary>
  714. /// 上料位X1
  715. /// </summary>
  716. public double LoadPoint_X1 { get; set; }
  717. /// <summary>
  718. /// 上料位X2
  719. /// </summary>
  720. public double LoadPoint_X2 { get; set; }
  721. /// <summary>
  722. /// 上料位Y
  723. /// </summary>
  724. public double LoadPoint_Y { get; set; }
  725. /// <summary>
  726. /// 上料位Z
  727. /// </summary>
  728. public double LoadPoint_Z { get; set; }
  729. /// <summary>
  730. /// 测厚气缸到位等待时间
  731. /// </summary>
  732. public int HeightDoWait { get; set; }
  733. /// <summary>
  734. /// 加紧气缸到位等待时间
  735. /// </summary>
  736. public int ProductDoWait { get; set; }
  737. #endregion
  738. #region 公开文件操作
  739. #region 点位配置
  740. public void WritePointsAndTime(double x1, double x2, double y, double z, int ht, int pt)
  741. {
  742. //XmlHelper.Serialize<SysConfParams>(_configFile, sysConfParams);
  743. IniHelper iniHelper = new IniHelper(_pointsPath);
  744. iniHelper.WriteDouble("LoadPoint", "X1", x1);
  745. iniHelper.WriteDouble("LoadPoint", "X2", x2);
  746. iniHelper.WriteDouble("LoadPoint", "Y", y);
  747. iniHelper.WriteDouble("LoadPoint", "Z", z);
  748. iniHelper.WriteInteger("WaitTime", "HeightDoWait", ht);
  749. iniHelper.WriteInteger("WaitTime", "ProductDoWait", pt);
  750. LoadPoint_X1 = x1;
  751. LoadPoint_X2 = x2;
  752. LoadPoint_Y = y;
  753. LoadPoint_Z = z;
  754. HeightDoWait = ht;
  755. ProductDoWait = pt;
  756. }
  757. public void ReadPointsAndTime()
  758. {
  759. IniHelper iniHelper = new IniHelper(_pointsPath);
  760. double dValue = 0;
  761. int iValue = 0;
  762. iniHelper.ReadDouble("LoadPoint", "X1", out dValue);
  763. LoadPoint_X1 = dValue;
  764. iniHelper.ReadDouble("LoadPoint", "X2", out dValue);
  765. LoadPoint_X2 = dValue;
  766. iniHelper.ReadDouble("LoadPoint", "Y", out dValue);
  767. LoadPoint_Y = dValue;
  768. iniHelper.ReadDouble("LoadPoint", "Z", out dValue);
  769. LoadPoint_Z = dValue;
  770. iniHelper.ReadInteger("WaitTime", "HeightDoWait", out iValue);
  771. HeightDoWait = iValue;
  772. iniHelper.ReadInteger("WaitTime", "ProductDoWait", out iValue);
  773. ProductDoWait = iValue;
  774. }
  775. #endregion
  776. #region 系统配置参数
  777. /// <summary>
  778. /// 写入ini
  779. /// </summary>
  780. /// <param name="SocketParams"></param>
  781. public void WriteSysConfParams(SysConfigParams SysParams)
  782. {
  783. //XmlHelper.Serialize<SysConfParams>(_configFile, sysConfParams);
  784. IniHelper iniHelper = new IniHelper(_configFile);
  785. iniHelper.WriteString("DefectSrcSmallImag", "Defect_SrcSmall_SavePath", SysParams.Defect_SrcSmall_SavePath);
  786. iniHelper.WriteDouble("DefectSrcSmallImag", "Defect_SrcSmall_Thres", SysParams.Defect_SrcSmall_Thres);
  787. iniHelper.WriteBool("SaveAllImg", "SaveAllImg", SysParams.SaveAllImg);
  788. iniHelper.WriteString("DefectBigImag", "SavePath", SysParams.DefectBigImag.SavePath);
  789. iniHelper.WriteBool("DefectBigImag", "AutoSave", SysParams.DefectBigImag.AutoSave);
  790. iniHelper.WriteBool("DefectBigImag", "AutoDelete", SysParams.DefectBigImag.AutoDelete);
  791. iniHelper.WriteDouble("DefectBigImag", "AutoDeleteDays", SysParams.DefectBigImag.AutoDeleteDays);
  792. iniHelper.WriteString("DefectSrcSmallImag", "SavePath", SysParams.DefectSrcSmallImag.SavePath);
  793. iniHelper.WriteBool("DefectSrcSmallImag", "AutoSave", SysParams.DefectSrcSmallImag.AutoSave);
  794. iniHelper.WriteBool("DefectSrcSmallImag", "AutoDelete", SysParams.DefectSrcSmallImag.AutoDelete);
  795. iniHelper.WriteDouble("DefectSrcSmallImag", "AutoDeleteDays", SysParams.DefectSrcSmallImag.AutoDeleteDays);
  796. iniHelper.WriteString("DefectSmallImag", "SavePath", SysParams.DefectSmallImag.SavePath);
  797. iniHelper.WriteBool("DefectSmallImag", "AutoSave", SysParams.DefectSmallImag.AutoSave);
  798. iniHelper.WriteBool("DefectSmallImag", "AutoDelete", SysParams.DefectSmallImag.AutoDelete);
  799. iniHelper.WriteDouble("DefectSmallImag", "AutoDeleteDays", SysParams.DefectSmallImag.AutoDeleteDays);
  800. iniHelper.WriteString("DefectRepairImag", "SavePath", SysParams.DefectRepairImag.SavePath);
  801. iniHelper.WriteBool("DefectRepairImag", "AutoSave", SysParams.DefectRepairImag.AutoSave);
  802. iniHelper.WriteBool("DefectRepairImag", "AutoDelete", SysParams.DefectRepairImag.AutoDelete);
  803. iniHelper.WriteDouble("DefectRepairImag", "AutoDeleteDays", SysParams.DefectRepairImag.AutoDeleteDays);
  804. iniHelper.WriteString("SizeBigImag", "SavePath", SysParams.SizeBigImag.SavePath);
  805. iniHelper.WriteBool("SizeBigImag", "AutoSave", SysParams.SizeBigImag.AutoSave);
  806. iniHelper.WriteBool("SizeBigImag", "AutoDelete", SysParams.SizeBigImag.AutoDelete);
  807. iniHelper.WriteDouble("SizeBigImag", "AutoDeleteDays", SysParams.SizeBigImag.AutoDeleteDays);
  808. iniHelper.WriteString("SizeNGImag", "SavePath", SysParams.SizeNGImag.SavePath);
  809. iniHelper.WriteBool("SizeNGImag", "AutoSave", SysParams.SizeNGImag.AutoSave);
  810. iniHelper.WriteBool("SizeNGImag", "AutoDelete", SysParams.SizeNGImag.AutoDelete);
  811. iniHelper.WriteDouble("SizeNGImag", "AutoDeleteDays", SysParams.SizeNGImag.AutoDeleteDays);
  812. iniHelper.WriteString("SizeRepairImag", "SavePath", SysParams.SizeRepairImag.SavePath);
  813. iniHelper.WriteBool("SizeRepairImag", "AutoSave", SysParams.SizeRepairImag.AutoSave);
  814. iniHelper.WriteBool("SizeRepairImag", "AutoDelete", SysParams.SizeRepairImag.AutoDelete);
  815. iniHelper.WriteDouble("SizeRepairImag", "AutoDeleteDays", SysParams.SizeRepairImag.AutoDeleteDays);
  816. iniHelper.WriteString("Log", "SavePath", SysParams.LogPath);
  817. iniHelper.WriteBool("Log", "AutoDelete", SysParams.AutoDeleteLog);
  818. iniHelper.WriteDouble("Log", "AutoDeleteDays", SysParams.AutoDeleteLogData);
  819. iniHelper.WriteBool("SysFunction", "OpenMarkErrorStop", SysParams.OpenMarkErrorStop);
  820. iniHelper.WriteBool("SysFunction", "OpenBuzzer", SysParams.OpenBuzzer);
  821. iniHelper.WriteBool("SysFunction", "OpenDoor", SysParams.OpenDoor);
  822. iniHelper.WriteBool("SysFunction", "OpenHttpLog", SysParams.OpenHttpLog);
  823. iniHelper.WriteBool("SysFunction", "OpenAutoGoHome", SysParams.OpenAutoGoHome);
  824. iniHelper.WriteBool("SysFunction", "OpenFlawDistribution", SysParams.OpenFlawDistribution);
  825. iniHelper.WriteBool("SysFunction", "OpenAxisXCalibration", SysParams.OpenAxisXCalibration);
  826. iniHelper.WriteBool("SysFunction", "OpenPdtIsHave", SysParams.OpenPdtIsHave);
  827. iniHelper.WriteBool("SysFunction", "OpenDefectSanp", SysParams.OpenDefectSanp);
  828. iniHelper.WriteBool("SysFunction", "OpenAsideDefect", SysParams.OpenAsideDefect);
  829. iniHelper.WriteBool("SysFunction", "OpenOredrCheck", SysParams.OpenOredrCheck);
  830. iniHelper.WriteBool("SysFunction", "OpenOredrCntCheck", SysParams.OpenOredrCntCheck);
  831. iniHelper.WriteBool("SysFunction", "OpenShowDB", SysParams.OpenShowDB);
  832. iniHelper.WriteBool("SysFunction", "OpenColorB", SysParams.OpenColorB);
  833. iniHelper.WriteBool("SysFunction", "OpenRemoveDuplicates", SysParams.OpenRemoveDuplicates);
  834. iniHelper.WriteString("Dev", "LightCom", SysParams.LightCom);
  835. iniHelper.WriteInteger("Dev", "LightComBaud", SysParams.LightComBaud);
  836. iniHelper.WriteString("Dev", "TensionCom", SysParams.TensionCom);
  837. iniHelper.WriteInteger("Dev", "TensionComBaud", SysParams.TensionComBaud);
  838. iniHelper.WriteDouble("Dev", "Tension_Offset", SysParams.Tension_Offset);
  839. iniHelper.WriteString("Dev", "LensMotorCom", SysParams.LensMotorCom);
  840. iniHelper.WriteInteger("Dev", "LensMotorComBaud", SysParams.LensMotorComBaud);
  841. iniHelper.WriteString("Dev", "ThicknessIP", SysParams.ThicknessIP);
  842. iniHelper.WriteInteger("Dev", "ThicknessPort", SysParams.ThicknessPort);
  843. iniHelper.WriteDouble("Dev", "ThicknessSafeValue", SysParams.ThicknessSafeValue);
  844. iniHelper.WriteDouble("Dev", "Thickness_Offset", SysParams.Thickness_Offset);
  845. iniHelper.WriteString("Dev", "IODevName", SysParams.IODevName);
  846. iniHelper.WriteString("Dev", "IOCfgPath", SysParams.IOCfgPath);
  847. iniHelper.WriteString("Dev", "MotionCfgPath", SysParams.MotionCfgPath);
  848. iniHelper.WriteString("Dev", "FrontCamName", SysParams.FrontCamName);
  849. iniHelper.WriteString("Dev", "FrontCamCfgPath", SysParams.FrontCamCfgPath);
  850. iniHelper.WriteString("Dev", "BackCamName", SysParams.BackCamName);
  851. iniHelper.WriteString("Dev", "BackCamCfgPath", SysParams.BackCamCfgPath);
  852. iniHelper.WriteBool("Disable", "DisableX1", SysParams.DisableX1);
  853. iniHelper.WriteBool("Disable", "DisableX2", SysParams.DisableX2);
  854. iniHelper.WriteBool("Disable", "DisableY", SysParams.DisableY);
  855. iniHelper.WriteBool("Disable", "DisableZ", SysParams.DisableZ);
  856. iniHelper.WriteBool("Disable", "DisableFrontCam", SysParams.DisableFrontCam);
  857. iniHelper.WriteBool("Disable", "DisableBackCam", SysParams.DisableBackCam);
  858. iniHelper.WriteBool("Disable", "DisableLight", SysParams.DisableLight);
  859. iniHelper.WriteBool("Disable", "DisableThickness", SysParams.DisableThickness);
  860. iniHelper.WriteBool("Disable", "DisableTensor", SysParams.DisableTensor);
  861. iniHelper.WriteBool("Disable", "DisableLensMotor", SysParams.DisableLensMotor);
  862. iniHelper.WriteString("Sys", "ImageProcessPath", SysParams.ImageProcessPath);
  863. iniHelper.WriteString("Sys", "ImageProcessDataPath", SysParams.ImageProcessDataPath);
  864. iniHelper.WriteString("Sys", "AIModelPath", SysParams.AIModelPath);
  865. iniHelper.WriteString("Sys", "ProductPath", SysParams.ProductPath);
  866. iniHelper.WriteString("Sys", "HttpServerIP", SysParams.HttpServerIP);
  867. iniHelper.WriteInteger("Sys", "HttpServerPort", SysParams.HttpServerPort);
  868. iniHelper.WriteBool("ShowMainWin", "ShowResetBtn", SysParams.ShowResetBtn);
  869. iniHelper.WriteBool("ShowMainWin", "ShowBuzz", SysParams.ShowBuzz);
  870. iniHelper.WriteBool("ShowMainWin", "ShowDoorAlm", SysParams.ShowDoorAlm);
  871. iniHelper.WriteBool("ShowMainWin", "ShowDistribution", SysParams.ShowDistribution);
  872. iniHelper.WriteBool("ShowMainWin", "ShowSizeBtn", SysParams.ShowSizeBtn);
  873. iniHelper.WriteBool("ShowMainWin", "ShowDefectBtn", SysParams.ShowDefectBtn);
  874. iniHelper.WriteDouble("CamView", "DefectCamViewX", SysParams.DefectCamViewX);
  875. iniHelper.WriteDouble("CamView", "DefectCamViewY", SysParams.DefectCamViewY);
  876. iniHelper.WriteBool("CloudAndMES", "EnableHttp", SysParams.EnableHttp);
  877. iniHelper.WriteString("CloudAndMES", "HttpUrl", SysParams.HttpUrl);
  878. iniHelper.WriteString("CloudAndMES", "HttpTempPath", SysParams.HttpTempPath);
  879. iniHelper.WriteString("CloudAndMES", "HttpReturnKey", SysParams.HttpReturnKey);
  880. iniHelper.WriteString("CloudAndMES", "HttpReturnValue", SysParams.HttpReturnValue);
  881. iniHelper.WriteBool("CloudAndMES", "OpenCloud", SysParams.OpenCloud);
  882. iniHelper.WriteString("CloudAndMES", "CloudThisName", SysParams.CloudThisName);
  883. iniHelper.WriteString("CloudAndMES", "CloudServerIP", SysParams.CloudServerIP);
  884. iniHelper.WriteInteger("CloudAndMES", "CloudServerPort", SysParams.CloudServerPort);
  885. iniHelper.WriteString("CloudAndMES", "CloudUser", SysParams.CloudUser);
  886. iniHelper.WriteString("CloudAndMES", "CloudPassword", SysParams.CloudPassword);
  887. iniHelper.WriteBool("CloudAndMES", "OpenPdtServer", SysParams.OpenPdtServer);
  888. iniHelper.WriteString("CloudAndMES", "PdtServerIP", SysParams.PdtServerIP);
  889. iniHelper.WriteInteger("CloudAndMES", "PdtServerPort", SysParams.PdtServerPort);
  890. iniHelper.WriteBool("CloudAndMES", "IsPdtServer", SysParams.IsPdtServer);
  891. iniHelper.WriteDouble("LensZ", "Z_0_58X", SysParams.LensAxisZPos.Z_0_58X);
  892. //iniHelper.WriteDouble("LensZ", "Z_0_6X", SysParams.LensAxisZPos.Z_0_6X);
  893. iniHelper.WriteDouble("LensZ", "Z_1_0X", SysParams.LensAxisZPos.Z_1_0X);
  894. iniHelper.WriteDouble("LensZ", "Z_1_5X", SysParams.LensAxisZPos.Z_1_5X);
  895. iniHelper.WriteDouble("LensZ", "Z_2_0X", SysParams.LensAxisZPos.Z_2_0X);
  896. iniHelper.WriteDouble("LensZ", "Z_2_5X", SysParams.LensAxisZPos.Z_2_5X);
  897. iniHelper.WriteDouble("LensZ", "Z_3_0X", SysParams.LensAxisZPos.Z_3_0X);
  898. iniHelper.WriteDouble("LensZ", "Z_3_5X", SysParams.LensAxisZPos.Z_3_5X);
  899. iniHelper.WriteDouble("LensZ", "Z_4_0X", SysParams.LensAxisZPos.Z_4_0X);
  900. iniHelper.WriteDouble("LensZ", "Z_4_5X", SysParams.LensAxisZPos.Z_4_5X);
  901. iniHelper.WriteDouble("LensZ", "Z_5_0X", SysParams.LensAxisZPos.Z_5_0X);
  902. iniHelper.WriteDouble("LensZ", "Z_5_5X", SysParams.LensAxisZPos.Z_5_5X);
  903. iniHelper.WriteDouble("LensZ", "Z_6_0X", SysParams.LensAxisZPos.Z_6_0X);
  904. iniHelper.WriteDouble("LensZ", "Z_6_5X", SysParams.LensAxisZPos.Z_6_5X);
  905. iniHelper.WriteDouble("LensZ", "Z_7_0X", SysParams.LensAxisZPos.Z_7_0X);
  906. iniHelper.WriteDouble("LensZ", "Z_7_5X", SysParams.LensAxisZPos.Z_7_5X);
  907. iniHelper.WriteBool("LabelPrint", "EnableLabelPrint", SysParams.EnableLabelPrint);
  908. iniHelper.WriteString("LabelPrint", "LabelPrinterName", SysParams.LabelPrinterName);
  909. iniHelper.WriteString("LabelPrint", "LabelTempPath", SysParams.LabelTempPath);
  910. iniHelper.WriteString("LabelPrint", "LabelData", JsonConvert.SerializeObject(SysParams.LabelData));
  911. iniHelper.WriteBool("ExcelPrint", "EnableExcelPrint", SysParams.EnableExcelPrint);
  912. iniHelper.WriteString("ExcelPrint", "ExcelPrinterName", SysParams.ExcelPrinterName);
  913. iniHelper.WriteString("ExcelPrint", "ExcelTempPath", SysParams.ExcelTempPath);
  914. iniHelper.WriteString("ExcelPrint", "ExcelData", JsonConvert.SerializeObject(SysParams.ExcelData));
  915. iniHelper.WriteDouble("Offset", "Pt_offset", SysParams.Pt_offset);
  916. iniHelper.WriteDouble("Offset", "Line_offset", SysParams.Line_offset);
  917. iniHelper.WriteDouble("Offset", "X_per", SysParams.X_per);
  918. iniHelper.WriteDouble("Offset", "Y_per", SysParams.Y_per);
  919. iniHelper.WriteInteger("DefectSnap", "LightCH", SysParams.LightCH);
  920. iniHelper.WriteInteger("DefectSnap", "LightLut", SysParams.LightLut);
  921. iniHelper.WriteInteger("DefectSnap", "CamExposureTime", SysParams.CamExposureTime);
  922. iniHelper.WriteInteger("SysOther", "LightChannelCnt", SysParams.LightChannelCnt);
  923. iniHelper.WriteString("SysOther", "CustomerName", SysParams.CustomerName);
  924. SysConfigParams = SysParams;
  925. }
  926. /// <summary>
  927. /// 读取ini
  928. /// </summary>
  929. /// <returns></returns>
  930. public SysConfigParams ReadSysConfParams()
  931. {
  932. //return XmlHelper.Deserialize<SysConfParams>(_configFile);
  933. SysConfigParams sysParams = new SysConfigParams();
  934. IniHelper iniHelper = new IniHelper(_configFile);
  935. string sValue = "";
  936. int iValue = 0;
  937. double dValue = 0;
  938. bool bValue = false;
  939. iniHelper.ReadString("DefectSrcSmallImag", "Defect_SrcSmall_SavePath", out sValue);
  940. sysParams.Defect_SrcSmall_SavePath = sValue;
  941. iniHelper.ReadDouble("DefectSrcSmallImag", "Defect_SrcSmall_Thres", out dValue);
  942. sysParams.Defect_SrcSmall_Thres = dValue;
  943. iniHelper.ReadBool("SaveAllImg", "SaveAllImg", out bValue);
  944. sysParams.SaveAllImg = bValue;
  945. iniHelper.ReadString("DefectBigImag", "SavePath", out sValue);
  946. sysParams.DefectBigImag.SavePath = sValue.Replace("\0", "");
  947. iniHelper.ReadBool("DefectBigImag", "AutoSave", out bValue);
  948. sysParams.DefectBigImag.AutoSave = bValue;
  949. iniHelper.ReadBool("DefectBigImag", "AutoDelete", out bValue);
  950. sysParams.DefectBigImag.AutoDelete = bValue;
  951. iniHelper.ReadDouble("DefectBigImag", "AutoDeleteDays", out dValue);
  952. sysParams.DefectBigImag.AutoDeleteDays = dValue;
  953. iniHelper.ReadString("DefectSrcSmallImag", "SavePath", out sValue);
  954. sysParams.DefectSrcSmallImag.SavePath = sValue.Replace("\0", "");
  955. iniHelper.ReadBool("DefectSrcSmallImag", "AutoSave", out bValue);
  956. sysParams.DefectSrcSmallImag.AutoSave = bValue;
  957. iniHelper.ReadBool("DefectSrcSmallImag", "AutoDelete", out bValue);
  958. sysParams.DefectSrcSmallImag.AutoDelete = bValue;
  959. iniHelper.ReadDouble("DefectSrcSmallImag", "AutoDeleteDays", out dValue);
  960. sysParams.DefectSrcSmallImag.AutoDeleteDays = dValue;
  961. iniHelper.ReadString("DefectSmallImag", "SavePath", out sValue);
  962. sysParams.DefectSmallImag.SavePath = sValue.Replace("\0", "");
  963. iniHelper.ReadBool("DefectSmallImag", "AutoSave", out bValue);
  964. sysParams.DefectSmallImag.AutoSave = bValue;
  965. iniHelper.ReadBool("DefectSmallImag", "AutoDelete", out bValue);
  966. sysParams.DefectSmallImag.AutoDelete = bValue;
  967. iniHelper.ReadDouble("DefectSmallImag", "AutoDeleteDays", out dValue);
  968. sysParams.DefectSmallImag.AutoDeleteDays = dValue;
  969. iniHelper.ReadString("DefectRepairImag", "SavePath", out sValue);
  970. sysParams.DefectRepairImag.SavePath = sValue.Replace("\0", "");
  971. iniHelper.ReadBool("DefectRepairImag", "AutoSave", out bValue);
  972. sysParams.DefectRepairImag.AutoSave = bValue;
  973. iniHelper.ReadBool("DefectRepairImag", "AutoDelete", out bValue);
  974. sysParams.DefectRepairImag.AutoDelete = bValue;
  975. iniHelper.ReadDouble("DefectRepairImag", "AutoDeleteDays", out dValue);
  976. sysParams.DefectRepairImag.AutoDeleteDays = dValue;
  977. iniHelper.ReadString("SizeBigImag", "SavePath", out sValue);
  978. sysParams.SizeBigImag.SavePath = sValue.Replace("\0", "");
  979. iniHelper.ReadBool("SizeBigImag", "AutoSave", out bValue);
  980. sysParams.SizeBigImag.AutoSave = bValue;
  981. iniHelper.ReadBool("SizeBigImag", "AutoDelete", out bValue);
  982. sysParams.SizeBigImag.AutoDelete = bValue;
  983. iniHelper.ReadDouble("SizeBigImag", "AutoDeleteDays", out dValue);
  984. sysParams.SizeBigImag.AutoDeleteDays = dValue;
  985. iniHelper.ReadString("SizeNGImag", "SavePath", out sValue);
  986. sysParams.SizeNGImag.SavePath = sValue.Replace("\0", "");
  987. iniHelper.ReadBool("SizeNGImag", "AutoSave", out bValue);
  988. sysParams.SizeNGImag.AutoSave = bValue;
  989. iniHelper.ReadBool("SizeNGImag", "AutoDelete", out bValue);
  990. sysParams.SizeNGImag.AutoDelete = bValue;
  991. iniHelper.ReadDouble("SizeNGImag", "AutoDeleteDays", out dValue);
  992. sysParams.SizeNGImag.AutoDeleteDays = dValue;
  993. iniHelper.ReadString("SizeRepairImag", "SavePath", out sValue);
  994. sysParams.SizeRepairImag.SavePath = sValue.Replace("\0", "");
  995. iniHelper.ReadBool("SizeRepairImag", "AutoSave", out bValue);
  996. sysParams.SizeRepairImag.AutoSave = bValue;
  997. iniHelper.ReadBool("SizeRepairImag", "AutoDelete", out bValue);
  998. sysParams.SizeRepairImag.AutoDelete = bValue;
  999. iniHelper.ReadDouble("SizeRepairImag", "AutoDeleteDays", out dValue);
  1000. sysParams.SizeRepairImag.AutoDeleteDays = dValue;
  1001. iniHelper.ReadString("Log", "SavePath", out sValue);
  1002. sysParams.LogPath = sValue.Replace("\0", "");
  1003. iniHelper.ReadBool("Log", "AutoDelete", out bValue);
  1004. sysParams.AutoDeleteLog = bValue;
  1005. iniHelper.ReadDouble("Log", "AutoDeleteDays", out dValue);
  1006. sysParams.AutoDeleteLogData = dValue;
  1007. iniHelper.ReadBool("SysFunction", "OpenMarkErrorStop", out bValue);
  1008. sysParams.OpenMarkErrorStop = bValue;
  1009. iniHelper.ReadBool("SysFunction", "OpenBuzzer", out bValue);
  1010. sysParams.OpenBuzzer = bValue;
  1011. iniHelper.ReadBool("SysFunction", "OpenDoor", out bValue);
  1012. sysParams.OpenDoor = bValue;
  1013. iniHelper.ReadBool("SysFunction", "OpenHttpLog", out bValue);
  1014. sysParams.OpenHttpLog = bValue;
  1015. iniHelper.ReadBool("SysFunction", "OpenAutoGoHome", out bValue);
  1016. sysParams.OpenAutoGoHome = bValue;
  1017. iniHelper.ReadBool("SysFunction", "OpenFlawDistribution", out bValue);
  1018. sysParams.OpenFlawDistribution = bValue;
  1019. iniHelper.ReadBool("SysFunction", "OpenAxisXCalibration", out bValue);
  1020. sysParams.OpenAxisXCalibration = bValue;
  1021. iniHelper.ReadBool("SysFunction", "OpenPdtIsHave", out bValue);
  1022. sysParams.OpenPdtIsHave = bValue;
  1023. iniHelper.ReadBool("SysFunction", "OpenDefectSanp", out bValue);
  1024. sysParams.OpenDefectSanp = bValue;
  1025. iniHelper.ReadBool("SysFunction", "OpenAsideDefect", out bValue);
  1026. sysParams.OpenAsideDefect = bValue;
  1027. iniHelper.ReadBool("SysFunction", "OpenOredrCheck", out bValue);
  1028. sysParams.OpenOredrCheck = bValue;
  1029. iniHelper.ReadBool("SysFunction", "OpenOredrCntCheck", out bValue);
  1030. sysParams.OpenOredrCntCheck = bValue;
  1031. iniHelper.ReadBool("SysFunction", "OpenShowDB", out bValue);
  1032. sysParams.OpenShowDB = bValue;
  1033. iniHelper.ReadBool("SysFunction", "OpenColorB", out bValue);
  1034. sysParams.OpenColorB = bValue;
  1035. iniHelper.ReadBool("SysFunction", "OpenRemoveDuplicates", out bValue);
  1036. sysParams.OpenRemoveDuplicates = bValue;
  1037. iniHelper.ReadString("Dev", "LightCom", out sValue);
  1038. sysParams.LightCom = sValue.Replace("\0", "");
  1039. iniHelper.ReadInteger("Dev", "LightComBaud", out iValue);
  1040. sysParams.LightComBaud = iValue;
  1041. iniHelper.ReadString("Dev", "TensionCom", out sValue);
  1042. sysParams.TensionCom = sValue.Replace("\0", "");
  1043. iniHelper.ReadInteger("Dev", "TensionComBaud", out iValue);
  1044. sysParams.TensionComBaud = iValue;
  1045. iniHelper.ReadDouble("Dev", "Tension_Offset", out dValue);
  1046. sysParams.Tension_Offset = dValue;
  1047. iniHelper.ReadString("Dev", "LensMotorCom", out sValue);
  1048. sysParams.LensMotorCom = sValue.Replace("\0", "");
  1049. iniHelper.ReadInteger("Dev", "LensMotorComBaud", out iValue);
  1050. sysParams.LensMotorComBaud = iValue;
  1051. iniHelper.ReadString("Dev", "ThicknessIP", out sValue);
  1052. sysParams.ThicknessIP = sValue.Replace("\0", "");
  1053. iniHelper.ReadInteger("Dev", "ThicknessPort", out iValue);
  1054. sysParams.ThicknessPort = iValue;
  1055. iniHelper.ReadDouble("Dev", "ThicknessSafeValue", out dValue);
  1056. sysParams.ThicknessSafeValue = dValue;
  1057. iniHelper.ReadDouble("Dev", "Thickness_Offset", out dValue);
  1058. sysParams.Thickness_Offset = dValue;
  1059. iniHelper.ReadString("Dev", "IODevName", out sValue);
  1060. sysParams.IODevName = sValue.Replace("\0", "");
  1061. iniHelper.ReadString("Dev", "IOCfgPath", out sValue);
  1062. sysParams.IOCfgPath = sValue.Replace("\0", "");
  1063. iniHelper.ReadString("Dev", "FrontCamName", out sValue);
  1064. sysParams.FrontCamName = sValue.Replace("\0", "");
  1065. iniHelper.ReadString("Dev", "FrontCamCfgPath", out sValue);
  1066. sysParams.FrontCamCfgPath = sValue.Replace("\0", "");
  1067. iniHelper.ReadString("Dev", "BackCamName", out sValue);
  1068. sysParams.BackCamName = sValue.Replace("\0", "");
  1069. iniHelper.ReadString("Dev", "BackCamCfgPath", out sValue);
  1070. sysParams.BackCamCfgPath = sValue.Replace("\0", "");
  1071. iniHelper.ReadString("Dev", "MotionCfgPath", out sValue);
  1072. sysParams.MotionCfgPath = sValue.Replace("\0", "");
  1073. iniHelper.ReadBool("Disable", "DisableX1", out bValue);
  1074. sysParams.DisableX1 = bValue;
  1075. iniHelper.ReadBool("Disable", "DisableX2", out bValue);
  1076. sysParams.DisableX2 = bValue;
  1077. iniHelper.ReadBool("Disable", "DisableY", out bValue);
  1078. sysParams.DisableY = bValue;
  1079. iniHelper.ReadBool("Disable", "DisableZ", out bValue);
  1080. sysParams.DisableZ = bValue;
  1081. iniHelper.ReadBool("Disable", "DisableFrontCam", out bValue);
  1082. sysParams.DisableFrontCam = bValue;
  1083. iniHelper.ReadBool("Disable", "DisableBackCam", out bValue);
  1084. sysParams.DisableBackCam = bValue;
  1085. iniHelper.ReadBool("Disable", "DisableLight", out bValue);
  1086. sysParams.DisableLight = bValue;
  1087. iniHelper.ReadBool("Disable", "DisableTensor", out bValue);
  1088. sysParams.DisableTensor = bValue;
  1089. iniHelper.ReadBool("Disable", "DisableThickness", out bValue);
  1090. sysParams.DisableThickness = bValue;
  1091. iniHelper.ReadBool("Disable", "DisableLensMotor", out bValue);
  1092. sysParams.DisableLensMotor = bValue;
  1093. iniHelper.ReadString("Sys", "ImageProcessPath", out sValue);
  1094. sysParams.ImageProcessPath = sValue.Replace("\0", "");
  1095. iniHelper.ReadString("Sys", "ImageProcessDataPath", out sValue);
  1096. sysParams.ImageProcessDataPath = sValue.Replace("\0", "");
  1097. iniHelper.ReadString("Sys", "AIModelPath", out sValue);
  1098. sysParams.AIModelPath = sValue.Replace("\0", "");
  1099. iniHelper.ReadString("Sys", "ProductPath", out sValue);
  1100. sysParams.ProductPath = sValue.Replace("\0", "");
  1101. iniHelper.ReadString("Sys", "HttpServerIP", out sValue);
  1102. sysParams.HttpServerIP = sValue.Replace("\0", "");
  1103. iniHelper.ReadInteger("Sys", "HttpServerPort", out iValue);
  1104. sysParams.HttpServerPort = iValue;
  1105. iniHelper.ReadBool("ShowMainWin", "ShowResetBtn", out bValue);
  1106. sysParams.ShowResetBtn = bValue;
  1107. iniHelper.ReadBool("ShowMainWin", "ShowBuzz", out bValue);
  1108. sysParams.ShowBuzz = bValue;
  1109. iniHelper.ReadBool("ShowMainWin", "ShowDoorAlm", out bValue);
  1110. sysParams.ShowDoorAlm = bValue;
  1111. iniHelper.ReadBool("ShowMainWin", "ShowDistribution", out bValue);
  1112. sysParams.ShowDistribution = bValue;
  1113. iniHelper.ReadBool("ShowMainWin", "ShowSizeBtn", out bValue);
  1114. sysParams.ShowSizeBtn = bValue;
  1115. iniHelper.ReadBool("ShowMainWin", "ShowDefectBtn", out bValue);
  1116. sysParams.ShowDefectBtn = bValue;
  1117. iniHelper.ReadDouble("CamView", "DefectCamViewX", out dValue);
  1118. sysParams.DefectCamViewX = dValue;
  1119. iniHelper.ReadDouble("CamView", "DefectCamViewY", out dValue);
  1120. sysParams.DefectCamViewY = dValue;
  1121. iniHelper.ReadBool("CloudAndMES", "EnableHttp", out bValue);
  1122. sysParams.EnableHttp = bValue;
  1123. iniHelper.ReadString("CloudAndMES", "HttpUrl", out sValue);
  1124. sysParams.HttpUrl = sValue;
  1125. iniHelper.ReadString("CloudAndMES", "HttpTempPath", out sValue);
  1126. sysParams.HttpTempPath = sValue;
  1127. iniHelper.ReadString("CloudAndMES", "HttpReturnKey", out sValue);
  1128. sysParams.HttpReturnKey = sValue;
  1129. iniHelper.ReadString("CloudAndMES", "HttpReturnValue", out sValue);
  1130. sysParams.HttpReturnValue = sValue;
  1131. iniHelper.ReadBool("CloudAndMES", "OpenCloud", out bValue);
  1132. sysParams.OpenCloud = bValue;
  1133. iniHelper.ReadString("CloudAndMES", "CloudThisName", out sValue);
  1134. sysParams.CloudThisName = sValue.Replace("\0", string.Empty);
  1135. iniHelper.ReadString("CloudAndMES", "CloudServerIP", out sValue);
  1136. sysParams.CloudServerIP = sValue;
  1137. iniHelper.ReadInteger("CloudAndMES", "CloudServerPort", out iValue);
  1138. sysParams.CloudServerPort = iValue;
  1139. iniHelper.ReadString("CloudAndMES", "CloudUser", out sValue);
  1140. sysParams.CloudUser = sValue;
  1141. iniHelper.ReadString("CloudAndMES", "CloudPassword", out sValue);
  1142. sysParams.CloudPassword = sValue;
  1143. iniHelper.ReadBool("CloudAndMES", "OpenPdtServer", out bValue);
  1144. sysParams.OpenPdtServer = bValue;
  1145. iniHelper.ReadString("CloudAndMES", "PdtServerIP", out sValue);
  1146. sysParams.PdtServerIP = sValue;
  1147. iniHelper.ReadInteger("CloudAndMES", "PdtServerPort", out iValue);
  1148. sysParams.PdtServerPort = iValue;
  1149. iniHelper.ReadBool("CloudAndMES", "IsPdtServer", out bValue);
  1150. sysParams.IsPdtServer = bValue;
  1151. iniHelper.ReadDouble("LensZ", "Z_0_58X", out dValue);
  1152. sysParams.LensAxisZPos.Z_0_58X = dValue;
  1153. //iniHelper.ReadDouble("LensZ", "Z_0_6X", out dValue);
  1154. //sysParams.LensAxisZPos.Z_0_6X = dValue;
  1155. iniHelper.ReadDouble("LensZ", "Z_1_0X", out dValue);
  1156. sysParams.LensAxisZPos.Z_1_0X = dValue;
  1157. iniHelper.ReadDouble("LensZ", "Z_1_5X", out dValue);
  1158. sysParams.LensAxisZPos.Z_1_5X = dValue;
  1159. iniHelper.ReadDouble("LensZ", "Z_2_0X", out dValue);
  1160. sysParams.LensAxisZPos.Z_2_0X = dValue;
  1161. iniHelper.ReadDouble("LensZ", "Z_2_5X", out dValue);
  1162. sysParams.LensAxisZPos.Z_2_5X = dValue;
  1163. iniHelper.ReadDouble("LensZ", "Z_3_0X", out dValue);
  1164. sysParams.LensAxisZPos.Z_3_0X = dValue;
  1165. iniHelper.ReadDouble("LensZ", "Z_3_5X", out dValue);
  1166. sysParams.LensAxisZPos.Z_3_5X = dValue;
  1167. iniHelper.ReadDouble("LensZ", "Z_4_0X", out dValue);
  1168. sysParams.LensAxisZPos.Z_4_0X = dValue;
  1169. iniHelper.ReadDouble("LensZ", "Z_4_5X", out dValue);
  1170. sysParams.LensAxisZPos.Z_4_5X = dValue;
  1171. iniHelper.ReadDouble("LensZ", "Z_5_0X", out dValue);
  1172. sysParams.LensAxisZPos.Z_5_0X = dValue;
  1173. iniHelper.ReadDouble("LensZ", "Z_5_5X", out dValue);
  1174. sysParams.LensAxisZPos.Z_5_5X = dValue;
  1175. iniHelper.ReadDouble("LensZ", "Z_6_0X", out dValue);
  1176. sysParams.LensAxisZPos.Z_6_0X = dValue;
  1177. iniHelper.ReadDouble("LensZ", "Z_6_5X", out dValue);
  1178. sysParams.LensAxisZPos.Z_6_5X = dValue;
  1179. iniHelper.ReadDouble("LensZ", "Z_7_0X", out dValue);
  1180. sysParams.LensAxisZPos.Z_7_0X = dValue;
  1181. iniHelper.ReadDouble("LensZ", "Z_7_5X", out dValue);
  1182. sysParams.LensAxisZPos.Z_7_5X = dValue;
  1183. iniHelper.ReadBool("LabelPrint", "EnableLabelPrint", out bValue);
  1184. sysParams.EnableLabelPrint = bValue;
  1185. iniHelper.ReadString("LabelPrint", "LabelPrinterName", out sValue);
  1186. sysParams.LabelPrinterName = sValue;
  1187. iniHelper.ReadString("LabelPrint", "LabelTempPath", out sValue);
  1188. sysParams.LabelTempPath = sValue;
  1189. iniHelper.ReadString("LabelPrint", "LabelData", out sValue);
  1190. if (string.IsNullOrEmpty(sValue))
  1191. sysParams.LabelData = new Dictionary<string, string>();
  1192. else
  1193. sysParams.LabelData = JsonConvert.DeserializeObject<Dictionary<string, string>>(sValue);
  1194. iniHelper.ReadBool("ExcelPrint", "EnableExcelPrint", out bValue);
  1195. sysParams.EnableExcelPrint = bValue;
  1196. iniHelper.ReadString("ExcelPrint", "ExcelPrinterName", out sValue);
  1197. sysParams.ExcelPrinterName = sValue;
  1198. iniHelper.ReadString("ExcelPrint", "ExcelTempPath", out sValue);
  1199. sysParams.ExcelTempPath = sValue;
  1200. iniHelper.ReadString("ExcelPrint", "ExcelData", out sValue);
  1201. if (string.IsNullOrEmpty(sValue))
  1202. sysParams.ExcelData = new Dictionary<string, string>();
  1203. else
  1204. sysParams.ExcelData = JsonConvert.DeserializeObject<Dictionary<string, string>>(sValue);
  1205. iniHelper.ReadDouble("Offset", "Pt_offset", out dValue);
  1206. sysParams.Pt_offset = dValue;
  1207. iniHelper.ReadDouble("Offset", "Line_offset", out dValue);
  1208. sysParams.Line_offset = dValue;
  1209. iniHelper.ReadDouble("Offset", "X_per", out dValue);
  1210. if (dValue > 1)
  1211. sysParams.X_per = 0.9;
  1212. else if (dValue <= 0)
  1213. sysParams.X_per = 0.1;
  1214. else
  1215. sysParams.X_per = dValue;
  1216. iniHelper.ReadDouble("Offset", "Y_per", out dValue);
  1217. if (dValue > 1)
  1218. sysParams.Y_per = 0.9;
  1219. else if (dValue <= 0)
  1220. sysParams.Y_per = 0.1;
  1221. else
  1222. sysParams.Y_per = dValue;
  1223. iniHelper.ReadInteger("DefectSnap", "LightCH", out iValue);
  1224. sysParams.LightCH = iValue;
  1225. iniHelper.ReadInteger("DefectSnap", "LightLut", out iValue);
  1226. sysParams.LightLut = iValue;
  1227. iniHelper.ReadInteger("DefectSnap", "CamExposureTime", out iValue);
  1228. sysParams.CamExposureTime = iValue;
  1229. iniHelper.ReadInteger("SysOther", "LightChannelCnt", out iValue);
  1230. sysParams.LightChannelCnt = iValue;
  1231. iniHelper.ReadString("SysOther", "CustomerName", out sValue);
  1232. sysParams.CustomerName = sValue;
  1233. iniHelper.ReadDouble("SysOther", "DefectCamPixel", out dValue);
  1234. sysParams.DefectCamPixel = dValue;
  1235. if (sysParams.DefectCamPixel == 0)
  1236. sysParams.DefectCamPixel = 0.002515;
  1237. iniHelper.ReadDouble("SysOther", "DefectAutoX", out dValue);
  1238. sysParams.DefectAutoX = dValue;
  1239. iniHelper.ReadDouble("SysOther", "DefectAutoY", out dValue);
  1240. sysParams.DefectAutoY = dValue;
  1241. SysConfigParams = sysParams;
  1242. return sysParams;
  1243. }
  1244. /// <summary>
  1245. /// 写入系统默认配置
  1246. /// </summary>
  1247. public void WriteDefaultSystemConfig()
  1248. {
  1249. SysConfigParams = new SysConfigParams();
  1250. WriteSysConfParams(SysConfigParams);
  1251. }
  1252. /// <summary>
  1253. /// 加载系统配置
  1254. /// </summary>
  1255. /// <returns></returns>
  1256. public bool LoadSystemConfig()
  1257. {
  1258. bool ret = false;
  1259. if (!Directory.Exists(_rootPath))
  1260. {
  1261. Directory.CreateDirectory(_rootPath);
  1262. }
  1263. if (!Directory.Exists(_projectDir))
  1264. {
  1265. Directory.CreateDirectory(_projectDir);
  1266. }
  1267. if (File.Exists(_pointsPath))
  1268. {
  1269. ReadPointsAndTime();
  1270. }
  1271. else
  1272. {
  1273. // write default value
  1274. WritePointsAndTime(0, 0, 0, 0, 1000, 1000);
  1275. ret = true;
  1276. }
  1277. if (File.Exists(_configFile))
  1278. {
  1279. SysConfigParams = ReadSysConfParams();
  1280. if (null != SysConfigParams)
  1281. {
  1282. ret = true;
  1283. }
  1284. }
  1285. else
  1286. {
  1287. // write default value
  1288. WriteDefaultSystemConfig();
  1289. ret = true;
  1290. }
  1291. return ret;
  1292. }
  1293. #endregion
  1294. #region 文件选择
  1295. /// <summary>
  1296. /// 选择目录
  1297. /// </summary>
  1298. /// <returns></returns>
  1299. public static string SelectFolder(string defaultPath = "")
  1300. {
  1301. FolderBrowserDialog dlg = new FolderBrowserDialog();
  1302. dlg.SelectedPath = (defaultPath != "" ? defaultPath : Path.GetFullPath("."));
  1303. if (dlg.ShowDialog() == DialogResult.OK)
  1304. return dlg.SelectedPath;
  1305. return "";
  1306. }
  1307. /// <summary>
  1308. /// 选择文件
  1309. /// </summary>
  1310. /// <param name="filter">如 图像文件|*.jpg|图像文件|*.png|所有文件|*.*</param>
  1311. /// <returns></returns>
  1312. public static string SelectFile(string filter = "所有文件|*.*", string defaultPath = "")
  1313. {
  1314. OpenFileDialog fie = new OpenFileDialog();
  1315. fie.Title = "选择文件";
  1316. //fie.InitialDirectory = (defaultPath != "" ? defaultPath : Path.GetFullPath("."));
  1317. fie.Filter = filter; //设置文件类型
  1318. if (fie.ShowDialog() == DialogResult.OK)
  1319. return fie.FileName;
  1320. return "";
  1321. }
  1322. /// <summary>
  1323. /// 删除指定目录下文件
  1324. /// </summary>
  1325. /// <param name="defaultPath"></param>
  1326. /// <param name="fileExtend"></param>
  1327. /// <returns></returns>
  1328. public static bool DelFilesInFolder(string FolderPath, string fileExtend = "*")
  1329. {
  1330. if (!Directory.Exists(FolderPath))
  1331. return false;
  1332. string[] files = Directory.GetFiles(FolderPath, fileExtend, SearchOption.TopDirectoryOnly);
  1333. foreach (string file in files)
  1334. API.DeleteFile(file);
  1335. return true;
  1336. }
  1337. /// <summary>
  1338. /// 另存为
  1339. /// </summary>
  1340. /// <param name="defaultFileName">默认文件名</param>
  1341. /// <param name="filter">如 图像文件|*.jpg|图像文件|*.png|所有文件|*.*</param>
  1342. /// <returns></returns>
  1343. public static string SaveAsFile(string defaultFileName, string filter = "所有文件|*.*")
  1344. {
  1345. SaveFileDialog s = new SaveFileDialog();
  1346. s.Title = "保存文件";
  1347. s.Filter = filter; //"图像文件|*.jpg|图像文件|*.png|所有文件|*.*";
  1348. //s.DefaultExt = "图像文件|*.jpg"; //默认扩展名
  1349. //s.InitialDirectory = @"C:\Users\Administrator\Desktop"; //保存的初始目录
  1350. s.FileName = defaultFileName;//默认文件名
  1351. if (s.ShowDialog() == DialogResult.OK)
  1352. return s.FileName;
  1353. return "";
  1354. }
  1355. #endregion
  1356. #region json操作
  1357. public static void addKey(JObject obj, string key, JToken value)
  1358. {
  1359. if (obj.ContainsKey(key))
  1360. obj[key] = value;
  1361. else
  1362. obj.Add(key, value);
  1363. }
  1364. #endregion
  1365. #region enum名称
  1366. public static ArrayList GetArrayList<T>()
  1367. {
  1368. ArrayList list = new ArrayList();
  1369. Type type = typeof(T);
  1370. //list.Add(new DictionaryEntry("start", "启动按钮"));
  1371. foreach (int value in Enum.GetValues(type))
  1372. {
  1373. string strName = Enum.GetName(type, value);//获取名称
  1374. list.Add(new DictionaryEntry(value, strName));
  1375. }
  1376. return list;
  1377. }
  1378. #endregion
  1379. #region 生产数据记录
  1380. public bool SetDailyOutputAdd(out int tDailyOutput)
  1381. {
  1382. bool ret = true;
  1383. try
  1384. {
  1385. //读取数据
  1386. string tempFile = Path.Combine(_rootPath, "DailyOutput.ini");
  1387. IniHelper iniHelper = new IniHelper(tempFile);
  1388. int iValue = 0;
  1389. iniHelper.ReadInteger("TempData", "DailyOutput", out iValue);
  1390. tDailyOutput = iValue;
  1391. iniHelper.ReadInteger("TempData", "Date", out iValue);
  1392. int dateNum = iValue;
  1393. int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
  1394. if (dateNum == nowDateNum)
  1395. {
  1396. //同一天,生产数量+1
  1397. tDailyOutput++;
  1398. }
  1399. else if(dateNum < nowDateNum)
  1400. {
  1401. //昨天数据,为1
  1402. tDailyOutput = 1;
  1403. }
  1404. //重新记录
  1405. iniHelper.WriteInteger("TempData", "DailyOutput", tDailyOutput);
  1406. iniHelper.WriteInteger("TempData", "Date", nowDateNum);
  1407. }
  1408. catch (Exception ex)
  1409. {
  1410. tDailyOutput = 0;
  1411. ret = false;
  1412. string tempFile = Path.Combine(_rootPath, "DailyOutput.ini");
  1413. IniHelper iniHelper = new IniHelper(tempFile);
  1414. int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
  1415. //重新记录
  1416. iniHelper.WriteInteger("TempData", "DailyOutput", tDailyOutput);
  1417. iniHelper.WriteInteger("TempData", "Date", nowDateNum);
  1418. }
  1419. return ret;
  1420. }
  1421. public bool GetDailyOutput(out int tDailyOutput)
  1422. {
  1423. bool ret = true;
  1424. try
  1425. {
  1426. //读取数据
  1427. string tempFile = Path.Combine(_rootPath, "DailyOutput.ini");
  1428. IniHelper iniHelper = new IniHelper(tempFile);
  1429. int iValue = 0;
  1430. iniHelper.ReadInteger("TempData", "DailyOutput", out iValue);
  1431. tDailyOutput = iValue;
  1432. iniHelper.ReadInteger("TempData", "Date", out iValue);
  1433. int dateNum = iValue;
  1434. int nowDateNum = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
  1435. if (dateNum == nowDateNum)
  1436. {
  1437. //同一天,生产数量+1
  1438. //tDailyOutput++;
  1439. }
  1440. else if (dateNum < nowDateNum)
  1441. {
  1442. //昨天数据,为1
  1443. tDailyOutput = 0;
  1444. }
  1445. }
  1446. catch (Exception ex)
  1447. {
  1448. tDailyOutput = 0;
  1449. ret = false;
  1450. }
  1451. return ret;
  1452. }
  1453. #endregion
  1454. #region 尺寸检测项
  1455. public List<SizeItemParam> SizeItemParamsList = new List<SizeItemParam>();
  1456. public void ReadSizeDefectItems()
  1457. {
  1458. string str = File.ReadAllText(_sizeItemsPath);
  1459. SizeItemParamsList = JsonConvert.DeserializeObject<List<SizeItemParam>>(str);
  1460. }
  1461. #endregion
  1462. #region 缺陷检测项
  1463. public List<DefectItemParam> DefectItemParamsList = new List<DefectItemParam>();
  1464. public void ReadDefectItems()
  1465. {
  1466. string str = File.ReadAllText(_defectItemsPath);
  1467. DefectItemParamsList = JsonConvert.DeserializeObject<List<DefectItemParam>>(str);
  1468. }
  1469. #endregion
  1470. #region 比对检测项
  1471. public List<DefectItemParam> SizeCompItemParamsList = new List<DefectItemParam>();
  1472. public void ReadSizeCompItems()
  1473. {
  1474. if (File.Exists(_sizeCompItemsPath))
  1475. {
  1476. string str = File.ReadAllText(_sizeCompItemsPath);
  1477. SizeCompItemParamsList = JsonConvert.DeserializeObject<List<DefectItemParam>>(str);
  1478. }
  1479. else
  1480. {
  1481. SizeCompItemParamsList.Add(new DefectItemParam()
  1482. {
  1483. Code = "wtg",
  1484. Name = "未通过",
  1485. Show = 1,
  1486. Type = "0",
  1487. });
  1488. }
  1489. }
  1490. #endregion
  1491. #endregion
  1492. }
  1493. }