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
c72fbd62
Commit
c72fbd62
authored
Nov 10, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Http API): добавил получение списка заказчиков по указанным
в параметрах датчкам
parent
2f1dbf5a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
15 deletions
+64
-15
SharedMemory.h
extensions/SharedMemory/SharedMemory.h
+3
-1
start_fg.sh
extensions/SharedMemory/start_fg.sh
+1
-1
IONotifyController.h
include/IONotifyController.h
+1
-0
IONotifyController.cc
src/Processes/IONotifyController.cc
+59
-13
No files found.
extensions/SharedMemory/SharedMemory.h
View file @
c72fbd62
...
...
@@ -314,7 +314,9 @@ namespace uniset
offset - начиная с,
limit - количество в ответе.
/consumers - получить список заказчиков по каждому датчику
/consumers?sens1,sens2,sens3 - получить список заказчиков по каждому датчику
Не обязательные параметры:
sens1,... - список по каким датчикам выдать ответ
/lost - получить список заказчиков с которыми терялась связь (и они удалялись из списка)
*/
class
SharedMemory
:
...
...
extensions/SharedMemory/start_fg.sh
View file @
c72fbd62
...
...
@@ -6,7 +6,7 @@ ulimit -Sc 10000000000
./uniset2-start.sh
-f
./uniset2-smemory
--smemory-id
SharedMemory
\
--confile
test.xml
--datfile
test.xml
--db-logging
1
--ulog-add-levels
system,level1
\
--sm-log-add-levels
any
$*
--sm-run-logserver
\
--sm-log-add-levels
any
$*
--sm-run-logserver
--activator-run-httpserver
\
#--pulsar-id DO_C --pulsar-iotype DO --pulsar-msec 100
...
...
include/IONotifyController.h
View file @
c72fbd62
...
...
@@ -326,6 +326,7 @@ class IONotifyController:
// http api
nlohmann
::
json
request_consumers
(
const
std
::
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
);
nlohmann
::
json
request_lost
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
);
nlohmann
::
json
getConsumers
(
uniset
::
ObjectId
sid
,
ConsumerListInfo
&
clist
,
bool
noEmpty
=
true
);
private
:
friend
class
NCRestorer
;
...
...
src/Processes/IONotifyController.cc
View file @
c72fbd62
...
...
@@ -1169,6 +1169,7 @@ nlohmann::json IONotifyController::httpHelp(const Poco::URI::QueryParameters& p)
{
nlohmann
::
json
jdata
=
IOController
::
httpHelp
(
p
);
jdata
[
myname
][
"help"
][
"consumers"
][
"desc"
]
=
"get consumers list"
;
jdata
[
myname
][
"help"
][
"consumers"
][
"params"
]
=
{
"sensor1,sensor2,sensor3"
,
"get consumers for sensors"
};
jdata
[
myname
][
"help"
][
"lost"
][
"desc"
]
=
"get lost consumers list"
;
return
std
::
move
(
jdata
);
}
...
...
@@ -1184,7 +1185,7 @@ nlohmann::json IONotifyController::httpRequest( const string& req, const Poco::U
return
IOController
::
httpRequest
(
req
,
p
);
}
// -----------------------------------------------------------------------------
nlohmann
::
json
IONotifyController
::
request_consumers
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
nlohmann
::
json
IONotifyController
::
request_consumers
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
{
//! \todo Не реализовано
nlohmann
::
json
json
;
...
...
@@ -1193,26 +1194,72 @@ nlohmann::json IONotifyController::request_consumers(const string& req, const Po
auto
oind
=
uniset_conf
()
->
oind
;
std
::
list
<
ParamSInfo
>
slist
;
if
(
p
.
size
()
>
0
)
{
if
(
!
p
[
0
].
first
.
empty
()
)
slist
=
uniset
::
getSInfoList
(
p
[
0
].
first
,
uniset_conf
()
);
if
(
slist
.
empty
()
)
{
ostringstream
err
;
err
<<
"(request_consumers): Bad request parameter: '"
<<
p
[
0
].
first
<<
"'"
;
throw
uniset
::
SystemError
(
err
.
str
());
}
}
uniset_rwmutex_rlock
lock
(
askIOMutex
);
// Проход по списку заданных..
if
(
!
slist
.
empty
()
)
{
auto
&
jnotfound
=
json
[
myname
][
"notfound"
];
for
(
const
auto
&
s
:
slist
)
{
auto
a
=
askIOList
.
find
(
s
.
si
.
id
);
if
(
a
==
askIOList
.
end
()
)
{
jnotfound
.
push_back
(
std
::
to_string
(
s
.
si
.
id
));
continue
;
}
// Включаем в ответ все, даже если список заказчиков пустой
jdata
.
push_back
(
getConsumers
(
a
->
first
,
a
->
second
,
false
)
);
}
}
else
// Проход по всему списку
{
for
(
auto
&&
a
:
askIOList
)
{
auto
&
i
=
a
.
second
;
// добавляем только датчики с непустым списком заказчиков
auto
jret
=
getConsumers
(
a
.
first
,
a
.
second
,
true
);
if
(
!
jret
.
empty
()
)
jdata
.
push_back
(
std
::
move
(
jret
)
);
}
}
uniset_rwmutex_rlock
lock
(
i
.
mut
);
return
std
::
move
(
json
);
}
// -----------------------------------------------------------------------------
nlohmann
::
json
IONotifyController
::
getConsumers
(
ObjectId
sid
,
ConsumerListInfo
&
ci
,
bool
noEmpty
)
{
nlohmann
::
json
jret
;
auto
oind
=
uniset_conf
()
->
oind
;
// отображаем только датчики с "не пустым" списком заказчиков
if
(
i
.
clst
.
empty
()
)
continue
;
uniset_rwmutex_rlock
lock
(
ci
.
mut
);
string
sid
(
std
::
to_string
(
a
.
first
)
);
auto
&
jsens
=
jdata
[
sid
]
;
if
(
ci
.
clst
.
empty
()
&&
noEmpty
)
return
std
::
move
(
jret
)
;
jsens
[
"id"
]
=
a
.
first
;
jsens
[
"sensor_name"
]
=
ORepHelpers
::
getShortName
(
oind
->
getMapName
(
a
.
first
));
string
strID
(
std
::
to_string
(
sid
)
);
auto
&
jsens
=
jret
[
strID
];
jsens
[
"id"
]
=
strID
;
jsens
[
"sensor_name"
]
=
ORepHelpers
::
getShortName
(
oind
->
getMapName
(
sid
));
auto
&
jcons
=
jsens
[
"consumers"
];
for
(
const
auto
&
c
:
i
.
clst
)
for
(
const
auto
&
c
:
c
i
.
clst
)
{
string
cid
(
std
::
to_string
(
c
.
id
)
);
auto
&
jconsinfo
=
jcons
[
cid
];
...
...
@@ -1222,9 +1269,8 @@ nlohmann::json IONotifyController::request_consumers(const string& req, const Po
jconsinfo
[
"attempt"
]
=
c
.
attempt
;
jconsinfo
[
"smCount"
]
=
c
.
smCount
;
}
}
return
std
::
move
(
j
son
);
return
std
::
move
(
j
ret
);
}
// -----------------------------------------------------------------------------
nlohmann
::
json
IONotifyController
::
request_lost
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
...
...
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