Closed OpenScanFan closed 2 years ago
@OpenScanEu I tried to implement pause function, however, due to the structure of the node-red code (mix of function blocks and python function blocks) I couldn't find a nice solution for this... I guess we would need a button to pass pause command to the "Routine" block (and then lock the "for" loop with "while" statement). Maybe that's due to my lack of knowledge of node-red but I couldn't manage to find a nice way to pass the pause command (damn python-3 blocks incompatible with internal node-red variables). If we need to pass the command to the python-3 block, we need to use a file (save/readstring - that's generally quite problematic in my opinion, maybe we somehow could minimize the use or write operations to limit the stress of the sd card?). But to execute a single write from the pause button we have to use a node-red function block?
Ok, it took me a while but I managed to implement this. In the SCAN flow a few new blocks are needed:
Moreover, the "Routine" code need to be changed to:
Finally, the dashboard elements needs to be placed in such configuration:
The pause button has got the pause icon and width of 4x1.
All this is implemented in my fork #20
The result is a pause button:
It is active only when scanning is running, when device is paused the status will be changed to "PAUSED". The device can be resumed by clicking the pause button again or stopped by stop button.
Sorry, but I have a couple of questions
id": "70e59042ca7c4455", "type": "ui_button", "z": "1613373abaf77a2c", <--- z? "name": "pause", "group": "7aaf184330605300", <----what group is this? where do I enter it? "order": 27, <---where can I change the order? "width": "4", "height": "1", "passthru": false, "label": "", "tooltip": "", "color": "", "bgcolor": "", "className": "", "icon": "fa-pause", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 330, <----where do I enter these values? "y": 1460, "wires": <----where is this?
Sorry, I am still learning this
You can import the blocks using the json code (https://nodered.org/docs/user-guide/editor/workspace/import-export) The values you marked are not mean to be input by hand, I guess that group describes to which dashboard the button is added (my second screen, you can follow one of the tutorials about dashboards to find this window, for example: https://www.arubacloud.com/tutorial/how-to-create-a-node-red-dashboard.aspx), order describes position in the dashboard. X and Y are probably just positions of this block in the node red editor sheet and wires describe connections to other nodes in the flow (black lines connecting the blocks). I have no idea what is the z value but as I mentioned - I don't think you should bother, I believe that you can just import the blocks from the json provided, adjust the connectors and function code and place the button in right place in the dashboard layout list.
@sokol07 @OpenScanFan I have added a pause button to the latest update.
It would be really handy to add a pause scan button