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
0c4a3da1
Commit
0c4a3da1
authored
Jun 07, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(codegen): добавил для пользовательских данных функцию getMonitInfo()
parent
5b906cdc
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
160 additions
and
145 deletions
+160
-145
TODO
TODO
+0
-5
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+3
-0
libuniset2.spec
conf/libuniset2.spec
+4
-1
uniset-codegen.dox
docs/DocPages/uniset-codegen.dox
+3
-0
UObject_SK.h
extensions/include/UObject_SK.h
+73
-67
UObject_SK.cc
extensions/lib/UObject_SK.cc
+76
-71
VMonitor.h
include/VMonitor.h
+1
-1
No files found.
TODO
View file @
0c4a3da1
...
...
@@ -46,12 +46,7 @@ SQL:
====
- добавить работу с History (при передаче указателя на SM в конструкторе).
Debug:
- в codegen встроить получение состояния всех переменных (dumpIO() + UniSetObject::getInfo()),
возможно написать на python утилиту "монитор".
- Сделать макрос с простым названием например NOTE(variable)(snap?)... пишуший в map var=value, а потом показывающий в getInfo() (и может dumpIO())
- дописать в codegen документацию по запуску и управлению логами через LogServer
...
...
Utilities/codegen/ctl-cpp-common.xsl
View file @
0c4a3da1
...
...
@@ -260,6 +260,8 @@
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 void testMode( bool state );
void updatePreviousValues();
void checkSensors();
...
...
@@ -432,6 +434,7 @@ UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo()
inf
<<
i->info
<<
endl;
inf
<<
dumpIO()
<<
endl;
inf
<<
vmon.pretty_str()
<<
endl;
inf
<<
getMonitInfo()
<<
endl;
i->info = inf.str().c_str();
...
...
conf/libuniset2.spec
View file @
0c4a3da1
...
...
@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.1
Release: alt7.
1
Release: alt7.
2
Summary: UniSet - library for building distributed industrial control systems
...
...
@@ -456,6 +456,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Sun Jun 07 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt7.2
- (codegen): add user info function (getMonitInfo())
* Sat Jun 06 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt7.1
- (vmonit): new utilities (variables monitor)
...
...
docs/DocPages/uniset-codegen.dox
View file @
0c4a3da1
...
...
@@ -486,4 +486,7 @@ MyClass_SK.cc: myclass.src.xml
После этого они появяться в выводе утилиты uniset2-vmonit
\warning На данный момент поддерживаются только простые типы переменных (bool,short,int,long,double,float см. VMonitor)
Для пользовательской информации введена виртуальная функция std::string getMonitInfo(), переопределив которую,
можно сформировать свою информацию, которую можно будет удалённо читать.
*/
extensions/include/UObject_SK.h
View file @
0c4a3da1
...
...
@@ -8,13 +8,15 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-0
5-31
+03:00
// generate timestamp: 2015-0
6-07
+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
// -----------------------------------------------------------------------------
#include <memory>
#include <string>
#include <unordered_map>
#include <sstream>
#include "UniSetObject.h"
#include "LT_Object.h"
#include "UniXML.h"
...
...
@@ -22,13 +24,14 @@
#include "DebugStream.h"
#include "LogServer.h"
#include "LogAgregator.h"
#include "VMonitor.h"
// -----------------------------------------------------------------------------
class
UObject_SK
:
public
UniSetObject
,
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
();
...
...
@@ -38,63 +41,62 @@ class UObject_SK:
void
askSensor
(
UniSetTypes
::
ObjectId
sid
,
UniversalIO
::
UIOCommand
,
UniSetTypes
::
ObjectId
node
=
UniSetTypes
::
uniset_conf
()
->
getLocalNode
()
);
void
updateValues
();
virtual
UniSetTypes
::
SimpleInfo
*
getInfo
()
override
;
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 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
...
...
@@ -103,17 +105,20 @@ class UObject_SK:
*/
std
::
string
dumpIO
();
/*!< Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
/*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
std
::
string
str
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*!< Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
std
::
string
strval
(
UniSetTypes
::
ObjectId
id
,
bool
showLinkName
=
true
);
/*! Вывод состояния внутренних переменных */
inline
std
::
string
dumpVars
(){
return
std
::
move
(
vmon
.
pretty_str
());
}
// ------------------------------------------------------------
...
...
@@ -141,12 +146,14 @@ class UObject_SK:
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
void
testMode
(
bool
state
);
void
updatePreviousValues
();
void
checkSensors
();
...
...
@@ -164,7 +171,7 @@ class UObject_SK:
int
resetMsgTime
;
// Выполнение очередного шага программы
virtual
void
step
()
{}
virtual
void
step
(){}
int
sleep_msec
;
/*!< пауза между итерациями */
bool
active
;
...
...
@@ -179,15 +186,9 @@ class UObject_SK:
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
;
...
...
@@ -204,6 +205,11 @@ class UObject_SK:
std
::
string
logserv_host
=
{
""
};
int
logserv_port
=
{
0
};
// snap
bool
no_snap
=
{
false
};
VMonitor
vmon
;
private
:
...
...
extensions/lib/UObject_SK.cc
View file @
0c4a3da1
...
...
@@ -11,9 +11,10 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-0
5-31
+03:00
// generate timestamp: 2015-0
6-07
+03:00
// -----------------------------------------------------------------------------
#include <memory>
#include <iomanip>
#include "Configuration.h"
#include "Exceptions.h"
#include "ORepHelpers.h"
...
...
@@ -31,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 )
...
...
@@ -58,7 +59,6 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
{
if
(
!
s1
.
empty
()
)
return
s1
;
if
(
!
s2
.
empty
()
)
return
s2
;
...
...
@@ -66,34 +66,34 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
}
// -----------------------------------------------------------------------------
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();
}
...
...
@@ -109,10 +109,10 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
{
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,14 +130,12 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
logserv_port
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"logserver-port"
,
it
.
getProp
(
"logserverPort"
),
getId
());
}
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
if
(
!
heart
.
empty
()
)
{
idHeartBeat
=
conf
->
getSensorID
(
heart
);
if
(
idHeartBeat
==
DefaultObjectId
)
{
ostringstream
err
;
...
...
@@ -145,37 +143,34 @@ 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
);
...
...
@@ -232,7 +227,7 @@ bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state )
// -----------------------------------------------------------------------------
void
UObject_SK
::
resetMsg
()
{
// reset messages
// reset messages
}
// -----------------------------------------------------------------------------
...
...
@@ -250,6 +245,7 @@ std::string UObject_SK::dumpIO()
ostringstream
s
;
s
<<
myname
<<
": "
<<
endl
;
return
s
.
str
();
}
// ----------------------------------------------------------------------------
...
...
@@ -310,13 +306,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
()
)
...
...
@@ -348,10 +342,9 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
// переоткрываем логи
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
;
}
}
...
...
@@ -364,6 +357,22 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
sysCommand
(
_sm
);
}
// -----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
UObject_SK
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
UniSetObject
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
dumpIO
()
<<
endl
;
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
getMonitInfo
()
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
sigterm
(
int
signo
)
{
...
...
@@ -404,7 +413,7 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
<<
wait_msec
<<
" msec"
<<
" testID="
<<
_testID
<<
endl
;
if
(
!
ui
->
waitReady
(
_testID
,
wait_msec
)
)
if
(
!
ui
->
waitReady
(
_testID
,
wait_msec
)
)
{
ostringstream
err
;
err
<<
myname
...
...
@@ -412,11 +421,11 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
<<
wait_msec
<<
" мсек"
;
ucrit
<<
err
.
str
()
<<
endl
;
// terminate();
// abort();
// terminate();
// abort();
raise
(
SIGTERM
);
terminate
();
// throw SystemError(err.str());
// throw SystemError(err.str());
}
...
...
@@ -428,39 +437,37 @@ 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
)
...
...
@@ -482,7 +489,7 @@ void UObject_SK::callback()
ucrit
<<
myname
<<
"(execute): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
...
...
@@ -497,7 +504,7 @@ void UObject_SK::setValue( UniSetTypes::ObjectId _sid, long _val )
{
ui
->
setValue
(
_sid
,
_val
);
ui
->
setValue
(
_sid
,
_val
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
updateOutputs
(
bool
_force
)
...
...
@@ -514,7 +521,7 @@ void UObject_SK::preSensorInfo( const UniSetTypes::SensorMessage* _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
)
...
...
@@ -536,12 +543,10 @@ 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
;
}
...
...
@@ -561,7 +566,7 @@ void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
{
ucrit
<<
myname
<<
"(preAskSensors): "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
catch
(
const
std
::
exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
...
...
include/VMonitor.h
View file @
0c4a3da1
...
...
@@ -88,7 +88,7 @@
private:
int myvar1;
bool myvar2;
lo
gn
myvar3;
lo
ng
myvar3;
...
VMonitor vmon;
}
...
...
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