//Programme de démonstration du module TC/USB-16IO Visual C++ 2010 Express
// V1.0 : 05/09/2016: 3CC-DB : Release


#pragma once

#include "TCUSB16IOx64.H"

namespace DemoTCUSB16IO {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Description résumée de Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: ajoutez ici le code du constructeur
			//
		}

	protected:
		/// <summary>
		/// Nettoyage des ressources utilisées.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Label^  label21;
	protected: 

	private: System::Windows::Forms::TextBox^  TextBoxSN;
	private: System::Windows::Forms::Label^  label17;
	private: System::Windows::Forms::TextBox^  textBoxDataPos;
	private: System::Windows::Forms::Button^  button10;
	private: System::Windows::Forms::Panel^  panelB;
	private: System::Windows::Forms::Label^  label18;
	private: System::Windows::Forms::Label^  label8;
	private: System::Windows::Forms::CheckBox^  checkBoxZ;
	private: System::Windows::Forms::Label^  label7;
	private: System::Windows::Forms::Label^  label19;
	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::Panel^  panelA;
	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::GroupBox^  groupBox3;
	private: System::Windows::Forms::Panel^  panelZ;
	private: System::Windows::Forms::TextBox^  textBoxCTR8;
	private: System::Windows::Forms::TextBox^  textBoxCTR7;
	private: System::Windows::Forms::GroupBox^  groupBox2;
	private: System::Windows::Forms::TextBox^  textBoxCTR6;
	private: System::Windows::Forms::TextBox^  textBoxCTR5;
	private: System::Windows::Forms::TextBox^  textBoxCTR4;
	private: System::Windows::Forms::TextBox^  textBoxCTR3;
	private: System::Windows::Forms::TextBox^  textBoxCTR2;
	private: System::Windows::Forms::TextBox^  textBoxCTR1;
	private: System::Windows::Forms::Panel^  panelI8;
	private: System::Windows::Forms::Button^  buttonOpen;
	private: System::Windows::Forms::Panel^  panelI7;
	private: System::Windows::Forms::GroupBox^  groupBox1;
	private: System::Windows::Forms::Button^  buttonS6;
	private: System::Windows::Forms::Panel^  panelI6;
	private: System::Windows::Forms::Button^  buttonS5;
	private: System::Windows::Forms::Panel^  panelI5;
	private: System::Windows::Forms::Button^  buttonS4;
	private: System::Windows::Forms::Panel^  panelI4;
	private: System::Windows::Forms::Button^  buttonS3;
	private: System::Windows::Forms::Panel^  panelI3;
	private: System::Windows::Forms::Button^  buttonS2;
	private: System::Windows::Forms::Button^  buttonS1;
	private: System::Windows::Forms::Panel^  panelI2;
	private: System::Windows::Forms::Panel^  panelI1;
	private: System::Windows::Forms::Timer^  timer1;
	private: System::Windows::Forms::Label^  labelDLL;
	private: System::Windows::Forms::Label^  labelFW;
	private: System::Windows::Forms::Label^  labelSN;

	private: System::Windows::Forms::Timer^  timer2;

	protected: 


	private: System::ComponentModel::IContainer^  components;
	private:
		/// <summary>
		/// Variable nécessaire au concepteur.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
		/// le contenu de cette méthode avec l'éditeur de code.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			this->label21 = (gcnew System::Windows::Forms::Label());
			this->TextBoxSN = (gcnew System::Windows::Forms::TextBox());
			this->label17 = (gcnew System::Windows::Forms::Label());
			this->textBoxDataPos = (gcnew System::Windows::Forms::TextBox());
			this->button10 = (gcnew System::Windows::Forms::Button());
			this->panelB = (gcnew System::Windows::Forms::Panel());
			this->label18 = (gcnew System::Windows::Forms::Label());
			this->label8 = (gcnew System::Windows::Forms::Label());
			this->checkBoxZ = (gcnew System::Windows::Forms::CheckBox());
			this->label7 = (gcnew System::Windows::Forms::Label());
			this->label19 = (gcnew System::Windows::Forms::Label());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->panelA = (gcnew System::Windows::Forms::Panel());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
			this->labelDLL = (gcnew System::Windows::Forms::Label());
			this->labelFW = (gcnew System::Windows::Forms::Label());
			this->labelSN = (gcnew System::Windows::Forms::Label());
			this->panelZ = (gcnew System::Windows::Forms::Panel());
			this->textBoxCTR8 = (gcnew System::Windows::Forms::TextBox());
			this->textBoxCTR7 = (gcnew System::Windows::Forms::TextBox());
			this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
			this->textBoxCTR6 = (gcnew System::Windows::Forms::TextBox());
			this->textBoxCTR5 = (gcnew System::Windows::Forms::TextBox());
			this->textBoxCTR4 = (gcnew System::Windows::Forms::TextBox());
			this->textBoxCTR3 = (gcnew System::Windows::Forms::TextBox());
			this->textBoxCTR2 = (gcnew System::Windows::Forms::TextBox());
			this->textBoxCTR1 = (gcnew System::Windows::Forms::TextBox());
			this->panelI8 = (gcnew System::Windows::Forms::Panel());
			this->buttonOpen = (gcnew System::Windows::Forms::Button());
			this->panelI7 = (gcnew System::Windows::Forms::Panel());
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
			this->buttonS6 = (gcnew System::Windows::Forms::Button());
			this->panelI6 = (gcnew System::Windows::Forms::Panel());
			this->buttonS5 = (gcnew System::Windows::Forms::Button());
			this->panelI5 = (gcnew System::Windows::Forms::Panel());
			this->buttonS4 = (gcnew System::Windows::Forms::Button());
			this->panelI4 = (gcnew System::Windows::Forms::Panel());
			this->buttonS3 = (gcnew System::Windows::Forms::Button());
			this->panelI3 = (gcnew System::Windows::Forms::Panel());
			this->buttonS2 = (gcnew System::Windows::Forms::Button());
			this->buttonS1 = (gcnew System::Windows::Forms::Button());
			this->panelI2 = (gcnew System::Windows::Forms::Panel());
			this->panelI1 = (gcnew System::Windows::Forms::Panel());
			this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
			this->timer2 = (gcnew System::Windows::Forms::Timer(this->components));
			this->groupBox3->SuspendLayout();
			this->groupBox2->SuspendLayout();
			this->groupBox1->SuspendLayout();
			this->SuspendLayout();
			// 
			// label21
			// 
			this->label21->AutoSize = true;
			this->label21->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label21->Location = System::Drawing::Point(26, 22);
			this->label21->Name = L"label21";
			this->label21->Size = System::Drawing::Size(268, 13);
			this->label21->TabIndex = 38;
			this->label21->Text = L"I 1        I 2       I 3        I 4         I 5        I 6        I 7       I 8";
			// 
			// TextBoxSN
			// 
			this->TextBoxSN->Location = System::Drawing::Point(17, 17);
			this->TextBoxSN->Name = L"TextBoxSN";
			this->TextBoxSN->Size = System::Drawing::Size(100, 20);
			this->TextBoxSN->TabIndex = 5;
			this->TextBoxSN->Text = L"0";
			this->TextBoxSN->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;
			// 
			// label17
			// 
			this->label17->AutoSize = true;
			this->label17->Location = System::Drawing::Point(32, 43);
			this->label17->Name = L"label17";
			this->label17->Size = System::Drawing::Size(15, 13);
			this->label17->TabIndex = 10;
			this->label17->Text = L"Z";
			// 
			// textBoxDataPos
			// 
			this->textBoxDataPos->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->textBoxDataPos->Location = System::Drawing::Point(18, 111);
			this->textBoxDataPos->Name = L"textBoxDataPos";
			this->textBoxDataPos->ReadOnly = true;
			this->textBoxDataPos->Size = System::Drawing::Size(100, 20);
			this->textBoxDataPos->TabIndex = 9;
			this->textBoxDataPos->Text = L"0";
			// 
			// button10
			// 
			this->button10->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button10->Location = System::Drawing::Point(126, 108);
			this->button10->Name = L"button10";
			this->button10->Size = System::Drawing::Size(126, 23);
			this->button10->TabIndex = 8;
			this->button10->Text = L"Reset position";
			this->button10->UseVisualStyleBackColor = true;
			this->button10->Click += gcnew System::EventHandler(this, &Form1::button10_Click);
			// 
			// panelB
			// 
			this->panelB->BackColor = System::Drawing::Color::Green;
			this->panelB->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelB->Location = System::Drawing::Point(90, 59);
			this->panelB->Name = L"panelB";
			this->panelB->Size = System::Drawing::Size(30, 30);
			this->panelB->TabIndex = 5;
			// 
			// label18
			// 
			this->label18->AutoSize = true;
			this->label18->Location = System::Drawing::Point(68, 43);
			this->label18->Name = L"label18";
			this->label18->Size = System::Drawing::Size(15, 13);
			this->label18->TabIndex = 11;
			this->label18->Text = L"A";
			// 
			// label8
			// 
			this->label8->AutoSize = true;
			this->label8->Location = System::Drawing::Point(521, 62);
			this->label8->Name = L"label8";
			this->label8->Size = System::Drawing::Size(47, 13);
			this->label8->TabIndex = 29;
			this->label8->Text = L"Count8";
			// 
			// checkBoxZ
			// 
			this->checkBoxZ->AutoSize = true;
			this->checkBoxZ->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->checkBoxZ->Location = System::Drawing::Point(126, 72);
			this->checkBoxZ->Name = L"checkBoxZ";
			this->checkBoxZ->Size = System::Drawing::Size(101, 17);
			this->checkBoxZ->TabIndex = 13;
			this->checkBoxZ->Text = L"Reset on Top Z";
			this->checkBoxZ->UseVisualStyleBackColor = true;
			this->checkBoxZ->CheckStateChanged += gcnew System::EventHandler(this, &Form1::checkBoxZ_CheckStateChanged);
			// 
			// label7
			// 
			this->label7->AutoSize = true;
			this->label7->Location = System::Drawing::Point(453, 62);
			this->label7->Name = L"label7";
			this->label7->Size = System::Drawing::Size(47, 13);
			this->label7->TabIndex = 28;
			this->label7->Text = L"Count7";
			// 
			// label19
			// 
			this->label19->AutoSize = true;
			this->label19->Location = System::Drawing::Point(103, 43);
			this->label19->Name = L"label19";
			this->label19->Size = System::Drawing::Size(15, 13);
			this->label19->TabIndex = 12;
			this->label19->Text = L"B";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->Location = System::Drawing::Point(387, 62);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(47, 13);
			this->label6->TabIndex = 27;
			this->label6->Text = L"Count6";
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->Location = System::Drawing::Point(324, 61);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(47, 13);
			this->label5->TabIndex = 26;
			this->label5->Text = L"Count5";
			// 
			// panelA
			// 
			this->panelA->BackColor = System::Drawing::Color::Green;
			this->panelA->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelA->Location = System::Drawing::Point(54, 59);
			this->panelA->Name = L"panelA";
			this->panelA->Size = System::Drawing::Size(30, 30);
			this->panelA->TabIndex = 6;
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Location = System::Drawing::Point(521, 22);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(47, 13);
			this->label4->TabIndex = 25;
			this->label4->Text = L"Count4";
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(453, 22);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(47, 13);
			this->label3->TabIndex = 24;
			this->label3->Text = L"Count3";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(387, 22);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(47, 13);
			this->label2->TabIndex = 23;
			this->label2->Text = L"Count2";
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(326, 22);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(47, 13);
			this->label1->TabIndex = 22;
			this->label1->Text = L"Count1";
			// 
			// groupBox3
			// 
			this->groupBox3->Controls->Add(this->labelDLL);
			this->groupBox3->Controls->Add(this->labelFW);
			this->groupBox3->Controls->Add(this->labelSN);
			this->groupBox3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->groupBox3->Location = System::Drawing::Point(335, 188);
			this->groupBox3->Name = L"groupBox3";
			this->groupBox3->Size = System::Drawing::Size(266, 146);
			this->groupBox3->TabIndex = 9;
			this->groupBox3->TabStop = false;
			this->groupBox3->Text = L"TC/USB-16IO Info";
			// 
			// labelDLL
			// 
			this->labelDLL->AutoSize = true;
			this->labelDLL->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->labelDLL->Location = System::Drawing::Point(17, 98);
			this->labelDLL->Name = L"labelDLL";
			this->labelDLL->Size = System::Drawing::Size(10, 13);
			this->labelDLL->TabIndex = 5;
			this->labelDLL->Text = L".";
			// 
			// labelFW
			// 
			this->labelFW->AutoSize = true;
			this->labelFW->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->labelFW->Location = System::Drawing::Point(17, 66);
			this->labelFW->Name = L"labelFW";
			this->labelFW->Size = System::Drawing::Size(10, 13);
			this->labelFW->TabIndex = 4;
			this->labelFW->Text = L".";
			// 
			// labelSN
			// 
			this->labelSN->AutoSize = true;
			this->labelSN->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->labelSN->Location = System::Drawing::Point(17, 34);
			this->labelSN->Name = L"labelSN";
			this->labelSN->Size = System::Drawing::Size(10, 13);
			this->labelSN->TabIndex = 3;
			this->labelSN->Text = L".";
			// 
			// panelZ
			// 
			this->panelZ->BackColor = System::Drawing::Color::Green;
			this->panelZ->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelZ->Location = System::Drawing::Point(18, 59);
			this->panelZ->Name = L"panelZ";
			this->panelZ->Size = System::Drawing::Size(30, 30);
			this->panelZ->TabIndex = 4;
			// 
			// textBoxCTR8
			// 
			this->textBoxCTR8->Location = System::Drawing::Point(524, 78);
			this->textBoxCTR8->Name = L"textBoxCTR8";
			this->textBoxCTR8->ReadOnly = true;
			this->textBoxCTR8->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->textBoxCTR8->Size = System::Drawing::Size(40, 20);
			this->textBoxCTR8->TabIndex = 13;
			this->textBoxCTR8->Text = L"0";
			// 
			// textBoxCTR7
			// 
			this->textBoxCTR7->Location = System::Drawing::Point(456, 78);
			this->textBoxCTR7->Name = L"textBoxCTR7";
			this->textBoxCTR7->ReadOnly = true;
			this->textBoxCTR7->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->textBoxCTR7->Size = System::Drawing::Size(40, 20);
			this->textBoxCTR7->TabIndex = 12;
			this->textBoxCTR7->Text = L"0";
			// 
			// groupBox2
			// 
			this->groupBox2->Controls->Add(this->checkBoxZ);
			this->groupBox2->Controls->Add(this->label19);
			this->groupBox2->Controls->Add(this->label18);
			this->groupBox2->Controls->Add(this->label17);
			this->groupBox2->Controls->Add(this->textBoxDataPos);
			this->groupBox2->Controls->Add(this->button10);
			this->groupBox2->Controls->Add(this->panelB);
			this->groupBox2->Controls->Add(this->panelA);
			this->groupBox2->Controls->Add(this->panelZ);
			this->groupBox2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->groupBox2->Location = System::Drawing::Point(17, 188);
			this->groupBox2->Name = L"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(299, 146);
			this->groupBox2->TabIndex = 8;
			this->groupBox2->TabStop = false;
			this->groupBox2->Text = L"Encoder";
			// 
			// textBoxCTR6
			// 
			this->textBoxCTR6->Location = System::Drawing::Point(390, 78);
			this->textBoxCTR6->Name = L"textBoxCTR6";
			this->textBoxCTR6->ReadOnly = true;
			this->textBoxCTR6->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->textBoxCTR6->Size = System::Drawing::Size(40, 20);
			this->textBoxCTR6->TabIndex = 11;
			this->textBoxCTR6->Text = L"0";
			// 
			// textBoxCTR5
			// 
			this->textBoxCTR5->Location = System::Drawing::Point(327, 78);
			this->textBoxCTR5->Name = L"textBoxCTR5";
			this->textBoxCTR5->ReadOnly = true;
			this->textBoxCTR5->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->textBoxCTR5->Size = System::Drawing::Size(40, 20);
			this->textBoxCTR5->TabIndex = 10;
			this->textBoxCTR5->Text = L"0";
			// 
			// textBoxCTR4
			// 
			this->textBoxCTR4->Location = System::Drawing::Point(524, 38);
			this->textBoxCTR4->Name = L"textBoxCTR4";
			this->textBoxCTR4->ReadOnly = true;
			this->textBoxCTR4->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->textBoxCTR4->Size = System::Drawing::Size(40, 20);
			this->textBoxCTR4->TabIndex = 9;
			this->textBoxCTR4->Text = L"0";
			// 
			// textBoxCTR3
			// 
			this->textBoxCTR3->Location = System::Drawing::Point(456, 38);
			this->textBoxCTR3->Name = L"textBoxCTR3";
			this->textBoxCTR3->ReadOnly = true;
			this->textBoxCTR3->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->textBoxCTR3->Size = System::Drawing::Size(40, 20);
			this->textBoxCTR3->TabIndex = 8;
			this->textBoxCTR3->Text = L"0";
			// 
			// textBoxCTR2
			// 
			this->textBoxCTR2->Location = System::Drawing::Point(390, 38);
			this->textBoxCTR2->Name = L"textBoxCTR2";
			this->textBoxCTR2->ReadOnly = true;
			this->textBoxCTR2->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->textBoxCTR2->Size = System::Drawing::Size(40, 20);
			this->textBoxCTR2->TabIndex = 7;
			this->textBoxCTR2->Text = L"0";
			// 
			// textBoxCTR1
			// 
			this->textBoxCTR1->Location = System::Drawing::Point(327, 38);
			this->textBoxCTR1->Name = L"textBoxCTR1";
			this->textBoxCTR1->ReadOnly = true;
			this->textBoxCTR1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
			this->textBoxCTR1->Size = System::Drawing::Size(40, 20);
			this->textBoxCTR1->TabIndex = 6;
			this->textBoxCTR1->Text = L"0";
			// 
			// panelI8
			// 
			this->panelI8->BackColor = System::Drawing::Color::Green;
			this->panelI8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelI8->Location = System::Drawing::Point(269, 38);
			this->panelI8->Name = L"panelI8";
			this->panelI8->Size = System::Drawing::Size(30, 30);
			this->panelI8->TabIndex = 3;
			// 
			// buttonOpen
			// 
			this->buttonOpen->Location = System::Drawing::Point(123, 17);
			this->buttonOpen->Name = L"buttonOpen";
			this->buttonOpen->Size = System::Drawing::Size(75, 20);
			this->buttonOpen->TabIndex = 6;
			this->buttonOpen->Text = L"Open!";
			this->buttonOpen->UseVisualStyleBackColor = true;
			this->buttonOpen->Click += gcnew System::EventHandler(this, &Form1::buttonOpen_Click_1);
			// 
			// panelI7
			// 
			this->panelI7->BackColor = System::Drawing::Color::Green;
			this->panelI7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelI7->Location = System::Drawing::Point(233, 38);
			this->panelI7->Name = L"panelI7";
			this->panelI7->Size = System::Drawing::Size(30, 30);
			this->panelI7->TabIndex = 3;
			// 
			// groupBox1
			// 
			this->groupBox1->Controls->Add(this->label21);
			this->groupBox1->Controls->Add(this->label8);
			this->groupBox1->Controls->Add(this->label7);
			this->groupBox1->Controls->Add(this->label6);
			this->groupBox1->Controls->Add(this->label5);
			this->groupBox1->Controls->Add(this->label4);
			this->groupBox1->Controls->Add(this->label3);
			this->groupBox1->Controls->Add(this->label2);
			this->groupBox1->Controls->Add(this->label1);
			this->groupBox1->Controls->Add(this->textBoxCTR8);
			this->groupBox1->Controls->Add(this->textBoxCTR7);
			this->groupBox1->Controls->Add(this->textBoxCTR6);
			this->groupBox1->Controls->Add(this->textBoxCTR5);
			this->groupBox1->Controls->Add(this->textBoxCTR4);
			this->groupBox1->Controls->Add(this->textBoxCTR3);
			this->groupBox1->Controls->Add(this->textBoxCTR2);
			this->groupBox1->Controls->Add(this->textBoxCTR1);
			this->groupBox1->Controls->Add(this->panelI8);
			this->groupBox1->Controls->Add(this->panelI7);
			this->groupBox1->Controls->Add(this->buttonS6);
			this->groupBox1->Controls->Add(this->panelI6);
			this->groupBox1->Controls->Add(this->buttonS5);
			this->groupBox1->Controls->Add(this->panelI5);
			this->groupBox1->Controls->Add(this->buttonS4);
			this->groupBox1->Controls->Add(this->panelI4);
			this->groupBox1->Controls->Add(this->buttonS3);
			this->groupBox1->Controls->Add(this->panelI3);
			this->groupBox1->Controls->Add(this->buttonS2);
			this->groupBox1->Controls->Add(this->buttonS1);
			this->groupBox1->Controls->Add(this->panelI2);
			this->groupBox1->Controls->Add(this->panelI1);
			this->groupBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->groupBox1->Location = System::Drawing::Point(17, 43);
			this->groupBox1->Name = L"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(584, 132);
			this->groupBox1->TabIndex = 7;
			this->groupBox1->TabStop = false;
			this->groupBox1->Text = L"Inputs / Outputs";
			// 
			// buttonS6
			// 
			this->buttonS6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->buttonS6->Location = System::Drawing::Point(233, 84);
			this->buttonS6->Name = L"buttonS6";
			this->buttonS6->Size = System::Drawing::Size(30, 30);
			this->buttonS6->TabIndex = 4;
			this->buttonS6->Tag = L"6";
			this->buttonS6->Text = L"O6";
			this->buttonS6->UseVisualStyleBackColor = true;
			this->buttonS6->Click += gcnew System::EventHandler(this, &Form1::buttonS6_Click);
			// 
			// panelI6
			// 
			this->panelI6->BackColor = System::Drawing::Color::Green;
			this->panelI6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelI6->Location = System::Drawing::Point(197, 38);
			this->panelI6->Name = L"panelI6";
			this->panelI6->Size = System::Drawing::Size(30, 30);
			this->panelI6->TabIndex = 3;
			// 
			// buttonS5
			// 
			this->buttonS5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->buttonS5->Location = System::Drawing::Point(197, 84);
			this->buttonS5->Name = L"buttonS5";
			this->buttonS5->Size = System::Drawing::Size(30, 30);
			this->buttonS5->TabIndex = 4;
			this->buttonS5->Tag = L"5";
			this->buttonS5->Text = L"O5";
			this->buttonS5->UseVisualStyleBackColor = true;
			this->buttonS5->Click += gcnew System::EventHandler(this, &Form1::buttonS5_Click);
			// 
			// panelI5
			// 
			this->panelI5->BackColor = System::Drawing::Color::Green;
			this->panelI5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelI5->Location = System::Drawing::Point(161, 38);
			this->panelI5->Name = L"panelI5";
			this->panelI5->Size = System::Drawing::Size(30, 30);
			this->panelI5->TabIndex = 3;
			// 
			// buttonS4
			// 
			this->buttonS4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->buttonS4->Location = System::Drawing::Point(161, 84);
			this->buttonS4->Name = L"buttonS4";
			this->buttonS4->Size = System::Drawing::Size(30, 30);
			this->buttonS4->TabIndex = 4;
			this->buttonS4->Tag = L"4";
			this->buttonS4->Text = L"O4";
			this->buttonS4->UseVisualStyleBackColor = true;
			this->buttonS4->Click += gcnew System::EventHandler(this, &Form1::buttonS4_Click);
			// 
			// panelI4
			// 
			this->panelI4->BackColor = System::Drawing::Color::Green;
			this->panelI4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelI4->Location = System::Drawing::Point(125, 38);
			this->panelI4->Name = L"panelI4";
			this->panelI4->Size = System::Drawing::Size(30, 30);
			this->panelI4->TabIndex = 3;
			// 
			// buttonS3
			// 
			this->buttonS3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->buttonS3->Location = System::Drawing::Point(125, 84);
			this->buttonS3->Name = L"buttonS3";
			this->buttonS3->Size = System::Drawing::Size(30, 30);
			this->buttonS3->TabIndex = 4;
			this->buttonS3->Tag = L"3";
			this->buttonS3->Text = L"O3";
			this->buttonS3->UseVisualStyleBackColor = true;
			this->buttonS3->Click += gcnew System::EventHandler(this, &Form1::buttonS3_Click);
			// 
			// panelI3
			// 
			this->panelI3->BackColor = System::Drawing::Color::Green;
			this->panelI3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelI3->Location = System::Drawing::Point(89, 38);
			this->panelI3->Name = L"panelI3";
			this->panelI3->Size = System::Drawing::Size(30, 30);
			this->panelI3->TabIndex = 3;
			// 
			// buttonS2
			// 
			this->buttonS2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->buttonS2->Location = System::Drawing::Point(89, 84);
			this->buttonS2->Name = L"buttonS2";
			this->buttonS2->Size = System::Drawing::Size(30, 30);
			this->buttonS2->TabIndex = 4;
			this->buttonS2->Tag = L"2";
			this->buttonS2->Text = L"O2";
			this->buttonS2->UseVisualStyleBackColor = true;
			this->buttonS2->Click += gcnew System::EventHandler(this, &Form1::buttonS2_Click);
			// 
			// buttonS1
			// 
			this->buttonS1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->buttonS1->Location = System::Drawing::Point(53, 84);
			this->buttonS1->Name = L"buttonS1";
			this->buttonS1->Size = System::Drawing::Size(30, 30);
			this->buttonS1->TabIndex = 1;
			this->buttonS1->Tag = L"1";
			this->buttonS1->Text = L"O1";
			this->buttonS1->UseVisualStyleBackColor = true;
			this->buttonS1->Click += gcnew System::EventHandler(this, &Form1::buttonS1_Click);
			// 
			// panelI2
			// 
			this->panelI2->BackColor = System::Drawing::Color::Green;
			this->panelI2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelI2->Location = System::Drawing::Point(53, 38);
			this->panelI2->Name = L"panelI2";
			this->panelI2->Size = System::Drawing::Size(30, 30);
			this->panelI2->TabIndex = 3;
			// 
			// panelI1
			// 
			this->panelI1->BackColor = System::Drawing::Color::Green;
			this->panelI1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->panelI1->Location = System::Drawing::Point(17, 38);
			this->panelI1->Name = L"panelI1";
			this->panelI1->Size = System::Drawing::Size(30, 30);
			this->panelI1->TabIndex = 0;
			// 
			// timer1
			// 
			this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
			// 
			// timer2
			// 
			this->timer2->Interval = 1000;
			this->timer2->Tick += gcnew System::EventHandler(this, &Form1::timer2_Tick);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(622, 349);
			this->Controls->Add(this->TextBoxSN);
			this->Controls->Add(this->groupBox3);
			this->Controls->Add(this->groupBox2);
			this->Controls->Add(this->buttonOpen);
			this->Controls->Add(this->groupBox1);
			this->Name = L"Form1";
			this->Text = L"TC/USB-16 IO Demo Program -(c) 2016 3C Concept S.A.S - V1.0  Visual C++ 2010";
			this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &Form1::Form1_FormClosing);
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->groupBox3->ResumeLayout(false);
			this->groupBox3->PerformLayout();
			this->groupBox2->ResumeLayout(false);
			this->groupBox2->PerformLayout();
			this->groupBox1->ResumeLayout(false);
			this->groupBox1->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

		bool ModuleOpened;
		int DataOut;

