using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.Runtime.InteropServices;

namespace MultiAo
{
	/// <summary>
	/// Form1 ̊Tv̐łB
	/// </summary>
	public class MultiAo : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.Label Label7;
		internal System.Windows.Forms.Label Label5;
		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.Label lblErrorString;
		internal System.Windows.Forms.Label lblVolt;
		internal System.Windows.Forms.Label lblAoChannels;
		internal System.Windows.Forms.Button btnSet;
		internal System.Windows.Forms.Label lblCData1;
		internal System.Windows.Forms.Button btnAioExit;
		internal System.Windows.Forms.Button btnAioMultiAo;
		internal System.Windows.Forms.Button btnStop;
		internal System.Windows.Forms.Button btnStart;
		internal System.Windows.Forms.Button btnAioInit;
		internal System.Windows.Forms.TextBox txtAoVolt;
		internal System.Windows.Forms.TextBox txtAoChannel;
		internal System.Windows.Forms.Label lblCData2;
		internal System.Windows.Forms.Label lblErr;
		internal System.Windows.Forms.Label lblStart;
		internal System.Windows.Forms.ComboBox cboAioSetAoRange;
		internal System.Windows.Forms.ComboBox cboDeviceName;
		/// <summary>
		/// KvȃfUCiϐłB
		/// </summary>
		private System.ComponentModel.Container components = null;
		// ֐̖߂l
		int	Ret;
		//ID
		short			Id;
		// ő`l
		short			MaxAoChannels;
		// o͓df[^
		float[]			AoVolt = new float[256];
		//G[R[h
		StringBuilder	ErrorString = new StringBuilder(256);
		// 񏑎쐬p
		string			TextString;				
		string			TextTemp;

