14个文件已修改
2 文件已重命名
13个文件已添加
2个文件已删除
| | |
| | | public class S7Config { |
| | | @Bean(name = "s7SerializerWLOne") |
| | | public S7Serializer s7SerializerWLOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.15"); |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.100"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerWLTwo") |
| | | public S7Serializer s7SerializerWLTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.21"); |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.130"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerMBTwo") |
| | | public S7Serializer s7SerializerMBTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.18"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerMBExtra") |
| | | public S7Serializer s7SerializerMBExtra() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.20.100"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | } |
| | |
| | | import com.mes.opctask.entity.EdgStorageDeviceTaskHistory; |
| | | import com.mes.opctask.service.EdgStorageDeviceTaskHistoryService; |
| | | import com.mes.opctask.service.EdgStorageDeviceTaskService; |
| | | import com.mes.s7.entity.S7DataMBOne; |
| | | import com.mes.s7.entity.S7DataWLOne; |
| | | import com.mes.s7.entity.S7DataWLTwo; |
| | | import com.mes.s7.entity.S7DataMB; |
| | | import com.mes.s7.entity.S7DataWL; |
| | | import com.mes.s7.entity.S7DataWLExtra; |
| | | import com.mes.sysconfig.service.SysConfigService; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @Qualifier("s7SerializerMBOne") |
| | | private S7Serializer s7SerializerMBOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerMBTwo") |
| | | private S7Serializer s7SerializerMBTwo; |
| | | |
| | | // @Value("${mes.threshold}") |
| | | private int threshold; |
| | | // @Value("${mes.cellLength}") |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void startOneOpcTask() throws Exception { |
| | | S7DataWLTwo s7DataWLTwo = s7SerializerWLTwo.read(S7DataWLTwo.class); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | log.info("二线卧理: {}", s7DataWLTwo); |
| | | //获取第二条线路的卧式理片笼状态 |
| | | // ReadWriteEntity twoInkageEntity = miloService.readFromOpcUa("WL2.WL2.deviceState"); |
| | | Boolean twoInkageEntity = s7DataWLTwo.getDeviceState(); |
| | |
| | | if (twoInkageEntity != null && !twoInkageEntity) { |
| | | cellFlag = 2; |
| | | } |
| | | startOneOpcTaskChild(EDG_STORAGE_DEVICE_ONE_TASK, 1, cellFlag); |
| | | startOneOpcTaskChild(s7DataWLOne, 1, cellFlag); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void startTwoOpcTask() throws Exception { |
| | | S7DataWLOne s7DataWLOne = s7SerializerWLOne.read(S7DataWLOne.class); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | log.info("一线卧理: {}", s7DataWLOne); |
| | | // ReadWriteEntity oneInkageEntity = miloService.readFromOpcUa("WL1.WL1.deviceState"); |
| | | Boolean oneInkageEntity = s7DataWLOne.getDeviceState(); |
| | | int cellFlag = 1; |
| | |
| | | if (oneInkageEntity != null && !oneInkageEntity) { |
| | | cellFlag = 2; |
| | | } |
| | | startOneOpcTaskChild(EDG_STORAGE_DEVICE_TWO_TASK, 2, cellFlag); |
| | | startOneOpcTaskChild(s7DataWLTwo, 2, cellFlag); |
| | | } |
| | | |
| | | private void startOneOpcTaskChild(String tableName, int device, int cellFlag) throws Exception { |
| | | // private void startOneOpcTaskChild(String tableName, int device, int cellFlag) throws Exception { |
| | | private void startOneOpcTaskChild(S7DataWL task, int device, int cellFlag) throws Exception { |
| | | threshold = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_THRESHOLD); |
| | | cellLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_CELL_LENGTH); |
| | | ratio = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_RATIO); |
| | |
| | | maxTwoSecondLength = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MAX_SECOND_LENGTH); |
| | | maxThickness = sysConfigService.queryConfigValue(ConstSysConfig.CACHE_MAX_THICKNESS); |
| | | |
| | | EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(tableName); |
| | | // EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(tableName); |
| | | |
| | | if (task == null) { |
| | | log.info("任务表基础数据录入失败,请检查数据是否录入成功"); |
| | | return; |
| | |
| | | //进片任务 |
| | | log.info("设备:{}状态:{}", device, request); |
| | | log.info("进片任务:进片玻璃id为:{}", task.getGlassIdIn()); |
| | | intoTask(task, tableName, device); |
| | | intoTask(task, "", device); |
| | | } else if (request == 2 && taskRunning == 0) { |
| | | //出片任务 |
| | | outTask(task, tableName, device, cellFlag); |
| | | outTask(task, "", device, cellFlag); |
| | | } else if (request == 3 && taskRunning == 0) { |
| | | //直通任务 |
| | | log.info("设备:{}状态:{}", device, request); |
| | | if (!outTask(task, tableName, device, cellFlag)) { |
| | | intoTask(task, tableName, device); |
| | | if (!outTask(task, "", device, cellFlag)) { |
| | | intoTask(task, "", device); |
| | | } |
| | | } else if (request == 4) { |
| | | log.info("设备:{}状态:{}", device, request); |
| | | log.info("将启动子改为4"); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_RUNNING); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_RUNNING); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (device == 2) { |
| | | s7SerializerWLTwo.write(S7DataWL.builder().taskRunning(Const.GLASS_CACHE_TYPE_RUNNING.shortValue()).build()); |
| | | } else { |
| | | s7SerializerWLOne.write(S7DataWL.builder().taskRunning(Const.GLASS_CACHE_TYPE_RUNNING.shortValue()).build()); |
| | | } |
| | | |
| | | } else if (request == 5) { |
| | | log.info("设备:{}状态:{}", device, request); |
| | | finishTask(task, tableName, device); |
| | | finishTask(task, "", device); |
| | | } else { |
| | | log.info("玻璃异常处理"); |
| | | damageTask(task, tableName, device); |
| | | damageTask(task, "", device); |
| | | } |
| | | // } catch(Exception e) |
| | | // |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void edgOneOpcTask() throws Exception { |
| | | EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(EDG_STORAGE_DEVICE_ONE_TASK); |
| | | String glassId = task.getGlassId(); |
| | | // EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(EDG_STORAGE_DEVICE_ONE_TASK); |
| | | // String glassId = task.getGlassId(); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | String glassId = s7DataWLOne.getGlassId(); |
| | | if (StringUtils.isBlank(glassId) || glassId.equals(glassIdOne)) { |
| | | log.info("{}号线磨边前玻璃未就位,结束本次任务", 1); |
| | | return; |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void edgTwoOpcTask() throws Exception { |
| | | EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(EDG_STORAGE_DEVICE_TWO_TASK); |
| | | String glassId = task.getGlassId(); |
| | | // EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(EDG_STORAGE_DEVICE_TWO_TASK); |
| | | // String glassId = task.getGlassId(); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | String glassId = s7DataWLTwo.getGlassId(); |
| | | if (StringUtils.isBlank(glassId) || glassId.equals(glassIdTwo)) { |
| | | log.info("{}号线磨边前玻璃未就位,结束本次任务", 2); |
| | | return; |
| | |
| | | // |
| | | // miloService.writeToOpcUa(list); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".thickness", (int) glassInfo.getThickness() * ratio)); |
| | | S7DataMBOne s7DataMBOne =new S7DataMBOne(); |
| | | s7DataMBOne.setToEdingId(Integer.parseInt(toEndingId)); |
| | | s7DataMBOne.setGlassId(Integer.parseInt(toEndingId)); |
| | | s7DataMBOne.setWidth((int) Math.max(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)); |
| | | s7DataMBOne.setHeight((int) Math.min(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)); |
| | | s7SerializerMBOne.write(s7DataMBOne); |
| | | S7DataMB s7DataMB = new S7DataMB(); |
| | | s7DataMB.setToEdingId(Integer.parseInt(toEndingId)); |
| | | s7DataMB.setGlassId(Integer.parseInt(toEndingId)); |
| | | s7DataMB.setWidth((int) Math.max(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)); |
| | | s7DataMB.setHeight((int) Math.min(glassInfo.getWidth() * ratio, glassInfo.getHeight() * ratio)); |
| | | s7SerializerMBOne.write(s7DataMB); |
| | | |
| | | s7DataMBOne =new S7DataMBOne(); |
| | | s7DataMBOne.setThickness((short) (glassInfo.getThickness() * ratio)); |
| | | s7SerializerMBOne.write(s7DataMBOne); |
| | | s7DataMB = new S7DataMB(); |
| | | s7DataMB.setThickness((short) (glassInfo.getThickness() * ratio)); |
| | | if (cell == 1) { |
| | | s7SerializerMBOne.write(s7DataMB); |
| | | } else { |
| | | s7SerializerMBTwo.write(s7DataMB); |
| | | } |
| | | //修改磨边对列中的磨边线路及状态 |
| | | edgGlassTaskInfoService.update(new LambdaUpdateWrapper<EdgGlassTaskInfo>() |
| | | .set(EdgGlassTaskInfo::getLine, cell) |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean intoTask(EdgStorageDeviceTask task, String tableName, int deviceId) { |
| | | private boolean intoTask(S7DataWL task, String tableName, int deviceId) { |
| | | Date startDate = new Date(); |
| | | log.info("开始执行进片任务,任务信息为:{},表名为:{},设备id:{},开始时间:{}", task, tableName, deviceId, startDate); |
| | | //获取玻璃的基本信息 |
| | |
| | | } |
| | | int firstLength = minTwoFirstLength; |
| | | int secondLength = minTwoSecondLength; |
| | | int fecondMaxLength = 2300; |
| | | if (deviceId == 1) { |
| | | firstLength = minOneFirstLength; |
| | | secondLength = minOneSecondLength; |
| | | fecondMaxLength = 2500; |
| | | } |
| | | if (Math.max(glassInfo.getWidth(), glassInfo.getHeight()) < firstLength || Math.min(glassInfo.getWidth(), glassInfo.getHeight()) < secondLength) { |
| | | if (Math.max(glassInfo.getWidth(), glassInfo.getHeight()) < firstLength || Math.min(glassInfo.getWidth(), glassInfo.getHeight()) < secondLength |
| | | || Math.max(glassInfo.getWidth(), glassInfo.getHeight()) > fecondMaxLength) { |
| | | log.info("进片玻璃尺寸小于{}*{},禁止进笼玻璃id:{},尺寸为{}、{}", firstLength, secondLength, task.getGlassIdIn(), glassInfo.getWidth(), glassInfo.getHeight()); |
| | | Date endDate = new Date(); |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.FALSE; |
| | | } |
| | | EdgStorageCage edgStorageCage = edgStorageCageService.selectNearestEmpty(task.getCurrentCell(), deviceId, Boolean.FALSE); |
| | | // EdgStorageCage edgStorageCage = edgStorageCageService.selectNearestEmpty(task.getCurrentCell(), deviceId, Boolean.FALSE); |
| | | EdgStorageCage edgStorageCage = edgStorageCageService.selectNearestEmpty(Integer.parseInt(task.getCurrentCell().toString()), deviceId, Boolean.FALSE); |
| | | Assert.isTrue(null != edgStorageCage, "格子已满"); |
| | | log.info("4、将玻璃信息插入卧式理片笼,当前玻璃信息:{}", glassInfo); |
| | | EdgStorageCageDetails details = new EdgStorageCageDetails(); |
| | |
| | | edgStorageCageDetailsService.save(details); |
| | | |
| | | //更新任务信息 |
| | | task.setStartCell(edgStorageCage.getSlot()); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_IN); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // task.setStartCell(edgStorageCage.getSlot()); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_IN); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | task.setStartCell(edgStorageCage.getSlot().shortValue()); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_IN.shortValue()); |
| | | if (deviceId == 1) { |
| | | s7SerializerWLOne.write( |
| | | S7DataWL.builder().startCell(edgStorageCage.getSlot().shortValue()) |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_IN.shortValue()).build() |
| | | ); |
| | | } else { |
| | | s7SerializerWLTwo.write( |
| | | S7DataWL.builder().startCell(edgStorageCage.getSlot().shortValue()) |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_IN.shortValue()).build() |
| | | ); |
| | | } |
| | | saveHistoryTask(task, deviceId); |
| | | //记录进片任务的玻璃id用于下次任务的比较,防止同一块玻璃重复执行 |
| | | if (deviceId == 1) { |
| | |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean outTask(EdgStorageDeviceTask task, String tableName, int deviceId, int cellFlag) throws Exception { |
| | | private boolean outTask(S7DataWL task, String tableName, int deviceId, int cellFlag) throws Exception { |
| | | Date startDate = new Date(); |
| | | //获取对应的设备状态信息 |
| | | // ReadWriteEntity oneOutStateEntity = miloService.readFromOpcUa("WL1.WL1.slotState"); |
| | | // ReadWriteEntity twoOutStateEntity = miloService.readFromOpcUa("WL2.WL2.slotState"); |
| | | // ReadWriteEntity d06OutStateEntity = miloService.readFromOpcUa("WL2.WL2.d06SlotState"); |
| | | S7DataWLOne s7DataWLOne = s7SerializerWLOne.read(S7DataWLOne.class); |
| | | S7DataWLTwo s7DataWLTwo = s7SerializerWLTwo.read(S7DataWLTwo.class); |
| | | S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class); |
| | | S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class); |
| | | S7DataWLExtra s7DataWLExtraTwo = s7SerializerWLTwo.read(S7DataWLExtra.class); |
| | | Short oneOutStateEntity = s7DataWLOne.getSlotState(); |
| | | Short twoOutStateEntity = s7DataWLTwo.getSlotState(); |
| | | Short d06OutStateEntity = s7DataWLTwo.getD06SlotState(); |
| | | Short d06OutStateEntity = s7DataWLExtraTwo.getD06SlotState(); |
| | | //状态有3中情况:0空闲 1忙碌 2禁用 |
| | | String oneOutState = Const.OUT_DISABLE; |
| | | String twoOutState = Const.OUT_DISABLE; |
| | |
| | | // if (null != oneOutStateEntity && null != oneOutStateEntity.getValue()) { |
| | | // oneOutState = oneOutStateEntity.getValue().toString(); |
| | | // } |
| | | if (null != oneOutStateEntity ) { |
| | | if (null != oneOutStateEntity) { |
| | | oneOutState = oneOutStateEntity.toString(); |
| | | } |
| | | // if (null != twoOutStateEntity && null != twoOutStateEntity.getValue()) { |
| | | // twoOutState = twoOutStateEntity.getValue().toString(); |
| | | // } |
| | | if (null != twoOutStateEntity ) { |
| | | if (null != twoOutStateEntity) { |
| | | twoOutState = twoOutStateEntity.toString(); |
| | | } |
| | | //两条线都为禁用则不出玻璃 |
| | |
| | | // if (null != d06OutStateEntity && null != d06OutStateEntity.getValue()) { |
| | | // d06OutState = d06OutStateEntity.getValue().toString(); |
| | | // } |
| | | if (null != d06OutStateEntity ) { |
| | | if (null != d06OutStateEntity) { |
| | | d06OutState = d06OutStateEntity.toString(); |
| | | } |
| | | //获取d06片台状态 |
| | |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean outChildTask(EdgStorageDeviceTask task, String tableName, int deviceId, int cell, Date startDate) { |
| | | private boolean outChildTask(S7DataWL task, String tableName, int deviceId, int cell, Date startDate) { |
| | | EdgStorageCageDetails edgStorageCageDetails = null; |
| | | |
| | | //笼内是版图相差是否超过阈值 |
| | |
| | | } |
| | | //前面已经尺寸问题处理完毕,开始计算无相同尺寸的新玻璃小片 |
| | | if (null == edgStorageCageDetails) { |
| | | edgStorageCageDetails = edgStorageCageDetailsService.queryEdgStorageDetailsByLimitSize(deviceId, task.getCurrentCell(), 0, 0, |
| | | edgStorageCageDetails = edgStorageCageDetailsService.queryEdgStorageDetailsByLimitSize(deviceId, Integer.parseInt(task.getCurrentCell().toString()), 0, 0, |
| | | cell, minOneFirstLength, minOneSecondLength, maxTwoFirstLength, maxTwoSecondLength, maxThickness); |
| | | } |
| | | if (edgStorageCageDetails == null && StringUtils.isNotBlank(task.getGlassIdIn())) { |
| | |
| | | log.info("5、更新出片玻璃的状态为{}", Const.GLASS_STATE_OUT); |
| | | } |
| | | //生成出片任务 |
| | | task.setGlassIdOut(edgStorageCageDetails.getGlassId()); |
| | | task.setStartCell(edgStorageCageDetails.getSlot()); |
| | | task.setTaskRunning(taskType); |
| | | task.setEndCell(cell); |
| | | |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // task.setGlassIdOut(edgStorageCageDetails.getGlassId()); |
| | | // task.setStartCell(edgStorageCageDetails.getSlot()); |
| | | // task.setTaskRunning(taskType); |
| | | // task.setEndCell(cell); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (deviceId == 1) { |
| | | s7SerializerWLOne.write( |
| | | S7DataWL.builder() |
| | | .glassIdOut(edgStorageCageDetails.getGlassId()) |
| | | .startCell(edgStorageCageDetails.getSlot().shortValue()) |
| | | .taskRunning((short) taskType) |
| | | .endCell((short) cell) |
| | | .build() |
| | | ); |
| | | } else { |
| | | s7SerializerWLTwo.write( |
| | | S7DataWL.builder() |
| | | .glassIdOut(edgStorageCageDetails.getGlassId()) |
| | | .startCell(edgStorageCageDetails.getSlot().shortValue()) |
| | | .taskRunning((short) taskType) |
| | | .endCell((short) cell) |
| | | .build() |
| | | ); |
| | | } |
| | | saveHistoryTask(task, deviceId); |
| | | //记录直通任务的玻璃id用于下次任务的比较,防止同一块玻璃重复执行 |
| | | if (3 == task.getTaskState()) { |
| | |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean finishTask(EdgStorageDeviceTask task, String tableName, int device) { |
| | | private boolean finishTask(S7DataWL task, String tableName, int device) { |
| | | if (task.getTaskState() <= 4) { |
| | | log.info("有正在执行的任务或这任务已执行任务状态{},任务启动情况{},结束", task.getTaskState(), task.getTaskRunning()); |
| | | return Boolean.FALSE; |
| | | } |
| | | Date startDate = new Date(); |
| | | log.info("开始执行完成任务后清除动作,任务信息为:{},表名为:{},开始时间:{}", task, tableName, startDate); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | task.setGlassIdOut(""); |
| | | task.setStartCell(0); |
| | | task.setEndCell(0); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | // task.setGlassIdOut(""); |
| | | // task.setStartCell(0); |
| | | // task.setEndCell(0); |
| | | EdgStorageDeviceTaskHistory taskHistory = edgStorageDeviceTaskHistoryService.getOne(new LambdaQueryWrapper<EdgStorageDeviceTaskHistory>() |
| | | .eq(EdgStorageDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_NEW) |
| | | .eq(EdgStorageDeviceTaskHistory::getDeviceId, device) |
| | |
| | | ); |
| | | } |
| | | //最后更新任务,保证任务前的动作都做完 |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | // task.setGlassIdOut(""); |
| | | // task.setStartCell(0); |
| | | // task.setEndCell(0); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (device == 1) { |
| | | s7SerializerWLOne.write( |
| | | S7DataWL.builder() |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_EMPTY.shortValue()) |
| | | .glassIdOut("") |
| | | .startCell((short) 0) |
| | | .endCell((short) 0) |
| | | .build() |
| | | ); |
| | | } else { |
| | | s7SerializerWLTwo.write( |
| | | S7DataWL.builder() |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_EMPTY.shortValue()) |
| | | .glassIdOut("") |
| | | .startCell((short) 0) |
| | | .endCell((short) 0) |
| | | .build() |
| | | ); |
| | | } |
| | | Date endDate = new Date(); |
| | | log.info("结束完成任务后清除动作,表名为:{},结束时间为:{},共耗时:{}ms", tableName, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean damageTask(EdgStorageDeviceTask task, String tableName, int device) { |
| | | private boolean damageTask(S7DataWL task, String tableName, int device) { |
| | | if (task.getTaskState() <= 5) { |
| | | log.info("任务未发生异常清空,任务结束,电气状态{},mes状态{}", task.getTaskState(), task.getTaskRunning()); |
| | | return Boolean.FALSE; |
| | |
| | | ); |
| | | } |
| | | //最后更新任务,保证任务前的动作都做完 |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | task.setGlassIdOut(""); |
| | | task.setStartCell(0); |
| | | task.setEndCell(0); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | // task.setGlassIdOut(""); |
| | | // task.setStartCell(0); |
| | | // task.setEndCell(0); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | if (device == 1) { |
| | | s7SerializerWLOne.write( |
| | | S7DataWL.builder() |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_EMPTY.shortValue()) |
| | | .glassIdOut("") |
| | | .startCell((short) 0) |
| | | .endCell((short) 0) |
| | | .build() |
| | | ); |
| | | } else { |
| | | s7SerializerWLTwo.write( |
| | | S7DataWL.builder() |
| | | .taskRunning(Const.GLASS_CACHE_TYPE_EMPTY.shortValue()) |
| | | .glassIdOut("") |
| | | .startCell((short) 0) |
| | | .endCell((short) 0) |
| | | .build() |
| | | ); |
| | | } |
| | | Date endDate = new Date(); |
| | | log.info("完成执行异常处理任务后清除动作,表名为:{},结束时间为:{},共耗时:{}ms", tableName, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.TRUE; |
| | |
| | | } |
| | | } |
| | | |
| | | public boolean saveHistoryTask(EdgStorageDeviceTask task, int deviceId) { |
| | | // public boolean saveHistoryTask(EdgStorageDeviceTask task, int deviceId) { |
| | | public boolean saveHistoryTask(S7DataWL task, int deviceId) { |
| | | EdgStorageDeviceTaskHistory taskHistory = new EdgStorageDeviceTaskHistory(); |
| | | BeanUtils.copyProperties(task, taskHistory); |
| | | taskHistory.setTaskType(task.getTaskRunning()); |
| | | // taskHistory.setTaskType(task.getTaskRunning()); |
| | | taskHistory.setTaskType(Integer.parseInt(task.getTaskRunning().toString())); |
| | | taskHistory.setCreateTime(new Date()); |
| | | taskHistory.setTaskState(Const.RAW_GLASS_TASK_NEW); |
| | | taskHistory.setDeviceId(deviceId); |
| | |
| | | package com.mes.job; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.s7.entity.S7DataMBExtra; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerMBExtra") |
| | | private S7Serializer s7SerializerMBExtra; |
| | | |
| | | @Resource |
| | | GlassInfoService glassInfoService; |
| | | |
| | |
| | | } |
| | | |
| | | private void startEdgTaskChild(String cell) throws Exception { |
| | | ReadWriteEntity request = miloService.readFromOpcUa("MB04.MB04.request" + cell); |
| | | if (null == request || "0".equals(request.getValue() + "")) { |
| | | S7DataMBExtra s7DataMBExtra = s7SerializerMBExtra.read(S7DataMBExtra.class); |
| | | |
| | | // ReadWriteEntity request = miloService.readFromOpcUa("MB04.MB04.request" + cell); |
| | | // if (null == request || "0".equals(request.getValue() + "")) { |
| | | String request = ""; |
| | | String glassIdEntity = ""; |
| | | if ("01".equals(cell)) { |
| | | request = s7DataMBExtra.getRequestOne().toString(); |
| | | glassIdEntity = s7DataMBExtra.getPlcGlassIdOne(); |
| | | } else { |
| | | request = s7DataMBExtra.getRequestTwo().toString(); |
| | | glassIdEntity = s7DataMBExtra.getPlcGlassIdTwo(); |
| | | } |
| | | if (null == request || "0".equals(request)) { |
| | | log.info("未收到玻璃请求,结束本次任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity glassIdEntity = miloService.readFromOpcUa("MB04.MB04.plc_glass_id_" + cell); |
| | | |
| | | if (null == glassIdEntity || StringUtils.isEmpty(glassIdEntity.getValue() + "")) { |
| | | // ReadWriteEntity glassIdEntity = miloService.readFromOpcUa("MB04.MB04.plc_glass_id_" + cell); |
| | | // if (null == glassIdEntity || StringUtils.isEmpty(glassIdEntity.getValue() + "")) { |
| | | if (null == glassIdEntity || StringUtils.isEmpty(glassIdEntity)) { |
| | | log.info("有请求但玻璃id为空,结束本次任务"); |
| | | return; |
| | | } |
| | | String glassId = glassIdEntity.getValue() + ""; |
| | | // String glassId = glassIdEntity.getValue() + ""; |
| | | String glassId = glassIdEntity; |
| | | log.info("获取到{}线的玻璃id:{}", cell, glassId); |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId).last("limit 1")); |
| | | |
| | | List<ReadWriteEntity> ualist = new ArrayList<>(); |
| | | ualist.add(generateReadWriteEntity("MB04.MB04.width" + cell, (int) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10))); |
| | | ualist.add(generateReadWriteEntity("MB04.MB04.height" + cell, (int) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10))); |
| | | ualist.add(generateReadWriteEntity("MB04.MB04.thickness" + cell, (int) glassInfo.getThickness() * 10)); |
| | | miloService.writeToOpcWord(ualist); |
| | | miloService.writeToOpcUa(generateReadWriteEntity("MB04.MB04.mes_glass_Id_" + cell, glassId)); |
| | | // List<ReadWriteEntity> ualist = new ArrayList<>(); |
| | | // ualist.add(generateReadWriteEntity("MB04.MB04.width" + cell, (int) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10))); |
| | | // ualist.add(generateReadWriteEntity("MB04.MB04.height" + cell, (int) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10))); |
| | | // ualist.add(generateReadWriteEntity("MB04.MB04.thickness" + cell, (int) glassInfo.getThickness() * 10)); |
| | | // miloService.writeToOpcWord(ualist); |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("MB04.MB04.mes_glass_Id_" + cell, glassId)); |
| | | |
| | | if ("01".equals(cell)) { |
| | | s7SerializerMBExtra.write( |
| | | S7DataMBExtra.builder() |
| | | .widthOne((short) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)) |
| | | .heightOne((short) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)) |
| | | .thicknessOne((short) (glassInfo.getThickness() * 10)) |
| | | .build() |
| | | ); |
| | | s7SerializerMBExtra.write( |
| | | S7DataMBExtra.builder().mesGlassIdOne(glassId).build() |
| | | ); |
| | | } else { |
| | | s7SerializerMBExtra.write( |
| | | S7DataMBExtra.builder() |
| | | .widthTwo((short) Math.max(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)) |
| | | .heightTwo((short) Math.min(glassInfo.getWidth() * 10, glassInfo.getHeight() * 10)) |
| | | .thicknessTwo((short) (glassInfo.getThickness() * 10)) |
| | | .build() |
| | | ); |
| | | s7SerializerMBExtra.write( |
| | | S7DataMBExtra.builder().mesglassIdTwo(glassId).build() |
| | | ); |
| | | } |
| | | } |
| | | |
| | | private ReadWriteEntity generateReadWriteEntity(String identifier, Object value) { |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataMB { |
| | | |
| | | |
| | | @S7Variable(address = "DB19.6", type = EDataType.FLOAT32) |
| | | private Float speed; |
| | | |
| | | @S7Variable(address = "DB49.10", type = EDataType.INT32) |
| | | private Integer width; |
| | | |
| | | @S7Variable(address = "DB49.2", type = EDataType.INT32) |
| | | private Integer toEdingId; |
| | | |
| | | @S7Variable(address = "DB49.6", type = EDataType.INT32) |
| | | private Integer glassId; |
| | | |
| | | @S7Variable(address = "DB49.14", type = EDataType.INT32) |
| | | private Integer height; |
| | | |
| | | @S7Variable(address = "DB49.18", type = EDataType.INT16) |
| | | private Short thickness; |
| | | |
| | | @S7Variable(address = "DB49.0.3", type = EDataType.BOOL) |
| | | private Boolean mesControl; |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | @Builder |
| | | public class S7DataMBExtra { |
| | | |
| | | |
| | | @S7Variable(address = "DB49.0", type = EDataType.INT16) |
| | | private Short requestOne; |
| | | |
| | | @S7Variable(address = "DB49.46", type = EDataType.INT16) |
| | | private Short widthOne; |
| | | |
| | | @S7Variable(address = "DB49.48", type = EDataType.INT16) |
| | | private Short heightOne; |
| | | |
| | | @S7Variable(address = "DB49.50", type = EDataType.INT16) |
| | | private Short thicknessOne; |
| | | |
| | | @S7Variable(address = "DB49.52", type = EDataType.INT16) |
| | | private Short requestTwo; |
| | | |
| | | @S7Variable(address = "DB49.98", type = EDataType.INT16) |
| | | private Short widthTwo; |
| | | |
| | | @S7Variable(address = "DB49.100", type = EDataType.INT16) |
| | | private Short heightTwo; |
| | | |
| | | @S7Variable(address = "DB49.102", type = EDataType.INT16) |
| | | private Short thicknessTwo; |
| | | |
| | | @S7Variable(address = "DB49.2", type = EDataType.STRING, count = 22) |
| | | private String plcGlassIdOne; |
| | | |
| | | @S7Variable(address = "DB49.24", type = EDataType.STRING, count = 22) |
| | | private String mesGlassIdOne; |
| | | |
| | | @S7Variable(address = "DB49.54", type = EDataType.STRING, count = 22) |
| | | private String plcGlassIdTwo; |
| | | |
| | | @S7Variable(address = "DB49.76", type = EDataType.STRING, count = 22) |
| | | private String mesglassIdTwo; |
| | | |
| | | } |
File was renamed from hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/s7/entity/S7DataWLOne.java |
| | |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataWLOne { |
| | | @Builder |
| | | public class S7DataWL { |
| | | |
| | | |
| | | @S7Variable(address = "DB19.0", type = EDataType.INT16) |
| | | @S7Variable(address = "DB49.0", type = EDataType.INT16) |
| | | private Short taskRunning; |
| | | |
| | | @S7Variable(address = "DB49.46", type = EDataType.INT16) |
| | | private Short slot; |
| | | private Short currentCell; |
| | | |
| | | @S7Variable(address = "DB49.48", type = EDataType.INT16) |
| | | private Short startCell; |
| | |
| | | private Short endCell; |
| | | |
| | | @S7Variable(address = "DB49.52", type = EDataType.INT16) |
| | | private Short plcTaskState; |
| | | private Short TaskState; |
| | | |
| | | @S7Variable(address = "DB49.116", type = EDataType.INT16) |
| | | private Short inPlace; |
| | |
| | | private Short slotState; |
| | | |
| | | @S7Variable(address = "DB49.118", type = EDataType.FLOAT32) |
| | | private Short speed; |
| | | private Float speed; |
| | | |
| | | @S7Variable(address = "DB49.2", type = EDataType.STRING) |
| | | @S7Variable(address = "DB49.2", type = EDataType.STRING, count = 22) |
| | | private String glassIdIn; |
| | | |
| | | @S7Variable(address = "DB49.24", type = EDataType.STRING) |
| | | @S7Variable(address = "DB49.24", type = EDataType.STRING, count = 22) |
| | | private String glassIdOut; |
| | | |
| | | @S7Variable(address = "DB49.94", type = EDataType.STRING) |
| | | @S7Variable(address = "DB49.94", type = EDataType.STRING, count = 22) |
| | | private String glassId; |
| | | |
| | | @S7Variable(address = "DB49.112", type = EDataType.BOOL) |
| | | @S7Variable(address = "DB49.112.0", type = EDataType.BOOL) |
| | | private Boolean deviceState; |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataWLExtra { |
| | | |
| | | @S7Variable(address = "DB49.126", type = EDataType.INT16) |
| | | private Short d06SlotState; |
| | | |
| | | } |
| | |
| | | |
| | | spring: |
| | | profiles: |
| | | active: dev |
| | | active: yw |
| | | application: |
| | | name: cacheGlass |
| | | liquibase: |
| | |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageHistoryTask; |
| | | import com.mes.bigstoragecagetask.entity.request.BigStorageCageHistoryRequest; |
| | | import com.mes.bigstoragecagetask.mapper.BigStorageCageHistoryTaskMapper; |
| | | import com.mes.bigstoragecagetask.service.BigStorageCageHistoryTaskService; |
| | | import com.mes.largenscreen.entity.DailyProductionVO; |
| | | import com.mes.largenscreen.entity.RunTime; |
| | | import com.mes.tools.DateUtil; |
New file |
| | |
| | | package com.mes.config; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 13:50 |
| | | * @Description: |
| | | */ |
| | | @Configuration |
| | | public class S7Config { |
| | | @Bean(name = "s7SerializerDLPOne") |
| | | public S7Serializer s7SerializerDLPOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.20.140"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerDLPTwo") |
| | | public S7Serializer s7SerializerDLPTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.20.140"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.largenscreen.entity.PieChartVO; |
| | | import com.mes.largenscreen.entity.RunTime; |
| | | import com.mes.s7.entity.S7DataDLPOne; |
| | | import com.mes.s7.entity.S7DataDLPTwo; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerDLPOne") |
| | | private S7Serializer s7SerializerDLPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerDLPTwo") |
| | | private S7Serializer s7SerializerDLPTwo; |
| | | |
| | | private JSONObject jsonObject = new JSONObject(); |
| | | |
| | | public void queryDataSource1() throws Exception { |
| | | S7DataDLPOne s7DataDLPOne = s7SerializerDLPOne.read(S7DataDLPOne.class); |
| | | S7DataDLPTwo s7DataWLTwo = s7SerializerDLPTwo.read(S7DataDLPTwo.class); |
| | | List<Double> carPostion = new ArrayList<>(); |
| | | carPostion.add(0.25); |
| | | carPostion.add(0.5); |
| | |
| | | try { |
| | | //进片任务数据 |
| | | List<BigStorageTaskVO> inTaskList = new ArrayList(); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); |
| | | String fromOpcUa = s7DataDLPOne.getFrom1().toString(); |
| | | List<Short> states = s7DataDLPOne.getStates(); |
| | | List<Short> tos = s7DataDLPOne.getTos(); |
| | | List<String> ids = s7DataDLPOne.getIds(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); |
| | | ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); |
| | | if (null != requestWord.getValue()) { |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | // ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); |
| | | // ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); |
| | | String requestWord = ids.get(i - 1); |
| | | String targetSlotWord = tos.get(i - 1).toString(); |
| | | String stateWord = states.get(i - 1).toString(); |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord) { |
| | | BigStorageTaskVO task = new BigStorageTaskVO(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | task.setGlassId(requestWord); |
| | | int isExistCount = bigStorageCageDetailsService.count(new LambdaQueryWrapper<BigStorageCageDetails>().in(BigStorageCageDetails::getGlassId, task.getGlassId()) |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | if (isExistCount > 0) { |
| | |
| | | } else { |
| | | task.setIsSame(0); |
| | | } |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | // task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord)); |
| | | task.setTaskState(Integer.parseInt(stateWord)); |
| | | inTaskList.add(task); |
| | | continue; |
| | | } |
| | |
| | | } |
| | | try { |
| | | //进片联机 |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | // jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | Boolean inkageEntity = s7DataDLPOne.getMesControl(); |
| | | jsonObject.append("inkageEntity", inkageEntity); |
| | | //进片请求 |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | // jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | String requestEntity = s7DataDLPOne.getRequestMes().toString(); |
| | | jsonObject.append("requestEntity", requestEntity); |
| | | //启动命令 |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | // ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | // jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | String mesReplyEntity = s7DataDLPOne.getMesReply().toString(); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity); |
| | | //出片联机 |
| | | ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | // ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | // jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | Boolean outInkageEntity = s7DataWLTwo.getMesControl(); |
| | | jsonObject.append("outInkageEntity", outInkageEntity); |
| | | //出片请求 |
| | | ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | // ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | // jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | String outRequestEntity = s7DataWLTwo.getRequestMes().toString(); |
| | | jsonObject.append("outRequestEntity", outRequestEntity); |
| | | |
| | | |
| | | //出片任务数据 |
| | |
| | | import cn.hutool.core.lang.Assert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | |
| | | import com.mes.edgglasstask.service.EdgGlassTaskInfoService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.s7.entity.S7DataDLPOne; |
| | | import com.mes.s7.entity.S7DataDLPTwo; |
| | | import com.mes.sysconfig.service.SysConfigService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerDLPOne") |
| | | private S7Serializer s7SerializerDLPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerDLPTwo") |
| | | private S7Serializer s7SerializerDLPTwo; |
| | | |
| | | @Resource |
| | | SysConfigService sysConfigService; |
| | | |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void inBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataDLPOne s7DataDLPOne = s7SerializerDLPOne.read(S7DataDLPOne.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataDLPOne.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | if (!"1".equals(requestEntity.getValue() + "")) { |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | // if (!"1".equals(requestEntity.getValue() + "")) { |
| | | String requestEntity = s7DataDLPOne.getRequestMes().toString(); |
| | | if (!"1".equals(requestEntity)) { |
| | | log.info("当前未收到进片请求,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | if ("1".equals(mesReplyEntity.getValue() + "")) { |
| | | // ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | // if ("1".equals(mesReplyEntity.getValue() + "")) { |
| | | String mesReplyEntity = s7DataDLPOne.getMesReply().toString(); |
| | | if (!"1".equals(mesReplyEntity)) { |
| | | log.info("有正在执行的任务,结束进片任务"); |
| | | return; |
| | | } |
| | | //获取进片任务信息 |
| | | List<BigStorageCageTask> inTaskList = new ArrayList(); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); |
| | | String fromOpcUa = s7DataDLPOne.getFrom1().toString(); |
| | | |
| | | List<Short> states = s7DataDLPOne.getStates(); |
| | | List<String> glassIdList = new ArrayList<>(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | if (null != requestWord.getValue()) { |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | String requestWord = states.get(i).toString(); |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord) { |
| | | BigStorageCageTask task = new BigStorageCageTask(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | task.setGlassId(requestWord); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | inTaskList.add(task); |
| | | glassIdList.add(requestWord.getValue() + ""); |
| | | // glassIdList.add(requestWord.getValue() + ""); |
| | | glassIdList.add(requestWord); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | log.info("获取任务的玻璃id:{}", glassIdList); |
| | | ReadWriteEntity countEntity = miloService.readFromOpcUa("DLP1A.DLP1A.glassCount"); |
| | | if (null == countEntity.getValue() || Integer.parseInt(countEntity.getValue() + "") != glassIdList.size()) { |
| | | log.info("当前大车进片玻璃数量{}与mes读取到的数量{}不匹配,结束进片任务", countEntity.getValue(), glassIdList.size()); |
| | | // ReadWriteEntity countEntity = miloService.readFromOpcUa("DLP1A.DLP1A.glassCount"); |
| | | String countEntity = s7DataDLPOne.getGlassCount().toString(); |
| | | // if (null == countEntity.getValue() || Integer.parseInt(countEntity.getValue() + "") != glassIdList.size()) { |
| | | if (null == countEntity || Integer.parseInt(countEntity) != glassIdList.size()) { |
| | | log.info("当前大车进片玻璃数量{}与mes读取到的数量{}不匹配,结束进片任务", countEntity, glassIdList.size()); |
| | | //向plc发送报警:当前大车进片玻璃数量与mes读取到的数量不匹配 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 1)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 1)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlramSignal((short) 1); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | Map<String, Long> glassCountMap = glassIdList.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting())); |
| | |
| | | if (entry.getValue() > 1) { |
| | | log.info("进片玻璃{}存在相同,结束本次任务", entry.getKey()); |
| | | //向plc发送报警:同一车进片玻璃存在相同 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 2)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 2)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlramSignal((short) 2); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | if (CollectionUtil.isNotEmpty(detailsList)) { |
| | | log.info("理片笼存在相同的进片玻璃{},结束本次任务", detailsList); |
| | | //向plc发送报警:理片笼存在相同的进片玻璃 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 4)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 4)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlramSignal((short) 4); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList)); |
| | |
| | | if (glassInfoList.size() != inTaskList.size()) { |
| | | log.info("进片任务数量{}与玻璃数量{}不匹配,结束本次进片", inTaskList.size(), glassInfoList.size()); |
| | | //向plc发送报警:进片任务数量与系统查询到的玻璃数量不匹配 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 8)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 8)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlramSignal((short) 8); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_GLASS_GAP); |
| | |
| | | if (count < entry.getValue()) { |
| | | log.info("笼内格子剩余数量不足,结束本次进片"); |
| | | //向plc发送报警:笼内格子剩余数量不足 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlramSignal((short) 16); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | if (count > 0) { |
| | | log.info("直通片台存在玻璃,结束本次进片"); |
| | | //向plc发送报警:直通片台存在玻璃,无法继续直通 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 64)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 64)); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | s7DataDLPOne.setAlramSignal((short) 64); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | //历史数据入库 |
| | | bigStorageCageHistoryTaskService.saveBatch(historyTasks); |
| | | //向opc发送启动信号 |
| | | List<ReadWriteEntity> list = new ArrayList<>(); |
| | | for (int i = 1; i <= inTaskList.size(); i++) { |
| | | list.add(generateReadWriteEntity("DLP1A.DLP1A.TO" + i, inTaskList.get(i - 1).getTargetSlot())); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // for (int i = 1; i <= inTaskList.size(); i++) { |
| | | // list.add(generateReadWriteEntity("DLP1A.DLP1A.TO" + i, inTaskList.get(i - 1).getTargetSlot())); |
| | | // } |
| | | // list.add(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 1)); |
| | | // miloService.writeToOpcWord(list); |
| | | s7DataDLPOne = new S7DataDLPOne(); |
| | | for (int i = 0; i < inTaskList.size() && i < 6; i++) { |
| | | short value = (short) Integer.parseInt(inTaskList.get(i).getTargetSlot().toString()); |
| | | switch (i) { |
| | | case 0: |
| | | s7DataDLPOne.setTo1(value); |
| | | break; |
| | | case 1: |
| | | s7DataDLPOne.setTo2(value); |
| | | break; |
| | | case 2: |
| | | s7DataDLPOne.setTo3(value); |
| | | break; |
| | | case 3: |
| | | s7DataDLPOne.setTo4(value); |
| | | break; |
| | | case 4: |
| | | s7DataDLPOne.setTo5(value); |
| | | break; |
| | | case 5: |
| | | s7DataDLPOne.setTo6(value); |
| | | break; |
| | | } |
| | | } |
| | | list.add(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 1)); |
| | | miloService.writeToOpcWord(list); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void outBigStorageTask() throws Exception { |
| | | Date startDate = new Date(); |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataDLPTwo s7DataWLTwo = s7SerializerDLPTwo.read(S7DataDLPTwo.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataWLTwo.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | if (!"1".equals(requestEntity.getValue() + "")) { |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | // if (!"1".equals(requestEntity.getValue() + "")) { |
| | | String requestEntity = s7DataWLTwo.getRequestMes().toString(); |
| | | if (!"1".equals(requestEntity)) { |
| | | log.info("当前未收到出片请求,结束出片任务"); |
| | | return; |
| | | } |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishInBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataDLPOne s7DataDLPOne = s7SerializerDLPOne.read(S7DataDLPOne.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataDLPOne.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束完成进片任务"); |
| | | return; |
| | | } |
| | |
| | | List<BigStorageCageTask> inTaskList = new ArrayList(); |
| | | |
| | | List<String> glassIdList = new ArrayList<>(); |
| | | ReadWriteEntity toWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO1"); |
| | | if ("0".equals(toWord.getValue() + "")) { |
| | | // ReadWriteEntity toWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO1"); |
| | | // if ("0".equals(toWord.getValue() + "")) { |
| | | String toWord = s7DataDLPOne.getTo1().toString(); |
| | | if ("0".equals(toWord)) { |
| | | log.info("完成任务已执行,结束本次完成进片任务"); |
| | | return; |
| | | } |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | ReadWriteEntity statetWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); |
| | | ReadWriteEntity toOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM" + i); |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); |
| | | // ReadWriteEntity statetWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); |
| | | // ReadWriteEntity toOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM" + i); |
| | | String requestWord = ""; |
| | | String statetWord = ""; |
| | | String toOpcUa = ""; |
| | | String fromOpcUa = ""; |
| | | switch (i) { |
| | | case 0: |
| | | requestWord = s7DataDLPOne.getId1().toString(); |
| | | statetWord = s7DataDLPOne.getState1().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo1().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom1().toString(); |
| | | break; |
| | | case 1: |
| | | requestWord = s7DataDLPOne.getId2().toString(); |
| | | statetWord = s7DataDLPOne.getState2().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo2().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom2().toString(); |
| | | break; |
| | | case 2: |
| | | requestWord = s7DataDLPOne.getId3().toString(); |
| | | statetWord = s7DataDLPOne.getState3().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo3().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom3().toString(); |
| | | break; |
| | | case 3: |
| | | requestWord = s7DataDLPOne.getId4().toString(); |
| | | statetWord = s7DataDLPOne.getState4().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo4().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom4().toString(); |
| | | break; |
| | | case 4: |
| | | requestWord = s7DataDLPOne.getId5().toString(); |
| | | statetWord = s7DataDLPOne.getState5().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo5().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom5().toString(); |
| | | break; |
| | | case 5: |
| | | requestWord = s7DataDLPOne.getId6().toString(); |
| | | statetWord = s7DataDLPOne.getState6().toString(); |
| | | toOpcUa = s7DataDLPOne.getTo6().toString(); |
| | | fromOpcUa = s7DataDLPOne.getFrom6().toString(); |
| | | break; |
| | | } |
| | | |
| | | if (null != requestWord.getValue()) { |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord) { |
| | | BigStorageCageTask task = new BigStorageCageTask(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | task.setTargetSlot(Integer.parseInt(toOpcUa.getValue() + "")); |
| | | task.setTaskState(Integer.parseInt(statetWord.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | // task.setTargetSlot(Integer.parseInt(toOpcUa.getValue() + "")); |
| | | // task.setTaskState(Integer.parseInt(statetWord.getValue() + "")); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setGlassId(requestWord); |
| | | task.setTargetSlot(Integer.parseInt(toOpcUa)); |
| | | task.setTaskState(Integer.parseInt(statetWord)); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | inTaskList.add(task); |
| | | glassIdList.add(requestWord.getValue() + ""); |
| | | // glassIdList.add(requestWord.getValue() + ""); |
| | | glassIdList.add(requestWord); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | //向opc发送启动信号 |
| | | List<ReadWriteEntity> list = new ArrayList<>(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | list.add(generateReadWriteEntity("DLP1A.DLP1A.TO" + i, 0)); |
| | | } |
| | | list.add(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 0)); |
| | | miloService.writeToOpcWord(list); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // for (int i = 1; i <= 6; i++) { |
| | | // list.add(generateReadWriteEntity("DLP1A.DLP1A.TO" + i, 0)); |
| | | // } |
| | | // list.add(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 0)); |
| | | // miloService.writeToOpcWord(list); |
| | | s7DataDLPOne =new S7DataDLPOne(); |
| | | s7DataDLPOne.setTo1((short)0); |
| | | s7DataDLPOne.setTo2((short)0); |
| | | s7DataDLPOne.setTo3((short)0); |
| | | s7DataDLPOne.setTo4((short)0); |
| | | s7DataDLPOne.setTo5((short)0); |
| | | s7DataDLPOne.setTo6((short)0); |
| | | s7DataDLPOne.setMesReply((short)0); |
| | | s7SerializerDLPOne.write(s7DataDLPOne); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishOutBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataDLPTwo s7DataWLTwo = s7SerializerDLPTwo.read(S7DataDLPTwo.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataWLTwo.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束完成出片任务"); |
| | | return; |
| | | } |
| | |
| | | bigStorageCageTaskService.updateOutTaskMessage("big_storage_cage_out_one_task"); |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 0)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 0)); |
| | | S7DataDLPTwo s7DataDLPTwo=new S7DataDLPTwo(); |
| | | s7DataDLPTwo.setMesReply((short)0); |
| | | s7SerializerDLPTwo.write(s7DataDLPTwo); |
| | | } |
| | | |
| | | private void dealDamageInTask(List<BigStorageCageTask> damageTaskList) { |
| | |
| | | .ne(BigStorageCageDetails::getState, Const.GLASS_STATE_OUT) |
| | | .in(BigStorageCageDetails::getGlassId, glassIds)); |
| | | try { |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | S7DataDLPTwo s7DataDLPTwo=new S7DataDLPTwo(); |
| | | s7DataDLPTwo.setMesReply((short)1); |
| | | s7SerializerDLPTwo.write(s7DataDLPTwo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | .set(Const.GLASS_STATE_SCHEDULE_ING.equals(state), BigStorageCageBaseInfo::getSlot, targetSlot) |
| | | .in(BigStorageCageDetails::getGlassId, glassIds)); |
| | | try { |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | S7DataDLPTwo s7DataDLPTwo=new S7DataDLPTwo(); |
| | | s7DataDLPTwo.setMesReply((short)1); |
| | | s7SerializerDLPTwo.write(s7DataDLPTwo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataDLPOne { |
| | | |
| | | |
| | | @S7Variable(address = "DB3.3118", type = EDataType.BOOL) |
| | | private Boolean mesControl; |
| | | |
| | | @S7Variable(address = "DB19.0", type = EDataType.INT16) |
| | | private Short requestMes; |
| | | |
| | | @S7Variable(address = "DB19.2", type = EDataType.INT16) |
| | | private Short mesReply; |
| | | |
| | | @S7Variable(address = "DB19.140", type = EDataType.INT16) |
| | | private Short from1; |
| | | |
| | | @S7Variable(address = "DB19.142", type = EDataType.INT16) |
| | | private Short from2; |
| | | |
| | | @S7Variable(address = "DB19.144", type = EDataType.INT16) |
| | | private Short from3; |
| | | |
| | | @S7Variable(address = "DB19.146", type = EDataType.INT16) |
| | | private Short from4; |
| | | |
| | | @S7Variable(address = "DB19.148", type = EDataType.INT16) |
| | | private Short from5; |
| | | |
| | | @S7Variable(address = "DB19.150", type = EDataType.INT16) |
| | | private Short from6; |
| | | |
| | | @S7Variable(address = "DB19.152", type = EDataType.INT16) |
| | | private Short to1; |
| | | |
| | | @S7Variable(address = "DB19.154", type = EDataType.INT16) |
| | | private Short to2; |
| | | |
| | | @S7Variable(address = "DB19.156", type = EDataType.INT16) |
| | | private Short to3; |
| | | |
| | | @S7Variable(address = "DB19.158", type = EDataType.INT16) |
| | | private Short to4; |
| | | |
| | | @S7Variable(address = "DB19.160", type = EDataType.INT16) |
| | | private Short to5; |
| | | |
| | | @S7Variable(address = "DB19.162", type = EDataType.INT16) |
| | | private Short to6; |
| | | |
| | | @S7Variable(address = "DB19.164", type = EDataType.INT16) |
| | | private Short state1; |
| | | |
| | | @S7Variable(address = "DB19.166", type = EDataType.INT16) |
| | | private Short state2; |
| | | |
| | | @S7Variable(address = "DB19.168", type = EDataType.INT16) |
| | | private Short state3; |
| | | |
| | | @S7Variable(address = "DB19.170", type = EDataType.INT16) |
| | | private Short state4; |
| | | |
| | | @S7Variable(address = "DB19.172", type = EDataType.INT16) |
| | | private Short state5; |
| | | |
| | | @S7Variable(address = "DB19.174", type = EDataType.INT16) |
| | | private Short state6; |
| | | |
| | | @S7Variable(address = "DB19.1246", type = EDataType.INT16) |
| | | private Short glassCount; |
| | | |
| | | @S7Variable(address = "DB19.8", type = EDataType.STRING, count = 22) |
| | | private String id1; |
| | | |
| | | @S7Variable(address = "DB19.30", type = EDataType.STRING, count = 22) |
| | | private String id2; |
| | | |
| | | @S7Variable(address = "DB19.52", type = EDataType.STRING, count = 22) |
| | | private String id3; |
| | | |
| | | @S7Variable(address = "DB19.74", type = EDataType.STRING, count = 22) |
| | | private String id4; |
| | | |
| | | @S7Variable(address = "DB19.96", type = EDataType.STRING, count = 22) |
| | | private String id5; |
| | | |
| | | @S7Variable(address = "DB19.118", type = EDataType.STRING, count = 22) |
| | | private String id6; |
| | | |
| | | @S7Variable(address = "MW1002", type = EDataType.INT16) |
| | | private Short alramSignal; |
| | | |
| | | public List<Short> getStates() { |
| | | return Arrays.asList(state1, state2, state3, state4, state5, state6); |
| | | } |
| | | |
| | | public List<String> getIds() { |
| | | return Arrays.asList(id1, id2, id3, id4, id5, id6); |
| | | } |
| | | |
| | | public List<Short> getTos() { |
| | | return Arrays.asList(to1, to2, to3, to4, to5, to6); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataDLPTwo { |
| | | |
| | | |
| | | @S7Variable(address = "DB3.3118", type = EDataType.BOOL) |
| | | private Boolean mesControl; |
| | | |
| | | @S7Variable(address = "DB19.4", type = EDataType.INT16) |
| | | private Short requestMes; |
| | | |
| | | @S7Variable(address = "DB19.6", type = EDataType.INT16) |
| | | private Short mesReply; |
| | | |
| | | @S7Variable(address = "DB19.308", type = EDataType.INT16) |
| | | private Short from1; |
| | | |
| | | @S7Variable(address = "DB19.310", type = EDataType.INT16) |
| | | private Short from2; |
| | | |
| | | @S7Variable(address = "DB19.312", type = EDataType.INT16) |
| | | private Short from3; |
| | | |
| | | @S7Variable(address = "DB19.314", type = EDataType.INT16) |
| | | private Short from4; |
| | | |
| | | @S7Variable(address = "DB19.316", type = EDataType.INT16) |
| | | private Short from5; |
| | | |
| | | @S7Variable(address = "DB19.318", type = EDataType.INT16) |
| | | private Short from6; |
| | | |
| | | @S7Variable(address = "DB19.320", type = EDataType.INT16) |
| | | private Short to1; |
| | | |
| | | @S7Variable(address = "DB19.322", type = EDataType.INT16) |
| | | private Short to2; |
| | | |
| | | @S7Variable(address = "DB19.324", type = EDataType.INT16) |
| | | private Short to3; |
| | | |
| | | @S7Variable(address = "DB19.326", type = EDataType.INT16) |
| | | private Short to4; |
| | | |
| | | @S7Variable(address = "DB19.328", type = EDataType.INT16) |
| | | private Short to5; |
| | | |
| | | @S7Variable(address = "DB19.330", type = EDataType.INT16) |
| | | private Short to6; |
| | | |
| | | @S7Variable(address = "DB19.332", type = EDataType.INT16) |
| | | private Short state1; |
| | | |
| | | @S7Variable(address = "DB19.334", type = EDataType.INT16) |
| | | private Short state2; |
| | | |
| | | @S7Variable(address = "DB19.336", type = EDataType.INT16) |
| | | private Short state3; |
| | | |
| | | @S7Variable(address = "DB19.338", type = EDataType.INT16) |
| | | private Short state4; |
| | | |
| | | @S7Variable(address = "DB19.340", type = EDataType.INT16) |
| | | private Short state5; |
| | | |
| | | @S7Variable(address = "DB19.342", type = EDataType.INT16) |
| | | private Short state6; |
| | | |
| | | @S7Variable(address = "DB19.176", type = EDataType.STRING, count = 22) |
| | | private String id1; |
| | | |
| | | @S7Variable(address = "DB19.198", type = EDataType.STRING, count = 22) |
| | | private String id2; |
| | | |
| | | @S7Variable(address = "DB19.220", type = EDataType.STRING, count = 22) |
| | | private String id3; |
| | | |
| | | @S7Variable(address = "DB19.242", type = EDataType.STRING, count = 22) |
| | | private String id4; |
| | | |
| | | @S7Variable(address = "DB19.264", type = EDataType.STRING, count = 22) |
| | | private String id5; |
| | | |
| | | @S7Variable(address = "DB19.286", type = EDataType.STRING, count = 22) |
| | | private String id6; |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | @Configuration |
| | | public class S7Config { |
| | | @Bean |
| | | public S7Serializer s7Serializer() { |
| | | |
| | | @Bean(name = "s7SerializerCC") |
| | | public S7Serializer s7SerializerCC() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.80"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerSPOne") |
| | | public S7Serializer s7SerializerSPOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.15"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerSPTwo") |
| | | public S7Serializer s7SerializerSPTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.10.21"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | } |
| | |
| | | import com.mes.rawglassstation.service.RawGlassStorageStationService; |
| | | import com.mes.rawglasstask.entity.RawGlassStorageTask; |
| | | import com.mes.rawglasstask.service.RawGlassStorageTaskService; |
| | | import com.mes.s7.entity.S7Data; |
| | | import com.mes.s7.entity.S7DataCC; |
| | | import com.mes.s7.entity.S7DataSP; |
| | | import com.mes.uppattenusage.entity.UpPattenUsage; |
| | | import com.mes.uppattenusage.entity.vo.UpPattenUsageVO; |
| | | import com.mes.uppattenusage.mapper.UpPattenUsageMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | @Autowired(required = false) |
| | | private MiloService miloService; |
| | | |
| | | @Autowired(required = false) |
| | | S7Serializer s7Serializer; |
| | | @Autowired |
| | | @Qualifier("s7SerializerCC") |
| | | S7Serializer s7SerializerCC; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerSPOne") |
| | | private S7Serializer s7SerializerSPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerSPTwo") |
| | | private S7Serializer s7SerializerSPTwo; |
| | | |
| | | |
| | | private static final String LOAD_GLASS_DEVICE_ONE_TASK = "load_glass_device_one_task"; |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void rawStorageTask() throws Exception { |
| | | S7Data S7DataCCOne = s7Serializer.read(S7Data.class); |
| | | S7DataCC S7DataCCOne = s7SerializerCC.read(S7DataCC.class); |
| | | String requestWord = S7DataCCOne.getRequest().toString(); |
| | | String confireWord = S7DataCCOne.getConfirmation().toString(); |
| | | String reportWord = S7DataCCOne.getReportWord().toString(); |
| | |
| | | if ("0".equals(requestValue)) { |
| | | if ("1".equals(confireWord) && "0".equals(reportWord)) { |
| | | // if ("1".equals(confireWord.getValue() + "") && "0".equals(reportWord.getValue() + "")) { |
| | | S7Data s7Data = new S7Data(); |
| | | S7DataCC s7Data = new S7DataCC(); |
| | | s7Data.setConfirmation((short) 0); |
| | | s7Serializer.write(s7Data); |
| | | s7SerializerCC.write(s7Data); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // list.add(generateReadWriteEntity("CC.CC.confirmation", 0)); |
| | | // miloService.writeToOpcWord(list); |
| | | } |
| | | if ("1".equals(taskWord)) { |
| | | // if ("1".equals(taskWord.getValue() + "")) { |
| | | S7Data s7Data = new S7Data(); |
| | | S7DataCC s7Data = new S7DataCC(); |
| | | s7Data.setTaskWord((short) 0); |
| | | s7Data.setStartSlot((short) 0); |
| | | s7Data.setEndSlot((short) 0); |
| | | s7Serializer.write(s7Data); |
| | | s7SerializerCC.write(s7Data); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // list.add(generateReadWriteEntity("CC.CC.taskWord", 0)); |
| | | // list.add(generateReadWriteEntity("CC.CC.startSlot", 0)); |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void rawStorageInCar() throws Exception { |
| | | S7Data S7DataCCOne = s7Serializer.read(S7Data.class); |
| | | S7DataCC S7DataCCOne = s7SerializerCC.read(S7DataCC.class); |
| | | String value = S7DataCCOne.getInCar().toString(); |
| | | // ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.inCar"); |
| | | // String value = entity.getValue() + ""; |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void rawStorageFinish() throws Exception { |
| | | S7Data S7DataCCOne = s7Serializer.read(S7Data.class); |
| | | S7DataCC S7DataCCOne = s7SerializerCC.read(S7DataCC.class); |
| | | String value = S7DataCCOne.getReportWord().toString(); |
| | | // ReadWriteEntity entity = miloService.readFromOpcUa("CC.CC.reportWord"); |
| | | // String value = entity.getValue() + ""; |
| | |
| | | .set(RawGlassStorageTask::getTaskState, Const.RAW_GLASS_TASK_FAILURE)); |
| | | |
| | | } |
| | | S7Data s7Data = new S7Data(); |
| | | S7DataCC s7Data = new S7DataCC(); |
| | | s7Data.setConfirmation((short) 1); |
| | | s7Serializer.write(s7Data); |
| | | s7SerializerCC.write(s7Data); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // list.add(generateReadWriteEntity("CC.CC.confirmation", 1)); |
| | | // miloService.writeToOpcWord(list); |
| | |
| | | RawGlassStorageDetails twoLoadStation = loadStationList.stream().filter(e -> e.getSlot().equals(loadStation.get(1))).findFirst().orElse(null); |
| | | if (null == twoLoadStation) { |
| | | //按照尺寸生成二号位上片任务信息 |
| | | LoadGlassDeviceTask loadTask = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | // LoadGlassDeviceTask loadTask = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | S7DataSP loadTask=new S7DataSP(); |
| | | if(stationCell == 5){ |
| | | loadTask=s7SerializerSPOne.read(S7DataSP.class); |
| | | }else{ |
| | | loadTask=s7SerializerSPTwo.read(S7DataSP.class); |
| | | } |
| | | RawGlassStorageDetails rawDetails = null; |
| | | if (oneLoadStation.getRemainQuantity() > (loadTask.getTotalCount() + loadTask.getDamageCount())) { |
| | | usageVOS = upListMap.get("2"); |
| | |
| | | } else { |
| | | //todo:当二号为的尺寸大于0时,是否执行调度任务,更换当前原片的尺寸,等待下一次任务的直接执行;还是继续等待,当尺寸不一样,等待一号工位的进出库调度任务。 |
| | | if (twoLoadStation.getRemainQuantity() > 0) { |
| | | LoadGlassDeviceTask loadTask = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | // LoadGlassDeviceTask loadTask = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | S7DataSP loadTask=new S7DataSP(); |
| | | if(stationCell == 5){ |
| | | loadTask=s7SerializerSPOne.read(S7DataSP.class); |
| | | }else{ |
| | | loadTask=s7SerializerSPTwo.read(S7DataSP.class); |
| | | } |
| | | if (oneLoadStation.getRemainQuantity() > (loadTask.getTotalCount() + loadTask.getDamageCount())) { |
| | | usageVOS = upListMap.get("2"); |
| | | if (CollectionUtils.isEmpty(usageVOS)) { |
File was renamed from hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/s7/entity/S7Data.java |
| | |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7Data { |
| | | public class S7DataCC { |
| | | |
| | | |
| | | // @S7Variable(address = "DB1.0", type = EDataType.INT16) |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataSP { |
| | | |
| | | |
| | | @S7Variable(address = "DB19.14", type = EDataType.INT16) |
| | | private Short taskState; |
| | | |
| | | @S7Variable(address = "DB19.18", type = EDataType.INT16) |
| | | private Short damageCount; |
| | | |
| | | @S7Variable(address = "DB19.20", type = EDataType.INT16) |
| | | private Short rawGlassWidth; |
| | | |
| | | @S7Variable(address = "DB19.22", type = EDataType.INT16) |
| | | private Short rawGlassHeight; |
| | | |
| | | @S7Variable(address = "DB19.24", type = EDataType.INT16) |
| | | private Short slot; |
| | | |
| | | @S7Variable(address = "DB19.26", type = EDataType.INT16) |
| | | private Short totalCount; |
| | | |
| | | @S7Variable(address = "DB19.28", type = EDataType.INT16) |
| | | private Short finishCount; |
| | | |
| | | @S7Variable(address = "DB19.16.0", type = EDataType.BOOL) |
| | | private Boolean taskRunning; |
| | | |
| | | @S7Variable(address = "DB19.30", type = EDataType.INT16) |
| | | private Short inkageState; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | private void opcLoadGlassChild(String tableName, Integer deviceId) { |
| | | S7DataSP s7DataSP = new S7DataSP(); |
| | | if(tableName.equals(LOAD_GLASS_DEVICE_ONE_TASK)){ |
| | | if (tableName.equals(LOAD_GLASS_DEVICE_ONE_TASK)) { |
| | | s7DataSP = s7SerializerSPOne.read(S7DataSP.class); |
| | | }else{ |
| | | } else { |
| | | s7DataSP = s7SerializerSPTwo.read(S7DataSP.class); |
| | | } |
| | | Engineering engineering = engineeringMapper.selectOne(new LambdaQueryWrapper<Engineering>() |
| | |
| | | return; |
| | | } |
| | | //任务暂停 |
| | | LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | S7DataSP task=new S7DataSP(); |
| | | if(LOAD_GLASS_ONE_DEVICE.equals(deviceId)){ |
| | | s7SerializerSPOne.read(S7DataSP.class); |
| | | }else{ |
| | | s7SerializerSPTwo.read(S7DataSP.class); |
| | | } |
| | | // LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | ; |
| | | if ("0".equals(s7DataSP.getInkageState().toString())) { |
| | | log.info("{}上片线,处于离线状态:{},结束本地上片请求", deviceId, s7DataSP.getInkageState().toString()); |
| | | // if (0 == task.getInkageState()) { |
| | | log.info("{}上片线,处于离线状态:{},结束本地上片请求", deviceId, task.getInkageState()); |
| | | // log.info("{}上片线,处于离线状态:{},结束本地上片请求", deviceId, task.getInkageState()); |
| | | return; |
| | | } |
| | | if (s7DataSP.getTaskRunning().toString().equals(Const.ENGINEERING_RUNNING)) { |
| | |
| | | } |
| | | int number = Math.min(twoLoadStation.getRemainQuantity(), usageVOS.size()); |
| | | //生成上片任务 |
| | | task.setTotalCount(number); |
| | | task.setTaskRunning(Const.ENGINEERING_RUNNING); |
| | | task.setRawGlassWidth((int) usageVOS.get(0).getWidth()); |
| | | task.setRawGlassHeight((int) usageVOS.get(0).getHeight()); |
| | | task.setSlot(loadStation.get(1)); |
| | | loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | task.setTotalCount((short)number); |
| | | task.setTaskRunning(Boolean.TRUE); |
| | | task.setRawGlassWidth((short) usageVOS.get(0).getWidth()); |
| | | task.setRawGlassHeight((short) usageVOS.get(0).getHeight()); |
| | | task.setSlot(loadStation.get(1).shortValue()); |
| | | // loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | S7DataSP s7DataSPWrite = new S7DataSP(); |
| | | s7DataSPWrite.setTotalCount((short) number); |
| | | s7DataSPWrite.setTaskRunning(Boolean.TRUE); |
| | | s7DataSPWrite.setRawGlassWidth((short) usageVOS.get(0).getWidth()); |
| | | s7DataSPWrite.setRawGlassHeight((short) usageVOS.get(0).getHeight()); |
| | | s7DataSPWrite.setSlot(loadStation.get(1).shortValue()); |
| | | if (LOAD_GLASS_ONE_DEVICE.equals(deviceId)) { |
| | | s7SerializerSPOne.write(s7DataSPWrite); |
| | | } else { |
| | | s7SerializerSPTwo.write(s7DataSPWrite); |
| | | } |
| | | saveHistoryTask(task, deviceId); |
| | | return; |
| | | } |
| | |
| | | } |
| | | //生成上片任务 |
| | | int number = Math.min(oneLoadStation.getRemainQuantity(), usageVOS.size()); |
| | | task.setTotalCount(number); |
| | | task.setTaskRunning(Const.ENGINEERING_RUNNING); |
| | | task.setRawGlassWidth((int) usageVOS.get(0).getWidth()); |
| | | task.setRawGlassHeight((int) usageVOS.get(0).getHeight()); |
| | | task.setSlot(loadStation.get(0)); |
| | | loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | task.setTotalCount((short)number); |
| | | task.setTaskRunning(Boolean.TRUE); |
| | | task.setRawGlassWidth((short) usageVOS.get(0).getWidth()); |
| | | task.setRawGlassHeight((short) usageVOS.get(0).getHeight()); |
| | | task.setSlot(loadStation.get(0).shortValue()); |
| | | // loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | S7DataSP s7DataSPWrite = new S7DataSP(); |
| | | s7DataSPWrite.setTotalCount((short) number); |
| | | s7DataSPWrite.setTaskRunning(Boolean.TRUE); |
| | | s7DataSPWrite.setRawGlassWidth((short) usageVOS.get(0).getWidth()); |
| | | s7DataSPWrite.setRawGlassHeight((short) usageVOS.get(0).getHeight()); |
| | | s7DataSPWrite.setSlot(loadStation.get(0).shortValue()); |
| | | if (LOAD_GLASS_ONE_DEVICE.equals(deviceId)) { |
| | | s7SerializerSPOne.write(s7DataSPWrite); |
| | | } else { |
| | | s7SerializerSPTwo.write(s7DataSPWrite); |
| | | } |
| | | saveHistoryTask(task, deviceId); |
| | | } |
| | | |
| | | private void opcLoadGlassFinishChid(String tableName, Integer deviceId) { |
| | | S7DataSP s7DataSP = new S7DataSP(); |
| | | if(tableName.equals(LOAD_GLASS_DEVICE_ONE_TASK)){ |
| | | if (tableName.equals(LOAD_GLASS_DEVICE_ONE_TASK)) { |
| | | s7DataSP = s7SerializerSPOne.read(S7DataSP.class); |
| | | }else{ |
| | | } else { |
| | | s7DataSP = s7SerializerSPTwo.read(S7DataSP.class); |
| | | } |
| | | LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | // LoadGlassDeviceTask task = loadGlassDeviceTaskService.queryTaskMessage(tableName); |
| | | if (s7DataSP.getTaskRunning().toString().equals(Const.ENGINEERING_NEW)) { |
| | | // if (task.getTaskRunning().equals(Const.ENGINEERING_NEW)) { |
| | | log.info("无任务,结束"); |
| | |
| | | // 已完成数量 破损数量 |
| | | Integer finishCount = Integer.parseInt(s7DataSP.getFinishCount().toString()); |
| | | Integer damageCount = Integer.parseInt(s7DataSP.getDamageCount().toString()); |
| | | Integer slot = Integer.parseInt(s7DataSP.getSlot().toString()); |
| | | // Integer finishCount = task.getFinishCount(); |
| | | // Integer damageCount = task.getDamageCount(); |
| | | |
| | | //更新当前架子上的原片剩余情况 |
| | | rawGlassStorageDetailsService.update(new UpdateWrapper<RawGlassStorageDetails>() |
| | | .inSql("slot", "select slot from raw_glass_storage_station where enable_state = 1") |
| | | .eq("slot", task.getSlot()) |
| | | // .eq("slot", task.getSlot()) |
| | | .eq("slot", slot) |
| | | .eq("state", Const.RAW_GLASS_STATE_IN) |
| | | .setSql("remain_quantity = remain_quantity - " + (finishCount + damageCount))); |
| | | //更新工程下的原片数量 todo:sql待优化 |
| | |
| | | .set(UpPattenUsage::getState, Const.LOAD_RAW_GLASS_SUCCESS)); |
| | | } |
| | | //任务表数据情况 |
| | | task.setTaskRunning(0); |
| | | task.setTotalCount(0); |
| | | task.setRawGlassWidth(0); |
| | | task.setRawGlassHeight(0); |
| | | task.setSlot(0); |
| | | loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // task.setTaskRunning(0); |
| | | // task.setTotalCount(0); |
| | | // task.setRawGlassWidth(0); |
| | | // task.setRawGlassHeight(0); |
| | | // task.setSlot(0); |
| | | // loadGlassDeviceTaskService.updateTaskMessage(tableName, task); |
| | | S7DataSP s7DataSPWrite = new S7DataSP(); |
| | | s7DataSPWrite.setTaskRunning(Boolean.FALSE); |
| | | s7DataSPWrite.setTotalCount((short) 0); |
| | | s7DataSPWrite.setRawGlassWidth((short) 0); |
| | | s7DataSPWrite.setRawGlassHeight((short) 0); |
| | | s7DataSPWrite.setSlot((short) 0); |
| | | if (LOAD_GLASS_ONE_DEVICE.equals(deviceId)) { |
| | | s7SerializerSPOne.write(s7DataSPWrite); |
| | | } else { |
| | | s7SerializerSPTwo.write(s7DataSPWrite); |
| | | } |
| | | loadGlassDeviceTaskHistoryService.update(new LambdaUpdateWrapper<LoadGlassDeviceTaskHistory>() |
| | | .set(LoadGlassDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_SUCCESS) |
| | | .eq(LoadGlassDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_NEW) |
| | |
| | | ); |
| | | } |
| | | |
| | | private boolean saveHistoryTask(LoadGlassDeviceTask task, Integer deviceId) { |
| | | private boolean saveHistoryTask(S7DataSP task, Integer deviceId) { |
| | | LoadGlassDeviceTaskHistory taskHistory = new LoadGlassDeviceTaskHistory(); |
| | | BeanUtils.copyProperties(task, taskHistory); |
| | | taskHistory.setStation(deviceId); |
| | |
| | | |
| | | |
| | | @S7Variable(address = "DB19.14", type = EDataType.INT16) |
| | | private Integer taskState; |
| | | private Short taskState; |
| | | |
| | | @S7Variable(address = "DB19.18", type = EDataType.INT16) |
| | | private Integer damageCount; |
| | | private Short damageCount; |
| | | |
| | | @S7Variable(address = "DB19.20", type = EDataType.INT16) |
| | | private Integer rawGlassWidth; |
| | | private Short rawGlassWidth; |
| | | |
| | | @S7Variable(address = "DB19.22", type = EDataType.INT16) |
| | | private Integer rawGlassHeight; |
| | | private Short rawGlassHeight; |
| | | |
| | | @S7Variable(address = "DB19.24", type = EDataType.INT16) |
| | | private Integer slot; |
| | | private Short slot; |
| | | |
| | | @S7Variable(address = "DB19.26", type = EDataType.INT16) |
| | | private Integer totalCount; |
| | | private Short totalCount; |
| | | |
| | | @S7Variable(address = "DB19.28", type = EDataType.INT16) |
| | | private Integer finishCount; |
| | | private Short finishCount; |
| | | |
| | | @S7Variable(address = "DB19.x16.0", type = EDataType.BOOL) |
| | | private Integer taskRunning; |
| | | @S7Variable(address = "DB19.16.0", type = EDataType.BOOL) |
| | | private Boolean taskRunning; |
| | | |
| | | @S7Variable(address = "DB19.30", type = EDataType.INT16) |
| | | private Integer inkageState; |
| | | private Short inkageState; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.config; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 13:50 |
| | | * @Description: |
| | | */ |
| | | @Configuration |
| | | public class S7Config { |
| | | @Bean(name = "s7SerializerGHOne") |
| | | public S7Serializer s7SerializerGHOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.20.180"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerGHTwo") |
| | | public S7Serializer s7SerializerGHTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1500, "192.168.20.180"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.common.config.Const; |
| | |
| | | import com.mes.pp.entity.OptimizeHeatLayout; |
| | | import com.mes.pp.service.OptimizeHeatDetailService; |
| | | import com.mes.pp.service.OptimizeHeatLayoutService; |
| | | import com.mes.s7.entity.S7DataGHOne; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Autowired |
| | | private OptimizeHeatDetailService optimizeHeatDetailService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerGHOne") |
| | | private S7Serializer s7SerializerGHOne; |
| | | |
| | | /** |
| | | * 摆片台请求进片逻辑处理 |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | |
| | | */ |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void requestTemperingTask() throws Exception { |
| | | ReadWriteEntity requestInTempering = miloService.readFromOpcUa("GH1S7.GH1S7.requestInTempering");//请求进片 |
| | | ReadWriteEntity requestTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.requestTemperingId");//请求进片 炉号ID |
| | | Integer request = Integer.parseInt(requestInTempering.getValue().toString()); |
| | | Integer id = Integer.parseInt(requestTemperingId.getValue().toString()); |
| | | S7DataGHOne s7DataGHOne=s7SerializerGHOne.read(S7DataGHOne.class); |
| | | // ReadWriteEntity requestInTempering = miloService.readFromOpcUa("GH1S7.GH1S7.requestInTempering");//请求进片 |
| | | // ReadWriteEntity requestTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.requestTemperingId");//请求进片 炉号ID |
| | | // Integer request = Integer.parseInt(requestInTempering.getValue().toString()); |
| | | // Integer id = Integer.parseInt(requestTemperingId.getValue().toString()); |
| | | Integer request = (int)s7DataGHOne.getRequestInTempering(); |
| | | Integer id = (int)s7DataGHOne.getRequestTemperingId(); |
| | | if (request == 0) { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 0));//允许送片清零 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 0));//允许送片清零 |
| | | s7SerializerGHOne.write( |
| | | S7DataGHOne.builder().responseInTempering((short)0).build() |
| | | ); |
| | | } else { |
| | | if (id == 0){ |
| | | log.info("炉号不能为0"); |
| | | return; |
| | | } |
| | | ReadWriteEntity placedNumber = miloService.readFromOpcUa("GH1S7.GH1S7.placedNumber");//已摆片数量 |
| | | // ReadWriteEntity placedNumber = miloService.readFromOpcUa("GH1S7.GH1S7.placedNumber");//已摆片数量 |
| | | String placedNumber = s7DataGHOne.getPlacedNumber().toString();//已摆片数量 |
| | | List<TemperingGlassInfo> glassList = temperingAgoService.selectGlassInfoById(id); |
| | | if (Integer.parseInt(placedNumber.getValue().toString()) == glassList.size()) { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 1));//写入允许送片 |
| | | // if (Integer.parseInt(placedNumber.getValue().toString()) == glassList.size()) { |
| | | if (Integer.parseInt(placedNumber) == glassList.size()) { |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 1));//写入允许送片 |
| | | s7SerializerGHOne.write( |
| | | S7DataGHOne.builder().responseInTempering((short)1).build() |
| | | ); |
| | | } else { |
| | | miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 2));//不满足进炉条件 |
| | | // miloService.writeToOpcUa(generateReadWriteEntity("GH1S7.GH1S7.responseInTempering", 2));//不满足进炉条件 |
| | | s7SerializerGHOne.write( |
| | | S7DataGHOne.builder().responseInTempering((short)2).build() |
| | | ); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void loadTemperingTask() throws Exception { |
| | | ReadWriteEntity loadTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.loadTemperingId");//进片完成 炉号ID |
| | | getNewTemperingID(Integer.parseInt(loadTemperingId.getValue().toString()));//进片完成 下发参数 |
| | | S7DataGHOne s7DataGHOne=s7SerializerGHOne.read(S7DataGHOne.class); |
| | | // ReadWriteEntity loadTemperingId = miloService.readFromOpcUa("GH1S7.GH1S7.loadTemperingId");//进片完成 炉号ID |
| | | // getNewTemperingID(Integer.parseInt(loadTemperingId.getValue().toString()));//进片完成 下发参数 |
| | | String loadTemperingId=s7DataGHOne.getLoadTemperingId().toString();//进片完成 炉号ID |
| | | getNewTemperingID(Integer.parseInt(loadTemperingId));//进片完成 下发参数 |
| | | } |
| | | /** |
| | | * 更新钢化小片表内的玻璃状态 |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | @Builder |
| | | public class S7DataGHOne { |
| | | |
| | | |
| | | @S7Variable(address = "DB99.0", type = EDataType.INT16) |
| | | private Short requestInTempering; |
| | | |
| | | @S7Variable(address = "DB99.2", type = EDataType.INT16) |
| | | private Short requestTemperingId; |
| | | |
| | | @S7Variable(address = "DB99.4", type = EDataType.INT16) |
| | | private Short placedNumber; |
| | | |
| | | @S7Variable(address = "DB99.6", type = EDataType.INT16) |
| | | private Short responseInTempering; |
| | | |
| | | @S7Variable(address = "DB99.8", type = EDataType.INT16) |
| | | private Short loadTemperingId; |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataGHTwo { |
| | | |
| | | |
| | | @S7Variable(address = "DB110.80", type = EDataType.INT16) |
| | | private Short mesControl; |
| | | |
| | | @S7Variable(address = "DB110.80", type = EDataType.INT16) |
| | | private Short requestMes; |
| | | |
| | | @S7Variable(address = "DB110.34", type = EDataType.STRING,count = 10) |
| | | private Short MesReply; |
| | | |
| | | @S7Variable(address = "DB110.82", type = EDataType.STRING,count = 10) |
| | | private Short From1; |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.config; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 13:50 |
| | | * @Description: |
| | | */ |
| | | @Configuration |
| | | public class S7Config { |
| | | @Bean(name = "s7SerializerZKDLPOne") |
| | | public S7Serializer s7SerializerZKDLPOne() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.30.100"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | @Bean(name = "s7SerializerZKDLPTwo") |
| | | public S7Serializer s7SerializerZKDLPTwo() { |
| | | S7PLC s7PLC = new S7PLC(EPlcType.S1200, "192.168.30.100"); |
| | | return S7Serializer.newInstance(s7PLC); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.base.entity.HollowBigStorageCageBaseInfo; |
| | |
| | | import com.mes.hollowqueue.service.HollowGlassQueueInfoService; |
| | | import com.mes.hollowtask.entity.HollowBigStorageCageHistoryTask; |
| | | import com.mes.hollowtask.service.HollowBigStorageCageHistoryTaskService; |
| | | import com.mes.s7.entity.S7DataZKDLPOne; |
| | | import com.mes.s7.entity.S7DataZKDLPTwo; |
| | | import com.mes.sysconfig.service.SysConfigService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Resource |
| | | private SysConfigService sysConfigService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerZKDLPOne") |
| | | private S7Serializer s7SerializerZKDLPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerZKDLPTwo") |
| | | private S7Serializer s7SerializerZKDLPTwo; |
| | | |
| | | private static final String BIG_STORAGE_CAGE_IN_TWO_TASK = "big_storage_cage_in_two_task"; |
| | | private static final String BIG_STORAGE_CAGE_OUT_TWO_TASK = "big_storage_cage_out_two_task"; |
| | | /** |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void inBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataZKDLPOne s7DataZKDLPOne = s7SerializerZKDLPOne.read(S7DataZKDLPOne.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataZKDLPOne.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2A.DLP2A.RequestMes"); |
| | | if (!"1".equals(requestEntity.getValue() + "")) { |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2A.DLP2A.RequestMes"); |
| | | // if (!"1".equals(requestEntity.getValue() + "")) { |
| | | String requestEntity = s7DataZKDLPOne.getRequestMes().toString(); |
| | | if (!"1".equals(requestEntity)) { |
| | | log.info("当前未收到进片请求,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP2A.DLP2A.MesReply"); |
| | | if ("1".equals(mesReplyEntity.getValue() + "")) { |
| | | // ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP2A.DLP2A.MesReply"); |
| | | // if ("1".equals(mesReplyEntity.getValue() + "")) { |
| | | String mesReplyEntity = s7DataZKDLPOne.getMesReply().toString(); |
| | | if ("1".equals(mesReplyEntity)) { |
| | | log.info("有正在执行的任务,结束进片任务"); |
| | | return; |
| | | } |
| | | |
| | | List<BigStorageCageTask> inTaskList = new ArrayList(); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM1"); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM1"); |
| | | String fromOpcUa = s7DataZKDLPOne.getFrom1().toString(); |
| | | List<String> glassIdList = new ArrayList<>(); |
| | | List<Short> requestWords = s7DataZKDLPOne.getStates(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | if (null != requestWord.getValue()) { |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | Short requestWord = requestWords.get(i - 1); |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord) { |
| | | BigStorageCageTask task = new BigStorageCageTask(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | task.setGlassId(requestWord.toString()); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | inTaskList.add(task); |
| | | glassIdList.add(requestWord.getValue() + ""); |
| | | // glassIdList.add(requestWord.getValue() + ""); |
| | | glassIdList.add(requestWord.toString()); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | if (entry.getValue() > 1) { |
| | | log.info("进片玻璃{}存在相同,结束本次任务", entry.getKey()); |
| | | //向plc发送报警:同一车进片玻璃存在相同 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 2)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 2)); |
| | | s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setAlramSignal((short) 2); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | if (CollectionUtil.isNotEmpty(detailsList)) { |
| | | log.info("理片笼存在相同的进片玻璃{},结束本次任务", detailsList); |
| | | //向plc发送报警:理片笼存在相同的进片玻璃 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 4)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 4)); |
| | | s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setAlramSignal((short) 4); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | return; |
| | | } |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList)); |
| | |
| | | if (glassInfoList.size() != inTaskList.size()) { |
| | | log.info("进片任务数量{}与玻璃数量{}不匹配,结束本次进片", inTaskList.size(), glassInfoList.size()); |
| | | //向plc发送报警:进片任务数量与系统查询到的玻璃数量不匹配 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 8)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 8)); |
| | | s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setAlramSignal((short) 8); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | return; |
| | | } |
| | | |
| | |
| | | if (count < entry.getValue()) { |
| | | log.info("笼内格子剩余数量不足,结束本次进片"); |
| | | //向plc发送报警:笼内格子剩余数量不足 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 16)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 16)); |
| | | s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setAlramSignal((short) 16); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | if (count > 0) { |
| | | log.info("直通片台存在玻璃,结束本次进片"); |
| | | //向plc发送报警:直通片台存在玻璃,无法继续直通 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 64)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.alarmSignal", 64)); |
| | | s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setAlramSignal((short) 64); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | return; |
| | | } |
| | | } |
| | |
| | | //历史数据入库 |
| | | hollowBigStorageCageHistoryTaskService.saveBatch(historyTasks); |
| | | //向opc发送启动信号 |
| | | List<ReadWriteEntity> list = new ArrayList<>(); |
| | | for (int i = 1; i <= inTaskList.size(); i++) { |
| | | list.add(generateReadWriteEntity("DLP2A.DLP2A.TO" + i, inTaskList.get(i - 1).getTargetSlot())); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // for (int i = 1; i <= inTaskList.size(); i++) { |
| | | // list.add(generateReadWriteEntity("DLP2A.DLP2A.TO" + i, inTaskList.get(i - 1).getTargetSlot())); |
| | | // } |
| | | // list.add(generateReadWriteEntity("DLP2A.DLP2A.MesReply", 1)); |
| | | // miloService.writeToOpcWord(list); |
| | | s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | for (int i = 0; i < inTaskList.size() && i < 6; i++) { |
| | | short value = (short) Integer.parseInt(inTaskList.get(i).getTargetSlot().toString()); |
| | | switch (i) { |
| | | case 0: |
| | | s7DataZKDLPOne.setTo1(value); |
| | | break; |
| | | case 1: |
| | | s7DataZKDLPOne.setTo2(value); |
| | | break; |
| | | case 2: |
| | | s7DataZKDLPOne.setTo3(value); |
| | | break; |
| | | case 3: |
| | | s7DataZKDLPOne.setTo4(value); |
| | | break; |
| | | case 4: |
| | | s7DataZKDLPOne.setTo5(value); |
| | | break; |
| | | case 5: |
| | | s7DataZKDLPOne.setTo6(value); |
| | | break; |
| | | } |
| | | } |
| | | list.add(generateReadWriteEntity("DLP2A.DLP2A.MesReply", 1)); |
| | | miloService.writeToOpcWord(list); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void outBigStorageTask() throws Exception { |
| | | Date startDate = new Date(); |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataZKDLPTwo s7DataZKDLPTwo = s7SerializerZKDLPTwo.read(S7DataZKDLPTwo.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataZKDLPTwo.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2B.DLP2B.RequestMes"); |
| | | if (!"1".equals(requestEntity.getValue() + "")) { |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2B.DLP2B.RequestMes"); |
| | | // if (!"1".equals(requestEntity.getValue() + "")) { |
| | | String requestEntity = s7DataZKDLPTwo.getRequestMes().toString(); |
| | | if (!"1".equals(requestEntity)) { |
| | | log.info("当前未收到出片请求,结束出片任务"); |
| | | return; |
| | | } |
| | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishInBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataZKDLPOne s7DataZKDLPOne = s7SerializerZKDLPOne.read(S7DataZKDLPOne.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataZKDLPOne.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束完成进片任务"); |
| | | return; |
| | | } |
| | | //获取进片任务表 |
| | | List<BigStorageCageTask> inTaskList = new ArrayList(); |
| | | List<String> glassIdList = new ArrayList<>(); |
| | | ReadWriteEntity toWord = miloService.readFromOpcUa("DLP2A.DLP2A.TO1"); |
| | | if ("0".equals(toWord.getValue() + "")) { |
| | | // ReadWriteEntity toWord = miloService.readFromOpcUa("DLP2A.DLP2A.TO1"); |
| | | // if ("0".equals(toWord.getValue() + "")) { |
| | | String toWord = s7DataZKDLPOne.getTo1().toString(); |
| | | if ("0".equals(toWord)) { |
| | | log.info("完成任务已执行,结束本次完成进片任务"); |
| | | return; |
| | | } |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | ReadWriteEntity statetWord = miloService.readFromOpcUa("DLP2A.DLP2A.STATE" + i); |
| | | ReadWriteEntity toOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.TO" + i); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM" + i); |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | // ReadWriteEntity statetWord = miloService.readFromOpcUa("DLP2A.DLP2A.STATE" + i); |
| | | // ReadWriteEntity toOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.TO" + i); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM" + i); |
| | | String requestWord = ""; |
| | | String statetWord = ""; |
| | | String toOpcUa = ""; |
| | | String fromOpcUa = ""; |
| | | switch (i) { |
| | | case 0: |
| | | requestWord = s7DataZKDLPOne.getId1().toString(); |
| | | statetWord = s7DataZKDLPOne.getState1().toString(); |
| | | toOpcUa = s7DataZKDLPOne.getTo1().toString(); |
| | | fromOpcUa = s7DataZKDLPOne.getFrom1().toString(); |
| | | break; |
| | | case 1: |
| | | requestWord = s7DataZKDLPOne.getId2().toString(); |
| | | statetWord = s7DataZKDLPOne.getState2().toString(); |
| | | toOpcUa = s7DataZKDLPOne.getTo2().toString(); |
| | | fromOpcUa = s7DataZKDLPOne.getFrom2().toString(); |
| | | break; |
| | | case 2: |
| | | requestWord = s7DataZKDLPOne.getId3().toString(); |
| | | statetWord = s7DataZKDLPOne.getState3().toString(); |
| | | toOpcUa = s7DataZKDLPOne.getTo3().toString(); |
| | | fromOpcUa = s7DataZKDLPOne.getFrom3().toString(); |
| | | break; |
| | | case 3: |
| | | requestWord = s7DataZKDLPOne.getId4().toString(); |
| | | statetWord = s7DataZKDLPOne.getState4().toString(); |
| | | toOpcUa = s7DataZKDLPOne.getTo4().toString(); |
| | | fromOpcUa = s7DataZKDLPOne.getFrom4().toString(); |
| | | break; |
| | | case 4: |
| | | requestWord = s7DataZKDLPOne.getId5().toString(); |
| | | statetWord = s7DataZKDLPOne.getState5().toString(); |
| | | toOpcUa = s7DataZKDLPOne.getTo5().toString(); |
| | | fromOpcUa = s7DataZKDLPOne.getFrom5().toString(); |
| | | break; |
| | | case 5: |
| | | requestWord = s7DataZKDLPOne.getId6().toString(); |
| | | statetWord = s7DataZKDLPOne.getState6().toString(); |
| | | toOpcUa = s7DataZKDLPOne.getTo6().toString(); |
| | | fromOpcUa = s7DataZKDLPOne.getFrom6().toString(); |
| | | break; |
| | | } |
| | | |
| | | if (null != requestWord.getValue()) { |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord) { |
| | | BigStorageCageTask task = new BigStorageCageTask(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | task.setTargetSlot(Integer.parseInt(toOpcUa.getValue() + "")); |
| | | task.setTaskState(Integer.parseInt(statetWord.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | // task.setTargetSlot(Integer.parseInt(toOpcUa.getValue() + "")); |
| | | // task.setTaskState(Integer.parseInt(statetWord.getValue() + "")); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setGlassId(requestWord); |
| | | task.setTargetSlot(Integer.parseInt(toOpcUa)); |
| | | task.setTaskState(Integer.parseInt(statetWord)); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | inTaskList.add(task); |
| | | glassIdList.add(requestWord.getValue() + ""); |
| | | // glassIdList.add(requestWord.getValue() + ""); |
| | | glassIdList.add(requestWord); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | //向opc发送启动信号 |
| | | List<ReadWriteEntity> list = new ArrayList<>(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | list.add(generateReadWriteEntity("DLP2A.DLP2A.TO" + i, 0)); |
| | | } |
| | | list.add(generateReadWriteEntity("DLP2A.DLP2A.MesReply", 0)); |
| | | miloService.writeToOpcWord(list); |
| | | // List<ReadWriteEntity> list = new ArrayList<>(); |
| | | // for (int i = 1; i <= 6; i++) { |
| | | // list.add(generateReadWriteEntity("DLP2A.DLP2A.TO" + i, 0)); |
| | | // } |
| | | // list.add(generateReadWriteEntity("DLP2A.DLP2A.MesReply", 0)); |
| | | // miloService.writeToOpcWord(list); |
| | | s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setTo1((short) 0); |
| | | s7DataZKDLPOne.setTo2((short) 0); |
| | | s7DataZKDLPOne.setTo3((short) 0); |
| | | s7DataZKDLPOne.setTo4((short) 0); |
| | | s7DataZKDLPOne.setTo5((short) 0); |
| | | s7DataZKDLPOne.setTo6((short) 0); |
| | | s7DataZKDLPOne.setMesReply((short) 0); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishOutBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | S7DataZKDLPTwo s7DataZKDLPTwo = s7SerializerZKDLPTwo.read(S7DataZKDLPTwo.class); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | // if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | Boolean inkageEntity = s7DataZKDLPTwo.getMesControl(); |
| | | if (true != inkageEntity) { |
| | | log.info("当前为非联机状态,结束完成出片任务"); |
| | | return; |
| | | } |
| | |
| | | |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2B.DLP2B.MesReply", 0)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP2B.DLP2B.MesReply", 0)); |
| | | s7DataZKDLPTwo = new S7DataZKDLPTwo(); |
| | | s7DataZKDLPTwo.setMesReply((short) 0); |
| | | s7SerializerZKDLPTwo.write(s7DataZKDLPTwo); |
| | | } |
| | | |
| | | private void dealDamageInTask(List<BigStorageCageTask> damageTaskList) { |
| | |
| | | |
| | | if (null == storageCage) { |
| | | //向plc发送报警:直通片台存在玻璃,无法继续直通 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16)); |
| | | S7DataZKDLPOne s7DataZKDLPOne = new S7DataZKDLPOne(); |
| | | s7DataZKDLPOne.setAlramSignal((short) 16); |
| | | s7SerializerZKDLPOne.write(s7DataZKDLPOne); |
| | | Assert.isFalse(storageCage == null, "任务调度没有多余格子,结束调度任务"); |
| | | } |
| | | |
| | |
| | | .ne(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_OUT) |
| | | .in(HollowBigStorageCageDetails::getGlassId, glassIds)); |
| | | try { |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2B.DLP2B.MesReply", 1)); |
| | | // miloService.writeToOpcWord(generateReadWriteEntity("DLP2B.DLP2B.MesReply", 1)); |
| | | S7DataZKDLPTwo s7DataZKDLPTwo = new S7DataZKDLPTwo(); |
| | | s7DataZKDLPTwo.setMesReply((short) 0); |
| | | s7SerializerZKDLPTwo.write(s7DataZKDLPTwo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageTask; |
| | |
| | | import com.mes.hollowtask.service.HollowBigStorageCageHistoryTaskService; |
| | | import com.mes.largenscreen.entity.PieChartVO; |
| | | import com.mes.largenscreen.entity.RunTime; |
| | | import com.mes.s7.entity.S7DataZKDLPOne; |
| | | import com.mes.s7.entity.S7DataZKDLPTwo; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerZKDLPOne") |
| | | private S7Serializer s7SerializerZKDLPOne; |
| | | |
| | | @Autowired |
| | | @Qualifier("s7SerializerZKDLPTwo") |
| | | private S7Serializer s7SerializerZKDLPTwo; |
| | | |
| | | @Resource |
| | | RedisUtil redisUtil; |
| | |
| | | |
| | | |
| | | public void queryDataSource1(JSONObject jsonObject) throws Exception { |
| | | S7DataZKDLPOne s7DataZKDLPOne = s7SerializerZKDLPOne.read(S7DataZKDLPOne.class); |
| | | S7DataZKDLPTwo s7DataZKDLPTwo = s7SerializerZKDLPTwo.read(S7DataZKDLPTwo.class); |
| | | List<Double> carPostion = new ArrayList<>(); |
| | | carPostion.add(0.25); |
| | | carPostion.add(0.5); |
| | |
| | | try { |
| | | //进片任务数据 |
| | | List<BigStorageTaskVO> inTaskList = new ArrayList(); |
| | | ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM1"); |
| | | // ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP2A.DLP2A.FROM1"); |
| | | String fromOpcUa = s7DataZKDLPOne.getFrom1().toString(); |
| | | for (int i = 1; i <= 6; i++) { |
| | | ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP2A.DLP2A.TO" + i); |
| | | ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP2A.DLP2A.STATE" + i); |
| | | if (null != requestWord.getValue()) { |
| | | // ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP2A.DLP2A.DI" + i); |
| | | // ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP2A.DLP2A.TO" + i); |
| | | // ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP2A.DLP2A.STATE" + i); |
| | | String requestWord = ""; |
| | | String stateWord = ""; |
| | | String targetSlotWord = ""; |
| | | switch (i) { |
| | | case 0: |
| | | requestWord = s7DataZKDLPOne.getId1().toString(); |
| | | stateWord = s7DataZKDLPOne.getState1().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo1().toString(); |
| | | break; |
| | | case 1: |
| | | requestWord = s7DataZKDLPOne.getId2().toString(); |
| | | stateWord = s7DataZKDLPOne.getState2().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo2().toString(); |
| | | break; |
| | | case 2: |
| | | requestWord = s7DataZKDLPOne.getId3().toString(); |
| | | stateWord = s7DataZKDLPOne.getState3().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo3().toString(); |
| | | break; |
| | | case 3: |
| | | requestWord = s7DataZKDLPOne.getId4().toString(); |
| | | stateWord = s7DataZKDLPOne.getState4().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo4().toString(); |
| | | break; |
| | | case 4: |
| | | requestWord = s7DataZKDLPOne.getId5().toString(); |
| | | stateWord = s7DataZKDLPOne.getState5().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo5().toString(); |
| | | break; |
| | | case 5: |
| | | requestWord = s7DataZKDLPOne.getId6().toString(); |
| | | stateWord = s7DataZKDLPOne.getState6().toString(); |
| | | targetSlotWord = s7DataZKDLPOne.getTo6().toString(); |
| | | break; |
| | | } |
| | | // if (null != requestWord.getValue()) { |
| | | if (null != requestWord) { |
| | | BigStorageTaskVO task = new BigStorageTaskVO(); |
| | | task.setGlassId(requestWord.getValue() + ""); |
| | | // task.setGlassId(requestWord.getValue() + ""); |
| | | task.setGlassId(requestWord); |
| | | int isExistCount = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>().in(HollowBigStorageCageDetails::getGlassId, task.getGlassId()) |
| | | .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | if (isExistCount > 0) { |
| | |
| | | } else { |
| | | task.setIsSame(0); |
| | | } |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | // task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); |
| | | // task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); |
| | | // task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); |
| | | task.setStartSlot(Integer.parseInt(fromOpcUa)); |
| | | task.setTargetSlot(Integer.parseInt(targetSlotWord)); |
| | | task.setTaskState(Integer.parseInt(stateWord)); |
| | | inTaskList.add(task); |
| | | continue; |
| | | } |
| | |
| | | } |
| | | try { |
| | | //进片联机 |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | // ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | | // jsonObject.append("inkageEntity", inkageEntity.getValue()); |
| | | Boolean inkageEntity = s7DataZKDLPOne.getMesControl(); |
| | | jsonObject.append("inkageEntity", inkageEntity); |
| | | //进片请求 |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2A.DLP2A.RequestMes"); |
| | | jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | // ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP2A.DLP2A.RequestMes"); |
| | | // jsonObject.append("requestEntity", requestEntity.getValue()); |
| | | String requestEntity = s7DataZKDLPOne.getRequestMes().toString(); |
| | | jsonObject.append("requestEntity", requestEntity); |
| | | //启动命令 |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP2A.DLP2A.MesReply"); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | // ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP2A.DLP2A.MesReply"); |
| | | // jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); |
| | | String mesReplyEntity = s7DataZKDLPOne.getMesReply().toString(); |
| | | jsonObject.append("mesReplyEntity", mesReplyEntity); |
| | | //出片联机 |
| | | ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | // ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | // jsonObject.append("outInkageEntity", outInkageEntity.getValue()); |
| | | String outInkageEntity = s7DataZKDLPTwo.getMesControl().toString(); |
| | | jsonObject.append("outInkageEntity", outInkageEntity); |
| | | //出片请求 |
| | | ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP2B.DLP2B.RequestMes"); |
| | | jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | // ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP2B.DLP2B.RequestMes"); |
| | | // jsonObject.append("outRequestEntity", outRequestEntity.getValue()); |
| | | String outRequestEntity = s7DataZKDLPTwo.getRequestMes().toString(); |
| | | jsonObject.append("outInkageEntity", outInkageEntity); |
| | | //930空闲信号 |
| | | ReadWriteEntity freeOneRequestEntity = miloService.readFromOpcUa("CMJ1.CMJ1.isFree"); |
| | | jsonObject.append("freeOneRequestEntity", freeOneRequestEntity.getValue()); |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataZKDLPOne { |
| | | |
| | | |
| | | @S7Variable(address = "DB3.8", type = EDataType.BOOL) |
| | | private Boolean mesControl; |
| | | |
| | | @S7Variable(address = "DB19.0", type = EDataType.INT16) |
| | | private Short requestMes; |
| | | |
| | | @S7Variable(address = "DB19.2", type = EDataType.INT16) |
| | | private Short mesReply; |
| | | |
| | | @S7Variable(address = "DB19.140", type = EDataType.INT16) |
| | | private Short from1; |
| | | |
| | | @S7Variable(address = "DB19.142", type = EDataType.INT16) |
| | | private Short from2; |
| | | |
| | | @S7Variable(address = "DB19.144", type = EDataType.INT16) |
| | | private Short from3; |
| | | |
| | | @S7Variable(address = "DB19.146", type = EDataType.INT16) |
| | | private Short from4; |
| | | |
| | | @S7Variable(address = "DB19.148", type = EDataType.INT16) |
| | | private Short from5; |
| | | |
| | | @S7Variable(address = "DB19.150", type = EDataType.INT16) |
| | | private Short from6; |
| | | |
| | | @S7Variable(address = "DB19.152", type = EDataType.INT16) |
| | | private Short to1; |
| | | |
| | | @S7Variable(address = "DB19.154", type = EDataType.INT16) |
| | | private Short to2; |
| | | |
| | | @S7Variable(address = "DB19.156", type = EDataType.INT16) |
| | | private Short to3; |
| | | |
| | | @S7Variable(address = "DB19.158", type = EDataType.INT16) |
| | | private Short to4; |
| | | |
| | | @S7Variable(address = "DB19.160", type = EDataType.INT16) |
| | | private Short to5; |
| | | |
| | | @S7Variable(address = "DB19.162", type = EDataType.INT16) |
| | | private Short to6; |
| | | |
| | | @S7Variable(address = "DB19.164", type = EDataType.INT16) |
| | | private Short state1; |
| | | |
| | | @S7Variable(address = "DB19.166", type = EDataType.INT16) |
| | | private Short state2; |
| | | |
| | | @S7Variable(address = "DB19.168", type = EDataType.INT16) |
| | | private Short state3; |
| | | |
| | | @S7Variable(address = "DB19.170", type = EDataType.INT16) |
| | | private Short state4; |
| | | |
| | | @S7Variable(address = "DB19.172", type = EDataType.INT16) |
| | | private Short state5; |
| | | |
| | | @S7Variable(address = "DB19.174", type = EDataType.INT16) |
| | | private Short state6; |
| | | |
| | | @S7Variable(address = "DB19.1246", type = EDataType.INT16) |
| | | private Short glassCount; |
| | | |
| | | @S7Variable(address = "DB19.8", type = EDataType.STRING, count = 22) |
| | | private String id1; |
| | | |
| | | @S7Variable(address = "DB19.30", type = EDataType.STRING, count = 22) |
| | | private String id2; |
| | | |
| | | @S7Variable(address = "DB19.52", type = EDataType.STRING, count = 22) |
| | | private String id3; |
| | | |
| | | @S7Variable(address = "DB19.74", type = EDataType.STRING, count = 22) |
| | | private String id4; |
| | | |
| | | @S7Variable(address = "DB19.96", type = EDataType.STRING, count = 22) |
| | | private String id5; |
| | | |
| | | @S7Variable(address = "DB19.118", type = EDataType.STRING, count = 22) |
| | | private String id6; |
| | | |
| | | @S7Variable(address = "MW1002", type = EDataType.INT16) |
| | | private Short alramSignal; |
| | | |
| | | public List<Short> getStates() { |
| | | return Arrays.asList(state1, state2, state3, state4, state5, state6); |
| | | } |
| | | |
| | | public List<String> getIds() { |
| | | return Arrays.asList(id1, id2, id3, id4, id5, id6); |
| | | } |
| | | |
| | | public List<Short> getTos() { |
| | | return Arrays.asList(to1, to2, to3, to4, to5, to6); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.s7.entity; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.common.enums.EDataType; |
| | | import com.github.xingshuangs.iot.protocol.s7.serializer.S7Variable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2025/4/30 14:19 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class S7DataZKDLPTwo { |
| | | |
| | | |
| | | @S7Variable(address = "DB3.8", type = EDataType.BOOL) |
| | | private Boolean mesControl; |
| | | |
| | | @S7Variable(address = "DB19.4", type = EDataType.INT16) |
| | | private Short requestMes; |
| | | |
| | | @S7Variable(address = "DB19.6", type = EDataType.INT16) |
| | | private Short mesReply; |
| | | |
| | | @S7Variable(address = "DB19.308", type = EDataType.INT16) |
| | | private Short from1; |
| | | |
| | | @S7Variable(address = "DB19.310", type = EDataType.INT16) |
| | | private Short from2; |
| | | |
| | | @S7Variable(address = "DB19.312", type = EDataType.INT16) |
| | | private Short from3; |
| | | |
| | | @S7Variable(address = "DB19.314", type = EDataType.INT16) |
| | | private Short from4; |
| | | |
| | | @S7Variable(address = "DB19.316", type = EDataType.INT16) |
| | | private Short from5; |
| | | |
| | | @S7Variable(address = "DB19.318", type = EDataType.INT16) |
| | | private Short from6; |
| | | |
| | | @S7Variable(address = "DB19.320", type = EDataType.INT16) |
| | | private Short to1; |
| | | |
| | | @S7Variable(address = "DB19.322", type = EDataType.INT16) |
| | | private Short to2; |
| | | |
| | | @S7Variable(address = "DB19.324", type = EDataType.INT16) |
| | | private Short to3; |
| | | |
| | | @S7Variable(address = "DB19.326", type = EDataType.INT16) |
| | | private Short to4; |
| | | |
| | | @S7Variable(address = "DB19.328", type = EDataType.INT16) |
| | | private Short to5; |
| | | |
| | | @S7Variable(address = "DB19.330", type = EDataType.INT16) |
| | | private Short to6; |
| | | |
| | | @S7Variable(address = "DB19.332", type = EDataType.INT16) |
| | | private Short state1; |
| | | |
| | | @S7Variable(address = "DB19.334", type = EDataType.INT16) |
| | | private Short state2; |
| | | |
| | | @S7Variable(address = "DB19.336", type = EDataType.INT16) |
| | | private Short state3; |
| | | |
| | | @S7Variable(address = "DB19.338", type = EDataType.INT16) |
| | | private Short state4; |
| | | |
| | | @S7Variable(address = "DB19.340", type = EDataType.INT16) |
| | | private Short state5; |
| | | |
| | | @S7Variable(address = "DB19.342", type = EDataType.INT16) |
| | | private Short state6; |
| | | |
| | | @S7Variable(address = "DB19.176", type = EDataType.STRING, count = 22) |
| | | private String id1; |
| | | |
| | | @S7Variable(address = "DB19.198", type = EDataType.STRING, count = 22) |
| | | private String id2; |
| | | |
| | | @S7Variable(address = "DB19.220", type = EDataType.STRING, count = 22) |
| | | private String id3; |
| | | |
| | | @S7Variable(address = "DB19.242", type = EDataType.STRING, count = 22) |
| | | private String id4; |
| | | |
| | | @S7Variable(address = "DB19.264", type = EDataType.STRING, count = 22) |
| | | private String id5; |
| | | |
| | | @S7Variable(address = "DB19.286", type = EDataType.STRING, count = 22) |
| | | private String id6; |
| | | |
| | | |
| | | } |