node-red-contrib-3dm-space 1.0.5 → 1.1.0
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.
- package/3dm-cloud-config.js +115 -825
- package/3dm-cloud-out.js +1 -1
- package/3dm-config-store.js +66 -5
- package/README.md +2246 -114
- package/package.json +1 -1
package/3dm-cloud-out.js
CHANGED
|
@@ -56,7 +56,7 @@ module.exports = function (RED) {
|
|
|
56
56
|
* 60000 = 1 update per minute.
|
|
57
57
|
* This only applies to live online data when the queue is empty.
|
|
58
58
|
*/
|
|
59
|
-
var LIVE_PUBLISH_INTERVAL_MS =
|
|
59
|
+
var LIVE_PUBLISH_INTERVAL_MS = 45000;
|
|
60
60
|
|
|
61
61
|
var RATE_LIMIT_TEXT = "rate limited: slow your payloads down!";
|
|
62
62
|
var QUEUE_FULL_TEXT = "queue full: message rejected";
|
package/3dm-config-store.js
CHANGED
|
@@ -140,6 +140,34 @@ module.exports = function (RED) {
|
|
|
140
140
|
return text === "scheduler" || text === "schedule" || text === "consched" || text === "control-schedule";
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
function stableStringify(value) {
|
|
144
|
+
if (value === null || typeof value !== "object") {
|
|
145
|
+
return JSON.stringify(value);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (Array.isArray(value)) {
|
|
149
|
+
return "[" + value.map(stableStringify).join(",") + "]";
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return "{" + Object.keys(value).sort().map(function (key) {
|
|
153
|
+
return JSON.stringify(key) + ":" + stableStringify(value[key]);
|
|
154
|
+
}).join(",") + "}";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function configBlockChanged(oldBlock, newBlock) {
|
|
158
|
+
if (!oldBlock) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return stableStringify({
|
|
163
|
+
type: oldBlock.type,
|
|
164
|
+
data: oldBlock.data
|
|
165
|
+
}) !== stableStringify({
|
|
166
|
+
type: newBlock.type,
|
|
167
|
+
data: newBlock.data
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
143
171
|
function ThreeDMConfigStoreNode(config) {
|
|
144
172
|
RED.nodes.createNode(this, config);
|
|
145
173
|
|
|
@@ -239,7 +267,23 @@ module.exports = function (RED) {
|
|
|
239
267
|
return true;
|
|
240
268
|
}
|
|
241
269
|
|
|
242
|
-
return String(configName) === node.configName;
|
|
270
|
+
return String(configName).trim() === node.configName;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function getAcceptedConfigNames(configStore) {
|
|
274
|
+
var names = [];
|
|
275
|
+
|
|
276
|
+
if (!configStore || typeof configStore !== "object" || Array.isArray(configStore)) {
|
|
277
|
+
return names;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
Object.keys(configStore).forEach(function (configName) {
|
|
281
|
+
if (shouldAcceptConfigName(configName)) {
|
|
282
|
+
names.push(String(configName).trim());
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
return names;
|
|
243
287
|
}
|
|
244
288
|
|
|
245
289
|
function inferBlockType(configName, block) {
|
|
@@ -309,12 +353,19 @@ module.exports = function (RED) {
|
|
|
309
353
|
return savedNames;
|
|
310
354
|
}
|
|
311
355
|
|
|
312
|
-
Object.keys(configStore).forEach(function (
|
|
313
|
-
if (!shouldAcceptConfigName(
|
|
356
|
+
Object.keys(configStore).forEach(function (rawConfigName) {
|
|
357
|
+
if (!shouldAcceptConfigName(rawConfigName)) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
var configName = String(rawConfigName).trim();
|
|
362
|
+
var normalisedBlock = normaliseConfigBlock(configName, configStore[rawConfigName]);
|
|
363
|
+
|
|
364
|
+
if (!configBlockChanged(latestStore[configName], normalisedBlock)) {
|
|
314
365
|
return;
|
|
315
366
|
}
|
|
316
367
|
|
|
317
|
-
latestStore[configName] =
|
|
368
|
+
latestStore[configName] = normalisedBlock;
|
|
318
369
|
savedNames.push(configName);
|
|
319
370
|
});
|
|
320
371
|
|
|
@@ -846,6 +897,7 @@ module.exports = function (RED) {
|
|
|
846
897
|
var configStore = extractConfigStore(msg);
|
|
847
898
|
|
|
848
899
|
if (configStore) {
|
|
900
|
+
var matchedNames = getAcceptedConfigNames(configStore);
|
|
849
901
|
var savedNames = storeConfig(configStore);
|
|
850
902
|
|
|
851
903
|
if (savedNames.length > 0) {
|
|
@@ -856,8 +908,17 @@ module.exports = function (RED) {
|
|
|
856
908
|
}
|
|
857
909
|
|
|
858
910
|
runConfigStore(false, true);
|
|
911
|
+
} else if (matchedNames.length > 0) {
|
|
912
|
+
setStatus("blue", "ring", "config unchanged: " + matchedNames.join(", "));
|
|
859
913
|
} else {
|
|
860
|
-
setStatus(
|
|
914
|
+
setStatus(
|
|
915
|
+
"yellow",
|
|
916
|
+
"ring",
|
|
917
|
+
"configStore ignored - looking for " +
|
|
918
|
+
(node.configName || "all") +
|
|
919
|
+
", received " +
|
|
920
|
+
Object.keys(configStore).join(", ")
|
|
921
|
+
);
|
|
861
922
|
}
|
|
862
923
|
|
|
863
924
|
if (done) {
|