Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically determine whether forcing is enabled on real-time target

Solved!
Go to solution

For an HMI application that I am working on, I would like to inform the user at startup whether forcing is enabled on the target/whether any I/O is currently being forced.  This information is easily available in the Distributed System Manager, but I can't seem to figure out how to get this information programmatically.  Is this possible?  I'm hoping that there is a simple solution that I'm overlooking.

0 Kudos
Message 1 of 10
(5,323 Views)

Anyone?

0 Kudos
Message 2 of 10
(5,304 Views)

Hi Apapr,

 

You can do this using an I/O Variable Engine property node, set the property to "Forcing Enabled" and set it to read.

 

These Forcing VIs have examples of using this property node if you open them up.

http://zone.ni.com/reference/en-XX/help/371361H-01/lvioscan/forcing_palette/

 

I've also attached pictures of the menus to go through to alter a generic property node to an I/O Variable Engine property node with the "Forcing Enabled" property.

 

Hope that helps!

Download All
0 Kudos
Message 3 of 10
(5,298 Views)

Hi Alisha,

 

That works perfectly!  Thanks for the reply.  What I still can't figure out, however, is how to check whether individual I/O variables are being forced.  In the Distributed System Manager the Quality of a variable will change from "Good" to "Forced" to indicate the forcing status.  If I create an I/O variable property node I do not see a forcing property or anything related to quality.  If I create a SharedVariableIO property node there is still no forcing status, but I can create a reference to the information I want (as shown in the image I attached).  Of course this reference doesn't really do anything for me because I don't know what to do with it.  What am I missing?

0 Kudos
Message 4 of 10
(5,285 Views)

Hi Apapr,

 

Can you provide more detailed instructions on how you got to the point where you can see the ForceEnabled boolean in the Shared Variable browser?

 

What version of LabVIEW are you using?

 

Thanks,

0 Kudos
Message 5 of 10
(5,266 Views)

Hi Alisha,

 

I am using LabVIEW 2010 SP1.  I also have the DSC module.  If I create a SharedVariableIO property node, then right-click on the reference input and create a constant, I can click on the down arrow on the constant and browse shared variables, as shown in the attached image.  From there I can browse to my I/O, or drill down farther and select ForceEnabled, ForceValue, or RefersTo (this was the image in my previous post).

 

In my second image I show that you can wire either reference to the SharedVariableIO property node.  (I'm not sure why you can do this because I do not think there are any properties specific to the second reference).  I would like to access the forcing information for each variable, but the problem is that the SharedVariableIO property node does not have properties for this information.  I can't figure out why I can browse to the information I want but not actually be able to use it.

 

Thanks again for your help; I really appreciate it.

Download All
0 Kudos
Message 6 of 10
(5,262 Views)

Hi Apapr,

 

Since this property doesn't seem to be available through any of the variable property nodes, I don't think that there's currently a way to access the information programmatically. You could suggest adding this functionality to LabVIEW at ni.com/ideas.

 

In your program, you might consider forcing or unforcing the variable at the start of the program. At least, that way you would always know whether the variable was being forced or not. Also, if forcing is off in general, you'll know that none of the variables could be forced. I'm sorry not to be more help.

0 Kudos
Message 7 of 10
(5,231 Views)

Hi Alisha,

 

I think I will follow your advice and get creative with forcing/unforcing at the start of the program.  It seems like a very good alternative.  I will also post on the idea exchange just to see what happens.

 

Thanks again for your help!

0 Kudos
Message 8 of 10
(5,227 Views)
Solution
Accepted by topic author apapr

The items shown in the browse dialog you attached in your previous post are PSP data items that are automatically published by the scan engine for each variable.  As long as you've enabled network publishing for the I/O Variable, you should be able to access the forcing information by reading a PSP Variable with the appropriate URL (e.g. "ni.var.psp://<hostname>/mod1/AI0/ForceEnabled").  Similarly, you could find out the forcing value by reading "ni.var.psp://<hostname>/mod1/AI0/ForceValue".  This is how the browse dialog is obtaining that information.  It's simply displaying all of the PSP items present on the network.

Message 9 of 10
(5,216 Views)

I can't believe all I needed was the Read Variable VI.  It works exactly as I wanted it to.  Thanks for the solution!

0 Kudos
Message 10 of 10
(5,195 Views)