1078-摄像头立即拍摄命令
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
package com.genersoft.iot.vmp.jt1078.bean;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(description = "拍摄命令参数")
|
||||
public class JTShootingCommand {
|
||||
|
||||
@Schema(description = "通道 ID")
|
||||
private int chanelId;
|
||||
|
||||
@Schema(description = "0:停止拍摄;0xFFFF:录像;其他:拍照张数")
|
||||
private int command;
|
||||
|
||||
@Schema(description = "拍照间隔/录像时间, 单位为秒(s) ,0 表示按最小间隔拍照或一直录像")
|
||||
private int time;
|
||||
|
||||
@Schema(description = "1:保存; 0:实时上传")
|
||||
private int save;
|
||||
|
||||
@Schema(description = "分辨率: " +
|
||||
"0x00:最低分辨率" +
|
||||
"0x01:320 x240;" +
|
||||
"0x02:640 x480;" +
|
||||
"0x03:800 x600;" +
|
||||
"0x04:1024 x768;" +
|
||||
"0x05:176 x144;" +
|
||||
"0x06:352 x288;" +
|
||||
"0x07:704 x288;" +
|
||||
"0x08:704 x576;" +
|
||||
"0xff:最高分辨率")
|
||||
private int resolvingPower;
|
||||
|
||||
@Schema(description = "图像/视频质量: 取值范围为 1 ~ 10 ,1 代表质量损失最小 ,10 表示压缩 比最大")
|
||||
private int quality;
|
||||
|
||||
@Schema(description = "亮度, 0 ~ 255")
|
||||
private int brightness;
|
||||
|
||||
@Schema(description = "对比度,0 ~ 127")
|
||||
private int contrastRatio;
|
||||
|
||||
@Schema(description = "饱和度,0 ~ 127")
|
||||
private int saturation;
|
||||
|
||||
@Schema(description = "色度,0 ~ 255")
|
||||
private int chroma;
|
||||
|
||||
public ByteBuf decode() {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeByte(chanelId);
|
||||
byteBuf.writeShort((short)(command & 0xffff));
|
||||
byteBuf.writeShort((short)(time & 0xffff));
|
||||
byteBuf.writeByte(save);
|
||||
byteBuf.writeByte(resolvingPower);
|
||||
byteBuf.writeByte(quality);
|
||||
byteBuf.writeByte(brightness);
|
||||
byteBuf.writeByte(contrastRatio);
|
||||
byteBuf.writeByte(saturation);
|
||||
byteBuf.writeByte(chroma);
|
||||
return byteBuf;
|
||||
}
|
||||
|
||||
public int getChanelId() {
|
||||
return chanelId;
|
||||
}
|
||||
|
||||
public void setChanelId(int chanelId) {
|
||||
this.chanelId = chanelId;
|
||||
}
|
||||
|
||||
public int getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(int command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public int getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(int save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public int getResolvingPower() {
|
||||
return resolvingPower;
|
||||
}
|
||||
|
||||
public void setResolvingPower(int resolvingPower) {
|
||||
this.resolvingPower = resolvingPower;
|
||||
}
|
||||
|
||||
public int getQuality() {
|
||||
return quality;
|
||||
}
|
||||
|
||||
public void setQuality(int quality) {
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
public int getBrightness() {
|
||||
return brightness;
|
||||
}
|
||||
|
||||
public void setBrightness(int brightness) {
|
||||
this.brightness = brightness;
|
||||
}
|
||||
|
||||
public int getContrastRatio() {
|
||||
return contrastRatio;
|
||||
}
|
||||
|
||||
public void setContrastRatio(int contrastRatio) {
|
||||
this.contrastRatio = contrastRatio;
|
||||
}
|
||||
|
||||
public int getSaturation() {
|
||||
return saturation;
|
||||
}
|
||||
|
||||
public void setSaturation(int saturation) {
|
||||
this.saturation = saturation;
|
||||
}
|
||||
|
||||
public int getChroma() {
|
||||
return chroma;
|
||||
}
|
||||
|
||||
public void setChroma(int chroma) {
|
||||
this.chroma = chroma;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JTShootingCommand{" +
|
||||
"chanelId=" + chanelId +
|
||||
", command=" + command +
|
||||
", time=" + time +
|
||||
", save=" + save +
|
||||
", resolvingPower=" + resolvingPower +
|
||||
", quality=" + quality +
|
||||
", brightness=" + brightness +
|
||||
", contrastRatio=" + contrastRatio +
|
||||
", saturation=" + saturation +
|
||||
", chroma=" + chroma +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class JT1078Template {
|
||||
private static final String H8607 = "8607";
|
||||
private static final String H8608 = "8608";
|
||||
private static final String H8702 = "8702";
|
||||
private static final String H8801 = "8801";
|
||||
private static final String H9101 = "9101";
|
||||
private static final String H9102 = "9102";
|
||||
private static final String H9201 = "9201";
|
||||
@@ -61,6 +62,7 @@ public class JT1078Template {
|
||||
private static final String H0500 = "0500";
|
||||
private static final String H0608 = "0608";
|
||||
private static final String H0702 = "0702";
|
||||
private static final String H0805 = "0805";
|
||||
private static final String H1205 = "1205";
|
||||
|
||||
/**
|
||||
@@ -567,4 +569,15 @@ public class JT1078Template {
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
|
||||
public Object shooting(String devId, J8801 j8801, int timeOut) {
|
||||
Cmd cmd = new Cmd.Builder()
|
||||
.setDevId(devId)
|
||||
.setPackageNo(randomInt())
|
||||
.setMsgId(H8801)
|
||||
.setRespId(H0805)
|
||||
.setRs(j8801)
|
||||
.build();
|
||||
return SessionManager.INSTANCE.request(cmd, timeOut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -749,5 +749,19 @@ public class JT1078Controller {
|
||||
return WVPResult.fail(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "1078-摄像头立即拍摄命令", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "deviceId", description = "设备编号", required = true)
|
||||
@PostMapping("/shooting")
|
||||
public WVPResult<List<Long>> shooting(@RequestBody ShootingParam param){
|
||||
|
||||
logger.info("[1078-摄像头立即拍摄命令] param: {}", param );
|
||||
List<Long> ids = service.shooting(param.getDeviceId(), param.getShootingCommand());
|
||||
if (ids != null) {
|
||||
return WVPResult.success(ids);
|
||||
}else {
|
||||
return WVPResult.fail(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.genersoft.iot.vmp.jt1078.controller.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTShootingCommand;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@Schema(description = "设备")
|
||||
public class ShootingParam {
|
||||
|
||||
@Schema(description = "设备")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "拍摄命令参数")
|
||||
private JTShootingCommand shootingCommand;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public JTShootingCommand getShootingCommand() {
|
||||
return shootingCommand;
|
||||
}
|
||||
|
||||
public void setShootingCommand(JTShootingCommand shootingCommand) {
|
||||
this.shootingCommand = shootingCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ShootingParam{" +
|
||||
"deviceId='" + deviceId + '\'' +
|
||||
", shootingCommand=" + shootingCommand +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.request;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 摄像头立即拍摄命令应答
|
||||
*/
|
||||
@MsgId(id = "0805")
|
||||
public class J0805 extends Re {
|
||||
|
||||
private int respNo;
|
||||
/**
|
||||
* 0:成功/确认;1:失败;2:消息有误;3:不支持
|
||||
*/
|
||||
private int result;
|
||||
|
||||
/**
|
||||
* 表示拍摄成功的多媒体个数
|
||||
*/
|
||||
private List<Long> ids;
|
||||
|
||||
@Override
|
||||
protected Rs decode0(ByteBuf buf, Header header, Session session) {
|
||||
respNo = buf.readUnsignedShort();
|
||||
result = buf.readUnsignedByte();
|
||||
int length = buf.readUnsignedByte();
|
||||
for (int i = 0; i < length; i++) {
|
||||
ids.add(buf.readUnsignedInt());
|
||||
}
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0805", (long) respNo, ids);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Rs handler(Header header, Session session, Ijt1078Service service) {
|
||||
SessionManager.INSTANCE.response(header.getTerminalId(), "0001", (long) respNo, result);
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getRespNo() {
|
||||
return respNo;
|
||||
}
|
||||
|
||||
public void setRespNo(int respNo) {
|
||||
this.respNo = respNo;
|
||||
}
|
||||
|
||||
public int getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(int result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public List<Long> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<Long> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvent getEvent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.genersoft.iot.vmp.jt1078.proc.response;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.bean.JTShootingCommand;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 摄像头立即拍摄命令
|
||||
*/
|
||||
@MsgId(id = "8801")
|
||||
public class J8801 extends Rs {
|
||||
|
||||
JTShootingCommand command;
|
||||
|
||||
@Override
|
||||
public ByteBuf encode() {
|
||||
return command.decode();
|
||||
}
|
||||
|
||||
public JTShootingCommand getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(JTShootingCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
}
|
||||
@@ -95,4 +95,7 @@ public interface Ijt1078Service {
|
||||
List<JTAreaOrRoute> queryRoute(String deviceId, List<Long> ids);
|
||||
|
||||
JTDriverInformation queryDriverInformation(String deviceId);
|
||||
|
||||
List<Long> shooting(String deviceId, JTShootingCommand shootingCommand);
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -705,4 +706,11 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
J8702 j8702 = new J8702();
|
||||
return (JTDriverInformation)jt1078Template.queryDriverInformation(deviceId, j8702, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> shooting(String deviceId, JTShootingCommand shootingCommand) {
|
||||
J8801 j8801 = new J8801();
|
||||
j8801.setCommand(shootingCommand);
|
||||
return (List<Long>)jt1078Template.shooting(deviceId, j8801, 20);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user