0

I have a class-service which control connection and data exchange beetwen CNC shell program and CNC controller. This class implement some methods among which GetResponse method.

...
public bool GetResponse(string query, out string result)
...

This method sends command to cnc controller. It may be success or fall. Method returns operation successfulity. "string result" returns code of error, or empty string if operation success. Sometimes I need to send command J+ (jogging) and A(stop jogging). Command J+ does continuous jogging of machine. Command A stops this joggind. Controller is connected through an ethernet. Sometimes GetResponse method may not send command and return false. But if it don't sends command A (stop jogging) then I have big problem, machine don't stay.

I could execute GetResponse method in "while loop" while it don't return success, but if it don't return succes never I will have new problem - deadlocking my program (infinite while loop).

Also I can implement queue of commands and this method will free the queue when it's commands executed successfully. But if the queue is too full, commands will not work in time and A command(stop jogging) execute too late. Is there a best practice in such cases?

Noisy88
  • 181
  • 1
  • 14
  • `Sometimes GetResponse method may not send command and return false` perhaps you can dig into that to figure out what is causing it :/ – zaitsman Sep 17 '19 at 07:16
  • @zaitsman This is due to the architecture and the behavior of the controller itself. Unfortunately, I can't influence it and I use it as-is. – Noisy88 Sep 17 '19 at 07:25
  • 2
    I'm not sure what the question is here. If you're unable to send commands to the controller, what do you expect us to give you here? A way to force it? – Lasse V. Karlsen Sep 17 '19 at 07:26
  • @LasseVågsætherKarlsen sometimes method GetResponse can't execute commands, not always, only sometimes. Often decided by resending the command. – Noisy88 Sep 17 '19 at 07:29

0 Answers0