07-29-2022 08:37 AM
Is it possible to get an updated value of LabView variable from inside of a python script?
For example, I have a python node running a loop, and I also have a sub-VI that logs a signal continuously. And I want to have access to the most recent signal value in my python loop's iterations. Maybe have a python variable that updates continuously, I am not sure how to approach this. Or is it even possible.
Writing to a file is not an option here due to high freq.
I am using native Python module (Open Python session, Python Node, Close Python session).
07-29-2022 08:56 AM
@Koval84 wrote:
Is it possible to get an updated value of LabView variable from inside of a python script?
For example, I have a python node running a loop, and I also have a sub-VI that logs a signal continuously. And I want to have access to the most recent signal value in my python loop's iterations. Maybe have a python variable that updates continuously, I am not sure how to approach this. Or is it even possible.
Writing to a file is not an option here due to high freq.
I am using native Python module (Open Python session, Python Node, Close Python session).
When the application is a high performance (high logging rate), a mix of LabVIEW and Python is not the preferred use. Instead, do everything either in LabVIEW or in Python.
07-29-2022 09:01 AM - edited 07-29-2022 09:05 AM
I don't need to process the signal at the same frequency it's being logged though, just be able to get the last value it got atm. In fact, I only mentioned the speed bc it makes it impossible to communicate through a file.
07-29-2022 09:49 AM
@Koval84 wrote:
For example, I have a python node running a loop
Running a loop or running in a loop? In other words, is the loop in the Python code or in the LabVIEW code?
Also what kind of loop?
07-29-2022 10:14 AM
@Koval84 wrote:
Is it possible to get an updated value of LabView variable from inside of a python script?
For example, I have a python node running a loop, and I also have a sub-VI that logs a signal continuously. And I want to have access to the most recent signal value in my python loop's iterations. Maybe have a python variable that updates continuously, I am not sure how to approach this. Or is it even possible.
Writing to a file is not an option here due to high freq.
I am using native Python module (Open Python session, Python Node, Close Python session).
Best bet is to decide on a form of inter process communication if you want to have two applications interact with each other. If you are just writing the apps now, as mentioned, pick labview or python but not both. If using both apps is a requirement, check out pipes, rabbitMQ, or TCP/IP, either way it it will be some work to get it going.
07-29-2022 10:19 AM
@JimB. wrote:
@Koval84 wrote:
For example, I have a python node running a loop
Running a loop or running in a loop? In other words, is the loop in the Python code or in the LabVIEW code?
Also what kind of loop?
Loop in the Python code. Any loop. A simple "for" or a comprehension list, doesn't matter. Something that iterates and uses the latest value of a signal.
Another example is minimization function.
The point is to get a value from LabView to Python script that is running already.
07-29-2022 02:22 PM
@Koval84 wrote:
@JimB. wrote:
@Koval84 wrote:
For example, I have a python node running a loop
Running a loop or running in a loop? In other words, is the loop in the Python code or in the LabVIEW code?
Also what kind of loop?
Loop in the Python code. Any loop. A simple "for" or a comprehension list, doesn't matter. Something that iterates and uses the latest value of a signal.
Another example is minimization function.
The point is to get a value from LabView to Python script that is running already.
Well, there could be different approaches but here's one example.
Should you do it like this? Probably not.
This is only a very simple implementation and probably has a lot of unsafe stuff I'm not even thinking about. Off the top of my head, a couple things I was too lazy to work out for this example: