VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Channel Outside of Custom Device

Solved!
Go to solution

Hi all,

 

I am trying to write a custom device to control certain aspects of my system definition (specifically another custom device).  I am having trouble accomplishing this because I cannot find a way to write to a VeriStand channel that is outside of my custom device.

 

The help for the Get Channel Data Reference (which I would usually use to get a data reference so that I could use the Set Channel by Data Reference.vi) specifically says that I cannot obtain write access for a channel outside of my custom device.

 

 

context help.PNG

 

Is there any way for me to get write access to a channel outside of my custom device?

 

I realize that I can create system mappings to output channels of my custom device, but I'm not crazy about a bunch of system mappings because they're not very visible and I'd like the user to only need to use my configuration pages.  I also realize that it's probably possible for me to create these mappings programmatically from my custom device configuration, but I haven't been brave enough to venture down that road yet....

 

I am using VeriStand 2011 SP1 and LabVIEW 2011 SP1.

 

Thanks,

 

Chris

Project Engineer

Certified LabVIEW Developer

jet-logo-black.gif 

 

 

 

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 1 of 10
(8,286 Views)

Hi Chris,

 

Unfortunately, I believe you have answered your own question: You cannot directly write to channels outside the custom device; you need to use system mappings.

 

0 Kudos
Message 2 of 10
(8,244 Views)

So now I'm wandering down the dark alley that is the VeriStand .NET API....

 

I've successfully created system mappings using the SetDataSourceValue method.  However, I can't find a way to delete those same mappings.  I figure there has to be a way to do that.....

 

right? Smiley Sad

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 3 of 10
(8,222 Views)
I think you can use SetDataSource with a null reference to erase a source mapping.
Jarrod S.
National Instruments
0 Kudos
Message 4 of 10
(8,215 Views)

Jarrod,

 

So I don't think that worked.

 

I just created a .NET constant, since I didn't know where to find a null constant:

Null Mapping.PNG

 

This just gave me an empty mapping (which will throw an error on deployment):

 

Bad Mappings.PNG

 

Is there a different way I should be doing this?

 

Thanks!

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 5 of 10
(8,204 Views)
Solution
Accepted by topic author Call_Me_Vinny

BaseNodeType is part of the SystemStorage assembly, which is something used internally and not intended for public use.  The publicly documented API is the SystemDefinition API, which has available documentation and is a little more user-friendly.

 

In the SystemDefinition API there is a class called "Utilities" which has an AddMapping(Channel Source, Channel Destination) method, and a ClearMapping(Channel Destination) method.  These work as expected, and clear the mapping entirely (not just creating an invalid mapping with a null source, like your screenshot).  This would be the preferred method of adding and removing mappings.

 


However, if you wanted to stick with your existing code, I think you can accomplish what you want by removing the "SetDataSourceValue" method and replaching it with a "RemoveProperty" method.  The name wired into "RemoveProperty" will stay the same ("DataSource").  This will actually entirely clear the mapping from the channel, instead of remapping it to a null channel.

 

Regards,

Devin

Message 6 of 10
(8,197 Views)

I should also mention that you can get your custom device into the SystemDefintion API in a similar way as you're getting into the SystemStorage API in your screenshot.  Instead of using "Item Reference to Pointer.vi", there are a series of VIs available to convert from the U64 ID to a SystemDefinition API reference.  These can be found in the following library:
<LabVIEW>\vi.lib\NI Veristand\Custom Device Offline API\Custom Device Offline API.lvlib

 

The VI you're looking for would be "ID to BaseNode.vi".

 

In my previous message, I mentioned the method in the "Utilities" class.  There are actually some issues with this, so instead, a better method to use would be DeleteChannelMappings(string[] channelPathDestinations) in the Root class.  There are also methods in this class to get a list of mappings, add new mappings, and to clear all mappings.

 

In the example below I navigate to the channel I want to unmap, get the SystemDefinition API reference, gets its path, then get a reference to the Root of the System Definition (the base node in the tree) and delete any mapping to this channel.

0 Kudos
Message 7 of 10
(8,190 Views)

Devin K,

 

Thanks!

 

I used your first solution (RemoveProperty) and it seems to work great.

 

I didn't implement the second solution with the System Definition API just because I had something working and didn't want to break it.  However, now that I look at it more closely, I wonder, would it work on an RT system? (since it's the offline API)

 

Again, thanks a million!  It's working great now!

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 8 of 10
(8,182 Views)

No problem!

 

All of the APIs are .NET and are therefore not supported on RT.  But, even if that wasn't the case, channel mappings are all done at configuration-time and can't be modified at runtime.  Once the System Definition is compiled for deployment, it can't be changed.

0 Kudos
Message 9 of 10
(8,178 Views)

Wow, this is what I get for posting while on a conference call!

 

Yes, I am doing all of this on the Windows configuration side, so my previous concerns are unwarranted and rather silly. Smiley Tongue

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 10 of 10
(8,176 Views)