| | |
| | | /** |
| | | * 条码数量 |
| | | */ |
| | | private int barcodeSize = 2; |
| | | private int barcodeSize = 3; |
| | | |
| | | /** |
| | | * 入出库模式 |
| | |
| | | staProtocol.setInEnable(status[2]); // 可入 |
| | | // staProtocol.setInEnable(true); // 可入 |
| | | staProtocol.setOutEnable(status[3]);// 可出 |
| | | // staProtocol.setOutEnable(true);// 可出 |
| | | staProtocol.setOutEnable(true);// 可出 |
| | | staProtocol.setEmptyMk(status[4]); // 空板信号 |
| | | staProtocol.setFullPlt(status[5]); // 满托盘 |
| | | staProtocol.setHigh(status[6]); // 高库位 |
| | | staProtocol.setLow(status[7]); // 低库位 |
| | | staProtocol.setStaOk(status[8]); // 就绪 |
| | | |
| | | |
| | | |
| | |
| | | |
| | | //条码 |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.100.0",(short) (barcodeSize*8)); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840.0",(short) (barcodeSize*8)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < barcodeSize; i++) { |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); |
| | |
| | | |
| | | int index = staNos.indexOf(staProtocol.getSiteId()); |
| | | |
| | | //更新命令日志 |
| | | CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); |
| | | CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); |
| | | CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId()); |
| | | CommandInfoLog commandInfoLog = new CommandInfoLog(); |
| | | if (commandInfo != null) { |
| | | commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); |
| | | commandInfoLog.setId(null); |
| | | }else { |
| | | Date now = new Date(); |
| | | commandInfoLog.setCommand(JSON.toJSONString(staProtocol)); |
| | | commandInfoLog.setCommandStatus(3); |
| | | commandInfoLog.setStartTime(now); |
| | | commandInfoLog.setExecuteTime(now); |
| | | commandInfoLog.setCompleteTime(now); |
| | | commandInfoLog.setDevice(SlaveType.Devp.toString()); |
| | | commandInfoLog.setWrkNo(9999); |
| | | commandInfoLog.setTaskNo("9999"); |
| | | commandInfoLog.setCommandDesc("手动命令"); |
| | | } |
| | | // //更新命令日志 |
| | | // CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); |
| | | // CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); |
| | | // CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId()); |
| | | // CommandInfoLog commandInfoLog = new CommandInfoLog(); |
| | | // if (commandInfo != null) { |
| | | // commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); |
| | | // commandInfoLog.setId(null); |
| | | // }else { |
| | | // Date now = new Date(); |
| | | // commandInfoLog.setCommand(JSON.toJSONString(staProtocol)); |
| | | // commandInfoLog.setCommandStatus(3); |
| | | // commandInfoLog.setStartTime(now); |
| | | // commandInfoLog.setExecuteTime(now); |
| | | // commandInfoLog.setCompleteTime(now); |
| | | // commandInfoLog.setDevice(SlaveType.Devp.toString()); |
| | | // commandInfoLog.setWrkNo(9999); |
| | | // commandInfoLog.setTaskNo("9999"); |
| | | // commandInfoLog.setCommandDesc("手动命令"); |
| | | // } |
| | | |
| | | OperateResult writeResult; |
| | | //任务下发次数 |
| | |
| | | //任务下发成功标识 |
| | | boolean writeFlag = false; |
| | | while(writeCount < 5){ |
| | | OperateResult writeResult1 = siemensS7Net.Write("DB100." + index*6, staProtocol.getWorkNo()); // 工作号 |
| | | OperateResult writeResult2 = siemensS7Net.Write("DB100." + (index*6+4), staProtocol.getStaNo()); // 目标站 |
| | | OperateResult writeResult1 = siemensS7Net.Write("DB101." + index*8, staProtocol.getWorkNo()); // 工作号 |
| | | OperateResult writeResult2 = siemensS7Net.Write("DB101." + (index*8+4), staProtocol.getStaNo().shortValue()); // 目标站 |
| | | if(writeResult1.IsSuccess && writeResult2.IsSuccess){ |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB101.0" + index*8, (short)4); |
| | | |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发成功"); |
| | | commandInfoLogService.insert(commandInfoLog); |
| | | // commandInfoLog.setDeviceLog("指令下发成功"); |
| | | // commandInfoLogService.insert(commandInfoLog); |
| | | |
| | | if(readResult.IsSuccess){ |
| | | Integer workNo = siemensS7Net.getByteTransform().TransInt32(readResult.Content, 0); |
| | |
| | | log.error("写入输送线命令失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | |
| | | //更新指令日志 |
| | | commandInfoLog.setDeviceLog("指令下发失败"); |
| | | commandInfoLogService.insert(commandInfoLog); |
| | | // commandInfoLog.setDeviceLog("指令下发失败"); |
| | | // commandInfoLogService.insert(commandInfoLog); |
| | | } |
| | | Thread.sleep(200); |
| | | } |