Discovery domain
Overview
To create a connection to the controller from a PC SDK application it has to make use of the Netscan functionality of the Discovery
namespace. A NetworkScanner object must be created and a scan call must be performed.
For the PC SDK to establish a connection either RobotStudio or Robot Communications Runtime must be installed on the PC hosting the PC SDK application. Robot Communications Runtime can be installed from <PCSDK>\Redistributable\RobotCommunicationRuntime, if RobotStudio is not installed.
To find out what controllers are available on the network you use the NetworkScanner methods Scan, Find, GetControllers and
GetRemoteControllers.
NetworkScanner
The NetworkScanner class can be declared and represented at class level. No scanning is done until the Scan method is called.
When the GetControllers method is called a collection of ControllerInfo objects is returned. Each such object holds information
about a particular controller connected to the local network. Both virtual and real controllers are detected this way.
private NetworkScanner aScanner = new NetworkScanner();
...
// Somewhere in the code
aScanner.Scan();
ControllerInfo[] aCollection = aScanner.GetControllers();
For a complete code sample, see Implement network scanning.
If only real controllers are of interest, you can first scan the network and then request only real controllers using the
NetworkScannerSearchCriterias enumeration in the GetControllers method.
ControllerInfo[] aCollection = aScanner.GetControllers(NetworkScannerSearchCriterias.Real);
If you know which controller system you want to connect to, you can call the Find method, which finds a specified controller
on the network. It takes the system ID as a System.Guid data type as argument. The system’s globally unique identifier (GUID)
can be found in the system.guid file in the INTERNAL folder of the robot system file system.
ControllerInfo object
When a network scan is performed a collection of ControllerInfo objects is returned. The ControllerInfo object has information
about availability. Remember that the ControllerInfo object is not updated when controller status changes. If you again need to
find out if a controller is available, you need to perform a new network scan or use an existing Controller object and check the
status directly.
Add controllers from outside local network
A network scan is done only on the local network. To detect controllers outside the local network you need to supply the IP address
of the controller using the static AddRemoteController method or configuring it in the App.config file. For more information,
see PC application configuration.
If you supply the controller IP address you either use a string argument or a System.Net.IPAddress object.
System.Net.IPAddress ipAddress;
try
{
ipAddress = System.Net.IPAddress.Parse(this.textBox1.Text);
NetworkScanner.AddRemoteController(ipAddress);
}
catch (FormatException ex)
{
this.textBox1.Text = "Wrong IP address format";
}
NetworkWatcher
By using a NetworkWatcher object you can supervise network changes and find out when a new controller is found or when a
controller is lost. For a complete code example,
see Add a network watcher.