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
04a11b83
Commit
04a11b83
authored
May 30, 2007
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conversion utf9-iso8859 and vv
parent
cedf14b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
23 deletions
+83
-23
opc/exe/opc_provider/src/opc_provider.cpp
opc/exe/opc_provider/src/opc_provider.cpp
+16
-8
opc/exe/opc_server/src/opc_server.cpp
opc/exe/opc_server/src/opc_server.cpp
+29
-13
opc/lib/opc/src/opc_utl.cpp
opc/lib/opc/src/opc_utl.cpp
+34
-1
opc/lib/opc/src/opc_utl.h
opc/lib/opc/src/opc_utl.h
+4
-1
No files found.
opc/exe/opc_provider/src/opc_provider.cpp
View file @
04a11b83
/*
* Proview $Id: opc_provider.cpp,v 1.1
3 2007-04-30 07:29:53
claes Exp $
* Proview $Id: opc_provider.cpp,v 1.1
4 2007-05-30 12:00:25
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <iostream.h>
#include <fstream.h>
#include <iconv.h>
#include "pwr.h"
#include "pwr_class.h"
#include "pwr_baseclasses.h"
...
...
@@ -451,7 +452,8 @@ void opc_provider::insert_object( pwr_tOix fth, pwr_tOix bws, s0__BrowseElement
_s0__Browse
browse
;
_s0__BrowseResponse
browse_response
;
browse
.
ItemName
=
new
std
::
string
(
o
->
item_name
);
browse
.
ItemName
=
new
std
::
string
(
cnv_iso8859_to_utf8
(
o
->
item_name
,
strlen
(
o
->
item_name
)
+
1
));
opc_mask_to_propertynames
(
browse
.
PropertyNames
,
opc_mProperty_DataType
|
opc_mProperty_Description
|
opc_mProperty_EuType
);
...
...
@@ -540,7 +542,8 @@ void opc_provider::objectOid( co_procom *pcom, pwr_tOix oix)
_s0__Browse
browse
;
_s0__BrowseResponse
browse_response
;
browse
.
ItemName
=
new
std
::
string
(
m_list
[
oix
]
->
item_name
);
browse
.
ItemName
=
new
std
::
string
(
cnv_iso8859_to_utf8
(
m_list
[
oix
]
->
item_name
,
strlen
(
m_list
[
oix
]
->
item_name
)
+
1
));
opc_mask_to_propertynames
(
browse
.
PropertyNames
,
opc_mProperty_DataType
|
opc_mProperty_Description
|
opc_mProperty_EuType
);
...
...
@@ -654,7 +657,8 @@ void opc_provider::objectName( co_procom *pcom, char *name, pwr_tOix poix)
_s0__Browse
browse
;
_s0__BrowseResponse
browse_response
;
browse
.
ItemName
=
new
std
::
string
(
m_list
[
oix
]
->
item_name
);
browse
.
ItemName
=
new
std
::
string
(
cnv_iso8859_to_utf8
(
m_list
[
oix
]
->
item_name
,
strlen
(
m_list
[
oix
]
->
item_name
)
+
1
));
opc_mask_to_propertynames
(
browse
.
PropertyNames
,
opc_mProperty_DataType
|
opc_mProperty_Description
|
opc_mProperty_EuType
);
...
...
@@ -794,7 +798,8 @@ void opc_provider::writeAttribute( co_procom *pcom, pwr_tOix oix, unsigned int o
int
opc_type
;
s0__ItemValue
*
item
=
new
s0__ItemValue
();
item
->
ItemName
=
new
std
::
string
(
m_list
[
oix
]
->
item_name
);
item
->
ItemName
=
new
std
::
string
(
cnv_iso8859_to_utf8
(
m_list
[
oix
]
->
item_name
,
strlen
(
m_list
[
oix
]
->
item_name
)
+
1
));
opc_pwrtype_to_opctype
(
m_list
[
oix
]
->
type
,
&
opc_type
);
opc_convert_pwrtype_to_opctype
(
buffer
,
opc_buffer
,
sizeof
(
opc_buffer
),
opc_type
,
m_list
[
oix
]
->
type
);
...
...
@@ -860,7 +865,8 @@ void opc_provider::readAttribute( co_procom *pcom, pwr_tOix oix, unsigned int of
_s0__ReadResponse
read_response
;
s0__ReadRequestItem
*
item
=
new
s0__ReadRequestItem
();
item
->
ItemName
=
new
std
::
string
(
m_list
[
oix
]
->
item_name
);
item
->
ItemName
=
new
std
::
string
(
cnv_iso8859_to_utf8
(
m_list
[
oix
]
->
item_name
,
strlen
(
m_list
[
oix
]
->
item_name
)
+
1
));
read
.
ItemList
=
new
s0__ReadRequestItemList
;
read
.
ItemList
->
Items
.
push_back
(
item
);
...
...
@@ -929,7 +935,8 @@ void opc_provider::subAssociateBuffer( co_procom *pcom, void **buff, int oix, in
subscribe
.
ItemList
=
new
s0__SubscribeRequestItemList
();
s0__SubscribeRequestItem
*
ritem
=
new
s0__SubscribeRequestItem
();
ritem
->
ItemName
=
new
std
::
string
(
m_list
[
oix
]
->
item_name
);
ritem
->
ItemName
=
new
std
::
string
(
cnv_iso8859_to_utf8
(
m_list
[
oix
]
->
item_name
,
strlen
(
m_list
[
oix
]
->
item_name
)
+
1
));
sprintf
(
handle
,
"%d"
,
oix
);
ritem
->
ClientItemHandle
=
new
std
::
string
(
handle
);
ritem
->
RequestedSamplingRate
=
(
int
*
)
malloc
(
sizeof
(
int
));
...
...
@@ -1066,7 +1073,8 @@ void opc_provider::cyclic( co_procom *pcom)
subscribe
.
ItemList
=
new
s0__SubscribeRequestItemList
();
s0__SubscribeRequestItem
*
ritem
=
new
s0__SubscribeRequestItem
();
ritem
->
ItemName
=
new
std
::
string
(
m_list
[
oix
]
->
item_name
);
ritem
->
ItemName
=
new
std
::
string
(
cnv_iso8859_to_utf8
(
m_list
[
oix
]
->
item_name
,
strlen
(
m_list
[
oix
]
->
item_name
)
+
1
));
ritem
->
ClientItemHandle
=
new
std
::
string
(
it
->
second
.
handle
);
ritem
->
RequestedSamplingRate
=
(
int
*
)
malloc
(
sizeof
(
int
));
*
ritem
->
RequestedSamplingRate
=
1000
;
...
...
opc/exe/opc_server/src/opc_server.cpp
View file @
04a11b83
/*
* Proview $Id: opc_server.cpp,v 1.1
6 2007-05-22 08:21:17
claes Exp $
* Proview $Id: opc_server.cpp,v 1.1
7 2007-05-30 12:00:25
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -240,8 +240,14 @@ int main()
for
(
int
k
=
0
;
k
<
restarts
+
1
;
k
++
)
{
m
=
soap_bind
(
&
soap
,
NULL
,
18083
,
100
);
if
(
m
<
0
)
soap_print_fault
(
&
soap
,
stderr
);
if
(
m
<
0
)
{
if
(
k
==
restarts
)
{
soap_print_fault
(
&
soap
,
stderr
);
break
;
}
printf
(
"Soap bind failed, retrying...
\n
"
);
sleep
(
10
);
}
else
{
fprintf
(
stderr
,
"Socket connection successfull: master socket = %d
\n
"
,
m
);
...
...
@@ -463,7 +469,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__Read(struct soap *soap,
iv
->
ClientItemHandle
=
new
std
::
string
(
*
s0__Read
->
ItemList
->
Items
[
ii
]
->
ClientItemHandle
);
sts
=
gdh_NameToAttrref
(
pwr_cNObjid
,
itemname
,
&
ar
);
sts
=
gdh_NameToAttrref
(
pwr_cNObjid
,
cnv_utf8_to_iso8859
(
itemname
,
strlen
(
itemname
)
+
1
)
,
&
ar
);
if
(
EVEN
(
sts
))
{
opcsrv_returnerror
(
s0__ReadResponse
->
Errors
,
&
iv
->
ResultID
,
opc_eResultCode_E_INVALIDITEMNAME
,
options
);
...
...
@@ -591,7 +597,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__Write(struct soap* soap,
if
(
options
&
opc_mRequestOption_ReturnDiagnosticInfo
)
iv
->
DiagnosticInfo
=
new
std
::
string
(
""
);
// ToDo !!
sts
=
gdh_NameToAttrref
(
pwr_cNObjid
,
itemname
,
&
ar
);
sts
=
gdh_NameToAttrref
(
pwr_cNObjid
,
cnv_utf8_to_iso8859
(
itemname
,
strlen
(
itemname
)
+
1
)
,
&
ar
);
if
(
EVEN
(
sts
))
{
opcsrv_returnerror
(
s0__WriteResponse
->
Errors
,
&
iv
->
ResultID
,
opc_eResultCode_E_INVALIDITEMNAME
,
options
);
s0__WriteResponse
->
RItemList
->
Items
.
push_back
(
iv
);
...
...
@@ -666,7 +672,9 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__Subscribe(struct soap* soap,
while
(
1
)
{
strcpy
(
aname
,
s0__Subscribe
->
ItemList
->
Items
[
i
]
->
ItemName
->
c_str
());
strcpy
(
aname
,
cnv_utf8_to_iso8859
(
(
char
*
)
s0__Subscribe
->
ItemList
->
Items
[
i
]
->
ItemName
->
c_str
(),
s0__Subscribe
->
ItemList
->
Items
[
i
]
->
ItemName
->
size
()
+
1
));
sts
=
gdh_GetAttributeCharacteristics
(
aname
,
&
a_tid
,
&
a_size
,
&
a_offs
,
&
a_elem
);
if
(
EVEN
(
sts
))
{
resultid
=
opc_eResultCode_E_UNKNOWNITEMNAME
;
...
...
@@ -800,6 +808,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__Subscribe(struct soap* soap,
client
->
m_sublist
[
*
s0__SubscribeResponse
->
ServerSubHandle
].
push_back
(
sub
);
break
;
}
if
(
resultid
||
s0__Subscribe
->
ReturnValuesOnReply
)
{
if
(
!
s0__SubscribeResponse
->
RItemList
)
s0__SubscribeResponse
->
RItemList
=
new
s0__SubscribeReplyItemList
();
...
...
@@ -807,7 +816,9 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__Subscribe(struct soap* soap,
s0__SubscribeItemValue
*
iv
=
new
s0__SubscribeItemValue
();
iv
->
ItemValue
=
new
s0__ItemValue
();
iv
->
ItemValue
->
ItemName
=
new
std
::
string
(
*
s0__Subscribe
->
ItemList
->
Items
[
i
]
->
ItemName
);
iv
->
ItemValue
->
ItemName
=
new
std
::
string
(
cnv_utf8_to_iso8859
(
(
char
*
)
s0__Subscribe
->
ItemList
->
Items
[
i
]
->
ItemName
->
c_str
(),
s0__Subscribe
->
ItemList
->
Items
[
i
]
->
ItemName
->
size
()
+
1
));
if
(
s0__Subscribe
->
ItemList
->
Items
[
i
]
->
ClientItemHandle
)
iv
->
ItemValue
->
ClientItemHandle
=
new
std
::
string
(
*
s0__Subscribe
->
ItemList
->
Items
[
i
]
->
ClientItemHandle
);
...
...
@@ -1553,6 +1564,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__Browse(struct soap *soap, _s0__Browse *s0__Brows
else
strncpy
(
pname
,
s0__Browse
->
ItemName
->
c_str
(),
sizeof
(
pname
));
strcpy
(
pname
,
cnv_utf8_to_iso8859
(
pname
,
strlen
(
pname
)
+
1
));
sts
=
gdh_NameToAttrref
(
pwr_cNOid
,
pname
,
&
paref
);
if
(
EVEN
(
sts
))
return
opcsrv
->
fault
(
soap
,
opc_eResultCode_E_UNKNOWNITEMNAME
);
...
...
@@ -1833,17 +1846,20 @@ SOAP_FMAC5 int SOAP_FMAC6 __s0__GetProperties(struct soap *soap,
else
path
=
s0__GetProperties
->
ItemPath
;
plist
->
ItemPath
=
path
;
plist
->
ItemName
=
new
std
::
string
(
*
s0__GetProperties
->
ItemIDs
[
i
]
->
ItemName
);
if
(
path
)
plist
->
ItemPath
=
new
std
::
string
(
cnv_utf8_to_iso8859
(
(
char
*
)
path
,
path
->
size
()
+
1
));
plist
->
ItemName
=
new
std
::
string
(
cnv_utf8_to_iso8859
(
(
char
*
)
s0__GetProperties
->
ItemIDs
[
i
]
->
ItemName
->
c_str
(),
s0__GetProperties
->
ItemIDs
[
i
]
->
ItemName
->
size
()
+
1
));
if
(
path
)
{
strcpy
(
iname
,
path
->
c_str
());
strcat
(
iname
,
plist
->
ItemName
->
c_str
());
strcat
(
iname
,
s0__GetProperties
->
ItemIDs
[
i
]
->
ItemName
->
c_str
());
}
else
strcpy
(
iname
,
plist
->
ItemName
->
c_str
());
strcpy
(
iname
,
s0__GetProperties
->
ItemIDs
[
i
]
->
ItemName
->
c_str
());
sts
=
gdh_NameToAttrref
(
pwr_cNOid
,
iname
,
&
aref
);
sts
=
gdh_NameToAttrref
(
pwr_cNOid
,
cnv_utf8_to_iso8859
(
iname
,
strlen
(
iname
)
+
1
)
,
&
aref
);
if
(
EVEN
(
sts
))
{
opcsrv_returnerror
(
s0__GetPropertiesResponse
->
Errors
,
&
plist
->
ResultID
,
opc_eResultCode_E_UNKNOWNITEMNAME
,
0
);
...
...
opc/lib/opc/src/opc_utl.cpp
View file @
04a11b83
/*
* Proview $Id: opc_utl.cpp,v 1.1
7 2007-04-25 13:42:17
claes Exp $
* Proview $Id: opc_utl.cpp,v 1.1
8 2007-05-30 12:00:25
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -19,6 +19,7 @@
#include <float.h>
#include <iconv.h>
#include "pwr_class.h"
#include "co_time.h"
#include "co_time_msg.h"
...
...
@@ -1955,3 +1956,35 @@ bool opc_cmp_pwr( void *p1, void *p2, int size, int type, float deadband)
}
return
false
;
}
char
*
cnv_iso8859_to_utf8
(
char
*
iso
,
size_t
iso_size
)
{
static
iconv_t
cd
=
0
;
static
char
utf8
[
2048
];
char
*
utf8p
=
utf8
;
size_t
utf8_size
=
sizeof
(
utf8
);
if
(
!
cd
)
cd
=
iconv_open
(
"UTF-8"
,
"ISO8859-1"
);
if
(
iconv
(
cd
,
&
iso
,
&
iso_size
,
&
utf8p
,
&
utf8_size
)
==
(
size_t
)(
-
1
))
strcpy
(
utf8
,
""
);
return
utf8
;
}
char
*
cnv_utf8_to_iso8859
(
char
*
utf8
,
size_t
utf8_size
)
{
static
iconv_t
cd
=
0
;
static
char
iso
[
2048
];
char
*
isop
=
iso
;
size_t
iso_size
=
sizeof
(
iso
);
if
(
!
cd
)
cd
=
iconv_open
(
"ISO8859-1"
,
"UTF-8"
);
if
(
iconv
(
cd
,
&
utf8
,
&
utf8_size
,
&
isop
,
&
iso_size
)
==
(
size_t
)(
-
1
))
strcpy
(
iso
,
""
);
return
iso
;
}
opc/lib/opc/src/opc_utl.h
View file @
04a11b83
/*
* Proview $Id: opc_utl.h,v 1.1
5 2007-04-05 13:32:03
claes Exp $
* Proview $Id: opc_utl.h,v 1.1
6 2007-05-30 12:00:25
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -133,3 +133,6 @@ bool opc_propertynames_to_mask( std::vector<std::string>& pnames, unsigned int *
bool
opc_quality_to_string
(
int
quality
,
char
**
str
);
bool
opc_cmp_pwr
(
void
*
p1
,
void
*
p2
,
int
size
,
int
type
,
float
deadband
);
char
*
cnv_utf8_to_iso8859
(
char
*
utf8
,
size_t
utf8_size
);
char
*
cnv_iso8859_to_utf8
(
char
*
iso
,
size_t
iso_size
);
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