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
e77133e0
Commit
e77133e0
authored
Jul 13, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Рефакторинг: расстановка const, перенос реализации из h-файлов
parent
f2e95a15
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
295 additions
and
213 deletions
+295
-213
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+2
-2
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+1
-1
UObject_SK.h
extensions/include/UObject_SK.h
+2
-2
UObject_SK.cc
extensions/lib/UObject_SK.cc
+2
-2
ComPort.h
include/ComPort.h
+2
-8
IOController.h
include/IOController.h
+4
-5
LT_Object.h
include/LT_Object.h
+1
-1
LogReader.h
include/LogReader.h
+7
-30
LogServer.h
include/LogServer.h
+5
-21
LogServerTypes.h
include/LogServerTypes.h
+4
-3
LogSession.h
include/LogSession.h
+5
-17
ObjectIndex.h
include/ObjectIndex.h
+2
-8
ObjectRepository.h
include/ObjectRepository.h
+4
-4
ThreadCreator.h
include/ThreadCreator.h
+2
-2
ModbusRTUMaster.h
include/modbus/ModbusRTUMaster.h
+2
-5
ModbusServer.h
include/modbus/ModbusServer.h
+9
-33
ModbusTCPMaster.h
include/modbus/ModbusTCPMaster.h
+4
-16
ModbusTCPServer.h
include/modbus/ModbusTCPServer.h
+10
-31
ModbusTCPSession.h
include/modbus/ModbusTCPSession.h
+1
-4
ComPort.cc
src/Communications/ComPort.cc
+10
-0
ModbusRTUMaster.cc
src/Communications/Modbus/ModbusRTUMaster.cc
+7
-1
ModbusServer.cc
src/Communications/Modbus/ModbusServer.cc
+41
-1
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+20
-0
ModbusTCPServer.cc
src/Communications/Modbus/ModbusTCPServer.cc
+36
-1
ModbusTCPSession.cc
src/Communications/Modbus/ModbusTCPSession.cc
+5
-0
LogReader.cc
src/Log/LogReader.cc
+35
-0
LogServer.cc
src/Log/LogServer.cc
+25
-0
LogSession.cc
src/Log/LogSession.cc
+20
-0
ObjectIndex.cc
src/ObjectRepository/ObjectIndex.cc
+10
-0
ObjectRepository.cc
src/ObjectRepository/ObjectRepository.cc
+4
-4
IOController.cc
src/Processes/IOController.cc
+0
-5
Configuration.cc
src/Various/Configuration.cc
+11
-4
LT_Object.cc
src/Various/LT_Object.cc
+2
-2
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
e77133e0
...
...
@@ -252,7 +252,7 @@
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return vmon.pretty_str(); }
// ------------------------------------------------------------
std::string help() noexcept;
std::string help()
const
noexcept;
<xsl:if
test=
"normalize-space($DISABLE_REST_API)!='1'"
>
#ifndef DISABLE_REST_API
...
...
@@ -869,7 +869,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
}
}
// ----------------------------------------------------------------------------
std::string
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::help() noexcept
std::string
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::help()
const
noexcept
{
ostringstream s;
s
<<
" ************* "
<<
myname
<<
" HELP:"
<<
" ************* "
<<
endl;
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
e77133e0
...
...
@@ -587,7 +587,7 @@ namespace uniset
bool
ok
=
false
;
tm
.
consumer
=
it
;
for
(
unsigned
in
t
i
=
0
;
i
<
2
;
i
++
)
for
(
size_
t
i
=
0
;
i
<
2
;
i
++
)
{
try
{
...
...
extensions/include/UObject_SK.h
View file @
e77133e0
...
...
@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2017-07-
02
+03:00
// generate timestamp: 2017-07-
13
+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
...
...
@@ -118,7 +118,7 @@ class UObject_SK:
/*! Вывод состояния внутренних переменных */
inline
std
::
string
dumpVars
(){
return
vmon
.
pretty_str
();
}
// ------------------------------------------------------------
std
::
string
help
()
noexcept
;
std
::
string
help
()
const
noexcept
;
#ifndef DISABLE_REST_API
...
...
extensions/lib/UObject_SK.cc
View file @
e77133e0
...
...
@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2017-07-
02
+03:00
// generate timestamp: 2017-07-
13
+03:00
// -----------------------------------------------------------------------------
#include <memory>
#include <iomanip>
...
...
@@ -717,7 +717,7 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
}
}
// ----------------------------------------------------------------------------
std
::
string
UObject_SK
::
help
()
noexcept
std
::
string
UObject_SK
::
help
()
const
noexcept
{
ostringstream
s
;
s
<<
" ************* "
<<
myname
<<
" HELP:"
<<
" ************* "
<<
endl
;
...
...
include/ComPort.h
View file @
e77133e0
...
...
@@ -95,10 +95,7 @@ namespace uniset
void
setSpeed
(
Speed
s
);
void
setSpeed
(
const
std
::
string
&
speed
);
inline
Speed
getSpeed
()
{
return
speed
;
}
Speed
getSpeed
()
const
;
static
Speed
getSpeed
(
const
std
::
string
&
s
);
static
std
::
string
getSpeed
(
Speed
s
);
...
...
@@ -108,10 +105,7 @@ namespace uniset
void
setStopBits
(
StopBits
sBit
);
virtual
void
setTimeout
(
timeout_t
msec
);
inline
timeout_t
getTimeout
()
{
return
uTimeout
/
1000
;
// msec
}
timeout_t
getTimeout
()
const
;
void
setWaiting
(
bool
waiting
);
...
...
include/IOController.h
View file @
e77133e0
...
...
@@ -150,7 +150,8 @@ namespace uniset
{
return
ioList
.
find
(
k
);
}
inline
int
ioCount
()
const
inline
int
ioCount
()
const
noexcept
{
return
ioList
.
size
();
}
...
...
@@ -250,8 +251,6 @@ namespace uniset
IOStateList
::
iterator
myioBegin
();
IOStateList
::
iterator
myioEnd
();
IOStateList
::
iterator
myiofind
(
uniset
::
ObjectId
id
);
size_t
ioCount
();
// --------------------------
private
:
friend
class
NCRestorer
;
...
...
@@ -338,7 +337,7 @@ namespace uniset
{
uniset
::
uniset_rwmutex_rlock
lock
(
val_lock
);
IOController_i
::
SensorIOInfo
s
(
*
this
);
return
s
td
::
move
(
s
)
;
return
s
;
}
inline
uniset
::
SensorMessage
makeSensorMessage
(
bool
with_lock
=
false
)
...
...
@@ -370,7 +369,7 @@ namespace uniset
sm
.
undefined
=
undefined
;
}
return
s
td
::
move
(
sm
)
;
return
s
m
;
}
};
};
...
...
include/LT_Object.h
View file @
e77133e0
...
...
@@ -72,7 +72,7 @@ namespace uniset
sleepTime=lt.checkTimers(this);
}
catch(
Exception& ex)
catch( uniset::
Exception& ex)
{
cout << myname << "(callback): " << ex << endl;
}
...
...
include/LogReader.h
View file @
e77133e0
...
...
@@ -52,42 +52,19 @@ namespace uniset
bool
isConnection
()
const
;
inline
void
setReadCount
(
unsigned
int
n
)
{
readcount
=
n
;
}
void
setReadCount
(
unsigned
int
n
);
void
setCommandOnlyMode
(
bool
s
);
inline
void
setCommandOnlyMode
(
bool
s
)
{
cmdonly
=
s
;
}
inline
void
setinTimeout
(
timeout_t
msec
)
{
inTimeout
=
msec
;
}
inline
void
setoutTimeout
(
timeout_t
msec
)
{
outTimeout
=
msec
;
}
inline
void
setReconnectDelay
(
timeout_t
msec
)
{
reconDelay
=
msec
;
}
inline
void
setTextFilter
(
const
std
::
string
&
f
)
{
textfilter
=
f
;
}
void
setinTimeout
(
timeout_t
msec
);
void
setoutTimeout
(
timeout_t
msec
);
void
setReconnectDelay
(
timeout_t
msec
);
void
setTextFilter
(
const
std
::
string
&
f
);
DebugStream
::
StreamEvent_Signal
signal_stream_event
();
void
setLogLevel
(
Debug
::
type
t
);
inline
std
::
shared_ptr
<
DebugStream
>
log
()
{
return
outlog
;
}
std
::
shared_ptr
<
DebugStream
>
log
();
protected
:
...
...
include/LogServer.h
View file @
e77133e0
...
...
@@ -98,29 +98,16 @@ namespace uniset
LogServer
(
std
::
shared_ptr
<
LogAgregator
>
log
);
virtual
~
LogServer
()
noexcept
;
inline
void
setCmdTimeout
(
timeout_t
msec
)
noexcept
{
cmdTimeout
=
msec
;
}
inline
void
setSessionLog
(
Debug
::
type
t
)
noexcept
{
sessLogLevel
=
t
;
}
inline
void
setMaxSessionCount
(
int
num
)
noexcept
{
sessMaxCount
=
num
;
}
void
setCmdTimeout
(
timeout_t
msec
)
noexcept
;
void
setSessionLog
(
Debug
::
type
t
)
noexcept
;
void
setMaxSessionCount
(
size_t
num
)
noexcept
;
bool
async_run
(
const
std
::
string
&
addr
,
Poco
::
UInt16
port
);
bool
run
(
const
std
::
string
&
addr
,
Poco
::
UInt16
port
);
void
terminate
();
inline
bool
isRunning
()
const
noexcept
{
return
isrunning
;
}
bool
isRunning
()
const
noexcept
;
bool
check
(
bool
restart_if_fail
=
true
);
...
...
@@ -139,10 +126,7 @@ namespace uniset
virtual
void
evprepare
(
const
ev
::
loop_ref
&
loop
)
override
;
virtual
void
evfinish
(
const
ev
::
loop_ref
&
loop
)
override
;
virtual
std
::
string
wname
()
const
noexcept
override
{
return
myname
;
}
virtual
std
::
string
wname
()
const
noexcept
override
;
void
ioAccept
(
ev
::
io
&
watcher
,
int
revents
);
void
sessionFinished
(
LogSession
*
s
);
...
...
include/LogServerTypes.h
View file @
e77133e0
...
...
@@ -25,7 +25,7 @@ namespace uniset
namespace
LogServerTypes
{
const
u
nsigned
int
MAGICNUM
=
0x20160417
;
const
uint
MAGICNUM
=
0x20160417
;
enum
Command
{
cmdNOP
,
/*!< отсутствие команды */
...
...
@@ -55,9 +55,10 @@ namespace uniset
{
std
::
memset
(
logname
,
0
,
sizeof
(
logname
));
}
unsigned
int
magic
;
uint
magic
;
Command
cmd
;
u
nsigned
int
data
;
uint
data
;
static
const
size_t
MAXLOGNAME
=
120
;
char
logname
[
MAXLOGNAME
+
1
];
// +1 reserverd for '\0'
...
...
include/LogSession.h
View file @
e77133e0
...
...
@@ -53,23 +53,11 @@ namespace uniset
// прервать работу
void
cancel
()
noexcept
;
inline
std
::
string
getClientAddress
()
const
noexcept
{
return
caddr
;
}
inline
void
setSessionLogLevel
(
Debug
::
type
t
)
noexcept
{
mylog
.
level
(
t
);
}
inline
void
addSessionLogLevel
(
Debug
::
type
t
)
noexcept
{
mylog
.
addLevel
(
t
);
}
inline
void
delSessionLogLevel
(
Debug
::
type
t
)
noexcept
{
mylog
.
delLevel
(
t
);
}
std
::
string
getClientAddress
()
const
noexcept
;
void
setSessionLogLevel
(
Debug
::
type
t
)
noexcept
;
void
addSessionLogLevel
(
Debug
::
type
t
)
noexcept
;
void
delSessionLogLevel
(
Debug
::
type
t
)
noexcept
;
//! Установить размер буфера для сообщений (количество записей. Не в байтах!!)
void
setMaxBufSize
(
size_t
num
);
...
...
include/ObjectIndex.h
View file @
e77133e0
...
...
@@ -50,16 +50,10 @@ namespace uniset
// node
//! \return "" if not found
inline
std
::
string
getNodeName
(
const
uniset
::
ObjectId
id
)
const
noexcept
{
return
getNameById
(
id
);
}
std
::
string
getNodeName
(
const
uniset
::
ObjectId
id
)
const
noexcept
;
//! \return uniset::DefaultObjectId if not found
inline
ObjectId
getNodeId
(
const
std
::
string
&
name
)
const
noexcept
{
return
getIdByName
(
name
);
}
ObjectId
getNodeId
(
const
std
::
string
&
name
)
const
noexcept
;
// src name
//! \return "" if not found
...
...
include/ObjectRepository.h
View file @
e77133e0
...
...
@@ -88,10 +88,10 @@ namespace uniset
};
//! Получение списка how_many объектов из секции section.
bool
list
(
const
std
::
string
&
section
,
uniset
::
ListObjectName
*
ls
,
size_t
how_many
=
300
)
throw
(
uniset
::
ORepFailed
);
bool
list
(
const
std
::
string
&
section
,
uniset
::
ListObjectName
*
ls
,
size_t
how_many
=
300
)
const
throw
(
uniset
::
ORepFailed
);
//! Получние списка how_many подсекций из секции in_section.
bool
listSections
(
const
std
::
string
&
in_section
,
uniset
::
ListObjectName
*
ls
,
size_t
how_many
=
300
)
throw
(
uniset
::
ORepFailed
);
bool
listSections
(
const
std
::
string
&
in_section
,
uniset
::
ListObjectName
*
ls
,
size_t
how_many
=
300
)
const
throw
(
uniset
::
ORepFailed
);
// -------------------------------------------------------------------
//! Создание секции
...
...
@@ -110,7 +110,7 @@ namespace uniset
bool
renameSection
(
const
std
::
string
&
newName
,
const
std
::
string
&
fullName
);
/*! Функция выводящая на экран список всех объектов расположенных в данной секции */
void
printSection
(
const
std
::
string
&
fullName
);
void
printSection
(
const
std
::
string
&
fullName
)
const
;
// @}
// end of add to ORepServiceGroup
...
...
@@ -121,7 +121,7 @@ namespace uniset
mutable
std
::
string
nsName
;
std
::
shared_ptr
<
uniset
::
Configuration
>
uconf
;
bool
list
(
const
std
::
string
&
section
,
uniset
::
ListObjectName
*
ls
,
unsigned
int
how_many
,
ObjectType
type
);
bool
list
(
const
std
::
string
&
section
,
uniset
::
ListObjectName
*
ls
,
unsigned
int
how_many
,
ObjectType
type
)
const
;
/*! Создание нового контекста(секции) */
bool
createContext
(
const
std
::
string
&
cname
,
CosNaming
::
NamingContext_ptr
ctx
);
...
...
include/ThreadCreator.h
View file @
e77133e0
...
...
@@ -90,7 +90,7 @@ namespace uniset
public
:
/*! прототип функции вызова
* use std::function ?
*
\todo
use std::function ?
*/
typedef
void
(
ThreadMaster
::*
Action
)(
void
);
...
...
@@ -113,7 +113,7 @@ namespace uniset
void
sleep
(
long
milliseconds
);
inline
bool
isRunning
()
inline
bool
isRunning
()
const
{
return
thr
.
isRunning
();
}
...
...
include/modbus/ModbusRTUMaster.h
View file @
e77133e0
...
...
@@ -26,10 +26,7 @@ namespace uniset
ModbusRTUMaster
(
const
std
::
string
&
dev
,
bool
use485
=
false
,
bool
tr_ctl
=
false
);
virtual
~
ModbusRTUMaster
();
virtual
void
cleanupChannel
()
override
{
if
(
port
)
port
->
cleanupChannel
();
}
virtual
void
cleanupChannel
()
override
;
void
setSpeed
(
ComPort
::
Speed
s
);
void
setSpeed
(
const
std
::
string
&
s
);
...
...
@@ -39,7 +36,7 @@ namespace uniset
void
setCharacterSize
(
ComPort
::
CharacterSize
csize
);
void
setStopBits
(
ComPort
::
StopBits
sBit
);
int
getTimeout
()
;
timeout_t
getTimeout
()
const
;
protected
:
...
...
include/modbus/ModbusServer.h
View file @
e77133e0
...
...
@@ -92,37 +92,16 @@ namespace uniset
void
setRecvTimeout
(
timeout_t
msec
);
/*! установить паузу при ожидании символа */
inline
void
setSleepPause
(
timeout_t
msec
)
{
sleepPause_msec
=
msec
;
}
void
setSleepPause
(
timeout_t
msec
);
inline
void
setCRCNoCheckit
(
bool
set
)
{
crcNoCheckit
=
set
;
}
inline
bool
isCRCNoCheckit
()
const
{
return
crcNoCheckit
;
}
void
setCRCNoCheckit
(
bool
set
);
bool
isCRCNoCheckit
()
const
;
inline
void
setBroadcastMode
(
bool
set
)
{
onBroadcast
=
set
;
}
inline
bool
getBroadcastMode
()
const
{
return
onBroadcast
;
}
void
setBroadcastMode
(
bool
set
);
bool
getBroadcastMode
()
const
;
inline
void
setCleanBeforeSend
(
bool
set
)
{
cleanBeforeSend
=
set
;
}
inline
bool
getCleanBeforeSend
()
{
return
cleanBeforeSend
;
}
void
setCleanBeforeSend
(
bool
set
);
bool
getCleanBeforeSend
()
const
;
/*! Вспомогательная функция реализующая обработку запроса на установку времени.
Основана на использовании gettimeofday и settimeofday.
...
...
@@ -151,13 +130,10 @@ namespace uniset
typedef
std
::
unordered_map
<
ModbusRTU
::
mbErrCode
,
size_t
>
ExchangeErrorMap
;
ExchangeErrorMap
getErrorMap
();
size_t
getErrCount
(
ModbusRTU
::
mbErrCode
e
);
size_t
getErrCount
(
ModbusRTU
::
mbErrCode
e
)
const
;
size_t
resetErrCount
(
ModbusRTU
::
mbErrCode
e
,
size_t
set
=
0
);
inline
size_t
getAskCount
()
const
{
return
askCount
;
}
size_t
getAskCount
()
const
;
void
resetAskCounter
();
protected
:
...
...
include/modbus/ModbusTCPMaster.h
View file @
e77133e0
...
...
@@ -30,27 +30,15 @@ namespace uniset
static
bool
checkConnection
(
const
std
::
string
&
ip
,
int
port
,
int
timeout_msec
=
100
);
inline
void
setForceDisconnect
(
bool
s
)
{
force_disconnect
=
s
;
}
void
setForceDisconnect
(
bool
s
);
bool
reconnect
();
void
cleanInputStream
();
virtual
void
cleanupChannel
()
override
{
cleanInputStream
();
}
virtual
void
cleanupChannel
()
override
;
inline
std
::
string
getAddress
()
const
{
return
iaddr
;
}
inline
int
getPort
()
const
{
return
port
;
}
std
::
string
getAddress
()
const
;
int
getPort
()
const
;
void
setReadTimeout
(
timeout_t
msec
);
timeout_t
getReadTimeout
()
const
;
...
...
include/modbus/ModbusTCPServer.h
View file @
e77133e0
...
...
@@ -51,51 +51,33 @@ namespace uniset
virtual
bool
isActive
()
const
override
;
void
setMaxSessions
(
size_t
num
);
inline
size_t
getMaxSessions
()
{
return
maxSessions
;
}
size_t
getMaxSessions
()
const
;
/*! установить timeout для поддержания соединения с "клиентом" (Default: 10 сек) */
void
setSessionTimeout
(
timeout_t
msec
);
inline
timeout_t
getSessionTimeout
()
{
return
sessTimeout
;
}
timeout_t
getSessionTimeout
()
const
;
/*! текущее количество подключений */
size_t
getCountSessions
();
size_t
getCountSessions
()
const
;
inline
void
setIgnoreAddrMode
(
bool
st
)
{
ignoreAddr
=
st
;
}
inline
bool
getIgnoreAddrMode
()
{
return
ignoreAddr
;
}
void
setIgnoreAddrMode
(
bool
st
);
bool
getIgnoreAddrMode
()
const
;
// Сбор статистики по соединениям...
struct
SessionInfo
{
SessionInfo
(
const
std
::
string
&
a
,
unsigned
in
t
ask
)
:
iaddr
(
a
),
askCount
(
ask
)
{}
SessionInfo
(
const
std
::
string
&
a
,
size_
t
ask
)
:
iaddr
(
a
),
askCount
(
ask
)
{}
std
::
string
iaddr
;
unsigned
in
t
askCount
;
size_
t
askCount
;
};
typedef
std
::
list
<
SessionInfo
>
Sessions
;
void
getSessions
(
Sessions
&
lst
);
inline
std
::
string
getInetAddress
()
{
return
iaddr
;
}
inline
int
getInetPort
()
{
return
port
;
}
std
::
string
getInetAddress
()
const
;
int
getInetPort
()
const
;
// -------------------------------------------------
// Таймер.
...
...
@@ -108,10 +90,7 @@ namespace uniset
TimerSignal
signal_timer
();
void
setTimer
(
timeout_t
msec
);
inline
timeout_t
getTimer
()
{
return
tmTime
;
}
inline
timeout_t
getTimer
()
const
;
protected
:
...
...
include/modbus/ModbusTCPSession.h
View file @
e77133e0
...
...
@@ -48,10 +48,7 @@ namespace uniset
void
connectFinalSession
(
FinalSlot
sl
);
inline
std
::
string
getClientAddress
()
const
{
return
caddr
;
}
std
::
string
getClientAddress
()
const
;
void
setSessionTimeout
(
double
t
);
...
...
src/Communications/ComPort.cc
View file @
e77133e0
...
...
@@ -298,6 +298,11 @@ void ComPort::setTimeout( timeout_t msec )
uTimeout
=
msec
*
1000
;
}
// --------------------------------------------------------------------------------
timeout_t
ComPort
::
getTimeout
()
const
{
return
uTimeout
/
1000
;
// msec
}
// --------------------------------------------------------------------------------
// Lav: ситуация, когда отправлено меньше запрошенного, не типична и должна
// генерировать исключение
size_t
ComPort
::
sendBlock
(
unsigned
char
*
msg
,
size_t
len
)
...
...
@@ -391,6 +396,11 @@ void ComPort::setSpeed( const std::string& s )
setSpeed
(
sp
);
}
// --------------------------------------------------------------------------------
ComPort
::
Speed
ComPort
::
getSpeed
()
const
{
return
speed
;
}
// --------------------------------------------------------------------------------
std
::
string
ComPort
::
getSpeed
(
Speed
s
)
{
if
(
s
==
ComSpeed9600
)
...
...
src/Communications/Modbus/ModbusRTUMaster.cc
View file @
e77133e0
...
...
@@ -81,6 +81,12 @@ namespace uniset
delete
port
;
}
// -------------------------------------------------------------------------
void
ModbusRTUMaster
::
cleanupChannel
()
{
if
(
port
)
port
->
cleanupChannel
();
}
// -------------------------------------------------------------------------
void
ModbusRTUMaster
::
setSpeed
(
ComPort
::
Speed
s
)
{
if
(
port
!=
NULL
)
...
...
@@ -119,7 +125,7 @@ namespace uniset
port
->
setStopBits
(
sBit
);
}
// -------------------------------------------------------------------------
int
ModbusRTUMaster
::
getTimeout
()
timeout_t
ModbusRTUMaster
::
getTimeout
()
const
{
if
(
port
==
NULL
)
return
0
;
...
...
src/Communications/Modbus/ModbusServer.cc
View file @
e77133e0
...
...
@@ -63,6 +63,41 @@ namespace uniset
recvTimeOut_ms
=
msec
;
}
// -------------------------------------------------------------------------
void
ModbusServer
::
setSleepPause
(
timeout_t
msec
)
{
sleepPause_msec
=
msec
;
}
// -------------------------------------------------------------------------
void
ModbusServer
::
setCRCNoCheckit
(
bool
set
)
{
crcNoCheckit
=
set
;
}
// -------------------------------------------------------------------------
bool
ModbusServer
::
isCRCNoCheckit
()
const
{
return
crcNoCheckit
;
}
// -------------------------------------------------------------------------
void
ModbusServer
::
setBroadcastMode
(
bool
set
)
{
onBroadcast
=
set
;
}
// -------------------------------------------------------------------------
bool
ModbusServer
::
getBroadcastMode
()
const
{
return
onBroadcast
;
}
// -------------------------------------------------------------------------
void
ModbusServer
::
setCleanBeforeSend
(
bool
set
)
{
cleanBeforeSend
=
set
;
}
// -------------------------------------------------------------------------
bool
ModbusServer
::
getCleanBeforeSend
()
const
{
return
cleanBeforeSend
;
}
// -------------------------------------------------------------------------
timeout_t
ModbusServer
::
setReplyTimeout
(
timeout_t
msec
)
{
// #warning "Why msec can be 0?"
...
...
@@ -1675,7 +1710,7 @@ namespace uniset
return
m
;
}
// -------------------------------------------------------------------------
size_t
ModbusServer
::
getErrCount
(
mbErrCode
e
)
size_t
ModbusServer
::
getErrCount
(
mbErrCode
e
)
const
{
auto
i
=
errmap
.
find
(
e
);
...
...
@@ -1697,6 +1732,11 @@ namespace uniset
return
ret
;
}
// -------------------------------------------------------------------------
size_t
ModbusServer
::
getAskCount
()
const
{
return
askCount
;
}
// -------------------------------------------------------------------------
void
ModbusServer
::
resetAskCounter
()
{
askCount
=
0
;
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
e77133e0
...
...
@@ -333,6 +333,21 @@ namespace uniset
catch
(
...
)
{}
}
// -------------------------------------------------------------------------
void
ModbusTCPMaster
::
cleanupChannel
()
{
cleanInputStream
();
}
// -------------------------------------------------------------------------
string
ModbusTCPMaster
::
getAddress
()
const
{
return
iaddr
;
}
// -------------------------------------------------------------------------
int
ModbusTCPMaster
::
getPort
()
const
{
return
port
;
}
// -------------------------------------------------------------------------
void
ModbusTCPMaster
::
setReadTimeout
(
timeout_t
msec
)
{
readTimeout
=
msec
;
...
...
@@ -366,6 +381,11 @@ namespace uniset
return
false
;
}
// -------------------------------------------------------------------------
void
ModbusTCPMaster
::
setForceDisconnect
(
bool
s
)
{
force_disconnect
=
s
;
}
// -------------------------------------------------------------------------
bool
ModbusTCPMaster
::
reconnect
()
{
if
(
dlog
->
is_info
()
)
...
...
src/Communications/Modbus/ModbusTCPServer.cc
View file @
e77133e0
...
...
@@ -71,16 +71,36 @@ namespace uniset
maxSessions
=
num
;
}
// -------------------------------------------------------------------------
size_t
ModbusTCPServer
::
getCountSessions
()
size_t
ModbusTCPServer
::
getMaxSessions
()
const
{
return
maxSessions
;
}
// -------------------------------------------------------------------------
size_t
ModbusTCPServer
::
getCountSessions
()
const
{
return
sessCount
;
}
// -------------------------------------------------------------------------
void
ModbusTCPServer
::
setIgnoreAddrMode
(
bool
st
)
{
ignoreAddr
=
st
;
}
// -------------------------------------------------------------------------
bool
ModbusTCPServer
::
getIgnoreAddrMode
()
const
{
return
ignoreAddr
;
}
// -------------------------------------------------------------------------
void
ModbusTCPServer
::
setSessionTimeout
(
timeout_t
msec
)
{
sessTimeout
=
msec
;
}
// -------------------------------------------------------------------------
timeout_t
ModbusTCPServer
::
getSessionTimeout
()
const
{
return
sessTimeout
;
}
// -------------------------------------------------------------------------
bool
ModbusTCPServer
::
run
(
const
std
::
unordered_set
<
ModbusAddr
>&
_vmbaddr
)
{
vmbaddr
=
&
_vmbaddr
;
...
...
@@ -188,6 +208,16 @@ namespace uniset
}
}
// -------------------------------------------------------------------------
string
ModbusTCPServer
::
getInetAddress
()
const
{
return
iaddr
;
}
// -------------------------------------------------------------------------
int
ModbusTCPServer
::
getInetPort
()
const
{
return
port
;
}
// -------------------------------------------------------------------------
ModbusTCPServer
::
TimerSignal
ModbusTCPServer
::
signal_timer
()
{
return
m_timer_signal
;
...
...
@@ -213,6 +243,11 @@ namespace uniset
}
}
// -------------------------------------------------------------------------
timeout_t
ModbusTCPServer
::
getTimer
()
const
{
return
tmTime
;
}
// -------------------------------------------------------------------------
void
ModbusTCPServer
::
iowait
(
timeout_t
msec
)
{
ptWait
.
setTiming
(
msec
);
...
...
src/Communications/Modbus/ModbusTCPSession.cc
View file @
e77133e0
...
...
@@ -591,4 +591,9 @@ namespace uniset
slFin
=
sl
;
}
// -------------------------------------------------------------------------
string
ModbusTCPSession
::
getClientAddress
()
const
{
return
caddr
;
}
// -------------------------------------------------------------------------
}
// end of namespace uniset
src/Log/LogReader.cc
View file @
e77133e0
...
...
@@ -54,6 +54,11 @@ void LogReader::setLogLevel( Debug::type t )
outlog
->
level
(
t
);
}
// -------------------------------------------------------------------------
std
::
shared_ptr
<
DebugStream
>
LogReader
::
log
()
{
return
outlog
;
}
// -------------------------------------------------------------------------
DebugStream
::
StreamEvent_Signal
LogReader
::
signal_stream_event
()
{
return
m_logsig
;
...
...
@@ -148,6 +153,36 @@ bool LogReader::isConnection() const
return
(
tcp
&&
tcp
->
isConnected
()
);
}
// -------------------------------------------------------------------------
void
LogReader
::
setReadCount
(
unsigned
int
n
)
{
readcount
=
n
;
}
// -------------------------------------------------------------------------
void
LogReader
::
setCommandOnlyMode
(
bool
s
)
{
cmdonly
=
s
;
}
// -------------------------------------------------------------------------
void
LogReader
::
setinTimeout
(
timeout_t
msec
)
{
inTimeout
=
msec
;
}
// -------------------------------------------------------------------------
void
LogReader
::
setoutTimeout
(
timeout_t
msec
)
{
outTimeout
=
msec
;
}
// -------------------------------------------------------------------------
void
LogReader
::
setReconnectDelay
(
timeout_t
msec
)
{
reconDelay
=
msec
;
}
// -------------------------------------------------------------------------
void
LogReader
::
setTextFilter
(
const
string
&
f
)
{
textfilter
=
f
;
}
// -------------------------------------------------------------------------
void
LogReader
::
sendCommand
(
const
std
::
string
&
_addr
,
int
_port
,
std
::
vector
<
Command
>&
vcmd
,
bool
cmd_only
,
bool
verbose
)
{
if
(
vcmd
.
empty
()
)
...
...
src/Log/LogServer.cc
View file @
e77133e0
...
...
@@ -41,6 +41,21 @@ namespace uniset
catch
(...)
{}
}
// -------------------------------------------------------------------------
void
LogServer
::
setCmdTimeout
(
timeout_t
msec
)
noexcept
{
cmdTimeout
=
msec
;
}
// -------------------------------------------------------------------------
void
LogServer
::
setSessionLog
(
Debug
::
type
t
)
noexcept
{
sessLogLevel
=
t
;
}
// -------------------------------------------------------------------------
void
LogServer
::
setMaxSessionCount
(
size_t
num
)
noexcept
{
sessMaxCount
=
num
;
}
// -------------------------------------------------------------------------
LogServer
::
LogServer
(
std
::
shared_ptr
<
LogAgregator
>
log
)
:
LogServer
()
{
...
...
@@ -111,6 +126,11 @@ namespace uniset
mylog
.
info
()
<<
myname
<<
"(LogServer): finished."
<<
endl
;
}
// -------------------------------------------------------------------------
std
::
string
LogServer
::
wname
()
const
noexcept
{
return
myname
;
}
// -------------------------------------------------------------------------
bool
LogServer
::
run
(
const
std
::
string
&
_addr
,
Poco
::
UInt16
_port
)
{
addr
=
_addr
;
...
...
@@ -143,6 +163,11 @@ namespace uniset
loop
.
evstop
(
this
);
}
// -------------------------------------------------------------------------
bool
LogServer
::
isRunning
()
const
noexcept
{
return
isrunning
;
}
// -------------------------------------------------------------------------
bool
LogServer
::
check
(
bool
restart_if_fail
)
{
// смущает пока только, что эта функция будет вызыватся (обычно) из другого потока
...
...
src/Log/LogSession.cc
View file @
e77133e0
...
...
@@ -636,6 +636,26 @@ namespace uniset
cancelled
=
true
;
}
// ---------------------------------------------------------------------
string
LogSession
::
getClientAddress
()
const
noexcept
{
return
caddr
;
}
// ---------------------------------------------------------------------
void
LogSession
::
setSessionLogLevel
(
Debug
::
type
t
)
noexcept
{
mylog
.
level
(
t
);
}
// ---------------------------------------------------------------------
void
LogSession
::
addSessionLogLevel
(
Debug
::
type
t
)
noexcept
{
mylog
.
addLevel
(
t
);
}
// ---------------------------------------------------------------------
void
LogSession
::
delSessionLogLevel
(
Debug
::
type
t
)
noexcept
{
mylog
.
delLevel
(
t
);
}
// ---------------------------------------------------------------------
void
LogSession
::
setMaxBufSize
(
size_t
num
)
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
logbuf_mutex
);
...
...
src/ObjectRepository/ObjectIndex.cc
View file @
e77133e0
...
...
@@ -34,6 +34,16 @@ string ObjectIndex::getNameById( const ObjectId id ) const noexcept
return
getMapName
(
id
);
}
// -----------------------------------------------------------------------------------------
std
::
string
ObjectIndex
::
getNodeName
(
const
ObjectId
id
)
const
noexcept
{
return
getNameById
(
id
);
}
// -----------------------------------------------------------------------------------------
ObjectId
ObjectIndex
::
getNodeId
(
const
std
::
__cxx11
::
string
&
name
)
const
noexcept
{
return
getIdByName
(
name
);
}
// -----------------------------------------------------------------------------------------
std
::
string
ObjectIndex
::
getBaseName
(
const
std
::
string
&
fname
)
noexcept
{
string
::
size_type
pos
=
fname
.
rfind
(
'/'
);
...
...
src/ObjectRepository/ObjectRepository.cc
View file @
e77133e0
...
...
@@ -308,7 +308,7 @@ throw(ORepFailed, NameNotFound)
* количество объектов в этой секции превышает заданное how_many.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool
ObjectRepository
::
list
(
const
string
&
section
,
ListObjectName
*
ls
,
size_t
how_many
)
throw
(
ORepFailed
)
bool
ObjectRepository
::
list
(
const
string
&
section
,
ListObjectName
*
ls
,
size_t
how_many
)
const
throw
(
ORepFailed
)
{
return
list
(
section
,
ls
,
how_many
,
ObjectRef
);
}
...
...
@@ -322,7 +322,7 @@ bool ObjectRepository::list(const string& section, ListObjectName* ls, size_t ho
* количество объектов в этой секции превышает заданное how_many.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool
ObjectRepository
::
listSections
(
const
string
&
in_section
,
ListObjectName
*
ls
,
size_t
how_many
)
throw
(
ORepFailed
)
bool
ObjectRepository
::
listSections
(
const
string
&
in_section
,
ListObjectName
*
ls
,
size_t
how_many
)
const
throw
(
ORepFailed
)
{
return
list
(
in_section
,
ls
,
how_many
,
Section
);
}
...
...
@@ -337,7 +337,7 @@ bool ObjectRepository::listSections(const string& in_section, ListObjectName* ls
* количество объектов в этой секции превышает заданное how_many.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool
ObjectRepository
::
list
(
const
string
&
section
,
ListObjectName
*
ls
,
unsigned
int
how_many
,
ObjectType
type
)
bool
ObjectRepository
::
list
(
const
string
&
section
,
ListObjectName
*
ls
,
unsigned
int
how_many
,
ObjectType
type
)
const
{
// Возвращает false если вынут не весь список...
CosNaming
::
NamingContext_var
ctx
;
...
...
@@ -563,7 +563,7 @@ bool ObjectRepository::createContext( const string& cname, CosNaming::NamingCont
/*!
\note Функция не вывести список, если не сможет получить доступ к секции
*/
void
ObjectRepository
::
printSection
(
const
string
&
fullName
)
void
ObjectRepository
::
printSection
(
const
string
&
fullName
)
const
{
ListObjectName
ls
;
...
...
src/Processes/IOController.cc
View file @
e77133e0
...
...
@@ -654,11 +654,6 @@ void IOController::USensorInfo::init( const IOController_i::SensorIOInfo& s )
(
*
this
)
=
std
::
move
(
r
);
}
// ----------------------------------------------------------------------------------------
size_t
IOController
::
ioCount
()
{
return
ioList
.
size
();
}
// ----------------------------------------------------------------------------------------
IOController
::
IOStateList
::
iterator
IOController
::
myioBegin
()
{
return
ioList
.
begin
();
...
...
src/Various/Configuration.cc
View file @
e77133e0
...
...
@@ -26,6 +26,7 @@
#include <sstream>
#include <iomanip>
#include <string>
#include <cassert>
#include <omniORB4/internal/initRefs.h>
#include "Configuration.h"
...
...
@@ -73,8 +74,8 @@ ostream& uniset::Configuration::help(ostream& os)
// -------------------------------------------------------------------------
namespace
uniset
{
static
shared_ptr
<
Configuration
>
uconf
;
static
std
::
shared_ptr
<
DebugStream
>
_ulog
=
nullptr
;
static
s
td
::
s
hared_ptr
<
Configuration
>
uconf
;
static
std
::
shared_ptr
<
DebugStream
>
_ulog
;
std
::
shared_ptr
<
DebugStream
>
ulog
()
noexcept
{
...
...
@@ -88,8 +89,14 @@ namespace uniset
std
::
shared_ptr
<
Configuration
>
uniset_conf
()
noexcept
{
// if( uconf == nullptr )
// throw SystemError("Don`t init uniset configuration! First use uniset_init().");
// Не делаем assert или exception
// потому-что считаем, что может быть необходимость не вызывать uniset_init()
// Т.е. проверка if( uconf ) возлагается на пользователя.
// assert( uconf );
// if( uconf == nullptr )
// throw SystemError("Don`t init uniset configuration! First use uniset_init().");
return
uconf
;
// см. uniset_init..
}
...
...
src/Various/LT_Object.cc
View file @
e77133e0
...
...
@@ -170,8 +170,8 @@ timeout_t LT_Object::askTimer( uniset::TimerId timerid, timeout_t timeMS, clock_
{
if
(
timeMS
<
UniSetTimer
::
MinQuantityTime
)
{
ucrit
<<
"(LT_askTimer): [мс] попытка заказть таймер "
<<
getTimerName
(
timerid
)
<<
" со временем срабатыания "
ucrit
<<
"(LT_askTimer): [мс] попытка заказ
а
ть таймер "
<<
getTimerName
(
timerid
)
<<
" со временем срабаты
в
ания "
<<
" меньше разрешённого "
<<
UniSetTimer
::
MinQuantityTime
<<
endl
;
timeMS
=
UniSetTimer
::
MinQuantityTime
;
}
...
...
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