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
Pymodaq as a client with TCP/IP #284
Comments
Could you explain a bit more thoroufully exactly what you want to do with pymodaq with respect to your program/server? I guess you want to use the daq_viewer to control/plot the data taken by your program. Could you confirm this ? |
Yes that's it. Here is a better explain:
|
Sure then you have to do the same as I did with the Horiba plugin (pymodaq_plugins_horiba). In there there is a DAQ_Viewer1D called labspec6 that connects to a server to communicate with the labspec6 software (so exactly what you want if you replace labspec6 by prg1). It means you have to code a new instrument class plugin to do so (not using the built in TCP/server stuff that's made for pymodaq control modules to communicate together) However, while you are it to code something on the plugin side, you may was well directly import your prg1 classes into the plugin as a wrapper to your instrument (or whatever is behind prg1) |
So, if I understand well: there is no way to easily connect daq_viewer to a custom program by tcp/ip. By easily, I mean "only create a server (as in the socket module documentation) and connect daq_viewer by entering the IP and port information". If so, is there an other way to send data from a custom program to daq_viewer (with an easier way)? |
Well there is but your program (prg1) has to be a client (while you use the TCP server on pymodaq side). Then your client has to implement the functionalities required by the TCP/IP communication |
There is an example (a bit old) of such a thing in the example folder when a client in Labview is connecting to the pymodaq server |
Sounds interesting. Where do I find the "example folder"? I didn't find any such "example folder"? Thanks a lot |
This is made for control modules to talk to each other (here a real instrument control module) will connect to a TCPServer control module (on localhost for simplicity). So you have to open both control modules from your console or IDE, first start the server and the client and finally connect the client to the server. But with this you cannot do custom stuff (like just sending "str(data).encode()" that by the way will just be your data string representation not your actual data) except if you know what your supposed to do... But then again, if you use it in that direction, your Mock control plugins (client) is made to acquire data from an instrument, even if just a mock, The Server can control the behaviour of this client and get back data from it (so you could control your real instrument from afar on the network). I created a somewhat better example (but not that much) on the 4.2.x_dev branch on github: where a custom client (that could be your program) connect to the server control module and use it to plot data on it. But if really your program is actually kind of an instrument and you want to display data (and control it a bit) then you should follow the Labspec6 example and create an instrument plugin |
Hi! |
good to know |
@rgeneaux maybe you could have also a look at it for your use case, but still I think the instrument plugin is still the best approach (with pyleco even better) ! |
Hi again! |
Well it is known that there is a tIme lag when using the legacy TCP/IP stuff. The problem is to do a proper asynchronous execution as here it is looping like creasy... We worked with @BenediktBurger to use a package he developed based on remote call procedure, called pyleco. It's use will be almost the same as the TCP/IP but works much better and is more general. There is a branch in the GitHub account of pymodaq to test it. |
You have to configure the refresh rate. As far as I know, the pymodaq module will poll the values only every some seconds (which you can configure). LECO - Laboratory Experiment COntrol, with its python package PyLECO, is a communication protocol to connect different programs on your computer. It encourages to use remote procedure calls as a communication standard. |
Hi!
I have a program that always runs and processes data (let's name it prg1.py) . What I want is to configure Pymodaq such that it connects as a client to the server prg1.py .
The programme prg1.py works as a server: I ve tried to exchange some data between prg1.py and a custom client program.
However, when I try to tell to Pymodaq to do the same. It doesn't even connect to the server:
(eventhough Pymodaq tells me that it is connected to something).
So, if someone has some ideas, I take!
Thanks
The text was updated successfully, but these errors were encountered: