private void SaveSetting(string fileName, ScanPara2D setting) { fs = new FileStream(fileName, FileMode.Create); serializer.Serialize(fs, setting); fs.Close(); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { this.sfd_setting.FileName = DateTime.Now.ToString("yyyyMMdd_HHmm") + "Setting_2DScan.xml"; this.sfd_setting.Filter = "2DScan Setting(*Setting_2DScan.xml)|*Setting_2DScan.xml"; if (this.sfd_setting.ShowDialog() == DialogResult.OK) { ScanPara2D setting = new ScanPara2D(); SetParameter(out setting); SaveSetting(this.sfd_setting.FileName, setting); } }
bool SetParameter(out ScanPara2D _pm) { _pm = new ScanPara2D(); bool success = true; success &= Int32.TryParse(this.textBox_XStart.Text, out _pm.XStart); success &= Int32.TryParse(this.textBox_XPitch.Text, out _pm.XPitch); success &= Int32.TryParse(this.textBox_XNum.Text, out _pm.XNum); success &= Int32.TryParse(this.textBox_ZStart.Text, out _pm.ZStart); success &= Int32.TryParse(this.textBox_ZPitch.Text, out _pm.ZPitch); success &= Int32.TryParse(this.textBox_ZNum.Text, out _pm.ZNum); success &= Double.TryParse(this.textBox_ExposureTime.Text, out _pm.dExposTime); success &= Double.TryParse(this.textBox_WaitTime.Text, out _pm.dWaitTime); _pm.EH = this.comboBox_EH.SelectedIndex+1; _pm.vme = this.form1.vme; if (this.radioButton_Focus2.Checked) { _pm.fsX = this.form1.fs1nmX; _pm.fsZ = this.form1.fs1nmZ; _pm.axisX = 1; _pm.axisZ = 1; } else if (this.radioButton_Focus1.Checked) { _pm.fsX = this.form1.fs5nm; _pm.fsZ = this.form1.fs5nm; _pm.axisX = this.form1.Axis5nmX; _pm.axisZ = this.form1.Axis5nmZ; } else success = false; if (this.radioButton_VectorScan.Checked) _pm.scanMethod = ScanPara2D.ScanMethod.vector; else _pm.scanMethod = ScanPara2D.ScanMethod.raster; _pm.strChName=new string[nCh]; for (int i = 0; i < nCh; i++) _pm.strChName[i] = txBox[i].Text; _pm.fbd = this.fbd.SelectedPath; _pm.savedir = this.textBox_DirName.Text; return success; }
private void button_ScanReserveAdd_Click(object sender, EventArgs e) { ScanPara2D _pm = new ScanPara2D(); if (!SetParameter(out _pm)) return; qList.Add(_pm); this.listBox_ScanReserve.Items.Add(_pm.ToString()); }
private async void button_ScanStart_Click(object sender, EventArgs e) { this.button_ScanStart.Enabled = false; this.button_ScanStop.Enabled = true; #region caution if (scan2D.IsScan) { MessageBox.Show("スキャン中です"); return; } if (!this.form1.vme.IsConnect) { MessageBox.Show("VMEサーバ未接続"); return; } #endregion try { do { #region Parameterの設定 if (qList.Count == 0) { if (!SetParameter(out pm)) { MessageBox.Show(""); return; } } else { pm = qList[0]; qList.RemoveAt(0); this.listBox_ScanReserve.Items.RemoveAt(0); } #endregion #region 保存先設定 //fbd\\scan2D0000F2R(\\data.csv) string f = this.radioButton_Focus1.Checked ? "F1" : "F2"; string s = this.radioButton_RasterScan.Checked ? "R" : "V"; string saveDir = this.fbd.SelectedPath + "\\" + this.textBox_DirName.Text + ((int)this.numericUpDown_DirNum.Value).ToString("D4") + f + s; #endregion #region スキャン開始 //スキャン初期化 scan2D.Init(pm); await Task.Run(() => scan2D.TaskScan(saveDir)); #endregion //設定を保存 SaveSetting(saveDir + "\\Setting_2DScan.xml", pm); this.button_ScanStop.Text = "Scan Stop"; this.numericUpDown_DirNum.Value++; } while (qList.Count > 0); } finally { this.button_ScanStart.Enabled = true; this.button_ScanStop.Enabled = false; } }