From 8026e81ee4829629d4c86d094999ba3beb31dda4 Mon Sep 17 00:00:00 2001 From: WinUser01 Date: Fri, 31 Dec 2021 14:55:45 +0800 Subject: [PATCH] =?UTF-8?q?hyzp=5Fybqx-Commit054=EF=BC=9A=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=88=9D=E6=AD=A5=E5=AE=9E=E7=8E=B0=E7=90=83=E6=9C=BA?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=B9=E5=90=91=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/commonFun.dart | 6 ++ lib/components/dioFun.dart | 120 ++++++++++++++++++++++++++------- lib/config/service_url.dart | 2 +- lib/widget/my_superplayer.dart | 36 +++++++--- 4 files changed, 131 insertions(+), 33 deletions(-) diff --git a/lib/components/commonFun.dart b/lib/components/commonFun.dart index 6cdf067..8c52fc7 100644 --- a/lib/components/commonFun.dart +++ b/lib/components/commonFun.dart @@ -54,6 +54,12 @@ import 'UserInfo.dart'; const serviceUrl_ybqx = 'http://125.64.218.67:9909'; // 区县的违章图片和视频地址前缀:http://125.64.218.67:9912/ const serviceUrl_ybqx_media = 'http://125.64.218.67:9912/'; +//5、球机方向控制接口说明: +// 接口地址:http://125.64.218.67:9906/api/ptz/{通道ID}/{球机ID} +// static const String setSphericalCameraUrl = 'http://125.64.218.67:9906/api/ptz/'; //球机方向控制接口 +// 区县球机方向控制: +// http://125.64.218.67:9914/?type=publish&dwip=172.16.3.21&topic=camera&dataType=PTZ&cmdCode=23&to=456&speed=40 +const String setSphericalCameraUrl = 'http://125.64.218.67:9914/'; //球机方向控制接口 // 511502、翠屏区 // int qxdm = 511502; diff --git a/lib/components/dioFun.dart b/lib/components/dioFun.dart index 4dffcc1..afda04b 100644 --- a/lib/components/dioFun.dart +++ b/lib/components/dioFun.dart @@ -25,21 +25,73 @@ import 'commonFun.dart'; // horizonSpeed 说明:横向位移速度 // verticalSpeed说明:垂直位移速度 // zoomSpeed说明:变焦速度 + +// 区县球机方向控制接口: +// 通过http协议向服务器发送POST数据,数据格式如下: +// http://125.64.218.67:9914/?type=publish&dwip=172.16.3.21&topic=camera&dataType=PTZ&cmdCode=23&to=456&speed=40 +// +// ----------------------------------------------- +// 云台控制代码: +// 1:停止动作 +// 3:启动雨刷 +// 11:焦距变大 +// 12:焦距变小 +// 21:上移 +// 22:下移 +// 23:左移 +// 24:右移 +// 25:左上移动 +// 26:右上移动 +// 27:左下移动 +// 28:右下移动 Future setSphericalCameraDio( {@required int id, + @required String dwip, @required int cmdCode, - int horizonSpeed = 120, - int verticalSpeed = 120, - int zoomSpeed = 120}) async { + String move_type = "publish", + String topic_type = "camera", + String data_type = "PTZ", + // int horizonSpeed = 120, + // int verticalSpeed = 120, + // int zoomSpeed = 120}) async { + int speed = 120}) async { + // --------------------------------------------------- + // 参数说明: + // type:动作类型,publish表示向设备发送指令 + // dwip:点位IP,向哪个点位的设备发送指令 + // topic:设备主题类型,camera表示向球机设备发送 + // dataType:控制类型,PTZ表示控制球机云台 + // cmdCode:球机云台的控制代码,整数,如21表示上,22表示下,详情见下方 + // to:客户端ID,暂不用,输入任意整数即可 + // speed:暂不用,输入任意整数即可 + + // --------------------------------------------------- + // http://125.64.218.67:9914/? + // type=publish& + // dwip=172.16.3.21& + // topic=camera& + // dataType=PTZ& + // cmdCode=23& + // to=456& + // speed=40 Map map = { + "type": move_type, + "dwip": dwip, + "topic": topic_type, + "dataType": data_type, "cmdCode": cmdCode.toString(), - "horizonSpeed": horizonSpeed.toString(), - "verticalSpeed": verticalSpeed.toString(), - "zoomSpeed": zoomSpeed.toString(), + "to": id.toString(), + "speed": speed.toString(), + // "horizonSpeed": horizonSpeed.toString(), + // "verticalSpeed": verticalSpeed.toString(), + // "zoomSpeed": zoomSpeed.toString(), }; - var api = getSphericalCameraApi(id, map); + var api = getSphericalCameraApi(map); print('api = ${api}'); - //I/flutter (28351): api = http://125.64.218.67:9906/api/ptz/34020000001320001016/34020000001320001016?cmdCode=8&horizonSpeed=60&verticalSpeed=60&zoomSpeed=60 + // api = + // OK: http://125.64.218.67:9914/?type=publish&dwip=172.16.3.21&topic=topic&dataType=dataType&cmdCode=21&to=1&speed=120 + // bug01: http://125.64.218.67:9914/?type=publish&dwip=172.16.3.21&topic=camera&dataType=PTZ&cmdCode=23&to=456&speed=40 + // api = http://125.64.218.67:9914/?type=publish&dwip=172.16.3.21&topic=camera&dataType=PTZ&cmdCode=21&to=1&speed=120 try { print('开始处理网络请求...'); @@ -55,16 +107,16 @@ Future setSphericalCameraDio( print('${api} 球机移动网络请求过程正常完成'); ///处理球机停止移动 - map["cmdCode"] = '0'; - api = getSphericalCameraApi(id, map); - print('api = ${api}'); - //I/flutter (28351): api = http://125.64.218.67:9906/api/ptz/34020000001320001016/34020000001320001016?cmdCode=0&horizonSpeed=60&verticalSpeed=60&zoomSpeed=60 - - response = await dio.post(api); - print('response = ${response.toString()}'); - if (response.statusCode == 200) { - print('${api} 球机停止移动网络请求过程正常完成'); - } + // map["cmdCode"] = '0'; + // api = getSphericalCameraApi(map); + // print('api = ${api}'); + // //I/flutter (28351): api = http://125.64.218.67:9906/api/ptz/34020000001320001016/34020000001320001016?cmdCode=0&horizonSpeed=60&verticalSpeed=60&zoomSpeed=60 + // + // response = await dio.post(api); + // print('response = ${response.toString()}'); + // if (response.statusCode == 200) { + // print('${api} 球机停止移动网络请求过程正常完成'); + // } } else { throw Exception('${api} 后端接口出现异常,请检测代码和服务器情况.........'); } @@ -84,16 +136,35 @@ Future setSphericalCameraDio( // zoomSpeed:60 // 上述调用可以一次性书写为: // http://125.64.218.67:9906/api/ptz/34020000001320002016/34020000001320002016?cmdCode=8&horizonSpeed=60&verticalSpeed=60&zoomSpeed=60 -String getSphericalCameraApi(int id, Map map) { - var api = ServicePath.setSphericalCameraUrl + - getSphericalCameraID(id) + - '/' + - getSphericalCameraID(id) + - '?'; +// String getSphericalCameraApi(int id, Map map) { +// // var api = ServicePath.setSphericalCameraUrl + +// var api = setSphericalCameraUrl + getSphericalCameraID(id) + '/' + getSphericalCameraID(id) + '?'; +// map.forEach((key, value) { +// //print("$key : $value"); +// api += (key + '=' + value + '&'); +// }); +// api = api.substring(0, api.length - 1); // 删除末尾字符 +// +// return api; +// } +// 兴文县: +String getSphericalCameraApi(Map map) { + // Map map = { + // "type": move_type, + // "dwip": dwip, + // "topic": topic_type, + // "dataType": data_type, + // "cmdCode": cmdCode.toString(), + // "to": id.toString(), + // "speed": speed, + // }; + // http://125.64.218.67:9914/?type=publish&dwip=172.16.3.21&topic=camera&dataType=PTZ&cmdCode=23&to=456&speed=40 + var api = setSphericalCameraUrl + '?'; map.forEach((key, value) { //print("$key : $value"); api += (key + '=' + value + '&'); + // E/flutter (23744): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: type 'int' is not a subtype of type 'String' of 'other' }); api = api.substring(0, api.length - 1); // 删除末尾字符 @@ -1951,6 +2022,7 @@ Future playUrl({@required int index, String url, BuildContext context}) { var ret = Navigator.of(context).push(MaterialPageRoute( builder: (context) => SuperPlayerPage( id: index + 1, + dwip: listDwinfoGetList2[index]['dwip'], url: urlnew, title: '点位视频\n${(index + 1)}、${listDwinfoGetList2[index]['dwmc']}', ))); diff --git a/lib/config/service_url.dart b/lib/config/service_url.dart index 6c78faf..d7cc4d0 100644 --- a/lib/config/service_url.dart +++ b/lib/config/service_url.dart @@ -127,7 +127,7 @@ class ServicePath { //5、球机方向控制接口说明: // 接口地址:http://125.64.218.67:9906/api/ptz/{通道ID}/{球机ID} - static const String setSphericalCameraUrl = 'http://125.64.218.67:9906/api/ptz/'; //球机方向控制接口 + // static const String setSphericalCameraUrl = 'http://125.64.218.67:9906/api/ptz/'; //球机方向控制接口 //6、获取 Apk 下载地址 // api = http://sctastech.com/download/index.html diff --git a/lib/widget/my_superplayer.dart b/lib/widget/my_superplayer.dart index e4a3216..2d16566 100644 --- a/lib/widget/my_superplayer.dart +++ b/lib/widget/my_superplayer.dart @@ -22,10 +22,12 @@ class SuperPlayerPage extends StatefulWidget { SuperPlayerPage( {@required this.url, this.id = -2, // 播放点位视频的点位编号,-2 表示播放违章视频 + this.dwip = '', // 点位IP,用于点位视频控制球机方向 this.loop = 1, this.title = 'Tencent Player', Key key}) : super(key: key); + String dwip; String url; String title; int loop; //设置播放循环,默认播放器的循环次数是1, 即不循环播放。如果设置循环次数0,表示无限循环。 @@ -284,44 +286,62 @@ class _SuperPlayerPageState extends State with SuperPlayerListe /// status == -1 超出范围 /// status == 0 右 case 0: - setSphericalCameraDio(id: widget.id, cmdCode: 1); + setSphericalCameraDio( + id: widget.id, dwip: widget.dwip, cmdCode: 1); break; /// status == 1 右上 case 1: - setSphericalCameraDio(id: widget.id, cmdCode: 9); + setSphericalCameraDio( + id: widget.id, dwip: widget.dwip, cmdCode: 9); break; ///三、球机位移接口方向代码说明: // 上:8 下:4 左:2 右:1 左上:10 左下:6 右上:9 右下:5 + + // 云台控制代码:1:停止动作、3:启动雨刷、11:焦距变大、12:焦距变小 + // 21:上移 + // 22:下移 + // 23:左移 + // 24:右移 + // 25:左上移动 + // 26:右上移动 + // 27:左下移动 + // 28:右下移动 /// status == 2 上 case 2: - setSphericalCameraDio(id: widget.id, cmdCode: 8); + setSphericalCameraDio( + id: widget.id, dwip: widget.dwip, cmdCode: 21); break; /// status == 3 左上 case 3: - setSphericalCameraDio(id: widget.id, cmdCode: 10); + setSphericalCameraDio( + id: widget.id, dwip: widget.dwip, cmdCode: 10); break; /// status == 4 左 case 4: - setSphericalCameraDio(id: widget.id, cmdCode: 2); + setSphericalCameraDio( + id: widget.id, dwip: widget.dwip, cmdCode: 2); break; /// status == 5 左下 case 5: - setSphericalCameraDio(id: widget.id, cmdCode: 6); + setSphericalCameraDio( + id: widget.id, dwip: widget.dwip, cmdCode: 6); break; /// status == 6 下 case 6: - setSphericalCameraDio(id: widget.id, cmdCode: 4); + setSphericalCameraDio( + id: widget.id, dwip: widget.dwip, cmdCode: 22); break; /// status == 7 右下 case 7: - setSphericalCameraDio(id: widget.id, cmdCode: 5); + setSphericalCameraDio( + id: widget.id, dwip: widget.dwip, cmdCode: 5); break; /// status == 8 还原