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;
using CgpibCs;
using CSubFuncCs;

namespace Slave
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Slave : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox txtMyAddress;
		private System.Windows.Forms.ComboBox cboStsByte;
		private System.Windows.Forms.Button btnInit;
		private System.Windows.Forms.TextBox txtSendData;
		private System.Windows.Forms.Button btnSend;
		private System.Windows.Forms.TextBox txtReceiveData;
		private System.Windows.Forms.Button btnReceive;
		private System.Windows.Forms.Button btnSrqOn;
		private System.Windows.Forms.Button btnDelData;
		private System.Windows.Forms.Button btnDelRet;
		private System.Windows.Forms.Button btnSrqOff;
		private System.Windows.Forms.TextBox txtRet;
		private System.Windows.Forms.ComboBox cboDelimBox;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.Button btnExt;
		private System.Windows.Forms.Timer timer;

		Cgpib			gpib = new Cgpib();
		CSubFunc		SubFunc = new CSubFunc(); 

		// Setting ///////////////////////////////////////
		string			szBuffer = new string(' ', 1024);		// Buffer
		uint			Ret;									// Return value
		uint			Myadr, /*Yradr, */MasterMode;			// MyAddress,Address of device,ModeSelect(Master=0,Slave=1)
		uint			Delim, Eoi;								// Delimiter
		uint			/*Timeout, Ifctime,Dmamode, */Srlen;	//10000,1,1(Default),Length of str
		uint			P_stb, P_eoi;							// 
		string			srBuffer = new string(' ', 10000);		// Buffer
		//uint			uTimerTrm;								// Used Timer
		//uint			uTimerEvent;							// Used	Timer
		string			csBuf;									// csBuf is String type
		string			pStb;									// Status Byte
		StringBuilder	rvBuffer = new StringBuilder(10000);	// Buffer
		GCHandle     	gChCmd;                 				// GCHandle for cmd array
		//////////////////////////////////////////////////

		public Slave()
		{
			//
			// 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.components = new System.ComponentModel.Container();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.txtMyAddress = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.btnInit = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.btnReceive = new System.Windows.Forms.Button();
			this.txtReceiveData = new System.Windows.Forms.TextBox();
			this.btnSend = new System.Windows.Forms.Button();
			this.txtSendData = new System.Windows.Forms.TextBox();
			this.btnSrqOn = new System.Windows.Forms.Button();
			this.btnDelData = new System.Windows.Forms.Button();
			this.btnDelRet = new System.Windows.Forms.Button();
			this.btnSrqOff = new System.Windows.Forms.Button();
			this.btnExt = new System.Windows.Forms.Button();
			this.txtRet = new System.Windows.Forms.TextBox();
			this.cboDelimBox = new System.Windows.Forms.ComboBox();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.cboStsByte = new System.Windows.Forms.ComboBox();
			this.label2 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.timer = new System.Windows.Forms.Timer(this.components);
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.groupBox3.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.txtMyAddress,
																					this.label1});
			this.groupBox1.Location = new System.Drawing.Point(11, 16);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(204, 48);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			// 
			// txtMyAddress
			// 
			this.txtMyAddress.Location = new System.Drawing.Point(128, 15);
			this.txtMyAddress.Name = "txtMyAddress";
			this.txtMyAddress.ReadOnly = true;
			this.txtMyAddress.Size = new System.Drawing.Size(30, 22);
			this.txtMyAddress.TabIndex = 2;
			this.txtMyAddress.TabStop = false;
			this.txtMyAddress.Text = "0";
			this.txtMyAddress.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(40, 18);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(88, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "My Address =";
			// 
			// btnInit
			// 
			this.btnInit.Location = new System.Drawing.Point(422, 24);
			this.btnInit.Name = "btnInit";
			this.btnInit.Size = new System.Drawing.Size(96, 32);
			this.btnInit.TabIndex = 1;
			this.btnInit.Text = "&Initialize";
			this.btnInit.Click += new System.EventHandler(this.btnInit_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.btnReceive,
																					this.txtReceiveData,
																					this.btnSend,
																					this.txtSendData});
			this.groupBox2.Location = new System.Drawing.Point(11, 67);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(404, 96);
			this.groupBox2.TabIndex = 2;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "Send / Receive Data";
			// 
			// btnReceive
			// 
			this.btnReceive.Enabled = false;
			this.btnReceive.Location = new System.Drawing.Point(307, 57);
			this.btnReceive.Name = "btnReceive";
			this.btnReceive.Size = new System.Drawing.Size(87, 28);
			this.btnReceive.TabIndex = 3;
			this.btnReceive.Text = "&Receive";
			this.btnReceive.Click += new System.EventHandler(this.btnReceive_Click);
			// 
			// txtReceiveData
			// 
			this.txtReceiveData.Location = new System.Drawing.Point(10, 60);
			this.txtReceiveData.Name = "txtReceiveData";
			this.txtReceiveData.Size = new System.Drawing.Size(288, 22);
			this.txtReceiveData.TabIndex = 2;
			this.txtReceiveData.Text = "";
			// 
			// btnSend
			// 
			this.btnSend.Enabled = false;
			this.btnSend.Location = new System.Drawing.Point(307, 21);
			this.btnSend.Name = "btnSend";
			this.btnSend.Size = new System.Drawing.Size(87, 28);
			this.btnSend.TabIndex = 1;
			this.btnSend.Text = "&Send";
			this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
			// 
			// txtSendData
			// 
			this.txtSendData.Location = new System.Drawing.Point(10, 24);
			this.txtSendData.Name = "txtSendData";
			this.txtSendData.Size = new System.Drawing.Size(288, 22);
			this.txtSendData.TabIndex = 0;
			this.txtSendData.Text = "";
			// 
			// btnSrqOn
			// 
			this.btnSrqOn.Enabled = false;
			this.btnSrqOn.Location = new System.Drawing.Point(424, 131);
			this.btnSrqOn.Name = "btnSrqOn";
			this.btnSrqOn.Size = new System.Drawing.Size(96, 32);
			this.btnSrqOn.TabIndex = 3;
			this.btnSrqOn.Text = "SR&Q SEND";
			this.btnSrqOn.Click += new System.EventHandler(this.btnSrqOn_Click);
			// 
			// btnDelData
			// 
			this.btnDelData.Location = new System.Drawing.Point(216, 171);
			this.btnDelData.Name = "btnDelData";
			this.btnDelData.Size = new System.Drawing.Size(96, 32);
			this.btnDelData.TabIndex = 4;
			this.btnDelData.Text = "&Del Data";
			this.btnDelData.Click += new System.EventHandler(this.btnDelData_Click);
			// 
			// btnDelRet
			// 
			this.btnDelRet.Location = new System.Drawing.Point(319, 171);
			this.btnDelRet.Name = "btnDelRet";
			this.btnDelRet.Size = new System.Drawing.Size(96, 32);
			this.btnDelRet.TabIndex = 5;
			this.btnDelRet.Text = "D&el Return";
			this.btnDelRet.Click += new System.EventHandler(this.btnDelRet_Click);
			// 
			// btnSrqOff
			// 
			this.btnSrqOff.Enabled = false;
			this.btnSrqOff.Location = new System.Drawing.Point(424, 171);
			this.btnSrqOff.Name = "btnSrqOff";
			this.btnSrqOff.Size = new System.Drawing.Size(96, 32);
			this.btnSrqOff.TabIndex = 6;
			this.btnSrqOff.Text = "SRQ STO&P";
			this.btnSrqOff.Click += new System.EventHandler(this.btnSrqOff_Click);
			// 
			// btnExt
			// 
			this.btnExt.Location = new System.Drawing.Point(424, 211);
			this.btnExt.Name = "btnExt";
			this.btnExt.Size = new System.Drawing.Size(96, 32);
			this.btnExt.TabIndex = 7;
			this.btnExt.Text = "E&xit";
			this.btnExt.Click += new System.EventHandler(this.btnExt_Click);
			// 
			// txtRet
			// 
			this.txtRet.Location = new System.Drawing.Point(11, 216);
			this.txtRet.Name = "txtRet";
			this.txtRet.Size = new System.Drawing.Size(405, 22);
			this.txtRet.TabIndex = 8;
			this.txtRet.Text = "";
			// 
			// cboDelimBox
			// 
			this.cboDelimBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboDelimBox.Items.AddRange(new object[] {
															 "Not Use",
															 "CR+LF",
															 "CR",
															 "LF"});
			this.cboDelimBox.Location = new System.Drawing.Point(422, 88);
			this.cboDelimBox.Name = "cboDelimBox";
			this.cboDelimBox.Size = new System.Drawing.Size(96, 24);
			this.cboDelimBox.TabIndex = 9;
			this.cboDelimBox.SelectedIndexChanged += new System.EventHandler(this.cboDelimBox_SelectedIndexChanged);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(422, 69);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(64, 16);
			this.label3.TabIndex = 10;
			this.label3.Text = "Delimiter";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(11, 192);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(88, 16);
			this.label4.TabIndex = 11;
			this.label4.Text = "Return value";
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.cboStsByte,
																					this.label2,
																					this.label6});
			this.groupBox3.Location = new System.Drawing.Point(213, 16);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(201, 48);
			this.groupBox3.TabIndex = 0;
			this.groupBox3.TabStop = false;
			// 
			// cboStsByte
			// 
			this.cboStsByte.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboStsByte.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cboStsByte.ItemHeight = 16;
			this.cboStsByte.Items.AddRange(new object[] {
															"40",
															"41",
															"42",
															"43",
															"44",
															"45",
															"46",
															"47",
															"48",
															"49",
															"4a",
															"4b",
															"4c",
															"4d",
															"4e",
															"4f",
															"50",
															"51",
															"52",
															"53",
															"54",
															"55",
															"56",
															"57",
															"58",
															"59",
															"5a",
															"5b",
															"5c",
															"5d",
															"5e",
															"5f",
															"60",
															"61",
															"62",
															"63",
															"64",
															"65",
															"66",
															"67",
															"68",
															"69",
															"6a",
															"6b",
															"6c",
															"6d",
															"6e",
															"6f",
															"70",
															"71",
															"72",
															"73",
															"74",
															"75",
															"76",
															"77",
															"78",
															"79",
															"7a",
															"7b",
															"7c",
															"7d",
															"7e",
															"7f",
															"80",
															"81",
															"82",
															"83",
															"84",
															"85",
															"86",
															"87",
															"88",
															"89",
															"8a",
															"8b",
															"8c",
															"8d",
															"8e",
															"8f",
															"90",
															"91",
															"92",
															"93",
															"94",
															"95",
															"96",
															"97",
															"98",
															"99",
															"9a",
															"9b",
															"9c",
															"9d",
															"9e",
															"9f",
															"a0",
															"a1",
															"a2",
															"a3",
															"a4",
															"a5",
															"a6",
															"a7",
															"a8",
															"a9",
															"aa",
															"ab",
															"ac",
															"ad",
															"ae",
															"af",
															"b0",
															"b1",
															"b2",
															"b3",
															"b4",
															"b5",
															"b6",
															"b7",
															"b8",
															"b9",
															"ba",
															"bb",
															"bc",
															"bd",
															"be",
															"bf",
															"c0",
															"c1",
															"c2",
															"c3",
															"c4",
															"c5",
															"c6",
															"c7",
															"c8",
															"c9",
															"ca",
															"cb",
															"cc",
															"cd",
															"ce",
															"cf",
															"d0",
															"d1",
															"d2",
															"d3",
															"d4",
															"d5",
															"d6",
															"d7",
															"d8",
															"d9",
															"da",
															"db",
															"dc",
															"dd",
															"de",
															"df",
															"e0",
															"e1",
															"e2",
															"e3",
															"e4",
															"e5",
															"e6",
															"e7",
															"e8",
															"e9",
															"ea",
															"eb",
															"ec",
															"ed",
															"ee",
															"ef",
															"f0",
															"f1",
															"f2",
															"f3",
															"f4",
															"f5",
															"f6",
															"f7",
															"f8",
															"f9",
															"fa",
															"fb",
															"fc",
															"fd",
															"fe",
															"ff"});
			this.cboStsByte.Location = new System.Drawing.Point(112, 14);
			this.cboStsByte.Name = "cboStsByte";
			this.cboStsByte.Size = new System.Drawing.Size(42, 24);
			this.cboStsByte.TabIndex = 15;
			// 
			// label2
			// 
			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label2.Location = new System.Drawing.Point(26, 18);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(88, 16);
			this.label2.TabIndex = 14;
			this.label2.Text = "Status Byte =";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(159, 18);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(25, 16);
			this.label6.TabIndex = 3;
			this.label6.Text = "H";
			// 
			// timer
			// 
			this.timer.Tick += new System.EventHandler(this.timer_Tick);
			// 
			// Slave
			// 
			this.ClientSize = new System.Drawing.Size(528, 254);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.groupBox3,
																		  this.label4,
																		  this.label3,
																		  this.cboDelimBox,
																		  this.txtRet,
																		  this.btnExt,
																		  this.btnSrqOff,
																		  this.btnDelRet,
																		  this.btnDelData,
																		  this.btnSrqOn,
																		  this.groupBox2,
																		  this.btnInit,
																		  this.groupBox1});
			this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Name = "Slave";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Slave Mode";
			this.Load += new System.EventHandler(this.Slave_Load);
			this.Closed += new System.EventHandler(this.Slave_Closed);
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

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

		private void Slave_Load(object sender, System.EventArgs e)
		{
			// ****************************************************** Setting ***
			cboDelimBox.SelectedIndex = 1;
			txtSendData.Text ="_0123456789_ Test Data / 33 Bytes";
			cboStsByte.Text = "40";								// Default
			// ******************************************************************

			// Specify Pinned handle to Cmd
			if (gChCmd.IsAllocated == false) {
				gChCmd = GCHandle.Alloc(SubFunc.Cmd, GCHandleType.Pinned);
			}
			// Get address object by Pinned handle
			SubFunc.pCmd = gChCmd.AddrOfPinnedObject();
		}

		private void Slave_Closed(object sender, System.EventArgs e)
		{
			SubFunc.GpibExit();									// Function of SubClass

			// GCHandle free
			if (gChCmd.IsAllocated == true) {
				gChCmd.Free();
			}
		}

		//////////////////////////////////////////// Initialize ///
		private void btnInit_Click(object sender, System.EventArgs e)
		{
			SubFunc.GpibInit(out csBuf);						// Some Initialize
			gpib.Boardsts(0x0a, out MasterMode);
			gpib.Boardsts(0x08, out Myadr);
			txtMyAddress.Text = Myadr.ToString();
	
			if (MasterMode == 0)
			{													// Not Slave
				txtRet.Text = "This is not Slave.";
				return;
			}
			else
			{
				btnSend.Enabled = true;
				btnReceive.Enabled = true;
				btnSrqOn.Enabled = true;
				txtRet.Text = csBuf;
			}

			cboDelimBox_SelectedIndexChanged(cboDelimBox, new System.EventArgs());
		}

		//////////////////////////////////////////////// SRQ ON ///
		private void btnSrqOn_Click(object sender, System.EventArgs e)
		{
			btnSrqOn.Enabled = false;
			btnSrqOff.Enabled = true;
			btnExt.Enabled = false;

			pStb = cboStsByte.Text;								// Get count of m_StsByte
			P_stb = SubFunc.chr2hex(pStb);						// SubClass Files
			Ret = gpib.Ppollmode(2);							// Parelell mode set
			SubFunc.CheckRet("GpPollmode", Ret, out csBuf);		// Error check 
			Ret = gpib.SrqEx(P_stb, 1, 1);						// SRQ mode set
			SubFunc.CheckRet("GpSrqEx", Ret, out csBuf);		// Error check

			timer.Enabled = true;								// TimerEvent
	
			btnSend.Enabled = false;
			btnReceive.Enabled = false;
			btnInit.Enabled = false;
			txtRet.Text = "Waitting for polling by Master...";
		}

		/////////////////////////////////////////////// SRQ OFF ///
		private void btnSrqOff_Click(object sender, System.EventArgs e)
		{
			btnSrqOn.Enabled = true;
			btnSrqOff.Enabled = false;

			timer.Enabled = false;								// Stop Timer
			txtRet.Text = "Send to SRQ stopped.";

			btnSend.Enabled = true;
			btnReceive.Enabled = true;
			btnInit.Enabled = true;
			btnSrqOn.Enabled = true;
			btnExt.Enabled = true;
		}

		////////////////////////////////////////////////// Send ///
		private void btnSend_Click(object sender, System.EventArgs e)
		{
			txtRet.Text = "Data sending...";
			txtRet.Refresh();									// Redraw

			srBuffer = txtSendData.Text;						// Copy srBuffer down from m_SendData
			Srlen = (uint)srBuffer.Length;						// Length of srBuffer
	
			if (Srlen != 0x0)
			{													// Srlen is not 0
				SubFunc.Cmd[0] = 0;								// Total commands
				Ret = gpib.Talk(SubFunc.pCmd, Srlen, srBuffer);	// Send data
				SubFunc.CheckRet("GpTalk", Ret , out csBuf);	// Error Check
			}
			else
				csBuf = "There is no data.";

			txtRet.Text = csBuf; 
		}

		/////////////////////////////////////////////// Receive ///
		private void btnReceive_Click(object sender, System.EventArgs e)
		{
			int StartIndex=0;
			int Strlen=0;
		
			btnSend.Enabled = false;
			btnReceive.Enabled = false;
			btnInit.Enabled = false;
			btnSrqOn.Enabled = false;
			btnExt.Enabled = false;

			txtRet.Text = "Data Receiving...";
			txtRet.Refresh();									// Redraw

			SubFunc.Cmd[0] = 0x00;								// Total commands
			rvBuffer.Remove(0, rvBuffer.Length);				// Clear receive buffer
			Srlen = (uint)rvBuffer.Capacity;					// Length of Srlen
			Ret = gpib.Listen(SubFunc.pCmd, ref Srlen, rvBuffer);// Receive Data
			if (SubFunc.CheckRet("GpListen", Ret, out csBuf) == 0)
			{													// Error check
				StartIndex=Convert.ToInt32(Srlen);
				Strlen=rvBuffer.Length-StartIndex;
				txtReceiveData.Text = rvBuffer.Remove(StartIndex,Strlen).ToString(); 
				szBuffer = string.Format("Data Receiving is Finished. Get [ {0:d} ] byte.", Srlen);
				csBuf = szBuffer;
			}
			txtRet.Text = csBuf;
			btnSend.Enabled = true;
			btnReceive.Enabled = true;
			btnInit.Enabled = true;
			btnSrqOn.Enabled = true;
			btnExt.Enabled = true;
		}

		///////////////////////////////////////////////// Timer ///
		private void timer_Tick(object sender, System.EventArgs e)
		{
			Ret = gpib.Chkstb(out P_stb, out P_eoi);			
			SubFunc.CheckRet("StatusByte", Ret, out csBuf);		

			if ((P_stb & 0x40) != 0x40)
			{													// 0x40	mask
				txtRet.Text = "[SRQ] was received by master.";
				timer.Enabled = false;							// TimerKill

				btnSend.Enabled = true;
				btnReceive.Enabled = true;
				btnInit.Enabled = true;
				btnSrqOn.Enabled = true;
				btnSrqOff.Enabled = false;
				btnExt.Enabled = true;
			}	
		}

		///////////////////////////////////////// Delete Return ///
		private void btnDelRet_Click(object sender, System.EventArgs e)
		{
			txtRet.Text = "";
		}

		/////////////////////////////////////////// Delete Data ///
		private void btnDelData_Click(object sender, System.EventArgs e)
		{
			txtSendData.Text = "";
			txtReceiveData.Text = "";
		}

		////////////////////////////////////////////////// Exit ///
		private void btnExt_Click(object sender, System.EventArgs e)
		{
			SubFunc.GpibExit();									// Function of SubClass 
			this.Close();										// End of dialog
		}

		/////////////////////////////////// Change Delimiter ///
		private void cboDelimBox_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			Eoi = 1;											// EOI : USE
			Delim = (uint)cboDelimBox.SelectedIndex;
			Ret = gpib.Delim(Delim, Eoi);
		}
	}
}
