03-25-2015 05:45 AM
Hello i am really new to labview and labpython and im trying to figure some stuff out. I have been handed a huge file with lost of vi's runnint and i need to import my python code into labview.
I have a few variables that need to run inside labview and others that need to run just so it can get the data. I have a csv file which the python code grabs data from and the sets an Int with that data, then reproforms this action over and over again for each line with a 5 second delay.
I need labview to set this Int as a glabal variable which i have set up. After it sets the glabla variable it needs to recieve 2 global varables and set them as Ints in the code, finally it needs to take a boolean from the code and set it as 1 of 3 outputs.
Ints:
t1input = (getfrom csv)
t1output = t1input
t2input = (t1ooutput - leak) //this is the Int it needs to get into the code
bollean
if t2input >= 50% of t1input (true/false)
if t2intpit < 50% of t1output (true/false)
if t2input < 25% of tioutput (true false)
Im just not sure how to set this up. all these variables are in the same code so where do i tell labpython which one i want to use ?
i am attatching the csv and pastebining the python so you can check what variables i am using.
python code = http://pastebin.com/NHDvKsNZ
Like i said i have basically been handed the labview file at work and told to get this working. Please dont get annoyed at me if i dont know the basics yet.
Solved! Go to Solution.
03-25-2015 07:38 AM - edited 03-25-2015 07:41 AM
That Python script is so basic, it would make more sense to simply implement it all in LabVIEW than trying to interface it to LabVIEW through LabPython. LabPython is not meant to query variables while a script runs. Rather it is sequentual like: set variables, execute script, read variables. The execute script function only returns AFTER the script has executed.
03-25-2015 08:27 AM
Thank you for your answer. could you possibly refer me to some learning documentation which i can use to put this script into labview. I am working wit a small team and we are all new to labview so no one is sure on how to get a straight code into labview correctly.
03-25-2015 08:55 AM
@AceScottie wrote:
Thank you for your answer. could you possibly refer me to some learning documentation which i can use to put this script into labview. I am working wit a small team and we are all new to labview so no one is sure on how to get a straight code into labview correctly.
What he meant is that you need to write what that code does using LabVIEW.
03-25-2015 09:29 AM
I think you would want to do something along these lines to get the Python script ecquivalent.
But there are several issues here. First the Python script always interpretes the number from offset 36 in the line but the sample data obviously doesn't always start at offset 36 for the number. Also the calculation of the fractional part I don't understand at all. It could be my understanding of what the script is supposed to do or my limited Python knowledge, but I'm pretty sure it does not do anything useful with that data set as is.