06-20-2012 07:59 AM
One of the big pains that I have encountered is when you change IO on a custom device, you have to delete and re-add the custom device to a Veristand Project to get the new channels in the project. This destroys all channel linking and creates great pains when changing large channel count custom devices.
I've created a good work around. I create a VI that scans the current channels in the Veristand Project against the channel list in the compiled custom device. I then delete the items that don't belong and add the channels that don't exist. The net result is that only the channels that are removed create bad links (obviously) and all old links stay in tact.
I then create a right click menu on the main page of the custom device that executes the VI I have created.
The end result is a refresh function that works exactly like the 'Refresh' button on a model.
Solved! Go to Solution.
06-20-2012 08:17 AM
I attached the code snippet as an attachment because it wouldn't fit in a message
Here is the xml portion
<Page> <Name> <eng>Lambda Genesys Power Supply</eng> <loc>Lambda Genesys Power Supply</loc> </Name> <GUID>cfbe9b2f-9a5f-4094-9071-559baab0f5b2</GUID> <Glyph> <Type>To Application Data Dir</Type> <Path>System Explorer\Glyphs\Lambda.png</Path> </Glyph> <Item2Launch> <Type>To Common Doc Dir</Type> <Path>Custom Devices\Lambda Genesys Power Supply\Lambda Genesys Power Supply Configuration.llb\Lambda Genesys Power Supply Main Page.vi</Path> </Item2Launch> <RunTimeMenu> <MenuItem> <GUID>183aa855-54a1-44dd-8579-4042fa0d765d</GUID> <Type>Action</Type> <Name> <eng>Refresh Custom Device</eng> <loc>Refresh Custom Device</loc> </Name> <Item2Launch> <Type>To Common Doc Dir</Type> <Path>Custom Devices\Lambda Genesys Power Supply\Reload Channels.vi</Path> </Item2Launch> </MenuItem> </RunTimeMenu> </Page>
07-16-2012 04:30 AM
Hi, MPCC.
I have the same issue and your solution is fantastic, but I have one question. Can it be included in existing custom devices? or only in news? I have a very large project with custom devices already compiled and I need to update them. So, do you know how to include in the existing ones?
Can you upload an example?
Thanks in advance.
Miguel
07-16-2012 11:03 AM - edited 07-16-2012 11:06 AM
One other things you can do to make this process more automatic is to use an "On Load" action VI. I use this approach to add mutation code to convert custom devices between versions. For example, in my Scan Engine and EtherCAT custom device, I added some extra status channels in my 3.4 version. To accomodate users which have a system definition file with an older version of the custom device, I added an OnLoad action to the main page to automatically add the new channels to their system definition file. If I have additional changes in future versions, I can just add a new case to this VI. The nice thing about this approach is that it will run any necessary upgrades in order, so that you can correctly upgrade any older version of the custom device.
In order to use this approach, you will need to increment the <Version> tag in the custom device xml whenever you make changes to it (you should be doing this anyway). I have attached a screenshot of my code and the relevent XML, but if you want to check it out further, you can download the source code for the custom device at the link above.
Hope this helps!
Devin
<Page>
<Name>
<eng>Scan Engine and EtherCAT</eng>
<loc>Scan Engine and EtherCAT</loc>
</Name>
<DisallowRenaming>true</DisallowRenaming>
<GUID>A04A67D4-9B64-052B-A031-6B05377B9B10</GUID>
<Glyph>
<Type>To Application Data Dir</Type>
<Path>System Explorer\Glyphs\network.png</Path>
</Glyph>
<Item2Launch>
<Type>To Common Doc Dir</Type>
<Path>Custom Devices\Scan Engine\Scan Engine - Configuration.llb\Scan Engine Main Page.vi</Path>
</Item2Launch>
<ActionVIOnLoad>
<Type>To Common Doc Dir</Type>
<Path>Custom Devices\Scan Engine\Scan Engine - Configuration.llb\Main - On Load.vi</Path>
</ActionVIOnLoad>
</Page>
07-16-2012 12:43 PM
Hi Devin_K.
Thanks for your answer but I'm having problems updating my custom devices. I have created them using the "Custom Device Template Tool.vi" provided by NI and adding my code, so I'm not very familiar including new vi's on my custom devices. I use to create a new "Asynchronous" device with Input and Output screen.
I can upload one of my custom devices. Can you help me to include this code on it? It would be fantastic because I don't know how to do it and I need to update a lot of devices. If you help me with one of them I'll be able to update the other ones by myself.
Thanks in advance.
Miguel.
07-25-2012 02:00 PM
OK SO I am having some issues now.
The VI that I built will delete non-existing channels and add the new ones.
However:
It doesn't restore correct order. SO your channels don't line up correctly.
I've tried a couple of new work-arounds to no avail.
I'm going to have to work out something better.
Sorry to those of you attempting to use this.
If anyone has a good solution - Please let me know!
07-27-2012 02:11 PM
Miguel,
Did you figure out how to include the code? It should be added on the main page of your custom device xml file. You'll only be adding this section:
<ActionVIOnLoad>
<Type>To Common Doc Dir</Type>
<Path>Custom Devices\Scan Engine\Scan Engine - Configuration.llb\Main - On Load.vi</Path>
</ActionVIOnLoad>
The rest of the code that Devin displays shows the context to place this portion of code in. This will cause it to load the VI everytime the custom device runs.
MPCC,
have you considered Devin's suggestion to create a VI to go through and update the channels every time the custom device is loaded and then keep track of the different versions?
07-27-2012 02:14 PM
I believe that Devon's method would suffer from the same problem.
His code would go through and delete or add the channels the same way. When you delete the channels, it destroys the linking and when you add the channels, it screws up the ordering.
Unless I am missing something - Am I?
07-27-2012 04:42 PM
Hi MPCC,
I'm a little confused by what you mean when you say "the channels don't line up correctly". Where is this order not showing up correctly? I assume you mean that when you get the channels in your RT code, the order is not what you expect?
If this is the problem, I'd say the best approach is to modify your RT code so that it doesn't rely on the order of the channels. In your code you can read info about the channels (name, GUID, properties...) which can help you determine what the channel is and what data it needs. If you're writing your custom device in such a way that your channels are frequently changing, it would make sense to write your RT code in such a way that it handles these changes.
Now, that being said, there is a method in the System Storage API which allows you to reorder the child nodes of a section. However, this API is not intended for public use, and is subject to change (or cease to exist) in the future, so I wouldn't rely on it. I think a better solution would be to move the logic into your RT code, as I described above.
07-30-2012 09:45 AM
I'm running as a custom Device inside of Veristand.
I don't have access to the RT, I just have custom device controls.
I'll try to describe what happens.
I have a device revision # 2.
It has 4 output channels: A,B,C,D
In rev three, I delete channel B and add channel X.
Now I recompile the device and run my update VI through the menu.
My VI deletes B and adds X to the veristand config. HOWEVER:
Now the data that was going to C is going to D and it cascades down.
The custom device is actually reporting data on the wrong channel.
When I delete the custom device and re-add it (Rebuilding all linking, aliases and calculated channels)
It works correctly.