Urgent SVP star de C#

hred1 Messages postés 108 Date d'inscription samedi 9 avril 2005 Statut Membre Dernière intervention 6 décembre 2007 - 8 mai 2006 à 02:12
mimic37 Messages postés 2 Date d'inscription mercredi 18 mars 2009 Statut Membre Dernière intervention 20 mars 2009 - 20 mars 2009 à 11:47
Bonjour,



Je test l'acquisition d'un signal en utilisant comme support le C#, donc j'arrive à acquirir mon signal

Par la suite je cherche le max de mon signal (amplitude) et l'abssice de ce max

mais je ne voix pas à quel moment je peux acceder aux valeurs du tableau des échantillons, afin d'effectuer ma routine calcul.

en fin je souhaite afficher cette valeur dans un text du form1, donc dois-je utiliser l'héritage ou autre chose...



voilà le code où figure une partie dont on cherche la FFT et pour mon max je doit faire comment

j'éspere que je suis claire et je vous remetci beaucoup....





// Description:

// You can use this DAQmx user
control to perform a continuous N-sample multichannel analog read.

// N is the number of samples per channel configured in the task.

//

// How to use the DAQmx user control on a Windows Form

// 1. Build the project.

// 2. Open the Toolbox and select My User Controls.

// 3. Drop your DAQmx user control on a form.

// 4. Call the Start method to run the task, as shown in the following example:

//

// userControl.Start();

//

// 5. Call the Stop method to end the task, as shown in the following example:

//

// userControl.Stop();

//

// How to use the DAQmx user control programmatically

// 1. Declare an instance of the class in your code without initializing its UI.

// Call its Start
method to run the task, as shown in the following example:

//

// DAQmxControl userControl = new DAQmxControl(false);

// userControl.Start();

//

// 2. Call the Stop method to end the task, as shown in the following example:

//

// userControl.Stop();



using System;

using System.Collections;

using System.ComponentModel;

using System.Drawing;

using System.Data;

using System.Windows.Forms;

using NationalInstruments.Analysis.Dsp;



namespace Data_Acquisition_in_CSharp

{

public class DAQmxControl : System.Windows.Forms.UserControl

{

public class TaskEventArgs : System.EventArgs

{

double[,] data;



public TaskEventArgs(double[,] d)

{

data = d;

}



public double[,] GetData() { return data; }

}



public delegate void EventHandler(object sender, TaskEventArgs args);



public event EventHandler DataReady;



private Data_Acquisition_in_CSharp.DAQmxTask1 daqmxTask;

private NationalInstruments.DAQmx.AnalogMultiChannelReader daqmxReader;

private System.AsyncCallback dataReadyHandler;



#region Fields



private bool stopped = true;

private NationalInstruments.UI.XAxis xAxis1;

private NationalInstruments.UI.YAxis yAxis1;

private NationalInstruments.UI.WaveformPlot waveformPlot1;

private NationalInstruments.UI.WindowsForms.WaveformGraph waveformGraph1;

private NationalInstruments.UI.WaveformPlot waveformPlot2;

private NationalInstruments.Net.DataSocket dataSocket1;

private NationalInstruments.UI.YAxis yAxis2;

private NationalInstruments.UI.XAxis xAxis2;

private System.ComponentModel.IContainer components = null;



#endregion



#region Constructors/Finalizers



public DAQmxControl()

{

// This call is required by the Windows.Forms Form Designer.

InitializeComponent();

this.DataReady += new EventHandler(this.OnDataReady);

}



public DAQmxControl(bool initializeUI)

{

if(initializeUI)

{

InitializeComponent();

}

this.DataReady += new EventHandler(this.OnDataReady);

CreateTask();

}



public DAQmxControl(IContainer container) : this()

{

container.Add(this);

CreateTask();

}



protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

CleanupTask();

}

base.Dispose( disposing );

}



#endregion



private void CreateTask()

{

if(daqmxTask != null)

return;

if(dataReadyHandler == null)


dataReadyHandler = new
System.AsyncCallback(DataReadyHandler);

daqmxTask = new Data_Acquisition_in_CSharp.DAQmxTask1();

daqmxReader =
new
NationalInstruments.DAQmx.AnalogMultiChannelReader(daqmxTask.Stream);

daqmxReader.SynchronizingObject = this;

}



private void CleanupTask()

{

if(daqmxTask != null)

{

Stop();

daqmxTask.Dispose();

}

}



public void Start()

{

if(!stopped)

return;

if(daqmxTask == null)

CreateTask();

daqmxTask.Start();

stopped = false;

daqmxReader.BeginReadMultiSample(100, dataReadyHandler, null);

}



public void Stop()

{

if(this.daqmxTask != null)

this.daqmxTask.Stop();

stopped = true;

}



public void DataReadyHandler(IAsyncResult result)

{

if(stopped)

return;

try

{


double[,] data =
daqmxReader.EndReadMultiSample(result);

DataReady(this, new TaskEventArgs(data));

}

catch(NationalInstruments.DAQmx.DaqException e)

{

MessageBox.Show(e.Message);

}

}



public virtual void OnDataReady(object sender, TaskEventArgs e)

{

double[,] data = e.GetData();

double[] SingleChannel = new double[100];

double[] FFTData = new double[50];



for(int i=0; i

3 réponses

rab33 Messages postés 63 Date d'inscription vendredi 6 mai 2005 Statut Membre Dernière intervention 11 mai 2006
8 mai 2006 à 07:20
salut

c pa necessairement d'ecrire toute le code, moi je trouve que ça
trop pour le lire et comprendre le code et detecte ou l'erreur,c
penible.

regarde, tu doit explique clairement ton problèmatique pour que les
autres puissent repondres a ta question sinon person va te repondre Ok!

j'espere que tu compris ca

Merci

Coll
0
TheSaib Messages postés 2367 Date d'inscription mardi 17 avril 2001 Statut Membre Dernière intervention 26 décembre 2007 23
13 mai 2006 à 00:09
Rien compris.

::|The S@ib|:: MVP C#.NET
0
mimic37 Messages postés 2 Date d'inscription mercredi 18 mars 2009 Statut Membre Dernière intervention 20 mars 2009
20 mars 2009 à 11:47
Merci d'avois mis tout ton code :p
Je ne saurais pas te dire quel est ton bug, mais moi qui débute avec le driver DAQMx et VB.NET, ton code va bien m'aider je pense
0
Rejoignez-nous