Commit 0b420448 authored by Pavel Vainerman's avatar Pavel Vainerman

(codegen): Сделал входные переменные (in_xxx) - readonly!

УБРАЛ обновление in_переменной в функции getValue(), т.к. это потенциально приводит к "потере" sensorInfo(). Перенёс некоторые функции в private.
parent a14e60c7
...@@ -123,12 +123,12 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::S ...@@ -123,12 +123,12 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::S
<xsl:if test="normalize-space(@vartype)='in'"> <xsl:if test="normalize-space(@vartype)='in'">
<xsl:if test="normalize-space(@loglevel)=''"> <xsl:if test="normalize-space(@loglevel)=''">
if( _sm->id == <xsl:value-of select="../../@name"/> ) if( _sm->id == <xsl:value-of select="../../@name"/> )
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _sm->value; priv_<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _sm->value;
</xsl:if> </xsl:if>
<xsl:if test="normalize-space(@loglevel)!=''"> <xsl:if test="normalize-space(@loglevel)!=''">
if( _sm->id == <xsl:value-of select="../../@name"/> ) if( _sm->id == <xsl:value-of select="../../@name"/> )
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _sm->value; priv_<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = _sm->value;
mylog->level( Debug::type(_sm->value) ); mylog->level( Debug::type(_sm->value) );
} }
</xsl:if> </xsl:if>
...@@ -150,7 +150,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -150,7 +150,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
{ {
try try
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>,node_<xsl:value-of select="../../@name"/>); <xsl:if test="normalize-space(@vartype)='in'">priv_</xsl:if><xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>,node_<xsl:value-of select="../../@name"/>);
} }
catch( std::exception&amp; ex ) catch( std::exception&amp; ex )
{ {
...@@ -258,7 +258,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -258,7 +258,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
<xsl:if test="normalize-space(../../@msg)!='1'"> <xsl:if test="normalize-space(../../@msg)!='1'">
if( _sid == <xsl:value-of select="../../@name"/> ) if( _sid == <xsl:value-of select="../../@name"/> )
{ {
<xsl:text> </xsl:text><xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>); <xsl:if test="normalize-space(@vartype)='in'">/* <xsl:text> </xsl:text>priv_<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>); */</xsl:if>
return <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>; return <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>;
} }
</xsl:if> </xsl:if>
...@@ -317,7 +317,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force ) ...@@ -317,7 +317,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
{ {
<xsl:if test="normalize-space(../../@msg)!='1'"> <xsl:if test="normalize-space(../../@msg)!='1'">
<xsl:if test="normalize-space(@name)=$OID"> <xsl:if test="normalize-space(@name)=$OID">
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>); priv_<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>);
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
} }
......
...@@ -148,7 +148,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -148,7 +148,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
{ {
try try
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>,node_<xsl:value-of select="../../@name"/>); <xsl:if test="normalize-space(@vartype)='in'">priv_</xsl:if><xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>,node_<xsl:value-of select="../../@name"/>);
} }
catch( std::exception&amp; ex ) catch( std::exception&amp; ex )
{ {
...@@ -257,7 +257,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() ...@@ -257,7 +257,7 @@ UniSetTypes::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID()
{ {
<xsl:if test="normalize-space(../../@msg)!='1'"> <xsl:if test="normalize-space(../../@msg)!='1'">
<xsl:if test="normalize-space(@name)=$OID"> <xsl:if test="normalize-space(@name)=$OID">
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>); priv_<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>);
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
} }
......
...@@ -168,12 +168,12 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::S ...@@ -168,12 +168,12 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::S
<xsl:if test="normalize-space(@vartype)='in'"> <xsl:if test="normalize-space(@vartype)='in'">
<xsl:if test="normalize-space(@loglevel)=''"> <xsl:if test="normalize-space(@loglevel)=''">
if( _sm->id == <xsl:value-of select="@name"/> ) if( _sm->id == <xsl:value-of select="@name"/> )
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _sm->value; priv_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _sm->value;
</xsl:if> </xsl:if>
<xsl:if test="normalize-space(@loglevel)!=''"> <xsl:if test="normalize-space(@loglevel)!=''">
if( _sm->id == <xsl:value-of select="@name"/> ) if( _sm->id == <xsl:value-of select="@name"/> )
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _sm->value; priv_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = _sm->value;
mylog->level( Debug::type(_sm->value) ); mylog->level( Debug::type(_sm->value) );
} }
</xsl:if> </xsl:if>
...@@ -191,7 +191,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -191,7 +191,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
{ {
try try
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>,node_<xsl:value-of select="@name"/>); <xsl:if test="normalize-space(@vartype)='in'">priv_</xsl:if><xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>,node_<xsl:value-of select="@name"/>);
} }
catch( std::exception&amp; ex ) catch( std::exception&amp; ex )
{ {
...@@ -214,7 +214,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si ...@@ -214,7 +214,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
<xsl:for-each select="//smap/item"> <xsl:for-each select="//smap/item">
if( _sid == <xsl:value-of select="@name"/> &amp;&amp; <xsl:value-of select="@name"/> != DefaultObjectId ) if( _sid == <xsl:value-of select="@name"/> &amp;&amp; <xsl:value-of select="@name"/> != DefaultObjectId )
{ {
<xsl:text> </xsl:text><xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>, node_<xsl:value-of select="@name"/>); <xsl:if test="normalize-space(@vartype)='in'">/* <xsl:text> </xsl:text>priv_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>, node_<xsl:value-of select="@name"/>); */</xsl:if>
return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>; return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
} }
</xsl:for-each> </xsl:for-each>
...@@ -278,7 +278,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm ...@@ -278,7 +278,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
{ {
try try
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>, node_<xsl:value-of select="@name"/>); priv_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>, node_<xsl:value-of select="@name"/>);
} }
catch( UniSetTypes::Exception&amp; ex ) catch( UniSetTypes::Exception&amp; ex )
{ {
......
...@@ -201,7 +201,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -201,7 +201,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
{ {
try try
{ {
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>,node_<xsl:value-of select="@name"/>); <xsl:if test="normalize-space(@vartype)='in'">priv_</xsl:if><xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>,node_<xsl:value-of select="@name"/>);
} }
catch( std::exception&amp; ex ) catch( std::exception&amp; ex )
{ {
...@@ -219,7 +219,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -219,7 +219,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
try try
{ {
if( <xsl:value-of select="@name"/> != DefaultObjectId ) if( <xsl:value-of select="@name"/> != DefaultObjectId )
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>,node_<xsl:value-of select="@name"/>); priv_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>,node_<xsl:value-of select="@name"/>);
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
......
...@@ -68,10 +68,9 @@ class <xsl:value-of select="$CLASSNAME"/>_SK: ...@@ -68,10 +68,9 @@ class <xsl:value-of select="$CLASSNAME"/>_SK:
// Используемые идентификаторы // Используемые идентификаторы
<xsl:for-each select="//smap/item"> <xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@vartype)!='io'">const UniSetTypes::ObjectId <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */ const UniSetTypes::ObjectId <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
UniSetTypes::ObjectId node_<xsl:value-of select="@name"/>; UniSetTypes::ObjectId node_<xsl:value-of select="@name"/>;
</xsl:if> <xsl:if test="normalize-space(@vartype)='io'">#error (uniset-codegen): vartype='io' NO LONGER SUPPORTED! (ignore variable: '<xsl:value-of select="@name"/>')
<xsl:if test="normalize-space(@vartype)='io'">#warning (uniset-codegen): vartype='io' NO LONGER SUPPORTED! (ignore variable: '<xsl:value-of select="@name"/>')
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
...@@ -83,7 +82,10 @@ class <xsl:value-of select="$CLASSNAME"/>_SK: ...@@ -83,7 +82,10 @@ class <xsl:value-of select="$CLASSNAME"/>_SK:
</xsl:for-each> </xsl:for-each>
// Текущее значение // Текущее значение
<xsl:for-each select="//smap/item">long <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>; <xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@vartype)='in'">const long&amp; </xsl:if>
<xsl:if test="normalize-space(@vartype)!='in'">long </xsl:if>
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
</xsl:for-each> </xsl:for-each>
// --- public variables --- // --- public variables ---
...@@ -170,6 +172,11 @@ class <xsl:value-of select="$CLASSNAME"/>_SK: ...@@ -170,6 +172,11 @@ class <xsl:value-of select="$CLASSNAME"/>_SK:
<xsl:for-each select="//smap/item">long prev_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>; <xsl:for-each select="//smap/item">long prev_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
</xsl:for-each> </xsl:for-each>
// Текущее значение (rw-переменные)
<xsl:for-each select="//smap/item"><xsl:if test="normalize-space(@vartype)='in'">long priv_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
</xsl:if>
</xsl:for-each>
// Используемые идентификаторы сообщений // Используемые идентификаторы сообщений
<xsl:for-each select="//msgmap/item">bool prev_m_<xsl:value-of select="@name"/>; /*!&lt; предыдущее состояние /> */ <xsl:for-each select="//msgmap/item">bool prev_m_<xsl:value-of select="@name"/>; /*!&lt; предыдущее состояние /> */
</xsl:for-each> </xsl:for-each>
......
...@@ -10,11 +10,17 @@ TestGen::TestGen( UniSetTypes::ObjectId id, xmlNode* confnode ): ...@@ -10,11 +10,17 @@ TestGen::TestGen( UniSetTypes::ObjectId id, xmlNode* confnode ):
vmonit(int_var); vmonit(int_var);
vmonit(bool_var); vmonit(bool_var);
long* i = valptr(input2_s); const long* i = valptr(input2_s);
long* k = outptr(output1_c);
if( !k )
cerr << "output1_c NOT FOUND!!!" << endl;
ObjectId d = idval(in_input2_s); ObjectId d = idval(in_input2_s);
ObjectId d2 = idval(&in_input2_s); ObjectId d2 = idval(&in_input2_s);
ObjectId d3 = idval(i); ObjectId d3 = idval(i);
ObjectId d4 = idval(&out_output1_c);
if( !i ) if( !i )
cerr << "input2_s NOT FOUND!!!" << endl; cerr << "input2_s NOT FOUND!!!" << endl;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2016-08-01+03:00 // generate timestamp: 2016-08-24+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,60 +43,54 @@ class UObject_SK: ...@@ -43,60 +43,54 @@ 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
// Вспомогательные функции для удобства логирования // Вспомогательные функции для удобства логирования
// ------------------------------------------------------------ // ------------------------------------------------------------
...@@ -113,19 +107,16 @@ class UObject_SK: ...@@ -113,19 +107,16 @@ class UObject_SK:
\param id - идентификатор датчика \param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить \param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/ */
std::string str( UniSetTypes::ObjectId id, bool showLinkName = true ) const; std::string str( UniSetTypes::ObjectId id, bool showLinkName=true ) const;
/*! Вывод значения входа/выхода в формате: 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 ) const; std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true ) const;
/*! Вывод состояния внутренних переменных */ /*! Вывод состояния внутренних переменных */
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,28 +145,21 @@ class UObject_SK: ...@@ -154,28 +145,21 @@ class UObject_SK:
virtual void callback() override; virtual void callback() override;
virtual void processingMessage( const UniSetTypes::VoidMessage* msg ) override; virtual void processingMessage( const 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 step(){}
virtual void testMode( bool state ); virtual void testMode( bool state );
void updatePreviousValues();
void checkSensors();
void updateOutputs( bool force ); void updateOutputs( bool force );
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 waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
void initFromSM();
UniSetTypes::ObjectId getSMTestID(); UniSetTypes::ObjectId getSMTestID();
void resetMsg(); void resetMsg();
...@@ -183,9 +167,6 @@ class UObject_SK: ...@@ -183,9 +167,6 @@ class UObject_SK:
PassiveTimer ptResetMsg; PassiveTimer ptResetMsg;
int resetMsgTime; int resetMsgTime;
// Выполнение очередного шага программы
virtual void step() {}
int sleep_msec; /*!< пауза между итерациями */ int sleep_msec; /*!< пауза между итерациями */
bool active; bool active;
...@@ -195,19 +176,13 @@ class UObject_SK: ...@@ -195,19 +176,13 @@ class UObject_SK:
// управление датчиком "сердцебиения" // управление датчиком "сердцебиения"
PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */ PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */
UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */ UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */
int maxHeartBeat; /*! < сохраняемое значение */ long maxHeartBeat; /*! < сохраняемое значение */
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;
...@@ -224,9 +199,6 @@ class UObject_SK: ...@@ -224,9 +199,6 @@ class UObject_SK:
std::string logserv_host = {""}; std::string logserv_host = {""};
int logserv_port = {0}; int logserv_port = {0};
// snap
bool no_snap = {false};
VMonitor vmon; VMonitor vmon;
...@@ -239,8 +211,21 @@ class UObject_SK: ...@@ -239,8 +211,21 @@ class UObject_SK:
// предыдущее значение (для работы UpdateValue()) // предыдущее значение (для работы UpdateValue())
// Текущее значение (rw-переменные)
// Используемые идентификаторы сообщений // Используемые идентификаторы сообщений
// ------------ private функции ---------------
void updatePreviousValues();
void preAskSensors( UniversalIO::UIOCommand cmd );
void preSensorInfo( const UniSetTypes::SensorMessage* sm );
void preTimerInfo( const UniSetTypes::TimerMessage* tm );
void preSysCommand( const UniSetTypes::SystemMessage* sm );
void initFromSM();
void checkSensors();
// --------------------------------------------
bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода) bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
}; };
......
...@@ -19,8 +19,33 @@ class VMon ...@@ -19,8 +19,33 @@ class VMon
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
using namespace std; using namespace std;
class PtrMapHashFn
{
public:
size_t operator() (const long* const& key) const
{
return std::hash<long>()((long)key);
}
};
int main( int argc, const char** argv ) int main( int argc, const char** argv )
{ {
unordered_map<const long*, const long*,PtrMapHashFn> vmap;
const long id = 10;
long prive_val = 100;
const long& val(prive_val);
vmap.emplace(&id,&val);
auto i = vmap.find(&id);
return 0;
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
auto sec = std::chrono::time_point_cast<std::chrono::nanoseconds>(now); auto sec = std::chrono::time_point_cast<std::chrono::nanoseconds>(now);
auto nsec = std::chrono::time_point_cast<std::chrono::seconds>(now); auto nsec = std::chrono::time_point_cast<std::chrono::seconds>(now);
......
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