		public MultiAo()
		{
			//
			// 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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MultiAo));
			this.lblErrorString = new System.Windows.Forms.Label();
			this.lblVolt = new System.Windows.Forms.Label();
			this.lblAoChannels = new System.Windows.Forms.Label();
			this.btnSet = new System.Windows.Forms.Button();
			this.lblCData1 = new System.Windows.Forms.Label();
			this.Label7 = new System.Windows.Forms.Label();
			this.btnAioExit = new System.Windows.Forms.Button();
			this.btnAioMultiAo = new System.Windows.Forms.Button();
			this.btnStop = new System.Windows.Forms.Button();
			this.btnStart = new System.Windows.Forms.Button();
			this.btnAioInit = new System.Windows.Forms.Button();
			this.txtAoVolt = new System.Windows.Forms.TextBox();
			this.txtAoChannel = new System.Windows.Forms.TextBox();
			this.lblCData2 = new System.Windows.Forms.Label();
			this.Label5 = new System.Windows.Forms.Label();
			this.lblErr = new System.Windows.Forms.Label();
			this.lblStart = new System.Windows.Forms.Label();
			this.Label4 = new System.Windows.Forms.Label();
			this.Label3 = new System.Windows.Forms.Label();
			this.cboAioSetAoRange = new System.Windows.Forms.ComboBox();
			this.Label2 = new System.Windows.Forms.Label();
			this.cboDeviceName = new System.Windows.Forms.ComboBox();
			this.Label1 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// lblErrorString
			// 
			this.lblErrorString.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblErrorString.Location = new System.Drawing.Point(15, 387);
			this.lblErrorString.Name = "lblErrorString";
			this.lblErrorString.Size = new System.Drawing.Size(307, 32);
			this.lblErrorString.TabIndex = 64;
			// 
			// lblVolt
			// 
			this.lblVolt.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblVolt.Location = new System.Drawing.Point(162, 184);
			this.lblVolt.Name = "lblVolt";
			this.lblVolt.Size = new System.Drawing.Size(72, 192);
			this.lblVolt.TabIndex = 63;
			// 
			// lblAoChannels
			// 
			this.lblAoChannels.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblAoChannels.Location = new System.Drawing.Point(104, 184);
			this.lblAoChannels.Name = "lblAoChannels";
			this.lblAoChannels.Size = new System.Drawing.Size(50, 192);
			this.lblAoChannels.TabIndex = 62;
			// 
			// btnSet
			// 
			this.btnSet.Location = new System.Drawing.Point(246, 136);
			this.btnSet.Name = "btnSet";
			this.btnSet.Size = new System.Drawing.Size(76, 24);
			this.btnSet.TabIndex = 48;
			this.btnSet.Text = "ݒ";
			this.btnSet.Click += new System.EventHandler(this.btnSet_Click);
			// 
			// lblCData1
			// 
			this.lblCData1.Location = new System.Drawing.Point(178, 168);
			this.lblCData1.Name = "lblCData1";
			this.lblCData1.Size = new System.Drawing.Size(64, 16);
			this.lblCData1.TabIndex = 61;
			this.lblCData1.Text = "d";
			// 
			// Label7
			// 
			this.Label7.Location = new System.Drawing.Point(104, 168);
			this.Label7.Name = "Label7";
			this.Label7.Size = new System.Drawing.Size(64, 16);
			this.Label7.TabIndex = 60;
			this.Label7.Text = "`l";
			// 
			// btnAioExit
			// 
			this.btnAioExit.Location = new System.Drawing.Point(16, 168);
			this.btnAioExit.Name = "btnAioExit";
			this.btnAioExit.Size = new System.Drawing.Size(76, 24);
			this.btnAioExit.TabIndex = 44;
			this.btnAioExit.Text = "I";
			this.btnAioExit.Click += new System.EventHandler(this.btnAioExit_Click);
			// 
			// btnAioMultiAo
			// 
			this.btnAioMultiAo.Location = new System.Drawing.Point(16, 136);
			this.btnAioMultiAo.Name = "btnAioMultiAo";
			this.btnAioMultiAo.Size = new System.Drawing.Size(76, 24);
			this.btnAioMultiAo.TabIndex = 43;
			this.btnAioMultiAo.Text = "ȈՏo";
			this.btnAioMultiAo.Click += new System.EventHandler(this.btnAioMultiAo_Click);
			// 
			// btnStop
			// 
			this.btnStop.Location = new System.Drawing.Point(16, 104);
			this.btnStop.Name = "btnStop";
			this.btnStop.Size = new System.Drawing.Size(76, 24);
			this.btnStop.TabIndex = 50;
			this.btnStop.Text = "~";
			this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
			// 
			// btnStart
			// 
			this.btnStart.Location = new System.Drawing.Point(16, 72);
			this.btnStart.Name = "btnStart";
			this.btnStart.Size = new System.Drawing.Size(76, 24);
			this.btnStart.TabIndex = 49;
			this.btnStart.Text = "N";
			this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
			// 
			// btnAioInit
			// 
			this.btnAioInit.Location = new System.Drawing.Point(16, 40);
			this.btnAioInit.Name = "btnAioInit";
			this.btnAioInit.Size = new System.Drawing.Size(76, 24);
			this.btnAioInit.TabIndex = 42;
			this.btnAioInit.Text = "";
			this.btnAioInit.Click += new System.EventHandler(this.btnAioInit_Click);
			// 
			// txtAoVolt
			// 
			this.txtAoVolt.Location = new System.Drawing.Point(162, 140);
			this.txtAoVolt.Name = "txtAoVolt";
			this.txtAoVolt.Size = new System.Drawing.Size(72, 19);
			this.txtAoVolt.TabIndex = 47;
			this.txtAoVolt.Text = "";
			// 
			// txtAoChannel
			// 
			this.txtAoChannel.Location = new System.Drawing.Point(104, 140);
			this.txtAoChannel.Name = "txtAoChannel";
			this.txtAoChannel.Size = new System.Drawing.Size(50, 19);
			this.txtAoChannel.TabIndex = 45;
			this.txtAoChannel.Text = "";
			// 
			// lblCData2
			// 
			this.lblCData2.Location = new System.Drawing.Point(176, 124);
			this.lblCData2.Name = "lblCData2";
			this.lblCData2.Size = new System.Drawing.Size(64, 16);
			this.lblCData2.TabIndex = 59;
			this.lblCData2.Text = "d";
			// 
			// Label5
			// 
			this.Label5.Location = new System.Drawing.Point(104, 124);
			this.Label5.Name = "Label5";
			this.Label5.Size = new System.Drawing.Size(64, 16);
			this.Label5.TabIndex = 58;
			this.Label5.Text = "`l";
			// 
			// lblErr
			// 
			this.lblErr.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblErr.Location = new System.Drawing.Point(176, 98);
			this.lblErr.Name = "lblErr";
			this.lblErr.Size = new System.Drawing.Size(39, 17);
			this.lblErr.TabIndex = 57;
			// 
			// lblStart
			// 
			this.lblStart.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.lblStart.Location = new System.Drawing.Point(104, 98);
			this.lblStart.Name = "lblStart";
			this.lblStart.Size = new System.Drawing.Size(39, 17);
			this.lblStart.TabIndex = 56;
			// 
			// Label4
			// 
			this.Label4.Location = new System.Drawing.Point(176, 82);
			this.Label4.Name = "Label4";
			this.Label4.Size = new System.Drawing.Size(82, 16);
			this.Label4.TabIndex = 55;
			this.Label4.Text = "G[WX^";
			// 
			// Label3
			// 
			this.Label3.Location = new System.Drawing.Point(104, 82);
			this.Label3.Name = "Label3";
			this.Label3.Size = new System.Drawing.Size(72, 16);
			this.Label3.TabIndex = 54;
			this.Label3.Text = "NWX^";
			// 
			// cboAioSetAoRange
			// 
			this.cboAioSetAoRange.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboAioSetAoRange.Location = new System.Drawing.Point(104, 55);
			this.cboAioSetAoRange.Name = "cboAioSetAoRange";
			this.cboAioSetAoRange.Size = new System.Drawing.Size(136, 20);
			this.cboAioSetAoRange.TabIndex = 46;
			this.cboAioSetAoRange.SelectionChangeCommitted += new System.EventHandler(this.cboAioSetAoRange_SelectionChangeCommitted);
			// 
			// Label2
			// 
			this.Label2.Location = new System.Drawing.Point(103, 38);
			this.Label2.Name = "Label2";
			this.Label2.Size = new System.Drawing.Size(64, 16);
			this.Label2.TabIndex = 53;
			this.Label2.Text = "W";
			// 
			// cboDeviceName
			// 
			this.cboDeviceName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboDeviceName.Location = new System.Drawing.Point(104, 9);
			this.cboDeviceName.Name = "cboDeviceName";
			this.cboDeviceName.Size = new System.Drawing.Size(216, 20);
			this.cboDeviceName.TabIndex = 51;
			// 
			// Label1
			// 
			this.Label1.Location = new System.Drawing.Point(16, 12);
			this.Label1.Name = "Label1";
			this.Label1.Size = new System.Drawing.Size(74, 16);
			this.Label1.TabIndex = 52;
			this.Label1.Text = "foCXF";
			// 
			// MultiAo
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
			this.ClientSize = new System.Drawing.Size(336, 429);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.lblErrorString,
																		  this.lblVolt,
																		  this.lblAoChannels,
																		  this.btnSet,
																		  this.lblCData1,
																		  this.Label7,
																		  this.btnAioExit,
																		  this.btnAioMultiAo,
																		  this.btnStop,
																		  this.btnStart,
																		  this.btnAioInit,
																		  this.txtAoVolt,
																		  this.txtAoChannel,
																		  this.lblCData2,
																		  this.Label5,
																		  this.lblErr,
																		  this.lblStart,
																		  this.Label4,
																		  this.Label3,
																		  this.cboAioSetAoRange,
																		  this.Label2,
																		  this.cboDeviceName,
																		  this.Label1});
			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.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.Name = "MultiAo";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "`l1AiOo";
			this.Load += new System.EventHandler(this.MultiAo_Load);
			this.ResumeLayout(false);

		}
		#endregion

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

		//---------------------------------------------------------
		//	_CAO
		//---------------------------------------------------------
		private void MultiAo_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 = AIO.Ccapaio.AioQueryDeviceName(Index, ref GroupID, ref UnitID, ref DeviceID, DeviceName, Device);
				if (Ret != AIO.Ccapaio.AIO_ERR_SUCCESS)
				{
					break;
				}
				cboDeviceName.Items.Add(DeviceName);
			}
			cboDeviceName.SelectedIndex = 0;

			//-----------------------------------
			// AiOo̓WpR{{bNX̍쐬
			//-----------------------------------
			cboAioSetAoRange.Items.Add("-10 - +10V");
			cboAioSetAoRange.Items.Add("-5 - +5V");
			cboAioSetAoRange.Items.Add("0 - +10V");
			cboAioSetAoRange.Items.Add("0 - +5V");
			cboAioSetAoRange.Items.Add("0 - +20mA");

			txtAoChannel.Text = "0";
			//-----------------------------------
			// o̓f[^0
			//-----------------------------------
			short i;
			for (i=0; i<256; i++)
			{
				AoVolt[i] = 0;
			}
		}	

		//--------------------------------------------------------------------------------------------------
		//	foCX̏
		//--------------------------------------------------------------------------------------------------
		private void btnAioInit_Click(object sender, System.EventArgs e)
		{
			//-----------------------------------
			// 
			//-----------------------------------
			string	DeviceName = new string(' ', 100);
			DeviceName = cboDeviceName.Text;
			Ret = AIO.Ccapaio.AioInit(DeviceName, ref Id);
			//-----------------------------------
			// G[
			//-----------------------------------
			AIO.Ccapaio.AioGetErrorString(Ret, ErrorString);
			TextString = "AioInit : " + ErrorString;
			lblErrorString.Text = TextString;
			if (Ret != 0)
			{
				return;
			}
			//-----------------------------------
			// W̎擾ƕ\
			//-----------------------------------
			short	AoRange;
			short	Index;
			AoRange = 0;
			Index = 0;
			Ret = AIO.Ccapaio.AioGetAoRange(Id, 0, ref AoRange);
			if (Ret == AIO.Ccapaio.AIO_ERR_SUCCESS)
			{
				switch (AoRange)
				{
					case AIO.Ccapaio.PM10:	Index = 0;	break;
					case AIO.Ccapaio.PM5:	Index = 1;	break;
					case AIO.Ccapaio.P10:	Index = 2;	break;
					case AIO.Ccapaio.P5:	Index = 3;	break;
					case AIO.Ccapaio.P20MA:	Index = 4;	break;
				}
				cboAioSetAoRange.SelectedIndex = Index;
				//-----------------------------------
				// \̐؂ւ
				//-----------------------------------
				if (AoRange == AIO.Ccapaio.P20MA)
				{
					lblCData1.Text = "d";
					lblCData2.Text = "d";
				}
				else
				{
					lblCData1.Text = "d";
					lblCData2.Text = "d";
				}
			}
			//-----------------------------------
			// ő`l̎擾
			//-----------------------------------
			Ret = AIO.Ccapaio.AioGetAoMaxChannels(Id, ref MaxAoChannels);
			if (Ret != 0)
			{
				AIO.Ccapaio.AioGetErrorString(Ret, ErrorString);
				TextString = "AioGetAoMaxChannels : " + ErrorString;
				lblErrorString.Text = TextString;
			}
			//-----------------------------------
			// d̕\
			//-----------------------------------
			short i;
			TextString = "";
			for (i=0; i<MaxAoChannels; i++)
			{
				TextTemp = string.Format("{0:d}\n", i);
				TextString += TextTemp;
				lblAoChannels.Text = TextString;
			}
			TextString = "";
			for (i=0; i<MaxAoChannels; i++)
			{
				TextTemp = string.Format("0.000\n");
				TextString += TextTemp;
				lblVolt.Text = TextString;
			}
			ShowRemoteStatus();
		}

		//--------------------------------------------------------------------------------------------------
		//	N{^
		//--------------------------------------------------------------------------------------------------
		private void btnStart_Click(object sender, System.EventArgs e)
		{
			//-----------------------------------
			// N
			//-----------------------------------
			Ret = AIO.Ccapaio.AioStartIO(Id, 0x01);
			//-----------------------------------
			// G[
			//-----------------------------------
			AIO.Ccapaio.AioGetErrorString(Ret, ErrorString);
			TextString = "AioStartIO : " + ErrorString;
			lblErrorString.Text = TextString;
			if (Ret != 0)
			{
				return;
			}
			ShowRemoteStatus();
		}

		//--------------------------------------------------------------------------------------------------
		//	~{^
		//--------------------------------------------------------------------------------------------------
		private void btnStop_Click(object sender, System.EventArgs e)
		{
			//-----------------------------------
			// ~
			//-----------------------------------
			Ret = AIO.Ccapaio.AioStartIO(Id, 0x00);
			//-----------------------------------
			// G[
			//-----------------------------------
			AIO.Ccapaio.AioGetErrorString(Ret, ErrorString);
			TextString = "AioStartIO : " + ErrorString;
			lblErrorString.Text = TextString;
			if (Ret != 0)
			{
				return;
			}
			ShowRemoteStatus();
		}

		//--------------------------------------------------------------------------------------------------
		//	`l1AiOo
		//--------------------------------------------------------------------------------------------------
		private void btnAioMultiAo_Click(object sender, System.EventArgs e)
		{
			GCHandle Pter = GCHandle.Alloc(AoVolt, GCHandleType.Pinned);
			//-----------------------------------
			// AiOo
			//-----------------------------------
			Ret = AIO.Ccapaio.AioMultiAoEx(Id, MaxAoChannels, AoVolt);
			Pter.Free();
			//-----------------------------------
			// G[
			//-----------------------------------
			AIO.Ccapaio.AioGetErrorString(Ret, ErrorString);
			TextString = "AioMultiAoEx : " + ErrorString;
			lblErrorString.Text = TextString;
			if (Ret != 0)
			{
				return;
			}
		}

		//--------------------------------------------------------------------------------------------------
		//	AiOo̓f[^̐ݒ
		//--------------------------------------------------------------------------------------------------
		private void btnSet_Click(object sender, System.EventArgs e)
		{
			string	szText = new string(' ', 100);
			short	AoChannel;
			float	AoVoltTmp;
			//-----------------------------------
			// ʂf[^擾
			//-----------------------------------
			szText = txtAoChannel.Text;
			try
			{
				AoChannel = Convert.ToInt16(szText);
			}
			catch (System.FormatException)
			{
				AoChannel = 0;
			}
			szText = txtAoVolt.Text;
			try
			{
				AoVoltTmp = Convert.ToSingle(szText);
			}
			catch (System.FormatException)
			{
				AoVoltTmp = 0;
			}

			if (AoChannel >= MaxAoChannels)
			{
				lblErrorString.Text = "o̓f[^ݒ : o̓`l͈͊Oł";
				return;
			}
			//-----------------------------------
			// zƕ\f[^XV
			//-----------------------------------
			AoVolt[AoChannel] = AoVoltTmp;

			TextString = "";
			short i;
			for (i=0 ; i<MaxAoChannels; i++)
			{
				TextTemp = string.Format("{0:f3}\n", AoVolt[i]);
				TextString += TextTemp;
				lblVolt.Text = TextString;
			}
		}

		//--------------------------------------------------------------------------------------------------
		//	foCX̏I
		//--------------------------------------------------------------------------------------------------
		private void btnAioExit_Click(object sender, System.EventArgs e)
		{
			//-----------------------------------
			// foCX̏I
			//-----------------------------------
			Ret = AIO.Ccapaio.AioExit(Id);
			AIO.Ccapaio.AioGetErrorString(Ret, ErrorString);
			TextString = "AioExit : " + ErrorString;
			lblErrorString.Text = TextString;
		}

		private void MultiAo_Closed(object sender, System.EventArgs e)
		{
			//-----------------------------------
			// foCX̏I
			//-----------------------------------
			Ret = AIO.Ccapaio.AioExit(Id);
		}

		//--------------------------------------------------------------------------------------------------
		//	AiOo̓W̐ݒ
		//--------------------------------------------------------------------------------------------------
		private void cboAioSetAoRange_SelectionChangeCommitted(object sender, System.EventArgs e)
		{
			short	AoRange;
			short	Index;
			AoRange = 0;
			//-----------------------------------
			// ʓe̎擾
			//-----------------------------------
			Index = (short)cboAioSetAoRange.SelectedIndex;
			switch (Index)
			{
				case 0:	AoRange = AIO.Ccapaio.PM10;		break;
				case 1:	AoRange = AIO.Ccapaio.PM5;		break;
				case 2:	AoRange = AIO.Ccapaio.P10;		break;
				case 3:	AoRange = AIO.Ccapaio.P5;		break;
				case 4:	AoRange = AIO.Ccapaio.P20MA;	break;
			}
			//-----------------------------------
			// o̓W̐ݒ
			//-----------------------------------
			Ret = AIO.Ccapaio.AioSetAoRangeAll(Id, AoRange);
			//-----------------------------------
			// G[
			//-----------------------------------
			AIO.Ccapaio.AioGetErrorString(Ret, ErrorString);
			TextString = "AioSetAoRangeAll : " + ErrorString;
			lblErrorString.Text = TextString;
			if (Ret != 0)
			{
				return;
			}
			//-----------------------------------
			// \̐؂ւ
			//-----------------------------------
			if (AoRange == AIO.Ccapaio.P20MA)
			{
				lblCData1.Text = "d";
				lblCData2.Text = "d";
			}
			else
			{
				lblCData1.Text = "d";
				lblCData2.Text = "d";
			}
		}

		//--------------------------------------------------------------------------------------------------
		//	[gXe[^X̕\
		//--------------------------------------------------------------------------------------------------
		private void ShowRemoteStatus()
		{
			byte	Start, Err;
			string	szText = new string(' ', 100);
			Start = 0;
			Err = 0;
			//-----------------------------------
			// [gXe[^X
			//-----------------------------------
			Ret = AIO.Ccapaio.AioGetRemoteStatus(Id, ref Start, ref Err);
			//-----------------------------------
			// G[
			//-----------------------------------
			if (Ret != AIO.Ccapaio.AIO_ERR_SUCCESS)
			{
				AIO.Ccapaio.AioGetErrorString(Ret, ErrorString);
				TextString = "AioGetRemoteStatus : " + ErrorString;
				lblErrorString.Text = TextString;
				return;
			}
			//-----------------------------------
			// [gXe[^X\
			//-----------------------------------
			szText = string.Format("{0:X2}", Start);
			lblStart.Text = szText;
			szText = string.Format("{0:X2}", Err);
			lblErr.Text = szText;
		}
	}
}