@ray-js/lamp-schedule-core 1.0.0 → 1.0.1-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.
|
@@ -237,7 +237,7 @@ function mergeListByOtherId(list) {
|
|
|
237
237
|
return Object.values(mergedData);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
//
|
|
240
|
+
// 冲突检测核心函数
|
|
241
241
|
export function checkConflicts(scheduleList, currentSchedule) {
|
|
242
242
|
let rule = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultRule;
|
|
243
243
|
const currentRanges = convertToTimeRanges([currentSchedule]);
|
|
@@ -260,6 +260,11 @@ export function checkConflicts(scheduleList, currentSchedule) {
|
|
|
260
260
|
const currentPreId = current === null || current === void 0 || (_current$originalSche = current.originalSchedule) === null || _current$originalSche === void 0 ? void 0 : _current$originalSche.prevId;
|
|
261
261
|
const currentId = current === null || current === void 0 || (_current$originalSche2 = current.originalSchedule) === null || _current$originalSche2 === void 0 ? void 0 : _current$originalSche2.id;
|
|
262
262
|
const otherId = other.id;
|
|
263
|
+
// 针对定时,如果当前定时自身修改 且 与自身冲突 则忽略
|
|
264
|
+
if (currentPreId && currentId === currentPreId && current.type === 'timer') {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
// FIXME:还是存在bug
|
|
263
268
|
// 如果当前定时自身修改 且 与自身冲突 并且其他定时不等于当前定时id 则忽略
|
|
264
269
|
if (currentPreId && currentId === currentPreId && otherId !== currentId) {
|
|
265
270
|
return;
|
|
@@ -23,10 +23,15 @@ export const timerDataToSchedule = data => {
|
|
|
23
23
|
status: (_data$status = data.status) !== null && _data$status !== void 0 ? _data$status : false,
|
|
24
24
|
weeks: data.loops.split('').map(item => Number(item)),
|
|
25
25
|
startTime: data.time,
|
|
26
|
-
endTime: data.time
|
|
26
|
+
endTime: data.time,
|
|
27
|
+
dps: data.dps,
|
|
28
|
+
aliasName: data.aliasName || '',
|
|
29
|
+
isAppPush: data.isAppPush || false,
|
|
30
|
+
id: (data === null || data === void 0 ? void 0 : data.id) || data.timerId
|
|
27
31
|
};
|
|
32
|
+
const timerId = `${EScheduleFunctionType.TIMER}_${_data.id}`;
|
|
28
33
|
return {
|
|
29
|
-
id: objectToId(_data, `${EScheduleFunctionType.TIMER}_`),
|
|
34
|
+
id: timerId || objectToId(_data, `${EScheduleFunctionType.TIMER}_`),
|
|
30
35
|
type: EScheduleFunctionType.TIMER,
|
|
31
36
|
data: _data
|
|
32
37
|
};
|
package/lib/dpParser/rtcTimer.js
CHANGED
|
@@ -31,6 +31,8 @@ var EDpCodes = /*#__PURE__*/function (EDpCodes) {
|
|
|
31
31
|
EDpCodes["colour_data"] = "colour_data";
|
|
32
32
|
EDpCodes["temp_value"] = "temp_value";
|
|
33
33
|
EDpCodes["switch_led"] = "switch_led";
|
|
34
|
+
EDpCodes["bright_value1"] = "bright_value1";
|
|
35
|
+
EDpCodes["temp_value1"] = "temp_value1";
|
|
34
36
|
return EDpCodes;
|
|
35
37
|
}(EDpCodes || {});
|
|
36
38
|
export class RtcTimerFormatter {
|
|
@@ -94,7 +96,7 @@ export class RtcTimerFormatter {
|
|
|
94
96
|
A=0x06,节能,
|
|
95
97
|
A=0x07,太阳能
|
|
96
98
|
*/
|
|
97
|
-
step(2).value;
|
|
99
|
+
const dataType = step(2).value;
|
|
98
100
|
let dps = {}; // 设备动作
|
|
99
101
|
// 白光模式 dp
|
|
100
102
|
if (length === brightLightLen) {
|
|
@@ -105,17 +107,31 @@ export class RtcTimerFormatter {
|
|
|
105
107
|
[EDpCodes.temp_value]: temp_value
|
|
106
108
|
};
|
|
107
109
|
} else if (length === colourLightLen) {
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
// 混光 混白光
|
|
111
|
+
if (dataType === 9) {
|
|
112
|
+
const bright_value = step(2).value;
|
|
113
|
+
const temp_value = step(2).value;
|
|
114
|
+
const bright_value1 = step(2).value;
|
|
115
|
+
const temp_value1 = step(2).value;
|
|
116
|
+
dps = {
|
|
117
|
+
[EDpCodes.bright_value]: bright_value,
|
|
118
|
+
[EDpCodes.temp_value]: temp_value,
|
|
119
|
+
[EDpCodes.bright_value1]: bright_value1,
|
|
120
|
+
[EDpCodes.temp_value1]: temp_value1
|
|
121
|
+
};
|
|
122
|
+
} else {
|
|
123
|
+
// 彩光模式dp
|
|
124
|
+
const hue = step(4).value;
|
|
125
|
+
const saturation = step(2).value;
|
|
126
|
+
const _value = step(2).value;
|
|
127
|
+
dps = {
|
|
128
|
+
[EDpCodes.colour_data]: {
|
|
129
|
+
hue,
|
|
130
|
+
saturation,
|
|
131
|
+
value: _value
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
119
135
|
} else if (length === mixLightLen) {
|
|
120
136
|
// 混光模式
|
|
121
137
|
const hue = step(4).value;
|
|
@@ -250,10 +266,21 @@ export class RtcTimerFormatter {
|
|
|
250
266
|
const saturationStr = this.to16(saturation, 2);
|
|
251
267
|
const valueStr = this.to16(value, 2);
|
|
252
268
|
dpDataStr = `03${hueStr}${saturationStr}${valueStr}`;
|
|
253
|
-
} else if (Object.keys(_dps).includes(EDpCodes.bright_value)) {
|
|
254
|
-
var _dps$EDpCodes$bright_, _dps$EDpCodes$temp_va2;
|
|
269
|
+
} else if (Object.keys(_dps).includes(EDpCodes.bright_value) && Object.keys(_dps).includes(EDpCodes.bright_value1)) {
|
|
270
|
+
var _dps$EDpCodes$bright_, _dps$EDpCodes$temp_va2, _dps$EDpCodes$bright_2, _dps$EDpCodes$temp_va3;
|
|
255
271
|
const bright_value = (_dps$EDpCodes$bright_ = _dps[EDpCodes.bright_value]) !== null && _dps$EDpCodes$bright_ !== void 0 ? _dps$EDpCodes$bright_ : 100;
|
|
256
272
|
const temp_value = (_dps$EDpCodes$temp_va2 = _dps[EDpCodes.temp_value]) !== null && _dps$EDpCodes$temp_va2 !== void 0 ? _dps$EDpCodes$temp_va2 : 0;
|
|
273
|
+
const bright_value1 = (_dps$EDpCodes$bright_2 = _dps[EDpCodes.bright_value1]) !== null && _dps$EDpCodes$bright_2 !== void 0 ? _dps$EDpCodes$bright_2 : 100;
|
|
274
|
+
const temp_value1 = (_dps$EDpCodes$temp_va3 = _dps[EDpCodes.temp_value1]) !== null && _dps$EDpCodes$temp_va3 !== void 0 ? _dps$EDpCodes$temp_va3 : 0;
|
|
275
|
+
const brightStr = this.to16(bright_value, 2);
|
|
276
|
+
const temperatureStr = this.to16(temp_value, 2);
|
|
277
|
+
const brightStr1 = this.to16(bright_value1, 2);
|
|
278
|
+
const temperatureStr1 = this.to16(temp_value1, 2);
|
|
279
|
+
dpDataStr = `09${brightStr}${temperatureStr}${brightStr1}${temperatureStr1}`;
|
|
280
|
+
} else if (Object.keys(_dps).includes(EDpCodes.bright_value)) {
|
|
281
|
+
var _dps$EDpCodes$bright_3, _dps$EDpCodes$temp_va4;
|
|
282
|
+
const bright_value = (_dps$EDpCodes$bright_3 = _dps[EDpCodes.bright_value]) !== null && _dps$EDpCodes$bright_3 !== void 0 ? _dps$EDpCodes$bright_3 : 100;
|
|
283
|
+
const temp_value = (_dps$EDpCodes$temp_va4 = _dps[EDpCodes.temp_value]) !== null && _dps$EDpCodes$temp_va4 !== void 0 ? _dps$EDpCodes$temp_va4 : 0;
|
|
257
284
|
const brightStr = this.to16(bright_value, 2);
|
|
258
285
|
const temperatureStr = this.to16(temp_value, 2);
|
|
259
286
|
dpDataStr = `02${brightStr}${temperatureStr}`;
|
package/lib/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export { useWakeUpDp } from './hooks/useWakeUpDp';
|
|
|
19
19
|
export { useRandomDp } from './hooks/useRandomDp';
|
|
20
20
|
export { useCycleDp } from './hooks/useCycleDp';
|
|
21
21
|
export { useWakeUpSupport } from './hooks/useWakeUpSupport';
|
|
22
|
-
export { useBaseLightDp, useFetchDpDataByMesh, getDpDataByMesh, useFetchDpData } from './hooks/useBaseLightDp';
|
|
22
|
+
export { useBaseLightDp, useFetchDpDataByMesh, getDpDataByMesh, useFetchDpData, } from './hooks/useBaseLightDp';
|
|
23
23
|
export { useTimerReportDp, useTimerReportDpPull } from './hooks/useTimerReportDp';
|
|
24
24
|
/** Conflict 冲突判断 */
|
|
25
25
|
export { transScheduleListToConflictList } from './conflict/transform';
|
package/lib/types/timer.d.ts
CHANGED
package/lib/utils/objectToId.js
CHANGED
|
@@ -24,7 +24,9 @@ export const objectToId = function (obj) {
|
|
|
24
24
|
// 简单哈希算法
|
|
25
25
|
let hash = 5381;
|
|
26
26
|
for (let i = 0; i < str.length; i++) {
|
|
27
|
+
// eslint-disable-next-line no-bitwise
|
|
27
28
|
hash = (hash << 5) + hash + str.charCodeAt(i);
|
|
29
|
+
// eslint-disable-next-line operator-assignment, no-bitwise
|
|
28
30
|
hash = hash & hash; // 转换为32位整数
|
|
29
31
|
}
|
|
30
32
|
|