-
Notifications
You must be signed in to change notification settings - Fork 1.3k
DRAFT: ZMQ messages from HALUI to GUIs #3580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Gstat sends out socket messages for jog rate
calls these functions in a GUI
This is a proof of concept to allow 3rd party (hal_bridge) to call macros. The macros are run from Gmoccapy so no timing problems should occur and and pre checks or post changes can be covered. There needs to be agreement on where to put macro definitions in the INI. Gmoccapy puts them under [MACROS], iniinfo under [DISPLAY] python ZMQ module package must be available for this to work
mdi commands with a comma in it (ie MSG, text) would not be interpeted properly
named INI MDI commands were not recognised.
you can use STATUS messages to 'press' ok or cancel
so you can use halui to accept the toolchange
so GUIs not basd in gobject can run the message system
|
Yes you could send gcode via ZMQ. I don't know what the limits of the amount of data you could send at once. A version of versa probe is actually already in linuxcnc's repo: |
|
Seems I somehow missed that discussion. Just wanted to say I did a fairly complete POC to add a 0mq messaging layer parallel to NML, so you could run linuxcnc without any NML. see https://github.com/rmu75/linuxcnc/tree/rs/zmq-experiments. |
|
rmu75: c-morley:
I dont agree. I think that halui.mdi-command, versa-probe, ncam, ...... should have same interface for GUI. |
Proof of Concept. machinekit did add a bridge between NML and something 0mq/protobuf based, probably because they didn't want to touch the NML layer. I wanted to explore if replacing NML would be feasible. |
How well did it work? |
The interface can not resolve mode switching problems by it's self. Only the GUI programmer can do that. It certainly can ask the GUI to run some gcode, if that is what you want. |
I thought "interface" + "modification GUI for interface" should be same for halui.mdi-command, versa-probe, ncam, ...... I thought "modification GUI for interface" should resolve issues related to mode switching and race-conditions with other commands.
I want:
But I'm not a Gmoccapy developer, so it doesn't matter to me. |
basically it does work. I tested with a minimal debug-tool https://github.com/rmu75/cockpit/tree/rs/zmq in parallel to axis & co. Overhead is slightly higher than with NML, because zeromq doesn't have a shared memory transport, so everything is serialized/desrialized into a pipe, but nothing really noticable. The tedious part, extraction of all messages into IDL files and the writing the boilerplate code turned out to be relatively quick and easy. one central point needed changing of a pointer to std::unique_ptr because messages received via zeromq are dynamically allocated and need to be disposed of whereas NML messages always get copied to some static buffer. That change already is in master. 6d65386 The zeromq messaging layer would allow for some improved semantics of e.g. the error / warning channel, at the moment, only one consumer is allowed, if you connect more than one it is defacto undeterministic which one receives a message. |
|
A few notes: I don't know if the probe-screen in the LinuxCNC repository has been updated for Python3 / Gtk3. I did that task in a fork of a fork of psng: https://github.com/andypugh/probe-screen-ng There was a plan some time ago to replace NML with 0MQ/ZMQ. I recall a phone call from a meetup in Wichita to the original author of NML at NIST. He was astonishd that we were still using it and thought that switching to zmq was a good idea. But that got all tangled up in the Machinekit split, and I don't think that MK ever got round to doing it. |
|
@rmu75 |
|
In principle it could be merged as is, it can be run parallel to NML. Modulo bugs and things I missed. Some infrastructure / configurability and tests have to be done. Maybe alternatives to 0mq resp. flatbuffers should be evaluated before merging: (nanomsg, protocol buffers, capt'n'proto) -- flatbuffers seemed to have lower overhead compared to protobuf. |
s32 is more common the u32 (easier to connect to) also axis select uses -1 as 'unselected'
|
It seems you are manually serializing the messages into JSON. Is there a particular reason you don't use something like protocol buffers, capt'n'proto or flatbuffers? Compare with the current NML situation, at some point a tool did exit that generated the boilerplate serialization/deserialization code, but that tool seems to have disappeared and changes to messages are tedious and error-prone. IMO it would be cleaner to use some tool that takes some kind of interface description (IDL-file) and generated code for serialization/deserialization. That would also make it easier to talk to other languages. |
|
Thanks for looking at the code and commenting. I used JSON as that was the example that I found and it was simple. At the moment I'm trying to flesh out the idea/process of adding this utility to HALUI and see if it's as useful as I think it is. |
|
I will rebase and fix my 0mq nml/rcs replacement branch in the next few weeks, then there should be a runnable example. I used flatbuffers to build the wire format https://flatbuffers.dev/, other candidates would be google protocol buffers and capt'n'proto. Protocol buffers seem to have slightly more overhead but are way more popular. https://github.com/rmu75/linuxcnc/blob/rs/zmq-experiments/src/emc/task/emctaskmain.cc#L239 shows how to put linuxcnc error message into a message and send it out to zmq, https://github.com/rmu75/linuxcnc/blob/rs/zmq-experiments/src/emc/flatbuf/emc_error.fbs is the corresponding interface definition. this https://github.com/rmu75/cockpit/blob/rs/zmq/src/zmqcom.cpp shows how the equivalent to I don't yet have any python-code examples, will have to refer to this https://flatbuffers.dev/tutorial/#python. It would be really nice if we could get rid of direct HAL usage of the diverse GUIs and use messages / remote procedure calls instead. Would make building some sort of remote control / remote GUI / remote DRO / android pendant app etc... much easier. |
Some GUIs use the MPG for other things then jogging. Qtdragon uses MPG for scrolling and needs a selected pin.
Ok thanks I'll look at that. I could library out the messages, so any technology could be used. |
like if you want to send responses to the current showing dialog
halui 'ok' or 'cancel' messages
ok and cancel are used by the system unlock dialog as an example. To do this properly for all dialogs would require some more thought.
|
Hi Chris, I wanted to make an improvement for LinuxCNC. Unfortunately, I was limited by the current technical capabilities of ChatGPT. I worked with ChatGPT for two days to architecture my improvement , and we programmed it together for another two days, and it ended up taking about half an hour for each of its responses, and ChatGPT got confused. However, we ended up a little short of our goal. When I have time, I will study everything ChatGPT created and finish it manually. I don't have time for my improvement at the moment. Why am I writing this to you? Thanks to ChatGPT, I have understood more deeply how LCNC works. I have become more familiar with the task module. Based on newly acquired information, I conclude that all of our images above were wrong.
I made a picture based on the official architecture: Merely replacing NML technology with ZMQ technology is not interesting to me. However, integrating all the requirements that arose during the development of LCNC into ZMQ technology would be interesting to me. I could help with creating the architecture (drawing blocks), writing and updating documentation, and testing. Above I asked the question why HAL is not used everywhere. Now I will answer this question:
I think that NML was done well, but at the time when it was created, current GUIs did not exist. At the time when current GUIs were created, NML was not adapted. I used to look for a problem with switching modes everywhere. Today I am convinced that the problem is in the TASK module. I wanted to ask you, what is your priority now? I think proper ZMQ integration should be addressed in LCNC 2.11. Because it will affect everything. I think version 2.11 should do:
|
|
Well that's quite a lot to digest. The problem I am trying to fix with this pr is with the fact that every UI has a slightly different way to connect HAL pins for common required behaviour. HALUI has turned into a fairly standard way to connect physical operator panel to linuxcnc. Unfortunately it also does things it's own way that does not integrate well with the other GUIs. IMHO mode switching between manual, mdi and auto is an old concept that could mostly be done away with. We are constantly working around the problem by switching modes then immediately switching back which is silly and error prone. |
On the other hand, we don't have a deadline for anything.
I agree that this PR is not intended to be a general NML/ZMQ exchange. However, we can continue the debate elsewhere.
Do you really want to create a communication triangle? HALUI <=> GUI <=> TASK <=> HALUI IMHO "ZMQ messages from HALUI to GUIs" is not good idea. I apologize if my opinions are rude. My English skills don't allow me to write this more politely. I know this PR has taken you a lot of work.
On the other hand, more people are trying to solve this problem by bypassing it. You created Bridge, I created HAL pins "is_running", @Sigma1912 created native HAL pins in Gmoccapy. We all made the mistake of not trying to understand/modify TASK and so our solutions are imperfect. |
|
HAL and NML are for two different uses and are not really interchangeable. NML and ZMQ are similar and could be interchanged. So yes if NML was easier to use, I might have used it instead of ZMQ for this pr. The reasons for having the GUI communicate to HALUI:
|


This is the on going work started here:
#3528
This generalizes the idea for messages.
There are three proof of concept sims:
axis_halui_test.ini
gmoccapy_halui_test.ini
qtdragon_halui_test.ini
They will load the respective gui and a separate simulated control panel.
You can notice the jograte slider on the control panel changes the jog rate on the gui.
I would love it if someone could test these rough changes.