▼Gainerメモ▼
アナログ出力


I/Oモジュールのアナログ出力を行うプログラムを作成する。
クリックすることにより値が変化する。



ブレッドボード



ソースコード

AOutForm.vb
Public Class AOutForm
    Private gio As Gainer
    Private aoutValue(3) As Integer 'アナログ出力値

    'ロード時の初期化
    Private Sub AOutForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        gio = New Gainer("localhost", 2000, Gainer.MODE1, True)
        gio.onReady = AddressOf onReady
    End Sub

    'gspとの接続成功時に発生
    Private Sub onReady()
        nudAOut0.Enabled = True
        nudAOut1.Enabled = True
        nudAOut2.Enabled = True
        nudAOut3.Enabled = True
    End Sub

    'アナログ0値変更のイベント処理
    Private Sub nudAOut0_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudAOut0.ValueChanged
        aoutValue(0) = nudAOut0.Value
        gio.analogOutput(aoutValue)
    End Sub

    'アナログ1値変更のイベント処理
    Private Sub nudAOut1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudAOut1.ValueChanged
        aoutValue(1) = nudAOut1.Value
        gio.analogOutput(aoutValue)
    End Sub

    'アナログ2値変更のイベント処理
    Private Sub nudAOut2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudAOut2.ValueChanged
        aoutValue(2) = nudAOut2.Value
        gio.analogOutput(aoutValue)
    End Sub

    'アナログ3値変更のイベント処理
    Private Sub nudAOut3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudAOut3.ValueChanged
        aoutValue(3) = nudAOut3.Value
        gio.analogOutput(aoutValue)
    End Sub
End Class



−戻る−