private void InitInstrument() { //初始化控件信息 foreach (InstrumentInfo instrumnet in InstrumentInfoList.getInstence()) { System.Windows.Data.Binding bd = new System.Windows.Data.Binding("DevInfoState"); bd.Mode = BindingMode.TwoWay; System.Windows.Data.Binding bdEnable = new System.Windows.Data.Binding("Enabled"); bdEnable.Mode = BindingMode.TwoWay; // if (instrumnet.InstrumentTypeID == InstrumentType.SignalSource) { this.SG.instrument = instrumnet; this.SG.SetBinding(imageControl.DevEnableProperty, bdEnable); this.SG.SetBinding(imageControl.DevStateProperty, bd); this.SG.DataContext = instrumnet; } //频谱仪 if (instrumnet.InstrumentTypeID == InstrumentType.SA) { this.PXA.instrument = instrumnet; this.PXA.SetBinding(imageControl.DevEnableProperty, bdEnable); this.PXA.SetBinding(imageControl.DevStateProperty, bd); this.PXA.DataContext = instrumnet; } } DutInfo = InstrumentInfoList.getInstence().GetInstrument("RackSys.TestLab.Instrument.DUT", "1"); //this.cmbPort.ItemsSource = new List<string>() //{ // "COM1" //}; }
/// <summary> /// 应用 /// </summary> private void btnApply_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.txtDevName.Text.Trim())) { MessageBox.Show("已更新设备名称为空,请先添写设备名称!", "提示消息", MessageBoxButton.OK, MessageBoxImage.Information); return; } else { var snList = (from q in InstrumentInfoList.getInstence() where q != this.instrumentInfo && (q.InstrumentTypeID == InstrumentType.DCPower || q.InstrumentTypeID == InstrumentType.DCPowerAnalyzer) select q.InstrumentName).ToList(); if (snList != null && snList.Contains(this.txtDevName.Text)) { MessageBox.Show("电源名称不能相同,请修改!", "提示消息", MessageBoxButton.OK, MessageBoxImage.Information); return; } } if (!string.IsNullOrEmpty(this.txtInnerNum.Text.Trim())) { var snList = (from q in InstrumentInfoList.getInstence() where q != this.instrumentInfo select q.IDInInstitute).ToList(); if (snList != null && snList.Contains(this.txtInnerNum.Text)) { if (MessageBox.Show("当前输入的所内编号已存在,是否强制修改?", "提示消息", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.OK) { SaveChange(); instrumentAddress.IsApply = false; } else { return; } } } SaveChange(); instrumentAddress.IsApply = false; }
/// <summary> /// 保存 /// </summary> protected void SaveChange() { IsOk = true; this.instrumentInfo.IpAddress = txtVisaAddr.Text; if (!string.IsNullOrEmpty(this.txtInnerNum.Text)) { this.instrumentInfo.IDInInstitute = this.txtInnerNum.Text; } else { this.instrumentInfo.IDInInstitute = ""; } if (!string.IsNullOrEmpty(this.txtDevName.Text.ToString()) && this.txtDevName.Text.ToString() != this.instrumentInfo.InstrumentName) { this.instrumentInfo.InstrumentName = this.txtDevName.Text.Trim(); } if (!string.IsNullOrEmpty(this.txtChanneNum.Text)) { this.instrumentInfo.DCModleNum = Convert.ToInt32(this.txtChanneNum.Text.Trim()); } InstrumentInfoList.getInstence().SaveParameterToXMLFile(); ///巡检,以初始化设备信息 SystemHardware.SysHardware.CreateInstrumentInstanceByInstrumentType(this.instrumentInfo.InstrumentTypeID); }