Commit ebd3c841 authored by Pavel Vainerman's avatar Pavel Vainerman

(Unet2): добавил параметр unet_respond_invert для возможности инвертирования…

(Unet2): добавил параметр unet_respond_invert для возможности инвертирования логики выставления датчиков связи.
parent a5e8affc
...@@ -35,7 +35,9 @@ int main(int argc, const char **argv) ...@@ -35,7 +35,9 @@ int main(int argc, const char **argv)
for(int i=0; i<size; i++) for(int i=0; i<size; i++)
cout << "id=" << seq[i].si.id << " val=" << seq[i].value << endl; cout << "id=" << seq[i].si.id << " val=" << seq[i].value << endl;
*/ */
bool fullname = conf->getArgInt("--fullname"); bool fullname = false;
if( findArgParam("--fullname",conf->getArgc(),conf->getArgv()) != -1 )
fullname = true;
SViewer sv(conf->getControllersSection(),!fullname); SViewer sv(conf->getControllersSection(),!fullname);
timeout_t timeMS = conf->getArgInt("--polltime"); timeout_t timeMS = conf->getArgInt("--polltime");
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 1.3 Version: 1.3
Release: alt13 Release: alt14
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
License: GPL License: GPL
Group: Development/C++ Group: Development/C++
...@@ -213,6 +213,9 @@ rm -f %buildroot%_libdir/*.la ...@@ -213,6 +213,9 @@ rm -f %buildroot%_libdir/*.la
%changelog %changelog
* Thu Mar 15 2012 Pavel Vainerman <pv@altlinux.ru> 1.3-alt14
- (unet2): add 'unet_respond_invert' parameter
* Sun Mar 11 2012 Pavel Vainerman <pv@altlinux.ru> 1.3-alt13 * Sun Mar 11 2012 Pavel Vainerman <pv@altlinux.ru> 1.3-alt13
- minor fixes in uniset-codegen (add "preAskSensors") - minor fixes in uniset-codegen (add "preAskSensors")
......
...@@ -151,6 +151,8 @@ sender2(0) ...@@ -151,6 +151,8 @@ sender2(0)
continue; continue;
} }
bool resp_invert = n_it.getIntProp("unet_respond_invert");
string s_resp_id(n_it.getProp("unet_respond1_id")); string s_resp_id(n_it.getProp("unet_respond1_id"));
UniSetTypes::ObjectId resp_id = UniSetTypes::DefaultObjectId; UniSetTypes::ObjectId resp_id = UniSetTypes::DefaultObjectId;
if( !s_resp_id.empty() ) if( !s_resp_id.empty() )
...@@ -250,7 +252,7 @@ sender2(0) ...@@ -250,7 +252,7 @@ sender2(0)
r->setUpdatePause(updatepause); r->setUpdatePause(updatepause);
r->setMaxDifferens(maxDiff); r->setMaxDifferens(maxDiff);
r->setMaxProcessingCount(maxProcessingCount); r->setMaxProcessingCount(maxProcessingCount);
r->setRespondID(resp_id); r->setRespondID(resp_id,resp_invert);
r->setLostPacketsID(lp_id); r->setLostPacketsID(lp_id);
r->connectEvent( sigc::mem_fun(this, &UNetExchange::receiverEvent) ); r->connectEvent( sigc::mem_fun(this, &UNetExchange::receiverEvent) );
...@@ -273,7 +275,7 @@ sender2(0) ...@@ -273,7 +275,7 @@ sender2(0)
r2->setUpdatePause(updatepause); r2->setUpdatePause(updatepause);
r2->setMaxDifferens(maxDiff); r2->setMaxDifferens(maxDiff);
r2->setMaxProcessingCount(maxProcessingCount); r2->setMaxProcessingCount(maxProcessingCount);
r2->setRespondID(resp2_id); r2->setRespondID(resp2_id,resp_invert);
r2->setLostPacketsID(lp2_id); r2->setLostPacketsID(lp2_id);
r2->connectEvent( sigc::mem_fun(this, &UNetExchange::receiverEvent) ); r2->connectEvent( sigc::mem_fun(this, &UNetExchange::receiverEvent) );
} }
...@@ -287,7 +289,7 @@ sender2(0) ...@@ -287,7 +289,7 @@ sender2(0)
} }
ReceiverInfo ri(r,r2); ReceiverInfo ri(r,r2);
ri.setRespondID(resp_comm_id); ri.setRespondID(resp_comm_id,resp_invert);
ri.setLostPacketsID(lp_comm_id); ri.setLostPacketsID(lp_comm_id);
recvlist.push_back(ri); recvlist.push_back(ri);
} }
...@@ -427,6 +429,9 @@ void UNetExchange::ReceiverInfo::step( SMInterface* shm, const std::string mynam ...@@ -427,6 +429,9 @@ void UNetExchange::ReceiverInfo::step( SMInterface* shm, const std::string mynam
if( sidRespond != DefaultObjectId ) if( sidRespond != DefaultObjectId )
{ {
bool resp = ( (r1 && r1->isRecvOK()) || (r2 && r2->isRecvOK()) ); bool resp = ( (r1 && r1->isRecvOK()) || (r2 && r2->isRecvOK()) );
if( respondInvert )
resp = !resp;
shm->localSaveState(ditRespond,sidRespond,resp,shm->ID()); shm->localSaveState(ditRespond,sidRespond,resp,shm->ID());
} }
} }
......
...@@ -148,6 +148,7 @@ class UNetExchange: ...@@ -148,6 +148,7 @@ class UNetExchange:
ReceiverInfo(UNetReceiver* _r1, UNetReceiver* _r2 ): ReceiverInfo(UNetReceiver* _r1, UNetReceiver* _r2 ):
r1(_r1),r2(_r2), r1(_r1),r2(_r2),
sidRespond(UniSetTypes::DefaultObjectId), sidRespond(UniSetTypes::DefaultObjectId),
respondInvert(false),
sidLostPackets(UniSetTypes::DefaultObjectId) sidLostPackets(UniSetTypes::DefaultObjectId)
{} {}
...@@ -156,7 +157,11 @@ class UNetExchange: ...@@ -156,7 +157,11 @@ class UNetExchange:
void step( SMInterface* shm, const std::string myname ); void step( SMInterface* shm, const std::string myname );
inline void setRespondID( UniSetTypes::ObjectId id ){ sidRespond = id; } inline void setRespondID( UniSetTypes::ObjectId id, bool invert=false)
{
sidRespond = id;
respondInvert = invert;
}
inline void setLostPacketsID( UniSetTypes::ObjectId id ){ sidLostPackets = id; } inline void setLostPacketsID( UniSetTypes::ObjectId id ){ sidLostPackets = id; }
inline void initIterators( SMInterface* shm ) inline void initIterators( SMInterface* shm )
{ {
...@@ -170,6 +175,7 @@ class UNetExchange: ...@@ -170,6 +175,7 @@ class UNetExchange:
// ( реализацию см. ReceiverInfo::step() ) // ( реализацию см. ReceiverInfo::step() )
UniSetTypes::ObjectId sidRespond; UniSetTypes::ObjectId sidRespond;
IOController::DIOStateList::iterator ditRespond; IOController::DIOStateList::iterator ditRespond;
bool respondInvert;
UniSetTypes::ObjectId sidLostPackets; UniSetTypes::ObjectId sidLostPackets;
IOController::AIOStateList::iterator aitLostPackets; IOController::AIOStateList::iterator aitLostPackets;
}; };
......
...@@ -28,6 +28,7 @@ recvTimeout(5000), ...@@ -28,6 +28,7 @@ recvTimeout(5000),
lostTimeout(5000), lostTimeout(5000),
lostPackets(0), lostPackets(0),
sidRespond(UniSetTypes::DefaultObjectId), sidRespond(UniSetTypes::DefaultObjectId),
respondInvert(false),
sidLostPackets(UniSetTypes::DefaultObjectId), sidLostPackets(UniSetTypes::DefaultObjectId),
activated(false), activated(false),
r_thr(0), r_thr(0),
...@@ -118,9 +119,10 @@ void UNetReceiver::setMaxDifferens( unsigned long set ) ...@@ -118,9 +119,10 @@ void UNetReceiver::setMaxDifferens( unsigned long set )
maxDifferens = set; maxDifferens = set;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetReceiver::setRespondID( UniSetTypes::ObjectId id ) void UNetReceiver::setRespondID( UniSetTypes::ObjectId id, bool invert )
{ {
sidRespond = id; sidRespond = id;
respondInvert = invert;
shm->initDIterator(ditRespond); shm->initDIterator(ditRespond);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -175,7 +177,8 @@ void UNetReceiver::update() ...@@ -175,7 +177,8 @@ void UNetReceiver::update()
{ {
try try
{ {
shm->localSaveState(ditRespond,sidRespond,isRecvOK(),shm->ID()); bool r = respondInvert ? !isRecvOK() : isRecvOK();
shm->localSaveState(ditRespond,sidRespond,r,shm->ID());
} }
catch(Exception& ex) catch(Exception& ex)
{ {
......
...@@ -75,7 +75,7 @@ class UNetReceiver ...@@ -75,7 +75,7 @@ class UNetReceiver
void setLostTimeout( timeout_t msec ); void setLostTimeout( timeout_t msec );
void setMaxDifferens( unsigned long set ); void setMaxDifferens( unsigned long set );
void setRespondID( UniSetTypes::ObjectId id ); void setRespondID( UniSetTypes::ObjectId id, bool invert=false );
void setLostPacketsID( UniSetTypes::ObjectId id ); void setLostPacketsID( UniSetTypes::ObjectId id );
void setMaxProcessingCount( int set ); void setMaxProcessingCount( int set );
...@@ -123,6 +123,7 @@ class UNetReceiver ...@@ -123,6 +123,7 @@ class UNetReceiver
UniSetTypes::ObjectId sidRespond; UniSetTypes::ObjectId sidRespond;
IOController::DIOStateList::iterator ditRespond; IOController::DIOStateList::iterator ditRespond;
bool respondInvert;
UniSetTypes::ObjectId sidLostPackets; UniSetTypes::ObjectId sidLostPackets;
IOController::AIOStateList::iterator aitLostPackets; IOController::AIOStateList::iterator aitLostPackets;
......
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