public: void actualise(void)
			{
				int i=0,j=0;
				DWORD InputData=0;
				long DataPos=0,etat=0;
				WORD mask=0x0001;
				BYTE ctr=0;

				//Rafraichissement données du module
				i=TCUSB16IO_Refresh(1);
				
				//Lecture entrées TOR
				i=TCUSB16IO_Input(1,&InputData);
				if ((mask & InputData)==mask)panelI1->BackColor= Color::Lime;
				else						 panelI1->BackColor= Color::Green;
				mask=mask<<1;
				if ((mask & InputData)==mask)panelI2->BackColor= Color::Lime;
				else						 panelI2->BackColor= Color::Green;
				mask=mask<<1;
				if ((mask & InputData)==mask)panelI3->BackColor= Color::Lime;
				else						 panelI3->BackColor= Color::Green;
				mask=mask<<1;
				if ((mask & InputData)==mask)panelI4->BackColor= Color::Lime;
				else						 panelI4->BackColor= Color::Green;
				mask=mask<<1;
				if ((mask & InputData)==mask)panelI5->BackColor= Color::Lime;
				else						 panelI5->BackColor= Color::Green;
				mask=mask<<1;
				if ((mask & InputData)==mask)panelI6->BackColor= Color::Lime;
				else						 panelI6->BackColor= Color::Green;
				mask=mask<<1;
				if ((mask & InputData)==mask)panelI7->BackColor= Color::Lime;
				else						 panelI7->BackColor= Color::Green;
				mask=mask<<1;
				if ((mask & InputData)==mask)panelI8->BackColor= Color::Lime;
				else						 panelI8->BackColor= Color::Green;
				mask=mask<<1;
								
				//Lecture entrées ABZ
				etat=TCUSB16IO_BitInput(1,11);
				if (etat==1)  panelZ->BackColor = Color::Lime;
				else		  panelZ->BackColor = Color::Green;

				etat=TCUSB16IO_BitInput(1,9);
				if (etat==1)  panelA->BackColor = Color::Lime;
				else		  panelA->BackColor = Color::Green;

				etat=TCUSB16IO_BitInput(1,10);
				if (etat==1)  panelB->BackColor = Color::Lime;
				else		  panelB->BackColor = Color::Green;

				//Lecture compteur de position codeur
				i=TCUSB16IO_Pos(1,&DataPos);	
				textBoxDataPos->Text=DataPos.ToString();
				
				//Lecteur des compteurs d'évenement sur les entrées TOR
				i=TCUSB16IO_Counter(1,1,&ctr);textBoxCTR1->Text=ctr.ToString();
				i=TCUSB16IO_Counter(1,2,&ctr);textBoxCTR2->Text=ctr.ToString();
				i=TCUSB16IO_Counter(1,3,&ctr);textBoxCTR3->Text=ctr.ToString();
				i=TCUSB16IO_Counter(1,4,&ctr);textBoxCTR4->Text=ctr.ToString();
				i=TCUSB16IO_Counter(1,5,&ctr);textBoxCTR5->Text=ctr.ToString();
				i=TCUSB16IO_Counter(1,6,&ctr);textBoxCTR6->Text=ctr.ToString();
				i=TCUSB16IO_Counter(1,7,&ctr);textBoxCTR7->Text=ctr.ToString();
				i=TCUSB16IO_Counter(1,8,&ctr);textBoxCTR8->Text=ctr.ToString();
				
			}
	
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
			 ModuleOpened=false;
			 DataOut=0x01;
		 }

