Subscribing To Events; Connecting To A Dataman Device; Your Ethernet Device; Create A Connector To Your Device - Cognex DataMan Communications And Programming Manual

Hide thumbs Also See for DataMan:
Table of Contents

Advertisement

a. Create a new SerSystemDiscoverer.
SerSystemDiscoverer serSystemDiscoverer = new
SerSystemDiscoverer();
b. Subscribe to its SystemDiscovered event.
serSystemDiscoverer.SystemDiscovered += new
SerSystemDiscoverer.SystemDiscoveredHandler(OnSerSystemDiscovered);
c. Create event handler of type SerSystemDiscoverer.SystemDiscoveredHandler.
d. The event handler argument is a SerSystemDiscoverer.SystemInfo. These SystemInfo objects contain information
required for connecting to a reader. You can store these SystemInfo objects in your own collection.
e. To start device discovery, call the serSystemDiscoverer.Discover() method.
Note: The SystemDiscovered event will be fired every time a device is detected (either the device announced itself
after booting up or it responded to the Discover() method).

Subscribing to Events

If you want to react to result-like events in your application, you have to subscribe to the related events. There are also
some events related to connection state changes.
Here is an example where you subscribe for the events of read string and image arrival:
mySystem.XmlResultArrived += new XmlResultArrivedHandler(OnXmlResultArrived);
mySystem.ImageArrived += new ImageArrivedHandler(OnImageArrived);
Note: The order of the result components may not always be the same, so if it is important to synchronize them, use
the ResultCollector utility class provided via the DataManUtils component. (See details in section

Connecting to a DataMan Device

Your Ethernet device

Connect to your Ethernet device by performing the following steps:

1. Create a connector to your device:

EthSystemConnector myConn = new EthSystemConnector(deviceIP);
where deviceIp is either a known IP address or one that was discovered by an EthSystemDiscoverer.
2. Specify user name and password:
myConn.UserName = "admin";
myConn.Password = "password or empty string";
3. Create a new DataManSystem instance with the created connector:
DataManSystem mySystem = new DataManSystem(myConn);
4. Call the Connect() method of your DataManSystem instance:
mySystem.Connect();
5. (Optional) Verify if you are connected:
if (mySystem.IsConnected)
6. To disconnect, call
DataMan Application Development
22
Helper
Utilities).

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DataMan and is the answer not in the manual?

Table of Contents

Save PDF