Commit 070f1f5b authored by Pavel Vainerman's avatar Pavel Vainerman

Расставляю const потихоньку

parent 60689442
......@@ -237,13 +237,13 @@
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true );
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true ) const;
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true );
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true ) const;
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
......@@ -1184,7 +1184,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
return std::move(s.str());
}
// ----------------------------------------------------------------------------
std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId id, bool showLinkName )
std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId id, bool showLinkName ) const
{
ostringstream s;
<xsl:for-each select="//smap/item">
......@@ -1198,7 +1198,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId
return "";
}
// ----------------------------------------------------------------------------
std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::ObjectId id, bool showLinkName )
std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::ObjectId id, bool showLinkName ) const
{
ostringstream s;
<xsl:for-each select="//smap/item">
......@@ -1511,7 +1511,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
return std::move(s.str());
}
// ----------------------------------------------------------------------------
std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId id, bool showLinkName )
std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId id, bool showLinkName ) const
{
ostringstream s;
<xsl:for-each select="//sensors/item/consumers/consumer">
......@@ -1529,7 +1529,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId
return "";
}
// ----------------------------------------------------------------------------
std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::ObjectId id, bool showLinkName )
std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::ObjectId id, bool showLinkName ) const
{
ostringstream s;
<xsl:for-each select="//sensors/item/consumers/consumer">
......
......@@ -64,7 +64,6 @@ class ComediInterface
void configureSubdev( int subdev, SubdevType type ) throw(UniSetTypes::Exception);
void configureChannel( int subdev, int channel, ChannelType type, int range = 0, int aref = 0 )
throw(UniSetTypes::Exception);
......
......@@ -186,15 +186,15 @@ class CardList:
{
public:
explicit CardList( int size ) : std::vector<ComediInterface * >(size) { }
explicit CardList( size_t size ) : std::vector<ComediInterface*>(size) { }
~CardList()
{
for( unsigned int i = 0; i < size(); i++ )
for( size_t i = 0; i < size(); i++ )
delete (*this)[i];
}
inline ComediInterface* getCard(int ncard)
inline ComediInterface* getCard(int ncard) const
{
if( ncard >= 0 && ncard < (int)size() )
return (*this)[ncard];
......@@ -258,7 +258,7 @@ class IOControl:
int subdev; /*!< (UNIO) подустройство (см. comedi_test для конкретной карты в/в) */
int channel; /*!< (UNIO) канал [0...23] */
int ncard; /*!< номер карты [1|2]. 0 - не определена. FIXME from Lav: -1 - не определена? */
int ncard; /*!< номер карты [1|2]. -1 - не определена. */
/*! Вид поключения
0 - analog ref = analog ground
......@@ -286,19 +286,19 @@ class IOControl:
struct IOPriority
{
IOPriority(int p, int i):
IOPriority(size_t p, size_t i):
priority(p), index(i) {}
int priority;
int index;
size_t priority;
size_t index;
};
enum TestModeID
{
tmNone = 0, /*!< тестовый режим отключён */
tmOffPoll = 1, /*!< отключить опрос */
tmConfigEnable = 2, /*!< специальный режим, в соответсвии с настройкой 'enable_testmode' */
tmConfigDisable = 3, /*!< специальный режим, в соответсвии с настройкой 'disable_testmode' */
tmConfigEnable = 2, /*!< специальный режим, в соответствии с настройкой 'enable_testmode' */
tmConfigDisable = 3, /*!< специальный режим, в соответствии с настройкой 'disable_testmode' */
tmOnlyInputs = 4, /*!< включены только входы */
tmOnlyOutputs = 5 /*!< включены только выходы */
};
......@@ -335,8 +335,6 @@ class IOControl:
void waitSM();
bool checkCards( const std::string& func = "" );
xmlNode* cnode = { 0 }; /*!< xml-узел в настроечном файле */
int polltime = { 150 }; /*!< переодичность обновления данных (опроса карт в/в), [мсек] */
......@@ -403,8 +401,7 @@ class IOControl:
bool readconf_ok = { false };
int activateTimeout;
UniSetTypes::ObjectId sidTestSMReady = { UniSetTypes::DefaultObjectId };
bool term = { false };
std::atomic_bool term = { false };
UniSetTypes::ObjectId testMode_as = { UniSetTypes::DefaultObjectId };
IOController::IOStateList::iterator itTestMode;
......
......@@ -23,7 +23,7 @@ using namespace std;
const Element::ElementID Element::DefaultElementID = "?id?";
// -------------------------------------------------------------------------
void Element::addChildOut( std::shared_ptr<Element> el, int num )
void Element::addChildOut( std::shared_ptr<Element> el, size_t num )
{
if( el.get() == this )
{
......@@ -90,7 +90,7 @@ std::shared_ptr<Element> Element::find(const ElementID& id )
return nullptr;
}
// -------------------------------------------------------------------------
void Element::addInput(int num, bool state)
void Element::addInput(size_t num, bool state)
{
for( auto& it : ins )
{
......@@ -105,7 +105,7 @@ void Element::addInput(int num, bool state)
ins.push_front(InputInfo(num, state));
}
// -------------------------------------------------------------------------
void Element::delInput( int num )
void Element::delInput(size_t num )
{
for( auto it = ins.begin(); it != ins.end(); ++it )
{
......
......@@ -57,30 +57,30 @@ class Element
*/
virtual void tick() {}
virtual void setIn( int num, bool state ) = 0;
virtual bool getOut() = 0;
virtual void setIn( size_t num, bool state ) = 0;
virtual bool getOut() const = 0;
inline ElementID getId()
inline ElementID getId() const
{
return myid;
}
virtual std::string getType()
virtual std::string getType() const
{
return "?type?";
}
virtual std::shared_ptr<Element> find( const ElementID& id );
virtual void addChildOut( std::shared_ptr<Element> el, int in_num );
virtual void addChildOut( std::shared_ptr<Element> el, size_t in_num );
virtual void delChildOut( std::shared_ptr<Element> el );
inline int outCount()
inline size_t outCount() const
{
return outs.size();
}
virtual void addInput( int num, bool state = false );
virtual void delInput( int num );
inline int inCount()
virtual void addInput( size_t num, bool state = false );
virtual void delInput( size_t num );
inline size_t inCount() const
{
return ins.size();
}
......@@ -103,24 +103,23 @@ class Element
struct ChildInfo
{
ChildInfo(std::shared_ptr<Element> e, int n):
ChildInfo(std::shared_ptr<Element> e, size_t n):
el(e), num(n) {}
ChildInfo(): el(0), num(0) {}
std::shared_ptr<Element> el;
int num;
size_t num;
};
typedef std::list<ChildInfo> OutputList;
OutputList outs;
virtual void setChildOut();
struct InputInfo
{
InputInfo(): num(0), state(false), type(unknown) {}
InputInfo(int n, bool s): num(n), state(s), type(unknown) {}
int num;
InputInfo(size_t n, bool s): num(n), state(s), type(unknown) {}
size_t num;
bool state;
InputType type;
};
......@@ -140,16 +139,16 @@ class TOR:
{
public:
TOR( ElementID id, unsigned int numbers = 0, bool st = false );
TOR( ElementID id,size_t numbers = 0, bool st = false );
virtual ~TOR();
virtual void setIn( int num, bool state ) override;
virtual bool getOut() override
virtual void setIn( size_t num, bool state ) override;
virtual bool getOut() const override
{
return myout;
}
virtual std::string getType() override
virtual std::string getType() const override
{
return "OR";
}
......@@ -167,11 +166,11 @@ class TAND:
{
public:
TAND( ElementID id, int numbers = 0, bool st = false );
TAND(ElementID id, size_t numbers = 0, bool st = false );
virtual ~TAND();
virtual void setIn( int num, bool state ) override;
virtual std::string getType() override
virtual void setIn( size_t num, bool state ) override;
virtual std::string getType() const override
{
return "AND";
}
......@@ -192,20 +191,20 @@ class TNOT:
TNOT( ElementID id, bool out_default );
virtual ~TNOT();
virtual bool getOut() override
virtual bool getOut() const override
{
return myout;
}
/* num игнорируется, т.к. элемент с одним входом
*/
virtual void setIn( int num, bool state ) override ;
virtual std::string getType() override
virtual void setIn( size_t num, bool state ) override ;
virtual std::string getType() const override
{
return "NOT";
}
virtual void addInput( int num, bool state = false ) override {}
virtual void delInput( int num ) override {}
virtual void addInput( size_t num, bool state = false ) override {}
virtual void delInput( size_t num ) override {}
protected:
TNOT(): myout(false) {}
......
......@@ -116,7 +116,7 @@ class LProcessor
void open( const std::string& lfile );
inline bool isOpen()
inline bool isOpen() const
{
return !fSchema.empty();
}
......@@ -133,7 +133,7 @@ class LProcessor
return sch;
}
inline int getSleepTime()
inline int getSleepTime() const
{
return sleepTime;
}
......
......@@ -21,7 +21,7 @@
using namespace std;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
TAND::TAND(ElementID id, int num, bool st):
TAND::TAND(ElementID id, size_t num, bool st):
TOR(id, num, st)
{
}
......@@ -30,7 +30,7 @@ TAND::~TAND()
{
}
// -------------------------------------------------------------------------
void TAND::setIn( int num, bool state )
void TAND::setIn(size_t num, bool state )
{
// cout << this << ": input " << num << " set " << state << endl;
for( auto& it : ins )
......
......@@ -21,7 +21,7 @@
using namespace std;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
TDelay::TDelay( Element::ElementID id, timeout_t delayMS, unsigned int inCount):
TDelay::TDelay(Element::ElementID id, timeout_t delayMS, size_t inCount):
Element(id),
myout(false),
delay(delayMS)
......@@ -38,7 +38,7 @@ TDelay::~TDelay()
{
}
// -------------------------------------------------------------------------
void TDelay::setIn( int num, bool state )
void TDelay::setIn( size_t num, bool state )
{
bool prev = myout;
......@@ -89,7 +89,7 @@ void TDelay::tick()
}
}
// -------------------------------------------------------------------------
bool TDelay::getOut()
bool TDelay::getOut() const
{
return myout;
}
......
......@@ -27,14 +27,13 @@ class TDelay:
{
public:
TDelay( Element::ElementID id, timeout_t delayMS = 0, unsigned int inCount = 0 );
TDelay( Element::ElementID id, timeout_t delayMS = 0, size_t inCount = 0 );
virtual ~TDelay();
virtual void tick() override;
virtual void setIn( int num, bool state ) override;
virtual bool getOut() override;
virtual std::string getType() override
virtual void setIn( size_t num, bool state ) override;
virtual bool getOut() const override;
virtual std::string getType() const override
{
return "Delay";
}
......
......@@ -33,7 +33,7 @@ TNOT::~TNOT()
{
}
// -------------------------------------------------------------------------
void TNOT::setIn( int num, bool state )
void TNOT::setIn( size_t num, bool state )
{
bool prev = myout;
myout = !state;
......
......@@ -22,7 +22,7 @@
using namespace std;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
TOR::TOR(ElementID id, unsigned int num, bool st):
TOR::TOR(ElementID id, size_t num, bool st):
Element(id),
myout(false)
{
......@@ -43,7 +43,7 @@ TOR::~TOR()
{
}
// -------------------------------------------------------------------------
void TOR::setIn( int num, bool state )
void TOR::setIn( size_t num, bool state )
{
// cout << getType() << "(" << myid << "): input " << num << " set " << state << endl;
......
......@@ -327,7 +327,7 @@ void MBExchange::step()
}
// -----------------------------------------------------------------------------
bool MBExchange::checkProcActive()
bool MBExchange::checkProcActive() const
{
return activated;
}
......@@ -509,7 +509,7 @@ bool MBExchange::checkUpdateSM( bool wrFunc, long mdev )
return true;
}
// -----------------------------------------------------------------------------
bool MBExchange::checkPoll( bool wrFunc )
bool MBExchange::checkPoll( bool wrFunc ) const
{
if( exchangeMode == emWriteOnly && !wrFunc )
{
......@@ -1463,14 +1463,14 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
VTypes::F2 f2(f);
for( int k = 0; k < VTypes::F2::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::F2::wsize(); k++, i++ )
i->second->mbval = f2.raw.v[k];
}
else if( p->vType == VTypes::vtF2r )
{
VTypes::F2r f2(f);
for( int k = 0; k < VTypes::F2r::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::F2r::wsize(); k++, i++ )
i->second->mbval = f2.raw.v[k];
}
......@@ -1481,7 +1481,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::F2::wsize()];
for( int k = 0; k < VTypes::F2::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::F2::wsize(); k++, i++ )
data[k] = i->second->mbval;
float f = 0;
......@@ -1513,7 +1513,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
float f = IOBase::processingFasAO( p, shm, force_out );
VTypes::F4 f4(f);
for( int k = 0; k < VTypes::F4::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::F4::wsize(); k++, i++ )
i->second->mbval = f4.raw.v[k];
r->sm_initOK = true;
......@@ -1523,7 +1523,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::F4::wsize()];
for( int k = 0; k < VTypes::F4::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::F4::wsize(); k++, i++ )
data[k] = i->second->mbval;
VTypes::F4 f(data, VTypes::F4::wsize());
......@@ -1546,14 +1546,14 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
VTypes::I2 i2(v);
for( int k = 0; k < VTypes::I2::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::I2::wsize(); k++, i++ )
i->second->mbval = i2.raw.v[k];
}
else if( p->vType == VTypes::vtI2r )
{
VTypes::I2r i2(v);
for( int k = 0; k < VTypes::I2::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::I2::wsize(); k++, i++ )
i->second->mbval = i2.raw.v[k];
}
......@@ -1564,7 +1564,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::I2::wsize()];
for( int k = 0; k < VTypes::I2::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::I2::wsize(); k++, i++ )
data[k] = i->second->mbval;
int v = 0;
......@@ -1598,14 +1598,14 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
VTypes::U2 u2(v);
for( int k = 0; k < VTypes::U2::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::U2::wsize(); k++, i++ )
i->second->mbval = u2.raw.v[k];
}
else if( p->vType == VTypes::vtU2r )
{
VTypes::U2r u2(v);
for( int k = 0; k < VTypes::U2::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::U2::wsize(); k++, i++ )
i->second->mbval = u2.raw.v[k];
}
......@@ -1616,7 +1616,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
ModbusRTU::ModbusData* data = new ModbusRTU::ModbusData[VTypes::U2::wsize()];
for( int k = 0; k < VTypes::U2::wsize(); k++, i++ )
for( size_t k = 0; k < VTypes::U2::wsize(); k++, i++ )
data[k] = i->second->mbval;
unsigned int v = 0;
......
......@@ -301,9 +301,9 @@ class MBExchange:
virtual void updateRespondSensors();
bool checkUpdateSM( bool wrFunc, long devMode );
bool checkPoll( bool wrFunc );
bool checkPoll( bool wrFunc ) const;
bool checkProcActive();
bool checkProcActive() const;
void setProcActive( bool st );
void waitSMReady();
......
......@@ -316,7 +316,7 @@ void MBTCPMultiMaster::final_thread()
}
// -----------------------------------------------------------------------------
bool MBTCPMultiMaster::MBSlaveInfo::check()
bool MBTCPMultiMaster::MBSlaveInfo::check() const
{
return mbtcp->checkConnection(ip, port, recv_timeout);
}
......
......@@ -302,7 +302,7 @@ class MBTCPMultiMaster:
}
bool init( std::shared_ptr<DebugStream>& mblog );
bool check();
bool check() const;
inline void setUse( bool st )
{
respond_init = !( st && !use );
......
......@@ -317,7 +317,7 @@ size_t UDPMessage::getMessage( UDPMessage& m, UDPPacket& p )
return i + sz;
}
// -----------------------------------------------------------------------------
uint16_t UDPMessage::getDataCRC()
uint16_t UDPMessage::getDataCRC() const
{
uint16_t crc[3];
crc[0] = makeCRC( (unsigned char*)(a_dat), sizeof(a_dat) );
......
......@@ -128,7 +128,7 @@ namespace UniSetUDP
return acount;
}
uint16_t getDataCRC();
uint16_t getDataCRC() const;
// количество байт в пакете с булевыми переменными...
size_t d_byte() const
......
......@@ -54,7 +54,7 @@ namespace MTR
// -------------------------------------------------------------------------
std::string type2str( MTRType t ); /*!< преоразование строки в тип */
MTRType str2type( const std::string& s ); /*!< преобразование названия в строку */
int wsize( MTRType t ); /*!< длина данных в словах */
size_t wsize( MTRType t ); /*!< длина данных в словах */
// -------------------------------------------------------------------------
// Информация
const ModbusRTU::ModbusData regModelNumber = 0x01;
......@@ -129,7 +129,7 @@ namespace MTR
void update_communication_params( ModbusRTU::ModbusAddr reg, ModbusRTU::ModbusData data,
ModbusRTUMaster* mb, ModbusRTU::ModbusAddr& addr, int verb );
// -------------------------------------------------------------------------
static const int u2size = 2;
static const size_t u2size = 2;
// -------------------------------------------------------------------------
class T1
{
......@@ -140,7 +140,7 @@ namespace MTR
~T1() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return 1;
}
......@@ -163,7 +163,7 @@ namespace MTR
~T2() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return 1;
}
......@@ -205,7 +205,7 @@ namespace MTR
raw.v[1] = v2;
}
T3( const ModbusRTU::ModbusData* data, int size )
T3( const ModbusRTU::ModbusData* data, size_t size )
{
if( size >= u2size )
{
......@@ -218,7 +218,7 @@ namespace MTR
~T3() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return u2size;
}
......@@ -262,7 +262,7 @@ namespace MTR
~T4() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return 1;
}
......@@ -311,7 +311,7 @@ namespace MTR
val = raw.u2.val * pow( (long)10, (long)raw.u2.exp );
}
T5( const ModbusRTU::ModbusData* data, int size ): val(0)
T5( const ModbusRTU::ModbusData* data, size_t size ): val(0)
{
if( size >= u2size )
{
......@@ -325,7 +325,7 @@ namespace MTR
~T5() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return u2size;
}
......@@ -374,7 +374,7 @@ namespace MTR
val = raw.u2.val * pow( (long)10, (long)raw.u2.exp );
}
T6( const ModbusRTU::ModbusData* data, int size )
T6( const ModbusRTU::ModbusData* data, size_t size )
{
if( size >= u2size )
{
......@@ -388,7 +388,7 @@ namespace MTR
~T6() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return u2size;
}
......@@ -437,7 +437,7 @@ namespace MTR
val = raw.u2.val * pow( (long)10, (long) - 4 );
}
T7( const ModbusRTU::ModbusData* data, int size )
T7( const ModbusRTU::ModbusData* data, size_t size )
{
if( size >= u2size )
{
......@@ -451,7 +451,7 @@ namespace MTR
~T7() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return u2size;
}
......@@ -494,7 +494,7 @@ namespace MTR
raw.v[1] = v2;
}
T8( const ModbusRTU::ModbusData* data, int size )
T8( const ModbusRTU::ModbusData* data, size_t size )
{
if( size >= u2size )
{
......@@ -524,7 +524,7 @@ namespace MTR
~T8() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return u2size;
}
......@@ -566,7 +566,7 @@ namespace MTR
raw.v[1] = v2;
}
T9( const ModbusRTU::ModbusData* data, int size )
T9( const ModbusRTU::ModbusData* data, size_t size )
{
if( size >= u2size )
{
......@@ -596,7 +596,7 @@ namespace MTR
~T9() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return u2size;
}
......@@ -637,7 +637,7 @@ namespace MTR
raw.v[1] = v2;
}
T10( const ModbusRTU::ModbusData* data, int size )
T10( const ModbusRTU::ModbusData* data, size_t size )
{
if( size >= u2size )
{
......@@ -663,7 +663,7 @@ namespace MTR
~T10() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return u2size;
}
......@@ -698,7 +698,7 @@ namespace MTR
~T16() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return 1;
}
......@@ -746,7 +746,7 @@ namespace MTR
~T17() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return 1;
}
......@@ -797,7 +797,7 @@ namespace MTR
raw.val = f;
}
F1( const ModbusRTU::ModbusData* data, int size )
F1( const ModbusRTU::ModbusData* data, size_t size )
{
if( size >= u2size )
{
......@@ -810,7 +810,7 @@ namespace MTR
~F1() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return u2size;
}
......@@ -855,7 +855,7 @@ namespace MTR
~T_Str16() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return 8;
}
......@@ -892,7 +892,7 @@ namespace MTR
~T_Str8() {}
// ------------------------------------------
/*! размер в словах */
static unsigned int wsize()
static size_t wsize()
{
return 4;
}
......
......@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2016-07-26+03:00
// generate timestamp: 2016-08-01+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
......@@ -107,13 +107,13 @@ class UObject_SK:
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true );
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true ) const;
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true );
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true ) const;
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
......
......@@ -54,7 +54,7 @@ namespace VTypes
public:
// ------------------------------------------
static const int f2Size = 2;
static const size_t f2Size = 2;
/*! тип хранения в памяти */
typedef union
{
......@@ -72,16 +72,16 @@ namespace VTypes
{
raw.val = f;
}
F2( const ModbusRTU::ModbusData* data, int size )
F2( const ModbusRTU::ModbusData* data, size_t size )
{
for( int i = 0; i < wsize() && i < size; i++ )
for( size_t i = 0; i < wsize() && i < size; i++ )
raw.v[i] = data[i];
}
~F2() {}
// ------------------------------------------
/*! размер в словах */
static int wsize()
static size_t wsize()
{
return f2Size;
}
......@@ -121,7 +121,7 @@ namespace VTypes
raw_backorder = raw;
std::swap(raw_backorder.v[0], raw_backorder.v[1]);
}
F2r( const ModbusRTU::ModbusData* data, int size ): F2(data, size)
F2r( const ModbusRTU::ModbusData* data, size_t size ): F2(data, size)
{
// принимаем в обратном порядке.. поэтому переворачиваем raw
raw_backorder = raw;
......@@ -137,7 +137,7 @@ namespace VTypes
{
public:
// ------------------------------------------
static const int f4Size = 4;
static const size_t f4Size = 4;
/*! тип хранения в памяти */
typedef union
{
......@@ -155,16 +155,16 @@ namespace VTypes
{
raw.val = f;
}
F4( const ModbusRTU::ModbusData* data, int size )
F4( const ModbusRTU::ModbusData* data, size_t size )
{
for( int i = 0; i < wsize() && i < size; i++ )
for( size_t i = 0; i < wsize() && i < size; i++ )
raw.v[i] = data[i];
}
~F4() {}
// ------------------------------------------
/*! размер в словах */
static int wsize()
static size_t wsize()
{
return f4Size;
}
......@@ -190,7 +190,7 @@ namespace VTypes
{
public:
static const int bsize = 2;
static const size_t bsize = 2;
// ------------------------------------------
/*! тип хранения в памяти */
......@@ -224,7 +224,7 @@ namespace VTypes
~Byte() {}
// ------------------------------------------
/*! размер в словах */
static int wsize()
static size_t wsize()
{
return 1;
}
......@@ -272,7 +272,7 @@ namespace VTypes
~Unsigned() {}
// ------------------------------------------
/*! размер в словах */
static int wsize()
static size_t wsize()
{
return 1;
}
......@@ -311,7 +311,7 @@ namespace VTypes
~Signed() {}
// ------------------------------------------
/*! размер в словах */
static int wsize()
static size_t wsize()
{
return 1;
}
......@@ -334,7 +334,7 @@ namespace VTypes
public:
// ------------------------------------------
static const int i2Size = 2;
static const size_t i2Size = 2;
/*! тип хранения в памяти */
typedef union
{
......@@ -352,16 +352,16 @@ namespace VTypes
{
raw.val = v;
}
I2( const ModbusRTU::ModbusData* data, int size )
I2( const ModbusRTU::ModbusData* data, size_t size )
{
for( int i = 0; i < wsize() && i < size; i++ )
for( size_t i = 0; i < wsize() && i < size; i++ )
raw.v[i] = data[i];
}
~I2() {}
// ------------------------------------------
/*! размер в словах */
static int wsize()
static size_t wsize()
{
return i2Size;
}
......@@ -390,7 +390,7 @@ namespace VTypes
raw_backorder = raw;
std::swap(raw_backorder.v[0], raw_backorder.v[1]);
}
I2r( const ModbusRTU::ModbusData* data, int size ): I2(data, size)
I2r( const ModbusRTU::ModbusData* data, size_t size ): I2(data, size)
{
// принимаем в обратном порядке.. поэтому переворачиваем raw
raw_backorder = raw;
......@@ -407,7 +407,7 @@ namespace VTypes
public:
// ------------------------------------------
static const int u2Size = 2;
static const size_t u2Size = 2;
/*! тип хранения в памяти */
typedef union
{
......@@ -425,16 +425,16 @@ namespace VTypes
{
raw.val = v;
}
U2( const ModbusRTU::ModbusData* data, int size )
U2( const ModbusRTU::ModbusData* data, size_t size )
{
for( int i = 0; i < wsize() && i < size; i++ )
for( size_t i = 0; i < wsize() && i < size; i++ )
raw.v[i] = data[i];
}
~U2() {}
// ------------------------------------------
/*! размер в словах */
static int wsize()
static size_t wsize()
{
return u2Size;
}
......@@ -463,7 +463,7 @@ namespace VTypes
raw_backorder = raw;
std::swap(raw_backorder.v[0], raw_backorder.v[1]);
}
U2r( const ModbusRTU::ModbusData* data, int size ): U2(data, size)
U2r( const ModbusRTU::ModbusData* data, size_t size ): U2(data, size)
{
// принимаем в обратном порядке.. поэтому переворачиваем raw
raw_backorder = raw;
......
......@@ -128,7 +128,7 @@ namespace MTR
return "Unknown";
}
// -------------------------------------------------------------------------
int wsize( MTRType t )
size_t wsize( MTRType t )
{
if( t == mtT1 )
return T1::wsize();
......
......@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2016-07-26+03:00
// generate timestamp: 2016-08-01+03:00
// -----------------------------------------------------------------------------
#include <memory>
#include <iomanip>
......@@ -305,14 +305,14 @@ std::string UObject_SK::dumpIO()
return std::move(s.str());
}
// ----------------------------------------------------------------------------
std::string UObject_SK::str( UniSetTypes::ObjectId id, bool showLinkName )
std::string UObject_SK::str( UniSetTypes::ObjectId id, bool showLinkName ) const
{
ostringstream s;
return "";
}
// ----------------------------------------------------------------------------
std::string UObject_SK::strval( UniSetTypes::ObjectId id, bool showLinkName )
std::string UObject_SK::strval( UniSetTypes::ObjectId id, bool showLinkName ) const
{
ostringstream s;
......
......@@ -18,7 +18,7 @@ class EventLoopServer
EventLoopServer();
virtual ~EventLoopServer();
bool evIsActive();
bool evIsActive() const;
protected:
// действия при завершении
......
......@@ -123,19 +123,19 @@ class HourGlass
}
// получить прошедшее время
inline timeout_t current()
inline timeout_t current() const
{
return t.getCurrent();
}
// получить заданное время
inline timeout_t interval()
inline timeout_t interval() const
{
return t.getInterval();
}
// проверить наступление
inline bool check()
inline bool check() const
{
// пока часы не "стоят"
// всегда false
......@@ -145,7 +145,7 @@ class HourGlass
return t.checkTime();
}
inline bool enabled()
inline bool enabled() const
{
return _state;
}
......
......@@ -44,11 +44,10 @@ class LogSession
typedef sigc::signal<std::string,LogSession*,LogServerTypes::Command, const std::string& > LogSessionCommand_Signal;
LogSessionCommand_Signal signal_logsession_command();
inline void cancel()
{
cancelled = true;
}
inline std::string getClientAddress()
// прервать работу
void cancel();
inline std::string getClientAddress() const
{
return caddr;
}
......@@ -68,17 +67,13 @@ class LogSession
//! Установить размер буфера для сообщений (количество записей. Не размер в байтах!!)
void setMaxBufSize( size_t num );
inline size_t getMaxBufSize()
{
return maxRecordsNum;
}
size_t getMaxBufSize() const;
// запуск обработки входящих запросов
void run( const ev::loop_ref& loop );
void terminate();
bool isAcive();
bool isAcive() const;
std::string getShortInfo();
......
......@@ -70,14 +70,14 @@ class MQAtomic
*/
VoidMessagePtr top();
size_t size();
bool empty();
size_t size() const;
bool empty() const;
// ----- Настройки -----
// неявно подразумевается, что всё настривается до первого использования
// ----------------------
void setMaxSizeOfMessageQueue( size_t s );
size_t getMaxSizeOfMessageQueue();
size_t getMaxSizeOfMessageQueue() const;
/*! Стратегия при переполнении */
enum LostStrategy
......
......@@ -56,7 +56,7 @@ class MQMutex
// неявно подразумевается, что всё настраивается до первого использования
// ----------------------
void setMaxSizeOfMessageQueue( size_t s );
size_t getMaxSizeOfMessageQueue();
size_t getMaxSizeOfMessageQueue() const;
/*! Стратегия при переполнении */
enum LostStrategy
......
......@@ -34,32 +34,32 @@ namespace UniSetTypes
virtual ~ObjectIndex() {};
// info
virtual const ObjectInfo* getObjectInfo( const UniSetTypes::ObjectId ) = 0;
virtual const ObjectInfo* getObjectInfo( const std::string& name ) = 0;
virtual const ObjectInfo* getObjectInfo( const UniSetTypes::ObjectId ) const = 0;
virtual const ObjectInfo* getObjectInfo( const std::string& name ) const = 0;
static std::string getBaseName( const std::string& fname );
// object id
virtual ObjectId getIdByName(const std::string& name) = 0;
virtual std::string getNameById( const UniSetTypes::ObjectId id );
virtual ObjectId getIdByName(const std::string& name) const = 0;
virtual std::string getNameById( const UniSetTypes::ObjectId id ) const;
// node
inline std::string getNodeName( const UniSetTypes::ObjectId id )
inline std::string getNodeName( const UniSetTypes::ObjectId id ) const
{
return getNameById(id);
}
inline ObjectId getNodeId( const std::string& name )
inline ObjectId getNodeId( const std::string& name ) const
{
return getIdByName(name);
}
// src name
virtual std::string getMapName( const UniSetTypes::ObjectId id ) = 0;
virtual std::string getTextName( const UniSetTypes::ObjectId id ) = 0;
virtual std::string getMapName( const UniSetTypes::ObjectId id ) const = 0;
virtual std::string getTextName( const UniSetTypes::ObjectId id ) const = 0;
//
virtual std::ostream& printMap(std::ostream& os) = 0;
virtual std::ostream& printMap(std::ostream& os) const = 0;
void initLocalNode( const UniSetTypes::ObjectId nodeid );
......
......@@ -42,23 +42,23 @@ namespace UniSetTypes
ObjectIndex_Array(const ObjectInfo* objectInfo);
virtual ~ObjectIndex_Array();
virtual const ObjectInfo* getObjectInfo( const ObjectId ) override;
virtual const ObjectInfo* getObjectInfo( const std::string& name ) override;
virtual ObjectId getIdByName( const std::string& name ) override;
virtual std::string getMapName( const ObjectId id ) override;
virtual std::string getTextName( const ObjectId id ) override;
virtual const ObjectInfo* getObjectInfo( const ObjectId ) const override;
virtual const ObjectInfo* getObjectInfo( const std::string& name ) const override;
virtual ObjectId getIdByName( const std::string& name ) const override;
virtual std::string getMapName( const ObjectId id ) const override;
virtual std::string getTextName( const ObjectId id ) const override;
virtual std::ostream& printMap(std::ostream& os) override;
virtual std::ostream& printMap(std::ostream& os) const override;
friend std::ostream& operator<<(std::ostream& os, ObjectIndex_Array& oi );
private:
int numOfObject;
size_t numOfObject;
typedef std::unordered_map<std::string, ObjectId> MapObjectKey;
MapObjectKey::iterator MapObjectKeyIterator;
MapObjectKey mok;
const ObjectInfo* objectInfo;
int maxId;
size_t maxId;
};
// -----------------------------------------------------------------------------------------
} // end of namespace
......
......@@ -36,17 +36,17 @@ namespace UniSetTypes
public ObjectIndex
{
public:
ObjectIndex_XML(const std::string& xmlfile, int minSize = 1000 );
ObjectIndex_XML( const std::shared_ptr<UniXML>& xml, int minSize = 1000 );
ObjectIndex_XML(const std::string& xmlfile, size_t minSize = 1000 );
ObjectIndex_XML( const std::shared_ptr<UniXML>& xml, size_t minSize = 1000 );
virtual ~ObjectIndex_XML();
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const ObjectId ) override;
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const std::string& name ) override;
virtual ObjectId getIdByName( const std::string& name ) override;
virtual std::string getMapName( const ObjectId id ) override;
virtual std::string getTextName( const ObjectId id ) override;
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const ObjectId ) const override;
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const std::string& name ) const override;
virtual ObjectId getIdByName( const std::string& name ) const override;
virtual std::string getMapName( const ObjectId id ) const override;
virtual std::string getTextName( const ObjectId id ) const override;
virtual std::ostream& printMap(std::ostream& os) override;
virtual std::ostream& printMap(std::ostream& os) const override;
friend std::ostream& operator<<(std::ostream& os, ObjectIndex_XML& oi );
protected:
......
......@@ -30,13 +30,13 @@ class ObjectIndex_idXML:
ObjectIndex_idXML( const std::shared_ptr<UniXML>& xml );
virtual ~ObjectIndex_idXML();
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const UniSetTypes::ObjectId ) override;
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const std::string& name ) override;
virtual UniSetTypes::ObjectId getIdByName( const std::string& name ) override;
virtual std::string getMapName( const UniSetTypes::ObjectId id ) override;
virtual std::string getTextName( const UniSetTypes::ObjectId id ) override;
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const UniSetTypes::ObjectId ) const override;
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const std::string& name ) const override;
virtual UniSetTypes::ObjectId getIdByName( const std::string& name ) const override;
virtual std::string getMapName( const UniSetTypes::ObjectId id ) const override;
virtual std::string getTextName( const UniSetTypes::ObjectId id ) const override;
virtual std::ostream& printMap( std::ostream& os ) override;
virtual std::ostream& printMap( std::ostream& os ) const override;
friend std::ostream& operator<<(std::ostream& os, ObjectIndex_idXML& oi );
protected:
......
......@@ -73,7 +73,6 @@ class Restorer_XML
it - интератор(указатель) на текущий считываемый xml-узел (<consumer>)
sec - указатель на текущий узел сообщения (<item>)
*/
void setReadConsumerItem( ReaderSlot sl );
......
......@@ -69,7 +69,7 @@ class Trigger
return false;
}
inline bool get()
inline bool get() const
{
return oldstate;
}
......
......@@ -82,13 +82,13 @@ class TriggerAND
TriggerAND(Caller* r, Action a);
~TriggerAND();
inline bool state()
inline bool state() const
{
return out;
}
bool getState(InputType in);
bool getState(InputType in) const;
bool commit(InputType in, bool state);
void add(InputType in, bool state);
......
......@@ -69,9 +69,9 @@ void TriggerAND<Caller,InputType>::remove(InputType num)
//---------------------------------------------------------------------------
template<class Caller, typename InputType>
bool TriggerAND<Caller,InputType>::getState(InputType num)
bool TriggerAND<Caller,InputType>::getState(InputType num) const
{
typename InputMap::iterator it=inputs.find(num);
auto it=inputs.find(num);
if( it!=inputs.end() )
return it->second;
......
......@@ -81,12 +81,12 @@ class TriggerOR
TriggerOR(Caller* r, Action a);
~TriggerOR();
inline bool state()
inline bool state() const
{
return out;
}
bool getState(InputType in);
bool getState(InputType in) const;
bool commit(InputType in, bool state);
void add(InputType in, bool state);
......
......@@ -60,7 +60,7 @@ void TriggerOR<Caller,InputType>::add(InputType num, bool state)
template<class Caller, typename InputType>
void TriggerOR<Caller,InputType>::remove(InputType num)
{
typename InputMap::iterator it=inputs.find(num);
auto it=inputs.find(num);
if( it!=inputs.end() )
inputs.erase(it);
......@@ -69,9 +69,9 @@ void TriggerOR<Caller,InputType>::remove(InputType num)
//---------------------------------------------------------------------------
template<class Caller, typename InputType>
bool TriggerOR<Caller,InputType>::getState(InputType num)
bool TriggerOR<Caller,InputType>::getState(InputType num) const
{
typename InputMap::iterator it=inputs.find(num);
auto it=inputs.find(num);
if( it!=inputs.end() )
return it->second;
......
......@@ -94,7 +94,7 @@ class TriggerOUT
/*! получить текущее значение указанного 'выхода' */
bool getState(OutIdType out);
bool getState(OutIdType out) const;
/*! установить значение одного из 'выходов'
\param out - идентификатор 'выхода'
......
......@@ -57,7 +57,7 @@ void TriggerOUT<Caller,OutIdType,ValueType>::remove(OutIdType num)
//---------------------------------------------------------------------------
template <class Caller, typename OutIdType, typename ValueType>
bool TriggerOUT<Caller,OutIdType,ValueType>::getState(OutIdType out)
bool TriggerOUT<Caller,OutIdType,ValueType>::getState(OutIdType out) const
{
auto it=outs.find(out);
if( it!=outs.end() )
......
......@@ -18,7 +18,7 @@ class UDPSocketU:
virtual ~UDPSocketU() {}
inline SOCKET getSocket()
inline SOCKET getSocket() const
{
return ost::UDPSocket::so;
}
......
......@@ -76,7 +76,7 @@ class UniSetActivator:
typedef sigc::signal<void, int> TerminateEvent_Signal;
TerminateEvent_Signal signal_terminate_event();
inline bool noUseGdbForStackTrace()
inline bool noUseGdbForStackTrace() const
{
return _noUseGdbForStackTrace;
}
......
......@@ -187,7 +187,7 @@ class UniXML
void open(const std::string& filename);
void close();
inline bool isOpen()
inline bool isOpen() const
{
return doc != 0;
}
......@@ -198,7 +198,7 @@ class UniXML
~UniXML();
xmlDoc* doc;
inline std::string getFileName()
inline std::string getFileName() const
{
return filename;
}
......
......@@ -150,12 +150,11 @@ class ModbusClient
void initLog( std::shared_ptr<UniSetTypes::Configuration> conf, const std::string& name, const std::string& logfile = "" );
void setLog( std::shared_ptr<DebugStream> dlog );
inline void setCRCNoCheckit( bool set )
{
crcNoCheckit = set;
}
inline bool isCRCNoCheckit()
inline bool isCRCNoCheckit() const
{
return crcNoCheckit;
}
......
......@@ -39,7 +39,7 @@ class ModbusRTUSlave:
}
virtual void terminate() override;
virtual bool isActive() override;
virtual bool isActive() const override;
protected:
......
......@@ -98,7 +98,7 @@ class ModbusServer
{
crcNoCheckit = set;
}
inline bool isCRCNoCheckit()
inline bool isCRCNoCheckit() const
{
return crcNoCheckit;
}
......@@ -107,7 +107,7 @@ class ModbusServer
{
onBroadcast = set;
}
inline bool getBroadcastMode()
inline bool getBroadcastMode() const
{
return onBroadcast;
}
......@@ -142,7 +142,7 @@ class ModbusServer
virtual void cleanupChannel() {}
virtual void terminate() {}
virtual bool isActive() = 0;
virtual bool isActive() const = 0;
// ------------ Статистика ---------------
typedef std::unordered_map<ModbusRTU::mbErrCode, size_t> ExchangeErrorMap;
......@@ -151,7 +151,7 @@ class ModbusServer
size_t getErrCount( ModbusRTU::mbErrCode e );
size_t resetErrCount( ModbusRTU::mbErrCode e, size_t set = 0 );
inline size_t getAskCount()
inline size_t getAskCount() const
{
return askCount;
}
......
......@@ -22,7 +22,7 @@ class ModbusTCPMaster:
void connect( ost::InetAddress addr, int port );
void disconnect();
void forceDisconnect();
bool isConnection();
bool isConnection() const;
static bool checkConnection( const std::string& ip, int port, int timeout_msec = 100 );
......@@ -39,11 +39,11 @@ class ModbusTCPMaster:
cleanInputStream();
}
inline std::string getAddress()
inline std::string getAddress() const
{
return iaddr;
}
inline int getPort()
inline int getPort() const
{
return port;
}
......
......@@ -37,7 +37,7 @@ class ModbusTCPServer:
*/
void run( const std::unordered_set<ModbusRTU::ModbusAddr>& vmbaddr, bool thread = false );
virtual bool isActive() override;
virtual bool isActive() const override;
void setMaxSessions( size_t num );
inline size_t getMaxSessions()
......
......@@ -45,7 +45,7 @@ class ModbusTCPSession:
void connectFinalSession( FinalSlot sl );
inline std::string getClientAddress()
inline std::string getClientAddress() const
{
return caddr;
}
......@@ -55,7 +55,7 @@ class ModbusTCPSession:
// запуск обработки входящих запросов
void run( ev::loop_ref& loop );
virtual bool isActive() override;
virtual bool isActive() const override;
void iowait( timeout_t msec );
......
......@@ -139,7 +139,7 @@ void ModbusRTUSlave::terminate()
catch(...) {}
}
// -------------------------------------------------------------------------
bool ModbusRTUSlave::isActive()
bool ModbusRTUSlave::isActive() const
{
return false;
}
......
......@@ -459,7 +459,7 @@ void ModbusTCPMaster::forceDisconnect()
tcp.reset();
}
// -------------------------------------------------------------------------
bool ModbusTCPMaster::isConnection()
bool ModbusTCPMaster::isConnection() const
{
return tcp && tcp->isConnected();
}
......
......@@ -83,7 +83,7 @@ void ModbusTCPServer::run( const std::unordered_set<ModbusAddr>& _vmbaddr, bool
evrun(thread);
}
// -------------------------------------------------------------------------
bool ModbusTCPServer::isActive()
bool ModbusTCPServer::isActive() const
{
return evIsActive();
}
......
......@@ -123,7 +123,7 @@ void ModbusTCPSession::run( ev::loop_ref& loop )
ioTimeout.start(sessTimeout);
}
// -------------------------------------------------------------------------
bool ModbusTCPSession::isActive()
bool ModbusTCPSession::isActive() const
{
return io.is_active();
}
......
......@@ -512,7 +512,7 @@ DataBits16::operator ModbusData()
return mdata();
}
// -------------------------------------------------------------------------
ModbusData DataBits16::mdata()
ModbusData DataBits16::mdata() const
{
ModbusData udata = 0;
......@@ -618,7 +618,7 @@ bool ReadCoilRetMessage::addData( DataBits d )
return true;
}
// -------------------------------------------------------------------------
bool ReadCoilRetMessage::getData( unsigned char dnum, DataBits& d )
bool ReadCoilRetMessage::getData( unsigned char dnum, DataBits& d ) const
{
if( dnum < bcnt )
{
......@@ -663,7 +663,7 @@ ModbusMessage ReadCoilRetMessage::transport_msg()
return std::move(mm);
}
// -------------------------------------------------------------------------
size_t ReadCoilRetMessage::szData()
size_t ReadCoilRetMessage::szData() const
{
// фактическое число данных + контрольная сумма
return sizeof(bcnt) + bcnt + szCRC;
......@@ -819,7 +819,7 @@ bool ReadInputStatusRetMessage::addData( DataBits d )
return true;
}
// -------------------------------------------------------------------------
bool ReadInputStatusRetMessage::getData( unsigned char dnum, DataBits& d )
bool ReadInputStatusRetMessage::getData( unsigned char dnum, DataBits& d ) const
{
if( dnum < bcnt )
{
......@@ -864,7 +864,7 @@ ModbusMessage ReadInputStatusRetMessage::transport_msg()
return std::move(mm);
}
// -------------------------------------------------------------------------
size_t ReadInputStatusRetMessage::szData()
size_t ReadInputStatusRetMessage::szData() const
{
// фактическое число данных + контрольная сумма
return sizeof(bcnt) + bcnt + szCRC;
......@@ -1074,7 +1074,7 @@ ModbusMessage ReadOutputRetMessage::transport_msg()
return std::move(mm);
}
// -------------------------------------------------------------------------
size_t ReadOutputRetMessage::szData()
size_t ReadOutputRetMessage::szData() const
{
// фактическое число данных + контрольная сумма
return sizeof(bcnt) + count * sizeof(ModbusData) + szCRC;
......@@ -1455,12 +1455,12 @@ void ForceCoilsMessage::init( const ModbusMessage& m )
memcpy(&crc, &(m.data[m.dlen - szCRC]), szCRC);
}
// -------------------------------------------------------------------------
bool ForceCoilsMessage::checkFormat()
bool ForceCoilsMessage::checkFormat() const
{
return ( func == fnForceMultipleCoils );
}
// -------------------------------------------------------------------------
size_t ForceCoilsMessage::szData()
size_t ForceCoilsMessage::szData() const
{
return szHead() + bcnt + szCRC;
}
......@@ -1703,13 +1703,13 @@ void WriteOutputMessage::init( const ModbusMessage& m )
data[i] = SWAPSHORT(data[i]);
}
// -------------------------------------------------------------------------
bool WriteOutputMessage::checkFormat()
bool WriteOutputMessage::checkFormat() const
{
// return ( quant*sizeof(ModbusData) == bcnt ) && ( func == fnWriteOutputRegisters );
return ( (bcnt == (quant * sizeof(ModbusData))) && (func == fnWriteOutputRegisters) );
}
// -------------------------------------------------------------------------
size_t WriteOutputMessage::szData()
size_t WriteOutputMessage::szData() const
{
return szHead() + bcnt + szCRC;
}
......@@ -1899,12 +1899,12 @@ void ForceSingleCoilMessage::init( const ModbusMessage& m )
}
// -------------------------------------------------------------------------
bool ForceSingleCoilMessage::checkFormat()
bool ForceSingleCoilMessage::checkFormat() const
{
return (func == fnForceSingleCoil);
}
// -------------------------------------------------------------------------
size_t ForceSingleCoilMessage::szData()
size_t ForceSingleCoilMessage::szData() const
{
return szHead() + sizeof(ModbusData) + szCRC;
}
......@@ -2076,7 +2076,7 @@ bool WriteSingleOutputMessage::checkFormat()
return ( (func == fnWriteOutputSingleRegister) );
}
// -------------------------------------------------------------------------
size_t WriteSingleOutputMessage::szData()
size_t WriteSingleOutputMessage::szData() const
{
return szHead() + sizeof(ModbusData) + szCRC;
}
......@@ -2365,7 +2365,7 @@ ModbusMessage DiagnosticMessage::transport_msg()
return std::move(mm);
}
// -------------------------------------------------------------------------
size_t DiagnosticMessage::szData()
size_t DiagnosticMessage::szData() const
{
// фактическое число данных + контрольная сумма
return sizeof(subf) + count * sizeof(ModbusData) + szCRC;
......@@ -2496,7 +2496,7 @@ void MEIMessageRDI::init( const ModbusMessage& m )
memcpy(&crc, &(m.data[m.dlen - szCRC]), szCRC);
}
// -------------------------------------------------------------------------
bool MEIMessageRDI::checkFormat()
bool MEIMessageRDI::checkFormat() const
{
return ( type == 0x0E );
}
......@@ -2696,7 +2696,7 @@ ModbusMessage MEIMessageRetRDI::transport_msg()
return std::move(mm);
}
// -------------------------------------------------------------------------
size_t MEIMessageRetRDI::szData()
size_t MEIMessageRetRDI::szData() const
{
// заголовочные поля + фактическое число данных + контрольная сумма
return 6 + bcnt + szCRC;
......@@ -2867,7 +2867,7 @@ ModbusMessage JournalCommandRetMessage::transport_msg()
return std::move(mm);
}
// -------------------------------------------------------------------------
size_t JournalCommandRetMessage::szData()
size_t JournalCommandRetMessage::szData() const
{
// фактическое число данных + контрольная сумма
return sizeof(bcnt) + count * sizeof(ModbusData) + szCRC;
......@@ -3052,7 +3052,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os, SetDateTimeMessage* m )
return os << (*m);
}
// -------------------------------------------------------------------------
bool SetDateTimeMessage::checkFormat()
bool SetDateTimeMessage::checkFormat() const
{
/*
// Lav: проверка >=0 бессмысленна, потому что в типе данных Modbusbyte не могут храниться отрицательные числа
......@@ -3207,7 +3207,7 @@ void RemoteServiceMessage::init( const ModbusMessage& m )
memcpy(&crc, &(m.data[m.dlen - szCRC]), szCRC);
}
// -------------------------------------------------------------------------
size_t RemoteServiceMessage::szData()
size_t RemoteServiceMessage::szData() const
{
return szHead() + bcnt + szCRC;
}
......@@ -3264,7 +3264,7 @@ void RemoteServiceRetMessage::clear()
bcnt = 0;
}
// -------------------------------------------------------------------------
size_t RemoteServiceRetMessage::szData()
size_t RemoteServiceRetMessage::szData() const
{
// фактическое число данных + контрольная сумма
return sizeof(bcnt) + count * sizeof(ModbusByte) + szCRC;
......@@ -3314,7 +3314,7 @@ ReadFileRecordMessage& ReadFileRecordMessage::operator=( const ModbusMessage& m
return *this;
}
// -------------------------------------------------------------------------
bool ReadFileRecordMessage::checkFormat()
bool ReadFileRecordMessage::checkFormat() const
{
return ( bcnt >= 0x07 && bcnt <= 0xF5 );
}
......@@ -3352,7 +3352,7 @@ void ReadFileRecordMessage::init( const ModbusMessage& m )
}
}
// -------------------------------------------------------------------------
size_t ReadFileRecordMessage::szData()
size_t ReadFileRecordMessage::szData() const
{
// фактическое число данных + контрольная сумма
return sizeof(bcnt) + count * sizeof(SubRequest) + szCRC;
......@@ -3520,7 +3520,7 @@ size_t FileTransferRetMessage::getDataLen( const ModbusMessage& m )
return (size_t)m.data[0];
}
// -----------------------------------------------------------------------
size_t FileTransferRetMessage::szData()
size_t FileTransferRetMessage::szData() const
{
// фактическое число данных + контрольная сумма
return sizeof(ModbusByte) * 2 + sizeof(ModbusData) * 3 + dlen + szCRC;
......
......@@ -551,13 +551,23 @@ LogSession::LogSessionCommand_Signal LogSession::signal_logsession_command()
return m_command_sig;
}
// ---------------------------------------------------------------------
void LogSession::cancel()
{
cancelled = true;
}
// ---------------------------------------------------------------------
void LogSession::setMaxBufSize( size_t num )
{
std::unique_lock<std::mutex> lk(logbuf_mutex);
maxRecordsNum = num;
}
// ---------------------------------------------------------------------
bool LogSession::isAcive()
size_t LogSession::getMaxBufSize() const
{
return maxRecordsNum;
}
// ---------------------------------------------------------------------
bool LogSession::isAcive() const
{
return io.is_active();
}
......
......@@ -29,7 +29,7 @@ using namespace UniSetTypes;
//const std::string ObjectIndex::sepNode = ":";
// -----------------------------------------------------------------------------------------
string ObjectIndex::getNameById( const ObjectId id )
string ObjectIndex::getNameById( const ObjectId id ) const
{
return getMapName(id);
}
......
......@@ -47,7 +47,7 @@ ObjectIndex_Array::ObjectIndex_Array( const ObjectInfo* objectInfo ):
}
}
// -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_Array::getIdByName( const string& name )
ObjectId ObjectIndex_Array::getIdByName( const string& name ) const
{
auto it = mok.find(name);
......@@ -58,7 +58,7 @@ ObjectId ObjectIndex_Array::getIdByName( const string& name )
}
// -----------------------------------------------------------------------------------------
string ObjectIndex_Array::getMapName( const ObjectId id )
string ObjectIndex_Array::getMapName( const ObjectId id ) const
{
if( id != UniSetTypes::DefaultObjectId && id >= 0 && id < maxId )
return objectInfo[id].repName;
......@@ -67,7 +67,7 @@ string ObjectIndex_Array::getMapName( const ObjectId id )
// throw OutOfRange("ObjectIndex_Array::getMapName OutOfRange");
}
// -----------------------------------------------------------------------------------------
string ObjectIndex_Array::getTextName( const ObjectId id )
string ObjectIndex_Array::getTextName( const ObjectId id ) const
{
if( id != UniSetTypes::DefaultObjectId && id >= 0 && id < maxId )
return objectInfo[id].textName;
......@@ -82,7 +82,7 @@ std::ostream& operator<<(std::ostream& os, ObjectIndex_Array& oi )
}
// -----------------------------------------------------------------------------------------
std::ostream& ObjectIndex_Array::printMap( std::ostream& os )
std::ostream& ObjectIndex_Array::printMap( std::ostream& os ) const
{
auto oind = uniset_conf()->oind;
......@@ -101,7 +101,7 @@ std::ostream& ObjectIndex_Array::printMap( std::ostream& os )
return os;
}
// -----------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_Array::getObjectInfo( const ObjectId id )
const ObjectInfo* ObjectIndex_Array::getObjectInfo( const ObjectId id ) const
{
if( id != UniSetTypes::DefaultObjectId && id >= 0 && id < maxId )
return &(objectInfo[id]);
......@@ -109,7 +109,7 @@ const ObjectInfo* ObjectIndex_Array::getObjectInfo( const ObjectId id )
return NULL;
}
// -----------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_Array::getObjectInfo( const std::string& name )
const ObjectInfo* ObjectIndex_Array::getObjectInfo( const std::string& name ) const
{
auto it = mok.find(name);
......
......@@ -24,7 +24,7 @@
using namespace UniSetTypes;
using namespace std;
// -----------------------------------------------------------------------------------------
ObjectIndex_XML::ObjectIndex_XML( const string& xmlfile, int minSize ):
ObjectIndex_XML::ObjectIndex_XML(const string& xmlfile, size_t minSize ):
omap(minSize)
{
shared_ptr<UniXML> xml = make_shared<UniXML>();
......@@ -36,7 +36,7 @@ ObjectIndex_XML::ObjectIndex_XML( const string& xmlfile, int minSize ):
// catch(...){}
}
// -----------------------------------------------------------------------------------------
ObjectIndex_XML::ObjectIndex_XML( const std::shared_ptr<UniXML>& xml, int minSize ):
ObjectIndex_XML::ObjectIndex_XML(const std::shared_ptr<UniXML>& xml, size_t minSize ):
omap(minSize)
{
build(xml);
......@@ -46,7 +46,7 @@ ObjectIndex_XML::~ObjectIndex_XML()
{
}
// -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_XML::getIdByName( const string& name )
ObjectId ObjectIndex_XML::getIdByName( const string& name ) const
{
auto it = mok.find(name);
......@@ -56,7 +56,7 @@ ObjectId ObjectIndex_XML::getIdByName( const string& name )
return DefaultObjectId;
}
// -----------------------------------------------------------------------------------------
string ObjectIndex_XML::getMapName( const ObjectId id )
string ObjectIndex_XML::getMapName( const ObjectId id ) const
{
if( (unsigned)id < omap.size() && (unsigned)id > 0 )
return omap[id].repName;
......@@ -64,7 +64,7 @@ string ObjectIndex_XML::getMapName( const ObjectId id )
return "";
}
// -----------------------------------------------------------------------------------------
string ObjectIndex_XML::getTextName( const ObjectId id )
string ObjectIndex_XML::getTextName( const ObjectId id ) const
{
if( (unsigned)id < omap.size() && (unsigned)id > 0 )
return omap[id].textName;
......@@ -77,9 +77,9 @@ std::ostream& operator<<(std::ostream& os, ObjectIndex_XML& oi )
return oi.printMap(os);
}
// -----------------------------------------------------------------------------------------
std::ostream& ObjectIndex_XML::printMap( std::ostream& os )
std::ostream& ObjectIndex_XML::printMap( std::ostream& os ) const
{
cout << "size: " << omap.size() << endl;
os << "size: " << omap.size() << endl;
for( auto it = omap.begin(); it != omap.end(); ++it )
{
......@@ -272,7 +272,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co
return ind;
}
// ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id )
const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id ) const
{
if( (unsigned)id < omap.size() && (unsigned)id > 0 )
return &omap[id];
......@@ -280,7 +280,7 @@ const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id )
return NULL;
}
// ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_XML::getObjectInfo( const std::string& name )
const ObjectInfo* ObjectIndex_XML::getObjectInfo( const std::string& name ) const
{
auto it = mok.find(name);
......
......@@ -43,7 +43,7 @@ ObjectIndex_idXML::~ObjectIndex_idXML()
{
}
// -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_idXML::getIdByName( const string& name )
ObjectId ObjectIndex_idXML::getIdByName( const string& name ) const
{
auto it = mok.find(name);
......@@ -53,7 +53,7 @@ ObjectId ObjectIndex_idXML::getIdByName( const string& name )
return DefaultObjectId;
}
// -----------------------------------------------------------------------------------------
string ObjectIndex_idXML::getMapName( const ObjectId id )
string ObjectIndex_idXML::getMapName( const ObjectId id ) const
{
auto it = omap.find(id);
......@@ -63,7 +63,7 @@ string ObjectIndex_idXML::getMapName( const ObjectId id )
return "";
}
// -----------------------------------------------------------------------------------------
string ObjectIndex_idXML::getTextName( const ObjectId id )
string ObjectIndex_idXML::getTextName( const ObjectId id ) const
{
auto it = omap.find(id);
......@@ -78,7 +78,7 @@ std::ostream& operator<<(std::ostream& os, ObjectIndex_idXML& oi )
return oi.printMap(os);
}
// -----------------------------------------------------------------------------------------
std::ostream& ObjectIndex_idXML::printMap( std::ostream& os )
std::ostream& ObjectIndex_idXML::printMap( std::ostream& os ) const
{
os << "size: " << omap.size() << endl;
......@@ -235,7 +235,7 @@ void ObjectIndex_idXML::read_nodes( const std::shared_ptr<UniXML>& xml, const st
}
}
// ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id )
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id ) const
{
auto it = omap.find(id);
......@@ -245,7 +245,7 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id )
return NULL;
}
// ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string& name )
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string& name ) const
{
auto it = mok.find(name);
......
......@@ -32,7 +32,7 @@ void EventLoopServer::evrun( bool thread )
thr = make_shared<std::thread>( [ = ] { defaultLoop(); } );
}
// ---------------------------------------------------------------------------
bool EventLoopServer::evIsActive()
bool EventLoopServer::evIsActive() const
{
return isrunning;
}
......
......@@ -137,7 +137,7 @@ timeout_t LT_Object::getTimeInterval( TimerId timerid )
return 0;
}
// ------------------------------------------------------------------------------------------
timeout_t LT_Object::getTimeLeft(TimerId timerid)
timeout_t LT_Object::getTimeLeft( TimerId timerid )
{
// lock
uniset_rwmutex_rlock lock(lstMutex);
......
......@@ -115,7 +115,7 @@ VoidMessagePtr MQAtomic::top()
return nullptr;
}
//---------------------------------------------------------------------------
size_t MQAtomic::size()
size_t MQAtomic::size() const
{
// т.к. rpos корректируется только при фактическом вызое top()
// то тут приходиться смотреть если у нас переполнение
......@@ -127,7 +127,7 @@ size_t MQAtomic::size()
return (qpos - rpos);
}
//---------------------------------------------------------------------------
bool MQAtomic::empty()
bool MQAtomic::empty() const
{
return (qpos == rpos);
}
......@@ -141,7 +141,7 @@ void MQAtomic::setMaxSizeOfMessageQueue( size_t s )
}
}
//---------------------------------------------------------------------------
size_t MQAtomic::getMaxSizeOfMessageQueue()
size_t MQAtomic::getMaxSizeOfMessageQueue() const
{
return SizeOfMessageQueue;
}
......
......@@ -82,7 +82,7 @@ void MQMutex::setMaxSizeOfMessageQueue( size_t s )
SizeOfMessageQueue = s;
}
//---------------------------------------------------------------------------
size_t MQMutex::getMaxSizeOfMessageQueue()
size_t MQMutex::getMaxSizeOfMessageQueue() const
{
return SizeOfMessageQueue;
}
......
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