Commit a46fcef3 authored by Pavel Vainerman's avatar Pavel Vainerman

(UNetUDP): небольшой рефакторинг, подправил тесты, добавил вывод дополнительной

информации в getShortInfo().
parent 1826c476
......@@ -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 )
{
CacheList& d_icache(mit->second.cache);
CacheVec& 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 )
{
CacheList& a_icache(mit->second.cache);
CacheVec& 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());
}
......
......@@ -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> CacheList;
typedef std::vector<CacheItem> CacheVec;
struct CacheInfo
{
CacheInfo():
......@@ -232,8 +232,9 @@ class UNetReceiver:
{
}
bool cache_init_ok;
CacheList cache;
CacheVec cache;
};
// ключом является UDPMessage::getDataID()
typedef std::unordered_map<long, CacheInfo> CacheMap;
CacheMap d_icache_map; /*!< кэш итераторов для булевых */
CacheMap a_icache_map; /*!< кэш итераторов для аналоговых */
......
......@@ -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());
}
......
#!/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
......
......@@ -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(120);
msleep(80);
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(120);
msleep(100);
REQUIRE( ui->getValue(8) == 21 );
REQUIRE( ui->getValue(node2_lostpackets_as) == nlost );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment