Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
46c028fe
Commit
46c028fe
authored
Mar 12, 2007
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
6a813866
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
355 additions
and
70 deletions
+355
-70
opc/lib/opc/src/opc_utl.cpp
opc/lib/opc/src/opc_utl.cpp
+289
-48
opc/lib/opc/src/opc_utl.h
opc/lib/opc/src/opc_utl.h
+66
-22
No files found.
opc/lib/opc/src/opc_utl.cpp
View file @
46c028fe
/*
/*
* Proview $Id: opc_utl.cpp,v 1.
4 2007-03-08 08:10:03
claes Exp $
* Proview $Id: opc_utl.cpp,v 1.
5 2007-03-12 07:52:02
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include "opc_utl.h"
#include "opc_utl.h"
#include "opc_soap_Stub.h"
#include "opc_soap_Stub.h"
pwr_tString16
str_dt
[
20
]
=
{
"str
"
,
static
pwr_tString16
str_dt
[
20
]
=
{
"string
"
,
"boolean"
,
"boolean"
,
"float"
,
"float"
,
"double"
,
"double"
,
...
@@ -63,6 +63,146 @@ static char opc_PropertyNames[17][20] = {"dataType",
...
@@ -63,6 +63,146 @@ static char opc_PropertyNames[17][20] = {"dataType",
"openLabel"
,
"openLabel"
,
"timeZone"
};
"timeZone"
};
static
char
opc_ResultCodes
[
23
][
30
]
=
{
"s:S_CLAMP"
,
"s:S_DATAQUEUEOVERFLOW"
,
"s:S_UNSUPPORTEDRATE"
,
"s:E_ACCESS_DENIED"
,
"s:E_BUSY"
,
"s:E_FAIL"
,
"s:E_INVALIDCONTINUATIONPOINT"
,
"s:E_INVALIDFILTER"
,
"s:E_INVALIDHOLDTIME"
,
"s:E_INVALIDITEMNAME"
,
"s:E_INVALIDITEMPATH"
,
"s:E_INVALIDPID"
,
"s:E_NOSUBSCRIPTION"
,
"s:E_NOTSUPPORTED"
,
"s:E_OUTOFMEMORY"
,
"s:E_RANGE"
,
"s:E_READONLY"
,
"s:E_SERVERSTATE"
,
"s:E_TIMEDOUT"
,
"s:E_UNKNOWNITEMNAME"
,
"s:E_UNKNOWNITEMPATH"
,
"s:E_WRITEONLY"
,
"s:E_BADTYPE"
};
static
char
opc_ResultTexts
[
23
][
20
]
=
{
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
,
"edgar o was here"
};
void
opcsrv_returnerror
(
std
::
vector
<
ns1__OPCError
*>&
errors
,
std
::
string
*
rc
,
int
err_code
,
unsigned
int
options
)
{
pwr_tString32
str
;
int
ii
;
bool
exists
=
false
;
opc_resultcode_to_string
(
err_code
,
str
);
rc
=
new
std
::
string
(
str
);
for
(
ii
=
0
;
ii
<
(
int
)
errors
.
size
();
ii
++
)
{
if
(
strncmp
(
errors
[
ii
]
->
ID
.
c_str
(),
str
,
sizeof
(
str
))
==
0
)
{
exists
=
true
;
}
}
if
(
!
exists
)
{
ns1__OPCError
*
oe
=
new
ns1__OPCError
();
oe
->
ID
=
std
::
string
(
str
);
if
(
options
&
opc_mRequestOption_ReturnErrorText
)
{
opc_resultcode_to_text
(
err_code
,
str
);
oe
->
Text
=
new
std
::
string
(
str
);
}
errors
.
push_back
(
oe
);
}
}
bool
opc_requestoptions_to_mask
(
ns1__RequestOptions
*
options
,
unsigned
int
*
mask
)
{
if
(
!
options
)
{
*
mask
=
0
;
return
false
;
}
if
(
options
->
ReturnErrorText
)
*
mask
|=
*
options
->
ReturnErrorText
?
opc_mRequestOption_ReturnErrorText
:
0
;
if
(
options
->
ReturnDiagnosticInfo
)
*
mask
|=
*
options
->
ReturnDiagnosticInfo
?
opc_mRequestOption_ReturnDiagnosticInfo
:
0
;
if
(
options
->
ReturnItemTime
)
*
mask
|=
*
options
->
ReturnItemTime
?
opc_mRequestOption_ReturnItemTime
:
0
;
if
(
options
->
ReturnItemPath
)
*
mask
|=
*
options
->
ReturnItemPath
?
opc_mRequestOption_ReturnItemPath
:
0
;
if
(
options
->
ReturnItemName
)
*
mask
|=
*
options
->
ReturnItemName
?
opc_mRequestOption_ReturnItemName
:
0
;
return
true
;
}
bool
opc_resultcode_to_string
(
int
type
,
char
*
str
)
{
str
=
opc_ResultCodes
[
type
];
return
true
;
}
bool
opc_resultcode_to_text
(
int
type
,
char
*
str
)
{
str
=
opc_ResultTexts
[
type
];
return
true
;
}
bool
opc_string_to_resultcode
(
char
*
str
,
int
*
type
)
{
int
ii
;
for
(
ii
=
0
;
ii
<
opc_cResultCodesSize
;
ii
++
)
{
if
(
strncmp
(
opc_ResultCodes
[
ii
],
str
,
sizeof
(
opc_ResultCodes
[
ii
]))
==
0
)
{
*
type
=
ii
;
return
true
;
}
}
return
false
;
}
//
// Return the corresponding opc type string for a pwr_eType
//
pwr_tStatus
time_AtoOPCAscii
(
pwr_tTime
*
tp
,
char
*
buf
,
int
bufsize
)
pwr_tStatus
time_AtoOPCAscii
(
pwr_tTime
*
tp
,
char
*
buf
,
int
bufsize
)
{
{
...
@@ -83,14 +223,77 @@ pwr_tStatus time_AtoOPCAscii (pwr_tTime *tp, char *buf, int bufsize)
...
@@ -83,14 +223,77 @@ pwr_tStatus time_AtoOPCAscii (pwr_tTime *tp, char *buf, int bufsize)
//
//
// Return the corresponding opc type for a opc type string
// Return the corresponding opc type for a opc type string
//
//
bool
opc_opctype_to_value
(
void
*
bufp
,
int
size
,
int
opc_type
)
{
switch
(
opc_type
)
{
case
opc_eDataType_string
:
break
;
case
opc_eDataType_boolean
:
if
(
*
(
char
*
)
bufp
)
{
sprintf
((
char
*
)
bufp
,
"true"
);
}
else
{
sprintf
((
char
*
)
bufp
,
"false"
);
}
break
;
case
opc_eDataType_float
:
snprintf
((
char
*
)
bufp
,
size
,
"%f"
,
*
(
pwr_tFloat32
*
)
bufp
);
break
;
case
opc_eDataType_decimal
:
case
opc_eDataType_double
:
snprintf
((
char
*
)
bufp
,
size
,
"%f"
,
*
(
pwr_tFloat64
*
)
bufp
);
break
;
case
opc_eDataType_long
:
snprintf
((
char
*
)
bufp
,
size
,
"%lli"
,
*
(
long
long
int
*
)
bufp
);
break
;
case
opc_eDataType_int
:
snprintf
((
char
*
)
bufp
,
size
,
"%i"
,
*
(
pwr_tInt32
*
)
bufp
);
break
;
case
opc_eDataType_short
:
snprintf
((
char
*
)
bufp
,
size
,
"%hi"
,
*
(
pwr_tInt16
*
)
bufp
);
break
;
case
opc_eDataType_byte
:
snprintf
((
char
*
)
bufp
,
size
,
"%hhi"
,
*
(
pwr_tChar
*
)
bufp
);
break
;
case
opc_eDataType_unsignedLong
:
snprintf
((
char
*
)
bufp
,
size
,
"%llu"
,
*
(
long
long
unsigned
*
)
bufp
);
break
;
case
opc_eDataType_unsignedInt
:
snprintf
((
char
*
)
bufp
,
size
,
"%u"
,
*
(
pwr_tInt32
*
)
bufp
);
break
;
case
opc_eDataType_unsignedShort
:
snprintf
((
char
*
)
bufp
,
size
,
"%hu"
,
*
(
pwr_tUInt16
*
)
bufp
);
break
;
case
opc_eDataType_unsignedByte
:
snprintf
((
char
*
)
bufp
,
size
,
"%hhu"
,
*
(
pwr_tUInt8
*
)
bufp
);
break
;
case
opc_eDataType_dateTime
:
pwr_tTime
at
;
at
=
(
*
(
pwr_tTime
*
)
bufp
);
time_AtoOPCAscii
(
&
at
,
(
char
*
)
bufp
,
size
);
break
;
case
opc_eDataType_duration
:
time_DtoAscii
((
pwr_tDeltaTime
*
)
bufp
,
0
,
(
char
*
)
bufp
,
size
);
break
;
default:
break
;
}
return
true
;
}
//
// Return the corresponding opc type for a opc type string
//
bool
opc_convert_pwrtype_to_opctype
(
void
*
bufp
,
int
size
,
int
opc_type
,
int
pwr_type
)
bool
opc_convert_pwrtype_to_opctype
(
void
*
bufp
,
int
size
,
int
opc_type
,
int
pwr_type
)
{
{
switch
(
opc_type
)
{
switch
(
opc_type
)
{
case
opc_
m
DataType_string
:
case
opc_
e
DataType_string
:
switch
(
pwr_type
)
{
switch
(
pwr_type
)
{
case
pwr_eType_Float64
:
case
pwr_eType_Float64
:
snprintf
((
char
*
)
bufp
,
size
,
"%f"
,
*
(
pwr_tFloat64
*
)
bufp
);
snprintf
((
char
*
)
bufp
,
size
,
"%f"
,
*
(
pwr_tFloat64
*
)
bufp
);
break
;
break
;
case
pwr_eType_Float32
:
snprintf
((
char
*
)
bufp
,
size
,
"%f"
,
*
(
pwr_tFloat32
*
)
bufp
);
break
;
case
pwr_eType_Char
:
case
pwr_eType_Char
:
snprintf
((
char
*
)
bufp
,
size
,
"%c"
,
*
(
pwr_tChar
*
)
bufp
);
snprintf
((
char
*
)
bufp
,
size
,
"%c"
,
*
(
pwr_tChar
*
)
bufp
);
break
;
break
;
...
@@ -101,6 +304,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -101,6 +304,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
snprintf
((
char
*
)
bufp
,
size
,
"%hi"
,
*
(
pwr_tInt16
*
)
bufp
);
snprintf
((
char
*
)
bufp
,
size
,
"%hi"
,
*
(
pwr_tInt16
*
)
bufp
);
break
;
break
;
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
case
pwr_eType_Boolean
:
snprintf
((
char
*
)
bufp
,
size
,
"%i"
,
*
(
pwr_tInt32
*
)
bufp
);
snprintf
((
char
*
)
bufp
,
size
,
"%i"
,
*
(
pwr_tInt32
*
)
bufp
);
break
;
break
;
case
pwr_eType_UInt8
:
case
pwr_eType_UInt8
:
...
@@ -130,29 +334,33 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -130,29 +334,33 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
break
;
break
;
}
}
break
;
break
;
case
opc_
m
DataType_boolean
:
case
opc_
e
DataType_boolean
:
switch
(
pwr_type
)
{
switch
(
pwr_type
)
{
case
pwr_eType_Float32
:
(
*
(
char
*
)
bufp
)
=
(
*
(
pwr_tFloat32
*
)
bufp
)
?
1
:
0
;
break
;
case
pwr_eType_Float64
:
case
pwr_eType_Float64
:
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tFloat64
*
)
bufp
)
;
(
*
(
char
*
)
bufp
)
=
(
*
(
pwr_tFloat64
*
)
bufp
)
?
1
:
0
;
break
;
break
;
case
pwr_eType_Char
:
case
pwr_eType_Char
:
case
pwr_eType_Int8
:
case
pwr_eType_Int8
:
// *bufp = (char) (char *bufp);
// *bufp = (char) (char *bufp);
break
;
break
;
case
pwr_eType_Int16
:
case
pwr_eType_Int16
:
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tInt16
*
)
bufp
)
;
(
*
(
char
*
)
bufp
)
=
(
*
(
pwr_tInt16
*
)
bufp
)
?
1
:
0
;
break
;
break
;
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tInt32
*
)
bufp
);
case
pwr_eType_Boolean
:
(
*
(
char
*
)
bufp
)
=
(
*
(
pwr_tInt32
*
)
bufp
)
?
1
:
0
;
break
;
break
;
case
pwr_eType_UInt8
:
case
pwr_eType_UInt8
:
// *bufp = (char) (unsigned char *bufp);
// *bufp = (char) (unsigned char *bufp);
break
;
break
;
case
pwr_eType_UInt16
:
case
pwr_eType_UInt16
:
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tUInt16
*
)
bufp
)
;
(
*
(
char
*
)
bufp
)
=
(
*
(
pwr_tUInt16
*
)
bufp
)
?
1
:
0
;
break
;
break
;
case
pwr_eType_UInt32
:
case
pwr_eType_UInt32
:
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tUInt32
*
)
bufp
)
;
(
*
(
char
*
)
bufp
)
=
(
*
(
pwr_tUInt32
*
)
bufp
)
?
1
:
0
;
break
;
break
;
case
pwr_eType_String
:
case
pwr_eType_String
:
case
pwr_eType_Time
:
case
pwr_eType_Time
:
...
@@ -163,8 +371,11 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -163,8 +371,11 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
break
;
break
;
}
}
break
;
break
;
case
opc_
m
DataType_float
:
case
opc_
e
DataType_float
:
switch
(
pwr_type
)
{
switch
(
pwr_type
)
{
case
pwr_eType_Float32
:
// (*(float *) bufp) = (float) (*(pwr_tFloat32 *) bufp);
break
;
case
pwr_eType_Float64
:
case
pwr_eType_Float64
:
(
*
(
float
*
)
bufp
)
=
(
float
)
(
*
(
pwr_tFloat64
*
)
bufp
);
(
*
(
float
*
)
bufp
)
=
(
float
)
(
*
(
pwr_tFloat64
*
)
bufp
);
break
;
break
;
...
@@ -176,6 +387,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -176,6 +387,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
(
*
(
float
*
)
bufp
)
=
(
float
)
(
*
(
pwr_tInt16
*
)
bufp
);
(
*
(
float
*
)
bufp
)
=
(
float
)
(
*
(
pwr_tInt16
*
)
bufp
);
break
;
break
;
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
case
pwr_eType_Boolean
:
(
*
(
float
*
)
bufp
)
=
(
float
)
(
*
(
pwr_tInt32
*
)
bufp
);
(
*
(
float
*
)
bufp
)
=
(
float
)
(
*
(
pwr_tInt32
*
)
bufp
);
break
;
break
;
case
pwr_eType_UInt8
:
case
pwr_eType_UInt8
:
...
@@ -196,9 +408,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -196,9 +408,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
break
;
break
;
}
}
break
;
break
;
case
opc_
m
DataType_double
:
case
opc_
e
DataType_double
:
case
opc_
m
DataType_decimal
:
case
opc_
e
DataType_decimal
:
switch
(
pwr_type
)
{
switch
(
pwr_type
)
{
case
pwr_eType_Float32
:
(
*
(
double
*
)
bufp
)
=
(
double
)
(
*
(
pwr_tFloat32
*
)
bufp
);
break
;
case
pwr_eType_Float64
:
case
pwr_eType_Float64
:
(
*
(
double
*
)
bufp
)
=
(
double
)
(
*
(
pwr_tFloat64
*
)
bufp
);
(
*
(
double
*
)
bufp
)
=
(
double
)
(
*
(
pwr_tFloat64
*
)
bufp
);
break
;
break
;
...
@@ -210,6 +425,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -210,6 +425,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
(
*
(
double
*
)
bufp
)
=
(
double
)
(
*
(
pwr_tInt16
*
)
bufp
);
(
*
(
double
*
)
bufp
)
=
(
double
)
(
*
(
pwr_tInt16
*
)
bufp
);
break
;
break
;
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
case
pwr_eType_Boolean
:
(
*
(
double
*
)
bufp
)
=
(
double
)
(
*
(
pwr_tInt32
*
)
bufp
);
(
*
(
double
*
)
bufp
)
=
(
double
)
(
*
(
pwr_tInt32
*
)
bufp
);
break
;
break
;
case
pwr_eType_UInt8
:
case
pwr_eType_UInt8
:
...
@@ -230,9 +446,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -230,9 +446,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
break
;
break
;
}
}
break
;
break
;
case
opc_
m
DataType_int
:
case
opc_
e
DataType_int
:
case
opc_
m
DataType_unsignedInt
:
case
opc_
e
DataType_unsignedInt
:
switch
(
pwr_type
)
{
switch
(
pwr_type
)
{
case
pwr_eType_Float32
:
(
*
(
int
*
)
bufp
)
=
(
int
)
(
*
(
pwr_tFloat32
*
)
bufp
);
break
;
case
pwr_eType_Float64
:
case
pwr_eType_Float64
:
(
*
(
int
*
)
bufp
)
=
(
int
)
(
*
(
pwr_tFloat64
*
)
bufp
);
(
*
(
int
*
)
bufp
)
=
(
int
)
(
*
(
pwr_tFloat64
*
)
bufp
);
break
;
break
;
...
@@ -243,6 +462,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -243,6 +462,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
case
pwr_eType_Int16
:
case
pwr_eType_Int16
:
(
*
(
int
*
)
bufp
)
=
(
int
)
(
*
(
pwr_tInt16
*
)
bufp
);
(
*
(
int
*
)
bufp
)
=
(
int
)
(
*
(
pwr_tInt16
*
)
bufp
);
break
;
break
;
case
pwr_eType_Boolean
:
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
// (*(double *) bufp) = (double) (*(pwr_tInt32 *) bufp);
// (*(double *) bufp) = (double) (*(pwr_tInt32 *) bufp);
break
;
break
;
...
@@ -264,9 +484,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -264,9 +484,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
break
;
break
;
}
}
break
;
break
;
case
opc_
m
DataType_short
:
case
opc_
e
DataType_short
:
case
opc_
m
DataType_unsignedShort
:
case
opc_
e
DataType_unsignedShort
:
switch
(
pwr_type
)
{
switch
(
pwr_type
)
{
case
pwr_eType_Float32
:
(
*
(
short
int
*
)
bufp
)
=
(
short
int
)
(
*
(
pwr_tFloat32
*
)
bufp
);
break
;
case
pwr_eType_Float64
:
case
pwr_eType_Float64
:
(
*
(
short
int
*
)
bufp
)
=
(
short
int
)
(
*
(
pwr_tFloat64
*
)
bufp
);
(
*
(
short
int
*
)
bufp
)
=
(
short
int
)
(
*
(
pwr_tFloat64
*
)
bufp
);
break
;
break
;
...
@@ -278,6 +501,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -278,6 +501,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
// (*(short int *) bufp) = (short int) (*(pwr_tInt16 *) bufp);
// (*(short int *) bufp) = (short int) (*(pwr_tInt16 *) bufp);
break
;
break
;
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
case
pwr_eType_Boolean
:
(
*
(
short
int
*
)
bufp
)
=
(
short
int
)
(
*
(
pwr_tInt32
*
)
bufp
);
(
*
(
short
int
*
)
bufp
)
=
(
short
int
)
(
*
(
pwr_tInt32
*
)
bufp
);
break
;
break
;
case
pwr_eType_UInt8
:
case
pwr_eType_UInt8
:
...
@@ -298,9 +522,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -298,9 +522,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
break
;
break
;
}
}
break
;
break
;
case
opc_
m
DataType_unsignedByte
:
case
opc_
e
DataType_unsignedByte
:
case
opc_
m
DataType_byte
:
case
opc_
e
DataType_byte
:
switch
(
pwr_type
)
{
switch
(
pwr_type
)
{
case
pwr_eType_Float32
:
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tFloat32
*
)
bufp
);
break
;
case
pwr_eType_Float64
:
case
pwr_eType_Float64
:
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tFloat64
*
)
bufp
);
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tFloat64
*
)
bufp
);
break
;
break
;
...
@@ -312,6 +539,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -312,6 +539,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tInt16
*
)
bufp
);
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tInt16
*
)
bufp
);
break
;
break
;
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
case
pwr_eType_Boolean
:
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tInt32
*
)
bufp
);
(
*
(
char
*
)
bufp
)
=
(
char
)
(
*
(
pwr_tInt32
*
)
bufp
);
break
;
break
;
case
pwr_eType_UInt8
:
case
pwr_eType_UInt8
:
...
@@ -332,9 +560,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -332,9 +560,12 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
break
;
break
;
}
}
break
;
break
;
case
opc_
m
DataType_unsignedLong
:
case
opc_
e
DataType_unsignedLong
:
case
opc_
m
DataType_long
:
case
opc_
e
DataType_long
:
switch
(
pwr_type
)
{
switch
(
pwr_type
)
{
case
pwr_eType_Float32
:
(
*
(
long
long
*
)
bufp
)
=
(
long
long
)
(
*
(
pwr_tFloat32
*
)
bufp
);
break
;
case
pwr_eType_Float64
:
case
pwr_eType_Float64
:
(
*
(
long
long
*
)
bufp
)
=
(
long
long
)
(
*
(
pwr_tFloat64
*
)
bufp
);
(
*
(
long
long
*
)
bufp
)
=
(
long
long
)
(
*
(
pwr_tFloat64
*
)
bufp
);
break
;
break
;
...
@@ -346,6 +577,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -346,6 +577,7 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
(
*
(
long
long
*
)
bufp
)
=
(
long
long
)
(
*
(
pwr_tInt16
*
)
bufp
);
(
*
(
long
long
*
)
bufp
)
=
(
long
long
)
(
*
(
pwr_tInt16
*
)
bufp
);
break
;
break
;
case
pwr_eType_Int32
:
case
pwr_eType_Int32
:
case
pwr_eType_Boolean
:
(
*
(
long
long
*
)
bufp
)
=
(
long
long
)
(
*
(
pwr_tInt32
*
)
bufp
);
(
*
(
long
long
*
)
bufp
)
=
(
long
long
)
(
*
(
pwr_tInt32
*
)
bufp
);
break
;
break
;
case
pwr_eType_UInt8
:
case
pwr_eType_UInt8
:
...
@@ -366,13 +598,13 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
...
@@ -366,13 +598,13 @@ bool opc_convert_pwrtype_to_opctype(void *bufp, int size, int opc_type, int pwr_
break
;
break
;
}
}
break
;
break
;
case
opc_
m
DataType_dateTime
:
case
opc_
e
DataType_dateTime
:
case
opc_
m
DataType_duration
:
case
opc_
e
DataType_duration
:
case
opc_
m
DataType_base64Binary
:
case
opc_
e
DataType_base64Binary
:
case
opc_
m
DataType_time
:
case
opc_
e
DataType_time
:
case
opc_
m
DataType_date
:
case
opc_
e
DataType_date
:
case
opc_
m
DataType_QName
:
case
opc_
e
DataType_QName
:
case
opc_
m
DataType_anyType
:
case
opc_
e
DataType_anyType
:
return
false
;
return
false
;
break
;
break
;
}
}
...
@@ -387,7 +619,7 @@ bool opc_string_to_opctype(char *str, int *type)
...
@@ -387,7 +619,7 @@ bool opc_string_to_opctype(char *str, int *type)
{
{
int
ii
;
int
ii
;
for
(
ii
=
0
;
ii
<
20
;
ii
++
)
{
for
(
ii
=
0
;
ii
<
opc_cDataTypeSize
;
ii
++
)
{
if
(
strncmp
(
str_dt
[
ii
],
str
,
sizeof
(
str_dt
[
ii
]))
==
0
)
{
if
(
strncmp
(
str_dt
[
ii
],
str
,
sizeof
(
str_dt
[
ii
]))
==
0
)
{
*
type
=
ii
;
*
type
=
ii
;
return
true
;
return
true
;
...
@@ -396,55 +628,64 @@ bool opc_string_to_opctype(char *str, int *type)
...
@@ -396,55 +628,64 @@ bool opc_string_to_opctype(char *str, int *type)
return
false
;
return
false
;
}
}
//
// Return the corresponding opc type string for a opc type
//
char
*
opc_opctype_to_string
(
int
type
)
{
return
str_dt
[
type
];
}
bool
opc_type_to_pwrtype
(
int
type
,
int
*
pwrtype
)
bool
opc_type_to_pwrtype
(
int
type
,
int
*
pwrtype
)
{
{
switch
(
type
)
{
switch
(
type
)
{
case
opc_
m
DataType_string
:
case
opc_
e
DataType_string
:
*
pwrtype
=
pwr_eType_String
;
*
pwrtype
=
pwr_eType_String
;
break
;
break
;
case
opc_
m
DataType_boolean
:
case
opc_
e
DataType_boolean
:
*
pwrtype
=
pwr_eType_Boolean
;
*
pwrtype
=
pwr_eType_Boolean
;
break
;
break
;
case
opc_
m
DataType_float
:
case
opc_
e
DataType_float
:
*
pwrtype
=
pwr_eType_Float32
;
*
pwrtype
=
pwr_eType_Float32
;
break
;
break
;
case
opc_
m
DataType_double
:
case
opc_
e
DataType_double
:
*
pwrtype
=
pwr_eType_Float64
;
*
pwrtype
=
pwr_eType_Float64
;
break
;
break
;
case
opc_
m
DataType_int
:
case
opc_
e
DataType_int
:
*
pwrtype
=
pwr_eType_Int32
;
*
pwrtype
=
pwr_eType_Int32
;
break
;
break
;
case
opc_
m
DataType_short
:
case
opc_
e
DataType_short
:
*
pwrtype
=
pwr_eType_Int16
;
*
pwrtype
=
pwr_eType_Int16
;
break
;
break
;
case
opc_
m
DataType_byte
:
case
opc_
e
DataType_byte
:
*
pwrtype
=
pwr_eType_Int8
;
*
pwrtype
=
pwr_eType_Int8
;
break
;
break
;
case
opc_
m
DataType_unsignedInt
:
case
opc_
e
DataType_unsignedInt
:
*
pwrtype
=
pwr_eType_UInt32
;
*
pwrtype
=
pwr_eType_UInt32
;
break
;
break
;
case
opc_
m
DataType_unsignedShort
:
case
opc_
e
DataType_unsignedShort
:
*
pwrtype
=
pwr_eType_UInt16
;
*
pwrtype
=
pwr_eType_UInt16
;
break
;
break
;
case
opc_
m
DataType_unsignedByte
:
case
opc_
e
DataType_unsignedByte
:
*
pwrtype
=
pwr_eType_UInt8
;
*
pwrtype
=
pwr_eType_UInt8
;
break
;
break
;
case
opc_
m
DataType_dateTime
:
case
opc_
e
DataType_dateTime
:
*
pwrtype
=
pwr_eType_Time
;
*
pwrtype
=
pwr_eType_Time
;
break
;
break
;
case
opc_
m
DataType_duration
:
case
opc_
e
DataType_duration
:
*
pwrtype
=
pwr_eType_DeltaTime
;
*
pwrtype
=
pwr_eType_DeltaTime
;
break
;
break
;
case
opc_
m
DataType_QName
:
case
opc_
e
DataType_QName
:
case
opc_
m
DataType_anyType
:
case
opc_
e
DataType_anyType
:
case
opc_
m
DataType_decimal
:
case
opc_
e
DataType_decimal
:
case
opc_
m
DataType_long
:
case
opc_
e
DataType_long
:
case
opc_
m
DataType_unsignedLong
:
case
opc_
e
DataType_unsignedLong
:
case
opc_
m
DataType_base64Binary
:
case
opc_
e
DataType_base64Binary
:
case
opc_
m
DataType_time
:
case
opc_
e
DataType_time
:
case
opc_
m
DataType_date
:
case
opc_
e
DataType_date
:
default:
default:
*
pwrtype
=
0
;
*
pwrtype
=
0
;
return
false
;
return
false
;
...
...
opc/lib/opc/src/opc_utl.h
View file @
46c028fe
/*
/*
* Proview $Id: opc_utl.h,v 1.
4 2007-03-08 08:10:03
claes Exp $
* Proview $Id: opc_utl.h,v 1.
5 2007-03-12 07:52:02
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -45,30 +45,74 @@ typedef enum {
...
@@ -45,30 +45,74 @@ typedef enum {
}
opc_mProperty
;
}
opc_mProperty
;
typedef
enum
{
typedef
enum
{
opc_mDataType_string
,
opc_mRequestOption_ReturnErrorText
=
1
<<
0
,
opc_mDataType_boolean
,
opc_mRequestOption_ReturnDiagnosticInfo
=
1
<<
1
,
opc_mDataType_float
,
opc_mRequestOption_ReturnItemTime
=
1
<<
2
,
opc_mDataType_double
,
opc_mRequestOption_ReturnItemPath
=
1
<<
3
,
opc_mDataType_decimal
,
opc_mRequestOption_ReturnItemName
=
1
<<
4
opc_mDataType_long
,
}
opc_mRequestOptions
;
opc_mDataType_int
,
opc_mDataType_short
,
opc_mDataType_byte
,
opc_mDataType_unsignedLong
,
opc_mDataType_unsignedInt
,
opc_mDataType_unsignedShort
,
opc_mDataType_unsignedByte
,
opc_mDataType_base64Binary
,
opc_mDataType_dateTime
,
opc_mDataType_time
,
opc_mDataType_date
,
opc_mDataType_duration
,
opc_mDataType_QName
,
opc_mDataType_anyType
}
opc_mDataType
;
const
int
opc_cDataTypeSize
=
20
;
typedef
enum
{
opc_eDataType_string
,
opc_eDataType_boolean
,
opc_eDataType_float
,
opc_eDataType_double
,
opc_eDataType_decimal
,
opc_eDataType_long
,
opc_eDataType_int
,
opc_eDataType_short
,
opc_eDataType_byte
,
opc_eDataType_unsignedLong
,
opc_eDataType_unsignedInt
,
opc_eDataType_unsignedShort
,
opc_eDataType_unsignedByte
,
opc_eDataType_base64Binary
,
opc_eDataType_dateTime
,
opc_eDataType_time
,
opc_eDataType_date
,
opc_eDataType_duration
,
opc_eDataType_QName
,
opc_eDataType_anyType
}
opc_eDataType
;
const
int
opc_cResultCodesSize
=
20
;
typedef
enum
{
opc_eResultCode_S_CLAMP
,
opc_eResultCode_S_DATAQUEUEOVERFLOW
,
opc_eResultCode_S_UNSUPPORTEDRATE
,
opc_eResultCode_E_ACCESS_DENIED
,
opc_eResultCode_E_BUSY
,
opc_eResultCode_E_FAIL
,
opc_eResultCode_E_INVALIDCONTINUATIONPOINT
,
opc_eResultCode_E_INVALIDFILTER
,
opc_eResultCode_E_INVALIDHOLDTIME
,
opc_eResultCode_E_INVALIDITEMNAME
,
opc_eResultCode_E_INVALIDITEMPATH
,
opc_eResultCode_E_INVALIDPID
,
opc_eResultCode_E_NOSUBSCRIPTION
,
opc_eResultCode_E_NOTSUPPORTED
,
opc_eResultCode_E_OUTOFMEMORY
,
opc_eResultCode_E_RANGE
,
opc_eResultCode_E_READONLY
,
opc_eResultCode_E_SERVERSTATE
,
opc_eResultCode_E_TIMEDOUT
,
opc_eResultCode_E_UNKNOWNITEMNAME
,
opc_eResultCode_E_UNKNOWNITEMPATH
,
opc_eResultCode_E_WRITEONLY
,
opc_eResultCode_E_BADTYPE
,
}
opc_eResultCode
;
void
opcsrv_returnerror
(
std
::
vector
<
ns1__OPCError
*>&
errors
,
std
::
string
*
rc
,
int
err_code
);
bool
opc_requestoptions_to_mask
(
ns1__RequestOptions
*
options
,
unsigned
int
*
mask
);
pwr_tStatus
time_AtoOPCAscii
(
pwr_tTime
*
tp
,
char
*
buf
,
int
bufsize
);
pwr_tStatus
time_AtoOPCAscii
(
pwr_tTime
*
tp
,
char
*
buf
,
int
bufsize
);
bool
opc_resultcode_to_string
(
int
type
,
char
*
str
);
bool
opc_resultcode_to_text
(
int
type
,
char
*
str
);
bool
opc_opctype_to_value
(
void
*
bufp
,
int
size
,
int
opc_type
);
bool
opc_string_to_opctype
(
char
*
str
,
int
*
type
);
bool
opc_string_to_opctype
(
char
*
str
,
int
*
type
);
char
*
opc_opctype_to_string
(
int
type
);
bool
opc_type_to_pwrtype
(
int
type
,
int
*
pwrtype
);
bool
opc_type_to_pwrtype
(
int
type
,
int
*
pwrtype
);
bool
opc_pwrtype_to_string
(
int
type
,
char
**
str
);
bool
opc_pwrtype_to_string
(
int
type
,
char
**
str
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment