Below example can be found under the SPM application directory
..\Pickering Interfaces Ltd\Switch Path Manager\.NET
using System;
using Pickering.SPM.Client;
namespace Tutorial_.NET_Example
{
internal class Program
{
[STAThread]
private static void Main()
{
bool hwExists = false; // select whether the system should boot online or offline
bool showIDE = true; // opens or closes the IDE window
bool stopServer = false; // if true then the SPM server wil be stopped and removed from memeory (if started from this application)
String ProjectPath = @"C:\Users\Public\Documents\Pickering Interfaces Ltd\Switch Path Manager\Projects\Tutorial\Tutorial.switchproj";
// First get the instance of the server access object:
var spm = ServerPortal.Instance;
try
{
// Starts the SPM Server.
spm.Start();
// Connects to the SPM Server. This has to be done first to be able to use other API methods.
spm.Connect();
if (showIDE)
spm.Application.ShowMainWindow();
else
spm.Application.CloseMainWindow();
if (spm.Project.GetIsOpen())
spm.Project.Close();
// Opens a SPM Project from the specified file path.
spm.Project.Open(ProjectPath);
// Boots the Test System with the active System Setup into Driver Online State.
// This initializes all Device Drivers. This requires the System Hardware to be connected to the computer and be powered on.
if (hwExists)
spm.System.BootOnline();
else
spm.System.BootOffline();
// Resets all switching modules to their initial state.
// If the Test System is booted in Online Mode this will be applied to the hardware.
spm.System.ResetFull();
Console.WriteLine("Launch the SPM Soft Front Panel and press the Get Relay Status button\n\n Press any key to continue...");
Console.ReadKey();
// based on the Tutorial Program the following scenario takes place
// SCENARIO WITH CONTROLLED Y-BUS USE
// 1. Connect Power Supply to PS+/PS-
spm.Switching.ConnectEndpoints("bus2", new[] {"PS+", "UUT_PS+"}); // controlled route via bus2
spm.Switching.ConnectEndpoints("bus3", new[] {"GND", "UUT_PS-"}); // controlled route via bus3
// 2. Pull Down CTRL Pin (GND)
spm.Switching.ConnectEndpoints("bus3", new[] {"GND", "UUT_PS-", "CTRL"}); // controlled route via bus3
// 3. Connect and Measure UUT1/UUT2 with Scope at the same time using ch1, ch2
spm.Switching.ConnectEndpoints("UUT1", "ScopeCH1");
spm.Switching.ConnectEndpoints("UUT2", "ScopeCH2");
// MEASURE HERE
spm.Switching.DisconnectEndpoints("UUT1", "ScopeCH1");
spm.Switching.DisconnectEndpoints("UUT2", "ScopeCH2");
// 4. Pull Up CTRL Pin (PS+)
spm.Switching.DisconnectEndpoints("bus3", "CTRL"); // controlled route via bus3
spm.Switching.DisconnectEndpoints("bus2", new[]{"PS+", "UUT_PS+"}); // controlled route via bus2
// 5. Connect and Measure UUT3/UUT4 with Scope at the same time using ch1, ch2
spm.Switching.DisconnectEndpoints("UUT3", "ScopeCH1");
spm.Switching.DisconnectEndpoints("UUT4", "ScopeCH2");
// MEASURE HERE
// 6. Disconnect All
spm.Switching.DisconnectAll();
// based on the Tutorial Program the following scenario takes place
// SCENARIO WITH UNCONTROLLED USE OF Y-BUS (auto selection of Y1 and Y2 for the first 2 routes)
// 1. Connect Power Supply to PS+/PS-
spm.Switching.ConnectEndpoints("PS+", "UUT_PS+");
spm.Switching.ConnectEndpoints("GND", "UUT_PS-");
// 2. Pull Down CTRL Pin (GND)
spm.Switching.ConnectEndpoints("GND", new[] {"UUT_PS-", "CTRL"});
// 3. Connect and Measure UUT1/UUT2 with Scope at the same time using ch1, ch2
spm.Switching.ConnectEndpoints("UUT1", "ScopeCH1");
spm.Switching.ConnectEndpoints("UUT2", "ScopeCH2");
// MEASURE HERE
spm.Switching.DisconnectEndpoints("UUT1", "ScopeCH1");
spm.Switching.DisconnectEndpoints("UUT2", "ScopeCH2");
// 4. Pull Up CTRL Pin (PS+)
spm.Switching.DisconnectEndpoints("GND", "CTRL");
spm.Switching.ConnectEndpoints("PS+", new []{"UUT_PS+", "CTRL"});
// 5. Connect and Measure UUT3/UUT4 with Scope at the same time using ch1, ch2
spm.Switching.ConnectEndpoints("UUT3", "ScopeCH1");
spm.Switching.ConnectEndpoints("UUT4", "ScopeCH2");
// MEASURE HERE
}
catch (ServerException ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
// Stops the SPM Server, if no other clients are connected.
if (stopServer)
spm.Stop();
Console.WriteLine("Press any key to end the program");
Console.ReadKey();
}
}
}
}
Copyright © 2014-2024 Pickering Interfaces