Commit e6b637c7 authored by Pavel Vainerman's avatar Pavel Vainerman

(travis-ci): added "compile matrix"

fix warning after clang and gcc compile
parent c1f75ad9
language: c++ language: cpp
# group: deprecated-2017Q4 env:
compiler: global:
# - clang # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
- gcc # via the "travis encrypt" command using the project repo's public key
- secure: "KrqAnUjd5+AjMOGnWvtyt0BF0BIkJMwJ0i/4X+VdI3sWYDy4rKZETh4uZLfgQmxBFHbQqCGLSdhM+Mbjt2LF/F5L1GqJELjXMYPxfiaXy2o1KJPZGYAn8Lm/FeTh2GPBkvHAOYrNpY758zKibZeTuIrr7fTiei8iRxELdtXRx/zNKyF3AacuqULrlziaQaUjJWaamwtbLuXWxJ2SsKq0cWNVwhp/SYLBvn4oZ5d6hWZWHav4mGo793nANKN4b6/0iLxOZVxBwdxE8o4bAgqs8Q+mTAeqJ19STCgq9unIMU8QvE5xu/PlR3Z1qJJRBTl3l8eiitW5y92DoJHj6AR3vit7YTTaXSD570CW+p5ZV9e+u/5s3nAZa5S1Qyk4mlEzDxDYv/3HoItC4Llqz3LqBhMHRf0i6ELBzOmsHRoWrG8ANSu5QhilepNbi73NQgp9mOoV7WtlfN/q1Vn3RCCWOb4ZIXEQPhmI9yLbDHOigzKvr2Oe/WSN5aitFBb49alaWzLsObuSVsPOnKfCBKQqqmai7O8asCIWA+FhSeKev7LKgKicK+dGF/Rwdp309MPghBXCiN5uH1AN4D350hIyvOHhC2ZrWgHqXPOjaRwo+J26oX9SFahOopZ/dfLxGyf1R3uX2Ao2AIm2gN0VSTuh41obocVE1pV8SOgF0olzRU8="
# - MAKEFLAGS="-j 2"
branches:
only:
- master
cache: cache:
apt: true apt: true
matrix:
include:
- os: linux
# dist: precise
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8']
env:
- MATRIX_EVAL="CXX=g++-4.8 CC=gcc-4.8"
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9']
env:
- MATRIX_EVAL="CXX=g++-4.9 CC=gcc-4.9"
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5']
env:
- MATRIX_EVAL="CXX=g++-5 CC=gcc-5"
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6']
env:
- MATRIX_EVAL="CXX=g++-6 CC=gcc-6"
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-7']
env:
- MATRIX_EVAL="CXX=g++-7 CC=gcc-7"
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-8']
env:
- MATRIX_EVAL="CXX=g++-8 CC=gcc-8"
- os: linux
compiler: clang
addons:
apt:
sources: ['llvm-toolchain-trusty-5.0']
packages: ['clang-5.0']
env:
- MATRIX_EVAL="CXX=clang++-5.0 CC=clang-5.0 COMPILER_NAME=clang"
- os: linux
compiler: clang
addons:
apt:
sources: ['llvm-toolchain-trusty-6.0', 'ubuntu-toolchain-r-test']
packages: ['clang-6.0']
env:
- MATRIX_EVAL="CXX=clang++-6.0 CC=clang-6.0 COMPILER_NAME=clang"
- os: linux
compiler: clang
addons:
apt:
sources: ['llvm-toolchain-trusty-7', 'ubuntu-toolchain-r-test']
packages: ['clang-7']
env:
- MATRIX_EVAL="CXX=clang++-7 CC=clang-7 COMPILER_NAME=clang"
# Disallowing packages: libcomedi-dev, libpoco-dev, libomniorb4-dev, libpqxx-dev, libev-dev # Disallowing packages: libcomedi-dev, libpoco-dev, libomniorb4-dev, libpqxx-dev, libev-dev
# If you require these packages, please review the package approval process at: https://github.com/travis-ci/apt-package-whitelist#package-approval-process # If you require these packages, please review the package approval process at: https://github.com/travis-ci/apt-package-whitelist#package-approval-process
#sudo: false #sudo: false
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "KrqAnUjd5+AjMOGnWvtyt0BF0BIkJMwJ0i/4X+VdI3sWYDy4rKZETh4uZLfgQmxBFHbQqCGLSdhM+Mbjt2LF/F5L1GqJELjXMYPxfiaXy2o1KJPZGYAn8Lm/FeTh2GPBkvHAOYrNpY758zKibZeTuIrr7fTiei8iRxELdtXRx/zNKyF3AacuqULrlziaQaUjJWaamwtbLuXWxJ2SsKq0cWNVwhp/SYLBvn4oZ5d6hWZWHav4mGo793nANKN4b6/0iLxOZVxBwdxE8o4bAgqs8Q+mTAeqJ19STCgq9unIMU8QvE5xu/PlR3Z1qJJRBTl3l8eiitW5y92DoJHj6AR3vit7YTTaXSD570CW+p5ZV9e+u/5s3nAZa5S1Qyk4mlEzDxDYv/3HoItC4Llqz3LqBhMHRf0i6ELBzOmsHRoWrG8ANSu5QhilepNbi73NQgp9mOoV7WtlfN/q1Vn3RCCWOb4ZIXEQPhmI9yLbDHOigzKvr2Oe/WSN5aitFBb49alaWzLsObuSVsPOnKfCBKQqqmai7O8asCIWA+FhSeKev7LKgKicK+dGF/Rwdp309MPghBXCiN5uH1AN4D350hIyvOHhC2ZrWgHqXPOjaRwo+J26oX9SFahOopZ/dfLxGyf1R3uX2Ao2AIm2gN0VSTuh41obocVE1pV8SOgF0olzRU8="
before_install: before_install:
- eval "${MATRIX_EVAL}"
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get -qq update - sudo apt-get -qq update
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8 libstdc++-4.8-dev; fi
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
install: install:
# have no catch package # have no catch package
...@@ -35,15 +118,20 @@ install: ...@@ -35,15 +118,20 @@ install:
before_script: before_script:
- export CXXFLAGS='-pipe -O2 -pedantic -Wall' - export CXXFLAGS='-pipe -O2 -pedantic -Wall'
- if [ "${COMPILER_NAME}" == "clang" ]; then export BUILD_TESTS="--disable-tests"; else export BUILD_TESTS="--enable-tests"; fi
# due broken comedi # due broken comedi
- export CXXFLAGS="$CXXFLAGS -Wl,--unresolved-symbols=ignore-in-shared-libs" - export CXXFLAGS="$CXXFLAGS -Wl,--unresolved-symbols=ignore-in-shared-libs"
- autoreconf -fiv - autoreconf -fiv
- ./configure --enable-tests --enable-mysql --enable-sqlite --enable-rrd --enable-io --disable-python --disable-mqtt --disable-pgsql --disable-api --disable-pkgchecklibev --disable-netdata --disable-logdb - ./configure $BUILD_TESTS --enable-mysql --enable-sqlite --enable-rrd --enable-io --disable-python --disable-mqtt --disable-pgsql --disable-api --disable-netdata --disable-logdb
script: script:
- if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make ; fi - if [ "${COVERITY_SCAN_BRANCH}" != "1" ]; then make ; fi
#- if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make check ; fi #- if [ ${COVERITY_SCAN_BRANCH} != 1 ]; then make check ; fi
notifications:
email:
recipients:
- pv@etersoft.ru
addons: addons:
# apt: # apt:
......
...@@ -563,7 +563,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository ...@@ -563,7 +563,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
} }
} }
} }
catch( ORepFailed ) catch( const ORepFailed& ex )
{ {
if( !quiet ) if( !quiet )
cerr << "..ORepFailed.." << endl; cerr << "..ORepFailed.." << endl;
...@@ -972,7 +972,7 @@ int logRotate( const string& arg, UInterface& ui ) ...@@ -972,7 +972,7 @@ int logRotate( const string& arg, UInterface& ui )
} }
TransportMessage tm( std::move(SystemMessage(SystemMessage::LogRotate).transport_msg()) ); TransportMessage tm( SystemMessage(SystemMessage::LogRotate).transport_msg() );
ui.send(id, tm); ui.send(id, tm);
if( verb ) if( verb )
...@@ -1013,7 +1013,7 @@ int configure( const string& arg, UInterface& ui ) ...@@ -1013,7 +1013,7 @@ int configure( const string& arg, UInterface& ui )
return 1; return 1;
} }
TransportMessage tm( std::move( SystemMessage(SystemMessage::ReConfiguration).transport_msg() )); TransportMessage tm( SystemMessage(SystemMessage::ReConfiguration).transport_msg() );
ui.send(id, tm); ui.send(id, tm);
if( verb ) if( verb )
......
...@@ -671,7 +671,7 @@ int main( int argc, char** argv ) ...@@ -671,7 +671,7 @@ int main( int argc, char** argv )
ModbusRTU::ModbusAddr a = ModbusHelpers::autodetectSlave(&mb, beg, end, reg, fn); ModbusRTU::ModbusAddr a = ModbusHelpers::autodetectSlave(&mb, beg, end, reg, fn);
cout << "autodetect modbus slave: " << ModbusRTU::addr2str(a) << endl; cout << "autodetect modbus slave: " << ModbusRTU::addr2str(a) << endl;
} }
catch( uniset::TimeOut ) catch( const uniset::TimeOut& ex )
{ {
cout << "slave not autodetect..." << endl; cout << "slave not autodetect..." << endl;
} }
...@@ -695,7 +695,7 @@ int main( int argc, char** argv ) ...@@ -695,7 +695,7 @@ int main( int argc, char** argv )
cout << "autodetect: slaveaddr=" << ModbusRTU::addr2str(slaveaddr) cout << "autodetect: slaveaddr=" << ModbusRTU::addr2str(slaveaddr)
<< " speed=" << ComPort::getSpeed(s) << endl; << " speed=" << ComPort::getSpeed(s) << endl;
} }
catch( uniset::TimeOut ) catch( const uniset::TimeOut& ex )
{ {
cout << "speed not autodetect for slaveaddr=" cout << "speed not autodetect for slaveaddr="
<< ModbusRTU::addr2str(slaveaddr) << endl; << ModbusRTU::addr2str(slaveaddr) << endl;
......
...@@ -274,10 +274,10 @@ ...@@ -274,10 +274,10 @@
<xsl:template name="COMMON-HEAD-PROTECTED"> <xsl:template name="COMMON-HEAD-PROTECTED">
virtual void callback() noexcept override; virtual void callback() noexcept override;
virtual void processingMessage( const uniset::VoidMessage* msg ) override; virtual void processingMessage( const uniset::VoidMessage* msg ) override;
virtual void sysCommand( const uniset::SystemMessage* sm ){}; virtual void sysCommand( const uniset::SystemMessage* sm ) override {}
virtual void askSensors( UniversalIO::UIOCommand cmd ){} virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const uniset::SensorMessage* sm ) override{} virtual void sensorInfo( const uniset::SensorMessage* sm ) override {}
virtual void timerInfo( const uniset::TimerMessage* tm ) override{} virtual void timerInfo( const uniset::TimerMessage* tm ) override {}
virtual bool activateObject() override; virtual bool activateObject() override;
virtual bool deactivateObject() override; virtual bool deactivateObject() override;
virtual std::string getMonitInfo() const { return ""; } /*!&lt; пользовательская информация выводимая в getInfo() */ virtual std::string getMonitInfo() const { return ""; } /*!&lt; пользовательская информация выводимая в getInfo() */
......
...@@ -55,9 +55,9 @@ namespace uniset ...@@ -55,9 +55,9 @@ namespace uniset
protected: protected:
PassiveLProcessor(): shm(0), maxHeartBeat(0) {}; PassiveLProcessor(): shm(0), maxHeartBeat(0) {};
virtual void step(); virtual void step() override;
virtual void getInputs(); virtual void getInputs() override;
virtual void setOuts(); virtual void setOuts() override;
void sysCommand( const uniset::SystemMessage* msg ) override; void sysCommand( const uniset::SystemMessage* msg ) override;
void sensorInfo( const uniset::SensorMessage* sm ) override; void sensorInfo( const uniset::SensorMessage* sm ) override;
......
...@@ -963,7 +963,7 @@ namespace uniset ...@@ -963,7 +963,7 @@ namespace uniset
{ {
mblog3 << myname << "(initSMValue):(IOBadParam) " << ex.err << endl; mblog3 << myname << "(initSMValue):(IOBadParam) " << ex.err << endl;
} }
catch(IONotifyController_i::BadRange ) catch(IONotifyController_i::BadRange& ex )
{ {
mblog3 << myname << "(initSMValue): (BadRange)..." << endl; mblog3 << myname << "(initSMValue): (BadRange)..." << endl;
} }
...@@ -1223,7 +1223,7 @@ namespace uniset ...@@ -1223,7 +1223,7 @@ namespace uniset
{ {
mblog3 << myname << "(updateSM):(IOBadParam) " << ex.err << endl; mblog3 << myname << "(updateSM):(IOBadParam) " << ex.err << endl;
} }
catch( IONotifyController_i::BadRange ) catch( IONotifyController_i::BadRange& ex )
{ {
mblog3 << myname << "(updateSM): (BadRange)..." << endl; mblog3 << myname << "(updateSM): (BadRange)..." << endl;
} }
...@@ -1261,7 +1261,7 @@ namespace uniset ...@@ -1261,7 +1261,7 @@ namespace uniset
{ {
mblog3 << myname << "(updateSM):(IOBadParam) " << ex.err << endl; mblog3 << myname << "(updateSM):(IOBadParam) " << ex.err << endl;
} }
catch( IONotifyController_i::BadRange ) catch( IONotifyController_i::BadRange& ex )
{ {
mblog3 << myname << "(updateSM): (BadRange)..." << endl; mblog3 << myname << "(updateSM): (BadRange)..." << endl;
} }
...@@ -1309,7 +1309,7 @@ namespace uniset ...@@ -1309,7 +1309,7 @@ namespace uniset
{ {
mblog3 << myname << "(updateSM):(IOBadParam) " << ex.err << endl; mblog3 << myname << "(updateSM):(IOBadParam) " << ex.err << endl;
} }
catch(IONotifyController_i::BadRange ) catch(IONotifyController_i::BadRange& ex )
{ {
mblog3 << myname << "(updateSM): (BadRange)..." << endl; mblog3 << myname << "(updateSM): (BadRange)..." << endl;
} }
...@@ -1774,7 +1774,7 @@ namespace uniset ...@@ -1774,7 +1774,7 @@ namespace uniset
{ {
mblog3 << myname << "(updateRSProperty):(IOBadParam) " << ex.err << endl; mblog3 << myname << "(updateRSProperty):(IOBadParam) " << ex.err << endl;
} }
catch(IONotifyController_i::BadRange ) catch(IONotifyController_i::BadRange& ex )
{ {
mblog3 << myname << "(updateRSProperty): (BadRange)..." << endl; mblog3 << myname << "(updateRSProperty): (BadRange)..." << endl;
} }
...@@ -2114,7 +2114,7 @@ namespace uniset ...@@ -2114,7 +2114,7 @@ namespace uniset
{ {
mblog3 << myname << "(updateMTR):(IOBadParam) " << ex.err << endl; mblog3 << myname << "(updateMTR):(IOBadParam) " << ex.err << endl;
} }
catch(IONotifyController_i::BadRange ) catch(IONotifyController_i::BadRange& ex )
{ {
mblog3 << myname << "(updateMTR): (BadRange)..." << endl; mblog3 << myname << "(updateMTR): (BadRange)..." << endl;
} }
...@@ -2181,7 +2181,7 @@ namespace uniset ...@@ -2181,7 +2181,7 @@ namespace uniset
{ {
mblog3 << myname << "(updateRTU188):(IOBadParam) " << ex.err << endl; mblog3 << myname << "(updateRTU188):(IOBadParam) " << ex.err << endl;
} }
catch(IONotifyController_i::BadRange ) catch(IONotifyController_i::BadRange& ex )
{ {
mblog3 << myname << "(updateRTU188): (BadRange)..." << endl; mblog3 << myname << "(updateRTU188): (BadRange)..." << endl;
} }
...@@ -3372,7 +3372,7 @@ namespace uniset ...@@ -3372,7 +3372,7 @@ namespace uniset
{ {
ostringstream s; ostringstream s;
s << "number of calls is " << poll_count << " (poll time: " << stat_time << " sec)"; s << "number of calls is " << poll_count << " (poll time: " << stat_time << " sec)";
statInfo = std::move(s.str()); statInfo = s.str();
mblog9 << myname << "(stat): " << statInfo << endl; mblog9 << myname << "(stat): " << statInfo << endl;
ptStatistic.reset(); ptStatistic.reset();
poll_count = 0; poll_count = 0;
......
...@@ -361,7 +361,7 @@ int main( int argc, char** argv ) ...@@ -361,7 +361,7 @@ int main( int argc, char** argv )
ModbusRTU::ModbusAddr a = ModbusHelpers::autodetectSlave(mb, beg, end, reg, fn); ModbusRTU::ModbusAddr a = ModbusHelpers::autodetectSlave(mb, beg, end, reg, fn);
cout << "(mtr-setup): autodetect modbus slave: " << ModbusRTU::addr2str(a) << endl; cout << "(mtr-setup): autodetect modbus slave: " << ModbusRTU::addr2str(a) << endl;
} }
catch( uniset::TimeOut ) catch( const uniset::TimeOut& ex )
{ {
cout << "(mtr-setup): slave not autodetect..." << endl; cout << "(mtr-setup): slave not autodetect..." << endl;
} }
...@@ -393,7 +393,7 @@ int main( int argc, char** argv ) ...@@ -393,7 +393,7 @@ int main( int argc, char** argv )
cout << "(mtr-setup): autodetect: slaveaddr=" << ModbusRTU::addr2str(slaveaddr) cout << "(mtr-setup): autodetect: slaveaddr=" << ModbusRTU::addr2str(slaveaddr)
<< " speed=" << ComPort::getSpeed(s) << endl; << " speed=" << ComPort::getSpeed(s) << endl;
} }
catch( uniset::TimeOut ) catch( const uniset::TimeOut& ex )
{ {
cout << "(mtr-setup): speed not autodetect for slaveaddr=" cout << "(mtr-setup): speed not autodetect for slaveaddr="
<< ModbusRTU::addr2str(slaveaddr) << endl; << ModbusRTU::addr2str(slaveaddr) << endl;
......
...@@ -599,7 +599,7 @@ namespace uniset ...@@ -599,7 +599,7 @@ namespace uniset
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SharedMemory::sendEvent( uniset::SystemMessage& sm ) void SharedMemory::sendEvent( uniset::SystemMessage& sm )
{ {
TransportMessage tm( std::move(sm.transport_msg()) ); TransportMessage tm( sm.transport_msg() );
for( const auto& it : elst ) for( const auto& it : elst )
{ {
......
...@@ -294,7 +294,7 @@ namespace uniset ...@@ -294,7 +294,7 @@ namespace uniset
// если нет данных(?) просто возвращаем номер пакета // если нет данных(?) просто возвращаем номер пакета
return num; return num;
} }
// -----------------------------------------------------------------------------
size_t UniSetUDP::UDPMessage::sizeOf() const noexcept size_t UniSetUDP::UDPMessage::sizeOf() const noexcept
{ {
// биты которые не уместились в очередной байт, добавляют ещё один байт // биты которые не уместились в очередной байт, добавляют ещё один байт
......
...@@ -63,10 +63,11 @@ namespace uniset ...@@ -63,10 +63,11 @@ namespace uniset
size_t dcount; /*!< количество булевых величин */ size_t dcount; /*!< количество булевых величин */
size_t acount; /*!< количество аналоговых величин */ size_t acount; /*!< количество аналоговых величин */
friend std::ostream& operator<<( std::ostream& os, UDPHeader& p );
friend std::ostream& operator<<( std::ostream& os, UDPHeader* p );
} __attribute__((packed)); } __attribute__((packed));
std::ostream& operator<<( std::ostream& os, UDPHeader& p );
std::ostream& operator<<( std::ostream& os, UDPHeader* p );
const size_t MaxPacketNum = std::numeric_limits<size_t>::max(); const size_t MaxPacketNum = std::numeric_limits<size_t>::max();
struct UDPAData struct UDPAData
...@@ -77,9 +78,9 @@ namespace uniset ...@@ -77,9 +78,9 @@ namespace uniset
long id; long id;
long val; long val;
friend std::ostream& operator<<( std::ostream& os, UDPAData& p );
} __attribute__((packed)); } __attribute__((packed));
std::ostream& operator<<( std::ostream& os, UDPAData& p );
// Теоретический размер данных в UDP пакете (исключая заголовки) 65507 // Теоретический размер данных в UDP пакете (исключая заголовки) 65507
// Фактически желательно не вылезать за размер MTU (обычно 1500) - заголовки = 1432 байта // Фактически желательно не вылезать за размер MTU (обычно 1500) - заголовки = 1432 байта
...@@ -178,10 +179,10 @@ namespace uniset ...@@ -178,10 +179,10 @@ namespace uniset
UDPAData a_dat[MaxACount]; /*!< аналоговые величины */ UDPAData a_dat[MaxACount]; /*!< аналоговые величины */
long d_id[MaxDCount]; /*!< список дискретных ID */ long d_id[MaxDCount]; /*!< список дискретных ID */
uint8_t d_dat[MaxDDataCount]; /*!< битовые значения */ uint8_t d_dat[MaxDDataCount]; /*!< битовые значения */
friend std::ostream& operator<<( std::ostream& os, UDPMessage& p );
}; };
std::ostream& operator<<( std::ostream& os, UDPMessage& p );
uint16_t makeCRC( unsigned char* buf, size_t len ) noexcept; uint16_t makeCRC( unsigned char* buf, size_t len ) noexcept;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -387,7 +387,7 @@ void UNetReceiver::update() noexcept ...@@ -387,7 +387,7 @@ void UNetReceiver::update() noexcept
return; return;
p = qpack.top(); p = qpack.top();
size_t sub = labs(p.num - pnum); size_t sub = labs( (long int)(p.num - pnum) );
if( pnum > 0 ) if( pnum > 0 )
{ {
...@@ -762,7 +762,7 @@ bool UNetReceiver::receive() noexcept ...@@ -762,7 +762,7 @@ bool UNetReceiver::receive() noexcept
return false; return false;
} }
if( rnum > 0 && labs(pack.num - rnum) > maxDifferens ) if( rnum > 0 && labs( (long int)(pack.num - rnum) ) > maxDifferens )
{ {
/* А что делать если мы уже ждём и ещё не "разгребли предыдущее".. а тут уже повторный "разрыв" /* А что делать если мы уже ждём и ещё не "разгребли предыдущее".. а тут уже повторный "разрыв"
* Можно откинуть всё.. что сложили во временную очередь и заново "копить" (но тогда теряем информацию) * Можно откинуть всё.. что сложили во временную очередь и заново "копить" (но тогда теряем информацию)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2018-05-18+03:00 // generate timestamp: 2018-10-16+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef UObject_SK_H_ #ifndef UObject_SK_H_
#define UObject_SK_H_ #define UObject_SK_H_
...@@ -29,7 +29,7 @@ class UObject_SK: ...@@ -29,7 +29,7 @@ class UObject_SK:
public uniset::UniSetObject public uniset::UniSetObject
{ {
public: public:
UObject_SK( uniset::ObjectId id, xmlNode* node = uniset::uniset_conf()->getNode("UObject"), const std::string& argprefix = "" ); UObject_SK( uniset::ObjectId id, xmlNode* node=uniset::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
UObject_SK(); UObject_SK();
virtual ~UObject_SK(); virtual ~UObject_SK();
...@@ -43,60 +43,54 @@ class UObject_SK: ...@@ -43,60 +43,54 @@ class UObject_SK:
virtual bool setMsg( uniset::ObjectId code, bool state = true ) noexcept; virtual bool setMsg( uniset::ObjectId code, bool state = true ) noexcept;
inline std::shared_ptr<DebugStream> log() noexcept inline std::shared_ptr<DebugStream> log() noexcept { return mylog; }
{ inline std::shared_ptr<uniset::LogAgregator> logAgregator() noexcept { return loga; }
return mylog;
}
inline std::shared_ptr<uniset::LogAgregator> logAgregator() noexcept
{
return loga;
}
void init_dlog( std::shared_ptr<DebugStream> d ) noexcept; void init_dlog( std::shared_ptr<DebugStream> d ) noexcept;
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef myinfo #ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info() #define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif #endif
#ifndef mywarn #ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn() #define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif #endif
#ifndef mycrit #ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit() #define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif #endif
#ifndef mylog1 #ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1() #define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif #endif
#ifndef mylog2 #ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2() #define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif #endif
#ifndef mylog3 #ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3() #define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif #endif
#ifndef mylog4 #ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4() #define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif #endif
#ifndef mylog5 #ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5() #define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif #endif
#ifndef mylog6 #ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6() #define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif #endif
#ifndef mylog7 #ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7() #define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif #endif
#ifndef mylog8 #ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8() #define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif #endif
#ifndef mylog9 #ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9() #define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif #endif
#ifndef mylogany #ifndef mylogany
#define mylogany log()->any() #define mylogany log()->any()
#endif #endif
#ifndef vmonit #ifndef vmonit
#define vmonit( var ) vmon.add( #var, var ) #define vmonit( var ) vmon.add( #var, var )
#endif #endif
// Вспомогательные функции для удобства логирования // Вспомогательные функции для удобства логирования
// ------------------------------------------------------------ // ------------------------------------------------------------
...@@ -113,26 +107,23 @@ class UObject_SK: ...@@ -113,26 +107,23 @@ class UObject_SK:
\param id - идентификатор датчика \param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить \param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/ */
std::string str( uniset::ObjectId id, bool showLinkName = true ) const; std::string str( uniset::ObjectId id, bool showLinkName=true ) const;
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val /*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика \param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить \param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/ */
std::string strval( uniset::ObjectId id, bool showLinkName = true ) const; std::string strval( uniset::ObjectId id, bool showLinkName=true ) const;
/*! Вывод в строку названия датчика-сообщения: xxx(SensorName) /*! Вывод в строку названия датчика-сообщения: xxx(SensorName)
\param id - идентификатор датчика \param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить \param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/ */
std::string msgstr( uniset::ObjectId id, bool showLinkName = true ) const; std::string msgstr( uniset::ObjectId id, bool showLinkName=true ) const;
/*! Вывод состояния внутренних переменных */ /*! Вывод состояния внутренних переменных */
inline std::string dumpVars() inline std::string dumpVars(){ return vmon.pretty_str(); }
{
return vmon.pretty_str();
}
// ------------------------------------------------------------ // ------------------------------------------------------------
std::string help() const noexcept; std::string help() const noexcept;
...@@ -168,29 +159,23 @@ class UObject_SK: ...@@ -168,29 +159,23 @@ class UObject_SK:
virtual void callback() noexcept override; virtual void callback() noexcept override;
virtual void processingMessage( const uniset::VoidMessage* msg ) override; virtual void processingMessage( const uniset::VoidMessage* msg ) override;
virtual void sysCommand( const uniset::SystemMessage* sm ) {}; virtual void sysCommand( const uniset::SystemMessage* sm ) override {}
virtual void askSensors( UniversalIO::UIOCommand cmd ) {} virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const uniset::SensorMessage* sm ) override {} virtual void sensorInfo( const uniset::SensorMessage* sm ) override {}
virtual void timerInfo( const uniset::TimerMessage* tm ) override {} virtual void timerInfo( const uniset::TimerMessage* tm ) override {}
virtual bool activateObject() override; virtual bool activateObject() override;
virtual bool deactivateObject() override; virtual bool deactivateObject() override;
virtual std::string getMonitInfo() const virtual std::string getMonitInfo() const { return ""; } /*!< пользовательская информация выводимая в getInfo() */
{ virtual std::string getTypeOfMessage( int t ) const { return uniset::strTypeOfMessage(t); } /*!< получение названия типа сообщения. Используется в getInfo() */
return ""; /*!< пользовательская информация выводимая в getInfo() */
}
virtual std::string getTypeOfMessage( int t ) const
{
return uniset::strTypeOfMessage(t); /*!< получение названия типа сообщения. Используется в getInfo() */
}
#ifndef DISABLE_REST_API #ifndef DISABLE_REST_API
virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ) {} /*!< для пользовательских данных в httpGet() */ virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ){} /*!< для пользовательских данных в httpGet() */
virtual Poco::JSON::Object::Ptr httpDumpIO(); virtual Poco::JSON::Object::Ptr httpDumpIO();
virtual Poco::JSON::Object::Ptr httpRequestLog( const Poco::URI::QueryParameters& p ); virtual Poco::JSON::Object::Ptr httpRequestLog( const Poco::URI::QueryParameters& p );
#endif #endif
// Выполнение очередного шага программы // Выполнение очередного шага программы
virtual void step() {} virtual void step(){}
void preAskSensors( UniversalIO::UIOCommand cmd ); void preAskSensors( UniversalIO::UIOCommand cmd );
void preSysCommand( const uniset::SystemMessage* sm ); void preSysCommand( const uniset::SystemMessage* sm );
...@@ -219,15 +204,9 @@ class UObject_SK: ...@@ -219,15 +204,9 @@ class UObject_SK:
xmlNode* confnode; xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */ /*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) int getIntProp(const std::string& name) { return uniset::uniset_conf()->getIntProp(confnode, name); }
{
return uniset::uniset_conf()->getIntProp(confnode, name);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */ /*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name) inline const std::string getProp(const std::string& name) { return uniset::uniset_conf()->getProp(confnode, name); }
{
return uniset::uniset_conf()->getProp(confnode, name);
}
uniset::timeout_t smReadyTimeout; /*!< время ожидания готовности SM */ uniset::timeout_t smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated = { false }; std::atomic_bool activated = { false };
...@@ -279,10 +258,10 @@ class UObject_SK: ...@@ -279,10 +258,10 @@ class UObject_SK:
} }
}; };
std::unordered_map<const uniset::ObjectId, size_t, StatHashFn> smStat; /*!< количество сообщений по датчикам */ std::unordered_map<const uniset::ObjectId,size_t, StatHashFn> smStat; /*!< количество сообщений по датчикам */
size_t processingMessageCatchCount = { 0 }; /*!< количество исключений пойманных в processingMessage */ size_t processingMessageCatchCount = { 0 }; /*!< количество исключений пойманных в processingMessage */
std::unordered_map<long, size_t> msgTypeStat; /*!< количество сообщений по типам */ std::unordered_map<long,size_t> msgTypeStat; /*!< количество сообщений по типам */
std::string ostate = { "" }; /*!< состояние процесса (выводится в getInfo()) */ std::string ostate = { "" }; /*!< состояние процесса (выводится в getInfo()) */
......
...@@ -160,6 +160,7 @@ namespace uniset ...@@ -160,6 +160,7 @@ namespace uniset
F4( const float& f ) noexcept F4( const float& f ) noexcept
{ {
memset(raw.v, 0, sizeof(raw.v));
raw.val = f; raw.val = f;
} }
F4( const ModbusRTU::ModbusData* data, size_t size ) noexcept F4( const ModbusRTU::ModbusData* data, size_t size ) noexcept
......
...@@ -24,7 +24,7 @@ int main(int argc, const char** argv) ...@@ -24,7 +24,7 @@ int main(int argc, const char** argv)
act->run(true); act->run(true);
SensorMessage smsg(100, 2); SensorMessage smsg(100, 2);
TransportMessage tm( std::move(smsg.transport_msg()) ); TransportMessage tm( smsg.transport_msg() );
size_t num = 0; size_t num = 0;
const size_t max = 100000; const size_t max = 100000;
......
...@@ -24,7 +24,7 @@ class TestProc: ...@@ -24,7 +24,7 @@ class TestProc:
tmLogControl tmLogControl
}; };
virtual void step(); virtual void step() override;
virtual void sensorInfo( const uniset::SensorMessage* sm ) override; virtual void sensorInfo( const uniset::SensorMessage* sm ) override;
virtual void timerInfo( const uniset::TimerMessage* tm ) override; virtual void timerInfo( const uniset::TimerMessage* tm ) override;
virtual void sysCommand( const uniset::SystemMessage* sm ) override; virtual void sysCommand( const uniset::SystemMessage* sm ) override;
......
...@@ -237,7 +237,7 @@ namespace uniset ...@@ -237,7 +237,7 @@ namespace uniset
ai.ci.precision = 0; ai.ci.precision = 0;
} }
return std::move(ai); return ai;
}; };
//! сохранение информации об изменении состояния датчика //! сохранение информации об изменении состояния датчика
...@@ -411,19 +411,6 @@ namespace uniset ...@@ -411,19 +411,6 @@ namespace uniset
(invert == r.invert) ); (invert == r.invert) );
} }
operator IONotifyController_i::ThresholdInfo()
{
IONotifyController_i::ThresholdInfo r;
r.id = id;
r.hilimit = hilimit;
r.lowlimit = lowlimit;
r.invert = invert;
r.tv_sec = tv_sec;
r.tv_nsec = tv_nsec;
r.state = state;
return r;
}
UThresholdInfo( const UThresholdInfo& ) = delete; UThresholdInfo( const UThresholdInfo& ) = delete;
UThresholdInfo& operator=( const UThresholdInfo& ) = delete; UThresholdInfo& operator=( const UThresholdInfo& ) = delete;
UThresholdInfo( UThresholdInfo&& ) = default; UThresholdInfo( UThresholdInfo&& ) = default;
......
...@@ -93,7 +93,7 @@ namespace uniset ...@@ -93,7 +93,7 @@ namespace uniset
virtual bool removeObject( const std::shared_ptr<UniSetObject>& obj ); virtual bool removeObject( const std::shared_ptr<UniSetObject>& obj );
enum OManagerCommand { deactiv, activ, initial }; enum OManagerCommand { deactiv, activ, initial };
friend std::ostream& operator<<(std::ostream& os, uniset::UniSetManager::OManagerCommand& cmd ); friend std::ostream& operator<<( std::ostream& os, uniset::UniSetManager::OManagerCommand& cmd );
// работа со списком объектов // работа со списком объектов
void objects(OManagerCommand cmd); void objects(OManagerCommand cmd);
......
...@@ -24,60 +24,57 @@ namespace uniset ...@@ -24,60 +24,57 @@ namespace uniset
ModbusRTUSlaveSlot( const std::string& dev, bool use485 = false, bool tr_ctl = false ); ModbusRTUSlaveSlot( const std::string& dev, bool use485 = false, bool tr_ctl = false );
virtual ~ModbusRTUSlaveSlot(); virtual ~ModbusRTUSlaveSlot();
virtual void terminate(); virtual void terminate() override;
inline ComPort* getComPort() ComPort* getComPort();
{
return port;
}
protected: protected:
virtual ModbusRTU::mbErrCode readCoilStatus( ModbusRTU::ReadCoilMessage& query, virtual ModbusRTU::mbErrCode readCoilStatus( ModbusRTU::ReadCoilMessage& query,
ModbusRTU::ReadCoilRetMessage& reply ); ModbusRTU::ReadCoilRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readInputStatus( ModbusRTU::ReadInputStatusMessage& query, virtual ModbusRTU::mbErrCode readInputStatus( ModbusRTU::ReadInputStatusMessage& query,
ModbusRTU::ReadInputStatusRetMessage& reply ); ModbusRTU::ReadInputStatusRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readOutputRegisters( ModbusRTU::ReadOutputMessage& query, virtual ModbusRTU::mbErrCode readOutputRegisters( ModbusRTU::ReadOutputMessage& query,
ModbusRTU::ReadOutputRetMessage& reply ); ModbusRTU::ReadOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readInputRegisters( ModbusRTU::ReadInputMessage& query, virtual ModbusRTU::mbErrCode readInputRegisters( ModbusRTU::ReadInputMessage& query,
ModbusRTU::ReadInputRetMessage& reply ); ModbusRTU::ReadInputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode forceSingleCoil( ModbusRTU::ForceSingleCoilMessage& query, virtual ModbusRTU::mbErrCode forceSingleCoil( ModbusRTU::ForceSingleCoilMessage& query,
ModbusRTU::ForceSingleCoilRetMessage& reply ); ModbusRTU::ForceSingleCoilRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode writeOutputSingleRegister( ModbusRTU::WriteSingleOutputMessage& query, virtual ModbusRTU::mbErrCode writeOutputSingleRegister( ModbusRTU::WriteSingleOutputMessage& query,
ModbusRTU::WriteSingleOutputRetMessage& reply ); ModbusRTU::WriteSingleOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode forceMultipleCoils( ModbusRTU::ForceCoilsMessage& query, virtual ModbusRTU::mbErrCode forceMultipleCoils( ModbusRTU::ForceCoilsMessage& query,
ModbusRTU::ForceCoilsRetMessage& reply ); ModbusRTU::ForceCoilsRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode writeOutputRegisters( ModbusRTU::WriteOutputMessage& query, virtual ModbusRTU::mbErrCode writeOutputRegisters( ModbusRTU::WriteOutputMessage& query,
ModbusRTU::WriteOutputRetMessage& reply ); ModbusRTU::WriteOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode diagnostics( ModbusRTU::DiagnosticMessage& query, virtual ModbusRTU::mbErrCode diagnostics( ModbusRTU::DiagnosticMessage& query,
ModbusRTU::DiagnosticRetMessage& reply ); ModbusRTU::DiagnosticRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode read4314( ModbusRTU::MEIMessageRDI& query, virtual ModbusRTU::mbErrCode read4314( ModbusRTU::MEIMessageRDI& query,
ModbusRTU::MEIMessageRetRDI& reply ); ModbusRTU::MEIMessageRetRDI& reply ) override;
virtual ModbusRTU::mbErrCode journalCommand( ModbusRTU::JournalCommandMessage& query, virtual ModbusRTU::mbErrCode journalCommand( ModbusRTU::JournalCommandMessage& query,
ModbusRTU::JournalCommandRetMessage& reply ); ModbusRTU::JournalCommandRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode setDateTime( ModbusRTU::SetDateTimeMessage& query, virtual ModbusRTU::mbErrCode setDateTime( ModbusRTU::SetDateTimeMessage& query,
ModbusRTU::SetDateTimeRetMessage& reply ); ModbusRTU::SetDateTimeRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode remoteService( ModbusRTU::RemoteServiceMessage& query, virtual ModbusRTU::mbErrCode remoteService( ModbusRTU::RemoteServiceMessage& query,
ModbusRTU::RemoteServiceRetMessage& reply ); ModbusRTU::RemoteServiceRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode fileTransfer( ModbusRTU::FileTransferMessage& query, virtual ModbusRTU::mbErrCode fileTransfer( ModbusRTU::FileTransferMessage& query,
ModbusRTU::FileTransferRetMessage& reply ); ModbusRTU::FileTransferRetMessage& reply ) override;
private: private:
}; };
// ------------------------------------------------------------------------- // ---------------------------------------------------------------------
} // end of namespace uniset } // end of namespace uniset
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
#endif // ModbusRTUSlaveSlot_H_ #endif // ModbusRTUSlaveSlot_H_
......
...@@ -16,9 +16,8 @@ ...@@ -16,9 +16,8 @@
namespace std namespace std
{ {
template<> template<>
class hash<uniset::ModbusRTU::mbErrCode> struct hash<uniset::ModbusRTU::mbErrCode>
{ {
public:
size_t operator()(const uniset::ModbusRTU::mbErrCode& e) const size_t operator()(const uniset::ModbusRTU::mbErrCode& e) const
{ {
return std::hash<size_t>()(e); return std::hash<size_t>()(e);
......
...@@ -46,7 +46,7 @@ namespace uniset ...@@ -46,7 +46,7 @@ namespace uniset
bool async_run( const std::unordered_set<ModbusRTU::ModbusAddr>& vmbaddr ); bool async_run( const std::unordered_set<ModbusRTU::ModbusAddr>& vmbaddr );
/*! остановить поток выполнения (см. run или async_run) */ /*! остановить поток выполнения (см. run или async_run) */
virtual void terminate(); virtual void terminate() override;
virtual bool isActive() const override; virtual bool isActive() const override;
......
...@@ -23,46 +23,46 @@ namespace uniset ...@@ -23,46 +23,46 @@ namespace uniset
protected: protected:
virtual ModbusRTU::mbErrCode readCoilStatus( ModbusRTU::ReadCoilMessage& query, virtual ModbusRTU::mbErrCode readCoilStatus( ModbusRTU::ReadCoilMessage& query,
ModbusRTU::ReadCoilRetMessage& reply ); ModbusRTU::ReadCoilRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readInputStatus( ModbusRTU::ReadInputStatusMessage& query, virtual ModbusRTU::mbErrCode readInputStatus( ModbusRTU::ReadInputStatusMessage& query,
ModbusRTU::ReadInputStatusRetMessage& reply ); ModbusRTU::ReadInputStatusRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readOutputRegisters( ModbusRTU::ReadOutputMessage& query, virtual ModbusRTU::mbErrCode readOutputRegisters( ModbusRTU::ReadOutputMessage& query,
ModbusRTU::ReadOutputRetMessage& reply ); ModbusRTU::ReadOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readInputRegisters( ModbusRTU::ReadInputMessage& query, virtual ModbusRTU::mbErrCode readInputRegisters( ModbusRTU::ReadInputMessage& query,
ModbusRTU::ReadInputRetMessage& reply ); ModbusRTU::ReadInputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode forceSingleCoil( ModbusRTU::ForceSingleCoilMessage& query, virtual ModbusRTU::mbErrCode forceSingleCoil( ModbusRTU::ForceSingleCoilMessage& query,
ModbusRTU::ForceSingleCoilRetMessage& reply ); ModbusRTU::ForceSingleCoilRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode writeOutputSingleRegister( ModbusRTU::WriteSingleOutputMessage& query, virtual ModbusRTU::mbErrCode writeOutputSingleRegister( ModbusRTU::WriteSingleOutputMessage& query,
ModbusRTU::WriteSingleOutputRetMessage& reply ); ModbusRTU::WriteSingleOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode forceMultipleCoils( ModbusRTU::ForceCoilsMessage& query, virtual ModbusRTU::mbErrCode forceMultipleCoils( ModbusRTU::ForceCoilsMessage& query,
ModbusRTU::ForceCoilsRetMessage& reply ); ModbusRTU::ForceCoilsRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode writeOutputRegisters( ModbusRTU::WriteOutputMessage& query, virtual ModbusRTU::mbErrCode writeOutputRegisters( ModbusRTU::WriteOutputMessage& query,
ModbusRTU::WriteOutputRetMessage& reply ); ModbusRTU::WriteOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode diagnostics( ModbusRTU::DiagnosticMessage& query, virtual ModbusRTU::mbErrCode diagnostics( ModbusRTU::DiagnosticMessage& query,
ModbusRTU::DiagnosticRetMessage& reply ); ModbusRTU::DiagnosticRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode read4314( ModbusRTU::MEIMessageRDI& query, virtual ModbusRTU::mbErrCode read4314( ModbusRTU::MEIMessageRDI& query,
ModbusRTU::MEIMessageRetRDI& reply ); ModbusRTU::MEIMessageRetRDI& reply ) override;
virtual ModbusRTU::mbErrCode journalCommand( ModbusRTU::JournalCommandMessage& query, virtual ModbusRTU::mbErrCode journalCommand( ModbusRTU::JournalCommandMessage& query,
ModbusRTU::JournalCommandRetMessage& reply ); ModbusRTU::JournalCommandRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode setDateTime( ModbusRTU::SetDateTimeMessage& query, virtual ModbusRTU::mbErrCode setDateTime( ModbusRTU::SetDateTimeMessage& query,
ModbusRTU::SetDateTimeRetMessage& reply ); ModbusRTU::SetDateTimeRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode remoteService( ModbusRTU::RemoteServiceMessage& query, virtual ModbusRTU::mbErrCode remoteService( ModbusRTU::RemoteServiceMessage& query,
ModbusRTU::RemoteServiceRetMessage& reply ); ModbusRTU::RemoteServiceRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode fileTransfer( ModbusRTU::FileTransferMessage& query, virtual ModbusRTU::mbErrCode fileTransfer( ModbusRTU::FileTransferMessage& query,
ModbusRTU::FileTransferRetMessage& reply ); ModbusRTU::FileTransferRetMessage& reply ) override;
private: private:
......
...@@ -70,53 +70,53 @@ namespace uniset ...@@ -70,53 +70,53 @@ namespace uniset
virtual void final(); virtual void final();
virtual size_t getNextData( unsigned char* buf, int len ) override; virtual size_t getNextData( unsigned char* buf, int len ) override;
virtual void setChannelTimeout( timeout_t msec ); virtual void setChannelTimeout( timeout_t msec ) override;
virtual ModbusRTU::mbErrCode sendData( unsigned char* buf, int len ) override; virtual ModbusRTU::mbErrCode sendData( unsigned char* buf, int len ) override;
virtual ModbusRTU::mbErrCode tcp_processing( ModbusRTU::MBAPHeader& mhead ); virtual ModbusRTU::mbErrCode tcp_processing( ModbusRTU::MBAPHeader& mhead );
virtual ModbusRTU::mbErrCode make_adu_header( ModbusRTU::ModbusMessage& request ) override; virtual ModbusRTU::mbErrCode make_adu_header( ModbusRTU::ModbusMessage& request ) override;
virtual ModbusRTU::mbErrCode post_send_request(ModbusRTU::ModbusMessage& request ) override; virtual ModbusRTU::mbErrCode post_send_request(ModbusRTU::ModbusMessage& request ) override;
virtual ModbusRTU::mbErrCode readCoilStatus( ModbusRTU::ReadCoilMessage& query, virtual ModbusRTU::mbErrCode readCoilStatus( ModbusRTU::ReadCoilMessage& query,
ModbusRTU::ReadCoilRetMessage& reply ); ModbusRTU::ReadCoilRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readInputStatus( ModbusRTU::ReadInputStatusMessage& query, virtual ModbusRTU::mbErrCode readInputStatus( ModbusRTU::ReadInputStatusMessage& query,
ModbusRTU::ReadInputStatusRetMessage& reply ); ModbusRTU::ReadInputStatusRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readOutputRegisters( ModbusRTU::ReadOutputMessage& query, virtual ModbusRTU::mbErrCode readOutputRegisters( ModbusRTU::ReadOutputMessage& query,
ModbusRTU::ReadOutputRetMessage& reply ); ModbusRTU::ReadOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode readInputRegisters( ModbusRTU::ReadInputMessage& query, virtual ModbusRTU::mbErrCode readInputRegisters( ModbusRTU::ReadInputMessage& query,
ModbusRTU::ReadInputRetMessage& reply ); ModbusRTU::ReadInputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode forceSingleCoil( ModbusRTU::ForceSingleCoilMessage& query, virtual ModbusRTU::mbErrCode forceSingleCoil( ModbusRTU::ForceSingleCoilMessage& query,
ModbusRTU::ForceSingleCoilRetMessage& reply ); ModbusRTU::ForceSingleCoilRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode writeOutputSingleRegister( ModbusRTU::WriteSingleOutputMessage& query, virtual ModbusRTU::mbErrCode writeOutputSingleRegister( ModbusRTU::WriteSingleOutputMessage& query,
ModbusRTU::WriteSingleOutputRetMessage& reply ); ModbusRTU::WriteSingleOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode forceMultipleCoils( ModbusRTU::ForceCoilsMessage& query, virtual ModbusRTU::mbErrCode forceMultipleCoils( ModbusRTU::ForceCoilsMessage& query,
ModbusRTU::ForceCoilsRetMessage& reply ); ModbusRTU::ForceCoilsRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode writeOutputRegisters( ModbusRTU::WriteOutputMessage& query, virtual ModbusRTU::mbErrCode writeOutputRegisters( ModbusRTU::WriteOutputMessage& query,
ModbusRTU::WriteOutputRetMessage& reply ); ModbusRTU::WriteOutputRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode diagnostics( ModbusRTU::DiagnosticMessage& query, virtual ModbusRTU::mbErrCode diagnostics( ModbusRTU::DiagnosticMessage& query,
ModbusRTU::DiagnosticRetMessage& reply ); ModbusRTU::DiagnosticRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode read4314( ModbusRTU::MEIMessageRDI& query, virtual ModbusRTU::mbErrCode read4314( ModbusRTU::MEIMessageRDI& query,
ModbusRTU::MEIMessageRetRDI& reply ); ModbusRTU::MEIMessageRetRDI& reply ) override;
virtual ModbusRTU::mbErrCode journalCommand( ModbusRTU::JournalCommandMessage& query, virtual ModbusRTU::mbErrCode journalCommand( ModbusRTU::JournalCommandMessage& query,
ModbusRTU::JournalCommandRetMessage& reply ); ModbusRTU::JournalCommandRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode setDateTime( ModbusRTU::SetDateTimeMessage& query, virtual ModbusRTU::mbErrCode setDateTime( ModbusRTU::SetDateTimeMessage& query,
ModbusRTU::SetDateTimeRetMessage& reply ); ModbusRTU::SetDateTimeRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode remoteService( ModbusRTU::RemoteServiceMessage& query, virtual ModbusRTU::mbErrCode remoteService( ModbusRTU::RemoteServiceMessage& query,
ModbusRTU::RemoteServiceRetMessage& reply ); ModbusRTU::RemoteServiceRetMessage& reply ) override;
virtual ModbusRTU::mbErrCode fileTransfer( ModbusRTU::FileTransferMessage& query, virtual ModbusRTU::mbErrCode fileTransfer( ModbusRTU::FileTransferMessage& query,
ModbusRTU::FileTransferRetMessage& reply ); ModbusRTU::FileTransferRetMessage& reply ) override;
private: private:
std::queue<unsigned char> qrecv; std::queue<unsigned char> qrecv;
...@@ -144,7 +144,7 @@ namespace uniset ...@@ -144,7 +144,7 @@ namespace uniset
PassiveTimer pt; PassiveTimer pt;
PassiveTimer ptWait; PassiveTimer ptWait;
}; };
// ------------------------------------------------------------------------- // ---------------------------------------------------------------------
} // end of namespace uniset } // end of namespace uniset
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
#endif // ModbusTCPSession_H_ #endif // ModbusTCPSession_H_
......
...@@ -29,7 +29,7 @@ namespace uniset ...@@ -29,7 +29,7 @@ namespace uniset
const size_t BitsPerByte = 8; const size_t BitsPerByte = 8;
typedef uint8_t ModbusAddr; /*!< адрес узла в modbus-сети */ typedef uint8_t ModbusAddr; /*!< адрес узла в modbus-сети */
typedef uint16_t ModbusData; /*!< размер данных в modbus-сообщениях */ typedef uint16_t ModbusData; /*!< размер данных в modbus-сообщениях */
const size_t BitsPerData = 16; const uint8_t BitsPerData = 16;
typedef uint16_t ModbusCRC; /*!< размер CRC16 в modbus-сообщениях */ typedef uint16_t ModbusCRC; /*!< размер CRC16 в modbus-сообщениях */
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
......
...@@ -338,7 +338,7 @@ size_t ComPort::receiveBlock(unsigned char* msg, size_t len) ...@@ -338,7 +338,7 @@ size_t ComPort::receiveBlock(unsigned char* msg, size_t len)
{ {
msg[k] = m_receiveByte(waiting); msg[k] = m_receiveByte(waiting);
} }
catch(TimeOut) catch( const uniset::TimeOut& ex )
{ {
break; break;
} }
......
...@@ -454,7 +454,7 @@ namespace uniset ...@@ -454,7 +454,7 @@ namespace uniset
return recv_pdu(qfunc, rbuf, timeout); return recv_pdu(qfunc, rbuf, timeout);
} }
catch( uniset::TimeOut ) catch( const uniset::TimeOut& ex )
{ {
// cout << "(recv): catch TimeOut " << endl; // cout << "(recv): catch TimeOut " << endl;
} }
...@@ -1390,7 +1390,7 @@ namespace uniset ...@@ -1390,7 +1390,7 @@ namespace uniset
return ex.err; return ex.err;
} }
catch( uniset::TimeOut ) catch( const uniset::TimeOut& ex )
{ {
// cout << "(recv): catch TimeOut " << endl; // cout << "(recv): catch TimeOut " << endl;
} }
......
...@@ -178,9 +178,14 @@ namespace uniset ...@@ -178,9 +178,14 @@ namespace uniset
{ {
try try
{ {
terminate(); ModbusRTUSlave::terminate();
} }
catch(...) {} catch(...) {}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ComPort* ModbusRTUSlaveSlot::getComPort()
{
return port;
}
// -------------------------------------------------------------------------
} // end of namespace uniset } // end of namespace uniset
...@@ -681,11 +681,11 @@ namespace uniset ...@@ -681,11 +681,11 @@ namespace uniset
return recv_pdu(rbuf, timeout); return recv_pdu(rbuf, timeout);
} }
catch( uniset::TimeOut ) catch( const uniset::TimeOut& ex )
{ {
// cout << "(recv): catch TimeOut " << endl; // cout << "(recv): catch TimeOut " << endl;
} }
catch( uniset::CommFailed ) catch( const uniset::CommFailed& ex )
{ {
cleanupChannel(); cleanupChannel();
return erSessionClosed; return erSessionClosed;
...@@ -1535,11 +1535,11 @@ namespace uniset ...@@ -1535,11 +1535,11 @@ namespace uniset
cleanupChannel(); cleanupChannel();
return ex.err; return ex.err;
} }
catch( uniset::TimeOut ) catch( const uniset::TimeOut& ex )
{ {
// cout << "(recv): catch TimeOut " << endl; // cout << "(recv): catch TimeOut " << endl;
} }
catch( uniset::Exception& ex ) // SystemError catch( const uniset::Exception& ex ) // SystemError
{ {
if( dlog->is_crit() ) if( dlog->is_crit() )
dlog->crit() << "(recv): " << ex << endl; dlog->crit() << "(recv): " << ex << endl;
......
...@@ -315,10 +315,7 @@ namespace uniset ...@@ -315,10 +315,7 @@ namespace uniset
return 0; return 0;
} }
} }
catch( uniset::CommFailed ) catch( const uniset::CommFailed& ex ){}
{
}
if( !cancelled && dlog->is_info() ) if( !cancelled && dlog->is_info() )
dlog->info() << peername << "(getNextData): client disconnected" << endl; dlog->info() << peername << "(getNextData): client disconnected" << endl;
...@@ -387,10 +384,7 @@ namespace uniset ...@@ -387,10 +384,7 @@ namespace uniset
} }
while( len == 0 && !pt.checkTime() ); while( len == 0 && !pt.checkTime() );
} }
catch( uniset::CommFailed ) catch( const uniset::CommFailed& ex ){}
{
}
if( len < mhead.len ) if( len < mhead.len )
{ {
......
...@@ -265,7 +265,7 @@ namespace uniset ...@@ -265,7 +265,7 @@ namespace uniset
uwarn << myname << "(registration): replace object (ObjectNameAlready)" << endl; uwarn << myname << "(registration): replace object (ObjectNameAlready)" << endl;
unregistration(); unregistration();
} }
catch( uniset::ORepFailed ) catch( const uniset::ORepFailed& ex )
{ {
uwarn << myname << "(registration): don`t registration in object reposotory " << endl; uwarn << myname << "(registration): don`t registration in object reposotory " << endl;
} }
......
...@@ -176,7 +176,7 @@ std::ostream& DebugStream::printDate(Debug::type t, char brk) noexcept ...@@ -176,7 +176,7 @@ std::ostream& DebugStream::printDate(Debug::type t, char brk) noexcept
std::time_t tv = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); std::time_t tv = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm tms = *std::localtime(&tv); std::tm tms = *std::localtime(&tv);
#if __GLIBCXX__ >= 20151207 #if __GNUC__ >= 5
std::ostringstream fmt; std::ostringstream fmt;
fmt << "%Od" << brk << "%Om" << brk << "%Y"; fmt << "%Od" << brk << "%Om" << brk << "%Y";
return (*this) << std::put_time(&tms, fmt.str().c_str()); return (*this) << std::put_time(&tms, fmt.str().c_str());
...@@ -199,7 +199,7 @@ std::ostream& DebugStream::printTime(Debug::type t, char brk) noexcept ...@@ -199,7 +199,7 @@ std::ostream& DebugStream::printTime(Debug::type t, char brk) noexcept
timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0); timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0);
std::tm tms = *std::localtime(&tv.tv_sec); std::tm tms = *std::localtime(&tv.tv_sec);
#if __GLIBCXX__ >= 20151207 #if __GNUC__ >= 5
std::ostringstream fmt; std::ostringstream fmt;
fmt << "%OH" << brk << "%OM" << brk << "%OS"; fmt << "%OH" << brk << "%OM" << brk << "%OS";
(*this) << std::put_time(&tms, fmt.str().c_str()); (*this) << std::put_time(&tms, fmt.str().c_str());
...@@ -229,7 +229,7 @@ std::ostream& DebugStream::printDateTime(Debug::type t) noexcept ...@@ -229,7 +229,7 @@ std::ostream& DebugStream::printDateTime(Debug::type t) noexcept
timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0); timespec tv = uniset::now_to_timespec(); // gettimeofday(tv,0);
std::tm tms = *std::localtime(&tv.tv_sec); std::tm tms = *std::localtime(&tv.tv_sec);
#if __GLIBCXX__ >= 20151207 #if __GNUC__ >= 5
*this << std::put_time(&tms, "%Od/%Om/%Y %OH:%OM:%OS"); *this << std::put_time(&tms, "%Od/%Om/%Y %OH:%OM:%OS");
#else #else
*this << std::setw(2) << std::setfill('0') << tms.tm_mday << "/" *this << std::setw(2) << std::setfill('0') << tms.tm_mday << "/"
......
...@@ -568,7 +568,7 @@ namespace uniset ...@@ -568,7 +568,7 @@ namespace uniset
try try
{ {
std::string ret( std::move(m_command_sig.emit(this, msg.cmd, cmdLogName)) ); std::string ret( m_command_sig.emit(this, msg.cmd, cmdLogName) );
if( !ret.empty() ) if( !ret.empty() )
{ {
......
...@@ -139,7 +139,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -139,7 +139,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
continue; continue;
} }
catch( const ORepFailed ) catch( const ORepFailed& ex )
{ {
string er("ObjectRepository(registrartion): (getContext) не смог зарегистрировать " + name); string er("ObjectRepository(registrartion): (getContext) не смог зарегистрировать " + name);
throw ORepFailed(er); throw ORepFailed(er);
...@@ -342,7 +342,7 @@ bool ObjectRepository::list( const string& section, ListObjectName* olist, size_ ...@@ -342,7 +342,7 @@ bool ObjectRepository::list( const string& section, ListObjectName* olist, size_
CORBA::ORB_var orb = uconf->getORB(); CORBA::ORB_var orb = uconf->getORB();
ctx = ORepHelpers::getContext(orb, section, nsName); ctx = ORepHelpers::getContext(orb, section, nsName);
} }
catch( const ORepFailed ) catch( const ORepFailed& ex )
{ {
uwarn << "ORepository(list): не смог получить ссылку на " << section << endl; uwarn << "ORepository(list): не смог получить ссылку на " << section << endl;
throw; throw;
...@@ -423,7 +423,7 @@ bool ObjectRepository::isExist( const ObjectPtr& oref ) const ...@@ -423,7 +423,7 @@ bool ObjectRepository::isExist( const ObjectPtr& oref ) const
UniSetObject_i_var o = UniSetObject_i::_narrow(oref); UniSetObject_i_var o = UniSetObject_i::_narrow(oref);
return o->exist(); return o->exist();
} }
catch( const CORBA::TRANSIENT) {} catch( const CORBA::TRANSIENT& ) {}
catch( const CORBA::SystemException&) {} catch( const CORBA::SystemException&) {}
catch( const CORBA::Exception&) {} catch( const CORBA::Exception&) {}
catch( const omniORB::fatalException& fe ) catch( const omniORB::fatalException& fe )
...@@ -512,13 +512,13 @@ bool ObjectRepository::createContext( const string& cname, CosNaming::NamingCont ...@@ -512,13 +512,13 @@ bool ObjectRepository::createContext( const string& cname, CosNaming::NamingCont
ulogrep << "ORepFactory(createContext): создал. " << endl; ulogrep << "ORepFactory(createContext): создал. " << endl;
return true; return true;
} }
catch(const CosNaming::NamingContext::AlreadyBound ab) catch(const CosNaming::NamingContext::AlreadyBound& ab)
{ {
// ctx->resolve(nc); // ctx->resolve(nc);
ulogrep << "ORepFactory(createContext): context " << cname << " already exist" << endl; ulogrep << "ORepFactory(createContext): context " << cname << " already exist" << endl;
return true; return true;
} }
catch( const CosNaming::NamingContext::NotFound ) catch( const CosNaming::NamingContext::NotFound& ex )
{ {
ulogrep << "ORepFactory(createContext): NotFound " << cname << endl; ulogrep << "ORepFactory(createContext): NotFound " << cname << endl;
throw NameNotFound(); throw NameNotFound();
...@@ -569,7 +569,7 @@ void ObjectRepository::printSection( const string& fullName ) const ...@@ -569,7 +569,7 @@ void ObjectRepository::printSection( const string& fullName ) const
if( olist.empty() ) if( olist.empty() )
cout << fullName << " пуст!!!" << endl; cout << fullName << " пуст!!!" << endl;
} }
catch( ORepFailed ) catch( ORepFailed& ex )
{ {
cout << "printSection: cath exceptions ORepFailed..." << endl; cout << "printSection: cath exceptions ORepFailed..." << endl;
return ; return ;
...@@ -601,7 +601,7 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c ...@@ -601,7 +601,7 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c
const char* const* argv(uconf->getArgv()); const char* const* argv(uconf->getArgv());
ctx = ORepHelpers::getContext(fullName, argc, argv, nsName); ctx = ORepHelpers::getContext(fullName, argc, argv, nsName);
} }
catch( ORepFailed ) catch( ORepFailed& ex )
{ {
return false; return false;
} }
...@@ -677,7 +677,7 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c ...@@ -677,7 +677,7 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c
ulogrep << "ORepFactory: контекст" << fullName << " не пустой " << endl; ulogrep << "ORepFactory: контекст" << fullName << " не пустой " << endl;
rem = false; rem = false;
} }
catch( ORepFailed ) catch( ORepFailed& ex )
{ {
ulogrep << "ORepFactory: не удаось получить ссылку на контекст " << in_sec << endl; ulogrep << "ORepFactory: не удаось получить ссылку на контекст " << in_sec << endl;
rem = false; rem = false;
...@@ -716,7 +716,7 @@ bool ObjectRepository::renameSection( const string& newFName, const string& oldF ...@@ -716,7 +716,7 @@ bool ObjectRepository::renameSection( const string& newFName, const string& oldF
in_ctx->rebind_context(ctxNewName, ctx); in_ctx->rebind_context(ctxNewName, ctx);
in_ctx->unbind(ctxOldName); in_ctx->unbind(ctxOldName);
} }
catch( ORepFailed ) catch( ORepFailed& ex )
{ {
return false; return false;
} }
......
...@@ -439,7 +439,7 @@ void IOController::logging( uniset::SensorMessage& sm ) ...@@ -439,7 +439,7 @@ void IOController::logging( uniset::SensorMessage& sm )
} }
sm.consumer = dbserverID; sm.consumer = dbserverID;
TransportMessage tm(std::move(sm.transport_msg())); TransportMessage tm(sm.transport_msg());
ui->send( sm.consumer, std::move(tm) ); ui->send( sm.consumer, std::move(tm) );
isPingDBServer = true; isPingDBServer = true;
} }
...@@ -468,7 +468,7 @@ void IOController::dumpToDB() ...@@ -468,7 +468,7 @@ void IOController::dumpToDB()
if ( !s->dbignore ) if ( !s->dbignore )
{ {
SensorMessage sm( std::move(s->makeSensorMessage()) ); SensorMessage sm( s->makeSensorMessage() );
logging(sm); logging(sm);
} }
} }
...@@ -600,7 +600,8 @@ IOController::USensorInfo::USensorInfo(IOController_i::SensorIOInfo* ai): ...@@ -600,7 +600,8 @@ IOController::USensorInfo::USensorInfo(IOController_i::SensorIOInfo* ai):
IOController::USensorInfo& IOController::USensorInfo&
IOController::USensorInfo::operator=(IOController_i::SensorIOInfo& r) IOController::USensorInfo::operator=(IOController_i::SensorIOInfo& r)
{ {
(*this) = r; IOController::USensorInfo tmp(r);
(*this) = std::move(tmp);
return *this; return *this;
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -625,9 +626,10 @@ IOController::USensorInfo::USensorInfo(): d_value(1), d_off_value(0) ...@@ -625,9 +626,10 @@ IOController::USensorInfo::USensorInfo(): d_value(1), d_off_value(0)
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
IOController::USensorInfo& IOController::USensorInfo&
IOController::USensorInfo::operator=(IOController_i::SensorIOInfo* r) IOController::USensorInfo::operator=( IOController_i::SensorIOInfo* r )
{ {
(*this) = (*r); IOController::USensorInfo tmp(r);
(*this) = std::move(tmp);
return *this; return *this;
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -650,10 +652,10 @@ void IOController::USensorInfo::setUserData( size_t index, void* data ) ...@@ -650,10 +652,10 @@ void IOController::USensorInfo::setUserData( size_t index, void* data )
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
const IOController::USensorInfo& const IOController::USensorInfo&
IOController::USensorInfo::operator=(const IOController_i::SensorIOInfo& r) IOController::USensorInfo::operator=( const IOController_i::SensorIOInfo& r )
{ {
(*this) = r; IOController::USensorInfo tmp(r);
// any=0; (*this) = std::move(tmp);
return *this; return *this;
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -537,7 +537,7 @@ void IONotifyController::askSensor(const uniset::ObjectId sid, ...@@ -537,7 +537,7 @@ void IONotifyController::askSensor(const uniset::ObjectId sid,
if( lst ) if( lst )
{ {
uniset::uniset_rwmutex_rlock lock(usi->val_lock); uniset::uniset_rwmutex_rlock lock(usi->val_lock);
SensorMessage smsg( std::move(usi->makeSensorMessage(false)) ); SensorMessage smsg( usi->makeSensorMessage(false) );
send(*lst, smsg, &ci); send(*lst, smsg, &ci);
} }
} }
...@@ -620,7 +620,7 @@ long IONotifyController::localSetValue( std::shared_ptr<IOController::USensorInf ...@@ -620,7 +620,7 @@ long IONotifyController::localSetValue( std::shared_ptr<IOController::USensorInf
uniset::uniset_rwmutex_rlock lock(usi->val_lock); uniset::uniset_rwmutex_rlock lock(usi->val_lock);
SensorMessage sm(std::move(usi->makeSensorMessage(false))); SensorMessage sm(usi->makeSensorMessage(false));
try try
{ {
...@@ -833,7 +833,7 @@ void IONotifyController::askThreshold(uniset::ObjectId sid, ...@@ -833,7 +833,7 @@ void IONotifyController::askThreshold(uniset::ObjectId sid,
break; break;
// посылка первый раз состояния // посылка первый раз состояния
SensorMessage sm(std::move(li->second->makeSensorMessage())); SensorMessage sm(li->second->makeSensorMessage());
sm.consumer = ci.id; sm.consumer = ci.id;
sm.tid = tid; sm.tid = tid;
...@@ -946,7 +946,7 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn ...@@ -946,7 +946,7 @@ void IONotifyController::checkThreshold( std::shared_ptr<IOController::USensorIn
// обрабатываем текущее состояние датчика обязательно "залочив" значение.. // обрабатываем текущее состояние датчика обязательно "залочив" значение..
uniset_rwmutex_rlock vlock(usi->val_lock); uniset_rwmutex_rlock vlock(usi->val_lock);
SensorMessage sm(std::move(usi->makeSensorMessage(false))); SensorMessage sm(usi->makeSensorMessage(false));
// текущее время // текущее время
struct timespec tm = uniset::now_to_timespec(); struct timespec tm = uniset::now_to_timespec();
...@@ -1177,7 +1177,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList() ...@@ -1177,7 +1177,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
void IONotifyController::onChangeUndefinedState( std::shared_ptr<USensorInfo>& usi, IOController* ic ) void IONotifyController::onChangeUndefinedState( std::shared_ptr<USensorInfo>& usi, IOController* ic )
{ {
uniset_rwmutex_rlock vlock(usi->val_lock); uniset_rwmutex_rlock vlock(usi->val_lock);
SensorMessage sm( std::move(usi->makeSensorMessage(false)) ); SensorMessage sm( usi->makeSensorMessage(false) );
try try
{ {
......
...@@ -80,7 +80,7 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj ) ...@@ -80,7 +80,7 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
if( li->tmr.checkTime() ) if( li->tmr.checkTime() )
{ {
// помещаем себе в очередь сообщение // помещаем себе в очередь сообщение
TransportMessage tm( std::move(TimerMessage(li->id, li->priority, obj->getId()).transport_msg()) ); TransportMessage tm( TimerMessage(li->id, li->priority, obj->getId()).transport_msg() );
obj->push(tm); obj->push(tm);
// Проверка на количество заданных тактов // Проверка на количество заданных тактов
......
...@@ -87,7 +87,7 @@ void SViewer::readSection( const string& section, const string& secRoot ) ...@@ -87,7 +87,7 @@ void SViewer::readSection( const string& section, const string& secRoot )
cout << "(readSection): получен не полный список" << endl; cout << "(readSection): получен не полный список" << endl;
} }
} }
catch( ORepFailed ) {} catch( const ORepFailed& ex ) {}
catch(...) catch(...)
{ {
std::exception_ptr p = std::current_exception(); std::exception_ptr p = std::current_exception();
...@@ -112,7 +112,7 @@ void SViewer::readSection( const string& section, const string& secRoot ) ...@@ -112,7 +112,7 @@ void SViewer::readSection( const string& section, const string& secRoot )
if( !rep.list(secName, &lstObj, 1000) ) if( !rep.list(secName, &lstObj, 1000) )
cout << "(readSection): получен не полный список" << endl; cout << "(readSection): получен не полный список" << endl;
} }
catch( ORepFailed ) catch( const ORepFailed& ex )
{ {
cout << "(readSection):.. catch ORepFailed" << endl; cout << "(readSection):.. catch ORepFailed" << endl;
return; return;
...@@ -176,7 +176,7 @@ void SViewer::getInfo( ObjectId id ) ...@@ -176,7 +176,7 @@ void SViewer::getInfo( ObjectId id )
IOController_i::SensorInfoSeq_var amap = ioc->getSensorsMap(); IOController_i::SensorInfoSeq_var amap = ioc->getSensorsMap();
updateSensors(amap, id); updateSensors(amap, id);
} }
catch( IOController_i::NameNotFound ) {} catch( const IOController_i::NameNotFound& ex ) {}
catch(...) {} catch(...) {}
try try
...@@ -184,7 +184,7 @@ void SViewer::getInfo( ObjectId id ) ...@@ -184,7 +184,7 @@ void SViewer::getInfo( ObjectId id )
IONotifyController_i::ThresholdsListSeq_var tlst = ioc->getThresholdsList(); IONotifyController_i::ThresholdsListSeq_var tlst = ioc->getThresholdsList();
updateThresholds(tlst, id); updateThresholds(tlst, id);
} }
catch( IOController_i::NameNotFound ) {} catch( const IOController_i::NameNotFound& ex ) {}
catch(...) {} catch(...) {}
return; return;
......
...@@ -19,7 +19,7 @@ const size_t COUNT = 1000000; // сколько сообщений помест ...@@ -19,7 +19,7 @@ const size_t COUNT = 1000000; // сколько сообщений помест
void mq_write_thread() void mq_write_thread()
{ {
SensorMessage smsg(100, 2); SensorMessage smsg(100, 2);
TransportMessage tm( std::move(smsg.transport_msg()) ); TransportMessage tm( smsg.transport_msg() );
auto vm = make_shared<VoidMessage>(tm); auto vm = make_shared<VoidMessage>(tm);
msleep(100); msleep(100);
...@@ -67,7 +67,7 @@ int main(int argc, const char** argv) ...@@ -67,7 +67,7 @@ int main(int argc, const char** argv)
// сперва просто проверка что очередь работает. // сперва просто проверка что очередь работает.
{ {
SensorMessage sm(100, 2); SensorMessage sm(100, 2);
TransportMessage tm( std::move(sm.transport_msg()) ); TransportMessage tm( sm.transport_msg() );
auto vm = make_shared<VoidMessage>(tm); auto vm = make_shared<VoidMessage>(tm);
mq.push(vm); mq.push(vm);
auto msg = mq.top(); auto msg = mq.top();
......
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