| | |
| | | |
| | | CommonUtil.IsRunning = true; |
| | | SetControls(); |
| | | |
| | | opc.Write(OPCOutputTag.DetectResult_OK, false); |
| | | opc.Write(OPCOutputTag.DetectResult_NG, false); |
| | | CommonUtil.WriteLog(LogType.Inf, "初始化下料NA"); |
| | | |
| | | string continuousNGStr = ConfigurationManager.AppSettings["ContinuousNGThreshold"]; |
| | | if (int.TryParse(continuousNGStr, out int temp)) |
| | | { |
| | | _continuousNGThreshold = temp; |
| | | } |
| | | else |
| | | { |
| | | _continuousNGThreshold = 999; |
| | | } |
| | | } |
| | | |
| | | public void Stop() |
| | |
| | | lblEmptyQuantity.Text = measureResultTTL.EmptyQuantity.ToString(); |
| | | } |
| | | |
| | | int _continuousNGThreshold = 999; |
| | | int _continuousNG = 0; |
| | | |
| | | #region PLC 监听 |
| | | void OPCEventHandler(object sender, EventTool.ListenEventArgs e) |
| | | { |
| | |
| | | MeasureState pState = MeasureState.NA; |
| | | |
| | | int detectID = CommonUtil.StepControl.GetUnloadStepID(); |
| | | ProductMeasureResult x = null; |
| | | if (detectID > 0) |
| | | { |
| | | var x = (from t in productTestCollection |
| | | where t.DetectID == detectID |
| | | select t |
| | | x = (from t in productTestCollection |
| | | where t.DetectID == detectID |
| | | select t |
| | | ).FirstOrDefault(); |
| | | if (x != default(ProductMeasureResult)) |
| | | { |
| | |
| | | case MeasureState.OK: |
| | | opc.Write(OPCOutputTag.DetectResult_OK, true); |
| | | opc.Write(OPCOutputTag.DetectResult_NG, false); |
| | | |
| | | CommonUtil.WriteLog(LogType.Inf, $"{x.DetectID}|{x.ProductNo}产品应放入OK Tray"); |
| | | |
| | | _continuousNG = 0; |
| | | break; |
| | | case MeasureState.NG: |
| | | opc.Write(OPCOutputTag.DetectResult_OK, false); |
| | | opc.Write(OPCOutputTag.DetectResult_NG, true); |
| | | |
| | | CommonUtil.WriteLog(LogType.Inf, $"{x.DetectID}|{x.ProductNo}产品应放入NG Tray"); |
| | | CommonUtil.StepControl.RemoveById(detectID); |
| | | |
| | | _continuousNG++; |
| | | break; |
| | | default: |
| | | opc.Write(OPCOutputTag.DetectResult_OK, false); |
| | | opc.Write(OPCOutputTag.DetectResult_NG, false); |
| | | |
| | | CommonUtil.WriteLog(LogType.Inf, $"{x.DetectID}|{x.ProductNo}产品应放入NA Tray"); |
| | | CommonUtil.StepControl.RemoveById(detectID); |
| | | |
| | | _continuousNG = 0; |
| | | break; |
| | | } |
| | | #endregion |
| | |
| | | DisplayCycleTime((int)Math.Round(ts.TotalMilliseconds)); |
| | | } |
| | | unloadTime = DateTime.Now; |
| | | |
| | | if (_continuousNG >= _continuousNGThreshold) |
| | | { |
| | | //脚本中设置报警码2000表示连续NG次数到达设定报警上限 |
| | | opc.Write(OPCInputTag.Alarm, 2000); |
| | | |
| | | CommonUtil.WriteLog(LogType.Inf, $"产品连续NG{_continuousNG}次,报警提示"); |
| | | _continuousNG = 0; |
| | | } |
| | | // |
| | | } |
| | | break; |
| | |
| | | if ((bool)item.value) |
| | | { |
| | | //opc.Write(OPCInputTag.UnloadBatteryDone, false); |
| | | |
| | | int batteryId = CommonUtil.StepControl.GetUnloadBatteryID(); |
| | | |
| | | CommonUtil.WriteLog(LogType.Inf, $"电池下料到位,Id:{batteryId}"); |
| | | |
| | | CommonUtil.StepControl.RemoveById(batteryId); |
| | | detectionData.SaveTrayBarcode(batteryId); |
| | | } |