DMM

A Fizipedia wikiből

Programming the Good Will Instek GDM 8246 digital multimeter using C# language. Fájl:DMM.zip

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            // Init COM port
            serialPort1.PortName = "COM1";
            serialPort1.BaudRate = 9600;
            serialPort1.DataBits = 8;
            serialPort1.StopBits = System.IO.Ports.StopBits.One;
            serialPort1.Parity = System.IO.Ports.Parity.None;
            serialPort1.Open();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            // Reads ID
            serialPort1.WriteLine("*idn?");
            IDtextBox.Text = serialPort1.ReadLine();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            // Reads Displayed Value
            serialPort1.WriteLine(":VAL?");
            ValuetextBox.Text = serialPort1.ReadLine();
        }
 
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Close Serial Port
            serialPort1.Close();
        }
    }
}