@ray-js/ipc-player-integration 0.0.45-beta.1 → 0.0.45-beta.2
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.
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { useDpState } from '../useDpState';
|
|
3
|
-
import { IPC_WATER_TEMPERATURE } from '../../utils/content/dpCode';
|
|
3
|
+
import { TEMP_UNIT_SELECT, IPC_WATER_TEMPERATURE, IPC_WATER_TEMPERATURE_F } from '../../utils/content/dpCode';
|
|
4
4
|
import { showMathPowValue } from '../../utils/device';
|
|
5
5
|
export const useWaterTemperature = devId => {
|
|
6
|
-
const [
|
|
6
|
+
const [tempUnit, setTempUnit] = useState('');
|
|
7
|
+
const [waterTempC, setWaterTempC] = useState('');
|
|
8
|
+
const [waterTempF, setWaterTempF] = useState('');
|
|
7
9
|
const [dpState, schemaObj] = useDpState({
|
|
8
10
|
devId,
|
|
9
|
-
dpCodes: [IPC_WATER_TEMPERATURE]
|
|
11
|
+
dpCodes: [TEMP_UNIT_SELECT, IPC_WATER_TEMPERATURE, IPC_WATER_TEMPERATURE_F]
|
|
10
12
|
});
|
|
11
13
|
useEffect(() => {
|
|
12
|
-
|
|
13
|
-
if (dpState[
|
|
14
|
-
|
|
15
|
-
return;
|
|
14
|
+
// 1=华氏度 0=摄氏度
|
|
15
|
+
if (dpState[TEMP_UNIT_SELECT] !== undefined) {
|
|
16
|
+
setTempUnit(dpState[TEMP_UNIT_SELECT] + '');
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
if (dpState[IPC_WATER_TEMPERATURE] !== undefined) {
|
|
19
|
+
var _schema$property;
|
|
20
|
+
const schema = schemaObj && schemaObj[IPC_WATER_TEMPERATURE];
|
|
21
|
+
const scale = (schema === null || schema === void 0 || (_schema$property = schema.property) === null || _schema$property === void 0 ? void 0 : _schema$property.scale) || 0;
|
|
22
|
+
const value = showMathPowValue(dpState[IPC_WATER_TEMPERATURE], scale);
|
|
23
|
+
setWaterTempC(value + '°C');
|
|
24
|
+
}
|
|
25
|
+
if (dpState[IPC_WATER_TEMPERATURE_F] !== undefined) {
|
|
26
|
+
var _schema$property2;
|
|
27
|
+
const schema = schemaObj && schemaObj[IPC_WATER_TEMPERATURE_F];
|
|
28
|
+
const scale = (schema === null || schema === void 0 || (_schema$property2 = schema.property) === null || _schema$property2 === void 0 ? void 0 : _schema$property2.scale) || 0;
|
|
29
|
+
const value = showMathPowValue(dpState[IPC_WATER_TEMPERATURE_F], scale);
|
|
30
|
+
setWaterTempF(value + '°F');
|
|
31
|
+
}
|
|
32
|
+
}, [dpState]);
|
|
33
|
+
return {
|
|
34
|
+
tempUnit,
|
|
35
|
+
waterTempC,
|
|
36
|
+
waterTempF
|
|
37
|
+
};
|
|
23
38
|
};
|
|
@@ -4,6 +4,7 @@ export declare const SENSOR_TEMPERATURE = "sensor_temperature";
|
|
|
4
4
|
export declare const SENSOR_HUMIDITY = "sensor_humidity";
|
|
5
5
|
export declare const IPC_EC = "ipc_ec";
|
|
6
6
|
export declare const IPC_WATER_TEMPERATURE = "ipc_water_temperature";
|
|
7
|
+
export declare const IPC_WATER_TEMPERATURE_F = "ipc_water_temperature_f";
|
|
7
8
|
export declare const PTZ_CONTROL = "ptz_control";
|
|
8
9
|
export declare const GUN_BALL = "ipc_multi_locate_coor";
|
|
9
10
|
export declare const ZOOM_CONTROL = "zoom_control";
|
|
@@ -8,7 +8,9 @@ export const SENSOR_HUMIDITY = 'sensor_humidity'; // 湿度
|
|
|
8
8
|
|
|
9
9
|
export const IPC_EC = 'ipc_ec'; // EC 值(电导率)
|
|
10
10
|
|
|
11
|
-
export const IPC_WATER_TEMPERATURE = 'ipc_water_temperature'; //
|
|
11
|
+
export const IPC_WATER_TEMPERATURE = 'ipc_water_temperature'; // 水温(摄氏度)
|
|
12
|
+
|
|
13
|
+
export const IPC_WATER_TEMPERATURE_F = 'ipc_water_temperature_f'; // 水温(华氏度)
|
|
12
14
|
|
|
13
15
|
export const PTZ_CONTROL = 'ptz_control'; // ptz
|
|
14
16
|
|
|
@@ -19,7 +19,10 @@ export const TempHumidity = props => {
|
|
|
19
19
|
} = useTemperature(devId);
|
|
20
20
|
const humidity = useHumidity(devId);
|
|
21
21
|
const ec = useEc(devId);
|
|
22
|
-
const
|
|
22
|
+
const {
|
|
23
|
+
waterTempC,
|
|
24
|
+
waterTempF
|
|
25
|
+
} = useWaterTemperature(devId);
|
|
23
26
|
// 稳定 dpCodes 引用,避免每次渲染都生成新数组导致 useDpSupport 内 getDeviceInfo 被反复触发
|
|
24
27
|
const dpCodes = useMemo(() => [...DP_CODES], []);
|
|
25
28
|
const dpSupport = useDpSupport({
|
|
@@ -51,14 +54,15 @@ export const TempHumidity = props => {
|
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
if (dpSupport[IPC_WATER_TEMPERATURE]) {
|
|
57
|
+
const waterTempText = tempUnit === '1' && waterTempF ? waterTempF : waterTempC || '--';
|
|
54
58
|
list.push({
|
|
55
59
|
key: 'waterTemp',
|
|
56
60
|
iconClass: 'icon-panel-lvye1',
|
|
57
|
-
text:
|
|
61
|
+
text: waterTempText
|
|
58
62
|
});
|
|
59
63
|
}
|
|
60
64
|
return list;
|
|
61
|
-
}, [dpSupport, ec, tempUnit, tempF, tempC, humidity,
|
|
65
|
+
}, [dpSupport, ec, tempUnit, tempF, tempC, humidity, waterTempC, waterTempF]);
|
|
62
66
|
if (!items.length) {
|
|
63
67
|
return null;
|
|
64
68
|
}
|