using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.Globalization;

namespace SimpleIO
{
	/// <summary>
	/// Form1 ̊Tv̐łB
	/// </summary>
	public class SimpleIO : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.Label Label5;
		internal System.Windows.Forms.GroupBox GroupBox4;
		internal System.Windows.Forms.Label Label12;
		internal System.Windows.Forms.Label Label13;
		internal System.Windows.Forms.GroupBox GroupBox2;
		internal System.Windows.Forms.Label Label6;
		internal System.Windows.Forms.Label Label7;
		internal System.Windows.Forms.GroupBox GroupBox1;
		internal System.Windows.Forms.Label Label4;
		internal System.Windows.Forms.Label Label3;
		internal System.Windows.Forms.Label Label2;
		internal System.Windows.Forms.Label Label1;
		internal System.Windows.Forms.GroupBox GroupBox3;
		internal System.Windows.Forms.Label Label8;
		internal System.Windows.Forms.Label Label9;
		internal System.Windows.Forms.Label Label10;
		internal System.Windows.Forms.TextBox txtReturnCode;
		internal System.Windows.Forms.Button btnExit;
		internal System.Windows.Forms.Button btnDioExit;
		internal System.Windows.Forms.Button btnDioInit;
		internal System.Windows.Forms.Button btnEchoBackBit;
		internal System.Windows.Forms.Button btnOutBit;
		internal System.Windows.Forms.TextBox txtOutBitData;
		internal System.Windows.Forms.TextBox txtOutBitNo;
		internal System.Windows.Forms.Button btnInpBit;
		internal System.Windows.Forms.TextBox txtInpBitData;
		internal System.Windows.Forms.TextBox txtInpBitNo;
		internal System.Windows.Forms.Button btnInpByte;
		internal System.Windows.Forms.TextBox txtInpPortData;
		internal System.Windows.Forms.TextBox txtInpPortNo;
		internal System.Windows.Forms.ComboBox cboDeviceName;
		internal System.Windows.Forms.Button btnEchoBackByte;
		internal System.Windows.Forms.Button btnOutByte;
		internal System.Windows.Forms.TextBox txtOutPortData;
		internal System.Windows.Forms.TextBox txtOutPortNo;
		/// <summary>
		/// KvȃfUCiϐłB
		/// </summary>
		private System.ComponentModel.Container components = null;
		// ǉf[^
		short			Id;											// foCXID
		int				Ret;										// ߂l
		StringBuilder	szError = new StringBuilder("", 256);		// G[
		string			szReturnCode = new string(' ', 256);		// \G[
		string			szText = new string(' ', 100);

		public SimpleIO()
		{
			//
			// Windows tH[ fUCi T|[gɕKvłB
			//
			InitializeComponent();

			//
			// TODO: InitializeComponent ĂяǒɁARXgN^ R[hǉĂB
			//
		}

		/// <summary>
		/// gpĂ郊\[XɌ㏈s܂B
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// fUCi T|[gɕKvȃ\bhłB̃\bh̓e
		/// R[h GfB^ŕύXȂłB
		/// </summary>
		private void InitializeComponent()
		{
			this.txtReturnCode = new System.Windows.Forms.TextBox();
			this.Label5 = new System.Windows.Forms.Label();
			this.btnExit = new System.Windows.Forms.Button();
			this.btnDioExit = new System.Windows.Forms.Button();
			this.btnDioInit = new System.Windows.Forms.Button();
			this.GroupBox4 = new System.Windows.Forms.GroupBox();
			this.btnEchoBackBit = new System.Windows.Forms.Button();
			this.btnOutBit = new System.Windows.Forms.Button();
			this.txtOutBitData = new System.Windows.Forms.TextBox();
			this.txtOutBitNo = new System.Windows.Forms.TextBox();
			this.Label12 = new System.Windows.Forms.Label();
			this.Label13 = new System.Windows.Forms.Label();
			this.GroupBox2 = new System.Windows.Forms.GroupBox();
			this.btnInpBit = new System.Windows.Forms.Button();
			this.txtInpBitData = new System.Windows.Forms.TextBox();
			this.txtInpBitNo = new System.Windows.Forms.TextBox();
			this.Label6 = new System.Windows.Forms.Label();
			this.Label7 = new System.Windows.Forms.Label();
			this.GroupBox1 = new System.Windows.Forms.GroupBox();
			this.btnInpByte = new System.Windows.Forms.Button();
			this.txtInpPortData = new System.Windows.Forms.TextBox();
			this.txtInpPortNo = new System.Windows.Forms.TextBox();
			this.Label4 = new System.Windows.Forms.Label();
			this.Label3 = new System.Windows.Forms.Label();
			this.Label2 = new System.Windows.Forms.Label();
			this.cboDeviceName = new System.Windows.Forms.ComboBox();
			this.Label1 = new System.Windows.Forms.Label();
			this.GroupBox3 = new System.Windows.Forms.GroupBox();
			this.btnEchoBackByte = new System.Windows.Forms.Button();
			this.btnOutByte = new System.Windows.Forms.Button();
			this.txtOutPortData = new System.Windows.Forms.TextBox();
			this.txtOutPortNo = new System.Windows.Forms.TextBox();
			this.Label8 = new System.Windows.Forms.Label();
			this.Label9 = new System.Windows.Forms.Label();
			this.Label10 = new System.Windows.Forms.Label();
			this.GroupBox4.SuspendLayout();
			this.GroupBox2.SuspendLayout();
			this.GroupBox1.SuspendLayout();
			this.GroupBox3.SuspendLayout();
			this.SuspendLayout();
			// 
			// txtReturnCode
			// 
			this.txtReturnCode.Location = new System.Drawing.Point(70, 335);
			this.txtReturnCode.Name = "txtReturnCode";
			this.txtReturnCode.Size = new System.Drawing.Size(288, 19);
			this.txtReturnCode.TabIndex = 7;
			this.txtReturnCode.Text = "";
			// 
			// Label5
			// 
			this.Label5.Location = new System.Drawing.Point(14, 338);
			this.Label5.Name = "Label5";
			this.Label5.Size = new System.Drawing.Size(72, 16);
			this.Label5.TabIndex = 27;
			this.Label5.Text = "߂lF";
			// 
			// btnExit
			// 
			this.btnExit.Location = new System.Drawing.Point(366, 362);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(105, 24);
			this.btnExit.TabIndex = 6;
			this.btnExit.Text = "Exit";
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// btnDioExit
			// 
			this.btnDioExit.Location = new System.Drawing.Point(366, 330);
			this.btnDioExit.Name = "btnDioExit";
			this.btnDioExit.Size = new System.Drawing.Size(105, 24);
			this.btnDioExit.TabIndex = 5;
			this.btnDioExit.Text = "DioExit";
			this.btnDioExit.Click += new System.EventHandler(this.btnDioExit_Click);
			// 
			// btnDioInit
			// 
			this.btnDioInit.Location = new System.Drawing.Point(366, 10);
			this.btnDioInit.Name = "btnDioInit";
			this.btnDioInit.Size = new System.Drawing.Size(105, 24);
			this.btnDioInit.TabIndex = 0;
			this.btnDioInit.Text = "DioInit";
			this.btnDioInit.Click += new System.EventHandler(this.btnDioInit_Click);
			// 
			// GroupBox4
			// 
			this.GroupBox4.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.btnEchoBackBit,
																					this.btnOutBit,
																					this.txtOutBitData,
																					this.txtOutBitNo,
																					this.Label12,
																					this.Label13});
			this.GroupBox4.Location = new System.Drawing.Point(14, 258);
			this.GroupBox4.Name = "GroupBox4";
			this.GroupBox4.Size = new System.Drawing.Size(580, 60);
			this.GroupBox4.TabIndex = 4;
			this.GroupBox4.TabStop = false;
			this.GroupBox4.Text = "Prbgo";
			// 
			// btnEchoBackBit
			// 
			this.btnEchoBackBit.Location = new System.Drawing.Point(464, 21);
			this.btnEchoBackBit.Name = "btnEchoBackBit";
			this.btnEchoBackBit.Size = new System.Drawing.Size(105, 24);
			this.btnEchoBackBit.TabIndex = 14;
			this.btnEchoBackBit.Text = "DioEchoBackBit";
			this.btnEchoBackBit.Click += new System.EventHandler(this.btnEchoBackBit_Click);
			// 
			// btnOutBit
			// 
			this.btnOutBit.Location = new System.Drawing.Point(352, 21);
			this.btnOutBit.Name = "btnOutBit";
			this.btnOutBit.Size = new System.Drawing.Size(105, 24);
			this.btnOutBit.TabIndex = 13;
			this.btnOutBit.Text = "DioOutBit";
			this.btnOutBit.Click += new System.EventHandler(this.btnOutBit_Click);
			// 
			// txtOutBitData
			// 
			this.txtOutBitData.Location = new System.Drawing.Point(236, 24);
			this.txtOutBitData.Name = "txtOutBitData";
			this.txtOutBitData.Size = new System.Drawing.Size(48, 19);
			this.txtOutBitData.TabIndex = 12;
			this.txtOutBitData.Text = "TextBox2";
			// 
			// txtOutBitNo
			// 
			this.txtOutBitNo.Location = new System.Drawing.Point(100, 23);
			this.txtOutBitNo.Name = "txtOutBitNo";
			this.txtOutBitNo.Size = new System.Drawing.Size(48, 19);
			this.txtOutBitNo.TabIndex = 11;
			this.txtOutBitNo.Text = "TextBox1";
			// 
			// Label12
			// 
			this.Label12.Location = new System.Drawing.Point(170, 27);
			this.Label12.Name = "Label12";
			this.Label12.Size = new System.Drawing.Size(72, 16);
			this.Label12.TabIndex = 2;
			this.Label12.Text = "o̓f[^F";
			// 
			// Label13
			// 
			this.Label13.Location = new System.Drawing.Point(10, 27);
			this.Label13.Name = "Label13";
			this.Label13.Size = new System.Drawing.Size(96, 16);
			this.Label13.TabIndex = 1;
			this.Label13.Text = "_rbgԍF";
			// 
			// GroupBox2
			// 
			this.GroupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.btnInpBit,
																					this.txtInpBitData,
																					this.txtInpBitNo,
																					this.Label6,
																					this.Label7});
			this.GroupBox2.Location = new System.Drawing.Point(14, 114);
			this.GroupBox2.Name = "GroupBox2";
			this.GroupBox2.Size = new System.Drawing.Size(580, 60);
			this.GroupBox2.TabIndex = 2;
			this.GroupBox2.TabStop = false;
			this.GroupBox2.Text = "Prbg";
			// 
			// btnInpBit
			// 
			this.btnInpBit.Location = new System.Drawing.Point(352, 21);
			this.btnInpBit.Name = "btnInpBit";
			this.btnInpBit.Size = new System.Drawing.Size(105, 24);
			this.btnInpBit.TabIndex = 6;
			this.btnInpBit.Text = "DioInpBit";
			this.btnInpBit.Click += new System.EventHandler(this.btnInpBit_Click);
			// 
			// txtInpBitData
			// 
			this.txtInpBitData.Location = new System.Drawing.Point(236, 24);
			this.txtInpBitData.Name = "txtInpBitData";
			this.txtInpBitData.Size = new System.Drawing.Size(48, 19);
			this.txtInpBitData.TabIndex = 5;
			this.txtInpBitData.Text = "";
			// 
			// txtInpBitNo
			// 
			this.txtInpBitNo.Location = new System.Drawing.Point(100, 23);
			this.txtInpBitNo.Name = "txtInpBitNo";
			this.txtInpBitNo.Size = new System.Drawing.Size(48, 19);
			this.txtInpBitNo.TabIndex = 4;
			this.txtInpBitNo.Text = "TextBox1";
			// 
			// Label6
			// 
			this.Label6.Location = new System.Drawing.Point(170, 27);
			this.Label6.Name = "Label6";
			this.Label6.Size = new System.Drawing.Size(72, 16);
			this.Label6.TabIndex = 2;
			this.Label6.Text = "̓f[^F";
			// 
			// Label7
			// 
			this.Label7.Location = new System.Drawing.Point(10, 27);
			this.Label7.Name = "Label7";
			this.Label7.Size = new System.Drawing.Size(96, 16);
			this.Label7.TabIndex = 1;
			this.Label7.Text = "_rbgԍF";
			// 
			// GroupBox1
			// 
			this.GroupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.btnInpByte,
																					this.txtInpPortData,
																					this.txtInpPortNo,
																					this.Label4,
																					this.Label3,
																					this.Label2});
			this.GroupBox1.Location = new System.Drawing.Point(14, 42);
			this.GroupBox1.Name = "GroupBox1";
			this.GroupBox1.Size = new System.Drawing.Size(580, 60);
			this.GroupBox1.TabIndex = 1;
			this.GroupBox1.TabStop = false;
			this.GroupBox1.Text = "P|[g";
			// 
			// btnInpByte
			// 
			this.btnInpByte.Location = new System.Drawing.Point(352, 21);
			this.btnInpByte.Name = "btnInpByte";
			this.btnInpByte.Size = new System.Drawing.Size(105, 24);
			this.btnInpByte.TabIndex = 3;
			this.btnInpByte.Text = "DioInpByte";
			this.btnInpByte.Click += new System.EventHandler(this.btnInpByte_Click);
			// 
			// txtInpPortData
			// 
			this.txtInpPortData.Location = new System.Drawing.Point(236, 24);
			this.txtInpPortData.Name = "txtInpPortData";
			this.txtInpPortData.Size = new System.Drawing.Size(48, 19);
			this.txtInpPortData.TabIndex = 2;
			this.txtInpPortData.Text = "";
			// 
			// txtInpPortNo
			// 
			this.txtInpPortNo.Location = new System.Drawing.Point(100, 23);
			this.txtInpPortNo.Name = "txtInpPortNo";
			this.txtInpPortNo.Size = new System.Drawing.Size(48, 19);
			this.txtInpPortNo.TabIndex = 1;
			this.txtInpPortNo.Text = "TextBox1";
			// 
			// Label4
			// 
			this.Label4.Location = new System.Drawing.Point(290, 27);
			this.Label4.Name = "Label4";
			this.Label4.Size = new System.Drawing.Size(56, 16);
			this.Label4.TabIndex = 3;
			this.Label4.Text = "(16i)";
			// 
			// Label3
			// 
			this.Label3.Location = new System.Drawing.Point(170, 27);
			this.Label3.Name = "Label3";
			this.Label3.Size = new System.Drawing.Size(72, 16);
			this.Label3.TabIndex = 2;
			this.Label3.Text = "̓f[^F";
			// 
			// Label2
			// 
			this.Label2.Location = new System.Drawing.Point(10, 27);
			this.Label2.Name = "Label2";
			this.Label2.Size = new System.Drawing.Size(96, 16);
			this.Label2.TabIndex = 1;
			this.Label2.Text = "_|[gԍF";
			// 
			// cboDeviceName
			// 
			this.cboDeviceName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboDeviceName.Location = new System.Drawing.Point(86, 10);
			this.cboDeviceName.Name = "cboDeviceName";
			this.cboDeviceName.Size = new System.Drawing.Size(213, 20);
			this.cboDeviceName.TabIndex = 8;
			// 
			// Label1
			// 
			this.Label1.Location = new System.Drawing.Point(14, 14);
			this.Label1.Name = "Label1";
			this.Label1.Size = new System.Drawing.Size(72, 16);
			this.Label1.TabIndex = 20;
			this.Label1.Text = "foCXF";
			// 
			// GroupBox3
			// 
			this.GroupBox3.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.btnEchoBackByte,
																					this.btnOutByte,
																					this.txtOutPortData,
																					this.txtOutPortNo,
																					this.Label8,
																					this.Label9,
																					this.Label10});
			this.GroupBox3.Location = new System.Drawing.Point(14, 186);
			this.GroupBox3.Name = "GroupBox3";
			this.GroupBox3.Size = new System.Drawing.Size(580, 60);
			this.GroupBox3.TabIndex = 3;
			this.GroupBox3.TabStop = false;
			this.GroupBox3.Text = "P|[go";
			// 
			// btnEchoBackByte
			// 
			this.btnEchoBackByte.Location = new System.Drawing.Point(464, 21);
			this.btnEchoBackByte.Name = "btnEchoBackByte";
			this.btnEchoBackByte.Size = new System.Drawing.Size(105, 24);
			this.btnEchoBackByte.TabIndex = 10;
			this.btnEchoBackByte.Text = "DioEchoBackByte";
			this.btnEchoBackByte.Click += new System.EventHandler(this.btnEchoBackByte_Click);
			// 
			// btnOutByte
			// 
			this.btnOutByte.Location = new System.Drawing.Point(352, 21);
			this.btnOutByte.Name = "btnOutByte";
			this.btnOutByte.Size = new System.Drawing.Size(105, 24);
			this.btnOutByte.TabIndex = 9;
			this.btnOutByte.Text = "DioOutByte";
			this.btnOutByte.Click += new System.EventHandler(this.btnOutByte_Click);
			// 
			// txtOutPortData
			// 
			this.txtOutPortData.Location = new System.Drawing.Point(236, 24);
			this.txtOutPortData.Name = "txtOutPortData";
			this.txtOutPortData.Size = new System.Drawing.Size(48, 19);
			this.txtOutPortData.TabIndex = 8;
			this.txtOutPortData.Text = "TextBox2";
			// 
			// txtOutPortNo
			// 
			this.txtOutPortNo.Location = new System.Drawing.Point(100, 23);
			this.txtOutPortNo.Name = "txtOutPortNo";
			this.txtOutPortNo.Size = new System.Drawing.Size(48, 19);
			this.txtOutPortNo.TabIndex = 7;
			this.txtOutPortNo.Text = "TextBox1";
			// 
			// Label8
			// 
			this.Label8.Location = new System.Drawing.Point(290, 27);
			this.Label8.Name = "Label8";
			this.Label8.Size = new System.Drawing.Size(56, 16);
			this.Label8.TabIndex = 3;
			this.Label8.Text = "(16i)";
			// 
			// Label9
			// 
			this.Label9.Location = new System.Drawing.Point(170, 27);
			this.Label9.Name = "Label9";
			this.Label9.Size = new System.Drawing.Size(72, 16);
			this.Label9.TabIndex = 2;
			this.Label9.Text = "o̓f[^F";
			// 
			// Label10
			// 
			this.Label10.Location = new System.Drawing.Point(10, 27);
			this.Label10.Name = "Label10";
			this.Label10.Size = new System.Drawing.Size(96, 16);
			this.Label10.TabIndex = 1;
			this.Label10.Text = "_|[gԍF";
			// 
			// SimpleIO
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
			this.ClientSize = new System.Drawing.Size(608, 397);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.txtReturnCode,
																		  this.Label5,
																		  this.btnExit,
																		  this.btnDioExit,
																		  this.btnDioInit,
																		  this.GroupBox4,
																		  this.GroupBox2,
																		  this.GroupBox1,
																		  this.cboDeviceName,
																		  this.Label1,
																		  this.GroupBox3});
			this.Font = new System.Drawing.Font("lr oSVbN", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(128)));
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "SimpleIO";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Po";
			this.Load += new System.EventHandler(this.SimpleIO_Load);
			this.GroupBox4.ResumeLayout(false);
			this.GroupBox2.ResumeLayout(false);
			this.GroupBox1.ResumeLayout(false);
			this.GroupBox3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// AvP[ṼC Gg |CgłB
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new SimpleIO());
		}

		//---------------------------------------------------------
		//	_CAO
		//---------------------------------------------------------
		private void SimpleIO_Load(object sender, System.EventArgs e)
		{
			//-----------------------------------
			// foCX̌o
			//-----------------------------------
			short	Index;
			short	GroupID, UnitID, DeviceID;
			StringBuilder	DeviceName = new StringBuilder(256);
			StringBuilder	Device = new StringBuilder(256);
			GroupID = 0;
			UnitID = 0;
			DeviceID = 0;
			for (Index=0; ; Index++)
			{
				Ret = DIO.Ccapdio.DioQueryDeviceName(Index, ref GroupID, ref UnitID, ref DeviceID, DeviceName, Device);
				if (Ret != DIO.Ccapdio.DIO_ERR_SUCCESS) 
				{
					break;
				}
				cboDeviceName.Items.Add(DeviceName);
			}
			cboDeviceName.SelectedIndex = 0;
			//-----------------------------------
			// ʃACȅ
			//-----------------------------------
			txtInpPortNo.Text = "0";
			txtInpBitNo.Text = "0";
			txtOutPortNo.Text = "0";
			txtOutBitNo.Text = "0";
			txtOutPortData.Text = "55";
			txtOutBitData.Text = "1";
			txtReturnCode.Text = "";
		}

		//---------------------------------------------------------
		//	
		//---------------------------------------------------------
		private void btnDioInit_Click(object sender, System.EventArgs e)
		{
			string	szDeviceName = new string(' ', 100);
			//-----------------------------
			// ʂfoCX擾
			//-----------------------------
			szDeviceName = cboDeviceName.Text;
			//-----------------------------
			// sȂAID擾
			//-----------------------------
			Ret = DIO.Ccapdio.DioInit(szDeviceName, ref Id);
			//-----------------------------
			// G[
			//-----------------------------
			DIO.Ccapdio.DioGetErrorString(Ret, szError);
			szReturnCode = "DioInit : " + szError;
			txtReturnCode.Text = szReturnCode;
		}

		//---------------------------------------------------------
		//	P|[g
		//---------------------------------------------------------
		private void btnInpByte_Click(object sender, System.EventArgs e)
		{
			short	InpPortNo;
			byte	InpPortData;
			InpPortData = 0;
			//-----------------------------
			// ʂ|[gԍ擾
			//-----------------------------
			szText = txtInpPortNo.Text;
			try
			{
				InpPortNo = Convert.ToInt16(szText);
			}
			catch (System.FormatException)
			{
				InpPortNo = 0;
			}
			//-----------------------------
			// |[g
			//-----------------------------
			Ret = DIO.Ccapdio.DioInpByte(Id, InpPortNo, ref InpPortData);
			//-----------------------------
			// G[
			//-----------------------------
			DIO.Ccapdio.DioGetErrorString(Ret, szError);
			szReturnCode = "DioInpByte : " + szError;
			txtReturnCode.Text = szReturnCode;
			if (Ret != DIO.Ccapdio.DIO_ERR_SUCCESS)
			{
				return;
			}
			//-----------------------------
			// f[^\
			//-----------------------------
			szText = string.Format("{0:X2}", InpPortData);
			txtInpPortData.Text = szText;
		}

		//---------------------------------------------------------
		//	Prbg
		//---------------------------------------------------------
		private void btnInpBit_Click(object sender, System.EventArgs e)
		{
			short	InpBitNo;
			byte	InpBitData;
			InpBitData = 0;
			//-----------------------------
			// ʂrbgԍ擾
			//-----------------------------
			szText = txtInpBitNo.Text;
			try
			{
				InpBitNo = Convert.ToInt16(szText);
			}
			catch (System.FormatException)
			{
				InpBitNo = 0;
			}
			//-----------------------------
			// rbg
			//-----------------------------
			Ret = DIO.Ccapdio.DioInpBit(Id, InpBitNo, ref InpBitData);
			//-----------------------------
			// G[
			//-----------------------------
			DIO.Ccapdio.DioGetErrorString(Ret, szError);
			szReturnCode = "DioInpBit : " + szError;
			txtReturnCode.Text = szReturnCode;
			if (Ret != DIO.Ccapdio.DIO_ERR_SUCCESS)
			{
				return;
			}
			//-----------------------------
			// f[^\
			//-----------------------------
			szText = string.Format("{0:X}", InpBitData);
			txtInpBitData.Text = szText;
		}

		//---------------------------------------------------------
		//	P|[go
		//---------------------------------------------------------
		private void btnOutByte_Click(object sender, System.EventArgs e)
		{
			short	OutPortNo;
			byte	OutPortData;
			uint	dwTmp;
			//-----------------------------
			// ʂ|[gԍƏo̓f[^擾
			//-----------------------------
			szText = txtOutPortNo.Text;
			try
			{
				OutPortNo = Convert.ToInt16(szText);			
			}
			catch (System.FormatException)
			{
				OutPortNo = 0;
			}
			szText = txtOutPortData.Text;
			try
			{
				dwTmp = uint.Parse(szText, NumberStyles.HexNumber);
			}
			catch (System.FormatException)
			{
				dwTmp = 0;
			}
			OutPortData = (byte)dwTmp;
			//-----------------------------
			// |[go
			//-----------------------------
			Ret = DIO.Ccapdio.DioOutByte(Id, OutPortNo, OutPortData);
			//-----------------------------
			// G[
			//-----------------------------
			DIO.Ccapdio.DioGetErrorString(Ret, szError);
			szReturnCode = "DioOutByte : " + szError;
			txtReturnCode.Text = szReturnCode;
			if (Ret != DIO.Ccapdio.DIO_ERR_SUCCESS)
			{
				return;
			}
		}

		//---------------------------------------------------------
		//	Prbgo
		//---------------------------------------------------------
		private void btnOutBit_Click(object sender, System.EventArgs e)
		{
			short	OutBitNo;
			byte	OutBitData;
			uint	dwTmp;
			//-----------------------------
			// ʂrbgԍƏo̓f[^擾
			//-----------------------------
			szText = txtOutBitNo.Text;
			try
			{
				OutBitNo = Convert.ToInt16(szText);
			}
			catch (System.FormatException)
			{
				OutBitNo = 0;
			}
			szText = txtOutBitData.Text;
			try
			{
				dwTmp = uint.Parse(szText, NumberStyles.HexNumber);
			}
			catch (System.FormatException)
			{
				dwTmp = 0;
			}
			OutBitData = (byte)dwTmp;
			//-----------------------------
			// rbgo
			//-----------------------------
			Ret = DIO.Ccapdio.DioOutBit(Id, OutBitNo, OutBitData);
			//-----------------------------
			// G[
			//-----------------------------
			DIO.Ccapdio.DioGetErrorString(Ret, szError);
			szReturnCode = "DioOutBit : " + szError;
			txtReturnCode.Text = szReturnCode;
			if (Ret != DIO.Ccapdio.DIO_ERR_SUCCESS)
			{
				return;
			}	
		}

		//---------------------------------------------------------
		//	P|[gGR[obN
		//---------------------------------------------------------
		private void btnEchoBackByte_Click(object sender, System.EventArgs e)
		{
			short	OutPortNo;
			byte	OutPortData;
			OutPortData = 0;
			//-----------------------------
			// ʂ|[gԍ擾
			//-----------------------------
			szText = txtOutPortNo.Text;
			try
			{
				OutPortNo = Convert.ToInt16(szText);
			}
			catch (System.FormatException)
			{
				OutPortNo = 0;
			}
			//-----------------------------
			// |[gGR[obN
			//-----------------------------
			Ret = DIO.Ccapdio.DioEchoBackByte(Id, OutPortNo, ref OutPortData);
			//-----------------------------
			// G[
			//-----------------------------
			DIO.Ccapdio.DioGetErrorString(Ret, szError);
			szReturnCode = "DioEchoBackByte : " + szError;
			txtReturnCode.Text = szReturnCode;	
			if (Ret != DIO.Ccapdio.DIO_ERR_SUCCESS)
			{
				return;
			}
			//-----------------------------
			// f[^\
			//-----------------------------
			szText = string.Format("{0:X2}", OutPortData);
			txtOutPortData.Text = szText;
		}

		//---------------------------------------------------------
		//	PrbgGR[obN
		//---------------------------------------------------------
		private void btnEchoBackBit_Click(object sender, System.EventArgs e)
		{
			short	OutBitNo;
			byte	OutBitData;
			OutBitData = 0;
			//-----------------------------
			// ʂrbgԍ擾
			//-----------------------------
			szText = txtOutBitNo.Text;
			try
			{
				OutBitNo = Convert.ToInt16(szText);
			}
			catch (System.FormatException)
			{
				OutBitNo = 0;
			}
			//-----------------------------
			// rbgGR[obN
			//-----------------------------
			Ret = DIO.Ccapdio.DioEchoBackBit(Id, OutBitNo, ref OutBitData);
			//-----------------------------
			// G[
			//-----------------------------
			DIO.Ccapdio.DioGetErrorString(Ret, szError);
			szReturnCode = "DioEchoBackBit : " + szError;
			txtReturnCode.Text = szReturnCode;	
			if (Ret != DIO.Ccapdio.DIO_ERR_SUCCESS)
			{
				return;
			}
			//-----------------------------
			// f[^\
			//-----------------------------
			szText = string.Format("{0:X}", OutBitData);
			txtOutBitData.Text = szText;
		}

		//---------------------------------------------------------
		//	I
		//---------------------------------------------------------
		private void btnDioExit_Click(object sender, System.EventArgs e)
		{
			//-----------------------------
			// Is
			//-----------------------------
			Ret = DIO.Ccapdio.DioExit(Id);
			//-----------------------------
			// G[
			//-----------------------------
			DIO.Ccapdio.DioGetErrorString(Ret, szError);
			szReturnCode = "DioExit : " + szError;
			txtReturnCode.Text = szReturnCode;	
		}

		//---------------------------------------------------------
		//	_CAOI
		//---------------------------------------------------------
		private void btnExit_Click(object sender, System.EventArgs e)
		{
			//-----------------------------
			// Is
			//-----------------------------
			Ret = DIO.Ccapdio.DioExit(Id);
			//-----------------------------
			// _CAOI
			//-----------------------------
			this.Close();
		}

		private void SimpleIO_Closed(object sender, System.EventArgs e)
		{
			//-----------------------------
			// Is
			//-----------------------------
			Ret = DIO.Ccapdio.DioExit(Id);
		}
	}
}