private: System::Void buttonOpen_Click_1(System::Object^  sender, System::EventArgs^  e) {
			 int err = 0;
			int i=0;
			DWORD SN=0;
			BYTE Data1=0,Data2=0;

			//ouverture du module
			SN=Convert::ToUInt32(TextBoxSN->Text);
			err=TCUSB16IO_OpenN(1,&SN);
						
			if (err==0)
			{
				buttonOpen->Enabled=false;
				ModuleOpened=true;
				labelSN->Text= "SN: "+SN.ToString();
				TextBoxSN->Text=SN.ToString();

				//Actualision des données du module
				err=TCUSB16IO_Refresh(1);

				//Lecture du firmware et la version de la dll
				err=TCUSB16IO_Version(1,&Data1,&Data2);
				labelFW->Text= "Firmware version: "+Data1.ToString();
				labelDLL->Text="DLL version: "+Data2.ToString();
				timer1->Enabled=true;
			}
			else
			{
				TextBoxSN->Text="Erreur N°"+i.ToString();
				ModuleOpened = false;
                if (err == 1) MessageBox::Show("Numero de serie incorrect");
                if (err == 2) MessageBox::Show("N° de module incorrect");
                if (err == 3) MessageBox::Show("Pas de module TC/USB-16IO détecté");
                if (err == 4) MessageBox::Show("Module non initialisé");
                Close();
			
			}
		 }
