| | |
| | | public class MyGenerator { |
| | | |
| | | /** 数据源配置*/ |
| | | private static final String jdbc = "jdbc:mysql://10.153.19.150:3306/albania?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai"; |
| | | private static final String jdbc = "jdbc:mysql://192.168.10.99:3306/albania?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai"; |
| | | private static final String driverName = "com.mysql.cj.jdbc.Driver"; |
| | | |
| | | private static final String username = "root"; |
| | |
| | | // readAndUpdateWordValues(PlcframeObject); |
| | | |
| | | // readAndUpdateWordValues(plcStateObject); |
| | | int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex(); |
| | | // System.out.println(index); |
| | | PlcMesObject.getPlcParameter("AddStart").getAddress(index); |
| | | // System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index)); |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("FeedID"); |
| | | addresses.add("AddStart"); |
| | | // System.out.println(addresses); |
| | | // System.out.println(PlcMesObject.getPlcParameterValues(addresses)); |
| | | List<String> addresses2 = new ArrayList<>(); |
| | | addresses2.add("FeedID"); |
| | | addresses2.add("FeedCarStatus"); |
| | | // int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex(); |
| | | // // System.out.println(index); |
| | | // PlcMesObject.getPlcParameter("AddStart").getAddress(index); |
| | | // // System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index)); |
| | | // List<String> addresses = new ArrayList<>(); |
| | | // addresses.add("FeedID"); |
| | | // addresses.add("AddStart"); |
| | | // // System.out.println(addresses); |
| | | // // System.out.println(PlcMesObject.getPlcParameterValues(addresses)); |
| | | // List<String> addresses2 = new ArrayList<>(); |
| | | // addresses2.add("FeedID"); |
| | | // addresses2.add("FeedCarStatus"); |
| | | |
| | | //System.out.println(PlcReadObject.getPlcParameterValues(addresses2)); |
| | | |
| | |
| | | // \\ TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | // List<Short> ss= S7control.getinstance().ReadWord("DB14.0", 1); |
| | | // System.out.println(ss); |
| | | // System.out.println(111111); |
| | | // List<Short> E0sss1id = S7control.getinstance().ReadWord("DB14.0",1); |
| | | // String E01id = S7control.getinstance().readStrings("DB14.38"); |
| | | // System.out.println(E01id); |
| | | // if (S7control.getinstance().CheckCsonnected() == false) { |
| | | List<Short> E0sss1id = S7control.getinstance().ReadWord("DB14.206",1); |
| | | List<String> st= S7control.getinstance().readStrings("DB14.206"); |
| | | byte[] E0sss1ids = S7control.getinstance().ReadByte("DB14.206",2); |
| | | byte[] E0sss1idss = S7control.getinstance().ReadByte("DB14.0",210); |
| | | |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class); |
| | | albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class); |
| | | //spianService.selectAll(albaniaMapper.SelectGlass()); |
| | |
| | | |
| | | |
| | | //一号线请求 |
| | | if (ExportTOMES1.equals("1") == true&&B01State.equals("0")==true) { |
| | | //将运输车状态改为忙碌 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | spianService.selectout(1); |
| | | } |
| | | //二线号请求时 |
| | | if (ExportToMES2.equals("1") == true&&B01State.equals("0")==true) { |
| | | //将运输车状态改为忙碌 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | spianService.selectout(2); |
| | | } |
| | | // if (ExportTOMES1.equals("1") == true&&B01State.equals("0")==true) { |
| | | // //将运输车状态改为忙碌 |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | // spianService.selectout(1); |
| | | // } |
| | | // //二线号请求时 |
| | | // if (ExportToMES2.equals("1") == true&&B01State.equals("0")==true) { |
| | | // //将运输车状态改为忙碌 |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | // spianService.selectout(2); |
| | | // } |
| | | //进片请求时 |
| | | if(PLCToMES!=null && B01State!=null){ |
| | | if(PLCToMES.equals("1")==true&&B01State.equals("0")==true){ |
| | | //将运输车状态改为忙碌 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | //S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1); |
| | | |
| | | spianService.selectAll(albaniaMapper.SelectGlass()); |
| | | } |
| | | |
| | | |
| | | |
| | | //任务完成时 |
| | | if(TastState.equals("1")==true){ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 查询数据库 |
| | | // 推送到前端 |
| | |
| | | //读取DB105区文件 |
| | | PlcParameterObject plcmes=PLCAutoMes.PlcMesObject; |
| | | |
| | | //String PlcRequest=plcmes.getPlcParameter("GaToMES").getValue();//请求 |
| | | //String MesSend=plcmes.getPlcParameter("MESToGaStatus").getValue();//发送 |
| | | //double width=plcmes.getPlcParameter("Height").getValue();//宽 |
| | | //double height=plcmes.getPlcParameter("width").getValue();//高 |
| | | // String PlcRequest=plcmes.getPlcParameter("GaToMES").getValue();//请求 |
| | | // String MesSend=plcmes.getPlcParameter("MESToGaStatus").getValue();//发送 |
| | | // double width=Double.valueOf(plcmes.getPlcParameter("Height").getValue());//宽 |
| | | // double height=Double.valueOf(plcmes.getPlcParameter("width").getValue());//高 |
| | | |
| | | String PlcRequest=S7control.getinstance().ReadWord("DB14.26", 1).get(0)+""; |
| | | double width=Double.parseDouble(S7control.getinstance().ReadWord("DB14.28", 1).get(0)+""); |
| | | double height=Double.parseDouble(S7control.getinstance().ReadWord("DB14.30", 1).get(0)+""); |
| | | String MesSend=S7control.getinstance().ReadWord("DB14.170", 1).get(0)+""; |
| | | |
| | | //获取测量的长,宽 |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | String PlcRequest = "1"; |
| | | String MesSend = "0"; |
| | | double width = 402; |
| | | double height = 402; |
| | | // String PlcRequest = "1"; |
| | | // String MesSend = "0"; |
| | | // double width = 402; |
| | | // double height = 402; |
| | | |
| | | //匹配 |
| | | if ("1".equals(PlcRequest)&&"0".equals(PlcRequest)) { |
| | | GlassInfo MesureGlassinfo=HomeService.Normal(width, height, "1"); |
| | | //System.err.println(PlcRequest+","+MesSend+","+width+","+height); |
| | | if ("0".equals(PlcRequest)) { |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 0); |
| | | } |
| | | if ("1".equals(PlcRequest)&&"0".equals(MesSend)) { |
| | | boolean is=HomeService.Normal(width, height, "1"); |
| | | if (is) { |
| | | // 测量成功 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 1); |
| | | |
| | | }else{ |
| | | // 重新测量 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 4); |
| | | } |
| | | |
| | | } |
| | | Queue LastQueue= QueueMapper.selectLastQueue(); |
| | | // String E01id = new String( S7controlLK.getinstance().ReadByte("DB17.0",16)); |
| | |
| | | List<StorageTask> StoragTaskeTaskOut = storageCageService.SelectStorageTask(1); |
| | | jsonObject.append("StoragTaskeTaskOut", StoragTaskeTaskOut); |
| | | |
| | | //查询当前订单任务 |
| | | // //查询当前订单任务 |
| | | List<FlowCard> OrderTask = storageCageService.SelectOrderTask(); |
| | | jsonObject.append("OrderTask", OrderTask); |
| | | |
| | |
| | | } |
| | | return addresslist; |
| | | } |
| | | |
| | | public void writeString(String addr,String data) { |
| | | s7PLC.writeString(addr,data); |
| | | } |
| | | |
| | | public String readStrings(String addr) { |
| | | return s7PLC.readString(addr); |
| | | } |
| | |
| | | // TODO Auto-generated method stub |
| | | // |
| | | System.out.println("启动完成"); |
| | | // new PLCAutoMes().start(); |
| | | new PLCAutoMes().start(); |
| | | // new PlcHold().start(); |
| | | // new PlcHoldNew().start(); |
| | | new PlcHoldNew().start(); |
| | | |
| | | new Plchome().start(); |
| | | //new Plchome().start(); |
| | | // new PlcLayout().start(); |
| | | // new Plcalarm().start(); |
| | | // new Plcsign().start(); |
| | |
| | | } |
| | | if (addressLength == 14 ) { |
| | | int wordindex = index; |
| | | int newIndex = wordindex + 13; |
| | | return stringdatas[0] + "." + wordindex +"-" + newIndex; |
| | | //int newIndex = wordindex + 13; |
| | | return stringdatas[0] + "." + wordindex ; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | @Update("UPDATE `albania`.`storage_cage` SET `glass_id` =#{glassid}, `width` =width-#{glasswidth}, `glasswidth` =#{glasswidth}, `glassheight` =#{glassheight}, `glasswidthmm` =#{glasswidthmm}, `glassheightmm` = #{glassheightmm}, `state` = #{state}, `glasstype` = #{glasstype}, `number` = #{number} WHERE `id` =#{id};") |
| | | void AddCage(int id,String glassid,Double glasswidth,Double glassheight,Double glasswidthmm,Double glassheightmm,int state,int glasstype,int number); |
| | | //获取进片数据 |
| | | @Select("select glassid,flowcard,glasswidth as width,glassheight as height,glasswidthmm,glassheightmm,glasstype from queue where state=0 limit 1") |
| | | @Select("select glassid,flowcard,glasswidth as width,glassheight as height,glasswidthmm,glassheightmm,glasstype from queue where state=1 limit 1") |
| | | GlassInfo SelectGlass(); |
| | | //一号线查询任务 |
| | | @Select("select * from v_cagerelease1 where mateid not in(select mateid from v_cagerelease1 where surplus=0 group by mateid);") |
| | |
| | | "values (null,null,null,null,null,null,#{glasswidthmm},#{glassheightmm},null,#{state},NOW())") |
| | | void insertMatchFailure(@Param("glasswidthmm") double glasswidthmm, @Param("glassheightmm") double glassheightmm,@Param("state") int state); |
| | | |
| | | @Delete("delete from queue where state<=0") |
| | | void DeleteErrorQueue(); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | // 匹配逻辑 |
| | | public GlassInfo Normal(double width, double height, String line) { |
| | | public boolean Normal(double width, double height, String line) { |
| | | List<Queue> ErrowQueues= QueueMapper.selectErrorQueues(); |
| | | if (ErrowQueues.size()>0) { |
| | | //System.out.println("有匹配失败数据未去除"); |
| | | return new GlassInfo(); |
| | | return false; |
| | | } |
| | | List<GlassInfo> Result = NormalGlassInfo(width, height, "1"); |
| | | if (Result.size() == 1) { |
| | |
| | | GlassInfoMapper.updatemeasurenumber(GlassInfo.getId()); |
| | | System.out.println("匹配成功"); |
| | | System.out.println(GlassInfo.getGlassid()); |
| | | return GlassInfo; |
| | | return true; |
| | | } else if (Result.size() > 1) { |
| | | // 匹配失败 匹配到多条符合的数据 添加数据 |
| | | QueueMapper.insertMatchFailure(width, height, 0); |
| | |
| | | QueueMapper.insertMatchFailure(width, height, -1); |
| | | System.out.println("未找到符合的数据"); |
| | | } |
| | | return new GlassInfo(); |
| | | return false; |
| | | } |
| | | |
| | | // Execl表格 传入文件路径 |
| | |
| | | //如果有同类型时直接增加 |
| | | 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{ |
| | |
| | | |
| | | StorageCage glass= albaniaMapper.SelectCageGlass(glasstype); |
| | | //发送配片数据 |
| | | Mestast(glassmate.getGlasstype()+"i", glass.getId(),2002, 0); |
| | | Mestast(glassmate.getGlasstype()+"i", glass.getId(),2002, 0,"MESID1"); |
| | | albaniaMapper.AddFinishNumber(flowcard, mateid, tier); |
| | | albaniaMapper.Inserttask(1, 0, glass.getId(), 2002, glassmate.getGlassid()+i, glasstype,glass.getFlowcard(),mateid,tier); |
| | | if(tier==sumid){ |
| | |
| | | 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) { |
| | | //outmesid(glassid, "MESID1");//下发玻璃id |
| | | S7control.getinstance().writeString(plcmes.getPlcParameter(address).getAddress(),glassid); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStart1").getAddress(), (short) MESToPLCStart1);//起始位置 |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCTarget1").getAddress(), (short) MESToPLCTarget1);//目标位置 |
| | | if(MESToPLC!=0){ |
| | |
| | | import com.example.springboot.entity.StorageTask; |
| | | import com.example.springboot.entity.device.PlcParameterObject; |
| | | import com.example.springboot.mapper.HomeMapper; |
| | | import com.example.springboot.mapper.QueueMapper; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | |
| | | @Service |
| | |
| | | |
| | | @Autowired |
| | | private OutSliceServive outSliceServive; |
| | | |
| | | @Autowired |
| | | private QueueMapper QueueMapper; |
| | | |
| | | @Autowired |
| | | private SpianService spianService; |
| | |
| | | // 查询订单任务 |
| | | public List<FlowCard> SelectOrderTask() { |
| | | List<FlowCard> OrderTask = homeMapper.SelectOrderTask(); |
| | | for (FlowCard flowcard : OrderTask) { |
| | | flowcard.setglassinfo(homeMapper.SelectOrderView(flowcard.getFlowcard())); |
| | | } |
| | | // for (FlowCard flowcard : OrderTask) { |
| | | // flowcard.setglassinfo(homeMapper.SelectOrderView(flowcard.getFlowcard())); |
| | | // } |
| | | return OrderTask; |
| | | } |
| | | |
| | |
| | | // 读取DB105区文件 |
| | | PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; |
| | | // 移除 |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), |
| | | // (short) 3); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 3); |
| | | //删除数据 |
| | | QueueMapper.DeleteErrorQueue(); |
| | | |
| | | // plcmes.getPlcParameter("GaToMES").setValue("3"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("message", "200"); |
| | |
| | | // 读取DB105区文件 |
| | | PlcParameterObject plcmes = PLCAutoMes.PlcMesObject; |
| | | // 重新测量 |
| | | // S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), |
| | | // (short) 2); |
| | | S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(),(short) 2); |
| | | //删除数据 |
| | | QueueMapper.DeleteErrorQueue(); |
| | | // plcmes.getPlcParameter("GaToMES").setValue("2"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("message", "200"); |
| | |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | },{ |
| | | "codeId": "MainControl", |
| | | "addressIndex":"208", |
| | | "addressLenght":"2", |
| | | "ratio":"1", |
| | | "unit":"mm/S" |
| | | } |
| | | } |
| | | ] |
| | | } |
| | |
| | | #\u6570\u636E\u5E93\u9A71\u52A8 |
| | | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
| | | #\u6570\u636E\u5E93\u8FDE\u63A5\u5730\u5740 |
| | | spring.datasource.url=jdbc:mysql://10.153.19.150:3306/albania?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai |
| | | spring.datasource.url=jdbc:mysql://192.168.10.99:3306/albania?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai |
| | | #\u6570\u636E\u5E93\u7528\u6237\u540D |
| | | spring.datasource.username=root |
| | | #\u6570\u636E\u5E93\u7528\u6237\u5BC6\u7801 |