0% found this document useful (0 votes)
238 views82 pages

752shrd0gb PDF

Uploaded by

Bouzidi Slim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
238 views82 pages

752shrd0gb PDF

Uploaded by

Bouzidi Slim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

OEM Environment:

Shared Memory Library

Technical Reference (SHRD)


OEM Documentation

Valid for:

Product: KVROS SW 162


from version 3.7

Edition: March 2001


Code: 91752.SHRD.0.GB

Esa/Gv s.r.l.
15 via Zamboni, CP 43
41011 Campogalliano Modena Italy
tel. +39 059 851414 - fax +39 059 851313
http://www.esagv.it - E-mail: info@esagv.it
Restrictions Duplication, transmission and use of this document or its contents shall be considered
prohitibed unless prior authorization has been received from Esa/Gv. All rights are
reserved.
Even when authorized, modification of this document (either by computer or on paper)
voids the guarantees specified below.

Guarantees The product may offer performances that are not described in these manuals. Esa/Gv
shall neither be obliged to maintain these functions in new versions of the product nor
to guarantee the relative assistance.

Checks have been carried out in order to ensure that the contents of these manuals
correspond to the documented product. Despite this fact, there may be discrepancies.
Esa/Gv therefore offers no guarantees as to the full compliance and completeness of the
texts.
The information in this document is periodically revised and new editions are issued
when necessary.

This manual has been compiled in partial compliance with ANSI/IEEE std 1063-1987
“IEEE Standard for software User Documentation”.

Editions This document is liable to be modified without prior notice. These modifications may
involve further editions or revisions of the document.
Further editions imply complete substitution of the document.
Revision involves replacement/addition/elimination of pages of the document.
Each page is identified by the code of the document at the bottom.

Notes
MS-DOS® Trademark registered by Microsoft Corporation.

ii 91752.SHRD.0.GB Esa/Gv
The chronological list of editions of this document is given in the following table:

Evolution of the document


Edition Document Code Release Type of edition
08/03/2001 91752.SHRD.0.GB 0 New document

Modifications
Release Chapters - Pages Description

Esa/Gv 91752.SHRD.0.GB iii


iv 91752.SHRD.0.GB Esa/Gv
SHRD Technical Reference

Technical Reference

Notes for the reader....................................................................................................... i


Explanation of the symbols............................................................................................................ ii
Printer’s conventions .................................................................................................................... iii
Glossary ....................................................................................................................................... iv

1 The Shared Library: Introduction .......................................................................... 1.1


1.1 Introduction........................................................................................................................... 1.1
1.2 Inserting a project ................................................................................................................. 1.1
1.3 Virtual Sharing ...................................................................................................................... 1.1
1.4 Simultaneously accessing a number of registers................................................................... 1.3
1.5 Alphabetical list of functions.................................................................................................. 1.4

2 Functions for accessing the registers in shared memory................................... 2.1


2.1 Initializing and closing........................................................................................................... 2.1
2.1.1 Initialization (InitShared) .......................................................................................... 2.1
2.1.2 Closing (ExitShared) ................................................................................................ 2.3
2.2 Managing Virtual Shared instances (SelectShared - SHRInstance) ....................................... 2.4
2.2.1 SelectShared ........................................................................................................... 2.4
2.2.2 SHRInstance............................................................................................................ 2.4
2.3 Accessing machine configuration registers............................................................................ 2.5
2.3.1 Writing (WriteParConf) ........................................................................................... 2.5
2.3.2 Reading (ShrReadParConf) .................................................................................... 2.7
2.4 Accessing channel registers.................................................................................................. 2.9
2.4.1 Configuration (WriteCnfChan - ShrReadCnfChan) ................................................... 2.9
2.4.2 Parameters (WriteParChan - ShrReadParChan) .................................................... 2.12
2.4.3 Command and Status Registers (WriteChan - ShrReadChan)................................ 2.14
2.4.4 Geometry Channel (WriteGeoChan - ShrReadGeoChan)....................................... 2.18
2.5 Accessing the axes registers............................................................................................... 2.20
2.5.1 Parameters (WriteParAxes - ShrReadParAxes - GetOffParam) ............................. 2.20
2.5.2 Command and Status Registers (WriteAxes - ShrReadAxes)................................. 2.27
2.5.3 Configuration (WriteAxNVel - ShrReadAxNVel - WriteAxNBit - ShrReadAxNBit) ... 2.30
2.6 Accessing the GUI-PLC interface registers (WriteUiPlc - ShrReadUiPlc) ............................ 2.34
2.7 Access to parametric variables ........................................................................................... 2.36
2.7.1 Read and write operations on VA, VL and VG variables (WriteVarR - ShrReadVarR)2.36

Esa/Gv 91752.SHRD.0.GB i
Technical Reference SHRD

2.7.2 Maximum offset of VA, VG and VL variables (GetRegVg - GetRegVa - GetRegVl)2.38


2.8 Accessing the Channel Origin registers (WriteOrigin - ShrReadOrigin) ............................... 2.39
2.9 Accessing the IOs (WriteIOWord - ReadIOWord - ReadIOOutputWord) ............................. 2.41
2.10 Accessing the machine status registers (ShrReadCNStatus - ShrReadHeader)................ 2.43
2.11 Accessing a number of registers simultaneously ............................................................... 2.45
2.11.1 Allocating the buffer for multiple requests (BeginPackedOperation) ..................... 2.45
2.11.2 Starting a multiple request section (StartPackedOperation).................................. 2.46
2.11.3 Explicit request for access to the shared memory (FlushPackedOperation).......... 2.47
2.11.4 Bufferizing accesses to non-system registers (AppendRequest) ........................... 2.48
2.11.5 Freeing the buffer (EndPackedOperation) ............................................................ 2.49
2.12 Auxiliary debug functions (_StartSharedReport - _EndSharedReport - _SetCallStackReport -
_SetStatusReport) .............................................................................................................. 2.50

3 File management functions.................................................................................... 3.1


3.1 Opening files (PgmOpen) ..................................................................................................... 3.1
3.2 Closing files (PgmClose)....................................................................................................... 3.3
3.3 3.5 Positioning within the file (PgmSeek) .............................................................................. 3.4
3.4 Positioning at the start of file (PgmRewind).......................................................................... 3.5
3.5 Current position within the file (PgmTell)............................................................................... 3.6
3.6 Reading a line (PgmGets) ..................................................................................................... 3.7
3.7 Reading a character (PgmGetc)........................................................................................... 3.8
3.8 Check EndOfFile (PgmEnd - PgmFeof) ................................................................................ 3.9
3.9 Checking the error value (PgmErr)..................................................................................... 3.10
3.10 Resetting the error value (PgmClearerr)............................................................................ 3.11

END OF SUMMARY

ii 91752.SHRD.0.GB Esa/Gv
SHRD Notes for the reader

Notes for the reader

General information The information in this manual only applies to the software versions indicated on the
frontispiece.

Not all the available functions may be described in this manual. In these cases, Esa/Gv
shall be obliged to neither guarantee these functions nor include them in future
versions.

Purpose The purpose of this document is to facilitate the use or modification of parts of the
software that use numeric control data.

Users This document contains information for:


‚ the computer technician with experience in the indusCNl automation field;
‚ the SW programmer.

Use of the document The document is divided into chapters that describe how parts of the software that uses
numeric control data can be created or modified.

Notification of Please contact Esa/Gv if any difficulties should arise when this manual is used.
difficulties

Esa/Gv 91752.SHRD.0.GB i
Notes for the reader SHRD

Explanation of the symbols

Graphic symbols may appear beside the text. These are used to emphasize information
of particular importance.

Attention
This symbol is used when failure to take the appropriate precautions could cause
slight damage to persons and property.

Danger
This symbol appears when failure to take the appropriate precautions or
accomplishment of incorrect manoeuvres could cause serious damage to persons
and/or property.

Important
This symbol appears in the manual to indicate information of particular importance. It
is essential to read these sections in order to fully understand the manual.

Option
This symbol indicates sections of the manual that describe optional functions or parts.
Use of optional performances must be established with the machine manufacturer.

Manufacturer
This symbol indicates those sections of the manual reserved to the machine
manufacturer.

Password
This symbol indicates sections of the manual that describe functions access to which is
safeguarded by software passwords.

CN
This symbol indicates sections of the manual that describe functions only available in
CN and not in the PC.

PC
This symbol indicates sections of the manual that describe functions only available in
the PC and not in CN.

ii 91752.SHRD.0.GB Esa/Gv
SHRD Notes for the reader

Printer’s conventions

Particular printer’s conventions are used to make it easier to identify the information in
this manual. These conventions are illustrated below.

Keyboard and video The following conventions are used.


‚ The names of the screen-printed keys are indicated in boldface and are enclosed
within square brackets. If the name of the key is preceded by “button”, reference is
being made to a key on the push button panel.
− [ENTER]. Identifies the key that bears the word ENTER.
− [+] indicates the + key of the keyboard, while button [+] indicates the + key of
the push button panel.
‚ The names of the function keys are indicated in boldface italics and are enclosed
within square brackets.
− [Plc Menu]. Identifies the function key that bears the words Plc Menu.
‚ References to fields and/or messages on the video are written in boldface italics.
‚ The specific text to be digitized by the user is underlined.
− If the manual indicates “digitize ok, the user must digitize exactly “ok”.
‚ DIRECTION or DIRECTIONAL keys is the collective name used to indicate the
UP, DOWN, LEFT and RIGHT keys.
‚ Pressure, in sequence, on a series of keys is written by separating the identifiers of
the required keys with the “>“ character.
− [Manual] > [START]. Describes pressure, in sequence, on the [Manual] and
[START] keys.
‚ Pressure on several keys at the same time is indicated by separating the identifiers
of the keys themselves with the “+” character.
− Æ
[SHIFT] + [ ] Describes contemporaneous pressure on the [SHIFT] and [ ] Æ
keys.

Text The following conventions are used.


‚ Italics are used to identify specialistic terms.
‚ Boldface is used to emphasize words of particular importance.

Esa/Gv 91752.SHRD.0.GB iii


Notes for the reader SHRD

Glossary

CNC This is an abbreviation of Computerized Numerical Control and indicates the


instrument that governs the machine, i.e. the electronic device through which the
machining cycles are programmed, the axes moved, etc..
It corresponds to one of the devices whose operation is described in this manual.

END OF PREFACE

iv 91752.SHRD.0.GB Esa/Gv
SHRD The Shared Library: Introduction

1 The Shared Library: Introduction

1.1 Introduction

This library provides services for accessing the system’s information stored in the
shared memory; it is supported by the communications library, and its use is
simplified, masking the connection to the registers and the knowledge of the symbolic
name of the registers which it accesses.
Access to the information contained in the Shared Memory requires a preliminary
connection phase, necessary for subsequent accesses for reading from or writing to the
register.

The library has the task of pre-connecting all the system registers, to enable them
subsequently to be accessed more rapidly. Use of the library also guarantees
compatibility relative to any re-organization to the data structure that hosts the
information.

The library incorporates functions such as request packing and the management of a
virtual instance of the database – functions that enable access times to be optimized.

1.2 Inserting a project

The library documented in this manual is VShared.dll (release version) or


VSharedD.DLL (debug version), released in the C:\Kvara\Exe directory of the
development environment for Kvara series CNC.

To be able to use the DLL it is necessary to link the VShared.lib library (release
version) or VsharedD.dll (debug version) to the project under development, which is
located in the C:\Kvara\Lib directory; the latter exports the functions of the DLL.
The static libraries are created using Microsoft® development environments, which
use the COFF format. If you wish to use different development environments you must
check whether or not these are compatible; if they are not, you cannot perform the
library link, but the DLL must be loaded implicitly (LoadLibrary method or
equivalent) and the services linked by symbol (GetProcAddress method or
equivalent).
All the functions are exported using the extern "C" format to prevent their
decoration.

You must also include the Shared.h file in each file that accesses the library services.

1.3 Virtual Sharing

Using the functions provided by the communication, you can create a SharedMemory
instance that is so-called Virtual, i.e. that does not access the memory that resides on
the CNC, but references a copy local to the process that effects the accesses.
Having a shared virtual instance allows you to obtain much faster access times.
However, the synchronization of the two instances – the “real” one and the “virtual”
one – is not automatic, but must be explicitly achieved by whoever intends to make use
of it.

Esa/Gv 91752.SHRD.0.GB 1.1


The Shared Library: Introduction SHRD

The DLL handles access to one instance rather than another in implicit mode. It is
sufficient at the time of initialization of the resources to specify whether the thread uses
the “real” shared instance rather than the “virtual” one. In one case the accesses to the
system registers in shared memory use the “real” addresses (TS_REG):, in the other
the “virtual” addresses (TS_REG).

Accessing real or By default, each thread accesses the real shared instance; to access the virtual shared
shared instances instance it must explicitly call up the InitShared that initializes the base TS_REG for
accessing the respective structures in SharedMemory. A parameter of the InitShared
establishes whether or not the TS_REG relative to the real Shared instance must be
initialized, or whether those relative to the virtual instance. The InitShared must be
called up for each process that intends to make use of the services made available by
the VSharedDLL.

Selecting the shared Subsequently, you should use the SelectShared function for selecting the shared
or real instance instance to be accessed (real or virtual).
The SelectShared may be called up several times by the same thread, to modify the
shared instance you wish to access; this ensures that the TS_REGs relative to the
selected instance are initialized. By default, a thread accesses the real Shared instance.

De-installing the Use the ExitShared on exiting the process for de-installing the VSharedDLL.
VSharedDLL

Checking the Call up the SHRInstance to obtain the instance currently selected.
instance currently The value returned by SHRInstance must be supplied as a parameter to the
selected get_reg_by_name_ex in order to connect a register that is not a system one, to the
virtually shared instance. Provided you know the virtual TS_REG, you can use the
normal Communications functions (Read_Reg ... Write_Reg... ) and thus access any
register of the Virtually Shared instance.

Example
//creates a VIRTUAL INSTANCE of SharedMemory
//and initialises the ShareDLL on the Virtual instance
HandleVirtual = CreateVirtualShared();
InitShared(HandleVirtual);

//accesses the VIRTUAL INSTANCE system registers


Err = ShrReadParAxes(iAx, AP_ACCTIME, &Val);
...
...
//reads an application register from the REAL ISTANCE
Err = get_reg_by_name(“SpecFeed”,&Reg);
Err = RF_ReadRegDword(Reg,0, &Val);
...
//writes an application register in the VIRTUAL INSTANCE
Err = get_reg_by_name_ex(“SpecFeed”,&Reg1, SHRInstance());
Err = RF_WriteRegDword(Reg1,0,Val);
...

ExitShared();

1.2 91752.SHRD.0.GB Esa/Gv


SHRD The Shared Library: Introduction

1.4 Simultaneously accessing a number of registers

You can compress the requests to the communications server to reduce the
communication protocol overhead. This operation allows you to reduce the access
times to the Shared Memory considerably.
This solution is very useful when GUI and CNC use communications channels that
are not very fast.

The DLL is organized so as to reduce to the minimum the modifications to be made in


the event of a code already existing; you merely have to insert a prologue and an
epilogue that enclose the functions of the SharedDLL to obtain a packed request.

The functions of the SharedDLL provide a set of services that are useful for achieving
multiple accesses also to non-system registers.

Esa/Gv 91752.SHRD.0.GB 1.3


The Shared Library: Introduction SHRD

1.5 Alphabetical list of functions

Function name
_EndSharedReport
_SetCallStackReport
_SetStatusReport
_StartSharedReport
AppendRequest
BeginPackedOperation
EndPacketOperation
ExitShared
FlushPackedOperation
GetOffParam
GetRegVa
GetRegVg
GetRegVl
InitShared
PgmClearerr
PgmClose
PgmEnd
PgmErr
PgmFeof
PgmGetc
PgmGets
PgmOpen
PgmRewind
PgmSeek
PgmTell
ReadIOOutputWord
ReadIOWord
SelectShared
SHRInstance
ShrRaedCNStatus
ShrReadAxes
ShrReadAxNBit
ShrReadAxNVel

1.4 91752.SHRD.0.GB Esa/Gv


SHRD The Shared Library: Introduction

Function name
ShrReadChan
ShrReadCnfChan
ShrReadGeoChan
ShrReadHeader
ShrReadOrigin
ShrReadParAxes
ShrReadUiPlc
ShrReadVarR
SrhReadParConf
StartPackedOperation
WriteAxes
WriteAxNBit
WriteAxNVel
WriteCnfChan
WriteGeoChan
WriteIOWord
WriteOrigin
WriteParAxes
WriteParChan
WriteParConf
WriteUiPlc
WriteVarR

END OF CHAPTER

Esa/Gv 91752.SHRD.0.GB 1.5


The Shared Library: Introduction SHRD

1.6 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2 Functions for accessing the registers in shared


memory

2.1 Initializing and closing

The functions of this group are used for initializing the use of the DLL and for closing
the work session.
The services of the DLL are not available if the initialization function has not first
been called up; similarly, it is essential to call up the closing function before closing
the communication with the NC.

2.1.1 Initialization (InitShared)

Syntax
(int) InitShared(LONG Location)

Description This function pre-connects the system registers defined in Defcn.


If InitShared has not been called up, any function of SharedDLL will fail.

This function must be called up at the start of every process that involves using the
functions provided by SharedDLL.

Parameters

Location Establishes if the connection concerns an instance of “virtual” or “real”


shared memory (on the NC).

It may assume the following values:


‚ 0 indicates that the shared memory to which reference is being made
is the one resident in the NC.
‚ Handle of the Virtual Shared returned by a CreateVirtualShared
(see Communication Manual) following the creation of a Virtual
Shared instance.

Reply codes

0 The initialization has terminated correctly.


!0 An invalidating error has occurred during the initialization phase.

Esa/Gv 91752.SHRD.0.GB 2.1


Functions for accessing the registers in shared memory SHRD

Example
if( KENVInitGlobalTable() ) {
if( iErr = _EstablishResourceLocation() ) {
return(RET_KO);
}
}
iErr = InitShared(0);
if( iErr ) {
KENVFreeGlobalTable()
return(RET_KO);
}
//for packed requests
iErr = BeginPackedOperation();

2.2 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.1.2 Closing (ExitShared)

Syntax
(int) ExitShared()

Description De-installs the DLL; after having called it up, you will no longer be able to access the
services of the DLL until a new initialization has been performed.

Reply codes

0 The function terminated correctly.


!0 The function did not terminate correctly.

Example
EndPackedOperation();
ExitShared();
KenvFreeGlobalTable();

Esa/Gv 91752.SHRD.0.GB 2.3


Functions for accessing the registers in shared memory SHRD

2.2 Managing Virtual Shared instances (SelectShared - SHRInstance)

2.2.1 SelectShared

Syntax
(int) SelectShared(LONG Location)

Description Selects the shared instance to be accessed (real or virtual).


This function may be called up a number of times from the same thread, to modify the
shared instance to be accessed; it ensures that the TS_REGs relative to the instance
selected have been initialized. A default thread accesses the Real Shared instance.

Parameters

Location Establishes if the connection concerns an instance of “virtual” or “real”


shared memory (on the NC).

It manages the following values:


‚ 0 indicates that the shared memory to which reference is being made
is the one resident in the CNC.
‚ Handle of the Virtual Shared returned by a CreateVirtualShared
(see Communication Manual) following the creation of a Virtual
Shared instance.

2.2.2 SHRInstance

Syntax

(LONG)SHRInstance()

Description Returns the value of the instance currently selected.


To connect a non-system register to the virtual shared instance, the value returned by
the SHRInstance must be provided as a parameter to the get_reg_by_name_ex.
Provided you know the virtual TS_REG, you can use the normal functions of the
Communication (Read_Reg ... Write_Reg.. ) and thus access any register of the
Virtual Shared.

Reply codes

0 Indicates Real Shared .


!0 Indicates Virtual Shared .

2.4 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.3 Accessing machine configuration registers

These functions perform read and write operations on the vectors that contain the
configuration data of the machine contained by the cg[] vector.

2.3.1 Writing (WriteParConf)

Syntax
(int) WriteParConf( long value,
int field)

Description Writes to the register indicated.

Parameters

value Numeric value to be set.

field Register selection index.

Field field values The field field may assume one of the following values:

Field Description Reg. No.


CN_NUMCHAN Number of channels configured 0
CN_NUMAX Number of axes 1
CN_FIRSTSLAVE Number of first slave board 2
CN_MON Channel monitor page keys mask 3
CN_MMINCI Default setting in mm(0) inch(1) 8
CN_DELAY NC channel delay 10
CN_CALCREG Calculation and adjustment time 11
CN_COMMTICALC Number of commands for calculation frequency 14
CN_DLY_PATTERN NC channel insertion delay time in units 15
CN_CNCTIMOT Timeout between two executions of CNC 16
channels
CN_USREXTLEN Dimensions of user extensions common to the 17
channels
CN_PTKB Memory for through execution 18
CN_CALCREG Calculation and adjustment time 11
CN_COMMTICALC Number of commands for calculation frequency 14
CN_DLY_PATTERN NC channel insertion delay time in units 15
CN_CNCTIMOT Timeout between two executions of CNC 16
channels
CN_USREXTLEN Dimensions of user extensions common to the 17
channels
CN_PTKB Memory for through execution 18
CN_SLVBLOCKS Blocks for slave codes 19
CN_SLVBLOCKS Blocks for slave codes 19

Esa/Gv 91752.SHRD.0.GB 2.5


Functions for accessing the registers in shared memory SHRD

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
long lTmp;
iErr = ShrReadParConf( CN_NUMCHAN, &lTmp );
if( iErr != RET_OK ) {
return( iErr );
//the read terminated incorrectly
}

iErr = WriteParConf(10,CN_NUMAX);
if( iErr != RET_OK ) {
return( iErr );
// the write terminated incorrectly
}

2.6 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.3.2 Reading (ShrReadParConf)

Syntax
(int) ShrReadParConf( int field,
long *pVal);

Description Reads the specified register; the value returned is only significant if the function
terminates correctly.

Parameters

field Register selection index.

pVal Address of the variable to which the value read from the
SharedMemory is returned.

Field field values The field field may assume one of the following values:

Field Description Reg. No.


CN_NUMCHAN Number of channels configured 0
CN_NUMAX Number of axes 1
CN_FIRSTSLAVE Number of first slave board 2
CN_MON Channel monitor page keys mask 3
CN_MMINCI Default setting in mm(0) inch(1) 8
CN_DELAY NC channel delay 10
CN_CALCREG Calculation and adjustment time 11
CN_COMMTICALC Number of commands for calculation frequency. 14
CN_DLY_PATTERN NC channel insertion delay time in units 15
CN_CNCTIMOT Timeout between execution of two CNC channels 16
CN_USREXTLEN Dimensions of user extensions common to both 17
channels
CN_PTKB Memory for through execution 18
CN_CALCREG Calculation and adjustment time 11
CN_COMMTICALC Number of commands for calculation frequency 14
CN_DLY_PATTERN NC channel insertion delay time in units 15
CN_CNCTIMOT Timeout between execution of two CNC channels 16
CN_USREXTLEN Dimensions of user extensions common to the 17
channels
CN_PTKB Memory for through execution 18
CN_SLVBLOCKS Blocks for slave codes 19
CN_SLVBLOCKS Blocks for slave codes 19

Esa/Gv 91752.SHRD.0.GB 2.7


Functions for accessing the registers in shared memory SHRD

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
long lTmp;
iErr = ShrReadParConf( CN_NUMCHAN, &lTmp );
if( iErr != RET_OK ) {
return( iErr );
//the read terminated incorrectly
}

iErr = WriteParConf(10,CN_NUMAX);
if( iErr != RET_OK ) {
return( iErr );
// the write terminated incorrectly }

2.8 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.4 Accessing channel registers

The channel registers reference a cn[] Table whose index selects the channel in
question; this, in turn, contains Sub-Tables, corresponding to each of the categories
described below.

2.4.1 Configuration (WriteCnfChan - ShrReadCnfChan)


These functions perform read and write operations on the vectors that contain the
configuration data of each channel contained in the cn[].cc[] vectors; it is necessary,
therefore, to identify the channel number to select the cn[] Table and subsequently
address the parameter of the .cc[] Sub-Table.
These parameters are accessed using BaseMenu and activating the [Parameters] >
[System] > [Configure Chanel] path from the shared editor.

Syntax
(int) WriteCnfChan( long value,
int nch,
int field)

(int) ShrReadCnfChan( int nch,


int field,
long *pVal)

Description

WriteCnfChan Writes to the cn[nch].cc[field] register.

ShrReadCnfChan Reads the cn[nch].cc[field] register; the value returned is significant only if the
function terminates correctly.

Parameters

nch Channel number.

field Register selection index. May assume the values described in the Table
below.

value Numeric value to be set.

pVal Address of the variable on which the value read from the SharedMemory is
returned.

Esa/Gv 91752.SHRD.0.GB 2.9


Functions for accessing the registers in shared memory SHRD

Field field values The field field may assume one of the following values:

Field Description Reg. No


CC_NUMBOARD Channel processing board number 0
CC_MASKAXES Axes channel mask (10 bit) 1
CC_NX X axis number (system wide) 2
CC_NY Y axis number (system wide) 3
CC_NZ Z axis number (system wide) 4
CC_NU U axis number (system wide) 5
CC_NV V axis number (system wide) 6
CC_NW W axis number (system wide) 7
CC_NA A axis number (system wide) 8
CC_NB B axis number (system wide) 9
CC_NC V axis number (system wide) 10
CC_NM Axis / spindle number (system wide) 11
CC_MAINPROC Main process number 12
CC_PRIORITY Channel priority (0 disabled, 10+ priority) 13
CC_TWIBASE Base Index Spindles/Kinematisms Table 14
CC_TWIAMOUNT Number of Spindles/Kinematisms in Table 15
CC_THDBASE Base Index of Toolholders Table 16
CC_THDAMOUNT Number of Toolholers in Table 17
CC_CEDBASE Base Index of Toolholders Table 18
CC_CEDAMOUNT Number of Tools in Table 19
CC_VARSPERLEVEL Local Var. for each level of subroutine 20
CC_CHANPTKB Memory for through execution 21
CC_MEDIATYPE Access channel to the FS (0 default 1 pipe 2 22
USREXT)
CC_MAG Magazine type (0: none 1: revolver 2: chain) 23
CC_RV Magazine number 24

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

2.10 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Example
iErr = ShrReadCnfChan( iCh, CC_MASKAXES, &Mask );
if( iErr != RET_OK )
return( iErr );

iErr = WriteCnfChan(3, iCh, CC_NX);


if( iErr != RET_OK )
return( iErr );

Esa/Gv 91752.SHRD.0.GB 2.11


Functions for accessing the registers in shared memory SHRD

2.4.2 Parameters (WriteParChan - ShrReadParChan)


These functions perform read and write operations on the vectors that contain the
parameters of each channel contained in the cn[].pc[] vectors; it is necessary,
therefore, to identify the channel number to select the cn[] Table and subsequently
address the parameters of the .pc[] Sub-Table.
These parameters are accessed using BaseMenu and activating the [Parameters] >
[System] > [Configure Channel] path of the shared editor.

Syntax
(int) WriteParChan( long value,
int nch,
int field )

(int) ShrReadParChan( int nch,


int field,
long *pVal)

Description

WriteParChan Writes to the cn[nch].pc[field] register.

ShrReadParChan Reads the cn[nch].pc[field] register; the value returned is only significant if the
function terminates correctly.

Parameters

nch Channel number (index of the cn[] register).

field .pc[] register selection index. May assume the values indicated in the Table
below.

value Numeric value to be set.

pVal Address of the variable to which the value read from the SharedMemory is
returned.

2.12 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Field field values The field field may assume one of the following values:

Field Description Reg. No


CP_CMDA Number of commands, exec queue 0
CP_CMDB Number of commands, slave queue 1
CP_CMDC Number of commands, continuous slave queue 2
CP_MTYPE M type functions 3
CP_STYPE S type functions 4
CP_TTYPE T type functions 5
CP_ACCTIME Acceleration time on the trajectory 6
CP_DECTIME Deceleration time on the trajectory 7
CP_VELMAX Max. speed on the trajectory 8
CP_MANDTAR Spindle Calibration measure 9
CP_BLOCKA Number of commands in a scanning 10
CP_BLOCKB Number of blocks without commands in a scanning 11
CP_BLOCKC Max. number of slave commands in a scanning 12
CP_VELDRY Dry Run mode feed 13
CP_OPTIONS Options 14
CP_TOLLRAD Radius control tolerance 15

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
iErr = ShrReadParChan(iCh, CP_ACCTIME, &TimeAcc);
if( iErr != RET_OK )
return( iErr );
iErr = WriteParChan(50,iCh, CP_CMDA);
if( iErr != RET_OK )
return( iErr );

Esa/Gv 91752.SHRD.0.GB 2.13


Functions for accessing the registers in shared memory SHRD

2.4.3 Command and Status Registers (WriteChan - ShrReadChan)


These functions perform read and write operations on the vectors that contain the
status and command registers of each channel contained in the cn[].rc[] vectors; it is
necessary, therefore, to identify the number of the channel to select the cn[] Table and
subsequently address the parameter of the .rc[] Sub-Table.
Access to these registers is not visible from BaseMenu.

STATUS Registers The status registers provide information on what the channel is doing; a write to these
registers is not significant as the channel continually updates the value of the
registers.

COMMAND registers The command registers allow you to select the channel’s operating mode, which only
executes read operations on these registers. Modifying the contents of these registers
results in the execution of commands by the channel.
Generally, the PLC has the task of commanding the channel; this does not, however,
prevent a GUI application from commanding one or more channels by means of these
registers, provided that this does not cause conflicts in writing between the PLC and
GUI.

Syntax
(int) WriteChan( long value,
int nch,
int field )

(int) ShrReadChan( int nch,


int field,
long *pVal)

Description

WriteChan Writes to the cn[nch].rc[field] register.


Writing is executed always by entire registers; if you wish to modify only the value of a
register bit, this requires reading the value from the command register, altering the bit
and performing the write for the new value.

ShrReadChan Reads the cn[nch].rc[field] register; the value returned is significant only if the
function terminates correctly.

2.14 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Parameters

nch channel number (index of the cn[] register).

field .rc[] register selection index. May assume the values indicated in the
Tables relative to the Status or Command registers.

value Numeric value to be set.

pVal Address of the variable to which the value read from the SharedMemory
is returned.

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

COMMAND Registers: The following list shows the values allowed for the field field to gain access to the
field field values COMMAND registers.

Field Description Reg. No


CI_CMDREG Channel command register 0
CI_NUMPPGM Number of part program selected for execution 1
CI_OVRD1 Advance override 2
CI_OVRD2 Rapid override (now under preparation) 3
CI_FIXINCR Dimension for fixed increments 4
CI_JOGOPEN JOG Voltage at Open Loop 5
CI_ENDISFNZ Function enabling/disabling 6
CI_PARKAX Axis parking enabling 7

Esa/Gv 91752.SHRD.0.GB 2.15


Functions for accessing the registers in shared memory SHRD

STATUS Registers: The following list shows the values allowed for the field field for accessing the
field field values STATUS registers.

Field Description Reg. No


CO_STATREG Channel status register 8
CO_MFUN M functions register 9
CO_SFUN S functions register (not used) 10
CO_TFUN T functions register 11
CO_CURRBLCK Progressive number of current block 12
CO_CURRPTR Current block pointer 13
CO_NESTLEV Nesting level 14
CO_NSUBLEV1 Number of part program being executed 15
CO_NSUBLEV2 Number of sub-program, 1st level 16
CO_NSUBLEV3 Number of sub-program, 2nd level 17
CO_ERRCODE Channel error code 18
CO_ALARMCODE Channel alarm code 19
CO_CURFFUN Current F function 20
CO_CURSFUN Current S function 21
CO_CURTFUN Current T function 22
CO_CURDFUN Current D function 23
CO_LASTM Last M function processed 24
CO_VELMAND Spindle velocity register 25
CO_VELCUT Cutting velocity register 26
CO_XORIG Current X axis origin 27
CO_YORIG Current Y axis origin 28
CO_ZORIG Current Z axis origin 29
CO_PATHAX Path axes mask 30
CO_UORIG Current U axis origin 31
CO_VORIG Current V axis origin 32
CO_WORIG Current W axis origin 33
CO_NSUBLEV4 Sub-program number, 3rd level 34
CO_NSUBLEV5 Sub-program number, 4th level 35
CO_NSUBLEV6 Sub-program number, 5th level 36
CO_POSAX Positioning axes mask 37
CO_ANGM19 Spindle M19 orientation angle register 38
CO_GGRP0 Modal function active, group 1 40
CO_GGRP1 Modal function active, group 2 41
CO_GGRP2 Modal function active, group 3 42
CO_GGRP3 Modal function active, group 4 43
CO_GGRP4 Modal function active, group 5 44
CO_GGRP5 Modal function active, group 6 45
CO_GGRP6 Modal function active, group 7 46
CO_GGRP7 Modal function active, group 8 47
CO_GGRP8 Modal function active, group 9 48
CO_GGRP9 Modal function active, group 10 49
CO_NSUBLEV7 Sub-program number, 6th level 50
CO_NSUBLEV8 Sub-program number, 7th level 51
CO_NSUBLEV9 Sub-program number, 8th level 52

2.16 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Field Description Reg. No


CO_NSUBLEV10 Sub-program number, 9th level 53
CO_NSUBLEV11 Sub-program number, 10th level 54
CO_NSUBLEV12 Sub-program number, 11th level 55
th
CO_NSUBLEV13 Sub-program number, 12 level 56
CO_NSUBLEV14 Sub-program number, 13th level 57
CO_NSUBLEV15 Sub-program number, 14th level 58
CO_NSUBLEV16 Sub-program number, 15th level 59
UC_CMDREG UI->NCC -debug signal handling- 60
CU_DBGSTAT NCC->UI –error code on BPcond- 61
STATUSCHPREC INTERNAL: contains the code relative to the 62
previous status.
STATUSCHCORR INTERNAL: contains the code relative to the 63
current status.

Example
iErr = WriteChan( (DWORD)ulPgm, iCh, CI_NUMPPGM );
if( iErr != RET_OK )
return( iErr );
iErr = ShrReadChan( iCh, CO_STATREG, &dwreg);
if( iErr != RET_OK )
return( iErr );

Esa/Gv 91752.SHRD.0.GB 2.17


Functions for accessing the registers in shared memory SHRD

2.4.4 Geometry Channel (WriteGeoChan - ShrReadGeoChan)


These functions execute read and write operations on the vectors containing the
descriptors of the geometry of the channels contained in the cn[].gc[] vectors; it is
necessary, therefore, to identify the channel number to select the cn[] Table and
subsequently address the parameter of the .gc[] Sub-Table.
These parameters are accessed using BaseMenu and activating the [Parameters] >
[System] > [Channel Geometry ] path of the shared editor.

Syntax
(int) WriteGeoChan( long value,
int nch,
int field)

(int) ShrReadGeoChan( int nch,


int field,
long *pVal)

Description

WriteGeoChan Writes to the cn[nch].gc[field] register.

ShrReadGeoChan Reads the cn[nch].gc[field] register; the value returned is significant only if the
function terminates correctly.

Parameters

nch Channel number (index of the cn[] register).

field .gc[] register selection index. It may assume the values described in the Table
below.

value Numeric value to be set

pVal Address of the variable to which the value read from the SharedMemory is
returned.

2.18 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Field field values The field field may assume the following values:

Field Description Reg. No


GC_GEOTYPE Geometry type 0
GC_MODE Mode (0=Disab 1=Enab) 1
GC_X_ANG_SGN (B) angle inversion 2
GC_X_ANG (B) angle X axis 3
GC_X_DST_SGN (X) axis inversion 4
GC_X_DST Distance of X from the MC 5
GC_Y_ANG_SGN (A) angle inversion 6
GC_Y_ANG (A) angle Y axis 7
GC_Y_DST_SGN (Y) axis inversion 8
GC_Y_DST Distance of Y from the MC 9
GC_Z_ANG_SGN (xx) angle inversion 10
GC_Z_ANG Z axis angle 11
GC_Z_DST_SGN (Z) axis inversion 12
GC_Z_DST Distance of Z from the MC 13
GC_EA_DEF_SGN (EA) angle inversion 14
GC_EA_DEF (EA) tool angle 15
GC_EB_DEF_SGN (EB) angle inversion 16
GC_EB_DEF (EB) tool angle 17
GC_EC_DEF_SGN (EC) angle inversion 18
GC_EC_DEF (EC) tool angle 19

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
iErr = WriteGeoChan( gType, iCh, GC_GEOTYPE);
if( iErr != RET_OK )
return( iErr );
iErr = ShrReadGeoChan( iCh, GC_X_ANG, &Beta);
if( iErr != RET_OK )
return( iErr );

Esa/Gv 91752.SHRD.0.GB 2.19


Functions for accessing the registers in shared memory SHRD

2.5 Accessing the axes registers

The axes registers reference an ax[] Table, the index of which selects the axis in
question; this, in turn, contains Sub-Tables corresponding to each of the categories
described below.

2.5.1 Parameters (WriteParAxes - ShrReadParAxes - GetOffParam)


These functions perform read and write operations on the vectors containing the
parameters of the axes contained in the ax[].pa[] vectors; it is necessary, therefore, to
identify the axis number to select the ax[] Table and subsequently address the
parameter of the .pa[] Sub-Table.
These parameters can be accessed from BaseMenu, by activating the [Parameters] >
[System] > [Axes Parameters ] path of the shared editor.

Accessing a parameter requires different indices depending on the type of axis


configured; the GetOffParam function converts an absolute index into the
appropriate index, which takes into consideration the type of axis configured. The
function is used every time the axis configuration is uncertain, to avoid carrying out
the XX_AXTYPE parameter test.

Syntax
(int) WriteParAxes( long value,
int nax,
int field)

(int) ShrReadParAxes( int nax,


int field,
long *pVal)

(int) GetOffParam ( int nax,


int field)

Description

WriteParAxes Writes the value in the ax[nax].pa[field] register.

ShrReadParAxes Reads the ax[nax].pa[field] register; the value returned is significant only if the
function terminates correctly.

GetOffParam Although the parameters have the same meaning, they may reside on different
registers, if the type of axis is different. The GetOffParam, starting from the specified
parameter, returns the correct index referenced to the type of axis in question.

2.20 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Parameters

nax Axis number (index of the ax[] register).

field .pa[] register selection index.

It may assume the following values:


‚ For the ShrReadParAxes and WriteParAxes functions, consult the
Tables relative to the axes.
‚ For the GetOffParam function, consult the relative Table.

value Numeric value to be written.

pVal Address of the variable to which the value read from the SharedMemory is
returned.

ShrReadParAxes and
WriteParAxes:
field field value

Proportional axes
The following is a list of the values allowed for the field field, for accessing the
parameters of a Proportional. Axis.

Field Description Reg. No


AP_AXTYPE Axis/spindle type 0
AP_ACCTIME Acceleration time 1
AP_DECTIME Deceleration time 2
AP_OPTIONS Options: 3
AP_FWERRVLIM Velocity limit for tracking propagation error 4
(0=disab)
AP_FWERR Maximum tracking error 5
AP_TOLLERG Rough tolerance measure 6
AP_TOLLERF Fine tolerance measure 7
AP_TOLLER Timer tolerance 8
AP_VELMAX Max. velocity 9
AP_GAINP P gain 10
AP_GAIND D gain 11
AP_GAINFWD Feed-forward gain 12
AP_MULENC Encoder multiplier 13
AP_INSPOS DAC steps positive insensitivity 14
AP_FATTCONV Conversion factor 15
AP_TARTYPE Calibration type 16
AP_INSNEG DAC steps negative insensitivity 17

Esa/Gv 91752.SHRD.0.GB 2.21


Functions for accessing the registers in shared memory SHRD

Field Description Reg. No


AP_TARQUOTA Calibration measure 18
AP_VELMICRO Velocity, micro in calibration 19
AP_VELTACCA Search speed, micro in calibration 20
AP_MINQUOTA Minimum measure 21
AP_MAXQUOTA Maximum measure 22
AP_VELMAN Manual velocity 23
AP_24 Self-learning speed (in preparation.) 24
AP_DELAYS Ramp speed S 25
AP_QCHKTARA Calibration measure alarm (0 = disab ) 26
AP_TIPOTSTENC Encoder Test Type (0 = disab ) 27
AP_OFFSET DAC steps max. offset adjustment (0 = disab) 28
AP_TIMEOFF Offset recovery time 29
AP_RECQTA Inversion play adjustment measure 30
AP_PARKQTA Parking measure 31
AP_EMERTIME Emergency ramp time 32
AP_AXMOD Polar axes module 33
AP_QTARECG Play adjustment measure 34
AP_TYPERECG Play adjustment type 35
AP_TIMCOMDIR Direction Change Timer 36
AP_INERZAV Forwards Inertia Measure 37
AP_INERZIND Backwards Inertia Measure 38
AP_TIMERFRENO Brake Timer 39
AP_AXNZONE Zone Correction Index Table 40
AP_TIMEREG Axis Adjustment Time 41
AP_FATTCONVDIV Conversion Factor (denom) 42

Spindle Axes

The following list show the values allowed for the field field for accessing the Spindle
parameters.

Field Description Reg.


No
SP_AXTYPE Axis/spindle type 0
SP_ACCTIME Acceleration time 1
SP_DECTIME Deceleration time 2
SP_OPTIONS Options: 3
SP_FWERRVLIM Velocity limit for proportional tracking error (0=disab) 4
SP_FWERR Maximum tracking error 5
SP_TOLLERG Rough tolerance measure 6
SP_TOLLERF Fine tolerance measure 7
SP_TOLLER Timer tolerance 8
SP_VELMAX Maximum velocity 9
SP_GAINP P gain 10
SP_GAIND D gain 11
SP_GAINFWD Feed forward 12
SP_MULENC Encoder multiplier 13

2.22 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Field Description Reg.


No
SP_INSPOS DAC steps positive insensitivity 14
SP_FATTCONV Conversion factor 15
SP_TARTYPE Calibration type (not used) 16
SP_INSNEG DAC steps negative insensitivity 17
SP_TARQUOTA Calibration measure 18
SP_VELMICRO Search velocity, micro in calibration 19
SP_VELTACCA Search velocity, mark in calibration 20
SP_VEL10V 10 Volt motor velocity 21
SP_ENCTYPE Encoder on motor (1) or spindle (0) 22
SP_N1 Transmission ratio, range 1 23
SP_N2 Transmission ratio, range 2 24
SP_N3 Transmission ratio, range 3 25
SP_N4 Transmission ratio, range 4 26
SP_VELND Hunting velocity 27
SP_VELLIM1 Limit velocity, range 1 28
SP_VELLIM2 Limit velocity, range 2 29
SP_VELLIM3 Limit velocity, range 3 30
SP_VELLIM4 Limit velocity, range 4 31
SP_VELLTOL Percentage tolerance velocity at operating speed 32
SP_FLT Maximum fluctuation percentage 33
SP_VELMIN Minimum fluctuation velocity 34
SP_VELSTOP Velocity tolerance, spindle stopped 35
SP_VELJOG Spindle velocity in jog mode 36
SP_VELM19 Spindle velocity in orientation 37
SP_EMERTIME Emergency ramp time 38
SP_TIMEREG Axis adjustment time 39
SP_TIPOTSTENC Encoder test type (0 = disab ) 40
SP_QCHKTARA Calibration alarm measure 41

NVEL axes The following list show the values allowed for the field field for accessing the
parameters of an NVEL Axis.

Field Description Reg.


No
NV_AXTYPE Axis/spindle type 0
NV_OPTIONS Options: 1
NV_TOLLERG Rough tolerance measure 2
NV_TOLLER Timer tolerance 3
NV_VELMAX Velocity number 4
NV_FATTCONV Conversion factor 5
NV_TARTYPE Calibration type (not used) 6
NV_TARQUOTA Calibration measure 7
NV_VELMICRO Search velocity, micro in calibration 8
NV_VELTACCA Search velocity, mark in calibration 9
NV_MINQUOTA Minimum measure 10
NV_MAXQUOTA Maximum measure 11

Esa/Gv 91752.SHRD.0.GB 2.23


Functions for accessing the registers in shared memory SHRD

Field Description Reg.


No
NV_VELMAN Manual velocity 12
NV_QCHKTARA Calibration alarm measure (0 = disab ) 13
NV_TIPOTSTENC Encoder test type (0 = disab ) 14
NV_RECQTA Inversion play adjustment measure 15
NV_PARKQTA Parking measure 16
NV_DECV1AVA V2->V1 step forwards measure 17
NV_DECV2AVA V3->V2 step forwards measure 18
NV_DECV1IND V2->V1 step backwards measure 19
NV_DECV2IND V3->V2 step backwards measure 20
NV_DECSOGV1 V2->V1 rough threshold step measure 21
NV_DECSOGV2 V3->V2 rough threshold step measure 22
NV_TIMCOMVEL Velocity commutation timer 23
NV_TIMCOMDIR Direction commutation timer 24
NV_QTARECG Play adjustment measure 25
NV_TYPERECG Play adjustment type 26
NV_INERZAV Forwards inertia measure 27
NV_INERZIND Backwards inertia measure 28
NV_TIMERFRENO Brake handling measure 29
NV_TIMEREG Axis adjustment time 30
NV_FATTCONVDIV Conversion factor (denom) 31

Ram axes

The following list show the values allowed for the field field for accessing the
parameters of a Ram axis.

Field Description Reg.


No
PT_AXTYPE Axis/spindle type 0
PT_ACCTIME Acceleration time 1
PT_DECTIME Deceleration time 2
PT_OPTIONS Options: 3
PT_FWERRVLIM Velocity limit for tracking propagation error 4
(0=disab)
PT_FWERR Maximum tracking error 5
PT_TOLLERG Rough tolerance measure 6
PT_TOLLERF Fine tolerance measure 7
PT_TOLLER Timer tolerance 8
PT_VELMAX Maximum velocity 9
PT_GAINP P gain 10
PT_GAIND D gain 11
PT_GAINFWD Feed-forward gain 12
PT_INSPOS DAC steps positive insensitivity 13
PT_FATTCONV Conversion factor 14
PT_TARTYPE Calibration type (not used) 15
PT_INSNEG DAC steps negative insensitivity 16

2.24 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Field Description Reg.


No
PT_TARQUOTA Calibration measure 17
PT_VELMICRO Search velocity, micro in calibration 18
PT_VELTACCA Search velocity, mark in calibration 19
PT_MINQUOTA Minimum measure 20
PT_MAXQUOTA Maximum measure 21
PT_VELMAN Manual velocity 22
PT_PARKQTA Parking measure 23
PT_EMERTIME Emergency ramp measure 24
PT_JOGUPVEL UP close loop parameters: velocity 25
PT_JOGUPACC UP close loop parameters: acceleration 26
PT_JOGUPGP UP close loop parameters: gain 27
PT_JOGUPTIMT UP close loop parameters: timer tolerance 28
PT_JOGDWVEL DOWN close loop parameters: velocity 29
PT_JOGDWACC DOWN close loop parameters: acceleration 30
PT_JOGDWGP DOWN close loop parameters: gain 31
PT_JOGDWGBL DOWN close loop parameters: K imbalance 32
PT_REFUPVEL Calibration parameters: velocity 33
PT_REFUPACC Calibration parameters: acceleration 34
PT_REFUPGP Calibration parameters: gain 35
PT_TIMEREG Axis adjustment time 36
PT_TIPOTSTENC Encoder test type (0 = disab ) 37
PT_FATTCONVDIV Conversion factor (denom) 38

GetOffParam values,
field field

The following list show the values allowed for the field field for accessing the
parameters of a GetOffParam function.

Field Register to be identified


MULENC Encoder multiplier
FATTCONV Conversion factor
FATTCONVDIV Conversion factor (divider)
QCHKTARA Calibration alarm measure
OPTIONS Options
TOLLERG Rough tolerance
TOLLERF Fine tolerance
TIMETOLL Timer tolerance
TIPOTSTENC Encoder test type
MINQUOTA Minimum measure
MAXQUOTA Maximum measure
TARTYPE Calibration type
VELMICRO Search velocity, slowing micro
TARQUOTA Calibration measure
VELTACCA Search velocity, zero mark
PARKQTA Parking measure

Esa/Gv 91752.SHRD.0.GB 2.25


Functions for accessing the registers in shared memory SHRD

Field Register to be identified


VELMAN Manual velocity
QTARECG Play adjustment measure
TYPERECG Play adjustment type
TIMCOMDIR Direction change timer
INERZAV Forwards inertia
INERZIND Backwards inertia
TIMERFRENO Brake timer
BITFRENO
TIMEREG Axis adjustment time
_VELMAX Maximum velocity
REGFRENO Brake register
REGONM On Motor register

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
if( ShrReadParAxes(Ax,GetOffParam(Ax,QTARECG),&Qrg) )
Qrg=0;
iErr = WriteParAxes(Qta,Ax,GetOffParam(Ax, PARKQTA));
if( iErr != RET_OK )
return( iErr );

2.26 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.5.2 Command and Status Registers (WriteAxes - ShrReadAxes)


These functions perform read and write operations on vectors containing the status and
command registers of each axis contained in the ax[].ra[] vectors; it is necessary,
therefore, to identify the axis number for selecting the ax[] Table, and subsequently
address the parameter of the .ra[] Sub-Table.
Access to these registers is not visible from BaseMenu.

STATUS Registers The status registers provide information on what the axis is doing; a write operation to
these registers is not significant, because the axis continually updates the values of the
status registers.

The command registers make it possible to select a number of operating modes for the
axis, which performs only read operations on these registers.
COMMAND Registers
Generally, the PLC has the task of interacting with the axes on their command
registers; this, however, does not prevent a GUI application from controlling one or
more axes through these registers, provided that this does not create conflicts in
writing between the PLC and GUI.

Syntax
(int) WriteAxes( long value,
int nax,
int field)

(int) ShrReadAxes( int nax,


int field,
long *pVal)

Description

WriteAxes Writes the value to the ax[nax].ra[field] register.


Writing is always by entire registers; if you have to modify just the value of a register
bit, the value must be read from the command register, the bit must be changed and the
new value written.

ShrReadAxes Reads the ax[nax].ra[field] register; the value returned is only significant if the
function terminates correctly.

Parameters

nax Axis number.

field Register selection index.

value Numeric value to be set.

Esa/Gv 91752.SHRD.0.GB 2.27


Functions for accessing the registers in shared memory SHRD

pVal Address of the variable to which the value read from the SharedMemory is
returned.

Command Registers, The following list shows the values allowed for the field field for accessing the
field field values Command registers.

Field Description Reg.


No
AI_CMDREG Axis/spindle command register 0
AI_OVRD Register override 1
AI_QTAIMM Immediate calibration measure 2
AI_SPEED Open Loop spindle speed register 32

Status Registers The following list shows the values allowed for the field field for accessing the Status
field field values registers.

Field Description Reg.


No
AO_STATREG Axis/spindle status register 3
AO_MEASURE Measure 4
AO_VEL Velocity 5
AO_ALAREG Alarm 6
AO_FWERR Tracking error register 7
AO_PROC Process status register 8
AO_LEVSYNC Sync Level Counter 9
AO_NCMDEXEC Number of commands in EXEC queue 10
AO_MASKSYNC Active processes group mask (ENAB) 11
AO_COMID Current ID command 12
AO_SYNCRO Internal synchronization signals 13
AO_VERSLAVE Slave version 14
AO_FF_STAT Feed Forwards status masking 15
AO_QTARGET Distance to go register 16
AO_QUOTASTA Calibration measure register (singfc) 17
AO_REFDAC DAC voltage register 18
AO_ISOAXSTATUS Axis in ISO channel status 19
AO_DUMMY Dummy DacPos On Motor register 20
AO_RVQUOTA Revolver 0-360 measure register 21

2.28 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
iErr = WriteAxes(ISO_NULLO, iAx, AO_ISOAXSTATUS);
if( iErr != RET_OK )
return( iErr );
iErr = ShrReadAxes(iAx, AO_MEASURE,&Measure);
if( iErr != RET_OK )
return( iErr );

Esa/Gv 91752.SHRD.0.GB 2.29


Functions for accessing the registers in shared memory SHRD

2.5.3 Configuration (WriteAxNVel - ShrReadAxNVel - WriteAxNBit - ShrReadAxNBit)


The axes configuration registers identify the physical address of the input and output
interface signals. They are divided into two vectors: the first – ax[ ].nvel[ ] – contains
the address of the registers associated with each signal; the second – ax[ ].nbit[ ] –
indicates the bit relative to the register specified by the first vector for the same signals.
These functions require identification of the axis number for selecting the ax[ ] Table
and subsequently address the parameter of the .nvel[ ] or .nbit[ ] Sub-Table.
The value of the index of the .nvel[] and .nbit[] registers varies depending on the type
of axis configured; it is necessary, therefore, to access the XX_AXTYPE field of the
axes parameters and check the contents to trace the type of axis concerned.

These parameters are accessed using BaseMenu and activating the [Parameters] >
[System] > [Configure Axes] path from the shared editor; both the nvel[ ] and nbit[ ]
Tables are located on the same editing page.

Syntax
(int) WriteAxNVel( long value,
int nax,
int field)

(int) ShrReadAxNVel( int nax,


int field,
long *pVal)

(int) WriteAxNBit( long value,


int nax,
int field)

(int) ShrReadAxNBit( int nax,


int field,
long *pVal)

Description

WriteAxNVel Writes the value in the ax[nax].nvel[field] register.

ShrReadAxNVel Reads the ax[nax].nvel[field] register; the value returned to pVal is significant only if
the function terminates correctly.

WriteAxNBit Writes the value in the ax[nax].nbit[field] register.

ShrReadAxNBit Reads the ax[nax].nbit[field] register; the value returned is significant only if the
function terminates correctly.

2.30 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Parameters

nax Axis number.

field Register selection number. It may assume the values described in the Tables
relative to the axes.

value Numeric value to be set.

pVal Address of the variable to which the value read from the SharedMemory is
returned.

Proportional axis and The following list shows the values allowed for accessing the axis configuration
Spindle field field registers, both for a Proportional axis and for a Spindle.
values

nvel[ ] Registers

Field Description Reg. No


AP_REGONM Motor on output register 0
AP_REGDACPOS Dac Pos output register 1
AP_REGFRENO Brake output register 2
AP_REGFCHWAV Forwards Fc Hw input register 3
AP_REGFCHWIND Backwards Fc Hw input register 4
AP_NUMENC Encoder number 5
AP_ENCTYPE Physical (0) or logical (1) encoder 6
AP_NUMDAC DAC number 7
AP_DACTYPE Physical (0) or logical (1) DAC 8
AP_REGDACPOSIND Backwards Dac Pos output register 9
AP_REGDACPOSAVA Forwards Dac Pos output register 10

nbit[ ] Registers

Field Description Reg. No


AP_BITONM Motor on output bit number 0
AP_BITDACPOS Dac Pos output bit number 1
AP_BITFRENO Brake output bit number 2
AP_BITFCHWAV Forwards Fc Hw output bit number 3
AP_BITFCHWIND Backwards Fc Hw output bit number 4
AP_BITDACPOSIND Backwards Dac Pos output bit number 9
AP_BITDACPOSAVA Forwards Dac Pos output bit number 10

Esa/Gv 91752.SHRD.0.GB 2.31


Functions for accessing the registers in shared memory SHRD

NVEL axis
field field value

The following list shows the values allowed for accessing the configuration registers of
an NVEL axis.

nvel[ ] registers

Field Description Reg. No


NV_VELAV1 Forwards velocity 1 output register 0
NV_VELIND1 Backwards velocity 1 output register 1
NV_VELAV2 Forwards velocity 2 output register 2
NV_VELIND2 Backwards velocity 2 output register 3
NV_VELAV3 Forwards velocity 3 output register 4
NV_VELIND3 Backwards velocity 3 output register 5
NV_REGFRENO Brake output register 6
NV_REGFCHWAV Forwards Input Fc Hw register 7
NV_REGFCHWIND Backwards Input Fc Hw register 8
NV_NUMENC Encoder number 9
NV_ENCTYPE Physical (0) or logical (1) encoder 10
NV_NUMDAC DAC number 11
NV_DACTYPE Physical (0) or logical (1) DAC 12

nbit[ ] Registers

Field Description Reg. No


NV_BITAV1 Forwards velocity 1 output bit number 0
NV_BITIND1 Backwards velocity 1 output bit number 1
NV_BITAV2 Forwards velocity 2 output bit number 2
NV_BITIND2 Backwards velocity 2 output bit number 3
NV_BITAV3 Forwards velocity 3 output bit number 4
NV_BITIND3 Backwards velocity 3 output bit number 5
NV_BITFRENO Brake output bit 6
NV_BITFCHWAV Forwards Fc Hw output bit number 7
NV_BITFCHWIND Backwards Fc Hw output bit number 8

2.32 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

*Ram axis The following list shows the values allowed for accessing the field field for configuring
field field value a Ram axis.

nvel[ ] Registers

Field Description Reg.


No
PT_REGONM On Motor output byte 0
PT_REGDACPOS Dac Pos output byte 1
PT_NUMENC Encoder number 2
PT_ENCTYPE Physical (0) or logical (1) encoder 3
PT_NUMDAC DAC number 4
PT_DACTYPE Physical (0) or logical (1) DAC 5

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
iErr = WriteAxNVel(Numregister,Ax,AP_REGONM);
if( iErr != RET_OK )
return( iErr );
if(ShrReadAxNVel(Ax, AP_REGFCHWIND, &NOut)== RET_OK){
iErr = ShrReadAxNBit(Ax,AP_BITFCHWAV,& NBitPHAv);
if ( iErr!= RET_OK ) {
return( iErr );
}
}

Esa/Gv 91752.SHRD.0.GB 2.33


Functions for accessing the registers in shared memory SHRD

2.6 Accessing the GUI-PLC interface registers (WriteUiPlc - ShrReadUiPlc)

These functions perform read and write operations in the vector set-up for interfacing
between the ui[] GUI and PLC; it is necessary, therefore, to identify the register
address.
Access to these registers is not visible from BaseMenu, but the Basemenu itself
accesses these registers in read and write mode to provide certain information to the
PLC, for example, the mode selected, current channel number, or for reading the axis
number selected.

Syntax
(int) WriteUiPlc( long value,
int field )

(int) ShrReadUiPlc( int field,


long *pVal)

Description

WriteUiPlc Writes the value in the ui[field] register.

ShrReadUiPlc Reads the ui[field] register; the value returned is significant only if the function
terminates correctly.

Parameters

field ui[ ] register selection index. It may assume the values described in the
Table below.

value Numeric value to be set.

pVal Address of the variable to which the value read from the SharedMemory
is returned.

Field field values The field field may assume one of the following values:

Field Description Reg. No


PU_ALM0 PLC alarms registers 0
PU_ALM1 PLC alarms registers 1
PU_ALM2 PLC alarms registers 2
PU_ALM3 PLC alarms registers 3
PU_ALM4 PLC alarms registers 4
PU_ALM5 PLC alarms registers 5

2.34 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

Field Description Reg. No


PU_MSG0 PLC messages registers 6
PU_MSG1 PLC messages registers 7
PU_AXSEL Selected axis register 8
PU_CHSEL Selected channel register 9
PU_TACIALL SILENCE alarm bit 0 (1 -> 0) 14
PU_PLCSTOP PLC register STOPPED 15
UP_MONCHAN Channel monitor page flags register 16
UP_SELCHAN Selected channel 17
UP_AXSEL Selected axis 18
UP_READYCHAN Register of channels set-up for the cycle 19
UP_OVRD1 Axes override register 20
UP_OVRD Spindles override register 21
UP_FIXINCR Fixed increments register 22
UP_JOGOPEN Open Loop JOG register 23
UP_DEBUG Debug register 24

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
iErr = WriteUiPlc( ChSel, PU_CHSEL);
if( iErr != RET_OK )
ChSel = 0;
iErr = ShrReadUiPlc( PU_CHSEL,&Tmp);
if( iErr == RET_OK )
ChSel = Tmp;

Esa/Gv 91752.SHRD.0.GB 2.35


Functions for accessing the registers in shared memory SHRD

2.7 Access to parametric variables

The functions of this category do not allow symbolic variables to be accessed.

2.7.1 Read and write operations on VA, VL and VG variables (WriteVarR -


ShrReadVarR)
These functions allow you to access the non-symbolic variables available in the ISO
part programs for both reading and wiring:
‚ Global Variables (VG)
‚ Local Variables (VL)
‚ Automatic Variables (VA)

These functions distinguish the access to the different types of variables on the basis of
the value specified for a parameter; the meaning of the parameters depends on the type
of variable to which access is made.

Syntax
(int) WriteVarR( double dValue,
int iCh,
int iR,
int iNest,
unsigned char iType)

(int) ShrReadVarR( int iCh,


int iR,
int iNest,
unsigned char iType,
double *pVal)

Description

WriteVarR Writes the value in the variable defined by the iCh, iNest and iR parameters.

ShrReadVarR Reads the variable defined by the iCh, iNest and iR parameters; the value returned is
significant only if the function terminates correctly

N.B. These parameters cannot be omitted, even if they are non-significant.

Parameters

ICh Channel number (significant only for VA and VL variables).

INest Nesting level number (significant only for VA variables).

IR Variable number to be addressed.

2.36 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

iType Indicates the type of variable you wish to access and what its significant
parameters are. It may assume the values indicated in the Table shown
below.

dValue Numeric value (in double) to be set.

PVal Address of the variable to which the value read from the SharedMemory is to
be returned.

The Table that follows indicates the possible values that a field of the iType may
assume, and which parameters are significant for each access. The non-significant
parameters cannot be omitted from the prototype of the function; their value, however,
is ignored.

Itype Significant parameters Register


SHARED_T_VA_SELECT ICh iNest iR cn[ ].lv[ ].va[ ]
SHARED_T_VL_SELECT iCh n.s. iR cn[ ].vl[ ]
SHARED_T_VG_SELECT n.s. n.s. iR vg[ ]

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
iErr = ShrReadVarR(
iCh, idxVar, Lev,
SHARED_T_VL_SELECT,
&dVal
);
if( iErr!= RET_OK)
Error(ERR2);
iErr = WriteVarR(
dval, iCh,
idxVar,Lev,
SHARED_T_VG_SELECT
);
if( iErr!= RET_OK)
Error(ERR21);

Esa/Gv 91752.SHRD.0.GB 2.37


Functions for accessing the registers in shared memory SHRD

2.7.2 Maximum offset of VA, VG and VL variables (GetRegVg - GetRegVa - GetRegVl)


These functions enable you to know the maximum number of variables available for
each group. They do not require parameters, as the sizing does not depend on the
channel instance to which reference is made; the allocation of local and automatic
variables is identical for each channel and for every nesting level.

Syntax
(long) GetRegVg()

(long) GetRegVa()

(long) GetRegVl()

Description These functions return the dimensions of the relative arrays defined in SharedMemory
through the defcn file.

double vg[10]; GetRegVg() restituisce 10;

Example
if( idxVar < GetRegVl() ){
iErr = ShrReadVarR( iCh, idxVar, Lev,
SHARED_T_VL_SELECT, &dVal);
}
else
Error(ERR52);

2.38 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.8 Accessing the Channel Origin registers (WriteOrigin - ShrReadOrigin)

These functions perform read and write operations on the Table containing the origins
of each channel, i.e. origins selected using the instructions G5 – G57; the data are
contained in the cn[].sr[].do[] vectors; it is necessary, therefore, to index the channel
number, the Table of origins (Table0 for G54, 1 for G55..) and the actual origin (0=X,
1=Y..).
These parameters are accessed using BaseMenu and activating the [Parameters] >
[Channel Origins ] path from the shared editor.

Syntax
(int) WriteOrigin( long value,
int nch,
int norig,
int field )

(int) ShrReadOrigin( int nch,


int norig,
int field,
long *pVal)

Description

WriteOrigin Writes the value in the cn[ich].sr[norig].do[field] register.

ShrReadOrigin Reads the cn[ich].sr[norig].do[field] register; the value returned is significant only if
the function terminates correctly.

Parameters

nch Channel number.

norig sr[] array index of the origins [0-3] (associated with the settings of the
instructions from G54 to G57).

field Origin register selection index. It may assume the values described in the
Table that follows.

value Numeric value to be set.

pVal Address of the variable to which the value read from the SharedMemory is
returned.

Esa/Gv 91752.SHRD.0.GB 2.39


Functions for accessing the registers in shared memory SHRD

Field field values The field field may assume one of the following values:

Field Description Reg. No


OG_X X origin co-ordinates 0
OG_Y Y origin co-ordinates 1
OG_Z Z origin co-ordinates 2

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
if( ShrReadOrigin(iCh, iCoord, OG_X, &offX )!=RET_OK)
offX= 0;
if( ShrReadOrigin(iCh, iCoord, OG_Y, &offY )!=RET_OK)
offY= 0;
if( ShrReadOrigin(iCh, iCoord, OG_Z, &offZ )!=RET_OK)
offZ= 0;
iErr = WriteOrigin(0,iCh, iCoord, OG_Z);
if( iErr != RET_OK )
return( iErr );

2.40 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.9 Accessing the IOs (WriteIOWord - ReadIOWord - ReadIOOutputWord)

These functions allow you to access (for reading) the images of the input and output
cards, and to access only the output cards (for writing). Writing to an output board is
not performed directly on the hardware component, but on an image; firmware then
updates the board on which the writing was performed.

Syntax
(int) WriteIOWord( unsigned short Value,
int iR)

(int) ReadIOWord( int iR,


unsigned short*pVal)

(int) ReadIOOutputWord( int iR,


unsigned short *pVal)

Description

ReadIOWord Reads the IW input register specified by the iR offset. The value returned is
significant only if the function terminates correctly.

ReadIOOutputWord Reads the QW output register specified by the iR offset. The value returned is
significant only if the function returns correctly.

WriteIOWord Writes the QW output register specified by the iR offset.

Parameters

iR Number of the input (IW) or the output (QW) to be accessed.

value Numeric value to be set.

pVal Address of the variable to which the value read by the ReadIOWord
and ReadIOOutputWord functions is returned.

Esa/Gv 91752.SHRD.0.GB 2.41


Functions for accessing the registers in shared memory SHRD

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Example
if( WriteIOWord( IdxOut, Value) ){
return( iErr );
}
if( ReadIOWord( IdxInput, &dwValue) != RET_OK )
dwValue = 0;
if( ReadIOOutputWord( IdxOut, &dwValue) != RET_OK )
dwValue = 0;

2.42 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.10 Accessing the machine status registers (ShrReadCNStatus -


ShrReadHeader)

These functions allow you to read a number of NC status registers, namely:

CNSTATUS Status register containing the system alarms of the NC.


SHCHK Register that contains the checksum of the shared memory.

Syntax
(int) ShrReadCNStatus( long *pVal)

(int) ShrReadHeader( int field,


long *pVal)

Description

ShrReadCNStatus Returns the value of the CNSTATUS register. The value returned is only valid if the
function returns correctly.

ShrReadHeader Returns the value of the SHCHK register. The value returned is only valid if the
function returns correctly.

Parameters

field SHARED_CHECK (only for ShrReadHeader).

pVal Address of the variable to which the value read from the function is
returned.

Reply codes

RET_OK Operation performed correctly.


INVALID_RESOURCE_OFFSET Offset too large.
INVALID_RESOURCE_TYPE Invalid resource type.
INVALID_REMOTE_COMMAND Invalid command.
INVALID_PACKET_LENGTH Packet too large.
EMPTY_PACKET Packet not available.

Esa/Gv 91752.SHRD.0.GB 2.43


Functions for accessing the registers in shared memory SHRD

Example
iErr = ShrReadCNStatus(&Status);
if( iErr != RET_OK )
return( iErr );
iErr = ShrReadPLCStatus(&TestPLC);
if( iErr != RET_OK )
return( iErr );

iErr = ShrReadHeader(SHARED_CHEK,&CheckSum);
if( iErr != RET_OK )
return( iErr );

2.44 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.11 Accessing a number of registers simultaneously

The functions of this group implement access to packets of the shared memory, that is,
they allow you to bufferize the requests that are either performed for completing the
buffer, or by explicit request. This technique makes it possible to optimize the accesses
to the physical communication channel, making the latter more efficient; however, the
data are consistent only on filling the buffer or executing a forced flush.
The Shared DLL handles the multiple access to the system registers in implicit mode,
and provides a number of functions that facilitate multiple access also to the non-
system registers.

2.11.1 Allocating the buffer for multiple requests (BeginPackedOperation)

Description This function allocates a buffer for multiple requests. The buffer is set-up to hold a
maximum of 30 requests.

This call is to be performed for each thread that intends to use multiple accesses.

Syntax
(int) BeginPackedOperation()

Reply codes

MALLOC_KVCOM_DATA_PACK_KO The operation terminated incorrectly, as


there were problems in allocating
memory. The operations that follow
will be performed individually, and not
packed.
KVCOM_DATA_PACK_OK The initialization terminated correctly;
the operations that follow comprising
StartPackedOperation and
FlushPackedOperation will be
performed as just one request to the
communications server.

Esa/Gv 91752.SHRD.0.GB 2.45


Functions for accessing the registers in shared memory SHRD

2.11.2 Starting a multiple request section (StartPackedOperation)

Syntax
(int) StartPackedOperation()

Description All the read and write functions of the Shared DLL that follow this call will be packed.
This means that such functions will be placed in the request buffer, and only following
a FlushPackedOperation will they be sent to the communication server.

Reply codes

0 The operation terminated correctly, and the


buffer is ready for holding multiple requests.
KVCOM_DATA_START_KO A buffer has not been allocated, or the
StartPackedOperation function has already
been performed.

2.46 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.11.3 Explicit request for access to the shared memory (FlushPackedOperation)

Syntax
(int) FlushPackedOperation()

Description This function forces performance of the requests to access the shared memory
accumulated starting from the last StartPackedOperation.
An implicit flush is performed in any case when the number of homogeneous accesses
reaches 30. Multiple requests must be of the same type, and for this reason it is
necessary to carry out a read and write operation in SharedMemory (or vice-versa); a
forced flush is always performed between the two requests.

Reply codes

KVCOM_DATA_PACK_OK The operation terminated correctly; this means that


all the write or read operations have been performed
correctly. If read operations are concerned, only after
the flush will the values read be available in the
indicated registers.
ERR_MULTIREAD + N A read error has occurred in reading the nth request
(n from 0 to 29).
ERR_MULTIWRITE + N A write error has occurred in writing the nth request
(n from 0 to 29).

ERR_MULTIREAD+N 0x8000 ... 0x801D


ERR_MULTIWRITE+N 0x8100 ... 0x811D

Esa/Gv 91752.SHRD.0.GB 2.47


Functions for accessing the registers in shared memory SHRD

2.11.4 Bufferizing accesses to non-system registers (AppendRequest)

Syntax
(int)AppendRequest( SHR_OP OpType,
LPTS_REG field,
DWORD Offset,
LPVOID pVal,
int size)

Description For non-system registers it is necessary to call up this function for storing the relative
information for accessing the request buffer.
If more than 30 AppendRequests are called up, or there are two successive
AppendRequests with non-homogeneous operations types, a FlushPackedOperation
is performed automatically; for this reason, ERR_MULTIREAD and
ERR_MULTIWRITE are found between the error codes.

In one and the same section of multiple accesses, included between a


StartPackedOperation and a FlushPackedOperation, both accesses to system
registers and non-system registers (both AppendRequest and Shared DLL functions)
may occur.

Parameters

opType Specifies access type:


‚ RD read access
‚ WR write access.

field Address of the register to be accessed.

Offset Offset (if any) relative to the TS_REG (if an array is concerned).

pVal Return buffer of the variable read, if the operation required is a READ.
Value to be set, if the operation required is a WRITE.

size Size of pVal.

Reply codes

0 The operation terminated correctly.


RET_KO No buffer has been reserved for the multiple requests.
ERR_MULTIREAD + N An error has occurred in reading the n-th request (n
from 0 to 29).
ERR_MULTIWRITE + N An error has occurred in writing the n-th request (n
from 0 to 29).

2.48 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

2.11.5 Freeing the buffer (EndPackedOperation)

Syntax
(int) EndPackedOperation()

Description This function frees the buffer reserved for multiple requests.
This call is to be performed for each thread that invoked the BeginPackedOperation.

Reply codes

0 The operation has terminated correctly.


MALLOC_KVCOM_DATA_PACK_KO There were problems in performing the
free buffer operation.

Example
BeginPackedOperation(); buffer allocation
// at this point, the data structure to be used
// for multiple read and write operations is available
...
StartPackedOperation();
// from this moment on, homogeneous requests are queued in
//the buffer

Err =ShrRead...(..,&ReadReg[0]);
Err =ShrRead...(..,&ReadReg[1]);
... ... ...
Err =ShrRead...(..,&ReadReg[n]);

Err = FlushPackedOperation();
// forces access to shared; only now are the
//ReadReg registers passed to the respective
// ShrRead...() containing the value awaited

StartPackedOperation();
// from this moment on, homogeneous requests are queued in
//the buffer

Err =ShrWrite...();
Err =ShrWrite...();
... ... ...
Err =AppendRequest(WR, ...);
Err =ShrWrite...();
Err = FlushPackedOperation();
//forces access to shared; only now are the registers in
//shared updated

....
EndPackedOperation(); frees the buffer
// This function is necessary for de-allocating the
reserved memory
//(it is very large)

Esa/Gv 91752.SHRD.0.GB 2.49


Functions for accessing the registers in shared memory SHRD

2.12 Auxiliary debug functions (_StartSharedReport - _EndSharedReport -


_SetCallStackReport - _SetStatusReport)

The functions described below allow you to generate a report for each call for a Shared
DLL function. This information allows you to check the number of accesses
to the Shared, and to check if the requests are actually packed.

N.B. To enable the user interface to use this information, you will have to modify the
FAKLOG library so that it generates a Report File.

Syntax
(int) _StartSharedReport()

(int) _EndSharedReport()

(int) _SetCallStackReport( char *szCaller)

(int) _SetStatusReport( char *szCaller)

Description

_StartSharedReport Enables the report to be generated.

_EndSharedReport Stops report generation.

_SetCallStackReport Enables the insertion of auxiliary information.

_SetStatusReport Enables the insertion of auxiliary information.

Parameters

szCaller String containing auxiliary information.

Example The following coding


int GestStatiAux(){
_StartSharedReport();
...
_SetStatusReport("KPAUX");
_SetCallStackReport("GestStatiAux");
...
_EndSharedReport();
}

2.50 91752.SHRD.0.GB Esa/Gv


SHRD Functions for accessing the registers in shared memory

generates the following report:

KPAUX_E_GestStatiAux (0=$0) - Request #57: ReadPLCStatus,0


KPAUX_E_GestStatiAux (0=$0) - Request #58: ReadAxes,8
KPAUX_E_GestStatiAux (0=$0) - Request #59: ReadParAxes,0
KPAUX_E_GestStatiAux (0=$0) - Request #5A: ReadAxes,0
KPAUX_E_GestStatiAux (0=$0) - Request #5B: ReadAxes,3

Status Callstack Request Number ShrFunction register

KPAUX_E_GestStatiAux (0=$0) - Request #5C: ReadAxes,8

END OF CHAPTER

Esa/Gv 91752.SHRD.0.GB 2.51


Functions for accessing the registers in shared memory SHRD

2.52 91752.SHRD.0.GB Esa/Gv


SHRD File management functions

3 File management functions

3.1 Opening files (PgmOpen)

Syntax
(int) PgmOpen(int iCh,
struct s_hprog *pPgm,
char *type,
char *name,
char *opt);

Description PgmOpen opens the file specified in name, making a search starting from the paths
specified in KVARA.INI.

To search for the file name, proceed as follows:


‚ In the directory associated with the specific type key of the PGM<1-5,8>
channel.
‚ In the directories associated with default PGM type key/keys.
‚ In the current directory.

If the file is opened correctly, the file handle is returned to pPgm to be used as input
to the functions that follow.

Parameters

iCh Channel number.

pPgm Return variable containing the file handle.

Type Type of file to be opened - “PGM”, “CFS” or other key containing the
search path in KVARA.INI under the section [CHA.PATH]. A number of
alternative keys can be specified using OR, for example “CFS|CFU”.

Name String containing the name of the file to be opened. The extension may
be omitted if the key that specifies the extension is present in KVARA.INI
under the section [CHA.EXT].

Opt Defines the opening options:


‚ r: open in read mode;
‚ a: append mode; the file is opened in write mode starting from the
end of the file.

Esa/Gv 91752.SHRD.0.GB 3.1


File management functions SHRD

Reply codes

RET_OK The operation has been performed


correctly.
KSTREAM_FILE_NOT_FOUND The file has not been found; check
that the search name or path is
correct.
KSTREAM_SHARING_VIOLATION Sharing error; the file to be opened is
already in use.
KSTREAM_NOT_ENOUGH_MEMORY There is insufficient memory to open
the file.

3.2 91752.SHRD.0.GB Esa/Gv


SHRD File management functions

3.2 Closing files (PgmClose)

Syntax
(int) PgmClose(struct s_hprog *pPgm);

Description Closes the file specified by pPgm.

Parameters

pPgm File handle to be closed.

Reply codes

RET_OK The operation has terminated OK.


EOF The operation has terminated incorrectly.

Esa/Gv 91752.SHRD.0.GB 3.3


File management functions SHRD

3.3 Positioning within the file (PgmSeek)

Syntax
(int) PgmSeek(struct s_hprog *pPgm,
long offs,
int whence);

Description This function moves the file pointer to the position determined by the starting point
plus the offset value.
N.B. This function only allows PGM_SE to be used, i.e. the offset is always relative to
the start of the file.

Parameters

pPgm File handle.

offs Number of offset bytes starting from whence.

whence Only PGM_SET is allowed (start of file).

Reply codes

RET_OK The operation has terminated OK.


RET_KO An error has occurred during positioning.

3.4 91752.SHRD.0.GB Esa/Gv


SHRD File management functions

3.4 Positioning at the start of file (PgmRewind)

Syntax
(void) PgmRewind(struct s_hprog *pPgm);

Description Positions the file pointer at the start of file and resets the error and EOF indicator.

Parameters

pPgm File handle.

Esa/Gv 91752.SHRD.0.GB 3.5


File management functions SHRD

3.5 Current position within the file (PgmTell)

Syntax
(long) PgmTell(struct s_hprog *pPgm);

Description This function returns the current value of the file pointer, specified by pPgm.

Parameters

pPgm File handle.

Reply codes

RET_OK The operation has terminated OK.


RET_KO There has been an error.

3.6 91752.SHRD.0.GB Esa/Gv


SHRD File management functions

3.6 Reading a line (PgmGets)

Syntax
(char*) PgmGets( char *s,
int n,
struct s_hprog *pPgm);

Description This function returns the characters read in s. PgmGets; it reads up to n-1 characters,
or stops if it encounters a newline character. It terminates s with the ‘\0’ character.

Parameters

s Reception buffer.

n Buffer size.

pPgm File handle.

Reply codes

!=NULL The return string is valid.


NULL The operation has terminated incorrectly.

Example
if( !PgmGets(pszBuffer, _BUFLEN, phPP, &iErr) ) {
if( !PgmFeof(pIntData->phPP) )
;//Read Error
}

Esa/Gv 91752.SHRD.0.GB 3.7


File management functions SHRD

3.7 Reading a character (PgmGetc)

Syntax
(int) PgmGetc(struct s_hprog *pPgm);

Description Reads just one character starting from the current position of the file.

Parameters

pPgm File handle.

Reply codes

Character read The value of the character read.


EOF An EOF has been encountered, or there has been an error.

3.8 91752.SHRD.0.GB Esa/Gv


SHRD File management functions

3.8 Check EndOfFile (PgmEnd - PgmFeof)

Syntax
(int) PgmEnd( struct s_hprog *pPgm);

(int) PgmFeof(struct s_hprog *pPgm);

Description These functions check if the file pointer is positioned at the EOF.

Parameters

pPgm File handle.

Reply codes

TRUE The file pointer has reached EOF.


FALSE The file pointer has not reached EOF.

Esa/Gv 91752.SHRD.0.GB 3.9


File management functions SHRD

3.9 Checking the error value (PgmErr)

This function returns the error value set by the file management functions, if they have
terminated incorrectly.

Syntax
(int) PgmErr(struct s_hprog *pPgm);

Parameters

pPgm File handle.

Reply codes

0 There have been no errors.


!=0 Specific value of the error, produced by one of the file management functions.

3.10 91752.SHRD.0.GB Esa/Gv


SHRD File management functions

3.10 Resetting the error value (PgmClearerr)

Syntax
(void) PgmClearerr(struct s_hprog *pPgm);

Description Clears the error and EOF indicators associated with the file. The indicators are
automatically reset, calling up the Seek and Rewind functions.

Parameters

pPgm File handle.

END OF CHAPTER

Esa/Gv 91752.SHRD.0.GB 3.11


File management functions SHRD

3.12 91752.SHRD.0.GB Esa/Gv


What do you think of this manual ?
We would be grateful for opinion about the following aspects of this manual:
Aspect in question Excellent Good Sufficient Insufficient Very bad

Ease with which the data can be consulted

Way in which the descriptions of the various


subjects are given

Completeness

Accuracy

Readability

Correctness of the terminology

Page layout

Number of illustrations

Quality of the illustrations

Please give us an evaluation of the overall quality of each chapter in the manual you have just consulted:
Chapter Excellent Good Sufficient Insufficient Very bad
number

Please write the code of the manual in this space:


(the code is printed on the frontispiece)

Comments:_______________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
_______________________________________________________________________________________
Write your address in the following space if you consider it necessary:
Name:_________________________________________________________________________________________________
Company: _____________________________________________________________________________________________
Address: ______________________________________________________________________________________________
Tel: ____________________________ Fax: ________________________________________________________________

Thanks for your help!


You can send this form via FAX, our number is +39-059-851313, or post it to our address: Esa-Gv - Ufficio
Documentazione Tecnica - 15 via Zamboni, Cp 43 - 41011 Campogalliano (Italy)
http://www.esagv.it - E-mail: info@esagv.it

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy