| | |
| | | import com.ard.utils.tcp.ClientInitialize; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.channel.Channel; |
| | | 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.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static jdk.nashorn.internal.runtime.regexp.joni.Config.log; |
| | | |
| | | /** |
| | | * @Description: 雷达接口 |
| | |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("/radar") |
| | | @Slf4j(topic = "netty") |
| | | public class RadarController { |
| | | |
| | | @Resource |
| | |
| | | radarPosition[1] = latitude; |
| | | double distance = GisUtils.getDistance(radarPosition, targetPosition); |
| | | float angleInRadians = (float)Math.atan(distance / altitude); |
| | | float t = 90-(float)Math.toDegrees(angleInRadians); |
| | | |
| | | float t = (90-(float)Math.toDegrees(angleInRadians))*-1; |
| | | log.debug("distance:"+distance); |
| | | log.debug("p:"+p); |
| | | log.debug("t:"+t); |
| | | //发送告警前端的角度提示 |
| | | byte[] header = {0x01, 0x02, 0x01};//包头 |
| | | byte[] payloadHeader = {0x10, 0x03, 0x40, 0x00};//负载头 |
| | | byte[] payloadHeader = {0x10, 0x03, 0x20, 0x00};//负载头 |
| | | byte[] distanceBytes = ByteUtils.decimalToBytes((int)distance); |
| | | distanceBytes=ByteUtils.toLittleEndian(distanceBytes); |
| | | byte[] pBytes = ByteUtils.floatToBytes(p); |
| | | pBytes=ByteUtils.toLittleEndian(pBytes); |
| | | byte[] tBytes = ByteUtils.floatToBytes(t); |
| | | tBytes=ByteUtils.toLittleEndian(tBytes); |
| | | byte[] resBytes=new byte[20]; |
| | | byte[] payloadBody = ByteUtils.appendArrays(distanceBytes,pBytes,tBytes,resBytes);//负载 |
| | | |