-
Notifications
You must be signed in to change notification settings - Fork 0
/
pressureCalibration.json
1 lines (1 loc) · 15.1 KB
/
pressureCalibration.json
1
[{"id":"47179133.095f9","type":"inject","z":"453c2e7a.81fb","name":"","repeat":"","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":150,"y":300,"wires":[["88e9f87f.fd4b88"]]},{"id":"88e9f87f.fd4b88","type":"file in","z":"453c2e7a.81fb","name":"PressureCal.txt","filename":"/home/pi/Desktop/PressureCal.txt","format":"utf8","chunk":false,"sendError":false,"x":340,"y":300,"wires":[["b71db4f2.105708"]]},{"id":"b71db4f2.105708","type":"function","z":"453c2e7a.81fb","name":"settings obj","func":"//global.set(\"settings\",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":300,"wires":[["bb441309.a53c9"]]},{"id":"bb441309.a53c9","type":"json","z":"453c2e7a.81fb","name":"","property":"payload","action":"","pretty":false,"x":670,"y":300,"wires":[["8daca704.5c6148"]]},{"id":"8daca704.5c6148","type":"ui_template","z":"453c2e7a.81fb","group":"4dcbd716.03c458","name":"Pressure Calibration","order":2,"width":"24","height":"8","format":"<html>\n <head>\n \n </head>\n <body>\n <style>\nbody{\n background-image : url(\"/background9.jpg\");\n}\n \n input[type=text]{\n \tbackground-color: white;\n \ttext-align : center;\n \tcolor : black;\n border:none;\n padding : 7px;\n }\n input[type=submit] {\n background-color: #4CAF50;\n color: white;\n padding: 5px 7px;\n text-align : center;\n border: none;\n border-radius: 1px;\n cursor: allowed;\n float: left;\n}\n\ninput[type=submit]:hover {\n background-color: #45a049;\n}\ntable, tr, th, td {\n \n background-color: white;\n border-collapse: collapse;\n\t\tborder: 1px solid black;\n\t\tcolor: black;\n\t\ttext-align: center;\n\t\tpadding: 1px;\n}\n\n input[type=number]{\n background-color: white;\n color : black;\n text-align : center;\n border : 1px solid #0093dc;\n padding : 7px 6px;\n text-align : center;\n } \n th{\n\t text-align : center;\n\t color: white;\n\t font-weight: normal;\n\t font-family: candara;\n\t font-size: 110%;\n\t background-color: #097479;\n\t padding : 7px 3px\n\t }\n\t td {\n \n background-color: white;\n border-collapse: collapse;\n\t\tborder: 1px solid black;\n\t\tcolor : black;\n\t\ttext-align : center;\n\t\tpadding: 1px;\n}\ntr, th, td \n{\n width: 200px;\n}\n</style>\n \n \n<div>\n\n\n<div >\n <form id=\"TableForm\" ng-submit=\"MyTableFormAction()\" >\n <table align = \"center\" id=\"EmptableWithEditDelete2\">\n <tr>\n <th>\n Sr. No.\n </th>\n <th>\n Pressure\n </th>\n <th>\n Value(Bar)\n </th>\n <th>\n Edit\n </th>\n <th>\n Add Record\n </th> \n <th>\n Delete\n </th>\n </tr>\n <tr ng-repeat=\"Set in IntMsg.payload.SetData\" >\n <td disabled=\"true\">\n {{$index+1}}\n </td>\n <td disabled=\"true\">\n Pressure {{$index+1}}\n </td>\n <td>\n <input type=\"number\" id=\"EmpHighInput{{$index}}\" ng-model=\"Set.Pressure\" disabled=\"true\" required> <!--ng-model=\"IntMsg.payload.SetData[$index].Name\"-->\n </td>\n <td>\n <button type=\"button\" ng-click=\"TableFormRowEditBtn($index)\" ng-style=\"{background: '#ffc399', color:'black', border : '1px solid #0093dc', cursor: 'allowed'}\">\n Edit\n </button>\n \n </td>\n <td>\n <button type=\"button\" ng-click=\"TableFormAddRowBtn($index)\" ng-style=\"{background: '#ffc399', color:'black', border : '1px solid #0093dc', cursor: 'allowed'}\">\n Add Record\n </button>\n \n </td>\n <td>\n <button type=\"button\" ng-click=\"TableFormRowDeleteBtn($index)\" ng-style=\"{background: '#ffc399', color:'black', border : '1px solid #0093dc', cursor: 'allowed'}\">\n Delete\n </button>\n </td>\n </tr>\n </table>\n <br>\n <br>\n\n <button type=\"Submit\" name=\"Submit\" ng-style=\"{float: 'right', background: '#54e18a', color:'Black',padding: '4px 6px', border: 'none', cursor: 'allowed'}\"> \n Submit Data\n </button>\n <button type=\"button\" ng-click=\"TableAddFirstRecord()\" ng-style=\"{float: 'left', background: '#54e18a', color:'Black',padding: '4px 6px', border: 'none', cursor: 'allowed'}\"> Add Record\n \n </button>\n \n \n </form>\n</div>\n</div>\n<script>\n//send({payload:myFunction1()})\n//few learnigs: if msg.pyload is used to link data to html tags like \n//<input type=\"text\" id=\"EmpId\" name=\"fname\" value={{msg.payload.TSetData.Selectedobj}} disabled > \n//then \n//ensure orginal data variables in msg.payload are intact through out the session/user interaction. \n\n//\"{{angular_var}}\" syntax is used in html to pass varible data from angular to html tags\n//angular function send({payload:var/funct}) is used to send the msg to node red using ng-click directives. it updates msg.payload of entire template. \n// if your html view tags like input msg/table/dropdowns are getting reset that means\n//while sending msg, orginal msg got disturbed.\n// to solve this issue you can preserve original msg by adding new varibles to orginal msg.payload .\n// this is allowed but you should not disturb incoming msg.payload varibales data structure.\n// i.e say incoming msg.payload had data structure like msg={\"payload\":{\"emp\":employees}}\n//employees=[{\"name\":\"e1\",\"id\":1,\"dept\":\"dept1\",\"div\":\"div1\"},{\"name\":\"e2\",\"id\":2,\"dept\":\"dept2\",\"div\":\"div2\"},{\"name\":\"e3\",\"id\":3,\"dept\":\"dept3\",\"div\":\"div3\"}]\n// in this case you can add msg={\"payload\":{\"emp\":employees},{\"newVar\":newVarData}} this will works as orignal msg.payload.emp is not disturbed and new object \"NewVar is added\"\n// you can chage values of all varibles . that will not create any error or reset of view.\n\n\n// to check node-red ui is working properly , type \"http://127.0.0.1:1880/ui/\" in chrome browser and click\n//on broweser three dots menu-->more tools-->developer tools ensure at riht side of broweser debug window is opend\n// click on Consol tab to see error/status mssages.\n// you can use console.log(\"your_var_name\"); to see the value\n\n var test=document.getElementById(\"EmpId\");\n\n(function(scope) {\n // use this func\n scope.IntMsg={\"payload\":{\"SetData\":[{}]}};\n \n scope.$watch('msg', function(msg) {\n if (msg) {\n // Do something when msg arrives\n scope.IntMsg=msg;\n \n console.log(msg.payload);\n }\n });\n\n \n //\n scope.TableFormRowEditBtn=function MyTableFormEditBtn(index){\n console.log(\"hi\");\n document.getElementById(\"EmptableWithEditDelete2\").rows[index+1].cells[2].getElementsByTagName(\"input\")[0].disabled=false\n \n //document.getElementById(\"DivtableWithEditDelete\").rows[index+1].cells[1] provides row-1 column 1 cell. in this cell. as index in JS starts with zero,need to do +1 to get first row.\n //to access input tag from row-1,column-1, \"getElementsByTagName(\"input\")[0]\" is used.[0] provides first input tag in this context.\n \n //console.log(scope.msg.payload.MyFormData.Edit[index]);\n \n }\n\n\n scope.TableAddFirstRecord=function MyTableAddFirstRecordBtn(){\n //Array index in JS variable starts from Zero where as table row index starts from 1 so index is added with +1\n console.log(\"TableAddFirstRecord clicked\");\n var dummy={\"Pressure\":\"\",};\n scope.IntMsg.payload.SetData.push(dummy);\n }\n\n\n scope.TableFormAddRowBtn=function MyTableFormAddRowBtn(index){\n //Array index in JS variable starts from Zero where as table row index starts from 1 so index is added with +1\n var dummy={\"Pressure\":\"\"};\n scope.IntMsg.payload.SetData.splice(index+1, 0, dummy);\n }\n scope.MyTableFormAction= function MyTableFormData(){\n var i;\n for (i = 0; i < scope.IntMsg.payload.SetData.length; i++) {\n document.getElementById(\"EmptableWithEditDelete2\").rows[i+1].cells[2].getElementsByTagName(\"input\")[0].disabled=true\n }\n \n console.log(\"MyTableFormData\");\n console.log(scope.IntMsg.payload.SetData);\n window.confirm(\"Data Saved\");\n scope.send({\"payload\":(scope.IntMsg.payload)});\n \n }\n scope.TableFormRowDeleteBtn=function MyTableFormRowDeleteBtn(index){\n var txt;\n var r = confirm(\"Press OK to Confim Delete \");\n if (r == true) {\n scope.IntMsg.payload.SetData.splice(index,1);\n scope.MyTableFormAction();\n console.log([\"TableFormRowDeleteBtn\"],index);\n }\n \n\n }\n \n})(scope);\n\n\n</script>\n</body>\n</html>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":840,"y":300,"wires":[["a0dea7a.c07c558"]]},{"id":"a0dea7a.c07c558","type":"file","z":"453c2e7a.81fb","name":"PressureCal.txt","filename":"/home/pi/Desktop/PressureCal.txt","appendNewline":false,"createDir":true,"overwriteFile":"true","x":1060,"y":300,"wires":[["8edbe636.5adca8","9e229a33.690698"]]},{"id":"9e229a33.690698","type":"function","z":"453c2e7a.81fb","name":"SetVal","func":"var data = msg.payload.SetData;\nvar n= data.length;\nfor(i=0;i<n;i++)\n{\n global.set('Pressure'+(i+1)+'High',msg.payload.SetData[i].Pressure);\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1230,"y":340,"wires":[["8edbe636.5adca8"]]},{"id":"8edbe636.5adca8","type":"debug","z":"453c2e7a.81fb","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1390,"y":300,"wires":[]},{"id":"e58f954b.61f6d8","type":"function","z":"453c2e7a.81fb","name":"","func":"var s30 = msg.payload.data[0];\nvar v = s30 *( 5.0/1024.0);\nvar map = function(value, istart, istop, ostart, ostop) {\n return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));\n}\nvar value = map(v,1,5,0,global.get('Pressure1High'))\nmsg.payload = value.toFixed(2);\nglobal.set('currentPressure',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":220,"wires":[["904beabb.a91be8"]]},{"id":"904beabb.a91be8","type":"ui_gauge","z":"453c2e7a.81fb","name":"","group":"6649d351.48241c","order":1,"width":6,"height":6,"gtype":"gage","title":"Pressure","label":"bar","format":"{{msg.value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":640,"y":220,"wires":[]},{"id":"4dcbd716.03c458","type":"ui_group","name":"Gas Settings","tab":"3ca9a14e.418b2e","order":4,"disp":true,"width":"24","collapse":false},{"id":"6649d351.48241c","type":"ui_group","name":"Pressure","tab":"e3d6fd3d.100a9","order":1,"disp":true,"width":"24","collapse":false},{"id":"3ca9a14e.418b2e","type":"ui_tab","name":"Settings","icon":"dashboard","order":2,"disabled":false,"hidden":false},{"id":"e3d6fd3d.100a9","type":"ui_tab","name":"Live Status","icon":"dashboard","order":1,"disabled":false,"hidden":false}]