using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Globalization; using System.IO; using System.Windows.Forms; using LabJack; namespace AIN { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { } static void Main(string[] args) { Form1 sAIN = new Form1(); sAIN.performActions(); } private void button1_Click(object sender, EventArgs e) { void showErrorMessage(LJM.LJMException e) { textBox1.AppendText("LJMException: " + e.ToString()); textBox1.AppendText(e.StackTrace); } void performActions() { int handle = 0; int devType = 0; int conType = 0; int serNum = 0; int ipAddr = 0; int port = 0; int maxBytesPerMB = 0; string ipAddrStr = ""; try { //Open first found LabJack LJM.OpenS("ANY", "ANY", "ANY", ref handle); // Any device, Any connection, Any identifier //LJM.OpenS("T7", "ANY", "ANY", ref handle); // T7 device, Any connection, Any identifier //LJM.OpenS("T4", "ANY", "ANY", ref handle); // T4 device, Any connection, Any identifier //LJM.Open(LJM.CONSTANTS.dtANY, LJM.CONSTANTS.ctANY, "ANY", ref handle); // Any device, Any connection, Any identifier LJM.GetHandleInfo(handle, ref devType, ref conType, ref serNum, ref ipAddr, ref port, ref maxBytesPerMB); LJM.NumberToIP(ipAddr, ref ipAddrStr); textBox1.AppendText("Opened a LabJack with Device type: " + devType + ", Connection type: " + conType + ","); textBox1.AppendText(Environment.NewLine); textBox1.AppendText("Serial number: " + serNum + ", IP address: " + ipAddrStr + ", Port: " + port + ","); textBox1.AppendText(Environment.NewLine); textBox1.AppendText("Max bytes per MB: " + maxBytesPerMB); textBox1.AppendText(Environment.NewLine); //Setup and call eReadName to read from an AIN on the LabJack. string name = "AIN0"; double value = 0; LJM.eReadName(handle, name, ref value); textBox1.AppendText("\n" + name + " reading : " + value.ToString("F4") + " V"); } catch (LJM.LJMException e) { showErrorMessage(e); } LJM.CloseAll(); //Close all handles textBox1.AppendText("\nDone.\nPress the enter key to exit."); Console.ReadLine(); //Pause for user } } } }