Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
23862161
Commit
23862161
authored
Jun 13, 2013
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Очередная группа исправлений по результатам прогона cppcheck.
parent
6c072713
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
157 additions
and
108 deletions
+157
-108
admin.cc
Utilities/Admin/admin.cc
+20
-20
MBSlave.cc
Utilities/MBTester/MBSlave.cc
+1
-1
MBSlave.h
Utilities/MBTester/MBSlave.h
+1
-1
MBTCPServer.cc
Utilities/MBTester/MBTCPServer.cc
+1
-1
MBTCPServer.h
Utilities/MBTester/MBTCPServer.h
+1
-1
mbrtutester.cc
Utilities/MBTester/mbrtutester.cc
+1
-1
mbtcptester.cc
Utilities/MBTester/mbtcptester.cc
+1
-1
ctl-cpp-cc-alone-ask.xsl
Utilities/codegen/ctl-cpp-cc-alone-ask.xsl
+4
-4
ctl-cpp-cc-alone.xsl
Utilities/codegen/ctl-cpp-cc-alone.xsl
+3
-3
ctl-cpp-cc-ask.xsl
Utilities/codegen/ctl-cpp-cc-ask.xsl
+4
-4
ctl-cpp-cc.xsl
Utilities/codegen/ctl-cpp-cc.xsl
+4
-4
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+4
-4
skel-main.cc
Utilities/codegen/skel-main.cc
+1
-1
DBInterface.cc
extensions/DBServer-MySQL/DBInterface.cc
+11
-11
DBInterface.h
extensions/DBServer-MySQL/DBInterface.h
+5
-5
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+2
-0
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+2
-0
SQLiteInterface.cc
extensions/DBServer-SQLite/SQLiteInterface.cc
+4
-5
SQLiteInterface.h
extensions/DBServer-SQLite/SQLiteInterface.h
+3
-3
ComediInterface.cc
extensions/IOControl/ComediInterface.cc
+2
-2
ComediInterface.h
extensions/IOControl/ComediInterface.h
+2
-2
Element.h
extensions/LogicProcessor/Element.h
+6
-5
LProcessor.cc
extensions/LogicProcessor/LProcessor.cc
+2
-2
LProcessor.h
extensions/LogicProcessor/LProcessor.h
+2
-2
PassiveLProcessor.cc
extensions/LogicProcessor/PassiveLProcessor.cc
+43
-1
PassiveLProcessor.h
extensions/LogicProcessor/PassiveLProcessor.h
+5
-2
Schema.cc
extensions/LogicProcessor/Schema.cc
+4
-4
Schema.h
extensions/LogicProcessor/Schema.h
+6
-6
SchemaXML.cc
extensions/LogicProcessor/SchemaXML.cc
+1
-1
TDelay.h
extensions/LogicProcessor/TDelay.h
+1
-1
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+1
-1
MBExchange.h
extensions/ModbusMaster/MBExchange.h
+2
-2
RTUStorage.cc
extensions/ModbusMaster/RTUStorage.cc
+1
-1
RTUStorage.h
extensions/ModbusMaster/RTUStorage.h
+1
-1
mtr-read.cc
extensions/ModbusMaster/mtr-read.cc
+2
-2
mtr-setup.cc
extensions/ModbusMaster/mtr-setup.cc
+1
-1
MBSlave.h
extensions/ModbusSlave/MBSlave.h
+1
-0
smemory-plus.cc
extensions/SharedMemoryPlus/smemory-plus.cc
+1
-2
No files found.
Utilities/Admin/admin.cc
View file @
23862161
...
...
@@ -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
)
...
...
Utilities/MBTester/MBSlave.cc
View file @
23862161
...
...
@@ -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),
...
...
Utilities/MBTester/MBSlave.h
View file @
23862161
...
...
@@ -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
)
...
...
Utilities/MBTester/MBTCPServer.cc
View file @
23862161
...
...
@@ -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),
...
...
Utilities/MBTester/MBTCPServer.h
View file @
23862161
...
...
@@ -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
)
...
...
Utilities/MBTester/mbrtutester.cc
View file @
23862161
...
...
@@ -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
;
}
...
...
Utilities/MBTester/mbtcptester.cc
View file @
23862161
...
...
@@ -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
;
}
...
...
Utilities/codegen/ctl-cpp-cc-alone-ask.xsl
View file @
23862161
...
...
@@ -239,7 +239,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
catch(Exception
&
ex)
{
unideb[Debug::CRIT]
<<
myname
<<
"(getState): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
}
// -----------------------------------------------------------------------------
...
...
@@ -318,7 +318,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch(Exception
&
ex)
{
unideb[Debug::CRIT]
<<
myname
<<
"(getdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
@@ -368,7 +368,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch(Exception
&
ex)
{
unideb[Debug::CRIT]
<<
myname
<<
"(setdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
@@ -398,7 +398,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch(Exception
&
ex)
{
unideb[Debug::CRIT]
<<
myname
<<
"(setdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
Utilities/codegen/ctl-cpp-cc-alone.xsl
View file @
23862161
...
...
@@ -256,7 +256,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(getdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
@@ -306,7 +306,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(setdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
@@ -336,7 +336,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(setdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
Utilities/codegen/ctl-cpp-cc-ask.xsl
View file @
23862161
...
...
@@ -204,7 +204,7 @@ long <xsl:value-of select="$CLASSNAME"/>_SK::getValue( UniSetTypes::ObjectId _si
catch(Exception
&
ex)
{
unideb[Debug::CRIT]
<<
myname
<<
"(getState): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
return 0;
...
...
@@ -294,7 +294,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(getdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
}
</xsl:template>
...
...
@@ -326,7 +326,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(setdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
}
</xsl:template>
...
...
@@ -359,7 +359,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId _code
catch( UniSetTypes::Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(setdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
}
</xsl:template>
...
...
Utilities/codegen/ctl-cpp-cc.xsl
View file @
23862161
...
...
@@ -240,7 +240,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
catch( Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(getdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
@@ -272,7 +272,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
catch( Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(setdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
@@ -305,7 +305,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
catch( Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(setdata): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
@@ -337,7 +337,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::setMsg( UniSetTypes::ObjectId code,
catch( Exception
&
ex )
{
unideb[Debug::CRIT]
<<
myname
<<
"(setmsg): "
<<
ex
<<
endl;
throw
ex
;
throw;
}
</xsl:template>
...
...
Utilities/codegen/ctl-cpp-common.xsl
View file @
23862161
...
...
@@ -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
&
name) { return UniSetTypes::conf->getProp(confnode, name); }
int smReadyTimeout; /*!
<
время ожидания готовности 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
&
s1, const std::string
&
s2, const std::string
&
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
&
s1, const std::string
&
s2, const std::string
&
s3 )
{
if( !s1.empty() )
return s1;
...
...
Utilities/codegen/skel-main.cc
View file @
23862161
...
...
@@ -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
);
...
...
extensions/DBServer-MySQL/DBInterface.cc
View file @
23862161
...
...
@@ -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
++
)
...
...
extensions/DBServer-MySQL/DBInterface.h
View file @
23862161
...
...
@@ -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
);
...
...
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
23862161
...
...
@@ -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();
...
...
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
23862161
...
...
@@ -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();
...
...
extensions/DBServer-SQLite/SQLiteInterface.cc
View file @
23862161
...
...
@@ -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
();
...
...
extensions/DBServer-SQLite/SQLiteInterface.h
View file @
23862161
...
...
@@ -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
();
...
...
extensions/IOControl/ComediInterface.cc
View file @
23862161
...
...
@@ -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
;
...
...
extensions/IOControl/ComediInterface.h
View file @
23862161
...
...
@@ -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
);
...
...
extensions/LogicProcessor/Element.h
View file @
23862161
...
...
@@ -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
:
...
...
extensions/LogicProcessor/LProcessor.cc
View file @
23862161
...
...
@@ -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
);
...
...
extensions/LogicProcessor/LProcessor.h
View file @
23862161
...
...
@@ -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
:
...
...
extensions/LogicProcessor/PassiveLProcessor.cc
View file @
23862161
...
...
@@ -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тавляем выходы
...
...
extensions/LogicProcessor/PassiveLProcessor.h
View file @
23862161
...
...
@@ -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
extensions/LogicProcessor/Schema.cc
View file @
23862161
...
...
@@ -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
)
...
...
extensions/LogicProcessor/Schema.h
View file @
23862161
...
...
@@ -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
:
};
...
...
extensions/LogicProcessor/SchemaXML.cc
View file @
23862161
...
...
@@ -16,7 +16,7 @@ SchemaXML::~SchemaXML()
{
}
// -------------------------------------------------------------------------
void
SchemaXML
::
read
(
const
string
xmlfile
)
void
SchemaXML
::
read
(
const
string
&
xmlfile
)
{
UniXML
xml
;
...
...
extensions/LogicProcessor/TDelay.h
View file @
23862161
...
...
@@ -24,7 +24,7 @@ class TDelay:
inline
int
getDelay
(){
return
delay
;
}
protected
:
TDelay
(){};
TDelay
()
:
myout
(
false
),
delay
(
0
)
{};
bool
myout
;
PassiveTimer
pt
;
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
23862161
...
...
@@ -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
;
...
...
extensions/ModbusMaster/MBExchange.h
View file @
23862161
...
...
@@ -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
)
{}
...
...
extensions/ModbusMaster/RTUStorage.cc
View file @
23862161
...
...
@@ -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
;
...
...
extensions/ModbusMaster/RTUStorage.h
View file @
23862161
...
...
@@ -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
);
...
...
extensions/ModbusMaster/mtr-read.cc
View file @
23862161
...
...
@@ -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
;
}
...
...
extensions/ModbusMaster/mtr-setup.cc
View file @
23862161
...
...
@@ -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
;
...
...
extensions/ModbusSlave/MBSlave.h
View file @
23862161
...
...
@@ -53,6 +53,7 @@ class MBSlave:
IOProperty
()
:
mbreg
(
0
),
amode
(
amRW
),
vtype
(
VTypes
::
vtUnknown
),
wnum
(
0
)
{}
...
...
extensions/SharedMemoryPlus/smemory-plus.cc
View file @
23862161
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment