[
{
"id": "b2b17973657164b1",
"type": "tab",
"label": "My_Station",
"disabled": false,
"info": "",
"env": []
},
{
"id": "7fd27bdf3a7ef97c",
"type": "http response",
"z": "b2b17973657164b1",
"name": "http/My_Station$",
"statusCode": "",
"headers": {},
"x": 870,
"y": 100,
"wires": []
},
{
"id": "edacfd20a4c15fe3",
"type": "http in",
"z": "b2b17973657164b1",
"name": "",
"url": "/My_Station$",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 130,
"y": 100,
"wires": [
[
"bf8abe7527f5586a"
]
]
},
{
"id": "ffb5986fcd4e0582",
"type": "mqtt in",
"z": "b2b17973657164b1",
"name": "",
"topic": "jmri/timetable",
"qos": "1",
"datatype": "auto-detect",
"broker": "cafe9d5b.d4035",
"nl": false,
"rap": false,
"inputs": 0,
"x": 90,
"y": 340,
"wires": [
[
"615bcd1b55054f49",
"de485296b0c3b7ee"
]
]
},
{
"id": "615bcd1b55054f49",
"type": "debug",
"z": "b2b17973657164b1",
"name": "mqtt message",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 300,
"y": 400,
"wires": []
},
{
"id": "de485296b0c3b7ee",
"type": "function",
"z": "b2b17973657164b1",
"name": "Generate Clock and Schedule Table",
"func": "var stations_to_be_displayed = \"My_Station_List\"\n\nvar type = msg.payload[0].type\n\n\n/* Variable for content in the text field\n of the timetable \"yes\" or \"no\" */\nvar FPtext = \"yes\";\nvar cancel = \"cancelled\";\nvar max_no_entries = 10000;\nvar FPlength = 0;\n\n/* If you want scrolling text set run to \"yes\" */\nvar run = \"yes\";\nvar stationRR = \"\";\n\n/* Clock */\nif (type == \"clock\") {\n\n var time = msg.payload[0].time\n var emblem = msg.payload[0].emblem\n \n // console.log(\"emblem ?\", emblem, \"?\", typeof(time), emblem === \"GB (British Rail)\")\n msg.payload = ({ \"emblem\" : emblem, \"time\" : time});\n // console.log(msg.payload)\n return msg;\n}\n\n/* Schedule table */\nvar list = []\n\nvar station = flow.get(\"station\") || \"\";\nvar platform = flow.get(\"platform\") || \"\";\n\n\nif (type == \"schedule\" ){\n \n \n var jObj = msg.payload\n var all_entries = Object.keys(jObj).length;\n // console.log(\"all entries\" + all_entries)\n var count = 0;\n for (var i = 0; i < all_entries; i++) {\n var station_name = msg.payload[i].station_name\n var platform = msg.payload[i].platform\n if (stations_to_be_displayed.includes(station_name)) {\n count = count + 1;\n }\n // console.log(count);\n }\n // console.log(count);\n if (max_no_entries < count) {\n var no_entries = max_no_entries\n } else {\n var no_entries = count\n }\n // console.log(\"no_entries\" + no_entries)\n list = []\n // var j = 0\n var j = 0\n for (var i = 0; i < all_entries; i++) {\n var station_name = msg.payload[i].station_name\n // console.log(\"j = \" + j + \" station_name = \" + station_name)\n if (stations_to_be_displayed.includes(station_name)){\n // console.log(\"j2 = \" + j + \" station_name = \" + station_name)\n var train_name = msg.payload[i].train_name\n var platform = msg.payload[i].platform.substring(0,20) // limit length of string to 20 chars to fit on display\n var station_arrival_time = msg.payload[i].station_arrival_time\n var station_departure_time = msg.payload[i].station_departure_time\n var first_station = msg.payload[i].first_station.substring(0, 20) // limit length of string to 20 chars to fit on display\n var last_station = msg.payload[i].last_station.substring(0, 20) // limit length of string to 20 chars to fit on display\n var via = msg.payload[i].via\n\n var arrival_time = station_departure_time\n \n list[j] = ({\n point: \"\", platform: platform, station_arrival_time: station_arrival_time, station_departure_time: station_departure_time, \n train: train_name, first_station: first_station, last_station: last_station, via: via,});\n j++;\n }\n if (j > count) {\n break;\n }\n }\n msg.payload = list;\n return msg;\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 340,
"wires": [
[
"de14de84c77ae188",
"c5e8ca11781a98b6"
]
]
},
{
"id": "de14de84c77ae188",
"type": "debug",
"z": "b2b17973657164b1",
"name": "schedule list and clock",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 720,
"y": 400,
"wires": []
},
{
"id": "c5e8ca11781a98b6",
"type": "websocket out",
"z": "b2b17973657164b1",
"name": "[ws] /ws/My_Station$",
"server": "My_Station$_ref",
"client": "",
"x": 920,
"y": 340,
"wires": []
},
{
"id": "ce10a6e6ebfc838d",
"type": "template",
"z": "b2b17973657164b1",
"name": "Template",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "\n\n
\n \n \n Timetable\n \n\n\n\n\n \n {{!-- gap --}}\n \n {{!-- departure and Station --}}\n \n {{!-- clock --}}\n \n {{!-- logo --}}\n \n\n \n {{!-- gap before Text --}}\n | \n {{!-- Departures and Station --}}\n \n Departures: My_Station\n | \n {{!-- clock --}}\n \n | \n \n | \n
\n
\n\n \n \n \n \n \n \n \n \n \n \n | \n Arrival | \n Departure | \n Platform | \n From | \n Destination | \n Via | \n
\n
\n\n \n \n \n \n \n \n \n \n \n\n
\n\n\n\n",
"output": "str",
"x": 620,
"y": 100,
"wires": [
[
"7fd27bdf3a7ef97c"
]
]
},
{
"id": "bf8abe7527f5586a",
"type": "template",
"z": "b2b17973657164b1",
"name": "Stylesheet",
"field": "payload.style",
"fieldType": "msg",
"format": "html",
"syntax": "mustache",
"template": ":root {\n/* Here are the colors defined for the output\nThe background and font color can be adjusted */\n/*background colour */\n--background: #006;\n/*Font Colour */\n--fontcolor: #fff;\n/* Font */\n--fontart: arial;\n//color: #fff;\n/* Backround Colour of List: Odd lines */\n--backgroundfirst: #006;\n/* Font Colour of List: Odd lines */\n--fontfirst: #fff;\n/* Backround Colour of List: Even lines */\n--backgroundsec: #309;\n/* Font Colour of List: Even lines */\n--fontsec: #fff;\n/* Background Colour of Faults */\n--backgroundfault: #ff0;\n/* Font Colour of Faults */\n--fontfault: #006;\n}\nbody {\n\n/* defines the font size to the total aspect ratio */\nfont-size: 1em;\nbackground-color: var(--background);\ncolor: var(--fontcolor);\npadding:0 0 0 0;\n}\n\n/* Arrival */\n.head1 {font-size: 2.5em}\n/* Departure*/\n.head2 {font-style: italic; font-size: 1.5em}\n/* Time */\n.head3 {font-size: 2.0em; text-align: left}\n/* Logo */\n.head4 { font-size: 2.0em; text-align: left; color: var(--fontcolor)}\n.it {font-style: italic; font-size: 1.3em; text-align: left}\n/* background colour of the header and footer */\ntd.head {background-: var(--background)}\ntd.foot {background-color: var(--background)}\n\ntable.head {\ntable-layout:fixed;\noverflow: hidden;\nwidth: 100%;\nheight: 50%;\nfont-family: var(--fontart);\nborder: 0px;\nborder-color: #fff;\n\nborder-spacing: 0;\nmargin:0;\npadding: 0;\n}\ntable.list {\ntable-layout:fixed;\noverflow: hidden;\nwidth: 100%;\nheight: 100%;\nfont-family: var(--fontart);\nborder: 0px;\nborder-spacing: 0;\nmargin:0;\npadding: 0;\n}\np { padding: 0; margin: 0;\n}\ntable.foot {\ntable-layout:fixed;\noverflow: hidden;\nbackground-color: var(--background);\nwidth: 100%;\nheight: 100%;\nfont-family: var(--fontart);\nborder: 0px;\nborder-spacing: 0;\nmargin:0;\npadding: 0;\n}\n\ndiv.run {\nbackground-color: var(--backgroundfault);\nwhite-space: nowrap;\noverflow: hidden;\n}\nspan.fault2 {\n/*display:block;*/\nmargin-left:100%;\nfont-size: 2em;\ncolor: var(--fontfault);\npadding: 0px;\n/*height: 2em;*/\n/*width: 100%;*/\n-webkit-animation: textrun 25s linear infinite;\nanimation: textrun 25s linear infinite;\n}\n@-webkit-keyframes textrun {\n0% { transform: translate(0%, 0);}\n100% { margin-left:-100%;transform: translate(-100%, 0);}\n}\n\n@keyframes textrun {\n0% { transform: translate(0, 0);}\n100% { margin-left:-100%; transform: translate(-100%, 0); }\n}\nspan.fault1 {\nfont-size: 2em;\ncolor: var(--fontfault);\nbackground-color: var(--backgroundfault);\npadding: 0px;\n/*height: 2em;*/\n/*width: 100%;*/\n}\nth {\nbackground-color: var(--background);\ncolor: var(--fontcolor);\nfont-size: 1.3em;\ntext-align: left;\nmargin:0;\npadding: 0 0 0 0;\nheight: 1.5em;\n/*border-bottom: 0px solid #ffffff;*/\n}\n/* Background color default of a line */\ntr {\nbackground-color: var(--background);\ncolor: var(--fontcolor);\n/* line height */\nheight : 2em;\n}\n/* Background color of odd rows */\ntr:nth-child(even) {\nbackground-color: var(--backgroundfirst);\ncolor: var(--fontfirst);\n/* line height */\nheight : 2em;\n}\n/* Background color of even rows */\ntr:nth-child(odd) {\nbackground-color: var(--backgroundsec);\ncolor: var(--fontsec);\n/* line height */\nheight : 2em;\n}\n/* Formatting the individual cells/fields of the list */\n.point {color: --fontcolor; text-align: center; position: absolut;}\n.station_arrival_time {text-align: left; font-size: 1.5em}\n.station_departure_time {text-align: left; font-size: 1.5em}\n.platform {text-align: left; font-size: 1.5em}\n.first_station {text-align: left; font-size: 1.5em; height: 2em}\n.last_station {text-align: left; font-size: 1.5em; height: 2em}\n.via {padding-left: 10px}\n\ndiv.DB-logo {\ndisplay: table-cell;\nposition: relative;\nwidth: 100px;\npadding-bottom: 60%; /*override this inline for aspect ratio other than square */\n}\n\n",
"output": "str",
"x": 390,
"y": 100,
"wires": [
[
"ce10a6e6ebfc838d"
]
]
},
{
"id": "86c45192bfd242e0",
"type": "comment",
"z": "b2b17973657164b1",
"name": "generate Web Page",
"info": "",
"x": 110,
"y": 40,
"wires": []
},
{
"id": "7fa4ed09c941b9ef",
"type": "comment",
"z": "b2b17973657164b1",
"name": "Import from mqtt, extract variables, send to websocket, which has the name of the station",
"info": "",
"x": 330,
"y": 240,
"wires": []
},
{
"id": "427c8bf5b8a16f07",
"type": "comment",
"z": "b2b17973657164b1",
"name": "This node red page was inspired by a Rocrail MQTT implementation and modified extensively from that implementation. ",
"info": "",
"x": 412,
"y": 480,
"wires": []
},
{
"id": "24aec3c6dc4d0fd2",
"type": "comment",
"z": "b2b17973657164b1",
"name": "The Rocrail implementation is licenced as follows: CC Attribution-Share Alike 4.0 International and we would like to acknowledge their inspiration. ",
"info": "",
"x": 492,
"y": 520,
"wires": []
},
{
"id": "adc848b432e422c7",
"type": "comment",
"z": "b2b17973657164b1",
"name": "Some code may still be identical to the Rocrail code.",
"info": "",
"x": 202,
"y": 560,
"wires": []
},
{
"id": "cafe9d5b.d4035",
"type": "mqtt-broker",
"broker": "127.0.0.1",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": ""
},
{
"id": "My_Station$_ref",
"type": "websocket-listener",
"path": "/ws/My_Station$",
"wholemsg": "false"
}
]