1
0

SDMDisplay.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except in compliance
  4. with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2012
  6. All rights reserved.
  7. */
  8. #include "StdAfx.h"
  9. #include "SDMDisplay.h"
  10. /**************************************************************************
  11. * SDMDisplay::ANT_eventNotification
  12. *
  13. * Process ANT channel event
  14. *
  15. * ucEventCode_: code of ANT channel event
  16. * pucEventBuffer_: pointer to buffer containing data received from ANT,
  17. * or a pointer to the transmit buffer in the case of an EVENT_TX
  18. *
  19. * returns: N/A
  20. *
  21. **************************************************************************/
  22. void SDMDisplay::ANT_eventNotification(UCHAR ucEventCode_, UCHAR* pucEventBuffer_)
  23. {
  24. switch(ucEventCode_)
  25. {
  26. case EVENT_RX_ACKNOWLEDGED:
  27. case EVENT_RX_BURST_PACKET: // intentional fall thru
  28. case EVENT_RX_BROADCAST:
  29. HandleReceive((UCHAR*) pucEventBuffer_);
  30. break;
  31. case EVENT_TRANSFER_TX_COMPLETED:
  32. ucAckRetryCount = 0; // Reset retransmission counter
  33. ucMsgExpectingAck = 0; // Clear pending msg code
  34. UpdateDisplayAckStatus(ACK_SUCCESS); // Tx successful
  35. break;
  36. case EVENT_TRANSFER_TX_FAILED:
  37. case EVENT_ACK_TIMEOUT: // Intentional fall thru
  38. if(ucMsgExpectingAck)
  39. {
  40. if(HandleRetransmit())
  41. UpdateDisplayAckStatus(ACK_RETRY); // Data was retransmitted
  42. else
  43. UpdateDisplayAckStatus(ACK_FAIL); // Maximum number of retries exceeded, Tx failed
  44. }
  45. break;
  46. default:
  47. break;
  48. }
  49. }
  50. /**************************************************************************
  51. * SDMDisplay::InitializeSim
  52. *
  53. * Initializes simulator variables
  54. *
  55. * returns: N/A
  56. *
  57. **************************************************************************/
  58. void SDMDisplay::InitializeSim()
  59. {
  60. ucLatency32 = 0;
  61. usSpeed256 = 0;
  62. usCadence16 = 0;
  63. sStatusFlags.ucBatteryStatus = 0;
  64. sStatusFlags.ucHealth = 0;
  65. sStatusFlags.ucLocation = 0;
  66. sStatusFlags.ucUseState = 0;
  67. ucStrideCount = 0;
  68. usTime200 = 0;
  69. usDistance16 = 0;
  70. ucCalCount = 0;
  71. ulAcumStrideCount = 0;
  72. ulAcumDistance16 = 0;
  73. ulAcumTime200 = 0;
  74. ulAcumCalCount = 0;
  75. ucMsgExpectingAck = 0;
  76. ucCapabFlags = 0;
  77. ucRqTxTimes = System::Convert::ToByte(this->numericUpDown_RqTxTimes->Value);
  78. bRqAckReply = FALSE;
  79. bRqTxUntilAck = FALSE;
  80. bInitialized = FALSE;
  81. bCalInitialized = FALSE;
  82. }
  83. /**************************************************************************
  84. * SDMDisplay::HandleReceive
  85. *
  86. * Decodes received data
  87. *
  88. * pucRxBuffer_: pointer to the buffer containing the received data
  89. *
  90. * returns: N/A
  91. *
  92. **************************************************************************/
  93. void SDMDisplay::HandleReceive(UCHAR* pucRxBuffer_)
  94. {
  95. UCHAR ucPageNum = pucRxBuffer_[0];
  96. ULONG ulTempHolder = 0;
  97. switch(ucPageNum)
  98. {
  99. case SDM_PAGE1: //Main page
  100. usTime200 = pucRxBuffer_[1]; // Current time, fractional portion, in 1/200 seconds
  101. usTime200 += pucRxBuffer_[2] * 200; // Convert integer portion of time to 1/200 seconds
  102. usDistance16 = pucRxBuffer_[3] << 4; // Distance, integer portion, in 1/16 seconds
  103. usDistance16 |= (pucRxBuffer_[4] & 0xF0) >> 4; // Distance, fractional part, in 1/16 seconds
  104. usSpeed256 = (pucRxBuffer_[4] & 0x0F) << 8; // Speed, in 1/256 seconds
  105. usSpeed256 |= pucRxBuffer_[5]; // Speed, fractional part, in 1/256 seconds
  106. ucStrideCount = pucRxBuffer_[6]; // Stride count
  107. ucLatency32 = pucRxBuffer_[7]; // Latency (1/32 seconds)
  108. if(!bInitialized)
  109. { // Initialize previous values for calculation of cumulative values
  110. ucPreviousStrideCount = ucStrideCount;
  111. usPreviousDistance16 = usDistance16;
  112. usPreviousTime200 = usTime200;
  113. bInitialized = TRUE;
  114. }
  115. break;
  116. case SDM_PAGE2:
  117. case SDM_PAGE3:
  118. case SDM_PAGE4:
  119. case SDM_PAGE5:
  120. case SDM_PAGE6:
  121. case SDM_PAGE7:
  122. case SDM_PAGE8:
  123. case SDM_PAGE9:
  124. case SDM_PAGE10:
  125. case SDM_PAGE11:
  126. case SDM_PAGE12:
  127. case SDM_PAGE13:
  128. case SDM_PAGE14:
  129. case SDM_PAGE15: // Intentional fall thru (pages 2 - 15 should have bytes 3,4,5, and 7 of the template on Page 2).
  130. usCadence16 = pucRxBuffer_[3] << 4; // Cadence (1/16 seconds)
  131. usCadence16 |= (pucRxBuffer_[4] & 0xF0) >>4;
  132. usSpeed256 = (pucRxBuffer_[4] & 0x0F) << 8; // Speed (1/256 seconds)
  133. usSpeed256 |= pucRxBuffer_[5];
  134. sStatusFlags.ucLocation = (pucRxBuffer_[7] & SDM_LOCATION_MASK) >> SDM_LOCATION_SHIFT; // Decode status flags
  135. sStatusFlags.ucBatteryStatus = (pucRxBuffer_[7] & SDM_BAT_MASK) >> SDM_BAT_SHIFT;
  136. sStatusFlags.ucHealth = (pucRxBuffer_[7] & SDM_HEALTH_MASK) >> SDM_HEALTH_SHIFT;
  137. sStatusFlags.ucUseState = (pucRxBuffer_[7] & SDM_STATE_MASK) >> SDM_STATE_SHIFT;
  138. // instead of handling Page 3 Calories separately, handle here for now. If more pages are added
  139. // should pull them out separately for readability.
  140. if (ucPageNum == SDM_PAGE3)
  141. ucCalCount = pucRxBuffer_[6];
  142. if(!bCalInitialized)
  143. { // Initialize previous values for calculation of cumulative values
  144. ucPreviousCalCount = ucCalCount;
  145. bCalInitialized = TRUE;
  146. }
  147. break;
  148. case SDM_PAGE16: // request page
  149. ulStridesAccum = pucRxBuffer_[1];
  150. ulTempHolder = pucRxBuffer_[2] & 0xFF;
  151. ulStridesAccum = ulStridesAccum | (ulTempHolder << 8);
  152. ulTempHolder = pucRxBuffer_[3] & 0xFF;
  153. ulStridesAccum = ulStridesAccum | (ulTempHolder << 16);
  154. ulDistanceAccum = pucRxBuffer_[4];
  155. ulTempHolder = pucRxBuffer_[5] & 0xFF;
  156. ulDistanceAccum = ulDistanceAccum | (ulTempHolder << 8);
  157. ulTempHolder = pucRxBuffer_[6] & 0xFF;
  158. ulDistanceAccum = ulDistanceAccum | (ulTempHolder << 16);
  159. ulTempHolder = pucRxBuffer_[7] & 0xFF;
  160. ulDistanceAccum = ulDistanceAccum | (ulTempHolder << 24);
  161. break;
  162. case SDM_PAGE22: // request page
  163. ucCapabFlags = pucRxBuffer_[1];
  164. break;
  165. case CommonData::PAGE80:
  166. case CommonData::PAGE81: // Intentional fall thru
  167. try
  168. {
  169. commonPages->Decode(pucRxBuffer_);
  170. }
  171. catch(CommonData::Error^ errorCommon)
  172. {
  173. }
  174. break;
  175. default:
  176. break;
  177. }
  178. // Update calculated data if dealing with a new event
  179. if(ucStrideCount != ucPreviousStrideCount)
  180. {
  181. // Update cumulative stride count
  182. if(ucStrideCount > ucPreviousStrideCount)
  183. ulAcumStrideCount += (ucStrideCount - ucPreviousStrideCount);
  184. else
  185. ulAcumStrideCount += (UCHAR) (0xFF - ucPreviousStrideCount + ucStrideCount + 1);
  186. // Update cumulative time
  187. if(usTime200 > usPreviousTime200)
  188. ulAcumTime200 += (usTime200 - usPreviousTime200);
  189. else
  190. ulAcumTime200 += (USHORT) (0xFFFF - usPreviousTime200 + usTime200 + 1);
  191. // Update cumulative distance
  192. if(usDistance16> usPreviousDistance16)
  193. ulAcumDistance16 += (usDistance16 - usPreviousDistance16);
  194. else
  195. ulAcumDistance16 += (0xFFF - usPreviousDistance16 + usDistance16 + 1) & 0x0FFF;
  196. ucPreviousStrideCount = ucStrideCount;
  197. usPreviousTime200 = usTime200;
  198. usPreviousDistance16 = usDistance16;
  199. }
  200. // Update calculated data if dealing with a new event for calories
  201. if (ucCalCount != ucPreviousCalCount)
  202. {
  203. if(ucCalCount > ucPreviousCalCount)
  204. ulAcumCalCount += (ucCalCount - ucPreviousCalCount);
  205. else
  206. ulAcumCalCount += (UCHAR) (0xFF - ucPreviousCalCount + ucCalCount + 1);
  207. ucPreviousCalCount = ucCalCount;
  208. }
  209. UpdateDisplay(ucPageNum);
  210. }
  211. /**************************************************************************
  212. * SDMDisplay::UpdateDisplay
  213. *
  214. * Shows received decoded data on GUI
  215. *
  216. * ucPageNum_: received page
  217. *
  218. * returns: N/A
  219. *
  220. **************************************************************************/
  221. void SDMDisplay::UpdateDisplay(UCHAR ucPageNum_)
  222. {
  223. switch(ucPageNum_)
  224. {
  225. case SDM_PAGE1:
  226. // Update stride count (required field)
  227. this->label_TransStrideCountDisplay->Text = ucStrideCount.ToString(); // Stride count
  228. this->label_P1StrideCountDisplay->Text = ulAcumStrideCount.ToString(); // Cumulative stride count
  229. if(usTime200)
  230. {
  231. this->label_Trn_EventTimeDisplay->Text = ((double)usTime200/200).ToString(); // Time in seconds
  232. this->label_Calc_TimeDisplay->Text = ((double) ulAcumTime200/200).ToString(); // Cumulative time in seconds
  233. }
  234. else
  235. {
  236. this->label_Trn_EventTimeDisplay->Text = "Off";
  237. }
  238. if(usDistance16)
  239. {
  240. this->label_TransDistDisplay->Text = ((double) usDistance16/16).ToString(); // Distance in m
  241. this->label_P1TotDistDisplay->Text = System::Math::Round((double) ulAcumDistance16/16 , 4).ToString(); // Cumulative distance in m
  242. }
  243. else
  244. {
  245. this->label_TransDistDisplay->Text = "Off";
  246. }
  247. if(usSpeed256)
  248. {
  249. this->label_TransInstSpeedDisplay->Text = ((double)usSpeed256/256).ToString(); // Speed in m/s
  250. this->label_Calc_SpeedDisplay->Text = System::Math::Round((double)usSpeed256/256 , 3).ToString(); // Speed in m/s
  251. this->label_Calc_PaceDisplay->Text = System::Math::Round((double) (256*1000/60)/usSpeed256 , 2).ToString(); // Pace in min/km
  252. }
  253. else
  254. {
  255. this->label_TransInstSpeedDisplay->Text = "Off";
  256. }
  257. if(ulAcumTime200) // Calculate average speed
  258. this->label_Calc_AvgSpdDisplay->Text = System::Math::Round((double) 12.5 * ulAcumDistance16/ulAcumTime200 , 3).ToString(); // Dist(1/16m) / Time(1/200s) -> m/s
  259. else
  260. this->label_Calc_AvgSpdDisplay->Text = "Off";
  261. if(ucLatency32)
  262. this->label_TransLatencyDisplay->Text = ((double) 1000 * ucLatency32/32).ToString(); // Latency in ms
  263. else // Unused
  264. this->label_TransLatencyDisplay->Text = "Off";
  265. break;
  266. case SDM_PAGE2:
  267. case SDM_PAGE3:
  268. case SDM_PAGE4:
  269. case SDM_PAGE5:
  270. case SDM_PAGE6:
  271. case SDM_PAGE7:
  272. case SDM_PAGE8:
  273. case SDM_PAGE9:
  274. case SDM_PAGE10:
  275. case SDM_PAGE11:
  276. case SDM_PAGE12:
  277. case SDM_PAGE13:
  278. case SDM_PAGE14:
  279. case SDM_PAGE15: // Intentional fall thru (pages 2 - 15 should have bytes 3,4,5, and 7 of the template on Page 2).
  280. if(usCadence16) // 0 is sent if disabled on sensor
  281. {
  282. this->label_Calc_CadenceDisplay->Text = ((double)usCadence16/16).ToString(); // Cadence in spm
  283. this->label_TransCadenceDisplay->Text = ((double)usCadence16/16).ToString();
  284. }
  285. else
  286. this->label_TransCadenceDisplay->Text = "Off";
  287. if(usSpeed256)
  288. {
  289. this->label_TransInstSpeedDisplay->Text = ((double)usSpeed256/256).ToString(); // Speed in m/s
  290. this->label_Calc_SpeedDisplay->Text = System::Math::Round((double)usSpeed256/256 , 3).ToString(); // Speed in m/s
  291. this->label_Calc_PaceDisplay->Text = System::Math::Round((double) (256*1000/60)/usSpeed256 , 2).ToString(); // Pace in min/km
  292. }
  293. else
  294. {
  295. this->label_TransInstSpeedDisplay->Text = "Off";
  296. }
  297. try{
  298. this->listBox_P2Location->SelectedIndex = sStatusFlags.ucLocation;
  299. this->listBox_P2Battery->SelectedIndex = sStatusFlags.ucBatteryStatus;
  300. this->listBox_P2Health->SelectedIndex = sStatusFlags.ucHealth;
  301. this->listBox_P2Use->SelectedIndex = sStatusFlags.ucUseState;
  302. }
  303. catch(...){
  304. //bad sent flags received
  305. }
  306. // instead of handling Page 3 Calories separately, handle here for now. If more pages are added
  307. // should pull them out separately for readability.
  308. if (ucPageNum_ == SDM_PAGE3) // calories must be enabled if page3 is enabled
  309. {
  310. this->label_TransCalDisplay->Text = ucCalCount.ToString(); // Current Calorie count
  311. this->label_P2Calories->Text = ulAcumCalCount.ToString(); // Total count
  312. }
  313. else
  314. this->label_TransCalDisplay->Text = "Off";
  315. break;
  316. case SDM_PAGE16:
  317. this->label_RqStridesDisplay->Text = ulStridesAccum.ToString();
  318. this->label_RqDistanceDisplay->Text = ulDistanceAccum.ToString();
  319. break;
  320. case SDM_PAGE22:
  321. if ((ucCapabFlags & SDM_TIME_MASK) > 0)
  322. this->label_RqTime->ForeColor = System::Drawing::Color::Green;
  323. else
  324. this->label_RqTime->ForeColor = System::Drawing::Color::Red;
  325. if ((ucCapabFlags & SDM_DISTANCE_MASK) > 0)
  326. this->label_RqDistance->ForeColor = System::Drawing::Color::Green;
  327. else
  328. this->label_RqDistance->ForeColor = System::Drawing::Color::Red;
  329. if ((ucCapabFlags & SDM_SPEED_MASK) > 0)
  330. this->label_RqSpeed->ForeColor = System::Drawing::Color::Green;
  331. else
  332. this->label_RqSpeed->ForeColor = System::Drawing::Color::Red;
  333. if ((ucCapabFlags & SDM_LATENCY_MASK) > 0)
  334. this->label_RqLatency->ForeColor = System::Drawing::Color::Green;
  335. else
  336. this->label_RqLatency->ForeColor = System::Drawing::Color::Red;
  337. if ((ucCapabFlags & SDM_CADENCE_MASK) > 0)
  338. this->label_RqCadence->ForeColor = System::Drawing::Color::Green;
  339. else
  340. this->label_RqCadence->ForeColor = System::Drawing::Color::Red;
  341. if ((ucCapabFlags & SDM_CALORIES_MASK) > 0)
  342. this->label_RqCalories->ForeColor = System::Drawing::Color::Green;
  343. else
  344. this->label_RqCalories->ForeColor = System::Drawing::Color::Red;
  345. break;
  346. case CommonData::PAGE80:
  347. this->label_Glb_HardwareVerDisplay->Text = commonPages->ucHwVersion.ToString();
  348. this->label_Glb_ManfIDDisplay->Text = commonPages->usMfgID.ToString();
  349. this->label_Glb_ModelNumDisplay->Text = commonPages->usModelNum.ToString();
  350. break;
  351. case CommonData::PAGE81:
  352. this->label_Glb_SoftwareVerDisplay->Text = commonPages->ucSwVersion.ToString();
  353. if(commonPages->ulSerialNum == 0xFFFFFFFF)
  354. this->label_Glb_SerialNumDisplay->Text = "N/A";
  355. else
  356. this->label_Glb_SerialNumDisplay->Text = commonPages->ulSerialNum.ToString();
  357. break;
  358. }
  359. }
  360. /**************************************************************************
  361. * SDMDisplay::SendRequestMsg
  362. *
  363. * Sends an acknoledged Page Requset message according to the message code
  364. *
  365. * ucMsgCode_: message ID of the calibration message to send
  366. * Supported messages:
  367. * - Page 16 Request (Distance and Strides)
  368. * - Page 22 Request (Capabilities)
  369. *
  370. * returns: N/A
  371. *
  372. **************************************************************************/
  373. void SDMDisplay::SendRequestMsg(UCHAR ucMsgCode_)
  374. {
  375. UCHAR aucAckBuffer[8] = {0,0,0,0,0,0,0,0};
  376. switch(ucMsgCode_)
  377. {
  378. case SDM_PAGE16: // Page 16 Request (Distance and Strides)
  379. EncodeRequestMsg(ucMsgCode_, aucAckBuffer);
  380. break;
  381. case SDM_PAGE22: // Page 22 Request (Capabilities)
  382. EncodeRequestMsg(ucMsgCode_, aucAckBuffer);
  383. break;
  384. default:
  385. return; // Do not transmit if unsupported message code
  386. }
  387. // Send acknowledged message
  388. if(!ucMsgExpectingAck) // If this message is not a retransmission
  389. {
  390. ucAckRetryCount = 0; // Reset retransmission counter
  391. ucMsgExpectingAck = ucMsgCode_; // Set code to message for which an ACK wil be expected
  392. }
  393. requestAckMsg(aucAckBuffer); // Send message
  394. }
  395. /**************************************************************************
  396. * SDMDisplay::HandleRetransmit
  397. *
  398. * Retransmits request message, up to the maximum retransmission number
  399. *
  400. * returns: TRUE if message was retransmitted
  401. * FALSE if maximum number of retransmissions was reached
  402. *
  403. **************************************************************************/
  404. BOOL SDMDisplay::HandleRetransmit()
  405. {
  406. BOOL bSuccess = TRUE;
  407. if(ucMsgExpectingAck) // Message still expecting an ack
  408. {
  409. if(ucAckRetryCount++ < MAX_RETRIES)
  410. SendRequestMsg(ucMsgExpectingAck);
  411. else
  412. bSuccess = FALSE;
  413. }
  414. return bSuccess;
  415. }
  416. /**************************************************************************
  417. * SDMDisplay::UpdateDisplayAckStatus
  418. *
  419. * Updates display to show if acknowledged request messages were
  420. * transmitted successfully
  421. *
  422. * returns: N/A
  423. *
  424. **************************************************************************/
  425. void SDMDisplay::UpdateDisplayAckStatus(UCHAR ucStatus_)
  426. {
  427. switch(ucStatus_)
  428. {
  429. case ACK_SUCCESS:
  430. this->label_AckMsgStatus->ForeColor = System::Drawing::Color::Green;
  431. this->label_AckMsgStatus->Text = "SENT";
  432. break;
  433. case ACK_RETRY:
  434. this->label_AckMsgStatus->ForeColor = System::Drawing::Color::Blue;
  435. this->label_AckMsgStatus->Text = "RTRY";
  436. break;
  437. case ACK_FAIL:
  438. this->label_AckMsgStatus->ForeColor = System::Drawing::Color::Red;
  439. this->label_AckMsgStatus->Text = "FAIL";
  440. break;
  441. default:
  442. break;
  443. }
  444. }
  445. /**************************************************************************
  446. * SDMDisplay::EncodeRequestMsg
  447. *
  448. * Encodes the Request Data Page
  449. *
  450. * ucPageID_: ID of the page to request;
  451. * pucTxBuffer_: pointer to the buffer that will store the encoded data
  452. *
  453. * returns: N/A
  454. *
  455. **************************************************************************/
  456. void SDMDisplay::EncodeRequestMsg(UCHAR ucPageID_, UCHAR* pucTxBuffer_)
  457. {
  458. if (bRqAckReply)
  459. ucRqTxTimes |= 0x80; // set the MSB bit to 1
  460. else
  461. ucRqTxTimes &= ~0x80; // clear the MSB
  462. if (bRqTxUntilAck)
  463. ucRqTxTimes = 0x80; // 0x80 is a special value
  464. pucTxBuffer_[0] = SDM_PAGE70; // Command ID
  465. pucTxBuffer_[1] = SDM_RESERVED;
  466. pucTxBuffer_[2] = SDM_RESERVED;
  467. pucTxBuffer_[3] = SDM_RESERVED; // invalid
  468. pucTxBuffer_[4] = SDM_RESERVED; // invalid
  469. pucTxBuffer_[5] = ucRqTxTimes; // number of times for sensor to send, based on UI
  470. pucTxBuffer_[6] = ucPageID_; // Page number to request
  471. pucTxBuffer_[7] = SDM_DATA_REQUEST; // Specify that we are requesting data (not ANT-FS)
  472. }
  473. /**************************************************************************
  474. * SDMDisplay::button_RequestPage16_Click
  475. *
  476. * Initates the sending of a message to the sensor to request data page 16
  477. *
  478. * returns: N/A
  479. *
  480. **************************************************************************/
  481. System::Void SDMDisplay::button_RequestPage16_Click(System::Object^ sender, System::EventArgs^ e)
  482. {
  483. SendRequestMsg(SDM_PAGE16);
  484. }
  485. /**************************************************************************
  486. * SDMDisplay::button_RequestPage22_Click
  487. *
  488. * Initates the sending of a message to the sensor to request data page 16
  489. *
  490. * returns: N/A
  491. *
  492. **************************************************************************/
  493. System::Void SDMDisplay::button_RequestPage22_Click(System::Object^ sender, System::EventArgs^ e)
  494. {
  495. SendRequestMsg(SDM_PAGE22);
  496. }
  497. /**************************************************************************
  498. * SDMDisplay::numericUpDown_numericUpDown_RqTxTimes_ValueChanged
  499. *
  500. * Updates the number of times for the sensor to resend the request
  501. * response when modified in UI
  502. *
  503. * returns: N/A
  504. *
  505. **************************************************************************/
  506. System::Void SDMDisplay::numericUpDown_RqTxTimes_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  507. {
  508. ucRqTxTimes = System::Convert::ToByte(this->numericUpDown_RqTxTimes->Value);
  509. }
  510. /**************************************************************************
  511. * SDMDisplay::checkBox_RqAckReply_CheckedChanged
  512. *
  513. * Select whether the sensor should request an ACK on its replies
  514. *
  515. * returns: N/A
  516. *
  517. **************************************************************************/
  518. System::Void SDMDisplay::checkBox_RqAckReply_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  519. {
  520. if(this->checkBox_RqAckReply->Checked) // If checked set flag
  521. {
  522. bRqAckReply = TRUE;
  523. }
  524. else // If not checked clear flag
  525. {
  526. bRqAckReply = FALSE;
  527. }
  528. }
  529. /**************************************************************************
  530. * SDMDisplay::checkBox_RqTxUntilAck_CheckedChanged
  531. *
  532. * Select whether the sensor should transmit repeatedly until it gets an ACK
  533. *
  534. * returns: N/A
  535. *
  536. **************************************************************************/
  537. System::Void SDMDisplay::checkBox_RqTxUntilAck_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  538. {
  539. if(this->checkBox_RqTxUntilAck->Checked) // If checked set flag
  540. {
  541. bRqTxUntilAck = TRUE;
  542. // disable other options in this case
  543. this->checkBox_RqAckReply->Enabled = FALSE;
  544. this->numericUpDown_RqTxTimes->Enabled = FALSE;
  545. }
  546. else // If not checked clear flag
  547. {
  548. bRqTxUntilAck = FALSE;
  549. // enable other options
  550. this->checkBox_RqAckReply->Enabled = TRUE;
  551. this->numericUpDown_RqTxTimes->Enabled = TRUE;
  552. ucRqTxTimes = System::Convert::ToByte(this->numericUpDown_RqTxTimes->Value); // reset this value
  553. }
  554. }