@rfkit/charts 1.0.95 → 1.0.97

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.
@@ -3,8 +3,12 @@ import type { SelectedSignal } from '../../types';
3
3
  interface UseTemplateComparisonProps {
4
4
  frequencyFormat: RefObject<(x: number) => string>;
5
5
  onChange: RefObject<(e: SelectedSignal) => void>;
6
+ globalID: string;
6
7
  }
7
8
  interface ExceedingSegment {
9
+ maxValue: number;
10
+ minValue: number;
11
+ avgValue: number;
8
12
  startFrequency: number;
9
13
  stopFrequency: number;
10
14
  centerFrequency: number;
@@ -15,7 +19,7 @@ interface ExceedingSegment {
15
19
  * 模板数据比较 Hook
16
20
  * 用于检测数据是否超出模板阈值,并输出相关信息
17
21
  */
18
- export default function useTemplateComparison({ frequencyFormat, onChange, }: UseTemplateComparisonProps): {
22
+ export default function useTemplateComparison({ frequencyFormat, onChange, globalID, }: UseTemplateComparisonProps): {
19
23
  findExceedingSegments: (dataArray: Float32Array, templateArray: Float32Array, timestamp: number) => ExceedingSegment[];
20
24
  processExceedingData: (data: Float32Array, templateData: Float32Array, timestamp: number) => void;
21
25
  };
package/index.js CHANGED
@@ -13265,7 +13265,13 @@ function useSeries() {
13265
13265
  resetSeries
13266
13266
  };
13267
13267
  }
13268
- function useTemplateComparison({ frequencyFormat, onChange }) {
13268
+ function useTemplateComparison({ frequencyFormat, onChange, globalID }) {
13269
+ const globalIDRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(globalID);
13270
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
13271
+ globalIDRef.current = globalID;
13272
+ }, [
13273
+ globalID
13274
+ ]);
13269
13275
  const findExceedingSegments = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((dataArray, templateArray, timestamp)=>{
13270
13276
  const length = templateArray.length;
13271
13277
  if (!length || dataArray.length !== length) return [];
@@ -13278,11 +13284,20 @@ function useTemplateComparison({ frequencyFormat, onChange }) {
13278
13284
  const startFreq = frequencyFormat.current(startPercent);
13279
13285
  const stopFreq = frequencyFormat.current(endPercent);
13280
13286
  const centerFreq = frequencyFormat.current(centerPercent);
13287
+ const db = withDatabase(globalIDRef.current);
13288
+ const rawData = db.getAllRawData();
13289
+ const centerIndex = Math.floor((start + end) / 2);
13290
+ const maxValue = rawData.maxData[centerIndex] || 0;
13291
+ const minValue = rawData.minData[centerIndex] || 0;
13292
+ const avgValue = rawData.avgData[centerIndex] || 0;
13281
13293
  return {
13282
13294
  startFrequency: startFreq,
13283
13295
  stopFrequency: stopFreq,
13284
13296
  centerFrequency: centerFreq,
13285
13297
  bandwidth: (stopFreq - startFreq) * 1000,
13298
+ maxValue,
13299
+ minValue,
13300
+ avgValue,
13286
13301
  timestamp
13287
13302
  };
13288
13303
  };
@@ -13332,7 +13347,8 @@ function useSpectrumAnalyzer(props) {
13332
13347
  ]);
13333
13348
  const { processExceedingData } = useTemplateComparison({
13334
13349
  frequencyFormat: frequencyFormatRef,
13335
- onChange: onChangeRef
13350
+ onChange: onChangeRef,
13351
+ globalID
13336
13352
  });
13337
13353
  const getExtraData = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((data)=>{
13338
13354
  const len = srcIndexCache.current?.length;
@@ -13486,7 +13502,7 @@ function useSpectrumAnalyzer(props) {
13486
13502
  data: getExtraData(occupancyData.current),
13487
13503
  totalOccupancy: totalOccupancyData.current
13488
13504
  });
13489
- if (templateData.current && templateData.current.length > 0) updateSpectrum({
13505
+ if (templateData.current?.length > 0) updateSpectrum({
13490
13506
  template: getExtraData(templateData.current)
13491
13507
  });
13492
13508
  }
@@ -13530,7 +13546,7 @@ function useSpectrumAnalyzer(props) {
13530
13546
  if (e.extraData) updateExtraData(e.extraData);
13531
13547
  if (e.data) {
13532
13548
  analyzer.current.process(e);
13533
- if (templateData.current.length > 0) processExceedingData(e.data, templateData.current, e.timestamp);
13549
+ if (templateData.current?.length > 0) processExceedingData(e.data, templateData.current, e.timestamp);
13534
13550
  }
13535
13551
  if (e.maxData) analyzer.current.setMaxData(e.maxData);
13536
13552
  if (e.template) updateTemplateData(e.template);
package/package.json CHANGED
@@ -5,6 +5,6 @@
5
5
  "types": "index.d.ts",
6
6
  "author": "Hxgh",
7
7
  "license": "MIT",
8
- "version": "1.0.95",
8
+ "version": "1.0.97",
9
9
  "private": false
10
10
  }