System MarshalByRefObject
Cognex.VisionPro.Implementation CogObjectBase
Cognex.VisionPro.Implementation CogChangedEventBase
Cognex.VisionPro.Comm CogEthernetPortSettings
Namespace: Cognex.VisionPro.Comm
Assembly: Cognex.VisionPro.Comm (in Cognex.VisionPro.Comm.dll) Version: 65.1.0.0
The CogEthernetPortSettings type exposes the following members.
| Name | Description | |
|---|---|---|
| CogEthernetPortSettings |
| Name | Description | |
|---|---|---|
| CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | |
| Equals | (Inherited from Object.) | |
| Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
| GetAttributes |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetClassName |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetComponentName |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetConverter |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetDefaultEvent |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetDefaultProperty |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEditor |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEvents |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEvents( Attribute ) |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
| GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
| GetProperties |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetProperties( Attribute ) |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetPropertyOwner |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) | |
| OnChanged(Int64) |
This method should be called internally whenever the object's state may
have changed.
(Inherited from CogChangedEventBase.) | |
| OnChanged(CogChangedEventArgs) |
This method may be called internally whenever a derived object's state
may have changed and the derived object expresses this change via a
derived CogChangedEventArgs class.
(Inherited from CogChangedEventBase.) | |
| ResumeAndRaiseChangedEvent |
Re-enables raising of the Changed event after SuspendChangedEvent
has been called, and raises the Changed event if the
ChangedEventSuspended count is reduced to zero and any changes were
made while events were suspended. Must be called once for each call to
SuspendChangedEvent.
(Inherited from CogChangedEventBase.) | |
| SuspendChangedEvent |
Temporarily suspends the raising of the Changed event. May be called
more than once, and a corresponding call to ResumeAndRaiseChangedEvent
must be made for each call to SuspendChangedEvent.
(Inherited from CogChangedEventBase.) | |
| ToString | (Inherited from Object.) |
| Name | Description | |
|---|---|---|
| SfDefaultGateway |
This bit will be set in the EventArgs of a Changed event every time the
value returned by DefaultGateway may have changed.
| |
| SfDHCPEnable |
This bit will be set in the EventArgs of a Changed event every time the
value returned by DHCPEnable may have changed.
| |
| SfDomainName |
This bit will be set in the EventArgs of a Changed event every time the
value returned by DomainName may have changed.
| |
| SfHostName |
This bit will be set in the EventArgs of a Changed event every time the
value returned by HostName may have changed.
| |
| SfIPAddress |
This bit will be set in the EventArgs of a Changed event every time the
value returned by IPAddress may have changed.
| |
| SfNextSf | ||
| SfSubnetMask |
This bit will be set in the EventArgs of a Changed event every time the
value returned by SubnetMask may have changed.
|
| Name | Description | |
|---|---|---|
| ChangedEventSuspended |
If nonzero, indicates that the raising of the Changed event has been
suspended. This value is incremented when SuspendChangedEvent is called
and decremented when ResumeAndRaiseChangedEvent is called.
(Inherited from CogChangedEventBase.) | |
| DefaultGateway |
Gets or sets the default gateway of the Ethernet port.
Attempts to set this property are ignored when DHCPEnable is true. | |
| DHCPEnable |
Gets or sets whether DHCP is enabled for the Ethernet port.
| |
| DomainName |
Gets or sets the domain name.
| |
| HostName |
Gets or sets the host name.
| |
| IPAddress |
Gets or sets the IP address of the Ethernet port.
Attempts to set this property are ignored when DHCPEnable is true. | |
| StateFlags |
Returns the complete set of state flags supported on this object. The
flags may be indexed by name as shown in the following C# code snippet:
if (changedObject.StateFlags["Color"] & eventArgs.StateFlags) { ... }
(Inherited from CogChangedEventBase.) | |
| SubnetMask |
Gets or sets the subnet mask of the Ethernet port.
Attempts to set this property are ignored when DHCPEnable is true. |
| Name | Description | |
|---|---|---|
| Changed |
This event is raised when one or more parts of the object's state may
have changed.
(Inherited from CogChangedEventBase.) |
Ethernet settings are written to the Comm Card using WriteSettings . These settings are stored in flash memory directly on the Comm Card.
When a VisionPro application first connects to a Comm Card, the Comm Card automatically attempts to bring the Ethernet port interface "UP" using the stored settings. Later, when the VisionPro application exits, the Comm Card will automatically bring the Interface "DOWN", removing the card from the network.
Both the Link (physical connection present) and the Interface (IP settings activated) need to be in the "UP" state for the Ethernet port to participate in an IP network. When the link or interface is "DOWN", the Ethernet port cannot communicate over an IP network.
Use IsLinkUp to see if the Link is in the "UP" state. When the Link is up, the Ethenet port is physically connected to a network and can physically transmit and receive data.
Use IsInterfaceUp to see if the Interface is in the "UP" state. When the Interface is up, the Ethernet port has been activated with IP network settings and can participate in an IP network.
Use WriteSettings and ReadSettings to read and write network settings to the Comm Card.
Use BringInterfaceUpAsync and BringInterfaceDownAsync to manually bring the interface "UP" and "DOWN" using the settings stored on the Card.
Use ReadActiveSettings to read the currently active settings while the Interface is "UP". The currently active settings may be different from the settings stored on the card in cases where the card is configured for DHCP, or if something (i.e. PROFINET) changes the active settings without also writing them to the storage location on the card.
Note that CogEthernetPort does not have exclusive control over the Ethernet port hardware. The Ethernet port interface may already be "UP" when a CogEthernetPort is created. Furthermore, the state of the Ethernet interface may report changes and events that were _not_ initiated from user calls into its own properties and methods.
Note also that the lifetime of this object is not related to the state ("UP" or "DOWN") of the Ethernet port interface. Disposing the CogEthernetPort object will not affect the state of actual Ethernet settings running on the card (even though exiting the _process_ will bring the network interface "DOWN").
using Cognex.VisionPro; using Cognex.VisionPro.Comm; // Change the IP address on a Comm Card Ethernet port. public void ChangeIPAddress( string newAddress, string newSubnet, string newDefaultGateway) { CogCommCards commCardCollection = new CogCommCards(); Console.WriteLine("Found: {0} Comm Cards", commCardCollection.Count); if (commCardCollection.Count == 0) return; // Get a reference to the the comm card object. CogCommCard card = commCardCollection[0]; Console.WriteLine("Name: {0}", card.Name); Console.WriteLine("Serial: {0}", card.SerialNumber); Console.WriteLine("NumEthernetPorts: {0}", card.EthernetPortAccess.NumPorts); if (card.EthernetPortAccess.NumPorts == 0) return; // Create a software object to interact with Ethernet port. CogEthernetPort etherPort = card.EthernetPortAccess.CreateEthernetPort(0); Console.WriteLine("Current Ethernet Port Settings:"); Console.WriteLine(" link up: {0}", etherPort.IsLinkUp); Console.WriteLine(" iface up: {0}", etherPort.IsInterfaceUp); // Read the persistant settings from the Comm Card. CogEthernetPortSettings settings = etherPort.ReadSettings(); Console.WriteLine(" ip: {0}", settings.IPAddress); Console.WriteLine(" subnet: {0}", settings.SubnetMask); Console.WriteLine(" default gateway: {0}", settings.DefaultGateway); Console.WriteLine(" host name: {0}", settings.HostName); Console.WriteLine(" domain name: {0}", settings.DomainName); Console.WriteLine(" dhcpEnable: {0}", settings.DHCPEnable); if (etherPort.IsInterfaceUp) { Console.WriteLine("Bringing Interface DOWN..."); bool timedOut = !etherPort.BringInterfaceDownAsync().Wait(2000); if (timedOut) { Console.WriteLine("Bringing Interface Down TIMED OUT!!"); return; } Console.WriteLine("The Interface is DOWN."); } Console.WriteLine("Writing new IP address to Comm Card."); // Change the settings to the new ip address. settings.IPAddress = IPAddress.Parse(newAddress); settings.SubnetMask = IPAddress.Parse(newSubnet); settings.DefaultGateway = IPAddress.Parse(newDefaultGateway); settings.HostName = "hostname"; settings.DomainName = ""; settings.DHCPEnable = false; // Write the new settings to the card. etherPort.WriteSettings(settings); // Bring up the interface with the new IP address. if (!etherPort.IsInterfaceUp) { Console.WriteLine("Bringing Interface UP..."); bool timedOut = !etherPort.BringInterfaceUpAsync().Wait(2000); if (timedOut) { Console.WriteLine("Bringing Interface UP TIMED OUT!!"); return; } Console.WriteLine("The Interface is UP."); } Console.WriteLine("New Ethernet Port Settings:"); Console.WriteLine(" link up: {0}", etherPort.IsLinkUp); Console.WriteLine(" iface up: {0}", etherPort.IsInterfaceUp); // Read the current settings from the Comm Card. settings = etherPort.ReadActiveSettings(); Console.WriteLine(" ip: {0}", settings.IPAddress); Console.WriteLine(" subnet: {0}", settings.SubnetMask); Console.WriteLine(" default gateway: {0}", settings.DefaultGateway); Console.WriteLine(" host name: {0}", settings.HostName); Console.WriteLine(" domain name: {0}", settings.DomainName); Console.WriteLine(" dhcpEnable: {0}", settings.DHCPEnable); } ------ Output ------ Found: 1 Comm Cards Name: Cognex Communications Card 24C Serial: 1A1410XN002183 NumEthernetPorts: 1 Current Ethernet Port Settings: link up: False iface up: True ip: 192.168.1.42 subnet: 255.255.0.0 default gateway: 192.168.1.3 host name: HostName domain name: dhcpEnable: False Bringing Interface DOWN... The Interface is DOWN. Writing new IP address to Comm Card. Bringing Interface UP... The Interface is UP. New Ethernet Port Settings: link up: False iface up: True ip: 192.168.1.100 subnet: 255.255.255.255 default gateway: 192.168.1.1 host name: hostname domain name: dhcpEnable: False