Commit 2d26f84d authored by Pavel Vainerman's avatar Pavel Vainerman

Исправления по результатам проверки статическим анализатором

parent 3556ba44
...@@ -955,7 +955,8 @@ int configure( const string& arg, UInterface& ui ) ...@@ -955,7 +955,8 @@ int configure( const string& arg, UInterface& ui )
UniSetTypes::ObjectId id = conf->getObjectID(arg); UniSetTypes::ObjectId id = conf->getObjectID(arg);
if( id == DefaultObjectId ) if( id == DefaultObjectId )
id = conf->getControllerID(arg); id = conf->getControllerID(arg);
else if( id == DefaultObjectId )
if( id == DefaultObjectId )
id = conf->getServiceID(arg); id = conf->getServiceID(arg);
if( id == DefaultObjectId ) if( id == DefaultObjectId )
......
...@@ -384,9 +384,11 @@ void DBServer_MySQL::timerInfo( const UniSetTypes::TimerMessage* tm ) ...@@ -384,9 +384,11 @@ void DBServer_MySQL::timerInfo( const UniSetTypes::TimerMessage* tm )
askTimer(DBServer_MySQL::ReconnectTimer, 0); askTimer(DBServer_MySQL::ReconnectTimer, 0);
askTimer(DBServer_MySQL::PingTimer, PingTime); askTimer(DBServer_MySQL::PingTimer, PingTime);
} }
else
connect_ok = false; {
dbwarn << myname << "(timerInfo): DB no connection.." << endl; connect_ok = false;
dbwarn << myname << "(timerInfo): DB no connection.." << endl;
}
} }
else else
initDBServer(); initDBServer();
......
...@@ -220,10 +220,9 @@ void DBServer_PostgreSQL::flushInsertBuffer() ...@@ -220,10 +220,9 @@ void DBServer_PostgreSQL::flushInsertBuffer()
} }
ibuf.erase(beg, end); ibuf.erase(beg, end);
ibufSize -= delnum;
if( ibufSize < 0 ) // ibufSize - беззнаковое, так что надо аккуратно
ibufSize = 0; ibufSize = (delnum < ibufSize) ? (ibufSize-delnum) : 0;
dbwarn << myname << "(flushInsertBuffer): overflow: clear data " << delnum << " records." << endl; dbwarn << myname << "(flushInsertBuffer): overflow: clear data " << delnum << " records." << endl;
return; return;
...@@ -438,9 +437,11 @@ void DBServer_PostgreSQL::timerInfo( const UniSetTypes::TimerMessage* tm ) ...@@ -438,9 +437,11 @@ void DBServer_PostgreSQL::timerInfo( const UniSetTypes::TimerMessage* tm )
askTimer(DBServer_PostgreSQL::ReconnectTimer, 0); askTimer(DBServer_PostgreSQL::ReconnectTimer, 0);
askTimer(DBServer_PostgreSQL::PingTimer, PingTime); askTimer(DBServer_PostgreSQL::PingTimer, PingTime);
} }
else
connect_ok = false; {
dbwarn << myname << "(timerInfo): DB no connection.." << endl; connect_ok = false;
dbwarn << myname << "(timerInfo): DB no connection.." << endl;
}
} }
else else
initDBServer(); initDBServer();
......
...@@ -359,9 +359,11 @@ void DBServer_SQLite::timerInfo( const UniSetTypes::TimerMessage* tm ) ...@@ -359,9 +359,11 @@ void DBServer_SQLite::timerInfo( const UniSetTypes::TimerMessage* tm )
askTimer(DBServer_SQLite::ReconnectTimer, 0); askTimer(DBServer_SQLite::ReconnectTimer, 0);
askTimer(DBServer_SQLite::PingTimer, PingTime); askTimer(DBServer_SQLite::PingTimer, PingTime);
} }
else
connect_ok = false; {
dbwarn << myname << "(timerInfo): DB no connection.." << endl; connect_ok = false;
dbwarn << myname << "(timerInfo): DB no connection.." << endl;
}
} }
else else
initDBServer(); initDBServer();
......
...@@ -69,9 +69,9 @@ IOControl::IOControl(UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -69,9 +69,9 @@ IOControl::IOControl(UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
auto conf = uniset_conf(); auto conf = uniset_conf();
string cname = conf->getArgParam("--" + prefix + "-confnode", myname); string cname = conf->getArgParam("--" + prefix + "-confnode", myname);
cnode = conf->getNode(cname); confnode = conf->getNode(cname);
if( cnode == NULL ) if( confnode == NULL )
throw SystemError("Not found conf-node " + cname + " for " + myname); throw SystemError("Not found conf-node " + cname + " for " + myname);
iolog = make_shared<DebugStream>(); iolog = make_shared<DebugStream>();
...@@ -89,10 +89,10 @@ IOControl::IOControl(UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -89,10 +89,10 @@ IOControl::IOControl(UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
ioinfo << myname << "(init): numcards=" << numcards << endl; ioinfo << myname << "(init): numcards=" << numcards << endl;
UniXML::iterator it(cnode); UniXML::iterator it(confnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix + "-logserver", cnode ); logserv->init( prefix + "-logserver", confnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
...@@ -306,7 +306,7 @@ IOControl::~IOControl() ...@@ -306,7 +306,7 @@ IOControl::~IOControl()
void IOControl::execute() void IOControl::execute()
{ {
// set_signals(true); // set_signals(true);
UniXML::iterator it(cnode); UniXML::iterator it(confnode);
waitSM(); // необходимо дождаться, чтобы нормально инициализировать итераторы waitSM(); // необходимо дождаться, чтобы нормально инициализировать итераторы
...@@ -1055,7 +1055,9 @@ void IOControl::check_testmode() ...@@ -1055,7 +1055,9 @@ void IOControl::check_testmode()
// если режим "выключено всё" // если режим "выключено всё"
// то гасим все выходы // то гасим все выходы
if( testmode == tmOffPoll ) if( testmode == tmOffPoll ||
testmode == tmConfigEnable ||
testmode == tmConfigDisable )
{ {
// выставляем безопасные состояния // выставляем безопасные состояния
for( auto& it : iomap ) for( auto& it : iomap )
...@@ -1602,17 +1604,15 @@ void IOControl::buildCardsList() ...@@ -1602,17 +1604,15 @@ void IOControl::buildCardsList()
return; return;
} }
//xmlNode* cnode = xml->findNode(mynode,"iocards",""); xmlNode* cardsnode = xml->extFindNode(mynode, 1, 1, "iocards", "");
//xmlNode* extFindNode(xmlNode* node, int depth, int width, const std::string searchnode, const std::string name = "", bool top=true );
xmlNode* cnode = xml->extFindNode(mynode, 1, 1, "iocards", "");
if( !cnode ) if( !cardsnode )
{ {
iowarn << myname << "(buildCardsList): Not found <iocards> for node=" << conf->getLocalNodeName() << "(" << conf->getLocalNode() << ")" << endl; iowarn << myname << "(buildCardsList): Not found <iocards> for node=" << conf->getLocalNodeName() << "(" << conf->getLocalNode() << ")" << endl;
return; return;
} }
UniXML::iterator it(cnode); UniXML::iterator it(cardsnode);
if( !it.goChildren() ) if( !it.goChildren() )
{ {
......
...@@ -295,12 +295,12 @@ class IOControl: ...@@ -295,12 +295,12 @@ class IOControl:
enum TestModeID enum TestModeID
{ {
tmNone = 0, /*!< тестовый режим отключён */ tmNone = 0, /*!< тестовый режим отключён */
tmOffPoll = 1, /*!< отключить опрос */ tmOffPoll = 1, /*!< отключить опрос */
tmConfigEnable = 2, /*!< специальный режим, в соответствии с настройкой 'enable_testmode' */ tmConfigEnable = 2, /*!< специальный режим, в соответствии с настройкой 'enable_testmode' */
tmConfigDisable = 3, /*!< специальный режим, в соответствии с настройкой 'disable_testmode' */ tmConfigDisable = 3, /*!< специальный режим, в соответствии с настройкой 'disable_testmode' */
tmOnlyInputs = 4, /*!< включены только входы */ tmOnlyInputs = 4, /*!< включены только входы */
tmOnlyOutputs = 5 /*!< включены только выходы */ tmOnlyOutputs = 5 /*!< включены только выходы */
}; };
void execute(); void execute();
...@@ -335,7 +335,7 @@ class IOControl: ...@@ -335,7 +335,7 @@ class IOControl:
void waitSM(); void waitSM();
xmlNode* cnode = { 0 }; /*!< xml-узел в настроечном файле */ xmlNode* confnode = { 0 }; /*!< xml-узел в настроечном файле */
int polltime = { 150 }; /*!< переодичность обновления данных (опроса карт в/в), [мсек] */ int polltime = { 150 }; /*!< переодичность обновления данных (опроса карт в/в), [мсек] */
CardList cards; /*!< список карт - массив созданных ComediInterface */ CardList cards; /*!< список карт - массив созданных ComediInterface */
......
...@@ -72,7 +72,6 @@ int subdev = 0; ...@@ -72,7 +72,6 @@ int subdev = 0;
int chan = 0; int chan = 0;
int range = 0; int range = 0;
int aref = AREF_GROUND; int aref = AREF_GROUND;
bool go = true;
static struct option longopts[] = static struct option longopts[] =
{ {
......
...@@ -337,7 +337,6 @@ class MBSlave: ...@@ -337,7 +337,6 @@ class MBSlave:
VTypes::VType vtype; /*!< type of value */ VTypes::VType vtype; /*!< type of value */
size_t wnum; /*!< номер слова (для типов с размеров больше 2х байт */ size_t wnum; /*!< номер слова (для типов с размеров больше 2х байт */
size_t nbyte; /*!< номер байта, который надо "сохранить" из "пришедщего в запросе" слова. [1-2] */ size_t nbyte; /*!< номер байта, который надо "сохранить" из "пришедщего в запросе" слова. [1-2] */
bool rawdata; /*!< флаг, что в SM просто сохраняются 4-байта (актуально для типа F4)*/
std::shared_ptr<BitRegProperty> bitreg; /*!< указатель, как признак является ли данный регистр "сборным" из битовых */ std::shared_ptr<BitRegProperty> bitreg; /*!< указатель, как признак является ли данный регистр "сборным" из битовых */
ModbusRTU::RegID regID; ModbusRTU::RegID regID;
...@@ -347,7 +346,6 @@ class MBSlave: ...@@ -347,7 +346,6 @@ class MBSlave:
vtype(VTypes::vtUnknown), vtype(VTypes::vtUnknown),
wnum(0), wnum(0),
nbyte(0), nbyte(0),
rawdata(false),
regID(0) regID(0)
{} {}
......
...@@ -99,9 +99,6 @@ int main( int argc, const char** argv ) ...@@ -99,9 +99,6 @@ int main( int argc, const char** argv )
ThreadCreator<IOControl>* io_thr = new ThreadCreator<IOControl>(ic.get(), &IOControl::execute); ThreadCreator<IOControl>* io_thr = new ThreadCreator<IOControl>(ic.get(), &IOControl::execute);
if( io_thr == NULL )
return 1;
act->add(ic); act->add(ic);
lst_iothr.push_back( io_thr ); lst_iothr.push_back( io_thr );
} }
......
...@@ -717,8 +717,8 @@ namespace MTR ...@@ -717,8 +717,8 @@ namespace MTR
return val; return val;
} }
unsigned short val; unsigned short val = { 0 };
float fval; float fval = { 0.0 };
}; };
std::ostream& operator<<(std::ostream& os, T16& t ); std::ostream& operator<<(std::ostream& os, T16& t );
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -765,8 +765,8 @@ namespace MTR ...@@ -765,8 +765,8 @@ namespace MTR
return val; return val;
} }
signed short val; signed short val = { 0 };
float fval; float fval = { 0 };
}; };
std::ostream& operator<<(std::ostream& os, T17& t ); std::ostream& operator<<(std::ostream& os, T17& t );
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -114,7 +114,7 @@ namespace VTypes ...@@ -114,7 +114,7 @@ namespace VTypes
// ------------------------------------------ // ------------------------------------------
// конструкторы на разные случаи... // конструкторы на разные случаи...
F2r() noexcept {} F2r() noexcept { raw_backorder.val = 0; }
F2r( const float& f ) noexcept: F2(f) F2r( const float& f ) noexcept: F2(f)
{ {
...@@ -383,7 +383,7 @@ namespace VTypes ...@@ -383,7 +383,7 @@ namespace VTypes
public I2 public I2
{ {
public: public:
I2r() noexcept {} I2r() noexcept { raw_backorder.val = 0; }
I2r( const int v ) noexcept: I2(v) I2r( const int v ) noexcept: I2(v)
{ {
...@@ -457,7 +457,7 @@ namespace VTypes ...@@ -457,7 +457,7 @@ namespace VTypes
public U2 public U2
{ {
public: public:
U2r() noexcept {} U2r() noexcept { raw_backorder.val = 0; }
U2r( int v ) noexcept: U2(v) U2r( int v ) noexcept: U2(v)
{ {
......
...@@ -192,7 +192,9 @@ bool IOBase::check_front( bool val ) ...@@ -192,7 +192,9 @@ bool IOBase::check_front( bool val )
void IOBase::processingAsAI( IOBase* it, long val, const std::shared_ptr<SMInterface>& shm, bool force ) void IOBase::processingAsAI( IOBase* it, long val, const std::shared_ptr<SMInterface>& shm, bool force )
{ {
if( it->stype == UniversalIO::DI || it->stype == UniversalIO::DO ) if( it->stype == UniversalIO::DI || it->stype == UniversalIO::DO )
val = (val ? 1.0 : 0.0); {
val = (val ? 1 : 0);
}
else else
{ {
// проверка на обрыв // проверка на обрыв
...@@ -270,7 +272,7 @@ void IOBase::processingFasAI( IOBase* it, float fval, const std::shared_ptr<SMIn ...@@ -270,7 +272,7 @@ void IOBase::processingFasAI( IOBase* it, float fval, const std::shared_ptr<SMIn
long val = lroundf(fval); long val = lroundf(fval);
if( it->stype == UniversalIO::DI || it->stype == UniversalIO::DO ) if( it->stype == UniversalIO::DI || it->stype == UniversalIO::DO )
val = (fval != 0 ? 1.0 : 0.0); val = (fval != 0 ? 1 : 0);
else else
{ {
if( it->rawdata ) if( it->rawdata )
......
...@@ -74,7 +74,7 @@ using namespace UniSetTypes; ...@@ -74,7 +74,7 @@ using namespace UniSetTypes;
{ \ { \
uwarn << "(" << __STRING(fname) << "): " << ex.err << endl; \ uwarn << "(" << __STRING(fname) << "): " << ex.err << endl; \
} \ } \
catch( const Exception& ex ) \ catch( const UniSetTypes::Exception& ex ) \
{ \ { \
uwarn << "(" << __STRING(fname) << "): " << ex << endl; \ uwarn << "(" << __STRING(fname) << "): " << ex << endl; \
} \ } \
......
...@@ -87,8 +87,8 @@ class LogServer: ...@@ -87,8 +87,8 @@ class LogServer:
{ {
public: public:
LogServer( std::shared_ptr<DebugStream> log ) noexcept; LogServer( std::shared_ptr<DebugStream> log );
LogServer( std::shared_ptr<LogAgregator> log ) noexcept; LogServer( std::shared_ptr<LogAgregator> log );
virtual ~LogServer() noexcept; virtual ~LogServer() noexcept;
inline void setCmdTimeout( timeout_t msec ) noexcept inline void setCmdTimeout( timeout_t msec ) noexcept
...@@ -122,7 +122,7 @@ class LogServer: ...@@ -122,7 +122,7 @@ class LogServer:
std::string getShortInfo(); std::string getShortInfo();
protected: protected:
LogServer() noexcept; LogServer();
virtual void evprepare( const ev::loop_ref& loop ) override; virtual void evprepare( const ev::loop_ref& loop ) override;
virtual void evfinish( const ev::loop_ref& loop ) override; virtual void evfinish( const ev::loop_ref& loop ) override;
...@@ -138,15 +138,16 @@ class LogServer: ...@@ -138,15 +138,16 @@ class LogServer:
std::string onCommand( LogSession* s, LogServerTypes::Command cmd, const std::string& logname ); std::string onCommand( LogSession* s, LogServerTypes::Command cmd, const std::string& logname );
private: private:
typedef std::vector< std::shared_ptr<LogSession> > SessionList;
SessionList slist;
UniSetTypes::uniset_rwmutex mutSList;
timeout_t timeout = { UniSetTimer::WaitUpTime }; timeout_t timeout = { UniSetTimer::WaitUpTime };
timeout_t cmdTimeout = { 2000 }; timeout_t cmdTimeout = { 2000 };
Debug::type sessLogLevel = { Debug::NONE }; Debug::type sessLogLevel = { Debug::NONE };
size_t sessMaxCount = { 10 }; size_t sessMaxCount = { 10 };
typedef std::vector< std::shared_ptr<LogSession> > SessionList;
SessionList slist;
UniSetTypes::uniset_rwmutex mutSList;
DebugStream mylog; DebugStream mylog;
ev::io io; ev::io io;
......
...@@ -180,8 +180,6 @@ class NCRestorer_XML: ...@@ -180,8 +180,6 @@ class NCRestorer_XML:
std::string s_filterField; std::string s_filterField;
std::string s_filterValue; std::string s_filterValue;
std::string c_filterField;
std::string c_filterValue;
std::string t_filterField; std::string t_filterField;
std::string t_filterValue; std::string t_filterValue;
......
...@@ -178,7 +178,7 @@ class ModbusClient ...@@ -178,7 +178,7 @@ class ModbusClient
/*! функция запрос-ответ */ /*! функция запрос-ответ */
virtual ModbusRTU::mbErrCode query( ModbusRTU::ModbusAddr addr, ModbusRTU::ModbusMessage& msg, virtual ModbusRTU::mbErrCode query( ModbusRTU::ModbusAddr addr, ModbusRTU::ModbusMessage& msg,
ModbusRTU::ModbusMessage& reply, timeout_t timeout ) = 0; ModbusRTU::ModbusMessage& qreply, timeout_t timeout ) = 0;
// ------------------------------------- // -------------------------------------
/*! посылка запроса */ /*! посылка запроса */
...@@ -191,11 +191,6 @@ class ModbusClient ...@@ -191,11 +191,6 @@ class ModbusClient
virtual ModbusRTU::mbErrCode recv_pdu( ModbusRTU::ModbusByte qfunc, virtual ModbusRTU::mbErrCode recv_pdu( ModbusRTU::ModbusByte qfunc,
ModbusRTU::ModbusMessage& rbuf, timeout_t timeout ); ModbusRTU::ModbusMessage& rbuf, timeout_t timeout );
ModbusRTU::ModbusMessage reply; /*!< буфер для приёма сообщений */
ModbusRTU::ModbusMessage qbuf; /*!< буфер для посылки сообщений */
timeout_t replyTimeOut_ms; /*!< таймаут на ожидание ответа */ timeout_t replyTimeOut_ms; /*!< таймаут на ожидание ответа */
timeout_t aftersend_msec; /*!< пауза после посылки запроса */ timeout_t aftersend_msec; /*!< пауза после посылки запроса */
timeout_t sleepPause_usec; /*!< пауза между попытками чтения символа из канала */ timeout_t sleepPause_usec; /*!< пауза между попытками чтения символа из канала */
...@@ -209,6 +204,9 @@ class ModbusClient ...@@ -209,6 +204,9 @@ class ModbusClient
PassiveTimer tmProcessing; PassiveTimer tmProcessing;
private: private:
ModbusRTU::ModbusMessage qreply; /*!< буфер для приёма сообщений */
ModbusRTU::ModbusMessage qbuf; /*!< буфер для посылки сообщений */
}; };
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
#endif // ModbusClient_H_ #endif // ModbusClient_H_
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
using namespace std; using namespace std;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static UInterface* ui = 0; static UInterface* uInterface = 0;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void pyUInterface::uniset_init_params( UTypes::Params* p, const std::string& xmlfile )throw(UException) void pyUInterface::uniset_init_params( UTypes::Params* p, const std::string& xmlfile )throw(UException)
{ {
...@@ -37,7 +37,7 @@ void pyUInterface::uniset_init( int argc, char* argv[], const std::string& xmlfi ...@@ -37,7 +37,7 @@ void pyUInterface::uniset_init( int argc, char* argv[], const std::string& xmlfi
try try
{ {
UniSetTypes::uniset_init(argc, argv, xmlfile); UniSetTypes::uniset_init(argc, argv, xmlfile);
ui = new UInterface(); uInterface = new UInterface();
return; return;
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
...@@ -54,7 +54,7 @@ long pyUInterface::getValue( long id )throw(UException) ...@@ -54,7 +54,7 @@ long pyUInterface::getValue( long id )throw(UException)
{ {
auto conf = UniSetTypes::uniset_conf(); auto conf = UniSetTypes::uniset_conf();
if( !conf || !ui ) if( !conf || !uInterface )
throw USysError(); throw USysError();
UniversalIO::IOType t = conf->getIOType(id); UniversalIO::IOType t = conf->getIOType(id);
...@@ -67,7 +67,7 @@ long pyUInterface::getValue( long id )throw(UException) ...@@ -67,7 +67,7 @@ long pyUInterface::getValue( long id )throw(UException)
case UniversalIO::DO: case UniversalIO::DO:
case UniversalIO::AI: case UniversalIO::AI:
case UniversalIO::AO: case UniversalIO::AO:
return ui->getValue(id); return uInterface->getValue(id);
break; break;
default: default:
...@@ -96,7 +96,7 @@ void pyUInterface::setValue( long id, long val, long supplier )throw(UException) ...@@ -96,7 +96,7 @@ void pyUInterface::setValue( long id, long val, long supplier )throw(UException)
{ {
auto conf = UniSetTypes::uniset_conf(); auto conf = UniSetTypes::uniset_conf();
if( !conf || !ui ) if( !conf || !uInterface )
throw USysError(); throw USysError();
UniversalIO::IOType t = conf->getIOType(id); UniversalIO::IOType t = conf->getIOType(id);
...@@ -109,7 +109,7 @@ void pyUInterface::setValue( long id, long val, long supplier )throw(UException) ...@@ -109,7 +109,7 @@ void pyUInterface::setValue( long id, long val, long supplier )throw(UException)
case UniversalIO::DO: case UniversalIO::DO:
case UniversalIO::AI: case UniversalIO::AI:
case UniversalIO::AO: case UniversalIO::AO:
ui->setValue(id, val, supplier); uInterface->setValue(id, val, supplier);
break; break;
default: default:
......
...@@ -60,10 +60,10 @@ throw(ModbusRTU::mbException) ...@@ -60,10 +60,10 @@ throw(ModbusRTU::mbException)
{ {
ReadCoilMessage msg(addr, start, count); ReadCoilMessage msg(addr, start, count);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return ReadCoilRetMessage(reply); return ReadCoilRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -74,10 +74,10 @@ throw(ModbusRTU::mbException) ...@@ -74,10 +74,10 @@ throw(ModbusRTU::mbException)
{ {
ReadInputStatusMessage msg(addr, start, count); ReadInputStatusMessage msg(addr, start, count);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return ReadInputStatusRetMessage(reply); return ReadInputStatusRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -90,10 +90,10 @@ throw(ModbusRTU::mbException) ...@@ -90,10 +90,10 @@ throw(ModbusRTU::mbException)
ReadOutputMessage msg(addr, start, count); ReadOutputMessage msg(addr, start, count);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return ReadOutputRetMessage(reply); return ReadOutputRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -104,10 +104,10 @@ throw(ModbusRTU::mbException) ...@@ -104,10 +104,10 @@ throw(ModbusRTU::mbException)
{ {
ReadInputMessage msg(addr, start, count); ReadInputMessage msg(addr, start, count);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return ReadInputRetMessage(reply); return ReadInputRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -119,10 +119,10 @@ throw(ModbusRTU::mbException) ...@@ -119,10 +119,10 @@ throw(ModbusRTU::mbException)
ForceSingleCoilMessage msg(addr, start, cmd); ForceSingleCoilMessage msg(addr, start, cmd);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return ForceSingleCoilRetMessage(reply); return ForceSingleCoilRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -135,10 +135,10 @@ throw(ModbusRTU::mbException) ...@@ -135,10 +135,10 @@ throw(ModbusRTU::mbException)
WriteSingleOutputMessage msg(addr, start, data); WriteSingleOutputMessage msg(addr, start, data);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return WriteSingleOutputRetMessage(reply); return WriteSingleOutputRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -147,10 +147,10 @@ ForceCoilsRetMessage ModbusClient::write0F( ForceCoilsMessage& msg ) ...@@ -147,10 +147,10 @@ ForceCoilsRetMessage ModbusClient::write0F( ForceCoilsMessage& msg )
throw(ModbusRTU::mbException) throw(ModbusRTU::mbException)
{ {
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(msg.addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(msg.addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return ForceCoilsRetMessage(reply); return ForceCoilsRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -160,10 +160,10 @@ WriteOutputRetMessage ModbusClient::write10( WriteOutputMessage& msg ) ...@@ -160,10 +160,10 @@ WriteOutputRetMessage ModbusClient::write10( WriteOutputMessage& msg )
throw(ModbusRTU::mbException) throw(ModbusRTU::mbException)
{ {
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(msg.addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(msg.addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return WriteOutputRetMessage(reply); return WriteOutputRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -175,10 +175,10 @@ throw(ModbusRTU::mbException) ...@@ -175,10 +175,10 @@ throw(ModbusRTU::mbException)
{ {
DiagnosticMessage msg(addr, subfunc, dat); DiagnosticMessage msg(addr, subfunc, dat);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(msg.addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(msg.addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return DiagnosticRetMessage(reply); return DiagnosticRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -190,10 +190,10 @@ throw(ModbusRTU::mbException) ...@@ -190,10 +190,10 @@ throw(ModbusRTU::mbException)
{ {
MEIMessageRDI msg(addr, devID, objID); MEIMessageRDI msg(addr, devID, objID);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(msg.addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(msg.addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return MEIMessageRetRDI(reply); return MEIMessageRetRDI(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -213,10 +213,10 @@ throw(ModbusRTU::mbException) ...@@ -213,10 +213,10 @@ throw(ModbusRTU::mbException)
msg.century = century; msg.century = century;
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(addr, qbuf, reply, replyTimeOut_ms); mbErrCode res = query(addr, qbuf, qreply, replyTimeOut_ms);
if( res == erNoError ) if( res == erNoError )
return SetDateTimeRetMessage(reply); return SetDateTimeRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
...@@ -320,10 +320,10 @@ throw(ModbusRTU::mbException) ...@@ -320,10 +320,10 @@ throw(ModbusRTU::mbException)
FileTransferMessage msg(addr, idFile, numpack); FileTransferMessage msg(addr, idFile, numpack);
qbuf = msg.transport_msg(); qbuf = msg.transport_msg();
mbErrCode res = query(addr, qbuf, reply, part_timeout_msec); mbErrCode res = query(addr, qbuf, qreply, part_timeout_msec);
if( res == erNoError ) if( res == erNoError )
return FileTransferRetMessage(reply); return FileTransferRetMessage(qreply);
throw mbException(res); throw mbException(res);
} }
......
...@@ -39,9 +39,6 @@ size_t ModbusTCPCore::readNextData(UTCPStream* tcp, ...@@ -39,9 +39,6 @@ size_t ModbusTCPCore::readNextData(UTCPStream* tcp,
char* buf = new char[max]; char* buf = new char[max];
if( buf == 0 )
return 0;
try try
{ {
ssize_t l = tcp->receiveBytes(buf, max); ssize_t l = tcp->receiveBytes(buf, max);
...@@ -114,10 +111,18 @@ size_t ModbusTCPCore::getNextData(UTCPStream* tcp, ...@@ -114,10 +111,18 @@ size_t ModbusTCPCore::getNextData(UTCPStream* tcp,
if( len <= 0 ) if( len <= 0 )
len = 7; len = 7;
size_t ret = ModbusTCPCore::readNextData(tcp, qrecv, len); try
{
size_t ret = ModbusTCPCore::readNextData(tcp, qrecv, len);
if( ret == 0 ) if( ret == 0 )
return 0; return 0;
}
catch( UniSetTypes::CommFailed& ex )
{
if( qrecv.empty() )
return 0;
}
} }
size_t i = 0; size_t i = 0;
...@@ -141,9 +146,6 @@ size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size ...@@ -141,9 +146,6 @@ size_t ModbusTCPCore::readDataFD( int fd, std::queue<unsigned char>& qrecv, size
char* buf = new char[max]; char* buf = new char[max];
if( buf == 0 )
return 0;
ssize_t l = 0; ssize_t l = 0;
size_t cnt = 0; size_t cnt = 0;
...@@ -209,10 +211,18 @@ size_t ModbusTCPCore::getDataFD( int fd, std::queue<unsigned char>& qrecv, ...@@ -209,10 +211,18 @@ size_t ModbusTCPCore::getDataFD( int fd, std::queue<unsigned char>& qrecv,
if( len == 0 ) if( len == 0 )
len = 7; len = 7;
size_t ret = ModbusTCPCore::readDataFD(fd, qrecv, len, attempts); try
{
size_t ret = ModbusTCPCore::readDataFD(fd, qrecv, len, attempts);
if( ret == 0 && qrecv.empty() ) if( ret == 0 && qrecv.empty() )
return 0; return 0;
}
catch( UniSetTypes::CommFailed& ex )
{
if( qrecv.empty() )
return 0;
}
} }
size_t i = 0; size_t i = 0;
......
...@@ -920,8 +920,8 @@ throw(ResolveNameError, UniSetTypes::TimeOut ) ...@@ -920,8 +920,8 @@ throw(ResolveNameError, UniSetTypes::TimeOut )
catch(const CosNaming::NamingContext::NotFound& nf) {} catch(const CosNaming::NamingContext::NotFound& nf) {}
catch(const CosNaming::NamingContext::InvalidName& nf) {} catch(const CosNaming::NamingContext::InvalidName& nf) {}
catch(const CosNaming::NamingContext::CannotProceed& cp) {} catch(const CosNaming::NamingContext::CannotProceed& cp) {}
catch( const Exception ) {} catch( const UniSetTypes::Exception& ex ) {}
catch( const CORBA::OBJECT_NOT_EXIST ) catch( const CORBA::OBJECT_NOT_EXIST& ex )
{ {
throw UniSetTypes::ResolveNameError("ObjectNOTExist"); throw UniSetTypes::ResolveNameError("ObjectNOTExist");
} }
......
...@@ -59,8 +59,8 @@ static const int numErrorTags = sizeof(errorTags) / sizeof(error_item); ...@@ -59,8 +59,8 @@ static const int numErrorTags = sizeof(errorTags) / sizeof(error_item);
Debug::type const Debug::ANY = Debug::type( Debug::type const Debug::ANY = Debug::type(
Debug::INFO | Debug::INIT | Debug::WARN | Debug::CRIT | Debug::INFO | Debug::INIT | Debug::WARN | Debug::CRIT |
Debug::LEVEL1 | Debug::LEVEL2 | Debug::LEVEL3 | Debug::LEVEL4 | Debug::LEVEL1 | Debug::LEVEL2 | Debug::LEVEL3 | Debug::LEVEL4 |
Debug::LEVEL5 | Debug::LEVEL5 | Debug::LEVEL6 | Debug::LEVEL7 | Debug::LEVEL5 | Debug::LEVEL6 | Debug::LEVEL7 | Debug::LEVEL8 |
Debug::LEVEL8 | Debug::LEVEL9 | Debug::REPOSITORY | Debug::SYSTEM | Debug::LEVEL9 | Debug::REPOSITORY | Debug::SYSTEM |
Debug::EXCEPTION ); Debug::EXCEPTION );
...@@ -124,7 +124,11 @@ void Debug::showTags(ostream& os) noexcept ...@@ -124,7 +124,11 @@ void Debug::showTags(ostream& os) noexcept
<< setw(10) << errorTags[i].name << setw(10) << errorTags[i].name
<< " " << errorTags[i].desc << '\n'; << " " << errorTags[i].desc << '\n';
os.flush(); try
{
os.flush();
}
catch(...){}
} }
std::ostream& operator<<(std::ostream& os, Debug::type level ) noexcept std::ostream& operator<<(std::ostream& os, Debug::type level ) noexcept
...@@ -166,7 +170,13 @@ std::string Debug::str( Debug::type level ) noexcept ...@@ -166,7 +170,13 @@ std::string Debug::str( Debug::type level ) noexcept
} }
} }
return s.str(); try
{
return s.str();
}
catch(...){}
return "";
} }
......
...@@ -39,28 +39,28 @@ LogServer::~LogServer() noexcept ...@@ -39,28 +39,28 @@ LogServer::~LogServer() noexcept
catch(...){} catch(...){}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
LogServer::LogServer( std::shared_ptr<LogAgregator> log ) noexcept: LogServer::LogServer( std::shared_ptr<LogAgregator> log ):
LogServer(static_pointer_cast<DebugStream>(log)) LogServer()
{ {
elog = static_pointer_cast<DebugStream>(log);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
LogServer::LogServer( std::shared_ptr<DebugStream> log ) noexcept: LogServer::LogServer( std::shared_ptr<DebugStream> log ):
slist(sessMaxCount),
timeout(UniSetTimer::WaitUpTime), timeout(UniSetTimer::WaitUpTime),
cmdTimeout(2000), cmdTimeout(2000),
sessLogLevel(Debug::NONE), sessLogLevel(Debug::NONE),
slist(sessMaxCount),
sock(0), sock(0),
elog(log) elog(log)
{ {
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
LogServer::LogServer() noexcept: LogServer::LogServer():
slist(sessMaxCount),
timeout(UniSetTimer::WaitUpTime), timeout(UniSetTimer::WaitUpTime),
cmdTimeout(2000), cmdTimeout(2000),
sessLogLevel(Debug::NONE), sessLogLevel(Debug::NONE),
slist(sessMaxCount),
sock(0), sock(0),
elog(nullptr) elog(nullptr)
{ {
......
...@@ -32,8 +32,6 @@ using namespace UniSetTypes; ...@@ -32,8 +32,6 @@ using namespace UniSetTypes;
NCRestorer_XML::NCRestorer_XML( const string& fname ): NCRestorer_XML::NCRestorer_XML( const string& fname ):
s_filterField(""), s_filterField(""),
s_filterValue(""), s_filterValue(""),
c_filterField(""),
c_filterValue(""),
t_filterField(""), t_filterField(""),
t_filterValue(""), t_filterValue(""),
fname(fname), fname(fname),
...@@ -47,8 +45,6 @@ NCRestorer_XML::NCRestorer_XML(const string& fname, ...@@ -47,8 +45,6 @@ NCRestorer_XML::NCRestorer_XML(const string& fname,
const std::string& f_value): const std::string& f_value):
s_filterField(f_field), s_filterField(f_field),
s_filterValue(f_value), s_filterValue(f_value),
c_filterField(""),
c_filterValue(""),
t_filterField(""), t_filterField(""),
t_filterValue(""), t_filterValue(""),
fname(fname), fname(fname),
......
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