| | |
| | | import com.example.springboot.component.S7control; |
| | | import com.example.springboot.entity.GlassInfo; |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.GlassInfo; |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | import com.example.springboot.mapper.AlbaniaMapper; |
| | | import com.google.common.primitives.Bytes; |
| | |
| | | //如果有同类型时直接增加 |
| | | if(cageid!=Integer.MIN_VALUE){ |
| | | //发送plc任务 |
| | | Mestast(glassid, 1001, cageid, 1,"MESID1"); |
| | | //任务发送字 |
| | | //Mestast(glassid,1001,cageid,1); |
| | | |
| | | }else{ |
| | |
| | | } |
| | | //当返回的格子号为空时,返回400笼子已满 |
| | | if(cageid!=Integer.MIN_VALUE){ |
| | | Mestast(glassid,1001,cageid,1); |
| | | Mestast(glassid,1001,cageid,1,"MESID1"); |
| | | //发送plc任务 |
| | | |
| | | }else{ |
| | |
| | | |
| | | for(int i=1;i<=7;i++){ |
| | | glassmate= albaniaMapper.SelectOutGlass(line); |
| | | if(glassmate==null){ |
| | | //未领取任务 |
| | | return (400); |
| | | }else{ |
| | | mateid=glassmate.getMateid(); |
| | | glasstype=glassmate.getGlasstype(); |
| | | tier=glassmate.getTier(); |
| | | sumid=glassmate.getId(); |
| | | flowcard=glassmate.getFlowcard(); |
| | | |
| | | |
| | | StorageCage glass= albaniaMapper.SelectCageGlass(glasstype); |
| | | if(glass!=null){ |
| | | //发送配片数据 |
| | | Mestast(glassmate.getGlasstype()+"i", glass.getId(),2002, 0); |
| | | Mestast(glassmate.getGlasstype()+"i", glass.getId(),2002, 0,"MESID"+i); |
| | | albaniaMapper.AddFinishNumber(flowcard, mateid, tier); |
| | | albaniaMapper.Inserttask(1, 0, glass.getId(), 2002, glassmate.getGlassid()+i, glasstype,glass.getFlowcard(),mateid,tier); |
| | | if(tier==sumid){ |
| | | if(tier==sumid){//当配片数量等于成品小片总片数时 |
| | | //本次配片完成发送启动命令 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)2);//出片任务启动 |
| | | return (200);//结束 |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | return(200);// 结束 |
| | | } |
| | | |
| | |
| | | glassidlist.add((byte) iditem); |
| | | } |
| | | byte[] bytes = Bytes.toArray(glassidlist); |
| | | //writeString |
| | | System.out.println("outmesidbytes:" + bytes.length); |
| | | S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(),bytes); |
| | | System.out.println(plcmes.getPlcParameter(address).getAddress()); |
| | | System.out.println(); |
| | | |
| | | //S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(),bytes); |
| | | //S7control.getinstance().WriteByte(address, bytes);// 派发出片id |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | //下发理片任务 |
| | | public void Mestast(String glassid,int MESToPLCStart1,int MESToPLCTarget1,int MESToPLC) { |
| | | outmesid(glassid, "MESID1");//下发玻璃id |
| | | public void Mestast(String glassid,int MESToPLCStart1,int MESToPLCTarget1,int MESToPLC,String address) { |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter(address).getAddress(),glassid);//玻璃id |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStart1").getAddress(), (short) MESToPLCStart1);//起始位置 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCTarget1").getAddress(), (short) MESToPLCTarget1);//目标位置 |
| | | if(MESToPLC!=0){ |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)MESToPLC);//mes理片任务类型 |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |