NAPOPC Server 001
back
Q: The digital input
channel shows "-1" which displays within our OPC client software when
using NAPOPC
DA server and the channel with "ON" condition. This reading changes from 0 to -1 (OFF & ON)
instead of
0
to 1. Other OPC server software displays these
numerals correctly.
¡@
Ans:
Please refer to the "Automation Programmer's
Reference/Microsoft Press" book,
page 164 to 165.
======= Cut from "Automation
Programmer's Reference" =======
VT_I2
A 2-byte integer value is stored in iVal.
VT_BOOL
A Boolean (True/False) value was specified. A value of 0xFFFF
(all bits 1) indicates True; a value of 0 (all bits 0) indicates
False. No other values are valid.
================ End of cut
==================
In C/C++ computer language, a value of 0
indicates False; other values (For examples: 0xFFFF, -1, 1
or....) indicates True.
But in
OLE/COM/DCOM/OPC, a value of 0xFFFF
(-1) indicates True; a value of 0 indicates False. No other
values are valid. Microsoft defines this in the OLE
specification.
In the NAPOPC DA server, the digital bit input
uses the VT_BOOL data type. Thus, it always has to returns 0xFFFF
(equal to -1) or 0. And the client program can explain the value
of -1 to "TRUE", "ON", "High" or...
If other OPC servers return 0 or 1 to
indicates False or True, they should use the VT_I2 data type to
return a integer value. Then the client programs have to check
the returned value if it is between 0 and 1 (It may return an
invalid value).
¡@
Written by Gary
Date:2004/9/7 |