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
b0299b2e
Commit
b0299b2e
authored
Jun 08, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Встроил в станадартные компоненты (SharedMemory,ModbusSlave,ModbusMaster,
UNetUDP) поддержку механизма удалённого контроля переменных. Сделал предварительную реализацию.
parent
0c4a3da1
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
361 additions
and
17 deletions
+361
-17
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+10
-0
libuniset2.spec
conf/libuniset2.spec
+5
-1
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+33
-0
MBExchange.h
extensions/ModbusMaster/MBExchange.h
+9
-0
MBTCPMaster.cc
extensions/ModbusMaster/MBTCPMaster.cc
+13
-0
MBTCPMaster.h
extensions/ModbusMaster/MBTCPMaster.h
+2
-0
MBTCPMultiMaster.cc
extensions/ModbusMaster/MBTCPMultiMaster.cc
+24
-0
MBTCPMultiMaster.h
extensions/ModbusMaster/MBTCPMultiMaster.h
+4
-0
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+30
-0
MBSlave.h
extensions/ModbusSlave/MBSlave.h
+9
-1
MBTCPMultiSlave.cc
extensions/ModbusSlave/MBTCPMultiSlave.cc
+30
-0
MBTCPMultiSlave.h
extensions/ModbusSlave/MBTCPMultiSlave.h
+4
-0
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+26
-0
SharedMemory.h
extensions/SharedMemory/SharedMemory.h
+10
-1
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+39
-0
UNetExchange.h
extensions/UNetUDP/UNetExchange.h
+9
-0
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+16
-0
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+9
-7
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+15
-0
UNetSender.h
extensions/UNetUDP/UNetSender.h
+13
-1
PassiveTimer.h
include/PassiveTimer.h
+2
-2
VMonitor.h
include/VMonitor.h
+13
-0
PassiveTimer.cc
src/Timers/PassiveTimer.cc
+1
-1
VMonitor.cc
src/Various/VMonitor.cc
+35
-3
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
b0299b2e
...
...
@@ -432,6 +432,7 @@ UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo()
ostringstream inf;
inf
<<
i->info
<<
endl;
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl;
inf
<<
dumpIO()
<<
endl;
inf
<<
vmon.pretty_str()
<<
endl;
inf
<<
getMonitInfo()
<<
endl;
...
...
@@ -881,6 +882,15 @@ end_private(false)
// ----------
</xsl:for-each>
// ===================== end of
<
variables
>
=====================
vmonit(sleep_msec);
vmonit(resetMsgTime);
vmonit(forceOut);
vmonit(argprefix);
vmonit(idHeartBeat);
vmonit(maxHeartBeat);
vmonit(activateTimeout);
vmonit(smReadyTimeout);
}
// -----------------------------------------------------------------------------
...
...
conf/libuniset2.spec
View file @
b0299b2e
...
...
@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.1
Release: alt7.
2
Release: alt7.
3
Summary: UniSet - library for building distributed industrial control systems
...
...
@@ -456,6 +456,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Sun Jun 07 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt7.3
- (vmonitor): added support vmonitor for standart components
(SharedMemory,ModbusSlave,ModbusMaster,UNetUDP)
* Sun Jun 07 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt7.2
- (codegen): add user info function (getMonitInfo())
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
b0299b2e
...
...
@@ -76,9 +76,14 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId
mbinfo
<<
myname
<<
"(init): read fileter-field='"
<<
s_field
<<
"' filter-value='"
<<
s_fvalue
<<
"'"
<<
endl
;
vmonit
(
s_field
);
vmonit
(
s_fvalue
);
prop_prefix
=
initPropPrefix
();
vmonit
(
prop_prefix
);
stat_time
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-statistic-sec"
,
it
.
getProp
(
"statistic_sec"
),
0
);
vmonit
(
stat_time
);
if
(
stat_time
>
0
)
ptStatistic
.
setTiming
(
stat_time
*
1000
);
...
...
@@ -89,15 +94,20 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId
int
tout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-reopen-timeout"
,
it
.
getProp
(
"reopen_timeout"
),
default_timeout
*
2
);
ptReopen
.
setTiming
(
tout
);
vmonit
(
recv_timeout
);
aftersend_pause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-aftersend-pause"
,
it
.
getProp
(
"aftersend_pause"
),
0
);
vmonit
(
aftersend_pause
);
noQueryOptimization
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-no-query-optimization"
,
it
.
getProp
(
"no_query_optimization"
));
vmonit
(
noQueryOptimization
);
mbregFromID
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-reg-from-id"
,
it
.
getProp
(
"reg_from_id"
));
mbinfo
<<
myname
<<
"(init): mbregFromID="
<<
mbregFromID
<<
endl
;
vmonit
(
mbregFromID
);
polltime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-polltime"
,
it
.
getProp
(
"polltime"
),
100
);
vmonit
(
polltime
);
initPause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-initPause"
,
it
.
getProp
(
"initPause"
),
3000
);
...
...
@@ -105,12 +115,19 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId
force
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
));
force_out
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force-out"
,
it
.
getProp
(
"force_out"
));
vmonit
(
force
);
vmonit
(
force_out
);
defaultMBtype
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-default-mbtype"
,
it
.
getProp
(
"default_mbtype"
),
"rtu"
);
defaultMBaddr
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-default-mbaddr"
,
it
.
getProp
(
"default_mbaddr"
),
""
);
vmonit
(
defaultMBtype
);
vmonit
(
defaultMBaddr
);
defaultMBinitOK
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-default-mbinit-ok"
,
it
.
getProp
(
"default_mbinitOK"
),
0
);
vmonit
(
defaultMBinitOK
);
// ********** HEARTBEAT *************
string
heart
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
...
...
@@ -167,6 +184,8 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId
}
activateTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-activate-timeout"
,
20000
);
vmonit
(
allInitOK
);
}
// -----------------------------------------------------------------------------
std
::
string
MBExchange
::
initPropPrefix
(
const
std
::
string
&
def_prop_prefix
)
...
...
@@ -3191,3 +3210,17 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::ExchangeMode& em )
return
os
;
}
// -----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
MBExchange
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
UniSetObject_LT
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// ----------------------------------------------------------------------------
extensions/ModbusMaster/MBExchange.h
View file @
b0299b2e
...
...
@@ -24,6 +24,11 @@
#include "LogAgregator.h"
#include "LogServer.h"
#include "LogAgregator.h"
#include "VMonitor.h"
// -----------------------------------------------------------------------------
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// -----------------------------------------------------------------------------
/*!
\par Базовый класс для реализация обмена по протоколу Modbus [RTU|TCP].
...
...
@@ -226,6 +231,8 @@ class MBExchange:
return
mblog
;
}
virtual
UniSetTypes
::
SimpleInfo
*
getInfo
()
override
;
protected
:
virtual
void
step
();
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
msg
)
override
;
...
...
@@ -368,6 +375,8 @@ class MBExchange:
int
logserv_port
=
{
0
};
const
std
::
shared_ptr
<
SharedMemory
>
ic
;
VMonitor
vmon
;
private
:
MBExchange
();
...
...
extensions/ModbusMaster/MBTCPMaster.cc
View file @
b0299b2e
...
...
@@ -245,3 +245,16 @@ std::shared_ptr<MBTCPMaster> MBTCPMaster::init_mbmaster( int argc, const char* c
return
make_shared
<
MBTCPMaster
>
(
ID
,
icID
,
ic
,
prefix
);
}
// -----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
MBTCPMaster
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
MBExchange
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
"poll: "
<<
iaddr
<<
":"
<<
port
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// ----------------------------------------------------------------------------
extensions/ModbusMaster/MBTCPMaster.h
View file @
b0299b2e
...
...
@@ -206,6 +206,8 @@ class MBTCPMaster:
/*! глобальная функция для вывода help-а */
static
void
help_print
(
int
argc
,
const
char
*
const
*
argv
);
virtual
UniSetTypes
::
SimpleInfo
*
getInfo
()
override
;
protected
:
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
)
override
;
virtual
std
::
shared_ptr
<
ModbusClient
>
initMB
(
bool
reopen
=
false
)
override
;
...
...
extensions/ModbusMaster/MBTCPMultiMaster.cc
View file @
b0299b2e
...
...
@@ -482,3 +482,27 @@ std::shared_ptr<MBTCPMultiMaster> MBTCPMultiMaster::init_mbmaster( int argc, con
return
make_shared
<
MBTCPMultiMaster
>
(
ID
,
icID
,
ic
,
prefix
);
}
// -----------------------------------------------------------------------------
const
std
::
string
MBTCPMultiMaster
::
MBSlaveInfo
::
getShortInfo
()
const
{
ostringstream
s
;
s
<<
myname
<<
" respond="
<<
respond
;
return
std
::
move
(
s
.
str
());
}
// -----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
MBTCPMultiMaster
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
MBExchange
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
"Gates: "
<<
endl
;
for
(
const
auto
&
m
:
mblist
)
inf
<<
" "
<<
m
.
getShortInfo
()
<<
endl
;
inf
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// ----------------------------------------------------------------------------
extensions/ModbusMaster/MBTCPMultiMaster.h
View file @
b0299b2e
...
...
@@ -226,6 +226,8 @@ class MBTCPMultiMaster:
/*! глобальная функция для вывода help-а */
static
void
help_print
(
int
argc
,
const
char
*
const
*
argv
);
virtual
UniSetTypes
::
SimpleInfo
*
getInfo
()
override
;
protected
:
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
)
override
;
virtual
void
initIterators
()
override
;
...
...
@@ -280,6 +282,8 @@ class MBTCPMultiMaster:
bool
initOK
;
bool
ignore
;
// игнорировать данное соединение (обычно флаг выставляется на время ignoreTimeout, если узел не отвечает, хотя связь есть.
PassiveTimer
ptIgnoreTimeout
;
const
std
::
string
getShortInfo
()
const
;
};
typedef
std
::
list
<
MBSlaveInfo
>
MBGateList
;
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
b0299b2e
...
...
@@ -14,6 +14,7 @@ using namespace ModbusRTU;
// -----------------------------------------------------------------------------
MBSlave
::
MBSlave
(
UniSetTypes
::
ObjectId
objId
,
UniSetTypes
::
ObjectId
shmId
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
,
const
string
&
prefix
)
:
UniSetObject_LT
(
objId
),
addr
(
0x01
),
initPause
(
0
),
test_id
(
DefaultObjectId
),
askcount_id
(
DefaultObjectId
),
...
...
@@ -74,6 +75,9 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons
mbinfo
<<
myname
<<
"(init): read s_field='"
<<
s_field
<<
"' s_fvalue='"
<<
s_fvalue
<<
"'"
<<
endl
;
vmonit
(
s_field
);
vmonit
(
s_fvalue
);
// префикс для "свойств" - по умолчанию
prop_prefix
=
""
;
...
...
@@ -95,13 +99,18 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons
prop_prefix
=
""
;
}
vmonit
(
prop_prefix
);
mbinfo
<<
myname
<<
"(init): prop_prefix="
<<
prop_prefix
<<
endl
;
force
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-force"
,
it
.
getProp
(
"force"
));
// int recv_timeout = conf->getArgParam("--" + prefix + "-recv-timeout",it.getProp("recv_timeout")));
vmonit
(
force
);
addr
=
ModbusRTU
::
str2mbAddr
(
conf
->
getArg2Param
(
"--"
+
prefix
+
"-my-addr"
,
it
.
getProp
(
"addr"
),
"0x01"
));
vmonit
(
addr
);
default_mbfunc
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-default-mbfunc"
,
it
.
getProp
(
"default_mbfunc"
),
0
);
...
...
@@ -114,6 +123,11 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons
<<
" noMBFuncOptimize="
<<
noMBFuncOptimize
<<
endl
;
vmonit
(
default_mbfunc
);
vmonit
(
checkMBFunc
);
vmonit
(
noMBFuncOptimize
);
respond_id
=
conf
->
getSensorID
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-respond-id"
,
it
.
getProp
(
"respond_id"
)));
respond_invert
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-respond-invert"
,
it
.
getProp
(
"respond_invert"
));
...
...
@@ -2226,3 +2240,19 @@ ModbusRTU::mbErrCode MBSlave::read4314( ModbusRTU::MEIMessageRDI& query,
return
erNoError
;
}
// -------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
MBSlave
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
UniSetObject_LT
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// ----------------------------------------------------------------------------
extensions/ModbusSlave/MBSlave.h
View file @
b0299b2e
...
...
@@ -21,6 +21,11 @@
#include "ThreadCreator.h"
#include "LogServer.h"
#include "LogAgregator.h"
#include "VMonitor.h"
// -----------------------------------------------------------------------------
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// -----------------------------------------------------------------------------
/*!
\page page_ModbusSlave Реализация Modbus slave
...
...
@@ -358,6 +363,8 @@ class MBSlave:
return
mblog
;
}
virtual
UniSetTypes
::
SimpleInfo
*
getInfo
()
override
;
protected
:
/*! обработка 0x01 */
...
...
@@ -427,7 +434,7 @@ class MBSlave:
IOMap
iomap
;
/*!< список входов/выходов */
std
::
shared_ptr
<
ModbusServerSlot
>
mbslot
;
ModbusRTU
::
ModbusAddr
addr
;
/*!< адрес данного узла */
ModbusRTU
::
ModbusAddr
addr
=
{
0x01
};
/*!< адрес данного узла */
xmlNode
*
cnode
;
std
::
string
s_field
;
...
...
@@ -528,6 +535,7 @@ class MBSlave:
std
::
shared_ptr
<
LogServer
>
logserv
;
std
::
string
logserv_host
=
{
""
};
int
logserv_port
=
{
0
};
VMonitor
vmon
;
};
// -----------------------------------------------------------------------------
#endif // _MBSlave_H_
...
...
extensions/ModbusSlave/MBTCPMultiSlave.cc
View file @
b0299b2e
...
...
@@ -31,16 +31,21 @@ MBTCPMultiSlave::MBTCPMultiSlave( UniSetTypes::ObjectId objId, UniSetTypes::Obje
if
(
waitTimeout
==
0
)
waitTimeout
=
4000
;
vmonit
(
waitTimeout
);
sessTimeout
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-session-timeout"
,
it
.
getProp
(
"sessTimeout"
));
if
(
sessTimeout
==
0
)
sessTimeout
=
10000
;
vmonit
(
sessTimeout
);
sessMaxNum
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-session-maxnum"
,
it
.
getProp
(
"sessMaxNum"
));
if
(
sessMaxNum
==
0
)
sessMaxNum
=
10
;
vmonit
(
sessMaxNum
);
sesscount_id
=
conf
->
getSensorID
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-session-count-id"
,
it
.
getProp
(
"sesscount"
))
);
UniXML
::
iterator
cit
(
it
);
...
...
@@ -349,3 +354,28 @@ void MBTCPMultiSlave::sigterm( int signo )
MBSlave
::
sigterm
(
signo
);
}
// -----------------------------------------------------------------------------
const
std
::
string
MBTCPMultiSlave
::
ClientInfo
::
getShortInfo
()
const
{
ostringstream
s
;
s
<<
iaddr
<<
" askCount="
<<
askCount
;
return
std
::
move
(
s
.
str
());
}
// -----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
MBTCPMultiSlave
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
MBSlave
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
"Clients: "
<<
endl
;
for
(
const
auto
&
m
:
cmap
)
inf
<<
" "
<<
m
.
second
.
getShortInfo
()
<<
endl
;
inf
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// ----------------------------------------------------------------------------
extensions/ModbusSlave/MBTCPMultiSlave.h
View file @
b0299b2e
...
...
@@ -32,6 +32,8 @@ class MBTCPMultiSlave:
/*! глобальная функция для вывода help-а */
static
void
help_print
(
int
argc
,
const
char
*
const
*
argv
);
UniSetTypes
::
SimpleInfo
*
getInfo
()
override
;
protected
:
virtual
void
execute_tcp
()
override
;
virtual
void
initIterators
()
override
;
...
...
@@ -68,6 +70,8 @@ class MBTCPMultiSlave:
shm
->
initIterator
(
respond_it
);
shm
->
initIterator
(
askcount_it
);
}
const
std
::
string
getShortInfo
()
const
;
};
typedef
std
::
unordered_map
<
std
::
string
,
ClientInfo
>
ClientsMap
;
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
b0299b2e
...
...
@@ -159,6 +159,17 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
msecPulsar
=
conf
->
getArgPInt
(
"--pulsar-msec"
,
it
.
getProp
(
"pulsar_msec"
),
5000
);
}
// Мониторинг переменных
vmonit
(
sidPulsar
);
vmonit
(
msecPulsar
);
vmonit
(
activateTimeout
);
vmonit
(
evntPause
);
vmonit
(
heartbeatCheckTime
);
vmonit
(
histSaveTime
);
vmonit
(
dblogging
);
vmonit
(
heartbeatCheckTime
);
vmonit
(
heartbeat_node
);
}
// --------------------------------------------------------------------------------
...
...
@@ -944,3 +955,18 @@ bool SharedMemory::initFromSM( UniSetTypes::ObjectId sm_id, UniSetTypes::ObjectI
return
false
;
}
// ----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
SharedMemory
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
IONotifyController_LT
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// ----------------------------------------------------------------------------
extensions/SharedMemory/SharedMemory.h
View file @
b0299b2e
...
...
@@ -14,6 +14,11 @@
#include "LogServer.h"
#include "DebugStream.h"
#include "LogAgregator.h"
#include "VMonitor.h"
// -----------------------------------------------------------------------------
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// -----------------------------------------------------------------------------
/*! \page page_SharedMemory Реализация разделямой между процессами памяти (SharedMemory)
...
...
@@ -291,7 +296,9 @@ class SharedMemory:
// функция определяет "готовность" SM к работе.
// должна использоваться другими процессами, для того,
// чтобы понять, когда можно получать от SM данные.
virtual
CORBA
::
Boolean
exist
();
virtual
CORBA
::
Boolean
exist
()
override
;
virtual
UniSetTypes
::
SimpleInfo
*
getInfo
()
override
;
void
addReadItem
(
Restorer_XML
::
ReaderSlot
sl
);
...
...
@@ -483,6 +490,8 @@ class SharedMemory:
std
::
string
logserv_host
=
{
""
};
int
logserv_port
=
{
0
};
VMonitor
vmon
;
private
:
HistorySlot
m_historySignal
;
};
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
b0299b2e
#include <sstream>
#include <iomanip>
#include "Exceptions.h"
#include "Extensions.h"
#include "UNetExchange.h"
...
...
@@ -414,6 +415,11 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
if
(
ic
)
ic
->
logAgregator
()
->
add
(
loga
);
vmonit
(
s_field
);
vmonit
(
s_fvalue
);
vmonit
(
maxHeartBeat
);
}
// -----------------------------------------------------------------------------
UNetExchange
::~
UNetExchange
()
...
...
@@ -886,3 +892,36 @@ void UNetExchange::receiverEvent( const shared_ptr<UNetReceiver>& r, UNetReceive
}
}
// -----------------------------------------------------------------------------
UniSetTypes
::
SimpleInfo
*
UNetExchange
::
getInfo
()
{
UniSetTypes
::
SimpleInfo_var
i
=
UniSetObject_LT
::
getInfo
();
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
endl
;
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
inf
<<
endl
;
inf
<<
"Receivers: "
<<
endl
;
for
(
const
auto
&
r
:
recvlist
)
{
inf
<<
"[ "
<<
endl
;
inf
<<
" chan1: "
<<
(
r
.
r1
?
r
.
r1
->
getShortInfo
()
:
"disable"
)
<<
endl
;
inf
<<
" chan2: "
<<
(
r
.
r2
?
r
.
r2
->
getShortInfo
()
:
"disable"
)
<<
endl
;
inf
<<
"]"
<<
endl
;
}
inf
<<
endl
;
inf
<<
"Senders: "
<<
endl
;
inf
<<
"[ "
<<
endl
;
inf
<<
" chan1: "
<<
(
sender
?
sender
->
getShortInfo
()
:
"disable"
)
<<
endl
;
inf
<<
" chan2: "
<<
(
sender2
?
sender2
->
getShortInfo
()
:
"disable"
)
<<
endl
;
inf
<<
"]"
<<
endl
;
inf
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
return
i
.
_retn
();
}
// ----------------------------------------------------------------------------
extensions/UNetUDP/UNetExchange.h
View file @
b0299b2e
...
...
@@ -18,6 +18,11 @@
#include "DebugStream.h"
#include "UNetLogSugar.h"
#include "LogAgregator.h"
#include "VMonitor.h"
// -----------------------------------------------------------------------------
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// -----------------------------------------------------------------------------
/*!
\page pageUNetExchangeUDP Сетевой обмен на основе UDP (UNetUDP)
...
...
@@ -108,6 +113,8 @@ class UNetExchange:
return
unetlog
;
}
virtual
UniSetTypes
::
SimpleInfo
*
getInfo
()
override
;
protected
:
xmlNode
*
cnode
;
...
...
@@ -221,6 +228,8 @@ class UNetExchange:
std
::
shared_ptr
<
LogServer
>
logserv
;
std
::
string
logserv_host
=
{
""
};
int
logserv_port
=
{
0
};
VMonitor
vmon
;
};
// -----------------------------------------------------------------------------
#endif // UNetExchange_H_
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
b0299b2e
#include <sstream>
#include <iomanip>
#include <iomanip>
#include "Exceptions.h"
#include "Extensions.h"
#include "UNetReceiver.h"
...
...
@@ -603,3 +604,18 @@ void UNetReceiver::connectEvent( UNetReceiver::EventSlot sl )
slEvent
=
sl
;
}
// -----------------------------------------------------------------------------
const
std
::
string
UNetReceiver
::
getShortInfo
()
const
{
// warning: будет вызываться из другого потока
// (считаем что чтение безопасно)
ostringstream
s
;
s
<<
setw
(
15
)
<<
std
::
right
<<
getAddress
()
<<
":"
<<
std
::
left
<<
setw
(
6
)
<<
getPort
()
<<
(
isLockUpdate
()
?
"PASSIVE"
:
"ACTIVE"
)
<<
" recvOK="
<<
isRecvOK
()
<<
" lostPackets="
<<
setw
(
6
)
<<
getLostPacketsNum
();
return
std
::
move
(
s
.
str
());
}
// -----------------------------------------------------------------------------
extensions/UNetUDP/UNetReceiver.h
View file @
b0299b2e
...
...
@@ -54,7 +54,7 @@ class UNetReceiver:
{
public
:
UNetReceiver
(
const
std
::
string
&
host
,
const
ost
::
tpport_t
port
,
const
std
::
shared_ptr
<
SMInterface
>&
smi
);
~
UNetReceiver
();
virtual
~
UNetReceiver
();
void
start
();
void
stop
();
...
...
@@ -62,25 +62,25 @@ class UNetReceiver:
void
receive
();
void
update
();
inline
std
::
string
getName
()
inline
const
std
::
string
getName
()
const
{
return
myname
;
}
// блокировать сохранение данных в SM
void
setLockUpdate
(
bool
st
);
inline
bool
isLockUpdate
()
inline
bool
isLockUpdate
()
const
{
return
lockUpdate
;
}
void
resetTimeout
();
inline
bool
isRecvOK
()
inline
bool
isRecvOK
()
const
{
return
!
ptRecvTimeout
.
checkTime
();
}
inline
unsigned
long
getLostPacketsNum
()
inline
unsigned
long
getLostPacketsNum
()
const
{
return
lostPackets
;
}
...
...
@@ -99,11 +99,11 @@ class UNetReceiver:
void
forceUpdate
();
// пересохранить очередной пакет в SM даже если данные не менялись
inline
ost
::
IPV4Address
getAddress
()
inline
ost
::
IPV4Address
getAddress
()
const
{
return
addr
;
}
inline
ost
::
tpport_t
getPort
()
inline
ost
::
tpport_t
getPort
()
const
{
return
port
;
}
...
...
@@ -123,6 +123,8 @@ class UNetReceiver:
return
unetlog
;
}
virtual
const
std
::
string
getShortInfo
()
const
;
protected
:
const
std
::
shared_ptr
<
SMInterface
>
shm
;
...
...
extensions/UNetUDP/UNetSender.cc
View file @
b0299b2e
...
...
@@ -367,3 +367,18 @@ void UNetSender::askSensors( UniversalIO::UIOCommand cmd )
shm
->
askSensor
(
it
.
id
,
cmd
);
}
// -----------------------------------------------------------------------------
const
std
::
string
UNetSender
::
getShortInfo
()
const
{
// warning: будет вызываться из другого потока
// (считаем что чтение безопасно)
ostringstream
s
;
s
<<
setw
(
15
)
<<
std
::
right
<<
getAddress
()
<<
":"
<<
std
::
left
<<
setw
(
6
)
<<
getPort
()
<<
" packetnum="
<<
packetnum
<<
" lastcrc="
<<
setw
(
6
)
<<
lastcrc
;
return
std
::
move
(
s
.
str
());
}
// -----------------------------------------------------------------------------
extensions/UNetUDP/UNetSender.h
View file @
b0299b2e
...
...
@@ -25,7 +25,7 @@ class UNetSender
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
();
virtual
~
UNetSender
();
struct
UItem
{
...
...
@@ -75,6 +75,18 @@ class UNetSender
return
unetlog
;
}
virtual
const
std
::
string
getShortInfo
()
const
;
inline
ost
::
IPV4Address
getAddress
()
const
{
return
addr
;
}
inline
ost
::
tpport_t
getPort
()
const
{
return
port
;
}
protected
:
std
::
string
s_field
;
...
...
include/PassiveTimer.h
View file @
b0299b2e
...
...
@@ -42,7 +42,7 @@ class UniSetTimer
public
:
virtual
~
UniSetTimer
()
{};
virtual
bool
checkTime
()
=
0
;
/*!< проверка наступления заданного времени */
virtual
bool
checkTime
()
const
=
0
;
/*!< проверка наступления заданного времени */
virtual
timeout_t
setTiming
(
timeout_t
msec
)
=
0
;
/*!< установить таймер и запустить */
virtual
void
reset
()
=
0
;
/*!< перезапустить таймер */
...
...
@@ -100,7 +100,7 @@ class PassiveTimer:
virtual
~
PassiveTimer
();
virtual
bool
checkTime
();
/*!< проверка наступления заданного времени */
virtual
bool
checkTime
()
const
;
/*!< проверка наступления заданного времени */
virtual
timeout_t
setTiming
(
timeout_t
msec
);
/*!< установить таймер и запустить. timeMS = 0 вызовет немедленное срабатывание */
virtual
void
reset
();
/*!< перезапустить таймер */
...
...
include/VMonitor.h
View file @
b0299b2e
...
...
@@ -26,6 +26,7 @@
#include <string>
#include <ostream>
#include <unordered_map>
#include "UniSetTypes.h"
// --------------------------------------------------------------------------
#ifndef VMON_DEF_FUNC
#define VMON_DEF_FUNC(T) void add( const std::string& name, const T& v )
...
...
@@ -45,6 +46,11 @@
std::unordered_map<const T*,const std::string> m_##T; \
std::unordered_map<const unsigned T*,const std::string> m_unsigned_##T
#endif
#ifndef VMON_DEF_MAP3
#define VMON_DEF_MAP3(T,M) std::unordered_map<const T*,const std::string> m_##M
#endif
// --------------------------------------------------------------------------
/* EXAMPLE HELPER MACROS
...
...
@@ -111,9 +117,13 @@ class VMonitor
VMON_DEF_FUNC2
(
int
);
VMON_DEF_FUNC2
(
long
);
VMON_DEF_FUNC2
(
short
);
VMON_DEF_FUNC2
(
char
);
VMON_DEF_FUNC
(
bool
);
VMON_DEF_FUNC
(
float
);
VMON_DEF_FUNC
(
double
);
// VMON_DEF_FUNC(UniSetTypes::ObjectId); // <--- long
void
add
(
const
std
::
string
&
name
,
const
std
::
string
&
v
);
protected
:
...
...
@@ -122,9 +132,12 @@ class VMonitor
VMON_DEF_MAP2
(
int
);
VMON_DEF_MAP2
(
long
);
VMON_DEF_MAP2
(
short
);
VMON_DEF_MAP2
(
char
);
VMON_DEF_MAP
(
bool
);
VMON_DEF_MAP
(
float
);
VMON_DEF_MAP
(
double
);
// VMON_DEF_MAP3(UniSetTypes::ObjectId,ObjectId); // <-- long
VMON_DEF_MAP3
(
std
::
string
,
string
);
};
// --------------------------------------------------------------------------
#endif
src/Timers/PassiveTimer.cc
View file @
b0299b2e
...
...
@@ -45,7 +45,7 @@ PassiveTimer::~PassiveTimer()
}
//------------------------------------------------------------------------------
bool
PassiveTimer
::
checkTime
()
bool
PassiveTimer
::
checkTime
()
const
{
if
(
t_msec
==
WaitUpTime
)
return
false
;
...
...
src/Various/VMonitor.cc
View file @
b0299b2e
...
...
@@ -19,6 +19,11 @@ void VMonitor::add( const std::string& name, const unsigned T& v ) \
m_unsigned_##T.emplace(&v,name); \
}
// --------------------------------------------------------------------------
#define VMON_IMPL_ADD3(T,M) void VMonitor::add( const std::string& name, const T& v ) \
{\
m_##M.emplace(&v,name); \
}
// --------------------------------------------------------------------------
#define VMON_IMPL_PRN(M,T) \
{\
for( const auto& e: M.m_##T ) \
...
...
@@ -34,36 +39,60 @@ void VMonitor::add( const std::string& name, const unsigned T& v ) \
os << e.second << "=" << *(e.first) << std::endl;\
}
// --------------------------------------------------------------------------
#define VMON_IMPL_PRN_CHAR(M) \
{\
for( const auto& e: M.m_char ) \
os << e.second << "=" << (int)(*(e.first)) << std::endl;\
\
for( const auto& e: M.m_unsigned_char) \
os << e.second << "=" << (int)(*(e.first)) << std::endl;\
}
// --------------------------------------------------------------------------
#define VMON_IMPL_PRET(T) \
{\
for( const auto& e: m_##T ) \
os << std::right << std::setw(
1
5) << e.second << std::left << " = " << std::right << std::setw(6) << *(e.first) << std::endl;\
os << std::right << std::setw(
2
5) << e.second << std::left << " = " << std::right << std::setw(6) << *(e.first) << std::endl;\
}
// --------------------------------------------------------------------------
#define VMON_IMPL_PRET2(T) \
{\
for( const auto& e: m_##T ) \
os << std::right << std::setw(
1
5) << e.second << std::left << " = " << std::right << std::setw(6) << *(e.first) << std::endl;\
os << std::right << std::setw(
2
5) << e.second << std::left << " = " << std::right << std::setw(6) << *(e.first) << std::endl;\
\
for( const auto& e: m_unsigned_##T ) \
os << std::right << std::setw(15) << e.second << std::left << " = " << std::right << std::setw(6) << *(e.first) << std::endl;\
os << std::right << std::setw(25) << e.second << std::left << " = " << std::right << std::setw(6) << *(e.first) << std::endl;\
}
// --------------------------------------------------------------------------
#define VMON_IMPL_PRET_CHAR \
{\
for( const auto& e: m_char ) \
os << std::right << std::setw(25) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first)) << std::endl;\
\
for( const auto& e: m_unsigned_char ) \
os << std::right << std::setw(25) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first)) << std::endl;\
}
// --------------------------------------------------------------------------
VMON_IMPL_ADD2
(
int
)
VMON_IMPL_ADD2
(
long
)
VMON_IMPL_ADD2
(
short
)
VMON_IMPL_ADD2
(
char
)
VMON_IMPL_ADD
(
bool
)
VMON_IMPL_ADD
(
float
)
VMON_IMPL_ADD
(
double
)
VMON_IMPL_ADD3
(
std
::
string
,
string
)
//VMON_IMPL_ADD3(UniSetTypes::ObjectId,ObjectId)
// --------------------------------------------------------------------------
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
VMonitor
&
m
)
{
VMON_IMPL_PRN2
(
m
,
int
);
VMON_IMPL_PRN2
(
m
,
long
);
VMON_IMPL_PRN2
(
m
,
short
);
VMON_IMPL_PRN_CHAR
(
m
);
VMON_IMPL_PRN
(
m
,
bool
);
VMON_IMPL_PRN
(
m
,
float
);
VMON_IMPL_PRN
(
m
,
double
);
VMON_IMPL_PRN
(
m
,
string
);
// VMON_IMPL_PRN(m,ObjectId);
return
os
;
}
...
...
@@ -82,9 +111,12 @@ std::string VMonitor::pretty_str()
VMON_IMPL_PRET2
(
int
);
VMON_IMPL_PRET2
(
long
);
VMON_IMPL_PRET2
(
short
);
VMON_IMPL_PRET_CHAR
;
VMON_IMPL_PRET
(
bool
);
VMON_IMPL_PRET
(
float
);
VMON_IMPL_PRET
(
double
);
VMON_IMPL_PRET
(
string
);
// VMON_IMPL_PRET(ObjectId);
return
std
::
move
(
os
.
str
());
}
...
...
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