Commit 23862161 authored by Pavel Vainerman's avatar Pavel Vainerman

Очередная группа исправлений по результатам прогона cppcheck.

parent 6c072713
......@@ -55,21 +55,21 @@ static struct option longopts[] = {
string conffile("configure.xml");
// --------------------------------------------------------------------------
static bool commandToAll(const string section, ObjectRepository *rep, Command cmd);
static void createSections(UniSetTypes::Configuration* c);
static bool commandToAll( const string& section, ObjectRepository *rep, Command cmd );
static void createSections( UniSetTypes::Configuration* c );
// --------------------------------------------------------------------------
int omap();
int msgmap();
int configure( const string args, UniversalInterface &ui );
int logRotate( const string args, UniversalInterface &ui );
int setValue( const string args, UniversalInterface &ui, Configuration* conf = UniSetTypes::conf );
int getValue( const string args, UniversalInterface &ui, Configuration* conf = UniSetTypes::conf );
int getRawValue( const string args, UniversalInterface &ui );
int getState( const string args, UniversalInterface &ui );
int getCalibrate( const string args, UniversalInterface &ui );
int oinfo( const string args, UniversalInterface &ui );
int configure( const string& args, UniversalInterface &ui );
int logRotate( const string& args, UniversalInterface &ui );
int setValue( const string& args, UniversalInterface &ui, Configuration* conf = UniSetTypes::conf );
int getValue( const string& args, UniversalInterface &ui, Configuration* conf = UniSetTypes::conf );
int getRawValue( const string& args, UniversalInterface &ui );
int getState( const string& args, UniversalInterface &ui );
int getCalibrate( const string& args, UniversalInterface &ui );
int oinfo( const string& args, UniversalInterface &ui );
// --------------------------------------------------------------------------
static void print_help(int width, const string cmd, const string help, const string tab=" " )
static void print_help(int width, const string& cmd, const string& help, const string& tab=" " )
{
// чтобы не менять параметры основного потока
// создаём свой stream...
......@@ -318,12 +318,12 @@ int main(int argc, char** argv)
{
cerr << "неизвестное исключение" << endl;
}
return 1;
}
// ==============================================================================================
static bool commandToAll(const string section, ObjectRepository *rep, Command cmd)
static bool commandToAll(const string& section, ObjectRepository *rep, Command cmd)
{
cout <<"\n||=======******** " << section << " ********=========||\n"<< endl;
......@@ -484,7 +484,7 @@ int msgmap()
}
// --------------------------------------------------------------------------------------
int setValue( const string args, UniversalInterface &ui, Configuration* conf )
int setValue( const string& args, UniversalInterface &ui, Configuration* conf )
{
int err = 0;
......@@ -539,7 +539,7 @@ int setValue( const string args, UniversalInterface &ui, Configuration* conf )
}
// --------------------------------------------------------------------------------------
int getValue( const string args, UniversalInterface &ui, Configuration* conf )
int getValue( const string& args, UniversalInterface &ui, Configuration* conf )
{
int err = 0;
......@@ -586,7 +586,7 @@ int getValue( const string args, UniversalInterface &ui, Configuration* conf )
return err;
}
// --------------------------------------------------------------------------------------
int getCalibrate( const std::string args, UniversalInterface &ui )
int getCalibrate( const std::string& args, UniversalInterface &ui )
{
int err = 0;
typedef std::list<UniSetTypes::ParamSInfo> SList;
......@@ -616,7 +616,7 @@ int getCalibrate( const std::string args, UniversalInterface &ui )
}
// --------------------------------------------------------------------------------------
int getRawValue( const std::string args, UniversalInterface &ui )
int getRawValue( const std::string& args, UniversalInterface &ui )
{
int err = 0;
typedef std::list<UniSetTypes::ParamSInfo> SList;
......@@ -643,7 +643,7 @@ int getRawValue( const std::string args, UniversalInterface &ui )
}
// --------------------------------------------------------------------------------------
int logRotate( const string arg, UniversalInterface &ui )
int logRotate( const string& arg, UniversalInterface &ui )
{
// посылка всем
if( arg.empty() || (arg.c_str())[0]!='-' )
......@@ -672,7 +672,7 @@ int logRotate( const string arg, UniversalInterface &ui )
}
// --------------------------------------------------------------------------------------
int configure( const string arg, UniversalInterface &ui )
int configure( const string& arg, UniversalInterface &ui )
{
// посылка всем
if( arg.empty() || (arg.c_str())[0]!='-' )
......@@ -700,7 +700,7 @@ int configure( const string arg, UniversalInterface &ui )
}
// --------------------------------------------------------------------------------------
int oinfo( const string arg, UniversalInterface &ui )
int oinfo( const string& arg, UniversalInterface &ui )
{
UniSetTypes::ObjectId oid(uni_atoi(arg));
if( oid==0 )
......
......@@ -15,7 +15,7 @@ using namespace std;
using namespace UniSetTypes;
using namespace ModbusRTU;
// -------------------------------------------------------------------------
MBSlave::MBSlave( ModbusRTU::ModbusAddr addr, const std::string dev, const std::string speed, bool use485 ):
MBSlave::MBSlave( ModbusRTU::ModbusAddr addr, const std::string& dev, const std::string& speed, bool use485 ):
rscomm(NULL),
addr(addr),
// prev(ModbusRTU::erNoError),
......
......@@ -11,7 +11,7 @@
class MBSlave
{
public:
MBSlave( ModbusRTU::ModbusAddr addr, const std::string dev, const std::string speed, bool use485=false );
MBSlave( ModbusRTU::ModbusAddr addr, const std::string& dev, const std::string& speed, bool use485=false );
~MBSlave();
inline void setVerbose( bool state )
......
......@@ -15,7 +15,7 @@ using namespace std;
using namespace UniSetTypes;
using namespace ModbusRTU;
// -------------------------------------------------------------------------
MBTCPServer::MBTCPServer( ModbusAddr myaddr, const string inetaddr, int port, bool verb ):
MBTCPServer::MBTCPServer( ModbusAddr myaddr, const string& inetaddr, int port, bool verb ):
sslot(NULL),
addr(myaddr),
// prev(ModbusRTU::erNoError),
......
......@@ -10,7 +10,7 @@
class MBTCPServer
{
public:
MBTCPServer( ModbusRTU::ModbusAddr myaddr, const std::string inetaddr, int port=502, bool verbose=false );
MBTCPServer( ModbusRTU::ModbusAddr myaddr, const std::string& inetaddr, int port=502, bool verbose=false );
~MBTCPServer();
inline void setVerbose( bool state )
......
......@@ -676,7 +676,7 @@ int main( int argc, char **argv )
catch( ModbusRTU::mbException& ex )
{
if( ex.err != ModbusRTU::erTimeOut )
throw ex;
throw;
cout << "timeout..." << endl;
}
......
......@@ -507,7 +507,7 @@ int main( int argc, char **argv )
catch( ModbusRTU::mbException& ex )
{
if( ex.err != ModbusRTU::erTimeOut )
throw ex;
throw;
cout << "timeout..." << endl;
}
......
......@@ -239,7 +239,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
catch(Exception&amp; ex)
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getState): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
}
// -----------------------------------------------------------------------------
......@@ -318,7 +318,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch(Exception&amp; ex)
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -368,7 +368,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch(Exception&amp; ex)
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -398,7 +398,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch(Exception&amp; ex)
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......
......@@ -256,7 +256,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -306,7 +306,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -336,7 +336,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......
......@@ -204,7 +204,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
catch(Exception&amp; ex)
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getState): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
return 0;
......@@ -294,7 +294,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
}
</xsl:template>
......@@ -326,7 +326,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
}
</xsl:template>
......@@ -359,7 +359,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
}
</xsl:template>
......
......@@ -240,7 +240,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(getdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -272,7 +272,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -305,7 +305,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setdata): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......@@ -337,7 +337,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
catch( Exception&amp; ex )
{
unideb[Debug::CRIT] &lt;&lt; myname &lt;&lt; "(setmsg): " &lt;&lt; ex &lt;&lt; endl;
throw ex;
throw;
}
</xsl:template>
......
......@@ -235,9 +235,9 @@
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) { return UniSetTypes::conf->getIntProp(confnode, name); }
int getIntProp(const std::string&amp; name) { return UniSetTypes::conf->getIntProp(confnode, name); }
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string name) { return UniSetTypes::conf->getProp(confnode, name); }
inline const std::string getProp(const std::string&amp; name) { return UniSetTypes::conf->getProp(confnode, name); }
int smReadyTimeout; /*!&lt; время ожидания готовности SM */
bool activated;
......@@ -553,7 +553,7 @@ end_private(false)
}
// -----------------------------------------------------------------------------
// ( val, confval, default val )
static const std::string init3_str(const std::string& s1, const std::string& s2, const std::string& s3 )
static const std::string init3_str( const std::string&amp; s1, const std::string&amp; s2, const std::string&amp; s3 )
{
if( !s1.empty() )
return s1;
......@@ -872,7 +872,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::testMode( bool _state )
<xsl:template name="COMMON-CC-ALONE-FUNCS">
// -----------------------------------------------------------------------------
// ( val, confval, default val )
static const std::string init3_str(const std::string& s1, const std::string& s2, const std::string& s3 )
static const std::string init3_str( const std::string&amp; s1, const std::string&amp; s2, const std::string&amp; s3 )
{
if( !s1.empty() )
return s1;
......
......@@ -9,7 +9,7 @@ int main( int argc, const char **argv )
{
try
{
string confile = uniset_init(argc, argv);
uniset_init(argc, argv);
string logfilename = conf->getArgParam("--logfile", "Skel.log");
string logname( conf->getLogDir() + logfilename );
......
......@@ -45,7 +45,7 @@ DBInterface::~DBInterface()
}
// -----------------------------------------------------------------------------------------
bool DBInterface::connect( const string host, const string user, const string pswd, const string dbname)
bool DBInterface::connect( const string& host, const string& user, const string& pswd, const string& dbname)
{
if (!mysql_real_connect(mysql,host.c_str(), user.c_str(),pswd.c_str(),dbname.c_str(),0,NULL,0))
{
......@@ -64,7 +64,7 @@ bool DBInterface::close()
return true;
}
// -----------------------------------------------------------------------------------------
bool DBInterface::insert(const string q)
bool DBInterface::insert( const string& q )
{
if( !mysql )
return false;
......@@ -79,7 +79,7 @@ bool DBInterface::insert(const string q)
return true;
}
// -----------------------------------------------------------------------------------------
bool DBInterface::query(const string q)
bool DBInterface::query( const string& q )
{
if( !mysql )
return false;
......@@ -178,7 +178,7 @@ bool DBInterface::createDB(const string dbname)
return true;
return false;
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool DBInterface::dropDB(const string dbname)
{
......@@ -187,8 +187,8 @@ bool DBInterface::dropDB(const string dbname)
return false;
}
*/
// -----------------------------------------------------------------------------------------
MYSQL_RES* DBInterface::listFields(const string table, const string wild )
// -----------------------------------------------------------------------------------------
MYSQL_RES* DBInterface::listFields( const string& table, const string& wild )
{
if( !mysql || !result )
return 0;
......@@ -206,7 +206,7 @@ MYSQL_RES* DBInterface::listFields(const string table, const string wild )
return res; // mysql_list_fields(mysql, table,wild);
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool DBInterface::moveToRow(int ind)
{
if(!mysql || !result)
......@@ -215,7 +215,7 @@ bool DBInterface::moveToRow(int ind)
mysql_data_seek(result, ind);
return true;
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool DBInterface::ping()
{
if( !mysql || !connected )
......@@ -225,13 +225,13 @@ bool DBInterface::ping()
// если всё хорошо.... (поэтому мы инвертируем)
return !mysql_ping(mysql);
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool DBInterface::isConnection()
{
return ping(); //!mysql;
}
// -----------------------------------------------------------------------------------------
string DBInterface::addslashes(const string& str)
// -----------------------------------------------------------------------------------------
string DBInterface::addslashes( const string& str )
{
ostringstream tmp;
for( unsigned int i=0; i<str.size(); i++ )
......
......@@ -39,16 +39,16 @@ class DBInterface
// bool createDB(const std::string dbname);
// bool dropDB(const std::string dbname);
MYSQL_RES * listFields(const std::string table, const std::string wild );
MYSQL_RES * listFields(const std::string& table, const std::string& wild );
bool connect( const std::string host, const std::string user, const std::string pswd,
const std::string dbname);
bool connect( const std::string& host, const std::string& user, const std::string& pswd,
const std::string& dbname);
bool close();
bool query(const std::string q);
bool query(const std::string& q);
const std::string lastQuery();
bool insert(const std::string q);
bool insert(const std::string& q);
std::string addslashes(const std::string& str);
......
......@@ -44,6 +44,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id):
ReconnectTime(180000),
connect_ok(false),
activate(true),
qbufSize(200),
lastRemove(false)
{
if( getId() == DefaultObjectId )
......@@ -61,6 +62,7 @@ DBServer_MySQL::DBServer_MySQL():
ReconnectTime(180000),
connect_ok(false),
activate(true),
qbufSize(200),
lastRemove(false)
{
// init();
......
......@@ -44,6 +44,7 @@ DBServer_SQLite::DBServer_SQLite( ObjectId id ):
ReconnectTime(180000),
connect_ok(false),
activate(true),
qbufSize(200),
lastRemove(false)
{
if( getId() == DefaultObjectId )
......@@ -61,6 +62,7 @@ DBServer_SQLite::DBServer_SQLite():
ReconnectTime(180000),
connect_ok(false),
activate(true),
qbufSize(200),
lastRemove(false)
{
// init();
......
......@@ -44,8 +44,7 @@ opCheckPause(50)
SQLiteInterface::~SQLiteInterface()
{
close();
if( db )
delete db;
delete db;
}
// -----------------------------------------------------------------------------------------
......@@ -54,7 +53,7 @@ bool SQLiteInterface::ping()
return db && ( sqlite3_db_status(db,0,NULL,NULL,0) == SQLITE_OK );
}
// -----------------------------------------------------------------------------------------
bool SQLiteInterface::connect( const string dbfile, bool create )
bool SQLiteInterface::connect( const string& dbfile, bool create )
{
// т.к. sqlite3 по умолчанию, создаёт файл при открытии, то проверим "сами"
// if( !create && !UniSetTypes::file_exist(dbfile) )
......@@ -97,7 +96,7 @@ void SQLiteInterface::setOperationTimeout( timeout_t msec )
sqlite3_busy_timeout(db,opTimeout);
}
// -----------------------------------------------------------------------------------------
bool SQLiteInterface::insert( const string q )
bool SQLiteInterface::insert( const string& q )
{
if( !db )
return false;
......@@ -134,7 +133,7 @@ bool SQLiteInterface::checkResult( int rc )
return true;
}
// -----------------------------------------------------------------------------------------
SQLiteResult SQLiteInterface::query( const string q )
SQLiteResult SQLiteInterface::query( const string& q )
{
if( !db )
return SQLiteResult();
......
......@@ -45,7 +45,7 @@ class SQLiteInterface
SQLiteInterface();
~SQLiteInterface();
bool connect( const std::string dbfile, bool create = false );
bool connect( const std::string& dbfile, bool create = false );
bool close();
bool isConnection();
bool ping(); // проверка доступности БД
......@@ -56,10 +56,10 @@ class SQLiteInterface
inline void setOperationCheckPause( timeout_t msec ){ opCheckPause = msec; }
inline timeout_t getOperationCheckPause(){ return opCheckPause; }
SQLiteResult query( const std::string q );
SQLiteResult query( const std::string& q );
const std::string lastQuery();
bool insert( const std::string q );
bool insert( const std::string& q );
int insert_id();
std::string error();
......
......@@ -6,7 +6,7 @@
using namespace UniSetTypes;
using namespace std;
// -----------------------------------------------------------------------------
ComediInterface::ComediInterface( const std::string dev ):
ComediInterface::ComediInterface( const std::string& dev ):
card(0),
dname(dev)
{
......@@ -190,7 +190,7 @@ std::string ComediInterface::type2str( ComediInterface::SubdevType t )
return "";
}
// -----------------------------------------------------------------------------
ComediInterface::SubdevType ComediInterface::str2type( const std::string s )
ComediInterface::SubdevType ComediInterface::str2type( const std::string& s )
{
if( s == "TBI24_0" )
return TBI24_0;
......
......@@ -10,7 +10,7 @@
class ComediInterface
{
public:
ComediInterface( const std::string dev );
ComediInterface( const std::string& dev );
~ComediInterface();
int getAnalogChannel( int subdev, int channel, int range=0, int aref=AREF_GROUND )
......@@ -45,7 +45,7 @@ class ComediInterface
};
static std::string type2str( SubdevType t );
static SubdevType str2type( const std::string s );
static SubdevType str2type( const std::string& s );
void configureSubdev( int subdev, SubdevType type ) throw(UniSetTypes::Exception);
......
......@@ -25,6 +25,7 @@ class Element
enum InputType
{
unknown,
external,
internal
};
......@@ -86,8 +87,8 @@ class Element
struct InputInfo
{
InputInfo():num(0),state(false){}
InputInfo(int n, bool s): num(n),state(s){}
InputInfo():num(0),state(false),type(unknown){}
InputInfo(int n, bool s): num(n),state(s),type(unknown){}
int num;
bool state;
InputType type;
......@@ -117,7 +118,7 @@ class TOR:
virtual std::string getType(){ return "OR"; }
protected:
TOR(){};
TOR():myout(false){}
bool myout;
......@@ -136,7 +137,7 @@ class TAND:
virtual std::string getType(){ return "AND"; }
protected:
TAND(){};
TAND(){}
private:
};
......@@ -161,7 +162,7 @@ class TNOT:
virtual void delInput( int num ){}
protected:
TNOT(){};
TNOT():myout(false){}
bool myout;
private:
......
......@@ -8,7 +8,7 @@ using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
LProcessor::LProcessor( const std::string name ):
LProcessor::LProcessor( const std::string& name ):
logname(name)
{
sleepTime = conf->getArgPInt("--sleepTime", 200);
......@@ -23,7 +23,7 @@ LProcessor::~LProcessor()
{
}
// -------------------------------------------------------------------------
void LProcessor::execute( const string lfile )
void LProcessor::execute( const string& lfile )
{
build(lfile);
......
......@@ -94,10 +94,10 @@
class LProcessor
{
public:
LProcessor( const std::string name="" );
LProcessor( const std::string& name="" );
virtual ~LProcessor();
virtual void execute( const string lfile );
virtual void execute( const string& lfile );
protected:
......
......@@ -7,13 +7,35 @@ using namespace UniSetTypes;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId objId,
UniSetTypes::ObjectId shmID, SharedMemory* ic ):
UniSetTypes::ObjectId shmID, SharedMemory* ic, const std::string& prefix ):
UniSetObject_LT(objId),
shm(0)
{
logname = myname;
shm = new SMInterface(shmID,&(UniSetObject_LT::ui),objId,ic);
build(lfile);
// ********** HEARTBEAT *************
string heart = conf->getArgParam("--" + prefix + "-heartbeat-id",""); // it.getProp("heartbeat_id"));
if( !heart.empty() )
{
sidHeartBeat = conf->getSensorID(heart);
if( sidHeartBeat == DefaultObjectId )
{
ostringstream err;
err << myname << ": ID not found ('HeartBeat') for " << heart;
dlog[Debug::CRIT] << myname << "(init): " << err.str() << endl;
throw SystemError(err.str());
}
int heartbeatTime = getHeartBeatTime();
if( heartbeatTime )
ptHeartBeat.setTiming(heartbeatTime);
else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime);
maxHeartBeat = conf->getArgPInt("--" + prefix + "-heartbeat-max","10", 10);
}
}
PassiveLProcessor::~PassiveLProcessor()
......@@ -96,6 +118,7 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm )
return;
}
UniSetTypes::uniset_mutex_lock l(mutex_start, 10000);
askSensors(UniversalIO::UIONotify);
askTimer(tidStep,LProcessor::sleepTime);
break;
......@@ -146,6 +169,25 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm )
}
}
// -------------------------------------------------------------------------
bool PassiveLProcessor::activateObject()
{
// блокирование обработки Starsp
// пока не пройдёт инициализация датчиков
// см. sysCommand()
{
UniSetTypes::uniset_mutex_lock l(mutex_start, 5000);
UniSetObject_LT::activateObject();
initIterators();
}
return true;
}
// ------------------------------------------------------------------------------------------
void PassiveLProcessor::initIterators()
{
shm->initAIterator(aitHeartBeat);
}
// -------------------------------------------------------------------------
void PassiveLProcessor::setOuts()
{
// выcтавляем выходы
......
......@@ -18,7 +18,7 @@ class PassiveLProcessor:
public:
PassiveLProcessor( std::string schema, UniSetTypes::ObjectId objId,
UniSetTypes::ObjectId shmID, SharedMemory* ic=0 );
UniSetTypes::ObjectId shmID, SharedMemory* ic=0, const std::string& prefix="lproc" );
virtual ~PassiveLProcessor();
enum Timers
......@@ -27,7 +27,7 @@ class PassiveLProcessor:
};
protected:
PassiveLProcessor(){};
PassiveLProcessor():shm(0),maxHeartBeat(0){};
virtual void step();
virtual void getInputs();
......@@ -42,6 +42,8 @@ class PassiveLProcessor:
// действия при завершении работы
virtual void sigterm( int signo );
void initIterators();
virtual bool activateObject();
SMInterface* shm;
......@@ -50,6 +52,7 @@ class PassiveLProcessor:
UniSetTypes::ObjectId sidHeartBeat;
int maxHeartBeat;
IOController::AIOStateList::iterator aitHeartBeat;
UniSetTypes::uniset_mutex mutex_start;
};
// ---------------------------------------------------------------------------
#endif
......@@ -23,7 +23,7 @@ Schema::~Schema()
}
}
// -------------------------------------------------------------------------
void Schema::link(Element::ElementID rootID, Element::ElementID childID, int numIn )
void Schema::link( Element::ElementID rootID, Element::ElementID childID, int numIn )
{
Element* e1 = 0;
Element* e2 = 0;
......@@ -88,7 +88,7 @@ void Schema::unlink( Element::ElementID rootID, Element::ElementID childID )
}
}
// -------------------------------------------------------------------------
void Schema::extlink(string name, Element::ElementID childID, int numIn )
void Schema::extlink( const string& name, Element::ElementID childID, int numIn )
{
ElementMap::iterator it = emap.find(childID);
if( it == emap.end() )
......@@ -167,7 +167,7 @@ bool Schema::getOut( Element::ElementID ID )
throw LogicException(msg.str());
}
// -------------------------------------------------------------------------
Element* Schema::find(Element::ElementID id)
Element* Schema::find( Element::ElementID id )
{
ElementMap::iterator it = emap.find(id);
if( it != emap.end() )
......@@ -175,7 +175,7 @@ Element* Schema::find(Element::ElementID id)
return 0;
}
// -------------------------------------------------------------------------
Element* Schema::findExtLink(const string name)
Element* Schema::findExtLink( const string& name )
{
// помечаем внешние связи
for( ExternalList::iterator it=extLinks.begin(); it!=extLinks.end(); ++it )
......
......@@ -52,9 +52,9 @@ class Schema
};
void link(Element::ElementID rootID, Element::ElementID childID, int numIn);
void unlink(Element::ElementID rootID, Element::ElementID childID );
void extlink(std::string name, Element::ElementID childID, int numIn );
void link( Element::ElementID rootID, Element::ElementID childID, int numIn );
void unlink( Element::ElementID rootID, Element::ElementID childID );
void extlink( const std::string& name, Element::ElementID childID, int numIn );
void setIn( Element::ElementID ID, int inNum, bool state );
bool getOut( Element::ElementID ID );
......@@ -94,8 +94,8 @@ class Schema
// find
Element* find(Element::ElementID id);
Element* findExtLink(const std::string name);
Element* findOut(const std::string name);
Element* findExtLink(const std::string& name);
Element* findOut(const std::string& name);
protected:
ElementMap emap; // список элеметов
......@@ -113,7 +113,7 @@ class SchemaXML:
SchemaXML();
virtual ~SchemaXML();
void read(const std::string xmlfile);
void read( const std::string& xmlfile );
protected:
};
......
......@@ -16,7 +16,7 @@ SchemaXML::~SchemaXML()
{
}
// -------------------------------------------------------------------------
void SchemaXML::read( const string xmlfile )
void SchemaXML::read( const string& xmlfile )
{
UniXML xml;
......
......@@ -24,7 +24,7 @@ class TDelay:
inline int getDelay(){ return delay; }
protected:
TDelay(){};
TDelay():myout(false),delay(0){};
bool myout;
PassiveTimer pt;
......
......@@ -277,7 +277,7 @@ bool MBExchange::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
}
// ------------------------------------------------------------------------------------------
MBExchange::DeviceType MBExchange::getDeviceType( const std::string dtype )
MBExchange::DeviceType MBExchange::getDeviceType( const std::string& dtype )
{
if( dtype.empty() )
return dtUnknown;
......
......@@ -55,7 +55,7 @@ class MBExchange:
dtRTU188 /*!< RTU188 (Fastwell) */
};
static DeviceType getDeviceType( const std::string dtype );
static DeviceType getDeviceType( const std::string& dtype );
friend std::ostream& operator<<( std::ostream& os, const DeviceType& dt );
struct RTUDevice;
......@@ -92,7 +92,7 @@ class MBExchange:
RegInfo():
mbval(0),mbreg(0),mbfunc(ModbusRTU::fnUnknown),
id(0),dev(0),
// rtuJack(RTUStorage::nUnknown),rtuChan(0),
rtuJack(RTUStorage::nUnknown),rtuChan(0),
mtrType(MTR::mtUnknown),
q_num(0),q_count(1),mb_initOK(true),sm_initOK(true)
{}
......
......@@ -559,7 +559,7 @@ void RTUStorage::print()
cout << this;
}
// -----------------------------------------------------------------------------
RTUStorage::RTUJack RTUStorage::s2j( const std::string jack )
RTUStorage::RTUJack RTUStorage::s2j( const std::string& jack )
{
if( jack == "J1" || jack == "j1" )
return nJ1;
......
......@@ -38,7 +38,7 @@ class RTUStorage
nX5 // DI (8)
};
static RTUJack s2j( const std::string jack );
static RTUJack s2j( const std::string& jack );
static std::string j2s( RTUJack j );
long getInt( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
......
......@@ -61,7 +61,7 @@ int main( int argc, char **argv )
ModbusRTU::ModbusAddr slaveaddr = 0x00;
int tout = 2000;
DebugStream dlog;
string tofile("");
// string tofile("");
int use485 = 0;
int ncycles = -1;
MTR::MTRType mtrtype = MTR::mtUnknown;
......@@ -189,7 +189,7 @@ int main( int argc, char **argv )
catch( ModbusRTU::mbException& ex )
{
if( ex.err != ModbusRTU::erTimeOut )
throw ex;
throw;
cout << "timeout..." << endl;
}
......
......@@ -88,7 +88,7 @@ int main( int argc, char **argv )
ModbusRTU::ModbusAddr end = 255;
int tout = 20;
DebugStream dlog;
string tofile("");
//string tofile("");
int use485 = 0;
ComPort::StopBits sbits = ComPort::OneBit;
ComPort::Parity parity = ComPort::NoParity;
......
......@@ -53,6 +53,7 @@ class MBSlave:
IOProperty():
mbreg(0),
amode(amRW),
vtype(VTypes::vtUnknown),
wnum(0)
{}
......
......@@ -67,8 +67,6 @@ int main( int argc, const char **argv )
std::list< ThreadCreator<IOControl>* > lst_iothr;
for( int i=0; i<MaxAddNum; i++ )
{
ThreadCreator<IOControl>* io_thr = NULL;
stringstream s;
s << "--add-io";
if( i>0 ) s << i;
......@@ -87,6 +85,7 @@ int main( int argc, const char **argv )
IOControl* ic = IOControl::init_iocontrol(argc,argv,shm->getId(),shm,p.str());
if( ic == NULL )
return 1;
ThreadCreator<IOControl>* io_thr = new ThreadCreator<IOControl>(ic, &IOControl::execute);
if( io_thr == NULL )
return 1;
......
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