Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
b1ef89fe
Commit
b1ef89fe
authored
Jan 18, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Исправил небольшую ошибку с параметром влючения сборки документации.
- Переход на shared_ptr везде где только можно.. - выпуск версии 2.0-alt11 с текущими изменениями.
parent
2fbcb22d
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
604 additions
and
628 deletions
+604
-628
ctl-cpp-cc-alone-ask.xsl
Utilities/codegen/ctl-cpp-cc-alone-ask.xsl
+11
-11
ctl-cpp-cc-alone.xsl
Utilities/codegen/ctl-cpp-cc-alone.xsl
+8
-8
ctl-cpp-cc-ask.xsl
Utilities/codegen/ctl-cpp-cc-ask.xsl
+10
-10
ctl-cpp-cc.xsl
Utilities/codegen/ctl-cpp-cc.xsl
+9
-9
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+11
-11
libuniset2.spec
conf/libuniset2.spec
+14
-9
configure.ac
configure.ac
+3
-3
IOControl.cc
extensions/IOControl/IOControl.cc
+1
-4
IOControl.h
extensions/IOControl/IOControl.h
+2
-2
PassiveLProcessor.cc
extensions/LogicProcessor/PassiveLProcessor.cc
+3
-3
PassiveLProcessor.h
extensions/LogicProcessor/PassiveLProcessor.h
+2
-1
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+1
-3
MBExchange.h
extensions/ModbusMaster/MBExchange.h
+1
-1
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+9
-16
MBSlave.h
extensions/ModbusSlave/MBSlave.h
+4
-3
MBTCPMultiSlave.cc
extensions/ModbusSlave/MBTCPMultiSlave.cc
+3
-3
MBTCPMultiSlave.h
extensions/ModbusSlave/MBTCPMultiSlave.h
+1
-1
RRDServer.cc
extensions/RRDServer/RRDServer.cc
+1
-1
SMViewer.cc
extensions/SMViewer/SMViewer.cc
+1
-2
SMViewer.h
extensions/SMViewer/SMViewer.h
+2
-2
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+2
-2
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+8
-21
UNetExchange.h
extensions/UNetUDP/UNetExchange.h
+7
-7
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+6
-12
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+8
-6
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+4
-7
UNetSender.h
extensions/UNetUDP/UNetSender.h
+3
-3
UniExchange.cc
extensions/UniNetwork/UniExchange.cc
+3
-7
UniExchange.h
extensions/UniNetwork/UniExchange.h
+3
-2
IOBase.h
extensions/include/IOBase.h
+10
-9
SMInterface.h
extensions/include/SMInterface.h
+3
-2
UObject_SK.h
extensions/include/UObject_SK.h
+103
-103
IOBase.cc
extensions/lib/IOBase.cc
+9
-9
SMInterface.cc
extensions/lib/SMInterface.cc
+1
-1
UObject_SK.cc
extensions/lib/UObject_SK.cc
+286
-286
TestProc.cc
extensions/tests/SMemoryTest/TestProc.cc
+4
-4
test_iobase.cc
extensions/tests/test_iobase.cc
+6
-6
test_iobase_with_sm.cc
extensions/tests/test_iobase_with_sm.cc
+4
-6
tests_with_sm.cc
extensions/tests/tests_with_sm.cc
+2
-2
ProxyManager.h
include/ProxyManager.h
+2
-1
SViewer.h
include/SViewer.h
+3
-1
UniSetObject.h
include/UniSetObject.h
+1
-1
ProxyManager.cc
src/ObjectRepository/ProxyManager.cc
+4
-4
UniSetObject.cc
src/ObjectRepository/UniSetObject.cc
+13
-11
IOController.cc
src/Processes/IOController.cc
+4
-4
IONotifyController.cc
src/Processes/IONotifyController.cc
+5
-5
SMonitor.cc
src/Various/SMonitor.cc
+1
-1
SViewer.cc
src/Various/SViewer.cc
+2
-2
No files found.
Utilities/codegen/ctl-cpp-cc-alone-ask.xsl
View file @
b1ef89fe
...
...
@@ -79,7 +79,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId
&&
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
&
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
&
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
&
ex)
{
...
...
Utilities/codegen/ctl-cpp-cc-alone.xsl
View file @
b1ef89fe
...
...
@@ -82,7 +82,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId
&&
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(
&
_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
&
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
&
ex )
{
...
...
Utilities/codegen/ctl-cpp-cc-ask.xsl
View file @
b1ef89fe
...
...
@@ -78,7 +78,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId
&&
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"
/>
&&
<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
&
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
&
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
&
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
&
ex )
{
...
...
Utilities/codegen/ctl-cpp-cc.xsl
View file @
b1ef89fe
...
...
@@ -82,7 +82,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
// "сердцебиение"
if( idHeartBeat!=DefaultObjectId
&&
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(
&
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
&
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
&
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
&
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
&
ex )
...
...
Utilities/codegen/ctl-cpp-common.xsl
View file @
b1ef89fe
...
...
@@ -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
&
ex )
{
...
...
@@ -387,7 +387,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
<<
wait_msec
<<
" msec"
<<
" testID="
<<
_testID
<<
endl;
if( !ui
.
waitReady(_testID,wait_msec) )
if( !ui
->
waitReady(_testID,wait_msec) )
{
ostringstream err;
err
<<
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
<<
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
&
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"
>
...
...
conf/libuniset2.spec
View file @
b1ef89fe
%def_enable doc
%def_enable doc
s
%def_enable mysql
%def_enable sqlite
%def_enable python
...
...
@@ -12,7 +12,7 @@
Name: libuniset2
Version: 2.0
Release: alt1
0
Release: alt1
1
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 doc
s
BuildRequires: doxygen
%endif
...
...
@@ -108,15 +108,15 @@ Obsoletes: %oname-utils
%description utils
UniSet utilities
%if_enabled doc
%if_enabled doc
s
%package doc
%package doc
s
Group: Development/C++
Summary: Documentations for developing with UniSet
Requires: %name = %version-%release
BuildArch: noarch
%description doc
%description doc
s
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 doc
s
} %{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 doc
s
%files doc
s
%_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
...
...
configure.ac
View file @
b1ef89fe
...
...
@@ -165,13 +165,13 @@ AM_CONDITIONAL(DISABLE_PYTHON, test ${buildpython} = false)
# check Doxygen
DOXYGEN=""
doc=false
doc
s
=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 doc
s=true; else docs=false; fi],[ docs
=false; ])
if test ${doc} = true; then
if test ${doc
s
} = true; then
AC_MSG_RESULT([yes])
AC_PATH_PROG([DOXYGEN], [doxygen])
test "x$DOXYGEN" = "x" && AC_MSG_WARN([*** Doxygen not found])
...
...
extensions/IOControl/IOControl.cc
View file @
b1ef89fe
...
...
@@ -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
;
}
// --------------------------------------------------------------------------------
...
...
extensions/IOControl/IOControl.h
View file @
b1ef89fe
...
...
@@ -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
;
...
...
extensions/LogicProcessor/PassiveLProcessor.cc
View file @
b1ef89fe
...
...
@@ -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
()
...
...
extensions/LogicProcessor/PassiveLProcessor.h
View file @
b1ef89fe
...
...
@@ -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
;
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
b1ef89fe
...
...
@@ -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
()
...
...
extensions/ModbusMaster/MBExchange.h
View file @
b1ef89fe
...
...
@@ -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
;
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
b1ef89fe
...
...
@@ -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
=
mb
tcp
;
thr
=
new
ThreadCreator
<
MBSlave
>
(
this
,
&
MBSlave
::
execute_tcp
);
mbslot
=
mb
slot
=
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
;
...
...
extensions/ModbusSlave/MBSlave.h
View file @
b1ef89fe
...
...
@@ -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
;
...
...
extensions/ModbusSlave/MBTCPMultiSlave.cc
View file @
b1ef89fe
...
...
@@ -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
);
}
...
...
extensions/ModbusSlave/MBTCPMultiSlave.h
View file @
b1ef89fe
...
...
@@ -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
);
...
...
extensions/RRDServer/RRDServer.cc
View file @
b1ef89fe
...
...
@@ -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
);
...
...
extensions/SMViewer/SMViewer.cc
View file @
b1ef89fe
...
...
@@ -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
()
...
...
extensions/SMViewer/SMViewer.h
View file @
b1ef89fe
...
...
@@ -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
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
b1ef89fe
...
...
@@ -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
;
}
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
b1ef89fe
...
...
@@ -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
)
...
...
extensions/UNetUDP/UNetExchange.h
View file @
b1ef89fe
...
...
@@ -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_
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
b1ef89fe
...
...
@@ -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
);
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
b1ef89fe
...
...
@@ -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
:
...
...
extensions/UNetUDP/UNetSender.cc
View file @
b1ef89fe
...
...
@@ -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
()
...
...
extensions/UNetUDP/UNetSender.h
View file @
b1ef89fe
...
...
@@ -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_
...
...
extensions/UniNetwork/UniExchange.cc
View file @
b1ef89fe
...
...
@@ -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
()
)
...
...
extensions/UniNetwork/UniExchange.h
View file @
b1ef89fe
...
...
@@ -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
;
...
...
extensions/include/IOBase.h
View file @
b1ef89fe
...
...
@@ -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
,
...
...
extensions/include/SMInterface.h
View file @
b1ef89fe
...
...
@@ -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
;
...
...
extensions/include/UObject_SK.h
View file @
b1ef89fe
...
...
@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-01-1
2
+03:00
// generate timestamp: 2015-01-1
7
+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
;
// вспомогательное поле (для внутреннего использования при генерировании кода)
};
// -----------------------------------------------------------------------------
...
...
extensions/lib/IOBase.cc
View file @
b1ef89fe
...
...
@@ -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
,
...
...
extensions/lib/SMInterface.cc
View file @
b1ef89fe
...
...
@@ -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
),
...
...
extensions/lib/UObject_SK.cc
View file @
b1ef89fe
...
...
@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-01-1
2
+03:00
// generate timestamp: 2015-01-1
7
+03:00
// -----------------------------------------------------------------------------
#include "Configuration.h"
#include "Exceptions.h"
...
...
@@ -44,19 +44,19 @@ forceOut(false),
end_private
(
false
)
{
ucrit
<<
"UObject: init failed!!!!!!!!!!!!!!!"
<<
endl
;
throw
Exception
(
string
(
myname
+
": init failed!!!"
)
);
ucrit
<<
"UObject: init failed!!!!!!!!!!!!!!!"
<<
endl
;
throw
Exception
(
string
(
myname
+
": init failed!!!"
)
);
}
// -----------------------------------------------------------------------------
// ( val, confval, default val )
static
const
std
::
string
init3_str
(
const
std
::
string
&
s1
,
const
std
::
string
&
s2
,
const
std
::
string
&
s3
)
{
if
(
!
s1
.
empty
()
)
return
s1
;
if
(
!
s2
.
empty
()
)
return
s2
;
return
s3
;
if
(
!
s1
.
empty
()
)
return
s1
;
if
(
!
s2
.
empty
()
)
return
s2
;
return
s3
;
}
// -----------------------------------------------------------------------------
UObject_SK
::
UObject_SK
(
ObjectId
id
,
xmlNode
*
cnode
,
const
std
::
string
&
argprefix
)
:
...
...
@@ -80,77 +80,77 @@ forceOut(false),
end_private
(
false
)
{
auto
conf
=
uniset_conf
();
auto
conf
=
uniset_conf
();
if
(
UniSetTypes
::
findArgParam
(
"--print-id-list"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
{
if
(
UniSetTypes
::
findArgParam
(
"--print-id-list"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
{
//
abort();
}
//
abort();
}
if
(
getId
()
==
DefaultObjectId
)
{
ostringstream
err
;
err
<<
"(UObject::init): Unknown ObjectID!"
;
throw
SystemError
(
err
.
str
()
);
}
if
(
getId
()
==
DefaultObjectId
)
{
ostringstream
err
;
err
<<
"(UObject::init): Unknown ObjectID!"
;
throw
SystemError
(
err
.
str
()
);
}
UniXML
::
iterator
it
(
cnode
);
UniXML
::
iterator
it
(
cnode
);
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
if
(
!
heart
.
empty
()
)
{
idHeartBeat
=
conf
->
getSensorID
(
heart
);
if
(
idHeartBeat
==
DefaultObjectId
)
{
ostringstream
err
;
err
<<
myname
<<
": не найден идентификатор для датчика 'HeartBeat' "
<<
heart
;
throw
SystemError
(
err
.
str
());
}
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
if
(
!
heart
.
empty
()
)
{
idHeartBeat
=
conf
->
getSensorID
(
heart
);
if
(
idHeartBeat
==
DefaultObjectId
)
{
ostringstream
err
;
err
<<
myname
<<
": не найден идентификатор для датчика 'HeartBeat' "
<<
heart
;
throw
SystemError
(
err
.
str
());
}
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
());
if
(
heartbeatTime
>
0
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
ptHeartBeat
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
());
if
(
heartbeatTime
>
0
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
ptHeartBeat
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
}
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
}
// Инициализация значений
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
// Инициализация значений
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
resetMsgTime
=
conf
->
getPIntProp
(
cnode
,
"resetMsgTime"
,
2000
);
ptResetMsg
.
setTiming
(
resetMsgTime
);
resetMsgTime
=
conf
->
getPIntProp
(
cnode
,
"resetMsgTime"
,
2000
);
ptResetMsg
.
setTiming
(
resetMsgTime
);
smReadyTimeout
=
conf
->
getArgInt
(
"--"
+
argprefix
+
"sm-ready-timeout"
,
""
);
if
(
smReadyTimeout
==
0
)
smReadyTimeout
=
60000
;
else
if
(
smReadyTimeout
<
0
)
smReadyTimeout
=
UniSetTimer
::
WaitUpTime
;
smReadyTimeout
=
conf
->
getArgInt
(
"--"
+
argprefix
+
"sm-ready-timeout"
,
""
);
if
(
smReadyTimeout
==
0
)
smReadyTimeout
=
60000
;
else
if
(
smReadyTimeout
<
0
)
smReadyTimeout
=
UniSetTimer
::
WaitUpTime
;
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
activateTimeout
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"activate-timeout"
,
20000
);
activateTimeout
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"activate-timeout"
,
20000
);
int
msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"startup-timeout"
,
10000
);
ptStartUpTimeout
.
setTiming
(
msec
);
int
msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"startup-timeout"
,
10000
);
ptStartUpTimeout
.
setTiming
(
msec
);
// ===================== <variables> =====================
// ===================== end of <variables> =====================
// ===================== <variables> =====================
// ===================== end of <variables> =====================
}
// -----------------------------------------------------------------------------
...
...
@@ -161,36 +161,36 @@ UObject_SK::~UObject_SK()
// -----------------------------------------------------------------------------
void
UObject_SK
::
updateValues
()
{
// Опрашиваем все входы...
// Опрашиваем все входы...
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
updatePreviousValues
()
{
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
checkSensors
()
{
}
// -----------------------------------------------------------------------------
bool
UObject_SK
::
alarm
(
UniSetTypes
::
ObjectId
_code
,
bool
_state
)
{
if
(
_code
==
UniSetTypes
::
DefaultObjectId
)
{
if
(
_code
==
UniSetTypes
::
DefaultObjectId
)
{
ucrit
<<
getName
()
<<
"(alarm): попытка послать сообщение с DefaultObjectId"
<<
endl
;
return
false
;
}
<<
"(alarm): попытка послать сообщение с DefaultObjectId"
<<
endl
;
return
false
;
}
ulog1
<<
getName
()
<<
"(alarm): "
<<
(
_state
?
"SEND "
:
"RESET "
)
<<
endl
;
ulog1
<<
" not found MessgeOID?!!"
<<
endl
;
return
false
;
return
false
;
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
resetMsg
()
...
...
@@ -201,11 +201,11 @@ void UObject_SK::resetMsg()
// -----------------------------------------------------------------------------
void
UObject_SK
::
testMode
(
bool
_state
)
{
if
(
!
_state
)
return
;
if
(
!
_state
)
return
;
// отключаем все выходы
// отключаем все выходы
}
// -----------------------------------------------------------------------------
...
...
@@ -214,139 +214,139 @@ void UObject_SK::testMode( bool _state )
// ------------------------------------------------------------------------------------------
void
UObject_SK
::
init_dlog
(
DebugStream
&
d
)
{
UObject_SK
::
mylog
=
d
;
UObject_SK
::
mylog
=
d
;
}
// ------------------------------------------------------------------------------------------
void
UObject_SK
::
processingMessage
(
UniSetTypes
::
VoidMessage
*
_msg
)
{
try
{
switch
(
_msg
->
type
)
{
case
Message
:
:
SensorInfo
:
preSensorInfo
(
reinterpret_cast
<
SensorMessage
*>
(
_msg
)
);
break
;
case
Message
:
:
Timer
:
preTimerInfo
(
reinterpret_cast
<
TimerMessage
*>
(
_msg
)
);
break
;
case
Message
:
:
SysCommand
:
sysCommand
(
reinterpret_cast
<
SystemMessage
*>
(
_msg
)
);
break
;
default
:
break
;
}
}
catch
(
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): "
<<
ex
<<
endl
;
}
try
{
switch
(
_msg
->
type
)
{
case
Message
:
:
SensorInfo
:
preSensorInfo
(
reinterpret_cast
<
SensorMessage
*>
(
_msg
)
);
break
;
case
Message
:
:
Timer
:
preTimerInfo
(
reinterpret_cast
<
TimerMessage
*>
(
_msg
)
);
break
;
case
Message
:
:
SysCommand
:
sysCommand
(
reinterpret_cast
<
SystemMessage
*>
(
_msg
)
);
break
;
default
:
break
;
}
}
catch
(
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(processingMessage): "
<<
ex
<<
endl
;
}
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
sysCommand
(
const
SystemMessage
*
_sm
)
{
switch
(
_sm
->
command
)
{
case
SystemMessage
:
:
WatchDog
:
ulog
<<
myname
<<
"(sysCommand): WatchDog"
<<
endl
;
if
(
!
active
||
!
ptStartUpTimeout
.
checkTime
()
)
{
switch
(
_sm
->
command
)
{
case
SystemMessage
:
:
WatchDog
:
ulog
<<
myname
<<
"(sysCommand): WatchDog"
<<
endl
;
if
(
!
active
||
!
ptStartUpTimeout
.
checkTime
()
)
{
uwarn
<<
myname
<<
"(sysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl
;
break
;
}
case
SystemMessage
:
:
StartUp
:
{
waitSM
(
smReadyTimeout
);
ptStartUpTimeout
.
reset
();
// т.к. для io-переменных важно соблюдать последовательность!
// сперва обновить входы.. а потом уже выходы
updateValues
();
updateOutputs
(
true
);
// принудительное обновление выходов
preAskSensors
(
UniversalIO
::
UIONotify
);
askSensors
(
UniversalIO
::
UIONotify
);
active
=
true
;
break
;
}
case
SystemMessage
:
:
FoldUp
:
case
SystemMessage
:
:
Finish
:
preAskSensors
(
UniversalIO
::
UIODontNotify
);
askSensors
(
UniversalIO
::
UIODontNotify
);
break
;
case
SystemMessage
:
:
LogRotate
:
{
// переоткрываем логи
mylog
<<
myname
<<
"(sysCommand): logRotate"
<<
endl
;
string
fname
(
mylog
.
getLogFile
()
);
if
(
!
fname
.
empty
()
)
{
mylog
.
logFile
(
fname
.
c_str
(),
true
);
mylog
<<
myname
<<
"(sysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl
;
}
}
break
;
default
:
break
;
}
break
;
}
case
SystemMessage
:
:
StartUp
:
{
waitSM
(
smReadyTimeout
);
ptStartUpTimeout
.
reset
();
// т.к. для io-переменных важно соблюдать последовательность!
// сперва обновить входы.. а потом уже выходы
updateValues
();
updateOutputs
(
true
);
// принудительное обновление выходов
preAskSensors
(
UniversalIO
::
UIONotify
);
askSensors
(
UniversalIO
::
UIONotify
);
active
=
true
;
break
;
}
case
SystemMessage
:
:
FoldUp
:
case
SystemMessage
:
:
Finish
:
preAskSensors
(
UniversalIO
::
UIODontNotify
);
askSensors
(
UniversalIO
::
UIODontNotify
);
break
;
case
SystemMessage
:
:
LogRotate
:
{
// переоткрываем логи
mylog
<<
myname
<<
"(sysCommand): logRotate"
<<
endl
;
string
fname
(
mylog
.
getLogFile
()
);
if
(
!
fname
.
empty
()
)
{
mylog
.
logFile
(
fname
.
c_str
(),
true
);
mylog
<<
myname
<<
"(sysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl
;
}
}
break
;
default
:
break
;
}
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
sigterm
(
int
signo
)
{
UniSetObject
::
sigterm
(
signo
);
active
=
false
;
UniSetObject
::
sigterm
(
signo
);
active
=
false
;
}
// -----------------------------------------------------------------------------
bool
UObject_SK
::
activateObject
()
{
// блокирование обработки Startup
// пока не пройдёт инициализация датчиков
// см. sysCommand()
{
activated
=
false
;
UniSetObject
::
activateObject
();
activated
=
true
;
}
return
true
;
// блокирование обработки Startup
// пока не пройдёт инициализация датчиков
// см. sysCommand()
{
activated
=
false
;
UniSetObject
::
activateObject
();
activated
=
true
;
}
return
true
;
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
preTimerInfo
(
const
UniSetTypes
::
TimerMessage
*
_tm
)
{
timerInfo
(
_tm
);
timerInfo
(
_tm
);
}
// ----------------------------------------------------------------------------
void
UObject_SK
::
waitSM
(
int
wait_msec
,
ObjectId
_testID
)
{
if
(
_testID
==
DefaultObjectId
)
_testID
=
smTestID
;
if
(
_testID
==
DefaultObjectId
)
_testID
=
smTestID
;
if
(
_testID
==
DefaultObjectId
)
return
;
uinfo
<<
myname
<<
"(waitSM): waiting SM ready "
<<
wait_msec
<<
" msec"
<<
" testID="
<<
_testID
<<
endl
;
if
(
!
ui
.
waitReady
(
_testID
,
wait_msec
)
)
{
ostringstream
err
;
err
<<
myname
<<
"(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
<<
wait_msec
<<
" мсек"
;
if
(
_testID
==
DefaultObjectId
)
return
;
uinfo
<<
myname
<<
"(waitSM): waiting SM ready "
<<
wait_msec
<<
" msec"
<<
" testID="
<<
_testID
<<
endl
;
if
(
!
ui
->
waitReady
(
_testID
,
wait_msec
)
)
{
ostringstream
err
;
err
<<
myname
<<
"(waitSM): Не дождались готовности(exist) SharedMemory к работе в течение "
<<
wait_msec
<<
" мсек"
;
ucrit
<<
err
.
str
()
<<
endl
;
terminate
();
abort
();
// kill(SIGTERM,getpid());
// прерываем (перезапускаем) процесс...
throw
SystemError
(
err
.
str
());
}
terminate
();
abort
();
// kill(SIGTERM,getpid());
// прерываем (перезапускаем) процесс...
throw
SystemError
(
err
.
str
());
}
}
...
...
@@ -355,152 +355,152 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
// --------------------------------------------------------------------------
void
UObject_SK
::
callback
()
{
if
(
!
active
)
return
;
try
{
// проверка таймеров
checkTimers
(
this
);
if
(
resetMsgTime
>
0
&&
trResetMsg
.
hi
(
ptResetMsg
.
checkTime
())
)
{
//
cout << myname << ": ********* reset messages *********" << endl;
resetMsg
();
}
// обработка сообщений (таймеров и т.п.)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
{
if
(
!
receiveMessage
(
msg
)
)
break
;
processingMessage
(
&
msg
);
updateOutputs
(
forceOut
);
//
updatePreviousValues();
}
// Выполнение шага программы
step
();
// "сердцебиение"
if
(
idHeartBeat
!=
DefaultObjectId
&&
ptHeartBeat
.
checkTime
()
)
{
ui
.
setValue
(
idHeartBeat
,
maxHeartBeat
,
UniversalIO
::
AI
);
ptHeartBeat
.
reset
();
}
// обновление выходов
updateOutputs
(
forceOut
);
updatePreviousValues
();
}
catch
(
Exception
&
ex
)
{
if
(
!
active
)
return
;
try
{
// проверка таймеров
checkTimers
(
this
);
if
(
resetMsgTime
>
0
&&
trResetMsg
.
hi
(
ptResetMsg
.
checkTime
())
)
{
//
cout << myname << ": ********* reset messages *********" << endl;
resetMsg
();
}
// обработка сообщений (таймеров и т.п.)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
{
if
(
!
receiveMessage
(
msg
)
)
break
;
processingMessage
(
&
msg
);
updateOutputs
(
forceOut
);
//
updatePreviousValues();
}
// Выполнение шага программы
step
();
// "сердцебиение"
if
(
idHeartBeat
!=
DefaultObjectId
&&
ptHeartBeat
.
checkTime
()
)
{
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
,
UniversalIO
::
AI
);
ptHeartBeat
.
reset
();
}
// обновление выходов
updateOutputs
(
forceOut
);
updatePreviousValues
();
}
catch
(
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(execute): "
<<
ex
<<
endl
;
}
catch
(
CORBA
::
SystemException
&
ex
)
{
}
catch
(
CORBA
::
SystemException
&
ex
)
{
ucrit
<<
myname
<<
"(execute): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(...)
{
}
catch
(...)
{
ucrit
<<
myname
<<
"(execute): catch ..."
<<
endl
;
}
}
if
(
!
active
)
return
;
msleep
(
sleep_msec
);
if
(
!
active
)
return
;
msleep
(
sleep_msec
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
setValue
(
UniSetTypes
::
ObjectId
_sid
,
long
_val
)
{
ui
.
setValue
(
_sid
,
_val
);
ui
->
setValue
(
_sid
,
_val
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
updateOutputs
(
bool
_force
)
{
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
preSensorInfo
(
const
UniSetTypes
::
SensorMessage
*
_sm
)
{
sensorInfo
(
_sm
);
sensorInfo
(
_sm
);
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
askSensor
(
UniSetTypes
::
ObjectId
_sid
,
UniversalIO
::
UIOCommand
_cmd
,
UniSetTypes
::
ObjectId
_node
)
{
ui
.
askRemoteSensor
(
_sid
,
_cmd
,
_node
,
getId
());
ui
->
askRemoteSensor
(
_sid
,
_cmd
,
_node
,
getId
());
}
// -----------------------------------------------------------------------------
long
UObject_SK
::
getValue
(
UniSetTypes
::
ObjectId
_sid
)
{
try
{
try
{
return
ui
.
getValue
(
_sid
);
}
catch
(
Exception
&
ex
)
{
return
ui
->
getValue
(
_sid
);
}
catch
(
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(getValue): "
<<
ex
<<
endl
;
throw
;
}
throw
;
}
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
preAskSensors
(
UniversalIO
::
UIOCommand
_cmd
)
{
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
cout
<<
myname
<<
"(preAskSensors): wait activate..."
<<
endl
;
msleep
(
300
);
if
(
activated
)
break
;
}
if
(
!
activated
)
ucrit
<<
myname
<<
"(preAskSensors): ************* don`t activated?! ************"
<<
endl
;
for
(
;;
)
{
try
{
return
;
}
catch
(
SystemError
&
err
)
{
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
cout
<<
myname
<<
"(preAskSensors): wait activate..."
<<
endl
;
msleep
(
300
);
if
(
activated
)
break
;
}
if
(
!
activated
)
ucrit
<<
myname
<<
"(preAskSensors): ************* don`t activated?! ************"
<<
endl
;
for
(
;;
)
{
try
{
return
;
}
catch
(
SystemError
&
err
)
{
ucrit
<<
myname
<<
"(preAskSensors): "
<<
err
<<
endl
;
}
catch
(
Exception
&
ex
)
{
}
catch
(
Exception
&
ex
)
{
ucrit
<<
myname
<<
"(preAskSensors): "
<<
ex
<<
endl
;
}
catch
(...)
{
}
catch
(...)
{
ucrit
<<
myname
<<
"(preAskSensors): catch(...)"
<<
endl
;
}
msleep
(
askPause
);
}
}
msleep
(
askPause
);
}
}
// -----------------------------------------------------------------------------
void
UObject_SK
::
setMsg
(
UniSetTypes
::
ObjectId
_code
,
bool
_state
)
{
// блокируем сброс (т.к. он автоматически по таймеру)
if
(
!
_state
)
{
ptResetMsg
.
reset
();
return
;
}
alarm
(
_code
,
_state
);
ptResetMsg
.
reset
();
}
// блокируем сброс (т.к. он автоматически по таймеру)
if
(
!
_state
)
{
ptResetMsg
.
reset
();
return
;
}
alarm
(
_code
,
_state
);
ptResetMsg
.
reset
();
}
// ----------------------------------------------------------------------------
extensions/tests/SMemoryTest/TestProc.cc
View file @
b1ef89fe
...
...
@@ -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
)
...
...
extensions/tests/test_iobase.cc
View file @
b1ef89fe
...
...
@@ -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
);
...
...
extensions/tests/test_iobase_with_sm.cc
View file @
b1ef89fe
...
...
@@ -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
();
...
...
extensions/tests/tests_with_sm.cc
View file @
b1ef89fe
...
...
@@ -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
);
}
...
...
include/ProxyManager.h
View file @
b1ef89fe
...
...
@@ -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
();
...
...
include/SViewer.h
View file @
b1ef89fe
...
...
@@ -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
;
};
...
...
include/UniSetObject.h
View file @
b1ef89fe
...
...
@@ -111,7 +111,7 @@ class UniSetObject:
/*! прервать ожидание сообщений */
void
termWaiting
();
UInterface
ui
;
/*!< универсальный интерфейс для работы с другими процессами */
std
::
shared_ptr
<
UInterface
>
ui
;
/*!< универсальный интерфейс для работы с другими процессами */
std
::
string
myname
;
std
::
string
section
;
...
...
src/ObjectRepository/ProxyManager.cc
View file @
b1ef89fe
...
...
@@ -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
)
{
...
...
src/ObjectRepository/UniSetObject.cc
View file @
b1ef89fe
...
...
@@ -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
(...)
...
...
src/Processes/IOController.cc
View file @
b1ef89fe
...
...
@@ -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
(...)
...
...
src/Processes/IONotifyController.cc
View file @
b1ef89fe
...
...
@@ -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
())
);
...
...
src/Various/SMonitor.cc
View file @
b1ef89fe
...
...
@@ -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
)
{
...
...
src/Various/SViewer.cc
View file @
b1ef89fe
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment