Commit 6ded0d3f authored by Pavel Vainerman's avatar Pavel Vainerman

backported to p8 as 2.7-alt10.M80P.11 (with rpmbph script)

parents ab8f5513 2d719114
......@@ -14,14 +14,19 @@
%def_disable netdata
%def_enable api
%def_enable logdb
%def_enable com485f
%def_enable opentsdb
%ifarch %ix86
%def_enable com485f
%else
%def_disable com485f
%endif
%define oname uniset2
Name: libuniset2
Version: 2.7
Release: alt9.M80P.10
Release: alt10.M80P.11
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
......@@ -542,9 +547,12 @@ rm -f %buildroot%_libdir/*.la
# history of current unpublished changes
%changelog
* Thu May 24 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt9.M80P.10
* Sun Jun 10 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt10.M80P.11
- backport to ALTLinux p8 (by rpmbph script)
* Sat Jun 09 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt11
- PostgreSQL: extended the interface
* Thu May 24 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt10
- fix pack opentsdb backend
......
......@@ -162,8 +162,7 @@ void BackendOpenTSDB::help_print( int argc, const char* const* argv )
cout << " set-levels ... " << endl;
cout << " logfile filanme " << endl;
cout << " no-debug " << endl;
cout << " Base oprtions: " << endl;
// cout << UObject_SK::help() << endl;
cout << endl;
cout << " LogServer: " << endl;
cout << "--prefix-run-logserver - run logserver. Default: localhost:id" << endl;
cout << "--prefix-logserver-host ip - listen ip. Default: localhost" << endl;
......
......@@ -222,7 +222,7 @@ void DBServer_PostgreSQL::flushInsertBuffer()
dbinfo << myname << "(flushInsertBuffer): write insert buffer[" << ibufSize << "] to DB.." << endl;
if( !db->copy("main_history", tblcols, ibuf) )
if( !writeBufferToDB("main_history", tblcols, ibuf) )
{
dbcrit << myname << "(flushInsertBuffer): error: " << db->error() << endl;
}
......@@ -233,6 +233,13 @@ void DBServer_PostgreSQL::flushInsertBuffer()
}
}
//--------------------------------------------------------------------------------------------
bool DBServer_PostgreSQL::writeBufferToDB( const std::string& tableName
, const std::vector<std::string>& colNames
, DBServer_PostgreSQL::InsertBuffer& wbuf )
{
return db->copy(tableName, colNames, wbuf);
}
//--------------------------------------------------------------------------------------------
void DBServer_PostgreSQL::sensorInfo( const uniset::SensorMessage* si )
{
try
......
......@@ -129,6 +129,10 @@ namespace uniset
size_t ibufMaxSize = { 2000 };
timeout_t ibufSyncTimeout = { 15000 };
void flushInsertBuffer();
virtual bool writeBufferToDB( const std::string& table
, const std::vector<std::string>& colname
, InsertBuffer& ibuf );
float ibufOverflowCleanFactor = { 0.5 }; // коэфициент {0...1} чистки буфера при переполнении
private:
......
......@@ -537,9 +537,7 @@ namespace uniset
else
{
dinfo << "(smemory): init from configure: " << conf->getConfFileName() << endl;
UniXML::iterator it(conf->getXMLSensorsSection());
it.goChildren();
ioconf = make_shared<IOConfig_XML>(conf->getConfXML(), conf, it);
ioconf = make_shared<IOConfig_XML>(conf->getConfXML(), conf, conf->getXMLSensorsSection());
}
uniset::ObjectId ID = conf->getControllerID(conf->getArgParam("--smemory-id", "SharedMemory"));
......
......@@ -51,7 +51,7 @@ namespace uniset
/*!
* \param xml - xml формата uniset-project
* \param conf - конфигурация
* \param root - узел с датчиками (если не задан, ищется "sensors")
* \param root - узел со списком датчиков (если не задан, ищется "sensors")
*/
IOConfig_XML( const std::shared_ptr<UniXML>& _xml, const std::shared_ptr<Configuration>& conf, xmlNode* root = nullptr );
......
......@@ -18,6 +18,7 @@
#define UHelpers_H_
// --------------------------------------------------------------------------
#include "UniSetTypes.h"
#include "Exceptions.h"
#include "Configuration.h"
// --------------------------------------------------------------------------
namespace uniset
......
......@@ -55,17 +55,17 @@ namespace uniset
IOController::IOStateList lst;
if( !root )
{
root = uxml->findNode( uxml->getFirstNode(), "sensors");
if( !root )
return lst;
UniXML::iterator it(root);
it.goChildren();
root = it.getCurrent();
}
if( root )
{
lst = read_list(root);
if( !it.goChildren() )
return lst;
lst = read_list(it);
// только после чтения всех датчиков и формирования списка IOList
// можно инициализировать списки зависимостей
init_depends_signals(lst);
......@@ -74,7 +74,6 @@ namespace uniset
if( tnode )
init_thresholds(tnode, lst);
}
return lst;
}
......
......@@ -598,6 +598,9 @@ bool UniXML_iterator::findName( const std::string& nodename, const std::string&
{
fnode = this->findX(fnode, nodename, deepfind);
if( !fnode )
return false;
if ( searchname == UniXML::getProp(fnode, "name") )
{
curNode = fnode;
......
......@@ -97,6 +97,10 @@ TEST_CASE("UniXML::iterator", "[unixml][iterator][basic]" )
--it;
CHECK( it.getName() == "UserData" );
UniXML::iterator it_bad = uxml.begin();
REQUIRE_FALSE( it_bad.findName("UnknownNode","NOTFOUND") );
REQUIRE_FALSE( !it_bad );
it = uxml.begin();
CHECK( it.findName("TestNode", "TestNode1") != 0 );
it = uxml.begin();
......
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