Form1.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. /*------------兼容ZLG的数据类型---------------------------------*/
  12. //1.ZLGCAN系列接口卡信息的数据类型。
  13. public struct VCI_BOARD_INFO
  14. {
  15. public UInt16 hw_Version;
  16. public UInt16 fw_Version;
  17. public UInt16 dr_Version;
  18. public UInt16 in_Version;
  19. public UInt16 irq_Num;
  20. public byte can_Num;
  21. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
  22. public byte[] str_Serial_Num;
  23. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 40)]
  24. public byte[] str_hw_Type;
  25. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
  26. public byte[] Reserved;
  27. }
  28. /////////////////////////////////////////////////////
  29. //2.定义CAN信息帧的数据类型。
  30. unsafe public struct VCI_CAN_OBJ //使用不安全代码
  31. {
  32. public uint ID;
  33. public uint TimeStamp; //时间标识
  34. public byte TimeFlag; //是否使用时间标识
  35. public byte SendType; //发送标志。保留,未用
  36. public byte RemoteFlag; //是否是远程帧
  37. public byte ExternFlag; //是否是扩展帧
  38. public byte DataLen; //数据长度
  39. public fixed byte Data[8]; //数据
  40. public fixed byte Reserved[3];//保留位
  41. }
  42. //3.定义初始化CAN的数据类型
  43. public struct VCI_INIT_CONFIG
  44. {
  45. public UInt32 AccCode;
  46. public UInt32 AccMask;
  47. public UInt32 Reserved;
  48. public byte Filter; //0或1接收所有帧。2标准帧滤波,3是扩展帧滤波。
  49. public byte Timing0; //波特率参数,具体配置,请查看二次开发库函数说明书。
  50. public byte Timing1;
  51. public byte Mode; //模式,0表示正常模式,1表示只听模式,2自测模式
  52. }
  53. /*------------其他数据结构描述---------------------------------*/
  54. //4.USB-CAN总线适配器板卡信息的数据类型1,该类型为VCI_FindUsbDevice函数的返回参数。
  55. public struct VCI_BOARD_INFO1
  56. {
  57. public UInt16 hw_Version;
  58. public UInt16 fw_Version;
  59. public UInt16 dr_Version;
  60. public UInt16 in_Version;
  61. public UInt16 irq_Num;
  62. public byte can_Num;
  63. public byte Reserved;
  64. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
  65. public byte[] str_Serial_Num;
  66. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
  67. public byte[] str_hw_Type;
  68. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
  69. public byte[] str_Usb_Serial;
  70. }
  71. public struct CHGDESIPANDPORT
  72. {
  73. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
  74. public byte[] szpwd;
  75. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
  76. public byte[] szdesip;
  77. public Int32 desport;
  78. public void Init()
  79. {
  80. szpwd = new byte[10];
  81. szdesip = new byte[20];
  82. }
  83. }
  84. public unsafe struct UdsAppMsgInfo
  85. {
  86. public UInt32 xUdsId;
  87. public UInt32 xDataLen;
  88. public byte xUdsRequest;
  89. public fixed byte aDataBuf[150];
  90. }
  91. public unsafe struct UdsAppResponseInfo
  92. {
  93. public bool isPositiveResponse;
  94. public byte responseDataLength;
  95. public fixed byte responseData[100];
  96. }
  97. public struct UdsDID
  98. {
  99. public byte DID_High;
  100. public byte DID_Low;
  101. }
  102. public struct UdsDIDList
  103. {
  104. public UdsDID fingerPrint;
  105. public UdsDID eraseFlash;
  106. public UdsDID checkProgramIndependence;
  107. public UdsDID checkCRCofBlock;
  108. }
  109. public struct FileDownloadDataType
  110. {
  111. public bool isDownloadFlag;
  112. public UInt32 memoryStartAddr;
  113. public UInt32 memorySize;
  114. public UInt16 fileBlockCRC16;
  115. public byte[] fileDownloadDataBuff;
  116. }
  117. namespace WindowsFormsApplication1
  118. {
  119. public partial class Form1 : Form
  120. {
  121. const int DEV_USBCAN = 3;
  122. const int DEV_USBCAN2 = 4;
  123. UInt32 receCount = new UInt32();
  124. /// <summary>
  125. ///
  126. /// </summary>
  127. /// <param name="DeviceType"></param>
  128. /// <param name="DeviceInd"></param>
  129. /// <param name="Reserved"></param>
  130. /// <returns></returns>
  131. /*------------兼容ZLG的函数描述---------------------------------*/
  132. [DllImport("controlcan.dll")]
  133. static extern UInt32 VCI_OpenDevice(UInt32 DeviceType, UInt32 DeviceInd, UInt32 Reserved);
  134. [DllImport("controlcan.dll")]
  135. static extern UInt32 VCI_CloseDevice(UInt32 DeviceType, UInt32 DeviceInd);
  136. [DllImport("controlcan.dll")]
  137. static extern UInt32 VCI_InitCAN(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd, ref VCI_INIT_CONFIG pInitConfig);
  138. [DllImport("controlcan.dll")]
  139. static extern UInt32 VCI_ReadBoardInfo(UInt32 DeviceType, UInt32 DeviceInd, ref VCI_BOARD_INFO pInfo);
  140. [DllImport("controlcan.dll")]
  141. static extern UInt32 VCI_GetReceiveNum(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd);
  142. [DllImport("controlcan.dll")]
  143. static extern UInt32 VCI_ClearBuffer(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd);
  144. [DllImport("controlcan.dll")]
  145. static extern UInt32 VCI_StartCAN(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd);
  146. [DllImport("controlcan.dll")]
  147. static extern UInt32 VCI_ResetCAN(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd);
  148. [DllImport("controlcan.dll")]
  149. static extern UInt32 VCI_Transmit(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd, ref VCI_CAN_OBJ pSend, UInt32 Len);
  150. [DllImport("controlcan.dll")]
  151. static extern UInt32 VCI_Receive(UInt32 DeviceType, UInt32 DeviceInd, UInt32 CANInd, ref VCI_CAN_OBJ pReceive, UInt32 Len, Int32 WaitTime);
  152. /*------------其他函数描述---------------------------------*/
  153. [DllImport("controlcan.dll")]
  154. static extern UInt32 VCI_ConnectDevice(UInt32 DevType, UInt32 DevIndex);
  155. [DllImport("controlcan.dll")]
  156. static extern UInt32 VCI_UsbDeviceReset(UInt32 DevType, UInt32 DevIndex, UInt32 Reserved);
  157. [DllImport("controlcan.dll")]
  158. static extern UInt32 VCI_FindUsbDevice(ref VCI_BOARD_INFO1 pInfo);
  159. private delegate void CrossThreadOperationControl();
  160. /*------------函数描述结束---------------------------------*/
  161. /*------------全局变量声明---------------------------------*/
  162. //private float X;//当前窗体的宽度
  163. //private float Y;//当前窗体的高度
  164. //private bool IsFirst = true;
  165. bool isForm1Colsed = false;
  166. byte controllerChooseFlag = 0xFF;
  167. static UInt32 m_devtype = 4;//USBCAN2
  168. UInt32 m_devind = 0;
  169. UInt32 m_canind = 0;
  170. UInt32[] m_arrdevtype = new UInt32[20];
  171. bool UpdateServiceSwitch = false;
  172. VCI_CAN_OBJ[] receobj = new VCI_CAN_OBJ[20];
  173. bool buttStartCan = false;
  174. bool buttStartDownload = false;
  175. public Form1()
  176. {
  177. InitializeComponent();
  178. }
  179. private void button1_Click(object sender, EventArgs e)
  180. {
  181. }
  182. private void Form1_Load(object sender, EventArgs e)
  183. {
  184. Int32 curindex = 0;
  185. comboBox_devtype.Items.Clear();
  186. curindex = comboBox_devtype.Items.Add("DEV_USBCAN");
  187. m_arrdevtype[curindex] = DEV_USBCAN;
  188. //comboBox_devtype.Items[2] = "VCI_USBCAN1";
  189. //m_arrdevtype[2]= VCI_USBCAN1 ;
  190. curindex = comboBox_devtype.Items.Add("DEV_USBCAN2");
  191. m_arrdevtype[curindex] = DEV_USBCAN2;
  192. //comboBox_devtype.Items[3] = "VCI_USBCAN2";
  193. //m_arrdevtype[3]= VCI_USBCAN2 ;
  194. comboBox_BoardIndex.SelectedIndex = 0;
  195. comboBox_CANIndex.SelectedIndex = 0;
  196. comboBox_DeviceIndex.SelectedIndex = 0;
  197. comboBox_CANIndex.SelectedIndex = 0;
  198. comboBox_MsgType.SelectedIndex = 1;
  199. comboBox_UC_TMSMod.SelectedIndex = 0;
  200. //comboBox_ControllerChoose.SelectedIndex = 0x00;
  201. //comboBox_MsgType.SelectedIndex = 0x01;
  202. //canMsgType = (byte)(comboBox_MsgType.SelectedIndex);
  203. //controllerChooseFlag = (byte)(comboBox_ControllerChoose.SelectedIndex + 1);
  204. //
  205. comboBox_devtype.SelectedIndex = 1;
  206. comboBox_devtype.MaxDropDownItems = comboBox_devtype.Items.Count;
  207. setBoxAndButtonEnalbe(true);
  208. isForm1Colsed = false;
  209. }
  210. private void setBoxAndButtonEnalbe(bool trueOrfalse)
  211. {
  212. comboBox_CANIndex.Enabled = trueOrfalse;
  213. comboBox_devtype.Enabled = trueOrfalse;
  214. comboBox_BoardIndex.Enabled = trueOrfalse;
  215. comboBox_DeviceIndex.Enabled = trueOrfalse;
  216. }
  217. private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  218. {
  219. if (buttStartCan == true)
  220. {
  221. //VCI_CloseDevice(m_devtype, m_devind);
  222. }
  223. //autoSaveFile();
  224. //UpdateStep = 0xFF;
  225. isForm1Colsed = true;
  226. //setBoxAndButtonEnalbe(false);
  227. }
  228. private void button_StartCAN_Click(object sender, EventArgs e)
  229. {
  230. if (buttStartCan == true)
  231. {
  232. buttStartCan = false;
  233. timer_rec.Enabled = buttStartCan == true ? true : false;
  234. timer_send.Enabled = buttStartCan == true ? true : false;
  235. }
  236. else
  237. {
  238. canMsgType = (byte)(comboBox_MsgType.SelectedIndex);
  239. m_devtype = m_arrdevtype[comboBox_devtype.SelectedIndex];
  240. m_devind = 0;
  241. m_canind = (UInt32)comboBox_CANIndex.SelectedIndex;
  242. m_devind = (UInt32)comboBox_DeviceIndex.SelectedIndex;
  243. if (VCI_OpenDevice(m_devtype, m_devind, 0) == 0)
  244. {
  245. MessageBox.Show("打开设备失败,请检查设备类型和设备索引号是否正确", "错误",
  246. MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  247. return;
  248. }
  249. buttStartCan = true;
  250. timer_rec.Interval = 10;
  251. timer_rec.Enabled = buttStartCan == true ? true : false;
  252. timer_send.Enabled = buttStartCan == true ? true : false;
  253. VCI_INIT_CONFIG config = new VCI_INIT_CONFIG();
  254. if (comboBox_MsgType.Text == "标准帧")
  255. {
  256. config.AccCode = 0;
  257. config.AccMask = 0xffffffff;
  258. //config.AccCode = Convert.ToUInt32(textBox_responseAddr.Text, 16) << 21;
  259. //config.AccMask = 0x1FFFFF;
  260. config.Filter = 0x02;//只接收符合要求的标准帧
  261. //0或1接收所有帧。2标准帧滤波,3是扩展帧滤波。
  262. }
  263. else if (comboBox_MsgType.Text == "扩展帧")
  264. {
  265. config.AccCode = 0;
  266. config.AccMask = 0xffffffff;
  267. //config.AccCode = Convert.ToUInt32(textBox_responseAddr.Text, 16) << 3;
  268. //config.AccMask = 0x07;
  269. config.Filter = 0x03;//只接收符合要求的扩展帧
  270. }
  271. //波特率设置为250K
  272. switch (comboBox_BoardIndex.Text)
  273. {
  274. case "250K":
  275. config.Timing0 = 0x01;
  276. config.Timing1 = 0x1C;
  277. break;
  278. case "500K":
  279. config.Timing0 = 0x00;
  280. config.Timing1 = 0x1C;
  281. break;
  282. default: //250K
  283. config.Timing0 = 0x01;
  284. config.Timing1 = 0x1C;
  285. break;
  286. }
  287. //config.Filter = 0x00;//接收所有报文
  288. config.Mode = (Byte)0x00; //正常工作模式
  289. VCI_InitCAN(m_devtype, m_devind, m_canind, ref config);
  290. }
  291. button_StartCAN.Text = buttStartCan == true ? "停止CAN" : "启动CAN";
  292. button_StartCAN.BackColor = buttStartCan == true ? Color.GreenYellow : SystemColors.Control;
  293. if (buttStartCan == false)
  294. {
  295. VCI_ResetCAN(m_devtype, m_devind, m_canind);
  296. comboBox_devtype.Enabled = true;
  297. comboBox_CANIndex.Enabled = true;
  298. comboBox_DeviceIndex.Enabled = true;
  299. comboBox_BoardIndex.Enabled = true;
  300. comboBox_MsgType.Enabled = true;
  301. //comboBox_ControllerChoose.Enabled = true;
  302. return;
  303. }
  304. VCI_StartCAN(m_devtype, m_devind, m_canind);
  305. comboBox_devtype.Enabled = false;
  306. comboBox_CANIndex.Enabled = false;
  307. comboBox_DeviceIndex.Enabled = false;
  308. comboBox_BoardIndex.Enabled = false;
  309. comboBox_MsgType.Enabled = false;
  310. //comboBox_ControllerChoose.Enabled = false;
  311. }
  312. private void timer_rec_Tick(object sender, EventArgs e)
  313. {
  314. if (receCount == 0)
  315. {
  316. uint res = VCI_GetReceiveNum(m_devtype, m_devind, m_canind);
  317. if (res > 0)
  318. {
  319. receobj = new VCI_CAN_OBJ[20];
  320. receCount = 0;
  321. receCount = VCI_Receive(m_devtype, m_devind, m_canind, ref receobj[0], 15, 0);
  322. if (receCount == 0xFFFFFFFF)
  323. {
  324. receCount = 0;
  325. }
  326. for (int i = 0; i < receCount; i++)
  327. {
  328. CAN_Receive_Decode(receobj[i]);
  329. //strCanMsg += CANMsgRecord(receobj[i], "rx");
  330. }
  331. receCount = 0;
  332. }
  333. else
  334. {
  335. }
  336. }
  337. }
  338. int getTwoByte(Byte data, int position)
  339. {
  340. return ((0X03 << position) & data) >> position;
  341. }
  342. private void CAN_Receive_Decode(VCI_CAN_OBJ data)
  343. {
  344. int bypassRelay = 0;
  345. byte RCB_bypass_rad = 0;
  346. byte RCB_bypass_HE = 0;
  347. byte RCB_pump = 0;
  348. byte RCB_fan = 0;
  349. byte RCB_PTC = 0;
  350. byte RCB_modTMax = 0;
  351. byte RCB_modTMin = 0;
  352. byte RCB_battery_inT = 0;
  353. byte RCB_battery_outT = 0;
  354. byte RCB_pdu_inT = 0;
  355. byte RCB_pdu_outT = 0;
  356. byte RCB_motor_outT = 0;
  357. byte RCB_rad_outT = 0;
  358. byte RCB_HE_outT = 0;
  359. byte RCB_EvT = 0;
  360. int RCB_battU = 0;
  361. int RCB_battCurr = 0;
  362. byte RCB_fltCode = 0;
  363. byte RCB_battSt = 0;
  364. UInt32 RCB_flowmeter1 = 0;
  365. UInt32 RCB_flowmeter2 = 0;
  366. byte RCB_T1 = 0;
  367. byte RCB_T2 = 0;
  368. byte RCB_T3 = 0;
  369. byte RCB_T4 = 0;
  370. unsafe
  371. {
  372. switch (data.ID)
  373. {
  374. case 0X1810EECB:
  375. bypassRelay = getTwoByte(data.Data[0], 2);
  376. if (1 == bypassRelay)
  377. {
  378. textBox_RCB_relay.Text = "开";
  379. }
  380. else
  381. {
  382. textBox_RCB_relay.Text = "关";
  383. }
  384. RCB_bypass_rad = data.Data[1];
  385. RCB_bypass_HE = data.Data[2];
  386. RCB_pump = data.Data[3];
  387. RCB_fan = data.Data[4];
  388. RCB_PTC = data.Data[5];
  389. textBox_RCB_bypass_rad.Text = RCB_bypass_rad.ToString();
  390. textBox_RCB_bypass_HE.Text = RCB_bypass_HE.ToString();
  391. textBox_RCB_pump.Text = RCB_pump.ToString();
  392. textBox_RCB_fan.Text = RCB_fan.ToString();
  393. textBox_RCB_PTC.Text = RCB_PTC.ToString();
  394. byte RCB_TMSMod = data.Data[6];
  395. byte RCB_SOC = data.Data[7];
  396. string[] tmsMod = { "关机模式","制冷模式","制热模式","自循环模式","ERROR"};
  397. if(RCB_TMSMod < 4)
  398. {
  399. textBox_RCB_TMSMod.Text = tmsMod[RCB_TMSMod];
  400. }
  401. else
  402. textBox_RCB_TMSMod.Text = tmsMod[4];
  403. textBox_RCB_SOC.Text = ((RCB_SOC + 0.0) * 0.4).ToString();
  404. break;
  405. case 0X1811EECB:
  406. RCB_modTMax = data.Data[0];
  407. RCB_modTMin = data.Data[1];
  408. RCB_battery_inT = data.Data[2];
  409. RCB_battery_outT = data.Data[3];
  410. RCB_pdu_inT = data.Data[4];
  411. RCB_pdu_outT = data.Data[5];
  412. RCB_motor_outT = data.Data[6];
  413. RCB_rad_outT = data.Data[7];
  414. textBox_RCB_modTMax.Text = (RCB_modTMax - 40).ToString();
  415. textBox_RCB_modTMin.Text = (RCB_modTMin - 40).ToString();
  416. textBox_RCB_battery_inT.Text = (RCB_battery_inT - 40).ToString();
  417. textBox_RCB_battery_outT.Text = (RCB_battery_outT - 40).ToString();
  418. textBox_RCB_pdu_inT.Text = (RCB_pdu_inT - 40).ToString();
  419. textBox_RCB_pdu_outT.Text = (RCB_pdu_outT - 40).ToString();
  420. textBox_RCB_motor_outT.Text = (RCB_motor_outT - 40).ToString();
  421. textBox_RCB_rad_outT.Text = (RCB_rad_outT - 40).ToString();
  422. break;
  423. case 0X1812EECB:
  424. RCB_HE_outT = data.Data[0];
  425. RCB_EvT = data.Data[1];
  426. RCB_battU = data.Data[3] + (data.Data[2] << 8);
  427. RCB_battCurr = data.Data[5] + (data.Data[4] << 8);
  428. RCB_fltCode = data.Data[6];
  429. RCB_battSt = data.Data[7];
  430. textBox_RCB_HE_outT.Text = (RCB_HE_outT - 40).ToString();
  431. textBox_RCB_EvT.Text = (RCB_EvT - 40).ToString();
  432. textBox_RCB_battU.Text = ((RCB_battU + 0.0)/10.0).ToString();
  433. textBox_RCB_battCurr.Text = ((RCB_battCurr + 0.0)/10.0 - 1000.0).ToString();
  434. textBox_RCB_fltCode.Text = (RCB_fltCode).ToString();
  435. textBox_RCB_battSt.Text = (RCB_battSt).ToString();
  436. break;
  437. case 0X1813EECB:
  438. byte[] tmp = new byte[8];
  439. for (int i = 0; i < 8; i++)
  440. tmp[i] = data.Data[i];
  441. RCB_flowmeter1 = BitConverter.ToUInt32(tmp, 0);
  442. RCB_flowmeter2 = BitConverter.ToUInt32(tmp, 4);
  443. textBox_RCB_flowmeter1.Text = ((RCB_flowmeter1 + 0.0)/100.0).ToString();
  444. textBox_RCB_flowmeter2.Text = ((RCB_flowmeter2 + 0.0) / 100.0).ToString();
  445. break;
  446. default:break;
  447. }
  448. }
  449. }
  450. byte twoByteMove( int position, bool ENABLE)
  451. {
  452. byte src = 0;
  453. if (true == ENABLE)
  454. src = 1;
  455. else
  456. src = 0;
  457. return (byte)(src << position);
  458. }
  459. byte canMsgType;
  460. private void CAN_Send_Decode_100ms()
  461. {
  462. byte tmp = 0;
  463. VCI_CAN_OBJ data = new VCI_CAN_OBJ();
  464. unsafe
  465. {
  466. //0X1801CBEE
  467. data.ID = 0X1801CBEE;
  468. data.DataLen = 8;
  469. data.ExternFlag = canMsgType;
  470. tmp += twoByteMove(0, comboBox_HandControlEnable.Text.Equals("使能"));
  471. tmp += twoByteMove(2, comboBox_RelayControlEnable.Text.Equals("开"));
  472. data.Data[0] = tmp;
  473. if (numericUpDown_RaThreeSet.Text != "")
  474. data.Data[1] = (byte)numericUpDown_RaThreeSet.Value;// Convert.ToByte(numericUpDown_RaThreeSet.Text);
  475. if (numericUpDown_ExThreeSet.Text != "")
  476. data.Data[2] = (byte)numericUpDown_ExThreeSet.Value;// Convert.ToByte(numericUpDown_ExThreeSet.Text);
  477. for(int i = 1; i < 3; i++)
  478. {
  479. data.Data[i] = data.Data[i] > (byte)180 ? (byte)180 : data.Data[i];
  480. }
  481. if (numericUpDown_WaPuSpConEnable.Text != "")
  482. data.Data[3] = (byte)numericUpDown_WaPuSpConEnable.Value;// Convert.ToByte(numericUpDown_WaPuSpConEnable.Text);
  483. if (numericUpDown_FanSpeedEnable.Text != "")
  484. data.Data[4] = (byte)numericUpDown_FanSpeedEnable.Value;// Convert.ToByte(numericUpDown_FanSpeedEnable.Text);
  485. if (numericUpDown_PTC_ControlEnable.Text != "")
  486. data.Data[5] = (byte)numericUpDown_FanSpeedEnable.Value;// Convert.ToByte(numericUpDown_PTC_ControlEnable.Text);
  487. for (int i = 3; i < 6; i++)
  488. {
  489. data.Data[i] = data.Data[i] > (byte)100 ? (byte)100 : data.Data[i];
  490. }
  491. data.Data[6] = (byte)comboBox_UC_TMSMod.SelectedIndex;
  492. VCI_Transmit(m_devtype, m_devind, m_canind,ref data, 1);
  493. }
  494. }
  495. private void timer_send_Tick(object sender, EventArgs e)
  496. {
  497. CAN_Send_Decode_100ms();
  498. }
  499. }
  500. }