@ray-js/lamp-schedule-core 1.0.1-beta-5 → 1.0.1-beta-7
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,7 +1,13 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
3
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
3
|
-
import { publishDps,
|
|
4
|
+
import { publishDps, publishGroupDps } from '@ray-js/ray';
|
|
4
5
|
import { scheduleLogger as ScheduleLogger } from '../utils/ScheduleLogger';
|
|
6
|
+
const DEFAULT_OPTIONS = {
|
|
7
|
+
mode: 2,
|
|
8
|
+
options: {},
|
|
9
|
+
pipelines: []
|
|
10
|
+
};
|
|
5
11
|
export const updateDeviceDp = (devId, groupId, dps) => {
|
|
6
12
|
if (Object.keys(dps).length === 0) {
|
|
7
13
|
ScheduleLogger.warn('updateDeviceDp', 'dps is empty');
|
|
@@ -12,30 +18,26 @@ export const updateDeviceDp = (devId, groupId, dps) => {
|
|
|
12
18
|
return;
|
|
13
19
|
}
|
|
14
20
|
if (groupId) {
|
|
15
|
-
|
|
21
|
+
publishGroupDps(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), {}, {
|
|
16
22
|
groupId,
|
|
17
23
|
dpCodes: dps,
|
|
18
24
|
success: () => {
|
|
19
|
-
ScheduleLogger.debug('
|
|
25
|
+
ScheduleLogger.debug('publishGroupDps dp success', dps);
|
|
20
26
|
},
|
|
21
27
|
fail: err => {
|
|
22
|
-
ScheduleLogger.error('
|
|
28
|
+
ScheduleLogger.error('publishGroupDps dp fail', err);
|
|
23
29
|
}
|
|
24
|
-
});
|
|
30
|
+
}));
|
|
25
31
|
return;
|
|
26
32
|
}
|
|
27
33
|
ScheduleLogger.debug('updateDeviceDp publishDps dps:', dps);
|
|
28
|
-
publishDps({
|
|
34
|
+
publishDps(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), {}, {
|
|
29
35
|
deviceId: devId,
|
|
30
|
-
dps,
|
|
31
|
-
mode: 2,
|
|
32
|
-
pipelines: [0, 1, 2, 3, 4, 5, 6],
|
|
33
|
-
options: {},
|
|
34
36
|
success: () => {
|
|
35
37
|
ScheduleLogger.debug('publishDps dp success', dps);
|
|
36
38
|
},
|
|
37
39
|
fail: err => {
|
|
38
40
|
ScheduleLogger.error('publishDps dp fail', err);
|
|
39
41
|
}
|
|
40
|
-
});
|
|
42
|
+
}));
|
|
41
43
|
};
|
|
@@ -31,7 +31,7 @@ export function useBaseLightDp(dpCode, defaultDpValue) {
|
|
|
31
31
|
if (+dpCode !== +dpCode) {
|
|
32
32
|
dpId = getDpIdByDpCode(dpCode);
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
34
|
+
if (dpId in dpData.dps) {
|
|
35
35
|
scheduleLogger.debug(`${dpCode} ==> emitter will changed:`, dpData);
|
|
36
36
|
const _dpValue = dpData.dps[dpId];
|
|
37
37
|
if (isEqual(preDpValue.current, _dpValue)) {
|
|
@@ -105,13 +105,18 @@ export const getDpDataByMesh = function () {
|
|
|
105
105
|
if (dpCodes.length >= 5) {
|
|
106
106
|
scheduleLogger.warn('getDpDataByMesh: 单次查询 dp 数过多,dp 可能响应不及时,请分次查询');
|
|
107
107
|
}
|
|
108
|
-
scheduleLogger.debug('getDpDataByMesh 开始查询DP参数 dpCodes:', dpCodes);
|
|
109
108
|
const deviceData = devIdOrGroupIdCache.get();
|
|
110
109
|
const deviceId = deviceData === null || deviceData === void 0 ? void 0 : deviceData.devId;
|
|
110
|
+
const groupId = deviceData === null || deviceData === void 0 ? void 0 : deviceData.groupId;
|
|
111
|
+
if (groupId) {
|
|
112
|
+
scheduleLogger.error('getDpDataByMesh: 群组中不支持查询dp');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
111
115
|
if (!deviceId) {
|
|
112
116
|
scheduleLogger.error('getDpDataByMesh: 未能获取到deviceId');
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
119
|
+
scheduleLogger.debug('getDpDataByMesh 开始查询DP参数 dpCodes:', dpCodes);
|
|
115
120
|
const dpIds = dpCodes.map(item => getDpIdByDpCode(item)).filter(i => !!i).map(String); // 简化字符串转换
|
|
116
121
|
|
|
117
122
|
if (dpIds.length === 0) {
|
|
@@ -92,7 +92,7 @@ export const useScheduleInit = props => {
|
|
|
92
92
|
}
|
|
93
93
|
ScheduleLogger.info(`useScheduleInit ${DP_CHANGE_EVENT_KEY}`, res);
|
|
94
94
|
emitter.emit(DP_CHANGE_EVENT_KEY, {
|
|
95
|
-
deviceId: res.devId || res.deviceId,
|
|
95
|
+
deviceId: res.devId || res.deviceId || res.groupId,
|
|
96
96
|
dps: res === null || res === void 0 ? void 0 : res.dps
|
|
97
97
|
});
|
|
98
98
|
});
|
|
@@ -103,7 +103,13 @@ export class Support {
|
|
|
103
103
|
setScheduleCache(DEV_INFO_KEY, res);
|
|
104
104
|
// 群组中为空
|
|
105
105
|
groupId && (devIdOrGroupIdCache === null || devIdOrGroupIdCache === void 0 ? void 0 : devIdOrGroupIdCache.set('', groupId));
|
|
106
|
-
|
|
106
|
+
const dpMap = {};
|
|
107
|
+
Object.keys(res.dps).forEach(dpId => {
|
|
108
|
+
const dpCode = getDpCodeByDpId(dpId);
|
|
109
|
+
dpCode && setDpState(dpCode, res.dps[dpId]);
|
|
110
|
+
});
|
|
111
|
+
Object.keys(dpMap).length && initDpState(dpMap);
|
|
112
|
+
resolve(res);
|
|
107
113
|
},
|
|
108
114
|
fail: err => {
|
|
109
115
|
this.groupDevInfo = {};
|