VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically Adding Service to Project

I have a custom device that has an accompanying VeriStand service.  I would love to be able to automatically add the service to the owning VeriStand project when the custom device is added to the system definition.

 

I realize that a system definition could theoretically be "owned" by more than 1 project, but that will not be the case for me.  I've been exploring the VeriStand .NET API, but haven't found the connecting pieces that I need.

 

  • Is there a way to get a reference to the current project from the configuration code of a custom device?
  • Is it possible to add a service to a VeriStand project through the .NET API?

Thank you,

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 1 of 9
(5,974 Views)

Hey Chris,

 

I can certainly see how this functionality would be useful, but unfortunately there is not currently an easy way to accomplish this with either the LabVIEW or .NET API. 

 

I spoke with some of my colleagues in R&D about this as well, and the consensus is that while this is probably technically possible it will likely involve a time consuming custom solution.

 

If you want to give us a little more information about why you're trying to do this (running code on the host alongside the custom device?) we might be able to make some other suggestions.

 

Best,

 

Andy C.

Applications Engineer

 

0 Kudos
Message 2 of 9
(5,950 Views)

Andy,

 

Thanks for the response.  Unfortunately, I suspected as much . . . 

 

I have a custom device that has a very non-intuitive channel API.  So I developed a Workspace Tool that has a more friendly interface and then communicates through the channel interface in a coordinated fashion.  I'd like this tool to appear anytime that the system is deployed (hence, why I turned it into a service).

 

The thing is that the tool is obviously not valid if the custom device does not exist and adding tools to a VeriStand project is far less intuitive than adding a custom device, which is why I was hoping to add it automatically.

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 3 of 9
(5,945 Views)

So indeed there are quite a few tricks to play around with.

 

  1. First we have to choose the right moment to add the service to the project. I suggest you add an ActionVI "On Shutdown" that will only trigger when your CD is present, upon closing the System Explorer. This ActionVI shall programmatically add you Service VI to the project owned by the SDF.
  2. Find the nivsproj file associated to the SDF. This could be done with the .NET call Factory.GetAllActiveProjects() (Client API assembly)
  3. There comes the unsupported and undocumented part. You can browse the nivsproj and thus edit it programmatically through the DocumentType class from the SystemStorage assembly. The attached code shows you that trick.
  4. Now your service is added to the nivsproj, but thing is your nivsproj loaded in NIVS can't automatically update. You need to close and reopen it thanks to the Project API.
  5. Once it reopens, you an check your service has been added.

 

Enjoy

--Eric

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

Message 4 of 9
(5,930 Views)

Awesome, thanks Eric!

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 5 of 9
(5,912 Views)

Hello Eric,

 

Thanks a lot for your idea and the code. I was able to add the service into the project. But the restarting part is not working. I am attaching my restart project vi, which I am calling asynchronously ( call and forget) from Actiononshutdown.vi. It is closing the veristand project but not reopening.

 

Again thanks for your great idea Smiley Happy

 

Regards,

Rajesh Raghavan Nair

Certified LabVIEW Architect
Certified Teststand Architect
0 Kudos
Message 6 of 9
(3,575 Views)

Hi Rajesh,

 

The code should work just fine. Have you tried it alone? Or as a static subVI?

I'm not 100% sure about what is going on, but I would not call async VIs from the OnShutdown action VI because the System Explorer process would stop before the async VI possibly finishes (in your case, you have enough time to close the project but not enough to reopen it).

 

--Eric

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

0 Kudos
Message 7 of 9
(3,552 Views)

Hello Eric,

 

Thanks for the reply. As a static VI its working. But when system explorer is open it is waiting in the close function for the closure of system explorer, that's why I tried to call this as Async. I increased the delay for opening the project but its not helping, its displaying the pop-up "Resetting the VI" and its getting stuck.

 

Regards,

Rajesh Raghavan Nair

Certified LabVIEW Architect
Certified Teststand Architect
0 Kudos
Message 8 of 9
(3,547 Views)

Hello Eric,

 

One more question, do you have any service template for configuring the service in sync? I need to deploy my custom device after my services is UP. Do you have any idea how we can do that?

 

Thanks & Regards,

Rajesh Raghavan Nair

Certified LabVIEW Architect
Certified Teststand Architect
0 Kudos
Message 9 of 9
(3,546 Views)