예제 #1
0
        public void DoReset()
        {
            ClassCommonSetting.ProgramLog(LogFile.Level.Debug, "WorkFlow", $"{Name}工作区域复位开始");
            ErrorInfoWithPause res = null;

            Reseting = true;
            lock (ResetLock)
            {
                ResetErr = new ClassErrorHandle();
                ClassCommonSetting.ProgramLog(LogFile.Level.Debug, "WorkFlow", $"{Name}工作区域所有端口复位");
                res = ResetOutPort();
                if (res != null)
                {
                    ClassErrorHandle.ShowError(this.Name, res);
                    return;
                }
                ClassCommonSetting.ProgramLog(LogFile.Level.Debug, "WorkFlow", $"{Name}工作区域所有电机上电");
                ServoOnAllMotor();
                Reset(ResetErr);
                if (ResetErr.NoError)
                {
                    _ioPublisher.notifyDoneEventSubscribers(this, new StateEventArgs("ResetDone", this.Name));
                }
                else
                {
                    _ioPublisher.notifyErrorEventSubscribers(this, new FailureException(ResetErr.ErrMessage));
                }
            }
            Reseting = false;
            ClassCommonSetting.ProgramLog(LogFile.Level.Debug, "WorkFlow", $"{Name}工作区域复位结束");
        }
예제 #2
0
 /// <summary>
 /// 设置SMEMA的Available信号。
 /// 流程没有运行,流程是空跑状态,或者流程运行但是暂停,Available信号始终设为false。
 /// </summary>
 /// <param name="Available">avaliable信号状态</param>
 /// <returns>返回执行结果。成功返回空字符。</returns>
 public ErrorInfoWithPause ActionSMEMAAvailable(bool Available)
 {
     lock (SMEMALock)
     {
         if (!_isRunning)
         {
             Available = false;
         }
         if (ClassWorkFlow.Instance.WorkMode == EnumWorkMode.空跑)
         {
             Available = false;
         }
         if (_isPausing)
         {
             Available = false;
         }
         ThisOutport(EnumOutportName.LoadInSMEMALoadAvailable).SetOutput(Available);
         if (SMEMAAvailable != Available)
         {
             SMEMAAvailable = Available;
             ClassCommonSetting.ProgramLog(LogFile.Level.Debug, this.Name, "SMEMA Available信号设为" + Available.ToString());
         }
         return(null);
     }
 }
예제 #3
0
파일: WinSock.cs 프로젝트: TopMouse72/BU1
 public void SendCommand(string sendstring)
 {
     if (stream.CanWrite)
     {
         byte[] data = Encoding.Default.GetBytes(sendstring);
         stream.Write(data, 0, data.Length);
         ClassCommonSetting.ProgramLog(LogFile.Level.Info, "WinSock", "发送指令: " + sendstring);
     }
 }
예제 #4
0
        private void GetData(EnumCellIndex index, string Data, DataComp NeedComp)
        {
            double temp;

            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "测厚", $"{index}测厚GetData得到的数据:{Data}");
            if (!double.TryParse(Data.Replace("?", ""), out temp))
            {
                ClassCommonSetting.ProgramLog(LogFile.Level.Info, "测厚", "GetData得到的数据转换为double失败,数据没有处理");
                return;
            }
            ThicknessDataStations[index].CellData.Data.CellThickness.Value = temp;// double.Parse(Data.Replace("?", ""));
            if (NeedComp != DataComp.NoComp && ClassCommonSetting.SysParam.CurrentUsedGauge != null)
            {
                double reference = 0;
                double slope = 0, intercept = 0;
                bool   enable = false;
                switch (index)
                {
                case EnumCellIndex.中电芯:
                    reference = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessMeasRefMid;
                    slope     = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessMidLinear.Slope;
                    intercept = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessMidLinear.Intercept;
                    enable    = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessMidLinear.Enable;
                    break;

                case EnumCellIndex.右电芯:
                    reference = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessMeasRefRight;
                    slope     = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessRightLinear.Slope;
                    intercept = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessRightLinear.Intercept;
                    enable    = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessRightLinear.Enable;
                    break;

                case EnumCellIndex.左电芯:
                    reference = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessMeasRefLeft;
                    slope     = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessLeftLinear.Slope;
                    intercept = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessLeftLinear.Intercept;
                    enable    = ClassCommonSetting.SysParam.CurrentUsedGauge.ThicknessLeftLinear.Enable;
                    break;
                }
                if ((NeedComp & DataComp.AddRef) != DataComp.NoComp)
                {
                    ThicknessDataStations[index].CellData.Data.CellThickness.Value = reference - ThicknessDataStations[index].CellData.Data.CellThickness.Value;
                }
                if ((NeedComp & DataComp.AddComp) != DataComp.NoComp && enable)
                {
                    ThicknessDataStations[index].CellData.Data.CellThickness.Value = ThicknessDataStations[index].CellData.Data.CellThickness.Value * slope + intercept;
                }
            }
            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "测厚", $"获取原始数据{temp},最终数据{ThicknessDataStations[index].CellData.Data.CellThickness.Value:0.000}");
            ThicknessDataStations[index].Refresh();
        }
예제 #5
0
        public override void ResumeHandler(BaseClass sender, StateEventArgs e)
        {
            base.ResumeHandler(sender, e);
            LightStartButton();
            _isPausing = false;
            //Statistic.WFStatus = WorkFlowStatus.运行;
            string strFrom = "流程恢复";

            if (e != null)
            {
                strFrom += "(" + e.eventInfo + ")";
            }
            Statistic.GetWorkFlowStatus(DateTime.Now, WorkFlowStatus.运行, strFrom, true);
            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "WorkFLow", strFrom);
        }
예제 #6
0
        /// <summary>
        /// 急停处理。
        /// 发送EStop系统事件。
        /// </summary>
        /// <returns>返回执行结果。成功返回空字符。</returns>
        public string DoEmergency()
        {
            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "WorkFLow", "流程因急停停止");
            if (_isRunning)
            {
                ClassErrorHandle.ShowError(this.Name, "急停按钮按下,流程因急停停止", ErrorLevel.Alarm);
            }
            else
            {
                ClassErrorHandle.ShowError(this.Name, "急停按钮按下", ErrorLevel.Alarm);
            }

            CommonFunction.SysPublisher.notifyEStopEventSubscribers(this, new StateEventArgs("急停", ""));

            return("");
        }
예제 #7
0
파일: WinSock.cs 프로젝트: TopMouse72/BU1
        public void GetData()
        {
            if (isConnectCamera)
            {
                if (client.Available > 0)
                {
                    int    startIndex = 0;
                    int    endindex   = 0;
                    string temp;
                    int    recbytes = stream.Read(data, 0, data.Length);
                    int    MeasIndex = 0, CapIndex = 0, BatchIndex = 0;
                    receivedstring = Encoding.Default.GetString(data).Substring(0, recbytes);
                    ClassCommonSetting.ProgramLog(LogFile.Level.Debug, "WinSock", "Winsock receive: " + receivedstring);
                    do
                    {
                        string comm = GetFirst(receivedstring, startIndex, ref MeasIndex, ref CapIndex, ref BatchIndex);
                        if (comm == "")
                        {
                            return;
                        }
                        switch (comm)
                        {
                        case MEASDONE:
                            //Meas first or only Meas exist.
                            endindex = receivedstring.IndexOf(END, MeasIndex);
                            temp     = receivedstring.Substring(MeasIndex + RET_MEASDONE.Length, endindex - MeasIndex - RET_MEASDONE.Length);
                            ClassCommonSetting.ProgramLog(LogFile.Level.Debug, "WinSock", "Receive Measure done: " + temp);
                            notifyDoneEventSubscribers(this, new StateEventArgs(MEASDONE, temp));
                            break;

                        case CAPFINISH:
                            //Cap first or only Cap exist.
                            endindex = receivedstring.IndexOf(";", CapIndex);
                            temp     = receivedstring.Substring(CapIndex + RET_CAPFINISH.Length, endindex - CapIndex - RET_CAPFINISH.Length);
                            ClassCommonSetting.ProgramLog(LogFile.Level.Debug, "WinSock", "Receive from Cap finish: " + temp);
                            notifyDoneEventSubscribers(this, new StateEventArgs(CAPFINISH, temp));
                            break;
                        }
                        startIndex = endindex;
                    } while (true);
                }
            }
        }
예제 #8
0
        public string StartBarcodeScan(bool HavePart = false)
        {
            string res     = "";
            string barcode = "";

            if (HavePart)
            {
                res = StartSerialReading(ThisSerialPortData(EnumSerialPortName.LoadInBarcode), HardwareSerialProtocolName.BarcodeRead, ref barcode);
                if (res != "")
                {
                    barcode = "";
                    ThisSerialPortData(EnumSerialPortName.LoadInBarcode).Stop();
                }
                else
                {
                    barcode = barcode.Trim();
                }
            }
            else
            {
                if (GRRStartOffset < 0)
                {
                    barcode = ClassWorkFlow.Instance.GetCell.ToString();
                }
                else
                {
                    barcode = (((ClassWorkFlow.Instance.GetCell + GRRStartOffset - 1) % 10) + 1).ToString();
                }
            }
            if (LoadInDataStations[LoadInDataStations.Length - 1].CellData != null)
            {
                LoadInDataStations[LoadInDataStations.Length - 1].CellData.Barcode = barcode;
            }
            if (barcode != "")
            {
                ClassCommonSetting.ProgramLog(LogFile.Level.Info, this.Name, "获取条码" + barcode);
            }
            else
            {
                ClassCommonSetting.ProgramLog(LogFile.Level.Info, this.Name, "获取条码失败(" + res + ")");
            }
            return(res);
        }
예제 #9
0
        public override void DoneHandler(BaseClass sender, StateEventArgs e)
        {
            base.DoneHandler(sender, e);
            int index;

            switch (e.eventName)
            {
            case WinSock.CAPFINISH:
                index = int.Parse(e.eventInfo) - 1;
                _camTrigFinish[index] = true;
                ClassCommonSetting.ProgramLog(LogFile.Level.Info, this.Name, "相机触发完成:" + (EnumCellIndex)index);
                break;

            case WinSock.MEASDONE:
                index           = GetData(e.eventInfo);
                MeasDone[index] = true;
                ClassCommonSetting.ProgramLog(LogFile.Level.Info, this.Name, "CCD测量完成:" + (EnumCellIndex)index);
                break;
            }
        }
예제 #10
0
        public override void StopHandler(BaseClass sender, StateEventArgs e)
        {
            base.StopHandler(sender, e);
            ClassErrorHandle.isWorkFlowRunning = false;
            LightStopButton();
            _isRunning = false;
            //Statistic.WFStatus = WorkFlowStatus.空闲;
            string strFrom = "流程停止";

            if (e != null)
            {
                strFrom += "(" + e.eventInfo + ")";
            }
            Statistic.GetWorkFlowStatus(DateTime.Now, WorkFlowStatus.空闲, strFrom, Statistic.WFStatus != WorkFlowStatus.空闲);
            if (Statistic.WFStatus == WorkFlowStatus.空闲)
            {
                Statistic.WorkFlowTimerStart(false);
            }
            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "WorkFLow", strFrom);
        }
예제 #11
0
        public override void StartHandler(BaseClass sender, StateEventArgs e)
        {
            base.StartHandler(sender, e);
            ClassErrorHandle.isWorkFlowRunning = true;
            _isRunning = true;
            LightStartButton();
            _isRunning = true;
            _isPausing = false;

            //Statistic.WFStatus = WorkFlowStatus.待料;
            string strFrom = "流程开始";

            if (e != null)
            {
                strFrom += "(" + e.eventInfo + ")";
            }
            Statistic.GetWorkFlowStatus(DateTime.Now, WorkFlowStatus.待料, strFrom, true);
            Statistic.WorkFlowTimerStart(!ClassWorkFlow.Instance.IsGRR);
            ClassCommonSetting.ProgramLog(LogFile.Level.Info, "WorkFLow", strFrom);
        }
예제 #12
0
        private ErrorInfoWithPause CheckNGSensor()
        {
            //waitHandle = false;
            string tempSensor = "", tempData = "";

            while (true)
            {
                for (int i = 0; i < 3; i++)
                {
                    System.Threading.Thread.Sleep(500);
                    tempSensor = tempData = "";
                    if (ThisInport(EnumInportName.UnloadOutUnloadLeft).status&& UnloadOutDataStations[(int)EnumCellIndex.左电芯].CellData == null)
                    {
                        tempSensor += " " + EnumCellIndex.左电芯.ToString();
                    }
                    else if (!ThisInport(EnumInportName.UnloadOutUnloadLeft).status&& UnloadOutDataStations[(int)EnumCellIndex.左电芯].CellData != null)
                    {
                        tempData += " " + EnumCellIndex.左电芯.ToString();
                    }
                    if (ThisInport(EnumInportName.UnloadOutUnloadMid).status&& UnloadOutDataStations[(int)EnumCellIndex.中电芯].CellData == null)
                    {
                        tempSensor += " " + EnumCellIndex.中电芯.ToString();
                    }
                    else if (!ThisInport(EnumInportName.UnloadOutUnloadMid).status&& UnloadOutDataStations[(int)EnumCellIndex.中电芯].CellData != null)
                    {
                        tempData += " " + EnumCellIndex.中电芯.ToString();
                    }
                    if (ThisInport(EnumInportName.UnloadOutUnloadRight).status&& UnloadOutDataStations[(int)EnumCellIndex.右电芯].CellData == null)
                    {
                        tempSensor += " " + EnumCellIndex.右电芯.ToString();
                    }
                    else if (!ThisInport(EnumInportName.UnloadOutUnloadRight).status&& UnloadOutDataStations[(int)EnumCellIndex.右电芯].CellData != null)
                    {
                        tempData += " " + EnumCellIndex.右电芯.ToString();
                    }
                    if (tempSensor == "" && tempData == "")
                    {
                        break;
                    }
                }
                if (tempSensor != "" || tempData != "")
                {
                    if (tempSensor == "")
                    {
                        tempSensor = "无";
                    }
                    if (tempData == "")
                    {
                        tempData = "无";
                    }
                    ClassCommonSetting.ProgramLog(LogFile.Level.Warning, "WorkFlow", $"NG挑选处下料电芯与数据不符:{tempSensor}{tempData}");
                    Colibri.CommonModule.Forms.BaseForm.DoInvokeRequired(MainForm.instance, () => MessageBox.Show(MainForm.instance, $"NG挑选处下料电芯与数据不符。{Environment.NewLine}{Environment.NewLine}" +
                                                                                                                  $"传感器检测到有电芯,但是程序没有数据记录:{tempSensor}。{Environment.NewLine}" +
                                                                                                                  $"错误处理:取出不符的多余电芯。{Environment.NewLine}{Environment.NewLine}" +
                                                                                                                  $"程序有数据记录,但是传感器没有检测到电芯:{tempData}。{Environment.NewLine}" +
                                                                                                                  $"错误处理:如果是电芯位置不对,摆正或取走电芯;如果没有电芯则不用处理。点确定后数据将会被删除忽略掉。{Environment.NewLine}{Environment.NewLine}" +
                                                                                                                  $"需要在流程恢复前清除不符电芯。处理完成后点确定。"));
                    SetUnloadOut();
                }
                else
                {
                    break;
                }
            }
            return(null);
        }
예제 #13
0
        /// <summary>
        /// 开始传送准备。
        /// 开始的条件是SMEMA的ready信号为true,并且InPos传感器没有检测到物料。
        /// 传送带运行,
        /// SMEMA avaliable为false。
        /// </summary>
        /// <returns>返回执行结果。成功返回空字符。</returns>
        public ErrorInfoWithPause ActionStartLoad(CallBackCommonFunc AfterActionLoadNew)
        {
            ErrorInfoWithPause res = null;
            string             barcodeReadRes;

            ////Go back to align the new cell.
            AxisLoadInConveyor.SetZero();
            bool   havenewpart = ClassWorkFlow.Instance.WorkMode != EnumWorkMode.空跑;// && ThisInport(EnumInportName.LoadInConvLoad).status;
            double offsetTemp  = 0;

            if (ClassWorkFlow.Instance.LoadMode == EnumLoadMode.自动)
            {
                offsetTemp  = ClassCommonSetting.SysParam.CurrentProductParam.CellDataSpec.CellWidth.Mean - ClassCommonSetting.SysParam.Products[CALIBPROD].CellDataSpec.CellWidth.Mean;
                offsetTemp /= 2;
                offsetTemp += ThisAxis(EnumAxisName.LoadInConveyor).PointList[EnumPointConveyor.BackDistance].Position;
                while (!ThisAxis(EnumAxisName.LoadInConveyor).MoveTo(offsetTemp))
                //return DispMotionError(AxisLoadInConveyor, "回移");
                {
                    res = DispMotionError(AxisLoadInConveyor, "回移");
                    if (res != null)
                    {
                        return(res);
                    }
                }
            }
            if ((havenewpart || ClassWorkFlow.Instance.WorkMode == EnumWorkMode.空跑) && ClassWorkFlow.Instance.FeedNewPart)
            {
                LoadInDataStations[LoadInDataStations.Length - 1].CellData = ClassDataInfo.NewCellData(++ClassWorkFlow.Instance.GetCell);
            }
            else
            {
                LoadInDataStations[LoadInDataStations.Length - 1].CellData = null;
            }
            //Go to next pitch position and start scan barcode
            AxisLoadInConveyor.SetZero();
            while (!AxisLoadInConveyor.MoveTo(EnumPointConveyor.CellPitch, true, -offsetTemp))
            //return DispMotionError(AxisLoadInConveyor, "进料移动");
            {
                res = DispMotionError(AxisLoadInConveyor, "进料移动");
                if (res != null)
                {
                    return(res);
                }
            }
            ////If PNP can pick
            //if (ThisInport(EnumInportName.LoadInConvInPos).status)
            //{
            //    NotifyDoneEvent(EnumEventName.NewCellLoad);
            //}
            if (LoadInDataStations[LoadInDataStations.Length - 1].CellData != null)
            {
                havenewpart &= BarcodeEnabled;
                if (ClassWorkFlow.Instance.LoadMode == EnumLoadMode.自动)
                {
                    barcodeReadRes = StartBarcodeScan(havenewpart);
                }
                else
                {
                    do
                    {
                        barcodeReadRes = StartBarcodeScan(havenewpart);
                        if (barcodeReadRes != "")
                        {
                            BaseForm.DoInvokeRequired(MainForm.instance,
                                                      () =>
                            {
                                while (MessageBox.Show(MainForm.instance, $"条码枪扫码出错: {barcodeReadRes}。{Environment.NewLine}请检查电芯位置是否正确或者是否有电芯。{Environment.NewLine}" +
                                                       "点“重试”重新扫条码。如果无电芯或需要移除电芯,则点“取消”放弃扫码。",
                                                       "条码枪扫码", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information) == DialogResult.Cancel)
                                {
                                    if (MessageBox.Show(MainForm.instance, "确定要取消并移除电芯?", "取消电芯", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                    {
                                        LoadInDataStations[LoadInDataStations.Length - 1].CellData = null;
                                        break;
                                    }
                                }
                            });
                        }
                    } while (LoadInDataStations[LoadInDataStations.Length - 1].CellData != null && barcodeReadRes != "");
                }
                if (LoadInDataStations[LoadInDataStations.Length - 1].CellData != null)
                {
                    ClassCommonSetting.ProgramLog(LogFile.Level.Notice, this.Name, "加载新物料,索引号" + ClassWorkFlow.Instance.GetCell.ToString() + " NG结果为" + (LoadInDataStations[LoadInDataStations.Length - 1].CellData.LoadNG ? "NG" : "OK"));
                }
            }
            if (AfterActionLoadNew != null)
            {
                AfterActionLoadNew();
            }
            return(null);
        }