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
2c07f42b
Commit
2c07f42b
authored
May 24, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(codegen): Встроил LogServer в генерируемый класс.
parent
51f45a5c
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
361 additions
and
291 deletions
+361
-291
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+55
-10
ctl-cpp-h-alone.xsl
Utilities/codegen/ctl-cpp-h-alone.xsl
+3
-0
ctl-cpp-h.xsl
Utilities/codegen/ctl-cpp-h.xsl
+2
-0
TestGenAlone.cc
Utilities/codegen/tests/TestGenAlone.cc
+2
-2
TestGenAlone.h
Utilities/codegen/tests/TestGenAlone.h
+4
-4
libuniset2.spec
conf/libuniset2.spec
+3
-1
RRDServer.cc
extensions/RRDServer/RRDServer.cc
+1
-22
RRDServer.h
extensions/RRDServer/RRDServer.h
+0
-8
main.cc
extensions/RRDServer/main.cc
+0
-11
start_fg.sh
extensions/RRDServer/start_fg.sh
+1
-1
SMLogSugar.h
extensions/SharedMemory/SMLogSugar.h
+43
-0
UObject_SK.h
extensions/include/UObject_SK.h
+99
-96
UObject_SK.cc
extensions/lib/UObject_SK.cc
+148
-136
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
2c07f42b
...
...
@@ -244,7 +244,7 @@
<xsl:template
name=
"COMMON-HEAD-PROTECTED"
>
virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm )
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{}
...
...
@@ -260,6 +260,7 @@
void preAskSensors( UniversalIO::UIOCommand cmd );
void preSensorInfo( const UniSetTypes::SensorMessage* sm );
void preTimerInfo( const UniSetTypes::TimerMessage* tm );
void preSysCommand( const UniSetTypes::SystemMessage* sm );
void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
void resetMsg();
...
...
@@ -302,6 +303,12 @@
IOController_i::SensorInfo si;
bool forceOut; /*!
<
флаг принудительного обноления "выходов" */
std::shared_ptr
<
LogAgregator
>
loga;
std::shared_ptr
<
DebugStream
>
smlog;
std::shared_ptr
<
LogServer
>
logserv;
std::string logserv_host = {""};
int logserv_port = {0};
</xsl:template>
<xsl:template
name=
"COMMON-HEAD-PRIVATE"
>
...
...
@@ -330,7 +337,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( UniSetTypes::Voi
break;
case Message::SysCommand:
s
ysCommand( reinterpret_cast
<
SystemMessage*
>
(_msg) );
preS
ysCommand( reinterpret_cast
<
SystemMessage*
>
(_msg) );
break;
default:
...
...
@@ -343,19 +350,25 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( UniSetTypes::Voi
}
}
// -----------------------------------------------------------------------------
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::
s
ysCommand( const SystemMessage* _sm )
void
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::
preS
ysCommand( const SystemMessage* _sm )
{
switch( _sm->command )
{
case SystemMessage::WatchDog:
ulogany
<<
myname
<<
"(
s
ysCommand): WatchDog"
<<
endl;
ulogany
<<
myname
<<
"(
preS
ysCommand): WatchDog"
<<
endl;
if( !active || !ptStartUpTimeout.checkTime() )
{
uwarn
<<
myname
<<
"(
s
ysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl;
uwarn
<<
myname
<<
"(
preS
ysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl;
break;
}
case SystemMessage::StartUp:
{
if( !logserv_host.empty()
&&
logserv_port != 0
&&
!logserv-
>
isRunning() )
{
myinfo
<<
myname
<<
"(preSysCommand): run log server "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl;
logserv-
>
run(logserv_host, logserv_port, true);
}
waitSM(smReadyTimeout);
ptStartUpTimeout.reset();
// т.к. для io-переменных важно соблюдать последовательность!
...
...
@@ -377,12 +390,12 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::sysCommand( const SystemMessage* _s
case SystemMessage::LogRotate:
{
// переоткрываем логи
mylogany
<<
myname
<<
"(
s
ysCommand): logRotate"
<<
endl;
mylogany
<<
myname
<<
"(
preS
ysCommand): logRotate"
<<
endl;
string fname( mylog->getLogFile() );
if( !fname.empty() )
{
mylog->logFile(fname.c_str(),true);
mylogany
<<
myname
<<
"(
s
ysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl;
mylogany
<<
myname
<<
"(
preS
ysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl;
}
}
break;
...
...
@@ -390,6 +403,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::sysCommand( const SystemMessage* _s
default:
break;
}
sysCommand(_sm);
}
// -----------------------------------------------------------------------------
<xsl:if
test=
"normalize-space($TESTMODE)!=''"
>
...
...
@@ -410,7 +425,7 @@ bool <xsl:value-of select="$CLASSNAME"/>_SK::activateObject()
{
// блокирование обработки Startup
// пока не пройдёт инициализация датчиков
// см.
s
ysCommand()
// см.
preS
ysCommand()
{
activated = false;
<xsl:if
test=
"normalize-space($BASECLASS)!=''"
><xsl:value-of
select=
"normalize-space($BASECLASS)"
/>
::activateObject();
</xsl:if>
...
...
@@ -550,6 +565,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
#include
<xsl:call-template
name=
"preinclude"
/>
Configuration.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
Exceptions.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
ORepHelpers.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
LogServer.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
DebugStream.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
LogAgregator.h
<xsl:call-template
name=
"postinclude"
/>
#include "
<xsl:value-of
select=
"$SK_H_FILENAME"
/>
"
// -----------------------------------------------------------------------------
...
...
@@ -690,6 +708,13 @@ end_private(false)
conf->initLogStream(mylog,s.str());
}
loga = make_shared
<
LogAgregator
>
();
loga-
>
add(mylog);
loga-
>
add(ulog());
logserv = make_shared
<
LogServer
>
(loga);
logserv-
>
init( argprefix + "-logserver", confnode );
<xsl:for-each
select=
"//smap/item"
>
<xsl:if
test=
"normalize-space(@no_check_id)!='1'"
>
if(
<xsl:value-of
select=
"normalize-space(@name)"
/>
== UniSetTypes::DefaultObjectId )
...
...
@@ -726,6 +751,13 @@ end_private(false)
UniXML::iterator it(cnode);
// ------- init logserver ---
if( findArgParam("--" + argprefix + "-run-logserver", conf-
>
getArgc(), conf-
>
getArgv()) != -1 )
{
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);
string heart = conf->getArgParam("--" + argprefix + "heartbeat-id",it.getProp("heartbeat_id"));
...
...
@@ -1066,9 +1098,15 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
s
<<
argprefix
<<
"log";
conf->initLogStream(mylog, s.str());
}
si.node = conf->getLocalNode();
loga = make_shared
<
LogAgregator
>
();
loga-
>
add(mylog);
loga-
>
add(ulog());
logserv = make_shared
<
LogServer
>
(loga);
logserv-
>
init( argprefix + "-logserver", confnode );
si.node = conf->getLocalNode();
<xsl:for-each
select=
"//sensors/item"
>
<xsl:call-template
name=
"setmsg"
>
...
...
@@ -1078,6 +1116,13 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
UniXML::iterator it(cnode);
// ------- init logserver ---
if( findArgParam("--" + argprefix + "-run-logserver", conf-
>
getArgc(), conf-
>
getArgv()) != -1 )
{
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);
string heart = conf->getArgParam("--" + argprefix + "heartbeat-id",it.getProp("heartbeat_id"));
...
...
Utilities/codegen/ctl-cpp-h-alone.xsl
View file @
2c07f42b
...
...
@@ -44,6 +44,9 @@
#include
<xsl:call-template
name=
"preinclude"
/>
UniXML.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
Trigger.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
UInterface.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
LogServer.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
DebugStream.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
LogAgregator.h
<xsl:call-template
name=
"postinclude"
/>
// -----------------------------------------------------------------------------
class
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK:
<xsl:if
test=
"normalize-space($BASECLASS)!=''"
>
public
<xsl:value-of
select=
"normalize-space($BASECLASS)"
/>
,
</xsl:if>
...
...
Utilities/codegen/ctl-cpp-h.xsl
View file @
2c07f42b
...
...
@@ -45,6 +45,8 @@
#include
<xsl:call-template
name=
"preinclude"
/>
UniXML.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
Trigger.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
DebugStream.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
LogServer.h
<xsl:call-template
name=
"postinclude"
/>
#include
<xsl:call-template
name=
"preinclude"
/>
LogAgregator.h
<xsl:call-template
name=
"postinclude"
/>
// -----------------------------------------------------------------------------
class
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK:
<xsl:if
test=
"normalize-space($BASECLASS)!=''"
>
public
<xsl:value-of
select=
"normalize-space($BASECLASS)"
/>
,
</xsl:if>
...
...
Utilities/codegen/tests/TestGenAlone.cc
View file @
2c07f42b
...
...
@@ -18,13 +18,13 @@ void TestGenAlone::step()
cout
<<
strval
(
in_input2_s
)
<<
endl
;
}
// -----------------------------------------------------------------------------
void
TestGenAlone
::
sensorInfo
(
SensorMessage
*
sm
)
void
TestGenAlone
::
sensorInfo
(
const
SensorMessage
*
sm
)
{
if
(
sm
->
id
==
input1_s
)
out_output1_c
=
in_input1_s
;
// sm->state
}
// -----------------------------------------------------------------------------
void
TestGenAlone
::
timerInfo
(
TimerMessage
*
tm
)
void
TestGenAlone
::
timerInfo
(
const
TimerMessage
*
tm
)
{
}
// -----------------------------------------------------------------------------
...
...
Utilities/codegen/tests/TestGenAlone.h
View file @
2c07f42b
...
...
@@ -13,10 +13,10 @@ class TestGenAlone:
protected
:
virtual
void
step
();
void
sensorInfo
(
UniSetTypes
::
SensorMessage
*
sm
)
;
void
timerInfo
(
UniSetTypes
::
TimerMessage
*
tm
)
;
virtual
void
sigterm
(
int
signo
);
virtual
void
step
()
override
;
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
;
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
override
;
virtual
void
sigterm
(
int
signo
)
override
;
private
:
};
...
...
conf/libuniset2.spec
View file @
2c07f42b
...
...
@@ -446,7 +446,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%changelog
* Sun May 24 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt35
- add supported LogServer for: SharedMemory,RRDServer,MBTCPMaster,MBSlave,UNetExchange,IOControl
- add supported LogServer for:
SharedMemory,RRDServer,MBTCPMaster,MBSlave,UNetExchange,IOControl,
codegen,DBServer_xxx
* Wed May 20 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt34.4
- (ModbusSlave): fixed bug in much_real_write (again) (thank`s hd@nio14)
...
...
extensions/RRDServer/RRDServer.cc
View file @
2c07f42b
...
...
@@ -13,30 +13,15 @@ using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
RRDServer
::
RRDServer
(
UniSetTypes
::
ObjectId
objId
,
xmlNode
*
cnode
,
UniSetTypes
::
ObjectId
shmId
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
,
const
string
&
prefix
)
:
UObject_SK
(
objId
,
cnode
),
UObject_SK
(
objId
,
cnode
,
string
(
prefix
+
"-"
)
),
prefix
(
prefix
)
{
auto
conf
=
uniset_conf
();
shm
=
make_shared
<
SMInterface
>
(
shmId
,
ui
,
objId
,
ic
);
loga
=
make_shared
<
LogAgregator
>
();
loga
->
add
(
mylog
);
loga
->
add
(
ulog
());
loga
->
add
(
dlog
());
UniXML
::
iterator
it
(
cnode
);
logserv
=
make_shared
<
LogServer
>
(
loga
);
logserv
->
init
(
prefix
+
"-logserver"
,
cnode
);
if
(
findArgParam
(
"--"
+
prefix
+
"-run-logserver"
,
conf
->
getArgc
(),
conf
->
getArgv
())
!=
-
1
)
{
logserv_host
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-logserver-host"
,
it
.
getProp
(
"logserverHost"
),
"localhost"
);
logserv_port
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-logserver-port"
,
it
.
getProp
(
"logserverPort"
),
getId
());
}
UniXML
::
iterator
it1
(
cnode
);
if
(
!
it1
.
goChildren
()
)
...
...
@@ -325,12 +310,6 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm )
if
(
sm
->
command
==
SystemMessage
::
StartUp
||
sm
->
command
==
SystemMessage
::
WatchDog
)
{
if
(
!
logserv_host
.
empty
()
&&
logserv_port
!=
0
&&
!
logserv
->
isRunning
()
)
{
myinfo
<<
myname
<<
"(init): run log server "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
logserv
->
run
(
logserv_host
,
logserv_port
,
true
);
}
for
(
auto
&&
it
:
rrdlist
)
{
try
...
...
extensions/RRDServer/RRDServer.h
View file @
2c07f42b
...
...
@@ -7,9 +7,6 @@
#include "SMInterface.h"
#include "SharedMemory.h"
#include "extensions/Extensions.h"
#include "LogAgregator.h"
#include "LogServer.h"
#include "LogAgregator.h"
// -----------------------------------------------------------------------------
/*!
\page page_RRDServer Реализация RRD хранилища
...
...
@@ -114,11 +111,6 @@ class RRDServer:
RRDList
rrdlist
;
std
::
shared_ptr
<
LogAgregator
>
loga
;
std
::
shared_ptr
<
LogServer
>
logserv
;
std
::
string
logserv_host
=
{
""
};
int
logserv_port
=
{
0
};
private
:
std
::
string
prefix
;
...
...
extensions/RRDServer/main.cc
View file @
2c07f42b
...
...
@@ -27,17 +27,6 @@ int main( int argc, const char** argv )
{
auto
conf
=
uniset_init
(
argc
,
argv
);
string
logfilename
(
conf
->
getArgParam
(
"--rrdstorage-logfile"
));
if
(
logfilename
.
empty
()
)
logfilename
=
"rrdstorage.log"
;
std
::
ostringstream
logname
;
string
dir
(
conf
->
getLogDir
());
logname
<<
dir
<<
logfilename
;
ulog
()
->
logFile
(
logname
.
str
()
);
dlog
()
->
logFile
(
logname
.
str
()
);
ObjectId
shmID
=
DefaultObjectId
;
string
sID
=
conf
->
getArgParam
(
"--smemory-id"
);
...
...
extensions/RRDServer/start_fg.sh
View file @
2c07f42b
...
...
@@ -2,4 +2,4 @@
uniset2-start.sh
-f
./uniset2-rrdserver
--confile
test.xml
\
--rrd-name
RRDServer1
\
--
dlog-add-levels
info,crit,warn
--
rrd-log-add-levels
any
$*
extensions/SharedMemory/SMLogSugar.h
0 → 100644
View file @
2c07f42b
#ifndef SMLogSugar_H_
#define SMLogSugar_H_
// "синтаксический сахар"..для логов
#ifndef sminfo
#define sminfo if( smlog->debugging(Debug::INFO) ) smlog->info()
#endif
#ifndef smwarn
#define smwarn if( smlog->debugging(Debug::WARN) ) smlog->warn()
#endif
#ifndef smcrit
#define smcrit if( smlog->debugging(Debug::CRIT) ) smlog->crit()
#endif
#ifndef smlog1
#define smlog1 if( smlog->debugging(Debug::LEVEL1) ) smlog->level1()
#endif
#ifndef smlog2
#define smlog2 if( smlog->debugging(Debug::LEVEL2) ) smlog->level2()
#endif
#ifndef smlog3
#define smlog3 if( smlog->debugging(Debug::LEVEL3) ) smlog->level3()
#endif
#ifndef smlog4
#define smlog4 if( smlog->debugging(Debug::LEVEL4) ) smlog->level4()
#endif
#ifndef smlog5
#define smlog5 if( smlog->debugging(Debug::LEVEL5) ) smlog->level5()
#endif
#ifndef smlog6
#define smlog6 if( smlog->debugging(Debug::LEVEL6) ) smlog->level6()
#endif
#ifndef smlog7
#define smlog7 if( smlog->debugging(Debug::LEVEL7) ) smlog->level7()
#endif
#ifndef smlog8
#define smlog8 if( smlog->debugging(Debug::LEVEL8) ) smlog->level8()
#endif
#ifndef smlog9
#define smlog9 if( smlog->debugging(Debug::LEVEL9) ) smlog->level9()
#endif
#ifndef smlogany
#define smlogany smlog->any()
#endif
#endif
extensions/include/UObject_SK.h
View file @
2c07f42b
...
...
@@ -3,12 +3,12 @@
/*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-0
4-02
+03:00
// generate timestamp: 2015-0
5-24
+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
...
...
@@ -20,17 +20,19 @@
#include "UniXML.h"
#include "Trigger.h"
#include "DebugStream.h"
#include "LogServer.h"
#include "LogAgregator.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
();
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
()
);
...
...
@@ -41,100 +43,100 @@ class UObject_SK:
std
::
shared_ptr
<
DebugStream
>
mylog
;
void
init_dlog
(
std
::
shared_ptr
<
DebugStream
>
d
);
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( mylog->debugging(Debug::INFO) ) mylog->info()
#endif
#ifndef mywarn
#define mywarn if( mylog->debugging(Debug::WARN) ) mylog->warn()
#endif
#ifndef mycrit
#define mycrit if( mylog->debugging(Debug::CRIT) ) mylog->crit()
#endif
#ifndef mylog1
#define mylog1 if( mylog->debugging(Debug::LEVEL1) ) mylog->level1()
#endif
#ifndef mylog2
#define mylog2 if( mylog->debugging(Debug::LEVEL2) ) mylog->level2()
#endif
#ifndef mylog3
#define mylog3 if( mylog->debugging(Debug::LEVEL3) ) mylog->level3()
#endif
#ifndef mylog4
#define mylog4 if( mylog->debugging(Debug::LEVEL4) ) mylog->level4()
#endif
#ifndef mylog5
#define mylog5 if( mylog->debugging(Debug::LEVEL5) ) mylog->level5()
#endif
#ifndef mylog6
#define mylog6 if( mylog->debugging(Debug::LEVEL6) ) mylog->level6()
#endif
#ifndef mylog7
#define mylog7 if( mylog->debugging(Debug::LEVEL7) ) mylog->level7()
#endif
#ifndef mylog8
#define mylog8 if( mylog->debugging(Debug::LEVEL8) ) mylog->level8()
#endif
#ifndef mylog9
#define mylog9 if( mylog->debugging(Debug::LEVEL9) ) mylog->level9()
#endif
#ifndef mylogany
#define mylogany mylog->any()
#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
);
// ------------------------------------------------------------
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( mylog->debugging(Debug::INFO) ) mylog->info()
#endif
#ifndef mywarn
#define mywarn if( mylog->debugging(Debug::WARN) ) mylog->warn()
#endif
#ifndef mycrit
#define mycrit if( mylog->debugging(Debug::CRIT) ) mylog->crit()
#endif
#ifndef mylog1
#define mylog1 if( mylog->debugging(Debug::LEVEL1) ) mylog->level1()
#endif
#ifndef mylog2
#define mylog2 if( mylog->debugging(Debug::LEVEL2) ) mylog->level2()
#endif
#ifndef mylog3
#define mylog3 if( mylog->debugging(Debug::LEVEL3) ) mylog->level3()
#endif
#ifndef mylog4
#define mylog4 if( mylog->debugging(Debug::LEVEL4) ) mylog->level4()
#endif
#ifndef mylog5
#define mylog5 if( mylog->debugging(Debug::LEVEL5) ) mylog->level5()
#endif
#ifndef mylog6
#define mylog6 if( mylog->debugging(Debug::LEVEL6) ) mylog->level6()
#endif
#ifndef mylog7
#define mylog7 if( mylog->debugging(Debug::LEVEL7) ) mylog->level7()
#endif
#ifndef mylog8
#define mylog8 if( mylog->debugging(Debug::LEVEL8) ) mylog->level8()
#endif
#ifndef mylog9
#define mylog9 if( mylog->debugging(Debug::LEVEL9) ) mylog->level9()
#endif
#ifndef mylogany
#define mylogany mylog->any()
#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
);
// ------------------------------------------------------------
// Используемые идентификаторы
// Используемые идентификаторы сообщений
// Текущее значение
// --- 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
)
override
;
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
void
testMode
(
bool
state
);
...
...
@@ -145,6 +147,7 @@ class UObject_SK:
void
preAskSensors
(
UniversalIO
::
UIOCommand
cmd
);
void
preSensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
);
void
preTimerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
);
void
preSysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
);
void
waitSM
(
int
wait_msec
,
UniSetTypes
::
ObjectId
testID
=
UniSetTypes
::
DefaultObjectId
);
void
resetMsg
();
...
...
@@ -153,7 +156,7 @@ class UObject_SK:
int
resetMsgTime
;
// Выполнение очередного шага программы
virtual
void
step
()
{}
virtual
void
step
(){}
int
sleep_msec
;
/*!< пауза между итерациями */
bool
active
;
...
...
@@ -165,39 +168,39 @@ 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
>
smlog
;
std
::
shared_ptr
<
LogServer
>
logserv
;
std
::
string
logserv_host
=
{
""
};
int
logserv_port
=
{
0
};
private
:
// --- private variables ---
// --- end of private variables ---
// предыдущее значение (для работы UpdateValue())
// Используемые идентификаторы сообщений
bool
end_private
;
// вспомогательное поле (для внутреннего использования при генерировании кода)
};
...
...
extensions/lib/UObject_SK.cc
View file @
2c07f42b
...
...
@@ -6,17 +6,20 @@
/*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-0
4-02
+03:00
// generate timestamp: 2015-0
5-24
+03:00
// -----------------------------------------------------------------------------
#include <memory>
#include "Configuration.h"
#include "Exceptions.h"
#include "ORepHelpers.h"
#include "LogServer.h"
#include "DebugStream.h"
#include "LogAgregator.h"
#include "UObject_SK.h"
// -----------------------------------------------------------------------------
...
...
@@ -28,26 +31,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 )
...
...
@@ -55,42 +58,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();
}
...
...
@@ -101,26 +103,38 @@ 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
>
();
loga
->
add
(
mylog
);
loga
->
add
(
ulog
());
logserv
=
make_shared
<
LogServer
>
(
loga
);
logserv
->
init
(
argprefix
+
"-logserver"
,
confnode
);
UniXML
::
iterator
it
(
cnode
);
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
)
);
UniXML
::
iterator
it
(
cnode
);
// ------- init logserver ---
if
(
findArgParam
(
"--"
+
argprefix
+
"-run-logserver"
,
conf
->
getArgc
(),
conf
->
getArgv
())
!=
-
1
)
{
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
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
if
(
!
heart
.
empty
()
)
{
idHeartBeat
=
conf
->
getSensorID
(
heart
);
if
(
idHeartBeat
==
DefaultObjectId
)
{
ostringstream
err
;
...
...
@@ -128,38 +142,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
);
...
...
@@ -167,7 +178,7 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
ptStartUpTimeout
.
setTiming
(
msec
);
// ===================== <variables> =====================
// ===================== end of <variables> =====================
}
...
...
@@ -180,42 +191,42 @@ 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
)
{
mycrit
<<
"(setMsg): попытка послать сообщение с DefaultObjectId"
<<
endl
;
return
false
;
mycrit
<<
myname
<<
"(setMsg): попытка послать сообщение с DefaultObjectId"
<<
endl
;
return
false
;
}
mylog8
<<
"(setMsg): "
<<
(
_state
?
"SEND "
:
"RESET "
)
<<
endl
;
// взводим автоматический сброс
if
(
_state
)
ptResetMsg
.
reset
();
mylog8
<<
myname
<<
"(setMsg): "
<<
(
_state
?
"SEND "
:
"RESET "
)
<<
endl
;
// взводим автоматический сброс
if
(
_state
)
ptResetMsg
.
reset
();
mylog8
<<
"(setMsg): not found MessgeOID?!!"
<<
endl
;
mylog8
<<
myname
<<
"(setMsg): not found MessgeOID?!!"
<<
endl
;
return
false
;
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
resetMsg
()
{
// reset messages
// reset messages
}
// -----------------------------------------------------------------------------
...
...
@@ -225,28 +236,28 @@ void UObject_SK::testMode( bool _state )
return
;
// отключаем все выходы
}
// -----------------------------------------------------------------------------
std
::
string
UObject_SK
::
dumpIO
()
{
ostringstream
s
;
s
<<
myname
<<
": "
<<
endl
;
return
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
""
;
}
// ----------------------------------------------------------------------------
...
...
@@ -267,19 +278,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
:
s
ysCommand
(
reinterpret_cast
<
SystemMessage
*>
(
_msg
)
);
break
;
preS
ysCommand
(
reinterpret_cast
<
SystemMessage
*>
(
_msg
)
);
break
;
default
:
break
;
}
}
}
catch
(
const
Exception
&
ex
)
{
...
...
@@ -287,21 +298,25 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg )
}
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
s
ysCommand
(
const
SystemMessage
*
_sm
)
void
UObject_SK
::
preS
ysCommand
(
const
SystemMessage
*
_sm
)
{
switch
(
_sm
->
command
)
{
case
SystemMessage
:
:
WatchDog
:
ulogany
<<
myname
<<
"(sysCommand): WatchDog"
<<
endl
;
ulogany
<<
myname
<<
"(preSysCommand): WatchDog"
<<
endl
;
if
(
!
active
||
!
ptStartUpTimeout
.
checkTime
()
)
{
uwarn
<<
myname
<<
"(s
ysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl
;
uwarn
<<
myname
<<
"(preS
ysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl
;
break
;
}
case
SystemMessage
:
:
StartUp
:
{
if
(
!
logserv_host
.
empty
()
&&
logserv_port
!=
0
&&
!
logserv
->
isRunning
()
)
{
myinfo
<<
myname
<<
"(preSysCommand): run log server "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
logserv
->
run
(
logserv_host
,
logserv_port
,
true
);
}
waitSM
(
smReadyTimeout
);
ptStartUpTimeout
.
reset
();
// т.к. для io-переменных важно соблюдать последовательность!
...
...
@@ -313,23 +328,22 @@ void UObject_SK::sysCommand( const SystemMessage* _sm )
active
=
true
;
break
;
}
case
SystemMessage
:
:
FoldUp
:
case
SystemMessage
:
:
Finish
:
preAskSensors
(
UniversalIO
::
UIODontNotify
);
askSensors
(
UniversalIO
::
UIODontNotify
);
break
;
case
SystemMessage
:
:
LogRotate
:
{
// переоткрываем логи
mylogany
<<
myname
<<
"(
s
ysCommand): logRotate"
<<
endl
;
mylogany
<<
myname
<<
"(
preS
ysCommand): logRotate"
<<
endl
;
string
fname
(
mylog
->
getLogFile
()
);
if
(
!
fname
.
empty
()
)
{
mylog
->
logFile
(
fname
.
c_str
(),
true
);
mylogany
<<
myname
<<
"(
s
ysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl
;
mylog
->
logFile
(
fname
.
c_str
(),
true
);
mylogany
<<
myname
<<
"(
preS
ysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl
;
}
}
break
;
...
...
@@ -337,6 +351,8 @@ void UObject_SK::sysCommand( const SystemMessage* _sm )
default
:
break
;
}
sysCommand
(
_sm
);
}
// -----------------------------------------------------------------------------
...
...
@@ -348,9 +364,9 @@ void UObject_SK::sigterm( int signo )
// -----------------------------------------------------------------------------
bool
UObject_SK
::
activateObject
()
{
// блокирование обработки Startup
// блокирование обработки Startup
// пока не пройдёт инициализация датчиков
// см.
s
ysCommand()
// см.
preS
ysCommand()
{
activated
=
false
;
UniSetObject
::
activateObject
();
...
...
@@ -374,24 +390,24 @@ 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());
}
...
...
@@ -403,37 +419,35 @@ 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
()
)
{
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
,
UniversalIO
::
AI
);
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
,
UniversalIO
::
AI
);
ptHeartBeat
.
reset
();
}
...
...
@@ -443,46 +457,46 @@ 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
)
{
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
)
...
...
@@ -495,7 +509,7 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
}
catch
(
const
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(getValue): "
<<
ex
<<
endl
;
ucrit
<<
myname
<<
"(getValue): "
<<
ex
<<
endl
;
throw
;
}
}
...
...
@@ -504,35 +518,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
);
}
...
...
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