ExportForm.cs 48 KB

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