Commit 30930362 authored by Pavel Vainerman's avatar Pavel Vainerman

(codegen): добавил в httpDumpIO() вывод (в json)

всех полей указанных в item из src.xml Очередная расстановка const везде где можно make style ещё пачка const..
parent 120645de
...@@ -448,7 +448,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository ...@@ -448,7 +448,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
UniSetObject_i_var obj; UniSetObject_i_var obj;
string fullName; string fullName;
for( const auto& oname: olist ) for( const auto& oname : olist )
{ {
fullName = section + "/" + oname; fullName = section + "/" + oname;
......
...@@ -163,7 +163,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM() ...@@ -163,7 +163,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::initFromSM()
</xsl:for-each> </xsl:for-each>
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
uniset::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() uniset::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() const
{ {
if( smTestID != DefaultObjectId ) if( smTestID != DefaultObjectId )
return smTestID; return smTestID;
......
...@@ -233,7 +233,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force ) ...@@ -233,7 +233,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::updateOutputs( bool _force )
--> -->
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
uniset::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() uniset::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() const
{ {
if( smTestID != DefaultObjectId ) if( smTestID != DefaultObjectId )
return smTestID; return smTestID;
......
...@@ -294,7 +294,7 @@ ...@@ -294,7 +294,7 @@
bool checkTestMode() const noexcept; bool checkTestMode() const noexcept;
</xsl:if> </xsl:if>
void waitSM( int wait_msec, uniset::ObjectId testID = uniset::DefaultObjectId ); void waitSM( int wait_msec, uniset::ObjectId testID = uniset::DefaultObjectId );
uniset::ObjectId getSMTestID(); uniset::ObjectId getSMTestID() const;
void resetMsg(); void resetMsg();
uniset::Trigger trResetMsg; uniset::Trigger trResetMsg;
...@@ -1430,7 +1430,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::resetMsg() ...@@ -1430,7 +1430,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::resetMsg()
</xsl:for-each> </xsl:for-each>
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
uniset::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() uniset::ObjectId <xsl:value-of select="$CLASSNAME"/>_SK::getSMTestID() const
{ {
if( smTestID != DefaultObjectId ) if( smTestID != DefaultObjectId )
return smTestID; return smTestID;
...@@ -1472,6 +1472,8 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpDumpIO() ...@@ -1472,6 +1472,8 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpDumpIO()
inf->set("id",<xsl:value-of select="@name"/>); inf->set("id",<xsl:value-of select="@name"/>);
inf->set("name",ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>))); inf->set("name",ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>)));
inf->set("value",<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>); inf->set("value",<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>);
<xsl:for-each select="@*[not(name()='name')]">inf->set("<xsl:value-of select="name(.)"/>","<xsl:value-of select="."/>");
</xsl:for-each>
} }
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
...@@ -1486,6 +1488,8 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpDumpIO() ...@@ -1486,6 +1488,8 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpDumpIO()
inf->set("id",<xsl:value-of select="@name"/>); inf->set("id",<xsl:value-of select="@name"/>);
inf->set("name",ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>))); inf->set("name",ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>)));
inf->set("value",<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>); inf->set("value",<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>);
<xsl:for-each select="@*[not(name()='name')]">inf->set("<xsl:value-of select="name(.)"/>","<xsl:value-of select="."/>");
</xsl:for-each>
} }
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
...@@ -1872,6 +1876,8 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpDumpIO() ...@@ -1872,6 +1876,8 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpDumpIO()
inf->set("id",<xsl:value-of select="../../@id"/>); inf->set("id",<xsl:value-of select="../../@id"/>);
inf->set("name", "<xsl:value-of select="../../@name"/>"); inf->set("name", "<xsl:value-of select="../../@name"/>");
inf->set("value",<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>); inf->set("value",<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>);
<xsl:for-each select="@*[not(name()='name' or name()='id')]">inf->set("<xsl:value-of select="name(.)"/>","<xsl:value-of select="."/>");
</xsl:for-each>
} }
</xsl:if> </xsl:if>
<xsl:if test="normalize-space(@vartype)='out'"> <xsl:if test="normalize-space(@vartype)='out'">
...@@ -1880,6 +1886,8 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpDumpIO() ...@@ -1880,6 +1886,8 @@ Poco::JSON::Object::Ptr <xsl:value-of select="$CLASSNAME"/>_SK::httpDumpIO()
inf->set("id",<xsl:value-of select="../../@id"/>); inf->set("id",<xsl:value-of select="../../@id"/>);
inf->set("name", "<xsl:value-of select="../../@name"/>"); inf->set("name", "<xsl:value-of select="../../@name"/>");
inf->set("value",<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>); inf->set("value",<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>);
<xsl:for-each select="@*[not(name()='name' or name()='id')]">inf->set("<xsl:value-of select="name(.)"/>","<xsl:value-of select="."/>");
</xsl:for-each>
} }
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
......
...@@ -37,7 +37,7 @@ using namespace std; ...@@ -37,7 +37,7 @@ using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ): DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ):
DBServer(id, prefix) DBServer(id, prefix)
{ {
if( getId() == DefaultObjectId ) if( getId() == DefaultObjectId )
{ {
...@@ -275,8 +275,8 @@ void DBServer_MySQL::initDBServer() ...@@ -275,8 +275,8 @@ void DBServer_MySQL::initDBServer()
tblMap[uniset::Message::SensorInfo] = "main_history"; tblMap[uniset::Message::SensorInfo] = "main_history";
tblMap[uniset::Message::Confirm] = "main_history"; tblMap[uniset::Message::Confirm] = "main_history";
PingTime = conf->getPIntProp(node, "pingTime",PingTime); PingTime = conf->getPIntProp(node, "pingTime", PingTime);
ReconnectTime = conf->getPIntProp(node, "reconnectTime",ReconnectTime); ReconnectTime = conf->getPIntProp(node, "reconnectTime", ReconnectTime);
qbufSize = conf->getArgPInt("--dbserver-buffer-size", it.getProp("bufferSize"), qbufSize); qbufSize = conf->getArgPInt("--dbserver-buffer-size", it.getProp("bufferSize"), qbufSize);
if( findArgParam("--dbserver-buffer-last-remove", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--dbserver-buffer-last-remove", conf->getArgc(), conf->getArgv()) != -1 )
......
...@@ -254,8 +254,8 @@ void DBServer_SQLite::initDBServer() ...@@ -254,8 +254,8 @@ void DBServer_SQLite::initDBServer()
tblMap[uniset::Message::SensorInfo] = "main_history"; tblMap[uniset::Message::SensorInfo] = "main_history";
tblMap[uniset::Message::Confirm] = "main_history"; tblMap[uniset::Message::Confirm] = "main_history";
PingTime = conf->getPIntProp(node, "pingTime",PingTime); PingTime = conf->getPIntProp(node, "pingTime", PingTime);
ReconnectTime = conf->getPIntProp(node, "reconnectTime",ReconnectTime); ReconnectTime = conf->getPIntProp(node, "reconnectTime", ReconnectTime);
qbufSize = conf->getArgPInt("--dbserver-buffer-size", it.getProp("bufferSize"), qbufSize); qbufSize = conf->getArgPInt("--dbserver-buffer-size", it.getProp("bufferSize"), qbufSize);
if( findArgParam("--dbserver-buffer-last-remove", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--dbserver-buffer-last-remove", conf->getArgc(), conf->getArgv()) != -1 )
......
...@@ -80,7 +80,7 @@ namespace uniset ...@@ -80,7 +80,7 @@ namespace uniset
} }
protected: protected:
ComediInterface():card(nullptr){} ComediInterface(): card(nullptr) {}
comedi_t* card; /*!< интерфейс для работы с картами в/в */ comedi_t* card; /*!< интерфейс для работы с картами в/в */
std::string dname; std::string dname;
......
...@@ -142,7 +142,7 @@ namespace uniset ...@@ -142,7 +142,7 @@ namespace uniset
else else
{ {
noCards = false; noCards = false;
cards[i] = new ComediInterface(iodev,""); cards[i] = new ComediInterface(iodev, "");
iolog3 << myname << "(init): ADD card" << i << " dev=" << iodev << endl; iolog3 << myname << "(init): ADD card" << i << " dev=" << iodev << endl;
} }
...@@ -405,6 +405,7 @@ namespace uniset ...@@ -405,6 +405,7 @@ namespace uniset
catch(...) {} catch(...) {}
ioinfo << myname << "(iothread): run..." << endl; ioinfo << myname << "(iothread): run..." << endl;
while( !term ) while( !term )
{ {
try try
...@@ -520,7 +521,7 @@ namespace uniset ...@@ -520,7 +521,7 @@ namespace uniset
// опять опросим приоритетные // опять опросим приоритетные
if( !prior && i > maxHalf ) if( !prior && i > maxHalf )
{ {
for( const auto& p: pmap ) for( const auto& p : pmap )
{ {
if( p.priority > 1 ) if( p.priority > 1 )
{ {
...@@ -549,8 +550,8 @@ namespace uniset ...@@ -549,8 +550,8 @@ namespace uniset
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
void IOControl::ioread( std::shared_ptr<IOInfo>& it ) void IOControl::ioread( std::shared_ptr<IOInfo>& it )
{ {
// cout << uniset_conf()->oind->getMapName(it->si.id) << " ignore=" << it->ignore << " ncard=" << it->ncard << endl; // cout << uniset_conf()->oind->getMapName(it->si.id) << " ignore=" << it->ignore << " ncard=" << it->ncard << endl;
// cerr << it << endl; // cerr << it << endl;
if( it->ignore || it->ncard == defCardNum ) if( it->ignore || it->ncard == defCardNum )
return; return;
...@@ -841,7 +842,7 @@ namespace uniset ...@@ -841,7 +842,7 @@ namespace uniset
{ {
iolog3 << myname << "(readItem): add threshold '" << it.getProp("name") iolog3 << myname << "(readItem): add threshold '" << it.getProp("name")
<< " for '" << uniset_conf()->oind->getNameById(inf->t_ai) << endl; << " for '" << uniset_conf()->oind->getNameById(inf->t_ai) << endl;
std::swap(iomap[maxItem++],inf); std::swap(iomap[maxItem++], inf);
return true; return true;
} }
...@@ -887,7 +888,7 @@ namespace uniset ...@@ -887,7 +888,7 @@ namespace uniset
iolog3 << myname << "(readItem): add: " << inf->stype << " " << inf << endl; iolog3 << myname << "(readItem): add: " << inf->stype << " " << inf << endl;
std::swap(iomap[maxItem++],inf); std::swap(iomap[maxItem++], inf);
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -1033,7 +1034,7 @@ namespace uniset ...@@ -1033,7 +1034,7 @@ namespace uniset
if( lst.empty() ) if( lst.empty() )
return; return;
for( const auto& io: lst ) for( const auto& io : lst )
{ {
if( io->subdev == IOBase::DefaultSubdev || io->channel == IOBase::DefaultChannel ) if( io->subdev == IOBase::DefaultSubdev || io->channel == IOBase::DefaultChannel )
continue; continue;
...@@ -1289,7 +1290,7 @@ namespace uniset ...@@ -1289,7 +1290,7 @@ namespace uniset
cout << LogServer::help_print("prefix-logserver") << endl; cout << LogServer::help_print("prefix-logserver") << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
SimpleInfo*IOControl::getInfo( const char* userparam ) SimpleInfo* IOControl::getInfo( const char* userparam )
{ {
uniset::SimpleInfo_var i = UniSetObject::getInfo(userparam); uniset::SimpleInfo_var i = UniSetObject::getInfo(userparam);
...@@ -1298,6 +1299,7 @@ namespace uniset ...@@ -1298,6 +1299,7 @@ namespace uniset
inf << i->info << endl; inf << i->info << endl;
inf << "LogServer: " << logserv_host << ":" << logserv_port << endl; inf << "LogServer: " << logserv_host << ":" << logserv_port << endl;
if( logserv ) if( logserv )
inf << logserv->getShortInfo() << endl; inf << logserv->getShortInfo() << endl;
else else
...@@ -1313,9 +1315,11 @@ namespace uniset ...@@ -1313,9 +1315,11 @@ namespace uniset
<< endl; << endl;
inf << endl; inf << endl;
for( size_t i=0; i<cards.size(); i++ )
for( size_t i = 0; i < cards.size(); i++ )
{ {
auto c = cards[i]; auto c = cards[i];
if( c ) if( c )
{ {
inf << "card[" << setw(2) << i << "]:" inf << "card[" << setw(2) << i << "]:"
...@@ -1432,9 +1436,9 @@ namespace uniset ...@@ -1432,9 +1436,9 @@ namespace uniset
<< activateTimeout << " мсек"; << activateTimeout << " мсек";
iocrit << err.str() << endl; iocrit << err.str() << endl;
// kill(SIGTERM, getpid()); // прерываем (перезапускаем) процесс... // kill(SIGTERM, getpid()); // прерываем (перезапускаем) процесс...
std::terminate(); std::terminate();
// throw SystemError(err.str()); // throw SystemError(err.str());
} }
PassiveTimer ptAct(activateTimeout); PassiveTimer ptAct(activateTimeout);
...@@ -1514,7 +1518,7 @@ namespace uniset ...@@ -1514,7 +1518,7 @@ namespace uniset
check_testmode(); check_testmode();
} }
for( auto&& it : iomap ) for( auto && it : iomap )
{ {
if( it->si.id == sm->id ) if( it->si.id == sm->id )
{ {
...@@ -1767,7 +1771,7 @@ namespace uniset ...@@ -1767,7 +1771,7 @@ namespace uniset
try try
{ {
cards[cardnum] = new ComediInterface(iodev,cname); cards[cardnum] = new ComediInterface(iodev, cname);
noCards = false; noCards = false;
} }
catch( const uniset::Exception& ex ) catch( const uniset::Exception& ex )
......
...@@ -25,13 +25,13 @@ namespace uniset ...@@ -25,13 +25,13 @@ namespace uniset
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
FakeIOControl::FakeIOControl(uniset::ObjectId id, uniset::ObjectId icID, FakeIOControl::FakeIOControl(uniset::ObjectId id, uniset::ObjectId icID,
const std::shared_ptr<SharedMemory>& ic, int numcards, const std::string& prefix_ ): const std::shared_ptr<SharedMemory>& ic, int numcards, const std::string& prefix_ ):
IOControl(id,icID,ic,numcards,prefix_) IOControl(id, icID, ic, numcards, prefix_)
{ {
fcard = new FakeComediInterface(); fcard = new FakeComediInterface();
// Подменяем все карты на fake-овые // Подменяем все карты на fake-овые
for( size_t i=0; i < cards.size(); i++ ) for( size_t i = 0; i < cards.size(); i++ )
{ {
if( cards[i] ) if( cards[i] )
delete cards[i]; delete cards[i];
...@@ -44,7 +44,7 @@ namespace uniset ...@@ -44,7 +44,7 @@ namespace uniset
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
FakeIOControl::~FakeIOControl() FakeIOControl::~FakeIOControl()
{ {
for( size_t i=0; i < cards.size(); i++ ) for( size_t i = 0; i < cards.size(); i++ )
{ {
if( cards[i] ) if( cards[i] )
{ {
...@@ -73,7 +73,7 @@ namespace uniset ...@@ -73,7 +73,7 @@ namespace uniset
if( ID == uniset::DefaultObjectId ) if( ID == uniset::DefaultObjectId )
{ {
std::cerr << "(iocontrol): Unknown ID for " << name std::cerr << "(iocontrol): Unknown ID for " << name
<< "' Not found in <objects>" << std::endl; << "' Not found in <objects>" << std::endl;
return 0; return 0;
} }
...@@ -87,8 +87,8 @@ namespace uniset ...@@ -87,8 +87,8 @@ namespace uniset
chInputs(maxChannelNum), chInputs(maxChannelNum),
chOutputs(maxChannelNum) chOutputs(maxChannelNum)
{ {
name="FakeCard"; name = "FakeCard";
dname="/dev/fakecomedi"; dname = "/dev/fakecomedi";
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
FakeComediInterface::~FakeComediInterface() FakeComediInterface::~FakeComediInterface()
...@@ -105,6 +105,7 @@ namespace uniset ...@@ -105,6 +105,7 @@ namespace uniset
<< " Must be [0," << maxChannelNum << "]" << endl; << " Must be [0," << maxChannelNum << "]" << endl;
std::terminate(); std::terminate();
} }
return chInputs[channel]; return chInputs[channel];
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -130,6 +131,7 @@ namespace uniset ...@@ -130,6 +131,7 @@ namespace uniset
<< " Must be [0," << maxChannelNum << "]" << endl; << " Must be [0," << maxChannelNum << "]" << endl;
std::terminate(); std::terminate();
} }
return (bool)chInputs[channel]; return (bool)chInputs[channel];
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -30,38 +30,38 @@ namespace uniset ...@@ -30,38 +30,38 @@ namespace uniset
FakeComediInterface(); FakeComediInterface();
virtual ~FakeComediInterface(); virtual ~FakeComediInterface();
static const size_t maxChannelNum = 32; static const size_t maxChannelNum = 32;
// Управление тестированием // Управление тестированием
// -------------------------------------------- // --------------------------------------------
// для простоты массивы специально объявлены в public // для простоты массивы специально объявлены в public
// warning: надо только иметь ввиду, что доступ к ним будет из разных потоков // warning: надо только иметь ввиду, что доступ к ним будет из разных потоков
// из теста и из потока опроса карт в/в (IOControl) // из теста и из потока опроса карт в/в (IOControl)
// в данном случае это не страшно.. // в данном случае это не страшно..
// -------------------------------------------- // --------------------------------------------
std::vector<int> chInputs; // массив значений 'входов' (для проверки чтения) std::vector<int> chInputs; // массив значений 'входов' (для проверки чтения)
mutable std::vector<int> chOutputs; // массив значений 'выходов' (для проверки функций вывода) mutable std::vector<int> chOutputs; // массив значений 'выходов' (для проверки функций вывода)
// -------------------------------------------- // --------------------------------------------
// при тестировании параметры range,aref,subdev игнорируются! // при тестировании параметры range,aref,subdev игнорируются!
virtual int getAnalogChannel( int subdev, int channel, int range = 0, int aref = AREF_GROUND ) const virtual int getAnalogChannel( int subdev, int channel, int range = 0, int aref = AREF_GROUND ) const
throw(uniset::Exception) override; throw(uniset::Exception) override;
virtual void setAnalogChannel( int subdev, int channel, int data, int range = 0, int aref = AREF_GROUND ) const virtual void setAnalogChannel( int subdev, int channel, int data, int range = 0, int aref = AREF_GROUND ) const
throw(uniset::Exception) override; throw(uniset::Exception) override;
virtual bool getDigitalChannel( int subdev, int channel ) const virtual bool getDigitalChannel( int subdev, int channel ) const
throw(uniset::Exception) override; throw(uniset::Exception) override;
virtual void setDigitalChannel( int subdev, int channel, bool bit ) const virtual void setDigitalChannel( int subdev, int channel, bool bit ) const
throw(uniset::Exception) override; throw(uniset::Exception) override;
virtual void configureSubdev( int subdev, SubdevType type ) const virtual void configureSubdev( int subdev, SubdevType type ) const
throw(uniset::Exception) override; throw(uniset::Exception) override;
virtual void configureChannel( int subdev, int channel, ChannelType type, int range = 0, int aref = 0 ) const virtual void configureChannel( int subdev, int channel, ChannelType type, int range = 0, int aref = 0 ) const
throw(uniset::Exception) override; throw(uniset::Exception) override;
}; };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -38,7 +38,7 @@ int main( int argc, const char* argv[] ) ...@@ -38,7 +38,7 @@ int main( int argc, const char* argv[] )
return returnCode; return returnCode;
auto conf = uniset_init(argc, argv); auto conf = uniset_init(argc, argv);
// dlog()->logFile("./smtest.log"); // dlog()->logFile("./smtest.log");
bool apart = findArgParam("--apart", argc, argv) != -1; bool apart = findArgParam("--apart", argc, argv) != -1;
......
...@@ -46,12 +46,12 @@ TEST_CASE("IOControl: DI", "[iocontrol][di]") ...@@ -46,12 +46,12 @@ TEST_CASE("IOControl: DI", "[iocontrol][di]")
InitTest(); InitTest();
ioc->fcard->chInputs[0] = 1; ioc->fcard->chInputs[0] = 1;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1000) == 1 ); REQUIRE( ui->getValue(1000) == 1 );
REQUIRE( ui->getValue(1001) == 0 ); // invert REQUIRE( ui->getValue(1001) == 0 ); // invert
ioc->fcard->chInputs[0] = 0; ioc->fcard->chInputs[0] = 0;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1000) == 0 ); REQUIRE( ui->getValue(1000) == 0 );
REQUIRE( ui->getValue(1001) == 1 ); // invert REQUIRE( ui->getValue(1001) == 1 ); // invert
} }
...@@ -60,15 +60,15 @@ TEST_CASE("IOControl: DO", "[iocontrol][do]") ...@@ -60,15 +60,15 @@ TEST_CASE("IOControl: DO", "[iocontrol][do]")
{ {
InitTest(); InitTest();
ui->setValue(1002,1); ui->setValue(1002, 1);
ui->setValue(1003,1); ui->setValue(1003, 1);
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ioc->fcard->chOutputs[0] == 1 ); REQUIRE( ioc->fcard->chOutputs[0] == 1 );
REQUIRE( ioc->fcard->chOutputs[1] == 0 ); // invert REQUIRE( ioc->fcard->chOutputs[1] == 0 ); // invert
ui->setValue(1002,0); ui->setValue(1002, 0);
ui->setValue(1003,0); ui->setValue(1003, 0);
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ioc->fcard->chOutputs[0] == 0 ); REQUIRE( ioc->fcard->chOutputs[0] == 0 );
REQUIRE( ioc->fcard->chOutputs[1] == 1 ); // invert REQUIRE( ioc->fcard->chOutputs[1] == 1 ); // invert
} }
...@@ -78,7 +78,8 @@ static size_t pulseCount( FakeComediInterface* card, size_t ch ) ...@@ -78,7 +78,8 @@ static size_t pulseCount( FakeComediInterface* card, size_t ch )
// считаем количество импульсов "0 -> 1 -> 0" // считаем количество импульсов "0 -> 1 -> 0"
size_t npulse = 0; size_t npulse = 0;
bool prev = false; bool prev = false;
for( size_t i=0; i < 20 && npulse < 3; i ++ )
for( size_t i = 0; i < 20 && npulse < 3; i ++ )
{ {
if( card->chOutputs[ch] == 1 && !prev ) if( card->chOutputs[ch] == 1 && !prev )
prev = true; prev = true;
...@@ -117,7 +118,7 @@ TEST_CASE("IOControl: AO", "[iocontrol][ao]") ...@@ -117,7 +118,7 @@ TEST_CASE("IOControl: AO", "[iocontrol][ao]")
ui->setValue(1005, 10); ui->setValue(1005, 10);
ui->setValue(1006, 100); ui->setValue(1006, 100);
ui->setValue(1007, 300); ui->setValue(1007, 300);
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ioc->fcard->chOutputs[5] == 10 ); REQUIRE( ioc->fcard->chOutputs[5] == 10 );
REQUIRE( ioc->fcard->chOutputs[6] == 1000 ); // calibration channel REQUIRE( ioc->fcard->chOutputs[6] == 1000 ); // calibration channel
...@@ -126,7 +127,7 @@ TEST_CASE("IOControl: AO", "[iocontrol][ao]") ...@@ -126,7 +127,7 @@ TEST_CASE("IOControl: AO", "[iocontrol][ao]")
ui->setValue(1005, 100); ui->setValue(1005, 100);
ui->setValue(1006, -100); ui->setValue(1006, -100);
ui->setValue(1007, -300); ui->setValue(1007, -300);
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ioc->fcard->chOutputs[5] == 100 ); REQUIRE( ioc->fcard->chOutputs[5] == 100 );
REQUIRE( ioc->fcard->chOutputs[6] == 0 ); // calibration channel REQUIRE( ioc->fcard->chOutputs[6] == 0 ); // calibration channel
...@@ -140,27 +141,27 @@ TEST_CASE("IOControl: threshold", "[iocontrol][threshold]") ...@@ -140,27 +141,27 @@ TEST_CASE("IOControl: threshold", "[iocontrol][threshold]")
auto card = ioc->fcard; auto card = ioc->fcard;
ioc->fcard->chInputs[10] = 20; ioc->fcard->chInputs[10] = 20;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1010) == 20 ); REQUIRE( ui->getValue(1010) == 20 );
REQUIRE( ui->getValue(1011) == 0 ); // threshold [30,40] REQUIRE( ui->getValue(1011) == 0 ); // threshold [30,40]
ioc->fcard->chInputs[10] = 35; ioc->fcard->chInputs[10] = 35;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1010) == 35 ); REQUIRE( ui->getValue(1010) == 35 );
REQUIRE( ui->getValue(1011) == 0 ); // threshold [30,40] REQUIRE( ui->getValue(1011) == 0 ); // threshold [30,40]
ioc->fcard->chInputs[10] = 45; ioc->fcard->chInputs[10] = 45;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1010) == 45 ); REQUIRE( ui->getValue(1010) == 45 );
REQUIRE( ui->getValue(1011) == 1 ); // threshold [30,40] REQUIRE( ui->getValue(1011) == 1 ); // threshold [30,40]
ioc->fcard->chInputs[10] = 35; ioc->fcard->chInputs[10] = 35;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1010) == 35 ); REQUIRE( ui->getValue(1010) == 35 );
REQUIRE( ui->getValue(1011) == 1 ); // threshold [30,40] REQUIRE( ui->getValue(1011) == 1 ); // threshold [30,40]
ioc->fcard->chInputs[10] = 25; ioc->fcard->chInputs[10] = 25;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1010) == 25 ); REQUIRE( ui->getValue(1010) == 25 );
REQUIRE( ui->getValue(1011) == 0 ); // < lowlimit (30) REQUIRE( ui->getValue(1011) == 0 ); // < lowlimit (30)
} }
...@@ -173,14 +174,14 @@ TEST_CASE("IOControl: test lamp", "[iocontrol][testlamp]") ...@@ -173,14 +174,14 @@ TEST_CASE("IOControl: test lamp", "[iocontrol][testlamp]")
// отключаем тест ламп // отключаем тест ламп
card->chInputs[12] = 0; card->chInputs[12] = 0;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1012) == 0 ); REQUIRE( ui->getValue(1012) == 0 );
REQUIRE( ui->getValue(1013) == 0 ); REQUIRE( ui->getValue(1013) == 0 );
REQUIRE( card->chOutputs[13] == 0 ); REQUIRE( card->chOutputs[13] == 0 );
// включаем тест ламп // включаем тест ламп
card->chInputs[12] = 1; card->chInputs[12] = 1;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1012) == 1 ); REQUIRE( ui->getValue(1012) == 1 );
// должны ловить мигание лампочки.. // должны ловить мигание лампочки..
...@@ -189,7 +190,7 @@ TEST_CASE("IOControl: test lamp", "[iocontrol][testlamp]") ...@@ -189,7 +190,7 @@ TEST_CASE("IOControl: test lamp", "[iocontrol][testlamp]")
// отключаем тест ламп // отключаем тест ламп
card->chInputs[12] = 0; card->chInputs[12] = 0;
msleep(polltime+10); msleep(polltime + 10);
REQUIRE( ui->getValue(1012) == 0 ); REQUIRE( ui->getValue(1012) == 0 );
REQUIRE( ui->getValue(1013) == 0 ); REQUIRE( ui->getValue(1013) == 0 );
REQUIRE( card->chOutputs[13] == 0 ); REQUIRE( card->chOutputs[13] == 0 );
......
...@@ -117,7 +117,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -117,7 +117,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
{ {
try try
{ {
for( auto&& it : extInputs ) for( auto && it : extInputs )
shm->askSensor(it.sid, cmd); shm->askSensor(it.sid, cmd);
} }
catch( const uniset::Exception& ex ) catch( const uniset::Exception& ex )
...@@ -129,7 +129,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd ) ...@@ -129,7 +129,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveLProcessor::sensorInfo( const uniset::SensorMessage* sm ) void PassiveLProcessor::sensorInfo( const uniset::SensorMessage* sm )
{ {
for( auto&& it : extInputs ) for( auto && it : extInputs )
{ {
if( it.sid == sm->id ) if( it.sid == sm->id )
it.value = sm->value; it.value = sm->value;
...@@ -230,7 +230,7 @@ void PassiveLProcessor::initIterators() ...@@ -230,7 +230,7 @@ void PassiveLProcessor::initIterators()
void PassiveLProcessor::setOuts() void PassiveLProcessor::setOuts()
{ {
// выcтавляем выходы // выcтавляем выходы
for( auto&& it : extOuts ) for( auto && it : extOuts )
{ {
try try
{ {
...@@ -249,7 +249,7 @@ void PassiveLProcessor::setOuts() ...@@ -249,7 +249,7 @@ void PassiveLProcessor::setOuts()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void PassiveLProcessor::sigterm( int signo ) void PassiveLProcessor::sigterm( int signo )
{ {
for( auto&& it : extOuts ) for( auto && it : extOuts )
{ {
try try
{ {
......
...@@ -597,7 +597,7 @@ namespace uniset ...@@ -597,7 +597,7 @@ namespace uniset
for( const auto& m : d.pollmap ) for( const auto& m : d.pollmap )
{ {
for( const auto& it : *(m.second) ) for( const auto& it : * (m.second) )
os << " " << it.second << endl; os << " " << it.second << endl;
} }
...@@ -620,7 +620,7 @@ namespace uniset ...@@ -620,7 +620,7 @@ namespace uniset
<< " mtrType=" << MTR::type2str(r.mtrType) << " mtrType=" << MTR::type2str(r.mtrType)
<< endl; << endl;
for( const auto& s: r.slst ) for( const auto& s : r.slst )
os << " " << s << endl; os << " " << s << endl;
return os; return os;
...@@ -629,11 +629,12 @@ namespace uniset ...@@ -629,11 +629,12 @@ namespace uniset
void MBExchange::rtuQueryOptimization( RTUDeviceMap& dm ) void MBExchange::rtuQueryOptimization( RTUDeviceMap& dm )
{ {
mbinfo << myname << "(rtuQueryOptimization): optimization..." << endl; mbinfo << myname << "(rtuQueryOptimization): optimization..." << endl;
for( const auto& d: dm )
for( const auto& d : dm )
rtuQueryOptimizationForDevice(d.second); rtuQueryOptimizationForDevice(d.second);
// printMap(dm); // printMap(dm);
// assert(false); // assert(false);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void MBExchange::rtuQueryOptimizationForDevice( const std::shared_ptr<RTUDevice>& d ) void MBExchange::rtuQueryOptimizationForDevice( const std::shared_ptr<RTUDevice>& d )
...@@ -674,7 +675,7 @@ namespace uniset ...@@ -674,7 +675,7 @@ namespace uniset
beg->q_count++; beg->q_count++;
regID = it->second->regID; regID = it->second->regID;
it->second->q_num = beg->q_count-1; it->second->q_num = beg->q_count - 1;
it->second->q_count = 0; it->second->q_count = 0;
if( beg->q_count >= maxQueryCount ) if( beg->q_count >= maxQueryCount )
...@@ -717,7 +718,7 @@ namespace uniset ...@@ -717,7 +718,7 @@ namespace uniset
os << "[ "; os << "[ ";
for( const auto& p: lst ) for( const auto& p : lst )
os << "(" << p.si.id << ")" << conf->oind->getBaseName(conf->oind->getMapName(p.si.id)) << " "; os << "(" << p.si.id << ")" << conf->oind->getBaseName(conf->oind->getMapName(p.si.id)) << " ";
os << "]"; os << "]";
...@@ -1421,6 +1422,7 @@ namespace uniset ...@@ -1421,6 +1422,7 @@ namespace uniset
else else
r->mbval = IOBase::processingAsAO( p, shm, force_out ); r->mbval = IOBase::processingAsAO( p, shm, force_out );
} }
r->sm_initOK = true; r->sm_initOK = true;
} }
} }
...@@ -1926,6 +1928,7 @@ namespace uniset ...@@ -1926,6 +1928,7 @@ namespace uniset
long val = safeMode ? it->safeval : IOBase::processingAsAO( &(*it), shm, force_out ); long val = safeMode ? it->safeval : IOBase::processingAsAO( &(*it), shm, force_out );
MTR::T5 t(val); MTR::T5 t(val);
for( size_t k = 0; k < MTR::T5::wsize(); k++, i++ ) for( size_t k = 0; k < MTR::T5::wsize(); k++, i++ )
i->second->mbval = t.raw.v[k]; i->second->mbval = t.raw.v[k];
} }
...@@ -3510,7 +3513,7 @@ namespace uniset ...@@ -3510,7 +3513,7 @@ namespace uniset
return os; return os;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::string to_string( const MBExchange::SafeMode & m ) std::string to_string( const MBExchange::SafeMode& m )
{ {
if( m == MBExchange::safeNone ) if( m == MBExchange::safeNone )
return "safeNone"; return "safeNone";
......
...@@ -83,7 +83,7 @@ namespace uniset ...@@ -83,7 +83,7 @@ namespace uniset
}; };
friend std::string to_string( const SafeMode & m ); friend std::string to_string( const SafeMode& m );
friend std::ostream& operator<<( std::ostream& os, const SafeMode& m ); friend std::ostream& operator<<( std::ostream& os, const SafeMode& m );
enum DeviceType enum DeviceType
......
...@@ -64,8 +64,10 @@ MBTCPMaster::MBTCPMaster(uniset::ObjectId objId, uniset::ObjectId shmId, ...@@ -64,8 +64,10 @@ MBTCPMaster::MBTCPMaster(uniset::ObjectId objId, uniset::ObjectId shmId,
if( shm->isLocalwork() ) if( shm->isLocalwork() )
{ {
readConfiguration(); readConfiguration();
if( !noQueryOptimization ) if( !noQueryOptimization )
rtuQueryOptimization(devices); rtuQueryOptimization(devices);
initDeviceList(); initDeviceList();
} }
else else
......
...@@ -181,14 +181,16 @@ MBTCPMultiMaster::MBTCPMultiMaster( uniset::ObjectId objId, uniset::ObjectId shm ...@@ -181,14 +181,16 @@ MBTCPMultiMaster::MBTCPMultiMaster( uniset::ObjectId objId, uniset::ObjectId shm
if( shm->isLocalwork() ) if( shm->isLocalwork() )
{ {
readConfiguration(); readConfiguration();
if( !noQueryOptimization ) if( !noQueryOptimization )
rtuQueryOptimization(devices); rtuQueryOptimization(devices);
initDeviceList(); initDeviceList();
} }
else else
ic->addReadItem( sigc::mem_fun(this, &MBTCPMultiMaster::readItem) ); ic->addReadItem( sigc::mem_fun(this, &MBTCPMultiMaster::readItem) );
pollThread =unisetstd::make_unique<ThreadCreator<MBTCPMultiMaster>>(this, &MBTCPMultiMaster::poll_thread); pollThread = unisetstd::make_unique<ThreadCreator<MBTCPMultiMaster>>(this, &MBTCPMultiMaster::poll_thread);
pollThread->setFinalAction(this, &MBTCPMultiMaster::final_thread); pollThread->setFinalAction(this, &MBTCPMultiMaster::final_thread);
checkThread = unisetstd::make_unique<ThreadCreator<MBTCPMultiMaster>>(this, &MBTCPMultiMaster::check_thread); checkThread = unisetstd::make_unique<ThreadCreator<MBTCPMultiMaster>>(this, &MBTCPMultiMaster::check_thread);
checkThread->setFinalAction(this, &MBTCPMultiMaster::final_thread); checkThread->setFinalAction(this, &MBTCPMultiMaster::final_thread);
......
...@@ -85,8 +85,10 @@ RTUExchange::RTUExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const s ...@@ -85,8 +85,10 @@ RTUExchange::RTUExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const s
if( shm->isLocalwork() ) if( shm->isLocalwork() )
{ {
readConfiguration(); readConfiguration();
if( !noQueryOptimization ) if( !noQueryOptimization )
rtuQueryOptimization(devices); rtuQueryOptimization(devices);
initDeviceList(); initDeviceList();
} }
else else
......
...@@ -683,7 +683,7 @@ TEST_CASE("MBTCPMaster: 0x66 (file transfer)", "[modbus][0x66][mbmaster][mbtcpma ...@@ -683,7 +683,7 @@ TEST_CASE("MBTCPMaster: 0x66 (file transfer)", "[modbus][0x66][mbmaster][mbtcpma
TEST_CASE("MBTCPMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmaster]") TEST_CASE("MBTCPMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmaster]")
{ {
InitTest(); InitTest();
ui->setValue(1050,0); // отключаем safeMode ui->setValue(1050, 0); // отключаем safeMode
mbs->setReply(53); mbs->setReply(53);
msleep(polltime + 200); msleep(polltime + 200);
...@@ -695,7 +695,7 @@ TEST_CASE("MBTCPMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmaster]") ...@@ -695,7 +695,7 @@ TEST_CASE("MBTCPMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmaster]")
REQUIRE( ui->getValue(1051) == 0 ); REQUIRE( ui->getValue(1051) == 0 );
REQUIRE( ui->getValue(1052) == 0 ); REQUIRE( ui->getValue(1052) == 0 );
ui->setValue(1050,42); // включаем safeMode ui->setValue(1050, 42); // включаем safeMode
msleep(polltime + 200); msleep(polltime + 200);
REQUIRE( ui->getValue(1051) == 42 ); REQUIRE( ui->getValue(1051) == 42 );
REQUIRE( ui->getValue(1052) == 1 ); REQUIRE( ui->getValue(1052) == 1 );
...@@ -705,7 +705,7 @@ TEST_CASE("MBTCPMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmaster]") ...@@ -705,7 +705,7 @@ TEST_CASE("MBTCPMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmaster]")
REQUIRE( ui->getValue(1051) == 42 ); REQUIRE( ui->getValue(1051) == 42 );
REQUIRE( ui->getValue(1052) == 1 ); REQUIRE( ui->getValue(1052) == 1 );
ui->setValue(1050,0); // отключаем safeMode ui->setValue(1050, 0); // отключаем safeMode
msleep(polltime + 200); msleep(polltime + 200);
REQUIRE( ui->getValue(1051) == 53 ); REQUIRE( ui->getValue(1051) == 53 );
REQUIRE( ui->getValue(1052) == 1 ); REQUIRE( ui->getValue(1052) == 1 );
......
...@@ -155,7 +155,7 @@ TEST_CASE("MBTCPMultiMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmult ...@@ -155,7 +155,7 @@ TEST_CASE("MBTCPMultiMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmult
{ {
InitTest(); InitTest();
ui->setValue(1050,0); // отключаем safeMode ui->setValue(1050, 0); // отключаем safeMode
mbs1->setReply(53); mbs1->setReply(53);
msleep(polltime + 200); msleep(polltime + 200);
...@@ -167,7 +167,7 @@ TEST_CASE("MBTCPMultiMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmult ...@@ -167,7 +167,7 @@ TEST_CASE("MBTCPMultiMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmult
REQUIRE( ui->getValue(1051) == 0 ); REQUIRE( ui->getValue(1051) == 0 );
REQUIRE( ui->getValue(1052) == 0 ); REQUIRE( ui->getValue(1052) == 0 );
ui->setValue(1050,42); // включаем safeMode ui->setValue(1050, 42); // включаем safeMode
msleep(polltime + 200); msleep(polltime + 200);
REQUIRE( ui->getValue(1051) == 42 ); REQUIRE( ui->getValue(1051) == 42 );
REQUIRE( ui->getValue(1052) == 1 ); REQUIRE( ui->getValue(1052) == 1 );
...@@ -178,7 +178,7 @@ TEST_CASE("MBTCPMultiMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmult ...@@ -178,7 +178,7 @@ TEST_CASE("MBTCPMultiMaster: safe mode", "[modbus][safemode][mbmaster][mbtcpmult
REQUIRE( ui->getValue(1051) == 42 ); REQUIRE( ui->getValue(1051) == 42 );
REQUIRE( ui->getValue(1052) == 1 ); REQUIRE( ui->getValue(1052) == 1 );
ui->setValue(1050,0); // отключаем safeMode ui->setValue(1050, 0); // отключаем safeMode
msleep(polltime + 200); msleep(polltime + 200);
REQUIRE( ui->getValue(1051) == 53 ); REQUIRE( ui->getValue(1051) == 53 );
REQUIRE( ui->getValue(1052) == 1 ); REQUIRE( ui->getValue(1052) == 1 );
......
...@@ -801,15 +801,17 @@ namespace uniset ...@@ -801,15 +801,17 @@ namespace uniset
static size_t upCounter = 0; static size_t upCounter = 0;
upCounter++; upCounter++;
if( ++upCounter > 5 ) if( ++upCounter > 5 )
{ {
// IOMap::iterator i; // IOMap::iterator i;
// cout << "SEGFAULT: " << i->first << endl; // cout << "SEGFAULT: " << i->first << endl;
upCounter = 0; upCounter = 0;
cerr << ".....THROW...." << endl; cerr << ".....THROW...." << endl;
throw std::string("TEST STRING EXCEPTION"); throw std::string("TEST STRING EXCEPTION");
} }
#endif #endif
// ВНИМАНИЕ! Эта функция вызывается из основного eventLoop // ВНИМАНИЕ! Эта функция вызывается из основного eventLoop
...@@ -978,7 +980,7 @@ namespace uniset ...@@ -978,7 +980,7 @@ namespace uniset
else if( mbtype == "TCP") else if( mbtype == "TCP")
execute_tcp(); execute_tcp();
askTimer(tmCheckExchange,checkExchangeTime); askTimer(tmCheckExchange, checkExchangeTime);
} }
break; break;
......
...@@ -635,6 +635,7 @@ namespace uniset ...@@ -635,6 +635,7 @@ namespace uniset
std::string ssafe = initProp(it, "safeval", prefix, init_prefix_only); std::string ssafe = initProp(it, "safeval", prefix, init_prefix_only);
b->safevalDefined = !ssafe.empty(); b->safevalDefined = !ssafe.empty();
if( b->safevalDefined ) if( b->safevalDefined )
b->safeval = uni_atoi(ssafe); b->safeval = uni_atoi(ssafe);
......
...@@ -180,7 +180,7 @@ namespace uniset ...@@ -180,7 +180,7 @@ namespace uniset
static std::vector<std::string> splitFirst( const std::string& lname, const std::string s = "/" ); static std::vector<std::string> splitFirst( const std::string& lname, const std::string s = "/" );
std::ostream& printLogList( std::ostream& os, const std::string& regexp_str = "" ); std::ostream& printLogList( std::ostream& os, const std::string& regexp_str = "" ) const;
static std::ostream& printLogList( std::ostream& os, std::list<iLog>& lst ); static std::ostream& printLogList( std::ostream& os, std::list<iLog>& lst );
protected: protected:
...@@ -192,7 +192,7 @@ namespace uniset ...@@ -192,7 +192,7 @@ namespace uniset
std::shared_ptr<DebugStream> findLog( const std::string& lname ) const; std::shared_ptr<DebugStream> findLog( const std::string& lname ) const;
// вывод в виде "дерева" // вывод в виде "дерева"
std::ostream& printTree(std::ostream& os, const std::string& g_tab = ""); std::ostream& printTree(std::ostream& os, const std::string& g_tab = "") const;
// получить список с именами (длинными) и с указателями на логи // получить список с именами (длинными) и с указателями на логи
std::list<iLog> makeLogNameList( const std::string& prefix ) const; std::list<iLog> makeLogNameList( const std::string& prefix ) const;
......
...@@ -178,10 +178,10 @@ namespace uniset ...@@ -178,10 +178,10 @@ namespace uniset
void read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController* ic); void read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController* ic);
void init( const std::string& fname ); void init( const std::string& fname );
bool getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, IOController_i::SensorInfo& si ); bool getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, IOController_i::SensorInfo& si ) const;
bool getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode* snode, std::shared_ptr<NCRestorer_XML::SInfo>& si ); bool getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode* snode, std::shared_ptr<NCRestorer_XML::SInfo>& si ) const;
bool getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController::ConsumerListInfo& lst); bool getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController::ConsumerListInfo& lst) const;
bool getThresholdInfo(const std::shared_ptr<UniXML>& xml, xmlNode* tnode, IONotifyController::ThresholdInfoExt& ti); bool getThresholdInfo(const std::shared_ptr<UniXML>& xml, xmlNode* tnode, IONotifyController::ThresholdInfoExt& ti) const;
static void set_dumptime( const std::shared_ptr<UniXML>& xml, xmlNode* node ); static void set_dumptime( const std::shared_ptr<UniXML>& xml, xmlNode* node );
static xmlNode* bind_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = ""); static xmlNode* bind_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "");
......
...@@ -54,19 +54,19 @@ namespace uniset ...@@ -54,19 +54,19 @@ namespace uniset
@{ */ @{ */
//! Функция регистрации объекта по имени с указанием секции //! Функция регистрации объекта по имени с указанием секции
void registration(const std::string& name, const uniset::ObjectPtr oRef, const std::string& section, bool force = false) const void registration(const std::string& name, const uniset::ObjectPtr oRef, const std::string& section, bool force = false) const
throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound); throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound);
//! Функция регистрации объекта по полному имени. //! Функция регистрации объекта по полному имени.
void registration(const std::string& fullName, const uniset::ObjectPtr oRef, bool force = false) const void registration(const std::string& fullName, const uniset::ObjectPtr oRef, bool force = false) const
throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound); throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound);
//! Удаление записи об объекте name в секции section //! Удаление записи об объекте name в секции section
void unregistration(const std::string& name, const std::string& section) const void unregistration(const std::string& name, const std::string& section) const
throw(uniset::ORepFailed, uniset::NameNotFound); throw(uniset::ORepFailed, uniset::NameNotFound);
//! Удаление записи об объекте по полному имени //! Удаление записи об объекте по полному имени
void unregistration(const std::string& fullName) const void unregistration(const std::string& fullName) const
throw(uniset::ORepFailed, uniset::NameNotFound); throw(uniset::ORepFailed, uniset::NameNotFound);
// @} // @}
// end of ORepGroup // end of ORepGroup
...@@ -99,11 +99,11 @@ namespace uniset ...@@ -99,11 +99,11 @@ namespace uniset
// ------------------------------------------------------------------- // -------------------------------------------------------------------
//! Создание секции //! Создание секции
bool createSection( const std::string& name, const std::string& in_section ) const bool createSection( const std::string& name, const std::string& in_section ) const
throw(uniset::ORepFailed, uniset::InvalidObjectName); throw(uniset::ORepFailed, uniset::InvalidObjectName);
/*! Создание секции по полному имени */ /*! Создание секции по полному имени */
bool createSectionF(const std::string& fullName) const bool createSectionF(const std::string& fullName) const
throw(uniset::ORepFailed, uniset::InvalidObjectName); throw(uniset::ORepFailed, uniset::InvalidObjectName);
//! Функция создания секции в корневом 'каталоге' //! Функция создания секции в корневом 'каталоге'
bool createRootSection( const std::string& name ) const; bool createRootSection( const std::string& name ) const;
......
...@@ -94,15 +94,15 @@ namespace uniset ...@@ -94,15 +94,15 @@ namespace uniset
\return true - если идентификаторы определены \return true - если идентификаторы определены
*/ */
bool getConsumerInfo( UniXML::iterator& it, bool getConsumerInfo( UniXML::iterator& it,
uniset::ObjectId& cid, uniset::ObjectId& cnode ); uniset::ObjectId& cid, uniset::ObjectId& cnode ) const;
/*! Функция поиска по текущему уровню (без рекурсии для дочерних узлов) */ /*! Функция поиска по текущему уровню (без рекурсии для дочерних узлов) */
static xmlNode* find_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "" ); static xmlNode* find_node( const std::shared_ptr<UniXML>& xml, xmlNode* root, const std::string& nodename, const std::string& nm = "" );
protected: protected:
virtual bool check_list_item( UniXML::iterator& it ); virtual bool check_list_item( UniXML::iterator& it ) const;
virtual bool check_consumer_item( UniXML::iterator& it ); virtual bool check_consumer_item( UniXML::iterator& it ) const;
ReaderSlot rslot; ReaderSlot rslot;
ReaderSlot cslot; ReaderSlot cslot;
......
...@@ -248,7 +248,7 @@ namespace uniset ...@@ -248,7 +248,7 @@ namespace uniset
MaxSize(maxsize), minCallCount(cleancount) {}; MaxSize(maxsize), minCallCount(cleancount) {};
~CacheOfResolve() {}; ~CacheOfResolve() {};
uniset::ObjectPtr resolve( const uniset::ObjectId id, const uniset::ObjectId node ) const throw(uniset::NameNotFound,uniset::SystemError); uniset::ObjectPtr resolve( const uniset::ObjectId id, const uniset::ObjectId node ) const throw(uniset::NameNotFound, uniset::SystemError);
void cache(const uniset::ObjectId id, const uniset::ObjectId node, uniset::ObjectVar& ptr ) const; void cache(const uniset::ObjectId id, const uniset::ObjectId node, uniset::ObjectVar& ptr ) const;
void erase( const uniset::ObjectId id, const uniset::ObjectId node ) const noexcept; void erase( const uniset::ObjectId id, const uniset::ObjectId node ) const noexcept;
......
...@@ -24,9 +24,9 @@ namespace uniset ...@@ -24,9 +24,9 @@ namespace uniset
Buffer( const std::string& s ); Buffer( const std::string& s );
virtual ~Buffer(); virtual ~Buffer();
unsigned char* dpos() noexcept; unsigned char* dpos() const noexcept;
size_t nbytes() noexcept; size_t nbytes() const noexcept;
unsigned char* data = { 0 }; unsigned char* data = { 0 };
size_t len; size_t len;
......
...@@ -27,7 +27,7 @@ namespace uniset ...@@ -27,7 +27,7 @@ namespace uniset
// return true if OK // return true if OK
bool setKeepAliveParams( timeout_t timeout_sec = 5, int conn_keepcnt = 1, int keepintvl = 2 ); bool setKeepAliveParams( timeout_t timeout_sec = 5, int conn_keepcnt = 1, int keepintvl = 2 );
int getSocket() noexcept; int getSocket() const noexcept;
protected: protected:
void init(); void init();
......
...@@ -39,7 +39,7 @@ namespace uniset ...@@ -39,7 +39,7 @@ namespace uniset
void create( const std::string& hname, uint16_t port, timeout_t tout_msec = 1000 ); void create( const std::string& hname, uint16_t port, timeout_t tout_msec = 1000 );
bool isConnected() noexcept; bool isConnected() const noexcept;
// set keepalive params // set keepalive params
// return true if OK // return true if OK
......
...@@ -122,7 +122,7 @@ namespace uniset ...@@ -122,7 +122,7 @@ namespace uniset
return lst.empty(); return lst.empty();
} }
std::list<ObjectId> getList() noexcept; std::list<ObjectId> getList() const noexcept;
// за освобождение выделеной памяти // за освобождение выделеной памяти
// отвечает вызывающий! // отвечает вызывающий!
...@@ -322,7 +322,10 @@ namespace uniset ...@@ -322,7 +322,10 @@ namespace uniset
{ {
public: public:
ios_fmt_restorer( std::ostream& s ): ios_fmt_restorer( std::ostream& s ):
os(s),f(nullptr){ f.copyfmt(s); } os(s), f(nullptr)
{
f.copyfmt(s);
}
~ios_fmt_restorer() ~ios_fmt_restorer()
{ {
......
...@@ -196,7 +196,7 @@ namespace uniset ...@@ -196,7 +196,7 @@ namespace uniset
} }
}; };
std::unique_ptr<xmlDoc,UniXMLDocDeleter> doc; std::unique_ptr<xmlDoc, UniXMLDocDeleter> doc;
}; };
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
} // end of uniset namespace } // end of uniset namespace
......
...@@ -124,13 +124,13 @@ namespace uniset ...@@ -124,13 +124,13 @@ namespace uniset
static const int ColCount = { 2 }; static const int ColCount = { 2 };
/*! вывести все элементы в "простом формате" (строки "varname = value") */ /*! вывести все элементы в "простом формате" (строки "varname = value") */
std::string str(); std::string str() const;
/*! вывести все элементы "с форматированием" (отсортированные по алфавиту) /*! вывести все элементы "с форматированием" (отсортированные по алфавиту)
* \param namewidth - ширина резервируемая под "имя" * \param namewidth - ширина резервируемая под "имя"
* \param colnum - количество столбцов вывода * \param colnum - количество столбцов вывода
*/ */
std::string pretty_str( int namewidth = NameWidth, int colnum = ColCount ); std::string pretty_str( int namewidth = NameWidth, int colnum = ColCount ) const;
// перегрузки для стандартных типов.. // перегрузки для стандартных типов..
VMON_DEF_FUNC2(int); VMON_DEF_FUNC2(int);
...@@ -150,7 +150,7 @@ namespace uniset ...@@ -150,7 +150,7 @@ namespace uniset
static const std::string pretty_str( const std::string& name, const std::string* v, int width = NameWidth ); static const std::string pretty_str( const std::string& name, const std::string* v, int width = NameWidth );
static const std::string pretty_str( const std::string& name, const std::string& v, int width = NameWidth ); static const std::string pretty_str( const std::string& name, const std::string& v, int width = NameWidth );
std::list<std::pair<std::string, std::string>> getList(); std::list<std::pair<std::string, std::string>> getList() const;
protected: protected:
......
...@@ -25,14 +25,15 @@ ...@@ -25,14 +25,15 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
namespace unisetstd { namespace unisetstd
template<typename T, typename ...Args>
std::unique_ptr<T> make_unique( Args&& ...args )
{ {
return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
} template<typename T, typename ...Args>
// -------------------------------------------------------------------------- std::unique_ptr<T> make_unique( Args&& ...args )
{
return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
}
// --------------------------------------------------------------------------
} // end of namespace unisetcpp } // end of namespace unisetcpp
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#endif #endif
...@@ -147,7 +147,7 @@ namespace uniset ...@@ -147,7 +147,7 @@ namespace uniset
ioTimer.set(loop); ioTimer.set(loop);
if( tmTime_msec != UniSetTimer::WaitUpTime ) if( tmTime_msec != UniSetTimer::WaitUpTime )
ioTimer.start(0,tmTime); ioTimer.start(0, tmTime);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPServer::terminate() void ModbusTCPServer::terminate()
......
...@@ -495,6 +495,7 @@ namespace uniset ...@@ -495,6 +495,7 @@ namespace uniset
os << "["; os << "[";
int max = d.b.size(); int max = d.b.size();
if( max > 0 ) if( max > 0 )
max--; max--;
...@@ -3071,13 +3072,13 @@ namespace uniset ...@@ -3071,13 +3072,13 @@ namespace uniset
ostringstream s; ostringstream s;
s << setfill('0') s << setfill('0')
<< setw(2) << (int)m.day << "-" << setw(2) << (int)m.day << "-"
<< setw(2) << (int)m.mon << "-" << setw(2) << (int)m.mon << "-"
<< setw(2) << (int)m.century << setw(2) << (int)m.century
<< setw(2) << (int)m.year << " " << setw(2) << (int)m.year << " "
<< setw(2) << (int)m.hour << ":" << setw(2) << (int)m.hour << ":"
<< setw(2) << (int)m.min << ":" << setw(2) << (int)m.min << ":"
<< setw(2) << (int)m.sec; << setw(2) << (int)m.sec;
return os << s.str(); return os << s.str();
} }
......
...@@ -56,12 +56,12 @@ namespace uniset ...@@ -56,12 +56,12 @@ namespace uniset
delete [] data; delete [] data;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
unsigned char* UTCPCore::Buffer::dpos() noexcept unsigned char* UTCPCore::Buffer::dpos() const noexcept
{ {
return data + pos; return data + pos;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
size_t UTCPCore::Buffer::nbytes() noexcept size_t UTCPCore::Buffer::nbytes() const noexcept
{ {
return len - pos; return len - pos;
} }
......
...@@ -44,7 +44,7 @@ namespace uniset ...@@ -44,7 +44,7 @@ namespace uniset
return UTCPCore::setKeepAliveParams(Poco::Net::ServerSocket::sockfd() , timeout_sec, keepcnt, keepintvl); return UTCPCore::setKeepAliveParams(Poco::Net::ServerSocket::sockfd() , timeout_sec, keepcnt, keepintvl);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
int UTCPSocket::getSocket() noexcept int UTCPSocket::getSocket() const noexcept
{ {
return Poco::Net::ServerSocket::sockfd(); return Poco::Net::ServerSocket::sockfd();
} }
......
...@@ -116,7 +116,7 @@ namespace uniset ...@@ -116,7 +116,7 @@ namespace uniset
setKeepAliveParams(); setKeepAliveParams();
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool UTCPStream::isConnected() noexcept bool UTCPStream::isConnected() const noexcept
{ {
return ( Poco::Net::StreamSocket::sockfd() != POCO_INVALID_SOCKET ); return ( Poco::Net::StreamSocket::sockfd() != POCO_INVALID_SOCKET );
/* /*
......
...@@ -1265,7 +1265,7 @@ namespace uniset ...@@ -1265,7 +1265,7 @@ namespace uniset
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
uniset::ObjectPtr UInterface::CacheOfResolve::resolve( const uniset::ObjectId id, const uniset::ObjectId node ) const uniset::ObjectPtr UInterface::CacheOfResolve::resolve( const uniset::ObjectId id, const uniset::ObjectId node ) const
throw(uniset::NameNotFound,uniset::SystemError) throw(uniset::NameNotFound, uniset::SystemError)
{ {
try try
{ {
......
...@@ -216,6 +216,7 @@ bool gdb_print_trace() ...@@ -216,6 +216,7 @@ bool gdb_print_trace()
sprintf(pid_buf, "%d", getpid()); sprintf(pid_buf, "%d", getpid());
char name_buf[512]; char name_buf[512];
ssize_t ind = readlink("/proc/self/exe", name_buf, 511); ssize_t ind = readlink("/proc/self/exe", name_buf, 511);
if( ind < 0 ) if( ind < 0 )
{ {
perror("Can't readlink..."); perror("Can't readlink...");
...@@ -301,6 +302,7 @@ static void start_terminate_process() ...@@ -301,6 +302,7 @@ static void start_terminate_process()
// посылаем сигнал потоку завершения, чтобы проснулся и начал заверешение // посылаем сигнал потоку завершения, чтобы проснулся и начал заверешение
{ {
std::unique_lock<std::mutex> lk(g_termmutex); std::unique_lock<std::mutex> lk(g_termmutex);
if( g_term ) if( g_term )
return; return;
...@@ -312,8 +314,12 @@ static void start_terminate_process() ...@@ -312,8 +314,12 @@ static void start_terminate_process()
static void wait_done() static void wait_done()
{ {
std::unique_lock<std::mutex> lk(g_donemutex); std::unique_lock<std::mutex> lk(g_donemutex);
while( !g_done ) while( !g_done )
g_doneevent.wait(lk, []() { return (g_done == true); } ); g_doneevent.wait(lk, []()
{
return (g_done == true);
} );
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
static void activator_terminate( int signo ) static void activator_terminate( int signo )
...@@ -322,6 +328,7 @@ static void activator_terminate( int signo ) ...@@ -322,6 +328,7 @@ static void activator_terminate( int signo )
return; return;
g_signo = signo; g_signo = signo;
if( signo == SIGABRT ) if( signo == SIGABRT )
{ {
if( g_act && !g_act->noUseGdbForStackTrace() ) if( g_act && !g_act->noUseGdbForStackTrace() )
...@@ -332,11 +339,12 @@ static void activator_terminate( int signo ) ...@@ -332,11 +339,12 @@ static void activator_terminate( int signo )
else else
printStackTrace(); printStackTrace();
// exit(EXIT_FAILURE); // exit(EXIT_FAILURE);
// return; // return;
} }
// else
// exit(EXIT_SUCCESS); // else
// exit(EXIT_SUCCESS);
start_terminate_process(); start_terminate_process();
} }
...@@ -495,7 +503,7 @@ namespace uniset ...@@ -495,7 +503,7 @@ namespace uniset
} }
} }
// g_act = nullptr; // g_act = nullptr;
UniSetActivator::set_signals(false); UniSetActivator::set_signals(false);
} }
......
...@@ -165,7 +165,7 @@ void uniset::IDList::del( ObjectId id ) ...@@ -165,7 +165,7 @@ void uniset::IDList::del( ObjectId id )
} }
} }
std::list<uniset::ObjectId> uniset::IDList::getList() noexcept std::list<uniset::ObjectId> uniset::IDList::getList() const noexcept
{ {
return lst; return lst;
} }
......
...@@ -170,7 +170,7 @@ namespace uniset ...@@ -170,7 +170,7 @@ namespace uniset
return findLog(logname); return findLog(logname);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::ostream& LogAgregator::printLogList( std::ostream& os, const std::string& regexp_str ) std::ostream& LogAgregator::printLogList( std::ostream& os, const std::string& regexp_str ) const
{ {
std::list<iLog> lst; std::list<iLog> lst;
...@@ -195,7 +195,7 @@ namespace uniset ...@@ -195,7 +195,7 @@ namespace uniset
return os; return os;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::ostream& LogAgregator::printTree( std::ostream& os, const std::string& g_tab ) std::ostream& LogAgregator::printTree( std::ostream& os, const std::string& g_tab ) const
{ {
const std::string::size_type tab_width = 15; const std::string::size_type tab_width = 15;
......
...@@ -387,7 +387,7 @@ void LogReader::readlogs( const std::string& _addr, int _port, LogServerTypes::C ...@@ -387,7 +387,7 @@ void LogReader::readlogs( const std::string& _addr, int _port, LogServerTypes::C
{ {
// Всё это пока не оптимально, // Всё это пока не оптимально,
// но мы ведь и не спешим.. // но мы ведь и не спешим..
for( ssize_t i=0; i<n; i++ ) for( ssize_t i = 0; i < n; i++ )
{ {
// пока не встретили конец строки // пока не встретили конец строки
// наполняем line.. // наполняем line..
......
...@@ -450,7 +450,7 @@ bool ObjectRepository::isExist( const ObjectPtr& oref ) const ...@@ -450,7 +450,7 @@ bool ObjectRepository::isExist( const ObjectPtr& oref ) const
* \exception ORepFailed - генерируется если произошла при получении доступа к секции * \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/ */
bool ObjectRepository::createSection(const string& name, const string& in_section) const bool ObjectRepository::createSection(const string& name, const string& in_section) const
throw(ORepFailed, InvalidObjectName) throw(ORepFailed, InvalidObjectName)
{ {
char bad = ORepHelpers::checkBadSymbols(name); char bad = ORepHelpers::checkBadSymbols(name);
...@@ -582,7 +582,7 @@ void ObjectRepository::printSection( const string& fullName ) const ...@@ -582,7 +582,7 @@ void ObjectRepository::printSection( const string& fullName ) const
cout << fullName << "(" << olist.size() << "):" << endl; cout << fullName << "(" << olist.size() << "):" << endl;
for( const auto& v: olist ) for( const auto& v : olist )
cout << v << endl; cout << v << endl;
} }
......
...@@ -27,6 +27,7 @@ namespace uniset ...@@ -27,6 +27,7 @@ namespace uniset
{ {
{ {
std::lock_guard<std::timed_mutex> l(run_mutex); std::lock_guard<std::timed_mutex> l(run_mutex);
if( isactive ) if( isactive )
return false; return false;
...@@ -42,7 +43,7 @@ namespace uniset ...@@ -42,7 +43,7 @@ namespace uniset
if( !run_mutex.try_lock_for(std::chrono::milliseconds(timeout_msec)) ) if( !run_mutex.try_lock_for(std::chrono::milliseconds(timeout_msec)) )
return false; return false;
std::lock_guard<std::timed_mutex> l(run_mutex,std::adopt_lock); std::lock_guard<std::timed_mutex> l(run_mutex, std::adopt_lock);
if( isactive ) if( isactive )
return true; return true;
...@@ -101,6 +102,7 @@ namespace uniset ...@@ -101,6 +102,7 @@ namespace uniset
{ {
if( thr->joinable() ) if( thr->joinable() )
thr->join(); thr->join();
thr = nullptr; thr = nullptr;
} }
} }
......
...@@ -222,7 +222,7 @@ void NCRestorer_XML::read( IONotifyController* ic, const std::shared_ptr<UniXML> ...@@ -222,7 +222,7 @@ void NCRestorer_XML::read( IONotifyController* ic, const std::shared_ptr<UniXML>
read_thresholds(xml, tnode, ic); read_thresholds(xml, tnode, ic);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, IOController_i::SensorInfo& si ) bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, IOController_i::SensorInfo& si ) const
{ {
string sname( xml->getProp(it, "name")); string sname( xml->getProp(it, "name"));
...@@ -267,7 +267,7 @@ bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* i ...@@ -267,7 +267,7 @@ bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* i
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, std::shared_ptr<NCRestorer_XML::SInfo>& inf ) bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode* it, std::shared_ptr<NCRestorer_XML::SInfo>& inf ) const
{ {
if( !getBaseInfo(xml, it, inf->si) ) if( !getBaseInfo(xml, it, inf->si) )
return false; return false;
...@@ -467,7 +467,7 @@ void NCRestorer_XML::read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode ...@@ -467,7 +467,7 @@ void NCRestorer_XML::read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNode* node, bool NCRestorer_XML::getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNode* node,
IONotifyController::ConsumerListInfo& lst ) IONotifyController::ConsumerListInfo& lst ) const
{ {
UniXML::iterator it(node); UniXML::iterator it(node);
...@@ -490,7 +490,7 @@ bool NCRestorer_XML::getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNod ...@@ -490,7 +490,7 @@ bool NCRestorer_XML::getConsumerList( const std::shared_ptr<UniXML>& xml, xmlNod
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNode* node, bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNode* node,
IONotifyController::ThresholdInfoExt& ti ) IONotifyController::ThresholdInfoExt& ti ) const
{ {
UniXML::iterator uit(node); UniXML::iterator uit(node);
......
...@@ -189,8 +189,11 @@ timeout_t LT_Object::askTimer( uniset::TimerId timerid, timeout_t timeMS, clock_ ...@@ -189,8 +189,11 @@ timeout_t LT_Object::askTimer( uniset::TimerId timerid, timeout_t timeMS, clock_
{ {
li->curTick = ticks; li->curTick = ticks;
li->tmr.setTiming(timeMS); li->tmr.setTiming(timeMS);
uinfo << "(LT_askTimer): заказ на таймер ["
<< timerid << "]" << getTimerName(timerid) << " " << timeMS << " [мс] уже есть..." << endl; if( ulog()->debugging(loglevel) )
ulog()->debug(loglevel) << "(LT_askTimer): заказ на таймер ["
<< timerid << "]" << getTimerName(timerid) << " " << timeMS << " [мс] уже есть..." << endl;
return sleepTime; return sleepTime;
} }
} }
...@@ -200,13 +203,16 @@ timeout_t LT_Object::askTimer( uniset::TimerId timerid, timeout_t timeMS, clock_ ...@@ -200,13 +203,16 @@ timeout_t LT_Object::askTimer( uniset::TimerId timerid, timeout_t timeMS, clock_
tlst.emplace_back(timerid, timeMS, ticks, p); tlst.emplace_back(timerid, timeMS, ticks, p);
} // unlock } // unlock
uinfo << "(LT_askTimer): поступил заказ на таймер [" << timerid << "]" if( ulog()->debugging(loglevel) )
<< getTimerName(timerid) << " " << timeMS << " [мс]\n"; ulog()->debug(loglevel) << "(LT_askTimer): поступил заказ на таймер [" << timerid << "]"
<< getTimerName(timerid) << " " << timeMS << " [мс]\n";
} }
else // отказ (при timeMS == 0) else // отказ (при timeMS == 0)
{ {
uinfo << "(LT_askTimer): поступил отказ по таймеру [" << timerid << "]" if( ulog()->debugging(loglevel) )
<< getTimerName(timerid) << endl; ulog()->debug(loglevel) << "(LT_askTimer): поступил отказ по таймеру [" << timerid << "]"
<< getTimerName(timerid) << endl;
{ {
// lock // lock
uniset_rwmutex_wrlock lock(lstMutex); uniset_rwmutex_wrlock lock(lstMutex);
......
...@@ -63,7 +63,7 @@ namespace uniset ...@@ -63,7 +63,7 @@ namespace uniset
// не знаю как по другому // не знаю как по другому
// приходиться делать это через промежуточную переменную // приходиться делать это через промежуточную переменную
std::chrono::milliseconds ms(msec); std::chrono::milliseconds ms(msec);
std::swap(t_inner_msec,ms); std::swap(t_inner_msec, ms);
PassiveTimer::reset(); PassiveTimer::reset();
return getInterval(); return getInterval();
......
...@@ -55,7 +55,7 @@ void Restorer_XML::setConsumerFilter( const string& field, const string& val ) ...@@ -55,7 +55,7 @@ void Restorer_XML::setConsumerFilter( const string& field, const string& val )
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool Restorer_XML::getConsumerInfo( UniXML::iterator& it, bool Restorer_XML::getConsumerInfo( UniXML::iterator& it,
ObjectId& cid, ObjectId& cnode ) ObjectId& cid, ObjectId& cnode ) const
{ {
if( !check_consumer_item(it) ) if( !check_consumer_item(it) )
return false; return false;
...@@ -110,12 +110,12 @@ bool Restorer_XML::getConsumerInfo( UniXML::iterator& it, ...@@ -110,12 +110,12 @@ bool Restorer_XML::getConsumerInfo( UniXML::iterator& it,
return true; return true;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool Restorer_XML::check_list_item( UniXML::iterator& it ) bool Restorer_XML::check_list_item( UniXML::iterator& it ) const
{ {
return uniset::check_filter(it, i_filterField, i_filterValue); return uniset::check_filter(it, i_filterField, i_filterValue);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool Restorer_XML::check_consumer_item( UniXML::iterator& it ) bool Restorer_XML::check_consumer_item( UniXML::iterator& it ) const
{ {
return uniset::check_filter(it, c_filterField, c_filterValue); return uniset::check_filter(it, c_filterField, c_filterValue);
} }
......
...@@ -74,7 +74,7 @@ void UniXML::newDoc(const string& root_node, const string& xml_ver) ...@@ -74,7 +74,7 @@ void UniXML::newDoc(const string& root_node, const string& xml_ver)
if( d == NULL ) if( d == NULL )
throw NameNotFound("UniXML(open): не смогли создать doc=" + root_node); throw NameNotFound("UniXML(open): не смогли создать doc=" + root_node);
doc = std::unique_ptr<xmlDoc,UniXMLDocDeleter>(d); doc = std::unique_ptr<xmlDoc, UniXMLDocDeleter>(d);
// xmlEncodeEntitiesReentrant(doc, (const xmlChar*)ExternalEncoding.c_str()); // xmlEncodeEntitiesReentrant(doc, (const xmlChar*)ExternalEncoding.c_str());
xmlNode* rootnode = xmlNewDocNode(d, NULL, (const xmlChar*)root_node.c_str(), NULL); xmlNode* rootnode = xmlNewDocNode(d, NULL, (const xmlChar*)root_node.c_str(), NULL);
...@@ -118,7 +118,7 @@ void UniXML::open( const string& _filename ) ...@@ -118,7 +118,7 @@ void UniXML::open( const string& _filename )
if( d == NULL ) if( d == NULL )
throw NameNotFound("UniXML(open): NotFound file=" + _filename); throw NameNotFound("UniXML(open): NotFound file=" + _filename);
doc = std::unique_ptr<xmlDoc,UniXMLDocDeleter>(d); doc = std::unique_ptr<xmlDoc, UniXMLDocDeleter>(d);
// Support for XInclude (see eterbug #6304) // Support for XInclude (see eterbug #6304)
// main tag must to have follow property: xmlns:xi="http://www.w3.org/2001/XInclude" // main tag must to have follow property: xmlns:xi="http://www.w3.org/2001/XInclude"
......
...@@ -150,7 +150,13 @@ namespace uniset ...@@ -150,7 +150,13 @@ namespace uniset
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
std::ostream& operator<<( std::ostream& os, VMonitor& m ) std::ostream& operator<<( std::ostream& os, VMonitor& m )
{ {
auto vlist = m.getList(); return os << m.str();
}
// --------------------------------------------------------------------------
std::string VMonitor::str() const
{
std::ostringstream s;
auto vlist = getList();
// сортируем по алфавиту // сортируем по алфавиту
vlist.sort( []( const std::pair<std::string, std::string>& a, const std::pair<std::string, std::string>& b ) vlist.sort( []( const std::pair<std::string, std::string>& a, const std::pair<std::string, std::string>& b )
{ {
...@@ -158,19 +164,12 @@ namespace uniset ...@@ -158,19 +164,12 @@ namespace uniset
}); });
for( const auto& e : vlist ) for( const auto& e : vlist )
os << e.first << " = " << e.second; s << e.first << " = " << e.second;
return os;
}
// --------------------------------------------------------------------------
std::string VMonitor::str()
{
std::ostringstream s;
s << (*this);
return s.str(); return s.str();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
std::list<std::pair<std::string, std::string> > VMonitor::getList() std::list<std::pair<std::string, std::string> > VMonitor::getList() const
{ {
std::list<std::pair<std::string, std::string>> vlist; std::list<std::pair<std::string, std::string>> vlist;
VMON_MAKE_PAIR2(vlist, int); VMON_MAKE_PAIR2(vlist, int);
...@@ -184,7 +183,7 @@ namespace uniset ...@@ -184,7 +183,7 @@ namespace uniset
return vlist; return vlist;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
std::string VMonitor::pretty_str( int namewidth, int colnum ) std::string VMonitor::pretty_str( int namewidth, int colnum ) const
{ {
auto vlist = getList(); auto vlist = getList();
std::ostringstream os; std::ostringstream os;
......
...@@ -22,7 +22,7 @@ struct TestClass ...@@ -22,7 +22,7 @@ struct TestClass
{ {
TestClass() TestClass()
{ {
memset(&data,0,sizeof(data)); memset(&data, 0, sizeof(data));
cerr << "TEST CLASS CREATE.." << endl; cerr << "TEST CLASS CREATE.." << endl;
} }
......
...@@ -203,7 +203,7 @@ TEST_CASE("[DelayTimer]: zero time", "[DelayTimer]" ) ...@@ -203,7 +203,7 @@ TEST_CASE("[DelayTimer]: zero time", "[DelayTimer]" )
// проверка работы при вызове check() // проверка работы при вызове check()
// уже после срабатывания таймера // уже после срабатывания таймера
dt.set(0,100); dt.set(0, 100);
REQUIRE( dt.check(true) ); // взводим REQUIRE( dt.check(true) ); // взводим
REQUIRE( dt.check(false) ); // отпускаем.. REQUIRE( dt.check(false) ); // отпускаем..
msleep(150); msleep(150);
......
...@@ -72,7 +72,7 @@ TEST_CASE("Pulse: basic tests", "[pulse][basic]" ) ...@@ -72,7 +72,7 @@ TEST_CASE("Pulse: basic tests", "[pulse][basic]" )
TEST_CASE("Pulse: ext tests", "[pulse][ext]" ) TEST_CASE("Pulse: ext tests", "[pulse][ext]" )
{ {
Pulse p; Pulse p;
p.setTiming(50,100,false); p.setTiming(50, 100, false);
REQUIRE_FALSE( p.isOn() ); REQUIRE_FALSE( p.isOn() );
p.set(true); p.set(true);
...@@ -87,7 +87,7 @@ TEST_CASE("Pulse: ext tests", "[pulse][ext]" ) ...@@ -87,7 +87,7 @@ TEST_CASE("Pulse: ext tests", "[pulse][ext]" )
REQUIRE_FALSE( p.isOn() ); REQUIRE_FALSE( p.isOn() );
REQUIRE_FALSE( p.step() ); REQUIRE_FALSE( p.step() );
p.setTiming(50,100,true); p.setTiming(50, 100, true);
REQUIRE( p.isOn() ); REQUIRE( p.isOn() );
REQUIRE( p.step() ); REQUIRE( p.step() );
} }
......
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