Bonjour à tous,
Je dois creer un prog en C++ qui lit des données acquises via un perif USB.
La partie acquisition du code m'a été donée par le fournisseur. Cependant il utilise une fenetre Windows et non la console...Je ne sais pas programmer ce genre de choses.
Grace à l'extrait de code, je peux cliquer sur un bouton start et afficher des mesures dans des tableaux.
J'aimerais faire un bouton SAVE et les sauvegarder dans un .Txt par exemple
Cependant je ne sais pas trop comment faire pour creer l'action lors du click
Voila l'exemple pour le bouton start :
this->cmdStart->Click += gcnew System::EventHandler(this, &Form1::cmdStart_Click);
De plus , je connais la methode classique avec les pointeurs etc pour sauvegarder mes tableaux mais là je ne vois pas trop comment faire. Code de la saisie dans les talbeaux, en cliquant sur start :
private: System::Void cmdStart_Click(System::Object^ sender, System::EventArgs^ e ) {
PaintEventArgs^ f;
System::Int32 Rate;
System::Int32 Count;
System::Int32 LowChan;
System::Int32 HighChan;
float MyData;
System::Int32 i;
System::Int32 j;
System::Int32 k;
System::Int32 FirstPoint = 0; // set first element in buffer to transfer to array
NumPoints = 10000; // Number of data points to collect
array <System::Int16> ^ ADData = gcnew array<System::Int16>(NumPoints);
for (i = 0 ; i < NumPoints ; i++){
ADData[i] = 0;
}
cmdStart->Enabled = false;
/////////////////////////////////////////////////// Z AXE /////////////////////////////////////////////////////////////////
Count = NumPoints;
Rate = 1000;
Acquisition :
ULStat = DaqBoard->AInScan( LowChan, HighChan, Count, Rate, Range, MemHandle, Options);
lblStatus->Text = ULStat->Message;
// Transfer the data from the memory buffer set up by Windows to an array
ULStat = MccDaq::MccService::WinBufToArray(MemHandle, ADData[0], FirstPoint, Count);
JE PENSE QUE LE TRANSFERT VERS UN .TXT SE FAIT LA MAIS JE NE SAIS PAS COMMENT
//ULStat = MccDaq::MccService::WinBufToArray(MemHandle, *MemHandle, FirstPoint, 10);
lblStatus->Text = ULStat->Message;
this->ARRAY1->Items->Clear();
this->ARRAY2->Items->Clear();
for(int i =0; i<NumPoints;i++)
{
lbxCounts->Items->Add(ADData[i]);
ULStat = DaqBoard->ToEngUnits(Range, ADData[i], MyData);
lbxVolts->Items->Add(MyData.ToString());
}
Comme vous pouvez le voir ce n'est pas tres conventionnel :)
Merci de votre aide