You can find an example of using the OpenTAP API to build and run a test plan in the SDK Examples here:
Answer: to load a bench profile called “Profile2” and print out the list of configured instruments, the following code works (tested with OpenTAP 9.26.1)
OpenTap.PluginManager.SearchAsync();
// Set the Bench to Profile2
OpenTap.EngineSettings.SetSettingsProfile("Bench", "Profile2");
// Load the current instrument settings and print out a list of instruments that are configured in Profile2
var instrumentType = OpenTap.PluginManager.LocateType("OpenTap.InstrumentSettings");
OpenTap.InstrumentSettings instruments = OpenTap.EngineSettings.GetCurrent(instrumentType) as OpenTap.InstrumentSettings;
foreach (var instrument in instruments)
{
Console.WriteLine($"Instrument: {instrument.Name}, Type: {instrument.GetType().Name}");
}