using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CdioCs;


namespace NetSimpleIO
{
	/// <summary>
	/// Summary description for NetSimpleIO.
	/// </summary>
	public class NetSimpleIO : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label_DeviceName;
		private System.Windows.Forms.Button button_DioInit;
		private System.Windows.Forms.TextBox textBox_DeviceName;
		private System.Windows.Forms.TextBox textBox_ReturnCode;
		private System.Windows.Forms.Button button_DioExit;
		private System.Windows.Forms.Label label_ReturnCode;
		private System.Windows.Forms.GroupBox group_1PortInput;
		private System.Windows.Forms.GroupBox group_1BitInput;
		private System.Windows.Forms.GroupBox group_1PortOutput;
		private System.Windows.Forms.GroupBox group_1BitOutput;
		private System.Windows.Forms.Label label_LogicPortNo;
		private System.Windows.Forms.Label label_LOgicBitNo;
		private System.Windows.Forms.Label label_LogicPortNo2;
		private System.Windows.Forms.Label label_LogicBitNo2;
		private System.Windows.Forms.Label label_InputData;
		private System.Windows.Forms.Label label_InputData2;
		private System.Windows.Forms.Label label_OutputData;
		private System.Windows.Forms.Label label_OutputData2;
		private System.Windows.Forms.Label label_Hex;
		private System.Windows.Forms.Label label_Hex2;
		private System.Windows.Forms.TextBox textBox_1PortInput_LogicPortNo;
		private System.Windows.Forms.TextBox textBox_1PortInput_InputData;
		private System.Windows.Forms.TextBox textBox_1BitInput_LogicBitNo;
		private System.Windows.Forms.TextBox textBox_1BitInput_InputData;
		private System.Windows.Forms.TextBox textBox_1PortOutput_LogicPortNo;
		private System.Windows.Forms.TextBox textBox_1PortOutput_OutputData;
		private System.Windows.Forms.TextBox textBox_1BitOutput_LogicBitNo;
		private System.Windows.Forms.TextBox textBox_1BitOutput_OutputData;
		private System.Windows.Forms.Button button_DioInpByte;
		private System.Windows.Forms.Button button_DioInpBit;
		private System.Windows.Forms.Button button_DioOutByte;
		private System.Windows.Forms.Button button_DioOutBit;
		private System.Windows.Forms.Button button_DioEchoBackByte;
		private System.Windows.Forms.Button button_DioEchoBackBit;
		private System.Windows.Forms.Button button_Exit;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textBox_DirData;
		private System.Windows.Forms.Button button_DioSetIoDirection;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		/// Create instance Cdio class
		/// </summary>
		Cdio  dio = new Cdio();

		public short m_Id;

		public NetSimpleIO()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label_DeviceName = new System.Windows.Forms.Label();
			this.button_DioInit = new System.Windows.Forms.Button();
			this.textBox_DeviceName = new System.Windows.Forms.TextBox();
			this.textBox_ReturnCode = new System.Windows.Forms.TextBox();
			this.button_DioExit = new System.Windows.Forms.Button();
			this.label_ReturnCode = new System.Windows.Forms.Label();
			this.group_1PortInput = new System.Windows.Forms.GroupBox();
			this.label_LogicPortNo = new System.Windows.Forms.Label();
			this.label_InputData = new System.Windows.Forms.Label();
			this.label_Hex = new System.Windows.Forms.Label();
			this.textBox_1PortInput_LogicPortNo = new System.Windows.Forms.TextBox();
			this.textBox_1PortInput_InputData = new System.Windows.Forms.TextBox();
			this.button_DioInpByte = new System.Windows.Forms.Button();
			this.group_1BitInput = new System.Windows.Forms.GroupBox();
			this.label_LOgicBitNo = new System.Windows.Forms.Label();
			this.label_InputData2 = new System.Windows.Forms.Label();
			this.textBox_1BitInput_LogicBitNo = new System.Windows.Forms.TextBox();
			this.textBox_1BitInput_InputData = new System.Windows.Forms.TextBox();
			this.button_DioInpBit = new System.Windows.Forms.Button();
			this.group_1PortOutput = new System.Windows.Forms.GroupBox();
			this.label_LogicPortNo2 = new System.Windows.Forms.Label();
			this.label_OutputData = new System.Windows.Forms.Label();
			this.label_Hex2 = new System.Windows.Forms.Label();
			this.textBox_1PortOutput_LogicPortNo = new System.Windows.Forms.TextBox();
			this.textBox_1PortOutput_OutputData = new System.Windows.Forms.TextBox();
			this.button_DioOutByte = new System.Windows.Forms.Button();
			this.button_DioEchoBackByte = new System.Windows.Forms.Button();
			this.group_1BitOutput = new System.Windows.Forms.GroupBox();
			this.label_LogicBitNo2 = new System.Windows.Forms.Label();
			this.label_OutputData2 = new System.Windows.Forms.Label();
			this.textBox_1BitOutput_LogicBitNo = new System.Windows.Forms.TextBox();
			this.textBox_1BitOutput_OutputData = new System.Windows.Forms.TextBox();
			this.button_DioOutBit = new System.Windows.Forms.Button();
			this.button_DioEchoBackBit = new System.Windows.Forms.Button();
			this.button_Exit = new System.Windows.Forms.Button();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.button_DioSetIoDirection = new System.Windows.Forms.Button();
			this.textBox_DirData = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.group_1PortInput.SuspendLayout();
			this.group_1BitInput.SuspendLayout();
			this.group_1PortOutput.SuspendLayout();
			this.group_1BitOutput.SuspendLayout();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// label_DeviceName
			// 
			this.label_DeviceName.Location = new System.Drawing.Point(24, 16);
			this.label_DeviceName.Name = "label_DeviceName";
			this.label_DeviceName.Size = new System.Drawing.Size(96, 24);
			this.label_DeviceName.TabIndex = 0;
			this.label_DeviceName.Text = "Device Name:";
			// 
			// button_DioInit
			// 
			this.button_DioInit.Location = new System.Drawing.Point(432, 16);
			this.button_DioInit.Name = "button_DioInit";
			this.button_DioInit.Size = new System.Drawing.Size(112, 24);
			this.button_DioInit.TabIndex = 1;
			this.button_DioInit.Text = "DioInit";
			this.button_DioInit.Click += new System.EventHandler(this.button_DioInit_Click);
			// 
			// textBox_DeviceName
			// 
			this.textBox_DeviceName.Location = new System.Drawing.Point(136, 16);
			this.textBox_DeviceName.Name = "textBox_DeviceName";
			this.textBox_DeviceName.Size = new System.Drawing.Size(72, 19);
			this.textBox_DeviceName.TabIndex = 2;
			this.textBox_DeviceName.Text = "DIO000";
			// 
			// textBox_ReturnCode
			// 
			this.textBox_ReturnCode.Location = new System.Drawing.Point(136, 376);
			this.textBox_ReturnCode.Name = "textBox_ReturnCode";
			this.textBox_ReturnCode.Size = new System.Drawing.Size(280, 19);
			this.textBox_ReturnCode.TabIndex = 5;
			this.textBox_ReturnCode.Text = "";
			// 
			// button_DioExit
			// 
			this.button_DioExit.Location = new System.Drawing.Point(432, 376);
			this.button_DioExit.Name = "button_DioExit";
			this.button_DioExit.Size = new System.Drawing.Size(112, 24);
			this.button_DioExit.TabIndex = 4;
			this.button_DioExit.Text = "DioExit";
			this.button_DioExit.Click += new System.EventHandler(this.button_DioExit_Click);
			// 
			// label_ReturnCode
			// 
			this.label_ReturnCode.Location = new System.Drawing.Point(24, 376);
			this.label_ReturnCode.Name = "label_ReturnCode";
			this.label_ReturnCode.Size = new System.Drawing.Size(96, 24);
			this.label_ReturnCode.TabIndex = 3;
			this.label_ReturnCode.Text = "Return Code:";
			// 
			// group_1PortInput
			// 
			this.group_1PortInput.Controls.AddRange(new System.Windows.Forms.Control[] {
																						   this.label_LogicPortNo,
																						   this.label_InputData,
																						   this.label_Hex,
																						   this.textBox_1PortInput_LogicPortNo,
																						   this.textBox_1PortInput_InputData,
																						   this.button_DioInpByte});
			this.group_1PortInput.Location = new System.Drawing.Point(24, 112);
			this.group_1PortInput.Name = "group_1PortInput";
			this.group_1PortInput.Size = new System.Drawing.Size(656, 56);
			this.group_1PortInput.TabIndex = 6;
			this.group_1PortInput.TabStop = false;
			this.group_1PortInput.Text = "1 Port Input";
			// 
			// label_LogicPortNo
			// 
			this.label_LogicPortNo.Location = new System.Drawing.Point(16, 24);
			this.label_LogicPortNo.Name = "label_LogicPortNo";
			this.label_LogicPortNo.Size = new System.Drawing.Size(96, 24);
			this.label_LogicPortNo.TabIndex = 10;
			this.label_LogicPortNo.Text = "Logic PortNo:";
			// 
			// label_InputData
			// 
			this.label_InputData.Location = new System.Drawing.Point(200, 24);
			this.label_InputData.Name = "label_InputData";
			this.label_InputData.Size = new System.Drawing.Size(96, 24);
			this.label_InputData.TabIndex = 10;
			this.label_InputData.Text = "Input Data:";
			// 
			// label_Hex
			// 
			this.label_Hex.Location = new System.Drawing.Point(368, 24);
			this.label_Hex.Name = "label_Hex";
			this.label_Hex.Size = new System.Drawing.Size(40, 24);
			this.label_Hex.TabIndex = 11;
			this.label_Hex.Text = "(Hex)";
			// 
			// textBox_1PortInput_LogicPortNo
			// 
			this.textBox_1PortInput_LogicPortNo.Location = new System.Drawing.Point(112, 24);
			this.textBox_1PortInput_LogicPortNo.Name = "textBox_1PortInput_LogicPortNo";
			this.textBox_1PortInput_LogicPortNo.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
			this.textBox_1PortInput_LogicPortNo.Size = new System.Drawing.Size(72, 19);
			this.textBox_1PortInput_LogicPortNo.TabIndex = 10;
			this.textBox_1PortInput_LogicPortNo.Text = "0";
			// 
			// textBox_1PortInput_InputData
			// 
			this.textBox_1PortInput_InputData.Location = new System.Drawing.Point(296, 24);
			this.textBox_1PortInput_InputData.Name = "textBox_1PortInput_InputData";
			this.textBox_1PortInput_InputData.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
			this.textBox_1PortInput_InputData.Size = new System.Drawing.Size(72, 19);
			this.textBox_1PortInput_InputData.TabIndex = 11;
			this.textBox_1PortInput_InputData.Text = "0";
			// 
			// button_DioInpByte
			// 
			this.button_DioInpByte.Location = new System.Drawing.Point(408, 24);
			this.button_DioInpByte.Name = "button_DioInpByte";
			this.button_DioInpByte.Size = new System.Drawing.Size(112, 24);
			this.button_DioInpByte.TabIndex = 10;
			this.button_DioInpByte.Text = "DioInpByte";
			this.button_DioInpByte.Click += new System.EventHandler(this.button_DioInpByte_Click);
			// 
			// group_1BitInput
			// 
			this.group_1BitInput.Controls.AddRange(new System.Windows.Forms.Control[] {
																						  this.label_LOgicBitNo,
																						  this.label_InputData2,
																						  this.textBox_1BitInput_LogicBitNo,
																						  this.textBox_1BitInput_InputData,
																						  this.button_DioInpBit});
			this.group_1BitInput.Location = new System.Drawing.Point(24, 176);
			this.group_1BitInput.Name = "group_1BitInput";
			this.group_1BitInput.Size = new System.Drawing.Size(656, 56);
			this.group_1BitInput.TabIndex = 7;
			this.group_1BitInput.TabStop = false;
			this.group_1BitInput.Text = "1 Bit Input";
			// 
			// label_LOgicBitNo
			// 
			this.label_LOgicBitNo.Location = new System.Drawing.Point(16, 24);
			this.label_LOgicBitNo.Name = "label_LOgicBitNo";
			this.label_LOgicBitNo.Size = new System.Drawing.Size(96, 24);
			this.label_LOgicBitNo.TabIndex = 10;
			this.label_LOgicBitNo.Text = "Logic BitNo:";
			// 
			// label_InputData2
			// 
			this.label_InputData2.Location = new System.Drawing.Point(200, 24);
			this.label_InputData2.Name = "label_InputData2";
			this.label_InputData2.Size = new System.Drawing.Size(96, 24);
			this.label_InputData2.TabIndex = 10;
			this.label_InputData2.Text = "Input Data:";
			// 
			// textBox_1BitInput_LogicBitNo
			// 
			this.textBox_1BitInput_LogicBitNo.Location = new System.Drawing.Point(112, 24);
			this.textBox_1BitInput_LogicBitNo.Name = "textBox_1BitInput_LogicBitNo";
			this.textBox_1BitInput_LogicBitNo.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
			this.textBox_1BitInput_LogicBitNo.Size = new System.Drawing.Size(72, 19);
			this.textBox_1BitInput_LogicBitNo.TabIndex = 12;
			this.textBox_1BitInput_LogicBitNo.Text = "0";
			// 
			// textBox_1BitInput_InputData
			// 
			this.textBox_1BitInput_InputData.Location = new System.Drawing.Point(296, 24);
			this.textBox_1BitInput_InputData.Name = "textBox_1BitInput_InputData";
			this.textBox_1BitInput_InputData.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
			this.textBox_1BitInput_InputData.Size = new System.Drawing.Size(72, 19);
			this.textBox_1BitInput_InputData.TabIndex = 12;
			this.textBox_1BitInput_InputData.Text = "0";
			// 
			// button_DioInpBit
			// 
			this.button_DioInpBit.Location = new System.Drawing.Point(408, 24);
			this.button_DioInpBit.Name = "button_DioInpBit";
			this.button_DioInpBit.Size = new System.Drawing.Size(112, 24);
			this.button_DioInpBit.TabIndex = 10;
			this.button_DioInpBit.Text = "DioInpBit";
			this.button_DioInpBit.Click += new System.EventHandler(this.button_DioInpBit_Click);
			// 
			// group_1PortOutput
			// 
			this.group_1PortOutput.Controls.AddRange(new System.Windows.Forms.Control[] {
																							this.label_LogicPortNo2,
																							this.label_OutputData,
																							this.label_Hex2,
																							this.textBox_1PortOutput_LogicPortNo,
																							this.textBox_1PortOutput_OutputData,
																							this.button_DioOutByte,
																							this.button_DioEchoBackByte});
			this.group_1PortOutput.Location = new System.Drawing.Point(24, 240);
			this.group_1PortOutput.Name = "group_1PortOutput";
			this.group_1PortOutput.Size = new System.Drawing.Size(656, 56);
			this.group_1PortOutput.TabIndex = 8;
			this.group_1PortOutput.TabStop = false;
			this.group_1PortOutput.Text = "1 Port Output";
			// 
			// label_LogicPortNo2
			// 
			this.label_LogicPortNo2.Location = new System.Drawing.Point(16, 24);
			this.label_LogicPortNo2.Name = "label_LogicPortNo2";
			this.label_LogicPortNo2.Size = new System.Drawing.Size(96, 24);
			this.label_LogicPortNo2.TabIndex = 10;
			this.label_LogicPortNo2.Text = "Logic PortNo:";
			// 
			// label_OutputData
			// 
			this.label_OutputData.Location = new System.Drawing.Point(200, 24);
			this.label_OutputData.Name = "label_OutputData";
			this.label_OutputData.Size = new System.Drawing.Size(96, 24);
			this.label_OutputData.TabIndex = 10;
			this.label_OutputData.Text = "Output Data:";
			// 
			// label_Hex2
			// 
			this.label_Hex2.Location = new System.Drawing.Point(368, 24);
			this.label_Hex2.Name = "label_Hex2";
			this.label_Hex2.Size = new System.Drawing.Size(40, 24);
			this.label_Hex2.TabIndex = 11;
			this.label_Hex2.Text = "(Hex)";
			// 
			// textBox_1PortOutput_LogicPortNo
			// 
			this.textBox_1PortOutput_LogicPortNo.Location = new System.Drawing.Point(112, 24);
			this.textBox_1PortOutput_LogicPortNo.Name = "textBox_1PortOutput_LogicPortNo";
			this.textBox_1PortOutput_LogicPortNo.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
			this.textBox_1PortOutput_LogicPortNo.Size = new System.Drawing.Size(72, 19);
			this.textBox_1PortOutput_LogicPortNo.TabIndex = 12;
			this.textBox_1PortOutput_LogicPortNo.Text = "0";
			// 
			// textBox_1PortOutput_OutputData
			// 
			this.textBox_1PortOutput_OutputData.Location = new System.Drawing.Point(296, 24);
			this.textBox_1PortOutput_OutputData.Name = "textBox_1PortOutput_OutputData";
			this.textBox_1PortOutput_OutputData.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
			this.textBox_1PortOutput_OutputData.Size = new System.Drawing.Size(72, 19);
			this.textBox_1PortOutput_OutputData.TabIndex = 12;
			this.textBox_1PortOutput_OutputData.Text = "0";
			// 
			// button_DioOutByte
			// 
			this.button_DioOutByte.Location = new System.Drawing.Point(408, 24);
			this.button_DioOutByte.Name = "button_DioOutByte";
			this.button_DioOutByte.Size = new System.Drawing.Size(112, 24);
			this.button_DioOutByte.TabIndex = 10;
			this.button_DioOutByte.Text = "DioOutByte";
			this.button_DioOutByte.Click += new System.EventHandler(this.button_DioOutByte_Click);
			// 
			// button_DioEchoBackByte
			// 
			this.button_DioEchoBackByte.Location = new System.Drawing.Point(528, 24);
			this.button_DioEchoBackByte.Name = "button_DioEchoBackByte";
			this.button_DioEchoBackByte.Size = new System.Drawing.Size(112, 24);
			this.button_DioEchoBackByte.TabIndex = 11;
			this.button_DioEchoBackByte.Text = "DioEchoBackByte";
			this.button_DioEchoBackByte.Click += new System.EventHandler(this.button_DioEchoBackByte_Click);
			// 
			// group_1BitOutput
			// 
			this.group_1BitOutput.Controls.AddRange(new System.Windows.Forms.Control[] {
																						   this.label_LogicBitNo2,
																						   this.label_OutputData2,
																						   this.textBox_1BitOutput_LogicBitNo,
																						   this.textBox_1BitOutput_OutputData,
																						   this.button_DioOutBit,
																						   this.button_DioEchoBackBit});
			this.group_1BitOutput.Location = new System.Drawing.Point(24, 304);
			this.group_1BitOutput.Name = "group_1BitOutput";
			this.group_1BitOutput.Size = new System.Drawing.Size(656, 56);
			this.group_1BitOutput.TabIndex = 9;
			this.group_1BitOutput.TabStop = false;
			this.group_1BitOutput.Text = "1 Bit Output";
			// 
			// label_LogicBitNo2
			// 
			this.label_LogicBitNo2.Location = new System.Drawing.Point(16, 24);
			this.label_LogicBitNo2.Name = "label_LogicBitNo2";
			this.label_LogicBitNo2.Size = new System.Drawing.Size(96, 24);
			this.label_LogicBitNo2.TabIndex = 10;
			this.label_LogicBitNo2.Text = "LogicBitNo:";
			// 
			// label_OutputData2
			// 
			this.label_OutputData2.Location = new System.Drawing.Point(200, 24);
			this.label_OutputData2.Name = "label_OutputData2";
			this.label_OutputData2.Size = new System.Drawing.Size(96, 24);
			this.label_OutputData2.TabIndex = 10;
			this.label_OutputData2.Text = "Output Data:";
			// 
			// textBox_1BitOutput_LogicBitNo
			// 
			this.textBox_1BitOutput_LogicBitNo.Location = new System.Drawing.Point(112, 24);
			this.textBox_1BitOutput_LogicBitNo.Name = "textBox_1BitOutput_LogicBitNo";
			this.textBox_1BitOutput_LogicBitNo.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
			this.textBox_1BitOutput_LogicBitNo.Size = new System.Drawing.Size(72, 19);
			this.textBox_1BitOutput_LogicBitNo.TabIndex = 12;
			this.textBox_1BitOutput_LogicBitNo.Text = "0";
			// 
			// textBox_1BitOutput_OutputData
			// 
			this.textBox_1BitOutput_OutputData.Location = new System.Drawing.Point(296, 24);
			this.textBox_1BitOutput_OutputData.Name = "textBox_1BitOutput_OutputData";
			this.textBox_1BitOutput_OutputData.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
			this.textBox_1BitOutput_OutputData.Size = new System.Drawing.Size(72, 19);
			this.textBox_1BitOutput_OutputData.TabIndex = 12;
			this.textBox_1BitOutput_OutputData.Text = "0";
			// 
			// button_DioOutBit
			// 
			this.button_DioOutBit.Location = new System.Drawing.Point(408, 24);
			this.button_DioOutBit.Name = "button_DioOutBit";
			this.button_DioOutBit.Size = new System.Drawing.Size(112, 24);
			this.button_DioOutBit.TabIndex = 10;
			this.button_DioOutBit.Text = "DioOutBit";
			this.button_DioOutBit.Click += new System.EventHandler(this.button_DioOutBit_Click);
			// 
			// button_DioEchoBackBit
			// 
			this.button_DioEchoBackBit.Location = new System.Drawing.Point(528, 24);
			this.button_DioEchoBackBit.Name = "button_DioEchoBackBit";
			this.button_DioEchoBackBit.Size = new System.Drawing.Size(112, 24);
			this.button_DioEchoBackBit.TabIndex = 11;
			this.button_DioEchoBackBit.Text = "DioEchoBackBit";
			this.button_DioEchoBackBit.Click += new System.EventHandler(this.button_DioEchoBackBit_Click);
			// 
			// button_Exit
			// 
			this.button_Exit.Location = new System.Drawing.Point(432, 416);
			this.button_Exit.Name = "button_Exit";
			this.button_Exit.Size = new System.Drawing.Size(112, 24);
			this.button_Exit.TabIndex = 10;
			this.button_Exit.Text = "Exit";
			this.button_Exit.Click += new System.EventHandler(this.button_Exit_Click);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.button_DioSetIoDirection,
																					this.textBox_DirData,
																					this.label1});
			this.groupBox1.Location = new System.Drawing.Point(24, 48);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(656, 56);
			this.groupBox1.TabIndex = 11;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "I/O Set";
			// 
			// button_DioSetIoDirection
			// 
			this.button_DioSetIoDirection.Location = new System.Drawing.Point(408, 21);
			this.button_DioSetIoDirection.Name = "button_DioSetIoDirection";
			this.button_DioSetIoDirection.Size = new System.Drawing.Size(112, 24);
			this.button_DioSetIoDirection.TabIndex = 13;
			this.button_DioSetIoDirection.Text = "DioSetIoDirection";
			this.button_DioSetIoDirection.Click += new System.EventHandler(this.button_DioSetIoDirection_Click);
			// 
			// textBox_DirData
			// 
			this.textBox_DirData.Location = new System.Drawing.Point(112, 24);
			this.textBox_DirData.Name = "textBox_DirData";
			this.textBox_DirData.Size = new System.Drawing.Size(72, 19);
			this.textBox_DirData.TabIndex = 12;
			this.textBox_DirData.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 26);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(96, 24);
			this.label1.TabIndex = 11;
			this.label1.Text = "I/O Direction:";
			// 
			// NetSimpleIO
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
			this.ClientSize = new System.Drawing.Size(696, 446);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.groupBox1,
																		  this.button_Exit,
																		  this.group_1BitOutput,
																		  this.group_1PortOutput,
																		  this.group_1BitInput,
																		  this.group_1PortInput,
																		  this.textBox_ReturnCode,
																		  this.button_DioExit,
																		  this.label_ReturnCode,
																		  this.textBox_DeviceName,
																		  this.button_DioInit,
																		  this.label_DeviceName});
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "NetSimpleIO";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "NetSimpleIO";
			this.Load += new System.EventHandler(this.NetSimpleIO_Load);
			this.group_1PortInput.ResumeLayout(false);
			this.group_1BitInput.ResumeLayout(false);
			this.group_1PortOutput.ResumeLayout(false);
			this.group_1BitOutput.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new NetSimpleIO());
		}

		private void NetSimpleIO_Load(object sender, System.EventArgs e)
		{
		
		}

		private void button_DioInit_Click(object sender, System.EventArgs e)
		{
			// Initialization handling
			int	Ret;
			Ret = dio.Init(textBox_DeviceName.Text, out m_Id);

			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
		}

		private void button_DioInpByte_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			short	InpPortNo;
			byte	InpPortData;
            ushort  timestamp;
            byte    mode;
            //-----------------------------
			// Get port No. from screen
			//-----------------------------
			try
			{
				InpPortNo = System.Convert.ToInt16(textBox_1PortInput_LogicPortNo.Text, 16);
			}
			catch
			{
				InpPortNo = 0;
			}
            //-----------------------------
            // Direct Access
            //-----------------------------
            mode = (byte)CdioConst.DIONET_MODE_DIRECT;
            //-----------------------------
			// Port input
			//-----------------------------
            Ret = dio.InpByteSR(m_Id, InpPortNo, out InpPortData, out timestamp, mode);
			//-----------------------------
			// Error process
			//-----------------------------
			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS) 
			{
				return;
			}
			//-----------------------------
			// Data express
			//-----------------------------
			textBox_1PortInput_InputData.Text = System.Convert.ToString(InpPortData, 16);
		}

		private void button_DioInpBit_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			short	InpBitNo;
			byte	InpBitData;
            ushort  timestamp;
            byte    mode;
            //-----------------------------
			// Get port No. from screen
			//-----------------------------
			try
			{
				InpBitNo = System.Convert.ToInt16(textBox_1BitInput_LogicBitNo.Text);
			}
			catch
			{
				InpBitNo = 0;
			}
            //-----------------------------
            // Direct Access
            //-----------------------------
            mode = (byte)CdioConst.DIONET_MODE_DIRECT;
            //-----------------------------
			// Port input
			//-----------------------------
			Ret = dio.InpBitSR(m_Id, InpBitNo, out InpBitData, out timestamp, mode);
			//-----------------------------
			// Error process
			//-----------------------------
			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS) 
			{
				return;
			}
			//-----------------------------
			// Data express
			//-----------------------------
			textBox_1BitInput_InputData.Text = System.Convert.ToString(InpBitData);		
		}

		private void button_DioOutByte_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			short	OutPortNo;
			byte	OutPortData;
            //-----------------------------
			// Get port No. and output data from screen
			//-----------------------------
			try
			{
				OutPortNo = System.Convert.ToInt16(textBox_1PortOutput_LogicPortNo.Text);
				OutPortData = System.Convert.ToByte(textBox_1PortOutput_OutputData.Text, 16);
			}
			catch
			{
				OutPortNo = 0;
				OutPortData = 0;
			}
            //-----------------------------
			// Port input
			//-----------------------------
            Ret = dio.OutByte(m_Id, OutPortNo, OutPortData);
			//-----------------------------
			// Error process
			//-----------------------------
			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS) 
			{
				return;
			}
		}

		private void button_DioEchoBackByte_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			short	OutPortNo;
			byte	OutPortData;			
			//-----------------------------
			// Get port No. from screen
			//-----------------------------
			try
			{
				OutPortNo = System.Convert.ToInt16(textBox_1PortOutput_LogicPortNo.Text);
			}
			catch
			{
				OutPortNo = 0;
			}
			//-----------------------------
			// Port input
			//-----------------------------
			Ret = dio.EchoBackByte(m_Id, OutPortNo, out OutPortData);
			//-----------------------------
			// Error process
			//-----------------------------
			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS) 
			{
				return;
			}
			//-----------------------------
			// Data express
			//-----------------------------
			textBox_1PortOutput_OutputData.Text = System.Convert.ToString(OutPortData, 16);
		}

		private void button_DioOutBit_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			short	OutBitNo;
			byte	OutBitData;			
			//-----------------------------
			// Get bit No. and output data from screen
			//-----------------------------
			try
			{
				OutBitNo = System.Convert.ToInt16(textBox_1BitOutput_LogicBitNo.Text);
				OutBitData = System.Convert.ToByte(textBox_1BitOutput_OutputData.Text, 16);
			}
			catch
			{
				OutBitNo = 0;
				OutBitData = 0;
			}
			//-----------------------------
			// Port input
			//-----------------------------
			Ret = dio.OutBit(m_Id, OutBitNo, OutBitData);
			//-----------------------------
			// Error process
			//-----------------------------
			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS) 
			{
				return;
			}
		}

		private void button_DioEchoBackBit_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			short	OutBitNo;
			byte	OutBitData;
			//-----------------------------
			// Get bit No. from screen
			//-----------------------------
			try
			{
				OutBitNo = System.Convert.ToInt16(textBox_1BitOutput_LogicBitNo.Text);
			}
			catch
			{
				OutBitNo = 0;
			}
			//-----------------------------
			// Port input
			//-----------------------------
			Ret = dio.EchoBackBit(m_Id, OutBitNo, out OutBitData);
			//-----------------------------
			// Error process
			//-----------------------------
			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
			if (Ret != (int)CdioConst.DIO_ERR_SUCCESS) 
			{
				return;
			}
			//-----------------------------
			// Data express
			//-----------------------------
			textBox_1BitOutput_OutputData.Text = System.Convert.ToString(OutBitData);		
		}

		private void button_DioExit_Click(object sender, System.EventArgs e)
		{
			// Exit handling of device
			int	Ret;
			Ret = dio.Exit(m_Id);

			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
		}

		private void button_Exit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void button_DioSetIoDirection_Click(object sender, System.EventArgs e)
		{
			uint dwDir;

			//-----------------------------
			// Get IoDirection
			//-----------------------------
			try 
			{
				dwDir = System.Convert.ToByte(textBox_DirData.Text, 16);
			}
			catch 
			{
				dwDir = 0;
			}
			//-----------------------------
			// Set IoDirection
			//-----------------------------
			int	Ret;
			Ret = dio.SetIoDirection(m_Id, dwDir);
			//-----------------------------
			// Error process
			//-----------------------------
			string	ErrorString;
			dio.GetErrorString(Ret, out ErrorString);
			textBox_ReturnCode.Text = "Ret = " + System.Convert.ToString(Ret) + " : " + ErrorString;
		}

	}
}
