14.08.2013 Views

snap ethernet-based i/o units protocols and programming guide

snap ethernet-based i/o units protocols and programming guide

snap ethernet-based i/o units protocols and programming guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 3: USING THE SNAP ETHERNET I/O DRIVER TOOLKIT<br />

OptoSnapIoMemMap Procedures<br />

Common procedures for using the OptoSnapIoMemMap C++ class in a program are:<br />

1. Add the class to a program by adding the O22SIOMM.cpp <strong>and</strong> O22SIOUT.cpp files <strong>and</strong><br />

including the file O22SIOMM.h for the class definition.<br />

2. Either statically or dynamically create an instance of the class.<br />

3. Open a connection to a brain.<br />

4. Use the public member functions of the class to communicate with the connected brain <strong>and</strong><br />

check for errors.<br />

5. When done, disconnect from the brain.<br />

6. If the instance was created dynamically in step 1, destroy it.<br />

See “MemMap Example Code” on page 55 for examples of these procedures in Visual Basic.<br />

O22SnapIoStream Procedures<br />

Common procedures for using the OptoSnapIoStream C++ class in a program are:<br />

1. Add the class to a program by adding the O22SIOST.cpp <strong>and</strong> O22SIOUT.cpp files <strong>and</strong><br />

including the file O22SIOST.h for the class definition.<br />

2. Create an instance of the O22SnapIoStream class.<br />

3. Call SetCallbackFuntions() to initialize several callback functions.<br />

4. Call OpenStreaming() to initialize the stream type, length, <strong>and</strong> port.<br />

5. Call StartStreamListening() for each I/O unit.<br />

A new thread is created to listen for incoming UDP packets. Every time a stream packet<br />

from a registered I/O unit is received, the Stream Event callback function will be called.<br />

6. Depending on the type set in step #3, call the function GetLastStreamSt<strong>and</strong>ardBlockEx() or<br />

GetLastStreamCustomBlockEx() every time this Stream Event is called.<br />

7. To stop listening for a specified I/O unit, call StopStreamListening() at any time.<br />

8. To add I/O <strong>units</strong>, call StartStreamListening() at any time.<br />

9. When done, call CloseStreaming()<br />

SNAP Ethernet-Based I/O Units Protocols <strong>and</strong> Programming Guide 51

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!