| | |
| | | package com.mes.service.CacheGlassService; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.mes.common.PlcTools.S7control; |
| | | import com.mes.entity.EdgStorageCageDetails; |
| | | import com.mes.entity.GlassInfo; |
| | | import com.mes.entity.TaskCache; |
| | | import com.mes.entity.device.PLCAutoMes; |
| | | import com.mes.entity.device.PlcParameterObject; |
| | | import com.mes.mapper.SelectInfo; |
| | | |
| | | |
| | |
| | | public class Logic { |
| | | @Autowired |
| | | private SelectInfo selectInfo; |
| | | //识别逻辑 |
| | | //识别逻辑 不交互 |
| | | public void identify(String Number){ |
| | | //查询任务 |
| | | // PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | String s=S7control.getinstance().ReadWord("DB14.26", 1).get(0)+""; |
| | | boolean isexist=isExist(Number); |
| | | if (isexist) { |
| | | //存在逻辑 1.添加信息 2.回复PLC存在 |
| | |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 2); |
| | | } |
| | | } |
| | | //理片 |
| | | public void Process(){ |
| | | String Result=S7control.getinstance().ReadWord("DB14.0", 1).get(0)+""; |
| | | String Number=S7control.getinstance().ReadWord("DB14.2", 1).get(0)+""; |
| | | if(Result=="1"){//进片请求 |
| | | processInto(Number); |
| | | }else if(Result=="2"){//出片请求 |
| | | processOut(); |
| | | }else if(Result=="3"){//进出片请求 |
| | | if (!processOut()) { //先出后进 |
| | | processInto(Number); |
| | | } |
| | | } |
| | | } |
| | | //理片 进 |
| | | public void process(String Number){ |
| | | public boolean processInto(String Number){ |
| | | //查询消息队列里的玻璃 |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | if(GlassInfo!=null){//存在此玻璃编号 |
| | | //同钢化版图内的栅格号 |
| | | List<EdgStorageCageDetails> list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperinglayoutid(),GlassInfo.getTemperingfeedsequence(),GlassInfo.getWidth()); |
| | | //空栅格号 |
| | | if (list.size()==0) { |
| | | list=selectInfo.SelectCacheLeisure(); |
| | | } |
| | | //小于此玻璃钢化版图序号的栅格号 |
| | | if(list.size()==0){ |
| | | list=selectInfo.SelectIsExistIntoCache(GlassInfo.getTemperinglayoutid(),GlassInfo.getWidth()); |
| | | } |
| | | if(list.size()>0){ |
| | | //存在空格 |
| | | //1.生成任务: 起始位置0 结束位置this.slot 任务类型 1 (进片任务) |
| | | //2.回复 1进片 |
| | | EdgStorageCageDetails item=list.get(0); |
| | | selectInfo.insertCacheTask(GlassInfo.getId()+"","0",item.getSlot()+"","1"); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | return true; |
| | | } |
| | | |
| | | }else{ |
| | | // ID编号不存在 不处理/回复PLC 进行报警提示 |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | //理片 出 |
| | | public void processOut(String Number){ |
| | | public boolean processOut(){ |
| | | //查询任务 |
| | | |
| | | //返回结果 |
| | | String A09=S7control.getinstance().ReadWord("DB14.56", 1).get(0)+""; |
| | | String A10=S7control.getinstance().ReadWord("DB14.58", 1).get(0)+""; |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | List<EdgStorageCageDetails> list=selectInfo.SelectCacheOut(); |
| | | boolean isOut=true;//其他情况条件 如:后续设备故障禁止理片出片 等 |
| | | if (list.size()>0&&isOut) { |
| | | EdgStorageCageDetails item=list.get(0); |
| | | if(A09=="0"&&A10=="1"){ |
| | | //出到 A09 |
| | | selectInfo.insertCacheTask(item.getGlassid()+"","0","09","2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "1"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | }else if(A09=="1"&&A10=="0"){ |
| | | //出到 A10 |
| | | selectInfo.insertCacheTask(item.getGlassid()+"","0","10","2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | }else if(A09=="0"&&A10=="0"){ |
| | | //都允许 A09/A10 上一片是否和此片玻璃尺寸尺寸相同 |
| | | String endcell="09"; |
| | | String SendEndcell="1"; |
| | | boolean If_=false; |
| | | GlassInfo glassInfo09= selectInfo.SelectLastOutCacheInfo("09"); |
| | | GlassInfo glassInfo10= selectInfo.SelectLastOutCacheInfo("10"); |
| | | if(glassInfo10!=null&&glassInfo10.getWidth()==item.getWidth()&&glassInfo10.getHeight()==item.getHeight()){ |
| | | endcell="10"; |
| | | SendEndcell="2"; |
| | | }else if(glassInfo10!=null&&If_){ |
| | | //其他条件 |
| | | } |
| | | //磨边 |
| | | selectInfo.insertCacheTask(item.getGlassid()+"","0",endcell,"2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | return true; |
| | | } |
| | | } |
| | | //返回结果 |
| | | return false; |
| | | } |
| | | |
| | | //磨边 不交互 理片和磨边机自己交互 |
| | | public void processMb(String Number){ |
| | | //查询任务 |
| | | |
| | | GlassInfo GlassInfo=selectInfo.SelectGlassId(Number); |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | if(GlassInfo!=null){ |
| | | //发送任务 ID 长 宽 厚 倒角 工艺功能等 |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.22").getAddress(),"N10000"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.24").getAddress(), "1000"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.26").getAddress(),"800"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(),"60"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.30").getAddress(), "2"); |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1"); |
| | | } |
| | | //返回结果 |
| | | } |
| | | |
| | |
| | | } |
| | | return true;//返回 存在 |
| | | } |
| | | |
| | | //是否存在此编号玻璃 |
| | | public boolean isExist(String Number){ |
| | | //查询是否存在 |