public static void ThrowErrorMessage(string msg, int errorCode) { StringBuilder errorString = new StringBuilder(50); LabJack.GetErrorString(errorCode, errorString); throw new Exception(msg + ":\r\n\r\n" + errorString); }
//--------------------------------------------------------------------- // AIStream // public void AIStream() { int error; int ljID = -1; int demo = 1, numChannels = 4, disableCal = 0; int[] channels = { 0, 1, 2, 3 }; int[] gains = { 0, 0, 0, 0 }; float sr = 250.0F; int numScans = 250, timeout = 10; float[,] voltages = new float[4096, 4]; int[] stateIOout = new int[4096]; int ljb = -1; int ov = -1; int numIts = 5; int reserved = 0; Console.WriteLine("AIStream"); error = LabJack.AIStreamStart(ref ljID, demo, 0, 0, 1, numChannels, channels, gains, ref sr, disableCal, 0, 0); if (error != 0) { richTextBox3.AppendText("AIStreamStart Error: " + error + "\r\n"); } int i = 0; while ((error == 0) && (i < numIts)) { for (int j = 0; j < 400; j++) { stateIOout[j] = 0; voltages[j, 3] = 0; //for (int k = 0; k < 4; k++) //{ //} double time = (double)j / numSample; chart3.Series["Second Harmonic"].Points.AddXY(time, voltages[0, 2]); } error = LabJack.AIStreamRead(ljID, numScans, timeout, voltages, stateIOout, ref reserved, ref ljb, ref ov); if (error != 0) { StringBuilder sb = new StringBuilder(); LabJack.GetErrorString(error, sb); richTextBox3.AppendText("AIStreamRead Error: " + sb + "\r\n"); } //richTextBox3.AppendText("1st Scan: V1="+ voltages[0, 0]+", V2="+ voltages[0, 1]+", V3="+ voltages[0, 2]+", V4="+ voltages[0, 3]+"\r\n"); richTextBox3.AppendText("1st Scan: V3=" + voltages[0, 2] + "\r\n"); richTextBox3.AppendText("LabJack Scan Backlog = " + ljb + "\r\n"); i++; chart3.ChartAreas["ChartArea1"].AxisX.Minimum = 0; chart3.ChartAreas["ChartArea1"].AxisX.RoundAxisValues(); } LabJack.AIStreamClear(ljID); }