private void Window_Loaded(object sender, RoutedEventArgs e) { DyeListBLL.ReadInitDye(); try { if (!OmniProvider.isSimulate) { if (OmniProvider.OpenSpectrometers() > 0) { OmniProvider.OpenSerialPort(); OmniProvider.SendCommand("ZZ", false); OmniProvider.GetWaveLengthsList();//获得波长 OmniProvider.GetParameters(); } else { MessageBox.Show("Connect fail.未找到光谱仪"); Functions.CommnucationLog("Connect fail.未找到光谱仪"); } } } catch (Exception ex) { MessageBox.Show("Connect fail." + ex.Message); Functions.CommnucationLog("Connect fail." + ex.Message); } }