152152 "y" : 740 ,
153153 "wires" : [
154154 [
155- " c45a10208faeea88" ,
156- " b19dbb8d1bfea2fc"
155+ " c45a10208faeea88"
157156 ]
158157 ]
159158 },
181180 "type" : " function" ,
182181 "z" : " 09012e75c72a4968" ,
183182 "name" : " MedicalDeviceTracking" ,
184- "func" : " " ,
183+ "func" : " let medicalDeviceModel = \" dtmi:io:github:smartoperatingblock:ImplantableMedicalDevice;1 \"\n msg.url = \" https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/ \" + msg.device_id + \" ?api-version=2023-02-27-preview \"\n msg.method = \" put \"\n\n msg.payload = { \n \" $metadata \" : { \n \" $model \" : medicalDeviceModel \n }, \n \" type \" : msg.device_type \n } \n\n return msg \n " ,
185184 "outputs" : 1 ,
186185 "noerr" : 0 ,
187186 "initialize" : " " ,
191190 "y" : 860 ,
192191 "wires" : [
193192 [
194- " c45a10208faeea88 "
193+ " 1024090145928519 "
195194 ]
196195 ]
197196 },
456455 "initialize" : " " ,
457456 "finalize" : " " ,
458457 "libs" : [],
459- "x" : 1870 ,
460- "y" : 720 ,
458+ "x" : 2910 ,
459+ "y" : 700 ,
461460 "wires" : [
462461 [
463462 " 6a5968a77bdcb8ec"
494493 "targetType" : " msg" ,
495494 "statusVal" : " " ,
496495 "statusType" : " auto" ,
497- "x" : 2220 ,
498- "y" : 720 ,
496+ "x" : 3240 ,
497+ "y" : 700 ,
499498 "wires" : []
500499 },
501500 {
512511 "x" : 1560 ,
513512 "y" : 980 ,
514513 "wires" : [
515- []
514+ [
515+ " 1a6d9092c128a0bd"
516+ ]
516517 ]
517518 },
518519 {
661662 "type" : " function" ,
662663 "z" : " 09012e75c72a4968" ,
663664 "name" : " setRequestToGetToken" ,
664- "func" : " msg.headers = {};\n msg.headers['Content-Type'] = \" application/x-www-form-urlencoded\"\n msg.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 `\n msg.url = \" https://login.microsoftonline.com/\" + env.get(\" AZURE_DT_TENANT_ID\" ) +\" /oauth2/token\" \n return msg;" ,
665+ "func" : " msg.headers = {};\n msg.headers['Content-Type'] = \" application/x-www-form-urlencoded\"\n msg.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 `\n msg.url = \" https://login.microsoftonline.com/\" + env.get(\" AZURE_DT_TENANT_ID\" ) +\" /oauth2/token\" \n return msg;\n //https://digitaltwins.azure.net " ,
665666 "outputs" : 1 ,
666667 "noerr" : 0 ,
667668 "initialize" : " " ,
13361337 ]
13371338 ]
13381339 },
1339- {
1340- "id" : " ea1d80c07843fb89" ,
1341- "type" : " serial out" ,
1342- "z" : " 09012e75c72a4968" ,
1343- "name" : " " ,
1344- "serial" : " 94b8abb47e4cb1f2" ,
1345- "x" : 2090 ,
1346- "y" : 1280 ,
1347- "wires" : []
1348- },
13491340 {
13501341 "id" : " 6a5968a77bdcb8ec" ,
13511342 "type" : " https-node" ,
13601351 "proxy" : " " ,
13611352 "authType" : " " ,
13621353 "senderr" : false ,
1363- "x" : 2050 ,
1364- "y" : 720 ,
1354+ "x" : 3070 ,
1355+ "y" : 700 ,
13651356 "wires" : [
13661357 [
13671358 " 3e879afc64077b51"
14201411 ]
14211412 },
14221413 {
1423- "id" : " b19dbb8d1bfea2fc " ,
1424- "type" : " debug " ,
1414+ "id" : " 61b317ae6b43b406 " ,
1415+ "type" : " inject " ,
14251416 "z" : " 09012e75c72a4968" ,
1426- "name" : " debug 1" ,
1427- "active" : true ,
1428- "tosidebar" : true ,
1429- "console" : false ,
1430- "tostatus" : false ,
1431- "complete" : " false" ,
1432- "statusVal" : " " ,
1433- "statusType" : " auto" ,
1434- "x" : 1900 ,
1435- "y" : 860 ,
1417+ "name" : " type6" ,
1418+ "props" : [
1419+ {
1420+ "p" : " payload"
1421+ },
1422+ {
1423+ "p" : " topic" ,
1424+ "vt" : " str"
1425+ }
1426+ ],
1427+ "repeat" : " " ,
1428+ "crontab" : " " ,
1429+ "once" : false ,
1430+ "onceDelay" : 0.1 ,
1431+ "topic" : " " ,
1432+ "payload" : " {\" type\" : 6, \" device_type\" : \" 0\" , \" device_id\" : \" med2\" , \" room_id\" : \" room1\" }" ,
1433+ "payloadType" : " str" ,
1434+ "x" : 110 ,
1435+ "y" : 460 ,
1436+ "wires" : [
1437+ [
1438+ " ead8458e27835fd5"
1439+ ]
1440+ ]
1441+ },
1442+ {
1443+ "id" : " 1a6d9092c128a0bd" ,
1444+ "type" : " function" ,
1445+ "z" : " 09012e75c72a4968" ,
1446+ "name" : " createActuatorDT" ,
1447+ "func" : " let actuatorModel = \" dtmi:io:github:smartoperatingblock:Actuator;1\"\n msg.url = \" https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.actuator_id + \" ?api-version=2023-02-27-preview\"\n msg.method = \" put\"\n\n msg.payload = {\n \" $metadata\" : {\n \" $model\" : actuatorModel\n },\n \" type\" : msg.actuator_type\n }\n\n return msg" ,
1448+ "outputs" : 1 ,
1449+ "noerr" : 0 ,
1450+ "initialize" : " " ,
1451+ "finalize" : " " ,
1452+ "libs" : [],
1453+ "x" : 1750 ,
1454+ "y" : 980 ,
1455+ "wires" : [
1456+ [
1457+ " f1d5bf00146cb950"
1458+ ]
1459+ ]
1460+ },
1461+ {
1462+ "id" : " c02092f546355c98" ,
1463+ "type" : " https-node" ,
1464+ "z" : " 09012e75c72a4968" ,
1465+ "name" : " " ,
1466+ "method" : " use" ,
1467+ "ret" : " txt" ,
1468+ "paytoqs" : " ignore" ,
1469+ "url" : " " ,
1470+ "tls" : " " ,
1471+ "persist" : true ,
1472+ "proxy" : " " ,
1473+ "authType" : " " ,
1474+ "senderr" : false ,
1475+ "x" : 2130 ,
1476+ "y" : 980 ,
1477+ "wires" : [
1478+ [
1479+ " 7e2fc28f43937855"
1480+ ]
1481+ ]
1482+ },
1483+ {
1484+ "id" : " 7e2fc28f43937855" ,
1485+ "type" : " function" ,
1486+ "z" : " 09012e75c72a4968" ,
1487+ "name" : " createRelationShipWithRoom" ,
1488+ "func" : " let relID = msg.room_id + \" -\" + msg.actuator_id\n msg.url = \" https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \" /relationships/\" + relID + \" ?api-version=2020-10-31\"\n msg.method = \" put\"\n msg.payload = \n {\n \" $targetId\" : msg.actuator_id,\n \" $relationshipName\" : \" rel_has_actuator\"\n }\n\n\n\n return msg\n " ,
1489+ "outputs" : 1 ,
1490+ "noerr" : 0 ,
1491+ "initialize" : " " ,
1492+ "finalize" : " " ,
1493+ "libs" : [],
1494+ "x" : 2370 ,
1495+ "y" : 980 ,
1496+ "wires" : [
1497+ [
1498+ " c45a10208faeea88"
1499+ ]
1500+ ]
1501+ },
1502+ {
1503+ "id" : " c6c4f1b87153a885" ,
1504+ "type" : " inject" ,
1505+ "z" : " 09012e75c72a4968" ,
1506+ "name" : " type8" ,
1507+ "props" : [
1508+ {
1509+ "p" : " payload"
1510+ },
1511+ {
1512+ "p" : " topic" ,
1513+ "vt" : " str"
1514+ }
1515+ ],
1516+ "repeat" : " " ,
1517+ "crontab" : " " ,
1518+ "once" : false ,
1519+ "onceDelay" : 0.1 ,
1520+ "topic" : " " ,
1521+ "payload" : " {\" type\" : 8, \" actuator_type\" : \" 0\" , \" actuator_id\" : \" act111\" , \" room_id\" : \" room1\" }" ,
1522+ "payloadType" : " str" ,
1523+ "x" : 110 ,
1524+ "y" : 500 ,
1525+ "wires" : [
1526+ [
1527+ " ead8458e27835fd5"
1528+ ]
1529+ ]
1530+ },
1531+ {
1532+ "id" : " f1d5bf00146cb950" ,
1533+ "type" : " function" ,
1534+ "z" : " 09012e75c72a4968" ,
1535+ "name" : " add header " ,
1536+ "func" : " msg.headers = {};\n msg.headers['Authorization'] = \" Bearer \" + msg.token\n msg.headers['Content-Type'] = \" application/json\"\n return msg;" ,
1537+ "outputs" : 1 ,
1538+ "noerr" : 0 ,
1539+ "initialize" : " " ,
1540+ "finalize" : " " ,
1541+ "libs" : [],
1542+ "x" : 1950 ,
1543+ "y" : 980 ,
1544+ "wires" : [
1545+ [
1546+ " c02092f546355c98"
1547+ ]
1548+ ]
1549+ },
1550+ {
1551+ "id" : " ea1d80c07843fb89" ,
1552+ "type" : " serial out" ,
1553+ "z" : " 09012e75c72a4968" ,
1554+ "name" : " " ,
1555+ "serial" : " 94b8abb47e4cb1f2" ,
1556+ "x" : 2090 ,
1557+ "y" : 1280 ,
14361558 "wires" : []
1559+ },
1560+ {
1561+ "id" : " 1024090145928519" ,
1562+ "type" : " function" ,
1563+ "z" : " 09012e75c72a4968" ,
1564+ "name" : " add header " ,
1565+ "func" : " msg.headers = {};\n msg.headers['Authorization'] = \" Bearer \" + msg.token\n msg.headers['Content-Type'] = \" application/json\"\n return msg;" ,
1566+ "outputs" : 1 ,
1567+ "noerr" : 0 ,
1568+ "initialize" : " " ,
1569+ "finalize" : " " ,
1570+ "libs" : [],
1571+ "x" : 1590 ,
1572+ "y" : 860 ,
1573+ "wires" : [
1574+ [
1575+ " b172127aa6066d80"
1576+ ]
1577+ ]
1578+ },
1579+ {
1580+ "id" : " b172127aa6066d80" ,
1581+ "type" : " https-node" ,
1582+ "z" : " 09012e75c72a4968" ,
1583+ "name" : " " ,
1584+ "method" : " use" ,
1585+ "ret" : " txt" ,
1586+ "paytoqs" : " ignore" ,
1587+ "url" : " " ,
1588+ "tls" : " " ,
1589+ "persist" : true ,
1590+ "proxy" : " " ,
1591+ "authType" : " " ,
1592+ "senderr" : false ,
1593+ "x" : 1750 ,
1594+ "y" : 860 ,
1595+ "wires" : [
1596+ [
1597+ " 1005329bc4b3f3df"
1598+ ]
1599+ ]
1600+ },
1601+ {
1602+ "id" : " 745c5f5dda78248a" ,
1603+ "type" : " function" ,
1604+ "z" : " 09012e75c72a4968" ,
1605+ "name" : " createRelationShipWithRoom" ,
1606+ "func" : " let process_id = JSON.parse(msg.payload)\n process_id = msg.process_id[\" value\" ][0][\" $dtId\" ]\n let relID = process_id + \" -\" + msg.device_id\n msg.url = \" https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + process_id + \" /relationships/\" + relID + \" ?api-version=2023-02-27-preview\"\n msg.method = \" put\"\n msg.payload = {\n \" $targetId\" : msg.device_id,\n \" $relationshipName\" : \" rel_contains_medical_technology\"\n }\n\n return msg\n " ,
1607+ "outputs" : 1 ,
1608+ "noerr" : 0 ,
1609+ "initialize" : " " ,
1610+ "finalize" : " " ,
1611+ "libs" : [],
1612+ "x" : 2670 ,
1613+ "y" : 860 ,
1614+ "wires" : [
1615+ [
1616+ " c45a10208faeea88"
1617+ ]
1618+ ]
1619+ },
1620+ {
1621+ "id" : " 1005329bc4b3f3df" ,
1622+ "type" : " function" ,
1623+ "z" : " 09012e75c72a4968" ,
1624+ "name" : " requestProcessRelatedToTheRoom" ,
1625+ "func" : " msg.url = \" https://digital-twin-layer.api.neu.digitaltwins.azure.net/query?api-version=2023-02-27-preview\"\n let 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'\"\n msg.method = \" post\"\n\n msg.payload = {\n \" query\" : query\n }\n return msg;" ,
1626+ "outputs" : 1 ,
1627+ "noerr" : 0 ,
1628+ "initialize" : " " ,
1629+ "finalize" : " " ,
1630+ "libs" : [],
1631+ "x" : 1990 ,
1632+ "y" : 860 ,
1633+ "wires" : [
1634+ [
1635+ " 3b376db55eb10b0f"
1636+ ]
1637+ ]
1638+ },
1639+ {
1640+ "id" : " d743a7865378b0dc" ,
1641+ "type" : " https-node" ,
1642+ "z" : " 09012e75c72a4968" ,
1643+ "name" : " " ,
1644+ "method" : " use" ,
1645+ "ret" : " txt" ,
1646+ "paytoqs" : " ignore" ,
1647+ "url" : " " ,
1648+ "tls" : " " ,
1649+ "persist" : true ,
1650+ "proxy" : " " ,
1651+ "authType" : " " ,
1652+ "senderr" : false ,
1653+ "x" : 2430 ,
1654+ "y" : 860 ,
1655+ "wires" : [
1656+ [
1657+ " 745c5f5dda78248a"
1658+ ]
1659+ ]
1660+ },
1661+ {
1662+ "id" : " 3b376db55eb10b0f" ,
1663+ "type" : " function" ,
1664+ "z" : " 09012e75c72a4968" ,
1665+ "name" : " add header " ,
1666+ "func" : " msg.headers = {};\n msg.headers['Authorization'] = \" Bearer \" + msg.token\n msg.headers['Content-Type'] = \" application/json\"\n return msg;" ,
1667+ "outputs" : 1 ,
1668+ "noerr" : 0 ,
1669+ "initialize" : " " ,
1670+ "finalize" : " " ,
1671+ "libs" : [],
1672+ "x" : 2250 ,
1673+ "y" : 860 ,
1674+ "wires" : [
1675+ [
1676+ " d743a7865378b0dc"
1677+ ]
1678+ ]
14371679 }
14381680]
0 commit comments