Exemple #1
0
        /// <summary>
        /// 电芯进站校验
        /// </summary>
        /// <param name="strSFC">Barcode</param>
        /// <returns>OK - MES return =0 </returns>
        /// <returns>NG - MEW return >0 </returns>
        public MESRes CheckSfcStatus(string strSFC)
        {
            MESRes      mesRes       = new MESRes();
            string      strStartTime = "";
            string      strEndTime   = "";
            HiPerfTimer hTimer       = new HiPerfTimer();

            mesRes.bSuccess  = false;
            mesRes.strErrMsg = "调用失败";
            try
            {
                hTimer.Start();
                strStartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ssfff");
                string strUser     = DataManage.StrValue(DataGroups.DataGroupMESCheckSfcParam, DataItemMESCheckSfcParam.User);
                string strPassword = DataManage.StrValue(DataGroups.DataGroupMESCheckSfcParam, DataItemMESCheckSfcParam.Password);
                int    iTimeout    = DataManage.IntValue(DataGroups.DataGroupMESCheckSfcParam, DataItemMESCheckSfcParam.TimeOut);
                miCheckSFCStatusService.Credentials = new NetworkCredential(strUser, strPassword);
                iTimeout = (iTimeout < 10 || iTimeout > 60000) ? 10000 : iTimeout;
                miCheckSFCStatusService.Timeout = iTimeout;

                changeStatusRequest.site              = DataManage.StrValue(DataGroups.DataGroupMESCheckSfcParam, DataItemMESCheckSfcParam.site);              //设备所在站点
                changeStatusRequest.operation         = DataManage.StrValue(DataGroups.DataGroupMESCheckSfcParam, DataItemMESCheckSfcParam.operation);         //工位
                changeStatusRequest.operationRevision = DataManage.StrValue(DataGroups.DataGroupMESCheckSfcParam, DataItemMESCheckSfcParam.operationRevision); //工位版本
                changeStatusRequest.sfc = strSFC;                                                                                                              //电芯号

                miCheckSFCsta.ChangeSFCStatusRequest = changeStatusRequest;
                miCheckSFCstatusRes    = miCheckSFCStatusService.miCheckSFCstatus(miCheckSFCsta);
                mesRes.miCheckResponse = miCheckSFCstatusRes;
                mesRes.bSuccess        = true;
            }
            catch (Exception ex)
            {
                mesRes.bSuccess  = false;
                mesRes.strErrMsg = ex.ToString();
            }
            strEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ssfff");
            int iTime = (int)(hTimer.Duration * 1000);

            MESLog.WriteMiCheckSfcStatusLog(miCheckSFCsta, mesRes, strStartTime, strEndTime, iTime);
            return(mesRes);
        }
Exemple #2
0
        public override void Process()
        {
            if (taskInfo.bTaskAlarm || MainModule.alarmManage.IsAlarm || IOManage.bEStop || !MainModule.formMain.bRunFlag || null == _plcDriver)
            {
                taskInfo.iTaskStep           = MainModule.formMain.macHomeSta != MacHomeSta.Reseted ? 0 : taskInfo.iTaskStep;
                taskInfo.bTaskAlarm          = MainModule.formMain.bClrFlag ? false : taskInfo.bTaskAlarm;
                taskInfo.bTaskFinish         = false;
                taskInfo.bTaskOnGoing        = false;
                MainModule.formMain.bRunFlag = false;

                return;
            }

            taskInfo.bTaskAlarm   = false;
            taskInfo.bTaskOnGoing = true;
            switch (taskInfo.iTaskStep)
            {
            case 0:
                if (MainModule.formMain.bRunFlag)
                {
                    taskInfo.bTaskFinish  = false;
                    taskInfo.bTaskAlarm   = false;
                    taskInfo.bTaskOnGoing = true;
                    taskInfo.htTimer.Start();

                    taskInfo.iTaskStep = 1;
                }
                break;

            case 1:
                taskGroup.AddRunMessage("等待扫码开始...", OutputLevel.Trace);
                taskInfo.iTaskStep = 10;
                break;

            case 10:
                if (!_plcDriver.plcData.dicScanItems[PLC1.内线扫码触发].strValue.Equals("100") || !_plcDriver.plcData.dicScanItems[PLC1.外线扫码触发].strValue.Equals("100"))
                {
                    break;
                }
                taskGroup.AddRunMessage("收到扫码触发信号,开始扫码...", OutputLevel.Trace);
                taskInfo.iTaskStep = 21;
                break;

            case 21:
                //开始读码
                if (null == insideCodeReader || null == outsideCodeReader)
                {
                    _plcDriver.WriteData(PLC1.内线扫码触发, 300);
                    _plcDriver.WriteData(PLC1.外线扫码触发, 300);

                    strErr             = "未发现读码器";
                    taskInfo.iTaskStep = 501;
                    break;
                }

                insideCodeReader.RecvData  = string.Empty;
                outsideCodeReader.RecvData = string.Empty;
                CodeReaderRes res1 = insideCodeReader.Read();     //以异步方式读取内线二维码
                CodeReaderRes res2 = outsideCodeReader.Read();    //以异步方式读取外线二维码
                if (res1 != CodeReaderRes.SUCCESS || res2 != CodeReaderRes.SUCCESS)
                {
                    //读码命令发送失败
                    _plcDriver.WriteData(PLC1.内线扫码触发, 300);
                    _plcDriver.WriteData(PLC1.外线扫码触发, 300);

                    strErr             = GetErrMsg(res1, res2);
                    taskInfo.iTaskStep = 501;
                    Program.formStart.formProductInfo.iScanNgCount++;
                    Program.formStart.ShowScanResult(false, 0, insideCodeReader.RecvData, outsideCodeReader.RecvData, strErr);

                    break;
                }
                taskGroup.AddRunMessage("读码命令发送成功,等待读码完成...", OutputLevel.Trace);
                taskHiperTimer.Start();
                taskInfo.iTaskStep = 22;
                break;

            case 22:
                //等待读码完成
                int iTimeout = 500;
                if (DataManage.docData.dicDataGroup.ContainsKey(DataGroups.DataGroupSystem) &&
                    DataManage.docData.dicDataGroup[DataGroups.DataGroupSystem].dicDataItem.ContainsKey(DataItemSystem.等待读码完成时间))
                {
                    iTimeout = DataManage.IntValue(DataGroups.DataGroupSystem, DataItemSystem.等待读码完成时间);
                }
                if (!string.IsNullOrEmpty(insideCodeReader.RecvData) && !string.IsNullOrEmpty(outsideCodeReader.RecvData))
                {
                    if (insideCodeReader.RecvData.Contains("ERROR") || outsideCodeReader.RecvData.Contains("ERROR"))
                    {
                        //读码失败
                        _plcDriver.WriteData(PLC1.内线扫码触发, 300);
                        _plcDriver.WriteData(PLC1.外线扫码触发, 300);

                        strErr             = "解码失败!";
                        taskInfo.iTaskStep = 501;
                        Program.formStart.formProductInfo.iScanNgCount++;
                        Program.formStart.ShowScanResult(false, (float)taskHiperTimer.Duration * 1000, insideCodeReader.RecvData, outsideCodeReader.RecvData, strErr);
                        break;
                    }
                    insideCodeReader.RecvData.Replace('\r', ' ');
                    insideCodeReader.RecvData.Replace('\n', ' ');
                    insideCodeReader.RecvData.Trim();
                    outsideCodeReader.RecvData.Replace('\r', ' ');
                    outsideCodeReader.RecvData.Replace('\n', ' ');
                    outsideCodeReader.RecvData.Trim();
                    taskInfo.iTaskStep = 31;
                }
                else if (taskHiperTimer.TimeUp((double)((double)iTimeout / 1000.0)))
                {
                    //读码超时
                    _plcDriver.WriteData(PLC1.内线扫码触发, 300);
                    _plcDriver.WriteData(PLC1.外线扫码触发, 300);

                    strErr             = "读码超时!";
                    taskInfo.iTaskStep = 501;
                    Program.formStart.formProductInfo.iScanNgCount++;
                    Program.formStart.ShowScanResult(false, (float)taskHiperTimer.Duration * 1000, insideCodeReader.RecvData, outsideCodeReader.RecvData, strErr);
                }
                break;

            case 31:
                //读码成功
                taskGroup.AddRunMessage("读码成功: " + "<" + insideCodeReader.RecvData + ">  <" + outsideCodeReader.RecvData + ">", OutputLevel.Trace);
                _plcDriver.WriteData(PLC1.内线二维码, insideCodeReader.RecvData);
                _plcDriver.WriteData(PLC1.外线二维码, outsideCodeReader.RecvData);

                Program.formStart.formProductInfo.iScanOkCount++;
                Program.formStart.ShowScanResult(true, (float)taskHiperTimer.Duration * 1000, insideCodeReader.RecvData, outsideCodeReader.RecvData, "");
                if (!Program.formStart.bMesSwitch)
                {
                    //MES屏蔽
                    _plcDriver.WriteData(PLC1.内线扫码触发, 200);
                    _plcDriver.WriteData(PLC1.外线扫码触发, 200);

                    taskInfo.iTaskStep = 601;
                    break;
                }

                taskGroup.AddRunMessage("开始进行电芯进站校验...", OutputLevel.Trace);

                taskInfo.iTaskStep = 41;
                break;

            case 41:
                //调用MES 进行电芯进站校验
                MESRes mesRes1 = MainModule.formMain.mes.CheckSfcStatus(insideCodeReader.RecvData);
                MESRes mesRes2 = MainModule.formMain.mes.CheckSfcStatus(outsideCodeReader.RecvData);
                if (!mesRes1.bSuccess || !mesRes2.bSuccess)
                {
                    //MES 调用失败
                    _plcDriver.WriteData(PLC1.内线扫码触发, 400);
                    _plcDriver.WriteData(PLC1.外线扫码触发, 400);

                    strErr             = "MES 调用失败,请检查网络与MES设置!";
                    taskInfo.iTaskStep = 501;
                    break;
                }
                if ([email protected] != 0 || [email protected] != 0)
                {
                    //电芯进站校验未通过
                    if ([email protected] != 0 && [email protected] != 0)
                    {
                        strErr = "内线与外线电芯进站校验均未通过!";
                    }
                    else if ([email protected] != 0)
                    {
                        strErr = "内线电芯进站校验未通过!";
                    }
                    else
                    {
                        strErr = "外线电芯进站校验未通过!";
                    }
                    _plcDriver.WriteData(PLC1.内线扫码触发, 400);
                    _plcDriver.WriteData(PLC1.外线扫码触发, 400);

                    taskInfo.iTaskStep = 501;
                    break;
                }

                //MES 调用成功,电芯进站校验通过
                _plcDriver.WriteData(PLC1.内线扫码触发, 200);
                _plcDriver.WriteData(PLC1.外线扫码触发, 200);

                taskGroup.AddRunMessage("电芯进站校验通过!", OutputLevel.Trace);
                taskInfo.iTaskStep = 51;
                taskHiperTimer.Start();
                break;

            case 51:
                if (!taskHiperTimer.TimeUp(0.5))
                {
                    break;
                }
                taskInfo.iTaskStep = 601;
                break;

                #region Error 501-600
            case 501:     //致命异常,需重新开始
                taskInfo.bTaskOnGoing = false;
                taskInfo.bTaskFinish  = false;
                taskInfo.bTaskAlarm   = true;
                taskInfo.iTaskStep    = 0;

                _plcDriver.plcData.dicScanItems[PLC1.内线扫码触发].strValue = "0";
                _plcDriver.plcData.dicScanItems[PLC1.外线扫码触发].strValue = "0";
                taskGroup.AddRunMessage(strErr, OutputLevel.Warn);
                MainModule.alarmManage.InsertAlarm(AppAlarmKeys.扫码异常, strErr);
                break;

            case 502:       //一般异常,解除后按下开始可以继续
                taskInfo.bTaskOnGoing = false;
                taskInfo.bTaskFinish  = false;
                taskInfo.bTaskAlarm   = true;
                taskInfo.strTaskMes   = "异常报警解除后,可以继续执行。";
                taskInfo.iTaskStep    = taskInfo.iTaskAlarmStep;

                _plcDriver.plcData.dicScanItems[PLC1.内线扫码触发].strValue = "0";
                _plcDriver.plcData.dicScanItems[PLC1.外线扫码触发].strValue = "0";
                taskGroup.AddRunMessage(strErr, OutputLevel.Warn);
                MainModule.alarmManage.InsertAlarm(AppAlarmKeys.扫码异常, strErr);
                break;

                #endregion
                #region Success 601 - 999
            case 601:
                taskInfo.bTaskOnGoing   = false;
                taskInfo.bTaskFinish    = true;
                taskInfo.bTaskAlarm     = false;
                taskInfo.iTaskStep      = 0;
                taskInfo.iTaskAlarmStep = 0;

                _plcDriver.plcData.dicScanItems[PLC1.内线扫码触发].strValue = "0";
                _plcDriver.plcData.dicScanItems[PLC1.外线扫码触发].strValue = "0";
                taskGroup.AddRunMessage("正常终了。", OutputLevel.Trace);
                break;

                #endregion
            default:
                taskInfo.iTaskStep  = 0;
                taskInfo.bTaskAlarm = true;
                break;
            }
        }
        private void ThreadScan()
        {
            int iCount = 0;

            System.Threading.Thread.Sleep(1000);

            while (!MainModule.formMain.bExit)
            {
                System.Threading.Thread.Sleep(1000);
                try
                {
                    #region 掉线检测重连
                    if (!yamahaRCX340API.Connected)    //取消自动重连
                    {
                        if (DataManage.CheckItemExist("System", "RXC340掉线重连次数"))
                        {
                            int iLimitTimes = DataManage.IntValue("System", "RXC340掉线重连次数");
                            if (_iTimes == iLimitTimes)
                            {
                                MainModule.alarmManage.InsertAlarm(AlarmKeys.ConnectAlarm1, "与机械手 YamahaRXC340 连接断开,请检查网络后在手动页面中手动重连!");
                                MainModule.AddRunMessage(">连接未成功。", OutputLevel.Warn);
                                _iTimes++;
                                continue;
                            }
                            else if (_iTimes > iLimitTimes)
                            {
                                continue;
                            }
                        }
                        ReConnectToRobot();
                        continue;
                    }
                    #endregion

                    #region 机械手信息获取
                    if (iCount % 2 == 0)
                    {
                        //2S
                        GetAlarmStatus();
                        //GetServoStatus();
                        GetCurrentPos();
                    }
                    if (iCount > 3)
                    {
                        //3S
                        //GetCurrentVel();
                        //GetCurrDist();
                        //iCount = 0;
                    }

                    //1S
                    GetInputStatus();
                    GetOutputStatus();
                    iCount++;
                    #endregion
                }
                catch (Exception)
                {
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 电芯出站,向MES传输需求的参数值
        /// </summary>
        /// <param name="strSFC">Barcode</param>
        /// <param name="sprayingInfo">清洗参数</param>
        /// <returns></returns>
        public MESRes DataCollectForSfcEx(string strSFC, SprayingInfo sprayingInfo)
        {
            string      strStartTime = "";
            string      strEndTime   = "";
            HiPerfTimer hTimer       = new HiPerfTimer();
            MESRes      mesRes       = new MESRes();

            try
            {
                hTimer.Start();
                strStartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ssfff");
                string strUser     = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.User);
                string strPassword = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.Password);
                int    iTimeout    = DataManage.IntValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.TimeOut);
                machineIntegrationService.Credentials = new NetworkCredential(strUser, strPassword);
                iTimeout = (iTimeout < 10 || iTimeout > 60000) ? 10000 : iTimeout;
                machineIntegrationService.Timeout = iTimeout;

                sfcDataCollectRequest.site              = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.site);
                sfcDataCollectRequest.user              = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.user);
                sfcDataCollectRequest.operation         = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.operation);
                sfcDataCollectRequest.operationRevision = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.operationRevision);;
                sfcDataCollectRequest.resource          = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.resource);
                sfcDataCollectRequest.activityId        = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.activityId);
                sfcDataCollectRequest.dcGroup           = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.dcGroup);;
                sfcDataCollectRequest.dcGroupRevision   = DataManage.StrValue(DataGroups.DataGroupMESDataCollectParam, DataItemMESDataCollectParam.dcGroupRevision);;
                sfcDataCollectRequest.modeProcessSfc    = ModeProcessSfc.MODE_PASS_SFC_POST_DC;
                sfcDataCollectRequest.sfc = strSFC;

                int index       = 0;
                int iArrayCount = 0;
                foreach (DataItem item in DataManage.docData.dicDataGroup[DataGroups.DataGroupParametricDataArray].listDataItem)
                {
                    iArrayCount++;
                }

                sfcDataCollectRequest.parametricDataArray = new machineIntegrationParametricData[iArrayCount];
                foreach (DataItem item in DataManage.docData.dicDataGroup[DataGroups.DataGroupParametricDataArray].listDataItem)
                {
                    sfcDataCollectRequest.parametricDataArray[index]          = new machineIntegrationParametricData();
                    sfcDataCollectRequest.parametricDataArray[index].dataType = ParameterDataType.NUMBER;
                    sfcDataCollectRequest.parametricDataArray[index].name     = item.strItemName;
                    sfcDataCollectRequest.parametricDataArray[index].value    = item.objValue.ToString();

                    if (sfcDataCollectRequest.parametricDataArray[index].name.Equals("DXQXPRES"))
                    {
                        sfcDataCollectRequest.parametricDataArray[index].value = sprayingInfo.strSprayingPressure;
                    }
                    if (sfcDataCollectRequest.parametricDataArray[index].name.Equals("DXQXTIME"))
                    {
                        sfcDataCollectRequest.parametricDataArray[index].value = sprayingInfo.strSprayingTime;
                    }
                    if (sfcDataCollectRequest.parametricDataArray[index].name.Equals("DXQXGZYL"))
                    {
                        sfcDataCollectRequest.parametricDataArray[index].value = sprayingInfo.strDryingPressure;
                    }
                    if (sfcDataCollectRequest.parametricDataArray[index].name.Equals("DXQXCCYSJ"))
                    {
                        sfcDataCollectRequest.parametricDataArray[index].value = sprayingInfo.strBlowingResidualFluidTime;
                    }
                    if (sfcDataCollectRequest.parametricDataArray[index].name.Equals("DXQCGZSJ"))
                    {
                        sfcDataCollectRequest.parametricDataArray[index].value = sprayingInfo.strDryingTime;
                    }
                    if (sfcDataCollectRequest.parametricDataArray[index].name.Equals("DXQXYW"))
                    {
                        sfcDataCollectRequest.parametricDataArray[index].value = sprayingInfo.strOilTemp;
                    }
                    index++;
                }

                sfcDataCollectRequest.ncCodeArray = new nonConfirmCodeArray[1];  //?
                sfcDataCollectRequest.sfc         = strSFC;

                dataCollect.SfcDcExRequest = sfcDataCollectRequest;
                dataCollectForSfcExRes     = machineIntegrationService.dataCollectForSfcEx(dataCollect);
                mesRes.dataCollectResponse = dataCollectForSfcExRes;

                mesRes.bSuccess = true;
                //strArrayMsg[4] = [email protected](",", ",").Replace("\r\n", " ");
            }
            catch (Exception ex)
            {
                mesRes.bSuccess  = false;
                mesRes.strErrMsg = ex.ToString();
            }

            strEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ssfff");
            int iTime = (int)(hTimer.Duration * 1000);

            MESLog.WriteDataCollectForSfcExLog(dataCollect, mesRes, strStartTime, strEndTime, iTime);
            return(mesRes);
        }