优化云台控制相关接口定义
parent
456ef2c5e4
commit
5ce562aea1
|
@ -224,7 +224,7 @@ public interface ISIPCommander {
|
||||||
* @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s)
|
* @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s)
|
||||||
* @param presetId 调用预置位编号,开启看守位时使用,取值范围0~255
|
* @param presetId 调用预置位编号,开启看守位时使用,取值范围0~255
|
||||||
*/
|
*/
|
||||||
void homePositionCmd(Device device, String channelId, boolean enabled, String resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
void homePositionCmd(Device device, String channelId, boolean enabled, Integer resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备配置命令
|
* 设备配置命令
|
||||||
|
|
|
@ -846,7 +846,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param presetId 调用预置位编号,开启看守位时使用,取值范围0~255
|
* @param presetId 调用预置位编号,开启看守位时使用,取值范围0~255
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void homePositionCmd(Device device, String channelId, boolean enabled, String resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void homePositionCmd(Device device, String channelId, boolean enabled, Integer resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
|
@ -862,7 +862,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
cmdXml.append("<HomePosition>\r\n");
|
cmdXml.append("<HomePosition>\r\n");
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
cmdXml.append("<Enabled>1</Enabled>\r\n");
|
cmdXml.append("<Enabled>1</Enabled>\r\n");
|
||||||
if (NumericUtil.isInteger(resetTime)) {
|
if (resetTime != null) {
|
||||||
cmdXml.append("<ResetTime>" + resetTime + "</ResetTime>\r\n");
|
cmdXml.append("<ResetTime>" + resetTime + "</ResetTime>\r\n");
|
||||||
} else {
|
} else {
|
||||||
cmdXml.append("<ResetTime>0</ResetTime>\r\n");
|
cmdXml.append("<ResetTime>0</ResetTime>\r\n");
|
||||||
|
|
|
@ -264,7 +264,12 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
HomePositionRequest homePosition = loadElement(rootElement, HomePositionRequest.class);
|
HomePositionRequest homePosition = loadElement(rootElement, HomePositionRequest.class);
|
||||||
//获取整个消息主体,我们只需要修改请求头即可
|
//获取整个消息主体,我们只需要修改请求头即可
|
||||||
HomePositionRequest.HomePosition info = homePosition.getHomePosition();
|
HomePositionRequest.HomePosition info = homePosition.getHomePosition();
|
||||||
cmder.homePositionCmd(device, channelId, info.getEnabled(), info.getResetTime(), info.getPresetIndex(),
|
if (info.getEnabled() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cmder.homePositionCmd(device, channelId, info.getEnabled().equals("1"),
|
||||||
|
info.getResetTime() != null ? Integer.parseInt(info.getResetTime()): null,
|
||||||
|
info.getPresetIndex() != null ? Integer.parseInt(info.getPresetIndex()): null,
|
||||||
errorResult -> onError(request, errorResult),
|
errorResult -> onError(request, errorResult),
|
||||||
okResult -> onOk(request, okResult));
|
okResult -> onOk(request, okResult));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -154,18 +154,19 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage());
|
logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
sync(device);
|
sync(device);
|
||||||
// TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台
|
List<Integer> ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId());
|
||||||
|
if (!ids.isEmpty()) {
|
||||||
|
commonGbChannelService.onlineForList(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
|
if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
|
||||||
logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId());
|
logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId());
|
||||||
sync(device);
|
sync(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceMapper.update(device);
|
deviceMapper.update(device);
|
||||||
redisCatchStorage.updateDevice(device);
|
redisCatchStorage.updateDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上线添加订阅
|
// 上线添加订阅
|
||||||
|
@ -207,6 +208,12 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
}
|
}
|
||||||
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId;
|
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId;
|
||||||
dynamicTask.stop(registerExpireTaskKey);
|
dynamicTask.stop(registerExpireTaskKey);
|
||||||
|
if (device.isOnLine()) {
|
||||||
|
List<Integer> ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId());
|
||||||
|
if (!ids.isEmpty()) {
|
||||||
|
commonGbChannelService.offlineForList(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
device.setOnLine(false);
|
device.setOnLine(false);
|
||||||
redisCatchStorage.updateDevice(device);
|
redisCatchStorage.updateDevice(device);
|
||||||
deviceMapper.update(device);
|
deviceMapper.update(device);
|
||||||
|
|
|
@ -255,7 +255,7 @@ public class DeviceControl {
|
||||||
@GetMapping("/home_position/{deviceId}")
|
@GetMapping("/home_position/{deviceId}")
|
||||||
public DeferredResult<String> homePositionApi(@PathVariable String deviceId,
|
public DeferredResult<String> homePositionApi(@PathVariable String deviceId,
|
||||||
String command,
|
String command,
|
||||||
@RequestParam(required = false) String resetTime,
|
@RequestParam(required = false) Integer resetTime,
|
||||||
@RequestParam(required = false) Integer presetId,
|
@RequestParam(required = false) Integer presetId,
|
||||||
String channelId) {
|
String channelId) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|
Loading…
Reference in New Issue