1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
| #pragma once
#include <string>
#include<windows.h>
#include "Unit_cfz.h"
namespace SoftSonde {
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
//
}
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ Connexionbutton;
private: System::Windows::Forms::Button^ Deconnexionbutton;
private: System::Windows::Forms::GroupBox^ groupBox1;
public: System::Windows::Forms::RichTextBox^ richTextBox1;
protected:
private:
/// <summary>
/// Variable nécessaire au concepteur.
/// </summary>
System::ComponentModel::Container ^components;
#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>
public:
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->Connexionbutton = (gcnew System::Windows::Forms::Button());
this->Deconnexionbutton = (gcnew System::Windows::Forms::Button());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
this->groupBox1->SuspendLayout();
this->SuspendLayout();
//
// Connexionbutton
//
resources->ApplyResources(this->Connexionbutton, L"Connexionbutton");
this->Connexionbutton->Name = L"Connexionbutton";
this->Connexionbutton->UseVisualStyleBackColor = true;
this->Connexionbutton->Click += gcnew System::EventHandler(this, &Form1::Connexionbutton_Click);
//
// Deconnexionbutton
//
resources->ApplyResources(this->Deconnexionbutton, L"Deconnexionbutton");
this->Deconnexionbutton->Name = L"Deconnexionbutton";
this->Deconnexionbutton->UseVisualStyleBackColor = true;
this->Deconnexionbutton->Click += gcnew System::EventHandler(this, &Form1::Deconnexionbutton_Click);
//
// groupBox1
//
this->groupBox1->Controls->Add(this->Deconnexionbutton);
this->groupBox1->Controls->Add(this->Connexionbutton);
resources->ApplyResources(this->groupBox1, L"groupBox1");
this->groupBox1->Name = L"groupBox1";
this->groupBox1->TabStop = false;
//
// richTextBox1
//
this->richTextBox1->AccessibleRole = System::Windows::Forms::AccessibleRole::Dialog;
this->richTextBox1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
resources->ApplyResources(this->richTextBox1, L"richTextBox1");
this->richTextBox1->Name = L"richTextBox1";
this->richTextBox1->TextChanged += gcnew System::EventHandler(this, &Form1::richTextBox1_TextChanged);
//
// Form1
//
resources->ApplyResources(this, L"$this");
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::ActiveCaptionText;
this->Controls->Add(this->richTextBox1);
this->Controls->Add(this->groupBox1);
this->Name = L"Form1";
this->groupBox1->ResumeLayout(false);
this->ResumeLayout(false);
}
private:
#pragma endregion
private: System::Void Connexionbutton_Click(System::Object^ sender, System::EventArgs^ e)
{
//Declaration des variables
bool libraryload = false;
bool Connexionstatus = false;
bool EnumconnectedDevice = false;
unsigned int NumPort = 0;
std::string Serialnumber = "";
int i = 0;
int Debug = 0;
//Affichage d'evenement dans la text box
richTextBox1->Text = " Initialisation ";
Sleep(5000);
//Chargement de la DLL
while (i !=2)
{
libraryload = load_library("unit_cfz.dll\0");
switch (libraryload)
{
case true :
i=2;
Debug=0;
richTextBox1->Text=" Chargement de la librairie réussi";
case false :
i=i+1;
Debug=+1;
richTextBox1->Text=" Echec charchement librairie, nouvel essai en cours";
}
}
Sleep(6000);
//Recherche du port
NumPort = get_enumerated_number_of_ports(PortType_USBMultilink);
Serialnumber = get_port_descriptor(PortType_USBMultilink,NumPort);
//Ouverture du port
Connexionstatus = open_port(PortType_USBMultilink,NumPort);
reset_hardware_interface( );
//Paramètrage de la vitesse
set_bdm_shift_speed(33333);
//Passage a l'arrière plan
force_background_mode( );
richTextBox1->Text= " Connexion OK "; |
Partager