@ray-js/robot-data-stream 0.0.10-beta-4 → 0.0.10-beta-6

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.
@@ -52,7 +52,6 @@ export declare class SweeperP2p extends P2pApi {
52
52
  streamFilePath: string;
53
53
  dataFilePath: string;
54
54
  downloadType: number;
55
- useStructuredMode: boolean;
56
55
  readingMap: boolean;
57
56
  readingClean: boolean;
58
57
  readingAI: boolean;
@@ -124,7 +123,7 @@ export declare class SweeperP2p extends P2pApi {
124
123
  * @param downloadType
125
124
  * 0: 下载断开 1: 持续下载
126
125
  */
127
- startObserverSweeperDataByP2P: (downloadType: number, useStructuredMode: boolean, devId: string, onReceiveMapData: (data: string) => void, onReceivePathData: (data: string) => void, onReceiveAIPicData?: ((data: string) => void) | undefined, onReceiveAIPicHDData?: ((data: string) => void) | undefined) => Promise<void>;
126
+ startObserverSweeperDataByP2P: (downloadType: number, devId: string, onReceiveMapData: (data: string) => void, onReceivePathData: (data: string) => void, onReceiveAIPicData?: ((data: string) => void) | undefined, onReceiveAIPicHDData?: ((data: string) => void) | undefined) => Promise<void>;
128
127
  /**
129
128
  * 在下载过程中继续添加下载文件
130
129
  * @param files
@@ -50,7 +50,6 @@ export class SweeperP2p extends P2pApi {
50
50
  super();
51
51
  this.file = undefined;
52
52
  this.downloadType = 1;
53
- this.useStructuredMode = false;
54
53
  this.fileIndex = -1; // -1 表示所有文件下载完成
55
54
  this.albumName = 'ipc_sweeper_robot';
56
55
  this.cacheDir = ty.env.USER_DATA_PATH;
@@ -191,10 +190,11 @@ export class SweeperP2p extends P2pApi {
191
190
  } = data;
192
191
  if (status < 0) {
193
192
  log4js.info('receive disconnect notice ==>', status);
193
+ this.isConnected = false;
194
194
  if (!this.isConnecting) {
195
195
  this.reconnectP2p(() => {
196
196
  // 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
197
- this.startObserverSweeperDataByP2P(this.downloadType, this.useStructuredMode, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
197
+ this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
198
198
  });
199
199
  } else {
200
200
  log4js.warn('receive disconnect notice, but connectDevice is connecting');
@@ -208,7 +208,7 @@ export class SweeperP2p extends P2pApi {
208
208
  * @param downloadType
209
209
  * 0: 下载断开 1: 持续下载
210
210
  */
211
- startObserverSweeperDataByP2P = async (downloadType, useStructuredMode, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData) => {
211
+ startObserverSweeperDataByP2P = async (downloadType, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData) => {
212
212
  var _this$file$items;
213
213
  if (![0, 1].some(item => item === downloadType)) {
214
214
  log4js.warn('download type must be 0 or 1');
@@ -223,7 +223,6 @@ export class SweeperP2p extends P2pApi {
223
223
  // do nothing
224
224
  });
225
225
  log4js.info('startObserverSweeperDataByP2P ==>');
226
- this.useStructuredMode = useStructuredMode;
227
226
  this.downloadType = downloadType;
228
227
  this.setDataFilePath(devId);
229
228
  this.setStreamFilePath(devId);
@@ -291,6 +290,7 @@ export class SweeperP2p extends P2pApi {
291
290
  * 注册下载有关的监听
292
291
  */
293
292
  registerP2pDownloadEvent = () => {
293
+ log4js.info('registerP2pDownloadEvent ==>');
294
294
  if (shouldDownloadStream) {
295
295
  // p2p数据流监听
296
296
  this.offP2pStreamPacketReceive = this.onP2pStreamPacketReceive(this.p2pStreamPacketReceiveCallback);
@@ -311,8 +311,7 @@ export class SweeperP2p extends P2pApi {
311
311
  * 移除下载有关的监听
312
312
  */
313
313
  removeP2pDownloadEvent = () => {
314
- this.offFileDownloadComplete && this.offFileDownloadComplete();
315
- this.offP2pStreamPacketReceive && this.offP2pStreamPacketReceive();
314
+ log4js.info('removeP2pDownloadEvent ==>');
316
315
  if (shouldDownloadStream) {
317
316
  [...this.packetSerialNumberCacheMap.keys()].forEach(key => {
318
317
  this.packetSerialNumberCacheMap.set(key, -1);
@@ -326,6 +325,8 @@ export class SweeperP2p extends P2pApi {
326
325
  } else {
327
326
  this.cacheData = {};
328
327
  }
328
+ this.offFileDownloadComplete && this.offFileDownloadComplete();
329
+ this.offP2pStreamPacketReceive && this.offP2pStreamPacketReceive();
329
330
 
330
331
  // this.offDownLoadProgressUpdate && this.offDownLoadProgressUpdate();
331
332
  // this.offTotalDownLoadProgressUpdate && this.offTotalDownLoadProgressUpdate();
@@ -363,6 +364,7 @@ export class SweeperP2p extends P2pApi {
363
364
  let {
364
365
  fileName
365
366
  } = data;
367
+ log4js.info(`p2pStreamPacketReceiveCallback: ${fileName}, ${fileSerialNumber}, ${packetType}`);
366
368
 
367
369
  // 因为XXXX_YYYYY会被替换为坐标值,所以这里需要替换一下
368
370
 
@@ -555,10 +557,6 @@ export class SweeperP2p extends P2pApi {
555
557
  }
556
558
  }
557
559
  });
558
- // 如果是使用结构化的数据,则直接把map. 相关的文件过滤掉
559
- if (this.useStructuredMode) {
560
- return exitFiles.filter(item => item.indexOf('map.') === -1);
561
- }
562
560
  return exitFiles;
563
561
  };
564
562
 
@@ -569,7 +567,8 @@ export class SweeperP2p extends P2pApi {
569
567
  stopObserverSweeperDataByP2P = async () => {
570
568
  try {
571
569
  this.removeP2pDownloadEvent();
572
- this.cancelDownloadTask();
570
+ // 没有必要cancelDownloadTask,只需要调用断连
571
+ // this.cancelDownloadTask();
573
572
 
574
573
  // 先销毁断开监听
575
574
  typeof this.offSessionStatusChange === 'function' && this.offSessionStatusChange();
package/lib/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  declare const useP2PDataStream: (devId: string, onReceiveMapData: (data: string) => void, onReceivePathData: (data: string) => void, opt?: {
2
2
  logTag?: string | undefined;
3
- useStructuredMode?: boolean | undefined;
4
3
  onReceiveAIPicData?: ((data: string) => void) | undefined;
5
4
  onReceiveAIPicHDData?: ((data: string) => void) | undefined;
6
5
  } | undefined) => {
package/lib/index.js CHANGED
@@ -8,7 +8,6 @@ import { getSystemInfoSync, usePageEvent } from '@ray-js/ray';
8
8
  const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
9
9
  const {
10
10
  logTag,
11
- useStructuredMode = false,
12
11
  onReceiveAIPicData,
13
12
  onReceiveAIPicHDData
14
13
  } = opt || {};
@@ -54,12 +53,12 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
54
53
  SweeperP2pInstance.isConnecting = true;
55
54
  SweeperP2pInstance.connectDevice(() => {
56
55
  isInit.current = true;
57
- SweeperP2pInstance.startObserverSweeperDataByP2P(1, useStructuredMode, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData);
56
+ SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData);
58
57
  offSessionStatusChange.current = SweeperP2pInstance.onSessionStatusChange(SweeperP2pInstance.sessionStatusCallback);
59
58
  }, () => {
60
59
  SweeperP2pInstance.reconnectP2p(() => {
61
60
  isInit.current = true;
62
- SweeperP2pInstance.startObserverSweeperDataByP2P(1, useStructuredMode, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData);
61
+ SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData);
63
62
  // 这里失败重连需要注册断开重连的事件
64
63
  offSessionStatusChange.current = SweeperP2pInstance.onSessionStatusChange(SweeperP2pInstance.sessionStatusCallback);
65
64
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.10-beta-4",
3
+ "version": "0.0.10-beta-6",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [