ProSoft Technology MVI69-ADM User Manual

Page 310

Advertising
background image

Side-Connect API Library Functions

MVI-ADM ♦ 'C' Programmable

Developer's Guide

'C' Programmable Application Development Module

Page 310 of 342

ProSoft Technology, Inc.

February 20, 2013

MVIsc_ReadPLC

Syntax

int MVIsc_ReadPLC(HANDLE handle, void *buf, WORD fileno, WORD elemno, WORD
subelemno, WORD size, WORD datatype, int fsync);

Parameters

handle

Handle returned by previous call to MVIsc_Open

buf

Pointer to user data buffer to receive the data to be read from the
PLC-5

fileno

PLC-5 data table file number

elemno

PLC-5 data table element number

subelemno

PLC-5 data table subelement number

size

Number of data items of type datatype to be read

datatype

Type of data item being written

fsync

Synchronization flag. Must be set to MVISC_SYNC_ACCESS or
MVISC_ASYNC_ACCESS.

Description
MVIsc_ReadPLC reads size data items of type datatype from the PLC-5 data
table file specified by fileno to the user-supplied buffer buf. elemno specifies the
element number of the data table file to begin read. buf must be large enough to
contain the data to be read. subelemno is used to address structured data. It
specifies the offset to a particular data item within a multi-word data structure,
such as a PID structure. For simple data files such as integer or float, subelemno
must be set to zero; otherwise, no data will be read and MVISC_ERR_XFERFAIL
will be returned. subelemno is specified as the word offset within the data
structure.

Note: For convenience, sub-element definitions for each of the data items within the various PLC-5
data structures are provided in the API include file MVISCAPI.H.

fsync specifies whether the access is synchronous or asynchronous with respect
to the PLC-5 ladder scan. When set to MVISC_SYNC_ACCESS, the transfer will
take place at the end of the next ladder scan. When set to
MVISC_ASYNC_ACCESS, the transfer will take place immediately. This flag
only has effect when the PLC-5 is in Run mode.

handle must be a valid handle returned from MVIsc_Open.

Notes: datatype specifies the type of data item being read, which may be different from the data

file type. For example, to access the SP value of a PID structure within a PD file, the data type
should be specified as MVISC_DTYP_FLOAT. In this example, subelemno must be set to the word

offset of the desired member within the PID structure, which in this case is defined as

MVISC_SUBEL_PD_SP. Valid values for datatype are MVISC_DTYP_WORD and

MVISC_DTYP_FLOAT.

Advertising