private: System::Void Form1_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
			 int i=0;
			 //Fermeture module
			 if (ModuleOpened)
				i=TCUSB16IO_Close(1);
		 }
private: System::Void buttonS1_Click(System::Object^  sender, System::EventArgs^  e) {
			 long Etat=0;
			 int i=0;
			 //Lecture de l'etat de la sortie et inversion de sa commande
			 i=TCUSB16IO_Refresh(1);
			 Etat=TCUSB16IO_BitReadBack(1,1);
			 Etat=~Etat & 0x00000001;
			 TCUSB16IO_BitOutput(1,1,Etat);
			 i=TCUSB16IO_Refresh(1);
		 }
private: System::Void buttonS2_Click(System::Object^  sender, System::EventArgs^  e) {
			 long Etat=0;
			 int i=0;
			 //Lecture de l'etat de la sortie et inversion de sa commande
			 i=TCUSB16IO_Refresh(1);
			 Etat=TCUSB16IO_BitReadBack(1,2);
			 Etat=~Etat & 0x00000001;
			 TCUSB16IO_BitOutput(1,2,Etat);
			 i=TCUSB16IO_Refresh(1);
		 }
private: System::Void buttonS3_Click(System::Object^  sender, System::EventArgs^  e) {
			 long Etat=0;
			 int i=0;
			 //Lecture de l'etat de la sortie et inversion de sa commande
			 i=TCUSB16IO_Refresh(1);
			 Etat=TCUSB16IO_BitReadBack(1,3);
			 Etat=~Etat & 0x00000001;
			 TCUSB16IO_BitOutput(1,3,Etat);
			 i=TCUSB16IO_Refresh(1);
		 }
