"use strict";module.exports=function(n){require("source-map-support").install();var i=require("./core/modbus-io-core");n.nodes.registerType("modbus-io-config",function(e){var a=require("fs-extra"),t=(n.nodes.createNode(this,e),this.name=e.name,this.path=e.path,this.format=e.format,this.addressOffset=e.addressOffset,this),e=(t.setMaxListeners(0),t.lastUpdatedAt=null,new i.LineByLineReader(t.path));i.internalDebug("Read IO File "+t.path),t.configData=[],e.on("error",function(e){i.internalDebug(e.message)}),e.on("line",function(e){e&&t.configData.push(JSON.parse(e))}),e.on("end",function(){t.lastUpdatedAt=Date.now(),i.internalDebug("Read IO Done From File "+t.path),t.warn({payload:i.allValueNamesFromIOFile(t),name:"Modbus Value Names From IO File",path:t.path}),t.emit("updatedConfig",t.configData)}),i.internalDebug("Loading IO File Started For "+t.path),t.watcher=a.watchFile(t.path,function(e,a){i.internalDebug("the current mtime is: ".concat(e.mtime)),i.internalDebug("the previous mtime was: ".concat(a.mtime)),e.mtime!==a.mtime&&(i.internalDebug("Reload IO File "+t.path),t.configData=[],delete t.lastUpdatedAt,(e=new i.LineByLineReader(t.path)).on("error",function(e){i.internalDebug(e.message)}),e.on("line",function(e){e&&t.configData.push(JSON.parse(e))}),e.on("end",function(){t.lastUpdatedAt=Date.now(),i.internalDebug("Reload IO Done From File "+t.path),t.warn({payload:i.allValueNamesFromIOFile(t),name:"Modbus Value Names From IO File",path:t.path}),t.emit("updatedConfig",t.configData)}),i.internalDebug("Reloading IO File Started For "+t.path))}),t.on("close",function(e){a.unwatchFile(t.path),t.watcher.stop(),e()})})};
//# sourceMappingURL=maps/modbus-io-config.js.map
