public void Restore() { if ((DevicePort != null) && isConnected) { foreach (NetworkPort partnerPort in PartnerPorts) { try { DevicePort.ConnectToPort(partnerPort); } catch { } } } }
//Set Topology private void SetTopology(Device device, List <NetworkPort> networkPorts) { int i = 0; foreach (DeviceItem deviceItem in device.DeviceItems[1].DeviceItems) { if (deviceItem.Name.Contains("PROFINET")) { foreach (DeviceItem port in deviceItem.DeviceItems) { NetworkPort networkPort = port.GetService <NetworkPort>(); if (networkPorts[i] != null) { networkPort.ConnectToPort(networkPorts[i]); } i++; } } } }