Commit 1826c476 authored by Pavel Vainerman's avatar Pavel Vainerman

(UNetUDP): небольшой рефакторинг названий

parent 341a72b4
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- \ref pgUNetUDP_Common - \ref pgUNetUDP_Common
- \ref pgUNetUDP_Conf - \ref pgUNetUDP_Conf
- \ref pgUNetUDP_Reserv - \ref pgUNetUDP_Reserv
- \ref pgUNetUDP_SendFactor - \ref pgUNetUDP_SendFactor
\section pgUNetUDP_Common Общее описание \section pgUNetUDP_Common Общее описание
Обмен построен на основе протокола UDP. Обмен построен на основе протокола UDP.
......
...@@ -306,7 +306,7 @@ void UNetReceiver::real_update() ...@@ -306,7 +306,7 @@ void UNetReceiver::real_update()
initACache(p, !a_cache_init_ok); initACache(p, !a_cache_init_ok);
// Обработка дискретных // Обработка дискретных
ItemVecInfo& d_iv = d_icache_map[p.getDataID()]; CacheInfo& d_iv = d_icache_map[p.getDataID()];
for( size_t i = 0; i < p.dcount; i++ ) for( size_t i = 0; i < p.dcount; i++ )
{ {
...@@ -315,7 +315,7 @@ void UNetReceiver::real_update() ...@@ -315,7 +315,7 @@ void UNetReceiver::real_update()
long id = p.dID(i); long id = p.dID(i);
bool val = p.dValue(i); bool val = p.dValue(i);
ItemInfo& ii(d_iv.cache[i]); CacheItem& ii(d_iv.cache[i]);
if( ii.id != id ) if( ii.id != id )
{ {
...@@ -345,7 +345,7 @@ void UNetReceiver::real_update() ...@@ -345,7 +345,7 @@ void UNetReceiver::real_update()
} }
// Обработка аналоговых // Обработка аналоговых
ItemVecInfo& a_iv = a_icache_map[p.getDataID()]; CacheInfo& a_iv = a_icache_map[p.getDataID()];
for( size_t i = 0; i < p.acount; i++ ) for( size_t i = 0; i < p.acount; i++ )
{ {
...@@ -353,7 +353,7 @@ void UNetReceiver::real_update() ...@@ -353,7 +353,7 @@ void UNetReceiver::real_update()
{ {
UniSetUDP::UDPAData& d = p.a_dat[i]; UniSetUDP::UDPAData& d = p.a_dat[i];
ItemInfo& ii(a_iv.cache[i]); CacheItem& ii(a_iv.cache[i]);
if( ii.id != d.id ) if( ii.id != d.id )
{ {
...@@ -546,7 +546,7 @@ void UNetReceiver::initIterators() ...@@ -546,7 +546,7 @@ void UNetReceiver::initIterators()
{ {
for( auto mit = d_icache_map.begin(); mit != d_icache_map.end(); ++mit ) for( auto mit = d_icache_map.begin(); mit != d_icache_map.end(); ++mit )
{ {
ItemVec& d_icache(mit->second.cache); CacheList& d_icache(mit->second.cache);
for( auto && it : d_icache ) for( auto && it : d_icache )
shm->initIterator(it.ioit); shm->initIterator(it.ioit);
...@@ -554,7 +554,7 @@ void UNetReceiver::initIterators() ...@@ -554,7 +554,7 @@ void UNetReceiver::initIterators()
for( auto mit = a_icache_map.begin(); mit != a_icache_map.end(); ++mit ) for( auto mit = a_icache_map.begin(); mit != a_icache_map.end(); ++mit )
{ {
ItemVec& a_icache(mit->second.cache); CacheList& a_icache(mit->second.cache);
for( auto && it : a_icache ) for( auto && it : a_icache )
shm->initIterator(it.ioit); shm->initIterator(it.ioit);
...@@ -563,7 +563,7 @@ void UNetReceiver::initIterators() ...@@ -563,7 +563,7 @@ void UNetReceiver::initIterators()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force ) void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
{ {
ItemVecInfo& d_info(d_icache_map[pack.getDataID()]); CacheInfo& d_info(d_icache_map[pack.getDataID()]);
if( !force && pack.dcount == d_info.cache.size() ) if( !force && pack.dcount == d_info.cache.size() )
return; return;
...@@ -575,7 +575,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -575,7 +575,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
for( ; it != d_icache_map.end(); ++it ) for( ; it != d_icache_map.end(); ++it )
{ {
ItemVecInfo& d_info(it->second); CacheInfo& d_info(it->second);
d_cache_init_ok = d_cache_init_ok && d_info.cache_init_ok; d_cache_init_ok = d_cache_init_ok && d_info.cache_init_ok;
if(d_cache_init_ok == false) if(d_cache_init_ok == false)
...@@ -595,7 +595,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -595,7 +595,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
for( size_t i = 0; i < sz; i++ ) for( size_t i = 0; i < sz; i++ )
{ {
ItemInfo& d(d_info.cache[i]); CacheItem& d(d_info.cache[i]);
if( d.id != pack.d_id[i] ) if( d.id != pack.d_id[i] )
{ {
...@@ -608,7 +608,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -608,7 +608,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force ) void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force )
{ {
ItemVecInfo& a_info(a_icache_map[pack.getDataID()]); CacheInfo& a_info(a_icache_map[pack.getDataID()]);
if( !force && pack.acount == a_info.cache.size() ) if( !force && pack.acount == a_info.cache.size() )
return; return;
...@@ -620,7 +620,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -620,7 +620,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force )
for( ; it != a_icache_map.end(); ++it ) for( ; it != a_icache_map.end(); ++it )
{ {
ItemVecInfo& a_info(it->second); CacheInfo& a_info(it->second);
a_cache_init_ok = a_cache_init_ok && a_info.cache_init_ok; a_cache_init_ok = a_cache_init_ok && a_info.cache_init_ok;
if(a_cache_init_ok == false) if(a_cache_init_ok == false)
...@@ -640,7 +640,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -640,7 +640,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force )
for( size_t i = 0; i < sz; i++ ) for( size_t i = 0; i < sz; i++ )
{ {
ItemInfo& d(a_info.cache[i]); CacheItem& d(a_info.cache[i]);
if( d.id != pack.a_dat[i].id ) if( d.id != pack.a_dat[i].id )
{ {
......
...@@ -214,29 +214,29 @@ class UNetReceiver: ...@@ -214,29 +214,29 @@ class UNetReceiver:
Trigger trTimeout; Trigger trTimeout;
UniSetTypes::uniset_rwmutex tmMutex; UniSetTypes::uniset_rwmutex tmMutex;
struct ItemInfo struct CacheItem
{ {
long id; long id;
IOController::IOStateList::iterator ioit; IOController::IOStateList::iterator ioit;
UniversalIO::IOType iotype; UniversalIO::IOType iotype;
ItemInfo(): CacheItem():
id(UniSetTypes::DefaultObjectId), iotype(UniversalIO::UnknownIOType) {} id(UniSetTypes::DefaultObjectId), iotype(UniversalIO::UnknownIOType) {}
}; };
typedef std::vector<ItemInfo> ItemVec; typedef std::vector<CacheItem> CacheList;
struct ItemVecInfo struct CacheInfo
{ {
ItemVecInfo(): CacheInfo():
cache_init_ok(false) cache_init_ok(false)
{ {
} }
bool cache_init_ok; bool cache_init_ok;
ItemVec cache; CacheList cache;
}; };
typedef std::unordered_map<long, ItemVecInfo> ItemVecInfoMap; typedef std::unordered_map<long, CacheInfo> CacheMap;
ItemVecInfoMap d_icache_map; /*!< кэш итераторов для булевых */ CacheMap d_icache_map; /*!< кэш итераторов для булевых */
ItemVecInfoMap a_icache_map; /*!< кэш итераторов для аналоговых */ CacheMap a_icache_map; /*!< кэш итераторов для аналоговых */
bool d_cache_init_ok; bool d_cache_init_ok;
bool a_cache_init_ok; bool a_cache_init_ok;
......
...@@ -244,7 +244,6 @@ void UNetSender::real_send(UniSetUDP::UDPMessage& mypack) ...@@ -244,7 +244,6 @@ void UNetSender::real_send(UniSetUDP::UDPMessage& mypack)
#endif #endif
if( packetnum > UniSetUDP::MaxPacketNum ) if( packetnum > UniSetUDP::MaxPacketNum )
packetnum = 1; packetnum = 1;
...@@ -453,7 +452,7 @@ void UNetSender::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -453,7 +452,7 @@ void UNetSender::askSensors( UniversalIO::UIOCommand cmd )
shm->askSensor(it.id, cmd); shm->askSensor(it.id, cmd);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int UNetSender::getDataPackCount() int UNetSender::getDataPackCount() const
{ {
return mypacks.size(); return mypacks.size();
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
/* /*
* Распределение датчиков по пакетам * Распределение датчиков по пакетам
* ========================================================================= * =========================================================================
* Все пересылаемые данные разбиваются в группы по частоте посылки("sendfactor"). * Все пересылаемые данные разбиваются на группы по частоте посылки("sendfactor").
* Частота посылки кратна sendpause, задаётся для каждого датчика, при помощи свойства prefix_sendfactor. * Частота посылки кратна sendpause, задаётся для каждого датчика, при помощи свойства prefix_sendfactor.
* Внутри каждой группы пакеты набираются по мере "заполнения". * Внутри каждой группы пакеты набираются по мере "заполнения".
* *
...@@ -64,7 +64,7 @@ class UNetSender ...@@ -64,7 +64,7 @@ class UNetSender
typedef std::vector<UItem> DMap; typedef std::vector<UItem> DMap;
int getDataPackCount(); int getDataPackCount() const;
void start(); void start();
void stop(); void stop();
...@@ -112,11 +112,11 @@ class UNetSender ...@@ -112,11 +112,11 @@ class UNetSender
return port; return port;
} }
inline size_t getADataSize() inline size_t getADataSize() const
{ {
return maxAData; return maxAData;
} }
inline size_t getDDataSize() inline size_t getDDataSize() const
{ {
return maxDData; return maxDData;
} }
...@@ -150,7 +150,6 @@ class UNetSender ...@@ -150,7 +150,6 @@ class UNetSender
UniSetTypes::uniset_rwmutex pack_mutex; UniSetTypes::uniset_rwmutex pack_mutex;
// int - sendfactor
typedef std::unordered_map<sendfactor_t, std::vector<UniSetUDP::UDPMessage>> Packs; typedef std::unordered_map<sendfactor_t, std::vector<UniSetUDP::UDPMessage>> Packs;
Packs mypacks; Packs mypacks;
......
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