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
7c03e4dd
Commit
7c03e4dd
authored
Aug 27, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make style
parent
9242dc0d
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
40 additions
and
29 deletions
+40
-29
admin.cc
Utilities/Admin/admin.cc
+10
-0
mbtcptester.cc
Utilities/MBTester/mbtcptester.cc
+2
-2
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+6
-5
MBTCPMultiMaster.cc
extensions/ModbusMaster/MBTCPMultiMaster.cc
+2
-2
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+2
-2
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+7
-7
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+2
-2
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+1
-1
UTCPStream.h
include/UTCPStream.h
+1
-1
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+4
-4
TCPCheck.cc
src/Communications/TCP/TCPCheck.cc
+1
-1
UTCPStream.cc
src/Communications/TCP/UTCPStream.cc
+2
-2
No files found.
Utilities/Admin/admin.cc
View file @
7c03e4dd
...
...
@@ -539,6 +539,7 @@ int omap()
{
if
(
!
quiet
)
cerr
<<
"std::exception: "
<<
ex
.
what
()
<<
endl
;
return
1
;
}
...
...
@@ -600,6 +601,7 @@ int setValue( const string& args, UInterface& ui )
{
if
(
!
quiet
)
cerr
<<
"std::exception: "
<<
ex
.
what
()
<<
endl
;
err
=
1
;
}
}
...
...
@@ -666,6 +668,7 @@ int getValue( const string& args, UInterface& ui )
{
if
(
!
quiet
)
cerr
<<
"std::exception: "
<<
ex
.
what
()
<<
endl
;
err
=
1
;
}
}
...
...
@@ -714,6 +717,7 @@ int getCalibrate( const std::string& args, UInterface& ui )
{
if
(
!
quiet
)
cerr
<<
"std::exception: "
<<
ex
.
what
()
<<
endl
;
err
=
1
;
}
}
...
...
@@ -758,6 +762,7 @@ int getRawValue( const std::string& args, UInterface& ui )
{
if
(
!
quiet
)
cerr
<<
"std::exception: "
<<
ex
.
what
()
<<
endl
;
err
=
1
;
}
}
...
...
@@ -802,12 +807,14 @@ int getChangedTime( const std::string& args, UInterface& ui )
{
if
(
!
quiet
)
cerr
<<
"CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
err
=
1
;
}
catch
(
const
CORBA
::
Exception
&
)
{
if
(
!
quiet
)
cerr
<<
"CORBA::Exception."
<<
endl
;
err
=
1
;
}
catch
(
const
omniORB
::
fatalException
&
fe
)
...
...
@@ -819,18 +826,21 @@ int getChangedTime( const std::string& args, UInterface& ui )
cerr
<<
" line: "
<<
fe
.
line
()
<<
endl
;
cerr
<<
" mesg: "
<<
fe
.
errmsg
()
<<
endl
;
}
err
=
1
;
}
catch
(
const
std
::
exception
&
ex
)
{
if
(
!
quiet
)
cerr
<<
"std::exception: "
<<
ex
.
what
()
<<
endl
;
err
=
1
;
}
catch
(...)
{
if
(
!
quiet
)
cerr
<<
"Unknown exception.."
<<
endl
;
err
=
1
;
}
}
...
...
Utilities/MBTester/mbtcptester.cc
View file @
7c03e4dd
...
...
@@ -609,7 +609,7 @@ int main( int argc, char** argv )
case
cmdCheck
:
{
bool
res
=
ModbusTCPMaster
::
checkConnection
(
iaddr
,
port
,
tout
);
bool
res
=
ModbusTCPMaster
::
checkConnection
(
iaddr
,
port
,
tout
);
cout
<<
iaddr
<<
":"
<<
port
<<
" connection "
<<
(
res
?
"OK"
:
"FAIL"
)
<<
endl
;
}
break
;
...
...
@@ -676,6 +676,6 @@ char* checkArg( int i, int argc, char* argv[] )
// --------------------------------------------------------------------------
void
ping
(
const
std
::
string
&
iaddr
,
int
port
)
{
cerr
<<
"ping2: check connection "
<<
ModbusTCPMaster
::
checkConnection
(
iaddr
,
port
,
1000
)
<<
endl
;
cerr
<<
"ping2: check connection "
<<
ModbusTCPMaster
::
checkConnection
(
iaddr
,
port
,
1000
)
<<
endl
;
}
// --------------------------------------------------------------------------
extensions/ModbusMaster/MBExchange.cc
View file @
7c03e4dd
...
...
@@ -945,7 +945,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
return
false
;
}
if
(
p
->
pollfactor
>
1
&&
ncycle
%
p
->
pollfactor
!=
0
)
if
(
p
->
pollfactor
>
1
&&
ncycle
%
p
->
pollfactor
!=
0
)
return
false
;
if
(
mblog
->
is_level3
()
)
...
...
@@ -2090,7 +2090,7 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, ModbusRTU::RegID id, Modbus
// ------------------------------------------------------------------------------------------
MBExchange
::
RSProperty
*
MBExchange
::
addProp
(
PList
&
plist
,
RSProperty
&&
p
)
{
for
(
auto
&&
it
:
plist
)
for
(
auto
&&
it
:
plist
)
{
if
(
it
.
si
.
id
==
p
.
si
.
id
&&
it
.
si
.
node
==
p
.
si
.
node
)
return
&
it
;
...
...
@@ -2184,7 +2184,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML::iterator& it, MBExchange::RTU
{
r
->
dev
=
dev
;
r
->
mbval
=
IOBase
::
initIntProp
(
it
,
"default"
,
prop_prefix
,
false
);
r
->
pollfactor
=
IOBase
::
initIntProp
(
it
,
"pollfactor"
,
prop_prefix
,
false
,
0
);
r
->
pollfactor
=
IOBase
::
initIntProp
(
it
,
"pollfactor"
,
prop_prefix
,
false
,
0
);
if
(
dev
->
dtype
==
MBExchange
::
dtRTU
)
...
...
@@ -2969,7 +2969,7 @@ void MBExchange::sensorInfo( const UniSetTypes::SensorMessage* sm )
if
(
!
isWriteFunction
(
it
.
second
->
mbfunc
)
)
continue
;
for
(
auto
&&
i
:
it
.
second
->
slst
)
for
(
auto
&&
i
:
it
.
second
->
slst
)
{
if
(
sm
->
id
==
i
.
si
.
id
&&
sm
->
node
==
i
.
si
.
node
)
{
...
...
@@ -3237,7 +3237,8 @@ UniSetTypes::SimpleInfo* MBExchange::getInfo()
inf
<<
"LogServer: "
<<
logserv_host
<<
":"
<<
logserv_port
<<
endl
;
inf
<<
"Devices:"
<<
endl
;
for
(
const
auto
&
it
:
rmap
)
for
(
const
auto
&
it
:
rmap
)
inf
<<
" "
<<
it
.
second
->
getShortInfo
()
<<
endl
;
i
->
info
=
inf
.
str
().
c_str
();
...
...
extensions/ModbusMaster/MBTCPMultiMaster.cc
View file @
7c03e4dd
...
...
@@ -415,7 +415,7 @@ void MBTCPMultiMaster::initIterators()
{
MBExchange
::
initIterators
();
for
(
auto
&&
it
:
mblist
)
for
(
auto
&&
it
:
mblist
)
shm
->
initIterator
(
it
.
respond_it
);
}
// -----------------------------------------------------------------------------
...
...
@@ -514,7 +514,7 @@ UniSetTypes::SimpleInfo* MBTCPMultiMaster::getInfo()
ostringstream
inf
;
inf
<<
i
->
info
<<
endl
;
inf
<<
"Gates: "
<<
(
checktime
<=
0
?
"/ check connections DISABLED /"
:
""
)
<<
endl
;
inf
<<
"Gates: "
<<
(
checktime
<=
0
?
"/ check connections DISABLED /"
:
""
)
<<
endl
;
for
(
const
auto
&
m
:
mblist
)
inf
<<
" "
<<
m
.
getShortInfo
()
<<
endl
;
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
7c03e4dd
...
...
@@ -559,7 +559,7 @@ void MBSlave::execute_rtu()
}
}
for
(
auto
&&
it
:
iomap
)
for
(
auto
&&
it
:
iomap
)
IOBase
::
processingThreshold
(
&
it
.
second
,
shm
,
force
);
}
catch
(...)
{}
...
...
@@ -645,7 +645,7 @@ void MBSlave::execute_tcp()
}
}
for
(
auto
&&
it
:
iomap
)
for
(
auto
&&
it
:
iomap
)
IOBase
::
processingThreshold
(
&
it
.
second
,
shm
,
force
);
}
catch
(
const
std
::
exception
&
ex
)
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
7c03e4dd
...
...
@@ -289,7 +289,7 @@ bool SharedMemory::activateObject()
itPulsar
=
myioEnd
();
for
(
auto
&&
it
:
hist
)
for
(
auto
&&
it
:
hist
)
{
for
(
auto
&&
hit
:
it
.
hlst
)
hit
.
ioit
=
myioEnd
();
...
...
@@ -331,7 +331,7 @@ void SharedMemory::checkHeartBeat()
bool
wdtpingOK
=
true
;
for
(
auto
&&
it
:
hlist
)
for
(
auto
&&
it
:
hlist
)
{
try
{
...
...
@@ -378,7 +378,7 @@ void SharedMemory::checkHeartBeat()
// ------------------------------------------------------------------------------------------
bool
SharedMemory
::
readItem
(
const
std
::
shared_ptr
<
UniXML
>&
xml
,
UniXML
::
iterator
&
it
,
xmlNode
*
sec
)
{
for
(
auto
&&
r
:
lstRSlot
)
for
(
auto
&&
r
:
lstRSlot
)
{
try
{
...
...
@@ -666,7 +666,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
// -----------------------------------------------------------------------------
void
SharedMemory
::
checkHistoryFilter
(
UniXML
::
iterator
&
xit
)
{
for
(
auto
&&
it
:
hist
)
for
(
auto
&&
it
:
hist
)
{
if
(
xit
.
getProp
(
it
.
filter
).
empty
()
)
continue
;
...
...
@@ -701,9 +701,9 @@ void SharedMemory::saveHistory()
if
(
hist
.
empty
()
)
return
;
for
(
auto
&&
it
:
hist
)
for
(
auto
&&
it
:
hist
)
{
for
(
auto
&&
hit
:
it
.
hlst
)
for
(
auto
&&
hit
:
it
.
hlst
)
{
try
{
...
...
@@ -743,7 +743,7 @@ void SharedMemory::updateHistory( std::shared_ptr<USensorInfo>& s_it, IOControll
<<
" value="
<<
value
<<
endl
;
for
(
auto
&&
it1
:
i
->
second
)
for
(
auto
&&
it1
:
i
->
second
)
{
History
::
iterator
it
=
it1
;
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
7c03e4dd
...
...
@@ -745,7 +745,7 @@ void UNetExchange::initIterators()
if
(
sender2
)
sender2
->
initIterators
();
for
(
auto
&&
it
:
recvlist
)
for
(
auto
&&
it
:
recvlist
)
it
.
initIterators
(
shm
);
}
// -----------------------------------------------------------------------------
...
...
@@ -814,7 +814,7 @@ std::shared_ptr<UNetExchange> UNetExchange::init_unetexchange( int argc, const c
// -----------------------------------------------------------------------------
void
UNetExchange
::
receiverEvent
(
const
shared_ptr
<
UNetReceiver
>&
r
,
UNetReceiver
::
Event
ev
)
{
for
(
auto
&&
it
:
recvlist
)
for
(
auto
&&
it
:
recvlist
)
{
if
(
it
.
r1
==
r
)
{
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
7c03e4dd
...
...
@@ -285,7 +285,7 @@ void UNetReceiver::real_update()
if
(
sub
>=
maxDifferens
)
{
// считаем сколько пакетов потеряли.. (pnum=0 - означает что мы только что запустились...)
if
(
pnum
!=
0
&&
p
.
num
>
pnum
)
if
(
pnum
!=
0
&&
p
.
num
>
pnum
)
lostPackets
+=
sub
;
}
}
...
...
include/UTCPStream.h
View file @
7c03e4dd
...
...
@@ -16,7 +16,7 @@ class UTCPStream:
void
create
(
const
std
::
string
&
hname
,
int
port
,
bool
throwflag
=
false
,
timeout_t
timer
=
0
);
// set keepalive params
void
setKeepAliveParams
(
timeout_t
timeout_sec
=
5
,
int
conn_keepcnt
=
1
,
int
keepintvl
=
2
);
void
setKeepAliveParams
(
timeout_t
timeout_sec
=
5
,
int
conn_keepcnt
=
1
,
int
keepintvl
=
2
);
protected
:
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
7c03e4dd
...
...
@@ -43,7 +43,7 @@ void ModbusTCPMaster::setChannelTimeout( timeout_t msec )
if
(
tcp
)
{
tcp
->
setTimeout
(
msec
);
tcp
->
setKeepAliveParams
((
msec
>
1000
?
msec
/
1000
:
1
));
tcp
->
setKeepAliveParams
((
msec
>
1000
?
msec
/
1000
:
1
));
}
}
// -------------------------------------------------------------------------
...
...
@@ -309,7 +309,7 @@ bool ModbusTCPMaster::checkConnection( const std::string& ip, int port, int time
// Проверяем просто попыткой создать соединение..
UTCPStream
t
;
t
.
create
(
ip
,
port
,
true
,
timeout_msec
);
t
.
setKeepAliveParams
(
(
timeout_msec
>
1000
?
timeout_msec
/
1000
:
1
),
1
,
1
);
t
.
setKeepAliveParams
(
(
timeout_msec
>
1000
?
timeout_msec
/
1000
:
1
),
1
,
1
);
t
.
disconnect
();
return
true
;
}
...
...
@@ -336,7 +336,7 @@ void ModbusTCPMaster::reconnect()
tcp
=
make_shared
<
UTCPStream
>
();
tcp
->
create
(
iaddr
,
port
,
true
,
500
);
tcp
->
setTimeout
(
replyTimeOut_ms
);
tcp
->
setKeepAliveParams
((
replyTimeOut_ms
>
1000
?
replyTimeOut_ms
/
1000
:
1
));
tcp
->
setKeepAliveParams
((
replyTimeOut_ms
>
1000
?
replyTimeOut_ms
/
1000
:
1
));
}
catch
(
const
std
::
exception
&
e
)
{
...
...
@@ -390,7 +390,7 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int _port )
tcp
=
make_shared
<
UTCPStream
>
();
tcp
->
create
(
iaddr
,
port
,
true
,
500
);
tcp
->
setTimeout
(
replyTimeOut_ms
);
tcp
->
setKeepAliveParams
((
replyTimeOut_ms
>
1000
?
replyTimeOut_ms
/
1000
:
1
));
tcp
->
setKeepAliveParams
((
replyTimeOut_ms
>
1000
?
replyTimeOut_ms
/
1000
:
1
));
}
catch
(
const
std
::
exception
&
e
)
{
...
...
src/Communications/TCP/TCPCheck.cc
View file @
7c03e4dd
...
...
@@ -60,7 +60,7 @@ void TCPCheck::check_thread()
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
UTCPStream
t
;
t
.
create
(
ip
,
port
,
true
,
tout_msec
);
t
.
setKeepAliveParams
(
(
tout_msec
>
1000
?
tout_msec
/
1000
:
1
)
);
t
.
setKeepAliveParams
(
(
tout_msec
>
1000
?
tout_msec
/
1000
:
1
)
);
setResult
(
true
);
t
.
disconnect
();
}
...
...
src/Communications/TCP/UTCPStream.cc
View file @
7c03e4dd
...
...
@@ -27,8 +27,8 @@ void UTCPStream::setKeepAliveParams(timeout_t timeout_sec, int keepcnt, int keep
{
SOCKET
fd
=
TCPStream
::
so
;
int
enable
=
1
;
setsockopt
(
fd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
enable
,
sizeof
(
enable
));
setsockopt
(
fd
,
SOL_TCP
,
TCP_KEEPCNT
,
(
void
*
)
&
keepcnt
,
sizeof
(
keepcnt
));
setsockopt
(
fd
,
SOL_SOCKET
,
SO_KEEPALIVE
,
(
void
*
)
&
enable
,
sizeof
(
enable
));
setsockopt
(
fd
,
SOL_TCP
,
TCP_KEEPCNT
,
(
void
*
)
&
keepcnt
,
sizeof
(
keepcnt
));
setsockopt
(
fd
,
SOL_TCP
,
TCP_KEEPINTVL
,
(
void
*
)
&
keepintvl
,
sizeof
(
keepintvl
));
setsockopt
(
fd
,
SOL_TCP
,
TCP_KEEPIDLE
,
(
void
*
)
&
timeout_sec
,
sizeof
(
timeout_sec
));
}
...
...
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