ptzControl static method
云台控制
'cameraIndexCode' 监控点唯一标识
'action' 行为:0开始,1停止
'command' 命令:不区分大小写
说明:
LEFT 左转
RIGHT右转
UP 上转
DOWN 下转
ZOOM_IN 焦距变大
ZOOM_OUT 焦距变小
LEFT_UP 左上
LEFT_DOWN 左下
RIGHT_UP 右上
RIGHT_DOWN 右下
FOCUS_NEAR 焦点前移
FOCUS_FAR 焦点后移
IRIS_ENLARGE 光圈扩大
IRIS_REDUCE 光圈缩小
以下命令presetIndex不可为空
GOTO_PRESET到预置点
isHttps是否为https请求
Implementation
static Future<dynamic> ptzControl(
String cameraIndexCode,
int action,
String command, {
bool isHttps = false,
}) async {
if (cameraIndexCode.isEmpty) {
return;
}
var headers = ArtemisConfig.createHeaders(controllingV1);
///根据实际服务器情况选用http或https
String url = 'http://${ArtemisConfig.host}$controllingV1';
if (isHttps) {
url = 'https://${ArtemisConfig.host}$controllingV1';
}
Map body = Map();
body['cameraIndexCode'] = cameraIndexCode;
body['action'] = action;
body['command'] = command;
Dio dio = Dio();
dio.interceptors.add(LogInterceptor(requestBody: true));
// 忽略SSL认证
// (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
// (client) {
// client.badCertificateCallback =
// (X509Certificate cert, String host, int port) {
// return true;
// };
// };
(dio.httpClientAdapter as IOHttpClientAdapter).createHttpClient = (){
var client = HttpClient();
client.badCertificateCallback = (X509Certificate cert, String host, int port) {
return true;
};
return client;
};
dio.options.headers.addAll(headers);
Response response = await dio.post(url, data: body);
return response.data;
}