Commit 1f5d6110 authored by Pavel Vainerman's avatar Pavel Vainerman

make style

parent bb263d34
......@@ -485,12 +485,6 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
* Wed Feb 17 2016 Pavel Vainerman <pv@altlinux.ru> 2.2-alt23
- IONotifyController: fixed buf for init thresholdslist
* Mon Jan 18 2016 Pavel Vainerman <pv@altlinux.ru> 2.2-alt19
- rebuild new version
* Fri Jan 15 2016 Pavel Vainerman <pv@altlinux.ru> 2.2-alt17
- rebuild new version
* Tue Feb 09 2016 Pavel Vainerman <pv@altlinux.ru> 2.2-alt22
- ModbusSlave(TCP): add show ip:port to vmonit setbug #9012
......
......@@ -48,6 +48,7 @@ MySQLInterface::~MySQLInterface()
{
cerr << "MySQLInterface::~MySQLInterface(): an error occured while closing connection!" << endl;
}
delete mysql;
}
......@@ -188,6 +189,7 @@ void MySQLInterface::makeResult(DBResult& dbres, MYSQL_RES* myres, bool finalize
{
if( finalize )
mysql_free_result(myres);
return;
}
......
......@@ -233,6 +233,7 @@ void SQLiteInterface::makeResult(DBResult& dbres, sqlite3_stmt* s, bool finalize
{
if( finalize )
sqlite3_finalize(s);
return;
}
......
......@@ -30,6 +30,7 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet
myinfo << myname << "(init): filter-field=" << ff << " filter-value=" << fv << endl;
xmlNode* senssec = conf->getXMLSensorsSection();
if( !senssec )
{
ostringstream err;
......@@ -39,6 +40,7 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet
}
UniXML::iterator sit(senssec);
if( !sit.goChildren() )
{
ostringstream err;
......@@ -48,6 +50,7 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet
}
ostringstream pubname;
for( ; sit.getCurrent(); sit++ )
{
if( !UniSetTypes::check_filter(sit, ff, fv) )
......@@ -55,6 +58,7 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet
std::string sname = sit.getProp("name");
ObjectId sid = conf->getSensorID(sname);
if( sid == DefaultObjectId )
{
ostringstream err;
......@@ -66,7 +70,7 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet
pubname.str("");
pubname << topicsensors << "/" << sname;
MQTTInfo m(sid,pubname.str());
MQTTInfo m(sid, pubname.str());
publist.emplace(sid, std::move(m) );
if( smTestID == DefaultObjectId )
......@@ -87,9 +91,9 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet
port = conf->getArgPInt("--" + argprefix + "mqtt-port", it.getProp("mqttPort"), 1883);
keepalive = conf->getArgPInt("--" + argprefix + "mqtt-keepalive", it.getProp("mqttKeepAlive"), 60);
// см. sysCommad()
// connect_async(host.c_str(),port,keepalive);
// loop_start();
// см. sysCommad()
// connect_async(host.c_str(),port,keepalive);
// loop_start();
}
// -----------------------------------------------------------------------------
MQTTPublisher::~MQTTPublisher()
......@@ -117,11 +121,12 @@ bool MQTTPublisher::deactivateObject()
void MQTTPublisher::sysCommand(const SystemMessage* sm)
{
UObject_SK::sysCommand(sm);
if( sm->command == SystemMessage::StartUp || sm->command == SystemMessage::WatchDog )
{
if( !connectOK )
{
connect_async(host.c_str(),port,keepalive);
connect_async(host.c_str(), port, keepalive);
loop_start();
}
}
......@@ -165,10 +170,11 @@ void MQTTPublisher::on_connect(int rc)
if( connectOK )
askSensors(UniversalIO::UIONotify);
// else
// {
// askTimer(reconnectTimer,reconnectTime);
// }
// else
// {
// askTimer(reconnectTimer,reconnectTime);
// }
}
// -----------------------------------------------------------------------------
void MQTTPublisher::on_message( const mosquitto_message* message )
......@@ -220,7 +226,8 @@ std::shared_ptr<MQTTPublisher> MQTTPublisher::init_mqttpublisher(int argc, const
void MQTTPublisher::askSensors( UniversalIO::UIOCommand cmd )
{
UObject_SK::askSensors(cmd);
for( const auto& i: publist )
for( const auto& i : publist )
{
try
{
......@@ -236,6 +243,7 @@ void MQTTPublisher::askSensors( UniversalIO::UIOCommand cmd )
void MQTTPublisher::sensorInfo( const UniSetTypes::SensorMessage* sm )
{
auto i = publist.find(sm->id);
if( i == publist.end() )
return;
......@@ -247,7 +255,8 @@ void MQTTPublisher::sensorInfo( const UniSetTypes::SensorMessage* sm )
//subscribe(NULL, i.second.pubname.c_str());
myinfo << "(sensorInfo): publish: topic='" << i->second.pubname << "' msg='" << tmsg.c_str() << "'" << endl;
int ret = publish(NULL,i->second.pubname.c_str(),tmsg.size(),tmsg.c_str(),1,false);
int ret = publish(NULL, i->second.pubname.c_str(), tmsg.size(), tmsg.c_str(), 1, false);
if( ret != MOSQ_ERR_SUCCESS )
{
mycrit << myname << "(sensorInfo): PUBLISH FAILED: err(" << ret << "): " << mosqpp::strerror(ret) << endl;
......
......@@ -81,8 +81,8 @@ class MQTTPublisher:
virtual void on_connect(int rc) override;
virtual void on_message(const struct mosquitto_message *message) override;
virtual void on_subscribe(int mid, int qos_count, const int *granted_qos) override;
virtual void on_message(const struct mosquitto_message* message) override;
virtual void on_subscribe(int mid, int qos_count, const int* granted_qos) override;
protected:
MQTTPublisher();
......
......@@ -531,7 +531,7 @@ const std::string MBTCPMultiMaster::MBSlaveInfo::getShortInfo() const
<< " recv_timeout=" << recv_timeout
<< " resp_force=" << respond_force
<< " use=" << use
<< " ignore=" << ( ptIgnoreTimeout.checkTime() ? "0":"1")
<< " ignore=" << ( ptIgnoreTimeout.checkTime() ? "0" : "1")
<< " priority=" << priority
<< " persistent-connection=" << !force_disconnect
<< ")";
......
......@@ -2409,6 +2409,7 @@ UniSetTypes::SimpleInfo* MBSlave::getInfo( CORBA::Long userparam )
inf << "LogServer: " << logserv_host << ":" << logserv_port << endl;
inf << "iomap=" << iomap.size() << " myaddr: " << ModbusServer::vaddr2str(vaddr) << endl;
inf << "Statistic: askCount=" << askCount << " pingOK=" << pingOK << endl;
if( sslot ) // т.е. если у нас tcp
{
ost::InetAddress iaddr = sslot->getInetAddress();
......
......@@ -386,7 +386,7 @@ RRDServer::RRDInfo::RRDInfo(const string& fname, long tmID, long sec, const RRDS
filename(fname), tid(tmID), sec(sec), dslist(lst)
{
// фомируем dsmap
for( auto&& i: dslist )
dsmap.emplace(i->sid,i);
for( auto && i : dslist )
dsmap.emplace(i->sid, i);
}
// -----------------------------------------------------------------------------
......@@ -29,7 +29,7 @@ class UObject_SK:
public UniSetObject
{
public:
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node = UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix = "" );
UObject_SK();
virtual ~UObject_SK();
......@@ -43,54 +43,60 @@ class UObject_SK:
virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true );
inline std::shared_ptr<DebugStream> log(){ return mylog; }
inline std::shared_ptr<LogAgregator> logAgregator(){ return loga; }
inline std::shared_ptr<DebugStream> log()
{
return mylog;
}
inline std::shared_ptr<LogAgregator> logAgregator()
{
return loga;
}
void init_dlog( std::shared_ptr<DebugStream> d );
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
......@@ -107,16 +113,19 @@ class UObject_SK:
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true );
std::string str( UniSetTypes::ObjectId id, bool showLinkName = true );
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true );
std::string strval( UniSetTypes::ObjectId id, bool showLinkName = true );
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
inline std::string dumpVars()
{
return std::move(vmon.pretty_str());
}
// ------------------------------------------------------------
std::string help();
......@@ -145,13 +154,16 @@ class UObject_SK:
virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ){};
virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) {};
virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override {}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override {}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */
virtual std::string getMonitInfo()
{
return ""; /*!< пользовательская информация выводимая в getInfo() */
}
virtual void testMode( bool state );
void updatePreviousValues();
......@@ -171,7 +183,7 @@ class UObject_SK:
int resetMsgTime;
// Выполнение очередного шага программы
virtual void step(){}
virtual void step() {}
int sleep_msec; /*!< пауза между итерациями */
bool active;
......@@ -186,9 +198,15 @@ class UObject_SK:
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); }
int getIntProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getIntProp(confnode, name);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name) { return UniSetTypes::uniset_conf()->getProp(confnode, name); }
inline const std::string getProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getProp(confnode, name);
}
timeout_t smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated;
......
......@@ -82,7 +82,11 @@ struct DBInterfaceDeleter
{
void operator()(DBInterface* p) const
{
try{ delete p; } catch(...) {}
try
{
delete p;
}
catch(...) {}
}
};
// ----------------------------------------------------------------------------------
......
......@@ -196,7 +196,10 @@ class LT_Object
TimersList getTimersList();
/*! пользовательская функция для вывода названия таймера */
virtual std::string getTimerName( int id ){ return ""; }
virtual std::string getTimerName( int id )
{
return "";
}
private:
TimersList tlst;
......
......@@ -78,8 +78,14 @@ class ModbusTCPServer:
void getSessions( Sessions& lst );
inline ost::InetAddress getInetAddress(){ return iaddr; }
inline ost::tpport_t getInetPort(){ return port; }
inline ost::InetAddress getInetAddress()
{
return iaddr;
}
inline ost::tpport_t getInetPort()
{
return port;
}
protected:
......
......@@ -868,14 +868,15 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
<< uniset_conf()->oind->getNameById(it->second.si.id)
<< " " << ex << endl;
}
/*
/*
catch( const IOController_i::NameNotFound& ex )
{
uwarn << myname << "(getThresholds): IOController_i::NameNotFound.. for sid"
<< uniset_conf()->oind->getNameById(it->second.si.id)
<< endl;
}
*/
*/
res->tlist.length( it->second.list.size() );
unsigned int k = 0;
......@@ -911,7 +912,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
try
{
(*res)[i].si = it->second.si;
(*res)[i].value = IOController::localGetValue(it->second.ait,it->second.si.id);
(*res)[i].value = IOController::localGetValue(it->second.ait, it->second.si.id);
(*res)[i].type = it->second.type;
}
catch( const std::exception& ex )
......
......@@ -125,7 +125,7 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, std::shared_ptr<IOCon
auto i = ic->find(inf->si.id);
ic->askTMap[inf->si.id].ait = i->second;
}
catch(...){}
catch(...) {}
ic->askTMap[inf->si.id].si = inf->si;
ic->askTMap[inf->si.id].type = inf->type;
......
......@@ -6,22 +6,26 @@ bool DBNetInterface::connect( const std::string& param )
std::string user = "";
std::string pswd = "";
std::string dbname = "";
for(;;)
{
std::string::size_type pos = param.find_first_of("@");
user = param.substr(0, pos);
if( pos == std::string::npos )
break;
std::string::size_type prev = pos + 1;
pos = param.find_first_of(":", prev);
host = param.substr(prev, pos - prev);
if( pos == std::string::npos )
break;
prev = pos + 1;
pos = param.find_first_of(":", prev);
pswd = param.substr(prev, pos - prev);
if( pos == std::string::npos )
break;
......
......@@ -199,7 +199,7 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
} // unlock
uinfo << "(LT_askTimer): поступил заказ на таймер([" << timerid << "]"
<< getTimerName(timerid) <<") " << timeMS << " [мс]\n";
<< getTimerName(timerid) << ") " << timeMS << " [мс]\n";
}
else // отказ (при timeMS == 0)
{
......
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