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
a46fcef3
Commit
a46fcef3
authored
Aug 13, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(UNetUDP): небольшой рефакторинг, подправил тесты, добавил вывод дополнительной
информации в getShortInfo().
parent
1826c476
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
12 deletions
+35
-12
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+18
-3
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+4
-3
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+9
-2
start_fg.sh
extensions/UNetUDP/start_fg.sh
+1
-1
test_unetudp.cc
extensions/UNetUDP/tests/test_unetudp.cc
+3
-3
No files found.
extensions/UNetUDP/UNetReceiver.cc
View file @
a46fcef3
...
...
@@ -270,6 +270,7 @@ void UNetReceiver::real_update()
if
(
!
ptLostTimeout
.
checkTime
()
)
return
;
unetwarn
<<
myname
<<
"(update): lostTimeout("
<<
ptLostTimeout
.
getInterval
()
<<
")! pnum="
<<
p
.
num
<<
" lost "
<<
sub
<<
" packets "
<<
endl
;
lostPackets
+=
sub
;
}
else
if
(
p
.
num
==
pnum
)
...
...
@@ -286,7 +287,10 @@ void UNetReceiver::real_update()
{
// считаем сколько пакетов потеряли..
if
(
p
.
num
>
pnum
)
{
lostPackets
+=
sub
;
unetwarn
<<
myname
<<
"(update): sub="
<<
sub
<<
" > maxDifferenst("
<<
maxDifferens
<<
")! lost "
<<
sub
<<
" packets "
<<
endl
;
}
}
}
...
...
@@ -546,7 +550,7 @@ void UNetReceiver::initIterators()
{
for
(
auto
mit
=
d_icache_map
.
begin
();
mit
!=
d_icache_map
.
end
();
++
mit
)
{
Cache
List
&
d_icache
(
mit
->
second
.
cache
);
Cache
Vec
&
d_icache
(
mit
->
second
.
cache
);
for
(
auto
&&
it
:
d_icache
)
shm
->
initIterator
(
it
.
ioit
);
...
...
@@ -554,7 +558,7 @@ void UNetReceiver::initIterators()
for
(
auto
mit
=
a_icache_map
.
begin
();
mit
!=
a_icache_map
.
end
();
++
mit
)
{
Cache
List
&
a_icache
(
mit
->
second
.
cache
);
Cache
Vec
&
a_icache
(
mit
->
second
.
cache
);
for
(
auto
&&
it
:
a_icache
)
shm
->
initIterator
(
it
.
ioit
);
...
...
@@ -666,7 +670,18 @@ const std::string UNetReceiver::getShortInfo() const
s
<<
setw
(
15
)
<<
std
::
right
<<
getAddress
()
<<
":"
<<
std
::
left
<<
setw
(
6
)
<<
getPort
()
<<
(
isLockUpdate
()
?
"PASSIVE"
:
"ACTIVE"
)
<<
" recvOK="
<<
isRecvOK
()
<<
" lostPackets="
<<
setw
(
6
)
<<
getLostPacketsNum
();
<<
" lostPackets="
<<
setw
(
6
)
<<
getLostPacketsNum
()
<<
endl
<<
"
\t
["
<<
" recvTimeout="
<<
setw
(
6
)
<<
recvTimeout
<<
" prepareTime="
<<
setw
(
6
)
<<
prepareTime
<<
" lostTimeout="
<<
setw
(
6
)
<<
lostTimeout
<<
" recvpause="
<<
setw
(
6
)
<<
recvpause
<<
" updatepause="
<<
setw
(
6
)
<<
updatepause
<<
" maxDifferens="
<<
setw
(
6
)
<<
maxDifferens
<<
" maxProcessingCount="
<<
setw
(
6
)
<<
maxProcessingCount
<<
" waitClean="
<<
waitClean
<<
" ]"
;
return
std
::
move
(
s
.
str
());
}
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
a46fcef3
...
...
@@ -162,7 +162,7 @@ class UNetReceiver:
private
:
UNetReceiver
();
int
recvpause
;
/*!< пауза меджду приёмами пакетов, [мсек] */
int
recvpause
;
/*!< пауза меджду приёмами пакетов, [мсек] */
int
updatepause
;
/*!< переодичность обновления данных в SM, [мсек] */
std
::
shared_ptr
<
ost
::
UDPReceive
>
udp
;
...
...
@@ -224,7 +224,7 @@ class UNetReceiver:
id
(
UniSetTypes
::
DefaultObjectId
),
iotype
(
UniversalIO
::
UnknownIOType
)
{}
};
typedef
std
::
vector
<
CacheItem
>
Cache
List
;
typedef
std
::
vector
<
CacheItem
>
Cache
Vec
;
struct
CacheInfo
{
CacheInfo
()
:
...
...
@@ -232,8 +232,9 @@ class UNetReceiver:
{
}
bool
cache_init_ok
;
Cache
List
cache
;
Cache
Vec
cache
;
};
// ключом является UDPMessage::getDataID()
typedef
std
::
unordered_map
<
long
,
CacheInfo
>
CacheMap
;
CacheMap
d_icache_map
;
/*!< кэш итераторов для булевых */
CacheMap
a_icache_map
;
/*!< кэш итераторов для аналоговых */
...
...
extensions/UNetUDP/UNetSender.cc
View file @
a46fcef3
...
...
@@ -465,8 +465,15 @@ const std::string UNetSender::getShortInfo() const
ostringstream
s
;
s
<<
setw
(
15
)
<<
std
::
right
<<
getAddress
()
<<
":"
<<
std
::
left
<<
setw
(
6
)
<<
getPort
()
<<
" packetnum="
<<
packetnum
<<
" lastcrc="
<<
setw
(
6
)
<<
lastcrc
;
<<
" lastpacknum="
<<
packetnum
<<
" lastcrc="
<<
setw
(
6
)
<<
lastcrc
<<
" items="
<<
maxItem
<<
endl
<<
"
\t
packs: [sendfactor]=count: "
<<
endl
;
for
(
auto
i
=
mypacks
.
begin
();
i
!=
mypacks
.
end
();
++
i
)
s
<<
"
\t\t
["
<<
i
->
first
<<
"]="
<<
i
->
second
.
size
()
<<
endl
;
return
std
::
move
(
s
.
str
());
}
...
...
extensions/UNetUDP/start_fg.sh
View file @
a46fcef3
#!/bin/sh
uniset2-start.sh
-f
./uniset2-unetexchange
--unet-name
UNetExchange
\
uniset2-start.sh
-f
./uniset2-unetexchange
--unet-name
UNetExchange
--unet-run-logserver
\
--confile
test.xml
--smemory-id
SharedMemory
\
--unet-filter-field
rs
--unet-filter-value
2
--unet-maxdifferense
40
--unet-sendpause
1000
\
--dlog-add-levels
info,crit,warn
--unet-log-add-levels
info,crit,warn
...
...
extensions/UNetUDP/tests/test_unetudp.cc
View file @
a46fcef3
...
...
@@ -319,13 +319,13 @@ TEST_CASE("[UNetUDP]: check packets 'hole'", "[unetudp][udphole]")
int
lastnum
=
s_numpack
-
1
;
// искуственно делаем дырку в два пакета
// искус
с
твенно делаем дырку в два пакета
s_numpack
=
lastnum
+
3
;
UniSetUDP
::
UDPMessage
pack_hole
;
pack_hole
.
addAData
(
8
,
30
);
send
(
pack_hole
);
// пакет с дыркой
msleep
(
12
0
);
msleep
(
8
0
);
REQUIRE
(
ui
->
getValue
(
8
)
==
15
);
REQUIRE
(
ui
->
getValue
(
node2_lostpackets_as
)
==
nlost
);
...
...
@@ -333,7 +333,7 @@ TEST_CASE("[UNetUDP]: check packets 'hole'", "[unetudp][udphole]")
UniSetUDP
::
UDPMessage
pack1
;
pack1
.
addAData
(
8
,
21
);
send
(
pack1
);
// заполняем первую дырку..// дырка закроется.. пакет тут же обработается
msleep
(
1
2
0
);
msleep
(
1
0
0
);
REQUIRE
(
ui
->
getValue
(
8
)
==
21
);
REQUIRE
(
ui
->
getValue
(
node2_lostpackets_as
)
==
nlost
);
...
...
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