![Pepperl+Fuchs SmartRunner Explorer Manual Download Page 44](http://html1.mh-extra.com/html/pepperl-fuchs/smartrunner-explorer/smartrunner-explorer_manual_1527552044.webp)
2
0
2
2
-0
2
42
Configuration
Example Program
The example program "ExampleSr2D.cs" is located in the "VSX-Interface libraries..." package.
It is intended to make the initial steps of integrating the SmartRunner Explorer easier. The fol-
lowing steps are performed in this example program:
•
TCP/IP connection
•
Command to start permanent trigger
•
Line data is saved in a container with each trigger
•
A specific number (number must be determined) of containers can be stored temporarily
in the API
•
Retrieve line data from container (polling)
•
Example access for line data
Examples of Using the Programming Interface
1. Establishing the TCP/IP Connection
First, all available devices are listed via UDP and an attempt is made to connect to the first
device. If no device was found via UDP, an attempt is made to establish a connection via a fixed
IP address (in this case the default IP).
//First discover devices via UDP and use the IP of the first device found
var sensors = await VsxProtocolDriver.UdpDeviceList();
if (sensors.Succ && sensors.DeviceList.Count > 0)
{
// create a new VsxProtocolDriver instance
_vsxProtocolDriver = VsxProtocolDriver.Init(sen-
sors.DeviceList[0].IpAddress);
}
else //use fixed IP address
{
// create a new VsxProtocolDriver instance with fixed IP address
_vsxProtocolDriver = VsxProtocolDriver.Init("192.168.2.3");
}
// Connect with device
var connRes =await_vsxProtocolDriver.Connect();