▼Gainerメモ▼
アナログ出力


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



ブレッドボード



ソースコード

AOutForm.cs
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 AOutEx {
    public partial class AOutForm : Form{
        private Gainer  gio;
        private int[] aoutValue=new int[4];//アナログ出力値

        //コンストラクタ
        public AOutForm() {
            InitializeComponent();            
        }

        //ロード時の初期化
        private void AOutForm_Load(object sender, EventArgs e) {
            gio=new Gainer("localhost",2000,Gainer.MODE1,true);
            gio.onReady+=onReady;
        }

        //gspとの接続成功時に発生
        private void onReady() {
            nudAout0.Enabled=true;
            nudAout1.Enabled=true;
            nudAout2.Enabled=true;
            nudAout3.Enabled=true;
        }    

        //アナログ0値変更のイベント処理
        private void nudAout0_ValueChanged(object sender, EventArgs e) {
            aoutValue[0]=(int)nudAout0.Value;
            gio.analogOutput(aoutValue);
        }

        //アナログ1値変更のイベント処理
        private void nudAout1_ValueChanged(object sender, EventArgs e) {
            aoutValue[1]=(int)nudAout1.Value;
            gio.analogOutput(aoutValue);
        }

        //アナログ2値変更のイベント処理
        private void nudAout2_ValueChanged(object sender, EventArgs e) {
            aoutValue[2]=(int)nudAout2.Value;
            gio.analogOutput(aoutValue);
        }

        //アナログ3値変更のイベント処理
        private void nudAout3_ValueChanged(object sender, EventArgs e) {
            aoutValue[3]=(int)nudAout3.Value;
            gio.analogOutput(aoutValue);
        }    
    }
}



−戻る−