| | |
| | | private Boolean full; |
| | | |
| | | |
| | | //重量 |
| | | private Double weight; |
| | | |
| | | } |
| | |
| | | */ |
| | | public enum DeviceField { |
| | | // 扫码器:每站点16字节,String[14] |
| | | BARCODE("DB101", 0, 16), |
| | | BARCODE("DB103", 254, 16), |
| | | // 称重:每站点4字节,Float |
| | | WEIGHT("DB102", 0, 4), |
| | | //WEIGHT("DB102", 0, 4), |
| | | |
| | | WEIGHT("DB103", 634, 4), |
| | | // 尺寸异常:每站点2字节,Bit数组 |
| | | DIMENSION_WORD("DB103", 0, 2); |
| | | DIMENSION_WORD("DB103", 2, 8); |
| | | |
| | | private final String addressPattern; |
| | | private final int offset; |
| | |
| | | * 站点状态字段枚举(对应 §2.1) |
| | | */ |
| | | public enum StationStatusField { |
| | | ALL("DB100", 0, 12), |
| | | ALL("DB100", 10, 10), |
| | | TASK_NUMBER("DB100", 0, 4), // 任务号,偏移0,4字节 |
| | | FINAL_TARGET("DB100", 4, 2), // 最终目标站,偏移4,2字节 |
| | | STATUS_WORD("DB100", 6, 2), // 状态字,偏移6,2字节 |
| | |
| | | * 任务下发字段枚举(对应 §2.4) |
| | | */ |
| | | public enum TaskField { |
| | | ALL("DB13", 0, 12), |
| | | ALL("DB13", 48, 48), |
| | | TASK_NUMBER("DB13", 0, 4), |
| | | START_STATION("DB13", 4, 2), |
| | | DEST_STATION("DB13", 6, 2), |
| | |
| | | import com.zy.acs.conveyor.entity.Devp; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 输送线plc单个站点详细信息 |
| | | * Created by vincent on 2020/8/6 |
| | | */ |
| | | @Data |
| | | public class StaProtocol implements Cloneable { |
| | | public class StaProtocol implements Cloneable, Serializable { |
| | | |
| | | private Integer plcId; |
| | | |
| | |
| | | applyInDto.setStaNo(staNo); |
| | | applyInDto.setBarcode(barcode); |
| | | applyInDto.setFull(staProtocol.isFullPlt()); |
| | | applyInDto.setWeight(staProtocol.getWeight()); |
| | | return applyInDto; |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | int baseOffset = index * TaskField.ALL.getByteLength(); |
| | | int baseOffset = TaskField.ALL.getOffset() + index * TaskField.ALL.getByteLength(); |
| | | String workNoAddr = TaskField.TASK_NUMBER.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION |
| | | + (baseOffset + TaskField.TASK_NUMBER.getOffset()); |
| | | String destStaAddr = TaskField.DEST_STATION.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION |
| | |
| | | boolean success = false; |
| | | |
| | | while (writeCount < WRITE_RETRY_MAX) { |
| | | OperateResult writeResult = siemensS7Net.Write(workNoAddr, staProtocol.getWorkNo().shortValue()); |
| | | OperateResult writeResult = siemensS7Net.Write(workNoAddr, staProtocol.getWorkNo()); |
| | | Thread.sleep(WRITE_RETRY_INTERVAL_MS); |
| | | |
| | | OperateResult writeResult1 = siemensS7Net.Write(destStaAddr, staProtocol.getStaNo().shortValue()); |
| | |
| | | |
| | | byte[] content = result.Content; |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | StaProtocol staProtocol = station.get(staNos.get(staNoSize)); |
| | | StaProtocol staProtocol = station.get(staNos.get(i)); |
| | | parseStationStatus(content, i, staProtocol); |
| | | } |
| | | |
| | |
| | | */ |
| | | private void parseStationStatus(byte[] content, int index, StaProtocol staProtocol) { |
| | | int offset = index * StationStatusField.ALL.getByteLength(); |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(content, offset)); |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(content, offset + StationStatusField.TASK_NUMBER.getOffset())); |
| | | staProtocol.setStaNo((int) siemensS7Net.getByteTransform().TransInt16( |
| | | content, offset + StationStatusField.FINAL_TARGET.getOffset())); |
| | | |
| | |
| | | log.warn("站点不存在 [id:{}] [staNo:{}]", slave.getId(), staNosError.get(i)); |
| | | continue; |
| | | } |
| | | |
| | | short i1 = siemensS7Net.getByteTransform().TransInt16( |
| | | content, 0); |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool( |
| | | content, i * DeviceField.DIMENSION_WORD.getByteLength(), |
| | | DeviceField.DIMENSION_WORD.getByteLength()); |
| | | content, 2+i * DeviceField.DIMENSION_WORD.getByteLength(), |
| | | 1); |
| | | |
| | | boolean[] status1 = siemensS7Net.getByteTransform().TransBool( |
| | | content, 2+i * DeviceField.DIMENSION_WORD.getByteLength()+1, |
| | | 1); |
| | | |
| | | staProtocol.setFrontErr(status[0]); |
| | | staProtocol.setBackErr(status[1]); |
| | |
| | | log.info("未返回站点状态:{}", staNo); |
| | | } else { |
| | | log.error("调用下发任务接口报错,响应码:{},响应内容:{}", jsonObject.getInteger(code), response); |
| | | throw new CoolException("调用下发任务接口报错,响应码:" + jsonObject.getInteger(code)); |
| | | //throw new CoolException("调用下发任务接口报错,响应码:" + jsonObject.getInteger(code)); |
| | | } |
| | | } catch (CoolException e) { |
| | | log.error("调用站点状态接口异常", e); |
| | | throw e; |
| | | //throw e; |
| | | } catch (Exception e) { |
| | | log.error("检查站点状态失败,站点编号:{}", staNo, e); |
| | | //log.error("检查站点状态失败,站点编号:{}", staNo, e); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | server: |
| | | port: 9090 |
| | | port: 8877 |
| | | servlet: |
| | | context-path: /cv |
| | | |
| | |
| | | path: /stock/out/cv/logs |
| | | |
| | | wms: |
| | | url: 10.10.10.220:8081 |
| | | url: 10.10.10.200:8081 |
| | | apply: /rsf-open-api/rcs/api/open/location/allocate |
| | | ctu: |
| | | url: 10.10.10.200:8088 |
| | |
| | | # 输送线1 |
| | | devp[0]: |
| | | id: 1 |
| | | ip: 10.10.10.191 |
| | | ip: 10.10.10.100 |
| | | port: 102 |
| | | rack: 0 |
| | | slot: 0 |
| | |
| | | barcodeArr: |
| | | - 1010 |
| | | weightArr: |
| | | - 1010 |
| | | - 1009 |
| | | # ctu放货站点 |
| | | releaseSta[0]: |
| | | # 本站点 |