Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            double        max             = 0;
            List <double> data_a_regarder = new List <double>();
            bool          trouve          = false;

            for (int i = 0, j = 0; i < measuredData[0].Length; i++)
            {
                if (measuredData[0][i] > max)
                {
                    max = measuredData[0][i];
                }

                if (measuredData[0][i] >= 2 && !trouve)
                {
                    data_a_regarder.Add(i);
                    j++;
                    trouve = true;
                }

                if (measuredData[0][i] <= 2 && trouve)
                {
                    trouve = false;
                }
            }

            comboBox1.Items.Clear();
            foreach (double index in data_a_regarder)
            {
                comboBox1.Items.Add(index);
                Console.WriteLine(index);
            }
            comboBox1.Items.Insert(0, "Vue d'ensemble");
            comboBox1.SelectedIndex = 0;

            measuredData = Traitement.supressionBruit(measuredData);

            // Affichage des courbes :
            waveformPlot1.PlotY(measuredData[0]);
            waveformPlot2.PlotY(measuredData[1]);
            waveformPlot3.PlotY(measuredData[2]);

            // Affichage d'un message flash dans la bar de status:
            Thread affiche = new Thread(new ParameterizedThreadStart(MessageFlash));

            affiche.Start("Fichiers ouverts");

            // Activation des menus Affichage et Analyse
            affichageToolStripMenuItem.Enabled = true;
            analyseToolStripMenuItem.Enabled   = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fonction gérant l'ouverture des fichiers et l'affichages des courbes
        /// </summary>
        private void openAndReadFiles()
        {
            // Déclaration des variables
            String[]                   input;
            OpenFileDialog             dialog = new OpenFileDialog();
            TdmsChannelGroupCollection channelGroups;
            TdmsChannelCollection      channels;
            long numChanValues;

            //Clear de la liste des fichiers
            files.Clear();
            comboBox1.DataSource = null;
            comboBox1.Enabled    = false;

            dialog.Filter           = "tdms files (*.tdms)|*.tdms|All files (*.*)|*.*";
            dialog.Multiselect      = true;
            dialog.InitialDirectory = "C:";
            dialog.Title            = "Select a tdms file";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                input = dialog.FileNames;
                Console.WriteLine(input.Length + " fichier(s) ouvert(s)");
                if (input.Length == 3)
                {
                    //Open TDMS file
                    for (int i = 0; i < input.Length; i++)
                    {
                        files.Add(new TdmsFile(input[i], TdmsFileAccess.Read));
                        Console.WriteLine("FILE[" + i + "] = " + files[i].Path);
                        // Recupération des métadata :
                        DateTime creationTime = File.GetLastWriteTime(files[i].Path);
                        Console.WriteLine("FILE[" + i + "] CREATION = " + creationTime);
                    }



                    // Lecture des données TDMS
                    for (int i = 0; i < files.Count; i++)
                    {
                        channelGroups   = files[i].GetChannelGroups();
                        channels        = channelGroups[0].GetChannels();
                        numChanValues   = channels[0].DataCount;
                        measuredData[i] = channels[0].GetData <double>();
                        files[i].Close();
                    }

                    measuredData = Traitement.supressionBruit(measuredData);
                    measuredData = Traitement.filtreMoyenne(measuredData);

                    for (int i = 0; i < measuredData.Length; i++)
                    {
                        measuredData[i] = Traitement.filtreMedian(measuredData[i], 150);
                        Console.WriteLine("Application du filtre median");
                    }

                    // Affichage des courbes
                    waveformGraph1.XAxes[0].Mode  = AxisMode.Fixed;
                    waveformGraph1.XAxes[0].Range = new NationalInstruments.UI.Range(0, measuredData[0].Length);
                    waveformPlot1.PlotY(measuredData[0]);
                    waveformPlot2.PlotY(measuredData[1]);
                    waveformPlot3.PlotY(measuredData[2]);

                    // Affichage d'un message flash dans la bar de status
                    Thread affiche = new Thread(new ParameterizedThreadStart(MessageFlash));
                    affiche.Start("Fichiers ouverts");

                    // Activation des menus Affichage et Analyse ainsi que le bouton d'analyse
                    //button1.Enabled = true;
                    affichageToolStripMenuItem.Enabled = true;
                    analyseToolStripMenuItem.Enabled   = true;
                }
                else
                {
                    MessageBox.Show("Vous devez sélectionner les trois fichiers du plateau!", "Erreur de sélection");
                }
            }
        }