diff --git a/.flutter-plugins b/.flutter-plugins index 37c1d28..a914b17 100644 --- a/.flutter-plugins +++ b/.flutter-plugins @@ -1,4 +1,5 @@ # This is a generated file; do not edit or check into version control. +flutter_webrtc=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\flutter_webrtc-0.9.48+hotfix.1\\ libserialport=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\git\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\ path_provider=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider-2.1.4\\ path_provider_android=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_android-2.2.10\\ diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 5dc29a9..cc1fb61 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"libserialport","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-08-26 18:57:11.469847","version":"3.24.0","swift_package_manager_enabled":false} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"flutter_webrtc","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_webrtc-0.9.48+hotfix.1\\\\","native_build":true,"dependencies":[]},{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"libserialport","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-08-27 18:06:29.957598","version":"3.24.0","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/images/pilerCar.png b/images/pilerCar.png new file mode 100644 index 0000000..799a54a Binary files /dev/null and b/images/pilerCar.png differ diff --git a/lib/appbar.dart b/lib/appbar.dart index c4e0b3b..57c654c 100644 --- a/lib/appbar.dart +++ b/lib/appbar.dart @@ -1,12 +1,13 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:scence_map/controllers/controller.dart'; // import '../login_in/connect/bluetooth_page.dart'; // import '../login_in/connect/connect_type.dart'; // import '../login_in/getx/real_data.dart'; // import 'main.dart'; -// final RealController controller1 = Get.find(); +final ScenceMapController mapcontroller = Get.find(); class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { final double appBarHeight; @@ -87,13 +88,13 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { () => InkWell( onTap: () { // 点击图标时显示对点卡片 - // sight.isCardVisible.value = - // !sight.isCardVisible.value; // 确保控制器已定义 + mapcontroller.isCardVisible.value = + !mapcontroller.isCardVisible.value; // 确保控制器已定义 }, child: Icon( Icons.my_location_sharp, size: 35, - color: isCardVisible.value + color: mapcontroller.isCardVisible.value ? Colors.blue // : const Color.fromARGB(200, 29, 28, 28), : (isDarkMode.value diff --git a/lib/controllers/gnss_Controller.dart b/lib/controllers/gnss_Controller.dart index d6bd51f..710c782 100644 --- a/lib/controllers/gnss_Controller.dart +++ b/lib/controllers/gnss_Controller.dart @@ -31,8 +31,8 @@ class GnssController extends GetxController { type: 2, height: 3.0, width: 3.0, - lat: 4196584.0, - lon: 517728, + lat: 3790616.710, + lon: 577046.048, image: ['assets/images/pilerCar.png']); mapController.addDevice(device); // pilerCenterPoint = PilerPointCalculate( @@ -42,7 +42,8 @@ class GnssController extends GetxController { // ); // 调用 pilerPos3D 方法 - pilerCenter = Pos3D(4196584.0, 517728, 0.0); + // pilerCenter = Pos3D(4196544.959, 517639.709, 0.0); + // 插入定时器测试代码 timer = Timer.periodic(Duration(seconds: 1), (Timer timer) { device.x += 0.2; diff --git a/lib/pages/aim_point/aimCard.dart b/lib/pages/aim_point/aimCard.dart new file mode 100644 index 0000000..56887ae --- /dev/null +++ b/lib/pages/aim_point/aimCard.dart @@ -0,0 +1,56 @@ +import 'package:cpnav/pages/pass_track/view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:get/get.dart'; + +import 'aimPointer.dart'; + +final SightController controller = Get.put(SightController()); + +class SightGview extends GetView { + const SightGview({super.key}); + + @override + Widget build(BuildContext context) { + final Size size = MediaQuery.of(context).size; + + return Obx(() => Positioned( + left: controller.sightOffset.value.dx, + top: controller.sightOffset.value.dy, + width: size.width / 5 * 1.5, + height: size.width / 5 * 1.5, + child: GestureDetector( + onScaleStart: (details) { + // 正确计算初始偏移量:当前手指位置与卡片当前位置之间的差值 + controller.sightInit.value = + details.localFocalPoint - controller.sightOffset.value; + }, + onScaleUpdate: (details) { + // 使用初始偏移量来更新卡片的位置 + controller.sightOffset.value = + details.localFocalPoint - controller.sightInit.value; + }, + child: Visibility( + visible: mapcontroller.isCardVisible.value, // 控制可见性 + child: Container( + decoration: const BoxDecoration(color: Colors.transparent), + child: Stack(children: [ + const Card( + elevation: 5.0, + child: SightView(), + ), + Positioned( + right: 0, + top: 0, + child: IconButton( + icon: const Icon(Icons.close), + onPressed: () { + // 关闭按钮的回调函数 + mapcontroller.isCardVisible.value = false; + }, + ), + ), + ]), + ))))); + } +} diff --git a/lib/pages/aim_point/aimPointer.dart b/lib/pages/aim_point/aimPointer.dart new file mode 100644 index 0000000..f1a18a7 --- /dev/null +++ b/lib/pages/aim_point/aimPointer.dart @@ -0,0 +1,213 @@ +import 'package:cpnav/pages/real_data/realController.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:scence_map/controllers/controller.dart'; +import 'package:scence_map/scence_map.dart'; + +import '../../service/pile/device_type.dart'; + +final RealController realcontroller = Get.put(RealController()); + +// 对点 瞄准器 +class SightController extends GetxController { + final mapcontroller = Get.put(ScenceMapController()); + + var isNomal = true.obs; + //左下圆 + var sightOffset = const Offset(3, 3).obs; + var sightOffsetInit = const Offset(0, 0).obs; + var sightInit = const Offset(0, 0).obs; + var lastSightOffset = const Offset(0, 0).obs; // 新增变量,用于存储上一次手指离开时的位置 + + var initDx = 0.0.obs; + var isFirst = true.obs; + var visualList = [].obs; + var plot = 2.0.obs; + var scale = 0.75.obs; + reset() { + sightOffset.value = const Offset(3, 3); + sightOffsetInit.value = const Offset(0, 0); + sightInit.value = const Offset(0, 0); + + initDx.value = 0.0; + update(); + } +} + +class SightView extends GetView { + const SightView({super.key}); + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + MediaQueryData mediaQueryData = + MediaQueryData.fromView(WidgetsBinding.instance.window); //获取当前屏幕信息 + final orientation = mediaQueryData.orientation; //获得设备方向 + final deviceType = getDeviceType(context); + double rectWidth = size.height / 2; + if (!controller.isNomal.value) { + rectWidth = size.width; + } else { + if (orientation == Orientation.landscape) { + rectWidth = size.width / 2; + if (deviceType == DeviceType.mobile) { + rectWidth = size.height - 5; + } + } else { + rectWidth = size.height / 2; + if (deviceType == DeviceType.mobile) { + rectWidth = size.width - 5; + } + } + } + + bool isDarkMode = Theme.of(context).brightness == Brightness.dark; + + return Obx(() { + return Stack( + children: [ + CustomPaint( + //绘制瞄准器 + size: Size(rectWidth, rectWidth), + painter: DrawCicle(controller, realcontroller.centerX.value, + realcontroller.centerX.value, isDarkMode), + ) + ], + ); + }); + } +} + +class DrawCicle extends CustomPainter { + final SightController controller; + final double tiltX; + final double tiltY; + final bool isDarkMode; + DrawCicle(this.controller, this.tiltX, this.tiltY, this.isDarkMode); + final _paint = Paint(); //创建一个画笔并配置其属性 + Path path = Path(); + + List icons = [ + Icons.arrow_drop_up, + Icons.arrow_drop_down, + Icons.arrow_left, + Icons.arrow_right + ]; + List iconOffset = []; + + List text = ["", "", "", ""]; //['前移', '后移', '左移', '右移']; + @override + void paint(Canvas canvas, size) { + _paint + ..strokeWidth = 2 + ..style = PaintingStyle.stroke + ..color = const Color.fromARGB(255, 183, 183, 162); + + double rectWidth = (size.height / 2 - 5).roundToDouble(); + if (!controller.isNomal.value) { + } else {} + + path.moveTo(0, rectWidth + 5); + path.lineTo(size.height, rectWidth + 5); + path.moveTo(rectWidth + 5, 0); + path.lineTo(rectWidth + 5, size.height); + canvas.drawPath(path, _paint); + // 总长 2m + double step = (rectWidth / controller.plot.value / 10).roundToDouble(); + canvas.translate(rectWidth + 5, rectWidth + 5); + for (var i = 0; i < 21; i++) { + if (i % 10 == 0) { + double line = 7; + canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint); + canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint); + canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint); + canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint); + drawText(canvas, Offset(line, i * step), i ~/ 10); + drawText(canvas, Offset(line, -i * step), (-i ~/ 10)); + if (i ~/ 10 != 0) { + drawText(canvas, Offset(i * step, line), i ~/ 10); + drawText(canvas, Offset(-i * step, line), (-i ~/ 10)); + } + } else if (i % 5 == 0) { + double line = 5; + canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint); + canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint); + canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint); + canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint); + } else { + double line = 3; + canvas.drawLine(Offset(0, i * step), Offset(line, i * step), _paint); + canvas.drawLine(Offset(i * step, 0), Offset(i * step, line), _paint); + canvas.drawLine(Offset(0, -i * step), Offset(line, -i * step), _paint); + canvas.drawLine(Offset(-i * step, 0), Offset(-i * step, line), _paint); + } + } + canvas.translate(-(rectWidth + 5), -(rectWidth + 5)); + + canvas.translate(rectWidth + 5, rectWidth + 5); + // if (controller.visualList.isNotEmpty) { + drawPoint(canvas, step); + // } + + // 绘制水平仪 + double x = realcontroller.tiltX.value; // + double y = realcontroller.tiltY.value; // + print( + "----${realcontroller.centerX.value},${realcontroller.centerY.value}"); + if (realcontroller.tiltX.value == 0 || realcontroller.tiltY.value == 0) { + x = 0; + y = 0; + } + _paint.color = Colors.red; + canvas.drawCircle(Offset(x * step * 10, y * step * 10), 10, _paint); + canvas.translate(-(rectWidth + 5), -(rectWidth + 5)); + } + + drawText(Canvas canvas, Offset offset, int i, [bool isShow = true]) { + TextPainter textPainter = TextPainter( + text: TextSpan( + text: isShow ? "$i m" : "$i", + style: TextStyle( + fontSize: 12, color: isDarkMode ? Colors.white : Colors.black)), + textDirection: TextDirection.ltr, + textAlign: TextAlign.left); + textPainter.layout(); + + textPainter.paint(canvas, offset); + } + + // drawPoint(Canvas canvas, double step) { + // // bug 绘制前应该旋转一定的角度 + + // // 设置当前施工点为中心,显示可视范围的点 + // for (int i = 0; i < plumDataController.plumList.length; i++) { + // Offset item = plumDataController.plumList[i]; + // double x = item.dx - realController.centerX.value; + // double y = item.dy - realController.centerY.value; + // // 纵向方向是相反 + + // Offset pos = Offset(x, y) * step * 10; + // canvas.drawCircle(pos, 20, Paint()..color = Colors.grey); + // drawText(canvas, pos - const Offset(20, 10), i, false); + // } + // } + + drawPoint(Canvas canvas, double step) { + // bug 绘制前应该旋转一定的角度 + + // 设置当前施工点为中心,显示可视范围的点 + for (int i = 0; i < plumDataController.plumList.length; i++) { + Offset item = plumDataController.plumList[i]; + double x = item.dx - realcontroller.centerX.value; + double y = item.dy - realcontroller.centerY.value; + // 纵向方向是相反 + + Offset pos = Offset(x, y) * step * 10; + canvas.drawCircle(pos, 20, Paint()..color = Colors.grey); + drawText(canvas, pos - const Offset(20, 10), i, false); + } + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) => true; +} diff --git a/lib/pages/pass_track/controller.dart b/lib/pages/pass_track/controller.dart index 3c58f32..5572914 100644 --- a/lib/pages/pass_track/controller.dart +++ b/lib/pages/pass_track/controller.dart @@ -1,9 +1,9 @@ import 'dart:ui'; - import 'package:get/get.dart'; - import 'package:cpnav/service/base.dart'; import 'package:scence_map/controllers/controller.dart'; +import 'package:scence_map/record_entity.dart'; + class PassTrackController extends GetxController { final mapController = Get.put(ScenceMapController()); @@ -20,7 +20,8 @@ class PassTrackController extends GetxController { service = GetServices(projCode: projCode, projType: projType); loadProject(); loadSideLine(); - loadBindDevice(); + // loadBindDevice(); + loadRcordList(); } loadBindDevice() async { @@ -73,4 +74,18 @@ class PassTrackController extends GetxController { mapController.centerXY = Offset((maxX + minX) / 2, (maxY + minY) / 2); } } + + loadRcordList() async { + List record = await service.getRcordList("2024-08-7"); + if (record.isNotEmpty) { + for (var i = 0; i < record.length; i++) { + RecordEntity item = RecordEntity.fromJson(record[i]); + mapController.recordList.add(item); + } + mapController.centerXY = Offset( + mapController.recordList[mapController.recordList.length - 1].x, + mapController.recordList[mapController.recordList.length - 1].y); + //将地图或画布的中心定位到最新记录的位置上 + } + } } diff --git a/lib/pages/pass_track/view.dart b/lib/pages/pass_track/view.dart index 39711d8..6fcbe34 100644 --- a/lib/pages/pass_track/view.dart +++ b/lib/pages/pass_track/view.dart @@ -9,8 +9,11 @@ import 'package:scence_map/controllers/controller.dart'; import 'package:scence_map/scence_map.dart'; import 'package:syncfusion_flutter_sliders/sliders.dart'; +import '../../controllers/gnss_Controller.dart'; +import '../aim_point/aimCard.dart'; import 'iconContainer.dart'; import "controller.dart"; + // import '../login_in/connect/bluetooth_page.dart'; // import '../login_in/connect/config.dart'; // import '../login_in/connect/connect_type.dart'; @@ -21,6 +24,7 @@ import "controller.dart"; // import '../setting/xy_change.dart'; ScenceMapController mapcontroller = Get.put(ScenceMapController()); +GnssController gnsscontroller = Get.find(); class PassTrack extends StatefulWidget { final String date; @@ -35,7 +39,7 @@ class PassTrack extends StatefulWidget { class _PasstrackState extends State { final GlobalKey> _popupMenuKey = GlobalKey>(); - final controller = Get.put(PassTrackController("WXLMB", "cp_orad")); + final controller = Get.put(PassTrackController("TEST", "pile_cm")); String str = "播放"; int sWidth = 0; int bits = -1; @@ -249,7 +253,8 @@ class _PasstrackState extends State { ], ), ), - IconContainer() + IconContainer(), + SightGview() ], ); }); diff --git a/lib/pages/real_data/process.dart b/lib/pages/real_data/process.dart new file mode 100644 index 0000000..fbe0221 --- /dev/null +++ b/lib/pages/real_data/process.dart @@ -0,0 +1,67 @@ +import 'dart:core'; + + +class ProcessEntity { + double speed; + double depth; + double tiltX; + double tiltY; + double current1; + double current2; + double toatalFlow2; + double toatalFlow1; + double subtotalFlow2; + double subtotalFlow1; + String recvTime; + // double? azimuth; + double alt = 0; + double lng = 0; + double lat = 0; + String pileId; + int utc; + int tid; + int? id; + ProcessEntity( + {this.speed = 0, + this.depth = 0, + this.tiltX = 0, + this.tiltY = 0, + this.current1 = 0, + this.current2 = 0, + this.toatalFlow2 = 0, + this.toatalFlow1 = 0, + this.subtotalFlow2 = 0, + this.subtotalFlow1 = 0, + required this.recvTime, + // this.azimuth, + this.alt = 0, + this.lng = 0, + this.lat = 0, + required this.pileId, + required this.utc, + required this.tid, + this.id}); + factory ProcessEntity.fromJson(Map json) { + return ProcessEntity( + speed: (json["speed"] ?? "0").toDouble(), + depth: (json["depth"] ?? "0").toDouble(), + tiltX: (json["tilt_x"] ?? "0").toDouble(), + tiltY: (json["tilt_y"] ?? "0").toDouble(), + current1: (json["current1"] ?? "0").toDouble(), + current2: (json["current2"] ?? "0").toDouble(), + toatalFlow2: (json["toatal_flow2"] ?? "0").toDouble(), + toatalFlow1: (json["toatal_flow1"] ?? "0").toDouble(), + subtotalFlow2: (json["subtotal_flow2"] ?? "0").toDouble(), + subtotalFlow1: (json["subtotal_flow1"] ?? "0").toDouble(), + recvTime: json["recv_time"] ?? DateTime.now(), + // azimuth: (json["azimuth"] ?? "0").toDouble(), + alt: (json["ALT"] ?? "0").toDouble(), + lng: (json["LNG"] ?? "0").toDouble(), + lat: (json["LAT"] ?? "0").toDouble(), + pileId: json["pile_id"].toString(), + utc: json["UTC"], + tid: json['tid'], + id: json["id"], + ); + } +} diff --git a/lib/pages/real_data/realController.dart b/lib/pages/real_data/realController.dart new file mode 100644 index 0000000..ae68d8e --- /dev/null +++ b/lib/pages/real_data/realController.dart @@ -0,0 +1,154 @@ +import 'dart:typed_data'; +import 'dart:ui'; +import 'package:get/get.dart'; +import 'package:flutter_webrtc/flutter_webrtc.dart'; + +import 'process.dart'; + +class RealController extends GetxController { + var sightOffset1 = const Offset(3, 3).obs; + var sightOffsetInit1 = const Offset(0, 0).obs; + var sightInit1 = const Offset(0, 0).obs; + var initDx = 0.0.obs; + reset() { + sightOffset1.value = const Offset(3, 3); + sightOffsetInit1.value = const Offset(0, 0); + sightInit1.value = const Offset(0, 0); + + initDx.value = 0.0; + update(); + } + + RTCPeerConnection? peerConnection; + RTCDataChannel? dataChannel; + final speed = 0.0.obs; + final depth = 0.0.obs; + final tiltX = 0.0.obs; + final tiltY = 0.0.obs; + final centerX = 0.0.obs; + final centerY = 0.0.obs; + final current1 = 0.0.obs; + final current2 = 0.0.obs; + final totalFlow2 = 0.0.obs; + final totalFlow1 = 0.0.obs; + final flow10cm1 = 0.0.obs; + final flow10cm2 = 0.0.obs; + final subtotalFlow2 = 0.0.obs; + final subtotalFlow1 = 0.0.obs; + final recvTime = ''.obs; + final alt = 0.0.obs; + final lng = 0.0.obs; + final lat = 0.0.obs; + final pileId = ''.obs; + final time = "0".obs; + final startIndex = 0.obs; + // 折线数组 + + final processList = [].obs; + var isDataVisible = false.obs; + + void updateProcessList(List newList) { + processList.assignAll(newList); // 使用 assignAll 方法更新 RxList + } + + DateTime? sliderTime; + updateSlider(double newValue, [isHand = true]) { + if (isHand) { + sliderTime = DateTime.now(); + } + startIndex.value = newValue.toInt(); + update(); + } + + @override + void onInit() { + super.onInit(); + // 定时器每秒更新时间 + // Timer.periodic(const Duration(milliseconds: 1000), (_) { + // time.value = DateTime.now(); + // }); + initializePeerConnection(); + } + + void initializePeerConnection() async { + final configuration = { + 'iceServers': [ + {'url': 'stun:stun.l.google.com:19302'}, + ], + }; + peerConnection = await createPeerConnection(configuration); + initializeDataChannel(); + } + + void initializeDataChannel() async { + // 创建数据通道 + dataChannel = await peerConnection! + .createDataChannel('dataChannel', RTCDataChannelInit()..id = 1); + + // 监听数据通道的消息事件 + dataChannel!.onMessage = (RTCDataChannelMessage message) { + // 处理接收到的消息 + if (message.isBinary) { + onBleData(message.binary); + } + }; + } + + onBleData(Uint8List data) { + ByteData byteData = data.buffer.asByteData(); + int tag = byteData.getUint8(0); + // int length = byteData.getUint8(1); + if (tag == 161) { + speed.value = byteData.getInt16(2, Endian.little) * 0.1; + int timeInt = byteData.getUint16(4, Endian.little); + // print(timeInt); + time.value = convertSecondsToMinSec(timeInt); + depth.value = byteData.getInt16(6, Endian.little) * 0.001; + pileId.value = byteData.getUint16(8, Endian.little).toString(); + subtotalFlow1.value = byteData.getInt16(10, Endian.little) * 0.01; + flow10cm1.value = byteData.getUint16(12, Endian.little) * 0.01; + totalFlow1.value = byteData.getInt32(14, Endian.little) * 0.01; + subtotalFlow2.value = byteData.getInt16(18, Endian.little) * 0.01; + flow10cm2.value = byteData.getUint16(20, Endian.little) * 0.01; + totalFlow2.value = byteData.getInt32(22, Endian.little) * 0.01; + current1.value = byteData.getUint16(26, Endian.little) * 0.01; + current2.value = byteData.getUint16(28, Endian.little) * 0.01; + // current3.value = byteData.getUint16(30, Endian.little) * 0.01; + int tag1 = byteData.getUint8(34); + // int length = byteData.getUint8(35); + if (tag1 == 162) { + // var gpsStatus = byteData.getUint8(36); + // var gpsView = byteData.getUint8(37); + + // var gpsUse = byteData.getUint8(38); + // var reg = byteData.getUint8(39); + // var utc = byteData.getUint32(40, Endian.little); +// 中心坐标 + centerX.value = byteData.getFloat64(44, Endian.little); + centerY.value = byteData.getFloat64(52, Endian.little); + // print("中心---$centerX,$centerY"); + // tiltX.value = byteData.getFloat64(44, Endian.little); + // tiltY.value = byteData.getFloat64(52, Endian.little); + // var direction = byteData.getFloat64(60, Endian.little); + // var pitch = byteData.getFloat64(68, Endian.little); + // print("$gpsUse,$gpsView,$utc,$direction,$pitch"); + } + } + } + + String convertSecondsToMinSec(int totalSeconds) { + int minutes = totalSeconds ~/ 60; + int seconds = totalSeconds % 60; + + String formattedTime = '$minutes:${seconds.toString().padLeft(2, '0')}'; + + return formattedTime; + } + + @override + void dispose() { + dataChannel?.close(); // 关闭数据通道 + peerConnection?.close(); // 关闭对等连接 + super.dispose(); + } +} diff --git a/lib/service/base.dart b/lib/service/base.dart index ed335dd..d911fed 100644 --- a/lib/service/base.dart +++ b/lib/service/base.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:io'; +import 'package:get/get.dart'; import 'package:http/http.dart' as http; import 'loginprefs.dart'; @@ -57,6 +58,8 @@ class BaseService { } } +class PileCmController extends GetxController {} + class GetServices { BaseService service = BaseService(); // String projCode = 'CJGKJEBYYB'; @@ -102,12 +105,12 @@ class GetServices { } // 液压夯 - getRcordData(int page, int size, String date, - [String sort = "desc", String order = "tp_id"]) async { - Map res = await service.getClient( - "/api/$projType/record/page?page=$page&size=$size&org_code=a&proj_code=$projCode&date=$date&sort=$sort&order=$order"); - return res['data']; - } + // getRcordData(int page, int size, String date, + // [String sort = "desc", String order = "tp_id"]) async { + // Map res = await service.getClient( + // "/api/$projType/record/page?page=$page&size=$size&org_code=a&proj_code=$projCode&date=$date&sort=$sort&order=$order"); + // return res['data']; + // } //获取水泥搅拌桩点数据 // getRcordData(int page, int size, String date, @@ -123,16 +126,16 @@ class GetServices { // "/api/$projType/record/list?org_code=a&proj_code=$projCode&tid=$tid&date=$date&dateEnd=$dateEnd"); // return res['data']; // } - getRcordList(String date, [String? dateEnd]) async { - dateEnd ??= date; - Map res = await service.getClient( - "/api/$projType/record/list?org_code=a&proj_code=$projCode&date=$date&dateEnd=$dateEnd"); - if (res['code'] == 1000) { - return res['data']; - } else { - return []; - } - } + // getRcordList(String date, [String? dateEnd]) async { + // dateEnd ??= date; + // Map res = await service.getClient( + // "/api/$projType/record/list?org_code=a&proj_code=$projCode&date=$date&dateEnd=$dateEnd"); + // if (res['code'] == 1000) { + // return res['data']; + // } else { + // return []; + // } + // } //获取施工记录的日期 getworkDateData() async { @@ -201,4 +204,19 @@ class GetServices { "/api/comm/coord_trans/list?proj_type=$projType&proj_code=$projCode"); return res['data']; } + + //获取水泥搅拌桩点数据 + getRcordData(int page, int size, String date, + [String sort = "desc", String order = "pile_id", int? tid]) async { + Map res = await service.getClient( + "/api/$projType/record/page?page=$page&size=$size&org_code=a&proj_code=$projCode&tid=$tid&date=$date&sort=$sort&order=$order"); + return res['data']; + } + + getRcordList(String date, [String? dateEnd, int? tid]) async { + dateEnd ??= date; + Map res = await service.getClient( + "/api/$projType/record/list?org_code=a&proj_code=$projCode&date=$date&dateEnd=$dateEnd");//&tid=1000 + return res['data']; + } } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 63b44da..efd1850 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,9 +6,13 @@ #include "generated_plugin_registrant.h" +#include #include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin"); + flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar); g_autoptr(FlPluginRegistrar) libserialport_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "LibserialportPlugin"); libserialport_plugin_register_with_registrar(libserialport_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 6eb336e..07da510 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + flutter_webrtc libserialport ) diff --git a/pubspec.lock b/pubspec.lock index 5d0481b..922aa82 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -73,6 +73,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + dart_webrtc: + dependency: transitive + description: + name: dart_webrtc + sha256: "5cbc40bd9b33d0c9b8004cff52e9883c71f0f54799afc8faca77535eeb9ef857" + url: "https://pub.dev" + source: hosted + version: "1.2.1" dylib: dependency: transitive description: @@ -123,6 +131,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_webrtc: + dependency: "direct main" + description: + name: flutter_webrtc + sha256: "2f17fb96e0c9c6ff75f6b1c36d94755461fc7f36a5c28386f5ee5a18b98688c8" + url: "https://pub.dev" + source: hosted + version: "0.9.48+hotfix.1" get: dependency: "direct main" description: @@ -180,6 +196,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.19.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" leak_tracker: dependency: transitive description: @@ -221,6 +245,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" matcher: dependency: transitive description: @@ -325,6 +357,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.5" + platform_detect: + dependency: transitive + description: + name: platform_detect + sha256: a62f99417fc4fa2d099ce0ccdbb1bd3977920f2a64292c326271f049d4bc3a4f + url: "https://pub.dev" + source: hosted + version: "2.1.0" plugin_platform_interface: dependency: transitive description: @@ -333,6 +373,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" roslibdart: dependency: "direct main" description: @@ -401,6 +449,14 @@ packages: url: "https://pub.dev" source: hosted version: "26.2.9" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: a824e842b8a054f91a728b783c177c1e4731f6b124f9192468457a8913371255 + url: "https://pub.dev" + source: hosted + version: "3.2.0" term_glyph: dependency: transitive description: @@ -481,6 +537,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.0" + webrtc_interface: + dependency: transitive + description: + name: webrtc_interface + sha256: abec3ab7956bd5ac539cf34a42fa0c82ea26675847c0966bb85160400eea9388 + url: "https://pub.dev" + source: hosted + version: "1.2.0" xdg_directories: dependency: transitive description: @@ -498,5 +562,5 @@ packages: source: hosted version: "6.5.0" sdks: - dart: ">=3.4.4 <4.0.0" + dart: ">=3.5.0 <4.0.0" flutter: ">=3.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index 68f11d0..b0fc8fa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,7 @@ dependencies: syncfusion_flutter_sliders: ^26.2.9 bottom_picker: ^2.8.0 roslibdart: ^0.0.1-dev+4 + flutter_webrtc: ^0.9.48+hotfix.1 dev_dependencies: flutter_test: @@ -73,6 +74,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: + - images/ - images/navi_pointer.png - images/satellite.png - images/pilerCar.png diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 9a30dcd..8b60194 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,9 +6,12 @@ #include "generated_plugin_registrant.h" +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { + FlutterWebRTCPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterWebRTCPlugin")); LibserialportPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("LibserialportPluginCApi")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 90e1f6f..6d4f117 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + flutter_webrtc libserialport )