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

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