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.
 
 
 
 
 

533 lines
32 KiB

  1. using Newtonsoft.Json.Linq;
  2. using ProductionControl.Utils;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using System.Windows.Forms.VisualStyles;
  13. namespace ProductionControl
  14. {
  15. public partial class FrmSysSetting : Form
  16. {
  17. public FrmSysSetting()
  18. {
  19. InitializeComponent();
  20. }
  21. private void FrmSetParams_Load(object sender, EventArgs e)
  22. {
  23. initData();
  24. }
  25. private void initData()
  26. {
  27. string configPath = Application.StartupPath + "\\SysConfig.ini";
  28. string lsTmp = "";
  29. var comNameList = Utils.SSerialPort.getPortNames().ToList();
  30. comNameList.ForEach(comName =>
  31. {
  32. this.cobLight_PortNum.Items.Add(comName);
  33. this.cobTension_PortNum.Items.Add(comName);
  34. this.cobSmallAxis_ComName.Items.Add(comName);
  35. });
  36. //Skip
  37. this.chkSkipAxis0.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipAxis0") == "1";
  38. this.chkSkipAxis1.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipAxis1") == "1";
  39. this.chkSkipAxis2.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipAxis2") == "1";
  40. this.chkSkipAxis3.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipAxis3") == "1";
  41. this.chkSkipTension.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipTension") == "1";
  42. this.chkSkipHeight.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipHeight") == "1";
  43. this.chkSkipLight.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipLight") == "1";
  44. this.chkSkipScannerGL.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipScannerGL") == "1";
  45. this.chkSkipScannerCC.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipScannerCC") == "1";
  46. this.chkSkipSmallAxis.Checked = Util.ReadIniValue(configPath, "SKIP", "SkipSmallAxis") == "1";
  47. this.ckSkipSizeFailed.Checked = Util.ReadIniValue(configPath, "SKIP", "MarkErrorStop") == "1";
  48. this.cbOpenFlawDistribution.Checked = Util.ReadIniValue(configPath, "SKIP", "OpenFlawDistribution") == "1";
  49. this.cbOpenAxisXCal.Checked = Util.ReadIniValue(configPath, "SKIP", "OpenAxisXCalibration") == "1";
  50. //DEV
  51. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis0_PulseOutMode");
  52. EnumUtil.BindToEnumName<AxisPulseOutMode>(this.cobAxis0PulseOutMode, typeof(AxisPulseOutMode), lsTmp == "" ? AxisPulseOutMode.O_CW_CCW : (AxisPulseOutMode)Convert.ToInt32(lsTmp));
  53. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis1_PulseOutMode");
  54. EnumUtil.BindToEnumName<AxisPulseOutMode>(this.cobAxis1PulseOutMode, typeof(AxisPulseOutMode), lsTmp == "" ? AxisPulseOutMode.O_CW_CCW : (AxisPulseOutMode)Convert.ToInt32(lsTmp));
  55. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis2_PulseOutMode");
  56. EnumUtil.BindToEnumName<AxisPulseOutMode>(this.cobAxis2PulseOutMode, typeof(AxisPulseOutMode), lsTmp == "" ? AxisPulseOutMode.O_CW_CCW : (AxisPulseOutMode)Convert.ToInt32(lsTmp));
  57. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis3_PulseOutMode");
  58. EnumUtil.BindToEnumName<AxisPulseOutMode>(this.cobAxis3PulseOutMode, typeof(AxisPulseOutMode), lsTmp == "" ? AxisPulseOutMode.O_CW_CCW : (AxisPulseOutMode)Convert.ToInt32(lsTmp));
  59. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis0_HomeMode");
  60. EnumUtil.BindToEnumName<AxitHomeMode>(this.cobAxis0HomeMode, typeof(AxitHomeMode), lsTmp == "" ? AxitHomeMode.MODE11_LmtSearch_Ref : (AxitHomeMode)Convert.ToInt32(lsTmp));
  61. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis1_HomeMode");
  62. EnumUtil.BindToEnumName<AxitHomeMode>(this.cobAxis1HomeMode, typeof(AxitHomeMode), lsTmp == "" ? AxitHomeMode.MODE11_LmtSearch_Ref : (AxitHomeMode)Convert.ToInt32(lsTmp));
  63. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis2_HomeMode");
  64. EnumUtil.BindToEnumName<AxitHomeMode>(this.cobAxis2HomeMode, typeof(AxitHomeMode), lsTmp == "" ? AxitHomeMode.MODE11_LmtSearch_Ref : (AxitHomeMode)Convert.ToInt32(lsTmp));
  65. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis3_HomeMode");
  66. EnumUtil.BindToEnumName<AxitHomeMode>(this.cobAxis3HomeMode, typeof(AxitHomeMode), lsTmp == "" ? AxitHomeMode.MODE11_LmtSearch_Ref : (AxitHomeMode)Convert.ToInt32(lsTmp));
  67. var lstLightName = Utils.EnumUtil.GetNamesArr<LightDevNameEnum>();
  68. this.cobLight_Name.Items.AddRange(lstLightName);
  69. lsTmp = Util.ReadIniValue(configPath, "DEV", "Light_Name");
  70. if (string.IsNullOrWhiteSpace(lsTmp))
  71. this.cobLight_Name.SelectedIndex = 0;
  72. else
  73. this.cobLight_Name.Text = ((LightDevNameEnum)Convert.ToInt32(lsTmp)).ToString();
  74. this.cobLight_PortNum.Text = "COM" + Util.ReadIniValue(configPath, "DEV", "Light_PortNum");
  75. this.cobTension_PortNum.Text = "COM" + Util.ReadIniValue(configPath, "DEV", "Tension_PortNum");
  76. lsTmp = Util.ReadIniValue(configPath, "DEV", "Tension_Offset");
  77. if (string.IsNullOrWhiteSpace(lsTmp))
  78. this.numOffset.Value = 0;
  79. else
  80. this.numOffset.Value = (decimal)double.Parse(lsTmp);
  81. this.cobSmallAxis_ComName.Text = Util.ReadIniValue(configPath, "DEV", "SmallAxis_ComName");
  82. this.cobAxis0HomeDir.SelectedIndex = Convert.ToInt32(Util.ReadIniValue(configPath, "DEV", "Axis0_HomeDir"));
  83. this.cobAxis1HomeDir.SelectedIndex = Convert.ToInt32(Util.ReadIniValue(configPath, "DEV", "Axis1_HomeDir"));
  84. this.cobAxis2HomeDir.SelectedIndex = Convert.ToInt32(Util.ReadIniValue(configPath, "DEV", "Axis2_HomeDir"));
  85. this.cobAxis3HomeDir.SelectedIndex = Convert.ToInt32(Util.ReadIniValue(configPath, "DEV", "Axis3_HomeDir"));
  86. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis_HomeVelLow");
  87. if (!string.IsNullOrWhiteSpace(lsTmp))
  88. {
  89. JArray Axis_HomeVelLow = JArray.Parse(lsTmp);
  90. this.numAxis0HomeVelLow.Value = Axis_HomeVelLow.Count > 0 ? (decimal)Axis_HomeVelLow[0] : 0;
  91. this.numAxis1HomeVelLow.Value = Axis_HomeVelLow.Count > 1 ? (decimal)Axis_HomeVelLow[1] : 0;
  92. this.numAxis2HomeVelLow.Value = Axis_HomeVelLow.Count > 2 ? (decimal)Axis_HomeVelLow[2] : 0;
  93. this.numAxis3HomeVelLow.Value = Axis_HomeVelLow.Count > 3 ? (decimal)Axis_HomeVelLow[3] : 0;
  94. }
  95. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis_HomeVelHigh");
  96. if (!string.IsNullOrWhiteSpace(lsTmp))
  97. {
  98. JArray Axis_HomeVelHigh = JArray.Parse(lsTmp);
  99. this.numAxis0HomeVelHigh.Value = Axis_HomeVelHigh.Count > 0 ? (decimal)Axis_HomeVelHigh[0] : 0;
  100. this.numAxis1HomeVelHigh.Value = Axis_HomeVelHigh.Count > 1 ? (decimal)Axis_HomeVelHigh[1] : 0;
  101. this.numAxis2HomeVelHigh.Value = Axis_HomeVelHigh.Count > 2 ? (decimal)Axis_HomeVelHigh[2] : 0;
  102. this.numAxis3HomeVelHigh.Value = Axis_HomeVelHigh.Count > 3 ? (decimal)Axis_HomeVelHigh[3] : 0;
  103. }
  104. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis_HomeAcc");
  105. if (!string.IsNullOrWhiteSpace(lsTmp))
  106. {
  107. JArray Axis_HomeAcc = JArray.Parse(lsTmp);
  108. this.numAxis0HomeAcc.Value = Axis_HomeAcc.Count > 0 ? (decimal)Axis_HomeAcc[0] : 0;
  109. this.numAxis1HomeAcc.Value = Axis_HomeAcc.Count > 1 ? (decimal)Axis_HomeAcc[1] : 0;
  110. this.numAxis2HomeAcc.Value = Axis_HomeAcc.Count > 2 ? (decimal)Axis_HomeAcc[2] : 0;
  111. this.numAxis3HomeAcc.Value = Axis_HomeAcc.Count > 3 ? (decimal)Axis_HomeAcc[3] : 0;
  112. }
  113. lsTmp = Util.ReadIniValue(configPath, "DEV", "Axis_HomeDec");
  114. if (!string.IsNullOrWhiteSpace(lsTmp))
  115. {
  116. JArray Axis_HomeDec = JArray.Parse(lsTmp);
  117. this.numAxis0HomeDec.Value = Axis_HomeDec.Count > 0 ? (decimal)Axis_HomeDec[0] : 0;
  118. this.numAxis1HomeDec.Value = Axis_HomeDec.Count > 1 ? (decimal)Axis_HomeDec[1] : 0;
  119. this.numAxis2HomeDec.Value = Axis_HomeDec.Count > 2 ? (decimal)Axis_HomeDec[2] : 0;
  120. this.numAxis3HomeDec.Value = Axis_HomeDec.Count > 3 ? (decimal)Axis_HomeDec[3] : 0;
  121. }
  122. this.txtHeightDev_IP.Text = Util.ReadIniValue(configPath, "DEV", "HeightDev_IP");
  123. this.numHeightDev_Port.Value = Convert.ToInt32(Util.ReadIniValue(configPath, "DEV", "HeightDev_Port"));
  124. this.numHeightDev_SafeValue.Value = Convert.ToDecimal(Util.ReadIniValue(configPath, "DEV", "HeightDev_SafeValue"));
  125. lsTmp = Util.ReadIniValue(configPath, "DEV", "HeightDev_BaseList");
  126. if (!string.IsNullOrWhiteSpace(lsTmp))
  127. {
  128. JArray HeightDev_BaseList = JArray.Parse(lsTmp);
  129. this.numHeightBase0.Value = HeightDev_BaseList.Count > 0 ? (decimal)HeightDev_BaseList[0] : 0;
  130. this.numHeightBase1.Value = HeightDev_BaseList.Count > 1 ? (decimal)HeightDev_BaseList[1] : 0;
  131. this.numHeightBase2.Value = HeightDev_BaseList.Count > 2 ? (decimal)HeightDev_BaseList[2] : 0;
  132. this.numHeightBase3.Value = HeightDev_BaseList.Count > 3 ? (decimal)HeightDev_BaseList[3] : 0;
  133. this.numHeightBase4.Value = HeightDev_BaseList.Count > 4 ? (decimal)HeightDev_BaseList[4] : 0;
  134. }
  135. this.txtIO_DevNum.Text = Util.ReadIniValue(configPath, "DEV", "IOCard_DeviceNum");
  136. this.txtDefect_Path.Text = Util.ReadIniValue(configPath, "DEV", "Defect_SavePath");
  137. this.txtDefect_Small_Path.Text = Util.ReadIniValue(configPath, "DEV", "Defect_Small_SavePath");
  138. this.txtDefect_Compress_SavePath.Text = Util.ReadIniValue(configPath, "DEV", "Defect_Compress_SavePath");
  139. this.txtDefect_SrcSmall_SavePath.Text = Util.ReadIniValue(configPath, "DEV", "Defect_SrcSmall_SavePath");
  140. //int liTmp = -1;
  141. double ldTmp = -1;
  142. lsTmp = Util.ReadIniValue(configPath, "DEV", "Defect_SavePath_AutoClear");
  143. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  144. ldTmp = Convert.ToDouble(lsTmp);
  145. chkDefect_Path_AutoClear.Checked = (ldTmp > -1);
  146. if (ldTmp > -1) numDefect_Path_AutoClear.Value = (decimal)ldTmp;
  147. lsTmp = Util.ReadIniValue(configPath, "DEV", "Defect_Compress_SavePath_AutoClear");
  148. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  149. ldTmp = Convert.ToDouble(lsTmp);
  150. chkDefect_Compress_SavePath_AutoClear.Checked = (ldTmp > -1);
  151. if (ldTmp > -1) numDefect_Compress_SavePath_AutoClear.Value = (decimal)ldTmp;
  152. lsTmp = Util.ReadIniValue(configPath, "DEV", "Defect_Small_SavePath_AutoClear");
  153. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  154. ldTmp = Convert.ToDouble(lsTmp);
  155. chkDefect_Small_Path_AutoClear.Checked = (ldTmp > -1);
  156. if (ldTmp > -1) numDefect_Small_Path_AutoClear.Value = (decimal)ldTmp;
  157. ///////////////////////////////////////
  158. ///
  159. lsTmp = Util.ReadIniValue(configPath, "DEV", "Defect_SrcSmall_SavePath_AutoClear");
  160. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  161. if (lsTmp == "")
  162. lsTmp = "3";
  163. ldTmp = Convert.ToDouble(lsTmp);
  164. chkDefect_SrcSmall_Path_AutoClear.Checked = (ldTmp > -1);
  165. if (ldTmp > -1) numDefect_SrcSmall_Path_AutoClear.Value = (decimal)ldTmp;
  166. lsTmp = Util.ReadIniValue(configPath, "DEV", "Defect_SrcSmall_Thres");
  167. if (lsTmp == "")
  168. lsTmp = "0.7";
  169. ldTmp = Convert.ToDouble(lsTmp);
  170. if (ldTmp > -1) Defect_SrcSmall_Thres.Value = (decimal)ldTmp;
  171. ///////////////////////////////////////
  172. this.chkSaveAllDefectImg.Checked= (Util.ReadIniValue(configPath, "DEV", "SaveAllDefectImg") == "1");
  173. this.chkMakeTag.Checked= (Util.ReadIniValue(configPath, "DEV", "MakeTag") == "1");
  174. this.txtSizeEnginePath.Text= Util.ReadIniValue(configPath, "DEV", "SizeEnginePath");
  175. this.txtSizeBmp_SavePath.Text = Util.ReadIniValue(configPath, "DEV", "SizeBmp_SavePath");
  176. this.txtSizeBmp_Compare_SavePath.Text = Util.ReadIniValue(configPath, "DEV", "SizeBmp_Compare_SavePath");
  177. this.txtSizeBmp_Zoom_Image_SavePath.Text = Util.ReadIniValue(configPath, "DEV", "SizeBmp_Zoom_Image_SavePath");
  178. lsTmp = Util.ReadIniValue(configPath, "DEV", "SizeBmp_SavePath_AutoClear");
  179. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  180. ldTmp = Convert.ToDouble(lsTmp);
  181. chkSizeBmp_SavePath_AutoClear.Checked = (ldTmp > -1);
  182. if (ldTmp > -1) numSizeBmp_SavePath_AutoClear.Value = (decimal)ldTmp;
  183. lsTmp = Util.ReadIniValue(configPath, "DEV", "SizeBmp_Compare_SavePath_AutoClear");
  184. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  185. ldTmp = Convert.ToDouble(lsTmp);
  186. chkSizeBmp_Compare_SavePath_AutoClear.Checked = (ldTmp > -1);
  187. if (ldTmp > -1) numSizeBmp_Compare_SavePath_AutoClear.Value = (decimal)ldTmp;
  188. lsTmp = Util.ReadIniValue(configPath, "DEV", "SizeBmp_Zoom_Image_SavePath_AutoClear");
  189. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  190. ldTmp = Convert.ToDouble(lsTmp);
  191. chkSizeBmp_Zoom_Image_SavePath_AutoClear.Checked = (ldTmp > -1);
  192. if (ldTmp > -1) numSizeBmp_Zoom_Image_SavePath_AutoClear.Value = (decimal)ldTmp;
  193. //线宽PT补偿
  194. lsTmp = Util.ReadIniValue(configPath, "DEV", "PT_Offset");
  195. if (string.IsNullOrWhiteSpace(lsTmp))
  196. this.numPToffset.Value = 0;
  197. else
  198. this.numPToffset.Value = (decimal)double.Parse(lsTmp);
  199. lsTmp = Util.ReadIniValue(configPath, "DEV", "LineWidth_Offset");
  200. if (string.IsNullOrWhiteSpace(lsTmp))
  201. this.numLineWidthoffset.Value = 0;
  202. else
  203. this.numLineWidthoffset.Value = (decimal)double.Parse(lsTmp);
  204. //DB
  205. this.txtDBCon.Text = Util.ReadIniValue(configPath, "DB", "DBConStr");
  206. //HTTP
  207. this.txtLocalIp.Text = Util.ReadIniValue(configPath, "HTTP", "LocalIp");
  208. lsTmp = Util.ReadIniValue(configPath, "HTTP", "LocalHttpPort");
  209. if (Util.IsNumber(lsTmp))this.numHttpPort.Value = Convert.ToInt32(lsTmp);
  210. //lsTmp = Util.ReadIniValue(configPath, "HTTP", "LocalSocketPort");
  211. //if (Util.IsNumber(lsTmp)) this.numSocketPort.Value = Convert.ToInt32(lsTmp);
  212. //LOG
  213. this.txtLogPath.Text = Util.ReadIniValue(configPath, "LOG", "LogPath");
  214. }
  215. private void tsbtnSave_Click(object sender, EventArgs e)
  216. {
  217. try
  218. {
  219. string configPath = Application.StartupPath + "\\SysConfig.ini";
  220. //DEV
  221. string lsLight_Name = this.cobLight_Name.Text.Trim();
  222. if (lsLight_Name == "")
  223. throw new Exception("请选择光源提供商!");
  224. LightDevNameEnum Light_Name = Utils.EnumUtil.Convert2Enum<LightDevNameEnum>(lsLight_Name);
  225. string Light_PortNum = this.cobLight_PortNum.Text.Trim();
  226. string Tension_PortNum = this.cobTension_PortNum.Text.Trim();
  227. decimal Tension_Offset = this.numOffset.Value;
  228. string SmallAxis_ComName = this.cobSmallAxis_ComName.Text.Trim();
  229. if (Light_PortNum == "" || Tension_PortNum == "" || SmallAxis_ComName == "")
  230. throw new Exception("请设置设备COM端口!");
  231. string HeightDev_IP = this.txtHeightDev_IP.Text;
  232. int HeightDev_Port = (int)this.numHeightDev_Port.Value;
  233. if(HeightDev_IP=="")
  234. throw new Exception("请设置厚度检测设备IP地址!");
  235. decimal HeightDev_SafeValue=this.numHeightDev_SafeValue.Value;
  236. string IOCard_DeviceNum = this.txtIO_DevNum.Text.Trim();
  237. if (IOCard_DeviceNum == "")
  238. throw new Exception("请设置I/O设备编号 !");
  239. string Defect_SavePath = this.txtDefect_Path.Text.Trim();
  240. if (Defect_SavePath == "")
  241. throw new Exception("请设置缺陷大图保存路径 !");
  242. string Defect_Compress_SavePath = this.txtDefect_Compress_SavePath.Text.Trim();
  243. if (Defect_Compress_SavePath == "")
  244. throw new Exception("请设置缺陷压缩大图保存路径 !");
  245. string Defect_Small_SavePath = this.txtDefect_Small_Path.Text.Trim();
  246. //if (Defect_Small_SavePath == "")
  247. // throw new Exception("请设置缺陷小图保存路径 !");
  248. string Defect_SrcSmall_SavePath = this.txtDefect_SrcSmall_SavePath.Text.Trim();
  249. if (Defect_SrcSmall_SavePath == "")
  250. throw new Exception("请设置原始缺陷小图保存路径 !");
  251. //DB
  252. string DBConStr = this.txtDBCon.Text.Trim();
  253. if (DBConStr == "")
  254. throw new Exception("请设置DB连接字符串 !");
  255. //LOG
  256. string LogPath = this.txtLogPath.Text.Trim();
  257. if (LogPath == "")
  258. throw new Exception("请设置日志保存路径 !");
  259. //最后统一保存
  260. //Skip
  261. Util.WriteIniValue(configPath, "SKIP", "SkipAxis0", this.chkSkipAxis0.Checked ? "1" : "0");
  262. Util.WriteIniValue(configPath, "SKIP", "SkipAxis1", this.chkSkipAxis1.Checked ? "1" : "0");
  263. Util.WriteIniValue(configPath, "SKIP", "SkipAxis2", this.chkSkipAxis2.Checked ? "1" : "0");
  264. Util.WriteIniValue(configPath, "SKIP", "SkipAxis3", this.chkSkipAxis3.Checked ? "1" : "0");
  265. Util.WriteIniValue(configPath, "SKIP", "SkipTension", this.chkSkipTension.Checked ? "1" : "0");
  266. Util.WriteIniValue(configPath, "SKIP", "SkipHeight", this.chkSkipHeight.Checked ? "1" : "0");
  267. Util.WriteIniValue(configPath, "SKIP", "SkipLight", this.chkSkipLight.Checked ? "1" : "0");
  268. Util.WriteIniValue(configPath, "SKIP", "SkipScannerGL", this.chkSkipScannerGL.Checked ? "1" : "0");
  269. Util.WriteIniValue(configPath, "SKIP", "SkipScannerCC", this.chkSkipScannerCC.Checked ? "1" : "0");
  270. Util.WriteIniValue(configPath, "SKIP", "SkipSmallAxis", this.chkSkipSmallAxis.Checked ? "1" : "0");
  271. Util.WriteIniValue(configPath, "SKIP", "MarkErrorStop", this.ckSkipSizeFailed.Checked ? "1" : "0");
  272. Util.WriteIniValue(configPath, "SKIP", "OpenFlawDistribution", this.cbOpenFlawDistribution.Checked ? "1" : "0");
  273. Util.WriteIniValue(configPath, "SKIP", "OpenAxisXCalibration", this.cbOpenAxisXCal.Checked ? "1" : "0");
  274. //DEV
  275. Utils.Util.WriteIniValue(configPath, "DEV", "Axis0_PulseOutMode", ((int)EnumUtil.GetSelectedItemToEnum<AxisPulseOutMode>(this.cobAxis0PulseOutMode)).ToString());
  276. Utils.Util.WriteIniValue(configPath, "DEV", "Axis1_PulseOutMode", ((int)EnumUtil.GetSelectedItemToEnum<AxisPulseOutMode>(this.cobAxis1PulseOutMode)).ToString());
  277. Utils.Util.WriteIniValue(configPath, "DEV", "Axis2_PulseOutMode", ((int)EnumUtil.GetSelectedItemToEnum<AxisPulseOutMode>(this.cobAxis2PulseOutMode)).ToString());
  278. Utils.Util.WriteIniValue(configPath, "DEV", "Axis3_PulseOutMode", ((int)EnumUtil.GetSelectedItemToEnum<AxisPulseOutMode>(this.cobAxis3PulseOutMode)).ToString());
  279. Utils.Util.WriteIniValue(configPath, "DEV", "Axis0_HomeMode", ((int)EnumUtil.GetSelectedItemToEnum<AxitHomeMode>(this.cobAxis0HomeMode)).ToString());
  280. Utils.Util.WriteIniValue(configPath, "DEV", "Axis1_HomeMode", ((int)EnumUtil.GetSelectedItemToEnum<AxitHomeMode>(this.cobAxis1HomeMode)).ToString());
  281. Utils.Util.WriteIniValue(configPath, "DEV", "Axis2_HomeMode", ((int)EnumUtil.GetSelectedItemToEnum<AxitHomeMode>(this.cobAxis2HomeMode)).ToString());
  282. Utils.Util.WriteIniValue(configPath, "DEV", "Axis3_HomeMode", ((int)EnumUtil.GetSelectedItemToEnum<AxitHomeMode>(this.cobAxis3HomeMode)).ToString());
  283. Utils.Util.WriteIniValue(configPath, "DEV", "Axis0_HomeDir", this.cobAxis0HomeDir.SelectedIndex.ToString());
  284. Utils.Util.WriteIniValue(configPath, "DEV", "Axis1_HomeDir", this.cobAxis1HomeDir.SelectedIndex.ToString());
  285. Utils.Util.WriteIniValue(configPath, "DEV", "Axis2_HomeDir", this.cobAxis2HomeDir.SelectedIndex.ToString());
  286. Utils.Util.WriteIniValue(configPath, "DEV", "Axis3_HomeDir", this.cobAxis3HomeDir.SelectedIndex.ToString());
  287. JArray HeightDev_BaseList = new JArray()
  288. {
  289. numHeightBase0.Value,numHeightBase1.Value,numHeightBase2.Value,numHeightBase3.Value,numHeightBase4.Value
  290. };
  291. Utils.Util.WriteIniValue(configPath, "DEV", "HeightDev_BaseList", HeightDev_BaseList.ToString().Replace("\r\n", ""));
  292. Utils.Util.WriteIniValue(configPath, "DEV", "Light_Name", ""+(int)Light_Name);
  293. Utils.Util.WriteIniValue(configPath, "DEV", "Light_PortNum", Light_PortNum.Substring(3));
  294. Utils.Util.WriteIniValue(configPath, "DEV", "Tension_PortNum", Tension_PortNum.Substring(3));
  295. Utils.Util.WriteIniValue(configPath, "DEV", "Tension_Offset", Tension_Offset.ToString());
  296. Utils.Util.WriteIniValue(configPath, "DEV", "SmallAxis_ComName", SmallAxis_ComName);
  297. Utils.Util.WriteIniValue(configPath, "DEV", "HeightDev_IP", HeightDev_IP);
  298. Utils.Util.WriteIniValue(configPath, "DEV", "HeightDev_Port", HeightDev_Port.ToString());
  299. Utils.Util.WriteIniValue(configPath, "DEV", "HeightDev_SafeValue", HeightDev_SafeValue.ToString());
  300. JArray Axis_HomeVelLow = new JArray()
  301. {
  302. numAxis0HomeVelLow.Value,numAxis1HomeVelLow.Value,numAxis2HomeVelLow.Value,numAxis3HomeVelLow.Value
  303. };
  304. Utils.Util.WriteIniValue(configPath, "DEV", "Axis_HomeVelLow", Axis_HomeVelLow.ToString().Replace("\r\n",""));
  305. JArray Axis_HomeVelHigh = new JArray()
  306. {
  307. numAxis0HomeVelHigh.Value,numAxis1HomeVelHigh.Value,numAxis2HomeVelHigh.Value,numAxis3HomeVelHigh.Value
  308. };
  309. Utils.Util.WriteIniValue(configPath, "DEV", "Axis_HomeVelHigh", Axis_HomeVelHigh.ToString().Replace("\r\n", ""));
  310. JArray Axis_HomeAcc = new JArray()
  311. {
  312. numAxis0HomeAcc.Value,numAxis1HomeAcc.Value,numAxis2HomeAcc.Value,numAxis3HomeAcc.Value
  313. };
  314. Utils.Util.WriteIniValue(configPath, "DEV", "Axis_HomeAcc", Axis_HomeAcc.ToString().Replace("\r\n", ""));
  315. JArray Axis_HomeDec = new JArray()
  316. {
  317. numAxis0HomeDec.Value,numAxis1HomeDec.Value,numAxis2HomeDec.Value,numAxis3HomeDec.Value
  318. };
  319. Utils.Util.WriteIniValue(configPath, "DEV", "Axis_HomeDec", Axis_HomeDec.ToString().Replace("\r\n", ""));
  320. Utils.Util.WriteIniValue(configPath, "DEV", "IOCard_DeviceNum", IOCard_DeviceNum);
  321. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_SavePath", Defect_SavePath);
  322. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_SavePath_AutoClear", (chkDefect_Path_AutoClear.Checked ? (double)numDefect_Path_AutoClear.Value : -1)+"");
  323. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_Compress_SavePath", Defect_Compress_SavePath);
  324. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_Compress_SavePath_AutoClear", (chkDefect_Compress_SavePath_AutoClear.Checked ? (double)numDefect_Compress_SavePath_AutoClear.Value : -1) + "");
  325. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_Small_SavePath", Defect_Small_SavePath);
  326. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_Small_SavePath_AutoClear", (chkDefect_Small_Path_AutoClear.Checked ? (double)numDefect_Small_Path_AutoClear.Value : -1) + "");
  327. //////////////////
  328. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_SrcSmall_SavePath", Defect_SrcSmall_SavePath);
  329. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_SrcSmall_Thres", Defect_SrcSmall_Thres.Value.ToString());
  330. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_SrcSmall_SavePath_AutoClear", (chkDefect_SrcSmall_Path_AutoClear.Checked ? (double)numDefect_SrcSmall_Path_AutoClear.Value : -1) + "");
  331. //////////////////
  332. Utils.Util.WriteIniValue(configPath, "DEV", "SaveAllDefectImg", this.chkSaveAllDefectImg.Checked ? "1" : "0");
  333. Utils.Util.WriteIniValue(configPath, "DEV", "MakeTag", this.chkMakeTag.Checked ? "1" : "0");
  334. Utils.Util.WriteIniValue(configPath, "DEV", "SizeEnginePath", this.txtSizeEnginePath.Text.Trim());
  335. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_SavePath", this.txtSizeBmp_SavePath.Text.Trim());
  336. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_SavePath_AutoClear", (chkSizeBmp_SavePath_AutoClear.Checked ? (double)numSizeBmp_SavePath_AutoClear.Value : -1) + "");
  337. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_Compare_SavePath", this.txtSizeBmp_Compare_SavePath.Text.Trim());
  338. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_Compare_SavePath_AutoClear", (chkSizeBmp_Compare_SavePath_AutoClear.Checked ? (double)numSizeBmp_Compare_SavePath_AutoClear.Value : -1) + "");
  339. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_Zoom_Image_SavePath", this.txtSizeBmp_Zoom_Image_SavePath.Text.Trim());
  340. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_Zoom_Image_SavePath_AutoClear", (chkSizeBmp_Zoom_Image_SavePath_AutoClear.Checked ? (double)numSizeBmp_Zoom_Image_SavePath_AutoClear.Value : -1) + "");
  341. decimal PT_Offset = this.numPToffset.Value;
  342. decimal LW_Offset = this.numLineWidthoffset.Value;
  343. Utils.Util.WriteIniValue(configPath, "DEV", "PT_Offset", PT_Offset.ToString());
  344. Utils.Util.WriteIniValue(configPath, "DEV", "LineWidth_Offset", LW_Offset.ToString());
  345. //DB
  346. Utils.Util.WriteIniValue(configPath, "DB", "DBConStr", DBConStr);
  347. //HTTP
  348. Utils.Util.WriteIniValue(configPath, "HTTP", "LocalIp",this.txtLocalIp.Text.Trim());
  349. Utils.Util.WriteIniValue(configPath, "HTTP", "LocalHttpPort", this.numHttpPort.Value.ToString());
  350. //LOG
  351. Utils.Util.WriteIniValue(configPath, "LOG", "LogPath", LogPath);
  352. //
  353. this.Hide();
  354. MessageBox.Show("保存成功,生效需重启程序!");
  355. this.Close();
  356. }
  357. catch (Exception ex)
  358. {
  359. MessageBox.Show(ex.Message, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
  360. }
  361. }
  362. private void tsbtnClose_Click(object sender, EventArgs e)
  363. {
  364. this.Close();
  365. }
  366. private void txtDefect_Path_Click(object sender, EventArgs e)
  367. {
  368. string path = FileUtil.selectFolder(Application.StartupPath);
  369. if (!string.IsNullOrWhiteSpace(path))
  370. this.txtDefect_Path.Text = path;
  371. }
  372. private void txtLogPath_Click(object sender, EventArgs e)
  373. {
  374. string path = FileUtil.selectFolder(Application.StartupPath);
  375. if (!string.IsNullOrWhiteSpace(path))
  376. this.txtLogPath.Text = path;
  377. }
  378. private void txtSizeEnginePath_Click(object sender, EventArgs e)
  379. {
  380. string path = FileUtil.selectFolder(Application.StartupPath);
  381. if (!string.IsNullOrWhiteSpace(path))
  382. this.txtSizeEnginePath.Text = path;
  383. }
  384. private void txtSizeBmp_Path_Click(object sender, EventArgs e)
  385. {
  386. string path = FileUtil.selectFolder(Application.StartupPath);
  387. if (!string.IsNullOrWhiteSpace(path))
  388. this.txtSizeBmp_SavePath.Text = path;
  389. }
  390. private void txtSizeBmp_Compare_SavePath_Click(object sender, EventArgs e)
  391. {
  392. string path = FileUtil.selectFolder(Application.StartupPath);
  393. if (!string.IsNullOrWhiteSpace(path))
  394. this.txtSizeBmp_Compare_SavePath.Text = path;
  395. }
  396. private void txtSizeBmp_Zoom_Image_SavePath_Click(object sender, EventArgs e)
  397. {
  398. string path = FileUtil.selectFolder(Application.StartupPath);
  399. if (!string.IsNullOrWhiteSpace(path))
  400. this.txtSizeBmp_Zoom_Image_SavePath.Text = path;
  401. }
  402. private void txtDefect_Small_Path_Click(object sender, EventArgs e)
  403. {
  404. string path = FileUtil.selectFolder(Application.StartupPath);
  405. if (!string.IsNullOrWhiteSpace(path))
  406. this.txtDefect_Small_Path.Text = path;
  407. }
  408. private void txtDefect_Compress_SavePath_Click(object sender, EventArgs e)
  409. {
  410. string path = FileUtil.selectFolder(Application.StartupPath);
  411. if (!string.IsNullOrWhiteSpace(path))
  412. this.txtDefect_Compress_SavePath.Text = path;
  413. }
  414. private void txtDefect_SrcSmall_SavePath_Click(object sender, EventArgs e)
  415. {
  416. string path = FileUtil.selectFolder(Application.StartupPath);
  417. if (!string.IsNullOrWhiteSpace(path))
  418. this.txtDefect_SrcSmall_SavePath.Text = path;
  419. }
  420. private void btnClearDefect_Small_Path_Click(object sender, EventArgs e)
  421. {
  422. this.txtDefect_Small_Path.Text = "";
  423. }
  424. private void btnClearDefect_SrcSmall_Path_Click(object sender, EventArgs e)
  425. {
  426. this.txtDefect_SrcSmall_SavePath.Text = "";
  427. }
  428. private void btnClearDefect_Path_Click(object sender, EventArgs e)
  429. {
  430. this.txtDefect_Path.Text = "";
  431. }
  432. private void btnClearDefect_Compress_SavePath_Click(object sender, EventArgs e)
  433. {
  434. txtDefect_Compress_SavePath.Text = "";
  435. }
  436. private void btnClearSizeBmp_Path_Click(object sender, EventArgs e)
  437. {
  438. txtSizeBmp_SavePath.Text = "";
  439. }
  440. private void btnClearSizeBmp_Compare_SavePath_Click(object sender, EventArgs e)
  441. {
  442. txtSizeBmp_Compare_SavePath.Text = "";
  443. }
  444. private void btnSizeBmp_Zoom_Image_SavePath_Click(object sender, EventArgs e)
  445. {
  446. txtSizeBmp_Zoom_Image_SavePath.Text = "";
  447. }
  448. private void btnBackDB_Click(object sender, EventArgs e)
  449. {
  450. try
  451. {
  452. string lsPath=Utils.FileUtil.selectFolder();
  453. if (string.IsNullOrWhiteSpace(lsPath))
  454. return;
  455. lsPath += "\\DB" + DateTime.Now.ToString("yyyyMMddHHmm") + ".bak";
  456. Service.InitDB.BackupDataBase(lsPath);
  457. MessageBox.Show("备份成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
  458. }
  459. catch (Exception ex)
  460. {
  461. MessageBox.Show(ex.Message, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
  462. }
  463. }
  464. private void chkMakeTag_CheckedChanged(object sender, EventArgs e)
  465. {
  466. }
  467. }
  468. }