diff --git a/databases/settings.table b/databases/settings.table index 7d0c8cd..b649808 100644 --- a/databases/settings.table +++ b/databases/settings.table @@ -1,2 +1,2 @@ rvo_name:string|lang:string|mqtt_host:string|mqtt_clientid:string|mqtt_username:string|mqtt_port:number|maintanace_mode:boolean|projects_id:number|controller_type:string|backup_on_failure:boolean|restore_from_backup:number|restore_backup_wait:number -+|Grafia 10.0.0.76|en|192.168.252.1|10_0_0_76_grafia|6TsPFTwE1j8iI8B1oIYD|1883|0|31|unipi|1|100|5|........................................... ++|Grafia 10.0.0.74|en||10_0_0_74_grafia||1883|0|29|unipi|1|30|50|........................................... diff --git a/flow/designer.json b/flow/designer.json index f6271ea..ffba053 100644 --- a/flow/designer.json +++ b/flow/designer.json @@ -10,7 +10,7 @@ { "name": "Time setter", "linker": "time-setter", - "id": "1667233810390", + "id": "1667235000217", "index": 1 } ], @@ -19,9 +19,9 @@ "id": "1636110851291", "component": "socomec", "tab": "1636110831878", - "name": "IP - 192.168.1.31 & 32", - "x": 34, - "y": 124, + "name": "IP - 192.168.1.11 & 12", + "x": 53, + "y": 145, "connections": { "0": [ { @@ -40,17 +40,17 @@ }, { "index": "0", - "id": "1643021318333" + "id": "1643023439891" } ], "2": [ { "index": "0", - "id": "1640011795746" + "id": "1640097360601" }, { "index": "0", - "id": "1645452856681" + "id": "1669850052514" } ] }, @@ -65,8 +65,8 @@ "color": "#2134B0", "notes": "", "options": { - "port": 502, - "host": "192.168.1.11" + "host": "192.168.1.11", + "port": 502 } }, { @@ -74,8 +74,8 @@ "component": "debug", "tab": "1636110831878", "name": "Debug", - "x": 389, - "y": 45, + "x": 376, + "y": 32, "connections": {}, "disabledio": { "input": [ @@ -100,11 +100,13 @@ "component": "debug", "tab": "1636110831878", "name": "Debug", - "x": 553, - "y": 83, + "x": 377, + "y": 113, "connections": {}, "disabledio": { - "input": [], + "input": [ + 0 + ], "output": [] }, "state": { @@ -124,13 +126,13 @@ "component": "virtualwirein", "tab": "1636110831878", "name": "tb-prod01-push", - "x": 30, - "y": 587, + "x": 23, + "y": 586, "connections": { "0": [ { "index": "0", - "id": "1694075854662" + "id": "1694077414274" } ] }, @@ -153,8 +155,8 @@ "component": "virtualwireout", "tab": "1636110831878", "name": "tb-prod01-push", - "x": 446, - "y": 194, + "x": 383, + "y": 234, "connections": {}, "disabledio": { "input": [], @@ -175,13 +177,13 @@ "component": "monitormemory", "tab": "1636110831878", "name": "Memory", - "x": 47, - "y": 987, + "x": 37, + "y": 945, "connections": { "0": [ { "index": "0", - "id": "1641214032469" + "id": "1641906774515" } ] }, @@ -190,14 +192,14 @@ "output": [] }, "state": { - "text": "847.58 MB / 987.80 MB", + "text": "804.16 MB / 987.80 MB", "color": "gray" }, "color": "#F6BB42", "notes": "", "options": { "enabled": true, - "interval": 60000 + "interval": 30000 } }, { @@ -205,8 +207,8 @@ "component": "debug", "tab": "1636110831878", "name": "Debug", - "x": 397, - "y": 1056, + "x": 395, + "y": 984, "connections": {}, "disabledio": { "input": [ @@ -231,13 +233,13 @@ "component": "monitorconsumption", "tab": "1636110831878", "name": "CPU", - "x": 43, - "y": 890, + "x": 35, + "y": 850, "connections": { "0": [ { "index": "0", - "id": "1641213956795" + "id": "1641906812467" } ] }, @@ -246,7 +248,7 @@ "output": [] }, "state": { - "text": "0.3% / 64.51 MB", + "text": "3.1% / 57.85 MB", "color": "gray" }, "color": "#967ADC", @@ -257,7 +259,7 @@ "monitorsize": true, "monitorconsumption": true, "enabled": true, - "interval": 60000 + "interval": 30000 } }, { @@ -265,8 +267,8 @@ "component": "debug", "tab": "1636110831878", "name": "Debug", - "x": 397, - "y": 868, + "x": 396, + "y": 808, "connections": {}, "disabledio": { "input": [ @@ -287,17 +289,17 @@ } }, { - "id": "1640011795746", + "id": "1640097360601", "component": "httprequest", "tab": "1636110831878", - "name": "grafia-prod01.worksys.io/total_energy", - "x": 443, - "y": 284, + "name": "grafia-prod01.worksys.io", + "x": 380, + "y": 317, "connections": { "0": [ { "index": "0", - "id": "1640011891453" + "id": "1640097392518" } ] }, @@ -312,19 +314,19 @@ "color": "#5D9CEC", "notes": "", "options": { - "method": "POST", "stringify": "json", + "method": "POST", "url": "http://192.168.252.2:8005/total_energy", "type": "json" } }, { - "id": "1640011891453", + "id": "1640097392518", "component": "debug", "tab": "1636110831878", "name": "Debug", - "x": 794, - "y": 279, + "x": 697, + "y": 317, "connections": {}, "disabledio": { "input": [ @@ -345,17 +347,17 @@ } }, { - "id": "1640013180066", - "component": "trigger", + "id": "1641906699312", + "component": "monitordisk", "tab": "1636110831878", - "name": "Trigger", - "x": 186, - "y": 292, + "name": "Disk", + "x": 35, + "y": 1036, "connections": { "0": [ { "index": "0", - "id": "1640011795746" + "id": "1641906732272" } ] }, @@ -364,32 +366,59 @@ "output": [] }, "state": { - "text": "", + "text": "5.67 GB / 7.26 GB", "color": "gray" }, "color": "#F6BB42", "notes": "", "options": { - "data": "{s:3}", - "datatype": "object" + "enabled": true, + "path": "/", + "interval": 30000 } }, { - "id": "1641213956795", + "id": "1641906703877", + "component": "debug", + "tab": "1636110831878", + "name": "Debug", + "x": 396, + "y": 1073, + "connections": {}, + "disabledio": { + "input": [ + 0 + ], + "output": [] + }, + "state": { + "text": "Enabled", + "color": "gray" + }, + "color": "#967ADC", + "notes": "", + "options": { + "type": "data", + "repository": false, + "enabled": true + } + }, + { + "id": "1641906732272", "component": "code", "tab": "1636110831878", "name": "Code", - "x": 214, - "y": 889, + "x": 196, + "y": 1034, "connections": { "0": [ { "index": "0", - "id": "1636972771931" + "id": "1641906703877" }, { "index": "0", - "id": "1641214092460" + "id": "1641907044563" } ] }, @@ -405,17 +434,19 @@ "notes": "", "options": { "keepmessage": true, - "code": "let response = {};\nresponse.cpu = value.cpu;\nresponse.uptime = value.uptime;\n\nsend(0, response);", - "outputs": 1 + "code": "let response = {};\n\nresponse.hdd_total = value.total;\nresponse.hdd_free = value.free;\nresponse.hdd_used = value.used;\n\nsend(0, response);", + "outputs": 1, + "COMPONENT": "code", + "NAME": "Code" } }, { - "id": "1641214032469", + "id": "1641906774515", "component": "code", "tab": "1636110831878", "name": "Code", - "x": 214, - "y": 983, + "x": 197, + "y": 941, "connections": { "0": [ { @@ -424,7 +455,7 @@ }, { "index": "0", - "id": "1641214092460" + "id": "1641907044563" } ] }, @@ -445,100 +476,21 @@ } }, { - "id": "1641214092460", - "component": "virtualwireout", - "tab": "1636110831878", - "name": "send-to-services", - "x": 414, - "y": 965, - "connections": {}, - "disabledio": { - "input": [], - "output": [] - }, - "state": { - "text": "send-to-services", - "color": "gray" - }, - "color": "#303E4D", - "notes": "", - "options": { - "wirename": "send-to-services" - } - }, - { - "id": "1641214696139", - "component": "monitordisk", - "tab": "1636110831878", - "name": "Disk", - "x": 52, - "y": 1088, - "connections": { - "0": [ - { - "index": "0", - "id": "1641214703623" - } - ] - }, - "disabledio": { - "input": [], - "output": [] - }, - "state": { - "text": "5.78 GB / 7.26 GB", - "color": "gray" - }, - "color": "#F6BB42", - "notes": "", - "options": { - "enabled": true, - "path": "/", - "interval": 60000 - } - }, - { - "id": "1641214703610", - "component": "debug", - "tab": "1636110831878", - "name": "Debug", - "x": 399, - "y": 1146, - "connections": {}, - "disabledio": { - "input": [ - 0 - ], - "output": [] - }, - "state": { - "text": "Enabled", - "color": "gray" - }, - "color": "#967ADC", - "notes": "", - "options": { - "type": "data", - "repository": false, - "enabled": true - } - }, - { - "id": "1641214703623", + "id": "1641906812467", "component": "code", "tab": "1636110831878", "name": "Code", - "x": 219, - "y": 1090, + "x": 202, + "y": 845, "connections": { "0": [ { "index": "0", - "id": "1641214703610" + "id": "1636972771931" }, { "index": "0", - "id": "1641214092460" + "id": "1641907044563" } ] }, @@ -554,26 +506,44 @@ "notes": "", "options": { "keepmessage": true, - "code": "let response = {};\n\nresponse.hdd_total = value.total;\nresponse.hdd_free = value.free;\nresponse.hdd_used = value.used;\n\nsend(0, response);", + "code": "let response = {};\nresponse.cpu = value.cpu;\nresponse.uptime = value.uptime;\n\nsend(0, response);", "outputs": 1 } }, { - "id": "1641214819493", + "id": "1641907044563", + "component": "virtualwireout", + "tab": "1636110831878", + "name": "send-to-services", + "x": 398, + "y": 892, + "connections": {}, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "send-to-services", + "color": "gray" + }, + "color": "#303E4D", + "notes": "", + "options": { + "wirename": "send-to-services" + } + }, + { + "id": "1641907104812", "component": "virtualwirein", "tab": "1636110831878", "name": "send-to-services", - "x": 57, - "y": 1349, + "x": 65, + "y": 1232, "connections": { "0": [ { "index": "0", - "id": "1641214853420" - }, - { - "index": "0", - "id": "1641214870492" + "id": "1641907121073" } ] }, @@ -592,47 +562,21 @@ } }, { - "id": "1641214853420", - "component": "debug", - "tab": "1636110831878", - "name": "Debug", - "x": 343, - "y": 1306, - "connections": {}, - "disabledio": { - "input": [ - 0 - ], - "output": [] - }, - "state": { - "text": "Enabled", - "color": "gray" - }, - "color": "#967ADC", - "notes": "", - "options": { - "type": "data", - "repository": false, - "enabled": true - } - }, - { - "id": "1641214870492", + "id": "1641907121073", "component": "infosender", "tab": "1636110831878", "name": "Info sender", - "x": 322, - "y": 1395, + "x": 304, + "y": 1227, "connections": { "0": [ { "index": "0", - "id": "1641214879162" + "id": "1641907134719" }, { "index": "0", - "id": "1641214887643" + "id": "1641907182409" } ] }, @@ -651,43 +595,17 @@ } }, { - "id": "1641214879162", - "component": "debug", - "tab": "1636110831878", - "name": "Debug", - "x": 543, - "y": 1470, - "connections": {}, - "disabledio": { - "input": [ - 0 - ], - "output": [] - }, - "state": { - "text": "Enabled", - "color": "gray" - }, - "color": "#967ADC", - "notes": "", - "options": { - "type": "data", - "repository": false, - "enabled": true - } - }, - { - "id": "1641214887643", + "id": "1641907134719", "component": "httprequest", "tab": "1636110831878", "name": "http://192.168.252.2:8004/sentmessage", - "x": 535, - "y": 1363, + "x": 533, + "y": 1191, "connections": { "0": [ { "index": "0", - "id": "1641214960946" + "id": "1641907188601" } ] }, @@ -702,19 +620,19 @@ "color": "#5D9CEC", "notes": "", "options": { - "type": "json", - "url": "http://192.168.252.2:8004/sentmessage", + "stringify": "json", "method": "POST", - "stringify": "json" + "url": "http://192.168.252.2:8004/sentmessage", + "type": "json" } }, { - "id": "1641214960946", + "id": "1641907182409", "component": "debug", "tab": "1636110831878", "name": "Debug", - "x": 911, - "y": 1359, + "x": 536, + "y": 1295, "connections": {}, "disabledio": { "input": [ @@ -735,17 +653,43 @@ } }, { - "id": "1643021318333", + "id": "1641907188601", + "component": "debug", + "tab": "1636110831878", + "name": "Debug", + "x": 906, + "y": 1189, + "connections": {}, + "disabledio": { + "input": [ + 0 + ], + "output": [] + }, + "state": { + "text": "Enabled", + "color": "gray" + }, + "color": "#967ADC", + "notes": "", + "options": { + "type": "data", + "repository": false, + "enabled": true + } + }, + { + "id": "1643023439891", "component": "code", "tab": "1636110831878", "name": "Code", - "x": 705.8833312988281, - "y": 130.53334045410156, + "x": 569, + "y": 176, "connections": { "0": [ { "index": "0", - "id": "1643021403079" + "id": "1643023495930" } ] }, @@ -763,17 +707,17 @@ "notes": "", "options": { "keepmessage": true, - "code": "//if(value.hasOwnProperty('RO8rjaBDy21qPQJzW7oKN17pK3xmNleVZg9Ed4Gw') || value.hasOwnProperty('K94XLav1glVRnyQ6r01VZ3kme3YJwBxM5oOzdP2j'))\n\tif(value.hasOwnProperty('K94XLav1glVRnyQ6r01VZ3kme3YJwBxM5oOzdP2j'))\n\t{\n\t\tsend(0, value);\n\t}", + "code": "//if(value.hasOwnProperty('1JMYvnx2RzKEo4aWQ7D93vAL8yZV3m9NBePXbrdj'))\n//{\n\t//send(0, value);\n//}\n//if(value.hasOwnProperty('1559') || value.hasOwnProperty('1558'))\nif(value.hasOwnProperty('1559'))\n{\n\tif(value[\"1559\"][0].values.hasOwnProperty(\"total_energy\"))\n\t\t{\n\t\t\tsend(0, value);\n\t\t}\n\n}\n\nif(value.hasOwnProperty('1558'))\n{\n\tif(value[\"1558\"][0].values.hasOwnProperty(\"total_energy\"))\n\t\t{\n\t\t\tsend(0, value);\n\t\t}\n\n}", "outputs": 1 } }, { - "id": "1643021403079", + "id": "1643023495930", "component": "debug", "tab": "1636110831878", - "name": "just 1 module", - "x": 882.8833312988281, - "y": 127.53334045410156, + "name": "Just 1 module", + "x": 719, + "y": 169, "connections": {}, "disabledio": { "input": [], @@ -792,36 +736,12 @@ } }, { - "id": "1645452856681", - "component": "debug", - "tab": "1636110831878", - "name": "Http req data", - "x": 449.8833312988281, - "y": 381.51666259765625, - "connections": {}, - "disabledio": { - "input": [], - "output": [] - }, - "state": { - "text": "Enabled", - "color": "gray" - }, - "color": "#967ADC", - "notes": "", - "options": { - "type": "data", - "repository": false, - "enabled": true - } - }, - { - "id": "1660045438935", + "id": "1660058310860", "component": "virtualwireout", "tab": "1636110831878", "name": "send-to-services", - "x": 582.8833312988281, - "y": 652, + "x": 590.5, + "y": 633.4166870117188, "connections": {}, "disabledio": { "input": [], @@ -838,17 +758,17 @@ } }, { - "id": "1667233820282", + "id": "1667235009598", "component": "timesetter", - "tab": "1667233810390", + "tab": "1667235000217", "name": "Timesetter", - "x": 333.8833312988281, - "y": 136, + "x": 245.0833282470703, + "y": 166, "connections": { "0": [ { "index": "0", - "id": "1667233834272" + "id": "1667235037440" } ] }, @@ -865,17 +785,17 @@ "options": {} }, { - "id": "1667233826092", + "id": "1667235012156", "component": "timer", - "tab": "1667233810390", + "tab": "1667235000217", "name": "Timer", - "x": 115.88333129882812, - "y": 227, + "x": 38.08332824707031, + "y": 249, "connections": { "0": [ { "index": "0", - "id": "1667233820282" + "id": "1667235009598" } ] }, @@ -894,12 +814,39 @@ } }, { - "id": "1667233834272", + "id": "1667235031667", + "component": "trigger", + "tab": "1667235000217", + "name": "Trigger", + "x": 41.08332824707031, + "y": 168, + "connections": { + "0": [ + { + "index": "0", + "id": "1667235009598" + } + ] + }, + "disabledio": { + "input": [], + "output": [] + }, + "state": { + "text": "", + "color": "gray" + }, + "color": "#F6BB42", + "notes": "", + "options": {} + }, + { + "id": "1667235037440", "component": "debug", - "tab": "1667233810390", + "tab": "1667235000217", "name": "Debug", - "x": 554.8833312988281, - "y": 133, + "x": 441.0833282470703, + "y": 162, "connections": {}, "disabledio": { "input": [], @@ -918,64 +865,43 @@ } }, { - "id": "1667233843489", - "component": "comment", - "tab": "1667233810390", - "name": "Getting actual time once a day from service-prod01.worksys.io", - "x": 163.88333129882812, - "y": 38, + "id": "1669850052514", + "component": "debug", + "tab": "1636110831878", + "name": "Http req data", + "x": 372.0833282470703, + "y": 422, "connections": {}, "disabledio": { - "input": [], + "input": [ + 0 + ], "output": [] }, "state": { - "text": "", + "text": "Enabled", "color": "gray" }, - "color": "#704cff", + "color": "#967ADC", "notes": "", - "options": {} + "options": { + "type": "data", + "repository": false, + "enabled": true + } }, { - "id": "1667233894816", - "component": "trigger", - "tab": "1667233810390", - "name": "Trigger", - "x": 118.88333129882812, - "y": 138, - "connections": { - "0": [ - { - "index": "0", - "id": "1667233820282" - } - ] - }, - "disabledio": { - "input": [], - "output": [] - }, - "state": { - "text": "", - "color": "gray" - }, - "color": "#F6BB42", - "notes": "", - "options": {} - }, - { - "id": "1694075854662", + "id": "1694077414274", "component": "httprequest", "tab": "1636110831878", - "name": "grafia-prod01.worksys.io/rerouting76", - "x": 263, - "y": 586, + "name": "grafia-prod01.worksys.io/rerouting74", + "x": 224, + "y": 584, "connections": { "0": [ { "index": "0", - "id": "1694075957040" + "id": "1694077451207" } ] }, @@ -990,19 +916,19 @@ "color": "#5D9CEC", "notes": "", "options": { - "stringify": "json", + "type": "json", + "url": "http://192.168.252.2:8005/rerouting74", "method": "POST", - "url": "http://192.168.252.2:8005/rerouting76", - "type": "json" + "stringify": "json" } }, { - "id": "1694075957040", + "id": "1694077451207", "component": "debug", "tab": "1636110831878", - "name": "To rerouting76", - "x": 599, - "y": 541, + "name": "rerouting", + "x": 591.0833282470703, + "y": 529, "connections": {}, "disabledio": { "input": [ diff --git a/flow/energomonitor_socomec.js b/flow/energomonitor_socomec.js index 6af47b7..d47d995 100644 --- a/flow/energomonitor_socomec.js +++ b/flow/energomonitor_socomec.js @@ -12,10 +12,20 @@ exports.readme = `Modbus requests to energomonitor socomec suitcase`; const streamBuilder = require("./helper/energo_streambuilder"); const structure = { - "192.168.1.31": { - 3: "i-35", - 2: "i-30", - 11: "i-35", + "192.168.1.11": { + 51: "i-35", // nový merák I-35, bez zóny + 16: "i-35", // zmena adresy z 1 na 16 - 13.5.2022 + "6A": "i-60A", + "6B": "i-60B", + "7A": "i-60A", + "7B": "i-60B", + "8A": "i-60A", + "8B": "i-60B", + 9: "i-30", + "10A": "i-60A", + "10B": "i-60B", + "11A": "i-60A", + "11B": "i-60B", "12A": "i-60A", "12B": "i-60B", "13A": "i-60A", @@ -24,19 +34,59 @@ const structure = { "14B": "i-60B", "15A": "i-60A", "15B": "i-60B", - 16: "i-30", - 21: "i-30", - "22A": "i-60A", - "22B": "i-60B", - "23A": "i-60A", - "23B": "i-60B", - "24A": "i-60A", - "24B": "i-60B", - // 76: "i-30"//vymyslene pre testovanie + 5: "i-30", + "2A": "i-60A", + "2B": "i-60B", + "3A": "i-60A", + "3B": "i-60B", + "4A": "i-60A", + "4B": "i-60B", +//novo nainstalovane 28.10.2024 + "21A": "i-60A", + "21B": "i-60B" + + // "36B": "i-60B" // vymyslene kvoli chybe + }, + "192.168.1.12": { + 18: "i-35", + "2A": "i-60A", + "2B": "i-60B", + "3A": "i-60A", + "3B": "i-60B", + "4A": "i-60A", + "4B": "i-60B", + "5A": "i-60A", + "5B": "i-60B", + "6A": "i-60A", + "6B": "i-60B", + "7A": "i-60A", + "7B": "i-60B", + "8A": "i-60A", + "8B": "i-60B", + "9A": "i-60A", + "9B": "i-60B", + "10A": "i-60A", + "10B": "i-60B", + "11A": "i-60A", + "11B": "i-60B", + "12A": "i-60A", + "12B": "i-60B", + "13A": "i-60A", + "13B": "i-60B", + "14A": "i-60A", + "14B": "i-60B", + "15A": "i-60A", + "15B": "i-60B", + "16A": "i-60A", + "16B": "i-60B", + "17A": "i-60A", + "17B": "i-60B" } }; + + exports.install = function(instance) { const modbus = require('jsmodbus'); @@ -44,7 +94,8 @@ exports.install = function(instance) { require('events').EventEmitter.defaultMaxListeners = 20; - const allModulesEnergy = {unipi_76: ""}; // key to identify source data + + const allModulesEnergy = {unipi_74: ""}; // key to identify source data const date = new Date(); let hour = date.getHours(); @@ -79,48 +130,85 @@ exports.install = function(instance) { // "multiplier":1, // }, // ] - // }, - // "192.168.1.12": { - // "streams": [ - // { - // "unitId": 18, - // "section": "", - // "name": 18488, - // "tb_value": "total_energy", - // "bytes": 2, - // "multiplier": 1, - // "month": 0 - // } - // ] - // } + // } // } const tbNames = { - "192.168.1.31": { - "3": "JX1ObgmqGZ54DMyYL7aJMlAEVdve38WKRzwjNrQ9", - "2": "RO8rjaBDy21qPQJzW7oKN17pK3xmNleVZg9Ed4Gw", - "11": "RvmwNz8QPblKp41GD7l4NY7JrLVYoBO92dMegn6W", - "12A": "K94XLav1glVRnyQ6r01VZ3kme3YJwBxM5oOzdP2j", - "12B": "3JjOWdylwgNLzxVab7NPpJ0Z2vG64rq8PEB5QmDo", - "13A": "Z5KyJe9nEg1QNbWlX0wmNP7oDjBLdqzR83VGv624", - "13B": "PjLblDgRBO6WQqnxmkJwpb7Jv3ewZN4p5a89yKdY", - "14A": "dz4ojlpP85JMgDLZWkQ1p3kaKYqQexEr62GXRV1y", - "14B": "d9x2V5LGYBzXp4mMRAOPpV0PloaqJwnQj6DgrNe3", - "15A": "1JMYvnx2RzKEo4aWQ7D9pXAL8yZV3m9NBePXbrdj", - "15B": "d5xjWYMwEJon6rLlK7ylNxkqgV4DaOeNB9ZX3Gzb", - "16": "gRoJEyXVx4qD9er287LwpEkwBzGldaPjLWQKm3Mv", - "21": "3JjOWdylwgNLzxVab7NPyn0Z2vG64rq8PEB5QmDo", - "22A": "Z5KyJe9nEg1QNbWlX0wmEB7oDjBLdqzR83VGv624", - "22B": "1JMYvnx2RzKEo4aWQ7D9y5AL8yZV3m9NBePXbrdj", - "23A": "PjLblDgRBO6WQqnxmkJwyr7Jv3ewZN4p5a89yKdY", - "23B": "dz4ojlpP85JMgDLZWkQ1GGkaKYqQexEr62GXRV1y", - "24A": "d5xjWYMwEJon6rLlK7ylZmkqgV4DaOeNB9ZX3Gzb", - "24B": "gRoJEyXVx4qD9er287LwyvkwBzGldaPjLWQKm3Mv" - // "76": "vymyslene pre testovanie" + "192.168.1.11": { + "51": "1JMYvnx2RzKEo4aWQ7D93vAL8yZV3m9NBePXbrdj", // nový merák I-35, bez zóny + "16": "6lQGaY9RDywdVzObj0PZer7Pg4NBn3exEK51LWZq", // zmena adresy z 1 na 16, 13.5.2022 + "6A": "JzwxZXOvDj1bVrN4nkWeR8A8qdyBl3MRKLpGPgaQ", + "6B": "g9OxBZ5KRwNznlY6pApbGmkWXvjdEL4eGQobMDy2", + "7A": "OzNMgZ9n43qPbjXmy7zOgGA2DKdYvW5e6pxGRrVa", + "7B": "JX1ObgmqGZ54DMyYL7aJzJAEVdve38WKRzwjNrQ9", + "8A": "RvmwNz8QPblKp41GD7l4WK7JrLVYoBO92dMegn6W", + "8B": "RO8rjaBDy21qPQJzW7oKpD7pK3xmNleVZg9Ed4Gw", + "9": "3JjOWdylwgNLzxVab7NPjw0Z2vG64rq8PEB5QmDo", + "10A": "Z5KyJe9nEg1QNbWlX0wmnM7oDjBLdqzR83VGv624", + "10B": "1JMYvnx2RzKEo4aWQ7D9xzAL8yZV3m9NBePXbrdj", + "11A": "PjLblDgRBO6WQqnxmkJwga7Jv3ewZN4p5a89yKdY", + "11B": "dz4ojlpP85JMgDLZWkQ12jkaKYqQexEr62GXRV1y", + "12A": "d5xjWYMwEJon6rLlK7yl3wkqgV4DaOeNB9ZX3Gzb", + "12B": "gRoJEyXVx4qD9er287LwbOkwBzGldaPjLWQKm3Mv", + "13A": "K94XLav1glVRnyQ6r01V3Wkme3YJwBxM5oOzdP2j", + "13B": "d9x2V5LGYBzXp4mMRAOPr10PloaqJwnQj6DgrNe3", + "14A": "B5EoxeMVp4zwr8nqW0Gen57RjvD1PNamOGbLg63Z", + "14B": "aw4eELG2DlPMdn1JW0Bz4Z0qQXOZRN3xB5yp8VKr", + "15A": "ZmRwd93QL4gaezxEbAx1Xw01prn2XjlPvGyqJ6BO", + "15B": "eod9aRWLVl34Gx1Dn7VYmDk2rz6qjgmpEXwQJN5Z", + "5": "3a5oqJN1bgnx4Ol9dk8BdqAByE6jQ8mKDWMpGrLV", + "2A": "EjgWGnXaLy9opPOz20ngWQk86BlYM3w1deVQvbKr", + "2B": "wvKJdZML6mXP4DzWBAXOK87jxNloa5g23Ve9Y1ry", + "3A": "Nzp2OoJlqn6r1ZgvdA3RqE7abBwP5G4eE3RQmyxD", + "3B": "PLBJzmK1r3Gynd6OW0g2WzAe5wV4vx9bDEqNgYR8", + "4A": "52dD6ZlV1QaOpRBmbAqvWb0KnGzWMLj4eJq38Pgo", + "4B": "rDbQ84xzwgdqEoPm3kbPWWA9anOZY1RXyBv2LVM6", + "21A": "1558", + "21B": "1559" + // "36B": "vymyslene kvoli chybe" + }, + "192.168.1.12": { + "18": "m6EYyZoJ4gWexdjVPARapL7RDOq9wv2N5XzKGplr", + "2A": "E6Kg9oDnLWyzPRMva7vW8yAJxp4VG58qO2w1lZYe", + "2B": "roKgWqY95V3mXMRzyAjrW6AbLjexpJPvaGDBw826", + "3A": "nJL5lPMwBx23YpqRe0rqa4AdamXvWVbOrD4gNzy8", + "3B": "XMBbew5z4ELrZa2mRAdZW9k8vPN6gy3DdVYlpKjq", + "4A": "gYbDLqlyZVoRerQpB72GgvAWJnwM5z24POKa8Exj", + "4B": "zdQO8GwxDqjRgP4137Y5eo7NyKlpem2nL65rvVJY", + "5A": "5dBNwRp9graYJxZn409R28klVov1b2QLPDqGm6XK", + "5B": "JzwxZXOvDj1bVrN4nkWeZ8A8qdyBl3MRKLpGPgaQ", + "6A": "zrR51V2ajQ9ZLygPKkEPVW0YDq38xOJolENBXGnv", + "6B": "g9OxBZ5KRwNznlY6pApbymkWXvjdEL4eGQobMDy2", + "7A": "OzNMgZ9n43qPbjXmy7zOyGA2DKdYvW5e6pxGRrVa", + "7B": "JX1ObgmqGZ54DMyYL7aJZJAEVdve38WKRzwjNrQ9", + "8A": "RvmwNz8QPblKp41GD7l4yK7JrLVYoBO92dMegn6W", + "8B": "RO8rjaBDy21qPQJzW7oKyD7pK3xmNleVZg9Ed4Gw", + "9A": "3JjOWdylwgNLzxVab7NPxw0Z2vG64rq8PEB5QmDo", + "9B": "Z5KyJe9nEg1QNbWlX0wmyM7oDjBLdqzR83VGv624", + "10A": "1JMYvnx2RzKEo4aWQ7D9MzAL8yZV3m9NBePXbrdj", + "10B": "PjLblDgRBO6WQqnxmkJwea7Jv3ewZN4p5a89yKdY", + "11A": "WlVJBygjDZMeKX3vnAMWvLk8NqdmG2x1Y69LQ4P5", + "11B": "dz4ojlpP85JMgDLZWkQ1njkaKYqQexEr62GXRV1y", + "12A": "BaY3Xpy1EbKGjLq2O7m9W27rx8owgQz9P4dDJRmN", + "12B": "DbQY6zyveZRwK5drV0Zl4j7joE4XJM83N9xl2nWq", + "13A": "apKVJBwOyrP35m2lv7KEqd0YXbeWNd64En9GxRqg", + "13B": "o9vbeQlLMVg8j5dq4kedWy0NxZpEmnXzwYKO1ar2", + "14A": "gP1eOZVj3Q9lv5aDEk4MbP7rdpqW8yLm2BbKzJxM", + "14B": "2O14VBzl8aDmWdNw3A53vOkGyZ5qLJoEMpj6R9ng", + "15A": "pE5X8NQPaow6vlOZxk6Yjw0q42ezGBMyWgDVjR3L", + "15B": "d5xjWYMwEJon6rLlK7ylywkqgV4DaOeNB9ZX3Gzb", + "16A": "6lQGaY9RDywdVzObj0PZdr7Pg4NBn3exEK51LWZq", + "16B": "m6EYyZoJ4gWexdjVPARaYL7RDOq9wv2N5XzKGplr", + "17A": "gRoJEyXVx4qD9er287LwBOkwBzGldaPjLWQKm3Mv", + "17B": "K94XLav1glVRnyQ6r01VpWkme3YJwBxM5oOzdP2j" } }; + const meter51 = ["total_energy","phase_1_power","phase_2_power","phase_3_power","phase_1_voltage","phase_2_voltage", + "phase_3_voltage","phase_1_react_power","phase_2_react_power","phase_3_react_power","phase_1_apparent_power", + "phase_2_apparent_power","phase_3_apparent_power","total_active_power","total_reactive_power","total_apparent_power"]; + class SocketWithClients { @@ -135,7 +223,7 @@ exports.install = function(instance) { this.streams = data.streams; //pole this.startSocket(); - } + } startSocket = () => { @@ -152,14 +240,14 @@ exports.install = function(instance) { this.socket.on('error', function(e) { console.log('socket connection error', e); if(e.code == 'ECONNREFUSED' || e.code == 'ECONNRESET') { - console.log(exports.title + ' Waiting 10 seconds before trying to connect again'); - setTimeout(obj.startSocket, 10000); + console.log(exports.title + ' Waiting 1 minute before trying to connect again'); + setTimeout(obj.startSocket, 60000); } }); this.socket.on('close', function() { - console.log('Socket connection closed ' + exports.title + ' Waiting 10 seconds before trying to connect again'); - setTimeout(obj.startSocket, 10000); + console.log('Socket connection closed ' + exports.title + ' Waiting 1 minute before trying to connect again'); + setTimeout(obj.startSocket, 60000); }); // we create client for all modules (unitIds) and push them into dictionary @@ -198,7 +286,7 @@ exports.install = function(instance) { let date = Date.now(); let tbval = this.streams[this.index].tb_value; - // console.log("citam tieto hodnoty", unitId, register, tbval); + // console.log("citam tieto hodnoty",unitId, register, tbval); let obj = this; this.clients[unitId].readHoldingRegisters(register, bytes) @@ -215,11 +303,10 @@ exports.install = function(instance) { console.log("error pri citani z grafie", register, unitId, section, tbNames[obj.ip][unitId + section], tbval); - // IMPLEMENTOVAT POSIELANIE CHYB PODLA POSLEDNHO REGISTRA V MODULE === "total_power_factor" + //! IMPLEMENTOVAT POSIELANIE CHYB PODLA POSLEDNHO REGISTRA V MODULE === "total_power_factor" if(tbval === "total_power_factor") { obj.sendNokStatus(tbNames[obj.ip][unitId + section], date); - if(arguments["0"].err == "Offline") { obj.socket.emit("close"); @@ -227,7 +314,7 @@ exports.install = function(instance) { } } - // POSIELANIE NOK STATUSU - posle sa az pri poslednom registri z daneho unitu, nie pri kazdej chybnej hlaske + //! POSIELANIE NOK STATUSU - posle sa az pri poslednom registri z daneho unitu, nie pri kazdej chybnej hlaske // if(obj.index + 1 == lenghtOfStreams) // { // obj.sendNokStatus(tbNames[obj.ip][unitId + section], date); @@ -236,10 +323,10 @@ exports.install = function(instance) { // { // obj.sendNokStatus(tbNames[obj.ip][unitId + section], date); // } - - console.error(require('util').inspect(arguments, { - depth: null - })) + + //console.error(require('util').inspect(arguments, { + // depth: null + //})) obj.index++; setTimeout(obj.readRegisters, 0); @@ -285,6 +372,8 @@ exports.install = function(instance) { if(temp_val >= (2**31)) // ak je MSB bit nastavený, eventuálne sa dá použiť aj (temp_val & 0x80000000), ak vieš robiť logický súčin { + //temp_val = temp_val - 2**31; // odstránim MSB bit, eventuálne sa dá použiť aj (temp_val & 0x7FFFFFFF), ak vieš robiť logický súčin + //temp_val = temp_val * (-1); // spravím z toho zápornú hodnotu temp_val = temp_val - "0xFFFFFFFF" + 1; } } @@ -294,7 +383,9 @@ exports.install = function(instance) { if(temp_val >= (2**15)) // ak je MSB bit nastavený, eventuálne sa dá použiť aj (temp_val & 0x8000), ak vieš robiť logický súčin { - temp_val = temp_val - "0xFFFF" + 1; + // temp_val = temp_val - 2**15; // odstránim MSB bit, eventuálne sa dá použiť aj (temp_val & 0x7FFF), ak vieš robiť logický súčin + // temp_val = temp_val * (-1); // spravím z toho zápornú hodnotu + temp_val = temp_val - "0xFFFF" + 1; } } @@ -307,16 +398,18 @@ exports.install = function(instance) { if(tbName == undefined) return; + // we handle multimeter 51 values: - if voltage or power, we multiply with 55 + if(tbName == '1JMYvnx2RzKEo4aWQ7D93vAL8yZV3m9NBePXbrdj' && meter51.includes(tb_value)) value = parseFloat((value * 55).toFixed(2)); + const values = { "status": "OK", [tb_value]: value }; - // we send "energy_last_month" value, that is equal to "total_energy" value, on first day of new month ==> it means when month changes + // we send "energy_last_month" value, that is equal to "total_energy" value, on first day and first minute of new month ==> it means when month has changed if(tb_value == "total_energy") { - const previousEnergy = a.previousEnergy; a.previousEnergy = value; @@ -336,7 +429,6 @@ exports.install = function(instance) { } allModulesEnergy[this.ip + '@' + unitId + section] = value; - } @@ -356,8 +448,8 @@ exports.install = function(instance) { }; } - - const newSocket = new SocketWithClients("192.168.1.31", conversionTable["192.168.1.31"]); + const newSocket = new SocketWithClients("192.168.1.11", conversionTable["192.168.1.11"]); + const newSocket2 = new SocketWithClients("192.168.1.12", conversionTable["192.168.1.12"]); } diff --git a/flow/helper/DataToTbHandler.js b/flow/helper/DataToTbHandler.js deleted file mode 100644 index 8fff312..0000000 --- a/flow/helper/DataToTbHandler.js +++ /dev/null @@ -1,163 +0,0 @@ -class DataToTbHandler -{ - constructor(index) { - this.index = index; - - this.previousValues = {}; - this.debug = false; - this.messageCounter = 0; - - this.sender = ""; - } - - dump() - { - console.log("----------------------------"); - console.log("previousValues", this.previousValues); - console.log("----------------------------"); - } - - setSender(sender) - { - this.sender = sender; - } - - isEmptyObject( obj ) { - for ( var name in obj ) { - return false; - } - return true; - } - - sendToTb(dataToTb, instance) - { - - if(!FLOW.OMS_brokerready) - { - return dataToTb; - } - - let keys = Object.keys(dataToTb); - - if(keys.length == 0) - { - if(this.debug) console.log("sendToTb received epty object", dataToTb); - return; - } - - - let tbname = keys[0]; - let ts; - - let arrayOfValues = dataToTb[tbname]; - let arrayOfValuesToSend = []; - - for(let i = 0; i < arrayOfValues.length; i++) - { - ts = arrayOfValues[i].ts; - - //console.log("sendToTb------------>before", arrayOfValues[i].values, tbname); - - let values = this.prepareValuesForTb(tbname, ts, arrayOfValues[i].values); - - //console.log("sendToTb------------>after", values); - - if(!this.isEmptyObject(values)) - { - arrayOfValuesToSend.push({ts: ts, values: values}); - } - } - - if(arrayOfValuesToSend.length == 0) - { - //if(this.debug) console.log("data not sent - empty array"); - return; - } - - /* - let dataToTb = { - [tbname]: [ - { - "ts": Date.now(), - "values": values - } - ] - } - */ - - this.messageCounter++; - - let dataToTbModified = { - [tbname]: arrayOfValuesToSend - } - - //console.log(this.sender + " DATA SEND TO TB ", tbname, this.messageCounter, new Date(ts), dataToTbModified[tbname][0].values, this.instance); - if(this.debug) console.log(this.sender + " DATA SEND TO TB ", this.index, tbname, arrayOfValuesToSend); - - instance.send(this.index, dataToTbModified); - } - - getDiffTimestamp(key) - { - let seconds = 60*60;//1h - //seconds = 1;//for testing - - //TODO set different value for given key!!! - //if(key == "status") seconds = 2*60*60;//2h - - let timestampDiffToRemoveKey = seconds*1000; - - return timestampDiffToRemoveKey; - } - - prepareValuesForTb(tbname, timestamp, values) - { - let keys = Object.keys(values); - if(!this.previousValues.hasOwnProperty(tbname)) - { - this.previousValues[tbname] = {}; - } - - //if(this.debug) console.log("prepareValuesForTb", tbname, timestamp, values); - - for(let i = 0; i < keys.length; i++) - { - let key = keys[i]; - let value = values[key]; - - if(!this.previousValues[tbname].hasOwnProperty(key)) - { - this.previousValues[tbname][key] = {ts: timestamp, value: value}; - continue; - } - - if(this.previousValues[tbname][key].value === value) - { - let diff = timestamp - this.previousValues[tbname][key].ts; - - let timestampDiffToRemoveKey = this.getDiffTimestamp(key); - if(diff > timestampDiffToRemoveKey) - { - this.previousValues[tbname][key].ts = Date.now(); - //if(this.debug) console.log(this.sender + ": update ts for key", key, "diff is", diff, "messageCounter", this.messageCounter); - - } - else - { - delete values[key]; - //if(this.debug) console.log(this.sender + ": delete key", key, "diff is", diff, "messageCounter", this.messageCounter, timestampDiffToRemoveKey); - } - } - else - { - this.previousValues[tbname][key].value = value; - this.previousValues[tbname][key].ts = timestamp; - } - - } - - return values; - } -} - -module.exports = DataToTbHandler; \ No newline at end of file diff --git a/flow/helper/energo_streambuilder.js b/flow/helper/energo_streambuilder.js index b1e37a9..2136ab5 100644 --- a/flow/helper/energo_streambuilder.js +++ b/flow/helper/energo_streambuilder.js @@ -150,7 +150,7 @@ const makeStreamsTable = (structure) => { const modul = structure[ip][item]; // console.log(modul) //i-35, i-60A ... - + let section = ""; if(modul == "i-60A") { @@ -169,7 +169,7 @@ const makeStreamsTable = (structure) => { const m = multiplier[tb_value]; if(isNaN(item)) item = item.slice(0,-1); - + const stream = { "unitId": parseInt(item), "section": section, @@ -177,7 +177,7 @@ const makeStreamsTable = (structure) => { "tb_value": tb_value, "bytes": b, "multiplier": m, - } + } if(tb_value == "total_energy") { @@ -197,14 +197,11 @@ const makeStreamsTable = (structure) => { }) return conversionTable; -} - +}; const getCurrentMonth = () => { const date = new Date(); return date.getMonth(); }; - - exports.makeStreamsTable = makeStreamsTable; \ No newline at end of file