📄 udpntscn.h
字号:
/* $Header: "%n Ver=%v %f LastEdit=%w Locker=%l" */
/* "UDPNTSCN.H Ver=1 5-Nov-97,14:00:00 LastEdit=JIMV Locker=***_NOBODY_***" */
/***********************************************************************\
* *
* Copyright Wonderware Software Development Corp. 1992-1997 *
* *
* ThisFileName="L:\ww\dde_serv\src\udsample\udpntscn.h" *
* LastEditDate="1997 Nov 05 14:00:00" *
* *
\***********************************************************************/
#ifndef H__pointscan
#define H__pointscan
/***********************************************************************
***********************************************************************
* POINT NAME VALIDATION routines *
***********************************************************************
***********************************************************************/
/** These routines support the use of a table to define valid patterns
for point names. For example,
NAME ADDRESS RANGE(S) SUFFIX USAGE
V 0, 65535 <none> integer
R real (IEEE format)
. real (IEEE format)
P real (IBM format)
is often represented in our manuals as
V#
V#R
V#.
V#P
where the # represents a string of decimal digits determining an address.
Other conventions used in the manuals include
V#-#B address blocks (i.e. strings) with blank padding
V#-#C address blocks (i.e. strings) C-style, with terminating zero
V#:# bit addressing, e.g. V234:10 is bit 10 of item 234 in V memory
The approach is to scan the point name and prepare a pattern description,
then search through the table for a matching pattern. The table can
contain descriptive constants (e.g. DDE data types and subtypes) that
can then be used to handle reading and writing the point data.
Example:
V1250-1743B
is composed of 4 components:
{"V",char or string} {"1250",number} {"-",char or string}
{"1743",number} {"B",char or string}
which we abbreviate as "V9-9B"
The reason we use '9' instead of '#' is to allow for the possibility
that the point names for some devices may actually use the '#' sign.
Now we LOOK for a table entry "V9-9B", and if we find that pattern
in the table, we flag that a match has been found and return the
index into the table.
Two additional simplifications are provided:
- Number interpretation.
As each string of digits is scanned, it is converted to a signed
long number. If the number is found to be out of range, the
point name is flagged as invalid. Converted numbers are returned
in an array, so the calling program only needs to handle these
values as addr[0], addr[1], etc. in a way appropriate to the
point name as identified by the pattern.
Examples:
- V1250-1743 corresponds to pattern "V9-9" with numbers
addr[0]=1250 and addr[1]=1743. The table should include
at least the pattern "V9-9" and something to identify this
as a string, e.g.
{"V9-9", P_STR, TI_V, PTT_STRING}
The calling program can then use a switch statement to
recognize the type P_STR and process addr[0] as the starting
address, addr[1] as the ending address.
- V234:10 corresponds to pattern "V9:9" with numbers
addr[0]=234 and addr[1]=10. The table should include
at least the pattern "V9:9" and something to identify this
as a bit access, e.g.
{"V9:9", P_BIT, TI_V, PTT_DISCRETE}
The calling program can then use a switch statement to
recognize the type P_BIT and process addr[0] as the point
address, addr[1] as the bit selection.
- Wild card characters.
The table can contain patterns that include one or more question mark
characters ('?'). This matches any character except an ASCII zero
(i.e. end of string). This is mostly to reduce the size of the table
and to streamline the search process. The calling program should
check any characters that were matched to wild cards, accept only
valid choices, and process the parameters accordingly. Of course,
if the point name actually is supposed to CONTAIN a question mark,
the calling program will need to verify that it actually got one,
not just "any" character.
Examples:
- V1250-1743 corresponds to pattern "V9-9" with numbers
addr[0]=1250 and addr[1]=1743.
V1250-1743B, V1250-1743C, and V1250-1743P all correspond to
pattern "V9-9?" with numbers addr[0]=1250 and addr[1]=1743.
The table should reflect this distinction:
{"V9-9", P_STR, TI_V, PTT_STRING}
{"V9-9?", P_STRS, TI_V, PTT_STRING}
and when processing the type P_STRS, the calling program should
check whether the wild-card was any of 'B', 'C', or 'P' and
process the point name appropriately if a match was found, or
flag it as invalid if the character was anything else.
**/
typedef struct tagMNEPATTERN /* point mnemonic pattern */
{
LPSTR pattern_buf; /* location of pattern buffer */
int pattern_size; /* size of pattern buffer */
BOOL enable_case; /* if TRUE, case is significant, i.e. 'A' != 'a' */
LONG FAR *addresses; /* location of address storage array */
int address_max; /* number of addresses permitted */
int address_count; /* number of addresses found */
LPSTR pattern_table; /* location of pattern table */
unsigned long element_size; /* size of table element */
int element_count; /* number of elements in table */
int match_index; /* index of element matching pattern */
} MNEPATTERN;
typedef MNEPATTERN FAR *LPMNEPATTERN; /* pointer to mnemonic pattern */
/***********************************************************************/
/** initialize mnemonic pattern **/
BOOL WINAPI InitializeMNEPATTERN (LPMNEPATTERN mne_patt,
LPSTR patt_buf, int patt_buf_size,
LONG FAR *address_array, int addr_max,
LPSTR pattern_table,
unsigned long entry_size, int num_entries);
/***********************************************************************/
/** scan point name, produce pattern string, list of values;
return TRUE if pattern string is in correct format;
return index+1 of table element that matches pattern;
if there is no match, return 0 **/
BOOL WINAPI ScanPointName (LPSTR lpszPointName, LPMNEPATTERN mne_patt);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -