Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

496 строки
30 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. //int liTmp = -1;
  140. double ldTmp = -1;
  141. lsTmp = Util.ReadIniValue(configPath, "DEV", "Defect_SavePath_AutoClear");
  142. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  143. ldTmp = Convert.ToDouble(lsTmp);
  144. chkDefect_Path_AutoClear.Checked = (ldTmp > -1);
  145. if (ldTmp > -1) numDefect_Path_AutoClear.Value = (decimal)ldTmp;
  146. lsTmp = Util.ReadIniValue(configPath, "DEV", "Defect_Compress_SavePath_AutoClear");
  147. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  148. ldTmp = Convert.ToDouble(lsTmp);
  149. chkDefect_Compress_SavePath_AutoClear.Checked = (ldTmp > -1);
  150. if (ldTmp > -1) numDefect_Compress_SavePath_AutoClear.Value = (decimal)ldTmp;
  151. lsTmp = Util.ReadIniValue(configPath, "DEV", "Defect_Small_SavePath_AutoClear");
  152. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  153. ldTmp = Convert.ToDouble(lsTmp);
  154. chkDefect_Small_Path_AutoClear.Checked = (ldTmp > -1);
  155. if (ldTmp > -1) numDefect_Small_Path_AutoClear.Value = (decimal)ldTmp;
  156. this.chkSaveAllDefectImg.Checked= (Util.ReadIniValue(configPath, "DEV", "SaveAllDefectImg") == "1");
  157. this.chkMakeTag.Checked= (Util.ReadIniValue(configPath, "DEV", "MakeTag") == "1");
  158. this.txtSizeEnginePath.Text= Util.ReadIniValue(configPath, "DEV", "SizeEnginePath");
  159. this.txtSizeBmp_SavePath.Text = Util.ReadIniValue(configPath, "DEV", "SizeBmp_SavePath");
  160. this.txtSizeBmp_Compare_SavePath.Text = Util.ReadIniValue(configPath, "DEV", "SizeBmp_Compare_SavePath");
  161. this.txtSizeBmp_Zoom_Image_SavePath.Text = Util.ReadIniValue(configPath, "DEV", "SizeBmp_Zoom_Image_SavePath");
  162. lsTmp = Util.ReadIniValue(configPath, "DEV", "SizeBmp_SavePath_AutoClear");
  163. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  164. ldTmp = Convert.ToDouble(lsTmp);
  165. chkSizeBmp_SavePath_AutoClear.Checked = (ldTmp > -1);
  166. if (ldTmp > -1) numSizeBmp_SavePath_AutoClear.Value = (decimal)ldTmp;
  167. lsTmp = Util.ReadIniValue(configPath, "DEV", "SizeBmp_Compare_SavePath_AutoClear");
  168. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  169. ldTmp = Convert.ToDouble(lsTmp);
  170. chkSizeBmp_Compare_SavePath_AutoClear.Checked = (ldTmp > -1);
  171. if (ldTmp > -1) numSizeBmp_Compare_SavePath_AutoClear.Value = (decimal)ldTmp;
  172. lsTmp = Util.ReadIniValue(configPath, "DEV", "SizeBmp_Zoom_Image_SavePath_AutoClear");
  173. //if (Util.IsNumber(lsTmp)) liTmp = Convert.ToInt32(lsTmp);
  174. ldTmp = Convert.ToDouble(lsTmp);
  175. chkSizeBmp_Zoom_Image_SavePath_AutoClear.Checked = (ldTmp > -1);
  176. if (ldTmp > -1) numSizeBmp_Zoom_Image_SavePath_AutoClear.Value = (decimal)ldTmp;
  177. //线宽PT补偿
  178. lsTmp = Util.ReadIniValue(configPath, "DEV", "PT_Offset");
  179. if (string.IsNullOrWhiteSpace(lsTmp))
  180. this.numPToffset.Value = 0;
  181. else
  182. this.numPToffset.Value = (decimal)double.Parse(lsTmp);
  183. lsTmp = Util.ReadIniValue(configPath, "DEV", "LineWidth_Offset");
  184. if (string.IsNullOrWhiteSpace(lsTmp))
  185. this.numLineWidthoffset.Value = 0;
  186. else
  187. this.numLineWidthoffset.Value = (decimal)double.Parse(lsTmp);
  188. //DB
  189. this.txtDBCon.Text = Util.ReadIniValue(configPath, "DB", "DBConStr");
  190. //HTTP
  191. this.txtLocalIp.Text = Util.ReadIniValue(configPath, "HTTP", "LocalIp");
  192. lsTmp = Util.ReadIniValue(configPath, "HTTP", "LocalHttpPort");
  193. if (Util.IsNumber(lsTmp))this.numHttpPort.Value = Convert.ToInt32(lsTmp);
  194. //lsTmp = Util.ReadIniValue(configPath, "HTTP", "LocalSocketPort");
  195. //if (Util.IsNumber(lsTmp)) this.numSocketPort.Value = Convert.ToInt32(lsTmp);
  196. //LOG
  197. this.txtLogPath.Text = Util.ReadIniValue(configPath, "LOG", "LogPath");
  198. }
  199. private void tsbtnSave_Click(object sender, EventArgs e)
  200. {
  201. try
  202. {
  203. string configPath = Application.StartupPath + "\\SysConfig.ini";
  204. //DEV
  205. string lsLight_Name = this.cobLight_Name.Text.Trim();
  206. if (lsLight_Name == "")
  207. throw new Exception("请选择光源提供商!");
  208. LightDevNameEnum Light_Name = Utils.EnumUtil.Convert2Enum<LightDevNameEnum>(lsLight_Name);
  209. string Light_PortNum = this.cobLight_PortNum.Text.Trim();
  210. string Tension_PortNum = this.cobTension_PortNum.Text.Trim();
  211. decimal Tension_Offset = this.numOffset.Value;
  212. string SmallAxis_ComName = this.cobSmallAxis_ComName.Text.Trim();
  213. if (Light_PortNum == "" || Tension_PortNum == "" || SmallAxis_ComName == "")
  214. throw new Exception("请设置设备COM端口!");
  215. string HeightDev_IP = this.txtHeightDev_IP.Text;
  216. int HeightDev_Port = (int)this.numHeightDev_Port.Value;
  217. if(HeightDev_IP=="")
  218. throw new Exception("请设置厚度检测设备IP地址!");
  219. decimal HeightDev_SafeValue=this.numHeightDev_SafeValue.Value;
  220. string IOCard_DeviceNum = this.txtIO_DevNum.Text.Trim();
  221. if (IOCard_DeviceNum == "")
  222. throw new Exception("请设置I/O设备编号 !");
  223. string Defect_SavePath = this.txtDefect_Path.Text.Trim();
  224. if (Defect_SavePath == "")
  225. throw new Exception("请设置缺陷大图保存路径 !");
  226. string Defect_Compress_SavePath = this.txtDefect_Compress_SavePath.Text.Trim();
  227. if (Defect_Compress_SavePath == "")
  228. throw new Exception("请设置缺陷压缩大图保存路径 !");
  229. string Defect_Small_SavePath = this.txtDefect_Small_Path.Text.Trim();
  230. //if (Defect_Small_SavePath == "")
  231. // throw new Exception("请设置缺陷小图保存路径 !");
  232. //DB
  233. string DBConStr = this.txtDBCon.Text.Trim();
  234. if (DBConStr == "")
  235. throw new Exception("请设置DB连接字符串 !");
  236. //LOG
  237. string LogPath = this.txtLogPath.Text.Trim();
  238. if (LogPath == "")
  239. throw new Exception("请设置日志保存路径 !");
  240. //最后统一保存
  241. //Skip
  242. Util.WriteIniValue(configPath, "SKIP", "SkipAxis0", this.chkSkipAxis0.Checked ? "1" : "0");
  243. Util.WriteIniValue(configPath, "SKIP", "SkipAxis1", this.chkSkipAxis1.Checked ? "1" : "0");
  244. Util.WriteIniValue(configPath, "SKIP", "SkipAxis2", this.chkSkipAxis2.Checked ? "1" : "0");
  245. Util.WriteIniValue(configPath, "SKIP", "SkipAxis3", this.chkSkipAxis3.Checked ? "1" : "0");
  246. Util.WriteIniValue(configPath, "SKIP", "SkipTension", this.chkSkipTension.Checked ? "1" : "0");
  247. Util.WriteIniValue(configPath, "SKIP", "SkipHeight", this.chkSkipHeight.Checked ? "1" : "0");
  248. Util.WriteIniValue(configPath, "SKIP", "SkipLight", this.chkSkipLight.Checked ? "1" : "0");
  249. Util.WriteIniValue(configPath, "SKIP", "SkipScannerGL", this.chkSkipScannerGL.Checked ? "1" : "0");
  250. Util.WriteIniValue(configPath, "SKIP", "SkipScannerCC", this.chkSkipScannerCC.Checked ? "1" : "0");
  251. Util.WriteIniValue(configPath, "SKIP", "SkipSmallAxis", this.chkSkipSmallAxis.Checked ? "1" : "0");
  252. Util.WriteIniValue(configPath, "SKIP", "MarkErrorStop", this.ckSkipSizeFailed.Checked ? "1" : "0");
  253. Util.WriteIniValue(configPath, "SKIP", "OpenFlawDistribution", this.cbOpenFlawDistribution.Checked ? "1" : "0");
  254. Util.WriteIniValue(configPath, "SKIP", "OpenAxisXCalibration", this.cbOpenAxisXCal.Checked ? "1" : "0");
  255. //DEV
  256. Utils.Util.WriteIniValue(configPath, "DEV", "Axis0_PulseOutMode", ((int)EnumUtil.GetSelectedItemToEnum<AxisPulseOutMode>(this.cobAxis0PulseOutMode)).ToString());
  257. Utils.Util.WriteIniValue(configPath, "DEV", "Axis1_PulseOutMode", ((int)EnumUtil.GetSelectedItemToEnum<AxisPulseOutMode>(this.cobAxis1PulseOutMode)).ToString());
  258. Utils.Util.WriteIniValue(configPath, "DEV", "Axis2_PulseOutMode", ((int)EnumUtil.GetSelectedItemToEnum<AxisPulseOutMode>(this.cobAxis2PulseOutMode)).ToString());
  259. Utils.Util.WriteIniValue(configPath, "DEV", "Axis3_PulseOutMode", ((int)EnumUtil.GetSelectedItemToEnum<AxisPulseOutMode>(this.cobAxis3PulseOutMode)).ToString());
  260. Utils.Util.WriteIniValue(configPath, "DEV", "Axis0_HomeMode", ((int)EnumUtil.GetSelectedItemToEnum<AxitHomeMode>(this.cobAxis0HomeMode)).ToString());
  261. Utils.Util.WriteIniValue(configPath, "DEV", "Axis1_HomeMode", ((int)EnumUtil.GetSelectedItemToEnum<AxitHomeMode>(this.cobAxis1HomeMode)).ToString());
  262. Utils.Util.WriteIniValue(configPath, "DEV", "Axis2_HomeMode", ((int)EnumUtil.GetSelectedItemToEnum<AxitHomeMode>(this.cobAxis2HomeMode)).ToString());
  263. Utils.Util.WriteIniValue(configPath, "DEV", "Axis3_HomeMode", ((int)EnumUtil.GetSelectedItemToEnum<AxitHomeMode>(this.cobAxis3HomeMode)).ToString());
  264. Utils.Util.WriteIniValue(configPath, "DEV", "Axis0_HomeDir", this.cobAxis0HomeDir.SelectedIndex.ToString());
  265. Utils.Util.WriteIniValue(configPath, "DEV", "Axis1_HomeDir", this.cobAxis1HomeDir.SelectedIndex.ToString());
  266. Utils.Util.WriteIniValue(configPath, "DEV", "Axis2_HomeDir", this.cobAxis2HomeDir.SelectedIndex.ToString());
  267. Utils.Util.WriteIniValue(configPath, "DEV", "Axis3_HomeDir", this.cobAxis3HomeDir.SelectedIndex.ToString());
  268. JArray HeightDev_BaseList = new JArray()
  269. {
  270. numHeightBase0.Value,numHeightBase1.Value,numHeightBase2.Value,numHeightBase3.Value,numHeightBase4.Value
  271. };
  272. Utils.Util.WriteIniValue(configPath, "DEV", "HeightDev_BaseList", HeightDev_BaseList.ToString().Replace("\r\n", ""));
  273. Utils.Util.WriteIniValue(configPath, "DEV", "Light_Name", ""+(int)Light_Name);
  274. Utils.Util.WriteIniValue(configPath, "DEV", "Light_PortNum", Light_PortNum.Substring(3));
  275. Utils.Util.WriteIniValue(configPath, "DEV", "Tension_PortNum", Tension_PortNum.Substring(3));
  276. Utils.Util.WriteIniValue(configPath, "DEV", "Tension_Offset", Tension_Offset.ToString());
  277. Utils.Util.WriteIniValue(configPath, "DEV", "SmallAxis_ComName", SmallAxis_ComName);
  278. Utils.Util.WriteIniValue(configPath, "DEV", "HeightDev_IP", HeightDev_IP);
  279. Utils.Util.WriteIniValue(configPath, "DEV", "HeightDev_Port", HeightDev_Port.ToString());
  280. Utils.Util.WriteIniValue(configPath, "DEV", "HeightDev_SafeValue", HeightDev_SafeValue.ToString());
  281. JArray Axis_HomeVelLow = new JArray()
  282. {
  283. numAxis0HomeVelLow.Value,numAxis1HomeVelLow.Value,numAxis2HomeVelLow.Value,numAxis3HomeVelLow.Value
  284. };
  285. Utils.Util.WriteIniValue(configPath, "DEV", "Axis_HomeVelLow", Axis_HomeVelLow.ToString().Replace("\r\n",""));
  286. JArray Axis_HomeVelHigh = new JArray()
  287. {
  288. numAxis0HomeVelHigh.Value,numAxis1HomeVelHigh.Value,numAxis2HomeVelHigh.Value,numAxis3HomeVelHigh.Value
  289. };
  290. Utils.Util.WriteIniValue(configPath, "DEV", "Axis_HomeVelHigh", Axis_HomeVelHigh.ToString().Replace("\r\n", ""));
  291. JArray Axis_HomeAcc = new JArray()
  292. {
  293. numAxis0HomeAcc.Value,numAxis1HomeAcc.Value,numAxis2HomeAcc.Value,numAxis3HomeAcc.Value
  294. };
  295. Utils.Util.WriteIniValue(configPath, "DEV", "Axis_HomeAcc", Axis_HomeAcc.ToString().Replace("\r\n", ""));
  296. JArray Axis_HomeDec = new JArray()
  297. {
  298. numAxis0HomeDec.Value,numAxis1HomeDec.Value,numAxis2HomeDec.Value,numAxis3HomeDec.Value
  299. };
  300. Utils.Util.WriteIniValue(configPath, "DEV", "Axis_HomeDec", Axis_HomeDec.ToString().Replace("\r\n", ""));
  301. Utils.Util.WriteIniValue(configPath, "DEV", "IOCard_DeviceNum", IOCard_DeviceNum);
  302. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_SavePath", Defect_SavePath);
  303. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_SavePath_AutoClear", (chkDefect_Path_AutoClear.Checked ? (double)numDefect_Path_AutoClear.Value : -1)+"");
  304. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_Compress_SavePath", Defect_Compress_SavePath);
  305. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_Compress_SavePath_AutoClear", (chkDefect_Compress_SavePath_AutoClear.Checked ? (double)numDefect_Compress_SavePath_AutoClear.Value : -1) + "");
  306. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_Small_SavePath", Defect_Small_SavePath);
  307. Utils.Util.WriteIniValue(configPath, "DEV", "Defect_Small_SavePath_AutoClear", (chkDefect_Small_Path_AutoClear.Checked ? (double)numDefect_Small_Path_AutoClear.Value : -1) + "");
  308. Utils.Util.WriteIniValue(configPath, "DEV", "SaveAllDefectImg", this.chkSaveAllDefectImg.Checked ? "1" : "0");
  309. Utils.Util.WriteIniValue(configPath, "DEV", "MakeTag", this.chkMakeTag.Checked ? "1" : "0");
  310. Utils.Util.WriteIniValue(configPath, "DEV", "SizeEnginePath", this.txtSizeEnginePath.Text.Trim());
  311. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_SavePath", this.txtSizeBmp_SavePath.Text.Trim());
  312. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_SavePath_AutoClear", (chkSizeBmp_SavePath_AutoClear.Checked ? (double)numSizeBmp_SavePath_AutoClear.Value : -1) + "");
  313. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_Compare_SavePath", this.txtSizeBmp_Compare_SavePath.Text.Trim());
  314. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_Compare_SavePath_AutoClear", (chkSizeBmp_Compare_SavePath_AutoClear.Checked ? (double)numSizeBmp_Compare_SavePath_AutoClear.Value : -1) + "");
  315. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_Zoom_Image_SavePath", this.txtSizeBmp_Zoom_Image_SavePath.Text.Trim());
  316. Utils.Util.WriteIniValue(configPath, "DEV", "SizeBmp_Zoom_Image_SavePath_AutoClear", (chkSizeBmp_Zoom_Image_SavePath_AutoClear.Checked ? (double)numSizeBmp_Zoom_Image_SavePath_AutoClear.Value : -1) + "");
  317. decimal PT_Offset = this.numPToffset.Value;
  318. decimal LW_Offset = this.numLineWidthoffset.Value;
  319. Utils.Util.WriteIniValue(configPath, "DEV", "PT_Offset", PT_Offset.ToString());
  320. Utils.Util.WriteIniValue(configPath, "DEV", "LineWidth_Offset", LW_Offset.ToString());
  321. //DB
  322. Utils.Util.WriteIniValue(configPath, "DB", "DBConStr", DBConStr);
  323. //HTTP
  324. Utils.Util.WriteIniValue(configPath, "HTTP", "LocalIp",this.txtLocalIp.Text.Trim());
  325. Utils.Util.WriteIniValue(configPath, "HTTP", "LocalHttpPort", this.numHttpPort.Value.ToString());
  326. //LOG
  327. Utils.Util.WriteIniValue(configPath, "LOG", "LogPath", LogPath);
  328. //
  329. this.Hide();
  330. MessageBox.Show("保存成功,生效需重启程序!");
  331. this.Close();
  332. }
  333. catch (Exception ex)
  334. {
  335. MessageBox.Show(ex.Message, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
  336. }
  337. }
  338. private void tsbtnClose_Click(object sender, EventArgs e)
  339. {
  340. this.Close();
  341. }
  342. private void txtDefect_Path_Click(object sender, EventArgs e)
  343. {
  344. string path = FileUtil.selectFolder(Application.StartupPath);
  345. if (!string.IsNullOrWhiteSpace(path))
  346. this.txtDefect_Path.Text = path;
  347. }
  348. private void txtLogPath_Click(object sender, EventArgs e)
  349. {
  350. string path = FileUtil.selectFolder(Application.StartupPath);
  351. if (!string.IsNullOrWhiteSpace(path))
  352. this.txtLogPath.Text = path;
  353. }
  354. private void txtSizeEnginePath_Click(object sender, EventArgs e)
  355. {
  356. string path = FileUtil.selectFolder(Application.StartupPath);
  357. if (!string.IsNullOrWhiteSpace(path))
  358. this.txtSizeEnginePath.Text = path;
  359. }
  360. private void txtSizeBmp_Path_Click(object sender, EventArgs e)
  361. {
  362. string path = FileUtil.selectFolder(Application.StartupPath);
  363. if (!string.IsNullOrWhiteSpace(path))
  364. this.txtSizeBmp_SavePath.Text = path;
  365. }
  366. private void txtSizeBmp_Compare_SavePath_Click(object sender, EventArgs e)
  367. {
  368. string path = FileUtil.selectFolder(Application.StartupPath);
  369. if (!string.IsNullOrWhiteSpace(path))
  370. this.txtSizeBmp_Compare_SavePath.Text = path;
  371. }
  372. private void txtSizeBmp_Zoom_Image_SavePath_Click(object sender, EventArgs e)
  373. {
  374. string path = FileUtil.selectFolder(Application.StartupPath);
  375. if (!string.IsNullOrWhiteSpace(path))
  376. this.txtSizeBmp_Zoom_Image_SavePath.Text = path;
  377. }
  378. private void txtDefect_Small_Path_Click(object sender, EventArgs e)
  379. {
  380. string path = FileUtil.selectFolder(Application.StartupPath);
  381. if (!string.IsNullOrWhiteSpace(path))
  382. this.txtDefect_Small_Path.Text = path;
  383. }
  384. private void txtDefect_Compress_SavePath_Click(object sender, EventArgs e)
  385. {
  386. string path = FileUtil.selectFolder(Application.StartupPath);
  387. if (!string.IsNullOrWhiteSpace(path))
  388. this.txtDefect_Compress_SavePath.Text = path;
  389. }
  390. private void btnClearDefect_Small_Path_Click(object sender, EventArgs e)
  391. {
  392. this.txtDefect_Small_Path.Text = "";
  393. }
  394. private void btnClearDefect_Path_Click(object sender, EventArgs e)
  395. {
  396. this.txtDefect_Path.Text = "";
  397. }
  398. private void btnClearDefect_Compress_SavePath_Click(object sender, EventArgs e)
  399. {
  400. txtDefect_Compress_SavePath.Text = "";
  401. }
  402. private void btnClearSizeBmp_Path_Click(object sender, EventArgs e)
  403. {
  404. txtSizeBmp_SavePath.Text = "";
  405. }
  406. private void btnClearSizeBmp_Compare_SavePath_Click(object sender, EventArgs e)
  407. {
  408. txtSizeBmp_Compare_SavePath.Text = "";
  409. }
  410. private void btnSizeBmp_Zoom_Image_SavePath_Click(object sender, EventArgs e)
  411. {
  412. txtSizeBmp_Zoom_Image_SavePath.Text = "";
  413. }
  414. private void btnBackDB_Click(object sender, EventArgs e)
  415. {
  416. try
  417. {
  418. string lsPath=Utils.FileUtil.selectFolder();
  419. if (string.IsNullOrWhiteSpace(lsPath))
  420. return;
  421. lsPath += "\\DB" + DateTime.Now.ToString("yyyyMMddHHmm") + ".bak";
  422. Service.InitDB.BackupDataBase(lsPath);
  423. MessageBox.Show("备份成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
  424. }
  425. catch (Exception ex)
  426. {
  427. MessageBox.Show(ex.Message, "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
  428. }
  429. }
  430. private void chkMakeTag_CheckedChanged(object sender, EventArgs e)
  431. {
  432. }
  433. }
  434. }