CustomDisplay.h 14 KB

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