Concept for central flow handling

I made a model that can be used for a large ICT system in Holland that has a hundred submodules and about 200 products that uses these submodules.

I made a concept in node-red to prove you can pre-define the way a service/product uses submodules.
In this way you have minimal knowledge in the different submodules, you define this knowledge in one place, in the product config (prg_config)

To do:

  • this version supports serial transactions; i like to add parrallel transactions or combinations.

feel free to use it, or make it better..

[{"id":"1ac73a57.6401de","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"92e4629.01dc42","type":"function","z":"1ac73a57.6401de","name":"prg_config","func":"// fq = flow-queue\n// fq_l = flow-queue-len\n// fq_a = flow-queue-active service\n\n// dit stuk bij t product\n\nvar fq,fq_l,fq_a;\n\nswitch(msg.prg) {\n  case \"Product_1\":\n    fq =[\n        {\"service\": \"module_x1\", \"service_status\" : false, \"time\": null, \"st_info\":true, \"st_debug\":false, \"result\":null},\n        {\"service\": \"module_x2\", \"service_status\" : false, \"time\": null,\"st_info\":true, \"st_debug\":true,\"result\":null},\n\t    {\"service\": \"module_x3\", \"service_status\" : false, \"time\": null,\"st_info\":true, \"st_debug\":true,\"result\":null},\n\t    {\"service\": \"module_end\", \"service_status\" : false, \"time\": null,\"st_info\":true, \"st_debug\":true,\"result\":null}\n\t    ];\n    break;\n\n  case \"Product_2\":\n    fq =[\n        {\"service\": \"module_x1\", \"service_status\" : false, \"time\": null, \"st_info\":true, \"st_debug\":false},\n\t    {\"service\": \"module_x3\", \"service_status\" : false, \"time\": null,\"st_info\":true, \"st_debug\":true},\n\t    {\"service\": \"module_end\", \"service_status\" : false, \"time\": null,\"st_info\":true, \"st_debug\":false}\n\t    ];  \n    break;\n\n  default:\n                } \n\n// init loop\n\nfq_a = -1;\nfq_l = fq.length-1;\n\nmsg.fq = fq;\nmsg.fq_l = fq_l;\nmsg.fq_a = fq_a;    \n\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":80,"wires":[["41ef44e.b632e3c"]]},{"id":"398ffd4f.5b265a","type":"debug","z":"1ac73a57.6401de","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1090,"y":280,"wires":[]},{"id":"a60c139.768547","type":"function","z":"1ac73a57.6401de","name":"raise_queue","func":"var fq_a;               //actief item in de array, start met -1 dit wordt dus 0 bij aanvang\nfq_a = msg.fq_a+1;      // de eerste loop wordt dus -1+1 =0, het eerste element in de array\n\nif(fq_a <= msg.fq_l)    // is actief array element gelijk aan het aantal records (aantal -1 want 0 is er ook een)\n    {\n    msg.fq_a = fq_a;    //teller in de array vastleggen in de msg zodat je deze info kan hergebruiken\n    return[msg,null];\n    }\nelse\n    {\n    return[null,msg];\n    }","outputs":2,"noerr":0,"x":230,"y":360,"wires":[["d0af317f.5e476"],["305e00c2.048428"]]},{"id":"d904bb60.915c7","type":"switch","z":"1ac73a57.6401de","name":"stuurmod","property":"service","propertyType":"msg","rules":[{"t":"eq","v":"module_x1","vt":"str"},{"t":"eq","v":"module_x2","vt":"str"},{"t":"eq","v":"module_x3","vt":"str"},{"t":"eq","v":"module_end","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":680,"y":420,"wires":[["9deaa996.6d34f"],["f528e180.cf7f7"],["3c3dc780.c0fd88"],["80b1b74.a0f4f48"]]},{"id":"30fd5af4.b1597e","type":"link out","z":"1ac73a57.6401de","name":"","links":["7827020e.4c3ab4"],"x":1155,"y":420,"wires":[]},{"id":"7827020e.4c3ab4","type":"link in","z":"1ac73a57.6401de","name":"","links":["30fd5af4.b1597e","41ef44e.b632e3c"],"x":95,"y":360,"wires":[["a60c139.768547"]]},{"id":"9deaa996.6d34f","type":"function","z":"1ac73a57.6401de","name":"module 1","func":"if(msg.st_info === true)\n    {msg.info = \"info1\"}\nif(msg.st_debug === true)\n    {msg.debug = \"debug1\"}\n\nmsg.result = \"test1\"\n\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":360,"wires":[["ecf9b5a0.30891"]]},{"id":"f528e180.cf7f7","type":"function","z":"1ac73a57.6401de","name":"module 2","func":"if(msg.st_info === true)\n    {msg.info = \"info2\"}\nif(msg.st_debug === true)\n    {msg.debug = \"debug2\"}\n\nmsg.result = \"test2\"\n\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":400,"wires":[["ecf9b5a0.30891"]]},{"id":"3c3dc780.c0fd88","type":"function","z":"1ac73a57.6401de","name":"module 3","func":"if(msg.st_info === true)\n    {msg.info = \"info3\"}\nif(msg.st_debug === true)\n    {msg.debug = \"debug3\"}\n\nmsg.result = \"test3\"\n\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":440,"wires":[["ecf9b5a0.30891"]]},{"id":"80b1b74.a0f4f48","type":"function","z":"1ac73a57.6401de","name":"module 4","func":"if(msg.st_info === true)\n    {msg.info = \"end\"}\nif(msg.st_debug === true)\n    {msg.debug = \"end\"}\n\nmsg.result = \"test4\"\n\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":480,"wires":[["ecf9b5a0.30891"]]},{"id":"2d65f199.dcdb46","type":"function","z":"1ac73a57.6401de","name":"extract data","func":"var msg_copy = RED.util.cloneMessage(msg);  // menu,\nmsg = JSON.parse(JSON.stringify(msg.fq[msg.fq_a]));\n\nmsg.fq = msg_copy.fq;\nmsg.fq_l = msg_copy.fq_l;\nmsg.fq_a = msg_copy.fq_a; \nmsg.mytime = msg_copy.mytime; \n\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":420,"wires":[["d904bb60.915c7"]]},{"id":"23ba6a15.b1a246","type":"comment","z":"1ac73a57.6401de","name":"to do","info":"to do\n- parrallel jobs en merge the outcome messages\n\nmenu\n- add msg id \n- product\n- info etc\n\n\nI made a model that can be used for a large ICT system in Holland that has a honderd submodules and about 200 product that uses these submodules. \n\nI made a concept in node-red to prove it works. You can pre-define the way a service/product uses submodules.\nIn this way you have minimal knowledge in the different submodules and you define this knowledge in one place, the product config (prg_config)\n\nTo do:\n- this version supports serial transactions, i like to add parrallel transactions or combinations config in prg_config and add the end combine the parrallel msg to one.\n\n\nfeel free to use it..","x":850,"y":300,"wires":[]},{"id":"d0af317f.5e476","type":"moment","z":"1ac73a57.6401de","name":"time","topic":"","input":"","inputType":"date","inTz":"Europe/Amsterdam","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD-MM-YYYY:HH:mm:ss:SS","locale":"nl","output":"mytime","outputType":"msg","outTz":"Europe/Amsterdam","x":350,"y":420,"wires":[["2d65f199.dcdb46"]]},{"id":"ecf9b5a0.30891","type":"function","z":"1ac73a57.6401de","name":"update queue","func":"\nmsg.fq[msg.fq_a]={\"service\": msg.service, \"service_status\" : true, \"time\": msg.mytime, \"st_info\": msg.st_info, \"st_debug\":msg.st_debug,\"result\":msg.result};\n\nreturn msg;","outputs":1,"noerr":0,"x":1020,"y":420,"wires":[["30fd5af4.b1597e"]]},{"id":"305e00c2.048428","type":"ui_template","z":"1ac73a57.6401de","group":"cf6d4235.6af71","name":"TRANSACTIE HISTORIE","order":1,"width":16,"height":11,"format":"\n<table style=\"width:100%\">\n\n  <tr>\n    <td>Module</td>\n    <td>Uitgevoerd</td>\n    <td>Tijd aanvang</td>\n    <td>Status info</td>\n    <td>Status debug</td>\n    <td>Resultaat</td>\n  </tr>\n\n  <tr ng-repeat=\"x in msg.fq\">\n    <td>{{msg.fq[$index].service}}</td>\n    <td>{{msg.fq[$index].service_status}}</td>\n    <td>{{msg.fq[$index].time}}</td>\n    <td>{{msg.fq[$index].st_info}}</td>\n    <td>{{msg.fq[$index].st_debug}}</td>\n    <td>{{msg.fq[$index].result}}</td>\n  </tr>\n</table>\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":190,"y":140,"wires":[[]]},{"id":"818d0c2a.f38d08","type":"ui_template","z":"1ac73a57.6401de","group":"cf6d4235.6af71","name":"START","order":3,"width":5,"height":3,"format":"<md-button class=\"md-cornered\" style=\"width: 150px; height: 120px\"\n        ng-class=\"msg.payload=='On' ? 'md-accent md-raised ' : 'md-primary'\"\n        ng-click=\"msg.payload = (msg.payload=='On' ? 'Off' : 'On');send(msg);\"\n        title=\"CAM\"\n    >\nSTART<br>\n\n </md-button>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":140,"y":80,"wires":[["3977cd5e.b2f3a2"]],"icon":"font-awesome/fa-search-plus"},{"id":"63b346b.0342938","type":"function","z":"1ac73a57.6401de","name":"init2","func":"var list_server = [\n                    {\n                        \"title\": \"Services\",\n                        \"icon\": \"https://upload.wikimedia.org/wikipedia/commons/f/fa/Leninux.jpg\",\n                        \"menu\": [\n                            \"Product_1\",\n                            \"Product_2\"\n                                ],\n\n                        \"output\": {\n                            \"Product_1\": '<empty>',\n                            \"Product_2\": 'sudo /home/pi/herstartdom.sh'\n                                }\n\n                    }\n                ];\n\nvar list_empty = [\n                    {\n                        \"title\": \"Services\",\n                        \"icon\": \"https://upload.wikimedia.org/wikipedia/commons/8/82/Domoticz.png\",\n                        \"menu\": [\n                            \"Geen opties\"\n                                ]\n                    }\n                ];\n\n\nmsg.payload = list_server;\n\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":200,"wires":[["e37346aa.470e1"]]},{"id":"e37346aa.470e1","type":"ui_list","z":"1ac73a57.6401de","group":"cf6d4235.6af71","name":"prg","order":4,"width":5,"height":2,"lineType":"one","actionType":"menu","allowHTML":true,"outputs":1,"topic":"prglijst","x":510,"y":200,"wires":[["93f6ad07.2a3bb"]]},{"id":"93f6ad07.2a3bb","type":"function","z":"1ac73a57.6401de","name":"var set ocmd","func":"var sel = msg.payload.selected;\noscmd = msg.payload.output[msg.payload.selected]\n\nmsg.oscmd = oscmd;\nmsg.prg = sel;   //deze is extra\nmsg.oms2 = sel;\nflow.set(\"oscmd\",oscmd);\nflow.set(\"prg\",sel);    //deze is extra\n\nmsg.payload=sel     // deze waarde hebben andere list nodes nodig om te bepalen wat aan/uit\n\nreturn msg;","outputs":1,"noerr":0,"x":690,"y":200,"wires":[["aa9039b.93fdc48"]]},{"id":"aa9039b.93fdc48","type":"ui_template","z":"1ac73a57.6401de","group":"cf6d4235.6af71","name":"oms2","order":6,"width":4,"height":2,"format":"<div ng-bind-html=\"msg.oms2\"></div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":850,"y":200,"wires":[[]]},{"id":"3977cd5e.b2f3a2","type":"change","z":"1ac73a57.6401de","name":"set  msg vars","rules":[{"t":"set","p":"prg","pt":"msg","to":"prg","tot":"flow"},{"t":"set","p":"aap","pt":"msg","to":"test","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":80,"wires":[["92e4629.01dc42"]]},{"id":"731ade4a.48629","type":"ui_ui_control","z":"1ac73a57.6401de","name":"","events":"connect","x":140,"y":200,"wires":[["63b346b.0342938"]]},{"id":"41ef44e.b632e3c","type":"link out","z":"1ac73a57.6401de","name":"","links":["7827020e.4c3ab4"],"x":655,"y":80,"wires":[]},{"id":"cf6d4235.6af71","type":"ui_group","z":"","name":"TRANSACTIE LOGGING","tab":"c4a4ea0c.5604a","order":1,"disp":true,"width":"16","collapse":false},{"id":"c4a4ea0c.5604a","type":"ui_tab","z":"","name":"queue","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.