Commit 7892eb68 authored by Pavel Vainerman's avatar Pavel Vainerman

(LogicProcessor): добавил возможность задавать время ожидания готовности SM

(--sm-ready-timeout)
parent a89f8c86
#include <iostream> #include <iostream>
#include "Configuration.h" #include "Configuration.h"
#include "Extensions.h" #include "Extensions.h"
#include "PassiveTimer.h"
#include "LProcessor.h" #include "LProcessor.h"
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
using namespace std; using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
LProcessor::LProcessor() LProcessor::LProcessor( const std::string name ):
logname(name)
{ {
sleepTime = conf->getArgPInt("--sleepTime", 200); sleepTime = conf->getArgPInt("--sleepTime", 200);
smReadyTimeout = conf->getArgInt("--sm-ready-timeout","");
if( smReadyTimeout == 0 )
smReadyTimeout = 60000;
else if( smReadyTimeout < 0 )
smReadyTimeout = UniSetTimer::WaitUpTime;
} }
LProcessor::~LProcessor() LProcessor::~LProcessor()
...@@ -28,15 +35,15 @@ void LProcessor::execute( const string lfile ) ...@@ -28,15 +35,15 @@ void LProcessor::execute( const string lfile )
} }
catch( LogicException& ex ) catch( LogicException& ex )
{ {
dlog[Debug::CRIT] << "(LProcessor::execute): " << ex << endl; dlog[Debug::CRIT] << logname << "(execute): " << ex << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(LProcessor::execute): " << ex << endl; dlog[Debug::CRIT] << logname << "(execute): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(LProcessor::execute): catch...\n"; dlog[Debug::CRIT] << logname << "(execute): catch...\n";
} }
msleep(sleepTime); msleep(sleepTime);
} }
......
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
class LProcessor class LProcessor
{ {
public: public:
LProcessor(); LProcessor( const std::string name="" );
virtual ~LProcessor(); virtual ~LProcessor();
virtual void execute( const string lfile ); virtual void execute( const string lfile );
...@@ -133,6 +133,9 @@ class LProcessor ...@@ -133,6 +133,9 @@ class LProcessor
UniversalInterface ui; UniversalInterface ui;
int sleepTime; int sleepTime;
int smReadyTimeout; /*!< время ожидания готовности SM */
std::string logname;
private: private:
......
...@@ -11,6 +11,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o ...@@ -11,6 +11,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
UniSetObject_LT(objId), UniSetObject_LT(objId),
shm(0) shm(0)
{ {
logname = myname;
shm = new SMInterface(shmID,&(UniSetObject_LT::ui),objId,ic); shm = new SMInterface(shmID,&(UniSetObject_LT::ui),objId,ic);
build(lfile); build(lfile);
} }
...@@ -88,9 +89,9 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm ) ...@@ -88,9 +89,9 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm )
{ {
case SystemMessage::StartUp: case SystemMessage::StartUp:
{ {
if( !shm->waitSMready(10000) ) if( !shm->waitSMready(smReadyTimeout) )
{ {
dlog[Debug::CRIT] << "(ERR): SM not ready. Terminated... " << endl; dlog[Debug::CRIT] << myname << "(ERR): SM not ready. Terminated... " << endl;
raise(SIGTERM); raise(SIGTERM);
return; return;
} }
...@@ -163,17 +164,17 @@ void PassiveLProcessor::setOuts() ...@@ -163,17 +164,17 @@ void PassiveLProcessor::setOuts()
break; break;
default: default:
dlog[Debug::CRIT] << "(LProcessor::setOuts): неподдерживаемый тип iotype=" << it->iotype << endl; dlog[Debug::CRIT] << myname << "(setOuts): неподдерживаемый тип iotype=" << it->iotype << endl;
break; break;
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(LProcessor::setOuts): " << ex << endl; dlog[Debug::CRIT] << myname << "(setOuts): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(LProcessor::setOuts): catch...\n"; dlog[Debug::CRIT] << myname << "(setOuts): catch...\n";
} }
} }
} }
...@@ -195,17 +196,17 @@ void PassiveLProcessor::sigterm( int signo ) ...@@ -195,17 +196,17 @@ void PassiveLProcessor::sigterm( int signo )
break; break;
default: default:
dlog[Debug::CRIT] << "(LProcessor::sigterm): неподдерживаемый тип iotype=" << it->iotype << endl; dlog[Debug::CRIT] << myname << "(sigterm): неподдерживаемый тип iotype=" << it->iotype << endl;
break; break;
} }
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
dlog[Debug::CRIT] << "(LProcessor::sigterm): " << ex << endl; dlog[Debug::CRIT] << myname << "(sigterm): " << ex << endl;
} }
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(LProcessor::sigterm): catch...\n"; dlog[Debug::CRIT] << myname << "(sigterm): catch...\n";
} }
} }
} }
......
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include "Extensions.h"
#include "Schema.h" #include "Schema.h"
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
using namespace std; using namespace std;
using namespace UniSetExtensions;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Schema::Schema() Schema::Schema()
...@@ -30,7 +32,7 @@ void Schema::link(Element::ElementID rootID, Element::ElementID childID, int num ...@@ -30,7 +32,7 @@ void Schema::link(Element::ElementID rootID, Element::ElementID childID, int num
if( it == emap.end() ) if( it == emap.end() )
{ {
ostringstream msg; ostringstream msg;
msg << "Schema: элемент id=" << rootID << " НЕ НАЙДЕН!!!"; msg << "Schema: элемент id=" << rootID << " NOT FOUND!";
throw LogicException(msg.str()); throw LogicException(msg.str());
} }
e1 = it->second; e1 = it->second;
...@@ -39,7 +41,7 @@ void Schema::link(Element::ElementID rootID, Element::ElementID childID, int num ...@@ -39,7 +41,7 @@ void Schema::link(Element::ElementID rootID, Element::ElementID childID, int num
if( it == emap.end() ) if( it == emap.end() )
{ {
ostringstream msg; ostringstream msg;
msg << "Schema: элемент id=" << childID << " НЕ НАЙДЕН!!!"; msg << "Schema: элемент id=" << childID << " NOT FOUND!";
throw LogicException(msg.str()); throw LogicException(msg.str());
} }
e2 = it->second; e2 = it->second;
...@@ -59,7 +61,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID ) ...@@ -59,7 +61,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID )
if( it == emap.end() ) if( it == emap.end() )
{ {
ostringstream msg; ostringstream msg;
msg << "Schema: элемент id=" << rootID << " НЕ НАЙДЕН!!!"; msg << "Schema: элемент id=" << rootID << " NOT FOUND!";
throw LogicException(msg.str()); throw LogicException(msg.str());
} }
e1 = it->second; e1 = it->second;
...@@ -68,7 +70,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID ) ...@@ -68,7 +70,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID )
if( it == emap.end() ) if( it == emap.end() )
{ {
ostringstream msg; ostringstream msg;
msg << "Schema: элемент id=" << childID << " НЕ НАЙДЕН!!!"; msg << "Schema: element id=" << childID << " NOT FOUND!";
throw LogicException(msg.str()); throw LogicException(msg.str());
} }
e2 = it->second; e2 = it->second;
...@@ -92,7 +94,7 @@ void Schema::extlink(string name, Element::ElementID childID, int numIn ) ...@@ -92,7 +94,7 @@ void Schema::extlink(string name, Element::ElementID childID, int numIn )
if( it == emap.end() ) if( it == emap.end() )
{ {
ostringstream msg; ostringstream msg;
msg << "Schema: элемент id=" << childID << " НЕ НАЙДЕН!!!"; msg << "Schema: element id=" << childID << " NOT FOUND!";
throw LogicException(msg.str()); throw LogicException(msg.str());
} }
...@@ -108,9 +110,10 @@ void Schema::extlink(string name, Element::ElementID childID, int numIn ) ...@@ -108,9 +110,10 @@ void Schema::extlink(string name, Element::ElementID childID, int numIn )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Element* Schema::manage( Element* el ) Element* Schema::manage( Element* el )
{ {
cout << "Schema: manage new element id=" << el->getId() if( dlog.debugging(Debug::INFO) )
<< " type=" << el->getType() dlog[Debug::INFO] << "Schema: manage new element id=" << el->getId()
<< " inputs=" << el->inCount() << endl; << " type=" << el->getType()
<< " inputs=" << el->inCount() << endl;
emap[el->getId()] = el; emap[el->getId()] = el;
return el; return el;
...@@ -160,7 +163,7 @@ bool Schema::getOut( Element::ElementID ID ) ...@@ -160,7 +163,7 @@ bool Schema::getOut( Element::ElementID ID )
return it->second->getOut(); return it->second->getOut();
ostringstream msg; ostringstream msg;
msg << "Schema: элемент id=" <<ID << " НЕ НАЙДЕН!!!"; msg << "Schema: element id=" <<ID << " NOT FOUND!";
throw LogicException(msg.str()); throw LogicException(msg.str());
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
...@@ -50,7 +50,7 @@ void SchemaXML::read( const string xmlfile ) ...@@ -50,7 +50,7 @@ void SchemaXML::read( const string xmlfile )
{ {
string type(xml.getProp(it, "type")); string type(xml.getProp(it, "type"));
string ID(xml.getProp(it, "id")); string ID(xml.getProp(it, "id"));
int inCount(xml.getPIntProp(it, "inCount", 1)); int inCount = xml.getPIntProp(it, "inCount", 1);
if( type == "OR" ) if( type == "OR" )
manage( new TOR(ID, inCount) ); manage( new TOR(ID, inCount) );
...@@ -96,7 +96,7 @@ void SchemaXML::read( const string xmlfile ) ...@@ -96,7 +96,7 @@ void SchemaXML::read( const string xmlfile )
string type(xml.getProp(it, "type")); string type(xml.getProp(it, "type"));
string fID(xml.getProp(it, "from")); string fID(xml.getProp(it, "from"));
string tID(xml.getProp(it, "to")); string tID(xml.getProp(it, "to"));
int toIn(xml.getIntProp(it, "toInput")); int toIn = xml.getIntProp(it, "toInput");
if( type == "ext" ) if( type == "ext" )
{ {
......
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