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* ...@@ -436,6 +436,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSysCommand( const SystemMessage*
sysCommand(_sm); sysCommand(_sm);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo( CORBA::Long userparam ) 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> <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: ...@@ -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; inf &lt;&lt; "Timers[" &lt;&lt; timers.size() &lt;&lt; "]:" &lt;&lt; endl;
for( const auto&amp; t: timers ) 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; setw(6) &lt;&lt; t.tmr.getInterval()
&lt;&lt; " timeleft=" &lt;&lt; setw(6) &lt;&lt; t.curTimeMS &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 ) &lt;&lt; " tick=" &lt;&lt; setw(3) &lt;&lt; ( t.curTick>=0 ? t.curTick : -1 )
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2015-12-15+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,7 +29,7 @@ class UObject_SK: ...@@ -29,7 +29,7 @@ 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();
...@@ -43,91 +43,82 @@ class UObject_SK: ...@@ -43,91 +43,82 @@ 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() inline std::shared_ptr<DebugStream> log(){ return mylog; }
{ 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() inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
{ // ------------------------------------------------------------
return std::move(vmon.pretty_str()); std::string help();
}
// ------------------------------------------------------------
std::string help();
...@@ -154,16 +145,13 @@ class UObject_SK: ...@@ -154,16 +145,13 @@ class UObject_SK:
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() virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */
{
return ""; /*!< пользовательская информация выводимая в getInfo() */
}
virtual void testMode( bool state ); virtual void testMode( bool state );
void updatePreviousValues(); void updatePreviousValues();
...@@ -183,7 +171,7 @@ class UObject_SK: ...@@ -183,7 +171,7 @@ class UObject_SK:
int resetMsgTime; int resetMsgTime;
// Выполнение очередного шага программы // Выполнение очередного шага программы
virtual void step() {} virtual void step(){}
int sleep_msec; /*!< пауза между итерациями */ int sleep_msec; /*!< пауза между итерациями */
bool active; bool active;
...@@ -198,15 +186,9 @@ class UObject_SK: ...@@ -198,15 +186,9 @@ class UObject_SK:
xmlNode* confnode; xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */ /*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) int getIntProp(const std::string& name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); }
{
return UniSetTypes::uniset_conf()->getIntProp(confnode, name);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */ /*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name) inline const std::string getProp(const std::string& name) { return UniSetTypes::uniset_conf()->getProp(confnode, name); }
{
return UniSetTypes::uniset_conf()->getProp(confnode, name);
}
timeout_t smReadyTimeout; /*!< время ожидания готовности SM */ timeout_t smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated; std::atomic_bool activated;
...@@ -229,6 +211,7 @@ class UObject_SK: ...@@ -229,6 +211,7 @@ class UObject_SK:
VMonitor vmon; VMonitor vmon;
private: private:
// --- private variables --- // --- private variables ---
......
...@@ -195,6 +195,9 @@ class LT_Object ...@@ -195,6 +195,9 @@ class LT_Object
TimersList getTimersList(); TimersList getTimersList();
/*! пользовательская функция для вывода названия таймера */
virtual std::string getTimerName( int id ){ return ""; }
private: private:
TimersList tlst; TimersList tlst;
/*! замок для блокирования совместного доступа к cписку таймеров */ /*! замок для блокирования совместного доступа к cписку таймеров */
......
...@@ -168,7 +168,8 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c ...@@ -168,7 +168,8 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
{ {
if( timeMS < UniSetTimer::MinQuantityTime ) if( timeMS < UniSetTimer::MinQuantityTime )
{ {
ucrit << "(LT_askTimer): [мс] попытка заказть таймер со временем срабатыания " ucrit << "(LT_askTimer): [мс] попытка заказть таймер " << getTimerName(timerid)
<< " со временем срабатыания "
<< " меньше разрешённого " << UniSetTimer::MinQuantityTime << endl; << " меньше разрешённого " << UniSetTimer::MinQuantityTime << endl;
timeMS = UniSetTimer::MinQuantityTime; timeMS = UniSetTimer::MinQuantityTime;
} }
...@@ -186,8 +187,8 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c ...@@ -186,8 +187,8 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
{ {
li->curTick = ticks; li->curTick = ticks;
li->tmr.setTiming(timeMS); li->tmr.setTiming(timeMS);
uinfo << "(LT_askTimer): заказ на таймер(id=" uinfo << "(LT_askTimer): заказ на таймер(["
<< timerid << ") " << timeMS << " [мс] уже есть..." << endl; << timerid << "]" << getTimerName(timerid) << ") " << timeMS << " [мс] уже есть..." << endl;
return sleepTime; return sleepTime;
} }
} }
...@@ -197,11 +198,13 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c ...@@ -197,11 +198,13 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
tlst.emplace_back(timerid, timeMS, ticks, p); tlst.emplace_back(timerid, timeMS, ticks, p);
} // unlock } // unlock
uinfo << "(LT_askTimer): поступил заказ на таймер(id=" << timerid << ") " << timeMS << " [мс]\n"; uinfo << "(LT_askTimer): поступил заказ на таймер([" << timerid << "]"
<< getTimerName(timerid) <<") " << timeMS << " [мс]\n";
} }
else // отказ (при timeMS == 0) else // отказ (при timeMS == 0)
{ {
uinfo << "(LT_askTimer): поступил отказ по таймеру id=" << timerid << endl; uinfo << "(LT_askTimer): поступил отказ по таймеру [" << timerid << "]"
<< getTimerName(timerid) << endl;
{ {
// lock // lock
uniset_rwmutex_wrlock lock(lstMutex); 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