This commit is contained in:
LiXiaoqi 2024-09-06 15:16:09 +08:00
parent 5cc66f8314
commit 07d3835cc6
5 changed files with 138 additions and 85 deletions

View File

@ -19,13 +19,13 @@ class PassTrackController extends GetxController {
late final GetServices service;
// final PassTrack _passTrackPlugin;
PassTrackController(this.projCode, this.projType);
Map<String, int> deviceMap = {};
@override
void onInit() {
super.onInit();
service = GetServices(projCode: projCode, projType: projType);
loadProject();
loadSideLine();
// loadSideLine();
loadBindDevice();
// getHisFileList();
}
@ -34,7 +34,8 @@ class PassTrackController extends GetxController {
var binddevices = await service.getDeviceBind();
for (var device in binddevices) {
var dev = DeviceItem.fromJson(device);
mapController.deviceList[dev.TID] = dev;
deviceMap[dev.TID.toString()] = 0;
// deviceMap[dev.TID as String] = dev[int.parse(dev["width"])];
}
}
@ -80,17 +81,19 @@ class PassTrackController extends GetxController {
}
}
getHisFileList(PassTrack passTrackPlugin) async {
Future<int> getHisFileList(PassTrack passTrackPlugin) async {
Map textlist = await GetServices().getHisFileList();
List fileList = textlist['list'];
for (var i = 0; i < fileList.length; i++) {
var file = fileList[i];
var jsData = await GetServices().getHisFile(file);
var jsData = await GetServices().getHisFil1(file);
print("have message");
int len = fileHandle.resolveJson(jsData, passTrackPlugin);
allLen += len;
// print("$pointList");
// var totalList =fileHandle.allPointData;
}
print("allLen: $allLen");
if (allLen >= 20000) {
break;
}
}
return allLen;
}
}

View File

@ -9,7 +9,6 @@ import 'package:ffi/ffi.dart';
import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/status.dart' as status;
import 'package:pass_track/binding.dart' as Binding;
import '../../../service/base.dart';
@ -17,8 +16,8 @@ import '../model/coord_trans.dart';
import '../model/draw_context.dart';
import '../model/recievemodel.dart';
DrawContext drawCtx = DrawContext();
class FileHandle {
int textureId = -1;
int index = 0;
@ -250,66 +249,83 @@ class FileHandle {
List<RecieveModel> allPointData = [];
int start = 0;
var allPointLen = 0;
//
while (true) {
int end = res.indexOf('\n', start);
if (end < 0) {
break;
}
String str = res.substring(start, end);
try {
if (str[str.length - 1] == ",") {
str = str.substring(0, str.length - 1);
}
var item = jsonDecode(str);
RecieveModel recieveModel = RecieveModel.fromJson(item);
if (drawCtx.zeroDX == 0 || drawCtx.zeroDY == 0) {
//dart重置中心
drawCtx.setCenter(
// {"x": recieveModel.x / 20, "y": recieveModel.y / 20});//532863.8,4208668.95
{"x": 10656637 / 20, "y": 84172941 / 20});//532863.8,4208668.95
}
int x = recieveModel.x;
int y = recieveModel.y;
int tid = recieveModel.TID;
int type = recieveModel.type;
// data
var data = jsonDecode(res)["data"];
for (var item in data) {
// RecieveModel recieveModel = RecieveModel.fromJson(item);
var X = item["X"].toDouble();
var Y = item["Y"].toDouble();
var TID = item["TID"];
var type = int.parse(item["type"]);
var p = passTrackPlugin.wantPoint();
p.ref.X = x.toDouble();
p.ref.Y = y.toDouble();
p.ref.TID = tid;
p.ref.X = X;
p.ref.Y = Y;
p.ref.TID = TID;
p.ref.type = type;
}
return data.length;
}
return 0;
//
// while (true) {
// int end = res.indexOf('\n', start);
// if (end < 0) {
// break;
// }
// String str = res.substring(start, end);
// try {
// if (str[str.length - 1] == ",") {
// str = str.substring(0, str.length - 1);
// }
// var item = jsonDecode(str);
// RecieveModel recieveModel = RecieveModel.fromJson(item);
// if (drawCtx.zeroDX == 0 || drawCtx.zeroDY == 0) {
// //dart重置中心
// drawCtx.setCenter(
// // {"x": recieveModel.x / 20, "y": recieveModel.y / 20});//532863.8,4208668.95
// {"x": 10656637 / 20, "y": 84172941 / 20}); //532863.8,4208668.95
// }
// int x = recieveModel.x;
// int y = recieveModel.y;
// int tid = recieveModel.TID;
// int type = recieveModel.type;
// var p = passTrackPlugin.wantPoint();
// p.ref.X = x.toDouble();
// p.ref.Y = y.toDouble();
// p.ref.TID = tid;
// p.ref.type = type;
// // var data = item['data'];
// // if (data != null) {
// // item['TID'] =
// // item['TID'] is int ? item['TID'] : num.parse(item['TID']);
// // item['type'] =
// // item['type'] is int ? item['type'] : num.parse(item['type']);
// // item['obj'] = DecodeDataObj.fromBase64(item['data']);
// // // this.updateDevice(item);
// // // this.sportsData.push(item);
// allPointData.add(recieveModel);
// // }
// } catch (e) {
// print("----$e\r\n$str");
// }
// allPointLen++;
// start = end + 1;
// }
// return allPointLen;
// } else {
// //
// var item = res;
// var data = item['data'];
// if (data != null) {
// item['TID'] =
// item['TID'] is int ? item['TID'] : num.parse(item['TID']);
// item['type'] =
// item['type'] is int ? item['type'] : num.parse(item['type']);
// item['obj'] = DecodeDataObj.fromBase64(item['data']);
// item['type'] = num.parse(item['type']);
// item['TID'] = num.parse(item['TID']);
// // this.updateDevice(item);
// // this.sportsData.push(item);
allPointData.add(recieveModel);
// }
} catch (e) {
print("----$e\r\n$str");
}
allPointLen++;
start = end + 1;
}
return allPointLen;
} else {
//
var item = res;
var data = item['data'];
if (data != null) {
item['obj'] = DecodeDataObj.fromBase64(item['data']);
item['type'] = num.parse(item['type']);
item['TID'] = num.parse(item['TID']);
// this.updateDevice(item);
// this.sportsData.push(item);
}
return 1;
}
// return 1;
// }
}
//bits和typeBits

View File

@ -39,15 +39,16 @@ class PassTrackWidget extends StatefulWidget {
class _PasstrackState extends State<PassTrackWidget> {
final GlobalKey<PopupMenuButtonState<int>> _popupMenuKey =
GlobalKey<PopupMenuButtonState<int>>();
final controller = Get.put(PassTrackController("WXLMB", "cp_orad"));
final controller = Get.put(PassTrackController("WXLMB", "cp_road"));
String str = "播放";
int sWidth = 0;
int sWidth = 800;
int sHeight = 800;
int bits = -1;
int speed = 50;
List<int> speedList = [1, 2, 10, 20, 50, 100, 200, 500];
// int maxLength = 200;
late SfRangeValues _rangevalues;
final _passTrackPlugin = PassTrack();
final PassTrack _passTrackPlugin = PassTrack();
@override
initState() {
@ -84,14 +85,20 @@ class _PasstrackState extends State<PassTrackWidget> {
// }
// });
});
initPlatformState();
controller.getHisFileList(_passTrackPlugin);
if (controller.allLen <= 0) {
return;
var f = initPlatformState();
f.then((void _) {
var future = controller.getHisFileList(_passTrackPlugin);
future.then((value) {
_passTrackPlugin.setScale(1);
for (var TID in controller.deviceMap.keys) {
_passTrackPlugin.addDevice(int.parse(TID), 0);
}
_passTrackPlugin.generateTile(0, controller.allLen);
_passTrackPlugin.generateTile(0, value);
_passTrackPlugin.waitForTile();
_passTrackPlugin.playTrack(0, controller.allLen, true, 0, ffi.nullptr);
_passTrackPlugin.playTrack(0, value, true, 0, ffi.nullptr);
});
});
}
Future<void> initPlatformState() async {
@ -106,11 +113,12 @@ class _PasstrackState extends State<PassTrackWidget> {
fileHandle.textureId = await _passTrackPlugin.getTextureId() ?? -1;
print("textureId: ${fileHandle.textureId}");
if (!mounted) return;
if (!mounted) Exception('Failed to get textureId.');
setState(() {
platformVersion = platformVersion;
});
return;
}
@override
@ -121,7 +129,16 @@ class _PasstrackState extends State<PassTrackWidget> {
return Stack(
children: [
ScenceMapView(
children: [],
children: [
Positioned(
top: 0,
left: 0,
child: SizedBox(
width: sWidth * 1.0,
height: sWidth * 1.0,
// child: Text('Running on: $_platformVersion\n'),
child: Texture(textureId: fileHandle.textureId))),
],
onUpdate: (Offset center, double scale, double rotation) {
print("center:$center scale:$scale rotation:$rotation");
},
@ -235,6 +252,7 @@ class _PasstrackState extends State<PassTrackWidget> {
),
const SizedBox(width: 12),
Column(
children: [
const Text("此处遍数0"),
StreamBuilder<DateTime>(
@ -264,7 +282,8 @@ class _PasstrackState extends State<PassTrackWidget> {
},
),
],
)
),
],
),
),

View File

@ -10,7 +10,7 @@ class BaseService {
//client实例
final _client = http.Client();
final String token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc1IiOjAsInJvbGVJZHMiOlsiMSIsIjI0Il0sInVzZXJuYW1lIjoiYWRtaW4iLCJ1c2VySWQiOjEsIlBWIjo1LCJvcmciOiJhIiwiaWF0IjoxNzIyODY1MTE0LCJleHAiOjE3MjQxNjExMTR9.zuY366ldKkbtd1TTfcYIZfvhrovMlXLzzRk3j65Ua7o";
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc1IiOjAsInJvbGVJZHMiOlsiODMiXSwidXNlcm5hbWUiOiJseWNzIiwidXNlcklkIjozNTYsIlBWIjoyLCJvcmciOiJhIiwiaWF0IjoxNzI1NTI2MDc0LCJleHAiOjE3MjY4MjIwNzR9.l47sd4L8OswBcHJxamGe9M5ttWqiukoJvE5QfwPARlw";
// String baseUrl = "http://192.168.1.189:8001";//
String baseUrl = "http://1.82.251.83:8001"; //线
@ -74,7 +74,7 @@ class GetServices {
// int tid = 109;
String projType;
String projCode;
GetServices({this.projCode = "", this.projType = ""});
GetServices({this.projCode = "WXLMB", this.projType = "cp_road"});
// int tid = 1000;
// String projType = "pile_cm";
// 线
@ -114,6 +114,21 @@ class GetServices {
return res;
}
getHisFil1(String file) async {
file = file.substring(file.length - 18, file.length);
String fullUrl =
"http://192.168.1.154:8300/api/cp_road/record/data1/$projCode/$file";
Map<String, String> headers = {
// HttpHeaders.contentTypeHeader: "text/plain",
HttpHeaders.authorizationHeader:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc1JlZnJlc2giOmZhbHNlLCJpc1IiOjAsInJvbGVJZHMiOlsiMSIsIjI0Il0sInVzZXJuYW1lIjoiYWRtaW4iLCJ1c2VySWQiOjEsIlBWIjo1LCJvcmciOiJhIiwiZXhwIjoxNzI2NzE1ODE3LCJpYXQiOjE3MjU0MTk4MTd9.RZ5MpHavsF_akOZALiHo-Y3bx-f_tTp5tfgNatR-98k",
};
Response response =
await http.Client().get(Uri.parse(fullUrl), headers: headers);
var res = response.body;
return res;
}
//
getproject() async {
Map res = await service

@ -1 +1 @@
Subproject commit 30a101b8415cd162ab14f661f6f75ac7751962d3
Subproject commit 5145127697ac2f0e3c8b80ae44d49fad9da760cf