LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI Data Spaces and LVLIBP/PPL - creating a truly singular instance

Solved!
Go to solution

I just meant my interpretation would mean a hack 😉

 

How would you send data to the broker? By value with an access vi didn't work as i had to learn.

0 Kudos
Message 21 of 27
(573 Views)

 


@Mark_Yedinak wrote:

@paul.r wrote:

@Mark_Yedinak wrote:

@paul.r wrote:

Using a class by reference isnt really a singleton - a singleton should guarantee that only one instance of the class exists. 


You can guarantee it is a singleton by having the create check if the DVR is valid or not. If it is valid, do nothing because the object has already been instantiated. You can even include a flag in the private data for extra protection. Once created any further calls to the create method will simply return the same instance of the class. Yes, someone could drop a class constant on the block diagram but the class is useless without the call to the create method since the DVR is invalid.


So then the create method would need some sort of global variable to check the state of the DVR, right? Thats what I was getting at, I don't know any way to create a singleton without at least one global variable used.  


You don't have to have a global variable. A simple test of the DVR would let you know if it is valid or not. If the DVR is never obtained the reference is not valid and any attempt to access it would throw an error. If it is valid, the object has been instantiated and you have your singleton. Dropping a class constant on the block diagram and wiring it to any method would throw an error because the DVR on that wire would not be valid. ALL class data is stored in the DVR so without a valid reference you have an invalid instance of the class. The only way to get a valid DVR is by calling the create method. If you call create more than once it will only initialize the DVR on the first call because that would be the only time the DVR is invalid. Well, a call to the destroy method would clear the DVR and set it back to an invalid reference. However, if you call the destroy method you are disposing the object anyway so a call to create after that is creating a new instance.


What are the inputs/outputs of the create method? Do you pass in the class, or just return class? I don't understand what you mean when you say if you called the create method twice, it would only initialize the DVR the first time because that is the only time the DVR is invalid. What DVR is it checking to be valid?

 

We may just not be matching on terminology, by global variable I am also including any persistent data structure like a shift register or feedback node. 

0 Kudos
Message 22 of 27
(571 Views)
Solution
Accepted by topic author Moray2000

Over TCP - each module communicates with the broker by sending TCP messages to it, other modules subscribe to the message types they want to receive - again the broker then forwards them the messages over TCP. 

 

This is probably a massive redesign of your application and not really what you are looking to do. At a previous job I worked on a very large HAL for Teststand that was all PPL based, and we did have an .exe 'softpanel' that you could use to get hardware status and readings by calling those PPLs while they were being called by teststand, but I cannot remember how we did it. (Or if that is exactly what we were doing)

0 Kudos
Message 23 of 27
(562 Views)

Here is what the creaCreate.pngte looks like.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 24 of 27
(558 Views)

Got it - like I said, I would consider that feedback node a form of global variable. 

0 Kudos
Message 25 of 27
(555 Views)

@paul.r wrote:

Got it - like I said, I would consider that feedback node a form of global variable. 


I wouldn't. It is state information that is only accessible within that one VI. Global variable implies it is accessible outside of the VI.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 26 of 27
(553 Views)

Just to revert my claim that this is not really documented:

https://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/application_instances/

 

I'll look into TCP

0 Kudos
Message 27 of 27
(542 Views)