-
Notifications
You must be signed in to change notification settings - Fork 1
/
modbus.js
executable file
·34 lines (29 loc) · 961 Bytes
/
modbus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const util = require("util");
const plugin = require("ih-plugin-api")();
const modbus = require("./app");
(async () => {
plugin.log("Modbus Master plugin has started.");
sendProcessInfo();
setInterval(sendProcessInfo, 10000);
try {
modbus.params = await plugin.params.get();
plugin.log('Received params...');
modbus.channels = await plugin.channels.get();
if (modbus.channels.length > 0) {
plugin.log(`Received ${modbus.channels.length} channels...`);
} else {
plugin.log('Empty channels list!');
process.exit(2);
}
await modbus.start(plugin);
} catch (err) {
plugin.exit(8, `Error! Message: ${util.inspect(err)}`);
}
})();
function sendProcessInfo() {
const mu = process.memoryUsage();
const memrss = Math.floor(mu.rss/1024)
const memheap = Math.floor(mu.heapTotal/1024)
const memhuse = Math.floor(mu.heapUsed/1024)
process.send({type:'procinfo', data:{memrss,memheap, memhuse }});
}