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
6bb81d47
Commit
6bb81d47
authored
Aug 26, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Попытка решить проблемму WaitUpTime --> Poco::TimeStamp.
Т.к. в Poco "вечное ожидание" - это 0, а в uniset = -1 (сейчас max::value).
parent
54f51f78
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
13 deletions
+30
-13
log.cc
Utilities/ULog/log.cc
+3
-2
libuniset2.spec
conf/libuniset2.spec
+4
-1
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+1
-1
PassiveTimer.h
include/PassiveTimer.h
+4
-0
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+8
-7
LogReader.cc
src/Log/LogReader.cc
+2
-2
PassiveTimer.cc
src/Timers/PassiveTimer.cc
+8
-0
No files found.
Utilities/ULog/log.cc
View file @
6bb81d47
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <getopt.h>
#include <getopt.h>
#include "Debug.h"
#include "Debug.h"
#include "UniSetTypes.h"
#include "UniSetTypes.h"
#include "PassiveTimer.h"
#include "Exceptions.h"
#include "Exceptions.h"
#include "LogReader.h"
#include "LogReader.h"
#include "LogServerTypes.h"
#include "LogServerTypes.h"
...
@@ -44,7 +45,7 @@ static void print_help()
...
@@ -44,7 +45,7 @@ static void print_help()
printf
(
"[-i|--iaddr] addr - LogServer ip or hostname.
\n
"
);
printf
(
"[-i|--iaddr] addr - LogServer ip or hostname.
\n
"
);
printf
(
"[-p|--port] port - LogServer port.
\n
"
);
printf
(
"[-p|--port] port - LogServer port.
\n
"
);
printf
(
"[-c|--command-only] - Send command and break. (No read logs).
\n
"
);
printf
(
"[-c|--command-only] - Send command and break. (No read logs).
\n
"
);
printf
(
"[-t|--timeout] msec - Timeout for wait data. Default:
0
- endless waiting
\n
"
);
printf
(
"[-t|--timeout] msec - Timeout for wait data. Default:
WaitUpTime
- endless waiting
\n
"
);
printf
(
"[-x|--reconnect-delay] msec - Pause for repeat connect to LogServer. Default: 5000 msec.
\n
"
);
printf
(
"[-x|--reconnect-delay] msec - Pause for repeat connect to LogServer. Default: 5000 msec.
\n
"
);
printf
(
"[-w|--logfile] logfile - Save log to 'logfile'.
\n
"
);
printf
(
"[-w|--logfile] logfile - Save log to 'logfile'.
\n
"
);
printf
(
"[-z|--logfile-truncate] - Truncate log file before write. Use with -w|--logfile
\n
"
);
printf
(
"[-z|--logfile-truncate] - Truncate log file before write. Use with -w|--logfile
\n
"
);
...
@@ -85,7 +86,7 @@ int main( int argc, char** argv )
...
@@ -85,7 +86,7 @@ int main( int argc, char** argv )
string
logfilter
(
""
);
string
logfilter
(
""
);
LogServerTypes
::
Command
cmd
=
LogServerTypes
::
cmdNOP
;
LogServerTypes
::
Command
cmd
=
LogServerTypes
::
cmdNOP
;
int
cmdonly
=
0
;
int
cmdonly
=
0
;
timeout_t
tout
=
5000
;
timeout_t
tout
=
UniSetTimer
::
WaitUpTime
;
timeout_t
rdelay
=
5000
;
timeout_t
rdelay
=
5000
;
string
logfile
(
""
);
string
logfile
(
""
);
bool
logtruncate
=
false
;
bool
logtruncate
=
false
;
...
...
conf/libuniset2.spec
View file @
6bb81d47
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
Name: libuniset2
Name: libuniset2
Version: 2.5
Version: 2.5
Release: alt
1.
2
Release: alt2
Summary: UniSet - library for building distributed industrial control systems
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
License: LGPL
...
@@ -484,6 +484,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -484,6 +484,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
# ..
%changelog
%changelog
* Fri Aug 26 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt2
- Fixed converting timeout_t to Poco::TimeSpan
* Thu Aug 25 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt1.2
* Thu Aug 25 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt1.2
- (UNetUDP): add debug information (getInfo)
- (UNetUDP): add debug information (getInfo)
- minor fixes
- minor fixes
...
...
extensions/UNetUDP/UNetSender.cc
View file @
6bb81d47
...
@@ -115,7 +115,7 @@ bool UNetSender::createConnection( bool throwEx )
...
@@ -115,7 +115,7 @@ bool UNetSender::createConnection( bool throwEx )
//udp = make_shared<UDPSocketU>(addr, port);
//udp = make_shared<UDPSocketU>(addr, port);
udp
=
make_shared
<
UDPSocketU
>
();
udp
=
make_shared
<
UDPSocketU
>
();
udp
->
setBroadcast
(
true
);
udp
->
setBroadcast
(
true
);
udp
->
setSendTimeout
(
writeTimeout
*
1000
);
udp
->
setSendTimeout
(
UniSetTimer
::
timeoutToPoco
(
writeTimeout
*
1000
)
);
// udp->setNoDelay(true);
// udp->setNoDelay(true);
}
}
catch
(
const
std
::
exception
&
e
)
catch
(
const
std
::
exception
&
e
)
...
...
include/PassiveTimer.h
View file @
6bb81d47
...
@@ -68,6 +68,10 @@ class UniSetTimer
...
@@ -68,6 +68,10 @@ class UniSetTimer
*/
*/
static
const
timeout_t
WaitUpTime
=
std
::
numeric_limits
<
timeout_t
>::
max
();
static
const
timeout_t
WaitUpTime
=
std
::
numeric_limits
<
timeout_t
>::
max
();
// преобразование WaitUpTime в Poco waitpuTime у которого он = 0 :(
static
const
Poco
::
Timespan
timeoutToPoco
(
const
timeout_t
);
/*! Минимальное время срабатывания. Задается в мсек. */
/*! Минимальное время срабатывания. Задается в мсек. */
static
const
timeout_t
MinQuantityTime
=
10
;
static
const
timeout_t
MinQuantityTime
=
10
;
};
};
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
6bb81d47
...
@@ -58,15 +58,13 @@ void ModbusTCPMaster::setChannelTimeout( timeout_t msec )
...
@@ -58,15 +58,13 @@ void ModbusTCPMaster::setChannelTimeout( timeout_t msec )
if
(
!
tcp
)
if
(
!
tcp
)
return
;
return
;
Poco
::
Timespan
tm
=
UniSetTimer
::
timeoutToPoco
(
msec
*
1000
);
Poco
::
Timespan
old
=
tcp
->
getReceiveTimeout
();;
Poco
::
Timespan
old
=
tcp
->
getReceiveTimeout
();;
//timeout_t old = tcp->getReceiveTimeout();
Poco
::
Timespan
tmsec
(
msec
*
1000
);
if
(
old
.
microseconds
()
==
tm
.
microseconds
()
)
if
(
old
==
msec
)
return
;
return
;
tcp
->
setReceiveTimeout
(
tm
sec
);
tcp
->
setReceiveTimeout
(
tm
);
int
oldKeepAlive
=
keepAliveTimeout
;
int
oldKeepAlive
=
keepAliveTimeout
;
keepAliveTimeout
=
(
msec
>
1000
?
msec
/
1000
:
1
);
keepAliveTimeout
=
(
msec
>
1000
?
msec
/
1000
:
1
);
...
@@ -114,7 +112,10 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
...
@@ -114,7 +112,10 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
assert
(
timeout
);
assert
(
timeout
);
ptTimeout
.
setTiming
(
timeout
);
ptTimeout
.
setTiming
(
timeout
);
tcp
->
setReceiveTimeout
(
timeout
*
1000
);
if
(
timeout
==
UniSetTimer
::
WaitUpTime
)
tcp
->
setReceiveTimeout
(
0
);
else
tcp
->
setReceiveTimeout
(
timeout
*
1000
);
msg
.
makeHead
(
++
nTransaction
,
crcNoCheckit
);
msg
.
makeHead
(
++
nTransaction
,
crcNoCheckit
);
...
@@ -379,7 +380,7 @@ void ModbusTCPMaster::reconnect()
...
@@ -379,7 +380,7 @@ void ModbusTCPMaster::reconnect()
{
{
tcp
=
make_shared
<
UTCPStream
>
();
tcp
=
make_shared
<
UTCPStream
>
();
tcp
->
create
(
iaddr
,
port
,
500
);
tcp
->
create
(
iaddr
,
port
,
500
);
tcp
->
setReceiveTimeout
(
replyTimeOut_ms
*
1000
);
tcp
->
setReceiveTimeout
(
UniSetTimer
::
timeoutToPoco
(
replyTimeOut_ms
*
1000
)
);
tcp
->
setKeepAliveParams
((
replyTimeOut_ms
>
1000
?
replyTimeOut_ms
/
1000
:
1
));
tcp
->
setKeepAliveParams
((
replyTimeOut_ms
>
1000
?
replyTimeOut_ms
/
1000
:
1
));
tcp
->
setNoDelay
(
true
);
tcp
->
setNoDelay
(
true
);
}
}
...
...
src/Log/LogReader.cc
View file @
6bb81d47
...
@@ -78,8 +78,8 @@ void LogReader::connect( const std::string& _addr, int _port, timeout_t msec )
...
@@ -78,8 +78,8 @@ void LogReader::connect( const std::string& _addr, int _port, timeout_t msec )
{
{
tcp
=
make_shared
<
UTCPStream
>
();
tcp
=
make_shared
<
UTCPStream
>
();
tcp
->
create
(
iaddr
,
port
,
msec
);
tcp
->
create
(
iaddr
,
port
,
msec
);
tcp
->
setReceiveTimeout
(
inTimeout
*
1000
);
tcp
->
setReceiveTimeout
(
UniSetTimer
::
timeoutToPoco
(
inTimeout
*
1000
)
);
tcp
->
setSendTimeout
(
outTimeout
*
1000
);
tcp
->
setSendTimeout
(
UniSetTimer
::
timeoutToPoco
(
outTimeout
*
1000
)
);
tcp
->
setKeepAlive
(
true
);
tcp
->
setKeepAlive
(
true
);
tcp
->
setBlocking
(
true
);
tcp
->
setBlocking
(
true
);
}
}
...
...
src/Timers/PassiveTimer.cc
View file @
6bb81d47
...
@@ -101,3 +101,11 @@ bool UniSetTimer::wait( timeout_t timeMS )
...
@@ -101,3 +101,11 @@ bool UniSetTimer::wait( timeout_t timeMS )
return
false
;
return
false
;
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const
Poco
::
Timespan
UniSetTimer
::
timeoutToPoco
(
const
timeout_t
msec
)
{
if
(
msec
==
WaitUpTime
)
return
Poco
::
Timespan
(
0
,
0
);
return
Poco
::
Timespan
(
msec
/
100
,
msec
%
1000
);
}
//------------------------------------------------------------------------------
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