MDI calls from qtvcp

More
20 Apr 2023 16:51 #269493 by daiman444
Hi all. I ran into an obscure issue when calling MDI on a button click.
there is a method in which MDI is called:
def mdi_commands(self, mdi):
         complete_time = 10
         self.cmd.mode(linuxcnc.MODE_MDI)
         self.cmd.mdi(mdi)
         self.cmd.wait_complete(complete_time)
         self.cmd.mode(linuxcnc.MODE_MANUAL)

if you send commands such as G92X0Y0Z0 they work instantly and do not cause any problems.

The first version of the problem:
if you send something like G0X2000Y6000, then the command works for 10 seconds and the interface seems to freeze: gcode_graphic does not display anything, the coordinates do not change, no buttons respond to pressing. but after 10 seconds ("complete_time") everything hangs but the command is not executed to the end.

second version of the problem:
If you specify a long time for complete_time, for example equal to 180, and issue the G0X2000Y6000 command, then everything will happen the same as in the first option, except that the axis will reach the command executor.

third option:
if everything is done as in the second option, except that you set the time for complete_time not as an int, but as a list, i.e. complete_time = [180] then the interface does not freeze, everything works fine, except for one BUT. there is a qtvcp warning that the value for complete_time must be specified as a real number, not as a list!

how to solve such a problem?

P.S.: I understand that the question is too confusing, maybe I will shoot a video on 3 senarias and stick it in the following posts, however, if someone came across and understood what was happening and could tell me, I would be grateful

Please Log in or Create an account to join the conversation.

More
20 Apr 2023 20:22 #269510 by blazini36
Replied by blazini36 on topic MDI calls from qtvcp
I'm not a code guy, like at all but I had help with a custom interface I needed. When I issued MDI through Python I had the program probing for a status to confirm completion. Like after a movement the program checked for the "in-position" flag or something like that. There's probably some other flag to check for the finish of an MDI execution but I'm not sure that waiting based on time is the greatest way to go about it.

Please Log in or Create an account to join the conversation.

More
20 Apr 2023 21:31 #269521 by cmorley
Replied by cmorley on topic MDI calls from qtvcp
Look in qtvcp's ACTION library:
github.com/LinuxCNC/linuxcnc/blob/master...cp/qt_action.py#L172

From memory the problems are:
asking for a mode linuxcnc is already in can cause a long pause.
using wait_complete will always cause the python program to freeze till the command ends.
monitoring the error status (if you need to) is a race condition

It's actually a difficult problem to work around.
What kind of MDI command do you wish to run?
The following user(s) said Thank You: daiman444

Please Log in or Create an account to join the conversation.

More
21 Apr 2023 13:30 - 21 Apr 2023 13:31 #269553 by daiman444
Replied by daiman444 on topic MDI calls from qtvcp

Look in qtvcp's ACTION library:
github.com/LinuxCNC/linuxcnc/blob/master...cp/qt_action.py#L172

.....

It's actually a difficult problem to work around.
What kind of MDI command do you wish to run?

 

thank you for your responses. the actions from qtvcp are based on the actions of linuxcnc.py and inherit all of its problems and even multiply them in some cases. in view of which the actions from qtvcp do not simplify the task in any way.

the code that I need to execute is just "G0X2000Y6000" so that the portal goes to the end of the working field
Last edit: 21 Apr 2023 13:31 by daiman444.

Please Log in or Create an account to join the conversation.

More
21 Apr 2023 13:56 #269554 by cmorley
Replied by cmorley on topic MDI calls from qtvcp
well qtvcp's action library checks the mode linuxcnc is in before trying to change it so that is an improvement from your example.

You need to use wait_complete just so you can change the mode to manual?
maybe you could completely define what behavior you want/need.

Please Log in or Create an account to join the conversation.

More
21 Apr 2023 14:38 #269555 by daiman444
Replied by daiman444 on topic MDI calls from qtvcp

well qtvcp's action library checks the mode linuxcnc is in before trying to change it so that is an improvement from your example.

You need to use wait_complete just so you can change the mode to manual?
maybe you could completely define what behavior you want/need.

without using wait_complete, waiting for mdi execution is critically small and only enough to execute something like "g92x0y0z0"

Please Log in or Create an account to join the conversation.

More
22 Apr 2023 04:11 #269592 by cmorley
Replied by cmorley on topic MDI calls from qtvcp
Wait complete only tells the python program to stop running until the command is completed, it doesn't stop the machine controller. If there are commands after mdi that will stop the machine controller (like mode changes) and you don't use wait complete, then the first command will be cut short.

So again, do you need to switch the mode back to manual? Remember I have little idea what you are ultimately trying to do.

Please Log in or Create an account to join the conversation.

More
23 Apr 2023 08:19 #269676 by cmorley
Replied by cmorley on topic MDI calls from qtvcp
There may be another way.
If you can get the serial number of the command, then check status to see if the serial number has past, then that should get you the same as wait_compleye without blocking.

Looks like command has 'serial' and status has echo_serial. Some testing will be needed.

Please Log in or Create an account to join the conversation.

More
23 Apr 2023 14:56 #269691 by daiman444
Replied by daiman444 on topic MDI calls from qtvcp

Wait complete only tells the python program to stop running until the command is completed, it doesn't stop the machine controller. If there are commands after mdi that will stop the machine controller (like mode changes) and you don't use wait complete, then the first command will be cut short.

So again, do you need to switch the mode back to manual? Remember I have little idea what you are ultimately trying to do.

 

hi. I just want to get the G0X2000Y6000 command executed.
the method by which I call the execution of the command:
def mdi_commands (я, mdi):
         полное_время = 10
         self.cmd.mode(linuxcnc.MODE_MDI)
         self.cmd.mdi(mdi)
         self.cmd.wait_complete (complete_time)
         self.cmd.mode(linuxcnc.MODE_MANUAL)
 

Please Log in or Create an account to join the conversation.

More
24 Apr 2023 05:13 #269719 by phillc54
Replied by phillc54 on topic MDI calls from qtvcp
You could try something like this:
ACTION.CALL_MDI('G0 X2000 Y6000')
while not STATUS.is_interp_idle():
    self.w.gcodegraphics.updateGL()
    QApplication.processEvents()
The following user(s) said Thank You: daiman444

Please Log in or Create an account to join the conversation.

Moderators: cmorley
Time to create page: 0.100 seconds
Powered by Kunena Forum