Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #undef UNICODE
- #define WIN32_LEAN_AND_MEAN
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <fstream>
- #include <math.h>
- #include <winsock2.h>
- #include <ws2tcpip.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <iostream>
- using namespace System;
- using namespace System::IO::Ports;
- using namespace System::Threading;
- #pragma comment (lib, "Ws2_32.lib")
- #pragma once
- #define DEFAULT_BUFLEN 32
- #define DEFAULT_PORT "27015"
- namespace SWIMIRGUI {
- using namespace System;
- using namespace System::ComponentModel;
- using namespace System::Collections;
- using namespace System::Windows::Forms;
- using namespace System::Data;
- using namespace System::Drawing;
- static char publicDataToReceive[32];
- static char publicDataToSend[32];
- static char sendToLogCA[32];
- static int threadReadyToSend;
- static int threadReadyToReceive;
- static int threadDone;
- public ref class ThreadExample
- {
- public:
- static void ThreadProc()
- {
- WSADATA wsaData;
- int iResult;
- SOCKET ListenSocket = INVALID_SOCKET;
- SOCKET ClientSocket = INVALID_SOCKET;
- struct addrinfo *result = NULL;
- struct addrinfo hints;
- int iSendResult;
- char recvbuf[DEFAULT_BUFLEN];
- int recvbuflen = DEFAULT_BUFLEN;
- // Initialize Winsock
- iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
- if (iResult != 0) {
- }
- ZeroMemory(&hints, sizeof(hints));
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- hints.ai_flags = AI_PASSIVE;
- // Resolve the server address and port
- iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
- if ( iResult != 0 ) {
- WSACleanup();
- }
- // Create a SOCKET for connecting to server
- ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
- if (ListenSocket == INVALID_SOCKET) {
- freeaddrinfo(result);
- WSACleanup();
- }
- // Setup the TCP listening socket
- iResult = bind( ListenSocket, result->ai_addr, (int)result->ai_addrlen);
- if (iResult == SOCKET_ERROR) {
- freeaddrinfo(result);
- closesocket(ListenSocket);
- WSACleanup();
- }
- freeaddrinfo(result);
- iResult = listen(ListenSocket, SOMAXCONN);
- if (iResult == SOCKET_ERROR) {
- closesocket(ListenSocket);
- WSACleanup();
- }
- // Accept a client socket
- ClientSocket = accept(ListenSocket, NULL, NULL);
- if (ClientSocket == INVALID_SOCKET) {
- closesocket(ListenSocket);
- WSACleanup();
- }
- // No longer need server socket
- closesocket(ListenSocket);
- // Receive until the peer shuts down the connection
- do {
- //iResult = recv(ClientSocket, recvbuf, recvbuflen, 0);
- //if (iResult > 0) {
- // printf(">>%s\n",recvbuf);
- // for(int k=0; k<32; k++){
- // publicDataToReceive[k] = E;
- // }
- // for(int k=0; k<32; k++){
- // publicDataToReceive[k] = recvbuf[k];
- // }
- //}
- Sleep(1000);
- strcpy_s(publicDataToSend,"samplemessage");//Probably delete when I have actual data going into publicDataToSend
- strcpy_s(sendToLogCA, publicDataToSend);
- iSendResult = send( ClientSocket, publicDataToSend, (int)strlen(publicDataToSend), 0 );
- if (iSendResult == SOCKET_ERROR) {
- closesocket(ClientSocket);
- WSACleanup();
- }
- } while(1);
- // shutdown the connection since we're done
- iResult = shutdown(ClientSocket, SD_SEND);
- if (iResult == SOCKET_ERROR) {
- closesocket(ClientSocket);
- WSACleanup();
- }
- // cleanup
- closesocket(ClientSocket);
- WSACleanup();
- // Yield the rest of the time slice.
- Thread::Sleep( 0 );
- }
- };
- /// <summary>
- /// Summary for Form1
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- SerialPort^ comPort;
- Form1(void)
- {
- InitializeComponent();
- //
- //TODO: Add the constructor code here
- //
- }
- protected:
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::TextBox^ receivedLog;
- private: System::Windows::Forms::TextBox^ sentLog;
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::TextBox^ lastCommand;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::TextBox^ textBox3;
- private: System::Windows::Forms::TextBox^ textBox4;
- private: System::Windows::Forms::Label^ label5;
- private: System::Windows::Forms::Label^ label6;
- private: System::Windows::Forms::Label^ label7;
- private: System::Windows::Forms::Label^ label9;
- private: System::Windows::Forms::TrackBar^ trackBar1;
- private: System::Windows::Forms::TrackBar^ trackBar2;
- private: System::Windows::Forms::TrackBar^ trackBar3;
- private: System::Windows::Forms::TrackBar^ trackBar4;
- private: System::Windows::Forms::TextBox^ textBox5;
- private: System::Windows::Forms::Label^ label8;
- private: System::Windows::Forms::GroupBox^ groupBox1;
- private: System::Windows::Forms::Label^ label4;
- private: System::Windows::Forms::TextBox^ lastReceived;
- private: System::Windows::Forms::Button^ lightToggle;
- private: System::Windows::Forms::Label^ label19;
- private: System::Windows::Forms::Label^ label18;
- private: System::Windows::Forms::Label^ label17;
- private: System::Windows::Forms::Label^ label14;
- private: System::Windows::Forms::Label^ label15;
- private: System::Windows::Forms::Label^ label16;
- private: System::Windows::Forms::Label^ label13;
- private: System::Windows::Forms::Label^ label12;
- private: System::Windows::Forms::Label^ label11;
- private: System::Windows::Forms::Label^ label20;
- private: System::Windows::Forms::Label^ label21;
- private: System::Windows::Forms::Label^ label22;
- private: System::Windows::Forms::GroupBox^ groupBox3;
- private: System::Windows::Forms::GroupBox^ groupBox2;
- private: System::Windows::Forms::GroupBox^ groupBox6;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::GroupBox^ groupBox4;
- private: System::Windows::Forms::Label^ label30;
- private: System::Windows::Forms::Label^ label29;
- private: System::Windows::Forms::Label^ label28;
- private: System::Windows::Forms::Label^ label27;
- private: System::Windows::Forms::Label^ label26;
- private: System::Windows::Forms::Label^ label25;
- private: System::Windows::Forms::Label^ label24;
- private: System::Windows::Forms::Label^ label23;
- private: System::Windows::Forms::MenuStrip^ menuStrip1;
- private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ exitToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ editToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ resetToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ viewToolStripMenuItem;
- private: System::Windows::Forms::ToolStripMenuItem^ onlineHelpToolStripMenuItem;
- private: System::Windows::Forms::TrackBar^ trackBar5;
- private: System::Windows::Forms::GroupBox^ groupBox5;
- private: System::Windows::Forms::Label^ label34;
- private: System::Windows::Forms::Label^ label33;
- private: System::Windows::Forms::Label^ label32;
- private: System::Windows::Forms::Label^ label31;
- private: System::Windows::Forms::TabControl^ tabControl1;
- private: System::Windows::Forms::TabPage^ tabPage1;
- private: System::Windows::Forms::TabPage^ tabPage2;
- private: System::Windows::Forms::Button^ getSensor;
- private: System::Windows::Forms::Button^ getBattery;
- private: System::Windows::Forms::Button^ surface;
- private: System::Windows::Forms::GroupBox^ groupBox7;
- private: System::Windows::Forms::Button^ sServoPlus;
- private: System::Windows::Forms::Label^ label35;
- private: System::Windows::Forms::Button^ bServoPlus;
- private: System::Windows::Forms::Label^ label10;
- private: System::Windows::Forms::Button^ bServoMinus;
- private: System::Windows::Forms::Button^ sServoMinus;
- private: System::Windows::Forms::Button^ hardwareOff;
- private: System::Windows::Forms::RadioButton^ radioButton1;
- private: System::Windows::Forms::TextBox^ textBox7;
- private: System::Windows::Forms::TextBox^ textBox6;
- protected:
- private:
- /// <summary>
- /// Required designer variable.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- void InitializeComponent(void)
- {
- this->receivedLog = (gcnew System::Windows::Forms::TextBox());
- this->sentLog = (gcnew System::Windows::Forms::TextBox());
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->lastCommand = (gcnew System::Windows::Forms::TextBox());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->label3 = (gcnew System::Windows::Forms::Label());
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->textBox2 = (gcnew System::Windows::Forms::TextBox());
- this->textBox3 = (gcnew System::Windows::Forms::TextBox());
- this->textBox4 = (gcnew System::Windows::Forms::TextBox());
- this->label5 = (gcnew System::Windows::Forms::Label());
- this->label6 = (gcnew System::Windows::Forms::Label());
- this->label7 = (gcnew System::Windows::Forms::Label());
- this->label9 = (gcnew System::Windows::Forms::Label());
- this->trackBar1 = (gcnew System::Windows::Forms::TrackBar());
- this->trackBar2 = (gcnew System::Windows::Forms::TrackBar());
- this->trackBar3 = (gcnew System::Windows::Forms::TrackBar());
- this->trackBar4 = (gcnew System::Windows::Forms::TrackBar());
- this->textBox5 = (gcnew System::Windows::Forms::TextBox());
- this->label8 = (gcnew System::Windows::Forms::Label());
- this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
- this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
- this->label19 = (gcnew System::Windows::Forms::Label());
- this->label18 = (gcnew System::Windows::Forms::Label());
- this->label17 = (gcnew System::Windows::Forms::Label());
- this->label13 = (gcnew System::Windows::Forms::Label());
- this->label12 = (gcnew System::Windows::Forms::Label());
- this->label11 = (gcnew System::Windows::Forms::Label());
- this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
- this->label21 = (gcnew System::Windows::Forms::Label());
- this->label20 = (gcnew System::Windows::Forms::Label());
- this->label22 = (gcnew System::Windows::Forms::Label());
- this->label14 = (gcnew System::Windows::Forms::Label());
- this->label15 = (gcnew System::Windows::Forms::Label());
- this->label16 = (gcnew System::Windows::Forms::Label());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->lastReceived = (gcnew System::Windows::Forms::TextBox());
- this->lightToggle = (gcnew System::Windows::Forms::Button());
- this->groupBox6 = (gcnew System::Windows::Forms::GroupBox());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->groupBox4 = (gcnew System::Windows::Forms::GroupBox());
- this->label30 = (gcnew System::Windows::Forms::Label());
- this->label29 = (gcnew System::Windows::Forms::Label());
- this->label28 = (gcnew System::Windows::Forms::Label());
- this->label27 = (gcnew System::Windows::Forms::Label());
- this->label26 = (gcnew System::Windows::Forms::Label());
- this->label25 = (gcnew System::Windows::Forms::Label());
- this->label24 = (gcnew System::Windows::Forms::Label());
- this->label23 = (gcnew System::Windows::Forms::Label());
- this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
- this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->editToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->resetToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->viewToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->onlineHelpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->trackBar5 = (gcnew System::Windows::Forms::TrackBar());
- this->groupBox5 = (gcnew System::Windows::Forms::GroupBox());
- this->label34 = (gcnew System::Windows::Forms::Label());
- this->label33 = (gcnew System::Windows::Forms::Label());
- this->label32 = (gcnew System::Windows::Forms::Label());
- this->label31 = (gcnew System::Windows::Forms::Label());
- this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
- this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
- this->radioButton1 = (gcnew System::Windows::Forms::RadioButton());
- this->hardwareOff = (gcnew System::Windows::Forms::Button());
- this->surface = (gcnew System::Windows::Forms::Button());
- this->getSensor = (gcnew System::Windows::Forms::Button());
- this->getBattery = (gcnew System::Windows::Forms::Button());
- this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
- this->groupBox7 = (gcnew System::Windows::Forms::GroupBox());
- this->sServoPlus = (gcnew System::Windows::Forms::Button());
- this->label35 = (gcnew System::Windows::Forms::Label());
- this->bServoPlus = (gcnew System::Windows::Forms::Button());
- this->label10 = (gcnew System::Windows::Forms::Label());
- this->bServoMinus = (gcnew System::Windows::Forms::Button());
- this->sServoMinus = (gcnew System::Windows::Forms::Button());
- this->textBox6 = (gcnew System::Windows::Forms::TextBox());
- this->textBox7 = (gcnew System::Windows::Forms::TextBox());
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar1))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar2))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar3))->BeginInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar4))->BeginInit();
- this->groupBox1->SuspendLayout();
- this->groupBox3->SuspendLayout();
- this->groupBox2->SuspendLayout();
- this->groupBox6->SuspendLayout();
- this->groupBox4->SuspendLayout();
- this->menuStrip1->SuspendLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar5))->BeginInit();
- this->groupBox5->SuspendLayout();
- this->tabControl1->SuspendLayout();
- this->tabPage1->SuspendLayout();
- this->tabPage2->SuspendLayout();
- this->groupBox7->SuspendLayout();
- this->SuspendLayout();
- //
- // receivedLog
- //
- this->receivedLog->Location = System::Drawing::Point(307, 113);
- this->receivedLog->Multiline = true;
- this->receivedLog->Name = L"receivedLog";
- this->receivedLog->ReadOnly = true;
- this->receivedLog->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
- this->receivedLog->Size = System::Drawing::Size(271, 144);
- this->receivedLog->TabIndex = 1;
- //
- // sentLog
- //
- this->sentLog->Location = System::Drawing::Point(18, 111);
- this->sentLog->Multiline = true;
- this->sentLog->Name = L"sentLog";
- this->sentLog->ReadOnly = true;
- this->sentLog->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
- this->sentLog->Size = System::Drawing::Size(268, 144);
- this->sentLog->TabIndex = 3;
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(15, 95);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(100, 13);
- this->label1->TabIndex = 4;
- this->label1->Text = L"Sent Command Log";
- //
- // lastCommand
- //
- this->lastCommand->Location = System::Drawing::Point(136, 43);
- this->lastCommand->Name = L"lastCommand";
- this->lastCommand->ReadOnly = true;
- this->lastCommand->Size = System::Drawing::Size(352, 20);
- this->lastCommand->TabIndex = 5;
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(31, 46);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(102, 13);
- this->label2->TabIndex = 6;
- this->label2->Text = L"Last Command Sent";
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(304, 97);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(105, 13);
- this->label3->TabIndex = 7;
- this->label3->Text = L"Micro Feedback Log";
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(69, 218);
- this->textBox1->Name = L"textBox1";
- this->textBox1->ReadOnly = true;
- this->textBox1->Size = System::Drawing::Size(41, 20);
- this->textBox1->TabIndex = 8;
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(25, 60);
- this->textBox2->Name = L"textBox2";
- this->textBox2->ReadOnly = true;
- this->textBox2->Size = System::Drawing::Size(41, 20);
- this->textBox2->TabIndex = 9;
- //
- // textBox3
- //
- this->textBox3->Location = System::Drawing::Point(73, 215);
- this->textBox3->Name = L"textBox3";
- this->textBox3->ReadOnly = true;
- this->textBox3->Size = System::Drawing::Size(41, 20);
- this->textBox3->TabIndex = 10;
- //
- // textBox4
- //
- this->textBox4->Location = System::Drawing::Point(28, 58);
- this->textBox4->Name = L"textBox4";
- this->textBox4->ReadOnly = true;
- this->textBox4->Size = System::Drawing::Size(41, 20);
- this->textBox4->TabIndex = 11;
- //
- // label5
- //
- this->label5->AutoSize = true;
- this->label5->Location = System::Drawing::Point(5, 63);
- this->label5->Name = L"label5";
- this->label5->Size = System::Drawing::Size(14, 13);
- this->label5->TabIndex = 14;
- this->label5->Text = L"Y";
- //
- // label6
- //
- this->label6->AutoSize = true;
- this->label6->Location = System::Drawing::Point(53, 219);
- this->label6->Name = L"label6";
- this->label6->Size = System::Drawing::Size(14, 13);
- this->label6->TabIndex = 15;
- this->label6->Text = L"Z";
- //
- // label7
- //
- this->label7->AutoSize = true;
- this->label7->Location = System::Drawing::Point(7, 59);
- this->label7->Name = L"label7";
- this->label7->Size = System::Drawing::Size(15, 13);
- this->label7->TabIndex = 16;
- this->label7->Text = L"R";
- //
- // label9
- //
- this->label9->AutoSize = true;
- this->label9->Location = System::Drawing::Point(49, 220);
- this->label9->Name = L"label9";
- this->label9->Size = System::Drawing::Size(14, 13);
- this->label9->TabIndex = 18;
- this->label9->Text = L"X";
- //
- // trackBar1
- //
- this->trackBar1->Location = System::Drawing::Point(8, 163);
- this->trackBar1->Maximum = 100;
- this->trackBar1->Name = L"trackBar1";
- this->trackBar1->Size = System::Drawing::Size(143, 45);
- this->trackBar1->TabIndex = 20;
- this->trackBar1->TickFrequency = 50;
- //
- // trackBar2
- //
- this->trackBar2->Location = System::Drawing::Point(72, 14);
- this->trackBar2->Maximum = 100;
- this->trackBar2->Name = L"trackBar2";
- this->trackBar2->Orientation = System::Windows::Forms::Orientation::Vertical;
- this->trackBar2->Size = System::Drawing::Size(45, 143);
- this->trackBar2->TabIndex = 21;
- this->trackBar2->TickFrequency = 50;
- //
- // trackBar3
- //
- this->trackBar3->Location = System::Drawing::Point(10, 161);
- this->trackBar3->Maximum = 100;
- this->trackBar3->Name = L"trackBar3";
- this->trackBar3->Size = System::Drawing::Size(143, 45);
- this->trackBar3->TabIndex = 22;
- this->trackBar3->TickFrequency = 50;
- //
- // trackBar4
- //
- this->trackBar4->Location = System::Drawing::Point(73, 13);
- this->trackBar4->Maximum = 100;
- this->trackBar4->Name = L"trackBar4";
- this->trackBar4->Orientation = System::Windows::Forms::Orientation::Vertical;
- this->trackBar4->Size = System::Drawing::Size(45, 143);
- this->trackBar4->TabIndex = 23;
- this->trackBar4->TickFrequency = 50;
- //
- // textBox5
- //
- this->textBox5->Location = System::Drawing::Point(9, 305);
- this->textBox5->Name = L"textBox5";
- this->textBox5->ReadOnly = true;
- this->textBox5->Size = System::Drawing::Size(76, 20);
- this->textBox5->TabIndex = 12;
- this->textBox5->TextChanged += gcnew System::EventHandler(this, &Form1::textBox5_TextChanged);
- //
- // label8
- //
- this->label8->AutoSize = true;
- this->label8->Location = System::Drawing::Point(6, 289);
- this->label8->Name = L"label8";
- this->label8->Size = System::Drawing::Size(79, 13);
- this->label8->TabIndex = 17;
- this->label8->Text = L"Button Pressed";
- //
- // groupBox1
- //
- this->groupBox1->Controls->Add(this->groupBox3);
- this->groupBox1->Controls->Add(this->groupBox2);
- this->groupBox1->Controls->Add(this->label8);
- this->groupBox1->Controls->Add(this->textBox5);
- this->groupBox1->Location = System::Drawing::Point(605, 14);
- this->groupBox1->Name = L"groupBox1";
- this->groupBox1->Size = System::Drawing::Size(373, 334);
- this->groupBox1->TabIndex = 24;
- this->groupBox1->TabStop = false;
- this->groupBox1->Text = L"Controls";
- //
- // groupBox3
- //
- this->groupBox3->Controls->Add(this->label19);
- this->groupBox3->Controls->Add(this->label18);
- this->groupBox3->Controls->Add(this->label17);
- this->groupBox3->Controls->Add(this->label13);
- this->groupBox3->Controls->Add(this->label12);
- this->groupBox3->Controls->Add(this->label11);
- this->groupBox3->Controls->Add(this->label9);
- this->groupBox3->Controls->Add(this->label5);
- this->groupBox3->Controls->Add(this->trackBar2);
- this->groupBox3->Controls->Add(this->textBox2);
- this->groupBox3->Controls->Add(this->trackBar1);
- this->groupBox3->Controls->Add(this->textBox1);
- this->groupBox3->Location = System::Drawing::Point(9, 19);
- this->groupBox3->Name = L"groupBox3";
- this->groupBox3->Size = System::Drawing::Size(176, 255);
- this->groupBox3->TabIndex = 37;
- this->groupBox3->TabStop = false;
- this->groupBox3->Text = L"Analog1";
- //
- // label19
- //
- this->label19->AutoSize = true;
- this->label19->Location = System::Drawing::Point(118, 195);
- this->label19->Name = L"label19";
- this->label19->Size = System::Drawing::Size(32, 13);
- this->label19->TabIndex = 32;
- this->label19->Text = L"Tilt R";
- //
- // label18
- //
- this->label18->AutoSize = true;
- this->label18->Location = System::Drawing::Point(66, 195);
- this->label18->Name = L"label18";
- this->label18->Size = System::Drawing::Size(33, 13);
- this->label18->TabIndex = 31;
- this->label18->Text = L"Level";
- //
- // label17
- //
- this->label17->AutoSize = true;
- this->label17->Location = System::Drawing::Point(5, 195);
- this->label17->Name = L"label17";
- this->label17->Size = System::Drawing::Size(30, 13);
- this->label17->TabIndex = 30;
- this->label17->Text = L"Tilt L";
- //
- // label13
- //
- this->label13->AutoSize = true;
- this->label13->Location = System::Drawing::Point(108, 144);
- this->label13->Name = L"label13";
- this->label13->Size = System::Drawing::Size(31, 13);
- this->label13->TabIndex = 26;
- this->label13->Text = L"Tilt B";
- //
- // label12
- //
- this->label12->AutoSize = true;
- this->label12->Location = System::Drawing::Point(108, 81);
- this->label12->Name = L"label12";
- this->label12->Size = System::Drawing::Size(33, 13);
- this->label12->TabIndex = 25;
- this->label12->Text = L"Level";
- //
- // label11
- //
- this->label11->AutoSize = true;
- this->label11->Location = System::Drawing::Point(108, 14);
- this->label11->Name = L"label11";
- this->label11->Size = System::Drawing::Size(30, 13);
- this->label11->TabIndex = 24;
- this->label11->Text = L"Tilt F";
- //
- // groupBox2
- //
- this->groupBox2->Controls->Add(this->label21);
- this->groupBox2->Controls->Add(this->label20);
- this->groupBox2->Controls->Add(this->label22);
- this->groupBox2->Controls->Add(this->label14);
- this->groupBox2->Controls->Add(this->label15);
- this->groupBox2->Controls->Add(this->label16);
- this->groupBox2->Controls->Add(this->label7);
- this->groupBox2->Controls->Add(this->textBox4);
- this->groupBox2->Controls->Add(this->label6);
- this->groupBox2->Controls->Add(this->trackBar3);
- this->groupBox2->Controls->Add(this->textBox3);
- this->groupBox2->Controls->Add(this->trackBar4);
- this->groupBox2->Location = System::Drawing::Point(191, 21);
- this->groupBox2->Name = L"groupBox2";
- this->groupBox2->Size = System::Drawing::Size(173, 255);
- this->groupBox2->TabIndex = 36;
- this->groupBox2->TabStop = false;
- this->groupBox2->Text = L"Analog2";
- //
- // label21
- //
- this->label21->Anchor = System::Windows::Forms::AnchorStyles::None;
- this->label21->AutoSize = true;
- this->label21->Location = System::Drawing::Point(70, 193);
- this->label21->Name = L"label21";
- this->label21->Size = System::Drawing::Size(43, 13);
- this->label21->TabIndex = 34;
- this->label21->Text = L"Straight";
- this->label21->TextAlign = System::Drawing::ContentAlignment::TopCenter;
- //
- // label20
- //
- this->label20->AutoSize = true;
- this->label20->Location = System::Drawing::Point(124, 193);
- this->label20->Name = L"label20";
- this->label20->Size = System::Drawing::Size(40, 13);
- this->label20->TabIndex = 35;
- this->label20->Text = L"Turn R";
- //
- // label22
- //
- this->label22->AutoSize = true;
- this->label22->Location = System::Drawing::Point(9, 193);
- this->label22->Name = L"label22";
- this->label22->Size = System::Drawing::Size(38, 13);
- this->label22->TabIndex = 33;
- this->label22->Text = L"Turn L";
- //
- // label14
- //
- this->label14->AutoSize = true;
- this->label14->Location = System::Drawing::Point(111, 142);
- this->label14->Name = L"label14";
- this->label14->Size = System::Drawing::Size(34, 13);
- this->label14->TabIndex = 29;
- this->label14->Text = L"Full R";
- //
- // label15
- //
- this->label15->AutoSize = true;
- this->label15->Location = System::Drawing::Point(111, 79);
- this->label15->Name = L"label15";
- this->label15->Size = System::Drawing::Size(15, 13);
- this->label15->TabIndex = 28;
- this->label15->Text = L"N";
- //
- // label16
- //
- this->label16->AutoSize = true;
- this->label16->Location = System::Drawing::Point(111, 13);
- this->label16->Name = L"label16";
- this->label16->Size = System::Drawing::Size(32, 13);
- this->label16->TabIndex = 27;
- this->label16->Text = L"Full F";
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(12, 71);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(122, 13);
- this->label4->TabIndex = 26;
- this->label4->Text = L"Last Message Received";
- //
- // lastReceived
- //
- this->lastReceived->Location = System::Drawing::Point(136, 69);
- this->lastReceived->Name = L"lastReceived";
- this->lastReceived->ReadOnly = true;
- this->lastReceived->Size = System::Drawing::Size(352, 20);
- this->lastReceived->TabIndex = 25;
- //
- // lightToggle
- //
- this->lightToggle->BackColor = System::Drawing::SystemColors::ControlDarkDark;
- this->lightToggle->Location = System::Drawing::Point(315, 27);
- this->lightToggle->Name = L"lightToggle";
- this->lightToggle->Size = System::Drawing::Size(54, 51);
- this->lightToggle->TabIndex = 27;
- this->lightToggle->Text = L"Light OFF";
- this->lightToggle->UseVisualStyleBackColor = false;
- this->lightToggle->Click += gcnew System::EventHandler(this, &Form1::lightToggle_Click);
- //
- // groupBox6
- //
- this->groupBox6->Controls->Add(this->label4);
- this->groupBox6->Controls->Add(this->lastReceived);
- this->groupBox6->Controls->Add(this->label3);
- this->groupBox6->Controls->Add(this->receivedLog);
- this->groupBox6->Controls->Add(this->label2);
- this->groupBox6->Controls->Add(this->lastCommand);
- this->groupBox6->Controls->Add(this->label1);
- this->groupBox6->Controls->Add(this->sentLog);
- this->groupBox6->Location = System::Drawing::Point(6, 14);
- this->groupBox6->Name = L"groupBox6";
- this->groupBox6->Size = System::Drawing::Size(593, 274);
- this->groupBox6->TabIndex = 39;
- this->groupBox6->TabStop = false;
- this->groupBox6->Text = L"Messages";
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(923, 364);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(55, 25);
- this->button1->TabIndex = 40;
- this->button1->Text = L"Debug ";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
- //
- // groupBox4
- //
- this->groupBox4->Controls->Add(this->label30);
- this->groupBox4->Controls->Add(this->label29);
- this->groupBox4->Controls->Add(this->label28);
- this->groupBox4->Controls->Add(this->label27);
- this->groupBox4->Controls->Add(this->label26);
- this->groupBox4->Controls->Add(this->label25);
- this->groupBox4->Controls->Add(this->label24);
- this->groupBox4->Controls->Add(this->label23);
- this->groupBox4->Location = System::Drawing::Point(13, 23);
- this->groupBox4->Name = L"groupBox4";
- this->groupBox4->Size = System::Drawing::Size(126, 109);
- this->groupBox4->TabIndex = 37;
- this->groupBox4->TabStop = false;
- this->groupBox4->Text = L"Compass";
- //
- // label30
- //
- this->label30->AutoSize = true;
- this->label30->Location = System::Drawing::Point(25, 32);
- this->label30->Name = L"label30";
- this->label30->Size = System::Drawing::Size(26, 13);
- this->label30->TabIndex = 36;
- this->label30->Text = L"NW";
- //
- // label29
- //
- this->label29->AutoSize = true;
- this->label29->Location = System::Drawing::Point(12, 50);
- this->label29->Name = L"label29";
- this->label29->Size = System::Drawing::Size(18, 13);
- this->label29->TabIndex = 35;
- this->label29->Text = L"W";
- //
- // label28
- //
- this->label28->AutoSize = true;
- this->label28->Location = System::Drawing::Point(25, 68);
- this->label28->Name = L"label28";
- this->label28->Size = System::Drawing::Size(25, 13);
- this->label28->TabIndex = 34;
- this->label28->Text = L"SW";
- //
- // label27
- //
- this->label27->AutoSize = true;
- this->label27->Location = System::Drawing::Point(53, 85);
- this->label27->Name = L"label27";
- this->label27->Size = System::Drawing::Size(14, 13);
- this->label27->TabIndex = 33;
- this->label27->Text = L"S";
- //
- // label26
- //
- this->label26->AutoSize = true;
- this->label26->Location = System::Drawing::Point(74, 68);
- this->label26->Name = L"label26";
- this->label26->Size = System::Drawing::Size(21, 13);
- this->label26->TabIndex = 32;
- this->label26->Text = L"SE";
- //
- // label25
- //
- this->label25->AutoSize = true;
- this->label25->Location = System::Drawing::Point(98, 50);
- this->label25->Name = L"label25";
- this->label25->Size = System::Drawing::Size(14, 13);
- this->label25->TabIndex = 31;
- this->label25->Text = L"E";
- //
- // label24
- //
- this->label24->AutoSize = true;
- this->label24->Location = System::Drawing::Point(73, 32);
- this->label24->Name = L"label24";
- this->label24->Size = System::Drawing::Size(22, 13);
- this->label24->TabIndex = 30;
- this->label24->Text = L"NE";
- //
- // label23
- //
- this->label23->Location = System::Drawing::Point(52, 17);
- this->label23->Name = L"label23";
- this->label23->Size = System::Drawing::Size(68, 15);
- this->label23->TabIndex = 29;
- this->label23->Text = L"N";
- //
- // menuStrip1
- //
- this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->fileToolStripMenuItem,
- this->editToolStripMenuItem, this->viewToolStripMenuItem});
- this->menuStrip1->Location = System::Drawing::Point(0, 0);
- this->menuStrip1->Name = L"menuStrip1";
- this->menuStrip1->Size = System::Drawing::Size(1017, 24);
- this->menuStrip1->TabIndex = 42;
- this->menuStrip1->Text = L"menuStrip1";
- //
- // fileToolStripMenuItem
- //
- this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->exitToolStripMenuItem});
- this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
- this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20);
- this->fileToolStripMenuItem->Text = L"File";
- //
- // exitToolStripMenuItem
- //
- this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
- this->exitToolStripMenuItem->Size = System::Drawing::Size(92, 22);
- this->exitToolStripMenuItem->Text = L"Exit";
- //
- // editToolStripMenuItem
- //
- this->editToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->resetToolStripMenuItem});
- this->editToolStripMenuItem->Name = L"editToolStripMenuItem";
- this->editToolStripMenuItem->Size = System::Drawing::Size(39, 20);
- this->editToolStripMenuItem->Text = L"Edit";
- //
- // resetToolStripMenuItem
- //
- this->resetToolStripMenuItem->Name = L"resetToolStripMenuItem";
- this->resetToolStripMenuItem->Size = System::Drawing::Size(102, 22);
- this->resetToolStripMenuItem->Text = L"Reset";
- //
- // viewToolStripMenuItem
- //
- this->viewToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->onlineHelpToolStripMenuItem});
- this->viewToolStripMenuItem->Name = L"viewToolStripMenuItem";
- this->viewToolStripMenuItem->Size = System::Drawing::Size(44, 20);
- this->viewToolStripMenuItem->Text = L"Help";
- //
- // onlineHelpToolStripMenuItem
- //
- this->onlineHelpToolStripMenuItem->Name = L"onlineHelpToolStripMenuItem";
- this->onlineHelpToolStripMenuItem->Size = System::Drawing::Size(137, 22);
- this->onlineHelpToolStripMenuItem->Text = L"Online Help";
- //
- // trackBar5
- //
- this->trackBar5->Location = System::Drawing::Point(45, 23);
- this->trackBar5->Maximum = 100;
- this->trackBar5->Name = L"trackBar5";
- this->trackBar5->Orientation = System::Windows::Forms::Orientation::Vertical;
- this->trackBar5->Size = System::Drawing::Size(45, 113);
- this->trackBar5->TabIndex = 43;
- this->trackBar5->TickFrequency = 50;
- //
- // groupBox5
- //
- this->groupBox5->Controls->Add(this->label34);
- this->groupBox5->Controls->Add(this->label33);
- this->groupBox5->Controls->Add(this->label32);
- this->groupBox5->Controls->Add(this->label31);
- this->groupBox5->Controls->Add(this->trackBar5);
- this->groupBox5->Location = System::Drawing::Point(169, 23);
- this->groupBox5->Name = L"groupBox5";
- this->groupBox5->Size = System::Drawing::Size(96, 142);
- this->groupBox5->TabIndex = 44;
- this->groupBox5->TabStop = false;
- this->groupBox5->Text = L"Battery Charge";
- //
- // label34
- //
- this->label34->AutoSize = true;
- this->label34->ForeColor = System::Drawing::Color::OliveDrab;
- this->label34->Location = System::Drawing::Point(21, 50);
- this->label34->Name = L"label34";
- this->label34->Size = System::Drawing::Size(19, 13);
- this->label34->TabIndex = 47;
- this->label34->Text = L"75";
- //
- // label33
- //
- this->label33->AutoSize = true;
- this->label33->ForeColor = System::Drawing::Color::Crimson;
- this->label33->Location = System::Drawing::Point(21, 82);
- this->label33->Name = L"label33";
- this->label33->Size = System::Drawing::Size(19, 13);
- this->label33->TabIndex = 46;
- this->label33->Text = L"40";
- //
- // label32
- //
- this->label32->AutoSize = true;
- this->label32->ForeColor = System::Drawing::Color::Crimson;
- this->label32->Location = System::Drawing::Point(27, 116);
- this->label32->Name = L"label32";
- this->label32->Size = System::Drawing::Size(13, 13);
- this->label32->TabIndex = 45;
- this->label32->Text = L"0";
- //
- // label31
- //
- this->label31->AutoSize = true;
- this->label31->ForeColor = System::Drawing::Color::OliveDrab;
- this->label31->Location = System::Drawing::Point(15, 23);
- this->label31->Name = L"label31";
- this->label31->Size = System::Drawing::Size(25, 13);
- this->label31->TabIndex = 44;
- this->label31->Text = L"100";
- //
- // tabControl1
- //
- this->tabControl1->Controls->Add(this->tabPage1);
- this->tabControl1->Controls->Add(this->tabPage2);
- this->tabControl1->Location = System::Drawing::Point(12, 27);
- this->tabControl1->Name = L"tabControl1";
- this->tabControl1->SelectedIndex = 0;
- this->tabControl1->Size = System::Drawing::Size(1000, 468);
- this->tabControl1->TabIndex = 45;
- //
- // tabPage1
- //
- this->tabPage1->Controls->Add(this->textBox7);
- this->tabPage1->Controls->Add(this->textBox6);
- this->tabPage1->Controls->Add(this->radioButton1);
- this->tabPage1->Controls->Add(this->hardwareOff);
- this->tabPage1->Controls->Add(this->surface);
- this->tabPage1->Controls->Add(this->getSensor);
- this->tabPage1->Controls->Add(this->getBattery);
- this->tabPage1->Controls->Add(this->groupBox5);
- this->tabPage1->Controls->Add(this->groupBox4);
- this->tabPage1->Controls->Add(this->lightToggle);
- this->tabPage1->Location = System::Drawing::Point(4, 22);
- this->tabPage1->Name = L"tabPage1";
- this->tabPage1->Padding = System::Windows::Forms::Padding(3);
- this->tabPage1->Size = System::Drawing::Size(992, 442);
- this->tabPage1->TabIndex = 0;
- this->tabPage1->Text = L"Main";
- this->tabPage1->UseVisualStyleBackColor = true;
- //
- // radioButton1
- //
- this->radioButton1->AutoSize = true;
- this->radioButton1->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
- this->radioButton1->Location = System::Drawing::Point(199, 233);
- this->radioButton1->Name = L"radioButton1";
- this->radioButton1->Size = System::Drawing::Size(13, 12);
- this->radioButton1->TabIndex = 49;
- this->radioButton1->TabStop = true;
- this->radioButton1->UseVisualStyleBackColor = true;
- //
- // hardwareOff
- //
- this->hardwareOff->BackColor = System::Drawing::SystemColors::ActiveCaption;
- this->hardwareOff->Location = System::Drawing::Point(555, 27);
- this->hardwareOff->Name = L"hardwareOff";
- this->hardwareOff->Size = System::Drawing::Size(54, 51);
- this->hardwareOff->TabIndex = 48;
- this->hardwareOff->Text = L"Turn All HW Off";
- this->hardwareOff->UseVisualStyleBackColor = false;
- this->hardwareOff->Click += gcnew System::EventHandler(this, &Form1::hardwareOff_Click);
- //
- // surface
- //
- this->surface->BackColor = System::Drawing::SystemColors::ActiveCaption;
- this->surface->Location = System::Drawing::Point(495, 27);
- this->surface->Name = L"surface";
- this->surface->Size = System::Drawing::Size(54, 51);
- this->surface->TabIndex = 47;
- this->surface->Text = L"Surface";
- this->surface->UseVisualStyleBackColor = false;
- this->surface->Click += gcnew System::EventHandler(this, &Form1::surface_Click_1);
- //
- // getSensor
- //
- this->getSensor->BackColor = System::Drawing::SystemColors::ActiveCaption;
- this->getSensor->Location = System::Drawing::Point(375, 27);
- this->getSensor->Name = L"getSensor";
- this->getSensor->Size = System::Drawing::Size(54, 51);
- this->getSensor->TabIndex = 46;
- this->getSensor->Text = L"Update Sensor";
- this->getSensor->UseVisualStyleBackColor = false;
- this->getSensor->Click += gcnew System::EventHandler(this, &Form1::getSensor_Click_1);
- //
- // getBattery
- //
- this->getBattery->BackColor = System::Drawing::SystemColors::ActiveCaption;
- this->getBattery->Location = System::Drawing::Point(435, 27);
- this->getBattery->Name = L"getBattery";
- this->getBattery->Size = System::Drawing::Size(54, 51);
- this->getBattery->TabIndex = 45;
- this->getBattery->Text = L"Update Battery";
- this->getBattery->UseVisualStyleBackColor = false;
- this->getBattery->Click += gcnew System::EventHandler(this, &Form1::getBattery_Click_1);
- //
- // tabPage2
- //
- this->tabPage2->Controls->Add(this->groupBox7);
- this->tabPage2->Controls->Add(this->groupBox1);
- this->tabPage2->Controls->Add(this->button1);
- this->tabPage2->Controls->Add(this->groupBox6);
- this->tabPage2->Location = System::Drawing::Point(4, 22);
- this->tabPage2->Name = L"tabPage2";
- this->tabPage2->Padding = System::Windows::Forms::Padding(3);
- this->tabPage2->Size = System::Drawing::Size(992, 442);
- this->tabPage2->TabIndex = 1;
- this->tabPage2->Text = L"Debug";
- this->tabPage2->UseVisualStyleBackColor = true;
- //
- // groupBox7
- //
- this->groupBox7->Controls->Add(this->sServoPlus);
- this->groupBox7->Controls->Add(this->label35);
- this->groupBox7->Controls->Add(this->bServoPlus);
- this->groupBox7->Controls->Add(this->label10);
- this->groupBox7->Controls->Add(this->bServoMinus);
- this->groupBox7->Controls->Add(this->sServoMinus);
- this->groupBox7->Location = System::Drawing::Point(6, 303);
- this->groupBox7->Name = L"groupBox7";
- this->groupBox7->Size = System::Drawing::Size(102, 96);
- this->groupBox7->TabIndex = 47;
- this->groupBox7->TabStop = false;
- this->groupBox7->Text = L"Servo Control";
- //
- // sServoPlus
- //
- this->sServoPlus->Location = System::Drawing::Point(60, 41);
- this->sServoPlus->Name = L"sServoPlus";
- this->sServoPlus->Size = System::Drawing::Size(29, 20);
- this->sServoPlus->TabIndex = 43;
- this->sServoPlus->Text = L"+";
- this->sServoPlus->UseVisualStyleBackColor = true;
- this->sServoPlus->Click += gcnew System::EventHandler(this, &Form1::sServoPlus_Click);
- //
- // label35
- //
- this->label35->AutoSize = true;
- this->label35->Location = System::Drawing::Point(52, 23);
- this->label35->Name = L"label35";
- this->label35->Size = System::Drawing::Size(45, 13);
- this->label35->TabIndex = 46;
- this->label35->Text = L"S Servo";
- //
- // bServoPlus
- //
- this->bServoPlus->Location = System::Drawing::Point(14, 41);
- this->bServoPlus->Name = L"bServoPlus";
- this->bServoPlus->Size = System::Drawing::Size(29, 20);
- this->bServoPlus->TabIndex = 41;
- this->bServoPlus->Text = L"+";
- this->bServoPlus->UseVisualStyleBackColor = true;
- this->bServoPlus->Click += gcnew System::EventHandler(this, &Form1::bServoPlus_Click);
- //
- // label10
- //
- this->label10->AutoSize = true;
- this->label10->Location = System::Drawing::Point(6, 23);
- this->label10->Name = L"label10";
- this->label10->Size = System::Drawing::Size(45, 13);
- this->label10->TabIndex = 45;
- this->label10->Text = L"B Servo";
- //
- // bServoMinus
- //
- this->bServoMinus->Location = System::Drawing::Point(14, 67);
- this->bServoMinus->Name = L"bServoMinus";
- this->bServoMinus->Size = System::Drawing::Size(29, 20);
- this->bServoMinus->TabIndex = 42;
- this->bServoMinus->Text = L"-";
- this->bServoMinus->UseVisualStyleBackColor = true;
- this->bServoMinus->Click += gcnew System::EventHandler(this, &Form1::bServoMinus_Click);
- //
- // sServoMinus
- //
- this->sServoMinus->Location = System::Drawing::Point(59, 66);
- this->sServoMinus->Name = L"sServoMinus";
- this->sServoMinus->Size = System::Drawing::Size(31, 20);
- this->sServoMinus->TabIndex = 44;
- this->sServoMinus->Text = L"-";
- this->sServoMinus->UseVisualStyleBackColor = true;
- this->sServoMinus->Click += gcnew System::EventHandler(this, &Form1::sServoMinus_Click);
- //
- // textBox6
- //
- this->textBox6->Location = System::Drawing::Point(249, 231);
- this->textBox6->Name = L"textBox6";
- this->textBox6->Size = System::Drawing::Size(45, 20);
- this->textBox6->TabIndex = 50;
- //
- // textBox7
- //
- this->textBox7->Location = System::Drawing::Point(315, 230);
- this->textBox7->Name = L"textBox7";
- this->textBox7->Size = System::Drawing::Size(45, 20);
- this->textBox7->TabIndex = 51;
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(1017, 507);
- this->Controls->Add(this->tabControl1);
- this->Controls->Add(this->menuStrip1);
- this->KeyPreview = true;
- this->MainMenuStrip = this->menuStrip1;
- this->Name = L"Form1";
- this->Text = L"SWIMIR Command Center";
- this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &Form1::Form1_FormClosing);
- this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
- this->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Form1::Form1_KeyPress);
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar1))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar2))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar3))->EndInit();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar4))->EndInit();
- this->groupBox1->ResumeLayout(false);
- this->groupBox1->PerformLayout();
- this->groupBox3->ResumeLayout(false);
- this->groupBox3->PerformLayout();
- this->groupBox2->ResumeLayout(false);
- this->groupBox2->PerformLayout();
- this->groupBox6->ResumeLayout(false);
- this->groupBox6->PerformLayout();
- this->groupBox4->ResumeLayout(false);
- this->groupBox4->PerformLayout();
- this->menuStrip1->ResumeLayout(false);
- this->menuStrip1->PerformLayout();
- (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->trackBar5))->EndInit();
- this->groupBox5->ResumeLayout(false);
- this->groupBox5->PerformLayout();
- this->tabControl1->ResumeLayout(false);
- this->tabPage1->ResumeLayout(false);
- this->tabPage1->PerformLayout();
- this->tabPage2->ResumeLayout(false);
- this->groupBox7->ResumeLayout(false);
- this->groupBox7->PerformLayout();
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private:
- int counter,counter1,counter2, counter3, counter4;
- int countcycles;
- String^ buffer;
- String^ lastcommand;
- String^ sendData;
- String^ receivedMsg;
- String^ receivedMsg2;
- String^ receivedSensorData;
- String^ receivedBatteryData;
- int lMtrSpeed, rMtrSpeed;
- int x,y,z,r;
- int xbuf, ybuf, zbuf, rbuf;
- int bldir, brdir, sldir, srdir;
- int bs, ss;
- int light, sensor, battery;
- int timeToOutput;
- __int32 rawSensorData;
- __int32 rawBatteryData;
- bool putIntoX, putIntoY, putIntoZ, putIntoR, putIntoB;
- //practice
- bool fillMessage;
- String^ incomingMessage;
- int charCounter;
- void Form1_KeyPress(Object^ sender, KeyPressEventArgs^ e)
- {
- if(e->KeyChar=='*'){
- fillMessage = true;
- }
- if(fillMessage == true && e->KeyChar != '*'){
- charCounter++;
- switch(charCounter)
- {
- case 1:
- textBox1->Text = "" + e->KeyChar;
- break;
- case 2:
- textBox1->Text = textBox1->Text + e->KeyChar;
- break;
- case 3:
- textBox1->Text = textBox1->Text + e->KeyChar;
- x = int::Parse(textBox1->Text);
- trackBar1->Value = x;
- //timeToOutput=1;
- break;
- case 4:
- textBox2->Text = "" + e->KeyChar;
- break;
- case 5:
- textBox2->Text = textBox2->Text + e->KeyChar;
- break;
- case 6:
- textBox2->Text = textBox2->Text + e->KeyChar;
- y = int::Parse(textBox2->Text);
- int ydummy;
- ydummy =y;
- ydummy = 100-ydummy;
- trackBar2->Value = ydummy;
- //timeToOutput=1;
- break;
- case 7:
- textBox3->Text = "" + e->KeyChar;
- break;
- case 8:
- textBox3->Text = textBox3->Text + e->KeyChar;
- break;
- case 9:
- textBox3->Text = textBox3->Text + e->KeyChar;
- z = int::Parse(textBox3->Text);
- trackBar3->Value = z;
- //timeToOutput=1;
- break;
- case 10:
- textBox4->Text = "" + e->KeyChar;
- break;
- case 11:
- textBox4->Text = textBox4->Text + e->KeyChar;
- break;
- case 12:
- textBox4->Text = textBox4->Text + e->KeyChar;
- r = int::Parse(textBox4->Text);
- int rdummy;
- rdummy = 100-r;
- trackBar4->Value = rdummy;
- fillMessage = false;
- charCounter = 0;
- timeToOutput=1;
- break;
- }
- }
- //For Buttons*************************************************************************************
- if(e->KeyChar=='b'){
- counter4++;
- putIntoB = true;
- textBox5->Text = "";
- }
- if(counter4>4){counter4=0; putIntoB=false; }
- if(putIntoB==true && counter4>0){
- counter4++;
- if(counter4==5){
- textBox5->Text = "" + e->KeyChar;
- switch(e->KeyChar)
- {
- case '1':
- lastCommand->Text = "Get Battery Data";
- battery = 1;
- timeToOutput = 1;
- break;
- case '2':
- lastCommand->Text = "Light Switched!";
- if(lightToggle->Text == "Light OFF")
- {
- lightToggle->Text = "Light ON";
- lastCommand->Text = "Light ON";
- lightToggle->BackColor = System::Drawing::SystemColors::Info;
- light = 1;
- timeToOutput = 1;
- }
- else
- {
- lightToggle->Text = "Light OFF";
- lastCommand->Text = "Light OFF";
- lightToggle->BackColor = System::Drawing::SystemColors::ControlDarkDark;
- light = 0;
- timeToOutput = 1;
- }
- break;
- case '3':
- lastCommand->Text = "Get Sensor Data";
- sensor = 1;
- timeToOutput = 1;
- break;
- case '4':
- break;
- case '5':
- ss = ss + 1;
- if(ss>9){ss=9;}
- timeToOutput = 1;
- break;
- case '6':
- bs = bs + 1;
- if(bs>9){bs=9;}
- timeToOutput = 1;
- break;
- case '7':
- ss = ss - 1;
- if(ss<0){ss=0;}
- timeToOutput = 1;
- break;
- case '8':
- bs = bs - 1;
- if(bs<0){bs=0;}
- timeToOutput = 1;
- break;
- default:
- break;
- }
- }
- }
- //***************************************************************************************
- if(timeToOutput == 1){
- ///UPDATED MOTOR CONTROL
- if(xbuf == x){x=50;}
- xbuf = x;
- if(ybuf == y){y=50;}
- ybuf = y;
- if(zbuf == z){z=50;}
- zbuf = z;
- if(rbuf == r){r=50;}
- rbuf = r;
- //BL
- if(x>=46 && x<=54){x=0;} else{
- if(x==100){x=99;}
- if(x<46){
- bldir = 0;
- x = (abs(x-45))/5;
- if(xbuf == x){x=0;}
- xbuf = x;
- }
- if(x>54){
- bldir = 1;
- x = x - 54;
- x = x/5;
- if(xbuf == x){x=0;}
- xbuf = x;
- }
- }
- //BR
- if(y>=46 && y<=54){y=0;} else{
- if(y==100){y=99;}
- if(y<46){
- brdir = 0;
- y = (abs(y-45))/5;
- if(ybuf == y){y=0;}
- ybuf = y;
- }
- if(y>54){
- brdir = 1;
- y = y - 54;
- y = y/5;
- if(ybuf == y){y=0;}
- ybuf = y;
- }
- }
- //SL
- if(z>=46 && z<=54){z=0;} else{
- if(z==100){z=99;}
- if(z<46){
- sldir = 0;
- z = (abs(z-45))/5;
- if(zbuf == z){z=0;}
- zbuf = z;
- }
- if(z>54){
- sldir = 1;
- z = z - 54;
- z = z/5;
- if(zbuf == z){z=0;}
- zbuf = z;
- }
- }
- //SR
- if(r>=46 && r<=54){r=0;}else{
- if(r==100){r=99;}
- if(r<46){
- srdir = 0;
- r = (abs(r-45))/5;
- if(rbuf == r){r=0;}
- rbuf = r;
- }
- if(r>54){
- srdir = 1;
- r = r - 54;
- r = r/5;
- if(rbuf == r){r=0;}
- rbuf = r;
- }
- }
- sendCOMData();
- }
- timeToOutput = 0;
- }
- private: System::Void sendCOMData(){
- comPort->WriteLine("*BL"+x+bldir+"BR"+y+brdir+"SL"+z+sldir+"SR"+r+srdir+"BS"+bs+"SS"+ss+"L"+light+"S"+sensor+"B"+battery+":");
- lastCommand->Text = "*BL"+x+bldir+"BR"+y+brdir+"SL"+z+sldir+"SR"+r+srdir+"BS"+bs+"SS"+ss+"L"+light+"S"+sensor+"B"+battery+":"+"\n";
- sentLog->Text = sentLog->Text + "*BL"+x+bldir+"BR"+y+brdir+"SL"+z+sldir+"SR"+r+srdir+"BS"+bs+"SS"+ss+"L"+light+"S"+sensor+"B"+battery+":"+"\n";
- String^ publicDataToSendString = lastCommand->Text;
- publicDataToSendString = "12345678912345678912345678912345";
- for(int k=0;k<32;k++){
- publicDataToSend[k]= publicDataToSendString[k];
- }
- //Auto Scroll stuff
- sentLog->SelectionStart = sentLog->Text->Length;
- sentLog->ScrollToCaret();
- if(battery){
- receivedMsg = comPort->ReadLine();
- receivedLog->Text = receivedLog->Text + "\r\n" + receivedMsg;
- lastReceived->Text = receivedMsg;
- receivedBatteryData = receivedMsg->Remove(0,25);
- rawBatteryData = System::Int32::Parse(receivedBatteryData);
- trackBar5->Value = rawBatteryData;
- battery = 0;
- }
- if(sensor){
- receivedMsg = comPort->ReadLine();
- receivedLog->Text = receivedLog->Text + "\r\n" + receivedMsg;
- lastReceived->Text = receivedMsg;
- receivedSensorData = receivedMsg->Remove(0,3);
- rawSensorData = System::Int32::Parse(receivedSensorData);
- sensor = 0;
- float rawSensorDataInt;
- rawSensorDataInt = rawSensorData;
- radioButton1->Location = Point(200+50*cos(((2*3.141592)/180)*rawSensorDataInt), 50*sin(200+((2*3.141592)/180)*rawSensorDataInt));
- timeToOutput = 0;
- }
- }
- private: System::Void textBox5_TextChanged(System::Object^ sender, System::EventArgs^ e) {
- //String^ toSend = textBox5->Text;
- //sentLog->Text = sentLog->Text +"\r\n" + toSend;
- //lastCommand->Text = toSend;
- //comPort->WriteLine(toSend);
- //receivedLog->Text = receivedLog->Text + "\r\n" + comPort->ReadLine();
- }
- private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
- Thread^ oThread = gcnew Thread( gcnew ThreadStart( &ThreadExample::ThreadProc ) );
- oThread->Start();
- //oThread->Join();
- //comPort = gcnew SerialPort("COM8", 115200);
- //comPort->Open();
- //sentLog->Text = "COM8 Opened";
- }
- private: System::Void Form1_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ ) {
- //comPort->Close();
- //sentLog->Text = "COM8 Closed";
- }
- private: System::Void lightToggle_Click(System::Object^ sender, System::EventArgs^ e) {
- lastCommand->Text = "Light Switched!";
- if(lightToggle->Text == "Light OFF")
- {
- lightToggle->Text = "Light ON";
- lastCommand->Text = "Light ON";
- lightToggle->BackColor = System::Drawing::SystemColors::Info;
- light = 1;
- timeToOutput = 1;
- }
- else
- {
- lightToggle->Text = "Light OFF";
- lastCommand->Text = "Light OFF";
- lightToggle->BackColor = System::Drawing::SystemColors::ControlDarkDark;
- light = 0;
- timeToOutput = 1;
- }
- sendCOMData();
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- ////Debugging Code
- //comPort->WriteLine("*BL30BR41SL80SR91BS1SS1L0S0B0:");
- //receivedMsg = comPort->ReadLine();
- //receivedLog->Text = receivedLog->Text + "\r\n" + receivedMsg;
- //lastReceived->Text = receivedMsg;
- //String^ xm = Char::ToString(receivedMsg[2]) + Char::ToString(receivedMsg[3]) + Char::ToString(receivedMsg[4]);
- //String^ ym = Char::ToString(receivedMsg[6]) + Char::ToString(receivedMsg[7]) + Char::ToString(receivedMsg[8]);
- //String^ zm = Char::ToString(receivedMsg[10]) + Char::ToString(receivedMsg[11]) + Char::ToString(receivedMsg[12]);
- //
- //lastReceived->Text = xm+ym+zm;
- //int sx = int::Parse(Char::ToString(receivedMsg[1]));
- //int sy = int::Parse(Char::ToString(receivedMsg[5]));
- //int sz = int::Parse(Char::ToString(receivedMsg[9]));
- //int ixm = int::Parse(xm);
- //int iym = int::Parse(ym);
- //int izm = int::Parse(zm);
- //if(ixm>270 && sx==0 && iym>10 && sy==0 && izm>288 && sz==0){//N
- // this->label23->BackColor = System::Drawing::SystemColors::ControlDark;
- // this->label25->BackColor = System::Drawing::SystemColors::Control;
- // this->label27->BackColor = System::Drawing::SystemColors::Control;
- // this->label29->BackColor = System::Drawing::SystemColors::Control;
- //}
- //if(ixm>153 && sx==0 && iym>17 && sy==0 && izm>231 && sz==0){//S
- // this->label23->BackColor = System::Drawing::SystemColors::Control;
- // this->label25->BackColor = System::Drawing::SystemColors::Control;
- // this->label27->BackColor = System::Drawing::SystemColors::ControlDark;
- // this->label29->BackColor = System::Drawing::SystemColors::Control;
- //}
- //if(ixm>194 && sx==0 && iym>34 && sy==0 && izm>241 && sz==0){//E
- // this->label23->BackColor = System::Drawing::SystemColors::Control;
- // this->label25->BackColor = System::Drawing::SystemColors::ControlDark;
- // this->label27->BackColor = System::Drawing::SystemColors::Control;
- // this->label29->BackColor = System::Drawing::SystemColors::Control;
- //}
- //if(ixm>211 && sx==0 && iym>31 && sy==0 && izm>212 && sz==0){//W
- // this->label23->BackColor = System::Drawing::SystemColors::Control;
- // this->label25->BackColor = System::Drawing::SystemColors::Control;
- // this->label27->BackColor = System::Drawing::SystemColors::Control;
- // this->label29->BackColor = System::Drawing::SystemColors::ControlDark;
- //}
- }
- private: System::Void getSensor_Click_1(System::Object^ sender, System::EventArgs^ e) {
- //if(threadDone = 1){
- //lastCommand->Text = System::Runtime::InteropServices::Marshal::PtrToStringAnsi(IntPtr((publicDataToSend)));
- //threadDone = 0;
- //}
- //lastCommand->Text = "Get Sensor Data";
- //sensor = 1;
- //timeToOutput = 1;
- //sendCOMData();
- }
- private: System::Void getBattery_Click_1(System::Object^ sender, System::EventArgs^ e) {
- lastCommand->Text = "Get Battery Data";
- battery = 1;
- timeToOutput = 1;
- sendCOMData();
- }
- private: System::Void surface_Click_1(System::Object^ sender, System::EventArgs^ e) {
- lastCommand->Text = "Surface!";
- x=9;
- y=9;
- z=9;
- r=9;
- bldir=1;
- brdir=1;
- sldir=1;
- srdir=1;
- bs=9;
- ss=9;
- sendCOMData();
- }
- private: System::Void bServoPlus_Click(System::Object^ sender, System::EventArgs^ e) {
- bs = bs + 1;
- if(bs>9){bs=9;}
- timeToOutput = 1;
- sendCOMData();
- }
- private: System::Void bServoMinus_Click(System::Object^ sender, System::EventArgs^ e) {
- bs = bs - 1;
- if(bs<0){bs=0;}
- timeToOutput = 1;
- sendCOMData();
- }
- private: System::Void sServoPlus_Click(System::Object^ sender, System::EventArgs^ e) {
- ss = ss + 1;
- if(ss>9){ss=9;}
- timeToOutput = 1;
- sendCOMData();
- }
- private: System::Void sServoMinus_Click(System::Object^ sender, System::EventArgs^ e) {
- ss = ss - 1;
- if(ss<0){ss=0;}
- timeToOutput = 1;
- sendCOMData();
- }
- private: System::Void hardwareOff_Click(System::Object^ sender, System::EventArgs^ e) {
- lastCommand->Text = "All Hardware Off!";
- x=0;
- y=0;
- z=0;
- r=0;
- bldir=0;
- brdir=0;
- sldir=0;
- srdir=0;
- bs=0;
- ss=0;
- light=0;
- sensor=0;
- battery=0;
- sendCOMData();
- }
- };
- }
- ////For X-Axis*************************************************************************************
- //if(e->KeyChar=='x'){
- // counter++;
- // putIntoX = true;
- // textBox1->Text = "";
- //
- //}
- //if(counter>3){counter=0; putIntoX=false; }
- //if(putIntoX==true && counter>0 && e->KeyChar != 'x'){
- // counter++;
- // textBox1->Text = textBox1->Text + e->KeyChar;
- // if(counter>3){
- // x = int::Parse(textBox1->Text);
- // trackBar1->Value = x;
- // timeToOutput=1;
- // }
- //}
- //if(putIntoX==false){
- // //textBox1->Text = "050";
- // //trackBar1->Value = int::Parse(textBox1->Text);
- //}
- //
- ////For Y-Axis*************************************************************************************
- //if(e->KeyChar=='y'){
- // counter1++;
- // putIntoY = true;
- // textBox2->Text = "";
- //}
- //if(counter1>3){counter1=0; putIntoY=false; }
- //if(putIntoY==true && counter1>0 && e->KeyChar != 'y'){
- // counter1++;
- // textBox2->Text = textBox2->Text + e->KeyChar;
- // if(counter1>3){
- // y = int::Parse(textBox2->Text);
- // int ydummy;
- // ydummy =y;
- // ydummy = 100-ydummy;
- // //y=100-y;
- // trackBar2->Value = ydummy;
- // //if(y==100){y=99;}
- // //y = y/10;
- // timeToOutput=1;
- // }
- //}
- //if(putIntoY==false){
- // //textBox2->Text = "050";
- // //trackBar2->Value = int::Parse(textBox2->Text);
- //}
- ////For Z-Axis*************************************************************************************
- //if(e->KeyChar=='z'){
- // counter2++;
- // putIntoZ = true;
- // textBox3->Text = "";
- //}
- //if(counter2>3){counter2=0; putIntoZ=false; }
- //if(putIntoZ==true && counter2>0 && e->KeyChar != 'z'){
- // counter2++;
- // textBox3->Text = textBox3->Text + e->KeyChar;
- // if(counter2>3){
- // z = int::Parse(textBox3->Text);
- // trackBar3->Value = z;
- // //if(z==100){z=99;}
- // //z = z/10;
- // timeToOutput=1;
- // }
- //}
- //if(putIntoZ==false){
- // //textBox3->Text = "050";
- // //trackBar3->Value = int::Parse(textBox3->Text);
- //}
- //
- ////For R-Axis*************************************************************************************
- //if(e->KeyChar=='r'){
- // counter3++;
- // putIntoR = true;
- // textBox4->Text = "";
- //}
- //if(counter3>3){counter3=0; putIntoR=false; }
- //if(putIntoR==true && counter3>0 && e->KeyChar != 'r'){
- // counter3++;
- // textBox4->Text = textBox4->Text + e->KeyChar;
- // if(counter3>3){
- // r = int::Parse(textBox4->Text);
- // int rdummy;
- // rdummy = 100-r;
- // trackBar4->Value = rdummy;
- // //if(r==100){r=99;}
- // //r = r/10;
- // timeToOutput=1;
- // }
- //}
- //if(putIntoR==false){
- // //textBox4->Text = "050";
- // //trackBar4->Value = int::Parse(textBox4->Text);
- //}
Add Comment
Please, Sign In to add comment