123
This commit is contained in:
parent
7f6e0bd0c7
commit
90bb63a532
@ -1,4 +1,5 @@
|
|||||||
import 'package:cpnav/appbar.dart';
|
import 'package:cpnav/appbar.dart';
|
||||||
|
import 'package:cpnav/pages/pass_track/controller.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -8,7 +9,7 @@ import 'pages/pass_track/view.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //设置全屏
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //设置全屏
|
||||||
|
Get.put(PassTrackController('WXLMB', 'cp_road'));
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
final _currentIndex = 0.obs;
|
final _currentIndex = 0.obs;
|
||||||
final List<Widget> _pages = [
|
final List<Widget> _pages = [
|
||||||
PassTrackView(
|
PassTrackView(
|
||||||
date: '',
|
// date: '',
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
import "dart:ffi" as ffi;
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:scence_map/controller.dart';
|
import 'package:scence_map/controller.dart';
|
||||||
import 'package:cpnav/service/base.dart';
|
import 'package:cpnav/service/base.dart';
|
||||||
@ -7,19 +7,24 @@ import 'package:pass_track/pass_track.dart';
|
|||||||
import 'sevice/file_handle.dart';
|
import 'sevice/file_handle.dart';
|
||||||
|
|
||||||
FileHandle fileHandle = FileHandle();
|
FileHandle fileHandle = FileHandle();
|
||||||
|
ScenceMapController mapcontroller = Get.put(ScenceMapController());
|
||||||
|
|
||||||
class PassTrackController extends GetxController {
|
class PassTrackController extends GetxController {
|
||||||
int allLen = 0;
|
var tileCount = 0.obs;
|
||||||
|
var tileFirst = 0.obs;
|
||||||
|
var tileLast = 0.obs;
|
||||||
final mapController = Get.put(ScenceMapController());
|
final mapController = Get.put(ScenceMapController());
|
||||||
|
|
||||||
String projCode;
|
String projCode;
|
||||||
String projType;
|
String projType;
|
||||||
var speed = 1.obs;
|
var speed = 1.obs;
|
||||||
late final GetServices service;
|
late final GetServices service;
|
||||||
// final PassTrack _passTrackPlugin;
|
|
||||||
PassTrackController(this.projCode, this.projType);
|
PassTrackController(this.projCode, this.projType);
|
||||||
Map<String, int> deviceMap = {};
|
Map<String, int> deviceMap = {};
|
||||||
Map<String, int> coorTransMap = {};
|
Map<String, int> coorTransMap = {};
|
||||||
|
// final PassTrack _passTrackPlugin;
|
||||||
|
final PassTrack _passTrackPlugin = PassTrack();
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@ -28,6 +33,72 @@ class PassTrackController extends GetxController {
|
|||||||
// loadSideLine();
|
// loadSideLine();
|
||||||
loadBindDevice();
|
loadBindDevice();
|
||||||
// getHisFileList();
|
// getHisFileList();
|
||||||
|
var future = getHisFileList(_passTrackPlugin);
|
||||||
|
|
||||||
|
// var maxLen =
|
||||||
|
// controller.allLen > 0 ? controller.allLen : 1.0; // 确保 maxLen 大于 0
|
||||||
|
// _rangevalues = SfRangeValues(0.0, maxLen);
|
||||||
|
// SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
// sWidth = sqrt(screen.width * screen.width + screen.height * screen.height)
|
||||||
|
// .ceil();
|
||||||
|
|
||||||
|
// // scenceMapController.scale = passTrackPlugin.passTrack_getScale() * 1.0;
|
||||||
|
// fileHandle.date = widget.date;
|
||||||
|
// await fileHandle.init();
|
||||||
|
// //在帧绘制完成后执行数据渲染
|
||||||
|
// // await initPlatformState();
|
||||||
|
// if (fileHandle.pointData.isNotEmpty) {
|
||||||
|
// DecodeDataObj obj = fileHandle.pointData[0].obj!;
|
||||||
|
// scenceMapController.centerXY = Offset(obj.y / 20, obj.x / 20);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for (var item in fileHandle.deviceList) {
|
||||||
|
// if (item["point"] != null) {
|
||||||
|
// bits = item["bits"];
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // passTrackPlugin.map_setCenterDevice(bits);
|
||||||
|
// setState(() {
|
||||||
|
// if (fileHandle.pointData.isNotEmpty) {
|
||||||
|
// maxLength = fileHandle.pointData.length;
|
||||||
|
// // _value = maxLength;
|
||||||
|
// _rangevalues = SfRangeValues(0.0, maxLength.toDouble());
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
var f = initPlatformState();
|
||||||
|
|
||||||
|
f.then((void _) {
|
||||||
|
_passTrackPlugin.setGridColor(const Color.fromARGB(255, 0, 0, 0).value);
|
||||||
|
_passTrackPlugin.drawGrid();
|
||||||
|
|
||||||
|
future.then((value) {
|
||||||
|
_passTrackPlugin.setScale(1);
|
||||||
|
for (var TID in deviceMap.keys) {
|
||||||
|
_passTrackPlugin.addDevice(int.parse(TID), 0);
|
||||||
|
}
|
||||||
|
for (var item in coorTransMap.entries) {
|
||||||
|
print("tid:${item.key} value:${item.value}");
|
||||||
|
}
|
||||||
|
// 统计用时 获取当前时间
|
||||||
|
var start = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
// _passTrackPlugin.generateTile(0, value);
|
||||||
|
_passTrackPlugin.waitForTile(() {
|
||||||
|
var start = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
print("len: ${_passTrackPlugin.allTileCnt()}");
|
||||||
|
tileCount.value = _passTrackPlugin.allTileCnt();
|
||||||
|
// _rangevalues = SfRangeValues(0, _passTrackPlugin.allTileCnt());
|
||||||
|
_passTrackPlugin.playTrack(
|
||||||
|
0, _passTrackPlugin.allTileCnt(), true, 0, ffi.nullptr);
|
||||||
|
var end = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
print("play: ${end - start}");
|
||||||
|
});
|
||||||
|
// _passTrackPlugin.drawGrid();
|
||||||
|
// 获取当前时间
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBindDevice() async {
|
loadBindDevice() async {
|
||||||
@ -89,12 +160,34 @@ class PassTrackController extends GetxController {
|
|||||||
var jsData = await GetServices().getHisFil1(file);
|
var jsData = await GetServices().getHisFil1(file);
|
||||||
print("have message");
|
print("have message");
|
||||||
int len = fileHandle.resolveJson(jsData, passTrackPlugin);
|
int len = fileHandle.resolveJson(jsData, passTrackPlugin);
|
||||||
allLen += len;
|
tileCount.value += len;
|
||||||
if (allLen >= 20000) {
|
if (tileCount.value >= 20000) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
coorTransMap = fileHandle.pointsMap;
|
coorTransMap = fileHandle.pointsMap;
|
||||||
return allLen;
|
return tileCount.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> initPlatformState() async {
|
||||||
|
String platformVersion;
|
||||||
|
try {
|
||||||
|
platformVersion = await _passTrackPlugin.getPlatformVersion() ??
|
||||||
|
'Unknown platform version';
|
||||||
|
} on Exception {
|
||||||
|
platformVersion = 'Failed to get platform version.';
|
||||||
|
}
|
||||||
|
await _passTrackPlugin.create(600, 600);
|
||||||
|
// mapcontroller.height.toInt(), mapcontroller.width.toInt());
|
||||||
|
fileHandle.textureId = await _passTrackPlugin.getTextureId() ?? -1;
|
||||||
|
print("textureId: ${fileHandle.textureId}");
|
||||||
|
print("${mapcontroller.height.toInt()}");
|
||||||
|
|
||||||
|
// if (!mounted) Exception('Failed to get textureId.');
|
||||||
|
|
||||||
|
// setState(() {
|
||||||
|
// platformVersion = platformVersion;
|
||||||
|
// });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,12 @@ class PassTrackView extends GetView<PassTrackController> {
|
|||||||
children: [
|
children: [
|
||||||
ScenceMapView(
|
ScenceMapView(
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
|
],
|
||||||
|
onUpdate: (Offset center, double scale, double rotation) {
|
||||||
|
print("center:$center scale:$scale rotation:$rotation");
|
||||||
|
},
|
||||||
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: mapcontroller.top,
|
top: mapcontroller.top,
|
||||||
left: mapcontroller.left,
|
left: mapcontroller.left,
|
||||||
@ -149,38 +155,34 @@ class PassTrackView extends GetView<PassTrackController> {
|
|||||||
height: mapcontroller.height,
|
height: mapcontroller.height,
|
||||||
// child: Text('Running on: $_platformVersion\n'),
|
// child: Text('Running on: $_platformVersion\n'),
|
||||||
child: Texture(textureId: fileHandle.textureId))),
|
child: Texture(textureId: fileHandle.textureId))),
|
||||||
],
|
|
||||||
onUpdate: (Offset center, double scale, double rotation) {
|
|
||||||
print("center:$center scale:$scale rotation:$rotation");
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Positioned(
|
Positioned(
|
||||||
width: isPortrait ? size.width * .63 : size.width * .41,
|
width: isPortrait ? size.width * .63 : size.width * .41,
|
||||||
left: isPortrait ? 190 : 200,
|
left: isPortrait ? 190 : 200,
|
||||||
bottom: 30,
|
bottom: 30,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.only(bottom: 5),
|
padding: const EdgeInsets.only(bottom: 5),
|
||||||
child: SfRangeSlider(
|
child: Obx(
|
||||||
|
() => SfRangeSlider(
|
||||||
min: 0.0,
|
min: 0.0,
|
||||||
// max: maxLength,
|
// max: maxLength,
|
||||||
max: controller.allLen > 0
|
max: controller.tileCount.value > 0
|
||||||
? controller.allLen
|
? controller.tileCount.value
|
||||||
: 1.0, // 确保 max 大于 0
|
: 1.0, // 确保 max 大于 0
|
||||||
values: _rangevalues,
|
values: SfRangeValues(
|
||||||
|
controller.tileFirst.value, controller.tileLast.value),
|
||||||
showTicks: false,
|
showTicks: false,
|
||||||
showLabels: false,
|
showLabels: false,
|
||||||
enableTooltip: true,
|
enableTooltip: true,
|
||||||
minorTicksPerInterval: 1,
|
minorTicksPerInterval: 1,
|
||||||
stepSize: 1,
|
stepSize: 1,
|
||||||
onChanged: (SfRangeValues values) {
|
onChanged: (SfRangeValues values) {
|
||||||
// setState(() {
|
controller.tileFirst.value = values.start.toInt();
|
||||||
// _rangevalues = SfRangeValues(values.start.roundToDouble(),
|
controller.tileLast.value = values.end.toInt();
|
||||||
// values.end.roundToDouble());
|
|
||||||
// });
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
left: isPortrait ? 190 : 200,
|
left: isPortrait ? 190 : 200,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 65de63acc0c565de548b02b15be6554b24ebad11
|
Subproject commit ad96316e993e3bbb2ca2b5b360b2fb5b6a50f0d2
|
Loading…
Reference in New Issue
Block a user