Commit e77133e0 authored by Pavel Vainerman's avatar Pavel Vainerman

Рефакторинг: расстановка const, перенос реализации из h-файлов

parent f2e95a15
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
/*! Вывод состояния внутренних переменных */ /*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return vmon.pretty_str(); } inline std::string dumpVars(){ return vmon.pretty_str(); }
// ------------------------------------------------------------ // ------------------------------------------------------------
std::string help() noexcept; std::string help() const noexcept;
<xsl:if test="normalize-space($DISABLE_REST_API)!='1'"> <xsl:if test="normalize-space($DISABLE_REST_API)!='1'">
#ifndef DISABLE_REST_API #ifndef DISABLE_REST_API
...@@ -869,7 +869,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te ...@@ -869,7 +869,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
} }
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string <xsl:value-of select="$CLASSNAME"/>_SK::help() noexcept std::string <xsl:value-of select="$CLASSNAME"/>_SK::help() const noexcept
{ {
ostringstream s; ostringstream s;
s &lt;&lt; " ************* " &lt;&lt; myname &lt;&lt; " HELP:" &lt;&lt; " ************* " &lt;&lt; endl; s &lt;&lt; " ************* " &lt;&lt; myname &lt;&lt; " HELP:" &lt;&lt; " ************* " &lt;&lt; endl;
......
...@@ -587,7 +587,7 @@ namespace uniset ...@@ -587,7 +587,7 @@ namespace uniset
bool ok = false; bool ok = false;
tm.consumer = it; tm.consumer = it;
for( unsigned int i = 0; i < 2; i++ ) for( size_t i = 0; i < 2; i++ )
{ {
try try
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2017-07-02+03:00 // generate timestamp: 2017-07-13+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef UObject_SK_H_ #ifndef UObject_SK_H_
#define UObject_SK_H_ #define UObject_SK_H_
...@@ -118,7 +118,7 @@ class UObject_SK: ...@@ -118,7 +118,7 @@ class UObject_SK:
/*! Вывод состояния внутренних переменных */ /*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return vmon.pretty_str(); } inline std::string dumpVars(){ return vmon.pretty_str(); }
// ------------------------------------------------------------ // ------------------------------------------------------------
std::string help() noexcept; std::string help() const noexcept;
#ifndef DISABLE_REST_API #ifndef DISABLE_REST_API
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2017-07-02+03:00 // generate timestamp: 2017-07-13+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include <memory> #include <memory>
#include <iomanip> #include <iomanip>
...@@ -717,7 +717,7 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID ) ...@@ -717,7 +717,7 @@ void UObject_SK::waitSM( int wait_msec, ObjectId _testID )
} }
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string UObject_SK::help() noexcept std::string UObject_SK::help() const noexcept
{ {
ostringstream s; ostringstream s;
s << " ************* " << myname << " HELP:" << " ************* " << endl; s << " ************* " << myname << " HELP:" << " ************* " << endl;
......
...@@ -95,10 +95,7 @@ namespace uniset ...@@ -95,10 +95,7 @@ namespace uniset
void setSpeed( Speed s ); void setSpeed( Speed s );
void setSpeed( const std::string& speed ); void setSpeed( const std::string& speed );
inline Speed getSpeed() Speed getSpeed() const;
{
return speed;
}
static Speed getSpeed( const std::string& s ); static Speed getSpeed( const std::string& s );
static std::string getSpeed( Speed s ); static std::string getSpeed( Speed s );
...@@ -108,10 +105,7 @@ namespace uniset ...@@ -108,10 +105,7 @@ namespace uniset
void setStopBits(StopBits sBit); void setStopBits(StopBits sBit);
virtual void setTimeout( timeout_t msec ); virtual void setTimeout( timeout_t msec );
inline timeout_t getTimeout() timeout_t getTimeout() const;
{
return uTimeout / 1000; // msec
}
void setWaiting(bool waiting); void setWaiting(bool waiting);
......
...@@ -150,7 +150,8 @@ namespace uniset ...@@ -150,7 +150,8 @@ namespace uniset
{ {
return ioList.find(k); return ioList.find(k);
} }
inline int ioCount() const
inline int ioCount() const noexcept
{ {
return ioList.size(); return ioList.size();
} }
...@@ -250,8 +251,6 @@ namespace uniset ...@@ -250,8 +251,6 @@ namespace uniset
IOStateList::iterator myioBegin(); IOStateList::iterator myioBegin();
IOStateList::iterator myioEnd(); IOStateList::iterator myioEnd();
IOStateList::iterator myiofind( uniset::ObjectId id ); IOStateList::iterator myiofind( uniset::ObjectId id );
size_t ioCount();
// --------------------------
private: private:
friend class NCRestorer; friend class NCRestorer;
...@@ -338,7 +337,7 @@ namespace uniset ...@@ -338,7 +337,7 @@ namespace uniset
{ {
uniset::uniset_rwmutex_rlock lock(val_lock); uniset::uniset_rwmutex_rlock lock(val_lock);
IOController_i::SensorIOInfo s(*this); IOController_i::SensorIOInfo s(*this);
return std::move(s); return s;
} }
inline uniset::SensorMessage makeSensorMessage( bool with_lock = false ) inline uniset::SensorMessage makeSensorMessage( bool with_lock = false )
...@@ -370,7 +369,7 @@ namespace uniset ...@@ -370,7 +369,7 @@ namespace uniset
sm.undefined = undefined; sm.undefined = undefined;
} }
return std::move(sm); return sm;
} }
}; };
}; };
......
...@@ -72,7 +72,7 @@ namespace uniset ...@@ -72,7 +72,7 @@ namespace uniset
sleepTime=lt.checkTimers(this); sleepTime=lt.checkTimers(this);
} }
catch(Exception& ex) catch( uniset::Exception& ex)
{ {
cout << myname << "(callback): " << ex << endl; cout << myname << "(callback): " << ex << endl;
} }
......
...@@ -52,42 +52,19 @@ namespace uniset ...@@ -52,42 +52,19 @@ namespace uniset
bool isConnection() const; bool isConnection() const;
inline void setReadCount( unsigned int n ) void setReadCount( unsigned int n );
{ void setCommandOnlyMode( bool s );
readcount = n;
}
inline void setCommandOnlyMode( bool s ) void setinTimeout( timeout_t msec );
{ void setoutTimeout( timeout_t msec );
cmdonly = s; void setReconnectDelay( timeout_t msec );
} void setTextFilter( const std::string& f );
inline void setinTimeout( timeout_t msec )
{
inTimeout = msec;
}
inline void setoutTimeout( timeout_t msec )
{
outTimeout = msec;
}
inline void setReconnectDelay( timeout_t msec )
{
reconDelay = msec;
}
inline void setTextFilter( const std::string& f )
{
textfilter = f;
}
DebugStream::StreamEvent_Signal signal_stream_event(); DebugStream::StreamEvent_Signal signal_stream_event();
void setLogLevel( Debug::type t ); void setLogLevel( Debug::type t );
inline std::shared_ptr<DebugStream> log() std::shared_ptr<DebugStream> log();
{
return outlog;
}
protected: protected:
......
...@@ -98,29 +98,16 @@ namespace uniset ...@@ -98,29 +98,16 @@ namespace uniset
LogServer( std::shared_ptr<LogAgregator> log ); LogServer( std::shared_ptr<LogAgregator> log );
virtual ~LogServer() noexcept; virtual ~LogServer() noexcept;
inline void setCmdTimeout( timeout_t msec ) noexcept void setCmdTimeout( timeout_t msec ) noexcept;
{ void setSessionLog( Debug::type t ) noexcept;
cmdTimeout = msec; void setMaxSessionCount( size_t num ) noexcept;
}
inline void setSessionLog( Debug::type t ) noexcept
{
sessLogLevel = t;
}
inline void setMaxSessionCount( int num ) noexcept
{
sessMaxCount = num;
}
bool async_run( const std::string& addr, Poco::UInt16 port ); bool async_run( const std::string& addr, Poco::UInt16 port );
bool run( const std::string& addr, Poco::UInt16 port ); bool run( const std::string& addr, Poco::UInt16 port );
void terminate(); void terminate();
inline bool isRunning() const noexcept bool isRunning() const noexcept;
{
return isrunning;
}
bool check( bool restart_if_fail = true ); bool check( bool restart_if_fail = true );
...@@ -139,10 +126,7 @@ namespace uniset ...@@ -139,10 +126,7 @@ namespace uniset
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;
virtual std::string wname() const noexcept override virtual std::string wname() const noexcept override;
{
return myname;
}
void ioAccept( ev::io& watcher, int revents ); void ioAccept( ev::io& watcher, int revents );
void sessionFinished( LogSession* s ); void sessionFinished( LogSession* s );
......
...@@ -25,7 +25,7 @@ namespace uniset ...@@ -25,7 +25,7 @@ namespace uniset
namespace LogServerTypes namespace LogServerTypes
{ {
const unsigned int MAGICNUM = 0x20160417; const uint MAGICNUM = 0x20160417;
enum Command enum Command
{ {
cmdNOP, /*!< отсутствие команды */ cmdNOP, /*!< отсутствие команды */
...@@ -55,9 +55,10 @@ namespace uniset ...@@ -55,9 +55,10 @@ namespace uniset
{ {
std::memset(logname, 0, sizeof(logname)); std::memset(logname, 0, sizeof(logname));
} }
unsigned int magic;
uint magic;
Command cmd; Command cmd;
unsigned int data; uint data;
static const size_t MAXLOGNAME = 120; static const size_t MAXLOGNAME = 120;
char logname[MAXLOGNAME + 1]; // +1 reserverd for '\0' char logname[MAXLOGNAME + 1]; // +1 reserverd for '\0'
......
...@@ -53,23 +53,11 @@ namespace uniset ...@@ -53,23 +53,11 @@ namespace uniset
// прервать работу // прервать работу
void cancel() noexcept; void cancel() noexcept;
inline std::string getClientAddress() const noexcept std::string getClientAddress() const noexcept;
{
return caddr; void setSessionLogLevel( Debug::type t ) noexcept;
} void addSessionLogLevel( Debug::type t ) noexcept;
void delSessionLogLevel( Debug::type t ) noexcept;
inline void setSessionLogLevel( Debug::type t ) noexcept
{
mylog.level(t);
}
inline void addSessionLogLevel( Debug::type t ) noexcept
{
mylog.addLevel(t);
}
inline void delSessionLogLevel( Debug::type t ) noexcept
{
mylog.delLevel(t);
}
//! Установить размер буфера для сообщений (количество записей. Не в байтах!!) //! Установить размер буфера для сообщений (количество записей. Не в байтах!!)
void setMaxBufSize( size_t num ); void setMaxBufSize( size_t num );
......
...@@ -50,16 +50,10 @@ namespace uniset ...@@ -50,16 +50,10 @@ namespace uniset
// node // node
//! \return "" if not found //! \return "" if not found
inline std::string getNodeName( const uniset::ObjectId id ) const noexcept std::string getNodeName( const uniset::ObjectId id ) const noexcept;
{
return getNameById(id);
}
//! \return uniset::DefaultObjectId if not found //! \return uniset::DefaultObjectId if not found
inline ObjectId getNodeId( const std::string& name ) const noexcept ObjectId getNodeId( const std::string& name ) const noexcept;
{
return getIdByName(name);
}
// src name // src name
//! \return "" if not found //! \return "" if not found
......
...@@ -88,10 +88,10 @@ namespace uniset ...@@ -88,10 +88,10 @@ namespace uniset
}; };
//! Получение списка how_many объектов из секции section. //! Получение списка how_many объектов из секции section.
bool list(const std::string& section, uniset::ListObjectName* ls, size_t how_many = 300)throw(uniset::ORepFailed); bool list(const std::string& section, uniset::ListObjectName* ls, size_t how_many = 300) const throw(uniset::ORepFailed);
//! Получние списка how_many подсекций из секции in_section. //! Получние списка how_many подсекций из секции in_section.
bool listSections(const std::string& in_section, uniset::ListObjectName* ls, size_t how_many = 300)throw(uniset::ORepFailed); bool listSections(const std::string& in_section, uniset::ListObjectName* ls, size_t how_many = 300) const throw(uniset::ORepFailed);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
//! Создание секции //! Создание секции
...@@ -110,7 +110,7 @@ namespace uniset ...@@ -110,7 +110,7 @@ namespace uniset
bool renameSection(const std::string& newName, const std::string& fullName); bool renameSection(const std::string& newName, const std::string& fullName);
/*! Функция выводящая на экран список всех объектов расположенных в данной секции */ /*! Функция выводящая на экран список всех объектов расположенных в данной секции */
void printSection(const std::string& fullName); void printSection(const std::string& fullName) const;
// @} // @}
// end of add to ORepServiceGroup // end of add to ORepServiceGroup
...@@ -121,7 +121,7 @@ namespace uniset ...@@ -121,7 +121,7 @@ namespace uniset
mutable std::string nsName; mutable std::string nsName;
std::shared_ptr<uniset::Configuration> uconf; std::shared_ptr<uniset::Configuration> uconf;
bool list(const std::string& section, uniset::ListObjectName* ls, unsigned int how_many, ObjectType type); bool list(const std::string& section, uniset::ListObjectName* ls, unsigned int how_many, ObjectType type) const;
/*! Создание нового контекста(секции) */ /*! Создание нового контекста(секции) */
bool createContext( const std::string& cname, CosNaming::NamingContext_ptr ctx); bool createContext( const std::string& cname, CosNaming::NamingContext_ptr ctx);
......
...@@ -90,7 +90,7 @@ namespace uniset ...@@ -90,7 +90,7 @@ namespace uniset
public: public:
/*! прототип функции вызова /*! прототип функции вызова
* use std::function ? * \todo use std::function ?
*/ */
typedef void(ThreadMaster::* Action)(void); typedef void(ThreadMaster::* Action)(void);
...@@ -113,7 +113,7 @@ namespace uniset ...@@ -113,7 +113,7 @@ namespace uniset
void sleep( long milliseconds ); void sleep( long milliseconds );
inline bool isRunning() inline bool isRunning() const
{ {
return thr.isRunning(); return thr.isRunning();
} }
......
...@@ -26,10 +26,7 @@ namespace uniset ...@@ -26,10 +26,7 @@ namespace uniset
ModbusRTUMaster( const std::string& dev, bool use485 = false, bool tr_ctl = false ); ModbusRTUMaster( const std::string& dev, bool use485 = false, bool tr_ctl = false );
virtual ~ModbusRTUMaster(); virtual ~ModbusRTUMaster();
virtual void cleanupChannel() override virtual void cleanupChannel() override;
{
if( port ) port->cleanupChannel();
}
void setSpeed( ComPort::Speed s ); void setSpeed( ComPort::Speed s );
void setSpeed( const std::string& s ); void setSpeed( const std::string& s );
...@@ -39,7 +36,7 @@ namespace uniset ...@@ -39,7 +36,7 @@ namespace uniset
void setCharacterSize( ComPort::CharacterSize csize ); void setCharacterSize( ComPort::CharacterSize csize );
void setStopBits( ComPort::StopBits sBit ); void setStopBits( ComPort::StopBits sBit );
int getTimeout(); timeout_t getTimeout() const;
protected: protected:
......
...@@ -92,37 +92,16 @@ namespace uniset ...@@ -92,37 +92,16 @@ namespace uniset
void setRecvTimeout( timeout_t msec ); void setRecvTimeout( timeout_t msec );
/*! установить паузу при ожидании символа */ /*! установить паузу при ожидании символа */
inline void setSleepPause( timeout_t msec ) void setSleepPause( timeout_t msec );
{
sleepPause_msec = msec;
}
inline void setCRCNoCheckit( bool set ) void setCRCNoCheckit( bool set );
{ bool isCRCNoCheckit() const;
crcNoCheckit = set;
}
inline bool isCRCNoCheckit() const
{
return crcNoCheckit;
}
inline void setBroadcastMode( bool set ) void setBroadcastMode( bool set );
{ bool getBroadcastMode() const;
onBroadcast = set;
}
inline bool getBroadcastMode() const
{
return onBroadcast;
}
inline void setCleanBeforeSend( bool set ) void setCleanBeforeSend( bool set );
{ bool getCleanBeforeSend() const;
cleanBeforeSend = set;
}
inline bool getCleanBeforeSend()
{
return cleanBeforeSend;
}
/*! Вспомогательная функция реализующая обработку запроса на установку времени. /*! Вспомогательная функция реализующая обработку запроса на установку времени.
Основана на использовании gettimeofday и settimeofday. Основана на использовании gettimeofday и settimeofday.
...@@ -151,13 +130,10 @@ namespace uniset ...@@ -151,13 +130,10 @@ namespace uniset
typedef std::unordered_map<ModbusRTU::mbErrCode, size_t> ExchangeErrorMap; typedef std::unordered_map<ModbusRTU::mbErrCode, size_t> ExchangeErrorMap;
ExchangeErrorMap getErrorMap(); ExchangeErrorMap getErrorMap();
size_t getErrCount( ModbusRTU::mbErrCode e ); size_t getErrCount( ModbusRTU::mbErrCode e ) const;
size_t resetErrCount( ModbusRTU::mbErrCode e, size_t set = 0 ); size_t resetErrCount( ModbusRTU::mbErrCode e, size_t set = 0 );
inline size_t getAskCount() const size_t getAskCount() const;
{
return askCount;
}
void resetAskCounter(); void resetAskCounter();
protected: protected:
......
...@@ -30,27 +30,15 @@ namespace uniset ...@@ -30,27 +30,15 @@ namespace uniset
static bool checkConnection( const std::string& ip, int port, int timeout_msec = 100 ); static bool checkConnection( const std::string& ip, int port, int timeout_msec = 100 );
inline void setForceDisconnect( bool s ) void setForceDisconnect( bool s );
{
force_disconnect = s;
}
bool reconnect(); bool reconnect();
void cleanInputStream(); void cleanInputStream();
virtual void cleanupChannel() override virtual void cleanupChannel() override;
{
cleanInputStream();
}
inline std::string getAddress() const std::string getAddress() const;
{ int getPort() const;
return iaddr;
}
inline int getPort() const
{
return port;
}
void setReadTimeout( timeout_t msec ); void setReadTimeout( timeout_t msec );
timeout_t getReadTimeout() const; timeout_t getReadTimeout() const;
......
...@@ -51,51 +51,33 @@ namespace uniset ...@@ -51,51 +51,33 @@ namespace uniset
virtual bool isActive() const override; virtual bool isActive() const override;
void setMaxSessions( size_t num ); void setMaxSessions( size_t num );
inline size_t getMaxSessions() size_t getMaxSessions() const;
{
return maxSessions;
}
/*! установить timeout для поддержания соединения с "клиентом" (Default: 10 сек) */ /*! установить timeout для поддержания соединения с "клиентом" (Default: 10 сек) */
void setSessionTimeout( timeout_t msec ); void setSessionTimeout( timeout_t msec );
inline timeout_t getSessionTimeout() timeout_t getSessionTimeout() const;
{
return sessTimeout;
}
/*! текущее количество подключений */ /*! текущее количество подключений */
size_t getCountSessions(); size_t getCountSessions() const;
inline void setIgnoreAddrMode( bool st ) void setIgnoreAddrMode( bool st );
{ bool getIgnoreAddrMode() const;
ignoreAddr = st;
}
inline bool getIgnoreAddrMode()
{
return ignoreAddr;
}
// Сбор статистики по соединениям... // Сбор статистики по соединениям...
struct SessionInfo struct SessionInfo
{ {
SessionInfo( const std::string& a, unsigned int ask ): iaddr(a), askCount(ask) {} SessionInfo( const std::string& a, size_t ask ): iaddr(a), askCount(ask) {}
std::string iaddr; std::string iaddr;
unsigned int askCount; size_t askCount;
}; };
typedef std::list<SessionInfo> Sessions; typedef std::list<SessionInfo> Sessions;
void getSessions( Sessions& lst ); void getSessions( Sessions& lst );
inline std::string getInetAddress() std::string getInetAddress() const;
{ int getInetPort() const;
return iaddr;
}
inline int getInetPort()
{
return port;
}
// ------------------------------------------------- // -------------------------------------------------
// Таймер. // Таймер.
...@@ -108,10 +90,7 @@ namespace uniset ...@@ -108,10 +90,7 @@ namespace uniset
TimerSignal signal_timer(); TimerSignal signal_timer();
void setTimer( timeout_t msec ); void setTimer( timeout_t msec );
inline timeout_t getTimer() inline timeout_t getTimer() const;
{
return tmTime;
}
protected: protected:
......
...@@ -48,10 +48,7 @@ namespace uniset ...@@ -48,10 +48,7 @@ namespace uniset
void connectFinalSession( FinalSlot sl ); void connectFinalSession( FinalSlot sl );
inline std::string getClientAddress() const std::string getClientAddress() const;
{
return caddr;
}
void setSessionTimeout( double t ); void setSessionTimeout( double t );
......
...@@ -298,6 +298,11 @@ void ComPort::setTimeout( timeout_t msec ) ...@@ -298,6 +298,11 @@ void ComPort::setTimeout( timeout_t msec )
uTimeout = msec * 1000; uTimeout = msec * 1000;
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
timeout_t ComPort::getTimeout() const
{
return uTimeout / 1000; // msec
}
// --------------------------------------------------------------------------------
// Lav: ситуация, когда отправлено меньше запрошенного, не типична и должна // Lav: ситуация, когда отправлено меньше запрошенного, не типична и должна
// генерировать исключение // генерировать исключение
size_t ComPort::sendBlock(unsigned char* msg, size_t len) size_t ComPort::sendBlock(unsigned char* msg, size_t len)
...@@ -391,6 +396,11 @@ void ComPort::setSpeed( const std::string& s ) ...@@ -391,6 +396,11 @@ void ComPort::setSpeed( const std::string& s )
setSpeed(sp); setSpeed(sp);
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
ComPort::Speed ComPort::getSpeed() const
{
return speed;
}
// --------------------------------------------------------------------------------
std::string ComPort::getSpeed( Speed s ) std::string ComPort::getSpeed( Speed s )
{ {
if( s == ComSpeed9600 ) if( s == ComSpeed9600 )
......
...@@ -81,6 +81,12 @@ namespace uniset ...@@ -81,6 +81,12 @@ namespace uniset
delete port; delete port;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusRTUMaster::cleanupChannel()
{
if( port )
port->cleanupChannel();
}
// -------------------------------------------------------------------------
void ModbusRTUMaster::setSpeed( ComPort::Speed s ) void ModbusRTUMaster::setSpeed( ComPort::Speed s )
{ {
if( port != NULL ) if( port != NULL )
...@@ -119,7 +125,7 @@ namespace uniset ...@@ -119,7 +125,7 @@ namespace uniset
port->setStopBits(sBit); port->setStopBits(sBit);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
int ModbusRTUMaster::getTimeout() timeout_t ModbusRTUMaster::getTimeout() const
{ {
if( port == NULL ) if( port == NULL )
return 0; return 0;
......
...@@ -63,6 +63,41 @@ namespace uniset ...@@ -63,6 +63,41 @@ namespace uniset
recvTimeOut_ms = msec; recvTimeOut_ms = msec;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusServer::setSleepPause(timeout_t msec)
{
sleepPause_msec = msec;
}
// -------------------------------------------------------------------------
void ModbusServer::setCRCNoCheckit(bool set)
{
crcNoCheckit = set;
}
// -------------------------------------------------------------------------
bool ModbusServer::isCRCNoCheckit() const
{
return crcNoCheckit;
}
// -------------------------------------------------------------------------
void ModbusServer::setBroadcastMode( bool set )
{
onBroadcast = set;
}
// -------------------------------------------------------------------------
bool ModbusServer::getBroadcastMode() const
{
return onBroadcast;
}
// -------------------------------------------------------------------------
void ModbusServer::setCleanBeforeSend(bool set)
{
cleanBeforeSend = set;
}
// -------------------------------------------------------------------------
bool ModbusServer::getCleanBeforeSend() const
{
return cleanBeforeSend;
}
// -------------------------------------------------------------------------
timeout_t ModbusServer::setReplyTimeout( timeout_t msec ) timeout_t ModbusServer::setReplyTimeout( timeout_t msec )
{ {
// #warning "Why msec can be 0?" // #warning "Why msec can be 0?"
...@@ -1675,7 +1710,7 @@ namespace uniset ...@@ -1675,7 +1710,7 @@ namespace uniset
return m; return m;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
size_t ModbusServer::getErrCount( mbErrCode e ) size_t ModbusServer::getErrCount( mbErrCode e ) const
{ {
auto i = errmap.find(e); auto i = errmap.find(e);
...@@ -1697,6 +1732,11 @@ namespace uniset ...@@ -1697,6 +1732,11 @@ namespace uniset
return ret; return ret;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
size_t ModbusServer::getAskCount() const
{
return askCount;
}
// -------------------------------------------------------------------------
void ModbusServer::resetAskCounter() void ModbusServer::resetAskCounter()
{ {
askCount = 0; askCount = 0;
......
...@@ -333,6 +333,21 @@ namespace uniset ...@@ -333,6 +333,21 @@ namespace uniset
catch( ... ) {} catch( ... ) {}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPMaster::cleanupChannel()
{
cleanInputStream();
}
// -------------------------------------------------------------------------
string ModbusTCPMaster::getAddress() const
{
return iaddr;
}
// -------------------------------------------------------------------------
int ModbusTCPMaster::getPort() const
{
return port;
}
// -------------------------------------------------------------------------
void ModbusTCPMaster::setReadTimeout( timeout_t msec ) void ModbusTCPMaster::setReadTimeout( timeout_t msec )
{ {
readTimeout = msec; readTimeout = msec;
...@@ -366,6 +381,11 @@ namespace uniset ...@@ -366,6 +381,11 @@ namespace uniset
return false; return false;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPMaster::setForceDisconnect( bool s )
{
force_disconnect = s;
}
// -------------------------------------------------------------------------
bool ModbusTCPMaster::reconnect() bool ModbusTCPMaster::reconnect()
{ {
if( dlog->is_info() ) if( dlog->is_info() )
......
...@@ -71,16 +71,36 @@ namespace uniset ...@@ -71,16 +71,36 @@ namespace uniset
maxSessions = num; maxSessions = num;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
size_t ModbusTCPServer::getCountSessions() size_t ModbusTCPServer::getMaxSessions() const
{
return maxSessions;
}
// -------------------------------------------------------------------------
size_t ModbusTCPServer::getCountSessions() const
{ {
return sessCount; return sessCount;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPServer::setIgnoreAddrMode(bool st)
{
ignoreAddr = st;
}
// -------------------------------------------------------------------------
bool ModbusTCPServer::getIgnoreAddrMode() const
{
return ignoreAddr;
}
// -------------------------------------------------------------------------
void ModbusTCPServer::setSessionTimeout( timeout_t msec ) void ModbusTCPServer::setSessionTimeout( timeout_t msec )
{ {
sessTimeout = msec; sessTimeout = msec;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
timeout_t ModbusTCPServer::getSessionTimeout() const
{
return sessTimeout;
}
// -------------------------------------------------------------------------
bool ModbusTCPServer::run( const std::unordered_set<ModbusAddr>& _vmbaddr ) bool ModbusTCPServer::run( const std::unordered_set<ModbusAddr>& _vmbaddr )
{ {
vmbaddr = &_vmbaddr; vmbaddr = &_vmbaddr;
...@@ -188,6 +208,16 @@ namespace uniset ...@@ -188,6 +208,16 @@ namespace uniset
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string ModbusTCPServer::getInetAddress() const
{
return iaddr;
}
// -------------------------------------------------------------------------
int ModbusTCPServer::getInetPort() const
{
return port;
}
// -------------------------------------------------------------------------
ModbusTCPServer::TimerSignal ModbusTCPServer::signal_timer() ModbusTCPServer::TimerSignal ModbusTCPServer::signal_timer()
{ {
return m_timer_signal; return m_timer_signal;
...@@ -213,6 +243,11 @@ namespace uniset ...@@ -213,6 +243,11 @@ namespace uniset
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
timeout_t ModbusTCPServer::getTimer() const
{
return tmTime;
}
// -------------------------------------------------------------------------
void ModbusTCPServer::iowait( timeout_t msec ) void ModbusTCPServer::iowait( timeout_t msec )
{ {
ptWait.setTiming(msec); ptWait.setTiming(msec);
......
...@@ -591,4 +591,9 @@ namespace uniset ...@@ -591,4 +591,9 @@ namespace uniset
slFin = sl; slFin = sl;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string ModbusTCPSession::getClientAddress() const
{
return caddr;
}
// -------------------------------------------------------------------------
} // end of namespace uniset } // end of namespace uniset
...@@ -54,6 +54,11 @@ void LogReader::setLogLevel( Debug::type t ) ...@@ -54,6 +54,11 @@ void LogReader::setLogLevel( Debug::type t )
outlog->level(t); outlog->level(t);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::shared_ptr<DebugStream> LogReader::log()
{
return outlog;
}
// -------------------------------------------------------------------------
DebugStream::StreamEvent_Signal LogReader::signal_stream_event() DebugStream::StreamEvent_Signal LogReader::signal_stream_event()
{ {
return m_logsig; return m_logsig;
...@@ -148,6 +153,36 @@ bool LogReader::isConnection() const ...@@ -148,6 +153,36 @@ bool LogReader::isConnection() const
return (tcp && tcp->isConnected() ); return (tcp && tcp->isConnected() );
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void LogReader::setReadCount(unsigned int n)
{
readcount = n;
}
// -------------------------------------------------------------------------
void LogReader::setCommandOnlyMode(bool s)
{
cmdonly = s;
}
// -------------------------------------------------------------------------
void LogReader::setinTimeout(timeout_t msec)
{
inTimeout = msec;
}
// -------------------------------------------------------------------------
void LogReader::setoutTimeout(timeout_t msec)
{
outTimeout = msec;
}
// -------------------------------------------------------------------------
void LogReader::setReconnectDelay(timeout_t msec)
{
reconDelay = msec;
}
// -------------------------------------------------------------------------
void LogReader::setTextFilter(const string& f)
{
textfilter = f;
}
// -------------------------------------------------------------------------
void LogReader::sendCommand(const std::string& _addr, int _port, std::vector<Command>& vcmd, bool cmd_only, bool verbose ) void LogReader::sendCommand(const std::string& _addr, int _port, std::vector<Command>& vcmd, bool cmd_only, bool verbose )
{ {
if( vcmd.empty() ) if( vcmd.empty() )
......
...@@ -41,6 +41,21 @@ namespace uniset ...@@ -41,6 +41,21 @@ namespace uniset
catch(...) {} catch(...) {}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void LogServer::setCmdTimeout( timeout_t msec ) noexcept
{
cmdTimeout = msec;
}
// -------------------------------------------------------------------------
void LogServer::setSessionLog( Debug::type t ) noexcept
{
sessLogLevel = t;
}
// -------------------------------------------------------------------------
void LogServer::setMaxSessionCount( size_t num ) noexcept
{
sessMaxCount = num;
}
// -------------------------------------------------------------------------
LogServer::LogServer( std::shared_ptr<LogAgregator> log ): LogServer::LogServer( std::shared_ptr<LogAgregator> log ):
LogServer() LogServer()
{ {
...@@ -111,6 +126,11 @@ namespace uniset ...@@ -111,6 +126,11 @@ namespace uniset
mylog.info() << myname << "(LogServer): finished." << endl; mylog.info() << myname << "(LogServer): finished." << endl;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::string LogServer::wname() const noexcept
{
return myname;
}
// -------------------------------------------------------------------------
bool LogServer::run( const std::string& _addr, Poco::UInt16 _port ) bool LogServer::run( const std::string& _addr, Poco::UInt16 _port )
{ {
addr = _addr; addr = _addr;
...@@ -143,6 +163,11 @@ namespace uniset ...@@ -143,6 +163,11 @@ namespace uniset
loop.evstop(this); loop.evstop(this);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool LogServer::isRunning() const noexcept
{
return isrunning;
}
// -------------------------------------------------------------------------
bool LogServer::check( bool restart_if_fail ) bool LogServer::check( bool restart_if_fail )
{ {
// смущает пока только, что эта функция будет вызыватся (обычно) из другого потока // смущает пока только, что эта функция будет вызыватся (обычно) из другого потока
......
...@@ -636,6 +636,26 @@ namespace uniset ...@@ -636,6 +636,26 @@ namespace uniset
cancelled = true; cancelled = true;
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
string LogSession::getClientAddress() const noexcept
{
return caddr;
}
// ---------------------------------------------------------------------
void LogSession::setSessionLogLevel(Debug::type t) noexcept
{
mylog.level(t);
}
// ---------------------------------------------------------------------
void LogSession::addSessionLogLevel(Debug::type t) noexcept
{
mylog.addLevel(t);
}
// ---------------------------------------------------------------------
void LogSession::delSessionLogLevel(Debug::type t) noexcept
{
mylog.delLevel(t);
}
// ---------------------------------------------------------------------
void LogSession::setMaxBufSize( size_t num ) void LogSession::setMaxBufSize( size_t num )
{ {
std::unique_lock<std::mutex> lk(logbuf_mutex); std::unique_lock<std::mutex> lk(logbuf_mutex);
......
...@@ -34,6 +34,16 @@ string ObjectIndex::getNameById( const ObjectId id ) const noexcept ...@@ -34,6 +34,16 @@ string ObjectIndex::getNameById( const ObjectId id ) const noexcept
return getMapName(id); return getMapName(id);
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
std::string ObjectIndex::getNodeName(const ObjectId id) const noexcept
{
return getNameById(id);
}
// -----------------------------------------------------------------------------------------
ObjectId ObjectIndex::getNodeId(const std::__cxx11::string& name) const noexcept
{
return getIdByName(name);
}
// -----------------------------------------------------------------------------------------
std::string ObjectIndex::getBaseName( const std::string& fname ) noexcept std::string ObjectIndex::getBaseName( const std::string& fname ) noexcept
{ {
string::size_type pos = fname.rfind('/'); string::size_type pos = fname.rfind('/');
......
...@@ -308,7 +308,7 @@ throw(ORepFailed, NameNotFound) ...@@ -308,7 +308,7 @@ throw(ORepFailed, NameNotFound)
* количество объектов в этой секции превышает заданное how_many. * количество объектов в этой секции превышает заданное how_many.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции * \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/ */
bool ObjectRepository::list(const string& section, ListObjectName* ls, size_t how_many)throw(ORepFailed) bool ObjectRepository::list(const string& section, ListObjectName* ls, size_t how_many) const throw(ORepFailed)
{ {
return list(section, ls, how_many, ObjectRef); return list(section, ls, how_many, ObjectRef);
} }
...@@ -322,7 +322,7 @@ bool ObjectRepository::list(const string& section, ListObjectName* ls, size_t ho ...@@ -322,7 +322,7 @@ bool ObjectRepository::list(const string& section, ListObjectName* ls, size_t ho
* количество объектов в этой секции превышает заданное how_many. * количество объектов в этой секции превышает заданное how_many.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции * \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/ */
bool ObjectRepository::listSections(const string& in_section, ListObjectName* ls, size_t how_many)throw(ORepFailed) bool ObjectRepository::listSections(const string& in_section, ListObjectName* ls, size_t how_many) const throw(ORepFailed)
{ {
return list(in_section, ls, how_many, Section); return list(in_section, ls, how_many, Section);
} }
...@@ -337,7 +337,7 @@ bool ObjectRepository::listSections(const string& in_section, ListObjectName* ls ...@@ -337,7 +337,7 @@ bool ObjectRepository::listSections(const string& in_section, ListObjectName* ls
* количество объектов в этой секции превышает заданное how_many. * количество объектов в этой секции превышает заданное how_many.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции * \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/ */
bool ObjectRepository::list(const string& section, ListObjectName* ls, unsigned int how_many, ObjectType type) bool ObjectRepository::list(const string& section, ListObjectName* ls, unsigned int how_many, ObjectType type) const
{ {
// Возвращает false если вынут не весь список... // Возвращает false если вынут не весь список...
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
...@@ -563,7 +563,7 @@ bool ObjectRepository::createContext( const string& cname, CosNaming::NamingCont ...@@ -563,7 +563,7 @@ bool ObjectRepository::createContext( const string& cname, CosNaming::NamingCont
/*! /*!
\note Функция не вывести список, если не сможет получить доступ к секции \note Функция не вывести список, если не сможет получить доступ к секции
*/ */
void ObjectRepository::printSection( const string& fullName ) void ObjectRepository::printSection( const string& fullName ) const
{ {
ListObjectName ls; ListObjectName ls;
......
...@@ -654,11 +654,6 @@ void IOController::USensorInfo::init( const IOController_i::SensorIOInfo& s ) ...@@ -654,11 +654,6 @@ void IOController::USensorInfo::init( const IOController_i::SensorIOInfo& s )
(*this) = std::move(r); (*this) = std::move(r);
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
size_t IOController::ioCount()
{
return ioList.size();
}
// ----------------------------------------------------------------------------------------
IOController::IOStateList::iterator IOController::myioBegin() IOController::IOStateList::iterator IOController::myioBegin()
{ {
return ioList.begin(); return ioList.begin();
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <string> #include <string>
#include <cassert>
#include <omniORB4/internal/initRefs.h> #include <omniORB4/internal/initRefs.h>
#include "Configuration.h" #include "Configuration.h"
...@@ -73,8 +74,8 @@ ostream& uniset::Configuration::help(ostream& os) ...@@ -73,8 +74,8 @@ ostream& uniset::Configuration::help(ostream& os)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
namespace uniset namespace uniset
{ {
static shared_ptr<Configuration> uconf; static std::shared_ptr<Configuration> uconf;
static std::shared_ptr<DebugStream> _ulog = nullptr; static std::shared_ptr<DebugStream> _ulog;
std::shared_ptr<DebugStream> ulog() noexcept std::shared_ptr<DebugStream> ulog() noexcept
{ {
...@@ -88,8 +89,14 @@ namespace uniset ...@@ -88,8 +89,14 @@ namespace uniset
std::shared_ptr<Configuration> uniset_conf() noexcept std::shared_ptr<Configuration> uniset_conf() noexcept
{ {
// if( uconf == nullptr ) // Не делаем assert или exception
// throw SystemError("Don`t init uniset configuration! First use uniset_init()."); // потому-что считаем, что может быть необходимость не вызывать uniset_init()
// Т.е. проверка if( uconf ) возлагается на пользователя.
// assert( uconf );
// if( uconf == nullptr )
// throw SystemError("Don`t init uniset configuration! First use uniset_init().");
return uconf; // см. uniset_init.. return uconf; // см. uniset_init..
} }
......
...@@ -170,8 +170,8 @@ timeout_t LT_Object::askTimer( uniset::TimerId timerid, timeout_t timeMS, clock_ ...@@ -170,8 +170,8 @@ timeout_t LT_Object::askTimer( uniset::TimerId timerid, timeout_t timeMS, clock_
{ {
if( timeMS < UniSetTimer::MinQuantityTime ) if( timeMS < UniSetTimer::MinQuantityTime )
{ {
ucrit << "(LT_askTimer): [мс] попытка заказть таймер " << getTimerName(timerid) ucrit << "(LT_askTimer): [мс] попытка заказать таймер " << getTimerName(timerid)
<< " со временем срабатыания " << " со временем срабатывания "
<< " меньше разрешённого " << UniSetTimer::MinQuantityTime << endl; << " меньше разрешённого " << UniSetTimer::MinQuantityTime << endl;
timeMS = UniSetTimer::MinQuantityTime; timeMS = UniSetTimer::MinQuantityTime;
} }
......
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