| | |
| | | import com.ard.utils.http.AjaxResult; |
| | | import com.ard.utils.util.ByteUtils; |
| | | import com.ard.utils.util.GisUtils; |
| | | import com.ard.utils.netty.tcp.ClientInitialize; |
| | | import com.ard.utils.netty.tcp.RadarNettyTcpClient; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.channel.Channel; |
| | | import io.netty.channel.ChannelFuture; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: 雷达接口 |
| | |
| | | if (ardEquipRadar == null) { |
| | | return AjaxResult.error("雷达不存在"); |
| | | } |
| | | Channel channel = ClientInitialize.SucChannelMap.get(ardEquipRadar.getIp() + ":" + ardEquipRadar.getPort()); |
| | | Channel channel= RadarNettyTcpClient.SERVER_MAP.get(ardEquipRadar.getIp() + ":" + ardEquipRadar.getPort()); |
| | | if (channel == null) { |
| | | return AjaxResult.error("雷达未连接"); |
| | | } |
| | |
| | | byte[] payloadCrc32 = ByteUtils.parseCrc32(payload);//负载头+负载的crc32校验 |
| | | byte[] footer = {0x01, 0x02, 0x00};//包尾 |
| | | byte[] data = ByteUtils.appendArrays(header, payload, payloadCrc32, footer); |
| | | System.out.println(ByteUtils.printHexBinary(data)); |
| | | |
| | | ByteBuf message = channel.alloc().buffer(); |
| | | message.writeBytes(data); |
| | | channel.writeAndFlush(message); |
| | | return AjaxResult.success(); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("distance",distance); |
| | | map.put("p",p); |
| | | map.put("t",t); |
| | | return AjaxResult.success(map); |
| | | } |
| | | } |
| | | } |