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
b8688490
Commit
b8688490
authored
Oct 14, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(VMonit): сделана сортировка по алфафиту, переписана реализация функций
вывода на экран.
parent
6b5e42ab
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
365 additions
and
366 deletions
+365
-366
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+33
-5
libuniset2.spec
conf/libuniset2.spec
+4
-1
UObject_SK.h
extensions/include/UObject_SK.h
+103
-120
UObject_SK.cc
extensions/lib/UObject_SK.cc
+165
-136
VMonitor.h
include/VMonitor.h
+10
-2
VMonitor.cc
src/Various/VMonitor.cc
+50
-102
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
b8688490
...
...
@@ -1036,18 +1036,44 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
ostringstream s;
s
<<
myname
<<
": "
<<
endl;
std::
vector
<
std::string
>
v
;
std::
list
<
std::string
>
v_in
;
ostringstream s1;
<xsl:for-each
select=
"//smap/item"
>
<xsl:sort
select=
"@name"
order=
"ascending"
data-type=
"text"
/>
<xsl:if
test=
"normalize-space(@vartype)='in'"
>
s1.str("");
s1
<<
" "
<<
setw(30)
<<
std::right
<<
"
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
"
<<
"
("
<<
setw(30)
<<
std::left
<<
ORepHelpers::getShortName( uniset_conf()->oind->getMapName(
<xsl:value-of
select=
"@name"
/>
))
<<
"
)"
<<
"
( "
<<
setw(30)
<<
std::left
<<
ORepHelpers::getShortName( uniset_conf()->oind->getMapName(
<xsl:value-of
select=
"@name"
/>
))
<<
"
)"
<<
std::right
<<
" = "
<<
setw(6)
<<
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
;
v.push_back(s1.str());
v_in.push_back(s1.str());
</xsl:if>
</xsl:for-each>
std::list
<
std::string
>
v_out;
<xsl:for-each
select=
"//smap/item"
>
<xsl:sort
select=
"@name"
order=
"ascending"
data-type=
"text"
/>
<xsl:if
test=
"normalize-space(@vartype)='out'"
>
s1.str("");
s1
<<
" "
<<
setw(30)
<<
std::right
<<
"
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
"
<<
" ( "
<<
setw(30)
<<
std::left
<<
ORepHelpers::getShortName( uniset_conf()->oind->getMapName(
<xsl:value-of
select=
"@name"
/>
))
<<
" )"
<<
std::right
<<
" = "
<<
setw(6)
<<
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"@name"
/>
;
v_out.push_back(s1.str());
</xsl:if>
</xsl:for-each>
s
<<
endl;
int n = 0;
for( const auto
&
e: v )
for( const auto
&
e: v_in )
{
s
<<
e;
if( (n++)%2 )
s
<<
std::endl;
}
s
<<
endl;
n = 0;
for( const auto
&
e: v_out )
{
s
<<
e;
if( (n++)%2 )
...
...
@@ -1354,6 +1380,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
vector
<
std::string
>
v;
<xsl:for-each
select=
"//sensors/item/consumers/consumer"
>
<xsl:sort
select=
"../../@name"
order=
"ascending"
data-type=
"text"
/>
<xsl:if
test=
"normalize-space(../../@msg)!='1'"
>
<xsl:if
test=
"normalize-space(@name)=$OID"
>
s1.str("");
...
...
@@ -1363,6 +1390,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
</xsl:if>
</xsl:for-each>
std::sort(std::begin(v),std::end(v));
int n=0;
for( const auto
&
e: v )
{
...
...
@@ -1401,7 +1429,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::Object
if( id ==
<xsl:value-of
select=
"../../@name"
/>
)
{
s
<<
"
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
";
if( showLinkName ) s
<<
"
(
<xsl:value-of
select=
"../../@name"
/>
)";
if( showLinkName ) s
<<
"
(
<xsl:value-of
select=
"../../@name"
/>
)";
s
<<
"="
<<
<xsl:call-template
name=
"setprefix"
/><xsl:value-of
select=
"../../@name"
/>
;
return std::move(s.str());
}
...
...
conf/libuniset2.spec
View file @
b8688490
...
...
@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.2
Release: alt8
Release: alt8
.1
Summary: UniSet - library for building distributed industrial control systems
...
...
@@ -456,6 +456,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Wed Oct 14 2015 Pavel Vainerman <pv@altlinux.ru> 2.2-alt8.1
- (VMonit): sort output
* Thu Oct 08 2015 Pavel Vainerman <pv@altlinux.ru> 2.2-alt8
- (uniset-codegen): minor fixes in resetMsg() mechanism
...
...
extensions/include/UObject_SK.h
View file @
b8688490
...
...
@@ -3,12 +3,12 @@
/*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-
06-08
+03:00
// generate timestamp: 2015-
10-14
+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
...
...
@@ -31,11 +31,11 @@ class UObject_SK:
public
LT_Object
{
public
:
UObject_SK
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
node
=
UniSetTypes
::
uniset_conf
()
->
getNode
(
"UObject"
),
const
std
::
string
&
argprefix
=
""
);
UObject_SK
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
node
=
UniSetTypes
::
uniset_conf
()
->
getNode
(
"UObject"
),
const
std
::
string
&
argprefix
=
""
);
UObject_SK
();
virtual
~
UObject_SK
();
long
getValue
(
UniSetTypes
::
ObjectId
sid
);
void
setValue
(
UniSetTypes
::
ObjectId
sid
,
long
value
);
void
askSensor
(
UniSetTypes
::
ObjectId
sid
,
UniversalIO
::
UIOCommand
,
UniSetTypes
::
ObjectId
node
=
UniSetTypes
::
uniset_conf
()
->
getLocalNode
()
);
...
...
@@ -45,127 +45,116 @@ class UObject_SK:
virtual
bool
setMsg
(
UniSetTypes
::
ObjectId
code
,
bool
state
=
true
);
inline
std
::
shared_ptr
<
DebugStream
>
log
()
{
return
mylog
;
}
inline
std
::
shared_ptr
<
LogAgregator
>
logAgregator
()
{
return
loga
;
}
inline
std
::
shared_ptr
<
DebugStream
>
log
(){
return
mylog
;
}
inline
std
::
shared_ptr
<
LogAgregator
>
logAgregator
(){
return
loga
;
}
void
init_dlog
(
std
::
shared_ptr
<
DebugStream
>
d
);
// "синтаксический сахар"..для логов
#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
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
/*! вывод в строку значение всех входов и выходов в формате
ObjectName:
in_xxx = val
in_xxx2 = val
out_zzz = val
...
*/
std
::
string
dumpIO
();
/*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод состояния внутренних переменных */
inline
std
::
string
dumpVars
()
{
return
std
::
move
(
vmon
.
pretty_str
());
}
// ------------------------------------------------------------
// "синтаксический сахар"..для логов
#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
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
/*! вывод в строку значение всех входов и выходов в формате
ObjectName:
in_xxx = val
in_xxx2 = val
out_zzz = val
...
*/
std
::
string
dumpIO
();
/*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод состояния внутренних переменных */
inline
std
::
string
dumpVars
(){
return
std
::
move
(
vmon
.
pretty_str
());
}
// ------------------------------------------------------------
std
::
string
help
();
// Используемые идентификаторы
// Используемые идентификаторы сообщений
// Текущее значение
// --- public variables ---
// --- end of public variables ---
protected
:
// --- protected variables ---
// ---- end of protected variables ----
virtual
void
callback
()
override
;
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
)
override
;
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
)
{};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{}
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
override
{}
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
){};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
){}
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
UniSetTypes
::
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() */
virtual
void
testMode
(
bool
state
);
void
updatePreviousValues
();
void
checkSensors
();
...
...
@@ -183,7 +172,7 @@ class UObject_SK:
int
resetMsgTime
;
// Выполнение очередного шага программы
virtual
void
step
()
{}
virtual
void
step
(){}
int
sleep_msec
;
/*!< пауза между итерациями */
bool
active
;
...
...
@@ -195,28 +184,22 @@ class UObject_SK:
PassiveTimer
ptHeartBeat
;
/*! < период "сердцебиения" */
UniSetTypes
::
ObjectId
idHeartBeat
;
/*! < идентификатор датчика (AI) "сердцебиения" */
int
maxHeartBeat
;
/*! < сохраняемое значение */
xmlNode
*
confnode
;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int
getIntProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
int
getIntProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
int
smReadyTimeout
;
/*!< время ожидания готовности SM */
std
::
atomic_bool
activated
;
int
activateTimeout
;
/*!< время ожидания готовности UniSetObject к работе */
PassiveTimer
ptStartUpTimeout
;
/*!< время на блокировку обработки WatchDog, если недавно был StartUp */
int
askPause
;
/*!< пауза между неудачными попытками заказать датчики */
IOController_i
::
SensorInfo
si
;
bool
forceOut
;
/*!< флаг принудительного обноления "выходов" */
std
::
shared_ptr
<
LogAgregator
>
loga
;
std
::
shared_ptr
<
DebugStream
>
mylog
;
std
::
shared_ptr
<
LogServer
>
logserv
;
...
...
@@ -225,20 +208,20 @@ class UObject_SK:
// snap
bool
no_snap
=
{
false
};
VMonitor
vmon
;
private
:
// --- private variables ---
// --- end of private variables ---
// предыдущее значение (для работы UpdateValue())
// Используемые идентификаторы сообщений
bool
end_private
;
// вспомогательное поле (для внутреннего использования при генерировании кода)
};
...
...
extensions/lib/UObject_SK.cc
View file @
b8688490
...
...
@@ -6,12 +6,12 @@
/*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-
06-08
+03:00
// generate timestamp: 2015-
10-14
+03:00
// -----------------------------------------------------------------------------
#include <memory>
#include <iomanip>
...
...
@@ -32,26 +32,26 @@ using namespace UniSetTypes;
// -----------------------------------------------------------------------------
UObject_SK
::
UObject_SK
()
:
// Инициализация идентификаторов (имена берутся из конф. файла)
// Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables
// variables
active
(
false
),
active
(
false
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
confnode
(
0
),
smReadyTimeout
(
0
),
activated
(
false
),
askPause
(
2000
),
forceOut
(
false
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
confnode
(
0
),
smReadyTimeout
(
0
),
activated
(
false
),
askPause
(
2000
),
forceOut
(
false
),
end_private
(
false
)
end_private
(
false
)
{
ucrit
<<
"UObject: init failed!!!!!!!!!!!!!!!"
<<
endl
;
throw
Exception
(
string
(
myname
+
": init failed!!!"
)
);
throw
Exception
(
string
(
myname
+
": init failed!!!"
)
);
}
// -----------------------------------------------------------------------------
// ( val, confval, default val )
...
...
@@ -59,42 +59,41 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
{
if
(
!
s1
.
empty
()
)
return
s1
;
if
(
!
s2
.
empty
()
)
return
s2
;
return
s3
;
}
// -----------------------------------------------------------------------------
UObject_SK
::
UObject_SK
(
ObjectId
id
,
xmlNode
*
cnode
,
const
std
::
string
&
_argprefix
)
:
UniSetObject
(
id
),
argprefix
(
(
_argprefix
.
empty
()
?
myname
+
"-"
:
_argprefix
)
),
// Инициализация идентификаторов (имена берутся из конф. файла)
UniSetObject
(
id
),
argprefix
(
(
_argprefix
.
empty
()
?
myname
+
"-"
:
_argprefix
)
),
// Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables
// variables
sleep_msec
(
150
),
active
(
true
),
sleep_msec
(
150
),
active
(
true
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
confnode
(
cnode
),
smReadyTimeout
(
0
),
activated
(
false
),
askPause
(
uniset_conf
()
->
getPIntProp
(
cnode
,
"askPause"
,
2000
)),
forceOut
(
false
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
confnode
(
cnode
),
smReadyTimeout
(
0
),
activated
(
false
),
askPause
(
uniset_conf
()
->
getPIntProp
(
cnode
,
"askPause"
,
2000
)),
forceOut
(
false
),
end_private
(
false
)
end_private
(
false
)
{
auto
conf
=
uniset_conf
();
if
(
UniSetTypes
::
findArgParam
(
"--print-id-list"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
if
(
UniSetTypes
::
findArgParam
(
"--print-id-list"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
{
// abort();
// abort();
}
...
...
@@ -105,15 +104,15 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
throw
SystemError
(
err
.
str
()
);
}
mylog
=
make_shared
<
DebugStream
>
();
mylog
=
make_shared
<
DebugStream
>
();
mylog
->
setLogName
(
myname
);
{
ostringstream
s
;
s
<<
argprefix
<<
"log"
;
conf
->
initLogStream
(
mylog
,
s
.
str
());
conf
->
initLogStream
(
mylog
,
s
.
str
());
}
loga
=
make_shared
<
LogAgregator
>
(
myname
+
"-loga"
);
loga
=
make_shared
<
LogAgregator
>
(
myname
+
"-loga"
);
loga
->
add
(
mylog
);
loga
->
add
(
ulog
());
...
...
@@ -130,15 +129,13 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
logserv_host
=
conf
->
getArg2Param
(
"--"
+
argprefix
+
"logserver-host"
,
it
.
getProp
(
"logserverHost"
),
"localhost"
);
logserv_port
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"logserver-port"
,
it
.
getProp
(
"logserverPort"
),
getId
());
}
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
if
(
!
heart
.
empty
()
)
{
idHeartBeat
=
conf
->
getSensorID
(
heart
);
if
(
idHeartBeat
==
DefaultObjectId
)
{
ostringstream
err
;
...
...
@@ -146,38 +143,35 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
throw
SystemError
(
err
.
str
());
}
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
());
if
(
heartbeatTime
>
0
)
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
());
if
(
heartbeatTime
>
0
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
ptHeartBeat
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
}
// Инициализация значений
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
string
s_resetTime
(
""
);
if
(
s_resetTime
.
empty
()
)
s_resetTime
=
"500"
;
resetMsgTime
=
uni_atoi
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"resetMsgTime"
),
conf
->
getProp
(
cnode
,
"resetMsgTime"
),
s_resetTime
));
resetMsgTime
=
uni_atoi
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"resetMsgTime"
),
conf
->
getProp
(
cnode
,
"resetMsgTime"
),
s_resetTime
));
ptResetMsg
.
setTiming
(
resetMsgTime
);
smReadyTimeout
=
conf
->
getArgInt
(
"--"
+
argprefix
+
"sm-ready-timeout"
,
""
);
smReadyTimeout
=
conf
->
getArgInt
(
"--"
+
argprefix
+
"sm-ready-timeout"
,
""
);
if
(
smReadyTimeout
==
0
)
smReadyTimeout
=
60000
;
else
if
(
smReadyTimeout
<
0
)
smReadyTimeout
=
UniSetTimer
::
WaitUpTime
;
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
activateTimeout
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"activate-timeout"
,
20000
);
...
...
@@ -185,7 +179,7 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
ptStartUpTimeout
.
setTiming
(
msec
);
// ===================== <variables> =====================
// ===================== end of <variables> =====================
vmonit
(
sleep_msec
);
...
...
@@ -207,42 +201,46 @@ UObject_SK::~UObject_SK()
void
UObject_SK
::
updateValues
()
{
// Опрашиваем все входы...
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
updatePreviousValues
()
{
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
checkSensors
()
{
}
// -----------------------------------------------------------------------------
bool
UObject_SK
::
setMsg
(
UniSetTypes
::
ObjectId
_code
,
bool
_state
)
{
if
(
_code
==
UniSetTypes
::
DefaultObjectId
)
{
my
crit
<<
myname
<<
"(setMsg): попытка послать сообщение с DefaultObjectId"
<<
endl
;
return
false
;
my
log8
<<
myname
<<
"(setMsg): попытка послать сообщение с DefaultObjectId"
<<
endl
;
return
false
;
}
mylog8
<<
myname
<<
"(setMsg): "
<<
(
_state
?
"SEND "
:
"RESET "
)
<<
endl
;
mylog8
<<
myname
<<
"(setMsg): "
<<
(
_state
?
"SEND "
:
"RESET "
)
<<
endl
;
// взводим автоматический сброс
if
(
_state
)
ptResetMsg
.
reset
();
// взводим автоматический сброс
if
(
_state
)
{
ptResetMsg
.
reset
();
trResetMsg
.
hi
(
false
);
}
mylog8
<<
myname
<<
"(setMsg): not found MessgeOID?!!"
<<
endl
;
mylog8
<<
myname
<<
"(setMsg): not found MessgeOID?!!"
<<
endl
;
return
false
;
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
resetMsg
()
{
// reset messages
mylog8
<<
myname
<<
"(resetMsg): reset messages.."
<<
endl
;
// reset messages
}
// -----------------------------------------------------------------------------
...
...
@@ -252,7 +250,7 @@ void UObject_SK::testMode( bool _state )
return
;
// отключаем все выходы
}
// -----------------------------------------------------------------------------
std
::
string
UObject_SK
::
dumpIO
()
...
...
@@ -260,21 +258,46 @@ std::string UObject_SK::dumpIO()
ostringstream
s
;
s
<<
myname
<<
": "
<<
endl
;
std
::
list
<
std
::
string
>
v_in
;
ostringstream
s1
;
std
::
list
<
std
::
string
>
v_out
;
return
s
.
str
();
s
<<
endl
;
int
n
=
0
;
for
(
const
auto
&
e
:
v_in
)
{
s
<<
e
;
if
(
(
n
++
)
%
2
)
s
<<
std
::
endl
;
}
s
<<
endl
;
n
=
0
;
for
(
const
auto
&
e
:
v_out
)
{
s
<<
e
;
if
(
(
n
++
)
%
2
)
s
<<
std
::
endl
;
}
return
std
::
move
(
s
.
str
());
}
// ----------------------------------------------------------------------------
std
::
string
UObject_SK
::
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
)
{
ostringstream
s
;
return
""
;
}
// ----------------------------------------------------------------------------
std
::
string
UObject_SK
::
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
)
{
ostringstream
s
;
return
""
;
}
// ----------------------------------------------------------------------------
...
...
@@ -295,19 +318,19 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg )
{
case
Message
:
:
SensorInfo
:
preSensorInfo
(
reinterpret_cast
<
SensorMessage
*>
(
_msg
)
);
break
;
break
;
case
Message
:
:
Timer
:
preTimerInfo
(
reinterpret_cast
<
TimerMessage
*>
(
_msg
)
);
break
;
break
;
case
Message
:
:
SysCommand
:
preSysCommand
(
reinterpret_cast
<
SystemMessage
*>
(
_msg
)
);
break
;
break
;
default
:
break
;
}
}
}
catch
(
const
Exception
&
ex
)
{
...
...
@@ -321,13 +344,11 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
{
case
SystemMessage
:
:
WatchDog
:
uinfo
<<
myname
<<
"(preSysCommand): WatchDog"
<<
endl
;
if
(
!
active
||
!
ptStartUpTimeout
.
checkTime
()
)
{
uwarn
<<
myname
<<
"(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl
;
break
;
}
case
SystemMessage
:
:
StartUp
:
{
if
(
!
logserv_host
.
empty
()
&&
logserv_port
!=
0
&&
!
logserv
->
isRunning
()
)
...
...
@@ -347,22 +368,21 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
active
=
true
;
break
;
}
case
SystemMessage
:
:
FoldUp
:
case
SystemMessage
:
:
Finish
:
preAskSensors
(
UniversalIO
::
UIODontNotify
);
askSensors
(
UniversalIO
::
UIODontNotify
);
break
;
case
SystemMessage
:
:
LogRotate
:
{
// переоткрываем логи
mylogany
<<
myname
<<
"(preSysCommand): logRotate"
<<
endl
;
string
fname
(
log
()
->
getLogFile
()
);
if
(
!
fname
.
empty
()
)
{
mylog
->
logFile
(
fname
.
c_str
(),
true
);
mylog
->
logFile
(
fname
.
c_str
(),
true
);
mylogany
<<
myname
<<
"(preSysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl
;
}
}
...
...
@@ -371,24 +391,26 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
default
:
break
;
}
sysCommand
(
_sm
);
}
// -----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
UObject_SK
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
UniSetObject
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
inf
<<
dumpIO
()
<<
endl
;
inf
<<
endl
;
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
endl
;
inf
<<
getMonitInfo
()
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// -----------------------------------------------------------------------------
...
...
@@ -401,7 +423,7 @@ void UObject_SK::sigterm( int signo )
// -----------------------------------------------------------------------------
bool
UObject_SK
::
activateObject
()
{
// блокирование обработки Startup
// блокирование обработки Startup
// пока не пройдёт инициализация датчиков
// см. preSysCommand()
{
...
...
@@ -427,68 +449,74 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
if
(
_testID
==
DefaultObjectId
)
return
;
uinfo
<<
myname
<<
"(waitSM): waiting SM ready "
<<
wait_msec
<<
" msec"
<<
" testID="
<<
_testID
<<
endl
;
if
(
!
ui
->
waitReady
(
_testID
,
wait_msec
)
)
<<
wait_msec
<<
" msec"
<<
" testID="
<<
_testID
<<
endl
;
if
(
!
ui
->
waitReady
(
_testID
,
wait_msec
)
)
{
ostringstream
err
;
err
<<
myname
<<
"(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
err
<<
myname
<<
"(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
<<
wait_msec
<<
" мсек"
;
ucrit
<<
err
.
str
()
<<
endl
;
// terminate();
// abort();
ucrit
<<
err
.
str
()
<<
endl
;
// terminate();
// abort();
raise
(
SIGTERM
);
terminate
();
// throw SystemError(err.str());
// throw SystemError(err.str());
}
}
// ----------------------------------------------------------------------------
std
::
string
UObject_SK
::
help
()
{
ostringstream
s
;
return
std
::
move
(
s
.
str
());
}
// ----------------------------------------------------------------------------
// --------------------------------------------------------------------------
void
UObject_SK
::
callback
()
{
if
(
!
active
)
return
;
try
{
// проверка таймеров
checkTimers
(
this
);
if
(
resetMsgTime
>
0
&&
trResetMsg
.
hi
(
ptResetMsg
.
checkTime
())
)
if
(
resetMsgTime
>
0
&&
trResetMsg
.
hi
(
ptResetMsg
.
checkTime
())
)
{
// cout << myname << ": ********* reset messages *********" << endl;
// cout << myname << ": ********* reset messages *********" << endl;
resetMsg
();
}
// обработка сообщений (таймеров и т.п.)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
{
if
(
!
receiveMessage
(
msg
)
)
break
;
processingMessage
(
&
msg
);
updateOutputs
(
forceOut
);
// updatePreviousValues();
// updatePreviousValues();
}
// Выполнение шага программы
step
();
// "сердцебиение"
if
(
idHeartBeat
!=
DefaultObjectId
&&
ptHeartBeat
.
checkTime
()
)
if
(
idHeartBeat
!=
DefaultObjectId
&&
ptHeartBeat
.
checkTime
()
)
{
try
{
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
);
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
);
ptHeartBeat
.
reset
();
}
catch
(
const
Exception
&
ex
)
...
...
@@ -503,46 +531,49 @@ void UObject_SK::callback()
}
catch
(
const
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
ucrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
ucrit
<<
myname
<<
"(execute): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
ucrit
<<
myname
<<
"(execute): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
if
(
!
active
)
return
;
msleep
(
sleep_msec
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
setValue
(
UniSetTypes
::
ObjectId
_sid
,
long
_val
)
{
if
(
_sid
==
UniSetTypes
::
DefaultObjectId
)
return
;
ui
->
setValue
(
_sid
,
_val
);
ui
->
setValue
(
_sid
,
_val
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
updateOutputs
(
bool
_force
)
{
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
preSensorInfo
(
const
UniSetTypes
::
SensorMessage
*
_sm
)
{
sensorInfo
(
_sm
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
askSensor
(
UniSetTypes
::
ObjectId
_sid
,
UniversalIO
::
UIOCommand
_cmd
,
UniSetTypes
::
ObjectId
_node
)
{
ui
->
askRemoteSensor
(
_sid
,
_cmd
,
_node
,
getId
());
ui
->
askRemoteSensor
(
_sid
,
_cmd
,
_node
,
getId
());
}
// -----------------------------------------------------------------------------
long
UObject_SK
::
getValue
(
UniSetTypes
::
ObjectId
_sid
)
...
...
@@ -555,7 +586,7 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
}
catch
(
const
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(getValue): "
<<
ex
<<
endl
;
ucrit
<<
myname
<<
"(getValue): "
<<
ex
<<
endl
;
throw
;
}
}
...
...
@@ -564,35 +595,33 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
void
UObject_SK
::
preAskSensors
(
UniversalIO
::
UIOCommand
_cmd
)
{
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
{
cout
<<
myname
<<
"(preAskSensors): wait activate..."
<<
endl
;
msleep
(
300
);
if
(
activated
)
break
;
}
if
(
!
activated
)
ucrit
<<
myname
<<
"(preAskSensors): ************* don`t activated?! ************"
<<
endl
;
<<
"(preAskSensors): ************* don`t activated?! ************"
<<
endl
;
for
(
;;
)
{
try
{
return
;
}
catch
(
const
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(preAskSensors): "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
ucrit
<<
myname
<<
"(preAskSensors): "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
msleep
(
askPause
);
}
...
...
include/VMonitor.h
View file @
b8688490
...
...
@@ -24,6 +24,7 @@
#define VMonitor_H_
// --------------------------------------------------------------------------
#include <string>
#include <list>
#include <ostream>
#include <unordered_map>
#include "UniSetTypes.h"
...
...
@@ -120,8 +121,14 @@ class VMonitor
static
const
int
NameWidth
=
{
30
};
static
const
int
ColCount
=
{
2
};
/*! вывести все элементы в "простом формате" (строки "varname = value") */
std
::
string
str
();
std
::
string
pretty_str
();
/*! вывести все элементы "с форматированием" (отсортированные по алфавиту)
* \param namewidth - ширина резервируемая под "имя"
* \param colnum - количество столбцов вывода
*/
std
::
string
pretty_str
(
int
namewidth
=
NameWidth
,
int
colnum
=
ColCount
);
// функции добавления..
VMON_DEF_FUNC2
(
int
);
...
...
@@ -138,6 +145,8 @@ class VMonitor
static
const
std
::
string
pretty_str
(
const
std
::
string
&
name
,
const
std
::
string
*
v
,
int
width
=
NameWidth
);
static
const
std
::
string
pretty_str
(
const
std
::
string
&
name
,
const
std
::
string
&
v
,
int
width
=
NameWidth
);
std
::
list
<
std
::
pair
<
std
::
string
,
std
::
string
>>
getList
();
protected
:
private
:
...
...
@@ -149,7 +158,6 @@ class VMonitor
VMON_DEF_MAP
(
bool
);
VMON_DEF_MAP
(
float
);
VMON_DEF_MAP
(
double
);
// VMON_DEF_MAP3(UniSetTypes::ObjectId,ObjectId); // <-- long
VMON_DEF_MAP3
(
std
::
string
,
string
);
};
// --------------------------------------------------------------------------
...
...
src/Various/VMonitor.cc
View file @
b8688490
...
...
@@ -3,6 +3,7 @@
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include "VMonitor.h"
// --------------------------------------------------------------------------
#define VMON_IMPL_ADD(T) void VMonitor::add( const std::string& name, const T& v ) \
...
...
@@ -13,7 +14,7 @@
const std::string VMonitor::pretty_str( const std::string& name, const T* v, int nwidth ) \
{ \
std::ostringstream s; \
s << std::right << std::setw(nwidth) << name << std::left << " = " << std::right << std::setw(
6)
<< *(v); \
s << std::right << std::setw(nwidth) << name << std::left << " = " << std::right << std::setw(
10)
<< *(v); \
return std::move(s.str()); \
} \
const std::string VMonitor::pretty_str( const std::string& name, const T& v, int nwidth ) \
...
...
@@ -33,13 +34,13 @@
const std::string VMonitor::pretty_str( const std::string& name, const T* v, int nwidth ) \
{ \
std::ostringstream s; \
s << std::right << std::setw(nwidth) << name << std::left << " = " << std::right << std::setw(
6)
<< *(v); \
s << std::right << std::setw(nwidth) << name << std::left << " = " << std::right << std::setw(
10)
<< *(v); \
return std::move(s.str()); \
} \
const std::string VMonitor::pretty_str( const std::string& name, const unsigned T* v, int nwidth ) \
{ \
std::ostringstream s; \
s << std::right << std::setw(nwidth) << name << std::left << " = " << std::right << std::setw(
6)
<< *(v); \
s << std::right << std::setw(nwidth) << name << std::left << " = " << std::right << std::setw(
10)
<< *(v); \
return std::move(s.str()); \
} \
const std::string VMonitor::pretty_str( const std::string& name, const T& v, int nwidth ) \
...
...
@@ -58,7 +59,7 @@
const std::string VMonitor::pretty_str( const std::string& name, const T* v, int nwidth ) \
{ \
std::ostringstream s; \
s << std::right << std::setw(nwidth) << name << std::left << " = " << std::right << std::setw(
6)
<< *(v); \
s << std::right << std::setw(nwidth) << name << std::left << " = " << std::right << std::setw(
10)
<< *(v); \
return std::move(s.str()); \
} \
const std::string VMonitor::pretty_str( const std::string& name, const T& v, int nwidth ) \
...
...
@@ -66,102 +67,36 @@
return pretty_str(name,&v,nwidth); \
}
// --------------------------------------------------------------------------
#define VMON_
IMPL_PRN(M,
T) \
#define VMON_
MAKE_PAIR(vlist,
T) \
{\
for( const auto& e: M.m_##T ) \
os << e.second << "=" << *(e.first) << std::endl;\
}
// --------------------------------------------------------------------------
#define VMON_IMPL_PRN2(M,T) \
{\
for( const auto& e: M.m_##T ) \
os << e.second << "=" << *(e.first) << std::endl;\
\
for( const auto& e: M.m_unsigned_##T ) \
os << e.second << "=" << *(e.first) << std::endl;\
}
// --------------------------------------------------------------------------
#define VMON_IMPL_PRN_CHAR(M) \
{\
for( const auto& e: M.m_char ) \
os << e.second << "=" << (int)(*(e.first)) << std::endl;\
\
for( const auto& e: M.m_unsigned_char) \
os << e.second << "=" << (int)(*(e.first)) << std::endl;\
for( const auto& e: m_##T ) \
vlist.push_back( std::make_pair(e.second, std::to_string(*(e.first))) );\
}
// --------------------------------------------------------------------------
#define VMON_
IMPL_PRET(
T) \
#define VMON_
MAKE_PAIR_S(vlist,
T) \
{\
std::vector<std::string> v(m_char.size()+m_unsigned_char.size());\
std::ostringstream s;\
for( const auto& e: m_##T ) \
{\
s.str("");\
s << pretty_str(e.second,e.first);\
v.push_back(s.str()); \
}\
\
int n = 0;\
for( const auto& e: v ) \
{\
os << e; \
if( (n++)%ColCount ) \
os << std::endl; \
} \
vlist.push_back( std::make_pair(e.second,*e.first) );\
}
// --------------------------------------------------------------------------
#define VMON_
IMPL_PRET2(
T) \
#define VMON_
MAKE_PAIR2(vlist,
T) \
{\
std::vector<std::string> v(m_char.size()+m_unsigned_char.size());\
std::ostringstream s;\
for( const auto& e: m_##T ) \
{\
s.str("");\
s << pretty_str(e.second,e.first);\
v.push_back(s.str());\
}\
vlist.push_back( std::make_pair(e.second, std::to_string(*(e.first))) );\
\
for( const auto& e: m_unsigned_##T ) \
{\
s.str("");\
s << pretty_str(e.second,e.first);\
v.push_back(s.str());\
}\
\
int n = 0;\
for( const auto& e: v ) \
{\
os << e; \
if( (n++)%ColCount ) \
os << std::endl; \
} \
vlist.push_back( std::make_pair(e.second, std::to_string(*(e.first))) );\
}
// --------------------------------------------------------------------------
#define VMON_
IMPL_PRET_CHAR
\
#define VMON_
MAKE_PAIR_CHAR(vlist)
\
{\
std::vector<std::string> v(m_char.size()+m_unsigned_char.size());\
std::ostringstream s;\
for( const auto& e: m_char ) \
{\
s.str("");\
s << std::right << std::setw(NameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first));\
v.push_back(s.str());\
}\
vlist.push_back(std::make_pair(e.second,std::to_string((int)(*(e.first)))) );\
\
for( const auto& e: m_unsigned_char ) \
{\
s.str("");\
s << std::right << std::setw(NameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first));\
v.push_back(s.str()); \
}\
\
int n = 0;\
for( const auto& e: v ) \
{\
os << e; \
if( (n++)%ColCount ) \
os << std::endl; \
} \
vlist.push_back(std::make_pair(e.second,std::to_string((int)(*(e.first)))) );\
}
// --------------------------------------------------------------------------
VMON_IMPL_ADD2
(
int
)
...
...
@@ -174,21 +109,17 @@ VMON_IMPL_ADD(double)
VMON_IMPL_ADD3
(
std
::
string
,
string
)
//VMON_IMPL_ADD3(UniSetTypes::ObjectId,ObjectId)
// --------------------------------------------------------------------------
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
VMonitor
&
m
)
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
VMonitor
&
m
)
{
VMON_IMPL_PRN2
(
m
,
int
);
VMON_IMPL_PRN2
(
m
,
long
);
VMON_IMPL_PRN2
(
m
,
short
);
VMON_IMPL_PRN_CHAR
(
m
);
VMON_IMPL_PRN
(
m
,
bool
);
VMON_IMPL_PRN
(
m
,
float
);
VMON_IMPL_PRN
(
m
,
double
);
VMON_IMPL_PRN
(
m
,
string
);
// VMON_IMPL_PRN(m,ObjectId);
auto
vlist
=
m
.
getList
();
// сортируем по алфавиту
vlist
.
sort
(
[](
const
std
::
pair
<
std
::
string
,
std
::
string
>
&
a
,
const
std
::
pair
<
std
::
string
,
std
::
string
>
&
b
)
{
return
a
.
first
<
b
.
first
;
});
for
(
const
auto
&
e
:
vlist
)
os
<<
e
.
first
<<
" = "
<<
e
.
second
;
return
os
;
}
// --------------------------------------------------------------------------
std
::
string
VMonitor
::
str
()
{
...
...
@@ -197,18 +128,35 @@ std::string VMonitor::str()
return
std
::
move
(
s
.
str
());
}
// --------------------------------------------------------------------------
std
::
string
VMonitor
::
pretty_str
()
std
::
list
<
std
::
pair
<
std
::
string
,
std
::
string
>
>
VMonitor
::
getList
()
{
std
::
list
<
std
::
pair
<
std
::
string
,
std
::
string
>>
vlist
;
VMON_MAKE_PAIR2
(
vlist
,
int
);
VMON_MAKE_PAIR2
(
vlist
,
long
);
VMON_MAKE_PAIR2
(
vlist
,
short
);
VMON_MAKE_PAIR_CHAR
(
vlist
);
VMON_MAKE_PAIR
(
vlist
,
bool
);
VMON_MAKE_PAIR
(
vlist
,
float
);
VMON_MAKE_PAIR
(
vlist
,
double
);
VMON_MAKE_PAIR_S
(
vlist
,
string
);
return
std
::
move
(
vlist
);
}
// --------------------------------------------------------------------------
std
::
string
VMonitor
::
pretty_str
(
int
namewidth
,
int
colnum
)
{
auto
vlist
=
getList
();
std
::
ostringstream
os
;
VMON_IMPL_PRET2
(
int
);
VMON_IMPL_PRET2
(
long
);
VMON_IMPL_PRET2
(
short
);
VMON_IMPL_PRET_CHAR
;
VMON_IMPL_PRET
(
bool
);
VMON_IMPL_PRET
(
float
);
VMON_IMPL_PRET
(
double
);
VMON_IMPL_PRET
(
string
);
// VMON_IMPL_PRET(ObjectId);
// сортируем по алфавиту
vlist
.
sort
(
[](
const
std
::
pair
<
std
::
string
,
std
::
string
>
&
a
,
const
std
::
pair
<
std
::
string
,
std
::
string
>
&
b
)
{
return
a
.
first
<
b
.
first
;
});
int
n
=
0
;
for
(
const
auto
&
e
:
vlist
)
{
os
<<
std
::
right
<<
std
::
setw
(
namewidth
)
<<
e
.
first
<<
std
::
left
<<
" = "
<<
std
::
right
<<
std
::
setw
(
10
)
<<
e
.
second
;
if
(
(
n
++
)
%
colnum
)
os
<<
std
::
endl
;
}
return
std
::
move
(
os
.
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