Overview, Common definitions, Copenldvapi and copenldvtrace – Echelon OpenLDV User Manual

Page 98: Copenldvni, message pumps, and message dispatchers

Advertising
background image

90

The OpenLDV Developer Example

Overview

The OpenLDV Developer Example is an example application that uses the

OpenLDV API. The example application is available from the Examples &

Tutorials folder in the Echelon OpenLDV 4.0 SDK program folder.
The example application is also installed as a ZIP file in the L

ON

W

ORKS

\OpenLDV SDK\SourceArchive folder on your computer. The ZIP file is

named LdvApiExamplesSource_vn.nn.nnn.ZIP, where the n.nn.nnn

represents the version and build number for the OpenLDV release.
The OpenLDV Developer Example is a simple dialog-based Windows application

written in C++ with Microsoft Foundation Classes (MFC). It is distributed in

Microsoft Visual Studio 2008 project format. The example illustrates how a

Windows application can access the OpenLDV API, and demonstrates a wide

range of simple to complex network operations.
The example application contains comments that should assist you when

reviewing the code. This chapter describes the structure of the example

application and the different classes that it contains.

Common Definitions

The OpenLDV API functions are specified in the ldv32.h header file. The

OpenLDV Developer Example provides additional definitions of constants,

enumerations, and aggregated types in the OpenLDVdefinitions.h header file.

These definitions are used throughout the remainder of the example application.

COpenLDVapi and COpenLDVtrace

The example application implements a COpenLDVapi class to wrap the

OpenLDV API functions. The COpenLDVapi class provides a simple interface

through four methods: Open, Close, Read, and Write.
This class provides thread-safe, synchronized, access to downlink messages

(ldv_write()), and implements a reader thread COpenLDVreader, which reads

uplink messages (ldv_read()) and supplies data to a protected queue. The

COpenLDVapi::Read() function reads that queue, thereby providing

coordinated access to both uplink and downlink messages.
The example application also implements a COpenLDVtrace class. This class

illustrates how an OpenLDV application can provide hooks for debugging or

tracing into the low-level portion of the OpenLDV application. The example

implementation provides a packet dump of all incoming and outgoing packets.
The related header files, OpenLDVapi.h and OpenLDVtrace.h, contain details

about these classes and their usage.

COpenLDVni, Message Pumps, and Message

Dispatchers

The COpenLDVni class implements the core functions of a network interface

API. The functions included in this class are NiInit(), NiSendMsgWait(),

Advertising