Commit 23862161 authored by Pavel Vainerman's avatar Pavel Vainerman

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

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