| package com.zy.acs.common.domain.protocol; | 
|   | 
| import com.zy.acs.framework.common.RadixTools; | 
| import com.zy.acs.common.domain.AgvActionItem; | 
| import com.zy.acs.common.utils.Utils; | 
| import lombok.Data; | 
|   | 
| import java.io.Serializable; | 
| import java.util.ArrayList; | 
| import java.util.List; | 
|   | 
| /** | 
|  * 路径数据包 | 
|  * Created by vincent on 2023/3/16 | 
|  */ | 
| @Data | 
| public class AGV_01_DOWN implements IMessageBody, Serializable { | 
|   | 
|     private static final long serialVersionUID = -2786382674008041014L; | 
|   | 
|     @Override | 
|     public byte[] writeToBytes() { | 
|         String serialNo = Utils.zeroFill(this.serialNo, 16); | 
|         byte[] serialNoBytes = Utils.reverse(serialNo.getBytes()); | 
|         byte pathLen = (byte) actionItems.size(); | 
|   | 
|         byte[] pathBytes = new byte[0]; | 
|         for (AgvActionItem<? extends IActionBody> item : actionItems) { | 
|             byte[] bytes = RadixTools.intToBytes(Integer.parseInt(item.getQrCode())); | 
|             byte[] qrCodeBytes = Utils.reverse(bytes); | 
|             byte actionCodeByte = (byte) item.getActionCmdType().actionCode; | 
|             byte valByte = (byte) item.getVal(); | 
|             byte[] actionBodyBytes = item.getActionBody().writeToBytes(); | 
|             byte[] merge = Utils.merge(qrCodeBytes, actionCodeByte, valByte, actionBodyBytes); | 
|             pathBytes = Utils.merge(pathBytes, merge); | 
|         } | 
|   | 
|         return Utils.merge(serialNoBytes, pathLen, pathBytes); | 
|     } | 
|   | 
|     @Override | 
|     public void readFromBytes(byte[] messageBodyBytes) { | 
|   | 
|     } | 
|   | 
|     // 流水号 - 16 | 
|     private String serialNo; | 
|   | 
|     // 路径长度 | 
|     private int pathLen; | 
|   | 
|     // 路径列表 | 
|     private List<AgvActionItem<? extends IActionBody>> actionItems = new ArrayList<>(); | 
|   | 
| } |