private: System::Void buttonS4_Click(System::Object^  sender, System::EventArgs^  e) {
			 long Etat=0;
			 int i=0;
			 //Lecture de l'etat de la sortie et inversion de sa commande
			 i=TCUSB16IO_Refresh(1);
			 Etat=TCUSB16IO_BitReadBack(1,4);
			 Etat=~Etat & 0x00000001;
			 TCUSB16IO_BitOutput(1,4,Etat);
			 i=TCUSB16IO_Refresh(1);
		 }
private: System::Void buttonS5_Click(System::Object^  sender, System::EventArgs^  e) {
			 long Etat=0;
			 int i=0;
			 //Lecture de l'etat de la sortie et inversion de sa commande
			 i=TCUSB16IO_Refresh(1);
			 Etat=TCUSB16IO_BitReadBack(1,5);
			 Etat=~Etat & 0x00000001;
			 TCUSB16IO_BitOutput(1,5,Etat);
			 i=TCUSB16IO_Refresh(1);
		 }
private: System::Void buttonS6_Click(System::Object^  sender, System::EventArgs^  e) {
			 long Etat=0;
			 int i=0;
			 //Lecture de l'etat de la sortie et inversion de sa commande
			 i=TCUSB16IO_Refresh(1);
			 Etat=TCUSB16IO_BitReadBack(1,6);
			 Etat=~Etat & 0x00000001;
			 TCUSB16IO_BitOutput(1,6,Etat);
			 i=TCUSB16IO_Refresh(1);
		 }
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
			 actualise();
		 }
private: System::Void button10_Click(System::Object^  sender, System::EventArgs^  e) {
			 //Raz de la position codeur & actualisation de l'affichage
			 TCUSB16IO_ResetPos(1);
			 actualise();
		 }
private: System::Void checkBoxZ_CheckStateChanged(System::Object^  sender, System::EventArgs^  e) {
			  //configuration du Topz (actif ou non)
			 int i=0;
			 if (checkBoxZ->Checked == true)
				TCUSB16IO_Config(1,0x08);
			 else
				TCUSB16IO_Config(1,0x00);
			 i=TCUSB16IO_Refresh(1);
		 }
private: System::Void timer2_Tick(System::Object^  sender, System::EventArgs^  e) {

			 TCUSB16IO_Output(1,DataOut);
			 TCUSB16IO_Refresh(1);
			 DataOut=DataOut<<1;
			 if (DataOut> 0x020) DataOut=0x01;
			 

		 }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 timer2->Enabled=true;
		 }
};
}

