| | |
| | | using System.IO; |
| | | using System.IO.Ports; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | |
| | |
| | | { |
| | | DataContext = this; |
| | | InitializeComponent(); |
| | | InitProducts(); |
| | | InitTsEngine(); |
| | | InitProducts(); |
| | | } |
| | | |
| | | public override void InitFinish() |
| | |
| | | get { return _selectedProduct; } |
| | | set |
| | | { |
| | | SetTestSeqFile(value); |
| | | Set(ref _selectedProduct, value); |
| | | SetTestSeqFile(value); |
| | | } |
| | | } |
| | | |
| | | private bool _enableMes; |
| | | public bool EnableMes |
| | | { |
| | | get => _enableMes; |
| | | set |
| | | { |
| | | if (WriteConfig("EnableMes", value)) |
| | | { |
| | | Set(ref _enableMes, value); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (!string.IsNullOrEmpty(lastModel)) |
| | | { |
| | | var product = Products.FirstOrDefault(p => p.Name == lastModel); |
| | | if (product != null) SelectedProduct = product; |
| | | goto Write; |
| | | if (product != null) |
| | | { |
| | | SelectedProduct = product; |
| | | RefershUI(); |
| | | return; |
| | | } |
| | | } |
| | | goto Write; |
| | | |
| | | Write: |
| | | SelectedProduct = Products[0]; |
| | | engine?.Globals.SetValString("StationState.ProductModel", 1, Products[0].Name); |
| | | |
| | | RefershUI(); |
| | | } |
| | | } |
| | | |
| | | private bool WriteConfig(string name, bool value) |
| | | { |
| | | //IniFileHelper.WriteIniData("Config", name, value.ToString(), CountIniPath); |
| | | try |
| | | { |
| | | if (ParameterManager.UpdateCommonParameter(name, value, out string errMsg)) |
| | | { |
| | | SequenceContext?.StationGlobals.SetValBoolean($"SystemSetting.{name}", 1, value); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception(errMsg); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgBoxHelper2.Error(ex.Message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取配置文件里的几个属性 |
| | | /// </summary> |
| | | /// <param name="pass"></param> |
| | | /// <param name="fail"></param> |
| | | private void ReadConfig() |
| | | { |
| | | ParameterData value; |
| | | try |
| | | { |
| | | value = ParameterManager.GetCommonParameterByName("EnableMes"); |
| | | _enableMes = bool.Parse(value.Value); |
| | | Set("EnableMes"); |
| | | } |
| | | catch |
| | | { |
| | | _enableMes = false; |
| | | Set("EnableMes"); |
| | | } |
| | | |
| | | //try |
| | | //{ |
| | | // value = ParameterManager.GetCommonParameterByName("EnableNGPause"); |
| | | // _enableNGPause = bool.Parse(value.Value); |
| | | // Set("EnableNGPause"); |
| | | //} |
| | | //catch |
| | | //{ |
| | | // _enableNGPause = false; |
| | | // Set("EnableNGPause"); |
| | | //} |
| | | |
| | | //try |
| | | //{ |
| | | // value = ParameterManager.GetCommonParameterByName("EnableCanLog"); |
| | | // _enableCanLog = bool.Parse(value.Value); |
| | | // Set("EnableCanLog"); |
| | | //} |
| | | //catch |
| | | //{ |
| | | // _enableCanLog = false; |
| | | // Set("EnableCanLog"); |
| | | //} |
| | | |
| | | //try |
| | | //{ |
| | | // value = ParameterManager.GetCommonParameterByName("EnableDebugMode"); |
| | | // _enableDebugMode = bool.Parse(value.Value); |
| | | // Set("EnableDebugMode"); |
| | | //} |
| | | //catch |
| | | //{ |
| | | // _enableDebugMode = false; |
| | | // Set("EnableDebugMode"); |
| | | //} |
| | | |
| | | //try |
| | | //{ |
| | | // value = ParameterManager.GetCommonParameterByName("EnableSimpleMode"); |
| | | // EnableSimpleMode = bool.Parse(value.Value); |
| | | //} |
| | | //catch |
| | | //{ |
| | | // EnableSimpleMode = false; |
| | | //} |
| | | |
| | | //try |
| | | //{ |
| | | // value = ParameterManager.GetCommonParameterByName("UI_ShowInfoDock"); |
| | | // UI_ShowInfoDock = bool.Parse(value.Value); |
| | | //} |
| | | //catch |
| | | //{ |
| | | // UI_ShowInfoDock = false; |
| | | //} |
| | | |
| | | //try |
| | | //{ |
| | | |
| | | // value = ParameterManager.GetCommonParameterByName("TestReportFolder"); |
| | | // csvDir = value.Value; |
| | | // if (!Directory.Exists(csvDir)) |
| | | // { |
| | | // Directory.CreateDirectory(csvDir); |
| | | // } |
| | | //} |
| | | //catch |
| | | //{ |
| | | // csvDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestReport"); |
| | | //} |
| | | } |
| | | |
| | | #region 扫码枪相关 |
| | |
| | | catch (Exception ex) |
| | | { |
| | | log.Error("Init Scan Gun Failed.", ex); |
| | | MsgBoxHelper.Error(this, $"{this.lang("Tr.InitGunFailed")}: {ex.StackTrace}"); |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | MsgBoxHelper.Error(this, $"{this.lang("Tr.InitGunFailed")}: {ex.StackTrace}"); |
| | | }); |
| | | } |
| | | } |
| | | private string ReadDataFrom(SerialPort sp) |
| | |
| | | try |
| | | { |
| | | SequenceContext?.StationGlobals.SetValBoolean("StationState.StopTest", 1, true); |
| | | log.Info($"Stop Result: {SequenceContext?.StationGlobals.GetValBoolean("StationState.StopTest", 1)}"); |
| | | if (this.execution == null) return true; |
| | | return this.execution.WaitForEndEx(2000, true, null, null); |
| | | } |
| | |
| | | catch (Exception ex) |
| | | { |
| | | log.Error("TsExecution Loaded Failed.", ex); |
| | | MsgBoxHelper.Error(this, $"{LangUtil.Get("Ts.UserControlLoadFailed")}: {ex.Message}"); |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | MsgBoxHelper.Error(this, $"{LangUtil.Get("Ts.UserControlLoadFailed")}: {ex.Message}"); |
| | | }); |
| | | } |
| | | Dispatcher.Invoke(() => |
| | | { |
| | |
| | | try |
| | | { |
| | | if (!isLoadOk) return; |
| | | engine?.Globals.SetValString("StationState.ProductModel", 1, SelectedProduct?.Name); |
| | | engine?.CommitGlobalsToDisk(promptOnSaveConflicts: false); |
| | | this.modeSeq = this.engine.GetSequenceFileEx(@"C:\Program Files\National Instruments\TestStand 2020\Components\Models\TestStandModels\ParallelModel.seq"); |
| | | this.testSeq = this.engine.GetSequenceFileEx(this.testSeqFile, 0, TypeConflictHandlerTypes.ConflictHandler_UseGlobalType); |
| | | this.execution = this.engine.NewExecution(this.testSeq, "Test UUTs", this.modeSeq, false, 0, null, null, null); |
| | |
| | | int index2 = int.Parse(arr2[0]); |
| | | this.tsSockets[index2].SetInfo(arr2[1]); |
| | | break; |
| | | case 8: |
| | | IsRunning = false; |
| | | break; |
| | | default: |
| | | break; |
| | | } |