Commit bfb0a5b0 authored by Pavel Vainerman's avatar Pavel Vainerman

Revert "(codegen): добавил проверку что 'выход' сохранился в SM."

This reverts commit 0e10a4b9.
parent 741852ac
...@@ -353,22 +353,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force ) ...@@ -353,22 +353,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
{ {
si.id = <xsl:value-of select="../../@name"/>; si.id = <xsl:value-of select="../../@name"/>;
si.node = node_<xsl:value-of select="../../@name"/>; si.node = node_<xsl:value-of select="../../@name"/>;
unsigned int i=0; ui->setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setmsg): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
...@@ -383,22 +368,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force ) ...@@ -383,22 +368,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
{ {
si.id = <xsl:value-of select="../../@name"/>; si.id = <xsl:value-of select="../../@name"/>;
si.node = node_<xsl:value-of select="../../@name"/>; si.node = node_<xsl:value-of select="../../@name"/>;
unsigned int i=0; ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == <xsl:value-of select="$setval"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setmsg): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
......
...@@ -291,22 +291,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() ...@@ -291,22 +291,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID()
{ {
si.id = <xsl:value-of select="../../@name"/>; si.id = <xsl:value-of select="../../@name"/>;
si.node = node_<xsl:value-of select="../../@name"/>; si.node = node_<xsl:value-of select="../../@name"/>;
unsigned int i=0; ui->setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setdata): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
...@@ -321,22 +306,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() ...@@ -321,22 +306,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID()
{ {
si.id = <xsl:value-of select="../../@name"/>; si.id = <xsl:value-of select="../../@name"/>;
si.node = node_<xsl:value-of select="../../@name"/>; si.node = node_<xsl:value-of select="../../@name"/>;
unsigned int i=0; ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == <xsl:value-of select="$setval"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setdata): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
......
...@@ -293,22 +293,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -293,22 +293,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
{ {
si.id = <xsl:value-of select="@name"/>; si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>; si.node = node_<xsl:value-of select="@name"/>;
unsigned int i=0; ui->setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setdata): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
...@@ -326,22 +311,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -326,22 +311,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
{ {
si.id = <xsl:value-of select="@name"/>; si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>; si.node = node_<xsl:value-of select="@name"/>;
unsigned int i=0; ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == <xsl:value-of select="$setval"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setdata): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
......
...@@ -234,22 +234,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -234,22 +234,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
{ {
si.id = <xsl:value-of select="@name"/>; si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>; si.node = node_<xsl:value-of select="@name"/>;
unsigned int i=0; ui->setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setdata): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
...@@ -267,22 +252,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -267,22 +252,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
{ {
si.id = <xsl:value-of select="@name"/>; si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>; si.node = node_<xsl:value-of select="@name"/>;
unsigned int i=0; ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == <xsl:value-of select="$setval"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setdata): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
...@@ -299,22 +269,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -299,22 +269,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
{ {
si.id = <xsl:value-of select="@name"/>; si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>; si.node = node_<xsl:value-of select="@name"/>;
unsigned int i=0; ui->setValue( si,(long)m_<xsl:value-of select="@name"/>, getId() );
for( ; i&lt;setValueNumberOfAttempts; i++ )
{
ui->setValue( si,(long)m_<xsl:value-of select="@name"/>, getId() );
// Проверка, что сохранилось
if( ui->getValue(si.id,si.node) == (long)m_<xsl:value-of select="@name"/> )
break;
}
if( i>=setValueNumberOfAttempts )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; "(setmsg): failed setValue for sid=" &lt;&lt; si.id;
mycrit &lt;&lt; err.str() &lt;&lt; endl;
throw UniSetTypes::SystemError(err.str());
}
} }
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
......
...@@ -345,7 +345,6 @@ ...@@ -345,7 +345,6 @@
</xsl:template> </xsl:template>
<xsl:template name="COMMON-HEAD-PRIVATE"> <xsl:template name="COMMON-HEAD-PRIVATE">
unsigned int setValueNumberOfAttempts = { 3 }; // количество попыток, сохранить 'out' (см. updateOutputs)
<xsl:if test="normalize-space($VARMAP)='1'"> <xsl:if test="normalize-space($VARMAP)='1'">
class PtrMapHashFn class PtrMapHashFn
{ {
...@@ -837,7 +836,7 @@ end_private(false) ...@@ -837,7 +836,7 @@ end_private(false)
logserv = make_shared&lt;LogServer&gt;(loga); logserv = make_shared&lt;LogServer&gt;(loga);
logserv-&gt;init( argprefix + "logserver", confnode ); logserv-&gt;init( argprefix + "logserver", confnode );
<xsl:for-each select="//smap/item"> <xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@no_check_id)!='1'"> <xsl:if test="normalize-space(@no_check_id)!='1'">
if( <xsl:value-of select="normalize-space(@name)"/> == UniSetTypes::DefaultObjectId ) if( <xsl:value-of select="normalize-space(@name)"/> == UniSetTypes::DefaultObjectId )
...@@ -908,8 +907,6 @@ end_private(false) ...@@ -908,8 +907,6 @@ end_private(false)
maxHeartBeat = conf->getArgPInt("--" + argprefix + "heartbeat-max",it.getProp("heartbeat_max"), 10); maxHeartBeat = conf->getArgPInt("--" + argprefix + "heartbeat-max",it.getProp("heartbeat_max"), 10);
} }
setValueNumberOfAttempts = conf->getArgPInt("--" + argprefix + "setValueNumberOfAttempts",it.getProp("setValueNumberOfAttempts"),setValueNumberOfAttempts);
// Инициализация значений // Инициализация значений
<xsl:for-each select="//smap/item"> <xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@default)=''"> <xsl:if test="normalize-space(@default)=''">
...@@ -997,7 +994,6 @@ end_private(false) ...@@ -997,7 +994,6 @@ end_private(false)
vmonit(maxHeartBeat); vmonit(maxHeartBeat);
vmonit(activateTimeout); vmonit(activateTimeout);
vmonit(smReadyTimeout); vmonit(smReadyTimeout);
vmonit(setValueNumberOfAttempts);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -1361,7 +1357,6 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000)) ...@@ -1361,7 +1357,6 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
si.node = conf->getLocalNode(); si.node = conf->getLocalNode();
sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec","<xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>", <xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>); sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec","<xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>", <xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>);
setValueNumberOfAttempts = conf->getArgPInt("--" + argprefix + "setValueNumberOfAttempts",it.getProp("setValueNumberOfAttempts"),setValueNumberOfAttempts);
string s_resetTime("<xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>"); string s_resetTime("<xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>");
if( s_resetTime.empty() ) if( s_resetTime.empty() )
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
Name: libuniset2 Name: libuniset2
Version: 2.3 Version: 2.3
Release: alt6 Release: alt5
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
License: LGPL License: LGPL
...@@ -483,9 +483,6 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -483,9 +483,6 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# .. # ..
%changelog %changelog
* Fri May 27 2016 Pavel Vainerman <pv@altlinux.ru> 2.3-alt6
- codegen: added several attempts to save the value
* Wed May 11 2016 Pavel Vainerman <pv@altlinux.ru> 2.3-alt5 * Wed May 11 2016 Pavel Vainerman <pv@altlinux.ru> 2.3-alt5
- fixes after coverity_scan - fixes after coverity_scan
......
...@@ -224,7 +224,6 @@ ...@@ -224,7 +224,6 @@
- \b --argprefix-activate-timeout msec - \b --argprefix-activate-timeout msec
- \b --argprefix-startup-timeout msec - \b --argprefix-startup-timeout msec
- \b --argprefix-log-[add|del]-levels xxx,xxx,xxx - \b --argprefix-log-[add|del]-levels xxx,xxx,xxx
- \b --argprefix-setValueNumberOfAttempts num
\section pg_Codegen_Configuration Конфигурирование \section pg_Codegen_Configuration Конфигурирование
...@@ -255,8 +254,6 @@ ...@@ -255,8 +254,6 @@
- \b activateTimeout = conf->getArgPInt("--activate-timeout", 20000); - время отведённое на инициализацию процесса - \b activateTimeout = conf->getArgPInt("--activate-timeout", 20000); - время отведённое на инициализацию процесса
- \b msec = conf->getArgPInt("--startup-timeout", 10000); - пауза, в течение которой игнорируется сообщение SystemMessage::WatchDog. - \b msec = conf->getArgPInt("--startup-timeout", 10000); - пауза, в течение которой игнорируется сообщение SystemMessage::WatchDog.
В случае если они приходят подряд. В случае если они приходят подряд.
- \b setValueNumberOfAttempts - количество попыток сохранить 'выходы'(out_xxx) в SharedMemory.
\section pg_Codegen_TestMode Специальный режим "тест" (TestMode) \section pg_Codegen_TestMode Специальный режим "тест" (TestMode)
......
/*
* Copyright (c) 2015 Pavel Vainerman.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 2.1.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/* /*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE. DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST. ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ. НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2016-05-27+03:00 // generate timestamp: 2015-12-19+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef UObject_SK_H_ #ifndef UObject_SK_H_
#define UObject_SK_H_ #define UObject_SK_H_
...@@ -29,11 +43,11 @@ class UObject_SK: ...@@ -29,11 +43,11 @@ class UObject_SK:
public UniSetObject public UniSetObject
{ {
public: 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(); UObject_SK();
virtual ~UObject_SK(); virtual ~UObject_SK();
long getValue( UniSetTypes::ObjectId sid ); long getValue( UniSetTypes::ObjectId sid );
void setValue( UniSetTypes::ObjectId sid, long value ); void setValue( UniSetTypes::ObjectId sid, long value );
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() ); void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
...@@ -43,116 +57,128 @@ class UObject_SK: ...@@ -43,116 +57,128 @@ class UObject_SK:
virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true ); virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true );
inline std::shared_ptr<DebugStream> log(){ return mylog; } inline std::shared_ptr<DebugStream> log()
inline std::shared_ptr<LogAgregator> logAgregator(){ return loga; } {
return mylog;
}
inline std::shared_ptr<LogAgregator> logAgregator()
{
return loga;
}
void init_dlog( std::shared_ptr<DebugStream> d ); void init_dlog( std::shared_ptr<DebugStream> d );
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef myinfo #ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info() #define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif #endif
#ifndef mywarn #ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn() #define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif #endif
#ifndef mycrit #ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit() #define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif #endif
#ifndef mylog1 #ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1() #define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif #endif
#ifndef mylog2 #ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2() #define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif #endif
#ifndef mylog3 #ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3() #define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif #endif
#ifndef mylog4 #ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4() #define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif #endif
#ifndef mylog5 #ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5() #define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif #endif
#ifndef mylog6 #ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6() #define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif #endif
#ifndef mylog7 #ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7() #define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif #endif
#ifndef mylog8 #ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8() #define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif #endif
#ifndef mylog9 #ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9() #define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif #endif
#ifndef mylogany #ifndef mylogany
#define mylogany log()->any() #define mylogany log()->any()
#endif #endif
#ifndef vmonit #ifndef vmonit
#define vmonit( var ) vmon.add( #var, var ) #define vmonit( var ) vmon.add( #var, var )
#endif #endif
// Вспомогательные функции для удобства логирования // Вспомогательные функции для удобства логирования
// ------------------------------------------------------------ // ------------------------------------------------------------
/*! вывод в строку значение всех входов и выходов в формате /*! вывод в строку значение всех входов и выходов в формате
ObjectName: ObjectName:
in_xxx = val in_xxx = val
in_xxx2 = val in_xxx2 = val
out_zzz = val out_zzz = val
... ...
*/ */
std::string dumpIO(); std::string dumpIO();
/*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName) /*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
\param id - идентификатор датчика \param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить \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 id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить \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()); } inline std::string dumpVars()
// ------------------------------------------------------------ {
std::string help(); return std::move(vmon.pretty_str());
}
// ------------------------------------------------------------
std::string help();
// Используемые идентификаторы // Используемые идентификаторы
// Используемые идентификаторы сообщений // Используемые идентификаторы сообщений
// Текущее значение // Текущее значение
// --- public variables --- // --- public variables ---
// --- end of public variables --- // --- end of public variables ---
protected: protected:
// --- protected variables --- // --- protected variables ---
// ---- end of protected variables ---- // ---- end of protected variables ----
virtual void callback() override; virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override; virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ){}; virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) {};
virtual void askSensors( UniversalIO::UIOCommand cmd ){} virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{} virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override {}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{} virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override {}
virtual void sigterm( int signo ) override; virtual void sigterm( int signo ) override;
virtual bool activateObject() override; virtual bool activateObject() override;
virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */ virtual std::string getMonitInfo()
{
return ""; /*!< пользовательская информация выводимая в getInfo() */
}
virtual void testMode( bool state ); virtual void testMode( bool state );
void updatePreviousValues(); void updatePreviousValues();
void checkSensors(); void checkSensors();
...@@ -164,7 +190,6 @@ class UObject_SK: ...@@ -164,7 +190,6 @@ class UObject_SK:
void preSysCommand( const UniSetTypes::SystemMessage* sm ); void preSysCommand( const UniSetTypes::SystemMessage* sm );
void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId ); void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
void initFromSM(); void initFromSM();
UniSetTypes::ObjectId getSMTestID();
void resetMsg(); void resetMsg();
Trigger trResetMsg; Trigger trResetMsg;
...@@ -172,7 +197,7 @@ class UObject_SK: ...@@ -172,7 +197,7 @@ class UObject_SK:
int resetMsgTime; int resetMsgTime;
// Выполнение очередного шага программы // Выполнение очередного шага программы
virtual void step(){} virtual void step() {}
int sleep_msec; /*!< пауза между итерациями */ int sleep_msec; /*!< пауза между итерациями */
bool active; bool active;
...@@ -184,22 +209,28 @@ class UObject_SK: ...@@ -184,22 +209,28 @@ class UObject_SK:
PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */ PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */
UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */ UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */
int maxHeartBeat; /*! < сохраняемое значение */ int maxHeartBeat; /*! < сохраняемое значение */
xmlNode* confnode; xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной 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 */ /*! получить текстовое свойство из конф. файла по привязанной 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);
}
timeout_t smReadyTimeout; /*!< время ожидания готовности SM */ timeout_t smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated; std::atomic_bool activated;
timeout_t activateTimeout; /*!< время ожидания готовности UniSetObject к работе */ timeout_t activateTimeout; /*!< время ожидания готовности UniSetObject к работе */
PassiveTimer ptStartUpTimeout; /*!< время на блокировку обработки WatchDog, если недавно был StartUp */ PassiveTimer ptStartUpTimeout; /*!< время на блокировку обработки WatchDog, если недавно был StartUp */
int askPause; /*!< пауза между неудачными попытками заказать датчики */ int askPause; /*!< пауза между неудачными попытками заказать датчики */
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
bool forceOut; /*!< флаг принудительного обноления "выходов" */ bool forceOut; /*!< флаг принудительного обноления "выходов" */
std::shared_ptr<LogAgregator> loga; std::shared_ptr<LogAgregator> loga;
std::shared_ptr<DebugStream> mylog; std::shared_ptr<DebugStream> mylog;
std::shared_ptr<LogServer> logserv; std::shared_ptr<LogServer> logserv;
...@@ -208,23 +239,21 @@ class UObject_SK: ...@@ -208,23 +239,21 @@ class UObject_SK:
// snap // snap
bool no_snap = {false}; bool no_snap = {false};
VMonitor vmon; VMonitor vmon;
private: private:
// --- private variables --- // --- private variables ---
// --- end of private variables --- // --- end of private variables ---
// предыдущее значение (для работы UpdateValue()) // предыдущее значение (для работы UpdateValue())
// Используемые идентификаторы сообщений // Используемые идентификаторы сообщений
unsigned int setValueNumberOfAttempts = { 3 }; // количество попыток, сохранить 'out' (см. updateOutputs)
bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода) bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
}; };
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
/* /*
DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE. DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
ALL YOUR CHANGES WILL BE LOST. ALL YOUR CHANGES WILL BE LOST.
НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ. НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2016-05-27+03:00 // generate timestamp: 2015-12-19+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include <memory> #include <memory>
#include <iomanip> #include <iomanip>
...@@ -32,26 +32,26 @@ using namespace UniSetTypes; ...@@ -32,26 +32,26 @@ using namespace UniSetTypes;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UObject_SK::UObject_SK(): UObject_SK::UObject_SK():
// Инициализация идентификаторов (имена берутся из конф. файла) // Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла) // Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables // variables
active(false), active(false),
idHeartBeat(DefaultObjectId), idHeartBeat(DefaultObjectId),
maxHeartBeat(10), maxHeartBeat(10),
confnode(0), confnode(0),
smReadyTimeout(0), smReadyTimeout(0),
activated(false), activated(false),
askPause(2000), askPause(2000),
forceOut(false), forceOut(false),
end_private(false) end_private(false)
{ {
mycrit << "UObject: init failed!!!!!!!!!!!!!!!" << endl; ucrit << "UObject: init failed!!!!!!!!!!!!!!!" << endl;
throw Exception( string(myname+": init failed!!!") ); throw Exception( string(myname + ": init failed!!!") );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ( val, confval, default val ) // ( val, confval, default val )
...@@ -59,41 +59,42 @@ static const std::string init3_str( const std::string& s1, const std::string& s2 ...@@ -59,41 +59,42 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
{ {
if( !s1.empty() ) if( !s1.empty() )
return s1; return s1;
if( !s2.empty() ) if( !s2.empty() )
return s2; return s2;
return s3; return s3;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argprefix ): UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argprefix ):
UniSetObject(id), UniSetObject(id),
// Инициализация идентификаторов (имена берутся из конф. файла) // Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла) // Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables // variables
sleep_msec(150), sleep_msec(150),
active(true), active(true),
argprefix( (_argprefix.empty() ? myname+"-" : _argprefix) ), argprefix( (_argprefix.empty() ? myname + "-" : _argprefix) ),
idHeartBeat(DefaultObjectId), idHeartBeat(DefaultObjectId),
maxHeartBeat(10), maxHeartBeat(10),
confnode(cnode), confnode(cnode),
smReadyTimeout(0), smReadyTimeout(0),
activated(false), activated(false),
askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000)), askPause(uniset_conf()->getPIntProp(cnode, "askPause", 2000)),
forceOut(false), forceOut(false),
end_private(false) end_private(false)
{ {
auto conf = uniset_conf(); 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();
} }
...@@ -104,21 +105,21 @@ end_private(false) ...@@ -104,21 +105,21 @@ end_private(false)
throw SystemError( err.str() ); throw SystemError( err.str() );
} }
mylog = make_shared<DebugStream>(); mylog = make_shared<DebugStream>();
mylog->setLogName(myname); mylog->setLogName(myname);
{ {
ostringstream s; ostringstream s;
s << argprefix << "log"; 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(mylog);
loga->add(ulog()); loga->add(ulog());
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( argprefix + "logserver", confnode ); logserv->init( argprefix + "logserver", confnode );
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
...@@ -129,13 +130,15 @@ end_private(false) ...@@ -129,13 +130,15 @@ end_private(false)
logserv_host = conf->getArg2Param("--" + argprefix + "logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + argprefix + "logserver-host", it.getProp("logserverHost"), "localhost");
logserv_port = conf->getArgPInt("--" + argprefix + "logserver-port", it.getProp("logserverPort"), getId()); 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() ) if( !heart.empty() )
{ {
idHeartBeat = conf->getSensorID(heart); idHeartBeat = conf->getSensorID(heart);
if( idHeartBeat == DefaultObjectId ) if( idHeartBeat == DefaultObjectId )
{ {
ostringstream err; ostringstream err;
...@@ -143,33 +146,34 @@ end_private(false) ...@@ -143,33 +146,34 @@ end_private(false)
throw SystemError(err.str()); throw SystemError(err.str());
} }
int heartbeatTime = conf->getArgPInt("--" + argprefix + "heartbeat-time",it.getProp("heartbeatTime"),conf->getHeartBeatTime()); int heartbeatTime = conf->getArgPInt("--" + argprefix + "heartbeat-time", it.getProp("heartbeatTime"), conf->getHeartBeatTime());
if( heartbeatTime>0 )
if( heartbeatTime > 0 )
ptHeartBeat.setTiming(heartbeatTime); ptHeartBeat.setTiming(heartbeatTime);
else else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime); 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);
} }
setValueNumberOfAttempts = conf->getArgPInt("--" + argprefix + "setValueNumberOfAttempts",it.getProp("setValueNumberOfAttempts"),setValueNumberOfAttempts);
// Инициализация значений // Инициализация значений
si.id = UniSetTypes::DefaultObjectId; si.id = UniSetTypes::DefaultObjectId;
si.node = conf->getLocalNode(); si.node = conf->getLocalNode();
sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec","150", 150); sleep_msec = conf->getArgPInt("--" + argprefix + "sleep-msec", "150", 150);
string s_resetTime(""); string s_resetTime("");
if( s_resetTime.empty() ) if( s_resetTime.empty() )
s_resetTime = "500"; 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); ptResetMsg.setTiming(resetMsgTime);
int sm_tout = conf->getArgInt("--" + argprefix + "sm-ready-timeout",""); int sm_tout = conf->getArgInt("--" + argprefix + "sm-ready-timeout", "");
if( sm_tout == 0 ) if( sm_tout == 0 )
smReadyTimeout = 60000; smReadyTimeout = 60000;
else if( sm_tout < 0 ) else if( sm_tout < 0 )
...@@ -177,11 +181,8 @@ end_private(false) ...@@ -177,11 +181,8 @@ end_private(false)
else else
smReadyTimeout = sm_tout; smReadyTimeout = sm_tout;
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"), ""));
if( smTestID == DefaultObjectId )
smTestID = getSMTestID();
activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 20000); activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 20000);
...@@ -189,7 +190,7 @@ end_private(false) ...@@ -189,7 +190,7 @@ end_private(false)
ptStartUpTimeout.setTiming(msec); ptStartUpTimeout.setTiming(msec);
// ===================== <variables> ===================== // ===================== <variables> =====================
// ===================== end of <variables> ===================== // ===================== end of <variables> =====================
vmonit(sleep_msec); vmonit(sleep_msec);
...@@ -200,7 +201,6 @@ end_private(false) ...@@ -200,7 +201,6 @@ end_private(false)
vmonit(maxHeartBeat); vmonit(maxHeartBeat);
vmonit(activateTimeout); vmonit(activateTimeout);
vmonit(smReadyTimeout); vmonit(smReadyTimeout);
vmonit(setValueNumberOfAttempts);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -212,17 +212,17 @@ UObject_SK::~UObject_SK() ...@@ -212,17 +212,17 @@ UObject_SK::~UObject_SK()
void UObject_SK::updateValues() void UObject_SK::updateValues()
{ {
// Опрашиваем все входы... // Опрашиваем все входы...
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::updatePreviousValues() void UObject_SK::updatePreviousValues()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::checkSensors() void UObject_SK::checkSensors()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state ) bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state )
...@@ -230,48 +230,38 @@ bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state ) ...@@ -230,48 +230,38 @@ bool UObject_SK::setMsg( UniSetTypes::ObjectId _code, bool _state )
if( _code == UniSetTypes::DefaultObjectId ) if( _code == UniSetTypes::DefaultObjectId )
{ {
mylog8 << myname << "(setMsg): попытка послать сообщение с DefaultObjectId" << endl; mylog8 << myname << "(setMsg): попытка послать сообщение с DefaultObjectId" << endl;
return false; return false;
} }
mylog8 << myname << "(setMsg): " << ( _state ? "SEND " : "RESET " ) << endl; mylog8 << myname << "(setMsg): " << ( _state ? "SEND " : "RESET " ) << endl;
// взводим автоматический сброс
if( _state )
{
ptResetMsg.reset();
trResetMsg.hi(false);
}
// взводим автоматический сброс
if( _state )
{
ptResetMsg.reset();
trResetMsg.hi(false);
}
mylog8 << myname << "(setMsg): not found MessgeOID?!!" << endl;
mylog8 << myname << "(setMsg): not found MessgeOID?!!" << endl;
return false; return false;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::resetMsg() void UObject_SK::resetMsg()
{ {
mylog8 << myname << "(resetMsg): reset messages.." << endl; mylog8 << myname << "(resetMsg): reset messages.." << endl;
// reset messages // reset messages
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UniSetTypes::ObjectId UObject_SK::getSMTestID()
{
if( smTestID != DefaultObjectId )
return smTestID;
return DefaultObjectId;
}
// -----------------------------------------------------------------------------
void UObject_SK::testMode( bool _state ) void UObject_SK::testMode( bool _state )
{ {
if( !_state ) if( !_state )
return; return;
// отключаем все выходы // отключаем все выходы
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::string UObject_SK::dumpIO() std::string UObject_SK::dumpIO()
...@@ -281,44 +271,48 @@ std::string UObject_SK::dumpIO() ...@@ -281,44 +271,48 @@ std::string UObject_SK::dumpIO()
std::list<std::string> v_in; std::list<std::string> v_in;
ostringstream s1; ostringstream s1;
std::list<std::string> v_out; std::list<std::string> v_out;
s << endl; s << endl;
int n = 0; int n = 0;
for( const auto& e: v_in )
for( const auto& e : v_in )
{ {
s << e; s << e;
if( (n++)%2 )
if( (n++) % 2 )
s << std::endl; s << std::endl;
} }
s << endl; s << endl;
n = 0; n = 0;
for( const auto& e: v_out )
for( const auto& e : v_out )
{ {
s << e; s << e;
if( (n++)%2 )
if( (n++) % 2 )
s << std::endl; s << std::endl;
} }
return std::move(s.str()); return std::move(s.str());
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string UObject_SK::str( UniSetTypes::ObjectId id, bool showLinkName ) std::string UObject_SK::str( UniSetTypes::ObjectId id, bool showLinkName )
{ {
ostringstream s; ostringstream s;
return ""; return "";
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string UObject_SK::strval( UniSetTypes::ObjectId id, bool showLinkName ) std::string UObject_SK::strval( UniSetTypes::ObjectId id, bool showLinkName )
{ {
ostringstream s; ostringstream s;
return ""; return "";
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -339,23 +333,23 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg ) ...@@ -339,23 +333,23 @@ void UObject_SK::processingMessage( UniSetTypes::VoidMessage* _msg )
{ {
case Message::SensorInfo: case Message::SensorInfo:
preSensorInfo( reinterpret_cast<SensorMessage*>(_msg) ); preSensorInfo( reinterpret_cast<SensorMessage*>(_msg) );
break; break;
case Message::Timer: case Message::Timer:
preTimerInfo( reinterpret_cast<TimerMessage*>(_msg) ); preTimerInfo( reinterpret_cast<TimerMessage*>(_msg) );
break; break;
case Message::SysCommand: case Message::SysCommand:
preSysCommand( reinterpret_cast<SystemMessage*>(_msg) ); preSysCommand( reinterpret_cast<SystemMessage*>(_msg) );
break; break;
default: default:
break; break;
} }
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
mycrit << myname << "(processingMessage): " << ex << endl; ucrit << myname << "(processingMessage): " << ex << endl;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -364,12 +358,14 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm ) ...@@ -364,12 +358,14 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
switch( _sm->command ) switch( _sm->command )
{ {
case SystemMessage::WatchDog: case SystemMessage::WatchDog:
myinfo << myname << "(preSysCommand): WatchDog" << endl; uinfo << myname << "(preSysCommand): WatchDog" << endl;
if( !active || !ptStartUpTimeout.checkTime() ) if( !active || !ptStartUpTimeout.checkTime() )
{ {
mywarn << myname << "(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули" << endl; uwarn << myname << "(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули" << endl;
break; break;
} }
case SystemMessage::StartUp: case SystemMessage::StartUp:
{ {
if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() ) if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() )
...@@ -390,21 +386,22 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm ) ...@@ -390,21 +386,22 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
active = true; active = true;
break; break;
} }
case SystemMessage::FoldUp: case SystemMessage::FoldUp:
case SystemMessage::Finish: case SystemMessage::Finish:
preAskSensors(UniversalIO::UIODontNotify); preAskSensors(UniversalIO::UIODontNotify);
askSensors(UniversalIO::UIODontNotify); askSensors(UniversalIO::UIODontNotify);
break; break;
case SystemMessage::LogRotate: case SystemMessage::LogRotate:
{ {
// переоткрываем логи // переоткрываем логи
mylogany << myname << "(preSysCommand): logRotate" << endl; mylogany << myname << "(preSysCommand): logRotate" << endl;
string fname( log()->getLogFile() ); string fname( log()->getLogFile() );
if( !fname.empty() ) if( !fname.empty() )
{ {
mylog->logFile(fname.c_str(),true); mylog->logFile(fname.c_str(), true);
mylogany << myname << "(preSysCommand): ***************** mylog LOG ROTATE *****************" << endl; mylogany << myname << "(preSysCommand): ***************** mylog LOG ROTATE *****************" << endl;
} }
} }
...@@ -413,7 +410,7 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm ) ...@@ -413,7 +410,7 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
default: default:
break; break;
} }
sysCommand(_sm); sysCommand(_sm);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -421,30 +418,32 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm ) ...@@ -421,30 +418,32 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
UniSetTypes::SimpleInfo* UObject_SK::getInfo( CORBA::Long userparam ) UniSetTypes::SimpleInfo* UObject_SK::getInfo( CORBA::Long userparam )
{ {
UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo(userparam); UniSetTypes::SimpleInfo_var i = UniSetObject::getInfo(userparam);
ostringstream inf; ostringstream inf;
inf << i->info << endl; inf << i->info << endl;
inf << "LogServer: " << logserv_host << ":" << logserv_port << endl; inf << "LogServer: " << logserv_host << ":" << logserv_port << endl;
inf << dumpIO() << endl; inf << dumpIO() << endl;
inf << endl; inf << endl;
auto timers = getTimersList(); auto timers = getTimersList();
inf << "Timers[" << timers.size() << "]:" << endl; inf << "Timers[" << timers.size() << "]:" << endl;
for( const auto& t: timers )
for( const auto& t : timers )
{ {
inf << " " << setw(15) << getTimerName(t.id) << "[" << t.id << "]: msec=" inf << " " << setw(15) << getTimerName(t.id) << "[" << t.id << "]: msec="
<< setw(6) << t.tmr.getInterval() << setw(6) << t.tmr.getInterval()
<< " timeleft=" << setw(6) << t.curTimeMS << " timeleft=" << setw(6) << t.curTimeMS
<< " tick=" << setw(3) << ( t.curTick>=0 ? t.curTick : -1 ) << " tick=" << setw(3) << ( t.curTick >= 0 ? t.curTick : -1 )
<< endl; << endl;
} }
inf << endl; inf << endl;
inf << vmon.pretty_str() << endl; inf << vmon.pretty_str() << endl;
inf << endl; inf << endl;
inf << getMonitInfo() << endl; inf << getMonitInfo() << endl;
i->info = inf.str().c_str(); i->info = inf.str().c_str();
return i._retn(); return i._retn();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -459,7 +458,7 @@ void UObject_SK::sigterm( int signo ) ...@@ -459,7 +458,7 @@ void UObject_SK::sigterm( int signo )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UObject_SK::activateObject() bool UObject_SK::activateObject()
{ {
// блокирование обработки Startup // блокирование обработки Startup
// пока не пройдёт инициализация датчиков // пока не пройдёт инициализация датчиков
// см. preSysCommand() // см. preSysCommand()
{ {
...@@ -485,47 +484,34 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID ) ...@@ -485,47 +484,34 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
if( _testID == DefaultObjectId ) if( _testID == DefaultObjectId )
return; return;
myinfo << myname << "(waitSM): waiting SM ready "
<< wait_msec << " msec"
<< " testID=" << _testID << endl;
// waitReady можно использовать т.к. датчик это по сути IONotifyController
if( !ui->waitReady(_testID,wait_msec) )
{
ostringstream err;
err << myname
<< "(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
<< wait_msec << " мсек";
mycrit << err.str() << endl; uinfo << myname << "(waitSM): waiting SM ready "
// terminate(); << wait_msec << " msec"
// abort(); << " testID=" << _testID << endl;
raise(SIGTERM);
terminate();
// throw SystemError(err.str());
}
if( !ui->waitWorking(_testID,wait_msec) ) if( !ui->waitReady(_testID, wait_msec) )
{ {
ostringstream err; ostringstream err;
err << myname err << myname
<< "(waitSM): Не дождались готовности(work) SharedMemory к работе в течение " << "(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
<< wait_msec << " мсек"; << wait_msec << " мсек";
mycrit << err.str() << endl; ucrit << err.str() << endl;
// terminate(); // terminate();
// abort(); // abort();
raise(SIGTERM); raise(SIGTERM);
// throw SystemError(err.str()); terminate();
// throw SystemError(err.str());
} }
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string UObject_SK::help() std::string UObject_SK::help()
{ {
ostringstream s; ostringstream s;
return std::move(s.str()); return std::move(s.str());
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -535,42 +521,44 @@ void UObject_SK::callback() ...@@ -535,42 +521,44 @@ void UObject_SK::callback()
{ {
if( !active ) if( !active )
return; return;
try try
{ {
// проверка таймеров // проверка таймеров
checkTimers(this); 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(); resetMsg();
} }
// обработка сообщений (таймеров и т.п.) // обработка сообщений (таймеров и т.п.)
for( unsigned int i=0; i<20; i++ ) for( unsigned int i = 0; i < 20; i++ )
{ {
if( !receiveMessage(msg) ) if( !receiveMessage(msg) )
break; break;
processingMessage(&msg); processingMessage(&msg);
updateOutputs(forceOut); updateOutputs(forceOut);
// updatePreviousValues(); // updatePreviousValues();
} }
// Выполнение шага программы // Выполнение шага программы
step(); step();
// "сердцебиение" // "сердцебиение"
if( idHeartBeat!=DefaultObjectId && ptHeartBeat.checkTime() ) if( idHeartBeat != DefaultObjectId && ptHeartBeat.checkTime() )
{ {
try try
{ {
ui->setValue(idHeartBeat,maxHeartBeat); ui->setValue(idHeartBeat, maxHeartBeat);
ptHeartBeat.reset(); ptHeartBeat.reset();
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
mycrit << myname << "(execute): " << ex << endl; ucrit << myname << "(execute): " << ex << endl;
} }
} }
...@@ -580,21 +568,21 @@ void UObject_SK::callback() ...@@ -580,21 +568,21 @@ void UObject_SK::callback()
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
mycrit << myname << "(execute): " << ex << endl; ucrit << myname << "(execute): " << ex << endl;
} }
catch( const CORBA::SystemException& ex ) catch( const CORBA::SystemException& ex )
{ {
mycrit << myname << "(execute): СORBA::SystemException: " ucrit << myname << "(execute): СORBA::SystemException: "
<< ex.NP_minorString() << endl; << ex.NP_minorString() << endl;
}
catch( const std::exception& ex )
{
ucrit << myname << "(execute): catch " << ex.what() << endl;
} }
catch( const std::exception&ex )
{
mycrit << myname << "(execute): catch " << ex.what() << endl;
}
if( !active ) if( !active )
return; return;
msleep( sleep_msec ); msleep( sleep_msec );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -602,32 +590,32 @@ void UObject_SK::setValue( UniSetTypes::ObjectId _sid, long _val ) ...@@ -602,32 +590,32 @@ void UObject_SK::setValue( UniSetTypes::ObjectId _sid, long _val )
{ {
if( _sid == UniSetTypes::DefaultObjectId ) if( _sid == UniSetTypes::DefaultObjectId )
return; return;
ui->setValue(_sid,_val);
ui->setValue(_sid, _val);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::updateOutputs( bool _force ) void UObject_SK::updateOutputs( bool _force )
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::preSensorInfo( const UniSetTypes::SensorMessage* _sm ) void UObject_SK::preSensorInfo( const UniSetTypes::SensorMessage* _sm )
{ {
sensorInfo(_sm); sensorInfo(_sm);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::initFromSM() void UObject_SK::initFromSM()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UObject_SK::askSensor( UniSetTypes::ObjectId _sid, UniversalIO::UIOCommand _cmd, UniSetTypes::ObjectId _node ) 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 ) long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
...@@ -640,7 +628,7 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid ) ...@@ -640,7 +628,7 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
mycrit << myname << "(getValue): " << ex << endl; ucrit << myname << "(getValue): " << ex << endl;
throw; throw;
} }
} }
...@@ -649,33 +637,35 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid ) ...@@ -649,33 +637,35 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd ) void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
{ {
PassiveTimer ptAct(activateTimeout); PassiveTimer ptAct(activateTimeout);
while( !activated && !ptAct.checkTime() ) while( !activated && !ptAct.checkTime() )
{ {
cout << myname << "(preAskSensors): wait activate..." << endl; cout << myname << "(preAskSensors): wait activate..." << endl;
msleep(300); msleep(300);
if( activated ) if( activated )
break; break;
} }
if( !activated ) if( !activated )
mycrit << myname ucrit << myname
<< "(preAskSensors): ************* don`t activated?! ************" << endl; << "(preAskSensors): ************* don`t activated?! ************" << endl;
for( ;; ) for( ;; )
{ {
try try
{ {
return; return;
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
mycrit << myname << "(preAskSensors): " << ex << endl; ucrit << myname << "(preAskSensors): " << ex << endl;
}
catch( const std::exception& ex )
{
ucrit << myname << "(execute): catch " << ex.what() << endl;
} }
catch( const std::exception&ex )
{
mycrit << myname << "(execute): catch " << ex.what() << endl;
}
msleep(askPause); msleep(askPause);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment