Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
5b3f66b1
Commit
5b3f66b1
authored
Jun 16, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Исправил ошибку с обработкой списка идентификаторов объектов в
uniset2-admin --oinfo. (функция не работала если задавать имена, а не числа).
parent
ccb609bc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
130 additions
and
11 deletions
+130
-11
admin.cc
Utilities/Admin/admin.cc
+6
-6
libuniset2.spec
conf/libuniset2.spec
+5
-1
UniSetTypes.h
include/UniSetTypes.h
+5
-0
UniSetTypes.cc
src/ObjectRepository/UniSetTypes.cc
+61
-1
test_utypes.cc
tests/test_utypes.cc
+45
-1
tests_with_conf.xml
tests/tests_with_conf.xml
+8
-2
No files found.
Utilities/Admin/admin.cc
View file @
5b3f66b1
...
...
@@ -843,22 +843,22 @@ int configure( const string& arg, UInterface& ui )
int
oinfo
(
const
string
&
args
,
UInterface
&
ui
)
{
auto
conf
=
uniset_conf
();
auto
sl
=
UniSetTypes
::
get
SInfo
List
(
args
,
conf
);
auto
sl
=
UniSetTypes
::
get
Objects
List
(
args
,
conf
);
for
(
auto
&&
it
:
sl
)
{
if
(
it
.
si
.
node
==
DefaultObjectId
)
it
.
si
.
node
=
conf
->
getLocalNode
();
if
(
it
.
node
==
DefaultObjectId
)
it
.
node
=
conf
->
getLocalNode
();
try
{
UniSetTypes
::
ObjectVar
o
=
ui
.
resolve
(
it
.
si
.
id
,
it
.
si
.
node
);
UniSetTypes
::
ObjectVar
o
=
ui
.
resolve
(
it
.
id
,
it
.
node
);
UniSetObject_i_var
obj
=
UniSetObject_i
::
_narrow
(
o
);
if
(
CORBA
::
is_nil
(
obj
))
{
if
(
!
quiet
)
cout
<<
"(oinfo): объект '"
<<
it
.
si
.
id
<<
"' недоступен"
<<
endl
;
cout
<<
"(oinfo): объект '"
<<
it
.
id
<<
"' недоступен"
<<
endl
;
}
else
{
...
...
@@ -868,7 +868,7 @@ int oinfo( const string& args, UInterface& ui )
}
catch
(
const
Exception
&
ex
)
{
cout
<<
"ID='"
<<
it
.
si
.
id
<<
"' ERROR: "
<<
ex
<<
endl
;
cout
<<
"ID='"
<<
it
.
id
<<
"' ERROR: "
<<
ex
<<
endl
;
}
cout
<<
endl
<<
endl
;
...
...
conf/libuniset2.spec
View file @
5b3f66b1
...
...
@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.1
Release: alt7.
6
Release: alt7.
7
Summary: UniSet - library for building distributed industrial control systems
...
...
@@ -456,6 +456,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Tue Jun 16 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt7.7
- fixed minor bug in uniset2-admin --oinfo (uniset2-vmonitor)
- vmonitor: add helper functions
* Wed Jun 10 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt7.6
- fixed libUniSet2Extensions.pc
...
...
include/UniSetTypes.h
View file @
5b3f66b1
...
...
@@ -192,6 +192,11 @@ namespace UniSetTypes
Если @node не указано, возвращается node=DefaultObjectId */
std
::
list
<
ParamSInfo
>
getSInfoList
(
const
std
::
string
&
s
,
std
::
shared_ptr
<
UniSetTypes
::
Configuration
>
conf
=
nullptr
);
/*! Функция разбора строки вида: id1@node1,id2@node2,...
Если @node не указано, возвращается node=DefaultObjectId */
std
::
list
<
UniSetTypes
::
ConsumerInfo
>
getObjectsList
(
const
std
::
string
&
s
,
std
::
shared_ptr
<
UniSetTypes
::
Configuration
>
conf
=
nullptr
);
/*! проверка является текст в строке - числом..*/
bool
is_digit
(
const
std
::
string
&
s
);
...
...
src/ObjectRepository/UniSetTypes.cc
View file @
5b3f66b1
...
...
@@ -325,7 +325,7 @@ std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str,
else
item
.
si
.
id
=
conf
->
getSensorID
(
s_id
);
if
(
is_digit
(
s_node
.
c_str
()
)
)
if
(
is_digit
(
s_node
)
)
item
.
si
.
node
=
uni_atoi
(
s_node
);
else
item
.
si
.
node
=
conf
->
getNodeID
(
s_node
);
...
...
@@ -342,7 +342,67 @@ std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str,
return
std
::
move
(
res
);
}
// --------------------------------------------------------------------------------------
std
::
list
<
UniSetTypes
::
ConsumerInfo
>
UniSetTypes
::
getObjectsList
(
const
string
&
str
,
std
::
shared_ptr
<
Configuration
>
conf
)
{
if
(
conf
==
nullptr
)
conf
=
uniset_conf
();
std
::
list
<
UniSetTypes
::
ConsumerInfo
>
res
;
auto
lst
=
UniSetTypes
::
explode_str
(
str
,
','
);
for
(
const
auto
&
it
:
lst
)
{
UniSetTypes
::
ConsumerInfo
item
;
auto
t
=
UniSetTypes
::
explode_str
(
it
,
'@'
);
if
(
t
.
size
()
==
1
)
{
std
::
string
s_id
(
*
(
t
.
begin
()));
if
(
is_digit
(
s_id
)
)
item
.
id
=
uni_atoi
(
s_id
);
else
{
item
.
id
=
conf
->
getObjectID
(
s_id
);
if
(
item
.
id
==
DefaultObjectId
)
item
.
id
=
conf
->
getControllerID
(
s_id
);
}
item
.
node
=
DefaultObjectId
;
}
else
if
(
t
.
size
()
==
2
)
{
std
::
string
s_id
=
*
(
t
.
begin
());
std
::
string
s_node
=
*
(
++
t
.
begin
());
if
(
is_digit
(
s_id
)
)
item
.
id
=
uni_atoi
(
s_id
);
else
{
item
.
id
=
conf
->
getObjectID
(
s_id
);
if
(
item
.
id
==
DefaultObjectId
)
item
.
id
=
conf
->
getControllerID
(
s_id
);
}
if
(
is_digit
(
s_node
)
)
item
.
node
=
uni_atoi
(
s_node
);
else
item
.
node
=
conf
->
getNodeID
(
s_node
);
}
else
{
cerr
<<
"WARNING: parse error for '"
<<
it
<<
"'. IGNORE..."
<<
endl
;
continue
;
}
res
.
push_back
(
item
);
}
return
std
::
move
(
res
);
}
// --------------------------------------------------------------------------------------
UniversalIO
::
IOType
UniSetTypes
::
getIOType
(
const
std
::
string
&
stype
)
{
if
(
stype
==
"DI"
||
stype
==
"di"
)
...
...
tests/test_utypes.cc
View file @
5b3f66b1
...
...
@@ -106,9 +106,53 @@ TEST_CASE("UniSetTypes: explode", "[utypes][explode]" )
// -----------------------------------------------------------------------------
TEST_CASE
(
"UniSetTypes: getSInfoList"
,
"[utypes][getsinfo]"
)
{
const
std
::
string
str1
(
"
id1@node1,id2,234,234@node5,45@245
"
);
const
std
::
string
str1
(
"
Input4_S@node2,Input1_S,5,5@node3,6@1001
"
);
auto
t1
=
UniSetTypes
::
getSInfoList
(
str1
);
CHECK
(
t1
.
size
()
==
5
);
vector
<
UniSetTypes
::
ParamSInfo
>
v
(
t1
.
begin
(),
t1
.
end
());
REQUIRE
(
v
[
0
].
si
.
id
==
141
);
REQUIRE
(
v
[
0
].
si
.
node
==
1001
);
REQUIRE
(
v
[
1
].
si
.
id
==
1
);
REQUIRE
(
v
[
1
].
si
.
node
==
DefaultObjectId
);
REQUIRE
(
v
[
2
].
si
.
id
==
5
);
REQUIRE
(
v
[
2
].
si
.
node
==
DefaultObjectId
);
REQUIRE
(
v
[
3
].
si
.
id
==
5
);
REQUIRE
(
v
[
3
].
si
.
node
==
1002
);
REQUIRE
(
v
[
4
].
si
.
id
==
6
);
REQUIRE
(
v
[
4
].
si
.
node
==
1001
);
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"UniSetTypes: getObjectsList"
,
"[utypes][getolist]"
)
{
const
std
::
string
str1
(
"TestProc@node2,TestProc,102,102@node3,103@1001"
);
auto
t1
=
UniSetTypes
::
getObjectsList
(
str1
);
CHECK
(
t1
.
size
()
==
5
);
vector
<
UniSetTypes
::
ConsumerInfo
>
v
(
t1
.
begin
(),
t1
.
end
());
REQUIRE
(
v
[
0
].
id
==
100
);
REQUIRE
(
v
[
0
].
node
==
1001
);
REQUIRE
(
v
[
1
].
id
==
100
);
REQUIRE
(
v
[
1
].
node
==
DefaultObjectId
);
REQUIRE
(
v
[
2
].
id
==
102
);
REQUIRE
(
v
[
2
].
node
==
DefaultObjectId
);
REQUIRE
(
v
[
3
].
id
==
102
);
REQUIRE
(
v
[
3
].
node
==
1002
);
REQUIRE
(
v
[
4
].
id
==
103
);
REQUIRE
(
v
[
4
].
node
==
1001
);
}
// -----------------------------------------------------------------------------
tests/tests_with_conf.xml
View file @
5b3f66b1
...
...
@@ -55,15 +55,18 @@
textname - текстовое имя датчика
-->
<nodes
port=
"2809"
>
<item
id=
"1000"
name=
"localhost"
alias=
""
textname=
"Локальный узел"
ip=
"127.0.0.1"
/>
<item
id=
"1001"
name=
"node2"
alias=
""
textname=
"Локальный узел"
ip=
"127.0.0.1"
/>
<item
id=
"1000"
name=
"localhost"
alias=
""
textname=
"Локальный узел"
ip=
"127.0.0.1"
/>
<item
id=
"1001"
name=
"node2"
alias=
""
textname=
"Локальный узел N2"
ip=
"127.0.0.1"
/>
<item
id=
"1002"
name=
"node3"
alias=
""
textname=
"Локальный узел N3"
ip=
"127.0.0.1"
/>
</nodes>
<!-- ************************ Датчики ********************** -->
<sensors
name=
"Sensors"
>
<item
id=
"1"
name=
"Input1_S"
textname=
"Команда 1"
node=
""
iotype=
"DI"
priority=
"Medium"
default=
"1"
/>
<item
id=
"4"
name=
"Input2_S"
textname=
"Команда 2"
node=
""
iotype=
"DI"
priority=
"Medium"
/>
<item
id=
"5"
name=
"Input5_S"
textname=
"Команда 2"
node=
""
iotype=
"DI"
priority=
"Medium"
/>
<item
id=
"140"
name=
"Input3_S"
textname=
"Команда 3"
node=
""
iotype=
"DI"
priority=
"Medium"
/>
<item
id=
"141"
name=
"Input4_S"
textname=
"Команда 4"
node=
""
iotype=
"DI"
priority=
"Medium"
/>
</sensors>
<thresholds
name=
"thresholds"
>
...
...
@@ -81,6 +84,9 @@
<!-- ******************* Идентификаторы объектов ***************** -->
<objects
name=
"UniObjects"
>
<item
id=
"100"
name=
"TestProc"
/>
<item
id=
"101"
name=
"TestProc2"
/>
<item
id=
"102"
name=
"TestProc3"
/>
<item
id=
"103"
name=
"TestProc4"
/>
</objects>
</ObjectsMap>
...
...
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