From a1ab834875a6863b736638da38e8a4e0ee989047 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 7 Apr 2024 07:07:27 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E6=B7=BB=E5=8A=A0=E4=BA=91=E5=8F=B0?= =?UTF-8?q?=E6=97=8B=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/jt1078/cmd/JT1078Template.java | 18 ++++++ .../iot/vmp/jt1078/proc/response/J9301.java | 64 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9301.java diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java b/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java index 141c811fe..2dd000a82 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/cmd/JT1078Template.java @@ -24,6 +24,7 @@ public class JT1078Template { private static final String H9205 = "9205"; private static final String H9206 = "9206"; private static final String H9207 = "9207"; + private static final String H9301 = "9301"; private static final String H0001 = "0001"; private static final String H1205 = "1205"; @@ -147,6 +148,23 @@ public class JT1078Template { return SessionManager.INSTANCE.request(cmd, timeOut); } + /** + * 云台控制指令-云台旋转 + * + * @param devId 设备号 + * @param j9301 云台旋转参数 + */ + public String ptzRotate(String devId, J9301 j9301, Integer timeOut) { + Cmd cmd = new Cmd.Builder() + .setDevId(devId) + .setPackageNo(randomInt()) + .setMsgId(H9301) + .setRespId(H0001) + .setRs(j9301) + .build(); + return SessionManager.INSTANCE.request(cmd, timeOut); + } + private Long randomInt() { return (long) random.nextInt(1000) + 1; } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9301.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9301.java new file mode 100644 index 000000000..0c24762d6 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9301.java @@ -0,0 +1,64 @@ +package com.genersoft.iot.vmp.jt1078.proc.response; + +import com.genersoft.iot.vmp.jt1078.annotation.MsgId; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; + +/** + * 云台控制指令-云台旋转 + * + */ +@MsgId(id = "9301") +public class J9301 extends Rs { + // 逻辑通道号 + private int channel; + + // 方向: 0:停止; 1:上; 2:下; 3:左; 4:右 + private int direction; + + // 速度:0 ~ 255 + private int speed; + + @Override + public ByteBuf encode() { + ByteBuf buffer = Unpooled.buffer(); + buffer.writeByte(channel); + buffer.writeByte(direction); + buffer.writeByte(speed); + return buffer; + } + + public int getChannel() { + return channel; + } + + public void setChannel(int channel) { + this.channel = channel; + } + + public int getDirection() { + return direction; + } + + public void setDirection(int direction) { + this.direction = direction; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + @Override + public String toString() { + return "J9301{" + + "channel=" + channel + + ", direction=" + direction + + ", speed=" + speed + + '}'; + } +}