| | |
| | | using NationalInstruments.TestStand.Interop.API; |
| | | using NPOI.HSSF.UserModel; |
| | | using NPOI.SS.UserModel; |
| | | using OpenTap; |
| | | using Plugin.TsSupport; |
| | | using ScottPlot; |
| | | using ScottPlot.Plottables; |
| | |
| | | using System.Linq; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | using System.Windows.Forms.DataVisualization.Charting; |
| | | |
| | | namespace Plugin.TsExecution |
| | | { |
| | |
| | | #endregion |
| | | |
| | | public static ILog logger { get; private set; } |
| | | private List<SingleControl> tsSockets = new List<SingleControl>(); |
| | | public List<SingleControl> tsSockets { get; private set; } = new List<SingleControl>(); |
| | | /// <summary> |
| | | /// 样件模式状态 |
| | | /// </summary> |
| | |
| | | } |
| | | } |
| | | |
| | | private string tsModelPath; |
| | | private bool enableManualDebug; |
| | | public bool EnableManualDebug |
| | | { |
| | | get => enableManualDebug; |
| | | set |
| | | { |
| | | if (IsTesting) |
| | | { |
| | | MsgBoxHelper2.Warn("请先结束自动测试"); |
| | | return; |
| | | } |
| | | Set(ref enableManualDebug, value); |
| | | } |
| | | } |
| | | |
| | | public string tsModelPath { get; private set; } |
| | | private string dataLogPath; |
| | | private SqliteHelper sqliteHelper; |
| | | |
| | |
| | | { |
| | | DataContext = this; |
| | | InitializeComponent(); |
| | | |
| | | InitChart(); |
| | | InitTsEngine(); |
| | | } |
| | | |
| | | public override void SetBaseFolder(string folder) |
| | |
| | | |
| | | public override void InitFinish() |
| | | { |
| | | InitTsEngine(); |
| | | this.ReadCount(out int pass, out int fail); |
| | | this.DisplayCount(pass, fail); |
| | | ReadConfig(); |
| | |
| | | catch (Exception ex) |
| | | { |
| | | log.Warn("Get Login User Failed.", ex); |
| | | } |
| | | RefreshUIConfig(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新UI配置 |
| | | /// </summary> |
| | | private void RefreshUIConfig() |
| | | { |
| | | try |
| | | { |
| | | bool enableManualDebug = ParameterManager.GetCommonParameterByName("EnableManualDebug", false); |
| | | if (enableManualDebug) |
| | | { |
| | | Cb_ManualDebug.Visibility = Visibility.Visible; |
| | | EnableManualDebug = false; |
| | | } |
| | | else |
| | | { |
| | | Cb_ManualDebug.Visibility = Visibility.Collapsed; |
| | | EnableManualDebug = false; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | log.Error("RefreshUIConfig Error.", ex); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (ParamSetting.EngineType == "Tap") |
| | | { |
| | | testExecutionWrapper = new TapWrapper(); |
| | | var wrapper = new TapWrapper(); |
| | | wrapper.RegisteUserInput(this); |
| | | log.Debug($"Wrapper UI is {wrapper.ui}"); |
| | | testExecutionWrapper = wrapper; |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | SocketName = name |
| | | }; |
| | | control.parent = this; |
| | | panel.Children.Add(control); |
| | | tsSockets.Add(control); |
| | | |
| | |
| | | { |
| | | |
| | | value = ParameterManager.GetCommonParameterByName("TestReportFolder"); |
| | | csvDir = value.Value; |
| | | csvDir = value?.Value ?? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestReport"); |
| | | if (!Directory.Exists(csvDir)) |
| | | { |
| | | Directory.CreateDirectory(csvDir); |
| | |
| | | { |
| | | |
| | | value = ParameterManager.GetCommonParameterByName("IsOptRequirePassword"); |
| | | IsOptRequirePassword = bool.Parse(value.Value); |
| | | IsOptRequirePassword = value == null ? false : bool.Parse(value.Value); |
| | | } |
| | | catch |
| | | { |
| | |
| | | |
| | | public void UpdatePositionStatus(int index, string status) |
| | | { |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | this.tsSockets[index].UpdateStatus(status); |
| | | OnStatusPublished(index, status); |
| | | this.UpdateTestCounter(); |
| | | }); |
| | | } |
| | | |
| | | private void OnStatusPublished(int index, string status) |
| | |
| | | break; |
| | | |
| | | case 10006://发送产品条码 |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | SetPositionBarcode(index, strData); |
| | | }); |
| | | break; |
| | | |
| | | case 10007://开始测试计时 |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | tsSockets[index].ElapseTime = "Start Timing"; |
| | | BtnStopSeq.IsEnabled = false; |
| | | }); |
| | | break; |
| | | |
| | | case 10008://停止测试计时 |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | tsSockets[index].ElapseTime = "Stop Timing"; |
| | | BtnStopSeq.IsEnabled = true; |
| | | }); |
| | | break; |
| | | |
| | | case 10009: |
| | |
| | | |
| | | break; |
| | | case 10017://更新测试计时,针对部分计时有PLC完成的项目 |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | this.tsSockets[index].ElapseTime = strData; |
| | | }); |
| | | break; |
| | | case (int)UIMessageCodes.UIMsg_EndExecution://执行结束 |
| | | //IsTesting = false; |
| | |
| | | break; |
| | | case 10030://显示测试进度 |
| | | int ProcessVal = Convert.ToInt32(strData); |
| | | Dispatcher.Invoke(() => |
| | | { |
| | | this.tsSockets[index].SetTestProcess(ProcessVal); |
| | | }); |
| | | break; |
| | | case 10031://导出CSV |
| | | |
| | |
| | | |
| | | public override void DoClose(object sender, EventArgs e) |
| | | { |
| | | testExecutionWrapper?.Dispose(); |
| | | base.DoClose(sender, e); |
| | | } |
| | | |