Outils > Obtenir les outils et fonctionnalités Cocher > Développement .NET Desktop Modifier > Oui
Fichier > Nouveau > Projet Tous les langages > C# Toutes les plateformes > Windows Tous les types de projet > Bureau Modèle de projet > Application Windows Forms Suivant ... Nom de projet > OscilloscopeGUI Emplacement > v01 Nom de la solution > OscilloscopeGUI Suivant ... Infrasctructure > .NET 8.0 (Prise en charge à long terme) Créer
namespace OscilloscopeGUI { internal static class Program { [STAThread] static void Main() { ApplicationConfiguration.Initialize(); Application.Run(new Form1()); } } }
namespace OscilloscopeGUI { public partial class Form1 : Form { public Form1() { InitializeComponent(); } } }
Déboguer > Démarrer le débogage
Form1 > Clic droit > Renommer > FrmMain.cs > Oui
namespace OscilloscopeGUI { internal static class Program { [STAThread] static void Main() { ApplicationConfiguration.Initialize(); Application.Run(new FrmMain()); } } }
namespace OscilloscopeGUI { public partial class FrmMain : Form { public FrmMain() { InitializeComponent(); } } }
Déboguer > Démarrer le débogage
VSCode > Extensions > C# Dev Kit > Install
VSCode > C# > Sign In Allow
Email > youremail@domain.com > Suivant Mot de passe > your.account.password > Suivant
VSCode > C#
FrmMain.cs > Clic droit > Concepteur de vues FrmMain.cs > Clic droit > Propriétés ... Form > Props > Name > FrmMain Form > Props > Text > ReadyScope - Oscilloscope Numérique Form > Props > FormBorderStyle > FixedSingle Form > Props > Icon > data\img\app-logo.ico Form > Event > Load > FrmMain_Load Form > Event > FormClosing > FrmMain_FormClosing ... ComboBox > Props > Name > cmbResources ComboBox > Props > Anchor > Top, Left, Right ... Button > Props > Name > btnRefresh Button > Props > Text > &Refresh Button > Props > Anchor > Top, Left, Right Button > Event > Click > btnRefresh_Click ... Button > Props > Name > btnConnect Button > Props > Text > &Connect to selected device Button > Event > Click > btnConnect_Click ... GroupBox > Props > Name > grbAcquisition GroupBox > Props > Text > Acquisition GroupBox > Props > Anchor > Top, Left, Right ... Label > Props > Name > lblChannels Label > Props > Text > Channels ... CheckBox > Props > Name > chbChannel1 CheckBox > Props > Text > Channel 1 CheckBox > Props > Checked > True CheckBox > Event > CheckedChanged > UpdatePoints ... CheckBox > Props > Name > chbChannel2 CheckBox > Props > Text > Channel 2 CheckBox > Event > CheckedChanged > UpdatePoints ... Label > Props > Name > lblMemoryDepth Label > Props > Text > Memory Depth ... Panel > Props > Name > pnlMemoryDepth ... RadioButton > Props > Name > radNormalMemoryDepth RadioButton > Props > Text > Normal RadioButton > Props > Checked > True RadioButton > Event > CheckedChanged > UpdatePoints ... RadioButton > Props > Name > radLongMemoryDepth RadioButton > Props > Text > Long RadioButton > Event > CheckedChanged > UpdatePoints ... Label > Props > Name > lblPointsMode Label > Props > Text > Points Mode ... RadioButton > Props > Name > radNormalPointsMode RadioButton > Props > Text > Normal RadioButton > Props > Checked > True RadioButton > Event > CheckedChanged > UpdatePoints ... RadioButton > Props > Name > radMaximumPointsMode RadioButton > Props > Text > Maximum RadioButton > Event > CheckedChanged > UpdatePoints ... Label > Props > Name > lblPoints Label > Props > Text > Points ... Label > Props > Name > lblPointsValue Label > Props > Text > 600 ... Label > Props > Name > lblGnuPlotPath Label > Props > Text > Gnu Plot Path ... TextBox > Props > Name > txbGnuPlotPath TextBox > Props > Anchor > Top, Right ... Label > Props > Name > lblOutput Label > Props > Text > Output ... RadioButton > Props > Name > radGnuPlot RadioButton > Props > Text > Gnu Plot ... RadioButton > Props > Name > radPngImage RadioButton > Props > Text > PNG Image RadioButton > Props > Checked > True ... Button > Props > Name > btnSave Button > Props > Text > &Save CSV and output Button > Props > Anchor > Top, Bottom, Left, Right Button > Event > Click > btnSave_Click ...
Ajouter le fichier > data\img\app-logo.ico
namespace OscilloscopeGUI { internal static class Program { [STAThread] static void Main() { ApplicationConfiguration.Initialize(); Application.Run(new FrmMain()); } } }
namespace OscilloscopeGUI { public partial class FrmMain : Form { public FrmMain() { InitializeComponent(); } } }
Déboguer > Démarrer le débogage
namespace OscilloscopeGUI { public partial class FrmMain : Form { public FrmMain() { InitializeComponent(); } ... private void FrmMain_Load(object sender, EventArgs e) { RefreshDevices(); } ... private void btnRefresh_Click(object sender, EventArgs e) { RefreshDevices(); } ... private void RefreshDevices() { cmbResources.Items.Clear(); cmbResources.Items.AddRange(GetResources()); cmbResources.SelectedIndex = cmbResources.Items.Count - 1; } ... private string[] GetResources() { string[] results = new string[] { "Resource 1", "Resource 2", "Resource 3", }; return results; } } }
VSCode > Extensions > CSharpier - Code formatter > Install ... Enregistrer un fichier C# Le code du fichier C# est automatiquement formaté
Déboguer > Démarrer le débogage ... Les ressources sont bien chargée La dernière ressource est sélectionnée ... Sélectionner la première ressource (Resource 1) Cliquer sur le bouton (Refresh) ... Les ressources sont bien chargée La dernière ressource est sélectionnée
Fichier > Nouveau > Projet Tous les langages > C# Toutes les plateformes > Windows Tous les types de projet > Bureau Sélectionner > Bibliothèque de classes WPF Suivant ... Nom du projet > OscilloscopeLIB Emplacement > v02 Solution > OscilloscopeLIB Suivant ... Infrasctructure > .NET 8.0 (Prise en charge à long terme) Créer
Class1.cs > Clic droit > Renommer > Oscilloscope.cs > Oui
public class Oscilloscope { public static string[] GetResources() { string[] results = [ "Ressource 1", "Ressource 2", "Ressource 3" ]; return results; } }
Générer > Générer la solution
OscilloscopeGUI > Clic droit > Ajouter > Référence de projet Parcourir > OscilloscopeLIB\bin\Debug\net8.0-windows\OscilloscopeLIB.dll Ajouter > OK ... OscilloscopeGUI > Dépendances > Assemblys > OscilloscopeLIB
using OscilloscopeLIB; ... namespace OscilloscopeGUI { public partial class FrmMain : Form { ... private void FrmMain_Load(object sender, EventArgs e) { RefreshDevices(); } ... private void btnRefresh_Click(object sender, EventArgs e) { RefreshDevices(); } ... } private void RefreshDevices() { cmbResources.Items.Clear(); cmbResources.Items.AddRange(Oscilloscope.GetResources()); cmbResources.SelectedIndex = cmbResources.Items.Count - 1; } ... } }
Déboguer > Démarrer le débogage ... Les ressources sont bien chargée La dernière ressource est sélectionnée ... Sélectionner la première ressource (Resource 1) Cliquer sur le bouton (Refresh) ... Les ressources sont bien chargée La dernière ressource est sélectionnée
https://www.ni.com/en/support/downloads/drivers/download.ni-visa.html ... Supported OS > Windows Version > 2024 Q4 Download
ni-visa_24.8_online.exe > Double clic > Oui Cocher > Je accepte les 2 contrats de licence ci-dessus > Suivant Cocher > Désactivation du démarrage rapide de Windows Suivant > Suivant
Cocher > Installeur de certificats NI Cocher > NI I/O Trace Cocher > NI-VISA - Assistant de développement du driver Cocher > NI-VISA - Exemples C Cocher > NI-VISA - Moteur d'exécution pour.NET Cocher > NI-VISA - Support de configuration Cocher > NI-VISA - Support de développement .NET Cocher > NI-VISA Interactive Control Cocher > PXI Platform Services - Moteur d'exécution Suivant Cocher > Je accepte les 2 contrats de licence ci-dessus > Suivant Suivant > Suivant
OscilloscopeLIB > Clic droit > Ajouter > Référence de projet Parcourir > C:\Program Files (x86)\IVI Foundation\VISA\Microsoft.NET\Framework32\v4.0.30319\NI VISA.NET 24.8\ Nom du fichier > NationalInstruments.Visa.dll Ajouter > OK ... OscilloscopeLIB > Dépendances > Assemblys > NationalInstruments.Visa
OscilloscopeGUI > Clic droit > Ajouter > Référence de projet Parcourir > C:\Program Files (x86)\IVI Foundation\VISA\Microsoft.NET\Framework32\v2.0.50727\VISA.NET Shared Components 7.2.0\ Nom du fichier > Ivi.Visa.dll Ajouter > OK ... OscilloscopeGUI > Dépendances > Assemblys > Ivi.Visa
... namespace OscilloscopeGUI { public partial class FrmMain : Form { ... private void FrmMain_Load(object sender, EventArgs e) { RefreshDevices(); } ... private void RefreshDevices() { cmbResources.Items.Clear(); cmbResources.Items.AddRange(Oscilloscope.GetResources()); cmbResources.SelectedIndex = cmbResources.Items.Count - 1; } ... } }
using System.Diagnostics; using NationalInstruments.Visa; ... namespace OscilloscopeLIB { public class Oscilloscope { static ResourceManager _resManager = new ResourceManager(); ... public static string[] GetResources() { string[] results = new string[] { }; try { results = _resManager.Find("?*").ToArray(); } catch (Exception ex) { Debug.WriteLine(ex); } return results; } } }
Déboguer > Démarrer le débogage ... Les ressources sont bien chargée La dernière ressource est sélectionnée ... Sélectionner la première ressource (Resource 1) Cliquer sur le bouton (Refresh) ... Les ressources NI-VISA sont bien chargée La dernière ressource NI-VISA est sélectionnée
Visual Studio > Placer les points d'arrêt aux lignes souhaitées ... Cliquer sur le côté gauche d'une ligne pour placer un point d'arrêt
Déboguer > Démarrer le débogage ... La fenêtre principale s'affiche ... Cliquer sur le bouton (Connect to selected device) ... Le débogueur s'arrête au premier point d'arrêt ... Les contrôleurs de débogage s'affiche ... La pile des appels est accessible ... Le contenu des variables est accessible
Débogueur bloqué à un point d'arrêt ... Les contrôleurs de débogage s'affiche
Débogueur bloqué à un point d'arrêt ... Cliquer sur la liste déroulante > Frame de pile ... La pile des appels apparaît
Débogueur bloqué à un point d'arrêt ... Faire survoler la souris sur une variable ... Le contenu de la variable apparaît