GeocacheSensor.cpp 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  1. /*******************************************************************************
  2. * THE FOLLOWING EXAMPLE CODE IS INTENDED FOR LIMITED CIRCULATION ONLY.
  3. *
  4. * Please forward all questions regarding this code to ANT Technical Support.
  5. *
  6. * Dynastream Innovations Inc.
  7. *
  8. * (P) +1 403 932 9292
  9. * (F) +1 403 932 4196
  10. * (E) support@thisisant.com
  11. *
  12. * www.thisisant.com
  13. *
  14. * Reference Design Disclaimer
  15. *
  16. * The references designs and codes provided may be used with ANT devices only and remain the copyrighted property of
  17. * Dynastream Innovations Inc. The reference designs and codes are being provided on an "as-is" basis and as an accommodation,
  18. * and therefore all warranties, representations, or guarantees of any kind (whether express, implied or statutory) including,
  19. * without limitation, warranties of merchantability, non-infringement,
  20. * or fitness for a particular purpose, are specifically disclaimed.
  21. *
  22. * ©2012 Dynastream Innovations Inc. All Rights Reserved
  23. * This software may not be reproduced by
  24. * any means without express written approval of Dynastream
  25. * Innovations Inc.
  26. *
  27. *******************************************************************************/
  28. #pragma once
  29. #include "stdafx.h"
  30. #include "GeocacheSensor.h"
  31. #include "antmessage.h"
  32. using namespace System::Runtime::InteropServices;
  33. static ULONG ulMessageCount = 0;
  34. static UCHAR ucPageCount = 0;
  35. static BOOL bCloseEvent = FALSE;
  36. /**************************************************************************
  37. * GeocacheSensor::InitializeSim
  38. *
  39. * Initialize the simulator variables
  40. *
  41. * returns: N/A
  42. *
  43. **************************************************************************/
  44. void GeocacheSensor::InitializeSim()
  45. {
  46. ulTimerInterval = 250; // in ms - simulates the sensor sending the most relevant information every message period
  47. ulTotalTime = 0;
  48. // initialize Geocache
  49. GeocacheData->InitSensor();
  50. GeocacheData->ucTotalPages = GeocacheData->START_PROG_PAGES;
  51. GeocacheData->usMessagePeriod = GeocacheData->MESG_P5HZ_PERIOD; // Defaults to Beacon Rate of 0.5Hz
  52. GeocacheData->b4HzRotation = FALSE;
  53. // required common pages
  54. commonData->ulSerialNum = System::Convert::ToUInt32(this->textBox_Glb_SerialNumChange->Text);
  55. commonData->ucSwVersion = System::Convert::ToByte(this->textBox_Glb_SoftwareVerChange->Text);
  56. commonData->ucHwVersion = System::Convert::ToByte(this->textBox_Glb_HardwareVerChange->Text);
  57. commonData->usMfgID = System::Convert::ToUInt16(this->textBox_Glb_ManfIDChange->Text);
  58. commonData->usModelNum = System::Convert::ToUInt16(this->textBox_Glb_ModelNumChange->Text);
  59. //battery common page
  60. commonData->bBattPageEnabled = TRUE;
  61. // update the variables
  62. UpdateBatStatus();
  63. commonData->eTimeResolution = CommonData::TimeResolution::TWO;
  64. commonData->ulOpTime = ulTotalTime / (UCHAR) commonData->eTimeResolution;
  65. commonData->usBatVoltage256 = ((USHORT) System::Convert::ToByte(this->numericUpDown_Bat_VoltInt->Value)) << 8 | (commonData->usBatVoltage256 & 0xFF); // Integer portion in high byte
  66. commonData->usBatVoltage256 |= System::Convert::ToByte(this->numericUpDown_Bat_VoltFrac->Value) | (commonData->usBatVoltage256 & 0xFF00); // Fractional portion in low byte
  67. commonData->eTimeResolution = CommonData::TimeResolution::TWO;
  68. commonData->ulOpTime = ulTotalTime;
  69. }
  70. /**************************************************************************
  71. * GeocacheSensor::ANT_eventNotification
  72. *
  73. * Process ANT channel event
  74. *
  75. * ucEventCode_: code of ANT channel event
  76. * pucEventBuffer_: pointer to buffer containing data received from ANT,
  77. * or a pointer to the transmit buffer in the case of an EVENT_TX
  78. *
  79. * returns: N/A
  80. *
  81. **************************************************************************/
  82. void GeocacheSensor::ANT_eventNotification(UCHAR ucEventCode_, UCHAR* pucEventBuffer_)
  83. {
  84. switch(ucEventCode_)
  85. {
  86. case EVENT_TX:
  87. HandleTransmit((UCHAR*) pucEventBuffer_);
  88. break;
  89. case EVENT_RX_BROADCAST:
  90. case EVENT_RX_ACKNOWLEDGED:
  91. HandleReceive((UCHAR*) pucEventBuffer_);
  92. break;
  93. case EVENT_TRANSFER_TX_COMPLETED:
  94. UpdateDisplayAckStatus(GeocacheData->ACK_SUCCESS);
  95. break;
  96. case EVENT_ACK_TIMEOUT:
  97. case EVENT_TRANSFER_TX_FAILED: // intentional fall through
  98. UpdateDisplayAckStatus(GeocacheData->ACK_FAIL);
  99. break;
  100. case MESG_CLOSE_CHANNEL_ID:
  101. bCloseEvent = TRUE;
  102. break;
  103. default:
  104. break;
  105. }
  106. }
  107. /**************************************************************************
  108. * GeocacheSensor::HandleReceive
  109. *
  110. * Handle incoming (GPS) requests
  111. *
  112. * pucRxBuffer_: pointer to the receive buffer
  113. *
  114. * returns: N/A
  115. *
  116. **************************************************************************/
  117. void GeocacheSensor::HandleReceive(UCHAR* pucRxBuffer_)
  118. {
  119. ulMessageCount = 0; // Reset Message Counter on Any Request
  120. // Change to 4Hz and begin Page Rotation on *ANY* RX
  121. if (!GeocacheData->b4HzRotation)
  122. {
  123. GeocacheData->b4HzRotation = TRUE;
  124. GeocacheData->usMessagePeriod = GeocacheData->MESG_4HZ_PERIOD;
  125. requestUpdateMesgPeriod(GeocacheData->MESG_4HZ_PERIOD);
  126. }
  127. if (pucRxBuffer_[0] == commonData->PAGE70) // Data Page Request
  128. {
  129. GeocacheData->ucRequestedPageNum = pucRxBuffer_[6];
  130. // How should we respond ? Broadcast (added to Page Rotation) or Ack'd ?
  131. if (pucRxBuffer_[5] == GeocacheData->MESG_REQ_RESP_ACK)
  132. GeocacheData->bAckResponseRequest = TRUE;
  133. else
  134. GeocacheData->bAckResponseRequest = FALSE;
  135. switch (GeocacheData->ucRequestedPageNum) // Get Requested Page #
  136. {
  137. case GeocacheData->PAGE_1 :
  138. GeocacheData->GetPageData(GeocacheData->ucRequestedPageNum, pucRxBuffer_);
  139. // Start Point for Page Rotation
  140. if (GeocacheData->ucTotalPages > 2)
  141. ucPageCount = GeocacheData->PAGE_2;
  142. else
  143. ucPageCount = commonData->PAGE80;
  144. break;
  145. case commonData->PAGE80 :
  146. commonData->Encode(commonData->PAGE80, pucRxBuffer_);
  147. break;
  148. case commonData->PAGE81 :
  149. commonData->Encode(commonData->PAGE81, pucRxBuffer_);
  150. break;
  151. case commonData->PAGE82 :
  152. if (commonData->bBattPageEnabled)
  153. {
  154. commonData->Encode(commonData->PAGE82, pucRxBuffer_);
  155. }
  156. break;
  157. default:
  158. GeocacheData->GetPageData(GeocacheData->ucRequestedPageNum, pucRxBuffer_);
  159. break;
  160. }
  161. // Broadcast (added to Page Rotation) or Ack'd ?
  162. if (GeocacheData->bAckResponseRequest)
  163. {
  164. requestAckMsg(pucRxBuffer_);
  165. }
  166. else
  167. {
  168. GeocacheData->bPageRequest = TRUE;
  169. }
  170. }
  171. else if (pucRxBuffer_[0] < GeocacheData->PAGE_32) // GPS is Programming Pages
  172. {
  173. GeocacheData->Decode(pucRxBuffer_);
  174. }
  175. else if (pucRxBuffer_[0] == GeocacheData->PAGE_32) // Authentication Request
  176. {
  177. Authentication(pucRxBuffer_);
  178. GeocacheData->bPageRequest = TRUE;
  179. GeocacheData->ucRequestedPageNum = pucRxBuffer_[0];
  180. }
  181. }
  182. /**************************************************************************
  183. * Geocache::Authentication
  184. *
  185. * Generate Authentication Token from GPS Serial # and Nonce
  186. *
  187. *
  188. * pucRxBuffer_: pointer to the buffer containing the received data
  189. *
  190. * returns: N/A
  191. *
  192. **************************************************************************/
  193. using namespace System::Security::Cryptography;
  194. void GeocacheSensor::Authentication(UCHAR* pucRxBuffer_)
  195. {
  196. cli::array<Byte>^ Nonce_SerialNum = gcnew cli::array<Byte>(6);
  197. for (int i=0; i<6; i++) Nonce_SerialNum[i] = (byte)pucRxBuffer_[2+i];
  198. HashAlgorithm^ sha = gcnew SHA1CryptoServiceProvider;
  199. array<Byte>^ result = sha->ComputeHash( Nonce_SerialNum );
  200. for (int i=0; i<7; i++)
  201. GeocacheData->ucAuthToken[i] = (UCHAR)result[i];
  202. }
  203. /**************************************************************************
  204. * GeocacheSensor::HandleTransmit
  205. *
  206. * Encode data generated by simulator for transmission
  207. *
  208. * ucPageNum_: The page number to be transmitted
  209. * pucTxBuffer_: pointer to the transmit buffer
  210. *
  211. * returns: N/A
  212. *
  213. **************************************************************************/
  214. void GeocacheSensor::HandleTransmit(UCHAR* pucTxBuffer_)
  215. {
  216. // Kill Page Requests and Switch to 0.5Hz Beacon Mode
  217. if (bCloseEvent)
  218. {
  219. bCloseEvent = FALSE;
  220. GeocacheData->bPageRequest = FALSE;
  221. GeocacheData->b4HzRotation = FALSE;
  222. GeocacheData->usMessagePeriod = GeocacheData->MESG_P5HZ_PERIOD;
  223. requestUpdateMesgPeriod(GeocacheData->MESG_P5HZ_PERIOD);
  224. }
  225. if (GeocacheData->bPageRequest)
  226. {
  227. switch (GeocacheData->ucRequestedPageNum)
  228. {
  229. case commonData->PAGE80 :
  230. commonData->Encode(commonData->PAGE80, pucTxBuffer_);
  231. break;
  232. case commonData->PAGE81 :
  233. commonData->Encode(commonData->PAGE81, pucTxBuffer_);
  234. break;
  235. case commonData->PAGE82 :
  236. if (commonData->bBattPageEnabled)
  237. {
  238. commonData->Encode(commonData->PAGE82, pucTxBuffer_);
  239. }
  240. break;
  241. default:
  242. GeocacheData->GetPageData(GeocacheData->ucRequestedPageNum, pucTxBuffer_);
  243. break;
  244. }
  245. GeocacheData->bPageRequest = FALSE;
  246. }
  247. else if (GeocacheData->b4HzRotation)
  248. {
  249. switch (ucPageCount)
  250. {
  251. case GeocacheData->PAGE_0 :
  252. // Encode PAGE 0
  253. GeocacheData->GetPageData(GeocacheData->PAGE_0, pucTxBuffer_);
  254. ucPageCount = GeocacheData->PAGE_1;
  255. break;
  256. case GeocacheData->PAGE_1 :
  257. // Encode PAGE 1
  258. GeocacheData->GetPageData(GeocacheData->PAGE_1, pucTxBuffer_);
  259. // Do we have Programmed Pages ?
  260. if (GeocacheData->ucTotalPages > 2)
  261. ucPageCount = GeocacheData->PAGE_2;
  262. else
  263. ucPageCount = commonData->PAGE80;
  264. break;
  265. case commonData->PAGE80 :
  266. commonData->Encode(ucPageCount, pucTxBuffer_);
  267. ucPageCount = commonData->PAGE81;
  268. break;
  269. case commonData->PAGE81 :
  270. commonData->Encode(ucPageCount, pucTxBuffer_);
  271. if (commonData->bBattPageEnabled)
  272. ucPageCount = commonData->PAGE82;
  273. else
  274. ucPageCount = GeocacheData->PAGE_0;
  275. break;
  276. case commonData->PAGE82 :
  277. commonData->Encode(ucPageCount, pucTxBuffer_);
  278. ucPageCount = GeocacheData->PAGE_0;
  279. break;
  280. default :
  281. GeocacheData->GetPageData(ucPageCount, pucTxBuffer_);
  282. ucPageCount++;
  283. if (ucPageCount > (GeocacheData->ucTotalPages-1)) ucPageCount = commonData->PAGE80;
  284. break;
  285. }
  286. }
  287. else // Not in 4Hz Rotation - just send Beacon (PAGE 0)
  288. {
  289. GeocacheData->GetPageData(GeocacheData->PAGE_0, pucTxBuffer_);
  290. }
  291. ulMessageCount++;
  292. // Return to 0.5Hz Beacon ONLY after 30 secs ... of no GPS requests
  293. if (GeocacheData->b4HzRotation && (ulMessageCount > GeocacheData->MESG_4HZ_TIMEOUT))
  294. {
  295. GeocacheData->b4HzRotation = FALSE;
  296. GeocacheData->usMessagePeriod = GeocacheData->MESG_P5HZ_PERIOD;
  297. requestUpdateMesgPeriod(GeocacheData->MESG_P5HZ_PERIOD);
  298. }
  299. static UCHAR ucTimeCount = 0;
  300. // update the batt op time every second
  301. if (ucTimeCount == 3)
  302. {
  303. ulTotalTime++;
  304. commonData->ulOpTime = ulTotalTime / (UCHAR) commonData->eTimeResolution;
  305. ucTimeCount = 0;
  306. }
  307. else
  308. ucTimeCount++;
  309. }
  310. /**************************************************************************
  311. * GeocacheSensor::buttonProgram_Click
  312. *
  313. * Update the Programmable Pages (per UI Values)
  314. *
  315. * returns: N/A
  316. *
  317. **************************************************************************/
  318. void GeocacheSensor::buttonProgram_Click(System::Object^ sender, System::EventArgs^ e)
  319. {
  320. GeocacheData->bLatitudeEnabled = FALSE;
  321. GeocacheData->bLongitudeEnabled = FALSE;
  322. GeocacheData->bHintEnabled = FALSE;
  323. GeocacheData->bLoggedVisitsEnabled = FALSE;
  324. // ID
  325. if (this->checkBoxID->Checked)
  326. {
  327. char* stringPointer = (char*) Marshal::StringToHGlobalAnsi(this->textBoxID->Text->ToUpper()).ToPointer();
  328. for (int i=0; i<this->textBoxID->Text->Length; i++)
  329. GeocacheData->cID[i] = stringPointer[i] - 0x20;
  330. for (int i=this->textBoxID->Text->Length; i<9; i++)
  331. GeocacheData->cID[i] = 0x00;
  332. // Always free the unmanaged string.
  333. Marshal::FreeHGlobal(IntPtr(stringPointer));
  334. }
  335. // PIN
  336. if (this->checkBoxPIN->Checked)
  337. {
  338. if (this->textBoxPIN->Text->Length > 0)
  339. {
  340. if(!UInt32::TryParse(this->textBoxPIN->Text, (unsigned int)GeocacheData->ulPIN))
  341. System::Windows::Forms::MessageBox::Show(this, "PIN could not be parsed as an unsigned 4 byte number");
  342. }
  343. else
  344. GeocacheData->ulPIN = GeocacheData->DEFAULT_PIN;
  345. }
  346. if (this->checkBoxLatitude->Checked)
  347. {
  348. GeocacheData->bLatitudeEnabled = TRUE;
  349. GeocacheData->slLatitude_SC = System::Convert::ToInt32(double (this->numericUpDownLatitude->Value) * GeocacheData->SEMI_CIRCLE_CONVERSION);
  350. }
  351. if (this->checkBoxLongitude->Checked)
  352. {
  353. GeocacheData->bLongitudeEnabled = TRUE;
  354. GeocacheData->slLongitude_SC = System::Convert::ToInt32(double (this->numericUpDownLongitude->Value) * GeocacheData->SEMI_CIRCLE_CONVERSION);
  355. }
  356. if (this->checkBoxLoggedVisits->Checked)
  357. {
  358. time_t tmtEpoch, tmtLastVisit;
  359. struct tm tmEpoch, tmLastVisit;
  360. tmEpoch.tm_year = 1989 - 1900;
  361. tmEpoch.tm_mon = 12 - 1;
  362. tmEpoch.tm_mday = 31;
  363. tmEpoch.tm_hour = 00;
  364. tmEpoch.tm_min = 00;
  365. tmEpoch.tm_sec = 00;
  366. tmtEpoch = mktime(&tmEpoch);
  367. tmLastVisit.tm_year = System::Convert::ToUInt16(this->numericUpDownYear->Value) - 1900;
  368. tmLastVisit.tm_mon = System::Convert::ToUInt16(this->numericUpDownMonth->Value) - 1;
  369. tmLastVisit.tm_mday = System::Convert::ToUInt16(this->numericUpDownDay->Value);
  370. tmLastVisit.tm_hour = System::Convert::ToUInt16(this->numericUpDownHours->Value);
  371. tmLastVisit.tm_min = System::Convert::ToUInt16(this->numericUpDownMinutes->Value);
  372. tmLastVisit.tm_sec = System::Convert::ToUInt16(this->numericUpDownSeconds->Value);
  373. tmtLastVisit = mktime(&tmLastVisit);
  374. //if (tmLastVisit.tm_isdst > 0) //Removed. We are calculating an absolute difference in UTC time, which is not impacted by daylight savings
  375. GeocacheData->ulLastVisitTimestamp = (ULONG) difftime(tmtLastVisit, tmtEpoch);
  376. GeocacheData->bLoggedVisitsEnabled = TRUE;
  377. GeocacheData->usNumVisits = System::Convert::ToUInt16(this->numericUpDownNumVisits->Value);
  378. }
  379. if (this->checkBoxHint->Checked)
  380. {
  381. char* stringPointer = (char*) Marshal::StringToHGlobalAnsi(this->textBoxHint->Text).ToPointer();
  382. for (int i=0; i<this->textBoxHint->Text->Length; i++)
  383. GeocacheData->cHint[i] = stringPointer[i];
  384. GeocacheData->ucNumHintPages = (this->textBoxHint->Text->Length/GeocacheData->HINT_CHARS_PER_PAGE) + 1;
  385. GeocacheData->bHintEnabled = TRUE;
  386. }
  387. GeocacheData->GenerateProgPages();
  388. UpdateDisplay();
  389. }
  390. /**************************************************************************
  391. * GeocacheSensor::Update Display
  392. *
  393. * Update the GUI with all the changes
  394. *
  395. * returns: N/A
  396. *
  397. **************************************************************************/
  398. void GeocacheSensor::UpdateDisplay()
  399. {
  400. // ID
  401. System::Text::StringBuilder^ builder = gcnew System::Text::StringBuilder();
  402. for(int i=0; i<GeocacheData->cID->Length; i++) builder->Append((Char)(GeocacheData->cID[i]+0x20));
  403. this->labelID->Text = builder->ToString();
  404. // PIN
  405. if (!this->checkBoxPIN->Checked) // Don't update if Selected
  406. this->textBoxPIN->Text = GeocacheData->ulPIN.ToString();
  407. this->labelPIN->Text = GeocacheData->ulPIN.ToString();
  408. // Total Pages
  409. this->labelTotNumPages->Text = GeocacheData->ucTotalPages.ToString();
  410. // Determine which pages are Enabled
  411. GeocacheData->EnabledProgPages();
  412. // Lat/Lon Pages
  413. if (GeocacheData->bLatitudeEnabled)
  414. {
  415. if (!this->checkBoxLatitude->Checked) // Don't update if Selected
  416. this->numericUpDownLatitude->Text = ((double)GeocacheData->slLatitude_SC / GeocacheData->SEMI_CIRCLE_CONVERSION).ToString("N2");
  417. this->labelLat->Text = ((double)GeocacheData->slLatitude_SC / GeocacheData->SEMI_CIRCLE_CONVERSION).ToString("N2");
  418. }
  419. else
  420. {
  421. this->labelLat->Text = "---";
  422. }
  423. if (GeocacheData->bLongitudeEnabled)
  424. {
  425. if (!this->checkBoxLongitude->Checked) // Don't update if Selected
  426. this->numericUpDownLongitude->Text = ((double)GeocacheData->slLongitude_SC / GeocacheData->SEMI_CIRCLE_CONVERSION).ToString("N2");
  427. this->labelLon->Text = ((double)GeocacheData->slLongitude_SC / GeocacheData->SEMI_CIRCLE_CONVERSION).ToString("N2");
  428. }
  429. else
  430. {
  431. this->labelLon->Text = "---";
  432. }
  433. // Hint Page(s)
  434. if (GeocacheData->bHintEnabled)
  435. {
  436. System::Text::StringBuilder^ builder = gcnew System::Text::StringBuilder();
  437. for(int i=0; i<GeocacheData->cHint->Length; i++) builder->Append((Char)GeocacheData->cHint[i]);
  438. this->labelHint->Text = builder->ToString();
  439. if (!this->checkBoxHint->Checked) // Don't update if Selected
  440. this->textBoxHint->Text = builder->ToString();
  441. }
  442. else
  443. {
  444. this->labelHint->Text = "---";
  445. }
  446. // Logged Visits Page
  447. if (GeocacheData->bLoggedVisitsEnabled && (GeocacheData->ulLastVisitTimestamp > 0))
  448. {
  449. if (!this->checkBoxLoggedVisits->Checked) // Don't update if Selected
  450. this->numericUpDownNumVisits->Value = GeocacheData->usNumVisits;
  451. this->labelNumVisits->Text = this->numericUpDownNumVisits->Text;
  452. time_t tmtEpoch;
  453. struct tm tmEpoch;
  454. tmEpoch.tm_year = 1989 - 1900;
  455. tmEpoch.tm_mon = 12 - 1;
  456. tmEpoch.tm_mday = 31;
  457. tmEpoch.tm_hour = 00;
  458. tmEpoch.tm_min = 00;
  459. tmEpoch.tm_sec = 00;
  460. tmtEpoch = mktime(&tmEpoch);
  461. time_t tmtLastVisit;
  462. struct tm * tmLastVisit;
  463. tmtLastVisit = ((time_t)GeocacheData->ulLastVisitTimestamp + tmtEpoch);
  464. #pragma warning (disable : 4068)
  465. #pragma warning (disable : 4996)
  466. tmLastVisit = localtime(&tmtLastVisit);
  467. //Additional correction for daylight savings not required
  468. if (!this->checkBoxLoggedVisits->Checked) // Don't update if Selected
  469. {
  470. this->numericUpDownYear->Value = tmLastVisit->tm_year + 1900;
  471. this->numericUpDownMonth->Value = tmLastVisit->tm_mon + 1;
  472. this->numericUpDownDay->Value = tmLastVisit->tm_mday;
  473. this->numericUpDownHours->Value = tmLastVisit->tm_hour;
  474. this->numericUpDownMinutes->Value = tmLastVisit->tm_min;
  475. this->numericUpDownSeconds->Value = tmLastVisit->tm_sec;
  476. }
  477. System::Text::StringBuilder^ builder = gcnew System::Text::StringBuilder();
  478. for(int i=0; i<26; i++) builder->Append((Char)((asctime(&tmLastVisit[0]))[i]));
  479. this->labelTimestamp->Text = builder->ToString();
  480. }
  481. else
  482. {
  483. this->labelNumVisits->Text = "-";
  484. this->labelTimestamp->Text = "-";
  485. }
  486. // Authentication Token
  487. UInt64 ui64AuthToken = ((UInt64)GeocacheData->ucAuthToken[0]) +
  488. ((UInt64)GeocacheData->ucAuthToken[1] << 8) +
  489. ((UInt64)GeocacheData->ucAuthToken[2] << 16) +
  490. ((UInt64)GeocacheData->ucAuthToken[3] << 24) +
  491. ((UInt64)GeocacheData->ucAuthToken[4] << 32) +
  492. ((UInt64)GeocacheData->ucAuthToken[5] << 40) +
  493. ((UInt64)GeocacheData->ucAuthToken[6] << 48);
  494. this->labelAuthToken->Text = ui64AuthToken.ToString("X2");
  495. // update the operating time for the battery common page
  496. this->label_Bat_ElpTimeDisplay->Text = ulTotalTime.ToString();
  497. }
  498. /**************************************************************************
  499. * GeocacheSensor::onTimerTock
  500. *
  501. * Simulates a sensor event, updating simulator data based on this event
  502. * Modifications to the timer interval are applied immediately after this
  503. * at ANTChannel
  504. *
  505. * usEventTime_: current time (ms)
  506. *
  507. * returns: N/A
  508. *
  509. **************************************************************************/
  510. void GeocacheSensor::onTimerTock(USHORT eventTime)
  511. {
  512. UpdateDisplay();
  513. }
  514. /**************************************************************************
  515. * GeocacheSensor::UpdateDisplayAckStatus
  516. *
  517. * Adjusts the GUI depending on the ACK status of the tx message
  518. *
  519. * UCHAR status_: gives the success or fail status of the tx message
  520. *
  521. * returns: N/A
  522. *
  523. **************************************************************************/
  524. void GeocacheSensor::UpdateDisplayAckStatus(UCHAR status_)
  525. {
  526. // Nothing to do ...
  527. }
  528. /**************************************************************************
  529. * GeocacheSensor::numericUpDownLongitude_ValueChanged
  530. *
  531. * Adjusts the current longitude via the GUI
  532. *
  533. * returns: N/A
  534. *
  535. **************************************************************************/
  536. void GeocacheSensor::numericUpDownLongitude_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  537. {
  538. // GeocacheData->slLongitude_SC = System::Convert::ToInt32(double (this->numericUpDownLongitude->Value) * GeocacheData->SEMI_CIRCLE_CONVERSION);
  539. }
  540. /**************************************************************************
  541. * GeocacheSensor::numericUpDownLatitude_ValueChanged
  542. *
  543. * Adjusts the current latitude via the GUI
  544. *
  545. * returns: N/A
  546. *
  547. **************************************************************************/
  548. void GeocacheSensor::numericUpDownLatitude_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  549. {
  550. // GeocacheData->slLatitude_SC = System::Convert::ToInt32(double (this->numericUpDownLatitude->Value) * GeocacheData->SEMI_CIRCLE_CONVERSION);
  551. }
  552. /**************************************************************************
  553. * GeocacheSensor::checkBoxID_CheckedChanged
  554. *
  555. * Enables and disables the ID Text Box
  556. *
  557. * returns: N/A
  558. *
  559. **************************************************************************/
  560. void GeocacheSensor::checkBoxID_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  561. {
  562. if (this->checkBoxID->Checked == TRUE)
  563. {
  564. this->textBoxID->Enabled = TRUE;
  565. }
  566. else
  567. {
  568. this->textBoxID->Enabled = FALSE;
  569. }
  570. }
  571. // Boolean flag used to determine when a character other than a number is entered.
  572. bool nonNumberEntered;
  573. /**************************************************************************
  574. * GeocacheSensor::textBoxID_TextChanged
  575. *
  576. * Ensures ID uses characters in the valid ASCII 6 bit range.
  577. * We use the text changed event so we have the actual characters and don't have to mess around with key codes.
  578. *
  579. * returns: N/A
  580. *
  581. **************************************************************************/
  582. void GeocacheSensor::textBoxID_TextChanged(System::Object^ sender, System::EventArgs^ e)
  583. {
  584. System::Text::StringBuilder^ sb = gcnew System::Text::StringBuilder();
  585. for(int i=0; i < textBoxID->Text->Length; ++i)
  586. {
  587. if(textBoxID->Text[i] >= 32 && textBoxID->Text[i] <= 95)
  588. sb->Append(textBoxID->Text[i]);
  589. }
  590. textBoxID->Text = sb->ToString();
  591. }
  592. /**************************************************************************
  593. * GeocacheSensor::checkBoxPIN_CheckedChanged
  594. *
  595. * Enables and disables the PIN Text Box
  596. *
  597. * returns: N/A
  598. *
  599. **************************************************************************/
  600. void GeocacheSensor::checkBoxPIN_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  601. {
  602. if (this->checkBoxPIN->Checked == TRUE)
  603. {
  604. this->textBoxPIN->Enabled = TRUE;
  605. }
  606. else
  607. {
  608. this->textBoxPIN->Enabled = FALSE;
  609. }
  610. }
  611. /**************************************************************************
  612. * GeocacheSensor:textBoxPIN_KeyDown
  613. *
  614. * Handle the KeyDown event to determine the type of character entered into the control.
  615. *
  616. * returns: N/A
  617. *
  618. **************************************************************************/
  619. void GeocacheSensor::textBoxPIN_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e )
  620. {
  621. // Initialize the flag to false.
  622. nonNumberEntered = false;
  623. // Determine whether the keystroke is a number from the top of the keyboard.
  624. // ... or a valid KEY ...
  625. if ( e->KeyCode < Keys::D0 || e->KeyCode > Keys::D9 )
  626. {
  627. // Determine whether the keystroke is a number from the keypad.
  628. if ( e->KeyCode < Keys::NumPad0 || e->KeyCode > Keys::NumPad9 )
  629. {
  630. // Determine whether the keystroke is a backspace.
  631. if ( e->KeyCode != Keys::Back )
  632. {
  633. // A non-numerical keystroke was pressed.
  634. // Set the flag to true and evaluate in KeyPress event.
  635. nonNumberEntered = true;
  636. }
  637. }
  638. }
  639. // If shift key was pressed, it's not a number.
  640. if (Control::ModifierKeys == Keys::Shift) {
  641. nonNumberEntered = true;
  642. }
  643. }
  644. /**************************************************************************
  645. * GeocacheSensor:textBoxPIN_KeyPress
  646. *
  647. * This event occurs after the KeyDown event and can be used to prevent
  648. * characters from entering the control.
  649. *
  650. * returns: N/A
  651. *
  652. **************************************************************************/
  653. void GeocacheSensor::textBoxPIN_KeyPress( Object^ /*sender*/, System::Windows::Forms::KeyPressEventArgs^ e )
  654. {
  655. // Check for the flag being set in the KeyDown event.
  656. if ( nonNumberEntered == true )
  657. { // Stop the character from being entered into the control since it is non-numerical.
  658. e->Handled = true;
  659. }
  660. }
  661. /**************************************************************************
  662. * GeocacheSensor::checkBoxLatitude_CheckedChanged
  663. *
  664. * Enables and disables the Latitude numeric upDown
  665. *
  666. * returns: N/A
  667. *
  668. **************************************************************************/
  669. void GeocacheSensor::checkBoxLatitude_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  670. {
  671. if (this->checkBoxLatitude->Checked == TRUE)
  672. {
  673. this->numericUpDownLatitude->Enabled = TRUE;
  674. }
  675. else
  676. {
  677. this->numericUpDownLatitude->Enabled = FALSE;
  678. }
  679. }
  680. /**************************************************************************
  681. * GeocacheSensor::checkBoxLongitude_CheckedChanged
  682. *
  683. * Enables and disables the Longitude numeric upDown
  684. *
  685. * returns: N/A
  686. *
  687. **************************************************************************/
  688. void GeocacheSensor::checkBoxLongitude_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  689. {
  690. if (this->checkBoxLongitude->Checked == TRUE)
  691. {
  692. this->numericUpDownLongitude->Enabled = TRUE;
  693. }
  694. else
  695. {
  696. this->numericUpDownLongitude->Enabled = FALSE;
  697. }
  698. }
  699. /**************************************************************************
  700. * GeocacheSensor::checkBoxHint_CheckedChanged
  701. *
  702. * Enables and disables the Hint Test Box
  703. *
  704. * returns: N/A
  705. *
  706. **************************************************************************/
  707. void GeocacheSensor::checkBoxHint_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  708. {
  709. if (this->checkBoxHint->Checked == TRUE)
  710. {
  711. this->textBoxHint->Enabled = TRUE;
  712. }
  713. else
  714. {
  715. this->textBoxHint->Enabled = FALSE;
  716. }
  717. }
  718. /**************************************************************************
  719. * GeocacheSensor::checkBoxLoggedVisits_CheckedChanged
  720. *
  721. * Enables and disables the Various Logged Visit Parameters ...
  722. *
  723. * returns: N/A
  724. *
  725. **************************************************************************/
  726. void GeocacheSensor::checkBoxLoggedVisits_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  727. {
  728. if (this->checkBoxLoggedVisits->Checked == TRUE)
  729. {
  730. this->numericUpDownNumVisits->Enabled = TRUE;
  731. this->numericUpDownYear->Enabled = TRUE;
  732. this->numericUpDownMonth->Enabled = TRUE;
  733. this->numericUpDownDay->Enabled = TRUE;
  734. this->numericUpDownHours->Enabled = TRUE;
  735. this->numericUpDownMinutes->Enabled = TRUE;
  736. this->numericUpDownSeconds->Enabled = TRUE;
  737. }
  738. else
  739. {
  740. this->numericUpDownNumVisits->Enabled = FALSE;
  741. this->numericUpDownYear->Enabled = FALSE;
  742. this->numericUpDownMonth->Enabled = FALSE;
  743. this->numericUpDownDay->Enabled = FALSE;
  744. this->numericUpDownHours->Enabled = FALSE;
  745. this->numericUpDownMinutes->Enabled = FALSE;
  746. this->numericUpDownSeconds->Enabled = FALSE;
  747. }
  748. }
  749. /**************************************************************************
  750. * GeocacheSensor::numericUpDownNumVisits_ValueChanged
  751. *
  752. * Adjusts the current Number of Visits via the GUI
  753. *
  754. * returns: N/A
  755. *
  756. **************************************************************************/
  757. void GeocacheSensor::numericUpDownNumVisits_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  758. {
  759. // Nothing to do ...
  760. }
  761. /**************************************************************************
  762. * GeocacheSensor::button_Glb_GlobalDataUpdate_Click
  763. *
  764. * Adjusts the global pages 80 and 81 via the GUI
  765. *
  766. * returns: N/A
  767. *
  768. **************************************************************************/
  769. void GeocacheSensor::button_Glb_GlobalDataUpdate_Click(System::Object^ sender, System::EventArgs^ e)
  770. {
  771. this->labelError->Visible = false;
  772. // required common pages
  773. try
  774. {
  775. if(this->checkBox_NoSerial->Checked)
  776. commonData->ulSerialNum = 0xFFFFFFFF;
  777. else
  778. commonData->ulSerialNum = System::Convert::ToUInt32(this->textBox_Glb_SerialNumChange->Text);
  779. commonData->ucSwVersion = System::Convert::ToByte(this->textBox_Glb_SoftwareVerChange->Text);
  780. commonData->ucHwVersion = System::Convert::ToByte(this->textBox_Glb_HardwareVerChange->Text);
  781. commonData->usMfgID = System::Convert::ToUInt16(this->textBox_Glb_ManfIDChange->Text);
  782. commonData->usModelNum = System::Convert::ToUInt16(this->textBox_Glb_ModelNumChange->Text);
  783. }
  784. catch(...)
  785. {
  786. this->labelError->Visible = true;
  787. }
  788. }
  789. /**************************************************************************
  790. * GeocacheSensor::checkBox_Bat_Status_CheckedChanged
  791. *
  792. * Enables and disables the battery voltage GUI elements
  793. *
  794. * returns: N/A
  795. *
  796. **************************************************************************/
  797. void GeocacheSensor::checkBox_Bat_Status_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  798. {
  799. if (this->checkBox_Bat_Status->Checked == TRUE)
  800. {
  801. commonData->bBattPageEnabled = TRUE;
  802. this->comboBoxBatStatus->Enabled = TRUE;
  803. this->label_Bat_ElpTimeDisplay->Enabled = TRUE;
  804. this->textBox_Bat_ElpTimeChange->Enabled = TRUE;
  805. this->checkBox_Bat_Voltage->Enabled = TRUE;
  806. this->checkBox_Bat_Voltage->Checked = TRUE;
  807. this->numericUpDown_Bat_VoltFrac->Enabled = TRUE;
  808. this->numericUpDown_Bat_VoltInt->Enabled = TRUE;
  809. this->groupBox_Resol->Enabled = TRUE;
  810. this->button_Bat_ElpTimeUpdate->Enabled = TRUE;
  811. // update the variables
  812. UpdateBatStatus();
  813. if (this->radioButton_Bat_Elp16Units->Checked)
  814. commonData->eTimeResolution = CommonData::TimeResolution::SIXTEEN;
  815. if (this->radioButton_Bat_Elp2Units->Checked)
  816. commonData->eTimeResolution = CommonData::TimeResolution::TWO;
  817. commonData->ulOpTime = ulTotalTime / (UCHAR) commonData->eTimeResolution;
  818. commonData->usBatVoltage256 = ((USHORT) System::Convert::ToByte(this->numericUpDown_Bat_VoltInt->Value)) << 8 | (commonData->usBatVoltage256 & 0xFF); // Integer portion in high byte
  819. commonData->usBatVoltage256 |= System::Convert::ToByte(this->numericUpDown_Bat_VoltFrac->Value) | (commonData->usBatVoltage256 & 0xFF00); // Fractional portion in low byte
  820. }
  821. else
  822. {
  823. commonData->bBattPageEnabled = FALSE;
  824. this->comboBoxBatStatus->Enabled = FALSE;
  825. this->label_Bat_ElpTimeDisplay->Enabled = FALSE;
  826. this->textBox_Bat_ElpTimeChange->Enabled = FALSE;
  827. this->checkBox_Bat_Voltage->Enabled = FALSE;
  828. this->checkBox_Bat_Voltage->Checked = FALSE;
  829. this->numericUpDown_Bat_VoltFrac->Enabled = FALSE;
  830. this->numericUpDown_Bat_VoltInt->Enabled = FALSE;
  831. this->groupBox_Resol->Enabled = FALSE;
  832. this->button_Bat_ElpTimeUpdate->Enabled = FALSE;
  833. }
  834. }
  835. /**************************************************************************
  836. * GeocacheSensor::checkBox_Bat_Voltage_CheckedChanged
  837. *
  838. * Enables and disables the battery voltage numeric upDown
  839. *
  840. * returns: N/A
  841. *
  842. **************************************************************************/
  843. void GeocacheSensor::checkBox_Bat_Voltage_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  844. {
  845. if (this->checkBox_Bat_Voltage->Checked == TRUE)
  846. {
  847. this->numericUpDown_Bat_VoltInt->Enabled = TRUE;
  848. this->numericUpDown_Bat_VoltFrac->Enabled = TRUE;
  849. commonData->usBatVoltage256 = ((USHORT) System::Convert::ToByte(this->numericUpDown_Bat_VoltInt->Value)) << 8 | (commonData->usBatVoltage256 & 0xFF); // Integer portion in high byte
  850. commonData->usBatVoltage256 |= System::Convert::ToByte(this->numericUpDown_Bat_VoltFrac->Value) | (commonData->usBatVoltage256 & 0xFF00); // Fractional portion in low byte
  851. }
  852. else
  853. {
  854. this->numericUpDown_Bat_VoltInt->Enabled = FALSE;
  855. this->numericUpDown_Bat_VoltFrac->Enabled = FALSE;
  856. commonData->usBatVoltage256 = commonData->BATTERY_VOLTAGE_INVALID;
  857. }
  858. }
  859. /**************************************************************************
  860. * GeocacheSensor::numericUpDown_Bat_VoltInt_ValueChanged
  861. *
  862. * changes the coarse battery voltage
  863. *
  864. * returns: N/A
  865. *
  866. **************************************************************************/
  867. void GeocacheSensor::numericUpDown_Bat_VoltInt_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  868. {
  869. commonData->usBatVoltage256 = ((USHORT) System::Convert::ToByte(this->numericUpDown_Bat_VoltInt->Value)) << 8 | (commonData->usBatVoltage256 & 0xFF); // Integer portion in high byte
  870. }
  871. /**************************************************************************
  872. * GeocacheSensor::numericUpDown_Bat_VoltFrac_ValueChanged
  873. *
  874. * changes the fractional battery voltage
  875. *
  876. * returns: N/A
  877. *
  878. **************************************************************************/
  879. void GeocacheSensor::numericUpDown_Bat_VoltFrac_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  880. {
  881. commonData->usBatVoltage256 = System::Convert::ToByte(this->numericUpDown_Bat_VoltFrac->Value) | (commonData->usBatVoltage256 & 0xFF00); // Fractional portion in low byte
  882. }
  883. /**************************************************************************
  884. * GeocacheSensor::comboBoxBatStatus_SelectedIndexChanged
  885. *
  886. * changes the battery status
  887. *
  888. * returns: N/A
  889. *
  890. **************************************************************************/
  891. void GeocacheSensor::comboBoxBatStatus_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
  892. {
  893. UpdateBatStatus();
  894. }
  895. /**************************************************************************
  896. * GeocacheSensor::UpdateBatStatus
  897. *
  898. * Updates the battery status
  899. *
  900. * returns: N/A
  901. *
  902. **************************************************************************/
  903. void GeocacheSensor::UpdateBatStatus()
  904. {
  905. if (this->comboBoxBatStatus->Text->Equals("New"))
  906. {
  907. commonData->eBatStatus = CommonData::BatStatus::NEW;
  908. }
  909. else if (this->comboBoxBatStatus->Text->Equals("Good"))
  910. {
  911. commonData->eBatStatus = CommonData::BatStatus::GOOD;
  912. }
  913. else if (this->comboBoxBatStatus->Text->Equals("Ok"))
  914. {
  915. commonData->eBatStatus = CommonData::BatStatus::OK;
  916. }
  917. else if (this->comboBoxBatStatus->Text->Equals("Low"))
  918. {
  919. commonData->eBatStatus = CommonData::BatStatus::LOW;
  920. }
  921. else if (this->comboBoxBatStatus->Text->Equals("Critical"))
  922. {
  923. commonData->eBatStatus = CommonData::BatStatus::CRITICAL;
  924. }
  925. else if (this->comboBoxBatStatus->Text->Equals("Invalid"))
  926. {
  927. commonData->eBatStatus = CommonData::BatStatus::INVALID;
  928. }
  929. }
  930. /**************************************************************************
  931. * GeocacheSensor::button_Bat_ElpTimeUpdate_Click
  932. *
  933. * changes the elapsed battery time
  934. *
  935. * returns: N/A
  936. *
  937. **************************************************************************/
  938. void GeocacheSensor::button_Bat_ElpTimeUpdate_Click(System::Object^ sender, System::EventArgs^ e)
  939. {
  940. ulTotalTime = System::Convert::ToUInt32(this->textBox_Bat_ElpTimeChange->Text);
  941. commonData->ulOpTime = ulTotalTime / (UCHAR) commonData->eTimeResolution;
  942. }
  943. /**************************************************************************
  944. * GeocacheSensor::radioButton_Bat_Elp2Units_CheckedChanged
  945. *
  946. * changes the elapsed battery time units
  947. *
  948. * returns: N/A
  949. *
  950. **************************************************************************/
  951. void GeocacheSensor::radioButton_Bat_Elp2Units_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  952. {
  953. if (this->radioButton_Bat_Elp2Units->Checked)
  954. commonData->eTimeResolution = CommonData::TimeResolution::TWO;
  955. }
  956. /**************************************************************************
  957. * GeocacheSensor::radioButton_Bat_Elp2Units_CheckedChanged
  958. *
  959. * changes the elapsed battery time units
  960. *
  961. * returns: N/A
  962. *
  963. **************************************************************************/
  964. void GeocacheSensor::radioButton_Bat_Elp16Units_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  965. {
  966. if (this->radioButton_Bat_Elp16Units->Checked)
  967. commonData->eTimeResolution = CommonData::TimeResolution::SIXTEEN;
  968. }
  969. /**************************************************************************
  970. * GeocacheSensor::numericUpDownDay_ValueChanged
  971. *
  972. * Sets value of the day
  973. *
  974. * returns: N/A
  975. *
  976. **************************************************************************/
  977. void GeocacheSensor::numericUpDownDay_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  978. {
  979. commonData->ucDays = System::Convert::ToByte(this->numericUpDownDay->Value);
  980. }
  981. /**************************************************************************
  982. * GeocacheSensor::numericUpDownMonth_ValueChanged
  983. *
  984. * Sets value of the month
  985. *
  986. * returns: N/A
  987. *
  988. **************************************************************************/
  989. void GeocacheSensor::numericUpDownMonth_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  990. {
  991. commonData->ucMonth = System::Convert::ToByte(this->numericUpDownMonth->Value);
  992. }
  993. /**************************************************************************
  994. * GeocacheSensor::numericUpDownYear_ValueChanged
  995. *
  996. * Sets value of the year
  997. *
  998. * returns: N/A
  999. *
  1000. **************************************************************************/
  1001. void GeocacheSensor::numericUpDownYear_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  1002. {
  1003. commonData->ucYears = System::Convert::ToByte(this->numericUpDownYear->Value);
  1004. }
  1005. /**************************************************************************
  1006. * GeocacheSensor::numericUpDownHours_ValueChanged
  1007. *
  1008. * Sets value of the hours
  1009. *
  1010. * returns: N/A
  1011. *
  1012. **************************************************************************/
  1013. void GeocacheSensor::numericUpDownHours_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  1014. {
  1015. commonData->ucHours = System::Convert::ToByte(this->numericUpDownHours->Value);
  1016. }
  1017. /**************************************************************************
  1018. * GeocacheSensor::numericUpDownMinutes_ValueChanged
  1019. *
  1020. * Sets value of the minutes
  1021. *
  1022. * returns: N/A
  1023. *
  1024. **************************************************************************/
  1025. void GeocacheSensor::numericUpDownMinutes_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  1026. {
  1027. commonData->ucMinutes = System::Convert::ToByte(this->numericUpDownMinutes->Value);
  1028. }
  1029. /**************************************************************************
  1030. * GeocacheSensor::numericUpDownSeconds_ValueChanged
  1031. *
  1032. * Sets value of the minutes
  1033. *
  1034. * returns: N/A
  1035. *
  1036. **************************************************************************/
  1037. void GeocacheSensor::numericUpDownSeconds_ValueChanged(System::Object^ sender, System::EventArgs^ e)
  1038. {
  1039. commonData->ucSeconds = System::Convert::ToByte(this->numericUpDownSeconds->Value);
  1040. }
  1041. /**************************************************************************
  1042. * GeocacheSensor::checkBox_NoSerial_CheckedChanged
  1043. *
  1044. * Handles checkBox CheckedChanged event
  1045. *
  1046. * returns: N/A
  1047. *
  1048. **************************************************************************/
  1049. void GeocacheSensor::checkBox_NoSerial_CheckedChanged(System::Object ^sender, System::EventArgs ^e)
  1050. {
  1051. if(this->checkBox_NoSerial->Checked)
  1052. this->textBox_Glb_SerialNumChange->Enabled = false;
  1053. else
  1054. this->textBox_Glb_SerialNumChange->Enabled = true;
  1055. }