@ray-js/robot-data-stream 0.0.10-beta-2 → 0.0.10-beta-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/sweeperP2p.d.ts +1 -0
- package/lib/api/sweeperP2p.js +12 -4
- package/package.json +1 -1
package/lib/api/sweeperP2p.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export declare class SweeperP2p extends P2pApi {
|
|
|
64
64
|
packetDataCacheMap: Map<keyof typeof FILE_NAME_MAP, Map<number, string>>;
|
|
65
65
|
packetSerialNumberCacheMap: Map<keyof typeof FILE_NAME_MAP, number>;
|
|
66
66
|
packetTotalMap: Map<keyof typeof FILE_NAME_MAP, number>;
|
|
67
|
+
firstPackageTime: number;
|
|
67
68
|
onReceiveMapData: (data: string) => void;
|
|
68
69
|
onReceivePathData: (data: string) => void;
|
|
69
70
|
onReceiveAIPicData: (data: string) => void;
|
package/lib/api/sweeperP2p.js
CHANGED
|
@@ -58,6 +58,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
58
58
|
this.readingClean = false;
|
|
59
59
|
this.cacheData = {};
|
|
60
60
|
this.exitFiles = [];
|
|
61
|
+
this.firstPackageTime = Date.now();
|
|
61
62
|
this.packetTotalMap = new Map([['map.bin', -1], ['map_structured.bin', -1], ['cleanPath.bin', -1], ['ai.bin', -1], ['aiHD_XXXX_YYYY.bin', -1], ['map.bin.stream', -1], ['map_structured.bin.stream', -1], ['cleanPath.bin.stream', -1], ['ai.bin.stream', -1], ['aiHD_XXXX_YYYY.bin.stream', -1]]);
|
|
62
63
|
this.packetSerialNumberCacheMap = new Map([['map.bin', -1], ['map_structured.bin', -1], ['cleanPath.bin', -1], ['ai.bin', -1], ['aiHD_XXXX_YYYY.bin', -1], ['map.bin.stream', -1], ['map_structured.bin.stream', -1], ['cleanPath.bin.stream', -1], ['ai.bin.stream', -1], ['aiHD_XXXX_YYYY.bin.stream', -1]]);
|
|
63
64
|
this.packetDataCacheMap = new Map([['map.bin', new Map()], ['map_structured.bin', new Map()], ['cleanPath.bin', new Map()], ['ai.bin', new Map()], ['aiHD_XXXX_YYYY.bin', new Map()], ['map.bin.stream', new Map()], ['map_structured.bin.stream', new Map()], ['cleanPath.bin.stream', new Map()], ['ai.bin.stream', new Map()], ['aiHD_XXXX_YYYY.bin.stream', new Map()]]);
|
|
@@ -241,14 +242,15 @@ export class SweeperP2p extends P2pApi {
|
|
|
241
242
|
if (exitFiles.length > 0) {
|
|
242
243
|
if (shouldDownloadStream) {
|
|
243
244
|
// 开启p2p流传输
|
|
244
|
-
this.downloadStream({
|
|
245
|
+
await this.downloadStream({
|
|
245
246
|
files: exitFiles
|
|
246
247
|
}, this.albumName);
|
|
247
248
|
} else if (await this.initFilePath(this.dataFilePath)) {
|
|
248
|
-
this.downloadFile({
|
|
249
|
+
await this.downloadFile({
|
|
249
250
|
files: exitFiles
|
|
250
251
|
}, this.albumName, this.dataFilePath);
|
|
251
252
|
}
|
|
253
|
+
this.firstPackageTime = Date.now();
|
|
252
254
|
}
|
|
253
255
|
} else if (this.downloadType === 1) {
|
|
254
256
|
const exitFiles = this.queryNeedFiles(this.file.items);
|
|
@@ -257,15 +259,16 @@ export class SweeperP2p extends P2pApi {
|
|
|
257
259
|
if (exitFiles.length > 0) {
|
|
258
260
|
if (shouldDownloadStream) {
|
|
259
261
|
// 开启p2p流传输
|
|
260
|
-
this.downloadStream({
|
|
262
|
+
await this.downloadStream({
|
|
261
263
|
files: exitFiles
|
|
262
264
|
}, this.albumName);
|
|
263
265
|
} else if (await this.initFilePath(this.streamFilePath)) {
|
|
264
266
|
// 每次要下载前都需要先检查文件目录是否存在 防止中间过程被删除掉文件目录
|
|
265
|
-
this.downloadFile({
|
|
267
|
+
await this.downloadFile({
|
|
266
268
|
files: exitFiles
|
|
267
269
|
}, this.albumName, this.streamFilePath);
|
|
268
270
|
}
|
|
271
|
+
this.firstPackageTime = Date.now();
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
274
|
}
|
|
@@ -401,6 +404,11 @@ export class SweeperP2p extends P2pApi {
|
|
|
401
404
|
let [index, data] = _ref;
|
|
402
405
|
return data;
|
|
403
406
|
}).join('');
|
|
407
|
+
if (this.firstPackageTime > 0) {
|
|
408
|
+
const packageTime = Date.now() - this.firstPackageTime;
|
|
409
|
+
log4js.info(`receive first full package, cost time: ${packageTime} ms, fileName: ${fileName}, data: ${hexValue}`);
|
|
410
|
+
this.firstPackageTime = 0;
|
|
411
|
+
}
|
|
404
412
|
const {
|
|
405
413
|
type
|
|
406
414
|
} = FILE_NAME_MAP[fileName];
|