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
fc266eae
Commit
fc266eae
authored
Jun 23, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(UNetExchange): первая версия реализации "паузы на начальную инициализацию"
(после которой обновляется состояние датчиков о наличии связи).
parent
56392381
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+6
-1
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+17
-0
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+5
-0
No files found.
extensions/UNetUDP/UNetExchange.cc
View file @
fc266eae
...
@@ -85,6 +85,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
...
@@ -85,6 +85,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
int
maxDiff
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-maxdifferense"
,
it
.
getProp
(
"maxDifferense"
),
100
);
int
maxDiff
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-maxdifferense"
,
it
.
getProp
(
"maxDifferense"
),
100
);
int
maxProcessingCount
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-maxprocessingcount"
,
it
.
getProp
(
"maxProcessingCount"
),
100
);
int
maxProcessingCount
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-maxprocessingcount"
,
it
.
getProp
(
"maxProcessingCount"
),
100
);
int
checkConnectionPause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-checkconnection-pause"
,
it
.
getProp
(
"checkConnectionPause"
),
10000
);
int
checkConnectionPause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-checkconnection-pause"
,
it
.
getProp
(
"checkConnectionPause"
),
10000
);
int
initpause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-initpause"
,
it
.
getProp
(
"initpause"
),
5000
);
std
::
string
updateStrategy
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-update-strategy"
,
it
.
getProp
(
"updateStrategy"
),
"evloop"
);
std
::
string
updateStrategy
=
conf
->
getArg2Param
(
"--"
+
prefix
+
"-update-strategy"
,
it
.
getProp
(
"updateStrategy"
),
"evloop"
);
...
@@ -340,6 +341,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
...
@@ -340,6 +341,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
r
->
setReceivePause
(
recvpause
);
r
->
setReceivePause
(
recvpause
);
r
->
setUpdatePause
(
updatepause
);
r
->
setUpdatePause
(
updatepause
);
r
->
setCheckConnectionPause
(
checkConnectionPause
);
r
->
setCheckConnectionPause
(
checkConnectionPause
);
r
->
setInitPause
(
initpause
);
r
->
setMaxDifferens
(
maxDiff
);
r
->
setMaxDifferens
(
maxDiff
);
r
->
setMaxProcessingCount
(
maxProcessingCount
);
r
->
setMaxProcessingCount
(
maxProcessingCount
);
r
->
setRespondID
(
resp_id
,
resp_invert
);
r
->
setRespondID
(
resp_id
,
resp_invert
);
...
@@ -370,6 +372,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
...
@@ -370,6 +372,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
r2
->
setReceivePause
(
recvpause
);
r2
->
setReceivePause
(
recvpause
);
r2
->
setUpdatePause
(
updatepause
);
r2
->
setUpdatePause
(
updatepause
);
r2
->
setCheckConnectionPause
(
checkConnectionPause
);
r2
->
setCheckConnectionPause
(
checkConnectionPause
);
r2
->
setInitPause
(
initpause
);
r2
->
setMaxDifferens
(
maxDiff
);
r2
->
setMaxDifferens
(
maxDiff
);
r2
->
setMaxProcessingCount
(
maxProcessingCount
);
r2
->
setMaxProcessingCount
(
maxProcessingCount
);
r2
->
setRespondID
(
resp2_id
,
resp_invert
);
r2
->
setRespondID
(
resp2_id
,
resp_invert
);
...
@@ -536,7 +539,9 @@ void UNetExchange::ReceiverInfo::step( const std::shared_ptr<SMInterface>& shm,
...
@@ -536,7 +539,9 @@ void UNetExchange::ReceiverInfo::step( const std::shared_ptr<SMInterface>& shm,
if
(
respondInvert
)
if
(
respondInvert
)
resp
=
!
resp
;
resp
=
!
resp
;
shm
->
localSetValue
(
itRespond
,
sidRespond
,
resp
,
shm
->
ID
());
// сохраняем только если закончилось время на начальную инициализацию
if
(
(
r1
&&
r1
->
isInitOK
())
||
(
r2
&&
r2
->
isInitOK
())
)
shm
->
localSetValue
(
itRespond
,
sidRespond
,
resp
,
shm
->
ID
());
}
}
}
}
catch
(
const
std
::
exception
&
ex
)
catch
(
const
std
::
exception
&
ex
)
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
fc266eae
...
@@ -83,6 +83,8 @@ UNetReceiver::UNetReceiver(const std::string& s_host, int _port, const std::shar
...
@@ -83,6 +83,8 @@ UNetReceiver::UNetReceiver(const std::string& s_host, int _port, const std::shar
evStatistic
.
set
<
UNetReceiver
,
&
UNetReceiver
::
statisticsEvent
>
(
this
);
evStatistic
.
set
<
UNetReceiver
,
&
UNetReceiver
::
statisticsEvent
>
(
this
);
evUpdate
.
set
<
UNetReceiver
,
&
UNetReceiver
::
updateEvent
>
(
this
);
evUpdate
.
set
<
UNetReceiver
,
&
UNetReceiver
::
updateEvent
>
(
this
);
ptInitOK
.
setTiming
(
initPause
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
UNetReceiver
::~
UNetReceiver
()
UNetReceiver
::~
UNetReceiver
()
...
@@ -144,6 +146,12 @@ void UNetReceiver::setEvrunTimeout( timeout_t msec ) noexcept
...
@@ -144,6 +146,12 @@ void UNetReceiver::setEvrunTimeout( timeout_t msec ) noexcept
evrunTimeout
=
msec
;
evrunTimeout
=
msec
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UNetReceiver
::
setInitPause
(
timeout_t
msec
)
noexcept
{
initPause
=
msec
;
ptInitOK
.
setTiming
(
initPause
);
}
// -----------------------------------------------------------------------------
void
UNetReceiver
::
setRespondID
(
uniset
::
ObjectId
id
,
bool
invert
)
noexcept
void
UNetReceiver
::
setRespondID
(
uniset
::
ObjectId
id
,
bool
invert
)
noexcept
{
{
sidRespond
=
id
;
sidRespond
=
id
;
...
@@ -166,6 +174,11 @@ void UNetReceiver::setLockUpdate( bool st ) noexcept
...
@@ -166,6 +174,11 @@ void UNetReceiver::setLockUpdate( bool st ) noexcept
ptPrepare
.
reset
();
ptPrepare
.
reset
();
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
bool
UNetReceiver
::
isInitOK
()
const
noexcept
{
return
ptInitOK
.
checkTime
();
}
// -----------------------------------------------------------------------------
void
UNetReceiver
::
resetTimeout
()
noexcept
void
UNetReceiver
::
resetTimeout
()
noexcept
{
{
std
::
lock_guard
<
std
::
mutex
>
l
(
tmMutex
);
std
::
lock_guard
<
std
::
mutex
>
l
(
tmMutex
);
...
@@ -238,7 +251,10 @@ void UNetReceiver::start()
...
@@ -238,7 +251,10 @@ void UNetReceiver::start()
}
}
if
(
upStrategy
==
useUpdateThread
&&
!
upThread
->
isRunning
()
)
if
(
upStrategy
==
useUpdateThread
&&
!
upThread
->
isRunning
()
)
{
ptInitOK
.
reset
();
upThread
->
start
();
upThread
->
start
();
}
}
}
else
else
forceUpdate
();
forceUpdate
();
...
@@ -248,6 +264,7 @@ void UNetReceiver::evprepare( const ev::loop_ref& eloop ) noexcept
...
@@ -248,6 +264,7 @@ void UNetReceiver::evprepare( const ev::loop_ref& eloop ) noexcept
{
{
evStatistic
.
set
(
eloop
);
evStatistic
.
set
(
eloop
);
evStatistic
.
start
(
0
,
1.0
);
// раз в сек
evStatistic
.
start
(
0
,
1.0
);
// раз в сек
ptInitOK
.
reset
();
if
(
upStrategy
==
useUpdateEventLoop
)
if
(
upStrategy
==
useUpdateEventLoop
)
{
{
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
fc266eae
...
@@ -119,6 +119,8 @@ namespace uniset
...
@@ -119,6 +119,8 @@ namespace uniset
return
lockUpdate
;
return
lockUpdate
;
}
}
bool
isInitOK
()
const
noexcept
;
void
resetTimeout
()
noexcept
;
void
resetTimeout
()
noexcept
;
inline
bool
isRecvOK
()
const
noexcept
inline
bool
isRecvOK
()
const
noexcept
...
@@ -138,6 +140,7 @@ namespace uniset
...
@@ -138,6 +140,7 @@ namespace uniset
void
setCheckConnectionPause
(
timeout_t
msec
)
noexcept
;
void
setCheckConnectionPause
(
timeout_t
msec
)
noexcept
;
void
setMaxDifferens
(
unsigned
long
set
)
noexcept
;
void
setMaxDifferens
(
unsigned
long
set
)
noexcept
;
void
setEvrunTimeout
(
timeout_t
msec
)
noexcept
;
void
setEvrunTimeout
(
timeout_t
msec
)
noexcept
;
void
setInitPause
(
timeout_t
msec
)
noexcept
;
void
setRespondID
(
uniset
::
ObjectId
id
,
bool
invert
=
false
)
noexcept
;
void
setRespondID
(
uniset
::
ObjectId
id
,
bool
invert
=
false
)
noexcept
;
void
setLostPacketsID
(
uniset
::
ObjectId
id
)
noexcept
;
void
setLostPacketsID
(
uniset
::
ObjectId
id
)
noexcept
;
...
@@ -278,10 +281,12 @@ namespace uniset
...
@@ -278,10 +281,12 @@ namespace uniset
PassiveTimer
ptRecvTimeout
;
PassiveTimer
ptRecvTimeout
;
PassiveTimer
ptPrepare
;
PassiveTimer
ptPrepare
;
PassiveTimer
ptInitOK
;
timeout_t
recvTimeout
=
{
5000
};
// msec
timeout_t
recvTimeout
=
{
5000
};
// msec
timeout_t
prepareTime
=
{
2000
};
timeout_t
prepareTime
=
{
2000
};
timeout_t
evrunTimeout
=
{
15000
};
timeout_t
evrunTimeout
=
{
15000
};
timeout_t
lostTimeout
=
{
200
};
timeout_t
lostTimeout
=
{
200
};
timeout_t
initPause
=
{
5000
};
// пауза на начальную инициализацию
PassiveTimer
ptLostTimeout
;
PassiveTimer
ptLostTimeout
;
size_t
lostPackets
=
{
0
};
/*!< счётчик потерянных пакетов */
size_t
lostPackets
=
{
0
};
/*!< счётчик потерянных пакетов */
...
...
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