wenxiangchao
4 天以前 559890c482f5973f06aafdfec9550fee5ba3c7f2
Plugin.TestResult/DataTable.xaml.cs
@@ -92,7 +92,7 @@
            set { RaiseAndSetIfchanged(ref tcpServerInfo, value); }
        }
        public int index { get; private set; }
        private readonly int cellCount;
        public readonly int cellCount;
        private readonly string chartTitle;
        public readonly TestResultView parent;
@@ -319,7 +319,7 @@
            else
            {
                /// 检查是否关门
                if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) != true)
                if (!GetDoorClose(parent.executionWrapper))
                {
                    /// 没关门不允许启动
                    MsgBoxHelper2.Warn("请先关闭舱门!");
@@ -390,6 +390,11 @@
            scanner = null;
        }
        public bool GetDoorClose(ITestExecutionWrapper wrapper)
        {
            return wrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) == true;
        }
        private void Scanner_FinishBarcode(object sender, BarcodeEventArg e)
        {
            if (parent.executionWrapper == null) return;
@@ -399,19 +404,37 @@
            CellInfo cellInfo = ScannerParser.GetCellInfoByCode(CbProduct.SelectedItem?.ToString(), mainGrid.Columns, rows, e.positionCode);
            string positionCode = e.positionCode, snrCode = e.snrCode;
            //将读到的条码写入到SN中
            int dutNo = this.index * this.cellCount + cellInfo.Index;
            //if (cellInfo.OvenName != this.title)
            //{
            //    MsgBoxHelper2.Warn($"请切换至 [{cellInfo.OvenName}] 区扫码,当前为 [{this.title}] 区!");
            //    return;
            //}
            var targetTable = TestResultView.nameTables[cellInfo.OvenName];
            //将读到的条码写入到SN中
            int dutNo = targetTable.index * targetTable.cellCount + cellInfo.Index;
            string LookupStr = $"StationState.SN[{dutNo}]";
            cellInfo.LookUpStr = LookupStr;
            ViewControl.Logger.Debug($"PositionCode: [{e.positionCode}], SNR: [{e.snrCode}], LookUpStr: [{LookupStr}]");
            ViewControl.Logger.Debug($"OvenName: [{cellInfo.OvenName}], CellIndex: [{cellInfo.Index}]");
            var cell = TestResultView.nameTables[cellInfo.OvenName].GetSingleCell(cellInfo.Index);
            ViewControl.Logger.Info($"PositionCode: [{e.positionCode}], SNR: [{e.snrCode}], LookUpStr: [{LookupStr}]");
            ViewControl.Logger.Info($"OvenName: [{cellInfo.OvenName}], CellIndex: [{cellInfo.Index}]");
            var cell = targetTable.GetSingleCell(cellInfo.Index);
            if (targetTable.GetDoorClose(parent.executionWrapper))
            {
                /// 关门了就不允许清条码
                MsgBoxHelper2.Warn($"{targetTable.title}炉生产中,不允许操作条码");
                //MsgBoxHelper2.Warn(this.lang("Tr.CantClearSNR"));
                return;
            }
            if (snrCode == null)
            {
                var oldCellInfo = e.lastInfo;
                var oldCell = TestResultView.nameTables[oldCellInfo.OvenName].GetSingleCell(oldCellInfo.Index);
                var oldTable = TestResultView.nameTables[oldCellInfo.OvenName];
                var oldCell = oldTable.GetSingleCell(oldCellInfo.Index);
                if (oldCell.status != "hadCode")
                {
                    throw new Exception(this.lang("Tr.PositionCantClearSNR", oldCellInfo.OriginCode));
@@ -441,18 +464,10 @@
            //parent.engine.Globals.SetValString(LookupStr, 1, snrCode);
            //parent.engine.CommitGlobalsToDisk(promptOnSaveConflicts: false);
            TestResultView.nameTables[cellInfo.OvenName].GetSingleCell(cellInfo.Index).SetStatus("hadCode");
            TestResultView.nameTables[cellInfo.OvenName].GetSingleCell(cellInfo.Index).sn = snrCode;
            cell.SetStatus("hadCode");
            cell.sn = snrCode;
            Scanner.InsertNewCode(snrCode, cellInfo);
            var light = $"Oven{this.index + 1}_Cell{cell.index + 1}_Light_OK";
            if (cell.LightGreen(true, out string msg))
            {
                ViewControl.Logger.Debug($"Open Light [{light}] ON.");
            }
            else
            {
                ViewControl.Logger.Debug($"Open Light [{light}] Error.{msg}");
            }
            cell.LightGreen(true, out string msg);
        }
@@ -572,16 +587,18 @@
            string strs = datas_10015[2];
            string[] values = strs.Split(',');
            GetSingleCell(cellIndex).SetInfos(new Info
            Dispatcher.Invoke(() =>
            {
                step = values[0],
                value = values[1],
                limitUp = values[2],
                limitDown = values[3],
                unit = values[4],
                result = values[5],
                updateTime = values[6]
                GetSingleCell(cellIndex).SetInfos(new Info
                {
                    step = values[0],
                    value = values[1],
                    limitUp = values[2],
                    limitDown = values[3],
                    unit = values[4],
                    result = values[5],
                    updateTime = values[6]
                });
            });
            //session.Send("1");
        }
@@ -590,17 +607,18 @@
        {
            infoTable.UpdateNumber(infoTable.okCount + ok, infoTable.ngCount + ng);
            if (ParamSetting.ProbeByModel)
            {
            //if (ParamSetting.ProbeByModel)
            //{
            }
            else
            {
                IniFileHelper.WriteIniData($"Oven_{index}", "Pass", infoTable.okCount.ToString(),
                   this.CountIniPath);
                IniFileHelper.WriteIniData($"Oven_{index}", "Fail", infoTable.ngCount.ToString(),
                    this.CountIniPath);
            }
            //}
            //else
            //{
            //}
            IniFileHelper.WriteIniData($"Oven_{index}", "Pass", infoTable.okCount.ToString(),
                  this.CountIniPath);
            IniFileHelper.WriteIniData($"Oven_{index}", "Fail", infoTable.ngCount.ToString(),
                this.CountIniPath);
        }
        /// <summary>
@@ -786,7 +804,7 @@
        private void ClearAllSnr_Click(object sender, RoutedEventArgs e)
        {
            if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) == true)
            if (GetDoorClose(parent.executionWrapper))
            {
                /// 关门了就不允许清条码
                MsgBoxHelper2.Warn(this.lang("Tr.CantClearSNR"));
@@ -818,7 +836,7 @@
        public void TryClearCellSN(int cellIndex)
        {
            if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) == true)
            if (GetDoorClose(parent.executionWrapper))
            {
                MsgBoxHelper.Error(Window.GetWindow(this), this.lang("Tr.CantClearSNR"));
                return;
@@ -851,10 +869,7 @@
                return;
            }
            string key = $"StationState.Start[{this.index}]";
            //string key = $"StationState.Start[{this.index}]";
            //if (parent.executionWrapper?.GetStationGlobalValue<bool>(key, 0) == true)
            //{
            //    MsgBoxHelper2.Warn("测试启动中,不允许Abort");
@@ -873,9 +888,9 @@
            {
                return;
            }
            LogHelper.Info("UI", "Abort按钮按下", out _);
            ViewControl.Logger.Info("Abort按钮按下");
            key = $"StationState.Abort[{this.index}]";
            LogHelper.Info("UI", $"{title} Abort按钮按下", out _);
            ViewControl.Logger.Info($"{title} Abort按钮按下");
            string key = $"StationState.Abort[{this.index}]";
            parent.executionWrapper?.SetStationGlobalValue(key, 0, true);
        }
    }