| | |
| | | package com.zy.acs.gateway.utils; |
| | | package com.example.agvcontroller.protocol; |
| | | |
| | | import com.zy.acs.common.domain.AgvProtocol; |
| | | import com.zy.acs.common.domain.protocol.IMessageBody; |
| | | import com.zy.acs.gateway.constant.ProtocolPojoType; |
| | | import com.zy.acs.gateway.constant.ProtocolType; |
| | | import com.zy.acs.gateway.domain.AgvPackage; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.logging.Logger; |
| | | |
| | | /** |
| | | * Created by vincent on 2019-04-03 |
| | | */ |
| | | public class ProtocolUtils { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(ProtocolUtils.class); |
| | | //private static final Logger log = LoggerFactory.getLogger(ProtocolUtils.class); |
| | | |
| | | // 下行协议报文组装 |
| | | public static AgvPackage installDownProtocol(AgvProtocol protocol){ |
| | | |
| | | |
| | | ProtocolPojoType protocolPojo = ProtocolPojoType.query(protocol.getMessageBody().getClass()); |
| | | //ProtocolPojoType protocolPojo = ProtocolPojoType.query(protocol.getMessageBody().getClass()); |
| | | |
| | | assert protocolPojo != null; |
| | | //assert protocolPojo != null; |
| | | |
| | | AgvPackage ackPackage = AgvPackage.valueOfEmpty(); |
| | | ackPackage.getHeader() |
| | | .setStartSymbol((byte)0xEE) |
| | | .setContentLength(0) |
| | | .setUniqueNo(protocol.getAgvNo()) |
| | | .setTimestamp(protocol.getTimestamp()) |
| | | .setProtocolType(protocolPojo.protocolType) |
| | | //.setUniqueNo(protocol.getAgvNo()) |
| | | //.setTimestamp(protocol.getTimestamp()) |
| | | //.setProtocolType(protocolPojo.protocolType) |
| | | ; |
| | | |
| | | ackPackage.getBody().setMessageBody(protocol.getMessageBody()); |
| | | //ackPackage.getBody().setMessageBody(protocol.getMessageBody()); |
| | | |
| | | return ackPackage; |
| | | |
| | |
| | | } catch (ReflectiveOperationException reflectiveOperationException) { |
| | | |
| | | |
| | | log.error("MessageBodyHandler ReflectiveOperationException", reflectiveOperationException); |
| | | //log.error("MessageBodyHandler ReflectiveOperationException", reflectiveOperationException); |
| | | |
| | | log.error("java反射创建实例失败:{}", protocolPojo.clazz.getName()); |
| | | //log.error("java反射创建实例失败:{}", protocolPojo.clazz.getName()); |
| | | |
| | | return null; |
| | | } |