ProSoft Technology MVI69-ADM User Manual

Page 309

Advertising
background image

MVI-ADM ♦ 'C' Programmable

Side-Connect API Library Functions

'C' Programmable Application Development Module

Developer's Guide

ProSoft Technology, Inc.

Page 309 of 342

February 20, 2013

Notes: datatype specifies the type of data item being written, 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. An attempt to write past the end of a data table file will result in a return

code of MVISC_ERR_XFERFAIL or MVISC_ERR_PCCCFAIL. If the PLC is in RUN mode when

this write is attempted, PLC-5 data will be corrupted and the PLC-5 will be faulted. Care should be
taken not to exceed the boundaries of the PLC-5 data tables. See MVIsc_GetPLCFileInfo to

determine valid data table boundaries.

Return Value

MVISC_SUCCESS

The data was written successfully

MVISC_ERR_NOACCESS

handle does not have access

MVISC_ERR_BADPARAM

Parameter contains invalid value

MVISC_ERR_PLCTIMEOUT

PLC-5 did not respond

MVISC_ERR_XFERFAIL

PLC-5 returned an error

MVISC_ERR_PCCCFAIL

PCCC error occurred

Example

HANDLE Handle;
short N;
float SP;
int rc;
/* Write 1 integer to element 4 of integer file 7 (N7:4), asynchronously */
rc = MVIsc_WritePLC(Handle, &N, 7, 4, 0, 1, MVISC_DTYP_WORD,
MVISC_ASYNC_ACCESS);
if (rc != MVISC_SUCCESS)
printf("ERROR: MVIsc_WritePLC failed");
/* Write to the set point value of PID element 3 of PD file 9 (PD9:3.SP),
synchronously */
rc = MVIscWritePLC(Handle, &SP, 9, 3, MVISC_SUBEL_PD_SP, 1, MVISC_DTYP_FLOAT,
MVISC_SYNC_ACCESS);
if (rc != MVISC_SUCCESS)
printf("ERROR: MVIsc_WritePLC failed");

Advertising