LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Object Persistence in LabPython

Hi,

 

I have a question about LabPython. Suppose I am given a Python script that contains class definitions. I want to use LabPython to initialize such objects and manipulate them. Is there a way of achieving object persistence with LabPython?

 

Here was my idea:

 

I could create a wrapper Python script around the script with the class definitions. 

 

Let's say my class definition script code/pseudocode looks like this:

 

class d

          bark_volume = 0 

          

          def bark(self)

                self.bark_volume = self.bark_volume+1  

 

Now my wrapper could like this:

 

i = 0;

           

if(i == 0)

     import stuff

 

if(i == 1)

     a = dog

 

if(i==2)

    bark_volume(a)

 

By changing the input variable i, I can import stuff, initialize an object of type dog, and then call methods on that class. By changing the variable i and making successive calls to the wrapper script from LabPython, I might be able to manipulate the object of type dog from the LabVIEW environment. Does this make any sense?

 

Thanks,

Carlo

0 Kudos
Message 1 of 3
(2,477 Views)

Sounds like it should work. I would try it using the Script Node and see if it works. If you run into issues then I would suggest posting your code so that other users to help troubleshoot the issue.

dK
0 Kudos
Message 2 of 3
(2,444 Views)

Cross-posted to LAVA.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 3
(2,437 Views)