ExportForm.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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. namespace MOTINOVA_Motor_Factory_Set
  13. {
  14. public partial class ExportForm : Form
  15. {
  16. //参数按照字典类型存储
  17. Dictionary<string, UInt16> Params1 = new Dictionary<string, UInt16>();
  18. Dictionary<string, UInt16> Params2 = new Dictionary<string, UInt16>();
  19. Dictionary<string, UInt16> MotorParam = new Dictionary<string, UInt16>();
  20. Dictionary<string, string> Otherinfo = new Dictionary<string, string>();
  21. Dictionary<string, UInt16> TestThData = new Dictionary<string, ushort>();
  22. //文件路径
  23. string FilePath = "cfg\\";
  24. public ExportForm()
  25. {
  26. InitializeComponent();
  27. }
  28. private void ExportForm_Load(object sender, EventArgs e)
  29. {
  30. }
  31. private void SetDefault()
  32. {
  33. //参数1
  34. Params1.Clear();
  35. Params1.Add("启动模式", 2);
  36. Params1.Add("停机时间", 100);
  37. Params1.Add("限速值", 25);
  38. Params1.Add("下降速度", 3);
  39. Params1.Add("前飞", 14);
  40. Params1.Add("后飞", 9);
  41. Params1.Add("限流", 15);
  42. Params1.Add("温度预警", 95);
  43. Params1.Add("温度保护", 125);
  44. Params1.Add("码表", 0x55);//有,不支持无码表
  45. Params1.Add("轮胎周长", 219);//cm
  46. Params1.Add("系列号", 0);
  47. Params1.Add("ECO增益", 100);//放大100倍
  48. Params1.Add("ECO加速", 100);
  49. Params1.Add("NORM增益", 100);
  50. Params1.Add("NORM加速", 100);
  51. Params1.Add("SPORT增益", 100);
  52. Params1.Add("SPORT加速", 100);
  53. Params1.Add("TURBO增益", 100);
  54. Params1.Add("TURBO加速", 100);
  55. Params1.Add("SMART增益", 100);
  56. Params1.Add("SMART加速", 100);
  57. Params1.Add("车速级数", 1);
  58. Params1.Add("踏频启动", 2);
  59. Params1.Add("指拨模式", 0x55);
  60. Params1.Add("速度信号来源", 0x55);//传感器
  61. Params1.Add("周长微调", 0);
  62. Params1.Add("低压保护", 3100);//mV
  63. Params1.Add("推行限速", 60);//放大10倍
  64. Params1.Add("推行转速", 135);
  65. //参数2
  66. Params2.Clear();
  67. Params2.Add("姿态传感器", 0x55);//不支持
  68. Params2.Add("俯仰角零偏", 0);
  69. Params2.Add("横滚角零偏", 0);
  70. Params2.Add("尾灯模式", 2);
  71. //马达参数
  72. MotorParam.Clear();
  73. MotorParam.Add("额定功率", 250);
  74. MotorParam.Add("额定转速", 1500);
  75. MotorParam.Add("定子电阻", 10);
  76. MotorParam.Add("定子Lq", 10);
  77. MotorParam.Add("定子Ld", 10);
  78. MotorParam.Add("反电动势", 36000);
  79. MotorParam.Add("额定电压", 36);
  80. //其它信息
  81. Otherinfo.Clear();
  82. Otherinfo.Add("生产商", "TTIUM");
  83. Otherinfo.Add("生产地", "WUHAN");
  84. Otherinfo.Add("生产日期", "20200901");
  85. Otherinfo.Add("校验密钥", "AVONITOM");
  86. Otherinfo.Add("信息1", "");
  87. Otherinfo.Add("信息2", "");
  88. Otherinfo.Add("信息3", "");
  89. //测试阈值
  90. TestThData.Clear();
  91. TestThData.Add("空载电流", 1000);
  92. TestThData.Add("车速", 60);
  93. TestThData.Add("指拨转速", 1200);
  94. }
  95. private void ParamsDisplayUpdate()
  96. {
  97. //参数1
  98. if (Params1["启动模式"] == 1)
  99. {
  100. comboBox_StartMode.Text = "柔和";
  101. }
  102. else if (Params1["启动模式"] == 2)
  103. {
  104. comboBox_StartMode.Text = "正常";
  105. }
  106. else if (Params1["启动模式"] == 3)
  107. {
  108. comboBox_StartMode.Text = "强劲";
  109. }
  110. textBox_StopTime.Text = Params1["停机时间"].ToString();
  111. textBox_SpeedLimit.Text = Params1["限速值"].ToString();
  112. textBox_Dec.Text = Params1["下降速度"].ToString();
  113. textBox_T_Front.Text = Params1["前飞"].ToString();
  114. textBox_T_Tail.Text = Params1["后飞"].ToString();
  115. textBox_MaxCurrent.Text = Params1["限流"].ToString();
  116. textBox_NTC_Alarm.Text = Params1["温度预警"].ToString();
  117. textBox_NTC_Ptotect.Text = Params1["温度保护"].ToString();
  118. if (Params1["码表"] == 0x55)
  119. {
  120. comboBox_NoPBU.Text = "有";
  121. }
  122. else if (Params1["码表"] == 0xAA)
  123. {
  124. comboBox_NoPBU.Text = "无";
  125. }
  126. textBox_WheelSize.Text = Params1["轮胎周长"].ToString();
  127. textBox_Serial.Text = Params1["系列号"].ToString();
  128. textBox_ECO_Gain.Text = ((float)(Params1["ECO增益"]) / 100.0f).ToString("#0.00");
  129. textBox_ECO_Acc.Text = ((float)(Params1["ECO加速"]) / 100.0f).ToString("#0.00");
  130. textBox_NORM_Gain.Text = ((float)(Params1["NORM增益"]) / 100.0f).ToString("#0.00");
  131. textBox_NORM_Acc.Text = ((float)(Params1["NORM加速"]) / 100.0f).ToString("#0.00");
  132. textBox_SPORT_Gain.Text = ((float)(Params1["SPORT增益"]) / 100.0f).ToString("#0.00");
  133. textBox_SPORT_Acc.Text = ((float)(Params1["SPORT加速"]) / 100.0f).ToString("#0.00");
  134. textBox_TURBO_Gain.Text = ((float)(Params1["TURBO增益"]) / 100.0f).ToString("#0.00");
  135. textBox_TURBO_Acc.Text = ((float)(Params1["TURBO加速"]) / 100.0f).ToString("#0.00");
  136. textBox_SMART_Gain.Text = ((float)(Params1["SMART增益"]) / 100.0f).ToString("#0.00");
  137. textBox_SMART_Acc.Text = ((float)(Params1["SMART加速"]) / 100.0f).ToString("#0.00");
  138. textBox_SpeedSensor.Text = Params1["车速级数"].ToString();
  139. textBox_CadenceStart.Text = Params1["踏频启动"].ToString();
  140. if (Params1["指拨模式"] == 0x55)
  141. {
  142. comboBox_GasMode.Text = "不支持";
  143. }
  144. else if (Params1["指拨模式"] == 0xAA)
  145. {
  146. comboBox_GasMode.Text = "支持";
  147. }
  148. if (Params1["速度信号来源"] == 0x55)
  149. {
  150. comboBox_SpeedSensor.Text = "传感器";
  151. }
  152. else if (Params1["速度信号来源"] == 0xAA)
  153. {
  154. comboBox_SpeedSensor.Text = "踏频";
  155. }
  156. else if (Params1["速度信号来源"] == 0xEE)
  157. {
  158. comboBox_SpeedSensor.Text = "通信";
  159. }
  160. textBox_WheelSizeAdj.Text = Params1["周长微调"].ToString();
  161. textBox_UV_Protect.Text = Params1["低压保护"].ToString();
  162. textBox_Walk_SpeedLimit.Text = ((float)(Params1["推行限速"]) / 10.0f).ToString("#0.0");
  163. textBox_WalkSpeed.Text = Params1["推行转速"].ToString();
  164. //参数2
  165. if (Params2["姿态传感器"] == 0x55)
  166. {
  167. comboBox_AstSensor.Text = "不支持";
  168. }
  169. else if (Params1["姿态传感器"] == 0xAA)
  170. {
  171. comboBox_AstSensor.Text = "支持";
  172. }
  173. textBox_Angle_P.Text = ((float)(Params2["俯仰角零偏"]) / 10.0f).ToString("#0.0");
  174. textBox_Angle_R.Text = ((float)(Params2["横滚角零偏"]) / 10.0f).ToString("#0.0");
  175. if (Params2["尾灯模式"] == 1)
  176. {
  177. comboBox_LightMode.Text = "模式 1";
  178. }
  179. else if (Params2["尾灯模式"] == 2)
  180. {
  181. comboBox_LightMode.Text = "模式 2";
  182. }
  183. else if (Params2["尾灯模式"] == 3)
  184. {
  185. comboBox_LightMode.Text = "模式 3";
  186. }
  187. else if (Params2["尾灯模式"] == 4)
  188. {
  189. comboBox_LightMode.Text = "模式 4";
  190. }
  191. //马达参数
  192. textBox_RatePower.Text = MotorParam["额定功率"].ToString();
  193. textBox_RateSpeed.Text = MotorParam["额定转速"].ToString();
  194. textBox_RotorR.Text = MotorParam["定子电阻"].ToString();
  195. textBox_Rotor_Lq.Text = MotorParam["定子Lq"].ToString();
  196. textBox_Rotor_Ld.Text = MotorParam["定子Ld"].ToString();
  197. textBox_E.Text = MotorParam["反电动势"].ToString();
  198. textBox_Rate_Vol.Text = MotorParam["额定电压"].ToString();
  199. //其它信息
  200. textBox_Mac.Text = Otherinfo["生产商"].ToString();
  201. textBox_Mac_Addr.Text = Otherinfo["生产地"].ToString();
  202. textBox_Mac_Date.Text = Otherinfo["生产日期"].ToString();
  203. textBox_Secrect.Text = Otherinfo["校验密钥"].ToString();
  204. textBox_Info1.Text = Otherinfo["信息1"].ToString();
  205. textBox_Info2.Text = Otherinfo["信息2"].ToString();
  206. textBox_Info3.Text = Otherinfo["信息3"].ToString();
  207. //测试阈值
  208. textBox_NC_Current.Text = TestThData["空载电流"].ToString();
  209. textBox_SpeedTh.Text = TestThData["车速"].ToString();
  210. textBox_GasSpeedTh.Text = TestThData["指拨转速"].ToString();
  211. }
  212. private bool DisplaySetToParams()
  213. {
  214. try
  215. {
  216. //参数1
  217. Params1.Clear();
  218. if (comboBox_StartMode.Text == "柔和")
  219. {
  220. Params1.Add("启动模式", 1);
  221. }
  222. else if (comboBox_StartMode.Text == "正常")
  223. {
  224. Params1.Add("启动模式", 2);
  225. }
  226. else if (comboBox_StartMode.Text == "强劲")
  227. {
  228. Params1.Add("启动模式", 3);
  229. }
  230. else
  231. {
  232. MessageBox.Show("请检查启动模式设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  233. return false;
  234. }
  235. Params1.Add("停机时间", Convert.ToUInt16(textBox_StopTime.Text));
  236. if (Params1["停机时间"] < 50 || Params1["停机时间"] > 500)
  237. {
  238. MessageBox.Show("停机时间有效值:50~500 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  239. return false;
  240. }
  241. Params1.Add("限速值", Convert.ToUInt16(textBox_SpeedLimit.Text));
  242. if (Params1["限速值"] < 5 || Params1["限速值"] > 80)
  243. {
  244. MessageBox.Show("限速值有效值:5~80 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  245. return false;
  246. }
  247. Params1.Add("下降速度", Convert.ToUInt16(textBox_Dec.Text));
  248. if (Params1["下降速度"] < 1 || Params1["下降速度"] > 5)
  249. {
  250. MessageBox.Show("下降速度有效值:1~5 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  251. return false;
  252. }
  253. Params1.Add("前飞", Convert.ToUInt16(textBox_T_Front.Text));
  254. if (Params1["前飞"] < 5 || Params1["前飞"] > 100)
  255. {
  256. MessageBox.Show("前飞有效值:5~100 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  257. return false;
  258. }
  259. Params1.Add("后飞", Convert.ToUInt16(textBox_T_Tail.Text));
  260. if (Params1["后飞"] < 5 || Params1["后飞"] > 100)
  261. {
  262. MessageBox.Show("后飞有效值:5~100 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  263. return false;
  264. }
  265. Params1.Add("限流", Convert.ToUInt16(textBox_MaxCurrent.Text));
  266. if (Params1["限流"] < 5 || Params1["限流"] > 25)
  267. {
  268. MessageBox.Show("限流有效值:5~25 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  269. return false;
  270. }
  271. Params1.Add("温度预警", Convert.ToUInt16(textBox_NTC_Alarm.Text));
  272. Params1.Add("温度保护", Convert.ToUInt16(textBox_NTC_Ptotect.Text));
  273. if (comboBox_NoPBU.Text == "有")
  274. {
  275. Params1.Add("码表", 0x55);
  276. }
  277. else if (comboBox_NoPBU.Text == "无")
  278. {
  279. Params1.Add("码表", 0xAA);
  280. }
  281. else
  282. {
  283. MessageBox.Show("请检查无码表设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  284. }
  285. Params1.Add("轮胎周长", Convert.ToUInt16(textBox_WheelSize.Text));
  286. if (Params1["轮胎周长"] < 100 || Params1["轮胎周长"] > 250)
  287. {
  288. MessageBox.Show("轮胎周长有效值:100~250 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  289. return false;
  290. }
  291. Params1.Add("系列号", Convert.ToUInt16(textBox_Serial.Text));
  292. if (Params1["系列号"] < 1 || Params1["系列号"] > 16)
  293. {
  294. MessageBox.Show("系列号有效值:1~16 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  295. return false;
  296. }
  297. Params1.Add("ECO增益", Convert.ToUInt16(float.Parse(textBox_ECO_Gain.Text) * 100));//放大100倍
  298. Params1.Add("ECO加速", Convert.ToUInt16(float.Parse(textBox_ECO_Acc.Text) * 100));
  299. Params1.Add("NORM增益", Convert.ToUInt16(float.Parse(textBox_NORM_Gain.Text) * 100));
  300. Params1.Add("NORM加速", Convert.ToUInt16(float.Parse(textBox_NORM_Acc.Text) * 100));
  301. Params1.Add("SPORT增益", Convert.ToUInt16(float.Parse(textBox_SPORT_Gain.Text) * 100));
  302. Params1.Add("SPORT加速", Convert.ToUInt16(float.Parse(textBox_SPORT_Acc.Text) * 100));
  303. Params1.Add("TURBO增益", Convert.ToUInt16(float.Parse(textBox_TURBO_Gain.Text) * 100));
  304. Params1.Add("TURBO加速", Convert.ToUInt16(float.Parse(textBox_TURBO_Acc.Text) * 100));
  305. Params1.Add("SMART增益", Convert.ToUInt16(float.Parse(textBox_SMART_Gain.Text) * 100));
  306. Params1.Add("SMART加速", Convert.ToUInt16(float.Parse(textBox_SMART_Acc.Text) * 100));
  307. Params1.Add("车速级数", Convert.ToUInt16(textBox_SpeedSensor.Text));
  308. Params1.Add("踏频启动", Convert.ToUInt16(textBox_CadenceStart.Text));
  309. if (comboBox_GasMode.Text == "不支持")
  310. {
  311. Params1.Add("指拨模式", 0x55);
  312. }
  313. else if (comboBox_GasMode.Text == "支持")
  314. {
  315. Params1.Add("指拨模式", 0xAA);
  316. }
  317. else
  318. {
  319. MessageBox.Show("请检查指拨模式设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  320. }
  321. if (comboBox_SpeedSensor.Text == "传感器")
  322. {
  323. Params1.Add("速度信号来源", 0x55);
  324. }
  325. else if (comboBox_SpeedSensor.Text == "踏频")
  326. {
  327. Params1.Add("速度信号来源", 0xAA);
  328. }
  329. else if (comboBox_SpeedSensor.Text == "通信")
  330. {
  331. Params1.Add("速度信号来源", 0xEE);
  332. }
  333. else
  334. {
  335. MessageBox.Show("请检查速度信号来源设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  336. }
  337. Params1.Add("周长微调", Convert.ToUInt16(textBox_WheelSizeAdj.Text));
  338. Params1.Add("低压保护", Convert.ToUInt16(textBox_UV_Protect.Text));//mV
  339. Params1.Add("推行限速", Convert.ToUInt16(float.Parse(textBox_Walk_SpeedLimit.Text) * 10));//放大10倍
  340. Params1.Add("推行转速", Convert.ToUInt16(textBox_WalkSpeed.Text));
  341. //参数2
  342. Params2.Clear();
  343. if (comboBox_AstSensor.Text == "不支持")
  344. {
  345. Params2.Add("姿态传感器", 0x55);
  346. }
  347. else if (comboBox_AstSensor.Text == "支持")
  348. {
  349. Params2.Add("姿态传感器", 0xAA);
  350. }
  351. else
  352. {
  353. MessageBox.Show("请检查姿态传感器设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  354. }
  355. Params2.Add("俯仰角零偏", Convert.ToUInt16(float.Parse(textBox_Angle_P.Text) * 10));
  356. Params2.Add("横滚角零偏", Convert.ToUInt16(float.Parse(textBox_Angle_R.Text) * 10));
  357. if (comboBox_LightMode.Text == "模式 1")
  358. {
  359. Params2.Add("尾灯模式", 1);
  360. }
  361. else if(comboBox_LightMode.Text == "模式 2")
  362. {
  363. Params2.Add("尾灯模式", 2);
  364. }
  365. else if (comboBox_LightMode.Text == "模式 3")
  366. {
  367. Params2.Add("尾灯模式", 3);
  368. }
  369. else if (comboBox_LightMode.Text == "模式 4")
  370. {
  371. Params2.Add("尾灯模式", 4);
  372. }
  373. //马达参数
  374. MotorParam.Clear();
  375. MotorParam.Add("额定功率", Convert.ToUInt16(textBox_RatePower.Text));
  376. MotorParam.Add("额定转速", Convert.ToUInt16(textBox_RateSpeed.Text));
  377. MotorParam.Add("定子电阻", Convert.ToUInt16(textBox_RotorR.Text));
  378. MotorParam.Add("定子Lq", Convert.ToUInt16(textBox_Rotor_Lq.Text));
  379. MotorParam.Add("定子Ld", Convert.ToUInt16(textBox_Rotor_Ld.Text));
  380. MotorParam.Add("反电动势", Convert.ToUInt16(textBox_E.Text));
  381. MotorParam.Add("额定电压", Convert.ToUInt16(textBox_Rate_Vol.Text));
  382. //其它信息
  383. Otherinfo.Clear();
  384. Otherinfo.Add("生产商", textBox_Mac.Text);
  385. Otherinfo.Add("生产地", textBox_Mac_Addr.Text);
  386. Otherinfo.Add("生产日期", textBox_Mac_Date.Text);
  387. Otherinfo.Add("校验密钥", textBox_Secrect.Text);
  388. Otherinfo.Add("信息1", textBox_Info1.Text);
  389. Otherinfo.Add("信息2", textBox_Info2.Text);
  390. Otherinfo.Add("信息3", textBox_Info3.Text);
  391. //测试阈值
  392. TestThData.Clear();
  393. TestThData.Add("空载电流", Convert.ToUInt16(textBox_NC_Current.Text));
  394. TestThData.Add("车速", Convert.ToUInt16(textBox_SpeedTh.Text));
  395. TestThData.Add("指拨转速", Convert.ToUInt16(textBox_GasSpeedTh.Text));
  396. return true;
  397. }
  398. catch(Exception ex)
  399. {
  400. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  401. return false;
  402. }
  403. }
  404. private void button_Default_Click(object sender, EventArgs e)
  405. {
  406. SetDefault();
  407. ParamsDisplayUpdate();
  408. }
  409. private void button_Generate_Click(object sender, EventArgs e)
  410. {
  411. //空间内容更新到字典
  412. if (DisplaySetToParams() == false)
  413. {
  414. MessageBox.Show("参数生成失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  415. return;
  416. }
  417. //保存为文件
  418. if (textBox_Model.Text == string.Empty) //判断型号是否填写
  419. {
  420. MessageBox.Show("请输入电机型号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  421. return;
  422. }
  423. if (textBox_Client.Text == string.Empty) //判断客户号是否填写
  424. {
  425. textBox_Client.Text = "STD";
  426. }
  427. Regex Reg = new Regex(@"[V][0-9].[0-9].[0-9].[0-9].[0-9]_20\d{6}");
  428. if (Reg.IsMatch(textBox_FW_Version.Text) == false) //判断主控软件版本是否填写
  429. {
  430. MessageBox.Show("主控软件版本格式不正确,例如V1.0.0.0.0_20210101 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  431. return;
  432. }
  433. Reg = new Regex(@"[V][0-9].[0-9].[0-9]_20\d{6}"); //判断TE软件版本是否填写
  434. if (Reg.IsMatch(textBox_TE_FW_Version.Text) == false) //判断TE软件版本是否填写
  435. {
  436. MessageBox.Show("TE软件版本格式不正确,例如V1.0.0_20210101 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  437. return;
  438. }
  439. if (System.IO.Directory.Exists(FilePath) == false)
  440. System.IO.Directory.CreateDirectory(FilePath);
  441. using (StreamWriter file = new StreamWriter(FilePath + 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"))
  442. {
  443. //用户参数1
  444. file.WriteLine("[{0}]", "用户参数1");
  445. foreach (var entry in Params1)
  446. if (entry.Key == "码表")
  447. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "有" : entry.Value == 0xAA ? "无" : "无效");
  448. else if (entry.Key == "指拨模式")
  449. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "不支持" : entry.Value == 0xAA ? "支持" : "无效");
  450. else if (entry.Key == "速度信号来源")
  451. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "传感器" : entry.Value == 0xAA ? "踏频" : entry.Value == 0xEE ? "通信" : "无效");
  452. else
  453. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  454. //用户参数2
  455. file.WriteLine("");
  456. file.WriteLine("[{0}]", "用户参数2");
  457. foreach (var entry in Params2)
  458. if (entry.Key == "姿态传感器")
  459. file.WriteLine("{0},{1},{2}", entry.Key, entry.Value, entry.Value == 0x55 ? "不支持" : entry.Value == 0xAA ? "支持" : "无效");
  460. else
  461. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  462. //马达参数
  463. file.WriteLine("");
  464. file.WriteLine("[{0}]", "马达参数");
  465. foreach (var entry in MotorParam)
  466. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  467. //其它信息
  468. file.WriteLine("");
  469. file.WriteLine("[{0}]", "其它信息");
  470. foreach (var entry in Otherinfo)
  471. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  472. //测试阈值
  473. file.WriteLine("");
  474. file.WriteLine("[{0}]", "测试阈值");
  475. foreach (var entry in TestThData)
  476. file.WriteLine("{0},{1}", entry.Key, entry.Value);
  477. }
  478. MessageBox.Show("参数已生成,进入文件管理页面查看!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  479. }
  480. }
  481. }