MSMSensor.cpp 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  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. #pragma once
  9. #include "StdAfx.h"
  10. #include "MSMSensor.h"
  11. /**************************************************************************
  12. * MSMSensor::InitializeSim
  13. *
  14. * Initialize the simulator variables
  15. *
  16. * returns: N/A
  17. *
  18. **************************************************************************/
  19. void MSMSensor::InitializeSim()
  20. {
  21. ulTimerInterval = 250; // in ms - simulates the sensor sending the most relevant information every message period
  22. dbDispAcumTime = 0;
  23. dbDispAcumDist = 0;
  24. usLastEventTime = 0;
  25. msmData->usInstSpeed1000 = System::Convert::ToUInt16 (this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR); // Set the speed to the what is shown in the menu
  26. eCalStatus = MSM::CalibrationStatus::NONE;
  27. ulTotalTime = 0;
  28. // required common pages
  29. commonData->ulSerialNum = System::Convert::ToUInt32(this->textBox_Glb_SerialNumChange->Text);
  30. commonData->ucSwVersion = System::Convert::ToByte(this->textBox_Glb_SoftwareVerChange->Text);
  31. commonData->ucHwVersion = System::Convert::ToByte(this->textBox_Glb_HardwareVerChange->Text);
  32. commonData->usMfgID = System::Convert::ToUInt16(this->textBox_Glb_ManfIDChange->Text);
  33. commonData->usModelNum = System::Convert::ToUInt16(this->textBox_Glb_ModelNumChange->Text);
  34. //battery common page
  35. commonData->eTimeResolution = CommonData::TimeResolution::TWO;
  36. commonData->ulOpTime = ulTotalTime;
  37. commonData->bBattPageEnabled = FALSE;
  38. // time common page
  39. commonData->bTimePageEnabled = FALSE;
  40. commonData->ucSeconds = System::Convert::ToByte(this->numericUpDownSeconds->Value);
  41. commonData->ucMinutes = System::Convert::ToByte(this->numericUpDownMinutes->Value);
  42. commonData->ucHours = System::Convert::ToByte(this->numericUpDownHours->Value);
  43. UpdateDayOfWeek();
  44. commonData->ucDays = System::Convert::ToByte(this->numericUpDownDay->Value);
  45. commonData->ucMonth = System::Convert::ToByte(this->numericUpDownMonth->Value);
  46. commonData->ucYears = System::Convert::ToByte(this->numericUpDownYear->Value);
  47. UpdateTxPattern();
  48. UpdateCommonPattern();
  49. }
  50. /**************************************************************************
  51. * MSMSensor::ANT_eventNotification
  52. *
  53. * Process ANT channel event
  54. *
  55. * ucEventCode_: code of ANT channel event
  56. * pucEventBuffer_: pointer to buffer containing data received from ANT,
  57. * or a pointer to the transmit buffer in the case of an EVENT_TX
  58. *
  59. * returns: N/A
  60. *
  61. **************************************************************************/
  62. void MSMSensor::ANT_eventNotification(UCHAR ucEventCode_, UCHAR* pucEventBuffer_)
  63. {
  64. switch(ucEventCode_)
  65. {
  66. case EVENT_TX:
  67. HandleTransmit((UCHAR*) pucEventBuffer_);
  68. UpdateDisplay();
  69. break;
  70. case EVENT_RX_ACKNOWLEDGED:
  71. HandleCalibration((UCHAR*) pucEventBuffer_);
  72. break;
  73. case EVENT_TRANSFER_TX_COMPLETED:
  74. UpdateDisplayAckStatus(msmData->ACK_SUCCESS);
  75. break;
  76. case EVENT_ACK_TIMEOUT:
  77. case EVENT_TRANSFER_TX_FAILED: // intentional fall through
  78. UpdateDisplayAckStatus(msmData->ACK_FAIL);
  79. break;
  80. default:
  81. break;
  82. }
  83. }
  84. /**************************************************************************
  85. * MSMSensor::HandleTransmit
  86. *
  87. * Encode data generated by simulator for transmission
  88. *
  89. * ucPageNum_: The page number to be transmitted
  90. * pucTxBuffer_: pointer to the transmit buffer
  91. *
  92. * returns: N/A
  93. *
  94. **************************************************************************/
  95. void MSMSensor::HandleTransmit(UCHAR* pucTxBuffer_)
  96. {
  97. static ULONG ulMessageCount = 1;
  98. static UCHAR ucMsmPatternCount = 0;
  99. static UCHAR ucCommonPatternCount = 0;
  100. if (ulMessageCount % 65)
  101. {
  102. if(ucMsmPatternCount >= ucTxPattern.Count)
  103. ucMsmPatternCount = 0;
  104. // send MSM data pages
  105. switch (ucTxPattern[ucMsmPatternCount])
  106. {
  107. case msmData->PAGE_1:
  108. msmData->EncodeData(msmData->PAGE_1, pucTxBuffer_);
  109. break;
  110. case msmData->PAGE_2:
  111. msmData->EncodeData(msmData->PAGE_2, pucTxBuffer_);
  112. break;
  113. case msmData->PAGE_3:
  114. msmData->EncodeData(msmData->PAGE_3, pucTxBuffer_);
  115. break;
  116. default:
  117. break;
  118. }
  119. ucMsmPatternCount++;
  120. //if (ucMsmPatternCount >= ucTxPattern.Count)
  121. // ucMsmPatternCount = 0; // reset the message count at the end
  122. }
  123. else
  124. {
  125. if(ucCommonPatternCount >= ucCommonPattern.Count)
  126. ucCommonPatternCount = 0;
  127. switch(ucCommonPattern[ucCommonPatternCount])
  128. {
  129. case commonData->PAGE80:
  130. commonData->Encode(commonData->PAGE80, pucTxBuffer_);
  131. break;
  132. case commonData->PAGE81:
  133. commonData->Encode(commonData->PAGE81, pucTxBuffer_);
  134. break;
  135. case commonData->PAGE82:
  136. commonData->Encode(commonData->PAGE82, pucTxBuffer_);
  137. break;
  138. case commonData->PAGE83:
  139. commonData->Encode(commonData->PAGE83, pucTxBuffer_);
  140. break;
  141. }
  142. ucCommonPatternCount++;
  143. }
  144. ulMessageCount++;
  145. static UCHAR ucTimeCount = 0;
  146. // update the batt op time every second
  147. if (ucTimeCount == 3)
  148. {
  149. ulTotalTime++;
  150. commonData->ulOpTime = ulTotalTime / (UCHAR) commonData->eTimeResolution;
  151. ucTimeCount = 0;
  152. }
  153. else
  154. ucTimeCount++;
  155. }
  156. /**************************************************************************
  157. * MSMSensor::Update Display
  158. *
  159. * Update the GUI with all the changes
  160. *
  161. * returns: N/A
  162. *
  163. **************************************************************************/
  164. void MSMSensor::UpdateDisplay()
  165. {
  166. this->labelAcumTime->Text = dbDispAcumTime.ToString("N2"); // Update the accumulated time label
  167. this->labelAcumDistance->Text = dbDispAcumDist.ToString("N2"); // Update the accumulated distance label
  168. // the tx variables will show the raw transmitted data decoded, but not scaled into proper units
  169. this->labelTxDist->Text = msmData->usAcumDist10.ToString(); // Update the tx box distance label
  170. this->labelTxTime->Text = msmData->usAcumTime1024.ToString(); // update the tx box time label
  171. this->labelTxSpeed->Text = msmData->usInstSpeed1000.ToString(); // update the tx box speed label
  172. if (msmData->IsCalScaleValid(msmData->usScaleFactor10000))
  173. this->labelCurrentScaleFactor->Text = ((double) msmData->usScaleFactor10000 / msmData->CAL_SF_SCALE_FACTOR).ToString("N4");
  174. else
  175. this->labelCurrentScaleFactor->Text = "Invalid";
  176. if (msmData->bPage2Enabled)
  177. {
  178. this->labelTxLat->Text = msmData->slLatitude_SC.ToString();
  179. this->lableTxLon->Text = msmData->slLongitude_SC.ToString();
  180. }
  181. if (msmData->bPage3Enabled)
  182. {
  183. this->labelTxElev->Text = msmData->usElevation5.ToString();
  184. this->labelTxHeading->Text = msmData->usHeading10.ToString();
  185. this->labelTxFix->Text = msmData->ucFixType.ToString();
  186. }
  187. // update the operating time for the battery common page
  188. this->label_Bat_ElpTimeDisplay->Text = ulTotalTime.ToString();
  189. }
  190. /**************************************************************************
  191. * MSMSensor::onTimerTock
  192. *
  193. * Simulates a sensor event, updating simulator data based on this event
  194. * Modifications to the timer interval are applied immediately after this
  195. * at ANTChannel
  196. *
  197. * usEventTime_: current time (ms)
  198. *
  199. * returns: N/A
  200. *
  201. **************************************************************************/
  202. void MSMSensor::onTimerTock(USHORT eventTime)
  203. {
  204. msmData->usAcumTime1024 += (USHORT) (ulTimerInterval << 10 / 1000); // time base is 1/1024 second
  205. dbDispAcumTime += (double) ulTimerInterval / 1000; // Update the display time
  206. dbDispAcumDist += (double) (msmData->usInstSpeed1000 * ulTimerInterval) / 1000000;
  207. msmData->usAcumDist10 = (USHORT) (dbDispAcumDist * 10); // distance is transmitted in 0.1m intervals
  208. }
  209. /**************************************************************************
  210. * MSMSensor::HandleCalibration
  211. *
  212. * Handlest teh Calibration mode of the MSM
  213. *
  214. * pucEventBuffer_: data buffer after receving an acknowleged message
  215. *
  216. * returns: N/A
  217. *
  218. **************************************************************************/
  219. void MSMSensor::HandleCalibration(UCHAR* pucEventBuffer_)
  220. {
  221. msmData->Decode(pucEventBuffer_);
  222. // check if the sensor supports calibration
  223. if (this->checkBoxCalibrationSupport->Checked == FALSE)
  224. {
  225. // set scale factor to unsupported value
  226. msmData->usScaleFactor10000 = msmData->CAL_SCALE_INVALID;
  227. msmData->ucMode = msmData->CAL_MODE_INVALID;
  228. eCalStatus = MSM::CalibrationStatus::NONE;
  229. // send the response
  230. msmData->EncodeData(msmData->PAGE_CALIBRATION, pucEventBuffer_);
  231. requestAckMsg(pucEventBuffer_);
  232. this->labelCalibrationProgress->Text = "Calibration is not supported";
  233. this->labelCalibrationProgress->BackColor = System::Drawing::SystemColors::Control;
  234. }
  235. else
  236. {
  237. // check if the mode is supported
  238. if (this->checkBoxModeStorageSupport->Checked == FALSE)
  239. {
  240. // only if mode storage is not supported does the mode need to change from the decoded value
  241. msmData->ucMode = msmData->CAL_MODE_INVALID;
  242. }
  243. // check if it is a Set Scale Command
  244. if ((msmData->usScaleFactor10000 != msmData->CAL_SCALE_REQUEST) && (msmData->IsCalScaleValid(msmData->usScaleFactor10000)))
  245. {
  246. // set the status
  247. eCalStatus = MSM::CalibrationStatus::SET_SCALE_IN_PROGRESS;
  248. // calibration request response state
  249. this->labelCalibrationProgress->Text = "Set Scale Factor Received";
  250. this->labelCalibrationProgress->BackColor = System::Drawing::Color::Yellow;
  251. // send the calibration request response
  252. msmData->EncodeData(msmData->PAGE_CALIBRATION, pucEventBuffer_);
  253. requestAckMsg(pucEventBuffer_);
  254. // update the display values
  255. this->labelCalibrationProgress->Text = "Scale Factor \nConfirmation Sent";
  256. this->labelCalibrationProgress->BackColor = System::Drawing::Color::Orange;
  257. }
  258. // check if it is a calibration request
  259. if (msmData->usScaleFactor10000 == msmData->CAL_SCALE_REQUEST && eCalStatus != MSM::CalibrationStatus::SET_SCALE_IN_PROGRESS)
  260. {
  261. // set the status
  262. eCalStatus = MSM::CalibrationStatus::REQUEST_IN_PROGRESS;
  263. // calibration request response state
  264. this->labelCalibrationProgress->Text = "Calibration Request Received";
  265. this->labelCalibrationProgress->BackColor = System::Drawing::Color::Yellow;
  266. msmData->usScaleFactor10000 = msmData->CAL_SCALE_CONF;
  267. // the mode will already be decoded by msmData->Decode()
  268. // send the calibration request response
  269. msmData->EncodeData(msmData->PAGE_CALIBRATION, pucEventBuffer_);
  270. requestAckMsg(pucEventBuffer_);
  271. // update the display values
  272. this->labelCalibrationProgress->Text = "Calibration Request \nResponse Sent";
  273. this->labelCalibrationProgress->BackColor = System::Drawing::Color::Orange;
  274. }
  275. }
  276. // update the display variables
  277. UpdateCalibDisplay();
  278. }
  279. /**************************************************************************
  280. * MSMSensor::UpdateCalibDisplay
  281. *
  282. * Adjusts the current speed via the GUI
  283. *
  284. * returns: N/A
  285. *
  286. **************************************************************************/
  287. void MSMSensor::UpdateCalibDisplay()
  288. {
  289. ULONG ulNewSpeed;
  290. // update the mode label
  291. if (msmData->IsCalModeValid(msmData->ucMode))
  292. this->labelCurrentMode->Text = msmData->ucMode.ToString();
  293. else
  294. this->labelCurrentMode->Text = "Mode Invalid";
  295. // update the scale factor label
  296. if (msmData->IsCalScaleValid(msmData->usScaleFactor10000))
  297. this->labelCurrentScaleFactor->Text = ((double) msmData->usScaleFactor10000 / msmData->CAL_SF_SCALE_FACTOR).ToString("N4");
  298. else
  299. this->labelCurrentScaleFactor->Text = "Scale Factor Invalid";
  300. if (eCalStatus != MSM::CalibrationStatus::COMPLETE)
  301. {
  302. // set the scale to change the speed and distance data that is now sent
  303. if (msmData->IsCalScaleValid(msmData->usScaleFactor10000))
  304. {
  305. // calc the new speed
  306. ulNewSpeed = System::Convert::ToUInt32(this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR * (System::Convert::ToDecimal(msmData->usScaleFactor10000) / msmData->CAL_SF_SCALE_FACTOR));
  307. // check if the new speed is within the range
  308. if (ulNewSpeed < msmData->INVALID_SPEED)
  309. msmData->usInstSpeed1000 = System::Convert::ToUInt16(this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR * (System::Convert::ToDecimal(msmData->usScaleFactor10000) / msmData->CAL_SF_SCALE_FACTOR));
  310. else
  311. {
  312. msmData->usInstSpeed1000 = msmData->MAX_SPEED;
  313. MessageBox::Show("Maximum speed reached. \nTx speed set to max speed: 65.534 m/s", "Speed Error", MessageBoxButtons::OK,MessageBoxIcon::Error, MessageBoxDefaultButton::Button1);
  314. }
  315. }
  316. else
  317. msmData->usInstSpeed1000 = System::Convert::ToUInt16(this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR);
  318. }
  319. // if process completed
  320. else if (eCalStatus == MSM::CalibrationStatus::COMPLETE)
  321. {
  322. this->labelCalibrationProgress->Text = "Calibration Process \nSuccessfully Completed";
  323. this->labelCalibrationProgress->BackColor = System::Drawing::SystemColors::Control;
  324. }
  325. }
  326. /**************************************************************************
  327. * MSMSensor::UpdateDisplayAckStatus
  328. *
  329. * Adjusts the GUI depending on the ACK status of the tx message
  330. *
  331. * UCHAR status_: gives the success or fail status of the tx message
  332. *
  333. * returns: N/A
  334. *
  335. **************************************************************************/
  336. void MSMSensor::UpdateDisplayAckStatus(UCHAR status_)
  337. {
  338. switch (eCalStatus)
  339. {
  340. case MSM::CalibrationStatus::REQUEST_IN_PROGRESS:
  341. if (status_ == msmData->ACK_FAIL)
  342. {
  343. this->labelCalibrationProgress->Text = "Cal Request Response \nFailed to Transmit";
  344. this->labelCalibrationProgress->BackColor = System::Drawing::Color::Red;
  345. }
  346. if (status_ == msmData->ACK_SUCCESS)
  347. {
  348. this->labelCalibrationProgress->Text = "Cal Request Response \nTransmission Success";
  349. this->labelCalibrationProgress->BackColor = System::Drawing::Color::Green;
  350. }
  351. break;
  352. case MSM::CalibrationStatus::SET_SCALE_IN_PROGRESS:
  353. if (status_ == msmData->ACK_FAIL)
  354. {
  355. this->labelCalibrationProgress->Text = "Set Scale Response \nFailed to Transmit";
  356. this->labelCalibrationProgress->BackColor = System::Drawing::Color::Red;
  357. }
  358. if (status_ == msmData->ACK_SUCCESS)
  359. {
  360. this->labelCalibrationProgress->Text = "Set Scale Response \nTransmission Success";
  361. this->labelCalibrationProgress->BackColor = System::Drawing::Color::Green;
  362. // update the display to tell the user the calibration has successfully finished
  363. eCalStatus = MSM::CalibrationStatus::COMPLETE;
  364. UpdateCalibDisplay();
  365. }
  366. break;
  367. default:
  368. break;
  369. }
  370. }
  371. /**************************************************************************
  372. * MSMSensor::numericUpDownSpeed_ValueChanged
  373. *
  374. * Adjusts the current speed via the GUI
  375. *
  376. * returns: N/A
  377. *
  378. **************************************************************************/
  379. void MSMSensor::numericUpDownSpeed_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  380. {
  381. ULONG ulNewSpeed;
  382. if (msmData->IsCalScaleValid(msmData->usScaleFactor10000))
  383. {
  384. // calc the new speed
  385. ulNewSpeed = System::Convert::ToUInt32(this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR * (System::Convert::ToDecimal(msmData->usScaleFactor10000) / msmData->CAL_SF_SCALE_FACTOR));
  386. // check if the new speed is within the range
  387. if (ulNewSpeed < msmData->INVALID_SPEED)
  388. msmData->usInstSpeed1000 = System::Convert::ToUInt16(this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR * (System::Convert::ToDecimal(msmData->usScaleFactor10000) / msmData->CAL_SF_SCALE_FACTOR));
  389. else
  390. {
  391. msmData->usInstSpeed1000 = msmData->MAX_SPEED;
  392. MessageBox::Show("Maximum speed reached. \nTx speed set to max speed: 65.534 m/s", "Speed Error", MessageBoxButtons::OK,MessageBoxIcon::Error, MessageBoxDefaultButton::Button1);
  393. }
  394. }
  395. else
  396. msmData->usInstSpeed1000 = System::Convert::ToUInt16(this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR);
  397. }
  398. /**************************************************************************
  399. * MSMSensor::checkBoxTxSpeed_CheckedChanged
  400. *
  401. * Adjusts the value if the speed data is invalid or not
  402. *
  403. * returns: N/A
  404. *
  405. **************************************************************************/
  406. void MSMSensor::checkBoxTxSpeed_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  407. {
  408. if (this->checkBoxTxSpeed->Checked == FALSE)
  409. msmData->usInstSpeed1000 = msmData->INVALID_SPEED;
  410. else
  411. msmData->usInstSpeed1000 = System::Convert::ToUInt16(this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR);
  412. }
  413. /**************************************************************************
  414. * MSMSensor::checkBoxCalibrationSupport_CheckedChanged
  415. *
  416. * Sets the calibration to be enabled or not
  417. *
  418. * returns: N/A
  419. *
  420. **************************************************************************/
  421. void MSMSensor::checkBoxCalibrationSupport_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  422. {
  423. if (this->checkBoxCalibrationSupport->Checked == FALSE)
  424. {
  425. msmData->usScaleFactor10000 = msmData->CAL_SCALE_INVALID;
  426. msmData->ucMode = msmData->CAL_MODE_INVALID;
  427. this->checkBoxModeStorageSupport->Checked = FALSE;
  428. this->checkBoxModeStorageSupport->Enabled = FALSE;
  429. // make the speed not use a scale factor any longer
  430. msmData->usInstSpeed1000 = System::Convert::ToUInt16(this->numericUpDownSpeed->Value * msmData->SPEED_SCALE_FACTOR);
  431. }
  432. else
  433. {
  434. this->checkBoxModeStorageSupport->Enabled = TRUE;
  435. }
  436. }
  437. /**************************************************************************
  438. * MSMSensor::checkBoxModeStorageSupport_CheckedChanged
  439. *
  440. * Sets the calibration to be enabled or not
  441. *
  442. * returns: N/A
  443. *
  444. **************************************************************************/
  445. void MSMSensor::checkBoxModeStorageSupport_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  446. {
  447. if (this->checkBoxModeStorageSupport->Checked == FALSE)
  448. msmData->ucMode = msmData->CAL_MODE_INVALID;
  449. }
  450. /**************************************************************************
  451. * MSMSensor::checkBoxSecondaryData_CheckedChanged
  452. *
  453. * Enables and sets the GPS parameters
  454. *
  455. * returns: N/A
  456. *
  457. **************************************************************************/
  458. void MSMSensor::checkBoxSecondaryData_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  459. {
  460. if (this->checkBoxSecondaryData->Checked == TRUE)
  461. {
  462. this->numericUpDownLatitude->Enabled = TRUE;
  463. this->numericUpDownLongitude->Enabled = TRUE;
  464. this->checkBoxPage3Enable->Enabled = TRUE;
  465. msmData->slLatitude_SC = System::Convert::ToInt32(double (this->numericUpDownLatitude->Value) * msmData->SEMI_CIRCLE_CONVERSION);
  466. msmData->slLongitude_SC = System::Convert::ToInt32(double (this->numericUpDownLongitude->Value) * msmData->SEMI_CIRCLE_CONVERSION);
  467. }
  468. else
  469. {
  470. this->numericUpDownLatitude->Enabled = FALSE;
  471. this->numericUpDownLongitude->Enabled = FALSE;
  472. msmData->slLatitude_SC = 0;
  473. msmData->slLongitude_SC = 0;
  474. // also disable the page 3 stuff
  475. this->checkBoxPage3Enable->Enabled = FALSE;
  476. this->checkBoxPage3Enable->Checked = FALSE;
  477. this->groupBoxPage3->Enabled = FALSE;
  478. }
  479. UpdateTxPattern();
  480. }
  481. /**************************************************************************
  482. * MSMSensor::checkBoxPage3Enable_CheckedChanged
  483. *
  484. * Sets the calibration to be enabled or not
  485. *
  486. * returns: N/A
  487. *
  488. **************************************************************************/
  489. void MSMSensor::checkBoxPage3Enable_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  490. {
  491. if (this->checkBoxPage3Enable->Checked == TRUE)
  492. {
  493. this->groupBoxPage3->Enabled = TRUE;
  494. msmData->usElevation5 = System::Convert::ToUInt16((this->numericUpDownElevation->Value + msmData->ELEVATION_OFFSET) * msmData->ELEVATION_SCALE_FACTOR);
  495. msmData->usHeading10 = System::Convert::ToUInt16(this->numericUpDownHeading->Value * msmData->HEADING_SCALE_FACTOR);
  496. UpdateGpsFixType();
  497. }
  498. else
  499. {
  500. this->groupBoxPage3->Enabled = FALSE;
  501. }
  502. UpdateTxPattern();
  503. }
  504. /**************************************************************************
  505. * MSMSensor::UpdateGpsFixType
  506. *
  507. * Updates the gps fix based on the settings in the combo box
  508. *
  509. * returns: N/A
  510. *
  511. **************************************************************************/
  512. void MSMSensor::UpdateGpsFixType()
  513. {
  514. if (this->comboBoxGPSFix->SelectedItem->Equals("None"))
  515. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::NONE);
  516. else if (this->comboBoxGPSFix->SelectedItem->Equals("Propagating"))
  517. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::PROPAGATING);
  518. else if (this->comboBoxGPSFix->SelectedItem->Equals("Searching"))
  519. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::SEARCHING);
  520. else if (this->comboBoxGPSFix->SelectedItem->Equals("Last Known"))
  521. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::LAST_KNOWN);
  522. else if (this->comboBoxGPSFix->SelectedItem->Equals("3D"))
  523. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::THREE_D);
  524. else if (this->comboBoxGPSFix->SelectedItem->Equals("3D WAAS"))
  525. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::THREE_D_WAAS);
  526. else if (this->comboBoxGPSFix->SelectedItem->Equals("3D Differential"))
  527. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::THREE_D_DIF);
  528. else if (this->comboBoxGPSFix->SelectedItem->Equals("2D"))
  529. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::TWO_D);
  530. else if (this->comboBoxGPSFix->SelectedItem->Equals("2D WAAS"))
  531. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::TWO_D_WAAS);
  532. else if (this->comboBoxGPSFix->SelectedItem->Equals("2D Differential"))
  533. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::TWO_D_DIF);
  534. else if (this->comboBoxGPSFix->SelectedItem->Equals("Invalid"))
  535. msmData->ucFixType = System::Convert::ToByte(MSM::GpsFix::INVALID);
  536. }
  537. /**************************************************************************
  538. * MSMSensor::numericUpDownLongitude_ValueChanged
  539. *
  540. * Adjusts the current longitude via the GUI
  541. *
  542. * returns: N/A
  543. *
  544. **************************************************************************/
  545. void MSMSensor::numericUpDownLongitude_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  546. {
  547. msmData->slLongitude_SC = System::Convert::ToInt32(double (this->numericUpDownLongitude->Value) * msmData->SEMI_CIRCLE_CONVERSION);
  548. }
  549. /**************************************************************************
  550. * MSMSensor::numericUpDownLatitude_ValueChanged
  551. *
  552. * Adjusts the current latitude via the GUI
  553. *
  554. * returns: N/A
  555. *
  556. **************************************************************************/
  557. void MSMSensor::numericUpDownLatitude_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  558. {
  559. msmData->slLatitude_SC = System::Convert::ToInt32(double (this->numericUpDownLatitude->Value) * msmData->SEMI_CIRCLE_CONVERSION);
  560. }
  561. /**************************************************************************
  562. * MSMSensor::numericUpDownElevation_ValueChanged
  563. *
  564. * Adjusts the current elevation via the GUI
  565. *
  566. * returns: N/A
  567. *
  568. **************************************************************************/
  569. void MSMSensor::numericUpDownElevation_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  570. {
  571. msmData->usElevation5 = System::Convert::ToUInt16((this->numericUpDownElevation->Value + msmData->ELEVATION_OFFSET) * msmData->ELEVATION_SCALE_FACTOR);
  572. }
  573. /**************************************************************************
  574. * MSMSensor::numericUpDownHeading_ValueChanged
  575. *
  576. * Adjusts the current heading via the GUI
  577. *
  578. * returns: N/A
  579. *
  580. **************************************************************************/
  581. void MSMSensor::numericUpDownHeading_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  582. {
  583. msmData->usHeading10 = System::Convert::ToUInt16(this->numericUpDownHeading->Value * msmData->HEADING_SCALE_FACTOR);
  584. }
  585. /**************************************************************************
  586. * MSMSensor::comboBoxGPSFix_SelectedIndexChanged
  587. *
  588. * Adjusts the current heading via the GUI
  589. *
  590. * returns: N/A
  591. *
  592. **************************************************************************/
  593. void MSMSensor::comboBoxGPSFix_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
  594. {
  595. UpdateGpsFixType();
  596. }
  597. /**************************************************************************
  598. * MSMSensor::button_Glb_GlobalDataUpdate_Click
  599. *
  600. * Adjusts the global pages 80 and 81 via the GUI
  601. *
  602. * returns: N/A
  603. *
  604. **************************************************************************/
  605. void MSMSensor::button_Glb_GlobalDataUpdate_Click(System::Object^ sender, System::EventArgs^ e)
  606. {
  607. this->label_Error->Visible = false;
  608. // required common pages
  609. try{
  610. if(this->checkBox_InvalidSerial->Checked)
  611. commonData->ulSerialNum = 0xFFFFFFFF;
  612. else
  613. commonData->ulSerialNum = System::Convert::ToUInt32(this->textBox_Glb_SerialNumChange->Text);
  614. commonData->ucSwVersion = System::Convert::ToByte(this->textBox_Glb_SoftwareVerChange->Text);
  615. commonData->ucHwVersion = System::Convert::ToByte(this->textBox_Glb_HardwareVerChange->Text);
  616. commonData->usMfgID = System::Convert::ToUInt16(this->textBox_Glb_ManfIDChange->Text);
  617. commonData->usModelNum = System::Convert::ToUInt16(this->textBox_Glb_ModelNumChange->Text);
  618. }
  619. catch(...)
  620. {
  621. label_Error->Visible = true;
  622. }
  623. }
  624. /**************************************************************************
  625. * MSMSensor::checkBox_Bat_Status_CheckedChanged
  626. *
  627. * Enables and disables the battery voltage GUI elements
  628. *
  629. * returns: N/A
  630. *
  631. **************************************************************************/
  632. void MSMSensor::checkBox_Bat_Status_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  633. {
  634. if (this->checkBox_Bat_Status->Checked == TRUE)
  635. {
  636. commonData->bBattPageEnabled = TRUE;
  637. this->comboBoxBatStatus->Enabled = TRUE;
  638. this->label_Bat_ElpTimeDisplay->Enabled = TRUE;
  639. this->textBox_Bat_ElpTimeChange->Enabled = TRUE;
  640. this->checkBox_Bat_Voltage->Enabled = TRUE;
  641. this->checkBox_Bat_Voltage->Checked = TRUE;
  642. this->numericUpDown_Bat_VoltFrac->Enabled = TRUE;
  643. this->numericUpDown_Bat_VoltInt->Enabled = TRUE;
  644. this->groupBox_Resol->Enabled = TRUE;
  645. this->button_Bat_ElpTimeUpdate->Enabled = TRUE;
  646. // update the variables
  647. UpdateBatStatus();
  648. if (this->radioButton_Bat_Elp16Units->Checked)
  649. commonData->eTimeResolution = CommonData::TimeResolution::SIXTEEN;
  650. if (this->radioButton_Bat_Elp2Units->Checked)
  651. commonData->eTimeResolution = CommonData::TimeResolution::TWO;
  652. commonData->ulOpTime = ulTotalTime / (UCHAR) commonData->eTimeResolution;
  653. commonData->usBatVoltage256 = ((USHORT) System::Convert::ToByte(this->numericUpDown_Bat_VoltInt->Value)) << 8 | (commonData->usBatVoltage256 & 0xFF); // Integer portion in high byte
  654. commonData->usBatVoltage256 = System::Convert::ToByte(this->numericUpDown_Bat_VoltFrac->Value) | (commonData->usBatVoltage256 & 0xFF00); // Fractional portion in low byte
  655. }
  656. else
  657. {
  658. commonData->bBattPageEnabled = FALSE;
  659. this->comboBoxBatStatus->Enabled = FALSE;
  660. this->label_Bat_ElpTimeDisplay->Enabled = FALSE;
  661. this->textBox_Bat_ElpTimeChange->Enabled = FALSE;
  662. this->checkBox_Bat_Voltage->Enabled = FALSE;
  663. this->checkBox_Bat_Voltage->Checked = FALSE;
  664. this->numericUpDown_Bat_VoltFrac->Enabled = FALSE;
  665. this->numericUpDown_Bat_VoltInt->Enabled = FALSE;
  666. this->groupBox_Resol->Enabled = FALSE;
  667. this->button_Bat_ElpTimeUpdate->Enabled = FALSE;
  668. }
  669. UpdateCommonPattern();
  670. }
  671. /**************************************************************************
  672. * MSMSensor::checkBox_Bat_Voltage_CheckedChanged
  673. *
  674. * Enables and disables the battery voltage numeric upDown
  675. *
  676. * returns: N/A
  677. *
  678. **************************************************************************/
  679. void MSMSensor::checkBox_Bat_Voltage_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  680. {
  681. if (this->checkBox_Bat_Voltage->Checked == TRUE)
  682. {
  683. this->numericUpDown_Bat_VoltInt->Enabled = TRUE;
  684. this->numericUpDown_Bat_VoltFrac->Enabled = TRUE;
  685. commonData->usBatVoltage256 = ((USHORT) System::Convert::ToByte(this->numericUpDown_Bat_VoltInt->Value)) << 8 | (commonData->usBatVoltage256 & 0xFF); // Integer portion in high byte
  686. commonData->usBatVoltage256 = System::Convert::ToByte(this->numericUpDown_Bat_VoltFrac->Value) | (commonData->usBatVoltage256 & 0xFF00); // Fractional portion in low byte
  687. }
  688. else
  689. {
  690. this->numericUpDown_Bat_VoltInt->Enabled = FALSE;
  691. this->numericUpDown_Bat_VoltFrac->Enabled = FALSE;
  692. commonData->usBatVoltage256 = commonData->BATTERY_VOLTAGE_INVALID;
  693. }
  694. }
  695. /**************************************************************************
  696. * MSMSensor::numericUpDown_Bat_VoltInt_ValueChanged
  697. *
  698. * changes the coarse battery voltage
  699. *
  700. * returns: N/A
  701. *
  702. **************************************************************************/
  703. void MSMSensor::numericUpDown_Bat_VoltInt_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  704. {
  705. commonData->usBatVoltage256 = ((USHORT) System::Convert::ToByte(this->numericUpDown_Bat_VoltInt->Value)) << 8 | (commonData->usBatVoltage256 & 0xFF); // Integer portion in high byte
  706. }
  707. /**************************************************************************
  708. * MSMSensor::numericUpDown_Bat_VoltFrac_ValueChanged
  709. *
  710. * changes the fractional battery voltage
  711. *
  712. * returns: N/A
  713. *
  714. **************************************************************************/
  715. void MSMSensor::numericUpDown_Bat_VoltFrac_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  716. {
  717. commonData->usBatVoltage256 = System::Convert::ToByte(this->numericUpDown_Bat_VoltFrac->Value) | (commonData->usBatVoltage256 & 0xFF00); // Fractional portion in low byte
  718. }
  719. /**************************************************************************
  720. * MSMSensor::comboBoxBatStatus_SelectedIndexChanged
  721. *
  722. * changes the battery status
  723. *
  724. * returns: N/A
  725. *
  726. **************************************************************************/
  727. void MSMSensor::comboBoxBatStatus_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
  728. {
  729. UpdateBatStatus();
  730. }
  731. /**************************************************************************
  732. * MSMSensor::UpdateBatStatus
  733. *
  734. * Updates the battery status
  735. *
  736. * returns: N/A
  737. *
  738. **************************************************************************/
  739. void MSMSensor::UpdateBatStatus()
  740. {
  741. if (this->comboBoxBatStatus->Text->Equals("New"))
  742. {
  743. commonData->eBatStatus = CommonData::BatStatus::NEW;
  744. }
  745. else if (this->comboBoxBatStatus->Text->Equals("Good"))
  746. {
  747. commonData->eBatStatus = CommonData::BatStatus::GOOD;
  748. }
  749. else if (this->comboBoxBatStatus->Text->Equals("Ok"))
  750. {
  751. commonData->eBatStatus = CommonData::BatStatus::OK;
  752. }
  753. else if (this->comboBoxBatStatus->Text->Equals("Low"))
  754. {
  755. commonData->eBatStatus = CommonData::BatStatus::LOW;
  756. }
  757. else if (this->comboBoxBatStatus->Text->Equals("Critical"))
  758. {
  759. commonData->eBatStatus = CommonData::BatStatus::CRITICAL;
  760. }
  761. else if (this->comboBoxBatStatus->Text->Equals("Invalid"))
  762. {
  763. commonData->eBatStatus = CommonData::BatStatus::INVALID;
  764. }
  765. }
  766. /**************************************************************************
  767. * MSMSensor::button_Bat_ElpTimeUpdate_Click
  768. *
  769. * changes the elapsed battery time
  770. *
  771. * returns: N/A
  772. *
  773. **************************************************************************/
  774. void MSMSensor::button_Bat_ElpTimeUpdate_Click(System::Object^ sender, System::EventArgs^ e)
  775. {
  776. ulTotalTime = System::Convert::ToUInt32(this->textBox_Bat_ElpTimeChange->Text);
  777. commonData->ulOpTime = ulTotalTime / (UCHAR) commonData->eTimeResolution;
  778. }
  779. /**************************************************************************
  780. * MSMSensor::radioButton_Bat_Elp2Units_CheckedChanged
  781. *
  782. * changes the elapsed battery time units
  783. *
  784. * returns: N/A
  785. *
  786. **************************************************************************/
  787. void MSMSensor::radioButton_Bat_Elp2Units_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  788. {
  789. if (this->radioButton_Bat_Elp2Units->Checked)
  790. commonData->eTimeResolution = CommonData::TimeResolution::TWO;
  791. }
  792. /**************************************************************************
  793. * MSMSensor::radioButton_Bat_Elp2Units_CheckedChanged
  794. *
  795. * changes the elapsed battery time units
  796. *
  797. * returns: N/A
  798. *
  799. **************************************************************************/
  800. void MSMSensor::radioButton_Bat_Elp16Units_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  801. {
  802. if (this->radioButton_Bat_Elp16Units->Checked)
  803. commonData->eTimeResolution = CommonData::TimeResolution::SIXTEEN;
  804. }
  805. /**************************************************************************
  806. * MSMSensor::checkBoxEnableDateTime_CheckedChanged
  807. *
  808. * Checks if the date and time page should be enabled and sent
  809. *
  810. * returns: N/A
  811. *
  812. **************************************************************************/
  813. void MSMSensor::checkBoxEnableDateTime_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  814. {
  815. if (this->checkBoxEnableDateTime->Checked == TRUE)
  816. {
  817. // enable all of the parameters
  818. commonData->bTimePageEnabled = TRUE;
  819. this->panelTimeDate->Enabled = TRUE;
  820. }
  821. else
  822. {
  823. commonData->bTimePageEnabled = FALSE;
  824. this->panelTimeDate->Enabled = FALSE;
  825. }
  826. UpdateCommonPattern();
  827. }
  828. /**************************************************************************
  829. * MSMSensor::comboBoxDayOfWeek_SelectedIndexChanged
  830. *
  831. * Sets the day of the week
  832. *
  833. * returns: N/A
  834. *
  835. **************************************************************************/
  836. void MSMSensor::comboBoxDayOfWeek_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
  837. {
  838. UpdateDayOfWeek();
  839. }
  840. /**************************************************************************
  841. * MSMSensor::UpdateDayOfWeek
  842. *
  843. * Sets the day of the week
  844. *
  845. * returns: N/A
  846. *
  847. **************************************************************************/
  848. void MSMSensor::UpdateDayOfWeek()
  849. {
  850. if (this->comboBoxDayOfWeek->Text->Equals("Monday"))
  851. commonData->eDayOfWeek = CommonData::DayOfWeek::MONDAY;
  852. else if (this->comboBoxDayOfWeek->Text->Equals("Tuesday"))
  853. commonData->eDayOfWeek = CommonData::DayOfWeek::TUESDAY;
  854. else if (this->comboBoxDayOfWeek->Text->Equals("Wednesday"))
  855. commonData->eDayOfWeek = CommonData::DayOfWeek::WEDNESDAY;
  856. else if (this->comboBoxDayOfWeek->Text->Equals("Thursday"))
  857. commonData->eDayOfWeek = CommonData::DayOfWeek::THURSDAY;
  858. else if (this->comboBoxDayOfWeek->Text->Equals("Friday"))
  859. commonData->eDayOfWeek = CommonData::DayOfWeek::FRIDAY;
  860. else if (this->comboBoxDayOfWeek->Text->Equals("Saturday"))
  861. commonData->eDayOfWeek = CommonData::DayOfWeek::SATURDAY;
  862. else if (this->comboBoxDayOfWeek->Text->Equals("Sunday"))
  863. commonData->eDayOfWeek = CommonData::DayOfWeek::SUNDAY;
  864. else if (this->comboBoxDayOfWeek->Text->Equals("Invalid"))
  865. commonData->eDayOfWeek = CommonData::DayOfWeek::INVALID;
  866. }
  867. /**************************************************************************
  868. * MSMSensor::numericUpDownDay_ValueChanged
  869. *
  870. * Sets value of the day
  871. *
  872. * returns: N/A
  873. *
  874. **************************************************************************/
  875. void MSMSensor::numericUpDownDay_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  876. {
  877. commonData->ucDays = System::Convert::ToByte(this->numericUpDownDay->Value);
  878. }
  879. /**************************************************************************
  880. * MSMSensor::numericUpDownMonth_ValueChanged
  881. *
  882. * Sets value of the month
  883. *
  884. * returns: N/A
  885. *
  886. **************************************************************************/
  887. void MSMSensor::numericUpDownMonth_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  888. {
  889. commonData->ucMonth = System::Convert::ToByte(this->numericUpDownMonth->Value);
  890. }
  891. /**************************************************************************
  892. * MSMSensor::numericUpDownYear_ValueChanged
  893. *
  894. * Sets value of the year
  895. *
  896. * returns: N/A
  897. *
  898. **************************************************************************/
  899. void MSMSensor::numericUpDownYear_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  900. {
  901. commonData->ucYears = System::Convert::ToByte(this->numericUpDownYear->Value);
  902. }
  903. /**************************************************************************
  904. * MSMSensor::numericUpDownHours_ValueChanged
  905. *
  906. * Sets value of the hours
  907. *
  908. * returns: N/A
  909. *
  910. **************************************************************************/
  911. void MSMSensor::numericUpDownHours_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  912. {
  913. commonData->ucHours = System::Convert::ToByte(this->numericUpDownHours->Value);
  914. }
  915. /**************************************************************************
  916. * MSMSensor::numericUpDownMinutes_ValueChanged
  917. *
  918. * Sets value of the minutes
  919. *
  920. * returns: N/A
  921. *
  922. **************************************************************************/
  923. void MSMSensor::numericUpDownMinutes_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  924. {
  925. commonData->ucMinutes = System::Convert::ToByte(this->numericUpDownMinutes->Value);
  926. }
  927. /**************************************************************************
  928. * MSMSensor::numericUpDownSeconds_ValueChanged
  929. *
  930. * Sets value of the minutes
  931. *
  932. * returns: N/A
  933. *
  934. **************************************************************************/
  935. void MSMSensor::numericUpDownSeconds_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  936. {
  937. commonData->ucSeconds = System::Convert::ToByte(this->numericUpDownSeconds->Value);
  938. }
  939. /**************************************************************************
  940. * MSMSensor::UpdateTxPattern
  941. *
  942. * Updates the transmission timing pattern according to what pages are
  943. * enabled.
  944. *
  945. * returns: N/A
  946. *
  947. **************************************************************************/
  948. void MSMSensor::UpdateTxPattern()
  949. {
  950. if(this->checkBoxSecondaryData->Checked)
  951. {
  952. if(this->checkBoxPage3Enable->Checked)
  953. {
  954. //Data pages 1, 2, and 3 enabled
  955. ucTxPattern.Clear();
  956. ucTxPattern.Add(msmData->PAGE_1);
  957. ucTxPattern.Add(msmData->PAGE_1);
  958. ucTxPattern.Add(msmData->PAGE_2);
  959. ucTxPattern.Add(msmData->PAGE_3);
  960. ucTxPattern.Add(msmData->PAGE_1);
  961. ucTxPattern.Add(msmData->PAGE_1);
  962. ucTxPattern.Add(msmData->PAGE_3);
  963. ucTxPattern.Add(msmData->PAGE_2);
  964. ucTxPattern.TrimExcess();
  965. }
  966. else
  967. {
  968. //Data pages 1 and 2 enabled
  969. ucTxPattern.Clear();
  970. ucTxPattern.Add(msmData->PAGE_1);
  971. ucTxPattern.Add(msmData->PAGE_1);
  972. ucTxPattern.Add(msmData->PAGE_2);
  973. ucTxPattern.Add(msmData->PAGE_2);
  974. ucTxPattern.TrimExcess();
  975. }
  976. }
  977. else
  978. {
  979. if(this->checkBoxPage3Enable->Checked)
  980. {
  981. //Data pages 1 and 3 enabled
  982. ucTxPattern.Clear();
  983. ucTxPattern.Add(msmData->PAGE_1);
  984. ucTxPattern.Add(msmData->PAGE_1);
  985. ucTxPattern.Add(msmData->PAGE_3);
  986. ucTxPattern.Add(msmData->PAGE_3);
  987. ucTxPattern.TrimExcess();
  988. }
  989. else
  990. {
  991. //Only data page 1 enabled
  992. ucTxPattern.Clear();
  993. ucTxPattern.Add(msmData->PAGE_1);
  994. ucTxPattern.TrimExcess();
  995. }
  996. }
  997. }
  998. /**************************************************************************
  999. * MSMSensor::UpdateCommonPattern
  1000. *
  1001. * Updates the common pages pattern depending on which common pages
  1002. * are supported.
  1003. *
  1004. * returns: N/A
  1005. *
  1006. **************************************************************************/
  1007. void MSMSensor::UpdateCommonPattern()
  1008. {
  1009. switch(this->checkBox_Bat_Status->Checked)
  1010. {
  1011. case TRUE:
  1012. switch(this->checkBoxEnableDateTime->Checked)
  1013. {
  1014. case TRUE:
  1015. //All common pages enabled
  1016. ucCommonPattern.Clear();
  1017. ucCommonPattern.Add(commonData->PAGE80);
  1018. ucCommonPattern.Add(commonData->PAGE80);
  1019. ucCommonPattern.Add(commonData->PAGE81);
  1020. ucCommonPattern.Add(commonData->PAGE81);
  1021. ucCommonPattern.Add(commonData->PAGE82);
  1022. ucCommonPattern.Add(commonData->PAGE82);
  1023. ucCommonPattern.Add(commonData->PAGE83);
  1024. ucCommonPattern.Add(commonData->PAGE83);
  1025. ucCommonPattern.TrimExcess();
  1026. break;
  1027. default:
  1028. //Common Time NOT enabled
  1029. ucCommonPattern.Clear();
  1030. ucCommonPattern.Add(commonData->PAGE80);
  1031. ucCommonPattern.Add(commonData->PAGE80);
  1032. ucCommonPattern.Add(commonData->PAGE81);
  1033. ucCommonPattern.Add(commonData->PAGE81);
  1034. ucCommonPattern.Add(commonData->PAGE82);
  1035. ucCommonPattern.Add(commonData->PAGE82);
  1036. ucCommonPattern.TrimExcess();
  1037. break;
  1038. }
  1039. break;
  1040. default:
  1041. switch(this->checkBoxEnableDateTime->Checked)
  1042. {
  1043. case TRUE:
  1044. //Common Battery page NOT enabled
  1045. ucCommonPattern.Clear();
  1046. ucCommonPattern.Add(commonData->PAGE80);
  1047. ucCommonPattern.Add(commonData->PAGE80);
  1048. ucCommonPattern.Add(commonData->PAGE81);
  1049. ucCommonPattern.Add(commonData->PAGE81);
  1050. ucCommonPattern.Add(commonData->PAGE83);
  1051. ucCommonPattern.Add(commonData->PAGE83);
  1052. ucCommonPattern.TrimExcess();
  1053. break;
  1054. default:
  1055. //No additional common pages enabled
  1056. ucCommonPattern.Clear();
  1057. ucCommonPattern.Add(commonData->PAGE80);
  1058. ucCommonPattern.Add(commonData->PAGE80);
  1059. ucCommonPattern.Add(commonData->PAGE81);
  1060. ucCommonPattern.Add(commonData->PAGE81);
  1061. ucCommonPattern.TrimExcess();
  1062. break;
  1063. }
  1064. break;
  1065. }
  1066. }
  1067. /**************************************************************************
  1068. * MSMSensor::checkBox_InvalidSerial_CheckedChanged
  1069. *
  1070. * Handles the CheckedChanged event for the checkBox
  1071. *
  1072. * returns: N/A
  1073. *
  1074. **************************************************************************/
  1075. void MSMSensor::checkBox_InvalidSerial_CheckedChanged(System::Object ^sender, System::EventArgs ^e)
  1076. {
  1077. if(this->checkBox_InvalidSerial->Checked)
  1078. this->textBox_Glb_SerialNumChange->Enabled = false;
  1079. else
  1080. this->textBox_Glb_SerialNumChange->Enabled = true;
  1081. }