@bakman2,
I am able to monitor the complete message object now but need a little assistance in meeting the requirement. My flow is as given below:
[
{
"id": "3f52fcdee953d32c",
"type": "status",
"z": "924e3c32cfb47491",
"name": "",
"scope": [
"66d6e76f56adf489"
],
"x": 120,
"y": 180,
"wires": [
[
"ab68851ac24be479"
]
]
},
{
"id": "ab68851ac24be479",
"type": "function",
"z": "924e3c32cfb47491",
"name": "function 36",
"func": "var log =msg.status\nglobal.set(\"plc_status\",log)\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 200,
"wires": [
[
"da02219844b2f66d"
]
]
},
{
"id": "da02219844b2f66d",
"type": "debug",
"z": "924e3c32cfb47491",
"name": "debug 12",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 500,
"y": 220,
"wires": []
},
{
"id": "66d6e76f56adf489",
"type": "pccc in",
"z": "924e3c32cfb47491",
"endpoint": "094e77d0aee89ede",
"mode": "single",
"variable": "plc",
"diff": false,
"name": "",
"x": 110,
"y": 80,
"wires": [
[
"e57cf786ef412ec1"
]
]
},
{
"id": "e57cf786ef412ec1",
"type": "function",
"z": "924e3c32cfb47491",
"name": "",
"func": "var status=global.get('plc_status');\n\nif(status.text==\"failure\")\n{\n global.set(\"plc\", null);\n}\nelse\n global.set(\"plc\", msg.payload);\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 280,
"y": 40,
"wires": [
[]
]
},
{
"id": "094e77d0aee89ede",
"type": "pccc endpoint",
"address": "192.168.4.108",
"port": "44818",
"userouting": false,
"routingbuf": "[1,0]",
"cycletime": "5000",
"timeout": "1500",
"name": "",
"vartable": [
{
"addr": "F8:1",
"name": "plc"
}
]
}
]
What I am trying to do is pass a null value to the global variable "plc" when the connection to the plc (allen bradely micrologix 1400) drops.
The status text shows "failure" when it disconnects but the global variable "plc_status" retains its past value.