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
c7904389
Commit
c7904389
authored
Dec 01, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make style
parent
b0ecd945
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
265 additions
and
225 deletions
+265
-225
TestGen.h
Utilities/codegen/tests/TestGen.h
+0
-0
UObject_SK.h
extensions/include/UObject_SK.h
+76
-58
UObject_SK.cc
extensions/lib/UObject_SK.cc
+0
-0
IOController.h
include/IOController.h
+0
-0
UHttpRequestHandler.h
include/UHttpRequestHandler.h
+28
-28
UHttpRequestHandler.cc
src/Communications/Http/UHttpRequestHandler.cc
+6
-6
LogServer.cc
src/Log/LogServer.cc
+2
-1
LogSession.cc
src/Log/LogSession.cc
+1
-1
UniSetActivator.cc
src/ObjectRepository/UniSetActivator.cc
+15
-6
UniSetObject.cc
src/ObjectRepository/UniSetObject.cc
+2
-2
IOController.cc
src/Processes/IOController.cc
+42
-39
IONotifyController.cc
src/Processes/IONotifyController.cc
+30
-21
uhttp-test.cc
tests/UHttpTest/uhttp-test.cc
+63
-63
No files found.
Utilities/codegen/tests/TestGen.h
View file @
c7904389
extensions/include/UObject_SK.h
View file @
c7904389
...
...
@@ -29,7 +29,7 @@ class UObject_SK:
public
uniset
::
UniSetObject
{
public
:
UObject_SK
(
uniset
::
ObjectId
id
,
xmlNode
*
node
=
uniset
::
uniset_conf
()
->
getNode
(
"UObject"
),
const
std
::
string
&
argprefix
=
""
);
UObject_SK
(
uniset
::
ObjectId
id
,
xmlNode
*
node
=
uniset
::
uniset_conf
()
->
getNode
(
"UObject"
),
const
std
::
string
&
argprefix
=
""
);
UObject_SK
();
virtual
~
UObject_SK
();
...
...
@@ -43,54 +43,60 @@ class UObject_SK:
virtual
bool
setMsg
(
uniset
::
ObjectId
code
,
bool
state
=
true
)
noexcept
;
inline
std
::
shared_ptr
<
DebugStream
>
log
()
noexcept
{
return
mylog
;
}
inline
std
::
shared_ptr
<
uniset
::
LogAgregator
>
logAgregator
()
noexcept
{
return
loga
;
}
inline
std
::
shared_ptr
<
DebugStream
>
log
()
noexcept
{
return
mylog
;
}
inline
std
::
shared_ptr
<
uniset
::
LogAgregator
>
logAgregator
()
noexcept
{
return
loga
;
}
void
init_dlog
(
std
::
shared_ptr
<
DebugStream
>
d
)
noexcept
;
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
...
...
@@ -107,16 +113,19 @@ class UObject_SK:
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
str
(
uniset
::
ObjectId
id
,
bool
showLinkName
=
true
)
const
;
std
::
string
str
(
uniset
::
ObjectId
id
,
bool
showLinkName
=
true
)
const
;
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
strval
(
uniset
::
ObjectId
id
,
bool
showLinkName
=
true
)
const
;
std
::
string
strval
(
uniset
::
ObjectId
id
,
bool
showLinkName
=
true
)
const
;
/*! Вывод состояния внутренних переменных */
inline
std
::
string
dumpVars
(){
return
std
::
move
(
vmon
.
pretty_str
());
}
inline
std
::
string
dumpVars
()
{
return
std
::
move
(
vmon
.
pretty_str
());
}
// ------------------------------------------------------------
std
::
string
help
()
noexcept
;
...
...
@@ -152,22 +161,25 @@ class UObject_SK:
virtual
void
callback
()
noexcept
override
;
virtual
void
processingMessage
(
const
uniset
::
VoidMessage
*
msg
)
override
;
virtual
void
sysCommand
(
const
uniset
::
SystemMessage
*
sm
){};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
){}
virtual
void
sensorInfo
(
const
uniset
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
uniset
::
TimerMessage
*
tm
)
override
{}
virtual
void
sysCommand
(
const
uniset
::
SystemMessage
*
sm
)
{};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{}
virtual
void
sensorInfo
(
const
uniset
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
uniset
::
TimerMessage
*
tm
)
override
{}
virtual
void
sigterm
(
int
signo
)
override
;
virtual
bool
activateObject
()
override
;
virtual
std
::
string
getMonitInfo
(){
return
""
;
}
/*!< пользовательская информация выводимая в getInfo() */
virtual
std
::
string
getMonitInfo
()
{
return
""
;
/*!< пользовательская информация выводимая в getInfo() */
}
#ifndef DISABLE_REST_API
virtual
void
httpGetUserData
(
Poco
::
JSON
::
Object
::
Ptr
&
jdata
){}
/*!< для пользовательских данных в httpGet() */
virtual
void
httpGetUserData
(
Poco
::
JSON
::
Object
::
Ptr
&
jdata
)
{}
/*!< для пользовательских данных в httpGet() */
virtual
Poco
::
JSON
::
Object
::
Ptr
httpDumpIO
();
virtual
Poco
::
JSON
::
Object
::
Ptr
httpRequestLog
(
const
Poco
::
URI
::
QueryParameters
&
p
);
#endif
// Выполнение очередного шага программы
virtual
void
step
(){}
virtual
void
step
()
{}
void
preAskSensors
(
UniversalIO
::
UIOCommand
cmd
);
void
preSysCommand
(
const
uniset
::
SystemMessage
*
sm
);
...
...
@@ -196,9 +208,15 @@ class UObject_SK:
xmlNode
*
confnode
;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int
getIntProp
(
const
std
::
string
&
name
)
{
return
uniset
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
int
getIntProp
(
const
std
::
string
&
name
)
{
return
uniset
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
uniset
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
uniset
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
uniset
::
timeout_t
smReadyTimeout
;
/*!< время ожидания готовности SM */
std
::
atomic_bool
activated
;
...
...
@@ -249,7 +267,7 @@ class UObject_SK:
}
};
std
::
unordered_map
<
const
uniset
::
ObjectId
,
size_t
,
StatHashFn
>
smStat
;
/*!< количество сообщений по датчикам */
std
::
unordered_map
<
const
uniset
::
ObjectId
,
size_t
,
StatHashFn
>
smStat
;
/*!< количество сообщений по датчикам */
size_t
processingMessageCatchCount
=
{
0
};
/*!< количество исключений пойманных в processingMessage */
...
...
extensions/lib/UObject_SK.cc
View file @
c7904389
This diff is collapsed.
Click to expand it.
include/IOController.h
View file @
c7904389
include/UHttpRequestHandler.h
View file @
c7904389
...
...
@@ -72,17 +72,17 @@
// -------------------------------------------------------------------------
namespace
uniset
{
namespace
UHttp
{
// текущая версия API
const
std
::
string
UHTTP_API_VERSION
=
"v0"
;
namespace
UHttp
{
// текущая версия API
const
std
::
string
UHTTP_API_VERSION
=
"v0"
;
/*! интерфейс для объекта выдающего json-данные */
class
IHttpRequest
{
/*! интерфейс для объекта выдающего json-данные */
class
IHttpRequest
{
public
:
IHttpRequest
()
{}
virtual
~
IHttpRequest
()
{}
IHttpRequest
()
{}
virtual
~
IHttpRequest
()
{}
// throw SystemError
virtual
Poco
::
JSON
::
Object
::
Ptr
httpGet
(
const
Poco
::
URI
::
QueryParameters
&
p
)
=
0
;
...
...
@@ -90,14 +90,14 @@ namespace uniset
// не обязательная функция.
virtual
Poco
::
JSON
::
Object
::
Ptr
httpRequest
(
const
std
::
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
);
};
// -------------------------------------------------------------------------
/*! интерфейс для обработки запросов к объектам */
class
IHttpRequestRegistry
{
};
// -------------------------------------------------------------------------
/*! интерфейс для обработки запросов к объектам */
class
IHttpRequestRegistry
{
public
:
IHttpRequestRegistry
()
{}
virtual
~
IHttpRequestRegistry
()
{}
IHttpRequestRegistry
()
{}
virtual
~
IHttpRequestRegistry
()
{}
// throw SystemError, NameNotFound
virtual
Poco
::
JSON
::
Object
::
Ptr
httpGetByName
(
const
std
::
string
&
name
,
const
Poco
::
URI
::
QueryParameters
&
p
)
=
0
;
...
...
@@ -106,36 +106,36 @@ namespace uniset
virtual
Poco
::
JSON
::
Array
::
Ptr
httpGetObjectsList
(
const
Poco
::
URI
::
QueryParameters
&
p
)
=
0
;
virtual
Poco
::
JSON
::
Object
::
Ptr
httpHelpByName
(
const
std
::
string
&
name
,
const
Poco
::
URI
::
QueryParameters
&
p
)
=
0
;
virtual
Poco
::
JSON
::
Object
::
Ptr
httpRequestByName
(
const
std
::
string
&
name
,
const
std
::
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
=
0
;
};
};
// -------------------------------------------------------------------------
class
UHttpRequestHandler
:
// -------------------------------------------------------------------------
class
UHttpRequestHandler
:
public
Poco
::
Net
::
HTTPRequestHandler
{
{
public
:
UHttpRequestHandler
(
std
::
shared_ptr
<
IHttpRequestRegistry
>
_registry
);
virtual
void
handleRequest
(
Poco
::
Net
::
HTTPServerRequest
&
req
,
Poco
::
Net
::
HTTPServerResponse
&
resp
)
override
;
virtual
void
handleRequest
(
Poco
::
Net
::
HTTPServerRequest
&
req
,
Poco
::
Net
::
HTTPServerResponse
&
resp
)
override
;
private
:
std
::
shared_ptr
<
IHttpRequestRegistry
>
registry
;
std
::
shared_ptr
<
DebugStream
>
log
;
};
// -------------------------------------------------------------------------
class
UHttpRequestHandlerFactory
:
};
// -------------------------------------------------------------------------
class
UHttpRequestHandlerFactory
:
public
Poco
::
Net
::
HTTPRequestHandlerFactory
{
{
public
:
UHttpRequestHandlerFactory
(
std
::
shared_ptr
<
IHttpRequestRegistry
>&
_registry
);
virtual
Poco
::
Net
::
HTTPRequestHandler
*
createRequestHandler
(
const
Poco
::
Net
::
HTTPServerRequest
&
)
override
;
virtual
Poco
::
Net
::
HTTPRequestHandler
*
createRequestHandler
(
const
Poco
::
Net
::
HTTPServerRequest
&
)
override
;
private
:
std
::
shared_ptr
<
IHttpRequestRegistry
>
registry
;
};
}
};
}
// -------------------------------------------------------------------------
}
// end of uniset namespace
// -------------------------------------------------------------------------
...
...
src/Communications/Http/UHttpRequestHandler.cc
View file @
c7904389
...
...
@@ -39,8 +39,8 @@ void UHttpRequestHandler::handleRequest( Poco::Net::HTTPServerRequest& req, Poco
resp
.
setContentType
(
"text/json"
);
std
::
ostream
&
out
=
resp
.
send
();
Poco
::
JSON
::
Object
::
Ptr
jdata
=
new
Poco
::
JSON
::
Object
();
jdata
->
set
(
"error"
,
resp
.
getReasonForStatus
(
resp
.
getStatus
()));
jdata
->
set
(
"ecode"
,
resp
.
getStatus
());
jdata
->
set
(
"error"
,
resp
.
getReasonForStatus
(
resp
.
getStatus
()));
jdata
->
set
(
"ecode"
,
resp
.
getStatus
());
jdata
->
set
(
"message"
,
"Unknown 'registry of objects'"
);
jdata
->
stringify
(
out
);
out
.
flush
();
...
...
@@ -128,10 +128,10 @@ void UHttpRequestHandler::handleRequest( Poco::Net::HTTPServerRequest& req, Poco
json
->
stringify
(
out
);
}
}
// catch( Poco::JSON::JSONException jsone )
// {
// std::cout << "JSON ERROR: " << jsone.message() << std::endl;
// }
// catch( Poco::JSON::JSONException jsone )
// {
// std::cout << "JSON ERROR: " << jsone.message() << std::endl;
// }
catch
(
std
::
exception
&
ex
)
{
ostringstream
err
;
...
...
src/Log/LogServer.cc
View file @
c7904389
...
...
@@ -358,7 +358,8 @@ Poco::JSON::Object::Ptr LogServer::httpGetShortInfo()
uniset_rwmutex_rlock
l
(
mutSList
);
Poco
::
JSON
::
Array
::
Ptr
jsess
=
new
Poco
::
JSON
::
Array
();
jdata
->
set
(
"sessions"
,
jsess
);
jdata
->
set
(
"sessions"
,
jsess
);
for
(
const
auto
&
s
:
slist
)
jsess
->
add
(
s
->
httpGetShortInfo
());
}
...
...
src/Log/LogSession.cc
View file @
c7904389
...
...
@@ -688,7 +688,7 @@ Poco::JSON::Object::Ptr LogSession::httpGetShortInfo()
}
Poco
::
JSON
::
Object
::
Ptr
jdata
=
new
Poco
::
JSON
::
Object
();
jret
->
set
(
caddr
,
jdata
);
jret
->
set
(
caddr
,
jdata
);
jdata
->
set
(
"client"
,
caddr
);
jdata
->
set
(
"maxbufsize"
,
maxRecordsNum
);
...
...
src/ObjectRepository/UniSetActivator.cc
View file @
c7904389
...
...
@@ -529,14 +529,16 @@ void UniSetActivator::init()
abortScript
=
conf
->
getArgParam
(
"--uniset-abort-script"
,
""
);
#ifndef DISABLE_REST_API
if
(
findArgParam
(
"--activator-run-httpserver"
,
conf
->
getArgc
(),
conf
->
getArgv
())
!=
-
1
)
{
httpHost
=
conf
->
getArgParam
(
"--activator-httpserver-host"
,
"localhost"
);
ostringstream
s
;
s
<<
(
getId
()
==
DefaultObjectId
?
8080
:
getId
()
);
s
<<
(
getId
()
==
DefaultObjectId
?
8080
:
getId
()
);
httpPort
=
conf
->
getArgInt
(
"--activator-httpserver-port"
,
s
.
str
());
ulog1
<<
myname
<<
"(init): http server parameters "
<<
httpHost
<<
":"
<<
httpPort
<<
endl
;
}
#endif
orb
=
conf
->
getORB
();
...
...
@@ -668,12 +670,13 @@ void UniSetActivator::run( bool thread )
set_signals
(
true
);
#ifndef DISABLE_REST_API
if
(
!
httpHost
.
empty
()
)
{
try
{
auto
reg
=
dynamic_pointer_cast
<
UHttp
::
IHttpRequestRegistry
>
(
shared_from_this
());
httpserv
=
make_shared
<
UHttp
::
UHttpServer
>
(
reg
,
httpHost
,
httpPort
);
httpserv
=
make_shared
<
UHttp
::
UHttpServer
>
(
reg
,
httpHost
,
httpPort
);
httpserv
->
start
();
}
catch
(
std
::
exception
&
ex
)
...
...
@@ -681,6 +684,7 @@ void UniSetActivator::run( bool thread )
uwarn
<<
myname
<<
"(run): init http server error: "
<<
ex
.
what
()
<<
endl
;
}
}
#endif
if
(
thread
)
...
...
@@ -719,8 +723,10 @@ void UniSetActivator::stop()
ulogsys
<<
myname
<<
"(stop): discard request ok."
<<
endl
;
#ifndef DISABLE_REST_API
if
(
httpserv
)
httpserv
->
stop
();
#endif
}
...
...
@@ -876,6 +882,7 @@ Poco::JSON::Object::Ptr UniSetActivator::httpGetByName( const string& name, cons
return
httpGet
(
p
);
auto
obj
=
deepFindObject
(
name
);
if
(
obj
)
return
obj
->
httpGet
(
p
);
...
...
@@ -894,9 +901,9 @@ Poco::JSON::Array::Ptr UniSetActivator::httpGetObjectsList( const Poco::URI::Que
//! \todo Доделать обработку параметров beg,lim на случай большого количества объектов (и частичных запросов)
size_t
lim
=
1000
;
getAllObjectsList
(
vec
,
lim
);
getAllObjectsList
(
vec
,
lim
);
for
(
const
auto
&
o
:
vec
)
for
(
const
auto
&
o
:
vec
)
jdata
->
add
(
o
->
getName
());
return
jdata
;
...
...
@@ -908,6 +915,7 @@ Poco::JSON::Object::Ptr UniSetActivator::httpHelpByName( const string& name, con
return
httpHelp
(
p
);
auto
obj
=
deepFindObject
(
name
);
if
(
obj
)
return
obj
->
httpHelp
(
p
);
...
...
@@ -919,11 +927,12 @@ Poco::JSON::Object::Ptr UniSetActivator::httpHelpByName( const string& name, con
Poco
::
JSON
::
Object
::
Ptr
UniSetActivator
::
httpRequestByName
(
const
string
&
name
,
const
std
::
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
{
if
(
name
==
myname
)
return
httpRequest
(
req
,
p
);
return
httpRequest
(
req
,
p
);
auto
obj
=
deepFindObject
(
name
);
if
(
obj
)
return
obj
->
httpRequest
(
req
,
p
);
return
obj
->
httpRequest
(
req
,
p
);
ostringstream
err
;
err
<<
"Object '"
<<
name
<<
"' not found"
;
...
...
src/ObjectRepository/UniSetObject.cc
View file @
c7904389
...
...
@@ -386,9 +386,9 @@ void UniSetObject::push( const TransportMessage& tm )
Poco
::
JSON
::
Object
::
Ptr
UniSetObject
::
httpGet
(
const
Poco
::
URI
::
QueryParameters
&
p
)
{
Poco
::
JSON
::
Object
::
Ptr
jret
=
new
Poco
::
JSON
::
Object
();
Poco
::
JSON
::
Object
::
Ptr
jdata
=
uniset
::
json
::
make_child
(
jret
,
myname
);
Poco
::
JSON
::
Object
::
Ptr
jdata
=
uniset
::
json
::
make_child
(
jret
,
myname
);
jdata
->
set
(
"name"
,
myname
);
jdata
->
set
(
"name"
,
myname
);
jdata
->
set
(
"id"
,
getId
());
jdata
->
set
(
"msgCount"
,
countMessages
());
jdata
->
set
(
"lostMessages"
,
getCountOfLostMessages
());
...
...
src/Processes/IOController.cc
View file @
c7904389
...
...
@@ -850,17 +850,17 @@ Poco::JSON::Object::Ptr IOController::httpHelp( const Poco::URI::QueryParameters
{
// 'get'
uniset
::
json
::
help
::
item
cmd
(
"get value for sensor"
);
cmd
.
param
(
"id1,name2,id3"
,
"get value for id1,name2,id3 sensors"
);
cmd
.
param
(
"shortInfo"
,
"get short information for sensors"
);
cmd
.
param
(
"id1,name2,id3"
,
"get value for id1,name2,id3 sensors"
);
cmd
.
param
(
"shortInfo"
,
"get short information for sensors"
);
myhelp
.
add
(
cmd
);
}
{
// 'sensors'
uniset
::
json
::
help
::
item
cmd
(
"et all sensors"
);
cmd
.
param
(
"nameonly"
,
"get only name sensors"
);
cmd
.
param
(
"offset=N"
,
"get from N record"
);
cmd
.
param
(
"limit=M"
,
"limit of records"
);
cmd
.
param
(
"nameonly"
,
"get only name sensors"
);
cmd
.
param
(
"offset=N"
,
"get from N record"
);
cmd
.
param
(
"limit=M"
,
"limit of records"
);
myhelp
.
add
(
cmd
);
}
...
...
@@ -870,12 +870,12 @@ Poco::JSON::Object::Ptr IOController::httpHelp( const Poco::URI::QueryParameters
Poco
::
JSON
::
Object
::
Ptr
IOController
::
httpRequest
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
{
if
(
req
==
"get"
)
return
request_get
(
req
,
p
);
return
request_get
(
req
,
p
);
if
(
req
==
"sensors"
)
return
request_sensors
(
req
,
p
);
return
request_sensors
(
req
,
p
);
return
UniSetManager
::
httpRequest
(
req
,
p
);
return
UniSetManager
::
httpRequest
(
req
,
p
);
}
// -----------------------------------------------------------------------------
Poco
::
JSON
::
Object
::
Ptr
IOController
::
request_get
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
...
...
@@ -889,6 +889,7 @@ Poco::JSON::Object::Ptr IOController::request_get( const string& req, const Poco
auto
conf
=
uniset_conf
();
auto
slist
=
uniset
::
getSInfoList
(
p
[
0
].
first
,
conf
);
if
(
slist
.
empty
()
)
{
ostringstream
err
;
...
...
@@ -897,34 +898,36 @@ Poco::JSON::Object::Ptr IOController::request_get( const string& req, const Poco
}
bool
shortInfo
=
false
;
if
(
p
.
size
()
>
1
&&
p
[
1
].
first
==
"shortInfo"
)
if
(
p
.
size
()
>
1
&&
p
[
1
].
first
==
"shortInfo"
)
shortInfo
=
true
;
// ulog1 << myname << "(GET): " << p[0].first << " size=" << slist.size() << endl;
// ulog1 << myname << "(GET): " << p[0].first << " size=" << slist.size() << endl;
// myname {
// sensors: [
// sid:
// value: long
// error: string
// ]
// }
// myname {
// sensors: [
// sid:
// value: long
// error: string
// ]
// }
Poco
::
JSON
::
Object
::
Ptr
jdata
=
new
Poco
::
JSON
::
Object
();
Poco
::
JSON
::
Array
::
Ptr
jsens
=
new
Poco
::
JSON
::
Array
();
jdata
->
set
(
"sensors"
,
jsens
);
jdata
->
set
(
"sensors"
,
jsens
);
Poco
::
JSON
::
Object
::
Ptr
nullObject
=
new
Poco
::
JSON
::
Object
();
for
(
const
auto
&
s
:
slist
)
for
(
const
auto
&
s
:
slist
)
{
try
{
auto
sinf
=
ioList
.
find
(
s
.
si
.
id
);
if
(
sinf
==
ioList
.
end
()
)
{
string
sid
(
std
::
to_string
(
s
.
si
.
id
)
);
jsens
->
add
(
json
::
make_object
(
sid
,
json
::
make_object
(
"value"
,
nullObject
)));
jsens
->
add
(
json
::
make_object
(
sid
,
json
::
make_object
(
"error"
,
"Sensor not found"
)));
jsens
->
add
(
json
::
make_object
(
sid
,
json
::
make_object
(
"value"
,
nullObject
)));
jsens
->
add
(
json
::
make_object
(
sid
,
json
::
make_object
(
"error"
,
"Sensor not found"
)));
continue
;
}
...
...
@@ -933,18 +936,18 @@ Poco::JSON::Object::Ptr IOController::request_get( const string& req, const Poco
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
string
sid
(
std
::
to_string
(
s
.
si
.
id
)
);
jsens
->
add
(
json
::
make_object
(
sid
,
uniset
::
json
::
make_object
(
"value"
,
nullObject
)));
jsens
->
add
(
json
::
make_object
(
sid
,
uniset
::
json
::
make_object
(
"error"
,
string
(
ex
.
err
))));
jsens
->
add
(
json
::
make_object
(
sid
,
uniset
::
json
::
make_object
(
"value"
,
nullObject
)));
jsens
->
add
(
json
::
make_object
(
sid
,
uniset
::
json
::
make_object
(
"error"
,
string
(
ex
.
err
))));
}
catch
(
std
::
exception
&
ex
)
{
string
sid
(
std
::
to_string
(
s
.
si
.
id
)
);
jsens
->
add
(
json
::
make_object
(
sid
,
uniset
::
json
::
make_object
(
"value"
,
nullObject
)));
jsens
->
add
(
json
::
make_object
(
sid
,
uniset
::
json
::
make_object
(
"error"
,
ex
.
what
())));
jsens
->
add
(
json
::
make_object
(
sid
,
uniset
::
json
::
make_object
(
"value"
,
nullObject
)));
jsens
->
add
(
json
::
make_object
(
sid
,
uniset
::
json
::
make_object
(
"error"
,
ex
.
what
())));
}
}
return
uniset
::
json
::
make_object
(
myname
,
jdata
);
return
uniset
::
json
::
make_object
(
myname
,
jdata
);
}
// -----------------------------------------------------------------------------
void
IOController
::
getSensorInfo
(
Poco
::
JSON
::
Array
::
Ptr
&
jdata
,
std
::
shared_ptr
<
USensorInfo
>&
s
,
bool
shortInfo
)
...
...
@@ -955,15 +958,15 @@ void IOController::getSensorInfo( Poco::JSON::Array::Ptr& jdata, std::shared_ptr
jdata
->
add
(
mydata
);
std
::
string
sid
(
to_string
(
s
->
si
.
id
));
mydata
->
set
(
sid
,
jsens
);
mydata
->
set
(
sid
,
jsens
);
{
uniset_rwmutex_rlock
lock
(
s
->
val_lock
);
jsens
->
set
(
"value"
,
s
->
value
);
jsens
->
set
(
"real_value"
,
s
->
real_value
);
jsens
->
set
(
"real_value"
,
s
->
real_value
);
}
jsens
->
set
(
"id"
,
sid
);
jsens
->
set
(
"id"
,
sid
);
jsens
->
set
(
"name"
,
ORepHelpers
::
getShortName
(
uniset_conf
()
->
oind
->
getMapName
(
s
->
si
.
id
)));
jsens
->
set
(
"tv_sec"
,
s
->
tv_sec
);
jsens
->
set
(
"tv_nsec"
,
s
->
tv_nsec
);
...
...
@@ -976,12 +979,12 @@ void IOController::getSensorInfo( Poco::JSON::Array::Ptr& jdata, std::shared_ptr
jsens
->
set
(
"dbignore"
,
s
->
dbignore
);
jsens
->
set
(
"nchanges"
,
s
->
nchanges
);
Poco
::
JSON
::
Object
::
Ptr
calibr
=
uniset
::
json
::
make_child
(
jsens
,
"calibration"
);
calibr
->
set
(
"cmin"
,
s
->
ci
.
minCal
);
calibr
->
set
(
"cmax"
,
s
->
ci
.
maxCal
);
calibr
->
set
(
"rmin"
,
s
->
ci
.
minRaw
);
calibr
->
set
(
"rmax"
,
s
->
ci
.
maxRaw
);
calibr
->
set
(
"precision"
,
s
->
ci
.
precision
);
Poco
::
JSON
::
Object
::
Ptr
calibr
=
uniset
::
json
::
make_child
(
jsens
,
"calibration"
);
calibr
->
set
(
"cmin"
,
s
->
ci
.
minCal
);
calibr
->
set
(
"cmax"
,
s
->
ci
.
maxCal
);
calibr
->
set
(
"rmin"
,
s
->
ci
.
minRaw
);
calibr
->
set
(
"rmax"
,
s
->
ci
.
maxRaw
);
calibr
->
set
(
"precision"
,
s
->
ci
.
precision
);
// ::CORBA::Boolean undefined;
// ::CORBA::Boolean blocked;
...
...
@@ -994,13 +997,13 @@ void IOController::getSensorInfo( Poco::JSON::Array::Ptr& jdata, std::shared_ptr
Poco
::
JSON
::
Object
::
Ptr
IOController
::
request_sensors
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
params
)
{
Poco
::
JSON
::
Object
::
Ptr
jdata
=
new
Poco
::
JSON
::
Object
();
Poco
::
JSON
::
Array
::
Ptr
jsens
=
uniset
::
json
::
make_child_array
(
jdata
,
"sensors"
);
Poco
::
JSON
::
Array
::
Ptr
jsens
=
uniset
::
json
::
make_child_array
(
jdata
,
"sensors"
);
size_t
num
=
0
;
size_t
offset
=
0
;
size_t
limit
=
0
;
for
(
const
auto
&
p
:
params
)
for
(
const
auto
&
p
:
params
)
{
if
(
p
.
first
==
"offset"
)
offset
=
uni_atoi
(
p
.
second
);
...
...
@@ -1010,7 +1013,7 @@ Poco::JSON::Object::Ptr IOController::request_sensors( const string& req, const
size_t
endnum
=
offset
+
limit
;
for
(
auto
it
=
myioBegin
();
it
!=
myioEnd
();
++
it
,
num
++
)
for
(
auto
it
=
myioBegin
();
it
!=
myioEnd
();
++
it
,
num
++
)
{
if
(
limit
>
0
&&
num
>=
endnum
)
break
;
...
...
@@ -1018,7 +1021,7 @@ Poco::JSON::Object::Ptr IOController::request_sensors( const string& req, const
if
(
offset
>
0
&&
num
<
offset
)
continue
;
getSensorInfo
(
jsens
,
it
->
second
,
false
);
getSensorInfo
(
jsens
,
it
->
second
,
false
);
}
jdata
->
set
(
"count"
,
num
);
...
...
src/Processes/IONotifyController.cc
View file @
c7904389
...
...
@@ -88,10 +88,12 @@ SimpleInfo* IONotifyController::getInfo( ::CORBA::Long userparam )
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lostConsumersMutex
);
if
(
lostConsumers
.
size
()
>
0
)
{
inf
<<
"-------------------------- lost consumers list [maxAttemtps="
<<
maxAttemtps
<<
"] ------------------"
<<
endl
;
for
(
const
auto
&
l
:
lostConsumers
)
for
(
const
auto
&
l
:
lostConsumers
)
{
inf
<<
" "
<<
"("
<<
setw
(
6
)
<<
l
.
first
<<
")"
<<
setw
(
35
)
<<
std
::
left
<<
ORepHelpers
::
getShortName
(
oind
->
getMapName
(
l
.
first
))
...
...
@@ -99,6 +101,7 @@ SimpleInfo* IONotifyController::getInfo( ::CORBA::Long userparam )
<<
endl
;
}
}
inf
<<
"----------------------------------------------------------------------------------"
<<
endl
;
}
...
...
@@ -198,7 +201,7 @@ bool IONotifyController::addConsumer( ConsumerListInfo& lst, const ConsumerInfo&
{
uniset_rwmutex_wrlock
l
(
lst
.
mut
);
for
(
auto
&&
it
:
lst
.
clst
)
for
(
auto
&&
it
:
lst
.
clst
)
{
if
(
it
.
id
==
ci
.
id
&&
it
.
node
==
ci
.
node
)
{
...
...
@@ -209,7 +212,8 @@ bool IONotifyController::addConsumer( ConsumerListInfo& lst, const ConsumerInfo&
// выставляем флаг, что заказчик опять "на связи"
std
::
lock_guard
<
std
::
mutex
>
lock
(
lostConsumersMutex
);
auto
c
=
lostConsumers
.
find
(
ci
.
id
);
if
(
c
!=
lostConsumers
.
end
()
)
if
(
c
!=
lostConsumers
.
end
()
)
c
->
second
.
lost
=
false
;
return
false
;
...
...
@@ -231,7 +235,8 @@ bool IONotifyController::addConsumer( ConsumerListInfo& lst, const ConsumerInfo&
// выставляем флаг, что клиент опять "на связи"
std
::
lock_guard
<
std
::
mutex
>
lock
(
lostConsumersMutex
);
auto
c
=
lostConsumers
.
find
(
ci
.
id
);
if
(
c
!=
lostConsumers
.
end
()
)
if
(
c
!=
lostConsumers
.
end
()
)
c
->
second
.
lost
=
false
;
return
true
;
...
...
@@ -545,6 +550,7 @@ void IONotifyController::send( ConsumerListInfo& lst, const uniset::SensorMessag
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lostConsumersMutex
);
auto
&
c
=
lostConsumers
[
li
->
id
];
// если уже выставлен флаг что "заказчик" пропал, то не надо увеличивать "счётчик"
// видимо мы уже зафиксировали его пропажу на другом датчике...
if
(
!
c
.
lost
)
...
...
@@ -1173,7 +1179,7 @@ Poco::JSON::Object::Ptr IONotifyController::httpHelp(const Poco::URI::QueryParam
{
// 'consumers'
uniset
::
json
::
help
::
item
cmd
(
"get consumers list"
);
cmd
.
param
(
"sensor1,sensor2,sensor3"
,
"get consumers for sensors"
);
cmd
.
param
(
"sensor1,sensor2,sensor3"
,
"get consumers for sensors"
);
myhelp
.
add
(
cmd
);
}
...
...
@@ -1189,23 +1195,24 @@ Poco::JSON::Object::Ptr IONotifyController::httpHelp(const Poco::URI::QueryParam
Poco
::
JSON
::
Object
::
Ptr
IONotifyController
::
httpRequest
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
{
if
(
req
==
"consumers"
)
return
request_consumers
(
req
,
p
);
return
request_consumers
(
req
,
p
);
if
(
req
==
"lost"
)
return
request_lost
(
req
,
p
);
return
request_lost
(
req
,
p
);
return
IOController
::
httpRequest
(
req
,
p
);
return
IOController
::
httpRequest
(
req
,
p
);
}
// -----------------------------------------------------------------------------
Poco
::
JSON
::
Object
::
Ptr
IONotifyController
::
request_consumers
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
{
Poco
::
JSON
::
Object
::
Ptr
json
=
new
Poco
::
JSON
::
Object
();
Poco
::
JSON
::
Object
::
Ptr
mydata
=
uniset
::
json
::
make_child
(
json
,
myname
);
Poco
::
JSON
::
Array
::
Ptr
jdata
=
uniset
::
json
::
make_child_array
(
mydata
,
"consumers"
);
Poco
::
JSON
::
Object
::
Ptr
mydata
=
uniset
::
json
::
make_child
(
json
,
myname
);
Poco
::
JSON
::
Array
::
Ptr
jdata
=
uniset
::
json
::
make_child_array
(
mydata
,
"consumers"
);
auto
oind
=
uniset_conf
()
->
oind
;
std
::
list
<
ParamSInfo
>
slist
;
if
(
p
.
size
()
>
0
)
{
if
(
!
p
[
0
].
first
.
empty
()
)
...
...
@@ -1224,11 +1231,12 @@ Poco::JSON::Object::Ptr IONotifyController::request_consumers( const string& req
// Проход по списку заданных..
if
(
!
slist
.
empty
()
)
{
auto
jnotfound
=
uniset
::
json
::
make_child_array
(
mydata
,
"notfound"
);
auto
jnotfound
=
uniset
::
json
::
make_child_array
(
mydata
,
"notfound"
);
for
(
const
auto
&
s
:
slist
)
for
(
const
auto
&
s
:
slist
)
{
auto
a
=
askIOList
.
find
(
s
.
si
.
id
);
if
(
a
==
askIOList
.
end
()
)
{
jnotfound
->
add
(
std
::
to_string
(
s
.
si
.
id
));
...
...
@@ -1236,15 +1244,16 @@ Poco::JSON::Object::Ptr IONotifyController::request_consumers( const string& req
}
// Включаем в ответ все, даже если список заказчиков пустой
jdata
->
add
(
getConsumers
(
a
->
first
,
a
->
second
,
false
)
);
jdata
->
add
(
getConsumers
(
a
->
first
,
a
->
second
,
false
)
);
}
}
else
// Проход по всему списку
{
for
(
auto
&&
a
:
askIOList
)
for
(
auto
&&
a
:
askIOList
)
{
// добавляем только датчики с непустым списком заказчиков
auto
jret
=
getConsumers
(
a
.
first
,
a
.
second
,
true
);
auto
jret
=
getConsumers
(
a
.
first
,
a
.
second
,
true
);
if
(
jret
)
jdata
->
add
(
jret
);
}
...
...
@@ -1264,9 +1273,9 @@ Poco::JSON::Object::Ptr IONotifyController::getConsumers( ObjectId sid, Consumer
return
jret
;
string
strID
(
std
::
to_string
(
sid
)
);
auto
jsens
=
uniset
::
json
::
make_child
(
jret
,
strID
);
auto
jsens
=
uniset
::
json
::
make_child
(
jret
,
strID
);
jsens
->
set
(
"id"
,
strID
);
jsens
->
set
(
"id"
,
strID
);
jsens
->
set
(
"sensor_name"
,
ORepHelpers
::
getShortName
(
oind
->
getMapName
(
sid
)));
auto
jcons
=
uniset
::
json
::
make_child
(
jsens
,
"consumers"
);
...
...
@@ -1274,7 +1283,7 @@ Poco::JSON::Object::Ptr IONotifyController::getConsumers( ObjectId sid, Consumer
for
(
const
auto
&
c
:
ci
.
clst
)
{
string
cid
(
std
::
to_string
(
c
.
id
)
);
auto
jconsinfo
=
uniset
::
json
::
make_child
(
jcons
,
cid
);
auto
jconsinfo
=
uniset
::
json
::
make_child
(
jcons
,
cid
);
jconsinfo
->
set
(
"id"
,
c
.
id
);
jconsinfo
->
set
(
"name"
,
ORepHelpers
::
getShortName
(
oind
->
getMapName
(
c
.
id
)));
jconsinfo
->
set
(
"lostEvents"
,
c
.
lostEvents
);
...
...
@@ -1289,14 +1298,14 @@ Poco::JSON::Object::Ptr IONotifyController::request_lost( const string& req, con
{
Poco
::
JSON
::
Object
::
Ptr
json
=
new
Poco
::
JSON
::
Object
();
Poco
::
JSON
::
Object
::
Ptr
mydata
=
uniset
::
json
::
make_child
(
json
,
myname
);
Poco
::
JSON
::
Array
::
Ptr
jdata
=
uniset
::
json
::
make_child_array
(
mydata
,
"lost consumers"
);
Poco
::
JSON
::
Object
::
Ptr
mydata
=
uniset
::
json
::
make_child
(
json
,
myname
);
Poco
::
JSON
::
Array
::
Ptr
jdata
=
uniset
::
json
::
make_child_array
(
mydata
,
"lost consumers"
);
auto
oind
=
uniset_conf
()
->
oind
;
std
::
lock_guard
<
std
::
mutex
>
lock
(
lostConsumersMutex
);
for
(
const
auto
&
c
:
lostConsumers
)
for
(
const
auto
&
c
:
lostConsumers
)
{
Poco
::
JSON
::
Object
::
Ptr
jcons
=
new
Poco
::
JSON
::
Object
();
jcons
->
set
(
"id"
,
c
.
first
);
...
...
tests/UHttpTest/uhttp-test.cc
View file @
c7904389
...
...
@@ -12,17 +12,17 @@ class UTestSupplier:
public
UHttp
::
IHttpRequest
{
public
:
UTestSupplier
(){}
virtual
~
UTestSupplier
(){}
UTestSupplier
()
{}
virtual
~
UTestSupplier
()
{}
virtual
Poco
::
JSON
::
Object
::
Ptr
httpGet
(
const
Poco
::
URI
::
QueryParameters
&
params
)
override
{
Poco
::
JSON
::
Object
::
Ptr
j
=
new
Poco
::
JSON
::
Object
();
for
(
const
auto
&
p
:
params
)
j
->
set
(
p
.
first
,
p
.
second
);
for
(
const
auto
&
p
:
params
)
j
->
set
(
p
.
first
,
p
.
second
);
j
->
set
(
"test"
,
42
);
j
->
set
(
"test"
,
42
);
return
j
;
}
...
...
@@ -31,18 +31,18 @@ class UTestSupplier:
uniset
::
json
::
help
::
object
myhelp
(
"test"
);
uniset
::
json
::
help
::
item
cmd1
(
"description for cmd1"
);
cmd1
.
param
(
"p1"
,
"description of p1"
);
cmd1
.
param
(
"p2"
,
"description of p1"
);
cmd1
.
param
(
"p3"
,
"description of p1"
);
cmd1
.
param
(
"p1"
,
"description of p1"
);
cmd1
.
param
(
"p2"
,
"description of p1"
);
cmd1
.
param
(
"p3"
,
"description of p1"
);
myhelp
.
add
(
cmd1
);
uniset
::
json
::
help
::
item
cmd2
(
"description for cmd2"
);
cmd2
.
param
(
"p1"
,
"description of p1"
);
cmd2
.
param
(
"p2"
,
"description of p1"
);
cmd2
.
param
(
"p3"
,
"description of p1"
);
cmd2
.
param
(
"p1"
,
"description of p1"
);
cmd2
.
param
(
"p2"
,
"description of p1"
);
cmd2
.
param
(
"p3"
,
"description of p1"
);
myhelp
.
add
(
cmd2
);
cmd1
.
param
(
"p4"
,
"description of p4"
);
cmd1
.
param
(
"p4"
,
"description of p4"
);
myhelp
.
add
(
cmd1
);
return
myhelp
;
...
...
@@ -51,7 +51,7 @@ class UTestSupplier:
virtual
Poco
::
JSON
::
Object
::
Ptr
httpRequest
(
const
std
::
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
override
{
Poco
::
JSON
::
Object
::
Ptr
j
=
new
Poco
::
JSON
::
Object
();
j
->
set
(
req
,
"OK"
);
j
->
set
(
req
,
"OK"
);
return
j
;
}
};
...
...
@@ -60,14 +60,14 @@ class UTestRequestRegistry:
public
UHttp
::
IHttpRequestRegistry
{
public
:
UTestRequestRegistry
(){}
virtual
~
UTestRequestRegistry
(){}
UTestRequestRegistry
()
{}
virtual
~
UTestRequestRegistry
()
{}
virtual
Poco
::
JSON
::
Object
::
Ptr
httpGetByName
(
const
std
::
string
&
name
,
const
Poco
::
URI
::
QueryParameters
&
p
)
override
{
Poco
::
JSON
::
Object
::
Ptr
j
=
sup
.
httpGet
(
p
);
j
->
set
(
"name"
,
name
);
j
->
set
(
"name"
,
name
);
return
j
;
}
...
...
@@ -87,7 +87,7 @@ class UTestRequestRegistry:
virtual
Poco
::
JSON
::
Object
::
Ptr
httpRequestByName
(
const
std
::
string
&
name
,
const
std
::
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
override
{
return
sup
.
httpRequest
(
req
,
p
);
return
sup
.
httpRequest
(
req
,
p
);
}
...
...
@@ -99,76 +99,76 @@ int main(int argc, const char** argv)
{
try
{
// Poco::JSON::Object::Ptr j = new Poco::JSON::Object();
// {
// Poco::DynamicStruct data;
// Poco::Dynamic::Array objects;
// Poco::JSON::Object::Ptr j = new Poco::JSON::Object();
// {
// Poco::DynamicStruct data;
// Poco::Dynamic::Array objects;
// Poco::DynamicStruct object;
// object["id"] = 4565;
// object["size"] = 2.64;
// object["name"] = "Foo";
// object["active"] = false;
// objects.push_back(object);
// Poco::DynamicStruct object;
// object["id"] = 4565;
// object["size"] = 2.64;
// object["name"] = "Foo";
// object["active"] = false;
// objects.push_back(object);
// data["objects"] = objects;
// data["count"] = 1;
// data["objects"] = objects;
// data["count"] = 1;
// std::string s = data.toString();
// std::string s = data.toString();
// std::cout << s << std::endl;
// std::cout << s << std::endl;
// Poco::DynamicAny result_s = Poco::DynamicAny::parse(s);
// Poco::DynamicAny result_s = Poco::DynamicAny::parse(s);
// std::cout << result_s.toString() << std::endl;
// std::cout << result_s.toString() << std::endl;
// j->set("test",object);
// }
// j->set("test",object);
// }
// j->stringify(std::cout);
// cout << endl;
// j->stringify(std::cout);
// cout << endl;
// Poco::JSON::Object::Ptr j = new Poco::JSON::Object();
// j->set("test",23);
// j->set("test2","sdfsdf");
// j->set("test3",232.4);
// Poco::JSON::Object::Ptr j = new Poco::JSON::Object();
// j->set("test",23);
// j->set("test2","sdfsdf");
// j->set("test3",232.4);
// Poco::JSON::Object::Ptr j2 = new Poco::JSON::Object();
// j2->set("rr",23);
// j2->set("rr2",23);
// j2->set("rr3",23);
// Poco::JSON::Object::Ptr j2 = new Poco::JSON::Object();
// j2->set("rr",23);
// j2->set("rr2",23);
// j2->set("rr3",23);
// Poco::JSON::Array::Ptr j3 = new Poco::JSON::Array();
// j3->set(1,23);
// j3->set(2,23);
// j3->set(3,23);
// Poco::JSON::Array::Ptr j3 = new Poco::JSON::Array();
// j3->set(1,23);
// j3->set(2,23);
// j3->set(3,23);
// j->set("Object2",j2);
// j->set("Object3",j3);
// j->set("Object2",j2);
// j->set("Object3",j3);
// j->stringify(std::cerr);
// cerr << endl;
// return 0;
// j->stringify(std::cerr);
// cerr << endl;
// return 0;
// auto j = uniset::json::make_object("key","weweew");
// j->set("key2","wefwefefr");
// auto j = uniset::json::make_object("key","weweew");
// j->set("key2","wefwefefr");
// auto j2 = uniset::json::make_object("key",j);
// auto j2 = uniset::json::make_object("key",j);
//// uniset::json j;
//// j["key"] = "werwe";
//// j["key"]["key2"] = "werwe";
//// uniset::json j;
//// j["key"] = "werwe";
//// j["key"]["key2"] = "werwe";
// j2->stringify(cerr);
// j2->stringify(cerr);
// return 0;
// return 0;
auto
reg
=
std
::
make_shared
<
UTestRequestRegistry
>
();
auto
ireg
=
dynamic_pointer_cast
<
UHttp
::
IHttpRequestRegistry
>
(
reg
);
auto
http
=
make_shared
<
UHttp
::
UHttpServer
>
(
ireg
,
"localhost"
,
5555
);
auto
http
=
make_shared
<
UHttp
::
UHttpServer
>
(
ireg
,
"localhost"
,
5555
);
http
->
log
()
->
level
(
Debug
::
ANY
);
cout
<<
"start http test server localhost:5555"
<<
endl
;
...
...
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