| | |
| | | form.put("direction", resolvePtzDirection(command)); |
| | | if ("start".equalsIgnoreCase(action)) { |
| | | form.put("speed", normalizePtzSpeed(speed)); |
| | | return postFormWithToken("/api/lapp/device/ptz/start", form); |
| | | JSONObject result = postFormWithToken("/api/lapp/device/ptz/start", form); |
| | | if (isCurrentOperationFailed(result)) { |
| | | postFormWithToken("/api/lapp/device/ptz/stop", form); |
| | | result = postFormWithToken("/api/lapp/device/ptz/start", form); |
| | | } |
| | | return result; |
| | | } |
| | | if ("stop".equalsIgnoreCase(action)) { |
| | | return postFormWithToken("/api/lapp/device/ptz/stop", form); |
| | |
| | | return Math.min(speed, 2); |
| | | } |
| | | |
| | | private boolean isCurrentOperationFailed(JSONObject result) { |
| | | return result != null |
| | | && !SUCCESS_CODE.equals(result.getString("code")) |
| | | && StringUtils.hasText(result.getString("msg")) |
| | | && result.getString("msg").contains("当前操作失败"); |
| | | } |
| | | |
| | | /** |
| | | * 开始云台控制。 |
| | | */ |