▼Gainerメモ▼
アナログ入力


I/Oモジュールのアナログ入力を表示するプログラムを作成する。



ブレッドボード


ソースコード

AInForm.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 AInEx {
    public partial class AInForm : Form{
        private Gainer gio;

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

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

        //gspとの接続成功時に発生
        private void onReady() {
            lblAIn0.Visible=true;
            lblAIn1.Visible=true;
            lblAIn2.Visible=true;
            lblAIn3.Visible=true;
            timInput.Enabled=true;
        } 

        //定期処理
        private void timInput_Tick(object sender, EventArgs e) {
            gio.peekAnalogInput();
            if (gio.analogInput!=null) {
                lblAIn0.Text="ain0 "+gio.analogInput[0];
                lblAIn1.Text="ain1 "+gio.analogInput[1];
                lblAIn2.Text="ain2 "+gio.analogInput[2];
                lblAIn3.Text="ain3 "+gio.analogInput[3];
            }
        }
    }
}



−戻る−