Step 4. stop communication, Step 5. close objects, Multiple applications on the same interface – National Instruments NI-DNET User Manual

Page 29: Multiple applications on the same interface -10

Advertising
background image

Chapter 3

Developing Your Application

NI-DNET User Manual

3-10

ni.com

Step 4. Stop Communication

Before you exit your application, stop communication to shut down
DeviceNet connections to remote devices. Use the Interface Object to
call the

ncOperateDnetIntf

function with the

Opcode

parameter set

to

Stop

.

Step 5. Close Objects

Before you exit your application, close all NI-DNET objects using the

ncCloseObject

function.

Multiple Applications on the Same Interface

The NI-DNET software allows multiple NI-DNET applications to use the
same interface object simultaneously, as long as the interface configuration
remains the same. For example, you can run both the

SingleDevice

example and SimpleWho on DNET0 as long as the

Interface MacId

,

BaudRate

, and

PollMode

parameters are the same in both applications

(SimpleWho uses a

PollMode

of

Scanned

). Similarly, you can open up

two copies of the

SingleDevice

example and communicate with two

different devices as if it were through a single application. These same rules
apply to the I/O Object and the Explicit Messaging Object.

As long as all the configuration attributes are the same, any object can be
opened multiple times. You can enable only one notification or wait
(through

ncWaitForState

,

ncCreateNotification

, or

ncCreateOccurrence

functions) for an object, no matter how many

handles you have opened for that particular object. For example, if you are
running two copies of the

SingleDevice

example on the same interface

with the same connection types, the notification triggers in only one
application at a time.

The synchronization of events and the protection of the object I/O data is
the responsibility of the application developer. Similarly, the application
performance might change based on the number of objects open and the
frequency of API calls made in each application. For example, several calls
to

ncGetDnetAttribute

in one application might slow down another

application running on the same interface.

To ensure proper clean up of all the objects, each open call to an object
should be matched by a close call to the same object, and each call to

ncOperateDnetIntf

with

NC_OP_START

code should be matched by

a call to the same function with

NC_OP_STOP

code.

Advertising