diff --git a/.gitignore b/.gitignore index 4721a2f..35951cf 100644 --- a/.gitignore +++ b/.gitignore @@ -64,5 +64,6 @@ typings/ .vscode dev* +.idea package-lock.json diff --git a/connection_pool.js b/connection_pool.js index 1a01d86..a3bea7d 100644 --- a/connection_pool.js +++ b/connection_pool.js @@ -22,8 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -var util = require("util"); - var pool = {}; module.exports = { @@ -46,7 +44,7 @@ module.exports = { options.autoConnect == "undefined" ? true : options.autoConnect; options.preventAutoReconnect = false; options.logLevel = options.logLevel || "WARN"; - util.log(`[mcprotocol] adding new connection to pool ~ ${id}`); + node.debug(`[mcprotocol] adding new connection to pool ~ ${id}`); var mcp = new mcprotocol(); @@ -97,10 +95,10 @@ module.exports = { disconnect: function() { this._instances -= 1; if (this._instances <= 0) { - util.log(`[mcprotocol] closing connection ~ ${id}`); + node.debug(`[mcprotocol] closing connection ~ ${id}`); mcp.dropConnection(); mcp = null; - util.log(`[mcprotocol] deleting connection from pool ~ ${id}`); + node.debug(`[mcprotocol] deleting connection from pool ~ ${id}`); delete pool[id]; } }, @@ -119,12 +117,12 @@ module.exports = { mcp.on("error", function(e) { if (mcp) { - util.log(`[mcprotocol] error ~ ${id}: ${e}`); + node.error(`[mcprotocol] error ~ ${id}: ${e}`); connecting = false; if (options.autoConnect) { setTimeout(function() { if (options.autoConnect && !options.preventAutoReconnect) { - util.log( + node.error( `[mcprotocol] autoConnect call from error handler ~ ${id}` ); obj.connect(); @@ -135,17 +133,17 @@ module.exports = { }); mcp.on("open", function() { if (mcp) { - util.log(`[mcprotocol] connected ~ ${id}`); + node.debug(`[mcprotocol] connected ~ ${id}`); connecting = false; } }); mcp.on("close", function(err) { - util.log(`[mcprotocol] connection closed ~ ${id}`); + node.debug(`[mcprotocol] connection closed ~ ${id}`); connecting = false; if (options.autoConnect) { setTimeout(function() { if (options.autoConnect && !options.preventAutoReconnect) { - util.log( + node.debug( `[mcprotocol] autoConnect call from close handler ~ ${id}` ); obj.connect(); diff --git a/nodes/write.js b/nodes/write.js index bf5f718..03d74ad 100644 --- a/nodes/write.js +++ b/nodes/write.js @@ -24,7 +24,7 @@ SOFTWARE. module.exports = function(RED) { var connection_pool = require("../connection_pool.js"); - var util = require("util"); + function isNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n); } diff --git a/package.json b/package.json index 461bbd6..2b620eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-mcprotocol", - "version": "1.2.0", + "version": "1.3.0", "description": "Mode-red nodes to Read from & Write to MITSUBISHI PLC over Ethernet using MC Protocol", "repository": { "type": "git",