Commit b1ef89fe authored by Pavel Vainerman's avatar Pavel Vainerman

- Исправил небольшую ошибку с параметром влючения сборки документации.

- Переход на shared_ptr везде где только можно.. - выпуск версии 2.0-alt11 с текущими изменениями.
parent 2fbcb22d
......@@ -79,7 +79,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId &amp;&amp; ptHeartBeat.checkTime() )
{
ui.setValue(idHeartBeat,maxHeartBeat,UniversalIO::AI);
ui->setValue(idHeartBeat,maxHeartBeat,UniversalIO::AI);
ptHeartBeat.reset();
}
......@@ -154,7 +154,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
<xsl:for-each select="//sensors/item/consumers/consumer">
<xsl:if test="normalize-space(@name)=$OID">
<xsl:if test="normalize-space(@vartype)='in'">
ui.askRemoteSensor(<xsl:value-of select="../../@name"/>,_cmd,node_<xsl:value-of select="../../@name"/>, getId());
ui->askRemoteSensor(<xsl:value-of select="../../@name"/>,_cmd,node_<xsl:value-of select="../../@name"/>, getId());
</xsl:if>
</xsl:if>
</xsl:for-each>
......@@ -178,7 +178,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
// -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _sid, long _val )
{
// ui.setState(sid,state);
// ui->setState(sid,state);
<xsl:for-each select="//sensors/item/consumers/consumer">
<xsl:if test="normalize-space(@name)=$OID">
<xsl:if test="normalize-space(../../@msg)!='1'">
......@@ -195,12 +195,12 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
</xsl:if>
</xsl:for-each>
ui.setValue(_sid,_val);
ui->setValue(_sid,_val);
}
// -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::askSensor( UniSetTypes::ObjectId _sid, UniversalIO::UIOCommand _cmd, UniSetTypes::ObjectId _node )
{
ui.askRemoteSensor(_sid,_cmd,_node,getId());
ui->askRemoteSensor(_sid,_cmd,_node,getId());
}
// -----------------------------------------------------------------------------
......@@ -213,14 +213,14 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
<xsl:if test="normalize-space(../../@msg)!='1'">
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:text> </xsl:text><xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>);
return <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>;
}
</xsl:if>
</xsl:if>
</xsl:for-each>
return ui.getValue(_sid);
return ui->getValue(_sid);
}
catch(Exception&amp; ex)
{
......@@ -255,7 +255,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
if( _force || prev_m_<xsl:value-of select="../../@name"/> != m_<xsl:value-of select="../../@name"/> )
{
si.id = mid_<xsl:value-of select="../../@name"/>;
ui.setValue( si,m_<xsl:value-of select="../../@name"/>, getId() );
ui->setValue( si,m_<xsl:value-of select="../../@name"/>, getId() );
prev_m_<xsl:value-of select="../../@name"/> = m_<xsl:value-of select="../../@name"/>;
}
</xsl:if>
......@@ -286,7 +286,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
<xsl:if test="normalize-space(../../@msg)!='1'">
<xsl:if test="normalize-space(@name)=$OID">
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui.getValue(<xsl:value-of select="../../@name"/>);
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>);
</xsl:if>
</xsl:if>
}
......@@ -323,7 +323,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
si.id = <xsl:value-of select="../../@name"/>;
si.node = node_<xsl:value-of select="../../@name"/>;
ui.setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
ui->setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
}
catch(Exception&amp; ex)
{
......@@ -338,7 +338,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
si.id = <xsl:value-of select="../../@name"/>;
si.node = node_<xsl:value-of select="../../@name"/>;
ui.setValue( si,<xsl:value-of select="$setval"/>, getId() );
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
}
catch(Exception&amp; ex)
{
......
......@@ -82,7 +82,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId &amp;&amp; ptHeartBeat.checkTime() )
{
ui.setValue(idHeartBeat,maxHeartBeat,UniversalIO::AI);
ui->setValue(idHeartBeat,maxHeartBeat,UniversalIO::AI);
ptHeartBeat.reset();
}
......@@ -138,7 +138,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::askSensor( UniSetTypes::ObjectId _s
// что-бы компилятор выбрал
// правильный(для аналоговых) конструктор у SensorMessage
IOController_i::CalibrateIo _ci;
SensorMessage _sm( _sid, (long)ui.getValue(_sid,_node), _ci );
SensorMessage _sm( _sid, (long)ui->getValue(_sid,_node), _ci );
_sm.node = _node;
_sm.sensor_type = UniversalIO::AI;
sensorInfo(&amp;_sm);
......@@ -147,7 +147,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::askSensor( UniSetTypes::ObjectId _s
// -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _sid, long _val )
{
// ui.setState(sid,state);
// ui->setState(sid,state);
<xsl:for-each select="//sensors/item/consumers/consumer">
<xsl:if test="normalize-space(../../@msg)!='1'">
<xsl:if test="normalize-space(@name)=$OID">
......@@ -163,7 +163,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
</xsl:if>
</xsl:for-each>
ui.setValue(_sid,_val);
ui->setValue(_sid,_val);
}
// -----------------------------------------------------------------------------
......@@ -178,7 +178,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
</xsl:if>
</xsl:for-each>
return ui.getValue(_sid);
return ui->getValue(_sid);
}
// -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
......@@ -220,7 +220,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
<xsl:if test="normalize-space(../../@msg)!='1'">
<xsl:if test="normalize-space(@name)=$OID">
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui.getValue(<xsl:value-of select="../../@name"/>);
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/> = ui->getValue(<xsl:value-of select="../../@name"/>);
</xsl:if>
</xsl:if>
}
......@@ -257,7 +257,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
si.id = <xsl:value-of select="../../@name"/>;
si.node = node_<xsl:value-of select="../../@name"/>;
ui.setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
ui->setValue( si,<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>, getId() );
}
catch( Exception&amp; ex )
{
......@@ -272,7 +272,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
si.id = <xsl:value-of select="../../@name"/>;
si.node = node_<xsl:value-of select="../../@name"/>;
ui.setValue( si,<xsl:value-of select="$setval"/>, getId() );
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
}
catch( Exception&amp; ex )
{
......
......@@ -78,7 +78,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId &amp;&amp; ptHeartBeat.checkTime() )
{
ui.setValue(idHeartBeat,maxHeartBeat,UniversalIO::AI);
ui->setValue(idHeartBeat,maxHeartBeat,UniversalIO::AI);
ptHeartBeat.reset();
}
......@@ -120,7 +120,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId _si
</xsl:if>
</xsl:for-each>
ui.setValue(_sid,_val);
ui->setValue(_sid,_val);
}
// -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
......@@ -143,7 +143,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
if( prev_m_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> != m_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> )
{
si.id = <xsl:value-of select="@name"/>;
ui.setValue( si,m_<xsl:value-of select="@name"/>,getId() );
ui->setValue( si,m_<xsl:value-of select="@name"/>,getId() );
prev_m_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = m_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
}
</xsl:for-each>
......@@ -173,7 +173,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::S
// -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::askSensor( UniSetTypes::ObjectId _sid, UniversalIO::UIOCommand _cmd, UniSetTypes::ObjectId _node )
{
ui.askRemoteSensor(_sid,_cmd,_node,getId());
ui->askRemoteSensor(_sid,_cmd,_node,getId());
}
// -----------------------------------------------------------------------------
long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _sid )
......@@ -183,12 +183,12 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
<xsl:for-each select="//smap/item">
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: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"/>);
return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
}
</xsl:for-each>
return ui.getValue(_sid);
return ui->getValue(_sid);
}
catch(Exception&amp; ex)
{
......@@ -220,7 +220,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preAskSensors( UniversalIO::UIOComm
<xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@vartype)='in'">
if( <xsl:value-of select="@name"/> != DefaultObjectId )
ui.askRemoteSensor(<xsl:value-of select="@name"/>,_cmd,node_<xsl:value-of select="@name"/>,getId());
ui->askRemoteSensor(<xsl:value-of select="@name"/>,_cmd,node_<xsl:value-of select="@name"/>,getId());
</xsl:if>
</xsl:for-each>
return;
......@@ -263,7 +263,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
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: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 )
{
......@@ -280,7 +280,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>;
ui.setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
ui->setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
}
catch( UniSetTypes::Exception&amp; ex )
{
......@@ -298,7 +298,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
{
si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>;
ui.setValue( si,<xsl:value-of select="$setval"/>, getId() );
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
}
catch( UniSetTypes::Exception&amp; ex )
{
......
......@@ -82,7 +82,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId &amp;&amp; ptHeartBeat.checkTime() )
{
ui.setValue(idHeartBeat,maxHeartBeat,UniversalIO::AI);
ui->setValue(idHeartBeat,maxHeartBeat,UniversalIO::AI);
ptHeartBeat.reset();
}
......@@ -123,7 +123,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setValue( UniSetTypes::ObjectId sid
</xsl:if>
</xsl:for-each>
ui.setValue(sid,val);
ui->setValue(sid,val);
}
// -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool force )
......@@ -138,7 +138,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool force )
// update messages
<xsl:for-each select="//msgmap/item">
si.id = <xsl:value-of select="@name"/>;
ui.setValue( si,m_<xsl:value-of select="@name"/>,getId() );
ui->setValue( si,m_<xsl:value-of select="@name"/>,getId() );
</xsl:for-each>
-->
}
......@@ -160,7 +160,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::askSensor( UniSetTypes::ObjectId si
// что-бы компилятор выбрал
// правильный(для аналоговых) конструктор у SensorMessage
IOController_i::CalibrateInfo _ci;
SensorMessage sm( sid, (long)ui.getValue(sid,node), _ci );
SensorMessage sm( sid, (long)ui->getValue(sid,node), _ci );
sm.sensor_type = UniversalIO::AI;
sm.node = node;
sensorInfo(&amp;sm);
......@@ -174,7 +174,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
return <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
</xsl:for-each>
return ui.getValue(_sid);
return ui->getValue(_sid);
}
// -----------------------------------------------------------------------------
void <xsl:value-of select="$CLASSNAME"/>_SK::preSensorInfo( const UniSetTypes::SensorMessage* sm )
......@@ -203,7 +203,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
try
{
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"/>);
<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> = ui->getValue(<xsl:value-of select="@name"/>,node_<xsl:value-of select="@name"/>);
}
catch( Exception&amp; ex )
{
......@@ -219,7 +219,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
{
si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>;
ui.setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
ui->setValue( si, <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>, getId() );
}
}
catch( Exception&amp; ex )
......@@ -237,7 +237,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
{
si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>;
ui.setValue( si,<xsl:value-of select="$setval"/>, getId() );
ui->setValue( si,<xsl:value-of select="$setval"/>, getId() );
}
}
catch( Exception&amp; ex )
......@@ -254,7 +254,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
{
si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>;
ui.setValue( si,(long)m_<xsl:value-of select="@name"/>, getId() );
ui->setValue( si,(long)m_<xsl:value-of select="@name"/>, getId() );
}
}
catch( Exception&amp; ex )
......
......@@ -101,7 +101,7 @@
</xsl:when>
<xsl:when test="$GENTYPE='U'">
si.id = mid_<xsl:value-of select="../../@name"/>;
ui.setValue( si,( m_<xsl:value-of select="../../@name"/> ? 1:0), getId() );
ui->setValue( si,( m_<xsl:value-of select="../../@name"/> ? 1:0), getId() );
</xsl:when>
<xsl:when test="$GENTYPE='A'">
if( _code == mid_<xsl:value-of select="../../@name"/> )
......@@ -112,7 +112,7 @@
{
// сохраняем сразу...
si.id = mid_<xsl:value-of select="../../@name"/>;
ui.setValue( si,(m_<xsl:value-of select="../../@name"/> ? 1:0), getId() );
ui->setValue( si,(m_<xsl:value-of select="../../@name"/> ? 1:0), getId() );
return true;
}
catch(...){}
......@@ -126,7 +126,7 @@
try
{
si.id = mid_<xsl:value-of select="../../@name"/>;
ui.setValue( si,0,getId() );
ui->setValue( si,0,getId() );
}
catch( UniSetTypes::Exception&amp; ex )
{
......@@ -387,7 +387,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
&lt;&lt; wait_msec &lt;&lt; " msec"
&lt;&lt; " testID=" &lt;&lt; _testID &lt;&lt; endl;
if( !ui.waitReady(_testID,wait_msec) )
if( !ui->waitReady(_testID,wait_msec) )
{
ostringstream err;
err &lt;&lt; myname
......@@ -404,7 +404,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
<xsl:if test="normalize-space($TESTMODE)!=''">
if( idTestMode_S != DefaultObjectId )
{
if( !ui.waitWorking(idTestMode_S,wait_msec) )
if( !ui->waitWorking(idTestMode_S,wait_msec) )
{
ostringstream err;
err &lt;&lt; myname
......@@ -749,8 +749,8 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateValues()
{
// Опрашиваем все входы...
<xsl:if test="normalize-space($TESTMODE)!=''">
in_TestMode_S = (idTestMode_S!=DefaultObjectId) ? ui.getValue(idTestMode_S):false;
in_LocalTestMode_S = (idLocalTestMode_S!=DefaultObjectId) ? ui.getValue(idLocalTestMode_S):false;
in_TestMode_S = (idTestMode_S!=DefaultObjectId) ? ui->getValue(idTestMode_S):false;
in_LocalTestMode_S = (idLocalTestMode_S!=DefaultObjectId) ? ui->getValue(idLocalTestMode_S):false;
</xsl:if>
<xsl:for-each select="//smap/item">
<xsl:choose>
......@@ -806,7 +806,7 @@ bool <xsl:value-of select="$CLASSNAME"/>_SK::alarm( UniSetTypes::ObjectId _code,
// сохраняем сразу...
si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>;
ui.setValue( si,m_<xsl:value-of select="@name"/>,getId() );
ui->setValue( si,m_<xsl:value-of select="@name"/>,getId() );
return true;
}
catch(...){}
......@@ -829,7 +829,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::resetMsg()
{
si.id = <xsl:value-of select="@name"/>;
si.node = node_<xsl:value-of select="@name"/>;
ui.setValue( si, 0, getId() );
ui->setValue( si, 0, getId() );
}
catch( UniSetTypes::Exception&amp; ex )
{
......@@ -998,8 +998,8 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
void <xsl:value-of select="$CLASSNAME"/>_SK::updateValues()
{
<xsl:if test="normalize-space($TESTMODE)!=''">
in_TestMode_S = (idTestMode_S!=DefaultObjectId) ? ui.getValue(idTestMode_S):false;
in_LocalTestMode_S = (idLocalTestMode_S!=DefaultObjectId) ? ui.getValue(idLocalTestMode_S):false;
in_TestMode_S = (idTestMode_S!=DefaultObjectId) ? ui->getValue(idTestMode_S):false;
in_LocalTestMode_S = (idLocalTestMode_S!=DefaultObjectId) ? ui->getValue(idLocalTestMode_S):false;
</xsl:if>
// Опрашиваем все входы...
<xsl:for-each select="//sensors/item/consumers/consumer">
......
%def_enable doc
%def_enable docs
%def_enable mysql
%def_enable sqlite
%def_enable python
......@@ -12,7 +12,7 @@
Name: libuniset2
Version: 2.0
Release: alt10
Release: alt11
Summary: UniSet - library for building distributed industrial control systems
......@@ -54,7 +54,7 @@ BuildRequires(pre): rpm-build-python
# add_findprov_lib_path %python_sitelibdir/%oname
%endif
%if_enabled doc
%if_enabled docs
BuildRequires: doxygen
%endif
......@@ -108,15 +108,15 @@ Obsoletes: %oname-utils
%description utils
UniSet utilities
%if_enabled doc
%if_enabled docs
%package doc
%package docs
Group: Development/C++
Summary: Documentations for developing with UniSet
Requires: %name = %version-%release
BuildArch: noarch
%description doc
%description docs
Documentations for developing with UniSet
%endif
......@@ -241,7 +241,7 @@ SharedMemoryPlus extension ('all in one') for libuniset
%build
%autoreconf
%configure %{subst_enable doc} %{subst_enable mysql} %{subst_enable sqlite} %{subst_enable python} %{subst_enable rrd} %{subst_enable io} %{subst_enable logicproc} %{subst_enable tests}
%configure %{subst_enable docs} %{subst_enable mysql} %{subst_enable sqlite} %{subst_enable python} %{subst_enable rrd} %{subst_enable io} %{subst_enable logicproc} %{subst_enable tests}
%make
%install
......@@ -323,8 +323,8 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%endif
%if_enabled doc
%files doc
%if_enabled docs
%files docs
%_docdir/%oname
%endif
......@@ -406,6 +406,11 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet2.pc
%changelog
* Sat Jan 17 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt11
- refactoring "exit process"
- fixed bug in specfile: --enable-doc --> --enable-docs
- transition to use shared_ptr wherever possible
* Mon Nov 24 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt10
- use shared_ptr
......
......@@ -165,13 +165,13 @@ AM_CONDITIONAL(DISABLE_PYTHON, test ${buildpython} = false)
# check Doxygen
DOXYGEN=""
doc=false
docs=false
dox=
AC_MSG_CHECKING([Generate docs])
AC_ARG_ENABLE(docs,AC_HELP_STRING([--enable-docs], [enable build docs]),
[ if test $enableval = yes; then doc=true; else doc=false; fi],[ doc=false; ])
[ if test $enableval = yes; then docs=true; else docs=false; fi],[ docs=false; ])
if test ${doc} = true; then
if test ${docs} = true; then
AC_MSG_RESULT([yes])
AC_PATH_PROG([DOXYGEN], [doxygen])
test "x$DOXYGEN" = "x" && AC_MSG_WARN([*** Doxygen not found])
......
......@@ -31,7 +31,6 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
iomap(100),
maxItem(0),
filterT(0),
shm(0),
myid(id),
prefix(prefix_),
blink_state(true),
......@@ -172,7 +171,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
dinfo << myname << "(init): testMode_as='" << testmode << "'" << endl;
}
shm = new SMInterface(icID,&ui,myid,ic);
shm = make_shared<SMInterface>(icID,ui,myid,ic);
// определяем фильтр
s_field = conf->getArgParam("--"+prefix+"-s-filter-field");
......@@ -247,8 +246,6 @@ IOControl::~IOControl()
//
for( unsigned int i=0; i<cards.size(); i++ )
delete cards[i];
delete shm;
}
// --------------------------------------------------------------------------------
......
......@@ -3,6 +3,7 @@
#define IOControl_H_
// -----------------------------------------------------------------------------
#include <vector>
#include <memory>
#include <deque>
#include <string>
#include "UniXML.h"
......@@ -335,8 +336,7 @@ class IOControl:
std::string s_field;
std::string s_fvalue;
SMInterface* shm;
UInterface ui;
std::shared_ptr<SMInterface> shm;
UniSetTypes::ObjectId myid;
std::string prefix;
......
......@@ -9,12 +9,12 @@ using namespace UniSetExtensions;
PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId objId,
UniSetTypes::ObjectId shmID, const std::shared_ptr<SharedMemory> ic, const std::string& prefix ):
UniSetObject_LT(objId),
shm(0)
shm(nullptr)
{
auto conf = uniset_conf();
logname = myname;
shm = new SMInterface(shmID,&(UniSetObject_LT::ui),objId,ic);
shm = make_shared<SMInterface>(shmID,UniSetObject_LT::ui,objId,ic);
build(lfile);
// ********** HEARTBEAT *************
......@@ -42,7 +42,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
PassiveLProcessor::~PassiveLProcessor()
{
delete shm;
}
// -------------------------------------------------------------------------
void PassiveLProcessor::step()
......
......@@ -2,6 +2,7 @@
#define PassiveLProcessor_H_
// --------------------------------------------------------------------------
#include <map>
#include <memory>
#include "UniSetTypes.h"
#include "UniSetObject_LT.h"
#include "Extensions.h"
......@@ -44,7 +45,7 @@ class PassiveLProcessor:
void initIterators();
virtual bool activateObject() override;
SMInterface* shm;
std::shared_ptr<SMInterface> shm;
private:
PassiveTimer ptHeartBeat;
......
......@@ -15,7 +15,6 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId
const std::shared_ptr<SharedMemory> ic, const std::string& prefix ):
UniSetObject_LT(objId),
allInitOK(false),
shm(0),
initPause(0),
force(false),
force_out(false),
......@@ -43,7 +42,7 @@ pollActivated(false)
if( cnode == NULL )
throw UniSetTypes::SystemError("(MBExchange): Not found node <" + conf_name + " ...> for " + myname );
shm = new SMInterface(shmId,&ui,objId,ic);
shm = make_shared<SMInterface>(shmId,ui,objId,ic);
UniXML::iterator it(cnode);
......@@ -189,7 +188,6 @@ MBExchange::~MBExchange()
}
mb.reset();
delete shm;
}
// -----------------------------------------------------------------------------
void MBExchange::waitSMReady()
......
......@@ -291,7 +291,7 @@ class MBExchange:
std::string s_field;
std::string s_fvalue;
SMInterface* shm;
std::shared_ptr<SMInterface> shm;
bool initPause;
UniSetTypes::uniset_rwmutex mutex_start;
......
......@@ -13,8 +13,6 @@ using namespace ModbusRTU;
// -----------------------------------------------------------------------------
MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, const std::shared_ptr<SharedMemory> ic, const string& prefix ):
UniSetObject_LT(objId),
mbslot(0),
shm(0),
initPause(0),
test_id(DefaultObjectId),
askcount_id(DefaultObjectId),
......@@ -40,7 +38,7 @@ prefix(prefix)
if( cnode == NULL )
throw UniSetTypes::SystemError("(MBSlave): Not found conf-node for " + myname );
shm = new SMInterface(shmId,&ui,objId,ic);
shm = make_shared<SMInterface>(shmId,ui,objId,ic);
UniXML::iterator it(cnode);
......@@ -89,15 +87,15 @@ prefix(prefix)
bool use485F = conf->getArgInt("--" + prefix + "-use485F",it.getProp("use485F"));
bool transmitCtl = conf->getArgInt("--" + prefix + "-transmit-ctl",it.getProp("transmitCtl"));
ModbusRTUSlaveSlot* rs = new ModbusRTUSlaveSlot(dev,use485F,transmitCtl);
auto rs = make_shared<ModbusRTUSlaveSlot>(dev,use485F,transmitCtl);
rs->setSpeed(speed);
rs->setRecvTimeout(2000);
rs->setAfterSendPause(aftersend_pause);
rs->setReplyTimeout(reply_tout);
rs->setLog(dlog);
mbslot = rs;
thr = new ThreadCreator<MBSlave>(this,&MBSlave::execute_rtu);
mbslot = std::static_pointer_cast<ModbusServerSlot>(rs);
thr = make_shared< ThreadCreator<MBSlave> >(this,&MBSlave::execute_rtu);
thr->setFinalAction(this,&MBSlave::finalThread);
dinfo << myname << "(init): type=RTU myaddr=" << ModbusRTU::addr2str(addr)
<< " dev=" << dev << " speed=" << speed << endl;
......@@ -114,13 +112,13 @@ prefix(prefix)
<< " inet=" << iaddr << " port=" << port << endl;
ost::InetAddress ia(iaddr.c_str());
ModbusTCPServerSlot* mbtcp = new ModbusTCPServerSlot(ia,port);
auto mbtcp = make_shared<ModbusTCPServerSlot>(ia,port);
mbtcp->setAfterSendPause(aftersend_pause);
mbtcp->setReplyTimeout(reply_tout);
mbslot = mbtcp;
thr = new ThreadCreator<MBSlave>(this,&MBSlave::execute_tcp);
mbslot = mbslot = std::static_pointer_cast<ModbusServerSlot>(mbtcp);
thr = make_shared< ThreadCreator<MBSlave> >(this,&MBSlave::execute_tcp);
thr->setFinalAction(this,&MBSlave::finalThread);
dinfo << myname << "(init): init TCP connection ok. " << " inet=" << iaddr << " port=" << port << endl;
......@@ -364,16 +362,11 @@ prefix(prefix)
MBSlave::~MBSlave()
{
cancelled = true;
if( thr && thr->isRunning() )
{
thr->stop();
// thr->join();
}
delete thr;
delete mbslot;
delete shm;
}
// -----------------------------------------------------------------------------
void MBSlave::finalThread()
......@@ -402,7 +395,7 @@ void MBSlave::waitSMReady()
// -----------------------------------------------------------------------------
void MBSlave::execute_rtu()
{
ModbusRTUSlaveSlot* rscomm = dynamic_cast<ModbusRTUSlaveSlot*>(mbslot);
auto rscomm = dynamic_pointer_cast<ModbusRTUSlaveSlot>(mbslot);
ModbusRTU::mbErrCode prev = erNoError;
......@@ -483,7 +476,7 @@ void MBSlave::execute_rtu()
// -------------------------------------------------------------------------
void MBSlave::execute_tcp()
{
ModbusTCPServerSlot* sslot = dynamic_cast<ModbusTCPServerSlot*>(mbslot);
auto sslot = dynamic_pointer_cast<ModbusTCPServerSlot>(mbslot);
ModbusRTU::mbErrCode prev = erNoError;
......
......@@ -4,6 +4,7 @@
// -----------------------------------------------------------------------------
#include <ostream>
#include <string>
#include <memory>
#include <map>
#include <vector>
#include "UniSetObject_LT.h"
......@@ -365,14 +366,14 @@ class MBSlave:
typedef std::map<ModbusRTU::ModbusData,IOProperty> IOMap;
IOMap iomap; /*!< список входов/выходов */
ModbusServerSlot* mbslot;
std::shared_ptr<ModbusServerSlot> mbslot;
ModbusRTU::ModbusAddr addr; /*!< адрес данного узла */
xmlNode* cnode;
std::string s_field;
std::string s_fvalue;
SMInterface* shm;
std::shared_ptr<SMInterface> shm;
virtual void sysCommand( const UniSetTypes::SystemMessage *msg ) override;
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override;
......@@ -407,7 +408,7 @@ class MBSlave:
MBSlave();
bool initPause;
UniSetTypes::uniset_rwmutex mutex_start;
ThreadCreator<MBSlave>* thr;
std::shared_ptr< ThreadCreator<MBSlave> > thr;
PassiveTimer ptHeartBeat;
UniSetTypes::ObjectId sidHeartBeat;
......
......@@ -136,7 +136,7 @@ std::shared_ptr<MBTCPMultiSlave> MBTCPMultiSlave::init_mbslave( int argc, const
// -----------------------------------------------------------------------------
void MBTCPMultiSlave::execute_tcp()
{
ModbusTCPServerSlot* sslot = dynamic_cast<ModbusTCPServerSlot*>(mbslot);
auto sslot = dynamic_pointer_cast<ModbusTCPServerSlot>(mbslot);
if( !sslot )
{
......@@ -309,7 +309,7 @@ bool MBTCPMultiSlave::deactivateObject()
{
if( mbslot )
{
ModbusTCPServerSlot* sslot = dynamic_cast<ModbusTCPServerSlot*>(mbslot);
auto sslot = dynamic_pointer_cast<ModbusTCPServerSlot>(mbslot);
if( sslot )
sslot->sigterm(SIGTERM);
}
......@@ -321,7 +321,7 @@ void MBTCPMultiSlave::sigterm( int signo )
{
if( mbslot )
{
ModbusTCPServerSlot* sslot = dynamic_cast<ModbusTCPServerSlot*>(mbslot);
auto sslot = dynamic_pointer_cast<ModbusTCPServerSlot>(mbslot);
if( sslot )
sslot->sigterm(signo);
}
......
......@@ -60,7 +60,7 @@ class MBTCPMultiSlave:
UniSetTypes::ObjectId askcount_s;
IOController::IOStateList::iterator askcount_it;
inline void initIterators( SMInterface* shm )
inline void initIterators( const std::shared_ptr<SMInterface>& shm )
{
shm->initIterator( respond_it );
shm->initIterator( askcount_it );
......
......@@ -16,7 +16,7 @@ RRDServer::RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::
UObject_SK(objId,cnode),
prefix(prefix)
{
shm = make_shared<SMInterface>(shmId,&ui,objId,ic);
shm = make_shared<SMInterface>(shmId,ui,objId,ic);
mylog = log;
UniXML::iterator it(cnode);
......
......@@ -9,12 +9,11 @@ using namespace UniSetExtensions;
SMViewer::SMViewer( UniSetTypes::ObjectId shmID ):
SViewer(uniset_conf()->getControllersSection(),true)
{
shm = new SMInterface(shmID,&ui,DefaultObjectId,0);
shm = make_shared<SMInterface>(shmID,ui,DefaultObjectId);
}
// --------------------------------------------------------------------------
SMViewer::~SMViewer()
{
delete shm;
}
// --------------------------------------------------------------------------
void SMViewer::run()
......
......@@ -3,6 +3,7 @@
#define _SMVIEWER_H
//--------------------------------------------------------------------------------
#include <string>
#include <memory>
#include "SViewer.h"
#include "SMInterface.h"
//--------------------------------------------------------------------------------
......@@ -17,9 +18,8 @@ class SMViewer:
protected:
std::shared_ptr<SMInterface> shm;
private:
SMInterface* shm;
UInterface ui;
};
// --------------------------------------------------------------------------
#endif
......
......@@ -215,7 +215,7 @@ void SharedMemory::askSensors( UniversalIO::UIOCommand cmd )
{
try
{
ui.askState( SID, cmd);
ui->askState( SID, cmd);
}
catch(Exception& ex)
{
......@@ -490,7 +490,7 @@ void SharedMemory::sendEvent( UniSetTypes::SystemMessage& sm )
{
try
{
ui.send(it, std::move(sm.transport_msg()) );
ui->send(it, std::move(sm.transport_msg()) );
ok = true;
break;
}
......
......@@ -9,12 +9,9 @@ using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, const std::shared_ptr<SharedMemory> ic, const std::string& prefix ):
UniSetObject_LT(objId),
shm(0),
initPause(0),
activated(false),
no_sender(false),
sender(0),
sender2(0)
no_sender(false)
{
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(UNetExchange): objId=-1?!! Use --" + prefix +"-unet-name" );
......@@ -25,7 +22,7 @@ sender2(0)
if( cnode == NULL )
throw UniSetTypes::SystemError("(UNetExchange): Not found conf-node for " + myname );
shm = make_shared<SMInterface>(shmId,&ui,objId,ic);
shm = make_shared<SMInterface>(shmId,ui,objId,ic);
UniXML::iterator it(cnode);
......@@ -122,7 +119,7 @@ sender2(0)
}
dinfo << myname << "(init): init sender.. my node " << n_it.getProp("name") << endl;
sender = new UNetSender(h,p,shm,s_field,s_fvalue);
sender = make_shared<UNetSender>(h,p,shm,s_field,s_fvalue);
sender->setSendPause(sendpause);
try
......@@ -131,7 +128,7 @@ sender2(0)
if( !h2.empty() )
{
dinfo << myname << "(init): init sender2.. my node " << n_it.getProp("name") << endl;
sender2 = new UNetSender(h2,p2,shm,s_field,s_fvalue);
sender2 = make_shared<UNetSender>(h2,p2,shm,s_field,s_fvalue);
sender2->setSendPause(sendpause);
}
}
......@@ -242,7 +239,7 @@ sender2(0)
dinfo << myname << "(init): (node='" << n << "') add receiver "
<< h2 << ":" << p2 << endl;
UNetReceiver* r = new UNetReceiver(h,p,shm);
auto r = make_shared<UNetReceiver>(h,p,shm);
// на всякий принудительно разблокируем,
// чтобы не зависеть от значения по умолчанию
......@@ -259,7 +256,7 @@ sender2(0)
r->setLostPacketsID(lp_id);
r->connectEvent( sigc::mem_fun(this, &UNetExchange::receiverEvent) );
UNetReceiver* r2 = 0;
shared_ptr<UNetReceiver> r2(nullptr);
try
{
if( !h2.empty() ) // создаём читателя впо второму каналу
......@@ -267,7 +264,7 @@ sender2(0)
dinfo << myname << "(init): (node='" << n << "') add reserv receiver "
<< h2 << ":" << p2 << endl;
r2 = new UNetReceiver(h2,p2,shm);
r2 = make_shared<UNetReceiver>(h2,p2,shm);
// т.к. это резервный канал (по началу блокируем его)
r2->setLockUpdate(true);
......@@ -339,16 +336,6 @@ sender2(0)
// -----------------------------------------------------------------------------
UNetExchange::~UNetExchange()
{
for( auto &it: recvlist )
{
if( it.r1 )
delete it.r1;
if( it.r2 )
delete it.r2;
}
delete sender;
delete sender2;
}
// -----------------------------------------------------------------------------
bool UNetExchange::checkExistUNetHost( const std::string& addr, ost::tpport_t port )
......@@ -680,7 +667,7 @@ std::shared_ptr<UNetExchange> UNetExchange::init_unetexchange( int argc, const c
return make_shared<UNetExchange>(ID,icID,ic,prefix);
}
// -----------------------------------------------------------------------------
void UNetExchange::receiverEvent( UNetReceiver* r, UNetReceiver::Event ev )
void UNetExchange::receiverEvent( const shared_ptr<UNetReceiver>& r, UNetReceiver::Event ev )
{
// пока, что другие события нас не интересуют
if( ev != UNetReceiver::evTimeout )
......
......@@ -106,7 +106,7 @@ class UNetExchange:
void timerInfo( const UniSetTypes::TimerMessage *tm ) override;
void askSensors( UniversalIO::UIOCommand cmd );
void waitSMReady();
void receiverEvent( UNetReceiver* r, UNetReceiver::Event ev );
void receiverEvent( const std::shared_ptr<UNetReceiver>& r, UNetReceiver::Event ev );
virtual bool activateObject();
......@@ -139,21 +139,21 @@ class UNetExchange:
struct ReceiverInfo
{
ReceiverInfo():r1(0),r2(0),
ReceiverInfo():r1(nullptr),r2(nullptr),
sidRespond(UniSetTypes::DefaultObjectId),
respondInvert(false),
sidLostPackets(UniSetTypes::DefaultObjectId)
{}
ReceiverInfo(UNetReceiver* _r1, UNetReceiver* _r2 ):
ReceiverInfo( const std::shared_ptr<UNetReceiver>& _r1, const std::shared_ptr<UNetReceiver>& _r2 ):
r1(_r1),r2(_r2),
sidRespond(UniSetTypes::DefaultObjectId),
respondInvert(false),
sidLostPackets(UniSetTypes::DefaultObjectId)
{}
UNetReceiver* r1; /*!< приём по первому каналу */
UNetReceiver* r2; /*!< приём по второму каналу */
std::shared_ptr<UNetReceiver> r1; /*!< приём по первому каналу */
std::shared_ptr<UNetReceiver> r2; /*!< приём по второму каналу */
void step( const std::shared_ptr<SMInterface> shm, const std::string& myname );
......@@ -184,8 +184,8 @@ class UNetExchange:
ReceiverList recvlist;
bool no_sender; /*!< флаг отключения посылки сообщений (создания потока для посылки)*/
UNetSender* sender;
UNetSender* sender2;
std::shared_ptr<UNetSender> sender;
std::shared_ptr<UNetSender> sender2;
};
// -----------------------------------------------------------------------------
#endif // UNetExchange_H_
......
......@@ -19,11 +19,10 @@ bool UNetReceiver::PacketCompare::operator()(const UniSetUDP::UDPMessage& lhs,
}
*/
// ------------------------------------------------------------------------------------------
UNetReceiver::UNetReceiver( const std::string& s_host, const ost::tpport_t port, const std::shared_ptr<SMInterface> smi ):
UNetReceiver::UNetReceiver( const std::string& s_host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi ):
shm(smi),
recvpause(10),
updatepause(100),
udp(0),
recvTimeout(5000),
prepareTime(2000),
lostTimeout(5000),
......@@ -32,8 +31,6 @@ sidRespond(UniSetTypes::DefaultObjectId),
respondInvert(false),
sidLostPackets(UniSetTypes::DefaultObjectId),
activated(false),
r_thr(0),
u_thr(0),
pnum(0),
maxDifferens(1000),
waitClean(false),
......@@ -58,7 +55,7 @@ a_cache_init_ok(false)
// addr = ci.getBroadcast();
// cerr << "****************** addr: " << addr << endl;
addr = s_host.c_str();
udp = new ost::UDPDuplex(addr,port);
udp = make_shared<ost::UDPDuplex>(addr,port);
}
catch( std::exception& e )
{
......@@ -75,8 +72,8 @@ a_cache_init_ok(false)
throw SystemError(s.str());
}
r_thr = new ThreadCreator<UNetReceiver>(this, &UNetReceiver::receive);
u_thr = new ThreadCreator<UNetReceiver>(this, &UNetReceiver::update);
r_thr = make_shared< ThreadCreator<UNetReceiver> >(this, &UNetReceiver::receive);
u_thr = make_shared< ThreadCreator<UNetReceiver> >(this, &UNetReceiver::update);
ptRecvTimeout.setTiming(recvTimeout);
ptPrepare.setTiming(prepareTime);
......@@ -84,9 +81,6 @@ a_cache_init_ok(false)
// -----------------------------------------------------------------------------
UNetReceiver::~UNetReceiver()
{
delete r_thr;
delete u_thr;
delete udp;
}
// -----------------------------------------------------------------------------
void UNetReceiver::setReceiveTimeout( timeout_t msec )
......@@ -405,9 +399,9 @@ void UNetReceiver::receive()
if( ptPrepare.checkTime() && trTimeout.change(tout) )
{
if( tout )
slEvent(this,evTimeout);
slEvent(shared_from_this(),evTimeout);
else
slEvent(this,evOK);
slEvent(shared_from_this(),evOK);
}
msleep(recvpause);
......
......@@ -2,6 +2,7 @@
#define UNetReceiver_H_
// -----------------------------------------------------------------------------
#include <ostream>
#include <memory>
#include <string>
#include <queue>
#include <cc++/socket.h>
......@@ -49,10 +50,11 @@
* ОПТИМИЗАЦИЯ N1: см. UNetSender.h. Если номер последнего принятого пакета не менялся.. не обрабатываем..
*/
// -----------------------------------------------------------------------------
class UNetReceiver
class UNetReceiver:
public std::enable_shared_from_this<UNetReceiver>
{
public:
UNetReceiver( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface> smi );
UNetReceiver( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi );
~UNetReceiver();
void start();
......@@ -95,7 +97,7 @@ class UNetReceiver
evTimeout /*!< потеря связи */
};
typedef sigc::slot<void,UNetReceiver*,Event> EventSlot;
typedef sigc::slot<void,const std::shared_ptr<UNetReceiver>&,Event> EventSlot;
void connectEvent( EventSlot sl );
protected:
......@@ -114,7 +116,7 @@ class UNetReceiver
int recvpause; /*!< пауза меджду приёмами пакетов, [мсек] */
int updatepause; /*!< переодичность обновления данных в SM, [мсек] */
ost::UDPReceive* udp;
std::shared_ptr<ost::UDPReceive> udp;
ost::IPV4Address addr;
ost::tpport_t port;
std::string myname;
......@@ -136,8 +138,8 @@ class UNetReceiver
std::atomic_bool activated;
ThreadCreator<UNetReceiver>* r_thr; // receive thread
ThreadCreator<UNetReceiver>* u_thr; // update thread
std::shared_ptr< ThreadCreator<UNetReceiver> > r_thr; // receive thread
std::shared_ptr< ThreadCreator<UNetReceiver> > u_thr; // update thread
// функция определения приоритетного сообщения для обработки
struct PacketCompare:
......
......@@ -8,7 +8,7 @@ using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
UNetSender::UNetSender( const std::string& s_host, const ost::tpport_t port, const std::shared_ptr<SMInterface> smi,
UNetSender::UNetSender( const std::string& s_host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi,
const std::string& s_f, const std::string& s_val ):
s_field(s_f),
s_fvalue(s_val),
......@@ -19,8 +19,7 @@ activated(false),
dlist(100),
maxItem(0),
packetnum(1),
lastcrc(0),
s_thr(0)
lastcrc(0)
{
{
......@@ -41,7 +40,7 @@ s_thr(0)
try
{
addr = s_host.c_str();
udp = new ost::UDPBroadcast(addr,port);
udp = make_shared<ost::UDPBroadcast>(addr,port);
}
catch( std::exception& e )
{
......@@ -58,7 +57,7 @@ s_thr(0)
throw SystemError(s.str());
}
s_thr = new ThreadCreator<UNetSender>(this, &UNetSender::send);
s_thr = make_shared< ThreadCreator<UNetSender> >(this, &UNetSender::send);
// -------------------------------
if( shm->isLocalwork() )
......@@ -89,8 +88,6 @@ s_thr(0)
// -----------------------------------------------------------------------------
UNetSender::~UNetSender()
{
delete s_thr;
delete udp;
}
// -----------------------------------------------------------------------------
void UNetSender::updateFromSM()
......
......@@ -21,7 +21,7 @@
class UNetSender
{
public:
UNetSender( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface> smi,
UNetSender( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi,
const std::string& s_field="", const std::string& s_fvalue="" );
~UNetSender();
......@@ -81,7 +81,7 @@ class UNetSender
private:
UNetSender();
ost::UDPBroadcast* udp;
std::shared_ptr<ost::UDPBroadcast> udp;
ost::IPV4Address addr;
ost::tpport_t port;
std::string s_host;
......@@ -98,7 +98,7 @@ class UNetSender
unsigned short lastcrc;
UniSetUDP::UDPPacket s_msg;
ThreadCreator<UNetSender>* s_thr; // send thread
std::shared_ptr< ThreadCreator<UNetSender> > s_thr; // send thread
};
// -----------------------------------------------------------------------------
#endif // UNetSender_H_
......
......@@ -20,7 +20,6 @@ UniExchange::NetNodeInfo::NetNodeInfo():
UniExchange::UniExchange( UniSetTypes::ObjectId id, UniSetTypes::ObjectId shmID,
const std::shared_ptr<SharedMemory> ic, const std::string& prefix ):
IOController(id),
shm(0),
polltime(200),
mymap(1),
maxIndex(0),
......@@ -32,7 +31,7 @@ smReadyTimeout(15000)
if( cnode == NULL )
throw UniSetTypes::SystemError("(UniExchange): Not found conf-node for " + myname );
shm = new SMInterface(shmID,&ui,id,ic);
shm = make_shared<SMInterface>(shmID,ui,id,ic);
UniXML::iterator it(cnode);
......@@ -114,12 +113,9 @@ smReadyTimeout(15000)
}
// -----------------------------------------------------------------------------
UniExchange::~UniExchange()
{
delete shm;
}
// -----------------------------------------------------------------------------
void UniExchange::execute()
{
......@@ -154,7 +150,7 @@ void UniExchange::execute()
{
dinfo << myname << ": connect to id=" << it.id << " node=" << it.node << endl;
IOController_i::ShortMapSeq_var sseq = ui.getSensors( it.id, it.node );
IOController_i::ShortMapSeq_var sseq = ui->getSensors( it.id, it.node );
ok = true;
dinfo << myname << " update sensors from id=" << it.id << " node=" << it.node << endl;
......@@ -197,7 +193,7 @@ void UniExchange::execute()
}
}
// -----------------------------------------------------------------------------
void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, SMInterface* shm )
void UniExchange::NetNodeInfo::update( IOController_i::ShortMapSeq_var& map, const std::shared_ptr<SMInterface>& shm )
{
bool reinit = false;
if( smap.size() != map->length() )
......
......@@ -3,6 +3,7 @@
#define UniExchange_H_
// -----------------------------------------------------------------------------
#include <list>
#include <memory>
#include "UniXML.h"
#include "IOController.h"
#include "SMInterface.h"
......@@ -60,7 +61,7 @@ class UniExchange:
xmlNode* cnode;
std::string s_field;
std::string s_fvalue;
SMInterface* shm;
std::shared_ptr<SMInterface> shm;
struct SInfo
{
......@@ -105,7 +106,7 @@ class UniExchange:
IOController::IOStateList::iterator conn_it;
SList smap;
void update(IOController_i::ShortMapSeq_var& map, SMInterface* shm );
void update(IOController_i::ShortMapSeq_var& map, const std::shared_ptr<SMInterface>& shm );
};
typedef std::list<NetNodeInfo> NetNodeList;
......
......@@ -3,6 +3,7 @@
#define IOBase_H_
// -----------------------------------------------------------------------------
#include <string>
#include <memory>
#include "PassiveTimer.h"
#include "Trigger.h"
#include "Mutex.h"
......@@ -70,7 +71,7 @@ struct IOBase
bool check_on_delay( bool val ); /*!< реализация задержки на включение */
bool check_off_delay( bool val ); /*!< реализация задержки на отключение */
bool check_front( bool val ); /*!< реализация срабатывания по фронту сигнала */
bool check_depend( SMInterface* shm ); /*!< проверка разрешения(зависимости) от другого датчика */
bool check_depend( const std::shared_ptr<SMInterface>& shm ); /*!< проверка разрешения(зависимости) от другого датчика */
IOController_i::SensorInfo si;
UniversalIO::IOType stype; /*!< тип канала (DI,DO,AI,AO) */
......@@ -143,18 +144,18 @@ struct IOBase
friend std::ostream& operator<<(std::ostream& os, IOBase& inf );
static void processingFasAI( IOBase* it, float new_val, SMInterface* shm, bool force );
static void processingAsAI( IOBase* it, long new_val, SMInterface* shm, bool force );
static void processingAsDI( IOBase* it, bool new_set, SMInterface* shm, bool force );
static long processingAsAO( IOBase* it, SMInterface* shm, bool force );
static float processingFasAO( IOBase* it, SMInterface* shm, bool force );
static bool processingAsDO( IOBase* it, SMInterface* shm, bool force );
static void processingThreshold( IOBase* it, SMInterface* shm, bool force );
static void processingFasAI( IOBase* it, float new_val, const std::shared_ptr<SMInterface>& shm, bool force );
static void processingAsAI( IOBase* it, long new_val, const std::shared_ptr<SMInterface>& shm, bool force );
static void processingAsDI( IOBase* it, bool new_set, const std::shared_ptr<SMInterface>& shm, bool force );
static long processingAsAO( IOBase* it, const std::shared_ptr<SMInterface>& shm, bool force );
static float processingFasAO( IOBase* it, const std::shared_ptr<SMInterface>& shm, bool force );
static bool processingAsDO( IOBase* it, const std::shared_ptr<SMInterface>& shm, bool force );
static void processingThreshold( IOBase* it, const std::shared_ptr<SMInterface>& shm, bool force );
/*! \param initPrefixOnly - TRUE - инициализировать только свойста с prefix (или брать значения по умолчанию).
FALSE - сперва искать свойство с prefix, если не найдено брать без prefix.
*/
static bool initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm,
static bool initItem( IOBase* b, UniXML::iterator& it, const std::shared_ptr<SMInterface>& shm,
const std::string& prefix, bool init_prefix_only,
DebugStream* dlog=0, std::string myname="",
int def_filtersize=0, float def_filterT=0.0,
......
......@@ -2,6 +2,7 @@
#define SMInterface_H_
//--------------------------------------------------------------------------
#include <string>
#include <memory>
#include "UniSetTypes.h"
#include "Mutex.h"
#include "IONotifyController.h"
......@@ -10,7 +11,7 @@ class SMInterface
{
public:
SMInterface( UniSetTypes::ObjectId _shmID, UInterface* ui,
SMInterface( UniSetTypes::ObjectId _shmID, const std::shared_ptr<UInterface>& ui,
UniSetTypes::ObjectId myid, const std::shared_ptr<IONotifyController> ic=nullptr );
~SMInterface();
......@@ -54,7 +55,7 @@ class SMInterface
protected:
const std::shared_ptr<IONotifyController> ic;
UInterface* ui;
const std::shared_ptr<UInterface> ui;
CORBA::Object_var oref;
UniSetTypes::ObjectId shmID;
UniSetTypes::ObjectId myid;
......
......@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-01-12+03:00
// generate timestamp: 2015-01-17+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
......@@ -21,24 +21,24 @@
#include "DebugStream.h"
// -----------------------------------------------------------------------------
class UObject_SK:
public UniSetObject,
public LT_Object
public UniSetObject,
public LT_Object
{
public:
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
UObject_SK();
virtual ~UObject_SK();
bool alarm( UniSetTypes::ObjectId sid, bool state );
long getValue( UniSetTypes::ObjectId sid );
void setValue( UniSetTypes::ObjectId sid, long value );
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
void updateValues();
void setMsg( UniSetTypes::ObjectId code, bool state );
DebugStream mylog;
void init_dlog( DebugStream& d );
public:
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
UObject_SK();
virtual ~UObject_SK();
bool alarm( UniSetTypes::ObjectId sid, bool state );
long getValue( UniSetTypes::ObjectId sid );
void setValue( UniSetTypes::ObjectId sid, long value );
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
void updateValues();
void setMsg( UniSetTypes::ObjectId code, bool state );
DebugStream mylog;
void init_dlog( DebugStream& d );
// "синтаксический сахар"..для логов
#define myinfo if( mylog.debugging(Debug::INFO) ) mylog
......@@ -55,91 +55,91 @@ class UObject_SK:
#define mylog9 if( mylog.debugging(Debug::LEVEL9) ) mylog
// Используемые идентификаторы
// Используемые идентификаторы сообщений
// Текущее значение
// --- public variables ---
// --- end of public variables ---
protected:
// --- protected variables ---
// ---- end of protected variables ----
virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual void testMode( bool state );
void updatePreviousValues();
void checkSensors();
void updateOutputs( bool force );
void preAskSensors( UniversalIO::UIOCommand cmd );
void preSensorInfo( const UniSetTypes::SensorMessage* sm );
void preTimerInfo( const UniSetTypes::TimerMessage* tm );
void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
void resetMsg();
Trigger trResetMsg;
PassiveTimer ptResetMsg;
int resetMsgTime;
// Выполнение очередного шага программы
virtual void step(){}
int sleep_msec; /*!< пауза между итерациями */
bool active;
UniSetTypes::ObjectId smTestID; /*!< идентификатор датчика для тестирования готовности SM */
// управление датчиком "сердцебиения"
PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */
UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */
int maxHeartBeat; /*! < сохраняемое значение */
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
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); }
int smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated;
int activateTimeout; /*!< время ожидания готовности UniSetObject к работе */
PassiveTimer ptStartUpTimeout; /*!< время на блокировку обработки WatchDog, если недавно был StartUp */
int askPause; /*!< пауза между неудачными попытками заказать датчики */
IOController_i::SensorInfo si;
bool forceOut; /*!< флаг принудительного обноления "выходов" */
private:
// --- private variables ---
// --- end of private variables ---
// предыдущее значение (для работы UpdateValue())
// Используемые идентификаторы сообщений
bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
// Используемые идентификаторы
// Используемые идентификаторы сообщений
// Текущее значение
// --- public variables ---
// --- end of public variables ---
protected:
// --- protected variables ---
// ---- end of protected variables ----
virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual void testMode( bool state );
void updatePreviousValues();
void checkSensors();
void updateOutputs( bool force );
void preAskSensors( UniversalIO::UIOCommand cmd );
void preSensorInfo( const UniSetTypes::SensorMessage* sm );
void preTimerInfo( const UniSetTypes::TimerMessage* tm );
void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
void resetMsg();
Trigger trResetMsg;
PassiveTimer ptResetMsg;
int resetMsgTime;
// Выполнение очередного шага программы
virtual void step(){}
int sleep_msec; /*!< пауза между итерациями */
bool active;
UniSetTypes::ObjectId smTestID; /*!< идентификатор датчика для тестирования готовности SM */
// управление датчиком "сердцебиения"
PassiveTimer ptHeartBeat; /*! < период "сердцебиения" */
UniSetTypes::ObjectId idHeartBeat; /*! < идентификатор датчика (AI) "сердцебиения" */
int maxHeartBeat; /*! < сохраняемое значение */
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
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); }
int smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated;
int activateTimeout; /*!< время ожидания готовности UniSetObject к работе */
PassiveTimer ptStartUpTimeout; /*!< время на блокировку обработки WatchDog, если недавно был StartUp */
int askPause; /*!< пауза между неудачными попытками заказать датчики */
IOController_i::SensorInfo si;
bool forceOut; /*!< флаг принудительного обноления "выходов" */
private:
// --- private variables ---
// --- end of private variables ---
// предыдущее значение (для работы UpdateValue())
// Используемые идентификаторы сообщений
bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
};
// -----------------------------------------------------------------------------
......
......@@ -26,7 +26,7 @@ bool IOBase::check_channel_break( long val )
return ( val < breaklim );
}
// -----------------------------------------------------------------------------
bool IOBase::check_depend( SMInterface* shm )
bool IOBase::check_depend( const std::shared_ptr<SMInterface>& shm )
{
if( d_id == DefaultObjectId )
return true;
......@@ -142,7 +142,7 @@ bool IOBase::check_front( bool val )
return front_state;
}
// -----------------------------------------------------------------------------
void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force )
void IOBase::processingAsAI( IOBase* it, long val, const std::shared_ptr<SMInterface>& shm, bool force )
{
// проверка на обрыв
if( it->check_channel_break(val) )
......@@ -210,7 +210,7 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
}
}
// -----------------------------------------------------------------------------
void IOBase::processingFasAI( IOBase* it, float fval, SMInterface* shm, bool force )
void IOBase::processingFasAI( IOBase* it, float fval, const std::shared_ptr<SMInterface>& shm, bool force )
{
long val = lroundf(fval);
......@@ -268,7 +268,7 @@ void IOBase::processingFasAI( IOBase* it, float fval, SMInterface* shm, bool for
}
}
// -----------------------------------------------------------------------------
void IOBase::processingAsDI( IOBase* it, bool set, SMInterface* shm, bool force )
void IOBase::processingAsDI( IOBase* it, bool set, const std::shared_ptr<SMInterface>& shm, bool force )
{
// проверка зависимости
if( !it->check_depend(shm) )
......@@ -292,7 +292,7 @@ void IOBase::processingAsDI( IOBase* it, bool set, SMInterface* shm, bool force
}
}
// -----------------------------------------------------------------------------
long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
long IOBase::processingAsAO( IOBase* it, const std::shared_ptr<SMInterface>& shm, bool force )
{
// проверка зависимости
if( !it->check_depend(shm) )
......@@ -344,7 +344,7 @@ long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
return val;
}
// -----------------------------------------------------------------------------
bool IOBase::processingAsDO( IOBase* it, SMInterface* shm, bool force )
bool IOBase::processingAsDO( IOBase* it, const std::shared_ptr<SMInterface>& shm, bool force )
{
// проверка зависимости
if( !it->check_depend(shm) )
......@@ -360,7 +360,7 @@ bool IOBase::processingAsDO( IOBase* it, SMInterface* shm, bool force )
return set;
}
// -----------------------------------------------------------------------------
float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
float IOBase::processingFasAO( IOBase* it, const std::shared_ptr<SMInterface>& shm, bool force )
{
// проверка зависимости
if( !it->check_depend(shm) )
......@@ -415,7 +415,7 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
return val;
}
// -----------------------------------------------------------------------------
void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force )
void IOBase::processingThreshold( IOBase* it, const std::shared_ptr<SMInterface>& shm, bool force )
{
if( it->t_ai == DefaultObjectId )
return;
......@@ -475,7 +475,7 @@ int IOBase::initIntProp( UniXML::iterator& it, const std::string& prop, const st
return defval;
}
// -----------------------------------------------------------------------------
bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const std::string& prefix,
bool IOBase::initItem( IOBase* b, UniXML::iterator& it, const std::shared_ptr<SMInterface>& shm, const std::string& prefix,
bool init_prefix_only,
DebugStream* dlog, std::string myname,
int def_filtersize, float def_filterT, float def_lsparam,
......
......@@ -84,7 +84,7 @@ using namespace UniSetTypes;
} \
// --------------------------------------------------------------------------
SMInterface::SMInterface( UniSetTypes::ObjectId _shmID, UInterface* _ui,
SMInterface::SMInterface( UniSetTypes::ObjectId _shmID, const std::shared_ptr<UInterface>& _ui,
UniSetTypes::ObjectId _myid, const std::shared_ptr<IONotifyController> ic ):
ic(ic),
ui(_ui),
......
......@@ -138,7 +138,7 @@ void TestProc::test_undefined_state()
si.id = undef_c;
si.node = conf->getLocalNode();
cerr << myname << ": set undefined=" << undef << endl;
ui.setUndefinedState( si, undef, getId() );
ui->setUndefinedState( si, undef, getId() );
}
// -----------------------------------------------------------------------------
void TestProc::test_thresholds()
......@@ -158,12 +158,12 @@ void TestProc::test_thresholds()
{
setValue(t_set_c, 0);
UniSetTypes::ThresholdId tid = 100;
ui.askThreshold( t_set_c, tid, UniversalIO::UIONotify, 10, 20 );
ui->askThreshold( t_set_c, tid, UniversalIO::UIONotify, 10, 20 );
IONotifyController_i::ThresholdInfo ti = ui.getThresholdInfo(t_set_c,tid);
IONotifyController_i::ThresholdInfo ti = ui->getThresholdInfo(t_set_c,tid);
cerr << myname << ": ask OFF threshold: " << ( ti.state == IONotifyController_i::NormalThreshold ? "ok" : "FAIL" ) << endl;
setValue(t_set_c, 25);
ti = ui.getThresholdInfo(t_set_c,tid);
ti = ui->getThresholdInfo(t_set_c,tid);
cerr << myname << ": ask ON threshold: " << ( ti.state == IONotifyController_i::HiThreshold ? "ok" : "FAIL" ) << endl;
}
catch( Exception& ex )
......
......@@ -71,13 +71,13 @@ TEST_CASE("[IOBase]: Init from xml","[iobase][init][extensions]")
xmlNode* cnode = conf->getNode("iobasetest");
CHECK( cnode != NULL );
UniXML::iterator it(cnode);
UInterface ui;
auto ui = make_shared<UInterface>();
ObjectId shmID = conf->getControllerID("SharedMemory");
CHECK( shmID != DefaultObjectId );
SMInterface shm(shmID,&ui,DefaultObjectId);
auto shm = make_shared<SMInterface>(shmID,ui,DefaultObjectId);
IOBase ib;
IOBase::initItem(&ib,it,&shm,"",false);
IOBase::initItem(&ib,it,shm,"",false);
CHECK( ib.si.id == 1 );
CHECK( ib.si.node == conf->getLocalNode() );
CHECK( ib.defval == -10 );
......@@ -95,13 +95,13 @@ TEST_CASE("[IOBase]: Init from xml","[iobase][init][extensions]")
xmlNode* cnode = conf->getNode("iobasetest3");
CHECK( cnode != NULL );
UniXML::iterator it(cnode);
UInterface ui;
auto ui = make_shared<UInterface>();
ObjectId shmID = conf->getControllerID("SharedMemory");
CHECK( shmID != DefaultObjectId );
SMInterface shm(shmID,&ui,DefaultObjectId);
auto shm = make_shared<SMInterface>(shmID,ui,DefaultObjectId);
IOBase ib;
IOBase::initItem(&ib,it,&shm,"myprefix_",false);
IOBase::initItem(&ib,it,shm,"myprefix_",false);
CHECK( ib.si.id == 10 );
CHECK( ib.si.node == conf->getLocalNode() );
CHECK( ib.defval == 5 );
......
......@@ -10,15 +10,13 @@ using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
static std::shared_ptr<SMInterface> shared_shm;
static SMInterface* shm;
static std::shared_ptr<SMInterface> shm;
static void init_test()
{
shared_shm = smiInstance();
CHECK( shared_shm != nullptr );
shm = shared_shm.get();
shm = smiInstance();
CHECK( shm != nullptr );
}
// -----------------------------------------------------------------------------
static bool init_iobase( IOBase* ib, const std::string& sensor )
{
init_test();
......
......@@ -16,7 +16,7 @@ using namespace UniSetExtensions;
// --------------------------------------------------------------------------
static shared_ptr<SMInterface> smi;
static shared_ptr<SharedMemory> shm;
static UInterface* ui = nullptr;
static shared_ptr<UInterface> ui;
static ObjectId myID = 6000;
// --------------------------------------------------------------------------
shared_ptr<SharedMemory> shmInstance()
......@@ -35,7 +35,7 @@ shared_ptr<SMInterface> smiInstance()
throw SystemError("SharedMemory don`t initialize..");
if( ui == nullptr )
ui = new UInterface();
ui = make_shared<UInterface>();
smi = make_shared<SMInterface>(shm->getId(), ui, myID, shm );
}
......
......@@ -25,6 +25,7 @@
#define ProxyManager_H_
//---------------------------------------------------------------------------
#include <map>
#include <memory>
#include "UniSetObject.h"
//----------------------------------------------------------------------------
......@@ -45,7 +46,7 @@ class ProxyManager:
void attachObject( PassiveObject* po, UniSetTypes::ObjectId id );
void detachObject( UniSetTypes::ObjectId id );
UInterface* uin;
std::shared_ptr<UInterface> uin;
protected:
ProxyManager();
......
......@@ -26,6 +26,7 @@
#define _SVIEWER_H
//--------------------------------------------------------------------------------
#include <string>
#include <memory>
#include "IOController_i.hh"
#include "ObjectRepository.h"
#include "UInterface.h"
......@@ -55,10 +56,11 @@ class SViewer
void printInfo(UniSetTypes::ObjectId id, const std::string& sname, long value, const std::string& owner,
const std::string& txtname, const std::string& iotype);
std::shared_ptr<UInterface> ui;
private:
ObjectRepository rep;
UInterface::CacheOfResolve cache;
UInterface ui;
bool isShort;
};
......
......@@ -111,7 +111,7 @@ class UniSetObject:
/*! прервать ожидание сообщений */
void termWaiting();
UInterface ui; /*!< универсальный интерфейс для работы с другими процессами */
std::shared_ptr<UInterface> ui; /*!< универсальный интерфейс для работы с другими процессами */
std::string myname;
std::string section;
......
......@@ -39,7 +39,7 @@ ProxyManager::~ProxyManager()
ProxyManager::ProxyManager( UniSetTypes::ObjectId id ):
UniSetObject(id)
{
uin = &ui;
uin = ui;
}
......@@ -86,7 +86,7 @@ bool ProxyManager::activateObject()
<< " (pname=" << it.second->getName() << ") "
<< uniset_conf()->oind->getNameById(it.first) << endl;
ui.registered(it.first, getRef(),true);
ui->registered(it.first, getRef(),true);
break;
}
catch( UniSetTypes::ObjectNameAlready& ex )
......@@ -94,7 +94,7 @@ bool ProxyManager::activateObject()
ucrit << myname << "(registered): СПЕРВА РАЗРЕГИСТРИРУЮ (ObjectNameAlready)" << endl;
try
{
ui.unregister(it.first);
ui->unregister(it.first);
}
catch(Exception & ex)
{
......@@ -118,7 +118,7 @@ bool ProxyManager::deactivateObject()
{
try
{
ui.unregister(it->first);
ui->unregister(it->first);
}
catch(Exception& ex )
{
......
......@@ -45,7 +45,6 @@ using namespace UniSetTypes;
// ------------------------------------------------------------------------------------------
UniSetObject::UniSetObject():
ui(UniSetTypes::DefaultObjectId),
msgpid(0),
reg(false),
active(0),
......@@ -57,6 +56,8 @@ MaxCountRemoveOfMessage(10),
stMaxQueueMessages(0),
stCountOfQueueFull(0)
{
ui = make_shared<UInterface>(UniSetTypes::DefaultObjectId);
tmr = CREATE_TIMER;
myname = "noname";
section = "nonameSection";
......@@ -64,7 +65,6 @@ stCountOfQueueFull(0)
}
// ------------------------------------------------------------------------------------------
UniSetObject::UniSetObject( ObjectId id ):
ui(id),
msgpid(0),
reg(false),
active(0),
......@@ -76,10 +76,11 @@ MaxCountRemoveOfMessage(10),
stMaxQueueMessages(0),
stCountOfQueueFull(0)
{
ui = make_shared<UInterface>(id);
tmr = CREATE_TIMER;
if (myid >=0)
{
string myfullname = ui.getNameById(id);
string myfullname = ui->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str());
section = ORepHelpers::getSectionName(myfullname.c_str());
}
......@@ -95,8 +96,7 @@ stCountOfQueueFull(0)
}
UniSetObject::UniSetObject(const string& name, const string& section):
ui(UniSetTypes::DefaultObjectId),
UniSetObject::UniSetObject( const string& name, const string& section ):
msgpid(0),
reg(false),
active(0),
......@@ -108,10 +108,12 @@ MaxCountRemoveOfMessage(10),
stMaxQueueMessages(0),
stCountOfQueueFull(0)
{
ui = make_shared<UInterface>(UniSetTypes::DefaultObjectId);
/*! \warning UniverslalInterface не инициализируется идентификатором объекта */
tmr = CREATE_TIMER;
myname = section + "/" + name;
myid = ui.getIdByName(myname);
myid = ui->getIdByName(myname);
if( myid == DefaultObjectId )
{
uwarn << "name: my ID not found!" << endl;
......@@ -119,7 +121,7 @@ stCountOfQueueFull(0)
}
init_object();
ui.initBackId(myid);
ui->initBackId(myid);
}
// ------------------------------------------------------------------------------------------
......@@ -187,11 +189,11 @@ void UniSetObject::setID( UniSetTypes::ObjectId id )
if( myid!=UniSetTypes::DefaultObjectId )
throw ObjectNameAlready("ObjectId already set(setID)");
string myfullname = ui.getNameById(id);
string myfullname = ui->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str());
section = ORepHelpers::getSectionName(myfullname.c_str());
myid = id;
ui.initBackId(myid);
ui->initBackId(myid);
}
// ------------------------------------------------------------------------------------------
......@@ -354,7 +356,7 @@ void UniSetObject::registered()
{
try
{
ui.registered(myid, getRef(),true);
ui->registered(myid, getRef(),true);
break;
}
catch( ObjectNameAlready& al )
......@@ -415,7 +417,7 @@ void UniSetObject::unregister()
try
{
uinfo << myname << ": unregister "<< endl;
ui.unregister(myid);
ui->unregister(myid);
uinfo << myname << ": unregister ok. "<< endl;
}
catch(...)
......
......@@ -382,13 +382,13 @@ void IOController::ioRegistration( USensorInfo&& ainf, bool force )
<< "(ioRegistration): регистрирую "
<< uniset_conf()->oind->getNameById(ainf.si.id) << endl;
ui.registered( ainf.si.id, getRef(), true );
ui->registered( ainf.si.id, getRef(), true );
return;
}
catch(ObjectNameAlready& ex )
{
uwarn << myname << "(asRegistration): ЗАМЕНЯЮ СУЩЕСТВУЮЩИЙ ОБЪЕКТ (ObjectNameAlready)" << endl;
ui.unregister(ainf.si.id);
ui->unregister(ainf.si.id);
}
}
}
......@@ -404,7 +404,7 @@ void IOController::ioRegistration( USensorInfo&& ainf, bool force )
// ---------------------------------------------------------------------------
void IOController::ioUnRegistration( const UniSetTypes::ObjectId sid )
{
ui.unregister(sid);
ui->unregister(sid);
}
// ---------------------------------------------------------------------------
void IOController::logging( UniSetTypes::SensorMessage& sm )
......@@ -421,7 +421,7 @@ void IOController::logging( UniSetTypes::SensorMessage& sm )
sm.consumer = dbID;
TransportMessage tm(sm.transport_msg());
ui.send( sm.consumer, std::move(tm) );
ui->send( sm.consumer, std::move(tm) );
isPingDBServer = true;
}
catch(...)
......
......@@ -98,7 +98,7 @@ bool IONotifyController::addConsumer( ConsumerListInfo& lst, const ConsumerInfo&
// получаем ссылку
try
{
UniSetTypes::ObjectVar op = ui.resolve(ci.id,ci.node);
UniSetTypes::ObjectVar op = ui->resolve(ci.id,ci.node);
cinf.ref = UniSetObject_i::_narrow(op);
}
catch(...){}
......@@ -176,7 +176,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
try
{
ui.send(ci.id, std::move(smsg.transport_msg()), ci.node);
ui->send(ci.id, std::move(smsg.transport_msg()), ci.node);
}
catch( Exception& ex )
{
......@@ -390,7 +390,7 @@ void IONotifyController::send( ConsumerListInfo& lst, UniSetTypes::SensorMessage
{
if( CORBA::is_nil(li->ref) )
{
CORBA::Object_var op = ui.resolve(li->id, li->node);
CORBA::Object_var op = ui->resolve(li->id, li->node);
li->ref = UniSetObject_i::_narrow(op);
}
......@@ -610,7 +610,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
if( val <= lowLimit )
{
sm.threshold = false;
CORBA::Object_var op = ui.resolve(ci.id, ci.node);
CORBA::Object_var op = ui->resolve(ci.id, ci.node);
UniSetObject_i_var ref = UniSetObject_i::_narrow(op);
if(!CORBA::is_nil(ref))
ref->push( std::move(sm.transport_msg()) );
......@@ -619,7 +619,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
else if( val >= hiLimit )
{
sm.threshold = true;
CORBA::Object_var op = ui.resolve(ci.id, ci.node);
CORBA::Object_var op = ui->resolve(ci.id, ci.node);
UniSetObject_i_var ref = UniSetObject_i::_narrow(op);
if(!CORBA::is_nil(ref))
ref->push( std::move(sm.transport_msg()) );
......
......@@ -54,7 +54,7 @@ void SMonitor::sysCommand( const SystemMessage *sm )
try
{
if( it.si.id != DefaultObjectId )
ui.askRemoteSensor(it.si.id,UniversalIO::UIONotify,it.si.node);
ui->askRemoteSensor(it.si.id,UniversalIO::UIONotify,it.si.node);
}
catch(Exception& ex)
{
......
......@@ -39,9 +39,9 @@ SViewer::SViewer(const string& csec, bool sn):
csec(csec),
rep(UniSetTypes::uniset_conf()),
cache(500, 15),
ui(UniSetTypes::uniset_conf()),
isShort(sn)
{
ui = make_shared<UInterface>(UniSetTypes::uniset_conf());
}
SViewer::~SViewer()
......@@ -171,7 +171,7 @@ void SViewer::getInfo( ObjectId id )
if( CORBA::is_nil(oref) )
{
oref = ui.resolve(id);
oref = ui->resolve(id);
cache.cache(id, uniset_conf()->getLocalNode(), oref);
}
......
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