Commit 19acdd2a authored by Aleksey Vinogradov's avatar Aleksey Vinogradov

добавил енабл и дисабл записи в шару для ресиверов

parent 205dae78
......@@ -765,4 +765,32 @@ void UNetExchange::receiverEvent( UNetReceiver* r, UNetReceiver::Event ev )
}
}
// -----------------------------------------------------------------------------
void UNetExchange::enable(UniSetTypes::ObjectId id)
{
std::list<UNetReceiver*> rList = get_receivers();
std::list<UNetReceiver*>::iterator rIt = rList.begin();
for(; rIt != rList.end(); ++ rIt )
(*rIt)->enable(id);
}
// -----------------------------------------------------------------------------
void UNetExchange::disable(UniSetTypes::ObjectId id)
{
std::list<UNetReceiver*> rList = get_receivers();
std::list<UNetReceiver*>::iterator rIt = rList.begin();
for(; rIt != rList.end(); ++ rIt )
(*rIt)->disable(id);
}
// -----------------------------------------------------------------------------
std::list<UNetReceiver*> UNetExchange::get_receivers()
{
std::list<UNetReceiver*> tList;
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it )
{
if(it->r1)
tList.push_back(it->r1);
if(it->r2)
tList.push_back(it->r2);
}
return tList;
}
// -----------------------------------------------------------------------------
......@@ -90,7 +90,9 @@ class UNetExchange:
static void help_print( int argc, const char* argv[] );
bool checkExistUNetHost( const std::string& host, ost::tpport_t port );
std::list<UNetReceiver*> get_receivers();
void enable(UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId);
void disable(UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId);
protected:
xmlNode* cnode;
......
......@@ -297,8 +297,9 @@ void UNetReceiver::real_update()
if( lockUpdate )
continue;
}
if( ii.iotype == UniversalIO::DigitalInput )
if( !ii.update )
continue;
else if( ii.iotype == UniversalIO::DigitalInput )
shm->localSaveState(ii.dit,id,val,shm->ID());
else if( ii.iotype == UniversalIO::AnalogInput )
shm->localSaveValue(ii.ait,id,val,shm->ID());
......@@ -341,7 +342,9 @@ void UNetReceiver::real_update()
continue;
}
if( ii.iotype == UniversalIO::DigitalInput )
if( !ii.update )
continue;
else if( ii.iotype == UniversalIO::DigitalInput )
shm->localSaveState(ii.dit,d.id,d.val,shm->ID());
else if( ii.iotype == UniversalIO::AnalogInput )
shm->localSaveValue(ii.ait,d.id,d.val,shm->ID());
......@@ -519,6 +522,54 @@ void UNetReceiver::initIterators()
}
}
// -----------------------------------------------------------------------------
void UNetReceiver::enable(UniSetTypes::ObjectId id)
{
for( ItemVec::iterator it=d_icache.begin(); it!=d_icache.end(); ++it )
{
if( id == UniSetTypes::DefaultObjectId )
it->update = true;
else if( id == it->id )
{
it->update = true;
return;
}
}
for( ItemVec::iterator it=a_icache.begin(); it!=a_icache.end(); ++it )
{
if( id == UniSetTypes::DefaultObjectId )
it->update = true;
else if( id == it->id )
{
it->update = true;
return;
}
}
}
// -----------------------------------------------------------------------------
void UNetReceiver::disable(UniSetTypes::ObjectId id)
{
for( ItemVec::iterator it=d_icache.begin(); it!=d_icache.end(); ++it )
{
if( id == UniSetTypes::DefaultObjectId )
it->update = false;
else if( id == it->id )
{
it->update = false;
return;
}
}
for( ItemVec::iterator it=a_icache.begin(); it!=a_icache.end(); ++it )
{
if( id == UniSetTypes::DefaultObjectId )
it->update = false;
else if( id == it->id )
{
it->update = false;
return;
}
}
}
// -----------------------------------------------------------------------------
void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
{
if( !force && pack.dcount == d_icache.size() )
......
......@@ -93,6 +93,8 @@ class UNetReceiver
typedef sigc::slot<void,UNetReceiver*,Event> EventSlot;
void connectEvent( EventSlot sl );
void enable(UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId);
void disable(UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId);
protected:
......@@ -174,10 +176,12 @@ class UNetReceiver
IOController::AIOStateList::iterator ait;
IOController::DIOStateList::iterator dit;
UniversalIO::IOTypes iotype;
bool update;
ItemInfo():
id(UniSetTypes::DefaultObjectId),
iotype(UniversalIO::UnknownIOType){}
iotype(UniversalIO::UnknownIOType),
update(true){}
};
typedef std::vector<ItemInfo> ItemVec;
......
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