Anchor Dashboard #31
Replies: 1 comment
-
[{"id":"39e30936.0abe66","type":"tab","label":"Anchoring","disabled":false,"info":""},{"id":"7bdb4e7e.37b94","type":"function","z":"39e30936.0abe66","name":"Set Anchor ON","func":"let _ = global.get('lodash');\nlet app = global.get('app');\nlet position = app.getSelfPath('navigation.position.value');\n\n// SET STATUS AND ANCHOR POSITION\nvar Anchored_STATUS=global.get('Anchored_STATUS') || 0;\nglobal.set("Anchored_STATUS", "ON");\nglobal.set("Anchored_LAT", position.latitude);\nglobal.set("Anchored_LON", position.longitude);\n\nmsg.payload = "Position Set";\n \nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":480,"wires":[["4af0b5c5.980fcc","7af2b6e7.413578","f4d6073.525f2f8","7d1f4fe.7779cb"]]},{"id":"92c4ec45.9bf23","type":"function","z":"39e30936.0abe66","name":"Distance From Anchor Point","func":"let _ = global.get('lodash');\nlet app = global.get('app');\nlet position = app.getSelfPath('navigation.position.value');\n\nmsg.lat1 = position.latitude;\nmsg.lon1 = position.longitude;\nmsg.lat2 = global.get("Anchored_LAT");\nmsg.lon2 = global.get("Anchored_LON");\n\nvar p = 0.017453292519943295; // Math.PI / 180\n\nvar dLat = p * (msg.lat2-msg.lat1); // Find delta and convert to radians\nvar dLon = p * (msg.lon2-msg.lon1); // Find delta and convert to radians\n\nvar earthRadiusKm = 6371; // Earth radius in km.\n\nvar lat1r = p* msg.lat1; // Convert to Radians\nvar lat2r = p* msg.lat2; // Convert to Radians\n\nvar a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1r) * Math.cos(lat2r); \nvar c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); \nvar m = Math.round((earthRadiusKm * c) * 1000); //calculate result in meters\n\n// Convert m from meters to feet\nvar f = Math.round(m3.28);\n\n// Set global variable in feet for display\nglobal.set("Anchored_DISTANCE", f);\n\n// Convert value for Influx to metric\nvar r = flow.get("ANCHOR_RADIUS");\nr = (r/3.28);\nr = Math.round(r10)/10; // Round to one decimal place\n\n// Send distance in meters to influx\nmsg.payload = {\n "status": global.get("Anchored_STATUS"),\n "distance": m,\n "max_radius": r\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":340,"wires":[["22ba1d15.6a3d72"]]},{"id":"9edbdbaa.ea4658","type":"function","z":"39e30936.0abe66","name":"Set Anchor OFF","func":"\nglobal.set("Anchored_STATUS", "OFF");\nglobal.set("Anchored_LAT");\nglobal.set("Anchored_LON");\nglobal.set("Anchored_DISTANCE","");\nflow.set("ANCHOR_DEPTH","");\nflow.set("ANCHOR_RADIUS",0);\nflow.set("ANCHOR_ALARM", "OFF");\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":580,"wires":[["db39d66b.6f8e38","1dbf66c0.794289","f4d6073.525f2f8"]]},{"id":"ab0e1281.e210b","type":"switch","z":"39e30936.0abe66","name":"Check Anchor Status","property":"Anchored_STATUS","propertyType":"global","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":380,"y":340,"wires":[["92c4ec45.9bf23","877b74b2.0392f8"]]},{"id":"b3ede12a.b6689","type":"inject","z":"39e30936.0abe66","name":"60s Trigger","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":340,"wires":[["ab0e1281.e210b"]]},{"id":"5bcfc7ad.3ca388","type":"signalk-send-pathvalue","z":"39e30936.0abe66","name":"Send MSG","source":"","meta":"","x":1270,"y":520,"wires":[]},{"id":"4af0b5c5.980fcc","type":"change","z":"39e30936.0abe66","name":"STATUS MSG","rules":[{"t":"set","p":"topic","pt":"msg","to":"navigation.anchor.status","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":500,"wires":[["5bcfc7ad.3ca388"]]},{"id":"db39d66b.6f8e38","type":"change","z":"39e30936.0abe66","name":"STATUS MSG","rules":[{"t":"set","p":"topic","pt":"msg","to":"navigation.anchor.status","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":560,"wires":[["5bcfc7ad.3ca388"]]},{"id":"7af2b6e7.413578","type":"change","z":"39e30936.0abe66","name":"LAT/LON MSG","rules":[{"t":"set","p":"topic","pt":"msg","to":"navigation.anchor.position","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{"latitude": $globalContext('Anchored_LAT'),\t"longitude": $globalContext('Anchored_LON')}\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":460,"wires":[["5bcfc7ad.3ca388"]]},{"id":"1dbf66c0.794289","type":"change","z":"39e30936.0abe66","name":"LAT/LON MSG","rules":[{"t":"set","p":"topic","pt":"msg","to":"navigation.anchor.position","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":600,"wires":[["5bcfc7ad.3ca388"]]},{"id":"b291ec34.b5354","type":"ui_button","z":"39e30936.0abe66","name":"Anchor ON","group":"c367d93b.84dc88","order":3,"width":5,"height":3,"passthru":false,"label":"Drop Anchor","tooltip":"","color":"","bgcolor":"","icon":"fa-anchor fa-2x","payload":"TOGGLE","payloadType":"str","topic":"topic","topicType":"msg","x":130,"y":480,"wires":[["11aa184.35b28e8"]]},{"id":"e34104b3.0752f8","type":"ui_text","z":"39e30936.0abe66","group":"c367d93b.84dc88","order":4,"width":6,"height":2,"name":"Anchor_Status","label":"ALARM","format":"{{msg.payload}}","layout":"col-center","x":760,"y":800,"wires":[]},{"id":"11aa184.35b28e8","type":"function","z":"39e30936.0abe66","name":"TRANSFORM","func":"global.set("Anchored_STATUS", "ON"); \n\nmsg.payload = "ON";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":480,"wires":[["7bdb4e7e.37b94","b5f9ccaf.d0f18"]]},{"id":"205c9036.b51d2","type":"ui_text","z":"39e30936.0abe66","group":"1ffe93d7.04cfac","order":2,"width":6,"height":1,"name":"RODE","label":"","format":"{{msg.payload}}","layout":"row-spread","x":730,"y":960,"wires":[]},{"id":"8d376c8a.a1e7d","type":"signalk-subscribe","z":"39e30936.0abe66","name":"Subscribe Depth","mode":"sendAll","flatten":true,"context":"vessels.self","path":"environment.depth.belowTransducer","source":"","period":1000,"x":140,"y":420,"wires":[["85078277.b3813"]]},{"id":"b5f9ccaf.d0f18","type":"function","z":"39e30936.0abe66","name":"Set Depth","func":"\nif (msg.payload == "ON") {\n flow.set("ANCHOR_DEPTH", flow.get("DEPTH"))\n}\nflow.set("DEPTH", msg.payload);\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":420,"wires":[[]]},{"id":"b0d91196.4f745","type":"ui_text","z":"39e30936.0abe66","group":"54ee39b1.58d218","order":2,"width":10,"height":2,"name":"ANCHOR DEPTH","label":"Anchor Depth","format":"{{msg.payload}}","layout":"row-spread","x":770,"y":880,"wires":[]},{"id":"b3d09e93.e4a83","type":"change","z":"39e30936.0abe66","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"DEPTH","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":760,"wires":[["ffa5473c.5043f8"]]},{"id":"ffa5473c.5043f8","type":"ui_text","z":"39e30936.0abe66","group":"54ee39b1.58d218","order":1,"width":10,"height":2,"name":"Current Depth","label":"Current Depth","format":"{{msg.payload}}","layout":"row-spread","x":760,"y":760,"wires":[]},{"id":"85078277.b3813","type":"function","z":"39e30936.0abe66","name":"Meters to Feet","func":"msg.payload = Math.round((msg.payload * 3.28084));\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":420,"wires":[["b5f9ccaf.d0f18"]]},{"id":"dc9e7653.4b4118","type":"ui_button","z":"39e30936.0abe66","name":"Anchor OFF","group":"c367d93b.84dc88","order":12,"width":5,"height":3,"passthru":false,"label":"Raise Anchor","tooltip":"","color":"","bgcolor":"","icon":"fa-anchor fa-2x","payload":"TOGGLE","payloadType":"str","topic":"topic","topicType":"msg","x":130,"y":580,"wires":[["9edbdbaa.ea4658"]]},{"id":"74b78552.d7f2fc","type":"ui_text","z":"39e30936.0abe66","group":"54ee39b1.58d218","order":3,"width":10,"height":2,"name":"ANCHOR DISTANCE","label":"Dist. to Anchor","format":"{{msg.payload}}","layout":"row-spread","x":980,"y":920,"wires":[]},{"id":"335b6eb0.26dca2","type":"inject","z":"39e30936.0abe66","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":860,"wires":[["b3d09e93.e4a83","a548ba5f.c3c7b8","1b1b79dc.3d91c6","37d5c6ff.2b14aa","436ddca6.f6d814"]]},{"id":"a548ba5f.c3c7b8","type":"change","z":"39e30936.0abe66","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Anchored_STATUS","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":800,"wires":[["e34104b3.0752f8"]]},{"id":"1b1b79dc.3d91c6","type":"change","z":"39e30936.0abe66","name":"set msg.payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"ANCHOR_DEPTH","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":880,"wires":[["b0d91196.4f745"]]},{"id":"37d5c6ff.2b14aa","type":"change","z":"39e30936.0abe66","name":"set msg.payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"Anchored_DISTANCE","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":920,"wires":[["199b9b83.e252c4"]]},{"id":"75e3d465.10ba8c","type":"inject","z":"39e30936.0abe66","name":"Set Default","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30","payloadType":"str","x":140,"y":960,"wires":[["c3754eec.57fd4"]]},{"id":"c3754eec.57fd4","type":"ui_slider","z":"39e30936.0abe66","name":"Slider Rode","label":"Rode","tooltip":"","group":"1ffe93d7.04cfac","order":1,"width":16,"height":1,"passthru":true,"outs":"all","topic":"topic","topicType":"msg","min":"30","max":"200","step":"10","x":330,"y":960,"wires":[["205c9036.b51d2","695a7873.e5a418"]]},{"id":"695a7873.e5a418","type":"function","z":"39e30936.0abe66","name":"Set Rode Value","func":"\nflow.set("RODE",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":1000,"wires":[[]]},{"id":"f4d6073.525f2f8","type":"change","z":"39e30936.0abe66","name":"CONNECTOR","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":800,"wires":[["a548ba5f.c3c7b8","1b1b79dc.3d91c6","37d5c6ff.2b14aa"]]},{"id":"9be95144.15922","type":"ui_text","z":"39e30936.0abe66","group":"54ee39b1.58d218","order":4,"width":10,"height":2,"name":"Swing Radius","label":"Swing Radius","format":"{{msg.payload}}","layout":"row-spread","x":760,"y":840,"wires":[]},{"id":"436ddca6.f6d814","type":"function","z":"39e30936.0abe66","name":"Calculate Radius","func":"s = flow.get("RODE");\nd = flow.get("ANCHOR_DEPTH");\n\n// Check Anchor Status\nif (global.get("Anchored_STATUS") == "OFF") {\n r = "";\n} else {\n r = Math.round(Math.sqrt((ss)-(dd)));\n}\n\nflow.set("ANCHOR_RADIUS",r);\nmsg.payload = r;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":840,"wires":[["9be95144.15922"]]},{"id":"877b74b2.0392f8","type":"function","z":"39e30936.0abe66","name":"Check Anchor Radius","func":"var d = global.get("Anchored_DISTANCE");\nvar o = flow.get("ANCHOR_ALARM");\nvar m = flow.get("ANCHOR_RADIUS");\nm = (m*1.1);\n\nif (o == "OVERRIDE"){\n} else if ( d > m) {\n flow.set("ANCHOR_ALARM", "ON")\n} else {\n flow.set("ANCHOR_ALARM", "OFF") \n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":240,"wires":[["c19b0d34.e31e3"]]},{"id":"c19b0d34.e31e3","type":"switch","z":"39e30936.0abe66","name":"Send ALARM STATUS","property":"ANCHOR_ALARM","propertyType":"flow","rules":[{"t":"eq","v":"OVERRIDE","vt":"str"},{"t":"eq","v":"OFF","vt":"str"},{"t":"eq","v":"ON","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":940,"y":240,"wires":[["150fddc9.7eed42"],["65630c48.d063c4"],["b75cb17a.059b5","fc362384.d7be"]]},{"id":"199b9b83.e252c4","type":"function","z":"39e30936.0abe66","name":"Round Distance","func":"msg.payload = Math.round(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":920,"wires":[["74b78552.d7f2fc"]]},{"id":"9fbfbb16.416428","type":"influxdb out","z":"39e30936.0abe66","influxdb":"a8c3eca7.425fb","name":"Influx SignalK","measurement":"","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"organisation","bucket":"bucket","x":1280,"y":360,"wires":[]},{"id":"7d1f4fe.7779cb","type":"change","z":"39e30936.0abe66","name":"Anchor.Position","rules":[{"t":"set","p":"measurement","pt":"msg","to":"anchor.position","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{"latitude": $globalContext('Anchored_LAT'),\t"longitude": $globalContext('Anchored_LON')}\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":400,"wires":[["9fbfbb16.416428"]]},{"id":"22ba1d15.6a3d72","type":"change","z":"39e30936.0abe66","name":"Anchor.Status","rules":[{"t":"set","p":"measurement","pt":"msg","to":"anchor.status","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":340,"wires":[["9fbfbb16.416428"]]},{"id":"b12037ca.ec29c8","type":"change","z":"39e30936.0abe66","name":"Alarm ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"28","tot":"num"},{"t":"set","p":"action","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1320,"y":260,"wires":[["a4b18cbc.10bed","fdc2ab8a.46b668"]]},{"id":"b75cb17a.059b5","type":"change","z":"39e30936.0abe66","name":"VOLUME=100%","rules":[{"t":"set","p":"payload","pt":"msg","to":"100","tot":"num"},{"t":"set","p":"action","pt":"msg","to":"VOLUME","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":300,"wires":[["a4b18cbc.10bed","fdc2ab8a.46b668"]]},{"id":"a4b18cbc.10bed","type":"link out","z":"39e30936.0abe66","name":"","links":["bfedf040.d0615"],"x":1495,"y":220,"wires":[]},{"id":"fc362384.d7be","type":"delay","z":"39e30936.0abe66","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1180,"y":260,"wires":[["b12037ca.ec29c8"]]},{"id":"27e84a9b.fa02b6","type":"ui_button","z":"39e30936.0abe66","name":"SILENCE ALARM","group":"c367d93b.84dc88","order":9,"width":4,"height":2,"passthru":false,"label":"{{payload}}","tooltip":"","color":"","bgcolor":"{{colour}}","icon":"","payload":"OVERRIDE","payloadType":"str","topic":"topic","topicType":"msg","x":530,"y":140,"wires":[["afbc977f.378848","ab2b39af.e2ef88"]]},{"id":"afbc977f.378848","type":"change","z":"39e30936.0abe66","name":"SET OVERRIDE","rules":[{"t":"set","p":"ANCHOR_ALARM","pt":"flow","to":"OVERRIDE","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":240,"wires":[["877b74b2.0392f8"]]},{"id":"65630c48.d063c4","type":"change","z":"39e30936.0abe66","name":"Alarm OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"28","tot":"num"},{"t":"set","p":"action","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":200,"wires":[["a4b18cbc.10bed","fdc2ab8a.46b668"]]},{"id":"fdc2ab8a.46b668","type":"debug","z":"39e30936.0abe66","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"action","targetType":"msg","statusVal":"","statusType":"auto","x":1580,"y":300,"wires":[]},{"id":"150fddc9.7eed42","type":"change","z":"39e30936.0abe66","name":"Alarm OVERRIDE","rules":[{"t":"set","p":"payload","pt":"msg","to":"28","tot":"num"},{"t":"set","p":"action","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":160,"wires":[["a4b18cbc.10bed","fdc2ab8a.46b668"]]},{"id":"cfd251ad.107ec","type":"change","z":"39e30936.0abe66","name":"RED","rules":[{"t":"set","p":"colour","pt":"msg","to":"#b62b1b","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"ALARM SILENCED","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":100,"wires":[["27e84a9b.fa02b6"]]},{"id":"b33e5b3a.e97ce8","type":"inject","z":"39e30936.0abe66","name":"","props":[{"p":"payload","v":"","vt":"str"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":true,"onceDelay":"","topic":"","payload":"","payloadType":"str","x":90,"y":100,"wires":[["d148c4de.4fe3b8"]]},{"id":"ab2b39af.e2ef88","type":"function","z":"39e30936.0abe66","name":"Button Color","func":"var state = context.state || false;\nstate = !state;\ncontext.state = state;\nif (state) { return [msg,null]; }\nelse { return [null,msg]; }\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":110,"y":140,"wires":[["cfd251ad.107ec"],["d148c4de.4fe3b8"]]},{"id":"d148c4de.4fe3b8","type":"change","z":"39e30936.0abe66","name":"TEAL","rules":[{"t":"set","p":"colour","pt":"msg","to":"#23AFB4","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"SILENCE ALARM","tot":"str"},{"t":"set","p":"ANCHOR_ALARM","pt":"flow","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":140,"wires":[["27e84a9b.fa02b6"]]},{"id":"c367d93b.84dc88","type":"ui_group","name":"Controls","tab":"9c2374fc.63ae28","order":1,"disp":true,"width":12,"collapse":false},{"id":"1ffe93d7.04cfac","type":"ui_group","name":"Rode Adjustment","tab":"9c2374fc.63ae28","order":3,"disp":true,"width":"22","collapse":false},{"id":"54ee39b1.58d218","type":"ui_group","name":"Data","tab":"9c2374fc.63ae28","order":2,"disp":true,"width":10,"collapse":false},{"id":"a8c3eca7.425fb","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"SignalK","name":"InfluxDb-SignalK","usetls":false,"tls":"","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true},{"id":"9c2374fc.63ae28","type":"ui_tab","name":"Anchoring Dashboard","icon":"dashboard","disabled":false,"hidden":false}] |
Beta Was this translation helpful? Give feedback.
-
This flow creates a Node-Red dashboard to manage and monitor anchor status. You can set your anchor position and then monitor the distance from the position. It captures the depth at which the anchor is set and your defined scope and then monitors the distance compared to the swing radius. Last this flow sets an alarm if you go over the swing radius by a set amount and makes a call to another flow that sets off an audible alarm to a Yacht Device N2K alarm. You can use whatever action you wish.
Beta Was this translation helpful? Give feedback.
All reactions