From fd9bb17fd99254bcc3a7e9a0f8db44e0005cab96 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Mar 2023 22:05:12 +0000 Subject: [PATCH 01/22] chore(deps): update node.js to 18.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5cadd37..fbb6361 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,6 @@ "semantic-release-preconfigured-conventional-commits": "1.1.16" }, "engines": { - "node": "18.14" + "node": "18.15" } } From 16b8be37cdaef26b4089f0c8632613f23588ad7c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:39:27 +0000 Subject: [PATCH 02/22] chore(deps): update dependency semantic-release-preconfigured-conventional-commits to v1.1.17 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fbb6361..c41576a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "semantic-release-preconfigured-conventional-commits": "1.1.16" + "semantic-release-preconfigured-conventional-commits": "1.1.17" }, "engines": { "node": "18.15" From b631dce46517436e2a3b5c9a29d14d58f0d5fcc0 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 7 Feb 2023 23:02:14 +0100 Subject: [PATCH 03/22] chore: change name to the serial on switch node --- data/flows.json | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/data/flows.json b/data/flows.json index b400856..3bfa64b 100644 --- a/data/flows.json +++ b/data/flows.json @@ -662,37 +662,19 @@ "rules": [ { "t": "eq", - "v": "1", - "vt": "str" - }, - { - "t": "eq", - "v": "2", - "vt": "str" - }, - { - "t": "eq", - "v": "3", - "vt": "str" - }, - { - "t": "eq", - "v": "4", + "v": "/dev/ttyUSB0", "vt": "str" } ], "checkall": "true", "repair": false, - "outputs": 4, + "outputs": 1, "x": 1890, "y": 1300, "wires": [ [ "ea1d80c07843fb89" - ], - [], - [], - [] + ] ] }, { From 9483cf0918cf8a74c36d6da77a99f364043e2990 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 7 Feb 2023 23:02:49 +0100 Subject: [PATCH 04/22] chore: delete unused inject nodes --- data/flows.json | 87 ------------------------------------------------- 1 file changed, 87 deletions(-) diff --git a/data/flows.json b/data/flows.json index 3bfa64b..8dfaf93 100644 --- a/data/flows.json +++ b/data/flows.json @@ -1230,35 +1230,6 @@ ] ] }, - { - "id": "fd738f445c2a696f", - "type": "inject", - "z": "09012e75c72a4968", - "name": "", - "props": [ - { - "p": "payload" - }, - { - "p": "topic", - "vt": "str" - } - ], - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "topic": "", - "payload": "{\"type\":0, \"room_id\": \"room1\", \"temperature_value\": 23, \"temperature_unit\": \"celsius\"}", - "payloadType": "json", - "x": 90, - "y": 80, - "wires": [ - [ - "ead8458e27835fd5" - ] - ] - }, { "id": "6b1290a059fc78a2", "type": "serial in", @@ -1301,63 +1272,5 @@ "x": 2070, "y": 1280, "wires": [] - }, - { - "id": "85e6e0aba603f370", - "type": "inject", - "z": "09012e75c72a4968", - "name": "", - "props": [ - { - "p": "payload" - }, - { - "p": "topic", - "vt": "str" - } - ], - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "topic": "", - "payload": "{\"type\":9, \"room_id\": \"room1\"}", - "payloadType": "json", - "x": 90, - "y": 260, - "wires": [ - [ - "ead8458e27835fd5" - ] - ] - }, - { - "id": "8d0bcc7809691b1b", - "type": "inject", - "z": "09012e75c72a4968", - "name": "", - "props": [ - { - "p": "payload" - }, - { - "p": "topic", - "vt": "str" - } - ], - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "topic": "", - "payload": "{\"type\":8, \"actuator_id\": \"act2\", \"actuator_type\": \"temp_sensor\", \"room_id\": \"room1\"}", - "payloadType": "json", - "x": 90, - "y": 320, - "wires": [ - [ - "ead8458e27835fd5" - ] - ] } ] \ No newline at end of file From c109f5737ce564bf7bb168151218f8e31e02fa90 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 7 Feb 2023 23:05:51 +0100 Subject: [PATCH 05/22] chore: add cast to int if state is a number --- data/flows.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/flows.json b/data/flows.json index 8dfaf93..ea6ba1a 100644 --- a/data/flows.json +++ b/data/flows.json @@ -1036,13 +1036,13 @@ "type": "function", "z": "09012e75c72a4968", "name": "setSerialMessage", - "func": "msg.payload = {}\nmsg.payload[\"command\"] = msg.type\nmsg.payload[\"room_id\"] = msg.room_id\nmsg.payload[\"status\"] = msg.state\n\nreturn msg;", + "func": "msg.state = isNaN(msg.state) ? msg.state : parseInt(msg.state)\nmsg.payload = {}\nmsg.payload[\"command\"] = msg.type\nmsg.payload[\"room_id\"] = msg.room_id\nmsg.payload[\"status\"] = msg.state\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 1710, + "x": 1690, "y": 1300, "wires": [ [ From a5db6cffa4da02a071cc504f11f017343bd2510d Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 7 Feb 2023 23:11:16 +0100 Subject: [PATCH 06/22] chore: edit commands to run the docker container --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c94242d..563d915 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,17 @@ Due to a bug in the node-red-node-serialport library, it is not possible to exec To run the microservice use the following docker command: ``` bash +#!/bin/bash $ docker rm operating-block-gateway -$ docker run -d --rm --device /dev/ttyUSB0:/dev/ttyUSB0 -v ./data:/data -p 1880:1880 -e NODE_RED_ENABLE_SAFE_MODE=true ghcr.io/smartoperatingblock/operating-block-gateway: -$ docker exec -it operating-block-gateway /bin/sh -c "cd /data; npm rebuild --build-from-source; exit" +$ docker rm operating-block-gateway-rebuilded +$ docker run -d --rm --name operating-block-gateway --device /dev/ttyUSB0:/dev/ttyUSB0 -v ./data:/data -p 1880:1880 -e NODE_RED_ENABLE_SAFE_MODE=true nodered/node-red +$ docker exec operating-block-gateway /bin/sh -c "cd /data; npm install node-red-contrib-https; npm install node-red-node-serialport" +$ docker exec operating-block-gateway /bin/sh -c "cd /data; npm rebuild --build-from-source" $ docker stop operating-block-gateway -$ docker run -p 1880:1880 -v ./data:/data --device /dev/ttyUSB0:/dev/ttyUSB0 --group-add dialout --env-file .env --name operating-block-gateway ghcr.io/smartoperatingblock/operating-block-gateway: +$ docker run -p 1880:1880 -v ./data:/data --device /dev/ttyUSB0:/dev/ttyUSB0 --group-add dialout --env-file .env --name operating-block-gateway-rebuilded nodered/node-red ``` -In order to simplify we provide a bash script that executes all the instructions above automatically. +In order to simplify we provide a bash script called bootstrap.sh that executes all the instructions above automatically. From f9c03f702ef0f15cf702dbfc817f07f2b62ee483 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 7 Feb 2023 23:11:41 +0100 Subject: [PATCH 07/22] chore: deletedockerfile --- Dockerfile | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 3152d23..0000000 --- a/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM nodered/node-red:2.2.3-12 - -#Install additional node -WORKDIR /usr/src/node-red -RUN npm install node-red-contrib-https -RUN npm install node-red-node-serialport From f0cbdec397c36773784c98dc0d7b033102f5c7b1 Mon Sep 17 00:00:00 2001 From: giacomoaccursi <52125090+giacomoaccursi@users.noreply.github.com> Date: Tue, 14 Feb 2023 19:37:21 +0100 Subject: [PATCH 08/22] chore: add command to clean configFiles --- bootstrap.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 1c606da..415917a 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -4,5 +4,6 @@ docker rm operating-block-gateway-rebuilded docker run -d --rm --name operating-block-gateway --device /dev/ttyUSB0:/dev/ttyUSB0 -v ./data:/data -p 1880:1880 -e NODE_RED_ENABLE_SAFE_MODE=true nodered/node-red docker exec operating-block-gateway /bin/sh -c "cd /data; npm install node-red-contrib-https; npm install node-red-node-serialport" docker exec operating-block-gateway /bin/sh -c "cd /data; npm rebuild --build-from-source" +docker exec operating-block-gateway /bin/sh -c "cd /data/configFiles; echo -n '' > *" docker stop operating-block-gateway -docker run -p 1880:1880 -v ./data:/data --device /dev/ttyUSB0:/dev/ttyUSB0 --group-add dialout --env-file .env --name operating-block-gateway-rebuilded nodered/node-red \ No newline at end of file +docker run -p 1880:1880 -v ./data:/data --device /dev/ttyUSB0:/dev/ttyUSB0 --group-add dialout --env-file .env --name operating-block-gateway-rebuilded nodered/node-red From 6b62efb09ccacfe5b1b97887b05570086ad5cb18 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Mon, 13 Feb 2023 15:40:26 +0100 Subject: [PATCH 09/22] chore: add serial port and https dependencies --- data/package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/package.json b/data/package.json index 4b5625c..c137ec4 100644 --- a/data/package.json +++ b/data/package.json @@ -8,5 +8,9 @@ "flowFile": "flows.json", "credentialsFile": "flows_cred.json" } + }, + "dependencies": { + "node-red-contrib-https": "~2.0.0", + "node-red-node-serialport": "~1.0.3" } -} \ No newline at end of file +} From 642d635abfa161ef8acfdaf8e2926a437951b131 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Mon, 13 Feb 2023 15:41:03 +0100 Subject: [PATCH 10/22] chore: disable project_enabled flag --- data/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/settings.js b/data/settings.js index 3dfc09b..ec247a6 100644 --- a/data/settings.js +++ b/data/settings.js @@ -390,7 +390,7 @@ module.exports = { projects: { /** To enable the Projects feature, set this value to true */ - enabled: true, + enabled: false, workflow: { /** Set the default projects workflow mode. * - manual - you must manually commit changes From 64d7389f1b88d781076b175d4498a6aa038425b5 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Mon, 13 Feb 2023 15:41:46 +0100 Subject: [PATCH 11/22] feat: add commands to update room digital twin on azure plaftorm --- data/flows.json | 152 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 143 insertions(+), 9 deletions(-) diff --git a/data/flows.json b/data/flows.json index ea6ba1a..5b7fa25 100644 --- a/data/flows.json +++ b/data/flows.json @@ -104,7 +104,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "UpdateTemperature", - "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": jsonData[\"temperature\"][\"path\"],\n \"value\": parseInt(msg.temperature_value)\n }\n]\n\nmsg.payload = {}\n\nmsg.url = \"https://room.api.wcus.digitaltwins.azure.net/digitaltwins/\"+ msg.room_id +\"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n\n", + "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/temperature\",\n \"value\": parseFloat(msg.temperature_value)\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\"+ msg.room_id +\"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n\n", "outputs": 1, "noerr": 0, "initialize": "", @@ -114,7 +114,8 @@ "y": 500, "wires": [ [ - "c45a10208faeea88" + "c45a10208faeea88", + "3b4b32fc0ebfe72e" ] ] }, @@ -123,7 +124,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "processSerialData", - "func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.temperature_value = msg.serialData[\"temperature_value\"]\nmsg.temperature_unit = msg.serialData[\"temperature_unit\"]\n\nreturn msg;", + "func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.temperature_value = msg.serialData[\"temperature_value\"]\n//msg.temperature_unit = msg.serialData[\"temperature_unit\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -886,7 +887,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "processSerialData", - "func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.luminosity_value = msg.serialData[\"luminosity_value\"]\nmsg.luminosity_unit = msg.serialData[\"luminosity_unit\"]\n\nreturn msg;", + "func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.luminosity_value = msg.serialData[\"luminosity_value\"]\n//msg.luminosity_unit = msg.serialData[\"luminosity_unit\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -924,7 +925,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "UpdateHumidity", - "func": "\n\n", + "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/humidity\",\n \"value\": parseFloat(msg.humidity_percentage)\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n\n", "outputs": 1, "noerr": 0, "initialize": "", @@ -943,7 +944,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "UpdateLuminosity", - "func": "\n\n", + "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/luminosity\",\n \"value\": parseFloat(msg.luminosity_value)\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n", "outputs": 1, "noerr": 0, "initialize": "", @@ -962,7 +963,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "UpdatePersonInside", - "func": "", + "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/presence_inside\",\n \"value\": msg.person_inside\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n", "outputs": 1, "noerr": 0, "initialize": "", @@ -1255,8 +1256,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 280, - "y": 180, + "x": 320, + "y": 240, "wires": [ [ "272e66b82d47e0e4" @@ -1272,5 +1273,138 @@ "x": 2070, "y": 1280, "wires": [] + }, + { + "id": "6c9f6e80226a5597", + "type": "inject", + "z": "09012e75c72a4968", + "name": "type0", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 0, \"room_id\": \"room1\", \"temperature_value\": 24, \"temperature_unit\": \"celsius\"}", + "payloadType": "str", + "x": 110, + "y": 260, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "3b4b32fc0ebfe72e", + "type": "debug", + "z": "09012e75c72a4968", + "name": "debug 1", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "statusVal": "", + "statusType": "auto", + "x": 1660, + "y": 440, + "wires": [] + }, + { + "id": "781486d011dadee8", + "type": "inject", + "z": "09012e75c72a4968", + "name": "type1", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 1, \"room_id\": \"room1\", \"humidity_percentage\": 40}", + "payloadType": "str", + "x": 110, + "y": 300, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "8c25201c78c9ab3b", + "type": "inject", + "z": "09012e75c72a4968", + "name": "type2", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 2, \"room_id\": \"room1\", \"luminosity_value\": 1000}", + "payloadType": "str", + "x": 110, + "y": 340, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "26ec74664cb5ff41", + "type": "inject", + "z": "09012e75c72a4968", + "name": "type3", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 3, \"room_id\": \"room1\", \"person_inside\": true}", + "payloadType": "str", + "x": 110, + "y": 380, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] } ] \ No newline at end of file From 7ca46c5e618bed8b44fc901e0fb737e8a64edcc0 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Mon, 13 Feb 2023 16:14:46 +0100 Subject: [PATCH 12/22] feat: add commands to update actuator digital twin on azure plaftorm --- data/flows.json | 208 +++++++++++++++++++++++++++--------------------- 1 file changed, 118 insertions(+), 90 deletions(-) diff --git a/data/flows.json b/data/flows.json index 5b7fa25..d23b56e 100644 --- a/data/flows.json +++ b/data/flows.json @@ -114,8 +114,7 @@ "y": 500, "wires": [ [ - "c45a10208faeea88", - "3b4b32fc0ebfe72e" + "c45a10208faeea88" ] ] }, @@ -143,7 +142,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "UpdateActuatorState", - "func": "", + "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/intensity_percentage\",\n \"value\": msg.intensity_percentage\n },\n {\n \"op\": \"add\",\n \"path\": \"/power_state\",\n \"value\": msg.state\n },\n {\n \"op\": \"add\",\n \"path\": \"/type\",\n \"value\": jsonData[msg.actuator_id][\"type\"]\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.actuator_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n", "outputs": 1, "noerr": 0, "initialize": "", @@ -153,7 +152,8 @@ "y": 740, "wires": [ [ - "c45a10208faeea88" + "c45a10208faeea88", + "b19dbb8d1bfea2fc" ] ] }, @@ -464,28 +464,6 @@ ] ] }, - { - "id": "6a5968a77bdcb8ec", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "txt", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 2050, - "y": 720, - "wires": [ - [ - "3e879afc64077b51" - ] - ] - }, { "id": "3a01a886905e5fed", "type": "http in", @@ -697,28 +675,6 @@ ] ] }, - { - "id": "dd96318fc1b5b6c4", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "getToken", - "method": "GET", - "ret": "obj", - "paytoqs": "body", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 1620, - "y": 180, - "wires": [ - [ - "1453612b8d0a384b" - ] - ] - }, { "id": "1453612b8d0a384b", "type": "function", @@ -1116,7 +1072,7 @@ "type": "file in", "z": "09012e75c72a4968", "name": "read file", - "filename": "/data/configFiles/type0.json", + "filename": "/data/configFiles/actuator_room_mapping.json", "filenameType": "str", "format": "utf8", "chunk": false, @@ -1231,20 +1187,6 @@ ] ] }, - { - "id": "6b1290a059fc78a2", - "type": "serial in", - "z": "09012e75c72a4968", - "name": "", - "serial": "94b8abb47e4cb1f2", - "x": 110, - "y": 180, - "wires": [ - [ - "ead8458e27835fd5" - ] - ] - }, { "id": "ead8458e27835fd5", "type": "function", @@ -1264,16 +1206,6 @@ ] ] }, - { - "id": "ea1d80c07843fb89", - "type": "serial out", - "z": "09012e75c72a4968", - "name": "", - "serial": "94b8abb47e4cb1f2", - "x": 2070, - "y": 1280, - "wires": [] - }, { "id": "6c9f6e80226a5597", "type": "inject", @@ -1303,23 +1235,6 @@ ] ] }, - { - "id": "3b4b32fc0ebfe72e", - "type": "debug", - "z": "09012e75c72a4968", - "name": "debug 1", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1660, - "y": 440, - "wires": [] - }, { "id": "781486d011dadee8", "type": "inject", @@ -1406,5 +1321,118 @@ "ead8458e27835fd5" ] ] + }, + { + "id": "6b1290a059fc78a2", + "type": "serial in", + "z": "09012e75c72a4968", + "name": "", + "serial": "94b8abb47e4cb1f2", + "x": 130, + "y": 180, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "ea1d80c07843fb89", + "type": "serial out", + "z": "09012e75c72a4968", + "name": "", + "serial": "94b8abb47e4cb1f2", + "x": 2090, + "y": 1280, + "wires": [] + }, + { + "id": "6a5968a77bdcb8ec", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 2050, + "y": 720, + "wires": [ + [ + "3e879afc64077b51" + ] + ] + }, + { + "id": "dd96318fc1b5b6c4", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "getToken", + "method": "GET", + "ret": "obj", + "paytoqs": "body", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 1620, + "y": 180, + "wires": [ + [ + "1453612b8d0a384b" + ] + ] + }, + { + "id": "105b0c2203081bf6", + "type": "inject", + "z": "09012e75c72a4968", + "name": "type4", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 4, \"actuator_id\": \"act1\", \"state\" : \"on\", \"intensity_percentage\": 40}", + "payloadType": "str", + "x": 110, + "y": 420, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "b19dbb8d1bfea2fc", + "type": "debug", + "z": "09012e75c72a4968", + "name": "debug 1", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 1900, + "y": 860, + "wires": [] } ] \ No newline at end of file From c25e97c119a999d6fbf931a95663b78222da190c Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 14 Feb 2023 12:42:35 +0100 Subject: [PATCH 13/22] feat: add commands to update medical device digital twin on azure plaftorm --- data/flows.json | 310 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 276 insertions(+), 34 deletions(-) diff --git a/data/flows.json b/data/flows.json index d23b56e..d62b72a 100644 --- a/data/flows.json +++ b/data/flows.json @@ -152,8 +152,7 @@ "y": 740, "wires": [ [ - "c45a10208faeea88", - "b19dbb8d1bfea2fc" + "c45a10208faeea88" ] ] }, @@ -181,7 +180,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "MedicalDeviceTracking", - "func": "", + "func": "let medicalDeviceModel = \"dtmi:io:github:smartoperatingblock:ImplantableMedicalDevice;1\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.device_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\n\nmsg.payload = {\n \"$metadata\": {\n \"$model\": medicalDeviceModel\n }, \n \"type\" : msg.device_type \n}\n\nreturn msg\n", "outputs": 1, "noerr": 0, "initialize": "", @@ -191,7 +190,7 @@ "y": 860, "wires": [ [ - "c45a10208faeea88" + "1024090145928519" ] ] }, @@ -456,8 +455,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1870, - "y": 720, + "x": 2910, + "y": 700, "wires": [ [ "6a5968a77bdcb8ec" @@ -494,8 +493,8 @@ "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 2220, - "y": 720, + "x": 3240, + "y": 700, "wires": [] }, { @@ -512,7 +511,9 @@ "x": 1560, "y": 980, "wires": [ - [] + [ + "1a6d9092c128a0bd" + ] ] }, { @@ -661,7 +662,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "setRequestToGetToken", - "func": "msg.headers = {};\nmsg.headers['Content-Type'] = \"application/x-www-form-urlencoded\"\nmsg.payload = `grant_type = client_credentials &\n client_id = ` + env.get(\"AZURE_DT_CLIENT_ID\") + ` &\n client_secret =` + env.get(\"AZURE_DT_CLIENT_SECRET\") + ` &\n resource = https://digitaltwins.azure.net \n `\nmsg.url = \"https://login.microsoftonline.com/\"+ env.get(\"AZURE_DT_TENANT_ID\") +\"/oauth2/token\" \nreturn msg;", + "func": "msg.headers = {};\nmsg.headers['Content-Type'] = \"application/x-www-form-urlencoded\"\nmsg.payload = `grant_type = client_credentials &\n client_id = ` + env.get(\"AZURE_DT_CLIENT_ID\") + ` &\n client_secret =` + env.get(\"AZURE_DT_CLIENT_SECRET\") + ` &\n resource = https://digitaltwins.azure.net\n `\nmsg.url = \"https://login.microsoftonline.com/\"+ env.get(\"AZURE_DT_TENANT_ID\") +\"/oauth2/token\" \nreturn msg;\n//https://digitaltwins.azure.net", "outputs": 1, "noerr": 0, "initialize": "", @@ -1336,16 +1337,6 @@ ] ] }, - { - "id": "ea1d80c07843fb89", - "type": "serial out", - "z": "09012e75c72a4968", - "name": "", - "serial": "94b8abb47e4cb1f2", - "x": 2090, - "y": 1280, - "wires": [] - }, { "id": "6a5968a77bdcb8ec", "type": "https-node", @@ -1360,8 +1351,8 @@ "proxy": "", "authType": "", "senderr": false, - "x": 2050, - "y": 720, + "x": 3070, + "y": 700, "wires": [ [ "3e879afc64077b51" @@ -1420,19 +1411,270 @@ ] }, { - "id": "b19dbb8d1bfea2fc", - "type": "debug", + "id": "61b317ae6b43b406", + "type": "inject", "z": "09012e75c72a4968", - "name": "debug 1", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "false", - "statusVal": "", - "statusType": "auto", - "x": 1900, - "y": 860, + "name": "type6", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 6, \"device_type\": \"0\", \"device_id\" : \"med2\", \"room_id\": \"room1\"}", + "payloadType": "str", + "x": 110, + "y": 460, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "1a6d9092c128a0bd", + "type": "function", + "z": "09012e75c72a4968", + "name": "createActuatorDT", + "func": "let actuatorModel = \"dtmi:io:github:smartoperatingblock:Actuator;1\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.actuator_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\n\nmsg.payload = {\n \"$metadata\": {\n \"$model\": actuatorModel\n },\n \"type\": msg.actuator_type\n}\n\nreturn msg", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1750, + "y": 980, + "wires": [ + [ + "f1d5bf00146cb950" + ] + ] + }, + { + "id": "c02092f546355c98", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 2130, + "y": 980, + "wires": [ + [ + "7e2fc28f43937855" + ] + ] + }, + { + "id": "7e2fc28f43937855", + "type": "function", + "z": "09012e75c72a4968", + "name": "createRelationShipWithRoom", + "func": "let relID = msg.room_id + \"-\" + msg.actuator_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \"/relationships/\" + relID + \"?api-version=2020-10-31\"\nmsg.method = \"put\"\nmsg.payload = \n {\n \"$targetId\": msg.actuator_id,\n \"$relationshipName\": \"rel_has_actuator\"\n }\n\n\n\nreturn msg\n", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2370, + "y": 980, + "wires": [ + [ + "c45a10208faeea88" + ] + ] + }, + { + "id": "c6c4f1b87153a885", + "type": "inject", + "z": "09012e75c72a4968", + "name": "type8", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 8, \"actuator_type\": \"0\", \"actuator_id\" : \"act111\", \"room_id\": \"room1\"}", + "payloadType": "str", + "x": 110, + "y": 500, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "f1d5bf00146cb950", + "type": "function", + "z": "09012e75c72a4968", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1950, + "y": 980, + "wires": [ + [ + "c02092f546355c98" + ] + ] + }, + { + "id": "ea1d80c07843fb89", + "type": "serial out", + "z": "09012e75c72a4968", + "name": "", + "serial": "94b8abb47e4cb1f2", + "x": 2090, + "y": 1280, "wires": [] + }, + { + "id": "1024090145928519", + "type": "function", + "z": "09012e75c72a4968", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1590, + "y": 860, + "wires": [ + [ + "b172127aa6066d80" + ] + ] + }, + { + "id": "b172127aa6066d80", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 1750, + "y": 860, + "wires": [ + [ + "1005329bc4b3f3df" + ] + ] + }, + { + "id": "745c5f5dda78248a", + "type": "function", + "z": "09012e75c72a4968", + "name": "createRelationShipWithRoom", + "func": "let process_id = JSON.parse(msg.payload)\nprocess_id = msg.process_id[\"value\"][0][\"$dtId\"]\nlet relID = process_id + \"-\" + msg.device_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + process_id + \"/relationships/\" + relID + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\nmsg.payload = {\n \"$targetId\": msg.device_id,\n \"$relationshipName\": \"rel_contains_medical_technology\"\n}\n\nreturn msg\n", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2670, + "y": 860, + "wires": [ + [ + "c45a10208faeea88" + ] + ] + }, + { + "id": "1005329bc4b3f3df", + "type": "function", + "z": "09012e75c72a4968", + "name": "requestProcessRelatedToTheRoom", + "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) Process.$dtId, Process FROM digitaltwins Process JOIN Room RELATED Process.process.rel_is_inside WHERE Room.$dtId = 'room1' AND Process.process_state = '1'\"\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1990, + "y": 860, + "wires": [ + [ + "3b376db55eb10b0f" + ] + ] + }, + { + "id": "d743a7865378b0dc", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 2430, + "y": 860, + "wires": [ + [ + "745c5f5dda78248a" + ] + ] + }, + { + "id": "3b376db55eb10b0f", + "type": "function", + "z": "09012e75c72a4968", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2250, + "y": 860, + "wires": [ + [ + "d743a7865378b0dc" + ] + ] } ] \ No newline at end of file From 6921265f3dac670dfd3f2372e943e7dd320d37c6 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 14 Feb 2023 14:09:41 +0100 Subject: [PATCH 14/22] feat: add commands to set patient on operating table in azure platform --- data/flows.json | 180 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 150 insertions(+), 30 deletions(-) diff --git a/data/flows.json b/data/flows.json index d62b72a..d211c7c 100644 --- a/data/flows.json +++ b/data/flows.json @@ -194,25 +194,6 @@ ] ] }, - { - "id": "d1be411bbad65001", - "type": "function", - "z": "09012e75c72a4968", - "name": "PatientOnOperatingTable", - "func": "", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1380, - "y": 920, - "wires": [ - [ - "c45a10208faeea88" - ] - ] - }, { "id": "f749ed1e2e58c229", "type": "function", @@ -455,8 +436,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2910, - "y": 700, + "x": 3210, + "y": 740, "wires": [ [ "6a5968a77bdcb8ec" @@ -493,8 +474,8 @@ "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 3240, - "y": 700, + "x": 3560, + "y": 740, "wires": [] }, { @@ -1144,7 +1125,7 @@ "y": 920, "wires": [ [ - "d1be411bbad65001" + "61eca1567ddb5e81" ] ] }, @@ -1351,8 +1332,8 @@ "proxy": "", "authType": "", "senderr": false, - "x": 3070, - "y": 700, + "x": 3390, + "y": 740, "wires": [ [ "3e879afc64077b51" @@ -1472,7 +1453,7 @@ "proxy": "", "authType": "", "senderr": false, - "x": 2130, + "x": 2110, "y": 980, "wires": [ [ @@ -1491,7 +1472,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2370, + "x": 2910, "y": 980, "wires": [ [ @@ -1609,7 +1590,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2670, + "x": 2650, "y": 860, "wires": [ [ @@ -1622,7 +1603,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "requestProcessRelatedToTheRoom", - "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) Process.$dtId, Process FROM digitaltwins Process JOIN Room RELATED Process.process.rel_is_inside WHERE Room.$dtId = 'room1' AND Process.process_state = '1'\"\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", + "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) SurgicalProcess.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Room RELATED SurgicalProcess.rel_is_inside WHERE Room.$dtId = \" + msg.room_id\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -1676,5 +1657,144 @@ "d743a7865378b0dc" ] ] + }, + { + "id": "61eca1567ddb5e81", + "type": "function", + "z": "09012e75c72a4968", + "name": "requestProcessRelatedToTheRoom", + "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) SurgicalProcess.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Room RELATED SurgicalProcess.rel_is_inside WHERE Room.$dtId = \" + msg.room_id\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1430, + "y": 920, + "wires": [ + [ + "780cd80ab50444c2" + ] + ] + }, + { + "id": "780cd80ab50444c2", + "type": "function", + "z": "09012e75c72a4968", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1690, + "y": 920, + "wires": [ + [ + "955129310e7a1ad4" + ] + ] + }, + { + "id": "955129310e7a1ad4", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 1850, + "y": 920, + "wires": [ + [ + "f51c81bfe7e71efa" + ] + ] + }, + { + "id": "f51c81bfe7e71efa", + "type": "function", + "z": "09012e75c72a4968", + "name": "requestPatientRelatedToTheProcess", + "func": "let process_id = JSON.parse(msg.payload)\nprocess_id = msg.process_id[\"value\"][0][\"$dtId\"]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) Patient.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Patient RELATED SurgicalProcess.rel_involve_patient where SurgicalProcess.$dtId =\"+ process_id\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2110, + "y": 920, + "wires": [ + [ + "dff86deba04d2359" + ] + ] + }, + { + "id": "dff86deba04d2359", + "type": "function", + "z": "09012e75c72a4968", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2370, + "y": 920, + "wires": [ + [ + "e1b522b4e3afd1db" + ] + ] + }, + { + "id": "e1b522b4e3afd1db", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 2550, + "y": 920, + "wires": [ + [ + "a35b075974d1b012" + ] + ] + }, + { + "id": "a35b075974d1b012", + "type": "function", + "z": "09012e75c72a4968", + "name": "setPatientOnOperatingTable", + "func": "let patient_id = JSON.parse(msg.payload)\npatient_id = msg.process_id[\"value\"][0][\"$dtId\"]\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/isOnOperatingTable\",\n \"value\": true\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + patient_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2760, + "y": 920, + "wires": [ + [ + "c45a10208faeea88" + ] + ] } ] \ No newline at end of file From d4ccdb7f2eaa2571fcaca7494fc1d8e3e984157d Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 14 Feb 2023 18:55:34 +0100 Subject: [PATCH 15/22] feat: add commands to manage people tracking on azure plaftform --- data/flows.json | 774 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 553 insertions(+), 221 deletions(-) diff --git a/data/flows.json b/data/flows.json index d211c7c..d201bf2 100644 --- a/data/flows.json +++ b/data/flows.json @@ -111,7 +111,7 @@ "finalize": "", "libs": [], "x": 1380, - "y": 500, + "y": 460, "wires": [ [ "c45a10208faeea88" @@ -130,7 +130,7 @@ "finalize": "", "libs": [], "x": 930, - "y": 500, + "y": 460, "wires": [ [ "af11a3caafbb5fa8" @@ -149,26 +149,7 @@ "finalize": "", "libs": [], "x": 1380, - "y": 740, - "wires": [ - [ - "c45a10208faeea88" - ] - ] - }, - { - "id": "38965161414b027a", - "type": "function", - "z": "09012e75c72a4968", - "name": "PersonEnterExit", - "func": "\n", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1360, - "y": 800, + "y": 700, "wires": [ [ "c45a10208faeea88" @@ -186,8 +167,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1380, - "y": 860, + "x": 1370, + "y": 1000, "wires": [ [ "1024090145928519" @@ -205,8 +186,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1360, - "y": 980, + "x": 1350, + "y": 1120, "wires": [ [ "5c6d578149de144a" @@ -225,7 +206,7 @@ "finalize": "", "libs": [], "x": 930, - "y": 740, + "y": 700, "wires": [ [ "635a32e66dd92586" @@ -244,30 +225,10 @@ "finalize": "", "libs": [], "x": 930, - "y": 800, - "wires": [ - [ - "145386797b8afe53" - ] - ] - }, - { - "id": "af11a3caafbb5fa8", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 500, + "y": 820, "wires": [ [ - "32174867b86c7b03" + "7810c6d0751cfd37" ] ] }, @@ -379,8 +340,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 930, - "y": 860, + "x": 920, + "y": 1000, "wires": [ [ "cb314a12c20513b3" @@ -398,8 +359,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 930, - "y": 920, + "x": 920, + "y": 1060, "wires": [ [ "3dc151189b79fc01" @@ -417,8 +378,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 930, - "y": 980, + "x": 920, + "y": 1120, "wires": [ [ "f6e56c9200cdd690" @@ -489,8 +450,8 @@ "createDir": false, "overwriteFile": "true", "encoding": "utf8", - "x": 1560, - "y": 980, + "x": 1550, + "y": 1120, "wires": [ [ "1a6d9092c128a0bd" @@ -662,7 +623,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "saveToken", - "func": "msg.token = msg.payload[\"access_token\"]\nmsg.expires_on = msg.payload[\"expiresOn\"]\nmsg.payload = {}\nmsg.payload[\"expiresOn\"] = msg.expires_on\nmsg.payload[\"token\"] = msg.token\n\nreturn msg;", + "func": "msg.token = msg.payload[\"access_token\"]\nmsg.expires_on = msg.payload[\"expires_on\"]\nmsg.payload = {}\nmsg.payload[\"expires_on\"] = msg.expires_on\nmsg.payload[\"token\"] = msg.token\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -681,7 +642,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "checkIfTokenExpired", - "func": "msg.payload = parseJson(msg.payload);\n\nif(msg.payload == \"\"){\n msg.tokenExpired = true\n}else{\n msg.tokenExpires_on = msg.payload[\"expiresOn\"]\n let fiveMinutesInUnixEpoch = 300\n msg.tokenExpired = (msg.tokenExpires_on - fiveMinutesInUnixEpoch) < Math.floor(Date.now() / 1000)\n}\n\nfunction parseJson(string) {\n return string === \"\" ? \"\" : JSON.parse(string)\n}\nreturn msg;\n\n", + "func": "msg.payload = parseJson(msg.payload);\n\nif(msg.payload == \"\"){\n msg.tokenExpired = true\n}else{\n msg.tokenExpires_on = msg.payload[\"expires_on\"]\n let fiveMinutesInUnixEpoch = 300\n msg.tokenExpired = (msg.tokenExpires_on - fiveMinutesInUnixEpoch) < Math.floor(Date.now() / 1000)\n}\n\nfunction parseJson(string) {\n return string === \"\" ? \"\" : JSON.parse(string)\n}\nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", @@ -713,7 +674,7 @@ "checkall": "true", "repair": false, "outputs": 2, - "x": 1190, + "x": 1200, "y": 240, "wires": [ [ @@ -813,7 +774,7 @@ "finalize": "", "libs": [], "x": 930, - "y": 560, + "y": 520, "wires": [ [ "3af5bf281111cdf5" @@ -832,7 +793,7 @@ "finalize": "", "libs": [], "x": 930, - "y": 620, + "y": 580, "wires": [ [ "eff2c757e27ebc08" @@ -851,7 +812,7 @@ "finalize": "", "libs": [], "x": 930, - "y": 680, + "y": 640, "wires": [ [ "e944970a233c812f" @@ -870,7 +831,7 @@ "finalize": "", "libs": [], "x": 1360, - "y": 560, + "y": 520, "wires": [ [ "c45a10208faeea88" @@ -889,7 +850,7 @@ "finalize": "", "libs": [], "x": 1370, - "y": 620, + "y": 580, "wires": [ [ "c45a10208faeea88" @@ -908,7 +869,7 @@ "finalize": "", "libs": [], "x": 1380, - "y": 680, + "y": 640, "wires": [ [ "c45a10208faeea88" @@ -926,8 +887,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1370, - "y": 1040, + "x": 1360, + "y": 1180, "wires": [ [ "4a089b6cc4d44d96" @@ -945,8 +906,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 930, - "y": 1040, + "x": 920, + "y": 1180, "wires": [ [ "3dd49201b59cb7f9" @@ -964,8 +925,8 @@ "createDir": false, "overwriteFile": "true", "encoding": "utf8", - "x": 1570, - "y": 1040, + "x": 1560, + "y": 1180, "wires": [ [] ] @@ -989,106 +950,6 @@ ] ] }, - { - "id": "3af5bf281111cdf5", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 560, - "wires": [ - [ - "931fbc85cf48c3ad" - ] - ] - }, - { - "id": "eff2c757e27ebc08", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 620, - "wires": [ - [ - "c1a003d2e63c8fc7" - ] - ] - }, - { - "id": "e944970a233c812f", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 680, - "wires": [ - [ - "f495c7f7c9e65097" - ] - ] - }, - { - "id": "635a32e66dd92586", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/actuator_room_mapping.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 740, - "wires": [ - [ - "c4db83d867cd1492" - ] - ] - }, - { - "id": "145386797b8afe53", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 800, - "wires": [ - [ - "38965161414b027a" - ] - ] - }, { "id": "cb314a12c20513b3", "type": "file in", @@ -1101,8 +962,8 @@ "sendError": false, "encoding": "utf8", "allProps": false, - "x": 1160, - "y": 860, + "x": 1150, + "y": 1000, "wires": [ [ "dcc8abdf633f1c30" @@ -1121,8 +982,8 @@ "sendError": false, "encoding": "utf8", "allProps": false, - "x": 1160, - "y": 920, + "x": 1150, + "y": 1060, "wires": [ [ "61eca1567ddb5e81" @@ -1141,8 +1002,8 @@ "sendError": false, "encoding": "utf8", "allProps": false, - "x": 1160, - "y": 980, + "x": 1150, + "y": 1120, "wires": [ [ "f749ed1e2e58c229" @@ -1161,8 +1022,8 @@ "sendError": false, "encoding": "utf8", "allProps": false, - "x": 1160, - "y": 1040, + "x": 1150, + "y": 1180, "wires": [ [ "b8465449f8f024c3" @@ -1180,7 +1041,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 320, + "x": 420, "y": 240, "wires": [ [ @@ -1413,7 +1274,7 @@ "payload": "{\"type\": 6, \"device_type\": \"0\", \"device_id\" : \"med2\", \"room_id\": \"room1\"}", "payloadType": "str", "x": 110, - "y": 460, + "y": 500, "wires": [ [ "ead8458e27835fd5" @@ -1431,8 +1292,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1750, - "y": 980, + "x": 1740, + "y": 1120, "wires": [ [ "f1d5bf00146cb950" @@ -1453,8 +1314,8 @@ "proxy": "", "authType": "", "senderr": false, - "x": 2110, - "y": 980, + "x": 2100, + "y": 1120, "wires": [ [ "7e2fc28f43937855" @@ -1465,15 +1326,15 @@ "id": "7e2fc28f43937855", "type": "function", "z": "09012e75c72a4968", - "name": "createRelationShipWithRoom", + "name": "createRelationshipWithRoom", "func": "let relID = msg.room_id + \"-\" + msg.actuator_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \"/relationships/\" + relID + \"?api-version=2020-10-31\"\nmsg.method = \"put\"\nmsg.payload = \n {\n \"$targetId\": msg.actuator_id,\n \"$relationshipName\": \"rel_has_actuator\"\n }\n\n\n\nreturn msg\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 2910, - "y": 980, + "x": 2750, + "y": 1120, "wires": [ [ "c45a10208faeea88" @@ -1502,7 +1363,7 @@ "payload": "{\"type\": 8, \"actuator_type\": \"0\", \"actuator_id\" : \"act111\", \"room_id\": \"room1\"}", "payloadType": "str", "x": 110, - "y": 500, + "y": 580, "wires": [ [ "ead8458e27835fd5" @@ -1520,8 +1381,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1950, - "y": 980, + "x": 1940, + "y": 1120, "wires": [ [ "c02092f546355c98" @@ -1535,7 +1396,7 @@ "name": "", "serial": "94b8abb47e4cb1f2", "x": 2090, - "y": 1280, + "y": 1300, "wires": [] }, { @@ -1549,8 +1410,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1590, - "y": 860, + "x": 1580, + "y": 1000, "wires": [ [ "b172127aa6066d80" @@ -1571,8 +1432,8 @@ "proxy": "", "authType": "", "senderr": false, - "x": 1750, - "y": 860, + "x": 1740, + "y": 1000, "wires": [ [ "1005329bc4b3f3df" @@ -1583,15 +1444,15 @@ "id": "745c5f5dda78248a", "type": "function", "z": "09012e75c72a4968", - "name": "createRelationShipWithRoom", + "name": "createRelationshipWithRoom", "func": "let process_id = JSON.parse(msg.payload)\nprocess_id = msg.process_id[\"value\"][0][\"$dtId\"]\nlet relID = process_id + \"-\" + msg.device_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + process_id + \"/relationships/\" + relID + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\nmsg.payload = {\n \"$targetId\": msg.device_id,\n \"$relationshipName\": \"rel_contains_medical_technology\"\n}\n\nreturn msg\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 2650, - "y": 860, + "x": 2640, + "y": 1000, "wires": [ [ "c45a10208faeea88" @@ -1609,8 +1470,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1990, - "y": 860, + "x": 1980, + "y": 1000, "wires": [ [ "3b376db55eb10b0f" @@ -1631,8 +1492,8 @@ "proxy": "", "authType": "", "senderr": false, - "x": 2430, - "y": 860, + "x": 2420, + "y": 1000, "wires": [ [ "745c5f5dda78248a" @@ -1650,8 +1511,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2250, - "y": 860, + "x": 2240, + "y": 1000, "wires": [ [ "d743a7865378b0dc" @@ -1669,8 +1530,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1430, - "y": 920, + "x": 1420, + "y": 1060, "wires": [ [ "780cd80ab50444c2" @@ -1688,8 +1549,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1690, - "y": 920, + "x": 1680, + "y": 1060, "wires": [ [ "955129310e7a1ad4" @@ -1710,8 +1571,8 @@ "proxy": "", "authType": "", "senderr": false, - "x": 1850, - "y": 920, + "x": 1840, + "y": 1060, "wires": [ [ "f51c81bfe7e71efa" @@ -1729,8 +1590,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2110, - "y": 920, + "x": 2100, + "y": 1060, "wires": [ [ "dff86deba04d2359" @@ -1748,8 +1609,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2370, - "y": 920, + "x": 2360, + "y": 1060, "wires": [ [ "e1b522b4e3afd1db" @@ -1770,8 +1631,8 @@ "proxy": "", "authType": "", "senderr": false, - "x": 2550, - "y": 920, + "x": 2540, + "y": 1060, "wires": [ [ "a35b075974d1b012" @@ -1783,18 +1644,489 @@ "type": "function", "z": "09012e75c72a4968", "name": "setPatientOnOperatingTable", - "func": "let patient_id = JSON.parse(msg.payload)\npatient_id = msg.process_id[\"value\"][0][\"$dtId\"]\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/isOnOperatingTable\",\n \"value\": true\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + patient_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\nreturn msg;", + "func": "let patient_id = JSON.parse(msg.payload)\npatient_id = msg.process_id[\"value\"][0][\"$dtId\"]\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/is_on_operating_table\",\n \"value\": true\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + patient_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 2760, - "y": 920, + "x": 2750, + "y": 1060, + "wires": [ + [ + "c45a10208faeea88" + ] + ] + }, + { + "id": "4702432e7293a098", + "type": "function", + "z": "09012e75c72a4968", + "name": "deleteHealtProfessionalRelationWIthRoom", + "func": "let room_id = msg.payload[\"value\"][0][\"$targetId\"]\nlet relID = room_id + \"-\" + msg.person_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"/relationships/\" + relID + \"?api-version=2023-02-27-preview\"\nmsg.method = \"delete\"\n\nreturn msg", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1990, + "y": 760, + "wires": [ + [ + "c45a10208faeea88" + ] + ] + }, + { + "id": "208b6e44f1f2d442", + "type": "function", + "z": "09012e75c72a4968", + "name": "createPersonRelationWithRoom", + "func": "let relID = msg.room_id + \"-\" + msg.person_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"/relationships/\" + relID + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\nmsg.payload = {\n \"$targetId\": msg.room_id,\n \"$relationshipName\": \"rel_is_inside\"\n}\n\nreturn msg", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2870, + "y": 780, "wires": [ [ "c45a10208faeea88" ] ] + }, + { + "id": "fefe9785d23b240b", + "type": "inject", + "z": "09012e75c72a4968", + "name": "type5", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 5, \"person_id\": \"health1\", \"person_role\": \"health\", \"room_id\": null} ", + "payloadType": "str", + "x": 110, + "y": 460, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "5cba3fef88d0f3ca", + "type": "inject", + "z": "09012e75c72a4968", + "name": "type7", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"type\": 7, \"room_id\": \"room1\"} ", + "payloadType": "str", + "x": 110, + "y": 540, + "wires": [ + [ + "ead8458e27835fd5" + ] + ] + }, + { + "id": "af11a3caafbb5fa8", + "type": "file in", + "z": "09012e75c72a4968", + "name": "read file", + "filename": "/data/configFiles/type0.json", + "filenameType": "str", + "format": "utf8", + "chunk": false, + "sendError": false, + "encoding": "utf8", + "allProps": false, + "x": 1160, + "y": 460, + "wires": [ + [ + "32174867b86c7b03" + ] + ] + }, + { + "id": "3af5bf281111cdf5", + "type": "file in", + "z": "09012e75c72a4968", + "name": "read file", + "filename": "/data/configFiles/type0.json", + "filenameType": "str", + "format": "utf8", + "chunk": false, + "sendError": false, + "encoding": "utf8", + "allProps": false, + "x": 1160, + "y": 520, + "wires": [ + [ + "931fbc85cf48c3ad" + ] + ] + }, + { + "id": "eff2c757e27ebc08", + "type": "file in", + "z": "09012e75c72a4968", + "name": "read file", + "filename": "/data/configFiles/type0.json", + "filenameType": "str", + "format": "utf8", + "chunk": false, + "sendError": false, + "encoding": "utf8", + "allProps": false, + "x": 1160, + "y": 580, + "wires": [ + [ + "c1a003d2e63c8fc7" + ] + ] + }, + { + "id": "e944970a233c812f", + "type": "file in", + "z": "09012e75c72a4968", + "name": "read file", + "filename": "/data/configFiles/type0.json", + "filenameType": "str", + "format": "utf8", + "chunk": false, + "sendError": false, + "encoding": "utf8", + "allProps": false, + "x": 1160, + "y": 640, + "wires": [ + [ + "f495c7f7c9e65097" + ] + ] + }, + { + "id": "635a32e66dd92586", + "type": "file in", + "z": "09012e75c72a4968", + "name": "read file", + "filename": "/data/configFiles/actuator_room_mapping.json", + "filenameType": "str", + "format": "utf8", + "chunk": false, + "sendError": false, + "encoding": "utf8", + "allProps": false, + "x": 1160, + "y": 700, + "wires": [ + [ + "c4db83d867cd1492" + ] + ] + }, + { + "id": "fec5274b054d2943", + "type": "function", + "z": "09012e75c72a4968", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2450, + "y": 940, + "wires": [ + [ + "c85da5a700a576e0" + ] + ] + }, + { + "id": "c85da5a700a576e0", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 2610, + "y": 940, + "wires": [ + [ + "208b6e44f1f2d442" + ] + ] + }, + { + "id": "d7aeec33f6a4d5e0", + "type": "switch", + "z": "09012e75c72a4968", + "name": "roleSwitch", + "property": "role", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "health", + "vt": "str" + }, + { + "t": "eq", + "v": "patient", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1310, + "y": 880, + "wires": [ + [ + "208b6e44f1f2d442" + ], + [ + "d119d9c78f4ac103" + ] + ] + }, + { + "id": "c0697d7b4441af53", + "type": "function", + "z": "09012e75c72a4968", + "name": "createPatientDT", + "func": "let patientModel = \"dtmi:io:github:smartoperatingblock:Patient;1\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\n\nmsg.payload = {\n \"$metadata\": {\n \"$model\": patientModel\n },\n \"is_on_operating_table\": false\n}\n\nreturn msg\n", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2280, + "y": 940, + "wires": [ + [ + "fec5274b054d2943" + ] + ] + }, + { + "id": "cda971bcd4ca8cc8", + "type": "function", + "z": "09012e75c72a4968", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1730, + "y": 920, + "wires": [ + [ + "52b89481233ff854" + ] + ] + }, + { + "id": "52b89481233ff854", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "obj", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 1890, + "y": 920, + "wires": [ + [ + "7fce2ecffbba5be0" + ] + ] + }, + { + "id": "d119d9c78f4ac103", + "type": "function", + "z": "09012e75c72a4968", + "name": "checkIfPatientDTExitsts", + "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"get\"\n\nreturn msg", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1530, + "y": 920, + "wires": [ + [ + "cda971bcd4ca8cc8" + ] + ] + }, + { + "id": "7fce2ecffbba5be0", + "type": "switch", + "z": "09012e75c72a4968", + "name": "StatusCodeSwitch", + "property": "statusCode", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "200", + "vt": "num" + }, + { + "t": "eq", + "v": "404", + "vt": "num" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 2070, + "y": 920, + "wires": [ + [ + "208b6e44f1f2d442" + ], + [ + "c0697d7b4441af53" + ] + ] + }, + { + "id": "7810c6d0751cfd37", + "type": "switch", + "z": "09012e75c72a4968", + "name": "enterExitSwitch", + "property": "room_id", + "propertyType": "msg", + "rules": [ + { + "t": "null" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1140, + "y": 820, + "wires": [ + [ + "b7d27c682271db4a" + ], + [ + "d7aeec33f6a4d5e0" + ] + ] + }, + { + "id": "20a8eea9561054e5", + "type": "function", + "z": "09012e75c72a4968", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1530, + "y": 760, + "wires": [ + [ + "302d634ed9fe8047" + ] + ] + }, + { + "id": "302d634ed9fe8047", + "type": "https-node", + "z": "09012e75c72a4968", + "name": "", + "method": "use", + "ret": "obj", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 1710, + "y": 760, + "wires": [ + [ + "4702432e7293a098" + ] + ] + }, + { + "id": "b7d27c682271db4a", + "type": "function", + "z": "09012e75c72a4968", + "name": "getCurrentRoom", + "func": "let relName = \"rel_is_inside\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"/relationships/?relationshipName=\" + relName + \"&api-version=2023-02-27-preview\"\nmsg.method = \"get\"\n\nreturn msg", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1330, + "y": 760, + "wires": [ + [ + "20a8eea9561054e5" + ] + ] } ] \ No newline at end of file From 55221fb71b41e3ff70e289323bc45ecbe3dfc128 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 14 Feb 2023 19:02:49 +0100 Subject: [PATCH 16/22] chore: change relation name between process and medical device digital twins --- data/flows.json | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/data/flows.json b/data/flows.json index d201bf2..52705df 100644 --- a/data/flows.json +++ b/data/flows.json @@ -1445,13 +1445,13 @@ "type": "function", "z": "09012e75c72a4968", "name": "createRelationshipWithRoom", - "func": "let process_id = JSON.parse(msg.payload)\nprocess_id = msg.process_id[\"value\"][0][\"$dtId\"]\nlet relID = process_id + \"-\" + msg.device_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + process_id + \"/relationships/\" + relID + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\nmsg.payload = {\n \"$targetId\": msg.device_id,\n \"$relationshipName\": \"rel_contains_medical_technology\"\n}\n\nreturn msg\n", + "func": "let process_id = msg.payload[\"value\"][0][\"$dtId\"]\nlet relID = process_id + \"-\" + msg.device_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + process_id + \"/relationships/\" + relID + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\nmsg.payload = {\n \"$targetId\": msg.device_id,\n \"$relationshipName\": \"rel_use\"\n}\n\nreturn msg\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 2640, + "x": 2690, "y": 1000, "wires": [ [ @@ -1464,7 +1464,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "requestProcessRelatedToTheRoom", - "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) SurgicalProcess.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Room RELATED SurgicalProcess.rel_is_inside WHERE Room.$dtId = \" + msg.room_id\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", + "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) SurgicalProcess.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Room RELATED SurgicalProcess.rel_is_inside WHERE Room.$dtId = '\" + msg.room_id + \"'\"\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -1484,7 +1484,7 @@ "z": "09012e75c72a4968", "name": "", "method": "use", - "ret": "txt", + "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "", @@ -1496,7 +1496,8 @@ "y": 1000, "wires": [ [ - "745c5f5dda78248a" + "745c5f5dda78248a", + "c2ebcd9b76d6cc45" ] ] }, @@ -2128,5 +2129,21 @@ "20a8eea9561054e5" ] ] + }, + { + "id": "c2ebcd9b76d6cc45", + "type": "debug", + "z": "09012e75c72a4968", + "name": "debug 1", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 2800, + "y": 940, + "wires": [] } ] \ No newline at end of file From dbaf7b0488f3f520781a47b2d5abfc03474ceb82 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Mon, 20 Feb 2023 10:06:26 +0100 Subject: [PATCH 17/22] chore: delete useless read from file --- data/flows.json | 199 +++++------------------------------------------- 1 file changed, 21 insertions(+), 178 deletions(-) diff --git a/data/flows.json b/data/flows.json index 52705df..acb8f00 100644 --- a/data/flows.json +++ b/data/flows.json @@ -110,7 +110,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1380, + "x": 1240, "y": 460, "wires": [ [ @@ -133,7 +133,7 @@ "y": 460, "wires": [ [ - "af11a3caafbb5fa8" + "32174867b86c7b03" ] ] }, @@ -148,7 +148,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1380, + "x": 1240, "y": 700, "wires": [ [ @@ -167,7 +167,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1370, + "x": 1270, "y": 1000, "wires": [ [ @@ -209,7 +209,7 @@ "y": 700, "wires": [ [ - "635a32e66dd92586" + "c4db83d867cd1492" ] ] }, @@ -344,7 +344,7 @@ "y": 1000, "wires": [ [ - "cb314a12c20513b3" + "dcc8abdf633f1c30" ] ] }, @@ -363,7 +363,7 @@ "y": 1060, "wires": [ [ - "3dc151189b79fc01" + "61eca1567ddb5e81" ] ] }, @@ -777,7 +777,7 @@ "y": 520, "wires": [ [ - "3af5bf281111cdf5" + "931fbc85cf48c3ad" ] ] }, @@ -796,7 +796,7 @@ "y": 580, "wires": [ [ - "eff2c757e27ebc08" + "c1a003d2e63c8fc7" ] ] }, @@ -815,7 +815,7 @@ "y": 640, "wires": [ [ - "e944970a233c812f" + "f495c7f7c9e65097" ] ] }, @@ -830,7 +830,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1360, + "x": 1220, "y": 520, "wires": [ [ @@ -849,7 +849,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1370, + "x": 1230, "y": 580, "wires": [ [ @@ -868,7 +868,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1380, + "x": 1240, "y": 640, "wires": [ [ @@ -950,46 +950,6 @@ ] ] }, - { - "id": "cb314a12c20513b3", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1150, - "y": 1000, - "wires": [ - [ - "dcc8abdf633f1c30" - ] - ] - }, - { - "id": "3dc151189b79fc01", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1150, - "y": 1060, - "wires": [ - [ - "61eca1567ddb5e81" - ] - ] - }, { "id": "f6e56c9200cdd690", "type": "file in", @@ -1360,7 +1320,7 @@ "once": false, "onceDelay": 0.1, "topic": "", - "payload": "{\"type\": 8, \"actuator_type\": \"0\", \"actuator_id\" : \"act111\", \"room_id\": \"room1\"}", + "payload": "{\"type\": 8, \"actuator_type\": \"0\", \"actuator_id\" : \"act1121\", \"room_id\": \"room1\"}", "payloadType": "str", "x": 110, "y": 580, @@ -1496,8 +1456,7 @@ "y": 1000, "wires": [ [ - "745c5f5dda78248a", - "c2ebcd9b76d6cc45" + "745c5f5dda78248a" ] ] }, @@ -1525,13 +1484,13 @@ "type": "function", "z": "09012e75c72a4968", "name": "requestProcessRelatedToTheRoom", - "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) SurgicalProcess.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Room RELATED SurgicalProcess.rel_is_inside WHERE Room.$dtId = \" + msg.room_id\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", + "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) SurgicalProcess.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Room RELATED SurgicalProcess.rel_is_inside WHERE Room.$dtId = '\" + msg.room_id + \"'\"\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 1420, + "x": 1290, "y": 1060, "wires": [ [ @@ -1564,7 +1523,7 @@ "z": "09012e75c72a4968", "name": "", "method": "use", - "ret": "txt", + "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "", @@ -1585,7 +1544,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "requestPatientRelatedToTheProcess", - "func": "let process_id = JSON.parse(msg.payload)\nprocess_id = msg.process_id[\"value\"][0][\"$dtId\"]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) Patient.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Patient RELATED SurgicalProcess.rel_involve_patient where SurgicalProcess.$dtId =\"+ process_id\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", + "func": "let process_id = msg.payload[\"value\"][0][\"$dtId\"]\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\nlet query = \"SELECT TOP (1) Patient.$dtId FROM DIGITALTWINS SurgicalProcess JOIN Patient RELATED SurgicalProcess.rel_involve_patient where SurgicalProcess.$dtId ='\"+ process_id + \"'\"\nmsg.method = \"post\"\n\nmsg.payload = {\n \"query\": query\n}\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -1624,7 +1583,7 @@ "z": "09012e75c72a4968", "name": "", "method": "use", - "ret": "txt", + "ret": "obj", "paytoqs": "ignore", "url": "", "tls": "", @@ -1645,7 +1604,7 @@ "type": "function", "z": "09012e75c72a4968", "name": "setPatientOnOperatingTable", - "func": "let patient_id = JSON.parse(msg.payload)\npatient_id = msg.process_id[\"value\"][0][\"$dtId\"]\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/is_on_operating_table\",\n \"value\": true\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + patient_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\nreturn msg;", + "func": "let patient_id = msg.payload[\"value\"][0][\"$dtId\"]\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/is_on_operating_table\",\n \"value\": true\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + patient_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -1755,106 +1714,6 @@ ] ] }, - { - "id": "af11a3caafbb5fa8", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 460, - "wires": [ - [ - "32174867b86c7b03" - ] - ] - }, - { - "id": "3af5bf281111cdf5", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 520, - "wires": [ - [ - "931fbc85cf48c3ad" - ] - ] - }, - { - "id": "eff2c757e27ebc08", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 580, - "wires": [ - [ - "c1a003d2e63c8fc7" - ] - ] - }, - { - "id": "e944970a233c812f", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/type0.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 640, - "wires": [ - [ - "f495c7f7c9e65097" - ] - ] - }, - { - "id": "635a32e66dd92586", - "type": "file in", - "z": "09012e75c72a4968", - "name": "read file", - "filename": "/data/configFiles/actuator_room_mapping.json", - "filenameType": "str", - "format": "utf8", - "chunk": false, - "sendError": false, - "encoding": "utf8", - "allProps": false, - "x": 1160, - "y": 700, - "wires": [ - [ - "c4db83d867cd1492" - ] - ] - }, { "id": "fec5274b054d2943", "type": "function", @@ -2129,21 +1988,5 @@ "20a8eea9561054e5" ] ] - }, - { - "id": "c2ebcd9b76d6cc45", - "type": "debug", - "z": "09012e75c72a4968", - "name": "debug 1", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "false", - "statusVal": "", - "statusType": "auto", - "x": 2800, - "y": 940, - "wires": [] } ] \ No newline at end of file From 0596e16ce68a8ec45dd8cd44d63db5d01de0c116 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Mon, 20 Feb 2023 10:17:36 +0100 Subject: [PATCH 18/22] chore: rename some functions name --- data/flows.json | 74 ++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/data/flows.json b/data/flows.json index acb8f00..30c7050 100644 --- a/data/flows.json +++ b/data/flows.json @@ -122,14 +122,14 @@ "id": "17a8a64fa23751ed", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processTemperatureData", "func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.temperature_value = msg.serialData[\"temperature_value\"]\n//msg.temperature_unit = msg.serialData[\"temperature_unit\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 930, + "x": 950, "y": 460, "wires": [ [ @@ -167,7 +167,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1270, + "x": 1250, "y": 1000, "wires": [ [ @@ -198,14 +198,14 @@ "id": "976a5466bc4b4345", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processAcutatorData", "func": "msg.actuator_id = msg.serialData[\"actuator_id\"]\nmsg.state = msg.serialData[\"state\"]\nmsg.intensity_percentage = msg.serialData[\"intensity_percentage\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 930, + "x": 940, "y": 700, "wires": [ [ @@ -217,14 +217,14 @@ "id": "5224a2d0c5f5e2ff", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processPersonEnterInRoom", "func": "msg.person_id = msg.serialData[\"person_id\"]\nmsg.room_id = msg.serialData[\"room_id\"]\nmsg.role = msg.serialData[\"person_role\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 930, + "x": 920, "y": 820, "wires": [ [ @@ -333,14 +333,14 @@ "id": "269af3b43e760d2b", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processMedicalDeviceTracking", "func": "msg.device_type = msg.serialData[\"device_type\"]\nmsg.device_id = msg.serialData[\"device_id\"]\nmsg.room_id = msg.serialData[\"room_id\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 920, + "x": 960, "y": 1000, "wires": [ [ @@ -352,14 +352,14 @@ "id": "637a5d6856e31424", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processPatientOnOperatingRoom", "func": "msg.room_id = msg.serialData[\"room_id\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 920, + "x": 970, "y": 1060, "wires": [ [ @@ -371,14 +371,14 @@ "id": "37741262158114fd", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processAvailableActuator", "func": "msg.actuator_id = msg.serialData[\"actuator_id\"]\nmsg.actuator_type = msg.serialData[\"actuator_type\"]\nmsg.room_id = msg.serialData[\"room_id\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 920, + "x": 940, "y": 1120, "wires": [ [ @@ -766,14 +766,14 @@ "id": "e0959707dc172828", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processHumidityData", "func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.humidity_percentage = msg.serialData[\"humidity_percentage\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 930, + "x": 940, "y": 520, "wires": [ [ @@ -785,14 +785,14 @@ "id": "2a72d09d78bb7407", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processLuminosityData", "func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.luminosity_value = msg.serialData[\"luminosity_value\"]\n//msg.luminosity_unit = msg.serialData[\"luminosity_unit\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 930, + "x": 950, "y": 580, "wires": [ [ @@ -804,14 +804,14 @@ "id": "5a61a2afa4a38b4a", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processPersonInside", "func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.person_inside = msg.serialData[\"person_inside\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 930, + "x": 940, "y": 640, "wires": [ [ @@ -887,7 +887,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1360, + "x": 1490, "y": 1180, "wires": [ [ @@ -899,14 +899,14 @@ "id": "5f4a2d6877405aa5", "type": "function", "z": "09012e75c72a4968", - "name": "processSerialData", + "name": "processMappingBetweenSerialAndArduino", "func": "msg.room_id = msg.serialData[\"room_id\"]\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 920, + "x": 1010, "y": 1180, "wires": [ [ @@ -925,7 +925,7 @@ "createDir": false, "overwriteFile": "true", "encoding": "utf8", - "x": 1560, + "x": 1680, "y": 1180, "wires": [ [] @@ -982,7 +982,7 @@ "sendError": false, "encoding": "utf8", "allProps": false, - "x": 1150, + "x": 1280, "y": 1180, "wires": [ [ @@ -1293,7 +1293,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2750, + "x": 2610, "y": 1120, "wires": [ [ @@ -1370,7 +1370,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1580, + "x": 1470, "y": 1000, "wires": [ [ @@ -1392,7 +1392,7 @@ "proxy": "", "authType": "", "senderr": false, - "x": 1740, + "x": 1630, "y": 1000, "wires": [ [ @@ -1411,7 +1411,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2690, + "x": 2570, "y": 1000, "wires": [ [ @@ -1430,7 +1430,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1980, + "x": 1890, "y": 1000, "wires": [ [ @@ -1452,7 +1452,7 @@ "proxy": "", "authType": "", "senderr": false, - "x": 2420, + "x": 2330, "y": 1000, "wires": [ [ @@ -1471,7 +1471,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2240, + "x": 2150, "y": 1000, "wires": [ [ @@ -1509,7 +1509,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1680, + "x": 1550, "y": 1060, "wires": [ [ @@ -1531,7 +1531,7 @@ "proxy": "", "authType": "", "senderr": false, - "x": 1840, + "x": 1710, "y": 1060, "wires": [ [ @@ -1550,7 +1550,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2100, + "x": 1970, "y": 1060, "wires": [ [ @@ -1569,7 +1569,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2360, + "x": 2230, "y": 1060, "wires": [ [ @@ -1591,7 +1591,7 @@ "proxy": "", "authType": "", "senderr": false, - "x": 2540, + "x": 2410, "y": 1060, "wires": [ [ @@ -1610,7 +1610,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2750, + "x": 2620, "y": 1060, "wires": [ [ From ffc7c547c9410d15d1a4932cd6148f61fe178079 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Mon, 20 Feb 2023 10:38:40 +0100 Subject: [PATCH 19/22] refactor: create subflow to make http request on azure --- data/flows.json | 614 +++++++++++++++++------------------------------- 1 file changed, 217 insertions(+), 397 deletions(-) diff --git a/data/flows.json b/data/flows.json index 30c7050..a31ba65 100644 --- a/data/flows.json +++ b/data/flows.json @@ -23,6 +23,39 @@ "info": "", "env": [] }, + { + "id": "70865c1f352e8a0c", + "type": "subflow", + "name": "AzureHttpRequest", + "info": "", + "category": "", + "in": [ + { + "x": 40, + "y": 80, + "wires": [ + { + "id": "20a8eea9561054e5" + } + ] + } + ], + "out": [ + { + "x": 520, + "y": 80, + "wires": [ + { + "id": "302d634ed9fe8047", + "port": 0 + } + ] + } + ], + "env": [], + "meta": {}, + "color": "#DDAA99" + }, { "id": "94b8abb47e4cb1f2", "type": "serial-port", @@ -99,12 +132,51 @@ "addchar": "", "responsetimeout": "10000" }, + { + "id": "20a8eea9561054e5", + "type": "function", + "z": "70865c1f352e8a0c", + "name": "add header ", + "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 190, + "y": 80, + "wires": [ + [ + "302d634ed9fe8047" + ] + ] + }, + { + "id": "302d634ed9fe8047", + "type": "https-node", + "z": "70865c1f352e8a0c", + "name": "", + "method": "use", + "ret": "obj", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": true, + "proxy": "", + "authType": "", + "senderr": false, + "x": 370, + "y": 80, + "wires": [ + [] + ] + }, { "id": "32174867b86c7b03", "type": "function", "z": "09012e75c72a4968", "name": "UpdateTemperature", - "func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/temperature\",\n \"value\": parseFloat(msg.temperature_value)\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\"+ msg.room_id +\"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n\n", + "func": "msg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/temperature\",\n \"value\": parseFloat(msg.temperature_value)\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\"+ msg.room_id +\"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; ", "outputs": 1, "noerr": 0, "initialize": "", @@ -114,7 +186,7 @@ "y": 460, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -152,7 +224,7 @@ "y": 700, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -160,18 +232,18 @@ "id": "dcc8abdf633f1c30", "type": "function", "z": "09012e75c72a4968", - "name": "MedicalDeviceTracking", + "name": "createImplantableMedicalDeviceDT", "func": "let medicalDeviceModel = \"dtmi:io:github:smartoperatingblock:ImplantableMedicalDevice;1\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.device_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\n\nmsg.payload = {\n \"$metadata\": {\n \"$model\": medicalDeviceModel\n }, \n \"type\" : msg.device_type \n}\n\nreturn msg\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 1250, + "x": 1290, "y": 1000, "wires": [ [ - "1024090145928519" + "dfc0c3d254b99e87" ] ] }, @@ -179,14 +251,14 @@ "id": "f749ed1e2e58c229", "type": "function", "z": "09012e75c72a4968", - "name": "AvailableActuator", + "name": "mapActuatorWithRoom", "func": "let jsonData = parseJson(msg.payload);\n\njsonData[msg.actuator_id] = {\n \"type\": msg.actuator_type,\n \"room\": msg.room_id\n}\n\n//msg.payload = jsonData\nfunction parseJson(string){\n return string === \"\" ? JSON.parse(\"{}\") : JSON.parse(string)\n}\n\nmsg.payload = jsonData\nreturn msg; \n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 1350, + "x": 1510, "y": 1120, "wires": [ [ @@ -386,25 +458,6 @@ ] ] }, - { - "id": "c45a10208faeea88", - "type": "function", - "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 3210, - "y": 740, - "wires": [ - [ - "6a5968a77bdcb8ec" - ] - ] - }, { "id": "3a01a886905e5fed", "type": "http in", @@ -435,22 +488,22 @@ "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 3560, - "y": 740, + "x": 3520, + "y": 700, "wires": [] }, { "id": "5c6d578149de144a", "type": "file", "z": "09012e75c72a4968", - "name": "write file", + "name": "saveNewAvailableActuator", "filename": "/data/configFiles/actuator_room_mapping.json", "filenameType": "str", "appendNewline": true, "createDir": false, "overwriteFile": "true", "encoding": "utf8", - "x": 1550, + "x": 1800, "y": 1120, "wires": [ [ @@ -834,7 +887,7 @@ "y": 520, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -853,7 +906,7 @@ "y": 580, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -872,7 +925,7 @@ "y": 640, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -880,14 +933,14 @@ "id": "b8465449f8f024c3", "type": "function", "z": "09012e75c72a4968", - "name": "AssociatedRoom", - "func": "let jsonData = parseJson(msg.payload);\n\njsonData[msg.room_id] = msg.serial_id\n\n\n//msg.payload = jsonData\nfunction parseJson(string){\n return string === \"\" ? JSON.parse(\"{}\") : JSON.parse(string)\n}\n\nmsg.payload = jsonData\nreturn msg; \n\n", + "name": "mapRoomWithSerial", + "func": "let jsonData = parseJson(msg.payload);\njsonData[msg.room_id] = msg.serial_id\n\nfunction parseJson(string){\n return string === \"\" ? JSON.parse(\"{}\") : JSON.parse(string)\n}\n\nmsg.payload = jsonData\nreturn msg; ", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 1490, + "x": 1600, "y": 1180, "wires": [ [ @@ -918,14 +971,14 @@ "id": "4a089b6cc4d44d96", "type": "file", "z": "09012e75c72a4968", - "name": "write file", + "name": "saveSerialRoomMapping", "filename": "/data/configFiles/arduino_room_mapping.json", "filenameType": "str", "appendNewline": true, "createDir": false, "overwriteFile": "true", "encoding": "utf8", - "x": 1680, + "x": 1870, "y": 1180, "wires": [ [] @@ -954,7 +1007,7 @@ "id": "f6e56c9200cdd690", "type": "file in", "z": "09012e75c72a4968", - "name": "read file", + "name": "readActuatorRoomMappingFile", "filename": "/data/configFiles/actuator_room_mapping.json", "filenameType": "str", "format": "utf8", @@ -962,7 +1015,7 @@ "sendError": false, "encoding": "utf8", "allProps": false, - "x": 1150, + "x": 1220, "y": 1120, "wires": [ [ @@ -974,7 +1027,7 @@ "id": "3dd49201b59cb7f9", "type": "file in", "z": "09012e75c72a4968", - "name": "read file", + "name": "readArduinoRoomMappingFile", "filename": "/data/configFiles/arduino_room_mapping.json", "filenameType": "str", "format": "utf8", @@ -982,7 +1035,7 @@ "sendError": false, "encoding": "utf8", "allProps": false, - "x": 1280, + "x": 1350, "y": 1180, "wires": [ [ @@ -1139,28 +1192,6 @@ ] ] }, - { - "id": "6a5968a77bdcb8ec", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "txt", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 3390, - "y": 740, - "wires": [ - [ - "3e879afc64077b51" - ] - ] - }, { "id": "dd96318fc1b5b6c4", "type": "https-node", @@ -1252,33 +1283,11 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1740, - "y": 1120, - "wires": [ - [ - "f1d5bf00146cb950" - ] - ] - }, - { - "id": "c02092f546355c98", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "txt", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 2100, + "x": 2070, "y": 1120, "wires": [ [ - "7e2fc28f43937855" + "00422d3334540982" ] ] }, @@ -1297,7 +1306,7 @@ "y": 1120, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -1330,25 +1339,6 @@ ] ] }, - { - "id": "f1d5bf00146cb950", - "type": "function", - "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1940, - "y": 1120, - "wires": [ - [ - "c02092f546355c98" - ] - ] - }, { "id": "ea1d80c07843fb89", "type": "serial out", @@ -1359,47 +1349,6 @@ "y": 1300, "wires": [] }, - { - "id": "1024090145928519", - "type": "function", - "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1470, - "y": 1000, - "wires": [ - [ - "b172127aa6066d80" - ] - ] - }, - { - "id": "b172127aa6066d80", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "txt", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 1630, - "y": 1000, - "wires": [ - [ - "1005329bc4b3f3df" - ] - ] - }, { "id": "745c5f5dda78248a", "type": "function", @@ -1411,11 +1360,11 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2570, + "x": 2610, "y": 1000, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -1434,48 +1383,7 @@ "y": 1000, "wires": [ [ - "3b376db55eb10b0f" - ] - ] - }, - { - "id": "d743a7865378b0dc", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "obj", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 2330, - "y": 1000, - "wires": [ - [ - "745c5f5dda78248a" - ] - ] - }, - { - "id": "3b376db55eb10b0f", - "type": "function", - "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 2150, - "y": 1000, - "wires": [ - [ - "d743a7865378b0dc" + "5664c9ae46ddedba" ] ] }, @@ -1494,48 +1402,7 @@ "y": 1060, "wires": [ [ - "780cd80ab50444c2" - ] - ] - }, - { - "id": "780cd80ab50444c2", - "type": "function", - "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1550, - "y": 1060, - "wires": [ - [ - "955129310e7a1ad4" - ] - ] - }, - { - "id": "955129310e7a1ad4", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "obj", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 1710, - "y": 1060, - "wires": [ - [ - "f51c81bfe7e71efa" + "cace2be9bbd83fd6" ] ] }, @@ -1554,48 +1421,7 @@ "y": 1060, "wires": [ [ - "dff86deba04d2359" - ] - ] - }, - { - "id": "dff86deba04d2359", - "type": "function", - "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 2230, - "y": 1060, - "wires": [ - [ - "e1b522b4e3afd1db" - ] - ] - }, - { - "id": "e1b522b4e3afd1db", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "obj", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 2410, - "y": 1060, - "wires": [ - [ - "a35b075974d1b012" + "b9dc0ea585c3b2dc" ] ] }, @@ -1614,7 +1440,7 @@ "y": 1060, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -1633,7 +1459,7 @@ "y": 760, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -1648,11 +1474,11 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2870, - "y": 780, + "x": 2850, + "y": 760, "wires": [ [ - "c45a10208faeea88" + "62c28667af053fe0" ] ] }, @@ -1714,47 +1540,6 @@ ] ] }, - { - "id": "fec5274b054d2943", - "type": "function", - "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 2450, - "y": 940, - "wires": [ - [ - "c85da5a700a576e0" - ] - ] - }, - { - "id": "c85da5a700a576e0", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "txt", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 2610, - "y": 940, - "wires": [ - [ - "208b6e44f1f2d442" - ] - ] - }, { "id": "d7aeec33f6a4d5e0", "type": "switch", @@ -1803,48 +1588,7 @@ "y": 940, "wires": [ [ - "fec5274b054d2943" - ] - ] - }, - { - "id": "cda971bcd4ca8cc8", - "type": "function", - "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1730, - "y": 920, - "wires": [ - [ - "52b89481233ff854" - ] - ] - }, - { - "id": "52b89481233ff854", - "type": "https-node", - "z": "09012e75c72a4968", - "name": "", - "method": "use", - "ret": "obj", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 1890, - "y": 920, - "wires": [ - [ - "7fce2ecffbba5be0" + "6e28ea76ba198ea8" ] ] }, @@ -1859,11 +1603,11 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1530, + "x": 1550, "y": 920, "wires": [ [ - "cda971bcd4ca8cc8" + "c24fc68b0de6902c" ] ] }, @@ -1930,39 +1674,30 @@ ] }, { - "id": "20a8eea9561054e5", + "id": "b7d27c682271db4a", "type": "function", "z": "09012e75c72a4968", - "name": "add header ", - "func": "msg.headers = {};\nmsg.headers['Authorization'] = \"Bearer \" + msg.token\nmsg.headers['Content-Type'] = \"application/json\"\nreturn msg;", + "name": "getCurrentRoom", + "func": "let relName = \"rel_is_inside\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"/relationships/?relationshipName=\" + relName + \"&api-version=2023-02-27-preview\"\nmsg.method = \"get\"\n\nreturn msg", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 1530, + "x": 1330, "y": 760, "wires": [ [ - "302d634ed9fe8047" + "382cf85deb32af58" ] ] }, { - "id": "302d634ed9fe8047", - "type": "https-node", + "id": "382cf85deb32af58", + "type": "subflow:70865c1f352e8a0c", "z": "09012e75c72a4968", "name": "", - "method": "use", - "ret": "obj", - "paytoqs": "ignore", - "url": "", - "tls": "", - "persist": true, - "proxy": "", - "authType": "", - "senderr": false, - "x": 1710, + "x": 1650, "y": 760, "wires": [ [ @@ -1971,21 +1706,106 @@ ] }, { - "id": "b7d27c682271db4a", - "type": "function", + "id": "c24fc68b0de6902c", + "type": "subflow:70865c1f352e8a0c", "z": "09012e75c72a4968", - "name": "getCurrentRoom", - "func": "let relName = \"rel_is_inside\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"/relationships/?relationshipName=\" + relName + \"&api-version=2023-02-27-preview\"\nmsg.method = \"get\"\n\nreturn msg", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1330, - "y": 760, + "name": "", + "x": 1810, + "y": 920, + "wires": [ + [ + "7fce2ecffbba5be0" + ] + ] + }, + { + "id": "6e28ea76ba198ea8", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 2510, + "y": 940, + "wires": [ + [ + "208b6e44f1f2d442" + ] + ] + }, + { + "id": "dfc0c3d254b99e87", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 1590, + "y": 1000, + "wires": [ + [ + "1005329bc4b3f3df" + ] + ] + }, + { + "id": "5664c9ae46ddedba", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 2230, + "y": 1000, "wires": [ [ - "20a8eea9561054e5" + "745c5f5dda78248a" + ] + ] + }, + { + "id": "cace2be9bbd83fd6", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 1610, + "y": 1060, + "wires": [ + [ + "f51c81bfe7e71efa" + ] + ] + }, + { + "id": "b9dc0ea585c3b2dc", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 2310, + "y": 1060, + "wires": [ + [ + "a35b075974d1b012" + ] + ] + }, + { + "id": "00422d3334540982", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 2350, + "y": 1120, + "wires": [ + [ + "7e2fc28f43937855" + ] + ] + }, + { + "id": "62c28667af053fe0", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 3270, + "y": 700, + "wires": [ + [ + "3e879afc64077b51" ] ] } From 869dd79be245ffe7403b78f354c86c2589ace505 Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 14 Mar 2023 19:12:16 +0100 Subject: [PATCH 20/22] chore: add deletion of rel between room and health professional when he changes room --- data/flows.json | 133 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 123 insertions(+), 10 deletions(-) diff --git a/data/flows.json b/data/flows.json index a31ba65..f77b935 100644 --- a/data/flows.json +++ b/data/flows.json @@ -220,7 +220,7 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1240, + "x": 1500, "y": 700, "wires": [ [ @@ -281,7 +281,7 @@ "y": 700, "wires": [ [ - "c4db83d867cd1492" + "0cec540c56ea23b3" ] ] }, @@ -488,8 +488,8 @@ "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 3520, - "y": 700, + "x": 3540, + "y": 780, "wires": [] }, { @@ -1474,8 +1474,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2850, - "y": 760, + "x": 2830, + "y": 860, "wires": [ [ "62c28667af053fe0" @@ -1501,7 +1501,7 @@ "once": false, "onceDelay": 0.1, "topic": "", - "payload": "{\"type\": 5, \"person_id\": \"health1\", \"person_role\": \"health\", \"room_id\": null} ", + "payload": "{\"type\": 5, \"person_id\": \"hp10\", \"person_role\": \"health\", \"room_id\": \"room10\"} ", "payloadType": "str", "x": 110, "y": 460, @@ -1566,7 +1566,7 @@ "y": 880, "wires": [ [ - "208b6e44f1f2d442" + "091e1425012342f8" ], [ "d119d9c78f4ac103" @@ -1801,12 +1801,125 @@ "type": "subflow:70865c1f352e8a0c", "z": "09012e75c72a4968", "name": "", - "x": 3270, - "y": 700, + "x": 3370, + "y": 780, "wires": [ [ "3e879afc64077b51" ] ] + }, + { + "id": "0cec540c56ea23b3", + "type": "file in", + "z": "09012e75c72a4968", + "name": "readActuatorRoomMappingFile", + "filename": "/data/configFiles/actuator_room_mapping.json", + "filenameType": "str", + "format": "utf8", + "chunk": false, + "sendError": false, + "encoding": "utf8", + "allProps": false, + "x": 1230, + "y": 700, + "wires": [ + [ + "c4db83d867cd1492" + ] + ] + }, + { + "id": "3f215909208d5fb3", + "type": "function", + "z": "09012e75c72a4968", + "name": "deleteHealtProfessionalRelationWIthRoom", + "func": "let room_id = msg.payload[\"value\"][0][\"$targetId\"]\nlet relID = room_id + \"-\" + msg.person_id\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"/relationships/\" + relID + \"?api-version=2023-02-27-preview\"\nmsg.method = \"delete\"\n\nreturn msg", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 2250, + "y": 860, + "wires": [ + [ + "c19c574b2b54b343" + ] + ] + }, + { + "id": "091e1425012342f8", + "type": "function", + "z": "09012e75c72a4968", + "name": "getCurrentRoom", + "func": "let relName = \"rel_is_inside\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"/relationships/?relationshipName=\" + relName + \"&api-version=2023-02-27-preview\"\nmsg.method = \"get\"\n\nreturn msg", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 1530, + "y": 820, + "wires": [ + [ + "f601941828d90ad1" + ] + ] + }, + { + "id": "f601941828d90ad1", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 1730, + "y": 820, + "wires": [ + [ + "7abff071a8097e2f" + ] + ] + }, + { + "id": "c19c574b2b54b343", + "type": "subflow:70865c1f352e8a0c", + "z": "09012e75c72a4968", + "name": "", + "x": 2550, + "y": 820, + "wires": [ + [ + "208b6e44f1f2d442" + ] + ] + }, + { + "id": "7abff071a8097e2f", + "type": "switch", + "z": "09012e75c72a4968", + "name": "CurrentRoomExistsSwitch", + "property": "currentRoom", + "propertyType": "msg", + "rules": [ + { + "t": "null" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1950, + "y": 820, + "wires": [ + [ + "208b6e44f1f2d442" + ], + [ + "3f215909208d5fb3" + ] + ] } ] \ No newline at end of file From f86ca2d02eeb76ab40ff3eecddd56f903e19e45c Mon Sep 17 00:00:00 2001 From: giacomo accursi Date: Tue, 21 Mar 2023 16:28:48 +0100 Subject: [PATCH 21/22] chore: delete creation of patientDT --- data/flows.json | 158 +++++------------------------------------------- 1 file changed, 14 insertions(+), 144 deletions(-) diff --git a/data/flows.json b/data/flows.json index f77b935..d9b7728 100644 --- a/data/flows.json +++ b/data/flows.json @@ -1474,8 +1474,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 2830, - "y": 860, + "x": 2870, + "y": 820, "wires": [ [ "62c28667af053fe0" @@ -1501,7 +1501,7 @@ "once": false, "onceDelay": 0.1, "topic": "", - "payload": "{\"type\": 5, \"person_id\": \"hp10\", \"person_role\": \"health\", \"room_id\": \"room10\"} ", + "payload": "{\"type\": 5, \"person_id\": \"ProvaPatient\", \"person_role\": \"patient\", \"room_id\": \"Room-2\"} ", "payloadType": "str", "x": 110, "y": 460, @@ -1540,110 +1540,6 @@ ] ] }, - { - "id": "d7aeec33f6a4d5e0", - "type": "switch", - "z": "09012e75c72a4968", - "name": "roleSwitch", - "property": "role", - "propertyType": "msg", - "rules": [ - { - "t": "eq", - "v": "health", - "vt": "str" - }, - { - "t": "eq", - "v": "patient", - "vt": "str" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 1310, - "y": 880, - "wires": [ - [ - "091e1425012342f8" - ], - [ - "d119d9c78f4ac103" - ] - ] - }, - { - "id": "c0697d7b4441af53", - "type": "function", - "z": "09012e75c72a4968", - "name": "createPatientDT", - "func": "let patientModel = \"dtmi:io:github:smartoperatingblock:Patient;1\"\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"put\"\n\nmsg.payload = {\n \"$metadata\": {\n \"$model\": patientModel\n },\n \"is_on_operating_table\": false\n}\n\nreturn msg\n", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 2280, - "y": 940, - "wires": [ - [ - "6e28ea76ba198ea8" - ] - ] - }, - { - "id": "d119d9c78f4ac103", - "type": "function", - "z": "09012e75c72a4968", - "name": "checkIfPatientDTExitsts", - "func": "msg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.person_id + \"?api-version=2023-02-27-preview\"\nmsg.method = \"get\"\n\nreturn msg", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 1550, - "y": 920, - "wires": [ - [ - "c24fc68b0de6902c" - ] - ] - }, - { - "id": "7fce2ecffbba5be0", - "type": "switch", - "z": "09012e75c72a4968", - "name": "StatusCodeSwitch", - "property": "statusCode", - "propertyType": "msg", - "rules": [ - { - "t": "eq", - "v": "200", - "vt": "num" - }, - { - "t": "eq", - "v": "404", - "vt": "num" - } - ], - "checkall": "true", - "repair": false, - "outputs": 2, - "x": 2070, - "y": 920, - "wires": [ - [ - "208b6e44f1f2d442" - ], - [ - "c0697d7b4441af53" - ] - ] - }, { "id": "7810c6d0751cfd37", "type": "switch", @@ -1669,7 +1565,7 @@ "b7d27c682271db4a" ], [ - "d7aeec33f6a4d5e0" + "091e1425012342f8" ] ] }, @@ -1705,32 +1601,6 @@ ] ] }, - { - "id": "c24fc68b0de6902c", - "type": "subflow:70865c1f352e8a0c", - "z": "09012e75c72a4968", - "name": "", - "x": 1810, - "y": 920, - "wires": [ - [ - "7fce2ecffbba5be0" - ] - ] - }, - { - "id": "6e28ea76ba198ea8", - "type": "subflow:70865c1f352e8a0c", - "z": "09012e75c72a4968", - "name": "", - "x": 2510, - "y": 940, - "wires": [ - [ - "208b6e44f1f2d442" - ] - ] - }, { "id": "dfc0c3d254b99e87", "type": "subflow:70865c1f352e8a0c", @@ -1841,7 +1711,7 @@ "finalize": "", "libs": [], "x": 2250, - "y": 860, + "y": 940, "wires": [ [ "c19c574b2b54b343" @@ -1859,8 +1729,8 @@ "initialize": "", "finalize": "", "libs": [], - "x": 1530, - "y": 820, + "x": 1330, + "y": 880, "wires": [ [ "f601941828d90ad1" @@ -1872,8 +1742,8 @@ "type": "subflow:70865c1f352e8a0c", "z": "09012e75c72a4968", "name": "", - "x": 1730, - "y": 820, + "x": 1530, + "y": 880, "wires": [ [ "7abff071a8097e2f" @@ -1886,7 +1756,7 @@ "z": "09012e75c72a4968", "name": "", "x": 2550, - "y": 820, + "y": 860, "wires": [ [ "208b6e44f1f2d442" @@ -1898,8 +1768,8 @@ "type": "switch", "z": "09012e75c72a4968", "name": "CurrentRoomExistsSwitch", - "property": "currentRoom", - "propertyType": "msg", + "property": "msg.payload[\"value\"][0][\"$targetId\"]", + "propertyType": "jsonata", "rules": [ { "t": "null" @@ -1911,8 +1781,8 @@ "checkall": "true", "repair": false, "outputs": 2, - "x": 1950, - "y": 820, + "x": 1830, + "y": 880, "wires": [ [ "208b6e44f1f2d442" From b082522a15f61908563c9dc1d16f316e01bb6c60 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 21 Mar 2023 15:31:39 +0000 Subject: [PATCH 22/22] chore(release)!: [skip ci] 1.1.0 released --- CHANGELOG.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40dba37..0b71c49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,42 @@ +## [1.1.0](https://github.com/SmartOperatingBlock/operating-block-gateway/compare/1.0.0...1.1.0) (2023-03-21) + + +### Features + +* add commands to manage people tracking on azure plaftform ([d4ccdb7](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/d4ccdb7f2eaa2571fcaca7494fc1d8e3e984157d)) +* add commands to set patient on operating table in azure platform ([6921265](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/6921265f3dac670dfd3f2372e943e7dd320d37c6)) +* add commands to update actuator digital twin on azure plaftorm ([7ca46c5](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/7ca46c5e618bed8b44fc901e0fb737e8a64edcc0)) +* add commands to update medical device digital twin on azure plaftorm ([c25e97c](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/c25e97c119a999d6fbf931a95663b78222da190c)) +* add commands to update room digital twin on azure plaftorm ([64d7389](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/64d7389f1b88d781076b175d4498a6aa038425b5)) + + +### Dependency updates + +* **deps:** update dependency semantic-release-preconfigured-conventional-commits to v1.1.17 ([16b8be3](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/16b8be37cdaef26b4089f0c8632613f23588ad7c)) +* **deps:** update node.js to 18.15 ([fd9bb17](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/fd9bb17fd99254bcc3a7e9a0f8db44e0005cab96)) + + +### Refactoring + +* create subflow to make http request on azure ([ffc7c54](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/ffc7c547c9410d15d1a4932cd6148f61fe178079)) + + +### General maintenance + +* add cast to int if state is a number ([c109f57](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/c109f5737ce564bf7bb168151218f8e31e02fa90)) +* add command to clean configFiles ([f0cbdec](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/f0cbdec397c36773784c98dc0d7b033102f5c7b1)) +* add deletion of rel between room and health professional when he changes room ([869dd79](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/869dd79be245ffe7403b78f354c86c2589ace505)) +* add serial port and https dependencies ([6b62efb](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/6b62efb09ccacfe5b1b97887b05570086ad5cb18)) +* change name to the serial on switch node ([b631dce](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/b631dce46517436e2a3b5c9a29d14d58f0d5fcc0)) +* change relation name between process and medical device digital twins ([55221fb](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/55221fb71b41e3ff70e289323bc45ecbe3dfc128)) +* delete creation of patientDT ([f86ca2d](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/f86ca2d02eeb76ab40ff3eecddd56f903e19e45c)) +* delete unused inject nodes ([9483cf0](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/9483cf0918cf8a74c36d6da77a99f364043e2990)) +* delete useless read from file ([dbaf7b0](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/dbaf7b0488f3f520781a47b2d5abfc03474ceb82)) +* deletedockerfile ([f9c03f7](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/f9c03f702ef0f15cf702dbfc817f07f2b62ee483)) +* disable project_enabled flag ([642d635](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/642d635abfa161ef8acfdaf8e2926a437951b131)) +* edit commands to run the docker container ([a5db6cf](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/a5db6cffa4da02a071cc504f11f017343bd2510d)) +* rename some functions name ([0596e16](https://github.com/SmartOperatingBlock/operating-block-gateway/commit/0596e16ce68a8ec45dd8cd44d63db5d01de0c116)) + ## 1.0.0 (2023-02-07)