node-red-contrib-hik-media-buffer 1.1.95 → 1.1.97

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.
@@ -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 * 60 * 1000)));
123
- const endTime = toJsonDate(new Date(referenceTime.getTime() + (2 * 60 * 1000)));
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, 3000));
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,7 +136,13 @@ module.exports = function(RED) {
136
136
  let fileDaCancellare = [];
137
137
 
138
138
  try {
139
- // Proviamo a passare il canale sia come stringa che come ID esteso per vedere quale digerisce il database
139
+ // Generiamo il SearchID dinamico per evitare il crash di prima
140
+ const dynamicSearchId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
141
+ var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
142
+ return v.toString(16).toUpperCase();
143
+ });
144
+
145
+ // Usiamo l'ID della traccia video reale (es. 201 per il canale 2)
140
146
  const searchPayload = {
141
147
  "EventSearchDescription": {
142
148
  "searchID": dynamicSearchId,
@@ -144,12 +150,9 @@ module.exports = function(RED) {
144
150
  "maxResults": 10,
145
151
  "timeSpanList": [{ "startTime": startTime, "endTime": endTime }],
146
152
  "type": "all",
147
- // Se [parseInt(channelID)] dava vuoto, proviamo a passargli l'ID traccia video reale (es. 201)
148
- // oppure la stringa del canale. Proviamo qui con la traccia video che è quella che contiene i dati:
149
153
  "channels": [ parseInt(channelID * 100 + 1) ]
150
154
  }
151
155
  };
152
-
153
156
  const tempJsonPath = path.join(baseStorage, `search_${channelID}_${timestamp}.json`);
154
157
  fs.writeFileSync(tempJsonPath, JSON.stringify(searchPayload), 'utf8');
155
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-hik-media-buffer",
3
- "version": "1.1.95",
3
+ "version": "1.1.97",
4
4
  "description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
5
5
  "keywords": [
6
6
  "node-red",