using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CgpibCs;
using System.IO;

namespace ConRec
{
	/// <summary>
	/// Form1 ̊Tv̐łB
	/// </summary>
	public class Form_conrec : System.Windows.Forms.Form
	{
		public System.Windows.Forms.Timer tmrTimerEventRec;
		public System.Windows.Forms.GroupBox Frame5;
		public System.Windows.Forms.Button cmdSaveCsv;
		public System.Windows.Forms.Button cmdEventRecStop;
		public System.Windows.Forms.Button cmdEventRecStart;
		public System.Windows.Forms.ListBox lstEventRec;
		public System.Windows.Forms.GroupBox Frame4;
		public System.Windows.Forms.Button cmdRec;
		public System.Windows.Forms.TextBox txtRec;
		public System.Windows.Forms.Button cmdSend;
		public System.Windows.Forms.TextBox txtSend;
		public System.Windows.Forms.Button cmdExit;
		public System.Windows.Forms.GroupBox Frame2;
		public System.Windows.Forms.ListBox lstRet;
		public System.Windows.Forms.GroupBox Frame6;
		public System.Windows.Forms.TextBox txtTimerInterval;
		public System.Windows.Forms.Button cmdSrqRecTrigger;
		public System.Windows.Forms.RadioButton optTimer;
		public System.Windows.Forms.RadioButton optMaxSpeed;
		public System.Windows.Forms.RadioButton optManual;
		public System.Windows.Forms.Label lblTimerUnit;
		public System.Windows.Forms.Button cmdDataDel;
		public System.Windows.Forms.Button cmdRetDel;
		public System.Windows.Forms.Button cmdInit;
		public System.Windows.Forms.GroupBox Frame3;
		public System.Windows.Forms.TextBox txtAddr;
		public System.Windows.Forms.Button cmdSearch;
		public System.Windows.Forms.ComboBox cboEoi;
		public System.Windows.Forms.ComboBox cboDelim;
		public System.Windows.Forms.ComboBox cboAddr;
		public System.Windows.Forms.Label Label5;
		public System.Windows.Forms.Label Label4;
		public System.Windows.Forms.Label Label3;
		public System.Windows.Forms.GroupBox Frame1;
		public System.Windows.Forms.TextBox txtMyAddr;
		public System.Windows.Forms.TextBox txtDevName;
		public System.Windows.Forms.Label Label2;
		public System.Windows.Forms.Label Label1;
		private System.ComponentModel.IContainer components;

		/// <summary>
		/// NXCgpibCX^X쐬
		/// </summary>
		Cgpib	gpib = new Cgpib();
		short	m_Id;
		short[]	m_EqpId = new short[32];
		private System.Windows.Forms.SaveFileDialog dlgSaveCsv;
		short	m_SelectEqpId;
		const long	GPIB_NOTIFY_MESSAGE = 0x15FF;
		
		public Form_conrec()
		{
			//
			// 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.components = new System.ComponentModel.Container();
			this.tmrTimerEventRec = new System.Windows.Forms.Timer(this.components);
			this.Frame5 = new System.Windows.Forms.GroupBox();
			this.cmdSaveCsv = new System.Windows.Forms.Button();
			this.cmdEventRecStop = new System.Windows.Forms.Button();
			this.cmdEventRecStart = new System.Windows.Forms.Button();
			this.lstEventRec = new System.Windows.Forms.ListBox();
			this.Frame4 = new System.Windows.Forms.GroupBox();
			this.cmdRec = new System.Windows.Forms.Button();
			this.txtRec = new System.Windows.Forms.TextBox();
			this.cmdSend = new System.Windows.Forms.Button();
			this.txtSend = new System.Windows.Forms.TextBox();
			this.cmdExit = new System.Windows.Forms.Button();
			this.Frame2 = new System.Windows.Forms.GroupBox();
			this.lstRet = new System.Windows.Forms.ListBox();
			this.Frame6 = new System.Windows.Forms.GroupBox();
			this.txtTimerInterval = new System.Windows.Forms.TextBox();
			this.cmdSrqRecTrigger = new System.Windows.Forms.Button();
			this.optTimer = new System.Windows.Forms.RadioButton();
			this.optMaxSpeed = new System.Windows.Forms.RadioButton();
			this.optManual = new System.Windows.Forms.RadioButton();
			this.lblTimerUnit = new System.Windows.Forms.Label();
			this.cmdDataDel = new System.Windows.Forms.Button();
			this.cmdRetDel = new System.Windows.Forms.Button();
			this.cmdInit = new System.Windows.Forms.Button();
			this.Frame3 = new System.Windows.Forms.GroupBox();
			this.txtAddr = new System.Windows.Forms.TextBox();
			this.cmdSearch = new System.Windows.Forms.Button();
			this.cboEoi = new System.Windows.Forms.ComboBox();
			this.cboDelim = new System.Windows.Forms.ComboBox();
			this.cboAddr = new System.Windows.Forms.ComboBox();
			this.Label5 = new System.Windows.Forms.Label();
			this.Label4 = new System.Windows.Forms.Label();
			this.Label3 = new System.Windows.Forms.Label();
			this.Frame1 = new System.Windows.Forms.GroupBox();
			this.txtMyAddr = new System.Windows.Forms.TextBox();
			this.txtDevName = new System.Windows.Forms.TextBox();
			this.Label2 = new System.Windows.Forms.Label();
			this.Label1 = new System.Windows.Forms.Label();
			this.dlgSaveCsv = new System.Windows.Forms.SaveFileDialog();
			this.Frame5.SuspendLayout();
			this.Frame4.SuspendLayout();
			this.Frame2.SuspendLayout();
			this.Frame6.SuspendLayout();
			this.Frame3.SuspendLayout();
			this.Frame1.SuspendLayout();
			this.SuspendLayout();
			// 
			// tmrTimerEventRec
			// 
			this.tmrTimerEventRec.Interval = 1;
			this.tmrTimerEventRec.Tick += new System.EventHandler(this.tmrTimerEventRec_Tick);
			// 
			// Frame5
			// 
			this.Frame5.BackColor = System.Drawing.SystemColors.Control;
			this.Frame5.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.cmdSaveCsv,
																				 this.cmdEventRecStop,
																				 this.cmdEventRecStart,
																				 this.lstEventRec});
			this.Frame5.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Frame5.Location = new System.Drawing.Point(16, 248);
			this.Frame5.Name = "Frame5";
			this.Frame5.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Frame5.Size = new System.Drawing.Size(497, 145);
			this.Frame5.TabIndex = 51;
			this.Frame5.TabStop = false;
			this.Frame5.Text = "SRQCxgMf[^";
			// 
			// cmdSaveCsv
			// 
			this.cmdSaveCsv.BackColor = System.Drawing.SystemColors.Control;
			this.cmdSaveCsv.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdSaveCsv.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdSaveCsv.Location = new System.Drawing.Point(352, 88);
			this.cmdSaveCsv.Name = "cmdSaveCsv";
			this.cmdSaveCsv.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdSaveCsv.Size = new System.Drawing.Size(113, 33);
			this.cmdSaveCsv.TabIndex = 26;
			this.cmdSaveCsv.Text = "Mf[^CSVt@Cŕۑ";
			this.cmdSaveCsv.Click += new System.EventHandler(this.cmdSaveCsv_Click);
			// 
			// cmdEventRecStop
			// 
			this.cmdEventRecStop.BackColor = System.Drawing.SystemColors.Control;
			this.cmdEventRecStop.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdEventRecStop.Enabled = false;
			this.cmdEventRecStop.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdEventRecStop.Location = new System.Drawing.Point(352, 48);
			this.cmdEventRecStop.Name = "cmdEventRecStop";
			this.cmdEventRecStop.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdEventRecStop.Size = new System.Drawing.Size(113, 25);
			this.cmdEventRecStop.TabIndex = 25;
			this.cmdEventRecStop.Text = "SRQM~";
			this.cmdEventRecStop.Click += new System.EventHandler(this.cmdEventRecStop_Click);
			// 
			// cmdEventRecStart
			// 
			this.cmdEventRecStart.BackColor = System.Drawing.SystemColors.Control;
			this.cmdEventRecStart.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdEventRecStart.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdEventRecStart.Location = new System.Drawing.Point(352, 16);
			this.cmdEventRecStart.Name = "cmdEventRecStart";
			this.cmdEventRecStart.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdEventRecStart.Size = new System.Drawing.Size(113, 25);
			this.cmdEventRecStart.TabIndex = 24;
			this.cmdEventRecStart.Text = "SRQMJn";
			this.cmdEventRecStart.Click += new System.EventHandler(this.cmdEventRecStart_Click);
			// 
			// lstEventRec
			// 
			this.lstEventRec.BackColor = System.Drawing.SystemColors.Window;
			this.lstEventRec.Cursor = System.Windows.Forms.Cursors.Default;
			this.lstEventRec.ForeColor = System.Drawing.SystemColors.WindowText;
			this.lstEventRec.ItemHeight = 12;
			this.lstEventRec.Location = new System.Drawing.Point(8, 16);
			this.lstEventRec.Name = "lstEventRec";
			this.lstEventRec.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.lstEventRec.Size = new System.Drawing.Size(329, 112);
			this.lstEventRec.TabIndex = 18;
			// 
			// Frame4
			// 
			this.Frame4.BackColor = System.Drawing.SystemColors.Control;
			this.Frame4.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.cmdRec,
																				 this.txtRec,
																				 this.cmdSend,
																				 this.txtSend});
			this.Frame4.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Frame4.Location = new System.Drawing.Point(8, 152);
			this.Frame4.Name = "Frame4";
			this.Frame4.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Frame4.Size = new System.Drawing.Size(553, 81);
			this.Frame4.TabIndex = 50;
			this.Frame4.TabStop = false;
			this.Frame4.Text = "Mf[^";
			// 
			// cmdRec
			// 
			this.cmdRec.BackColor = System.Drawing.SystemColors.Control;
			this.cmdRec.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdRec.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdRec.Location = new System.Drawing.Point(432, 48);
			this.cmdRec.Name = "cmdRec";
			this.cmdRec.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdRec.Size = new System.Drawing.Size(113, 25);
			this.cmdRec.TabIndex = 22;
			this.cmdRec.Text = "M(&R)";
			this.cmdRec.Click += new System.EventHandler(this.cmdRec_Click);
			// 
			// txtRec
			// 
			this.txtRec.AcceptsReturn = true;
			this.txtRec.AutoSize = false;
			this.txtRec.BackColor = System.Drawing.SystemColors.Window;
			this.txtRec.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtRec.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtRec.Location = new System.Drawing.Point(8, 48);
			this.txtRec.MaxLength = 0;
			this.txtRec.Name = "txtRec";
			this.txtRec.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtRec.Size = new System.Drawing.Size(417, 25);
			this.txtRec.TabIndex = 21;
			this.txtRec.Text = "";
			// 
			// cmdSend
			// 
			this.cmdSend.BackColor = System.Drawing.SystemColors.Control;
			this.cmdSend.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdSend.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdSend.Location = new System.Drawing.Point(432, 16);
			this.cmdSend.Name = "cmdSend";
			this.cmdSend.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdSend.Size = new System.Drawing.Size(113, 25);
			this.cmdSend.TabIndex = 20;
			this.cmdSend.Text = "M(&S)";
			this.cmdSend.Click += new System.EventHandler(this.cmdSend_Click);
			// 
			// txtSend
			// 
			this.txtSend.AcceptsReturn = true;
			this.txtSend.AutoSize = false;
			this.txtSend.BackColor = System.Drawing.SystemColors.Window;
			this.txtSend.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtSend.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtSend.Location = new System.Drawing.Point(8, 16);
			this.txtSend.MaxLength = 0;
			this.txtSend.Name = "txtSend";
			this.txtSend.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtSend.Size = new System.Drawing.Size(417, 25);
			this.txtSend.TabIndex = 19;
			this.txtSend.Text = "";
			// 
			// cmdExit
			// 
			this.cmdExit.BackColor = System.Drawing.SystemColors.Control;
			this.cmdExit.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdExit.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdExit.Location = new System.Drawing.Point(448, 24);
			this.cmdExit.Name = "cmdExit";
			this.cmdExit.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdExit.Size = new System.Drawing.Size(113, 25);
			this.cmdExit.TabIndex = 47;
			this.cmdExit.Text = "I(&X)";
			this.cmdExit.Click += new System.EventHandler(this.cmdExit_Click);
			// 
			// Frame2
			// 
			this.Frame2.BackColor = System.Drawing.SystemColors.Control;
			this.Frame2.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.lstRet});
			this.Frame2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Frame2.Location = new System.Drawing.Point(8, 400);
			this.Frame2.Name = "Frame2";
			this.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Frame2.Size = new System.Drawing.Size(553, 81);
			this.Frame2.TabIndex = 48;
			this.Frame2.TabStop = false;
			this.Frame2.Text = "߂l";
			// 
			// lstRet
			// 
			this.lstRet.BackColor = System.Drawing.SystemColors.Window;
			this.lstRet.Cursor = System.Windows.Forms.Cursors.Default;
			this.lstRet.ForeColor = System.Drawing.SystemColors.WindowText;
			this.lstRet.ItemHeight = 12;
			this.lstRet.Location = new System.Drawing.Point(8, 16);
			this.lstRet.Name = "lstRet";
			this.lstRet.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.lstRet.Size = new System.Drawing.Size(537, 52);
			this.lstRet.TabIndex = 35;
			// 
			// Frame6
			// 
			this.Frame6.BackColor = System.Drawing.SystemColors.Control;
			this.Frame6.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.txtTimerInterval,
																				 this.cmdSrqRecTrigger,
																				 this.optTimer,
																				 this.optMaxSpeed,
																				 this.optManual,
																				 this.lblTimerUnit});
			this.Frame6.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Frame6.Location = new System.Drawing.Point(520, 248);
			this.Frame6.Name = "Frame6";
			this.Frame6.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Frame6.Size = new System.Drawing.Size(161, 145);
			this.Frame6.TabIndex = 52;
			this.Frame6.TabStop = false;
			this.Frame6.Text = "Jn^C~Oݒ";
			// 
			// txtTimerInterval
			// 
			this.txtTimerInterval.AcceptsReturn = true;
			this.txtTimerInterval.AutoSize = false;
			this.txtTimerInterval.BackColor = System.Drawing.SystemColors.Window;
			this.txtTimerInterval.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtTimerInterval.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtTimerInterval.ImeMode = System.Windows.Forms.ImeMode.Disable;
			this.txtTimerInterval.Location = new System.Drawing.Point(72, 48);
			this.txtTimerInterval.MaxLength = 5;
			this.txtTimerInterval.Name = "txtTimerInterval";
			this.txtTimerInterval.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtTimerInterval.Size = new System.Drawing.Size(41, 25);
			this.txtTimerInterval.TabIndex = 31;
			this.txtTimerInterval.Text = "";
			// 
			// cmdSrqRecTrigger
			// 
			this.cmdSrqRecTrigger.BackColor = System.Drawing.SystemColors.Control;
			this.cmdSrqRecTrigger.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdSrqRecTrigger.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdSrqRecTrigger.Location = new System.Drawing.Point(88, 16);
			this.cmdSrqRecTrigger.Name = "cmdSrqRecTrigger";
			this.cmdSrqRecTrigger.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdSrqRecTrigger.Size = new System.Drawing.Size(41, 25);
			this.cmdSrqRecTrigger.TabIndex = 30;
			this.cmdSrqRecTrigger.Text = "gK";
			this.cmdSrqRecTrigger.Click += new System.EventHandler(this.cmdSrqRecTrigger_Click);
			// 
			// optTimer
			// 
			this.optTimer.BackColor = System.Drawing.SystemColors.Control;
			this.optTimer.Cursor = System.Windows.Forms.Cursors.Default;
			this.optTimer.ForeColor = System.Drawing.SystemColors.ControlText;
			this.optTimer.Location = new System.Drawing.Point(8, 48);
			this.optTimer.Name = "optTimer";
			this.optTimer.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.optTimer.Size = new System.Drawing.Size(65, 17);
			this.optTimer.TabIndex = 29;
			this.optTimer.TabStop = true;
			this.optTimer.Text = "^C}[";
			// 
			// optMaxSpeed
			// 
			this.optMaxSpeed.BackColor = System.Drawing.SystemColors.Control;
			this.optMaxSpeed.Cursor = System.Windows.Forms.Cursors.Default;
			this.optMaxSpeed.ForeColor = System.Drawing.SystemColors.ControlText;
			this.optMaxSpeed.Location = new System.Drawing.Point(8, 88);
			this.optMaxSpeed.Name = "optMaxSpeed";
			this.optMaxSpeed.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.optMaxSpeed.Size = new System.Drawing.Size(89, 17);
			this.optMaxSpeed.TabIndex = 28;
			this.optMaxSpeed.TabStop = true;
			this.optMaxSpeed.Text = "őXs[h";
			// 
			// optManual
			// 
			this.optManual.BackColor = System.Drawing.SystemColors.Control;
			this.optManual.Checked = true;
			this.optManual.Cursor = System.Windows.Forms.Cursors.Default;
			this.optManual.ForeColor = System.Drawing.SystemColors.ControlText;
			this.optManual.Location = new System.Drawing.Point(8, 16);
			this.optManual.Name = "optManual";
			this.optManual.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.optManual.Size = new System.Drawing.Size(81, 15);
			this.optManual.TabIndex = 27;
			this.optManual.TabStop = true;
			this.optManual.Text = "}jA";
			// 
			// lblTimerUnit
			// 
			this.lblTimerUnit.AutoSize = true;
			this.lblTimerUnit.BackColor = System.Drawing.SystemColors.Control;
			this.lblTimerUnit.Cursor = System.Windows.Forms.Cursors.Default;
			this.lblTimerUnit.ForeColor = System.Drawing.SystemColors.ControlText;
			this.lblTimerUnit.Location = new System.Drawing.Point(120, 56);
			this.lblTimerUnit.Name = "lblTimerUnit";
			this.lblTimerUnit.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.lblTimerUnit.Size = new System.Drawing.Size(33, 12);
			this.lblTimerUnit.TabIndex = 32;
			this.lblTimerUnit.Text = "mSec";
			// 
			// cmdDataDel
			// 
			this.cmdDataDel.BackColor = System.Drawing.SystemColors.Control;
			this.cmdDataDel.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdDataDel.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdDataDel.Location = new System.Drawing.Point(568, 168);
			this.cmdDataDel.Name = "cmdDataDel";
			this.cmdDataDel.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdDataDel.Size = new System.Drawing.Size(113, 25);
			this.cmdDataDel.TabIndex = 54;
			this.cmdDataDel.Text = "f[^";
			this.cmdDataDel.Click += new System.EventHandler(this.cmdDataDel_Click);
			// 
			// cmdRetDel
			// 
			this.cmdRetDel.BackColor = System.Drawing.SystemColors.Control;
			this.cmdRetDel.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdRetDel.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdRetDel.Location = new System.Drawing.Point(568, 432);
			this.cmdRetDel.Name = "cmdRetDel";
			this.cmdRetDel.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdRetDel.Size = new System.Drawing.Size(113, 25);
			this.cmdRetDel.TabIndex = 53;
			this.cmdRetDel.Text = "߂l";
			this.cmdRetDel.Click += new System.EventHandler(this.cmdRetDel_Click);
			// 
			// cmdInit
			// 
			this.cmdInit.BackColor = System.Drawing.SystemColors.Control;
			this.cmdInit.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdInit.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdInit.Location = new System.Drawing.Point(328, 24);
			this.cmdInit.Name = "cmdInit";
			this.cmdInit.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdInit.Size = new System.Drawing.Size(113, 25);
			this.cmdInit.TabIndex = 46;
			this.cmdInit.Text = "(&I)";
			this.cmdInit.Click += new System.EventHandler(this.cmdInit_Click);
			// 
			// Frame3
			// 
			this.Frame3.BackColor = System.Drawing.SystemColors.Control;
			this.Frame3.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.txtAddr,
																				 this.cmdSearch,
																				 this.cboEoi,
																				 this.cboDelim,
																				 this.cboAddr,
																				 this.Label5,
																				 this.Label4,
																				 this.Label3});
			this.Frame3.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Frame3.Location = new System.Drawing.Point(8, 64);
			this.Frame3.Name = "Frame3";
			this.Frame3.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Frame3.Size = new System.Drawing.Size(553, 81);
			this.Frame3.TabIndex = 49;
			this.Frame3.TabStop = false;
			this.Frame3.Text = "@";
			// 
			// txtAddr
			// 
			this.txtAddr.AcceptsReturn = true;
			this.txtAddr.AutoSize = false;
			this.txtAddr.BackColor = System.Drawing.SystemColors.Window;
			this.txtAddr.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtAddr.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtAddr.Location = new System.Drawing.Point(88, 16);
			this.txtAddr.MaxLength = 0;
			this.txtAddr.Name = "txtAddr";
			this.txtAddr.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtAddr.Size = new System.Drawing.Size(73, 18);
			this.txtAddr.TabIndex = 36;
			this.txtAddr.Text = "Text1";
			// 
			// cmdSearch
			// 
			this.cmdSearch.BackColor = System.Drawing.SystemColors.Control;
			this.cmdSearch.Cursor = System.Windows.Forms.Cursors.Default;
			this.cmdSearch.ForeColor = System.Drawing.SystemColors.ControlText;
			this.cmdSearch.Location = new System.Drawing.Point(432, 48);
			this.cmdSearch.Name = "cmdSearch";
			this.cmdSearch.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cmdSearch.Size = new System.Drawing.Size(113, 25);
			this.cmdSearch.TabIndex = 15;
			this.cmdSearch.Text = "@팟(&F)";
			this.cmdSearch.Click += new System.EventHandler(this.cmdSearch_Click);
			// 
			// cboEoi
			// 
			this.cboEoi.BackColor = System.Drawing.SystemColors.Window;
			this.cboEoi.Cursor = System.Windows.Forms.Cursors.Default;
			this.cboEoi.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboEoi.ForeColor = System.Drawing.SystemColors.WindowText;
			this.cboEoi.Items.AddRange(new object[] {
														"o͂Ȃ",
														"o͂"});
			this.cboEoi.Location = new System.Drawing.Point(272, 48);
			this.cboEoi.Name = "cboEoi";
			this.cboEoi.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cboEoi.Size = new System.Drawing.Size(113, 20);
			this.cboEoi.TabIndex = 14;
			// 
			// cboDelim
			// 
			this.cboDelim.BackColor = System.Drawing.SystemColors.Window;
			this.cboDelim.Cursor = System.Windows.Forms.Cursors.Default;
			this.cboDelim.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboDelim.ForeColor = System.Drawing.SystemColors.WindowText;
			this.cboDelim.Items.AddRange(new object[] {
														  "gpȂ",
														  "CR+LF",
														  "CR",
														  "LF"});
			this.cboDelim.Location = new System.Drawing.Point(88, 48);
			this.cboDelim.Name = "cboDelim";
			this.cboDelim.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cboDelim.Size = new System.Drawing.Size(113, 20);
			this.cboDelim.TabIndex = 13;
			// 
			// cboAddr
			// 
			this.cboAddr.BackColor = System.Drawing.SystemColors.Window;
			this.cboAddr.Cursor = System.Windows.Forms.Cursors.Default;
			this.cboAddr.ForeColor = System.Drawing.SystemColors.WindowText;
			this.cboAddr.Location = new System.Drawing.Point(176, 16);
			this.cboAddr.Name = "cboAddr";
			this.cboAddr.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cboAddr.Size = new System.Drawing.Size(369, 20);
			this.cboAddr.TabIndex = 12;
			// 
			// Label5
			// 
			this.Label5.BackColor = System.Drawing.SystemColors.Control;
			this.Label5.Cursor = System.Windows.Forms.Cursors.Default;
			this.Label5.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Label5.Location = new System.Drawing.Point(8, 16);
			this.Label5.Name = "Label5";
			this.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Label5.Size = new System.Drawing.Size(81, 17);
			this.Label5.TabIndex = 11;
			this.Label5.Text = "@AhX =";
			// 
			// Label4
			// 
			this.Label4.BackColor = System.Drawing.SystemColors.Control;
			this.Label4.Cursor = System.Windows.Forms.Cursors.Default;
			this.Label4.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Label4.Location = new System.Drawing.Point(224, 48);
			this.Label4.Name = "Label4";
			this.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Label4.Size = new System.Drawing.Size(49, 17);
			this.Label4.TabIndex = 10;
			this.Label4.Text = "EOI =";
			// 
			// Label3
			// 
			this.Label3.BackColor = System.Drawing.SystemColors.Control;
			this.Label3.Cursor = System.Windows.Forms.Cursors.Default;
			this.Label3.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Label3.Location = new System.Drawing.Point(8, 48);
			this.Label3.Name = "Label3";
			this.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Label3.Size = new System.Drawing.Size(81, 17);
			this.Label3.TabIndex = 9;
			this.Label3.Text = "f~^ =";
			// 
			// Frame1
			// 
			this.Frame1.BackColor = System.Drawing.SystemColors.Control;
			this.Frame1.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.txtMyAddr,
																				 this.txtDevName,
																				 this.Label2,
																				 this.Label1});
			this.Frame1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Frame1.Location = new System.Drawing.Point(8, 8);
			this.Frame1.Name = "Frame1";
			this.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Frame1.Size = new System.Drawing.Size(313, 49);
			this.Frame1.TabIndex = 45;
			this.Frame1.TabStop = false;
			this.Frame1.Text = "@";
			// 
			// txtMyAddr
			// 
			this.txtMyAddr.AcceptsReturn = true;
			this.txtMyAddr.AutoSize = false;
			this.txtMyAddr.BackColor = System.Drawing.SystemColors.Window;
			this.txtMyAddr.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtMyAddr.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtMyAddr.Location = new System.Drawing.Point(256, 16);
			this.txtMyAddr.MaxLength = 0;
			this.txtMyAddr.Name = "txtMyAddr";
			this.txtMyAddr.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtMyAddr.Size = new System.Drawing.Size(33, 25);
			this.txtMyAddr.TabIndex = 4;
			this.txtMyAddr.Text = "";
			// 
			// txtDevName
			// 
			this.txtDevName.AcceptsReturn = true;
			this.txtDevName.AutoSize = false;
			this.txtDevName.BackColor = System.Drawing.SystemColors.Window;
			this.txtDevName.Cursor = System.Windows.Forms.Cursors.IBeam;
			this.txtDevName.ForeColor = System.Drawing.SystemColors.WindowText;
			this.txtDevName.Location = new System.Drawing.Point(80, 16);
			this.txtDevName.MaxLength = 0;
			this.txtDevName.Name = "txtDevName";
			this.txtDevName.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.txtDevName.Size = new System.Drawing.Size(73, 25);
			this.txtDevName.TabIndex = 2;
			this.txtDevName.Text = "";
			// 
			// Label2
			// 
			this.Label2.BackColor = System.Drawing.SystemColors.Control;
			this.Label2.Cursor = System.Windows.Forms.Cursors.Default;
			this.Label2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Label2.Location = new System.Drawing.Point(176, 24);
			this.Label2.Name = "Label2";
			this.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Label2.Size = new System.Drawing.Size(81, 17);
			this.Label2.TabIndex = 3;
			this.Label2.Text = "@AhX =";
			// 
			// Label1
			// 
			this.Label1.BackColor = System.Drawing.SystemColors.Control;
			this.Label1.Cursor = System.Windows.Forms.Cursors.Default;
			this.Label1.ForeColor = System.Drawing.SystemColors.ControlText;
			this.Label1.Location = new System.Drawing.Point(8, 24);
			this.Label1.Name = "Label1";
			this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.Label1.Size = new System.Drawing.Size(81, 17);
			this.Label1.TabIndex = 1;
			this.Label1.Text = "foCX =";
			// 
			// dlgSaveCsv
			// 
			this.dlgSaveCsv.FileName = "doc1";
			// 
			// Form_conrec
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
			this.ClientSize = new System.Drawing.Size(696, 494);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.Frame4,
																		  this.cmdExit,
																		  this.Frame2,
																		  this.Frame6,
																		  this.cmdDataDel,
																		  this.cmdRetDel,
																		  this.cmdInit,
																		  this.Frame3,
																		  this.Frame1,
																		  this.Frame5});
			this.Name = "Form_conrec";
			this.Text = "ConRec";
			this.Load += new System.EventHandler(this.Form_conrec_Load);
			this.Frame5.ResumeLayout(false);
			this.Frame4.ResumeLayout(false);
			this.Frame2.ResumeLayout(false);
			this.Frame6.ResumeLayout(false);
			this.Frame3.ResumeLayout(false);
			this.Frame1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

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

		//**************************************************************************************************
		//   lݒ
		//**************************************************************************************************
		private void Form_conrec_Load(object sender, System.EventArgs e)
		{
			txtDevName.Text			= "GPIB000";
			txtTimerInterval.Text	= "1000";	//1000mSec
			txtAddr.Text			= "0";
			txtSend.Text			= "CONTEC ConRec Sample";
			cboDelim.SelectedIndex	= 1;		//CR+LF
			cboEoi.SelectedIndex	= 1;		//o͂
		}

		//**************************************************************************************************
		//   nꂽ߂lXg{bNXɔf܂(Tu[`)
		//**************************************************************************************************
		private void funcSetlstRet(string strRet)
		{
			//Xg{bNX̍Ōɍڂǉ܂
			//256ڂ𒴂ƍڂSč폜܂
			if (lstRet.Items.Count >= 256)
			{
				lstRet.Items.RemoveAt(0);
				lstRet.Items.Add(strRet);
			}
			else
			{
				lstRet.Items.Add(strRet);
			}
			lstRet.SelectedIndex = lstRet.Items.Count - 1;
		}

		//**************************************************************************************************
		//   nꂽMf[^Xg{bNXɔf܂(Tu[`)
		//**************************************************************************************************
		private void funcSetlstSrqRecData(string strRet)
		{
			//Xg{bNX̍Ōɍڂǉ܂
			//256ڂ𒴂ƍڂSč폜܂
			if (lstEventRec.Items.Count >= 256)
			{
				lstEventRec.Items.RemoveAt(0);
				lstEventRec.Items.Add(strRet);
			}
			else
			{
				lstEventRec.Items.Add(strRet);
			}
			lstRet.SelectedIndex = lstRet.Items.Count - 1;
		}

		//**************************************************************************************************
		//   @̐ݒ(Tu[`)
		//   @\FEquipent IDEf~^EEOI̐ݒs܂
		//   ߂lF    true(), false(ُ)
		//**************************************************************************************************
		private bool funcSetParam()
		{
			short	Delim;
			short	Eoi;
			short	Eos;
			short	PrmAddr;
			int		Ret;
			string	strRet;

			//@킪oĂ΁AoĂ@w
			if (cboAddr.Items.Count != 0) 
			{
				//R{{bNXŎw肳Ă@̃CNEBbvgID擾
				m_SelectEqpId = m_EqpId[cboAddr.SelectedIndex];
			} 
			else 
			{
				//GfBbg{bNXŎw肳Ă@AhX̃CNEBbvgID擾
				Delim	= (short)cboDelim.SelectedIndex;
				PrmAddr	= short.Parse(txtAddr.Text);
				Ret = gpib.SetEquipment(	m_Id,				//Device ID
											out m_SelectEqpId,	//擾Equipent ID
											PrmAddr,			//ꎟAhX
											0,					//񎟃AhX
											Delim);				//f~^ݒ
				if (Ret != 0) 
				{
					//G[̏ꍇ
					gpib.GetErrorString(Ret, out strRet);
					funcSetlstRet(strRet);		//Xgɕ\
					return false;
				}
			}

			//f~^R[hEOIC̐ݒ
			Delim	= (short)cboDelim.SelectedIndex;
			Eoi		= (short)cboEoi.SelectedIndex;
			Eos		= 0;
			Ret	= gpib.SetDelim(	m_SelectEqpId,
				Delim,			//f~^R[h̐ݒ
				Eoi,			//EOIC̐ݒ
				Eos);			//EOS̐ݒi\j
			if (Ret != 0)
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);			//Xgɕ\
			}
			else
			{
				funcSetlstRet("u@̐ݒvI");	//Xgɕ\
			}
			return true;
		}

		//**************************************************************************************************
		//   
		//   @\FfoCXfoCXID擾
		//**************************************************************************************************
		private void cmdInit_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			int		Data;
			string	strRet;

			Ret = gpib.Init(txtDevName.Text, out m_Id);
			if (Ret != 0) 
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);			//Xgɕ\
			} 
			else  
			{
				//ɃfoCXID擾łꍇ
				strRet = "GpibInit : foCXID = " + m_Id;
				funcSetlstRet(strRet);	//Xgɕ\
				//@AhX̎擾
				Ret = gpib.GetStatus(m_Id, 0x08, out Data);
				if (Ret == 0)
				{
					txtMyAddr.Text = Data.ToString();
				}
				//}X^ɐݒ肳Ă邩ǂ̊mF
				Ret = gpib.GetStatus(m_Id, 0x0A, out Data);
				if ((Ret == 0) && (Data == 1)) 
				{
					MessageBox.Show("}X^ɐݒ肳Ă܂BvpeBŃ}X^ɐݒ肵ĂB");
				} 
				else 
				{
					strRet = "uvI";
					funcSetlstRet(strRet);	//Xgɕ\
				}
			}

			gpib.SendIFC(m_Id, 1);	//IFC𑗏o
		}

		//**************************************************************************************************
		//   I
		//   @\FfoCXID𖳌ɂ
		//**************************************************************************************************
		private void cmdExit_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			string	strRet;

			Ret = gpib.Exit(m_Id);
			if (Ret != 0) 
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);	//Xgɕ\
			}
			this.Close();
		}

		//**************************************************************************************************
		//   @̌
		//   @\FfoCXIDɑ@ACNEBbvgID擾B
		//         ܂ACNEBbvgID̑@IEEE488.2ʃR}hu*IDN?v𑗐M
		//         @IDi[JAfԍj擾
		//**************************************************************************************************
		private void cmdSearch_Click(object sender, System.EventArgs e)
		{
			short	PrmAddr;
			short	ScdAddr;
			short	ArraySize;
			short	ArrayCount;
			short[]	AddrArray = new short[32];
			int		Ret;
			int		SendLen;
			int		RecLen;	
			string	RecBuf;
			string	strRet;
			string	SendBuf;
			string	EqpInforBuf;

			PrmAddr		= -1;	//SĂ̈ꎟAhX
			ScdAddr		= 0;	//񎟃AhXȂ
			ArraySize	= 32;	//o@퐔w
			Ret = gpib.FindListener(m_Id, PrmAddr, ScdAddr, ref ArraySize, AddrArray);
			if (Ret != 0) 
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);	//Xgɕ\
				return;
			} 
			//ɌłꍇA o@퐔̕\s
			strRet = "GpibFindListener : o@퐔 = " + ArraySize;
			funcSetlstRet(strRet);	//Xgɕ\

			//oꂽ@̋@擾
			cboAddr.ResetText();	//R{{bNX̍ڂ
			for (ArrayCount = 0; ArrayCount < ArraySize; ArrayCount++) 
			{
				//Equipent ID̎擾
				Ret = gpib.SetEquipment(
					m_Id,							//Device ID
					out m_EqpId[ArrayCount],		//擾Equipent ID
					AddrArray[ArrayCount],			//ꎟAhX
					0,								//񎟃AhX
					(short)cboDelim.SelectedIndex	//f~^ݒ
					);
				if (Ret != 0) 
				{
					//G[̏ꍇ
					gpib.GetErrorString(Ret, out strRet);
					funcSetlstRet(strRet);	//Xgɕ\
					continue;
				}
		
				//@₢킹iMj
				SendBuf = "*IDN?";	//Mf[^
				SendLen = SendBuf.Length;	//Mf[^
				Ret = gpib.SendData(m_EqpId[ArrayCount], ref SendLen, SendBuf);
				if (Ret != 0) 
				{
					//G[̏ꍇ
					gpib.GetErrorString(Ret, out strRet);
					funcSetlstRet(strRet);	//Xgɕ\
					continue;
				}

				//@₢킹iMj
				RecLen = 256;	//Mobt@TCYw
				Ret = gpib.RecData(m_EqpId[ArrayCount], ref RecLen, out RecBuf);
				if (Ret != 0) 
				{
					//G[̏ꍇ
					gpib.GetErrorString(Ret, out strRet);
					funcSetlstRet(strRet);	//Xgɕ\
					continue;
				}

				//Mf[^IEEE488.2KimF
				if (RecBuf.IndexOf(",") != -1) 
				{
					//AhX
					EqpInforBuf = "Address:" + AddrArray[ArrayCount] + RecBuf;
				} 
				else 
				{
					//Mf[^IEEE488.2KiłȂꍇAAhX̂
					EqpInforBuf = "Address:" + AddrArray[ArrayCount];
				}
				//oς݂̋@탊Xgɒǉ
				cboAddr.Items.Insert(ArrayCount, EqpInforBuf);
				cboAddr.SelectedIndex = ArrayCount;
			}

			//oς݂̋@R{{bNXAGfBbg{bNXɔf
			if(cboAddr.SelectedIndex != -1)
			{
				txtAddr.Text = AddrArray[cboAddr.SelectedIndex].ToString();
			}
		}

		//**************************************************************************************************
		//   f[^̑M
		//   @\FX[u@Ƀf[^𑗐M
		//**************************************************************************************************
		private void cmdSend_Click(object sender, System.EventArgs e)
		{
			int		SendLen;
			int		Ret;
			string	strRet;
			string	SendBuf;

			//Equipent IDEf~^EEOI̐ݒ
			if (funcSetParam() == false) return;

			//GfBbg{bNX瑗Mf[^擾
			SendBuf = txtSend.Text;
			SendLen = SendBuf.Length;
			if (SendLen == 0) 
			{
				strRet = "GpibSendData : Mf[^܂";
				funcSetlstRet(strRet);	//Xgɕ\
				return;
			}

			funcSetlstRet("GpibSendData : M...");	//Xgɕ\
			//Ms
			Ret = gpib.SendData(m_SelectEqpId, ref SendLen, SendBuf);
			if (Ret != 0) 
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);	//Xgɕ\
			} 
			else  
			{
				//ɑMłꍇ
				strRet = "GpibSendData : Mf[^ = " + SendLen;
				funcSetlstRet(strRet);	//Xgɕ\
				funcSetlstRet("uf[^̑MvI");	//Xgɕ\
			}
		}

		//**************************************************************************************************
		//   f[^̎M
		//   @\FX[u@킩f[^M
		//**************************************************************************************************
		private void cmdRec_Click(object sender, System.EventArgs e)
		{
			int		RecLen;
			int		Ret;
			string	strRet;
			string	RecBuf;

			//Equipent IDEf~^EEOI̐ݒ
			if (funcSetParam() == false) return;

			RecLen = 256;	//Mobt@TCYw
			funcSetlstRet("GpibRecData : M...");	//Xgɕ\
			//Ms
			Ret = gpib.RecData(m_SelectEqpId, ref RecLen, out RecBuf);
			if (Ret != 0) 
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);	//Xgɕ\
			} 
			else 
			{
				//ɎMłꍇ
				txtRec.Text = RecBuf.Substring(0,RecLen);
				strRet = "GpibRecData : Mf[^ = " + RecLen;
				funcSetlstRet(strRet);	//Xgɕ\
				strRet = "uf[^̎MvI";
				funcSetlstRet(strRet);	//Xgɕ\
			}
		}

		//**************************************************************************************************
		//   MeLXgf[^
		//**************************************************************************************************
		private void cmdDataDel_Click(object sender, System.EventArgs e)
		{
			txtSend.Text	= "";
			txtRec.Text		= "";
			
			//Xg{bNX̍ڂ폜
			lstEventRec.Items.Clear();
		}

		//**************************************************************************************************
		//   ߂lf[^
		//**************************************************************************************************
		private void cmdRetDel_Click(object sender, System.EventArgs e)
		{
			//Xg{bNX̍ڂ폜
			lstRet.Items.Clear();		
		}

		//**************************************************************************************************
		//   }jA^C~O̊Jn
		//   @\FGETR}h𑗐M
		//         @ɂĂGETR}hł͐ɓ삵Ȃꍇ܂̂
		//         @̎dlɂ킹ĕύXĂ
		//**************************************************************************************************
		private void cmdSrqRecTrigger_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			string	strRet;

			if (funcSetParam() == false) return;

			//GETR}hM֐̎s
			Ret = gpib.SendTrigger(m_SelectEqpId);
			if (Ret != 0) 
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);	//Xgɕ\
			} 
			else 
			{
				funcSetlstRet("uGETR}h̑MvI");	//Xgɕ\
			}
		}

		//**************************************************************************************************
		//   SRQCxgMJn
		//   @\FSRQLɂȂꍇMs
		//**************************************************************************************************
		private void cmdEventRecStart_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			string	strRet;

			//^C}IĂ΃^C}N
			if (optTimer.Checked == true) 
			{
				tmrTimerEventRec.Interval = short.Parse(txtTimerInterval.Text);
				tmrTimerEventRec.Enabled = true;
			}
			//őXs[hIĂ΃gKs
			if (optMaxSpeed.Checked == true) 
			{
				cmdSrqRecTrigger_Click(cmdSrqRecTrigger, new System.EventArgs());
			}

			//Cxgݒ֐̎s(SRQMŃCxg)
			Ret = gpib.SetNotifySignal(m_Id, (uint)Handle, 0x0020);
			if (Ret != 0) 
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);	//Xgɕ\
			} 
			else 
			{
				cmdEventRecStart.Enabled	= false;
				cmdEventRecStop.Enabled		= true;
				funcSetlstRet("uSRQCxgMJnvI");	//Xgɕ\
			}
		}

		//**************************************************************************************************
		//   SRQCxgM~
		//   @\FCxgM~
		//**************************************************************************************************
		private void cmdEventRecStop_Click(object sender, System.EventArgs e)
		{
			int		Ret;
			string	strRet;

			//^C}IĂ΃^C}~
			if (optTimer.Checked == true) 
			{
				tmrTimerEventRec.Enabled = false;
			}
			//Cxgݒ֐̎s(SRQMCxg̃LZ)
			Ret = gpib.SetNotifySignal(m_Id, (uint)Handle, 0x0000);
			if (Ret != 0) 
			{
				//G[̏ꍇ
				gpib.GetErrorString(Ret, out strRet);
				funcSetlstRet(strRet);	//Xgɕ\
			} 
			else 
			{
				cmdEventRecStart.Enabled	= true;
				cmdEventRecStop.Enabled		= false;
				funcSetlstRet("uSRQCxgM~vI");	//Xgɕ\
			}
		}

		//**************************************************************************************************
		//   Mf[^CSVt@Cŕۑ
		//**************************************************************************************************
		private void cmdSaveCsv_Click(object sender, System.EventArgs e)
		{
			string			strFileDataBuf;
			short			i;
			FileStream		OutFile = null;
			StreamWriter	FileWriter = null; 

			dlgSaveCsv.FileName			= "ConRec.csv";		//ftHgt@C
			dlgSaveCsv.DefaultExt		= "csv";
			dlgSaveCsv.Title			= "Mf[^ۑ";	//_CAO^Cg
			dlgSaveCsv.InitialDirectory	= Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //ŏɊJtH_AvP[VpXɐݒ
			dlgSaveCsv.Filter			= "csv files(*.csv)|*.csv|All files (*.*)|*.*";

			//_CAO\
			if (dlgSaveCsv.ShowDialog() != DialogResult.OK)
			{
				return;
            }

			OutFile		= new FileStream(dlgSaveCsv.FileName, FileMode.Create, FileAccess.Write);
			FileWriter	= new StreamWriter(OutFile, System.Text.Encoding.GetEncoding("Shift_JIS")); 
			
			//t@CɃf[^
			strFileDataBuf = "M,Mf[^\n";
			FileWriter.Write(strFileDataBuf);

			for(i = 0; i < lstEventRec.Items.Count; i++)
			{
				strFileDataBuf = i + "," + lstEventRec.Items[i] + "\n";
				FileWriter.Write(strFileDataBuf);
			}
			//t@C
			FileWriter.Close();
			OutFile.Close();
		}

		//**************************************************************************************************
		//   ^C}CxgJn
		//   @\FԊuŃgKs
		//**************************************************************************************************
		private void tmrTimerEventRec_Tick(object sender, System.EventArgs e)
		{
			cmdSrqRecTrigger_Click(cmdSrqRecTrigger, new System.EventArgs());
		}

		//**************************************************************************************************
		//   SRQCxgM
		//   @\FSRQCLɂȂꍇɃVA|[EMs
		//**************************************************************************************************
		[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
		protected override void WndProc(ref Message m)
		{
			short	Stb;
			short	Srq;
			int		RecLen;
			int		Ret;
			string	strRet;
			string	RecBuf;

			//----------------------------------------
			//   SRQMꍇ̏
			//----------------------------------------
			if (m.Msg == GPIB_NOTIFY_MESSAGE) 
			{
				if ((m.WParam.ToInt32() & 0x0020) != 0) 
				{
					//Equipent IDEf~^EEOI̐ݒ
					if (funcSetParam() == false) goto cmsNotifySignalEventEnd;
		
					funcSetlstRet("GpibSPoll : VA|[...");	//Xgɕ\

					//VA|[֐̎s
					Ret = gpib.SPoll(m_SelectEqpId, out Stb, out Srq);
					if (Ret != 0) 
					{
						//G[̏ꍇ
						gpib.GetErrorString(Ret, out strRet);
						funcSetlstRet(strRet);	//Xgɕ\
						//VA|[ŃG[ꍇASRQM~܂
						cmdEventRecStop_Click(cmdEventRecStop, new System.EventArgs());
						return;
					} 
					else 
					{
						strRet = string.Format("GpibSPoll : Xe[^XoCg = {0:X2}(H) SRQ C = {1:X2}(H)", Stb, Srq);
						funcSetlstRet(strRet);	//Xgɕ\
						funcSetlstRet("uVA|[̎svI");	//Xgɕ\
					}

					//   f[^̎M
					RecLen = 256;	//Mobt@TCYw
					funcSetlstRet("GpibRecData : M...");	//Xgɕ\
					//Ms
					Ret = gpib.RecData(m_SelectEqpId, ref RecLen, out RecBuf);
					if (Ret != 0) 
					{
						//G[̏ꍇ
						gpib.GetErrorString(Ret, out strRet);
						funcSetlstRet(strRet);	//Xgɕ\
						//f[^̎MŃG[ꍇASRQM~܂
						cmdEventRecStop_Click(cmdEventRecStop, new System.EventArgs());
						return;
					} 
					else 
					{
						//ɎMłꍇ
						RecBuf	= RecBuf.Substring(0,RecLen);
						funcSetlstSrqRecData(RecBuf);	//Mf[^Xgɕ\
						strRet	= "GpibRecData : Mf[^ = " + RecLen;
						funcSetlstRet(strRet);	//Xgɕ\
						funcSetlstRet("uf[^̎MvI");	//Xgɕ\
					}

					//őXs[hIĂ΃gKs
					if (optMaxSpeed.Checked == true) 
					{
						cmdSrqRecTrigger_Click(cmdSrqRecTrigger, new System.EventArgs());
					}
				}

				cmsNotifySignalEventEnd:
					//----------------------------------------
					//   ēxCxg҂ݒ
					//----------------------------------------
					//Cxgݒ֐̎s
					Ret = gpib.SetNotifySignal(m_Id, (uint)Handle, 0x0020);
					//߂l
					if (Ret != 0) 
					{
						//G[̏ꍇ
						gpib.GetErrorString(Ret, out strRet);
						funcSetlstRet(strRet);	//Xgɕ\
					}
			}
			base.WndProc(ref m);
		}
	}
}
