[
    {
        "id": "d4900938ba6ba410",
        "type": "subflow",
        "name": "EMR Example OPCUA Server",
        "info": "",
        "category": "EMR Simulators",
        "in": [],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#3FADB5"
    },
    {
        "id": "6fa2c1f3150018a8",
        "type": "function",
        "z": "d4900938ba6ba410",
        "name": "Example OPCUA Server",
        "func": "// Code here will run on every message input.\n// You can react to the msg object and for\n// example, edit the address space or restart\n// the server.\n\n// To let objects survive after scripts have been\n// finished, put them in the node, flow or global\n// context.\n\n// For more information on this mutable server, please check out the PLUS\n// for Node-RED OPC UA book or ask your P4NR contact person.\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "// Code added here will be run once\n// whenever the node is started.\n\n// Create and start the mutable server here.\nvar p4nrFramework = global.get('p4nrFramework');\n\n//let server = new p4nrFramework.MachineryServer(24840, \"MutableTestServer\")\nlet server = new p4nrFramework.BaseServer()\nconst DataType = p4nrFramework.DataTypeIds\n\nlet scriptObjects = {}\nlet eventObjects = []\n\ncontext.set(\"scriptObjects\", scriptObjects)\ncontext.set(\"eventObjects\", eventObjects)\ncontext.set(\"server\", server)\n\n\n\nconst StatusCodes = p4nrFramework.StatusCodes\nconst Variant = p4nrFramework.Variant\nconst LocalizedText = p4nrFramework.LocalizedText\n\nlet servConf = {\n    port: 24840,\n    serverName: \"EMRDemoServer\"\n}\nserver.init(servConf).then(() => {\n    node.status({ fill: \"yellow\", shape: \"ring\", text: \"initialized\" });\n\n    try{\n        // After init, you can access and edit the address\n        // space however you like\n\n        const addressSpace = server.addressSpace\n        const namespace = addressSpace.getOwnNamespace()\n        const applicationNamespace = addressSpace.registerNamespace('https://emerson.com')\n        context.set(\"namespace\", applicationNamespace.index)\n        \n\n        let pacedgeExample = applicationNamespace.addObject({\n            browseName: 'EMR-Example-Server',\n            description: 'EMR-Example-Server',\n            organizedBy: addressSpace.rootFolder.objects,\n            notifierOf: addressSpace.rootFolder.objects.server\n        })\n\n        // set initial value\n        scriptObjects.sin_output = 0\n        // add new tag\n        scriptObjects.exampleVariable = applicationNamespace.addAnalogDataItem({\n            componentOf: pacedgeExample,\n            valuePrecision: 2,\n            instrumentRange: { low: -1, high: 1 },\n            engineeringUnitsRange: { low: -1, high: 1 },\n            //accessLevel: 'CurrentWrite',\n            nodeId: 's=sin_output',\n            browseName: 'SIN Output',\n            displayName: [\n                new LocalizedText({ text: 'SIN Output', locale: 'en-US' })\n            ],\n            dataType: 'Float',\n            value: {\n                get: function () {\n                    return new Variant({\n                        dataType: 'Float',\n                        value: scriptObjects.sin_output\n                    })\n                },\n                set: function (variant) {\n                    scriptObjects.sin_output = parseFloat(variant.value)\n                    return StatusCodes.Good\n                }\n            }\n        })\n\n        // set initial value\n        scriptObjects.sin_scaling = 50\n        // add new tag\n        scriptObjects.exampleVariable = applicationNamespace.addAnalogDataItem({\n            componentOf: pacedgeExample,\n            //valuePrecision: 2,\n            //instrumentRange: { low: 0, high: 65535 },\n            engineeringUnitsRange: { low: 0, high: 65535 },\n            //accessLevel: 'CurrentWrite',\n            nodeId: 's=sin_scaling',\n            browseName: 'SIN Scaling',\n            displayName: [\n                new LocalizedText({ text: 'SIN Scaling', locale: 'en-US' })\n            ],\n            dataType: DataType.Int16,\n            value: {\n                get: function () {\n                    return new Variant({\n                        dataType: DataType.Int16,\n                        value: scriptObjects.sin_scaling\n                    })\n                },\n                set: function (variant) {\n                    scriptObjects.sin_scaling = parseInt(variant.value)\n                    return StatusCodes.Good\n                }\n            }\n        })\n\n        // set initial value\n        scriptObjects.sweep_time = 0\n        // add new tag\n        scriptObjects.exampleVariable = applicationNamespace.addAnalogDataItem({\n            componentOf: pacedgeExample,\n            valuePrecision: 5,\n            instrumentRange: { low: 0, high: 100 },\n            engineeringUnitsRange: { low: 0, high: 100 },\n            //accessLevel: 'CurrentWrite',\n            nodeId: 'i=20108',\n            browseName: 'Sweep Time',\n            displayName: [\n                new LocalizedText({ text: 'Sweep Time', locale: 'en-US' })\n            ],\n            dataType: 'Double',\n            value: {\n                get: function () {\n                    return new Variant({\n                        dataType: 'Double',\n                        value: scriptObjects.sweep_time\n                    })\n                },\n                set: function (variant) {\n                    scriptObjects.sweep_time = parseFloat(variant.value)\n                    return StatusCodes.Good\n                }\n            }\n        })\n \n\n    } catch(e) {\n        node.error(\"Error editing the address space: \" + e);\n        console.log(e)\n        return\n    }\n\n\n    // Then you can start the created server\n    server.start().then(() => {\n        node.status({ fill: \"green\", shape: \"dot\", text: \"started\" })\n    }).catch((e) => {\n        node.error(\"Error starting Server: \" + e)\n        node.status({ fill: \"red\", shape: \"dot\", text: \"error\" });\n    })\n}).catch((e) => {\n    node.error(\"Error initializing Server: \" + e)\n    node.status({ fill: \"red\", shape: \"dot\", text: \"error\" });\n})",
        "finalize": "// Code added here will be run when the\n// node is being stopped or re-deployed.\n\n// Shutdown the server here.\nlet server = context.get(\"server\")\nif (server) {\n    server.stop()\n        .then(() => {\n            node.status({ fill: \"red\", shape: \"ring\", text: \"stopped\" });\n        })\n        .catch(e => {\n            node.error(\"Error stopping Server: \" + e)\n            node.status({ fill: \"red\", shape: \"dot\", text: \"error\" });\n        })\n} else {\n    node.status({ fill: \"red\", shape: \"dot\", text: \"error\" });\n    node.error(\"No Server in context to stop\");\n}",
        "libs": [],
        "x": 440,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "edeccb678243bd10",
        "type": "inject",
        "z": "d4900938ba6ba410",
        "name": "Read Inject",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "0.5",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 620,
        "wires": [
            [
                "f8174bbc28676c44"
            ]
        ]
    },
    {
        "id": "f8174bbc28676c44",
        "type": "opcua-inject-tool",
        "z": "d4900938ba6ba410",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "appendMode": false,
        "addressSpaceItems": [
            {
                "name": "",
                "nodeId": "ns=2;s=sin_scaling",
                "datatypeName": "Int16"
            }
        ],
        "plusOpcuaDataStructureObject": {
            "opcuaItems": [
                {
                    "name": "",
                    "nodeId": "ns=2;s=sin_scaling",
                    "datatypeName": "Int16"
                }
            ],
            "metadata": {
                "hasOpcuaItems": true,
                "opcuaItemsLength": 1,
                "parameters": {}
            }
        },
        "template": "None",
        "templateClass": "None",
        "templateType": "None",
        "templateInputs": {
            "normal": "ReadOptions",
            "event": "None",
            "template": "None",
            "type": "None",
            "class": ""
        },
        "x": 400,
        "y": 620,
        "wires": [
            [
                "3b7abb154e9bfbdd"
            ]
        ]
    },
    {
        "id": "3b7abb154e9bfbdd",
        "type": "opcua-service-read",
        "z": "d4900938ba6ba410",
        "clientNode": "389d1524d905a991",
        "name": "Read Mutable Machinery Server",
        "showStatusActivities": false,
        "showErrors": false,
        "x": 660,
        "y": 620,
        "wires": [
            [
                "7ac3b30c6cd252cd"
            ]
        ]
    },
    {
        "id": "7ac3b30c6cd252cd",
        "type": "function",
        "z": "d4900938ba6ba410",
        "name": "Generate Sine values",
        "func": "let sin_scaling = msg.payload.opcuaItems[0].value.value;\n\nmsg.payload = {};\n\ncontext.data.i += 10*50/sin_scaling;\n// trying to minimize jumps when reseting the variable\nif (context.data.i >= 360){\n    context.data.i = 0 + (context.data.i-360);\n}\nlet val_rad = Math.PI / 180 * context.data.i;\nlet sin_val = Math.sin(val_rad);\n\nmsg.payload = {\n    \"opcuaItems\": [\n        {\n            \"nodeId\": \"ns=2;s=sin_output\",\n            \"attributeId\": 13,\n            \"value\": {\n                \"value\": {\n                    \"value\": sin_val,\n                    \"dataType\": \"Float\"\n                }\n            }\n        }\n    ],\n    \"metadata\": {\n        \"parameters\": {},\n        \"hasOpcuaItems\": true,\n        \"opcuaItemsLength\": 1\n    }\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "// Code added here will be run once\n// whenever the node is started.\ncontext.data = {};\ncontext.data.i = 0;",
        "finalize": "",
        "libs": [],
        "x": 460,
        "y": 740,
        "wires": [
            [
                "763bd8ce145ee33a"
            ]
        ]
    },
    {
        "id": "763bd8ce145ee33a",
        "type": "opcua-service-write",
        "z": "d4900938ba6ba410",
        "clientNode": "389d1524d905a991",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "x": 680,
        "y": 740,
        "wires": [
            []
        ]
    },
    {
        "id": "7b1e02817066c72a",
        "type": "inject",
        "z": "d4900938ba6ba410",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "0.5",
        "crontab": "",
        "once": true,
        "onceDelay": "10",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 520,
        "wires": [
            [
                "4ec2944326d821d7"
            ]
        ]
    },
    {
        "id": "4ec2944326d821d7",
        "type": "function",
        "z": "d4900938ba6ba410",
        "name": "Generate Sweep Time",
        "func": "msg.payload = {};\n\nlet sweep_val = 0.0003 + Math.random()/10000;\n\nmsg.payload = {};\nmsg.payload = {\n    \"opcuaItems\": [\n        {\n            \"nodeId\": \"ns=2;i=20108\",\n            \"attributeId\": 13,\n            \"value\": {\n                \"value\": {\n                    \"value\": sweep_val,\n                    \"dataType\": \"Double\"\n                }\n            }\n        }\n    ],\n    \"metadata\": {\n        \"parameters\": {},\n        \"hasOpcuaItems\": true,\n        \"opcuaItemsLength\": 1\n    }\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 460,
        "y": 520,
        "wires": [
            [
                "7ae17fca70c95011"
            ]
        ]
    },
    {
        "id": "7ae17fca70c95011",
        "type": "opcua-service-write",
        "z": "d4900938ba6ba410",
        "clientNode": "389d1524d905a991",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "x": 680,
        "y": 520,
        "wires": [
            []
        ]
    },
    {
        "id": "65e7a9e872161c2d",
        "type": "comment",
        "z": "d4900938ba6ba410",
        "name": "OPCUA Server Configuration",
        "info": "",
        "x": 460,
        "y": 80,
        "wires": []
    },
    {
        "id": "05995b60a82e420b",
        "type": "comment",
        "z": "d4900938ba6ba410",
        "name": "Writing simulated values to Tags",
        "info": "",
        "x": 470,
        "y": 420,
        "wires": []
    },
    {
        "id": "3f016fd1c3593e57",
        "type": "inject",
        "z": "d4900938ba6ba410",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 120,
        "wires": [
            [
                "6fa2c1f3150018a8"
            ]
        ]
    },
    {
        "id": "389d1524d905a991",
        "type": "opcua-compact-client",
        "name": "EMR OPCUA Example Server",
        "clientOptions": {
            "endpoint": "opc.tcp://localhost:24840",
            "applicationName": "EMR Example Server",
            "applicationUri": "",
            "clientCertificateManager": null,
            "certificateFile": null,
            "clientName": "EMR Example Server",
            "connectionStrategy": {
                "initialDelay": 1000,
                "maxDelay": 20000,
                "maxRetry": 20,
                "randomisationFactor": 0.1
            },
            "defaultSecureTokenLifetime": 600000,
            "discoveryUrl": "",
            "endpointMustExist": false,
            "keepPendingSessionsOnDisconnect": false,
            "keepSessionAlive": true,
            "privateKeyFile": null,
            "requestedSessionTimeout": 60000,
            "securityMode": 1,
            "securityPolicy": "http://opcfoundation.org/UA/SecurityPolicy#None",
            "tokenRenewalInterval": 0,
            "userIdentityInfo": {
                "type": 0
            },
            "autoConnectCorrectEndpoint": true,
            "performanceMode": 0
        },
        "template": "Unsecured",
        "templateInputs": {
            "template": "Unsecured"
        }
    },
    {
        "id": "b8275e1b1ea99326",
        "type": "subflow",
        "name": "Trigger Python (2)",
        "info": "",
        "category": "EMR Python Example",
        "in": [
            {
                "x": 300,
                "y": 180,
                "wires": [
                    {
                        "id": "12b318efad7d37cd"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 790,
                "y": 240,
                "wires": [
                    {
                        "id": "1cca99f580911c6e",
                        "port": 0
                    }
                ]
            },
            {
                "x": 790,
                "y": 300,
                "wires": [
                    {
                        "id": "1cca99f580911c6e",
                        "port": 1
                    }
                ]
            }
        ],
        "env": [
            {
                "name": "Python_Script",
                "type": "str",
                "value": "",
                "ui": {
                    "type": "select",
                    "opts": {
                        "opts": [
                            {
                                "l": {
                                    "en-US": "1"
                                },
                                "v": "1"
                            },
                            {
                                "l": {
                                    "en-US": "2"
                                },
                                "v": "2"
                            }
                        ]
                    }
                }
            },
            {
                "name": "Parameter",
                "type": "num",
                "value": "1"
            }
        ],
        "meta": {},
        "color": "#3FADB5",
        "inputLabels": [
            "Input"
        ],
        "outputLabels": [
            "Result",
            "Error"
        ],
        "icon": "node-red/arrow-in.svg"
    },
    {
        "id": "12b318efad7d37cd",
        "type": "function",
        "z": "b8275e1b1ea99326",
        "name": "",
        "func": "let msg2 = {};\nmsg2.topic = \"emr_python_v1/start_script\";\nmsg2.payload = {};\nif ('opcuaItems' in msg.payload){\n    //message from OPCUA Client\n    msg2.payload.value = msg.payload.opcuaItems[0].value.value;\n    let tagName = msg.payload.opcuaItems[0].nodeId.split(';')[1];\n    msg2.payload.tagName = tagName.split('=')[1];\n}else{\n    // generic message\n    msg2.payload.value = msg.payload.value.value;\n    msg2.payload.tagName = msg.payload.value.tagName;\n}\n\nmsg2.payload.parameter = env.get('Parameter');\nmsg2.payload.command = \"run script \"+env.get('Python_Script');\nmsg2.payload.metadata = {};\nmsg2.payload.metadata = msg.payload;\nreturn msg2;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 460,
        "y": 180,
        "wires": [
            [
                "635a6d95242b210a"
            ]
        ]
    },
    {
        "id": "635a6d95242b210a",
        "type": "mqtt out",
        "z": "b8275e1b1ea99326",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "b4ad0587.7610d8",
        "x": 670,
        "y": 180,
        "wires": []
    },
    {
        "id": "f080c71fca93b4ef",
        "type": "mqtt in",
        "z": "b8275e1b1ea99326",
        "name": "",
        "topic": "emr_python_v1/script_done",
        "qos": "2",
        "datatype": "json",
        "broker": "b4ad0587.7610d8",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 390,
        "y": 240,
        "wires": [
            [
                "1cca99f580911c6e"
            ]
        ]
    },
    {
        "id": "1cca99f580911c6e",
        "type": "function",
        "z": "b8275e1b1ea99326",
        "name": "",
        "func": "if(msg.payload.script_number == env.get('Python_Script')){\n    let msg2 = {};\n    msg2.payload = {};\n    if(msg.payload.status == \"ok\"){\n        msg2.payload = msg.payload;\n        node.send([msg2,null]);\n    }else{\n        msg2.payload.status = msg.payload.status;\n        node.send([null,msg2]);\n    }\n}\n\nreturn;",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 240,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "3826641611ddd578",
        "type": "subflow",
        "name": "EMR Subscribe to OPCUA (2)",
        "info": "",
        "category": "EMR Python Example",
        "in": [],
        "out": [
            {
                "x": 1140,
                "y": 140,
                "wires": [
                    {
                        "id": "70a10e2bce6b5b51",
                        "port": 0
                    }
                ]
            },
            {
                "x": 1110,
                "y": 200,
                "wires": [
                    {
                        "id": "323515d11c90cdee",
                        "port": 0
                    }
                ]
            },
            {
                "x": 1110,
                "y": 240,
                "wires": [
                    {
                        "id": "51ec58ad77d90d84",
                        "port": 0
                    }
                ]
            },
            {
                "x": 1110,
                "y": 280,
                "wires": [
                    {
                        "id": "e22707008e5df226",
                        "port": 0
                    }
                ]
            },
            {
                "x": 1110,
                "y": 320,
                "wires": [
                    {
                        "id": "719c83f2cca6b4d6",
                        "port": 0
                    }
                ]
            },
            {
                "x": 1110,
                "y": 360,
                "wires": [
                    {
                        "id": "5f07dccd19704b51",
                        "port": 0
                    }
                ]
            },
            {
                "x": 1000,
                "y": 440,
                "wires": [
                    {
                        "id": "49a74d490eda68f2",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [
            {
                "name": "OPCUA Server Port",
                "type": "str",
                "value": "localhost:24840",
                "ui": {
                    "icon": "font-awesome/fa-exchange",
                    "type": "select",
                    "opts": {
                        "opts": [
                            {
                                "l": {
                                    "en-US": "CPL410 Internal VNIC"
                                },
                                "v": "192.168.180.2:4840"
                            },
                            {
                                "l": {
                                    "en-US": "CPL410 LAN1"
                                },
                                "v": "192.168.0.100:4840"
                            },
                            {
                                "l": {
                                    "en-US": "Simulator"
                                },
                                "v": "localhost:24840"
                            }
                        ]
                    }
                }
            },
            {
                "name": "Tag-1 ID",
                "type": "str",
                "value": "ns=2;i=20108"
            },
            {
                "name": "Tag-2 ID",
                "type": "str",
                "value": ""
            },
            {
                "name": "Tag-3 ID",
                "type": "str",
                "value": ""
            },
            {
                "name": "Tag-4 ID",
                "type": "str",
                "value": ""
            },
            {
                "name": "Tag-5 ID",
                "type": "str",
                "value": ""
            }
        ],
        "meta": {},
        "color": "#3FADB5",
        "outputLabels": [
            "OPCUA Client Config",
            "Tag-1 Value",
            "Tag-2 Value",
            "Tag-3 Value",
            "Tag-4 Value",
            "Tag-5 Value",
            "All Tag Values"
        ],
        "status": {
            "x": 880,
            "y": 60,
            "wires": [
                {
                    "id": "76ac4d4da8d1fbf9",
                    "port": 0
                }
            ]
        }
    },
    {
        "id": "49a74d490eda68f2",
        "type": "opcua-service-monitor",
        "z": "3826641611ddd578",
        "clientNode": "ecd65bcc2d453703",
        "name": "EMR_Example_OPCUA_Client",
        "configInNode": false,
        "groupedMonitoring": true,
        "queueSize": 10,
        "discardOldest": true,
        "samplingInterval": "100",
        "requestedPublishingInterval": 1000,
        "priority": 0,
        "concatWithInputParams": true,
        "x": 650,
        "y": 300,
        "wires": [
            [
                "323515d11c90cdee",
                "51ec58ad77d90d84",
                "e22707008e5df226",
                "719c83f2cca6b4d6",
                "5f07dccd19704b51"
            ]
        ]
    },
    {
        "id": "323515d11c90cdee",
        "type": "switch",
        "z": "3826641611ddd578",
        "name": "",
        "property": "payload.opcuaItems[0].nodeId",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Tag-1 ID",
                "vt": "env"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 910,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "26968b454f0d7340",
        "type": "function",
        "z": "3826641611ddd578",
        "name": "function 2",
        "func": "//if (typeof env.get('Tag-1 ID') === 'string' && env.get('Tag-1 ID').length > 0){\n//    node.warn(\"Tag variable has been defined\");\n//}else{\n//    node.warn(\"Tag variable has not been defined\")\n//}\n\nlet tagDefined = false;\nmsg = {};\nmsg.payload = {\n    \"opcuaItems\": []\n}\nif (typeof env.get('Tag-1 ID') === 'string' && env.get('Tag-1 ID').length > 0) {\n    // variable has been defined\n    msg.payload.opcuaItems.push({nodeId: env.get('Tag-1 ID')});\n    tagDefined = true;\n}\nif (typeof env.get('Tag-2 ID') === 'string' && env.get('Tag-2 ID').length > 0) {\n    // variable has been defined\n    msg.payload.opcuaItems.push({ nodeId: env.get('Tag-2 ID') });\n    tagDefined = true;\n}\nif (typeof env.get('Tag-3 ID') === 'string' && env.get('Tag-3 ID').length > 0) {\n    // variable has been defined\n    msg.payload.opcuaItems.push({ nodeId: env.get('Tag-3 ID') });\n    tagDefined = true;\n}\nif (typeof env.get('Tag-4 ID') === 'string' && env.get('Tag-4 ID').length > 0) {\n    // variable has been defined\n    msg.payload.opcuaItems.push({ nodeId: env.get('Tag-4 ID') });\n    tagDefined = true;\n}\nif (typeof env.get('Tag-5 ID') === 'string' && env.get('Tag-5 ID').length > 0) {\n    // variable has been defined\n    msg.payload.opcuaItems.push({ nodeId: env.get('Tag-5 ID') });\n    tagDefined = true;\n}\n\nif(!tagDefined){\n    node.error(\"ERROR, at least one OPCUA Tag needs to be configured\", \n    { ERROR: \"Error, at least one OPCUA Tag needs to be configrued\" })\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 300,
        "wires": [
            [
                "49a74d490eda68f2"
            ]
        ]
    },
    {
        "id": "3441f5f837f87f6e",
        "type": "inject",
        "z": "3826641611ddd578",
        "name": "Trigger subscription",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "7",
        "topic": "subscribe",
        "x": 160,
        "y": 300,
        "wires": [
            [
                "26968b454f0d7340"
            ]
        ]
    },
    {
        "id": "51ec58ad77d90d84",
        "type": "switch",
        "z": "3826641611ddd578",
        "name": "",
        "property": "payload.opcuaItems[0].nodeId",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Tag-2 ID",
                "vt": "env"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 910,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "e22707008e5df226",
        "type": "switch",
        "z": "3826641611ddd578",
        "name": "",
        "property": "payload.opcuaItems[0].nodeId",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Tag-3 ID",
                "vt": "env"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 910,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "719c83f2cca6b4d6",
        "type": "switch",
        "z": "3826641611ddd578",
        "name": "",
        "property": "payload.opcuaItems[0].nodeId",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Tag-4 ID",
                "vt": "env"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 910,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "5f07dccd19704b51",
        "type": "switch",
        "z": "3826641611ddd578",
        "name": "",
        "property": "payload.opcuaItems[0].nodeId",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "Tag-5 ID",
                "vt": "env"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 910,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "70a10e2bce6b5b51",
        "type": "function",
        "z": "3826641611ddd578",
        "name": "function 8",
        "func": "\nmsg = {};\nmsg.payload = {\n    \"opcuaItems\": [],\n    \"metadata\": {\n        \"parameters\": {\n            \"controlType\": 6,\n            //\"endpoint\": \"opc.tcp://\" + env.get('CPL410 OPCUA Server Port') + \":4840\",\n            \"endpoint\": \"opc.tcp://\" + env.get('OPCUA Server Port'),\n            \"autoConnectCorrectEndpoint\": true\n        },\n        \"hasOpcuaItems\": false,\n        \"opcuaItemsLength\": 0\n    }\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "ab76f9cb58c9d4fc",
        "type": "inject",
        "z": "3826641611ddd578",
        "name": "Trigger subscription",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "2",
        "topic": "configure OPCUA Server",
        "x": 160,
        "y": 140,
        "wires": [
            [
                "70a10e2bce6b5b51"
            ]
        ]
    },
    {
        "id": "76ac4d4da8d1fbf9",
        "type": "status",
        "z": "3826641611ddd578",
        "name": "",
        "scope": [
            "49a74d490eda68f2"
        ],
        "x": 420,
        "y": 40,
        "wires": [
            []
        ]
    },
    {
        "id": "2975150879276a06",
        "type": "subflow",
        "name": "Store to InfluxDB (2)",
        "info": "Customized node to store data in InfluxDB database\r\n\r\nNode if data comes from OPCUA Client node or from Python node and adjust formating appropriately:\r\n\r\nWhen from OPCUA Client:\r\n\r\ntag name: **msg.payload.opcuaItems[0].nodeId**\r\n\r\nvalue: **msg.payload.opcuaItems[0].value.value**\r\n\r\nWhen data comes from Python:\r\n\r\ntag name and value is from: **msg.payload.value**, \r\n\r\nwhich is expected to be an Object with key:value pair.",
        "category": "EMR Python Example",
        "in": [
            {
                "x": 40,
                "y": 80,
                "wires": [
                    {
                        "id": "5b57c3d8bd08a176"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 530,
                "y": 140,
                "wires": [
                    {
                        "id": "5b57c3d8bd08a176",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [
            {
                "name": "username",
                "type": "str",
                "value": "admin"
            },
            {
                "name": "password",
                "type": "cred"
            },
            {
                "name": "database",
                "type": "str",
                "value": "data"
            },
            {
                "name": "measurement",
                "type": "str",
                "value": "EMR_valve"
            }
        ],
        "meta": {},
        "color": "#3FADB5",
        "inputLabels": [
            "Data In"
        ],
        "outputLabels": [
            "Status"
        ],
        "icon": "node-red/db.svg"
    },
    {
        "id": "cccd7176c069a5d1",
        "type": "influxdb out",
        "z": "2975150879276a06",
        "influxdb": "d1d3cecd07607808",
        "name": "",
        "measurement": "$(measurement)",
        "precision": "",
        "retentionPolicy": "",
        "database": "database",
        "precisionV18FluxV20": "ms",
        "retentionPolicyV18Flux": "",
        "org": "organisation",
        "bucket": "bucket",
        "x": 650,
        "y": 80,
        "wires": []
    },
    {
        "id": "5b57c3d8bd08a176",
        "type": "function",
        "z": "2975150879276a06",
        "name": "format data for InfluxDB",
        "func": "let msg2 = {};\nmsg2.payload = {};\n// check if incoming data format is from OPCUA or from Python\nif ('opcuaItems' in msg.payload) {\n    //message from OPCUA Client\n    let tagName = msg.payload.opcuaItems[0].nodeId.split(';')[1];\n    tagName = tagName.split('=')[1];\n    msg2.payload[tagName] = msg.payload.opcuaItems[0].value.value;\n    msg2.topic = \"OPCUA_data\";\n}else{\n    // this is data from Python \n    msg2.payload = msg.payload.value;\n    msg2.topic = \"Python_data\";\n}\nreturn msg2;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 250,
        "y": 80,
        "wires": [
            [
                "cccd7176c069a5d1"
            ]
        ]
    },
    {
        "id": "d1d3cecd07607808",
        "type": "influxdb",
        "z": "2975150879276a06",
        "hostname": "influxdb",
        "port": "8086",
        "protocol": "http",
        "database": "$(database)",
        "name": "EMR_influxdb",
        "usetls": false,
        "tls": "",
        "influxdbVersion": "1.x",
        "url": "http://localhost:8086",
        "rejectUnauthorized": true,
		"credentials": {
			"username": "$(username)",
			"password": "$(password)",
			"token": ""
		}
    },
    {
        "id": "92ad2ae1b56c71d8",
        "type": "subflow",
        "name": "EMR Write to OPCUA (2)",
        "info": "Emerson Valve Input Node, to be used to set Tags value\n\nValue to be provided in:\n\n**msg.payload.value**\n\nTag value shall be **Int16**",
        "category": "EMR Python Example",
        "in": [
            {
                "x": 100,
                "y": 340,
                "wires": [
                    {
                        "id": "d9cc996028c69d08"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 870,
                "y": 340,
                "wires": [
                    {
                        "id": "d9cc996028c69d08",
                        "port": 1
                    },
                    {
                        "id": "6ef6a28cecf4c6e1",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [
            {
                "name": "Tag Id",
                "type": "str",
                "value": ""
            },
            {
                "name": "Tag Type",
                "type": "str",
                "value": ""
            }
        ],
        "meta": {},
        "color": "#3FADB5",
        "inputLabels": [
            "Tag Input"
        ],
        "outputLabels": [
            "Status"
        ],
        "icon": "node-red/join.svg",
        "status": {
            "x": 860,
            "y": 220,
            "wires": [
                {
                    "id": "18f14b446f2f12d6",
                    "port": 0
                }
            ]
        }
    },
    {
        "id": "d9cc996028c69d08",
        "type": "function",
        "z": "92ad2ae1b56c71d8",
        "name": "",
        "func": "let msg2={};\nif ('value' in msg.payload.value) {\n    msg2.payload = {\n        \"opcuaItems\": [\n            {\n                \"nodeId\": env.get('Tag Id'),\n                \"attributeId\": 13,\n                \"value\": {\n                    \"value\": {\n                        \"value\": msg.payload.value.value,\n                        \"dataType\": env.get('Tag Type')\n                    }\n                }\n            }\n        ],\n        \"metadata\": {\n            \"parameters\": {},\n            \"hasOpcuaItems\": true,\n            \"opcuaItemsLength\": 1\n        }\n    }\n    node.send([msg2,null]);\n}else{\n    msg.error = \"ERROR, msg.payload.value.value object does not exist, corrent the input message format\";\n    node.send([null,msg]);\n    node.error(\"ERROR, msg.payload.value.value object does not exist, corrent the input message format\", msg);\n}\nreturn;\n",
        "outputs": 2,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 380,
        "y": 340,
        "wires": [
            [
                "6ef6a28cecf4c6e1"
            ],
            []
        ]
    },
    {
        "id": "6ef6a28cecf4c6e1",
        "type": "opcua-service-write",
        "z": "92ad2ae1b56c71d8",
        "clientNode": "ecd65bcc2d453703",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "x": 600,
        "y": 300,
        "wires": [
            [
                "18f14b446f2f12d6"
            ]
        ]
    },
    {
        "id": "18f14b446f2f12d6",
        "type": "function",
        "z": "92ad2ae1b56c71d8",
        "name": "function 9",
        "func": "msg.payload = msg.payload.opcuaItems[0]._description;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "ecd65bcc2d453703",
        "type": "opcua-compact-client",
        "name": "EMR_Example_OPCUA_Client",
        "clientOptions": {
            "endpoint": "opc.tcp://localhost:24840",
            "applicationName": "P4NR-OpcUA-Client",
            "applicationUri": "",
            "clientCertificateManager": null,
            "certificateFile": null,
            "clientName": "P4NR-OpcUA-Client",
            "connectionStrategy": {
                "initialDelay": 1000,
                "maxDelay": 20000,
                "maxRetry": 20,
                "randomisationFactor": 0.1
            },
            "defaultSecureTokenLifetime": 600000,
            "discoveryUrl": "",
            "endpointMustExist": false,
            "keepPendingSessionsOnDisconnect": false,
            "keepSessionAlive": true,
            "privateKeyFile": null,
            "requestedSessionTimeout": 60000,
            "securityMode": 1,
            "securityPolicy": "http://opcfoundation.org/UA/SecurityPolicy#None",
            "tokenRenewalInterval": 0,
            "userIdentityInfo": {
                "type": 0
            },
            "autoConnectCorrectEndpoint": true,
            "performanceMode": 0
        },
        "template": "Unsecured",
        "templateInputs": {
            "template": "Unsecured"
        }
    },
    {
        "id": "cf294e934e79426c",
        "type": "tab",
        "label": "EMR Python Example",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c7ad4629ba1f9a51",
        "type": "subflow:92ad2ae1b56c71d8",
        "z": "cf294e934e79426c",
        "name": "",
        "env": [
            {
                "name": "Tag Id",
                "value": "ns=2;s=sin_scaling",
                "type": "str"
            },
            {
                "name": "Tag Type",
                "value": "Int16",
                "type": "str"
            }
        ],
        "x": 560,
        "y": 900,
        "wires": [
            [
                "0489ef6c09f97d2c"
            ]
        ]
    },
    {
        "id": "0489ef6c09f97d2c",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 770,
        "y": 900,
        "wires": []
    },
    {
        "id": "278d7377e1f322f7",
        "type": "mqtt in",
        "z": "cf294e934e79426c",
        "name": "",
        "topic": "#",
        "qos": "2",
        "datatype": "json",
        "broker": "b4ad0587.7610d8",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 190,
        "y": 1120,
        "wires": [
            [
                "d064d4edb9e03703"
            ]
        ]
    },
    {
        "id": "d064d4edb9e03703",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "debug",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 410,
        "y": 1120,
        "wires": []
    },
    {
        "id": "f769355772db6895",
        "type": "inject",
        "z": "cf294e934e79426c",
        "name": "Write 20 to SIN Scaling tag",
        "props": [
            {
                "p": "payload.value.value",
                "v": "20",
                "vt": "num"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 240,
        "y": 900,
        "wires": [
            [
                "c7ad4629ba1f9a51"
            ]
        ]
    },
    {
        "id": "69e74fa5677699eb",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "Manually Setting the Tag value",
        "info": "",
        "x": 250,
        "y": 860,
        "wires": []
    },
    {
        "id": "e71e2922997cd47e",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "Subscribing to all topics on MQTT Broker, for debug",
        "info": "",
        "x": 310,
        "y": 1080,
        "wires": []
    },
    {
        "id": "7227b2fef7b07b49",
        "type": "subflow:2975150879276a06",
        "z": "cf294e934e79426c",
        "name": "",
        "env": [
            {
                "name": "password",
                "type": "cred"
            },
            {
                "name": "measurement",
                "value": "EMR_example",
                "type": "str"
            }
        ],
        "x": 710,
        "y": 480,
        "wires": [
            []
        ]
    },
    {
        "id": "3f97aa1c05b7028f",
        "type": "subflow:3826641611ddd578",
        "z": "cf294e934e79426c",
        "name": "",
        "env": [
            {
                "name": "Tag-2 ID",
                "value": "ns=2;s=sin_output",
                "type": "str"
            },
            {
                "name": "Tag-3 ID",
                "value": "ns=2;s=sin_scaling",
                "type": "str"
            },
            {
                "name": "CPL410 OPCUA Server Port",
                "value": "192.168.0.100",
                "type": "str"
            },
            {
                "name": "CPL410 OPCUA Server Connection",
                "value": "192.168.0.100",
                "type": "str"
            }
        ],
        "x": 370,
        "y": 380,
        "wires": [
            [
                "f92aacc4084fe667"
            ],
            [
                "9d8ebadf06121ae3",
                "4a740c3e28a4597d"
            ],
            [
                "5772f250dbcf0c3a",
                "7227b2fef7b07b49",
                "bddc379e49d59bee"
            ],
            [
                "6f7fafedcda552da"
            ],
            [
                "d85fd74224049fb2"
            ],
            [
                "167f79b9e5848311"
            ],
            [
                "9f733048d504a113"
            ]
        ]
    },
    {
        "id": "9d8ebadf06121ae3",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "OPCUA Tag value",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload.opcuaItems[0].value.value",
        "statusType": "msg",
        "x": 710,
        "y": 260,
        "wires": []
    },
    {
        "id": "9f733048d504a113",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "All Tags",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 680,
        "y": 720,
        "wires": []
    },
    {
        "id": "f92aacc4084fe667",
        "type": "opcua-compact-client-control",
        "z": "cf294e934e79426c",
        "clientNode": "ecd65bcc2d453703",
        "name": "EMR_Example_OPCUA_Client",
        "showStatusActivities": false,
        "showErrors": false,
        "x": 530,
        "y": 160,
        "wires": [
            [
                "301565392f3b5b7f"
            ]
        ]
    },
    {
        "id": "301565392f3b5b7f",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 780,
        "y": 160,
        "wires": []
    },
    {
        "id": "6e11efec77f064af",
        "type": "subflow:b8275e1b1ea99326",
        "z": "cf294e934e79426c",
        "name": "",
        "env": [
            {
                "name": "Python_Script",
                "value": "1",
                "type": "str"
            },
            {
                "name": "Parameter",
                "value": "1000",
                "type": "num"
            }
        ],
        "x": 1140,
        "y": 280,
        "wires": [
            [
                "aa03eb425be29924",
                "2f95d63f79ca3a54",
                "a2d723bc9df65e9b"
            ],
            [
                "36a880cf7032811f"
            ]
        ]
    },
    {
        "id": "36a880cf7032811f",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1390,
        "y": 360,
        "wires": []
    },
    {
        "id": "4a740c3e28a4597d",
        "type": "switch",
        "z": "cf294e934e79426c",
        "name": "Trigger Condition",
        "property": "payload.opcuaItems[0].value.value",
        "propertyType": "msg",
        "rules": [
            {
                "t": "gt",
                "v": "0.00037",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 930,
        "y": 280,
        "wires": [
            [
                "6e11efec77f064af",
                "f603d9316406e68a"
            ]
        ]
    },
    {
        "id": "bddc379e49d59bee",
        "type": "subflow:b8275e1b1ea99326",
        "z": "cf294e934e79426c",
        "name": "",
        "env": [
            {
                "name": "Python_Script",
                "value": "2",
                "type": "str"
            },
            {
                "name": "Parameter",
                "value": "10",
                "type": "num"
            }
        ],
        "x": 1140,
        "y": 420,
        "wires": [
            [
                "639f0752a5cb6971",
                "0d8b774cfdd922f0"
            ],
            [
                "fae6f3f7db9ef9e4"
            ]
        ]
    },
    {
        "id": "639f0752a5cb6971",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "debug",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload.value",
        "statusType": "msg",
        "x": 1390,
        "y": 560,
        "wires": []
    },
    {
        "id": "fae6f3f7db9ef9e4",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1390,
        "y": 620,
        "wires": []
    },
    {
        "id": "aa03eb425be29924",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "debug",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload.value",
        "statusType": "msg",
        "x": 1390,
        "y": 200,
        "wires": []
    },
    {
        "id": "90c53ecea96d3d79",
        "type": "ui_chart",
        "z": "cf294e934e79426c",
        "name": "",
        "group": "1f3378e650777dfb",
        "order": 3,
        "width": 0,
        "height": 0,
        "label": "Sine Wave",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "1",
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1610,
        "y": 520,
        "wires": [
            []
        ]
    },
    {
        "id": "0d8b774cfdd922f0",
        "type": "template",
        "z": "cf294e934e79426c",
        "name": "Extract Value",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{{payload.value.value_sine}}",
        "output": "json",
        "x": 1410,
        "y": 520,
        "wires": [
            [
                "90c53ecea96d3d79"
            ]
        ]
    },
    {
        "id": "2f95d63f79ca3a54",
        "type": "subflow:2975150879276a06",
        "z": "cf294e934e79426c",
        "name": "",
        "env": [
            {
                "name": "password",
                "type": "cred"
            },
            {
                "name": "measurement",
                "value": "EMR_example",
                "type": "str"
            }
        ],
        "x": 1430,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "5772f250dbcf0c3a",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "OPCUA Tag value",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload.opcuaItems[0].value.value",
        "statusType": "msg",
        "x": 710,
        "y": 380,
        "wires": []
    },
    {
        "id": "6f7fafedcda552da",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "OPCUA Tag value",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload.opcuaItems[0].value.value",
        "statusType": "msg",
        "x": 710,
        "y": 540,
        "wires": []
    },
    {
        "id": "d85fd74224049fb2",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "OPCUA Tag value",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload.opcuaItems[0].value.value",
        "statusType": "msg",
        "x": 710,
        "y": 600,
        "wires": []
    },
    {
        "id": "167f79b9e5848311",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "OPCUA Tag value",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload.opcuaItems[0].value.value",
        "statusType": "msg",
        "x": 710,
        "y": 660,
        "wires": []
    },
    {
        "id": "a1175ab785797d7a",
        "type": "inject",
        "z": "cf294e934e79426c",
        "name": "Clear the Chart",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[]",
        "payloadType": "jsonata",
        "x": 1420,
        "y": 480,
        "wires": [
            [
                "90c53ecea96d3d79"
            ]
        ]
    },
    {
        "id": "19cd61602b621231",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "1. Select pre-configured OPCUA Server, enter Tags to subscribe to",
        "info": "",
        "x": 300,
        "y": 280,
        "wires": [],
        "icon": "node-red/alert.svg"
    },
    {
        "id": "e4ca5f1255ddcff0",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "Double click Client node, select Tree View and browse OPCUA address space",
        "info": "",
        "x": 650,
        "y": 120,
        "wires": []
    },
    {
        "id": "335f607aa3b9f513",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "double click here for Python details",
        "info": "Node-RED communicates with Python using MQTT. Node-RED will send to Python an object \nthat includes:\n\npayload:\n    value: (a number)\n    tagName: (string name)\n    parameter: (a number that is entered in Trigger Python node)\n    command: (a string command, like \"run script 1\")\n\n\n Python Script 1 will get same Tag value via Python OPCUA Client, \n then will multiply the value by provided Parameter and return both: value that Node-RED sent, \n as well as the value that Python got directly using own OPCUA Client. This is to\n demonstrate that depending on how frequently value is being update on OPCUA server there \n might be a differences in values due to communication delays. Therefore if Node-RED is used to\n trigger the Python script then it is also advisable to use the OPCUA value that Node-RED got\n and not the value that Python can get directly via it's own client.",
        "x": 1140,
        "y": 220,
        "wires": []
    },
    {
        "id": "f603d9316406e68a",
        "type": "debug",
        "z": "cf294e934e79426c",
        "name": "debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1090,
        "y": 320,
        "wires": []
    },
    {
        "id": "fcd516e53ed3d573",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "double click here for Python details",
        "info": "Node-RED communicates with Python using MQTT. Node-RED will send to Python an object \nthat includes:\n\npayload:\n    value: (a number)\n    tagName: (string name)\n    parameter: (a number that is entered in Trigger Python node)\n    command: (a string command, like \"run script 1\")\n\n\n Python Script 2 will take a value, calculate the sine of it, add Parameter (which was \n specified in Trigger Python node) and return result.",
        "x": 1140,
        "y": 380,
        "wires": []
    },
    {
        "id": "6e79142c4c5faa53",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "To see the Chart, open Node-RED UI",
        "info": "",
        "x": 1570,
        "y": 440,
        "wires": []
    },
    {
        "id": "b5708943d47382a0",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "2. Enter Password",
        "info": "",
        "x": 710,
        "y": 440,
        "wires": [],
        "icon": "node-red/alert.svg"
    },
    {
        "id": "59fe48cc4474bf1c",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "3. Enter Password",
        "info": "",
        "x": 1441.1666259765625,
        "y": 283.1666564941406,
        "wires": [],
        "icon": "node-red/alert.svg"
    },
    {
        "id": "7aa2944c05b01489",
        "type": "ui_chart",
        "z": "cf294e934e79426c",
        "name": "",
        "group": "1f3378e650777dfb",
        "order": 3,
        "width": 0,
        "height": 0,
        "label": "Sweep Time",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "1",
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1610,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "7d28a9b1034fb0ae",
        "type": "inject",
        "z": "cf294e934e79426c",
        "name": "Clear the Chart",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[]",
        "payloadType": "jsonata",
        "x": 1420,
        "y": 120,
        "wires": [
            [
                "7aa2944c05b01489"
            ]
        ]
    },
    {
        "id": "31a56382dc7a9738",
        "type": "comment",
        "z": "cf294e934e79426c",
        "name": "To see the Chart, open Node-RED UI",
        "info": "",
        "x": 1570,
        "y": 80,
        "wires": []
    },
    {
        "id": "a2d723bc9df65e9b",
        "type": "template",
        "z": "cf294e934e79426c",
        "name": "Extract Value",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{{payload.value.value_mqtt}}",
        "output": "json",
        "x": 1410,
        "y": 160,
        "wires": [
            [
                "7aa2944c05b01489"
            ]
        ]
    },
    {
        "id": "4ae4f3ed2cf9a0aa",
        "type": "inject",
        "z": "cf294e934e79426c",
        "name": "Write 100 to  SIN Scaling tag",
        "props": [
            {
                "p": "payload.value.value",
                "v": "100",
                "vt": "num"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 260,
        "y": 940,
        "wires": [
            [
                "c7ad4629ba1f9a51"
            ]
        ]
    },
    {
        "id": "0700c15e2be344f0",
        "type": "subflow:d4900938ba6ba410",
        "z": "cf294e934e79426c",
        "name": "",
        "x": 200,
        "y": 160,
        "wires": []
    },
    {
        "id": "b4ad0587.7610d8",
        "type": "mqtt-broker",
        "name": "emerson-mqtt-internal-ipc",
        "broker": "emerson-mqtt-internal-ipc",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    },
    {
        "id": "1f3378e650777dfb",
        "type": "ui_group",
        "name": "Default",
        "tab": "89bd8a8805c00660",
        "order": 1,
        "disp": true,
        "width": "11",
        "collapse": false,
        "className": ""
    },
    {
        "id": "89bd8a8805c00660",
        "type": "ui_tab",
        "name": "Python Example",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]