NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a Configuration Entry Point from a C# code module

Hi,

 

Is it possible to call a configuration entry point from a C# code module?

 

I have a custom process model which creates some configuration entry points.

One of the entry points, calls a C# method in a code module to display a Startup screen for the operator.

In an Editor User Interface, I have added a toolbar, now I want to execute the previous entry point initiated from my C# code to get the Startup screen again when a button is clicked on the toolbar.

 

Best regards

0 Kudos
Message 1 of 7
(3,666 Views)

I haven't tried it, but the following might work:

 

applicationMgr.GetCommand(CommandKind_ConfigurationEntryPoints_Set, indexOfYourEntryPointInTheListOfConfigurationEntryPointsInYourModel).Execute(true);

 

 

0 Kudos
Message 2 of 7
(3,660 Views)

Thanks a lot James,

 

It works great!

0 Kudos
Message 3 of 7
(3,656 Views)

Hi James,

 

Is it also possible to call a configuration entry point from a C# code module instantiated from the sequence editor? (Not a User interface)

 

I have a custom process model which creates some configuration entry points.

One of the entry points, calls a C# method in a code module to display a Startup screen for the operator.

I have added a separate windows form with a toolbar that becomes visible after constructing my C# class.

This toolbar contains a button to display my StartUp form. When clicked on this button, I want to execute the previous entry point again to get the Startup screen again.

  

Best regards

0 Kudos
Message 4 of 7
(3,630 Views)

Sure, use the same code.

 

To get the ApplicationMgr, pass the Engine to your code module (or reinstantiate it, it is a process singleton) and call Engine.GetInternalOption(InternalOption_ApplicationManager).

0 Kudos
Message 5 of 7
(3,627 Views)

Hi James,

 

Thanks for your suggestion, but unfortunely the code hangs after executing the entrypoint, if have tried it in two ways, but both have the same result. Do you have any idea how to fix this.

 

Trial 1:

 

  Engine engine = new Engine();

ApplicationMgr applicationMgr = (ApplicationMgr)engine.GetInternalOption(InternalOptions.InternalOption_ApplicationManager);

EntryPoints entryPoints = applicationMgr.ConfigurationEntryPoints;

int intIndex = 0;

foreach (EntryPoint entryPoint in entryPoints)

{

    switch (entryPoint.Name.ToUpper())

   {

        case "TOGGLE ONLINE <-> OFFLINE":

           object objEditArgs = System.Type.Missing;           entryPoint.Run(objEditArgs); // Application hangs after executing this command, the entrypoint does not execute!

            break;

        default:            break;

    }

     intIndex++;

}

 

Trial 2:

 

  Engine engine = new Engine();

ApplicationMgr applicationMgr = (ApplicationMgr)engine.GetInternalOption(InternalOptions.InternalOption_ApplicationManager);

EntryPoints entryPoints = applicationMgr.ConfigurationEntryPoints;

int intIndex = 0;

foreach (EntryPoint entryPoint in entryPoints)

{

    switch (entryPoint.Name.ToUpper())

   {

        case "TOGGLE ONLINE <-> OFFLINE":

           // Application hangs after executing next command, the entrypoint does not execute!

           applicationMgr.GetCommand(CommandKinds.CommandKind_ConfigurationEntryPoints_Set, intIndex).Execute(true);

             break;

        default:            break;

    }

     intIndex++;

}

 

Best regards

0 Kudos
Message 6 of 7
(3,607 Views)

I'm not sure. I tried it both from a sequence and from a .net module (pretty much the same way as you) and both worked fine for me.

 

If you could create a simple project that reproduces the problem and submit it to tech support, they can debug the issue.

 

One question, how are you calling the module? I tried calling it from a .net step in a sequence.

0 Kudos
Message 7 of 7
(3,586 Views)