private void Form1_Load(object sender, EventArgs e) { return; InitSystemParam(); // TestReport.MakeReport(); //this.Controls.Add(this.m_ImageBox); AcqConfigDlg acConfigDlg = new AcqConfigDlg(null, "", AcqConfigDlg.ServerCategory.ServerAcq); if (acConfigDlg.InitServerCombo()) { m_online = true; } else { m_online = false; } if (m_online) { //SerialFunc.SerialPortName = "COM2"; if (!SerialFunc.OpenSerialPort()) { this.Close(); } } else { toolStripButton3.Enabled = false; toolStripButton6.Enabled = false; toolStripButton8.Enabled = false; toolStripButton7.Enabled = false; m_Buffers = new SapBuffer(1, 600, 480, SapFormat.Mono16, SapBuffer.MemoryType.ScatterGather); //m_View = new SapView(m_Buffers); StatusLabelInfo.Text = "offline... Load images"; float WidthScalor = (float)(splitContainer1.Panel2.Size.Width) / m_Buffers.Width; float HeightScalor = (float)(splitContainer1.Panel2.Size.Height) / m_Buffers.Height; //m_View.SetScalingMode(WidthScalor, HeightScalor); } //m_ImageBox.View = m_View; if (!CreateObjects()) { DisposeObjects(); return; } //m_ImageBox.OnSize(); for (int i = 0; i < listView1.Items.Count; i++) { listView1.Items[i].SubItems.Add(""); listView1.Items[i].SubItems.Add(""); } //EnableSignalStatus(); }
/// <summary> /// 打开相机 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_opencamera_Click(object sender, EventArgs e) { AcqConfigDlg acConfigDlg = new AcqConfigDlg(null, "", AcqConfigDlg.ServerCategory.ServerAcqDevice); if (acConfigDlg.ShowDialog() == DialogResult.OK) { if (!CreateNewObjects(acConfigDlg, false)) { this.Close(); } } else { MessageBox.Show("No GigE-Vision cameras found or selected"); this.Close(); } }
private void button_LoadConfig_Click(object sender, EventArgs e) { _dalsaCore.DestroyObjects(); var acConfigDlg = new AcqConfigDlg(null, "", AcqConfigDlg.ServerCategory.ServerAcq); if (acConfigDlg.ShowDialog() == DialogResult.OK) { var onlineSave = _dalsaCore.Online; _dalsaCore.Online = true; var serverLocationSave = _dalsaCore.Location; _dalsaCore.DestroyObjects(); _dalsaConfig.FileName = acConfigDlg.m_ConfigFile; _dalsaConfig.ResourceIndex = acConfigDlg.m_ResourceIndex; _dalsaConfig.ServerName = acConfigDlg.m_ServerName; if (!_dalsaCore.CreateNewObjects(acConfigDlg.ServerLocation, _dalsaConfig.FileName, false)) { MessageBox.Show("New objects creation has failed. Restoring original object "); _dalsaCore.Location = serverLocationSave; _dalsaCore.Online = onlineSave; if (!_dalsaCore.CreateNewObjects(null, "", true)) { MessageBox.Show("Original object creation has failed. Closing application "); Application.Exit(); } } _dalsaConfig.Width = _dalsaCore.m_View.Buffer.Width; _dalsaConfig.Height = _dalsaCore.m_View.Buffer.Height; _dalsaCore.ObjSize = _dalsaConfig.Width * _dalsaConfig.Height; textBoxWidth.Text = _dalsaConfig.Width.ToString(); textBoxHeight.Text = _dalsaConfig.Height.ToString(); } else { MessageBox.Show("No Modification in Acquisition"); } }
/// <summary> /// 初始化设备 /// </summary> /// <param name="acConfigDlg"></param> /// <param name="Restore"></param> /// <returns></returns> public bool CreateNewObjects(AcqConfigDlg acConfigDlg, bool Restore) { if (!Restore) { m_ServerLocation = acConfigDlg.ServerLocation; m_ConfigFileName = acConfigDlg.ConfigFile; } m_AcqDevice = new SapAcqDevice(m_ServerLocation, m_ConfigFileName); if (SapBuffer.IsBufferTypeSupported(m_ServerLocation, SapBuffer.MemoryType.ScatterGather)) { m_Buffers = new SapBufferWithTrash(2, m_AcqDevice, SapBuffer.MemoryType.ScatterGather); } else { m_Buffers = new SapBufferWithTrash(2, m_AcqDevice, SapBuffer.MemoryType.ScatterGatherPhysical); } m_Xfer = new SapAcqDeviceToBuf(m_AcqDevice, m_Buffers); m_View = new SapView(m_Buffers); m_ImageBox.View = m_View; m_Xfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame; m_Xfer.XferNotify += new SapXferNotifyHandler(xfer_XferNotify); m_Xfer.XferNotifyContext = this; StatusLabelInfo.Text = "Online... Waiting grabbed images"; if (!CreateObjects()) { DisposeObjects(); return(false); } // Resize ImagBox to take into account the size of created sapview m_ImageBox.OnSize(); UpdateControls(); return(true); }