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