ExportForm.cs 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Runtime.Serialization.Formatters.Binary;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using System.Xml.Serialization;
  11. using System.Text.RegularExpressions;
  12. using System.Net;
  13. using System.Reflection;
  14. using NPOI;
  15. using NPOI.SS.UserModel;
  16. using NPOI.HSSF.UserModel;
  17. using Spire.Xls;
  18. using Workbook = Spire.Xls.Workbook;
  19. namespace MOTINOVA_Motor_Factory_Set
  20. {
  21. public partial class ExportForm : Form
  22. {
  23. //参数按照字典类型存储
  24. Dictionary<string, UInt16> Params1 = new Dictionary<string, UInt16>();
  25. Dictionary<string, UInt16> Params2 = new Dictionary<string, UInt16>();
  26. Dictionary<string, UInt16> MotorParam = new Dictionary<string, UInt16>();
  27. Dictionary<string, string> Otherinfo = new Dictionary<string, string>();
  28. Dictionary<string, UInt16> TestThData = new Dictionary<string, ushort>();
  29. Dictionary<string, string> MarkInfo = new Dictionary<string, string>();
  30. //文件路径
  31. public string FilePath = "";
  32. public ExportForm()
  33. {
  34. InitializeComponent();
  35. }
  36. private void ExportForm_Load(object sender, EventArgs e)
  37. {
  38. }
  39. private void SetDefault()
  40. {
  41. //参数1
  42. Params1.Clear();
  43. Params1.Add("启动模式", 2);
  44. Params1.Add("停机时间", 100);
  45. Params1.Add("限速值", 25);
  46. Params1.Add("下降速度", 3);
  47. Params1.Add("前飞", 14);
  48. Params1.Add("后飞", 9);
  49. Params1.Add("限流", 15);
  50. Params1.Add("温度预警", 95);
  51. Params1.Add("温度保护", 125);
  52. Params1.Add("码表", 0x55);//有,不支持无码表
  53. Params1.Add("轮胎周长", 219);//cm
  54. Params1.Add("系列号", 0);
  55. Params1.Add("ECO增益", 100);//放大100倍
  56. Params1.Add("ECO加速", 100);
  57. Params1.Add("NORM增益", 100);
  58. Params1.Add("NORM加速", 100);
  59. Params1.Add("SPORT增益", 100);
  60. Params1.Add("SPORT加速", 100);
  61. Params1.Add("TURBO增益", 100);
  62. Params1.Add("TURBO加速", 100);
  63. Params1.Add("SMART增益", 100);
  64. Params1.Add("SMART加速", 100);
  65. Params1.Add("车速级数", 1);
  66. Params1.Add("踏频启动", 2);
  67. Params1.Add("指拨模式", 0x55);
  68. Params1.Add("速度信号来源", 0x55);//传感器
  69. Params1.Add("周长微调", 0);
  70. Params1.Add("低压保护", 3000);//mV
  71. Params1.Add("推行限速", 60);//放大10倍
  72. Params1.Add("推行转速", 135);
  73. //参数2
  74. Params2.Clear();
  75. Params2.Add("姿态传感器", 0x55);//不支持
  76. Params2.Add("俯仰角零偏", 0);
  77. Params2.Add("横滚角零偏", 0);
  78. Params2.Add("尾灯模式", 2);
  79. Params2.Add("前灯电压", 12);
  80. Params2.Add("尾灯电压", 12);
  81. Params2.Add("报警阈值", 150);//放大10倍
  82. Params2.Add("尾灯脉宽", 70);
  83. Params2.Add("尾灯周期", 150);
  84. //马达参数
  85. MotorParam.Clear();
  86. MotorParam.Add("额定功率", 250);
  87. MotorParam.Add("空载转速", 1200);
  88. MotorParam.Add("定子电阻", 10);
  89. MotorParam.Add("定子Lq", 10);
  90. MotorParam.Add("定子Ld", 10);
  91. MotorParam.Add("反电动势", 36000);
  92. MotorParam.Add("额定电压", 36);
  93. //其它信息
  94. Otherinfo.Clear();
  95. Otherinfo.Add("生产商", "TTIUM");
  96. Otherinfo.Add("生产地", "WUHAN");
  97. Otherinfo.Add("生产日期", DateTime.Now.ToString("yyyyMMdd"));
  98. Otherinfo.Add("校验密钥", "AVONITOM");
  99. Otherinfo.Add("信息1", "");
  100. Otherinfo.Add("信息2", "");
  101. Otherinfo.Add("信息3", "");
  102. //测试阈值
  103. TestThData.Clear();
  104. TestThData.Add("空载电流", 1000);
  105. TestThData.Add("车速", 150);
  106. TestThData.Add("指拨转速", 1225);
  107. TestThData.Add("零偏最小值", 100);
  108. TestThData.Add("零偏最大值", 1800);
  109. TestThData.Add("标定系数最小值", 25);
  110. TestThData.Add("标定系数最大值", 75);
  111. TestThData.Add("启动值最小值", 350);
  112. TestThData.Add("启动值最大值", 750);
  113. //其它测试备注信息
  114. MarkInfo.Clear();
  115. MarkInfo.Add("PCBA版号", "");
  116. }
  117. private void ParamsDisplayUpdate()
  118. {
  119. //参数1
  120. comboBox_StartMode.SelectedIndex = Params1["启动模式"] - 1;
  121. textBox_StopTime.Text = Params1["停机时间"].ToString();
  122. textBox_SpeedLimit.Text = Params1["限速值"].ToString();
  123. textBox_Dec.Text = Params1["下降速度"].ToString();
  124. textBox_T_Front.Text = Params1["前飞"].ToString();
  125. textBox_T_Tail.Text = Params1["后飞"].ToString();
  126. textBox_MaxCurrent.Text = Params1["限流"].ToString();
  127. textBox_NTC_Alarm.Text = Params1["温度预警"].ToString();
  128. textBox_NTC_Ptotect.Text = Params1["温度保护"].ToString();
  129. if (Params1["码表"] == 0x55)
  130. {
  131. comboBox_NoPBU.SelectedIndex = 1;
  132. }
  133. else if (Params1["码表"] == 0xAA)
  134. {
  135. comboBox_NoPBU.SelectedIndex = 0;
  136. }
  137. textBox_WheelSize.Text = Params1["轮胎周长"].ToString();
  138. textBox_Serial.Text = Params1["系列号"].ToString();
  139. textBox_ECO_Gain.Text = ((float)(Params1["ECO增益"]) / 100.0f).ToString("#0.00");
  140. textBox_ECO_Acc.Text = ((float)(Params1["ECO加速"]) / 100.0f).ToString("#0.00");
  141. textBox_NORM_Gain.Text = ((float)(Params1["NORM增益"]) / 100.0f).ToString("#0.00");
  142. textBox_NORM_Acc.Text = ((float)(Params1["NORM加速"]) / 100.0f).ToString("#0.00");
  143. textBox_SPORT_Gain.Text = ((float)(Params1["SPORT增益"]) / 100.0f).ToString("#0.00");
  144. textBox_SPORT_Acc.Text = ((float)(Params1["SPORT加速"]) / 100.0f).ToString("#0.00");
  145. textBox_TURBO_Gain.Text = ((float)(Params1["TURBO增益"]) / 100.0f).ToString("#0.00");
  146. textBox_TURBO_Acc.Text = ((float)(Params1["TURBO加速"]) / 100.0f).ToString("#0.00");
  147. textBox_SMART_Gain.Text = ((float)(Params1["SMART增益"]) / 100.0f).ToString("#0.00");
  148. textBox_SMART_Acc.Text = ((float)(Params1["SMART加速"]) / 100.0f).ToString("#0.00");
  149. textBox_SpeedSensor.Text = Params1["车速级数"].ToString();
  150. textBox_CadenceStart.Text = Params1["踏频启动"].ToString();
  151. if (Params1["指拨模式"] == 0x55)
  152. {
  153. comboBox_GasMode.SelectedIndex = 0;
  154. }
  155. else if (Params1["指拨模式"] == 0xAA)
  156. {
  157. comboBox_GasMode.SelectedIndex = 1;
  158. }
  159. if (Params1["速度信号来源"] == 0x55)
  160. {
  161. comboBox_SpeedSensor.SelectedIndex = 0;
  162. }
  163. else if (Params1["速度信号来源"] == 0xAA)
  164. {
  165. comboBox_SpeedSensor.SelectedIndex = 1;
  166. }
  167. else if (Params1["速度信号来源"] == 0xEE)
  168. {
  169. comboBox_SpeedSensor.SelectedIndex = 2;
  170. }
  171. textBox_WheelSizeAdj.Text = Params1["周长微调"].ToString();
  172. textBox_UV_Protect.Text = Params1["低压保护"].ToString();
  173. textBox_Walk_SpeedLimit.Text = ((float)(Params1["推行限速"]) / 10.0f).ToString("#0.0");
  174. textBox_WalkSpeed.Text = Params1["推行转速"].ToString();
  175. //参数2
  176. if (Params2["姿态传感器"] == 0x55)
  177. {
  178. comboBox_AstSensor.SelectedIndex = 0;
  179. }
  180. else if (Params1["姿态传感器"] == 0xAA)
  181. {
  182. comboBox_AstSensor.SelectedIndex = 1;
  183. }
  184. textBox_Angle_P.Text = ((float)(Params2["俯仰角零偏"]) / 10.0f).ToString("#0.0");
  185. textBox_Angle_R.Text = ((float)(Params2["横滚角零偏"]) / 10.0f).ToString("#0.0");
  186. comboBox_LightMode.SelectedIndex = Params2["尾灯模式"] - 1;
  187. if (Params2["前灯电压"] == 6)
  188. {
  189. comboBox_HeadLightVol.SelectedIndex = 0;
  190. }
  191. else if (Params2["前灯电压"] == 12)
  192. {
  193. comboBox_HeadLightVol.SelectedIndex = 1;
  194. }
  195. else if (Params2["前灯电压"] == 0xFF)
  196. {
  197. comboBox_HeadLightVol.SelectedIndex = 2;
  198. }
  199. else if (Params2["前灯电压"] == 0)
  200. {
  201. comboBox_HeadLightVol.SelectedIndex = 3;
  202. }
  203. if (Params2["尾灯电压"] == 6)
  204. {
  205. comboBox_TailLightVol.SelectedIndex = 0;
  206. }
  207. else if (Params2["尾灯电压"] == 12)
  208. {
  209. comboBox_TailLightVol.SelectedIndex = 1;
  210. }
  211. else if (Params2["尾灯电压"] == 0xFF)
  212. {
  213. comboBox_TailLightVol.SelectedIndex = 2;
  214. }
  215. else if (Params2["尾灯电压"] == 0)
  216. {
  217. comboBox_TailLightVol.SelectedIndex = 3;
  218. }
  219. textBox_AlarmSpeed.Text = ((float)(Params2["报警阈值"]) / 10.0f).ToString("#0.0");
  220. textBox_LightPluse.Text = Params2["尾灯脉宽"].ToString();
  221. textBox_LightPeriod.Text = Params2["尾灯周期"].ToString();
  222. //马达参数
  223. textBox_RatePower.Text = MotorParam["额定功率"].ToString();
  224. textBox_RateSpeed.Text = MotorParam["空载转速"].ToString();
  225. textBox_RotorR.Text = MotorParam["定子电阻"].ToString();
  226. textBox_Rotor_Lq.Text = MotorParam["定子Lq"].ToString();
  227. textBox_Rotor_Ld.Text = MotorParam["定子Ld"].ToString();
  228. textBox_E.Text = MotorParam["反电动势"].ToString();
  229. textBox_Rate_Vol.Text = MotorParam["额定电压"].ToString();
  230. //其它信息
  231. textBox_Mac.Text = Otherinfo["生产商"].ToString();
  232. textBox_Mac_Addr.Text = Otherinfo["生产地"].ToString();
  233. textBox_Mac_Date.Text = Otherinfo["生产日期"].ToString();
  234. textBox_Secrect.Text = Otherinfo["校验密钥"].ToString();
  235. textBox_Info1.Text = Otherinfo["信息1"].ToString();
  236. textBox_Info2.Text = Otherinfo["信息2"].ToString();
  237. textBox_Info3.Text = Otherinfo["信息3"].ToString();
  238. //测试阈值
  239. textBox_NC_Current.Text = TestThData["空载电流"].ToString();
  240. textBox_SpeedTh.Text = TestThData["车速"].ToString();
  241. textBox_GasSpeedTh.Text = TestThData["指拨转速"].ToString();
  242. textBox_Zero_Min.Text = TestThData["零偏最小值"].ToString();
  243. textBox_Zero_Max.Text = TestThData["零偏最大值"].ToString();
  244. textBox_K_Min.Text = ((float)(TestThData["标定系数最小值"]) / 100.0f).ToString("#0.00");
  245. textBox_K_Max.Text = ((float)(TestThData["标定系数最大值"]) / 100.0f).ToString("#0.00");
  246. textBox_Start_Min.Text = TestThData["启动值最小值"].ToString();
  247. textBox_Start_Max.Text = TestThData["启动值最大值"].ToString();
  248. //其它测试备注信息
  249. textBox_HW_Version.Text = MarkInfo["PCBA版号"];
  250. }
  251. private bool DisplaySetToParams()
  252. {
  253. try
  254. {
  255. //参数1
  256. Params1.Clear();
  257. if (comboBox_StartMode.Text == "柔和")
  258. {
  259. Params1.Add("启动模式", 1);
  260. }
  261. else if (comboBox_StartMode.Text == "正常")
  262. {
  263. Params1.Add("启动模式", 2);
  264. }
  265. else if (comboBox_StartMode.Text == "强劲")
  266. {
  267. Params1.Add("启动模式", 3);
  268. }
  269. else
  270. {
  271. MessageBox.Show("请检查启动模式设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  272. return false;
  273. }
  274. Params1.Add("停机时间", Convert.ToUInt16(textBox_StopTime.Text));
  275. if (Params1["停机时间"] < 50 || Params1["停机时间"] > 500)
  276. {
  277. MessageBox.Show("停机时间有效值:50~500 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  278. return false;
  279. }
  280. Params1.Add("限速值", Convert.ToUInt16(textBox_SpeedLimit.Text));
  281. if (Params1["限速值"] < 5 || Params1["限速值"] > 120)
  282. {
  283. MessageBox.Show("限速值有效值:5~120 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  284. return false;
  285. }
  286. Params1.Add("下降速度", Convert.ToUInt16(textBox_Dec.Text));
  287. if (Params1["下降速度"] < 1 || Params1["下降速度"] > 5)
  288. {
  289. MessageBox.Show("下降速度有效值:1~5 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  290. return false;
  291. }
  292. Params1.Add("前飞", Convert.ToUInt16(textBox_T_Front.Text));
  293. if (Params1["前飞"] < 5 || Params1["前飞"] > 100)
  294. {
  295. MessageBox.Show("前飞有效值:5~100 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  296. return false;
  297. }
  298. Params1.Add("后飞", Convert.ToUInt16(textBox_T_Tail.Text));
  299. if (Params1["后飞"] < 5 || Params1["后飞"] > 100)
  300. {
  301. MessageBox.Show("后飞有效值:5~100 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  302. return false;
  303. }
  304. Params1.Add("限流", Convert.ToUInt16(textBox_MaxCurrent.Text));
  305. if (Params1["限流"] < 5 || Params1["限流"] > 25)
  306. {
  307. MessageBox.Show("限流有效值:5~25 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  308. return false;
  309. }
  310. Params1.Add("温度预警", Convert.ToUInt16(textBox_NTC_Alarm.Text));
  311. Params1.Add("温度保护", Convert.ToUInt16(textBox_NTC_Ptotect.Text));
  312. if (comboBox_NoPBU.Text == "有")
  313. {
  314. Params1.Add("码表", 0x55);
  315. }
  316. else if (comboBox_NoPBU.Text == "无")
  317. {
  318. Params1.Add("码表", 0xAA);
  319. }
  320. else
  321. {
  322. MessageBox.Show("请检查无码表设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  323. return false;
  324. }
  325. Params1.Add("轮胎周长", Convert.ToUInt16(textBox_WheelSize.Text));
  326. if (Params1["轮胎周长"] < 80 || Params1["轮胎周长"] > 250)
  327. {
  328. MessageBox.Show("轮胎周长有效值:80~250 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  329. return false;
  330. }
  331. Params1.Add("系列号", Convert.ToUInt16(textBox_Serial.Text));
  332. if (Params1["系列号"] < 1 || Params1["系列号"] > 16)
  333. {
  334. MessageBox.Show("系列号有效值:1~16 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  335. return false;
  336. }
  337. Params1.Add("ECO增益", Convert.ToUInt16(float.Parse(textBox_ECO_Gain.Text) * 100));//放大100倍
  338. Params1.Add("ECO加速", Convert.ToUInt16(float.Parse(textBox_ECO_Acc.Text) * 100));
  339. Params1.Add("NORM增益", Convert.ToUInt16(float.Parse(textBox_NORM_Gain.Text) * 100));
  340. Params1.Add("NORM加速", Convert.ToUInt16(float.Parse(textBox_NORM_Acc.Text) * 100));
  341. Params1.Add("SPORT增益", Convert.ToUInt16(float.Parse(textBox_SPORT_Gain.Text) * 100));
  342. Params1.Add("SPORT加速", Convert.ToUInt16(float.Parse(textBox_SPORT_Acc.Text) * 100));
  343. Params1.Add("TURBO增益", Convert.ToUInt16(float.Parse(textBox_TURBO_Gain.Text) * 100));
  344. Params1.Add("TURBO加速", Convert.ToUInt16(float.Parse(textBox_TURBO_Acc.Text) * 100));
  345. Params1.Add("SMART增益", Convert.ToUInt16(float.Parse(textBox_SMART_Gain.Text) * 100));
  346. Params1.Add("SMART加速", Convert.ToUInt16(float.Parse(textBox_SMART_Acc.Text) * 100));
  347. Params1.Add("车速级数", Convert.ToUInt16(textBox_SpeedSensor.Text));
  348. Params1.Add("踏频启动", Convert.ToUInt16(textBox_CadenceStart.Text));
  349. if (comboBox_GasMode.Text == "不支持")
  350. {
  351. Params1.Add("指拨模式", 0x55);
  352. }
  353. else if (comboBox_GasMode.Text == "支持")
  354. {
  355. Params1.Add("指拨模式", 0xAA);
  356. }
  357. else
  358. {
  359. MessageBox.Show("请检查指拨模式设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  360. return false;
  361. }
  362. if (comboBox_SpeedSensor.Text == "传感器")
  363. {
  364. Params1.Add("速度信号来源", 0x55);
  365. }
  366. else if (comboBox_SpeedSensor.Text == "踏频")
  367. {
  368. Params1.Add("速度信号来源", 0xAA);
  369. }
  370. else if (comboBox_SpeedSensor.Text == "通信")
  371. {
  372. Params1.Add("速度信号来源", 0xEE);
  373. }
  374. else
  375. {
  376. MessageBox.Show("请检查速度信号来源设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  377. return false;
  378. }
  379. Params1.Add("周长微调", Convert.ToUInt16(textBox_WheelSizeAdj.Text));
  380. Params1.Add("低压保护", Convert.ToUInt16(textBox_UV_Protect.Text));//mV
  381. Params1.Add("推行限速", Convert.ToUInt16(float.Parse(textBox_Walk_SpeedLimit.Text) * 10));//放大10倍
  382. Params1.Add("推行转速", Convert.ToUInt16(textBox_WalkSpeed.Text));
  383. //参数2
  384. Params2.Clear();
  385. if (comboBox_AstSensor.Text == "不支持")
  386. {
  387. Params2.Add("姿态传感器", 0x55);
  388. }
  389. else if (comboBox_AstSensor.Text == "支持")
  390. {
  391. Params2.Add("姿态传感器", 0xAA);
  392. }
  393. else
  394. {
  395. MessageBox.Show("请检查姿态传感器设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  396. return false;
  397. }
  398. Params2.Add("俯仰角零偏", Convert.ToUInt16(float.Parse(textBox_Angle_P.Text) * 10));
  399. Params2.Add("横滚角零偏", Convert.ToUInt16(float.Parse(textBox_Angle_R.Text) * 10));
  400. if (comboBox_LightMode.Text == "模式 1")
  401. {
  402. Params2.Add("尾灯模式", 1);
  403. }
  404. else if(comboBox_LightMode.Text == "模式 2")
  405. {
  406. Params2.Add("尾灯模式", 2);
  407. }
  408. else if (comboBox_LightMode.Text == "模式 3")
  409. {
  410. Params2.Add("尾灯模式", 3);
  411. }
  412. else if (comboBox_LightMode.Text == "模式 4")
  413. {
  414. Params2.Add("尾灯模式", 4);
  415. }
  416. else if (comboBox_LightMode.Text == "模式 5")
  417. {
  418. Params2.Add("尾灯模式", 5);
  419. }
  420. else if (comboBox_LightMode.Text == "模式 6")
  421. {
  422. Params2.Add("尾灯模式", 6);
  423. }
  424. if (comboBox_HeadLightVol.Text == "6V")
  425. {
  426. Params2.Add("前灯电压", 6);
  427. }
  428. else if (comboBox_HeadLightVol.Text == "12V")
  429. {
  430. Params2.Add("前灯电压", 12);
  431. }
  432. else if (comboBox_HeadLightVol.Text == "随电池")
  433. {
  434. Params2.Add("前灯电压", 0xFF);
  435. }
  436. else if (comboBox_HeadLightVol.Text == "硬件配置")
  437. {
  438. Params2.Add("前灯电压", 0);
  439. }
  440. if (comboBox_TailLightVol.Text == "6V")
  441. {
  442. Params2.Add("尾灯电压", 6);
  443. }
  444. else if (comboBox_TailLightVol.Text == "12V")
  445. {
  446. Params2.Add("尾灯电压", 12);
  447. }
  448. else if (comboBox_TailLightVol.Text == "随电池")
  449. {
  450. Params2.Add("尾灯电压", 0xFF);
  451. }
  452. else if (comboBox_TailLightVol.Text == "硬件配置")
  453. {
  454. Params2.Add("尾灯电压", 0);
  455. }
  456. Params2.Add("报警阈值", Convert.ToUInt16(float.Parse(textBox_AlarmSpeed.Text) * 10));//放大10倍
  457. Params2.Add("尾灯脉宽", Convert.ToUInt16(textBox_LightPluse.Text));
  458. Params2.Add("尾灯周期", Convert.ToUInt16(textBox_LightPeriod.Text));
  459. //马达参数
  460. MotorParam.Clear();
  461. MotorParam.Add("额定功率", Convert.ToUInt16(textBox_RatePower.Text));
  462. MotorParam.Add("空载转速", Convert.ToUInt16(textBox_RateSpeed.Text));
  463. MotorParam.Add("定子电阻", Convert.ToUInt16(textBox_RotorR.Text));
  464. MotorParam.Add("定子Lq", Convert.ToUInt16(textBox_Rotor_Lq.Text));
  465. MotorParam.Add("定子Ld", Convert.ToUInt16(textBox_Rotor_Ld.Text));
  466. MotorParam.Add("反电动势", Convert.ToUInt16(textBox_E.Text));
  467. MotorParam.Add("额定电压", Convert.ToUInt16(textBox_Rate_Vol.Text));
  468. //其它信息
  469. Otherinfo.Clear();
  470. Otherinfo.Add("生产商", textBox_Mac.Text);
  471. Otherinfo.Add("生产地", textBox_Mac_Addr.Text);
  472. Otherinfo.Add("生产日期", textBox_Mac_Date.Text);
  473. Otherinfo.Add("校验密钥", textBox_Secrect.Text);
  474. Otherinfo.Add("信息1", textBox_Info1.Text);
  475. Otherinfo.Add("信息2", textBox_Info2.Text);
  476. Otherinfo.Add("信息3", textBox_Info3.Text);
  477. //测试阈值
  478. TestThData.Clear();
  479. TestThData.Add("空载电流", Convert.ToUInt16(textBox_NC_Current.Text));
  480. TestThData.Add("车速", Convert.ToUInt16(textBox_SpeedTh.Text));
  481. TestThData.Add("指拨转速", Convert.ToUInt16(textBox_GasSpeedTh.Text));
  482. TestThData.Add("零偏最小值", Convert.ToUInt16(textBox_Zero_Min.Text));
  483. TestThData.Add("零偏最大值", Convert.ToUInt16(textBox_Zero_Max.Text));
  484. TestThData.Add("标定系数最小值", Convert.ToUInt16(float.Parse(textBox_K_Min.Text) * 100));
  485. TestThData.Add("标定系数最大值", Convert.ToUInt16(float.Parse(textBox_K_Max.Text) * 100));
  486. TestThData.Add("启动值最小值", Convert.ToUInt16(textBox_Start_Min.Text));
  487. TestThData.Add("启动值最大值", Convert.ToUInt16(textBox_Start_Max.Text));
  488. //其它测试备注信息
  489. MarkInfo.Clear();
  490. if (textBox_HW_Version.Text == string.Empty)
  491. {
  492. MessageBox.Show("请输入PCBA版号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  493. return false;
  494. }
  495. else
  496. {
  497. MarkInfo.Add("PCBA版号", textBox_HW_Version.Text);
  498. }
  499. return true;
  500. }
  501. catch(Exception ex)
  502. {
  503. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  504. return false;
  505. }
  506. }
  507. private void button_Default_Click(object sender, EventArgs e)
  508. {
  509. if (MessageBox.Show("确认恢复默认值?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
  510. {
  511. return;
  512. }
  513. SetDefault();
  514. ParamsDisplayUpdate();
  515. }
  516. private void button_Generate_Click(object sender, EventArgs e)
  517. {
  518. if (MessageBox.Show("确认提交?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
  519. {
  520. return;
  521. }
  522. //空间内容更新到字典
  523. if (DisplaySetToParams() == false)
  524. {
  525. MessageBox.Show("参数生成失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  526. return;
  527. }
  528. //保存为配置文件
  529. if (textBox_Model.Text == string.Empty) //判断型号是否填写
  530. {
  531. MessageBox.Show("请输入电机型号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  532. return;
  533. }
  534. if (textBox_Client.Text == string.Empty) //判断订单编号是否填写
  535. {
  536. MessageBox.Show("请输入订单号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  537. return;
  538. }
  539. if (textBox_HW_Version.Text == String.Empty) //判断PCBA板号是否填写
  540. {
  541. MessageBox.Show("请输入PCBA板号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  542. return;
  543. }
  544. if (comboBox_Baudrate.SelectedIndex == -1)
  545. {
  546. MessageBox.Show("请设定波特率!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  547. return;
  548. }
  549. Regex Reg = new Regex(@"[V][0-9].[0-9]|[0-9][0-9].[0-9]|[0-9][0-9].[0-9]|[0-9][0-9].[0-9]|[0-9][0-9]_20\d{6}");
  550. if (Reg.IsMatch(textBox_FW_Version.Text) == false) //判断主控软件版本是否填写
  551. {
  552. MessageBox.Show("主控软件版本格式不正确,例如V1.0.0.0.0_20210101 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  553. return;
  554. }
  555. if (textBox_TE_FW_Version.Text != "N_A")//兼容单MCU主控板,无TE时填写N_A
  556. {
  557. Reg = new Regex(@"[V][0-9].[0-9].[0-9]_20\d{6}"); //判断TE软件版本是否填写
  558. if (Reg.IsMatch(textBox_TE_FW_Version.Text) == false) //判断TE软件版本是否填写
  559. {
  560. MessageBox.Show("TE软件版本格式不正确,例如N_A或V1.0.0_20210101 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  561. return;
  562. }
  563. }
  564. button_Generate.BackColor = Color.Red;
  565. button_Generate.Text = "生成中";
  566. button_Generate.Enabled = false;
  567. if (System.IO.Directory.Exists(FilePath) == false)
  568. System.IO.Directory.CreateDirectory(FilePath);
  569. string Datenow = DateTime.Now.ToString("yyyy-MM-dd") + "\\";
  570. if (System.IO.Directory.Exists(FilePath + Datenow) == false)
  571. System.IO.Directory.CreateDirectory(FilePath + Datenow);
  572. string fileName = FilePath + Datenow + textBox_Model.Text + "_" + textBox_Client.Text + "_" + textBox_FW_Version.Text + "_" + textBox_TE_FW_Version.Text + "_" + ((textBox_Remark.Text == string.Empty) ? "" : textBox_Remark.Text + "_") + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".ttcfg";
  573. using (StreamWriter file = new StreamWriter(fileName))
  574. {
  575. //用户参数1
  576. file.WriteLine("[{0}]", "用户参数1");
  577. foreach (var entry in Params1)
  578. if (entry.Key == "码表")
  579. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "有" : entry.Value == 0xAA ? "无" : "无效");
  580. else if (entry.Key == "指拨模式")
  581. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "不支持" : entry.Value == 0xAA ? "支持" : "无效");
  582. else if (entry.Key == "速度信号来源")
  583. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "传感器" : entry.Value == 0xAA ? "踏频" : entry.Value == 0xEE ? "通信" : "无效");
  584. else
  585. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  586. //用户参数2
  587. file.WriteLine("");
  588. file.WriteLine("[{0}]", "用户参数2");
  589. foreach (var entry in Params2)
  590. if (entry.Key == "姿态传感器")
  591. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "不支持" : entry.Value == 0xAA ? "支持" : "无效");
  592. else if (entry.Key == "前灯电压")
  593. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0xFF ? "随电池" : entry.Value == 0 ? "硬件配置" : entry.Value + "V");
  594. else if (entry.Key == "尾灯电压")
  595. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0xFF ? "随电池" : entry.Value == 0 ? "硬件配置" : entry.Value + "V");
  596. else
  597. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  598. //马达参数
  599. file.WriteLine("");
  600. file.WriteLine("[{0}]", "马达参数");
  601. foreach (var entry in MotorParam)
  602. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  603. //其它信息
  604. file.WriteLine("");
  605. file.WriteLine("[{0}]", "其它信息");
  606. foreach (var entry in Otherinfo)
  607. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  608. //测试阈值
  609. file.WriteLine("");
  610. file.WriteLine("[{0}]", "测试阈值");
  611. foreach (var entry in TestThData)
  612. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  613. //其它测试备注信息
  614. file.WriteLine("");
  615. file.WriteLine("[{0}]", "其它测试备注信息");
  616. foreach (var entry in MarkInfo)
  617. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  618. }
  619. button_Generate.Text = "转换中";
  620. //保存为Excel文件
  621. string importExcelName = "FOQC成机参数检验标准_Temple3.xls";
  622. string exportExcelName = FilePath + Datenow + textBox_Model.Text + "_" + textBox_Client.Text + "_" + ((textBox_Remark.Text == string.Empty) ? "" : textBox_Remark.Text + "_") + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".xls";
  623. try
  624. {
  625. //导入文件
  626. IWorkbook workbook = WorkbookFactory.Create(importExcelName);
  627. //获取第一个工作薄
  628. ISheet sheet = workbook.GetSheetAt(0);
  629. #region 开始按行写入单元格
  630. //第3行,文件信息
  631. IRow row = sheet.GetRow(2);
  632. row.GetCell(0).SetCellValue("文件信息 File Info:" + textBox_Model.Text + "_" + textBox_Client.Text + "_" + ((textBox_Remark.Text == string.Empty) ? "" : textBox_Remark.Text + "_") + DateTime.Now.ToString("yyyy-MM-dd-HHmmss"));
  633. //第5行,第2列型号,第10列SPORT加速
  634. row = sheet.GetRow(4);
  635. row.GetCell(1).SetCellValue(textBox_Model.Text);
  636. row.GetCell(9).SetCellValue(textBox_SPORT_Acc.Text);
  637. //第6行,第2列SN,第10列TURBO增益
  638. row = sheet.GetRow(5);
  639. row.GetCell(1).SetCellValue("Same as marking");
  640. row.GetCell(9).SetCellValue(textBox_TURBO_Gain.Text);
  641. //第7行,第2列硬件板号,第10列TURBO加速
  642. row = sheet.GetRow(6);
  643. row.GetCell(1).SetCellValue(textBox_HW_Version.Text);
  644. row.GetCell(9).SetCellValue(textBox_TURBO_Acc.Text);
  645. //第8行,第2列主控软件版本,第10列SMART增益
  646. row = sheet.GetRow(7);
  647. row.GetCell(1).SetCellValue(textBox_FW_Version.Text);
  648. row.GetCell(9).SetCellValue(textBox_SMART_Gain.Text);
  649. //第9行,第2列TE软件版本,第10列SMART加速
  650. row = sheet.GetRow(8);
  651. row.GetCell(1).SetCellValue(textBox_TE_FW_Version.Text);
  652. row.GetCell(9).SetCellValue(textBox_SMART_Acc.Text);
  653. //第10行,第2列BOOT版本,第10列额定功率
  654. row = sheet.GetRow(9);
  655. row.GetCell(1).SetCellValue(comboBox_Baudrate.SelectedIndex == 0 ? "V1.2.2 125K" : "V2.0.0 250K");
  656. row.GetCell(9).SetCellValue(textBox_RatePower.Text + " W");
  657. //第11行,第2列静态电压,第10列空载转速
  658. row = sheet.GetRow(10);
  659. row.GetCell(1).SetCellValue(textBox_Rate_Vol.Text + " ± 1 V");
  660. row.GetCell(9).SetCellValue(textBox_RateSpeed.Text + " rpm");
  661. //第12行,第2列静态电流,第10列额定电压
  662. row = sheet.GetRow(11);
  663. row.GetCell(1).SetCellValue("≤ 0.050 A");
  664. row.GetCell(9).SetCellValue(textBox_Rate_Vol.Text + " V");
  665. //第13行,第2列指拨模式,第10列速度信号个数
  666. row = sheet.GetRow(12);
  667. row.GetCell(1).SetCellValue(comboBox_GasMode.Text == "不支持" ? "不支持 No" : "支持 Yes");
  668. row.GetCell(9).SetCellValue(textBox_SpeedSensor.Text);
  669. //第14行,第2列启动模式,第10列踏频启动信号个数
  670. row = sheet.GetRow(13);
  671. row.GetCell(1).SetCellValue(comboBox_StartMode.Text == "柔和" ? "柔和 Comfort" : comboBox_StartMode.Text == "正常" ? "正常 Normal" : "强劲 Dynamic");
  672. row.GetCell(9).SetCellValue(textBox_CadenceStart.Text);
  673. //第15行,第2列停机时间,第10列车速信号来源
  674. row = sheet.GetRow(14);
  675. row.GetCell(1).SetCellValue(textBox_StopTime.Text + " ms");
  676. row.GetCell(9).SetCellValue(comboBox_SpeedSensor.Text == "传感器" ? "传感器 Sensor" : comboBox_SpeedSensor.Text == "踏频" ? "踏频 Cadence" : "通信 CAN");
  677. //第16行,第2列限速,第10列轮胎周长微调
  678. row = sheet.GetRow(15);
  679. row.GetCell(1).SetCellValue(textBox_SpeedLimit.Text + " km/h");
  680. row.GetCell(9).SetCellValue(textBox_WheelSizeAdj.Text + " cm");
  681. //第17行,第2列下降速度,第10列推行转速
  682. row = sheet.GetRow(16);
  683. row.GetCell(1).SetCellValue("Level " + textBox_Dec.Text);
  684. row.GetCell(9).SetCellValue(textBox_WalkSpeed.Text + " rpm");
  685. //第18行,第2列前齿,第10列俯仰角零偏
  686. row = sheet.GetRow(17);
  687. row.GetCell(1).SetCellValue(textBox_T_Front.Text + " T");
  688. row.GetCell(9).SetCellValue(textBox_Angle_P.Text + " °");
  689. //第19行,第2列后齿,第10列横滚角零偏
  690. row = sheet.GetRow(18);
  691. row.GetCell(1).SetCellValue(textBox_T_Tail.Text + " T");
  692. row.GetCell(9).SetCellValue(textBox_Angle_R.Text + " °");
  693. //第20行,第2列限流,第10列姿态传感器
  694. row = sheet.GetRow(19);
  695. row.GetCell(1).SetCellValue(textBox_MaxCurrent.Text + " A");
  696. row.GetCell(9).SetCellValue(comboBox_AstSensor.Text == "不支持" ? "不支持 No" : "支持 Yes");
  697. //第21行,第2列温度预警,第10列尾灯模式
  698. row = sheet.GetRow(20);
  699. row.GetCell(1).SetCellValue(textBox_NTC_Alarm.Text + " ℃");
  700. row.GetCell(9).SetCellValue(comboBox_LightMode.Text.Replace("模式", "Mode"));
  701. //第22行,第2列温度保护,第10列前灯电压
  702. row = sheet.GetRow(21);
  703. row.GetCell(1).SetCellValue(textBox_NTC_Ptotect.Text + " ℃");
  704. row.GetCell(9).SetCellValue(comboBox_HeadLightVol.Text.Contains("随电池") ? comboBox_HeadLightVol.Text + " " + textBox_Rate_Vol.Text + " V" : comboBox_HeadLightVol.Text.Contains("硬件") ? "硬件配置 By HW" : comboBox_HeadLightVol.Text);
  705. //第23行,第2列码表,第10列后灯电压
  706. row = sheet.GetRow(22);
  707. row.GetCell(1).SetCellValue(comboBox_NoPBU.Text == "有" ? "有 Yes" : "无 No");
  708. row.GetCell(9).SetCellValue(comboBox_TailLightVol.Text.Contains("随电池") ? comboBox_TailLightVol.Text + " " + textBox_Rate_Vol.Text + " V" : comboBox_TailLightVol.Text.Contains("硬件") ? "硬件配置 By HW" : comboBox_TailLightVol.Text);
  709. //第24行,第2列轮胎周长,第10列启动值
  710. row = sheet.GetRow(23);
  711. row.GetCell(1).SetCellValue(textBox_WheelSize.Text + " cm");
  712. row.GetCell(9).SetCellValue(textBox_Start_Min.Text + " - " + textBox_Start_Max.Text);
  713. //第25行,第2列电机系列,第10列校正系数1
  714. row = sheet.GetRow(24);
  715. row.GetCell(1).SetCellValue(textBox_Serial.Text);
  716. row.GetCell(9).SetCellValue(textBox_K_Min.Text + " - " + textBox_K_Max.Text);
  717. //第26行,第2列低压保护,第10列校正系数2
  718. row = sheet.GetRow(25);
  719. row.GetCell(1).SetCellValue(textBox_UV_Protect.Text + " mV");
  720. if ((textBox_Model.Text.Contains("PG")) || (textBox_Model.Text.Contains("PS")) || (textBox_Model.Text.Contains("J01")))
  721. row.GetCell(9).SetCellValue(textBox_K_Min.Text + " - " + textBox_K_Max.Text);
  722. else
  723. row.GetCell(9).SetCellValue("无此项目 None");
  724. //第27行,第2列推行限速,第10列校正系数3
  725. row = sheet.GetRow(26);
  726. row.GetCell(1).SetCellValue(textBox_Walk_SpeedLimit.Text + " km/h");
  727. if ((textBox_Model.Text.Contains("PG")) || (textBox_Model.Text.Contains("PS")) || (textBox_Model.Text.Contains("J01")))
  728. row.GetCell(9).SetCellValue(textBox_K_Min.Text + " - " + textBox_K_Max.Text);
  729. else
  730. row.GetCell(9).SetCellValue("无此项目 None");
  731. //第28行,第2列ECO增益,第10列零点值1
  732. row = sheet.GetRow(27);
  733. row.GetCell(1).SetCellValue(textBox_ECO_Gain.Text);
  734. row.GetCell(9).SetCellValue(textBox_Zero_Min.Text + " - " + textBox_Zero_Max.Text);
  735. //第29行,第2列ECO加速,第10列零点值2
  736. row = sheet.GetRow(28);
  737. row.GetCell(1).SetCellValue(textBox_ECO_Acc.Text);
  738. if ((textBox_Model.Text.Contains("PG")) || (textBox_Model.Text.Contains("PS")) || (textBox_Model.Text.Contains("J01")))
  739. row.GetCell(9).SetCellValue(textBox_Zero_Min.Text + " - " + textBox_Zero_Max.Text);
  740. else
  741. row.GetCell(9).SetCellValue("无此项目 None");
  742. //第30行,第2列NORM增益,第10列零点值3
  743. row = sheet.GetRow(29);
  744. row.GetCell(1).SetCellValue(textBox_NORM_Gain.Text);
  745. if ((textBox_Model.Text.Contains("PG")) || (textBox_Model.Text.Contains("PS")) || (textBox_Model.Text.Contains("J01")))
  746. row.GetCell(9).SetCellValue(textBox_Zero_Min.Text + " - " + textBox_Zero_Max.Text);
  747. else
  748. row.GetCell(9).SetCellValue("无此项目 None");
  749. //第31行,第2列NORM加速,第10列骑行历史
  750. row = sheet.GetRow(30);
  751. row.GetCell(1).SetCellValue(textBox_NORM_Acc.Text);
  752. row.GetCell(9).SetCellValue("0 km / 0 min");
  753. //第32行,第2列SPORT增益,第10列故障码
  754. row = sheet.GetRow(31);
  755. row.GetCell(1).SetCellValue(textBox_SPORT_Gain.Text);
  756. row.GetCell(9).SetCellValue("无故障记录 None");
  757. //第33行,第2列尾灯脉宽,第10列尾灯周期
  758. row = sheet.GetRow(32);
  759. row.GetCell(1).SetCellValue(textBox_LightPluse.Text + "\n" + ((float)Convert.ToDouble(textBox_LightPluse.Text) / 15000f).ToString("0.000") + " s");
  760. row.GetCell(9).SetCellValue(textBox_LightPeriod.Text + "\n" + ((float)Convert.ToDouble(textBox_LightPeriod.Text) / 15000f).ToString("0.000") + " s");
  761. //第34行,第2列超速报警阈值
  762. row = sheet.GetRow(33);
  763. row.GetCell(1).SetCellValue(textBox_AlarmSpeed.Text + " km/h");
  764. #endregion
  765. using (FileStream file = File.OpenWrite(exportExcelName))
  766. {
  767. workbook.Write(file);
  768. workbook.Close();
  769. }
  770. }
  771. catch (Exception ex)
  772. {
  773. throw (ex);
  774. }
  775. //文件转换为pdf格式保存
  776. string exportPdfName = FilePath + Datenow + textBox_Model.Text + "_" + textBox_Client.Text + "_" + ((textBox_Remark.Text == string.Empty) ? "" : textBox_Remark.Text + "_") + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".pdf";
  777. Workbook workbook_1 = new Workbook();//创建Workbook类的实例
  778. workbook_1.LoadFromFile(exportExcelName);//加载Excel工作簿
  779. workbook_1.SaveToFile(exportPdfName, FileFormat.PDF);//将整个工作薄保存为PDF
  780. MessageBox.Show("参数已生成,进入文件管理页面查看!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  781. button_Generate.Text = "上传中";
  782. //发送文件到服务器
  783. if (StartForm.myFtp.IsNetConnected == true)
  784. {
  785. string DateNow = DateTime.Now.ToString("yyyy-MM-dd");
  786. int okCnt = 0;
  787. if (StartForm.myFtp.DirectoryExist(StartForm.myServerCfg.RootPath + "/cfg/", DateNow) == false)
  788. {
  789. StartForm.myFtp.MakeDir(StartForm.myServerCfg.RootPath + "/cfg/" + DateNow);
  790. }
  791. //上传配置文件
  792. bool result = StartForm.myFtp.UploadFile(fileName, StartForm.myServerCfg.RootPath + "/cfg/" + DateNow);
  793. if (result == true)
  794. {
  795. okCnt++;
  796. //MessageBox.Show("配置文件上传服务器成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  797. }
  798. //上传配置清单excel
  799. result = StartForm.myFtp.UploadFile(exportExcelName, StartForm.myServerCfg.RootPath + "/cfg/" + DateNow);
  800. if (result == true)
  801. {
  802. okCnt++;
  803. //MessageBox.Show("配置检验清单上传服务器成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  804. }
  805. //上传配置清单pdf
  806. result = StartForm.myFtp.UploadFile(exportPdfName, StartForm.myServerCfg.RootPath + "/cfg/" + DateNow);
  807. if (result == true)
  808. {
  809. okCnt++;
  810. //MessageBox.Show("配置检验清单上传服务器成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  811. }
  812. if (okCnt >= 3)
  813. {
  814. MessageBox.Show("配置检验文件上传服务器成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  815. }
  816. else
  817. {
  818. MessageBox.Show("配置检验文件上传服务器失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  819. }
  820. }
  821. button_Generate.Text = "生成";
  822. button_Generate.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(113)))), ((int)(((byte)(185)))));
  823. button_Generate.Enabled = true;
  824. }
  825. private void button_keyboard_Click(object sender, EventArgs e)
  826. {
  827. System.Diagnostics.Process.Start("osk.exe");
  828. }
  829. //输入型号时自动更新关键参数
  830. private void textBox_Model_TextChanged(object sender, EventArgs e)
  831. {
  832. if (textBox_Model.Text.Contains("J01"))
  833. {
  834. textBox_Serial.Text = "1";//系列号
  835. textBox_MaxCurrent.Text = "13";//限流
  836. textBox_RatePower.Text = "250";//额定功率
  837. textBox_RateSpeed.Text = "1200";//额定转速
  838. textBox_Rate_Vol.Text = "36";//额定电压
  839. textBox_NC_Current.Text = "800";//空载电流
  840. textBox_Zero_Min.Text = "100";//零偏下限
  841. textBox_Zero_Max.Text = "2000";//零偏上限
  842. textBox_K_Min.Text = "0.40";//传感器标定值下限
  843. textBox_K_Max.Text = "1.20";//传感器标定值下限
  844. textBox_Start_Min.Text = "280";//启动值下限
  845. textBox_Start_Max.Text = "500";//启动值上限
  846. textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
  847. }
  848. else if (textBox_Model.Text.Contains("VL"))
  849. {
  850. textBox_Serial.Text = "1";//系列号
  851. textBox_MaxCurrent.Text = "13";//限流
  852. textBox_RatePower.Text = "250";//额定功率
  853. textBox_RateSpeed.Text = "1200";//额定转速
  854. textBox_Rate_Vol.Text = "36";//额定电压
  855. textBox_NC_Current.Text = "800";//空载电流
  856. textBox_Zero_Min.Text = "200";//零偏下限
  857. textBox_Zero_Max.Text = "1800";//零偏上限
  858. textBox_K_Min.Text = "0.25";//传感器标定值下限
  859. textBox_K_Max.Text = "0.75";//传感器标定值下限
  860. textBox_Start_Min.Text = "350";//启动值下限
  861. textBox_Start_Max.Text = "750";//启动值上限
  862. if (textBox_Model.Text.Contains("03") || textBox_Model.Text.Contains("13"))
  863. {
  864. textBox_GasSpeedTh.Text = "200";
  865. }
  866. else
  867. {
  868. textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
  869. }
  870. }
  871. else if (textBox_Model.Text.Contains("VS"))
  872. {
  873. textBox_Serial.Text = "2";//系列号
  874. textBox_MaxCurrent.Text = "15";//限流
  875. textBox_RatePower.Text = "250";//额定功率
  876. textBox_RateSpeed.Text = "1200";//额定转速
  877. textBox_Rate_Vol.Text = "36";//额定电压
  878. textBox_NC_Current.Text = "800";//空载电流
  879. textBox_Zero_Min.Text = "200";//零偏下限
  880. textBox_Zero_Max.Text = "1800";//零偏上限
  881. textBox_K_Min.Text = "0.25";//传感器标定值下限
  882. textBox_K_Max.Text = "0.75";//传感器标定值下限
  883. textBox_Start_Min.Text = "350";//启动值下限
  884. textBox_Start_Max.Text = "750";//启动值上限
  885. if (textBox_Model.Text.Contains("03") || textBox_Model.Text.Contains("13"))
  886. {
  887. textBox_GasSpeedTh.Text = "200";
  888. }
  889. else
  890. {
  891. textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
  892. }
  893. }
  894. else if (textBox_Model.Text.Contains("VR"))
  895. {
  896. textBox_Serial.Text = "2";//系列号
  897. textBox_MaxCurrent.Text = "15";//限流
  898. textBox_RatePower.Text = "250";//额定功率
  899. textBox_RateSpeed.Text = "1200";//额定转速
  900. textBox_Rate_Vol.Text = "36";//额定电压
  901. textBox_NC_Current.Text = "800";//空载电流
  902. textBox_Zero_Min.Text = "200";//零偏下限
  903. textBox_Zero_Max.Text = "1800";//零偏上限
  904. textBox_K_Min.Text = "0.25";//传感器标定值下限
  905. textBox_K_Max.Text = "0.75";//传感器标定值下限
  906. textBox_Start_Min.Text = "350";//启动值下限
  907. textBox_Start_Max.Text = "750";//启动值上限
  908. textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
  909. }
  910. else if (textBox_Model.Text.Contains("PG"))
  911. {
  912. textBox_Serial.Text = "3";//系列号
  913. textBox_MaxCurrent.Text = "17";//限流
  914. textBox_RatePower.Text = "250";//额定功率
  915. textBox_RateSpeed.Text = "1600";//额定转速
  916. textBox_Rate_Vol.Text = "36";//额定电压
  917. textBox_NC_Current.Text = "1000";//空载电流
  918. textBox_Zero_Min.Text = "100";//零偏下限
  919. textBox_Zero_Max.Text = "2000";//零偏上限
  920. textBox_K_Min.Text = "0.25";//传感器标定值下限
  921. textBox_K_Max.Text = "1.20";//传感器标定值下限
  922. textBox_Start_Min.Text = "280";//启动值下限
  923. textBox_Start_Max.Text = "500";//启动值上限
  924. textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
  925. }
  926. else if (textBox_Model.Text.Contains("PS"))
  927. {
  928. textBox_Serial.Text = "4";//系列号
  929. textBox_MaxCurrent.Text = "17";//限流
  930. textBox_RatePower.Text = "500";//额定功率
  931. textBox_RateSpeed.Text = "1800";//额定转速
  932. textBox_Rate_Vol.Text = "48";//额定电压
  933. textBox_NC_Current.Text = "1000";//空载电流
  934. textBox_Zero_Min.Text = "100";//零偏下限
  935. textBox_Zero_Max.Text = "2000";//零偏上限
  936. textBox_K_Min.Text = "0.25";//传感器标定值下限
  937. textBox_K_Max.Text = "1.20";//传感器标定值下限
  938. textBox_Start_Min.Text = "280";//启动值下限
  939. textBox_Start_Max.Text = "500";//启动值上限
  940. textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
  941. }
  942. else
  943. {
  944. textBox_Serial.Text = "";//系列号
  945. textBox_MaxCurrent.Text = "";//限流
  946. textBox_RatePower.Text = "";//额定功率
  947. textBox_RateSpeed.Text = "";//额定转速
  948. textBox_Rate_Vol.Text = "";//额定电压
  949. textBox_NC_Current.Text = "";//空载电流
  950. textBox_Zero_Min.Text = "";//零偏下限
  951. textBox_Zero_Max.Text = "";//零偏上限
  952. textBox_K_Min.Text = "";//传感器标定值下限
  953. textBox_K_Max.Text = "";//传感器标定值下限
  954. textBox_Start_Min.Text = "";//启动值下限
  955. textBox_Start_Max.Text = "";//启动值上限
  956. textBox_GasSpeedTh.Text = "";
  957. }
  958. }
  959. //输入限速时更改指拨转速阈值
  960. private void textBox_SpeedLimit_TextChanged(object sender, EventArgs e)
  961. {
  962. if (textBox_SpeedLimit.Text == "")
  963. return;
  964. if ((!textBox_Model.Text.Contains("6503")) && (!textBox_Model.Text.Contains("6513")) && (!textBox_Model.Text.Contains("7503")) && (!textBox_Model.Text.Contains("7513")))
  965. {
  966. textBox_GasSpeedTh.Text = (Convert.ToInt16(textBox_SpeedLimit.Text) * 49).ToString();
  967. }
  968. }
  969. //更改尾灯模式时更改尾灯脉宽和周期
  970. private void comboBox_LightMode_SelectedIndexChanged(object sender, EventArgs e)
  971. {
  972. if (comboBox_LightMode.SelectedIndex == 0) // 模式1,开灯低亮,刹车高亮
  973. {
  974. textBox_AlarmSpeed.Text = "15.0";
  975. textBox_LightPluse.Text = "75";
  976. textBox_LightPeriod.Text = "150";
  977. }
  978. else if (comboBox_LightMode.SelectedIndex == 5) // 模式6,超速报警
  979. {
  980. textBox_AlarmSpeed.Text = "15.0";
  981. textBox_LightPluse.Text = "7500";
  982. textBox_LightPeriod.Text = "45000";
  983. }
  984. }
  985. //指拨转速阈值修改
  986. private void textBox_GasSpeedTh_TextChanged(object sender, EventArgs e)
  987. {
  988. UInt32 DataTemp = 0;
  989. if (textBox_GasSpeedTh.Text == "")
  990. {
  991. return;
  992. }
  993. DataTemp = Convert.ToUInt32(textBox_GasSpeedTh.Text);
  994. if (textBox_Model.Text.Contains("VL"))
  995. {
  996. if (DataTemp >= 1200)
  997. {
  998. textBox_GasSpeedTh.Text = "1200";
  999. }
  1000. }
  1001. else if (textBox_Model.Text.Contains("VS"))
  1002. {
  1003. if (DataTemp >= 1200)
  1004. {
  1005. textBox_GasSpeedTh.Text = "1200";
  1006. }
  1007. }
  1008. else if (textBox_Model.Text.Contains("PG"))
  1009. {
  1010. if (DataTemp >= 1400)
  1011. {
  1012. textBox_GasSpeedTh.Text = "1400";
  1013. }
  1014. }
  1015. else if (textBox_Model.Text.Contains("PS"))
  1016. {
  1017. if (DataTemp >= 1600)
  1018. {
  1019. textBox_GasSpeedTh.Text = "1600";
  1020. }
  1021. }
  1022. }
  1023. }
  1024. }