Commit eebde190 authored by Pavel Vainerman's avatar Pavel Vainerman

(codegen): добавил возможность вывести имя таймера в виде string

переопределив virtual getTimerName( int id );
parent cd2cef2f
......@@ -436,6 +436,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSysCommand( const SystemMessage*
sysCommand(_sm);
}
// -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo( CORBA::Long userparam )
{
<xsl:if test="not(normalize-space($BASECLASS)='')">UniSetTypes::SimpleInfo_var i = <xsl:value-of select="$BASECLASS"/>::getInfo(userparam);</xsl:if>
......@@ -451,7 +452,7 @@ UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo( CORBA:
inf &lt;&lt; "Timers[" &lt;&lt; timers.size() &lt;&lt; "]:" &lt;&lt; endl;
for( const auto&amp; t: timers )
{
inf &lt;&lt; " " &lt;&lt; "[" &lt;&lt; t.id &lt;&lt; "]: msec="
inf &lt;&lt; " " &lt;&lt; setw(15) &lt;&lt; getTimerName(t.id) &lt;&lt; "[" &lt;&lt; t.id &lt;&lt; "]: msec="
&lt;&lt; setw(6) &lt;&lt; t.tmr.getInterval()
&lt;&lt; " timeleft=" &lt;&lt; setw(6) &lt;&lt; t.curTimeMS
&lt;&lt; " tick=" &lt;&lt; setw(3) &lt;&lt; ( t.curTick>=0 ? t.curTick : -1 )
......
......@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-12-15+03:00
// generate timestamp: 2015-12-19+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
......@@ -29,7 +29,7 @@ class UObject_SK:
public UniSetObject
{
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();
......@@ -43,60 +43,54 @@ class UObject_SK:
virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true );
inline std::shared_ptr<DebugStream> log()
{
return mylog;
}
inline std::shared_ptr<LogAgregator> logAgregator()
{
return loga;
}
inline std::shared_ptr<DebugStream> log(){ return mylog; }
inline std::shared_ptr<LogAgregator> logAgregator(){ return loga; }
void init_dlog( std::shared_ptr<DebugStream> d );
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
......@@ -113,19 +107,16 @@ class UObject_SK:
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string str( UniSetTypes::ObjectId id, bool showLinkName = true );
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true );
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string strval( UniSetTypes::ObjectId id, bool showLinkName = true );
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true );
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars()
{
return std::move(vmon.pretty_str());
}
inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
// ------------------------------------------------------------
std::string help();
......@@ -154,16 +145,13 @@ class UObject_SK:
virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) {};
virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override {}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override {}
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ){};
virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual std::string getMonitInfo()
{
return ""; /*!< пользовательская информация выводимая в getInfo() */
}
virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */
virtual void testMode( bool state );
void updatePreviousValues();
......@@ -183,7 +171,7 @@ class UObject_SK:
int resetMsgTime;
// Выполнение очередного шага программы
virtual void step() {}
virtual void step(){}
int sleep_msec; /*!< пауза между итерациями */
bool active;
......@@ -198,15 +186,9 @@ class UObject_SK:
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getIntProp(confnode, name);
}
int getIntProp(const std::string& name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); }
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getProp(confnode, name);
}
inline const std::string getProp(const std::string& name) { return UniSetTypes::uniset_conf()->getProp(confnode, name); }
timeout_t smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated;
......@@ -229,6 +211,7 @@ class UObject_SK:
VMonitor vmon;
private:
// --- private variables ---
......
......@@ -195,6 +195,9 @@ class LT_Object
TimersList getTimersList();
/*! пользовательская функция для вывода названия таймера */
virtual std::string getTimerName( int id ){ return ""; }
private:
TimersList tlst;
/*! замок для блокирования совместного доступа к cписку таймеров */
......
......@@ -168,7 +168,8 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
{
if( timeMS < UniSetTimer::MinQuantityTime )
{
ucrit << "(LT_askTimer): [мс] попытка заказть таймер со временем срабатыания "
ucrit << "(LT_askTimer): [мс] попытка заказть таймер " << getTimerName(timerid)
<< " со временем срабатыания "
<< " меньше разрешённого " << UniSetTimer::MinQuantityTime << endl;
timeMS = UniSetTimer::MinQuantityTime;
}
......@@ -186,8 +187,8 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
{
li->curTick = ticks;
li->tmr.setTiming(timeMS);
uinfo << "(LT_askTimer): заказ на таймер(id="
<< timerid << ") " << timeMS << " [мс] уже есть..." << endl;
uinfo << "(LT_askTimer): заказ на таймер(["
<< timerid << "]" << getTimerName(timerid) << ") " << timeMS << " [мс] уже есть..." << endl;
return sleepTime;
}
}
......@@ -197,11 +198,13 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
tlst.emplace_back(timerid, timeMS, ticks, p);
} // unlock
uinfo << "(LT_askTimer): поступил заказ на таймер(id=" << timerid << ") " << timeMS << " [мс]\n";
uinfo << "(LT_askTimer): поступил заказ на таймер([" << timerid << "]"
<< getTimerName(timerid) <<") " << timeMS << " [мс]\n";
}
else // отказ (при timeMS == 0)
{
uinfo << "(LT_askTimer): поступил отказ по таймеру id=" << timerid << endl;
uinfo << "(LT_askTimer): поступил отказ по таймеру [" << timerid << "]"
<< getTimerName(timerid) << endl;
{
// lock
uniset_rwmutex_wrlock lock(lstMutex);
......
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