National Instruments 373392C-01 Manual de usuario Pagina 138

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 179
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 137
Chapter 5 Getting Started with Measurement Studio
Measurement Studio User Manual 5-34 ni.com
8. In Program.cs, add the following code to write an array of data to the
server:
[VB.NET]
Imports NationalInstruments.NetworkVariable
Imports System.Threading
Imports System
Module Module1
Private Function GenerateDoubleArray(ByVal phase As Double) As Double()
Dim values(999) As Double
Dim x As Integer
For x = 0 To 999
values(x) = Math.Sin(((2 * Math.PI * x) / 1000) + phase) * 2
Next x
Return values
End Function
Sub Main()
Const location As String = "\\localhost\system\double"
Dim bufferedWriter As NetworkVariableBufferedWriter(Of Double()) =
New NetworkVariableBufferedWriter(Of Double())(location)
bufferedWriter.Connect()
Dim phase As Integer = 0
While (True)
Dim values As Double() = GenerateDoubleArray(phase)
Console.WriteLine("Writing Array")
bufferedWriter.WriteValue(values)
Thread.Sleep(500)
phase = phase + 1
End While
End Sub
End Module
[C#]
using System;
using System.Threading;
using NationalInstruments.NetworkVariable;
namespace NetworkVariableWriter
{
class Program
{
private static double[] GenerateDoubleArray(double phase)
{
double[] values = new double[1000];
for (int x = 0; x < 1000; x++)
values[x] = Math.Sin(((2 * Math.PI * x) / 1000) + phase) * 2;
return values;
Vista de pagina 137
1 2 ... 133 134 135 136 137 138 139 140 141 142 143 ... 178 179

Comentarios a estos manuales

Sin comentarios