VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Refresh Custom Device Channels instead of deleting device

Solved!
Go to solution

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.

 

 

0 Kudos
Message 1 of 11
(8,054 Views)
Solution
Accepted by MPCC

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>

 

Message 2 of 11
(8,051 Views)

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

0 Kudos
Message 3 of 11
(7,981 Views)

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

 

onload.png

 

 

 

 

 


 

        <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>

 

Message 4 of 11
(7,964 Views)

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.

0 Kudos
Message 5 of 11
(7,956 Views)

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!

0 Kudos
Message 6 of 11
(7,891 Views)

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?

 



0 Kudos
Message 7 of 11
(7,854 Views)

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?

0 Kudos
Message 8 of 11
(7,852 Views)

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.

0 Kudos
Message 9 of 11
(7,844 Views)

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.

0 Kudos
Message 10 of 11
(7,825 Views)