CustomSensor.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 "ISimBase.h"
  11. #include "custom.h"
  12. #include "types.h"
  13. #include "antdefines.h"
  14. using namespace System;
  15. using namespace System::ComponentModel;
  16. using namespace System::Collections;
  17. using namespace System::Windows::Forms;
  18. using namespace System::Data;
  19. using namespace System::Drawing;
  20. public ref class CustomSensor : public System::Windows::Forms::Form, public ISimBase{
  21. public:
  22. CustomSensor(System::Timers::Timer^ channelTimer, dRequestAckMsg^ channelAckMsg){
  23. InitializeComponent();
  24. arrayUserData = gcnew array<UCHAR>(8);
  25. InitializeSim();
  26. requestAckMsg = channelAckMsg;
  27. }
  28. ~CustomSensor(){
  29. this->panel_Display->Controls->Clear();
  30. this->panel_Settings->Controls->Clear();
  31. delete this->panel_Display;
  32. delete this->panel_Settings;
  33. //clean up floating resources with the garbage collector
  34. GC::Collect(2);
  35. if (components)
  36. {
  37. delete components;
  38. }
  39. }
  40. public:
  41. virtual void ANT_eventNotification(UCHAR ucEventCode_, UCHAR* pucEventBuffer_);
  42. virtual UCHAR getDeviceType(){return CUSTOM_DEVICE_TYPE;}
  43. virtual UCHAR getTransmissionType(){return CUSTOM_TX_TYPE;}
  44. virtual USHORT getTransmitPeriod(){return CUSTOM_MSG_PERIOD;}
  45. virtual DOUBLE getTimerInterval(){return 1000;} // One second
  46. virtual void onTimerTock(USHORT eventTime);
  47. virtual System::Windows::Forms::Panel^ getSimSettingsPanel(){return this->panel_Settings;}
  48. virtual System::Windows::Forms::Panel^ getSimTranslatedDisplay(){return this->panel_Display;}
  49. private:
  50. void InitializeSim();
  51. void HandleTransmit(UCHAR* pucTxBuffer_);
  52. void ValidateInput();
  53. System::Void button_UpdateData_Click(System::Object^ sender, System::EventArgs^ e);
  54. System::Void radioButton_TranslateSelect_CheckedChanged(System::Object^ sender, System::EventArgs^ e);
  55. System::Void button_SendAck_Click(System::Object^ sender, System::EventArgs^ e);
  56. private:
  57. dRequestAckMsg^ requestAckMsg; // Handle to delegate function handling transmission of acknowledged messages
  58. ULONG ulEventCounter; // Number of events
  59. BOOL bSendHex; // Text box interpreted as Hex or characters
  60. array<UCHAR,1>^ arrayUserData; // Array to hold user data for transmission
  61. private: System::Windows::Forms::Panel^ panel_Settings;
  62. private: System::Windows::Forms::TextBox^ textBox_customTxData;
  63. private: System::Windows::Forms::Label^ label_customTxData;
  64. private: System::Windows::Forms::RadioButton^ radioButton_asChar;
  65. private: System::Windows::Forms::RadioButton^ radioButton_asHex;
  66. private: System::Windows::Forms::Label^ label_inputFormat;
  67. private: System::Windows::Forms::Label^ label_TxEventCount;
  68. private: System::Windows::Forms::Label^ label_TxData;
  69. private: System::Windows::Forms::Label^ label_DataTxd;
  70. private: System::Windows::Forms::Label^ label_EventCount;
  71. private: System::Windows::Forms::Panel^ panel_Display;
  72. private: System::Windows::Forms::Label^ label_InputError;
  73. private: System::Windows::Forms::Button^ button_SendAck;
  74. private: System::Windows::Forms::Label^ label_Trans_Title;
  75. private: System::Windows::Forms::Button^ button_UpdateData;
  76. private:
  77. /// <summary>
  78. /// Required designer variable.
  79. /// </summary>
  80. System::ComponentModel::Container ^components;
  81. #pragma region Windows Form Designer generated code
  82. /// <summary>
  83. /// Required method for Designer support - do not modify
  84. /// the contents of this method with the code editor.
  85. /// </summary>
  86. void InitializeComponent(void)
  87. {
  88. this->panel_Settings = (gcnew System::Windows::Forms::Panel());
  89. this->button_SendAck = (gcnew System::Windows::Forms::Button());
  90. this->label_InputError = (gcnew System::Windows::Forms::Label());
  91. this->label_inputFormat = (gcnew System::Windows::Forms::Label());
  92. this->radioButton_asChar = (gcnew System::Windows::Forms::RadioButton());
  93. this->radioButton_asHex = (gcnew System::Windows::Forms::RadioButton());
  94. this->textBox_customTxData = (gcnew System::Windows::Forms::TextBox());
  95. this->label_customTxData = (gcnew System::Windows::Forms::Label());
  96. this->panel_Display = (gcnew System::Windows::Forms::Panel());
  97. this->label_Trans_Title = (gcnew System::Windows::Forms::Label());
  98. this->label_DataTxd = (gcnew System::Windows::Forms::Label());
  99. this->label_EventCount = (gcnew System::Windows::Forms::Label());
  100. this->label_TxData = (gcnew System::Windows::Forms::Label());
  101. this->label_TxEventCount = (gcnew System::Windows::Forms::Label());
  102. this->button_UpdateData = (gcnew System::Windows::Forms::Button());
  103. this->panel_Settings->SuspendLayout();
  104. this->panel_Display->SuspendLayout();
  105. this->SuspendLayout();
  106. //
  107. // panel_Settings
  108. //
  109. this->panel_Settings->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
  110. this->panel_Settings->Controls->Add(this->button_UpdateData);
  111. this->panel_Settings->Controls->Add(this->button_SendAck);
  112. this->panel_Settings->Controls->Add(this->label_InputError);
  113. this->panel_Settings->Controls->Add(this->label_inputFormat);
  114. this->panel_Settings->Controls->Add(this->radioButton_asChar);
  115. this->panel_Settings->Controls->Add(this->radioButton_asHex);
  116. this->panel_Settings->Controls->Add(this->textBox_customTxData);
  117. this->panel_Settings->Controls->Add(this->label_customTxData);
  118. this->panel_Settings->Location = System::Drawing::Point(322, 50);
  119. this->panel_Settings->Name = L"panel_Settings";
  120. this->panel_Settings->Size = System::Drawing::Size(400, 140);
  121. this->panel_Settings->TabIndex = 0;
  122. //
  123. // button_SendAck
  124. //
  125. this->button_SendAck->Location = System::Drawing::Point(14, 98);
  126. this->button_SendAck->Name = L"button_SendAck";
  127. this->button_SendAck->Size = System::Drawing::Size(120, 23);
  128. this->button_SendAck->TabIndex = 14;
  129. this->button_SendAck->Text = L"Send Acknowledged";
  130. this->button_SendAck->UseVisualStyleBackColor = true;
  131. this->button_SendAck->Click += gcnew System::EventHandler(this, &CustomSensor::button_SendAck_Click);
  132. //
  133. // label_InputError
  134. //
  135. this->label_InputError->AutoSize = true;
  136. this->label_InputError->Location = System::Drawing::Point(47, 82);
  137. this->label_InputError->Name = L"label_InputError";
  138. this->label_InputError->Size = System::Drawing::Size(0, 13);
  139. this->label_InputError->TabIndex = 13;
  140. //
  141. // label_inputFormat
  142. //
  143. this->label_inputFormat->AutoSize = true;
  144. this->label_inputFormat->Location = System::Drawing::Point(160, 39);
  145. this->label_inputFormat->Name = L"label_inputFormat";
  146. this->label_inputFormat->Size = System::Drawing::Size(90, 13);
  147. this->label_inputFormat->TabIndex = 12;
  148. this->label_inputFormat->Text = L"Interpret Data As:";
  149. //
  150. // radioButton_asChar
  151. //
  152. this->radioButton_asChar->AutoSize = true;
  153. this->radioButton_asChar->Checked = true;
  154. this->radioButton_asChar->Location = System::Drawing::Point(261, 37);
  155. this->radioButton_asChar->Name = L"radioButton_asChar";
  156. this->radioButton_asChar->Size = System::Drawing::Size(101, 17);
  157. this->radioButton_asChar->TabIndex = 12;
  158. this->radioButton_asChar->TabStop = true;
  159. this->radioButton_asChar->Text = L"Character String";
  160. this->radioButton_asChar->UseVisualStyleBackColor = true;
  161. this->radioButton_asChar->CheckedChanged += gcnew System::EventHandler(this, &CustomSensor::radioButton_TranslateSelect_CheckedChanged);
  162. //
  163. // radioButton_asHex
  164. //
  165. this->radioButton_asHex->AutoSize = true;
  166. this->radioButton_asHex->Location = System::Drawing::Point(261, 60);
  167. this->radioButton_asHex->Name = L"radioButton_asHex";
  168. this->radioButton_asHex->Size = System::Drawing::Size(130, 30);
  169. this->radioButton_asHex->TabIndex = 13;
  170. this->radioButton_asHex->Text = L"Hex Couplets\nSeparated by commas";
  171. this->radioButton_asHex->UseVisualStyleBackColor = true;
  172. //
  173. // textBox_customTxData
  174. //
  175. this->textBox_customTxData->Location = System::Drawing::Point(10, 36);
  176. this->textBox_customTxData->MaxLength = 8;
  177. this->textBox_customTxData->Name = L"textBox_customTxData";
  178. this->textBox_customTxData->Size = System::Drawing::Size(130, 20);
  179. this->textBox_customTxData->TabIndex = 10;
  180. this->textBox_customTxData->Text = L"hi/68,69";
  181. //
  182. // label_customTxData
  183. //
  184. this->label_customTxData->AutoSize = true;
  185. this->label_customTxData->Location = System::Drawing::Point(7, 20);
  186. this->label_customTxData->Name = L"label_customTxData";
  187. this->label_customTxData->Size = System::Drawing::Size(88, 13);
  188. this->label_customTxData->TabIndex = 1;
  189. this->label_customTxData->Text = L"Data to Transmit:";
  190. //
  191. // panel_Display
  192. //
  193. this->panel_Display->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
  194. this->panel_Display->Controls->Add(this->label_Trans_Title);
  195. this->panel_Display->Controls->Add(this->label_DataTxd);
  196. this->panel_Display->Controls->Add(this->label_EventCount);
  197. this->panel_Display->Controls->Add(this->label_TxData);
  198. this->panel_Display->Controls->Add(this->label_TxEventCount);
  199. this->panel_Display->Location = System::Drawing::Point(58, 188);
  200. this->panel_Display->Name = L"panel_Display";
  201. this->panel_Display->Size = System::Drawing::Size(200, 90);
  202. this->panel_Display->TabIndex = 1;
  203. //
  204. // label_Trans_Title
  205. //
  206. this->label_Trans_Title->AutoSize = true;
  207. this->label_Trans_Title->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Underline,
  208. System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0)));
  209. this->label_Trans_Title->Location = System::Drawing::Point(2, 2);
  210. this->label_Trans_Title->Name = L"label_Trans_Title";
  211. this->label_Trans_Title->Size = System::Drawing::Size(92, 13);
  212. this->label_Trans_Title->TabIndex = 4;
  213. this->label_Trans_Title->Text = L"Transmission Info:";
  214. //
  215. // label_DataTxd
  216. //
  217. this->label_DataTxd->AutoSize = true;
  218. this->label_DataTxd->Location = System::Drawing::Point(130, 50);
  219. this->label_DataTxd->Name = L"label_DataTxd";
  220. this->label_DataTxd->Size = System::Drawing::Size(16, 13);
  221. this->label_DataTxd->TabIndex = 3;
  222. this->label_DataTxd->Text = L"---";
  223. this->label_DataTxd->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
  224. //
  225. // label_EventCount
  226. //
  227. this->label_EventCount->AutoSize = true;
  228. this->label_EventCount->Location = System::Drawing::Point(130, 27);
  229. this->label_EventCount->Name = L"label_EventCount";
  230. this->label_EventCount->Size = System::Drawing::Size(16, 13);
  231. this->label_EventCount->TabIndex = 2;
  232. this->label_EventCount->Text = L"---";
  233. this->label_EventCount->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
  234. //
  235. // label_TxData
  236. //
  237. this->label_TxData->AutoSize = true;
  238. this->label_TxData->Location = System::Drawing::Point(57, 50);
  239. this->label_TxData->Name = L"label_TxData";
  240. this->label_TxData->Size = System::Drawing::Size(67, 13);
  241. this->label_TxData->TabIndex = 1;
  242. this->label_TxData->Text = L"Transmitting:";
  243. this->label_TxData->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
  244. //
  245. // label_TxEventCount
  246. //
  247. this->label_TxEventCount->AutoSize = true;
  248. this->label_TxEventCount->Location = System::Drawing::Point(12, 27);
  249. this->label_TxEventCount->Name = L"label_TxEventCount";
  250. this->label_TxEventCount->Size = System::Drawing::Size(112, 13);
  251. this->label_TxEventCount->TabIndex = 0;
  252. this->label_TxEventCount->Text = L"Transmit Event Count:";
  253. this->label_TxEventCount->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
  254. //
  255. // button_UpdateData
  256. //
  257. this->button_UpdateData->Location = System::Drawing::Point(14, 64);
  258. this->button_UpdateData->Name = L"button_UpdateData";
  259. this->button_UpdateData->Size = System::Drawing::Size(120, 23);
  260. this->button_UpdateData->TabIndex = 15;
  261. this->button_UpdateData->Text = L"Update Data";
  262. this->button_UpdateData->UseVisualStyleBackColor = true;
  263. this->button_UpdateData->Click += gcnew System::EventHandler(this, &CustomSensor::button_UpdateData_Click);
  264. //
  265. // CustomSensor
  266. //
  267. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  268. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  269. this->ClientSize = System::Drawing::Size(786, 317);
  270. this->Controls->Add(this->panel_Display);
  271. this->Controls->Add(this->panel_Settings);
  272. this->Name = L"CustomSensor";
  273. this->Text = L"CustomSensor";
  274. this->panel_Settings->ResumeLayout(false);
  275. this->panel_Settings->PerformLayout();
  276. this->panel_Display->ResumeLayout(false);
  277. this->panel_Display->PerformLayout();
  278. this->ResumeLayout(false);
  279. }
  280. #pragma endregion
  281. };