begin process at 2012 02 10 08:21:05
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C#

 > 

Archives

 > 

Au secours

 > 

Urgent SVP star de C#


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Urgent SVP star de C#

lundi 8 mai 2006 à 02:12:03 | Urgent SVP star de C#

hred1

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<100; i++)
                SingleChannel[i] = data[0,i];

            Transforms.PowerSpectrum(SingleChannel);

            for(int i=0; i<50; i++)
                FFTData[i] = SingleChannel[i];           
           
            #region Update UI
           
            if(waveformGraph1 != null)
            {
                waveformGraph1.PlotYMultiple(data);
                waveformPlot2.PlotY(FFTData, 0, 10);
            }
           
            #endregion

            dataSocket1.Data.Value = data;
           
            if(!stopped)
                daqmxReader.BeginReadMultiSample(100, dataReadyHandler, null);
        }

        #region Methods
       
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.waveformGraph1 = new NationalInstruments.UI.WindowsForms.WaveformGraph();
            this.waveformPlot1 = new NationalInstruments.UI.WaveformPlot();
            this.xAxis1 = new NationalInstruments.UI.XAxis();
            this.yAxis1 = new NationalInstruments.UI.YAxis();
            this.waveformPlot2 = new NationalInstruments.UI.WaveformPlot();
            this.dataSocket1 = new NationalInstruments.Net.DataSocket(this.components);
            this.yAxis2 = new NationalInstruments.UI.YAxis();
            this.xAxis2 = new NationalInstruments.UI.XAxis();
            ((System.ComponentModel.ISupportInitialize)(this.waveformGraph1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dataSocket1)).BeginInit();
            this.SuspendLayout();
            //
            // waveformGraph1
            //
            this.waveformGraph1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.waveformGraph1.Location = new System.Drawing.Point(0, 0);
            this.waveformGraph1.Name = "waveformGraph1";
            this.waveformGraph1.Plots.AddRange(new NationalInstruments.UI.WaveformPlot[] {
                                                                                             this.waveformPlot1,
                                                                                             this.waveformPlot2});
            this.waveformGraph1.Size = new System.Drawing.Size(192, 168);
            this.waveformGraph1.TabIndex = 0;
            this.waveformGraph1.XAxes.AddRange(new NationalInstruments.UI.XAxis[] {
                                                                                      this.xAxis1,
                                                                                      this.xAxis2});
            this.waveformGraph1.YAxes.AddRange(new NationalInstruments.UI.YAxis[] {
                                                                                      this.yAxis1,
                                                                                      this.yAxis2});
            //
            // waveformPlot1
            //
            this.waveformPlot1.XAxis = this.xAxis1;
            this.waveformPlot1.YAxis = this.yAxis1;
            //
            // xAxis1
            //
            this.xAxis1.Caption = "# of Samples/Frequency";
            //
            // waveformPlot2
            //
            this.waveformPlot2.LineColor = System.Drawing.Color.Red;
            this.waveformPlot2.XAxis = this.xAxis2;
            this.waveformPlot2.YAxis = this.yAxis2;
            //
            // dataSocket1
            //
            this.dataSocket1.AccessMode = NationalInstruments.Net.AccessMode.WriteAutoUpdate;
            this.dataSocket1.SynchronizingObject = this;
            this.dataSocket1.Url = "dstp://localhost/data";
            //
            // yAxis2
            //
            this.yAxis2.Visible = false;
            //
            // xAxis2
            //
            this.xAxis2.Mode = NationalInstruments.UI.AxisMode.Fixed;
            this.xAxis2.Range = new NationalInstruments.UI.Range(0, 100);
            this.xAxis2.Visible = false;
            //
            // DAQmxControl
            //
            this.Controls.Add(this.waveformGraph1);
            this.Name = "DAQmxControl";
            this.Size = new System.Drawing.Size(192, 168);
            ((System.ComponentModel.ISupportInitialize)(this.waveformGraph1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dataSocket1)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion
    }
}


RED1
lundi 8 mai 2006 à 07:20:26 | Re : Urgent SVP star de C#

rab33

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

samedi 13 mai 2006 à 00:09:34 | Re : Urgent SVP star de C#

TheSaib

Administrateur CodeS-SourceS
Rien compris.

::|The S@ib|:: MVP C#.NET
vendredi 20 mars 2009 à 11:47:41 | Re : Urgent SVP star de C#

mimic37

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




Cette discussion est classée dans : system, private, ui, nationalinstruments, waveformgraph1


Répondre à ce message

Sujets en rapport avec ce message

transfere les donnés dune bases acces dans un fichier txt [ par kmbmaster ] bonjour ,je suis debutant en c# jaimerais pouvoir transfere les donnés dune base (accesss) dans un fichier texte mais je n'y arrive pas ! est ce qun datagrid et edition de données [ par tobleronne ] Bonjour,j'essaye de faire une edition de donnée comme le prevois le framework, mais ca ne marche pas pourquoi ?!?<asp:DataGrid id="myDataGrid" runat=" Temps de copie [ par cpetter ] Bonsoir Je viens de créer une divxothèque et lors de la copie j'utilise 2 threads : 1 pour la copie et 1 pour l'affichage d'une progressbar. Pour l controls crée dynamiquement qui disparaissent au rafraichissement de la page [ par majoroupas ] Bonjour a tous, j'ai un petit problème, j'ai pensé a pleins de solutions de secours mais j'aimerai tout de même savoir si il y a pas une facon propre definir une url dans axWebBrowser [ par gfpl ] hello bon voila je sais comment on fait a partir d'une case de selection mais comment faire pour avoir tjs la meme page que l'utilisateur ne puisse p Probleme dans une classe SMTP en .NET 2 [ par walteau ] Bonsoir, je suis en pleine création d'une classe Smtp dont voici la source:using System;using System.Collections.Generic;using System.Text;using  m =S probleme avec IIS [ par Linux55 ] BonjourVoilà je crée un site avec visual web developer2005 express edition. Comme j'ai le IIS alors tous les fichiers liés au site sont regroupés dans Problème d'instanciation... [ par bofkill ] Salut à tous ! Bon, j'annonce la couleur en signalant que je suis un grooos noob en C#. La 1ere fois que j'y ai touché, c'était lundi ^^ J'ai une fen Problème procédures stockées [ par LOUTTY ] bonjou j'ai un problème avec ce code au niveau du SqlDataReader dr_user = cmd_req.ExecuteReader(); ya un problème ca me prends grave la tete alors mer connection à myql esyphp en C# [ par patou1007 ] Bonjour,J'ai installé easy php et j'ai créer une base de donées mysql avc phpadmin.Je travaille avec visual studio 2005 et je souhaiterais avoir un co


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,061 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales