 |
» |
|
 |
|
 |

Copyright (c) Digital Equipment Corporation 1993. All rights reserved
-----------------------------------------------------------------------
Title: Use of BCC$PARSE to return data type in 'buffer' DSC$K_DTYPE_Z
-----------------------------------------------------------------------
Component: BASEstar (Classic) for VMS OP/SYS: VMS
SOURCE: Digital Customer Support Center
Version Information:
Applies to: Classic BASEstar, Version 3.1B, KERNAL 3.1-040
and prior.
-----------------------------------------------------------------------
GENERAL INFORMATION ARTICLE:
-----------------------------------------------------------------------
Here is a suggestion that should speed up handling of
notification messages in many applications.
Several BASEstar users have mentioned a potential performance problem
for an application which has requested notification for multiple
points which may have different data formats. Since the data format
can't be determined before the first call to
BCC$PARSE_NOTIFICATION_MSG there is no way to know which data type to
use for the buffer passed to the service. Most users have solved this
problem by calling the BCC$PARSE... service once to determine the
compiled point name, which is then used to get the data format.
BCC$PARSE... is then called a second time with a buffer of the correct
format to retrieve the data.
There is a way to accomplish the same results with one BCC$PARSE...
call. Call BCC$PARSE... requesting the compiled point name and
specifying a buffer with a data type of DSC$K_DTYPE_Z (Unspecified
data type). This will allow BASEstar to copy the data from the
notification message to the buffer without any format conversion. The
application can then determine the data format from the compiled point
name as before. A variable or structure of the correct data type can
then be overlayed on the buffer based on the data format of the point.
----------------------------------------------------------------
The following PLI program is provided as a EXAMPLE ONLY.
----------------------------------------------------------------
NOTIFY: PROCEDURE
OPTIONS (MAIN);
/*****************************************************************************/
/* */
/* Very crude program to demonstrate the use of a Z-TYPE descriptor */
/* (Unspecified) in a PLI program. Note that the class should be SCALAR. */
/* This is the only class currently supported by BASEstar Data Manager. */
/* Data Manager will copy the data without converting it when a Z-TYPE */
/* descriptor is specified. Note that this program is expecting the data */
/* to be a longword. In an application you would need to find out the */
/* defined data type of the point and use the proper overlay definition. */
/* */
/*****************************************************************************/
%INCLUDE 'SYS$LIBRARY:BCCDEFS.PLI';
%INCLUDE $DSCDEF;
%INCLUDE $STSDEF;
%INCLUDE LIB$STOP;
%REPLACE TRUE BY '1'B;
%REPLACE FALSE BY '0'B;
/* */
/* Local variable declarations. */
/* */
DCL POINT_NAME CHAR(50),
COMPILED_NAME CHAR(BCC$K_CPN_LEN),
(EXIT_REQUESTED, FIRST_TIME) BIT ALIGNED,
MESSAGE_PORT FIXED BIN(31),
MESSAGE_POINTER POINTER;
DCL DATA CHAR (2000);
DCL 1 ZDESCR LIKE DSCDEF1;
DCL LONG_OVERLAY FIXED BIN(31) BASED(ADDR(DATA));
DCL WORD_OVERLAY FIXED BIN(15) BASED(ADDR(DATA));
ON FINISH BEGIN;
PUT SKIP LIST ('Canceling Notifications');
sts$value = BCC$CANCEL_VALUE('*',MESSAGE_PORT);
if ^sts$success THEN PUT SKIP LIST ('Error CANCELLING:',sts$value);
sts$value = BCC$DELETE_MSGPORT(MESSAGE_PORT);
if ^sts$success THEN PUT SKIP LIST ('Error DELETING:',sts$value);
PUT SKIP LIST ('Cancel notification done');
END;
/* */
/* Create the BASEstar port to receive notification messages */
/* */
STS$VALUE = BCC$CREATE_MSGPORT (MESSAGE_PORT,500 ,100 );
IF ^STS$SUCCESS THEN
CALL LIB$STOP (STS$VALUE);
/* */
/* Set up the TYPE Z Descriptor to a data buffer. */
/* */
ZDESCR.DSC$B_DTYPE = DSC$K_DTYPE_Z;
ZDESCR.DSC$B_CLASS = DSC$K_CLASS_S;
ZDESCR.DSC$W_MAXSTRLEN = SIZE(DATA);
ZDESCR.DSC$A_POINTER = ADDR(DATA);
/* */
/* Request the points to get notifications for. */
/* */
EXIT_REQUESTED = FALSE;
FIRST_TIME = TRUE;
PUT SKIP LIST
('Enter the name to request notification for: (<CR> when done)');
PUT SKIP;
DO UNTIL (EXIT_REQUESTED);
POINT_NAME = '';
GET LIST (POINT_NAME) OPTIONS (PROMPT('Point Name: '));
IF (POINT_NAME = '') THEN
EXIT_REQUESTED = TRUE;
ELSE
DO;
FIRST_TIME = FALSE;
STS$VALUE = BCC$REQUEST_VALUE_MSG (POINT_NAME,
MESSAGE_PORT);
IF ^STS$SUCCESS THEN
DO;
PUT SKIP LIST ('Error requesting notification for '||
TRIM(POINT_NAME));
PUT SKIP;
END;
END;
END;
IF FIRST_TIME THEN STOP;
/* */
/* Wait for notification messages */
/* */
DO WHILE (TRUE);
STS$VALUE = BCC$RECEIVE_MSG (MESSAGE_PORT,
MESSAGE_POINTER,,,,,);
IF ^STS$SUCCESS THEN
CALL LIB$STOP (STS$VALUE);
STS$VALUE = BCC$PARSE_NOTIFICATION_MSG ( MESSAGE_POINTER,,,
ZDESCR);
IF ^STS$SUCCESS THEN CALL LIB$STOP (STS$VALUE);
PUT SKIP LIST ('Point value = ',LONG_OVERLAY);
STS$VALUE = BCC$DELETE_MSG (MESSAGE_POINTER);
IF ^STS$SUCCESS THEN CALL LIB$STOP (STS$VALUE);
END;
END NOTIFY;
-----------------------------------------------------------------------
|
buy online or call 1.800.AT.COMPAQ
|
|