node-red-contrib-hikvision-ultimate
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -5,2 +5,7 @@ # node-red-contrib-hikvision-ultimate | ||
<p> | ||
<b>Version 0.0.7 BETA</b> November 2020<br/> | ||
- ANPR node now works and correclty handles the plates queue by disregarding old plates. | ||
- Fixes and improvements. | ||
</p> | ||
<p> | ||
<b>Version 0.0.6 BETA</b> November 2020<br/> | ||
@@ -7,0 +12,0 @@ - Automatic reconnection and error handling. Resilency is done. |
@@ -32,3 +32,3 @@ | ||
if (err) { | ||
console.log("MAIN ERROR: " + err); | ||
//console.log("MAIN ERROR: " + err); | ||
node.setAllClientsStatus({ fill: "grey", shape: "ring", text: "Server unreachable. Retry..." }); | ||
@@ -44,14 +44,30 @@ if (node.isConnected) { | ||
} | ||
res.on('data', function (chunk) { | ||
node.isConnected = true; | ||
try { | ||
var sRet = chunk.toString(); | ||
sRet = sRet.substring(sRet.indexOf("<")); // Get only the XML, starting with "<" | ||
// By xml2js | ||
xml2js(sRet, function (err, result) { | ||
node.nodeClients.forEach(oClient => { | ||
if (result !== undefined) oClient.sendPayload({ topic: oClient.topic || "", payload: result, connected: true }); | ||
}) | ||
}); | ||
sRet = sRet.replace(/--boundary/g, ''); | ||
var i = sRet.indexOf("<"); // Get only the XML, starting with "<" | ||
if (i > -1) { | ||
sRet = sRet.substring(i); | ||
// By xml2js | ||
xml2js(sRet, function (err, result) { | ||
node.nodeClients.forEach(oClient => { | ||
if (result !== undefined) oClient.sendPayload({ topic: oClient.topic || "", payload: result, connected: true }); | ||
}) | ||
}); | ||
} else { | ||
i = sRet.indexOf("{") // It's a Json | ||
if (i > -1) { | ||
sRet = sRet.substring(i); | ||
//sRet = sRet.replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/g, '"$2": '); // Fix numbers and chars invalid in JSON | ||
//console.log("BANANA : " + sRet); | ||
node.nodeClients.forEach(oClient => { | ||
oClient.sendPayload({ topic: oClient.topic || "", payload: JSON.parse(sRet), connected: true }); | ||
}) | ||
} | ||
} | ||
} catch (error) { console.log("ERRORE CATCHATO " + error); } | ||
@@ -61,6 +77,8 @@ | ||
res.on('end', function () { | ||
console.log("END"); | ||
//console.log("Hikvision-Config: END " + res.statusMessage); | ||
if (res.statusMessage === "Unauthorized") { | ||
node.setAllClientsStatus({ fill: "red", shape: "ring", text: res.statusMessage }); | ||
} | ||
}); | ||
res.on('close', function () { | ||
console.log("CLOSE"); | ||
node.setAllClientsStatus({ fill: "grey", shape: "ring", text: "Disconnected. Retry..." }); | ||
@@ -76,3 +94,3 @@ if (node.isConnected) { | ||
res.on('error', function (err) { | ||
console.log("ERROR: " + err); | ||
//("ERROR: " + err); | ||
}); | ||
@@ -86,3 +104,3 @@ | ||
//#region "FUNCTIONS" | ||
@@ -89,0 +107,0 @@ node.on('close', function (removed, done) { |
@@ -17,16 +17,8 @@ | ||
if (_msg.payload === null) { node.send(_msg); return; }; // If null, then it's disconnected. Avoid processing the event | ||
node.send(_msg); | ||
try { | ||
node.setNodeStatus({ fill: "green", shape: "dot", text: "Plate " + _msg.payload.Plates.Plate[0].plateNumber }); | ||
} catch (error) { | ||
var retMsg = { topic: _msg.topic, connected: _msg.connected }; | ||
if (_msg.payload.EventNotificationAlert.hasOwnProperty("ANPR")) { | ||
if (_msg.payload.EventNotificationAlert.ANPR.hasOwnProperty("licensePlate")){ | ||
retMsg.payload = { licensePlate: _msg.payload.EventNotificationAlert.ANPR.licensePlate }; | ||
if (_msg.payload.EventNotificationAlert.ANPR.hasOwnProperty("confidenceLevel")) retMsg.payload.confidenceLevel = _msg.payload.EventNotificationAlert.ANPR.confidenceLevel; | ||
node.setNodeStatus({ fill: "green", shape: "dot", text: "Plate: " + retMsg.payload.licensePlate }); | ||
node.send(retMsg); | ||
} | ||
} else { | ||
// The connection is alive, but we've no plates | ||
node.setNodeStatus({ fill: "green", shape: "ring", text: "Connected. Waiting for plate..." }); | ||
} | ||
} | ||
@@ -41,3 +33,3 @@ | ||
this.on('input', function (msg) { | ||
}); | ||
@@ -44,0 +36,0 @@ |
{ | ||
"name": "node-red-contrib-hikvision-ultimate", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A native set of node for Hikvision Cameras, Alarms, Radars etc.", | ||
@@ -25,2 +25,3 @@ "author": "Supergiovane (https://github.com/Supergiovane)", | ||
"Hikvision-config": "nodes/Hikvision-config.js", | ||
"ANPR-config": "nodes/ANPR-config.js", | ||
"hikvisionUltimateAlarmRaw": "nodes/hikvisionUltimateAlarmRaw.js", | ||
@@ -27,0 +28,0 @@ "hikvisionUltimateANPR": "nodes/hikvisionUltimateANPR.js" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
432992
18
398