node-red-contrib-hik-media-buffer 1.1.96 → 1.1.98
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/hik-media-buffer.js +11 -7
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -119,13 +119,13 @@ module.exports = function(RED) {
|
|
|
119
119
|
const timestamp = Math.floor(referenceTime.getTime() / 1000);
|
|
120
120
|
|
|
121
121
|
// Nuova finestra temporale larga: cerca da 10 minuti fa a 2 minuti nel futuro per compensare i disallineamenti di orario
|
|
122
|
-
const startTime = toJsonDate(new Date(referenceTime.getTime() - (10 *
|
|
123
|
-
const endTime = toJsonDate(new Date(referenceTime.getTime() + (
|
|
122
|
+
const startTime = toJsonDate(new Date(referenceTime.getTime() - (10 * 1000)));
|
|
123
|
+
const endTime = toJsonDate(new Date(referenceTime.getTime() + (10 * 1000)));
|
|
124
124
|
|
|
125
125
|
node.status({fill:"yellow", shape:"dot", text:`Ricerca Evento Cam ${channelID}...`});
|
|
126
126
|
|
|
127
127
|
// Aspettiamo 3 secondi per dare tempo all'NVR di indicizzare l'evento sul log
|
|
128
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
128
|
+
await new Promise(resolve => setTimeout(resolve, 6000));
|
|
129
129
|
|
|
130
130
|
let output = {
|
|
131
131
|
tipo_messaggio: "evento", nome_cliente: node.name, nome_telecamera: nomeCamera,
|
|
@@ -136,21 +136,25 @@ module.exports = function(RED) {
|
|
|
136
136
|
let fileDaCancellare = [];
|
|
137
137
|
|
|
138
138
|
try {
|
|
139
|
-
//
|
|
139
|
+
// Ripristiniamo il SearchID dinamico
|
|
140
140
|
const dynamicSearchId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
141
141
|
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
142
142
|
return v.toString(16).toUpperCase();
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
-
//
|
|
145
|
+
// Ricostruiamo il JSON IDENTICO a quello intercettato su Chrome che funzionava
|
|
146
146
|
const searchPayload = {
|
|
147
147
|
"EventSearchDescription": {
|
|
148
148
|
"searchID": dynamicSearchId,
|
|
149
149
|
"searchResultPosition": 0,
|
|
150
|
-
"maxResults":
|
|
150
|
+
"maxResults": 30,
|
|
151
151
|
"timeSpanList": [{ "startTime": startTime, "endTime": endTime }],
|
|
152
152
|
"type": "all",
|
|
153
|
-
"channels": [ parseInt(channelID
|
|
153
|
+
"channels": [ parseInt(channelID) ], // Ritorniamo al canale puro (es. 2)
|
|
154
|
+
"eventType": "behavior",
|
|
155
|
+
"behavior": {
|
|
156
|
+
"behaviorEventType": evento.toLowerCase() // Spara "linedetection" o "fielddetection"
|
|
157
|
+
}
|
|
154
158
|
}
|
|
155
159
|
};
|
|
156
160
|
const tempJsonPath = path.join(baseStorage, `search_${channelID}_${timestamp}.json`);
|