beautypg.com

ProSoft Technology MVI56E-LDM User Manual

Page 60

background image

Understanding the MVI56-LDM API

ControlLogix Platform ♦ "C" Programmable

Developer's Manual

Linux Application Development Module

Page 54 of 264

ProSoft Technology, Inc.

March 12, 2014

Creates a handle allowing access to the tag database of the controller by
invoking

OCXcip_CreateTagDbHandl

. Options for accessing the database are set

using

OCXcip_SetTagDbOptions

.

A test is then made to ensure that the local copy of the database matches the
controller's copy of the tag database. This is done using the

OCXcip_TestTagDbVer

routine which will return a database empty error on the first

invocation, causing the local database to be rebuilt with the

OCXcip_BuildTagDb

routine.
The database contents are then printed to the console via

print_database_symbols

.

print_data_symbols

calls

OCXcip_GetSymbolInfo

for

each symbol (i.e., Tag) in the controller. It prints the name, dimensions if its an
array, the element size, and the type of each tag. If the type is simple,

print_cip_data_type

is called. If the type is a structure,

print_structure_info

is

called to print information about each element of the structure.

print_structure_info

uses

OCXcip_GetStructInfo

to get information about a

structure and then prints the name, data type, number of members, and overall
size to the console. It then request info about each member using

OCXcip_GetStructMbrInfo

and prints that information (name, array dimension,

offset in structure, element size, and data type) to the console. Again, a data
type may be simple (

print_cip_data_type

) or a structure which causes a

recursive invocation of the print_structure_info routine.
In the main program,

print_tag_info

is called on "index". This routine uses

OCXcip_GatTagDbTagInfo

to get information about this tag and prints that info to

the console.
The main loop then calls

print_controller_status

to check for changes in

controller status. This routine uses

OCXcip_GetDeviceIdStatus

to check the fault

state, run mode, and key switch mode of the controller. If any of these states
change, the new state is printed to the console.
The main loop then uses

OCXcip_AccessTagData

to read the value of the tag

"

LDM_Test

". The value of this tag is then incremented and written back to the

controller using the

OCXcip_AccessTagData

routine.