[ { "id": "8cc1361c68dc2d8f", "type": "tab", "label": "MySQL auf IOT V1", "disabled": false, "info": "", "env": [] }, { "id": "4fab32aa2c7cc31e", "type": "function", "z": "8cc1361c68dc2d8f", "name": "INSERT", "func": "date = msg.mysqltimestamp;\nActCntCyc = msg.payload ;\nactmaschinestate = 5;\n\ntopic = \"INSERT INTO `IOT_Data` ( `date`,`ActCntCyc`, `actmaschinestate`) VALUES ('\";\ntopic = topic + date + \"', '\";\ntopic = topic + ActCntCyc + \"', '\";\ntopic = topic + actmaschinestate + \"');\";\n\n\nmsg.topic = topic;\nreturn msg;\n\n", "outputs": 1, "noerr": 14, "initialize": "", "finalize": "", "libs": [], "x": 1400, "y": 280, "wires": [ [ "b9eecf9b0edffcce" ] ] }, { "id": "527a9c7185174e52", "type": "inject", "z": "8cc1361c68dc2d8f", "name": "Create", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 90, "y": 180, "wires": [ [ "972b1429a4f0b2b4" ] ] }, { "id": "972b1429a4f0b2b4", "type": "function", "z": "8cc1361c68dc2d8f", "name": "TABLE", "func": "topic = \"CREATE TABLE `IOT_Data` ( \";\ntopic = topic + \"`no` INT NULL AUTO_INCREMENT,\";\ntopic = topic + \"`date` DATETIME DEFAULT NULL,\";\ntopic = topic + \"`ActCntCyc` INT NULL,\";\ntopic = topic + \"`ActMaschinestate` INT NULL,\";\ntopic = topic + \"INDEX `no` (`no`)) COLLATE='latin1_swedish_ci';\";\nmsg.topic = topic;\n\nreturn msg;", "outputs": 1, "noerr": 12, "initialize": "", "finalize": "", "libs": [], "x": 1390, "y": 200, "wires": [ [ "c426f2cf33c5bc49" ] ] }, { "id": "8faca34adf7f5225", "type": "inject", "z": "8cc1361c68dc2d8f", "name": "CREATE", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 140, "y": 100, "wires": [ [ "aad135a3bde51009" ] ] }, { "id": "7a0b285634455cad", "type": "debug", "z": "8cc1361c68dc2d8f", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 2090, "y": 100, "wires": [] }, { "id": "aad135a3bde51009", "type": "function", "z": "8cc1361c68dc2d8f", "name": "DATABASE", "func": "var newMsg = {\n\"topic\" : \"CREATE DATABASE `IOT2050_Data`;\"\n}\nreturn newMsg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1410, "y": 100, "wires": [ [ "95b4228bd39fc616" ] ] }, { "id": "eec797ce76346f62", "type": "debug", "z": "8cc1361c68dc2d8f", "name": "debug 11", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 2100, "y": 200, "wires": [] }, { "id": "2e7d8a7675796a11", "type": "debug", "z": "8cc1361c68dc2d8f", "name": "debug 12", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 2080, "y": 280, "wires": [] }, { "id": "37dede5756e9e65b", "type": "change", "z": "8cc1361c68dc2d8f", "name": "", "rules": [ { "t": "move", "p": "payload.number", "pt": "msg", "to": "LOL", "tot": "msg" }, { "t": "set", "p": "mysqltimestamp", "pt": "msg", "to": "$moment($now()).format(\"YYYY-MM-DD HH:mm:ss\")\t", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 780, "y": 260, "wires": [ [ "4fab32aa2c7cc31e" ] ] }, { "id": "245dd7bd5aab7131", "type": "inject", "z": "8cc1361c68dc2d8f", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "10", "crontab": "", "once": true, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 90, "y": 260, "wires": [ [ "62273cdcea369e50" ] ] }, { "id": "95b4228bd39fc616", "type": "mysql", "z": "8cc1361c68dc2d8f", "mydb": "07048d252636d6b8", "name": "", "x": 1690, "y": 100, "wires": [ [ "7a0b285634455cad" ] ] }, { "id": "c426f2cf33c5bc49", "type": "mysql", "z": "8cc1361c68dc2d8f", "mydb": "5345a8ba384d4504", "name": "", "x": 1690, "y": 200, "wires": [ [ "eec797ce76346f62" ] ] }, { "id": "b9eecf9b0edffcce", "type": "mysql", "z": "8cc1361c68dc2d8f", "mydb": "5345a8ba384d4504", "name": "", "x": 1690, "y": 280, "wires": [ [ "2e7d8a7675796a11", "492fafd1f8feda9c" ] ] }, { "id": "62273cdcea369e50", "type": "OpcUa-Item", "z": "8cc1361c68dc2d8f", "item": "ns=4;i=6008", "datatype": "Int32", "value": "", "name": "CounterTotalPcs", "x": 260, "y": 260, "wires": [ [ "2c93014e5a3dd80a" ] ] }, { "id": "2c93014e5a3dd80a", "type": "OpcUa-Client", "z": "8cc1361c68dc2d8f", "endpoint": "f1aca64a72868a85", "action": "subscribe", "deadbandvalue": "0", "time": "5", "timeUnit": "s", "certificate": "n", "localfile": "", "localkeyfile": "", "folderName4PKI": "", "name": "", "x": 440, "y": 260, "wires": [ [ "27df998dd12ac537" ] ] }, { "id": "27df998dd12ac537", "type": "switch", "z": "8cc1361c68dc2d8f", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "lte", "v": "1000000", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 610, "y": 260, "wires": [ [ "37dede5756e9e65b" ] ] }, { "id": "c38314d148158b02", "type": "inject", "z": "8cc1361c68dc2d8f", "name": "checking for reconnect", "props": [], "repeat": "1", "crontab": "", "once": true, "onceDelay": 0.1, "topic": "", "x": 170, "y": 400, "wires": [ [ "668c25c0ee346a4d" ] ] }, { "id": "85e5c9681f5bbb24", "type": "delay", "z": "8cc1361c68dc2d8f", "name": "", "pauseType": "delay", "timeout": "1", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "1", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": false, "allowrate": false, "outputs": 1, "x": 160, "y": 520, "wires": [ [] ] }, { "id": "c8b642c4427d9fec", "type": "comment", "z": "8cc1361c68dc2d8f", "name": "checking for reconnect", "info": "jede sekunde einen input\ngeht durch wenn keine verbindung\nwartet 1 sekunde\ngeht durch wenn in der sekunde eine verbindung aufgebaut wurde\nsendet die gestauten daten in mindsphere und löscht aus mySql", "x": 160, "y": 560, "wires": [] }, { "id": "cb1d29f8cb49131d", "type": "is online", "z": "8cc1361c68dc2d8f", "name": "Pass through if online", "url": "", "action": "1", "x": 420, "y": 600, "wires": [ [] ] }, { "id": "668c25c0ee346a4d", "type": "is online", "z": "8cc1361c68dc2d8f", "name": "is offline", "url": "", "action": "2", "x": 140, "y": 480, "wires": [ [ "85e5c9681f5bbb24" ] ] }, { "id": "492fafd1f8feda9c", "type": "function", "z": "8cc1361c68dc2d8f", "name": "get values from mySql", "func": "msg.topic = \"SELECT date, ActCntCyc, actmaschinestate, no FROM IOT_Data\"\nreturn msg\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 760, "y": 520, "wires": [ [ "dab38a0dab37ca7a", "6f6bef4ac5071bad" ] ] }, { "id": "dab38a0dab37ca7a", "type": "debug", "z": "8cc1361c68dc2d8f", "name": "debug 13", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 1000, "y": 640, "wires": [] }, { "id": "9e165daa4186c2dd", "type": "function", "z": "8cc1361c68dc2d8f", "name": "values from mySql to cloud and delete", "func": "var items = msg.payload\nvar bufferMsg = {}\nvar no = []\nfor (var i = 0; i < items.length; i++) {\n var bufferValues = []\n no.push(items[i].no)\n bufferValues[0] = items[i].date\n bufferValues[1] = items[i].ActCntCyc\n bufferValues[2] = items[i].actmaschinestate\n msg.payload = bufferValues\n node.send(msg)\n}\nbufferMsg.payload = no\nreturn[null, bufferMsg]", "outputs": 2, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1290, "y": 520, "wires": [ [ "344dd7fb2385538c" ], [ "3dcd8b056ef0f83b", "1565143fbfec0221" ] ] }, { "id": "6f6bef4ac5071bad", "type": "mysql", "z": "8cc1361c68dc2d8f", "mydb": "5345a8ba384d4504", "name": "", "x": 1010, "y": 520, "wires": [ [ "9e165daa4186c2dd", "b2d5138ebd31dbb8" ] ] }, { "id": "3dcd8b056ef0f83b", "type": "function", "z": "8cc1361c68dc2d8f", "name": "delete out of mySql", "func": "var no = msg.payload\nmsg.payload = {}\nfor (var i = 0; i < no.length; i++) {\n msg.payload.id = no[i]\n msg.topic = \"DELETE FROM IOT_Data WHERE no = :id\"\n node.send(msg)\n}", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 890, "y": 820, "wires": [ [ "16d4d81734856563", "0d9d9071c5e4a987" ] ] }, { "id": "16d4d81734856563", "type": "mysql", "z": "8cc1361c68dc2d8f", "mydb": "5345a8ba384d4504", "name": "", "x": 1250, "y": 800, "wires": [ [] ] }, { "id": "0d9d9071c5e4a987", "type": "debug", "z": "8cc1361c68dc2d8f", "name": "debug 14", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 1180, "y": 900, "wires": [] }, { "id": "7fe425f1f243e5c2", "type": "mindconnect", "z": "8cc1361c68dc2d8f", "name": "", "configtype": "SHARED_SECRET", "agentconfig": "", "privatekey": "", "model": "", "validate": true, "validateevent": true, "chunk": false, "disablekeepalive": false, "emitcontrol": false, "datalakeonly": false, "supressverbosity": false, "retry": 3, "parallel": 1, "asyncduration": 10, "x": 2150, "y": 540, "wires": [ [ "20c61f952be66a28" ] ] }, { "id": "20c61f952be66a28", "type": "debug", "z": "8cc1361c68dc2d8f", "name": "debug 15", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 2440, "y": 540, "wires": [] }, { "id": "b2d5138ebd31dbb8", "type": "debug", "z": "8cc1361c68dc2d8f", "name": "debug 17", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 1440, "y": 700, "wires": [] }, { "id": "344dd7fb2385538c", "type": "function", "z": "8cc1361c68dc2d8f", "name": "convert to mindconnect", "func": "\n// take a look at the flow examples at https://playground.mindconnect.rocks\n//\n// - MindSphere expects all values to be encoded as strings\n// - Integers must not have any decimal places\n// - It is a good practice to use javascript literal notation\n// \n// * Examples: \n// \n// - Random value between 0 and 100: `${Math.random()*100}` \n// - Variable (HUMIDITY) from input node : `${msg.payload.HUMIDITY}` \n// - Variable (SPEED) from input node with 0 as default: `${msg.payload.SPEED || 0}`\n\nconst values = [\n {\n timestamp: `${msg.payload[0]}`,\n values: [{\n \"dataPointId\": \"DP-OPC_UA_COUNTER\",\n \"qualityCode\": \"1\",\n \"value\": `${msg.payload[1]}`\n }]\n }\n];\nmsg._time = new Date();\nmsg.payload = values;\nreturn msg;\n\n\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1730, "y": 540, "wires": [ [ "7fe425f1f243e5c2" ] ] }, { "id": "1565143fbfec0221", "type": "debug", "z": "8cc1361c68dc2d8f", "name": "debug 20", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 1820, "y": 640, "wires": [] }, { "id": "c5b915f19cc37ff7", "type": "function", "z": "8cc1361c68dc2d8f", "name": "function 2", "func": "let values = [\n {\n \"dataPointId\": \"DP-OPC_UA_COUNTER\",\n \"qualityCode\": \"1\",\n \"value\": `${msg.payload}`\n },\n];\nmsg.payload = values;\nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1740, "y": 460, "wires": [ [] ] }, { "id": "cec50056030a6f52", "type": "comment", "z": "8cc1361c68dc2d8f", "name": "Fault", "info": "Mindsphere Aspect List is online, but no values", "x": 2130, "y": 480, "wires": [] }, { "id": "2af5ab65f9073774", "type": "comment", "z": "8cc1361c68dc2d8f", "name": "Informaton", "info": "With \"Read\" its working", "x": 440, "y": 320, "wires": [] }, { "id": "07048d252636d6b8", "type": "MySQLdatabase", "name": "", "host": "127.0.0.1", "port": "3306", "db": "Test", "tz": "", "charset": "UTF8" }, { "id": "5345a8ba384d4504", "type": "MySQLdatabase", "name": "", "host": "127.0.0.1", "port": "3306", "db": "iot2050_data", "tz": "", "charset": "UTF8" }, { "id": "f1aca64a72868a85", "type": "OpcUa-Endpoint", "endpoint": "opc.tcp://10.232.19.117:4840", "secpol": "None", "secmode": "None", "none": true, "login": false, "usercert": false, "usercertificate": "", "userprivatekey": "" } ]