1078-添加云台旋转

This commit is contained in:
648540858
2024-04-07 07:07:27 +08:00
parent 4ec4d618d6
commit a1ab834875
2 changed files with 82 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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 +
'}';
}
}