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
2b8c397e
Commit
2b8c397e
authored
May 11, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'devel/master'
parents
38a454ba
34a31d77
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
685 additions
and
51 deletions
+685
-51
TODO
TODO
+4
-0
main.cc
Utilities/SImitator/main.cc
+2
-2
libuniset2.spec
conf/libuniset2.spec
+53
-5
configure.ac
configure.ac
+19
-0
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+1
-1
DBServer_PostgreSQL.cc
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
+0
-0
DBServer_PostgreSQL.h
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.h
+75
-0
Makefile.am
extensions/DBServer-PostgreSQL/Makefile.am
+30
-0
PostgreSQLInterface.cc
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
+216
-0
PostgreSQLInterface.h
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
+98
-0
create_links.sh
extensions/DBServer-PostgreSQL/create_links.sh
+4
-0
libUniSet2PostgreSQL.pc.in
extensions/DBServer-PostgreSQL/libUniSet2PostgreSQL.pc.in
+11
-0
main.cc
extensions/DBServer-PostgreSQL/main.cc
+40
-0
start_fg.sh
extensions/DBServer-PostgreSQL/start_fg.sh
+7
-0
test.cc
extensions/DBServer-PostgreSQL/test.cc
+65
-0
Makefile.am
extensions/IOControl/Makefile.am
+4
-1
PassiveLProcessor.cc
extensions/LogicProcessor/PassiveLProcessor.cc
+2
-1
PassiveLProcessor.h
extensions/LogicProcessor/PassiveLProcessor.h
+1
-1
plogicproc.cc
extensions/LogicProcessor/plogicproc.cc
+1
-1
Makefile.am
extensions/Makefile.am
+2
-1
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+6
-5
test_mbslave.cc
extensions/ModbusSlave/tests/test_mbslave.cc
+2
-2
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+2
-2
test_sm.cc
extensions/SharedMemory/tests/test_sm.cc
+9
-8
Makefile.am
extensions/UniNetwork/Makefile.am
+2
-1
Calibration.h
extensions/include/Calibration.h
+8
-5
Calibration.cc
extensions/lib/Calibration.cc
+6
-5
TCPCheck.h
include/TCPCheck.h
+2
-2
TCPCheck.cc
src/Communications/TCP/TCPCheck.cc
+2
-1
LogSession.cc
src/Log/LogSession.cc
+2
-6
test_tcpcheck.cc
tests/test_tcpcheck.cc
+1
-1
uniset2.files
uniset2.files
+8
-0
No files found.
TODO
View file @
2b8c397e
...
@@ -46,6 +46,10 @@ uniset-codegen: добавить ключ --gen-sensor-name для генери
...
@@ -46,6 +46,10 @@ uniset-codegen: добавить ключ --gen-sensor-name для генери
- перевести PassiveTimer на использование crono:: (c++11)
- перевести PassiveTimer на использование crono:: (c++11)
SQL:
====
- добавить работу с History (при передаче указателя на SM в конструкторе).
Version 2.1
Version 2.1
============
============
- smonit запись значений в файл (csv?,sqlite?)
- smonit запись значений в файл (csv?,sqlite?)
...
...
Utilities/SImitator/main.cc
View file @
2b8c397e
...
@@ -60,7 +60,7 @@ int main( int argc, char** argv )
...
@@ -60,7 +60,7 @@ int main( int argc, char** argv )
std
::
list
<
ExtInfo
>
l
;
std
::
list
<
ExtInfo
>
l
;
for
(
auto
&&
it
:
lst
)
for
(
auto
&&
it
:
lst
)
{
{
UniversalIO
::
IOType
t
=
conf
->
getIOType
(
it
.
si
.
id
);
UniversalIO
::
IOType
t
=
conf
->
getIOType
(
it
.
si
.
id
);
...
@@ -129,7 +129,7 @@ int main( int argc, char** argv )
...
@@ -129,7 +129,7 @@ int main( int argc, char** argv )
cout
<<
"
\r
"
<<
" i = "
<<
j
<<
" "
<<
flush
;
cout
<<
"
\r
"
<<
" i = "
<<
j
<<
" "
<<
flush
;
for
(
const
auto
&
it
:
l
)
for
(
const
auto
&
it
:
l
)
{
{
try
try
{
{
...
...
conf/libuniset2.spec
View file @
2b8c397e
%def_enable docs
%def_enable docs
%def_enable mysql
%def_enable mysql
%def_enable sqlite
%def_enable sqlite
%def_enable pgsql
%def_enable python
%def_enable python
%def_enable rrd
%def_enable rrd
%def_enable io
%def_enable io
...
@@ -12,7 +13,7 @@
...
@@ -12,7 +13,7 @@
Name: libuniset2
Name: libuniset2
Version: 2.0
Version: 2.0
Release: alt3
0
Release: alt3
1
Summary: UniSet - library for building distributed industrial control systems
Summary: UniSet - library for building distributed industrial control systems
...
@@ -26,8 +27,9 @@ Packager: Pavel Vainerman <pv@altlinux.ru>
...
@@ -26,8 +27,9 @@ Packager: Pavel Vainerman <pv@altlinux.ru>
Source: %name-%version.tar
Source: %name-%version.tar
# manually removed: glibc-devel-static
# manually removed: glibc-devel-static
# Automatically added by buildreq on Fri Nov 26 2010
# Automatically added by buildreq on Mon May 11 2015
BuildRequires: libcommoncpp2-devel libomniORB-devel libsigc++2.0-devel xsltproc catch
# optimized out: fontconfig gcc-c++ libcloog-isl4 libstdc++-devel libwayland-client libwayland-server libxml2-devel pkg-config python-base python-devel python-module-omniidl python-modules
BuildRequires: libcommoncpp2-devel libomniORB-devel libsigc++2-devel
%if_enabled io
%if_enabled io
BuildRequires: libcomedi-devel
BuildRequires: libcomedi-devel
...
@@ -35,13 +37,17 @@ BuildRequires: libcomedi-devel
...
@@ -35,13 +37,17 @@ BuildRequires: libcomedi-devel
%if_enabled mysql
%if_enabled mysql
# Using old package name instead of libmysqlclient-devel it absent in branch 5.0 for yauza
# Using old package name instead of libmysqlclient-devel it absent in branch 5.0 for yauza
BuildRequires: lib
MySQL
-devel
BuildRequires: lib
mysqlclient
-devel
%endif
%endif
%if_enabled sqlite
%if_enabled sqlite
BuildRequires: libsqlite3-devel
BuildRequires: libsqlite3-devel
%endif
%endif
%if_enabled pgsql
BuildRequires: libpqxx-devel
%endif
%if_enabled rrd
%if_enabled rrd
BuildRequires: librrd-devel
BuildRequires: librrd-devel
%endif
%endif
...
@@ -175,6 +181,24 @@ Requires: %name-extension-common = %version-%release
...
@@ -175,6 +181,24 @@ Requires: %name-extension-common = %version-%release
Libraries needed to develop for uniset SQLite
Libraries needed to develop for uniset SQLite
%endif
%endif
%if_enabled pgsql
%package extension-pgsql
Group: Development/Databases
Summary: PostgreSQL-dbserver implementatioin for UniSet
Requires: %name-extension-common = %version-%release
%description extension-pgsql
PostgreSQL dbserver for %name
%package extension-pgsql-devel
Group: Development/Databases
Summary: Libraries needed to develop for uniset PostgreSQL
Requires: %name-extension-common-devel = %version-%release
%description extension-pgsql-devel
Libraries needed to develop for uniset PostgreSQL
%endif
%if_enabled rrd
%if_enabled rrd
%package extension-rrd
%package extension-rrd
Group: Development/C++
Group: Development/C++
...
@@ -241,7 +265,7 @@ SharedMemoryPlus extension ('all in one') for libuniset
...
@@ -241,7 +265,7 @@ SharedMemoryPlus extension ('all in one') for libuniset
%build
%build
%autoreconf
%autoreconf
%configure %{subst_enable docs} %{subst_enable mysql} %{subst_enable sqlite} %{subst_enable python} %{subst_enable rrd} %{subst_enable io} %{subst_enable logicproc} %{subst_enable tests}
%configure %{subst_enable docs} %{subst_enable mysql} %{subst_enable sqlite} %{subst_enable p
gsql} %{subst_enable p
ython} %{subst_enable rrd} %{subst_enable io} %{subst_enable logicproc} %{subst_enable tests}
%make
%make
%install
%install
...
@@ -292,6 +316,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -292,6 +316,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%if_enabled sqlite
%if_enabled sqlite
%_includedir/%oname/sqlite/
%_includedir/%oname/sqlite/
%endif
%endif
%if_enabled pgsql
%_includedir/%oname/pgsql/
%endif
%_libdir/libUniSet2.so
%_libdir/libUniSet2.so
%_datadir/idl/%oname/
%_datadir/idl/%oname/
...
@@ -315,6 +342,15 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -315,6 +342,15 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%_pkgconfigdir/libUniSet2SQLite.pc
%_pkgconfigdir/libUniSet2SQLite.pc
%endif
%endif
%if_enabled pgsql
%files extension-pgsql
%_bindir/%oname-pgsql-*dbserver
%_libdir/*-pgsql.so*
%files extension-pgsql-devel
%_pkgconfigdir/libUniSet2PostgreSQL.pc
%endif
%if_enabled python
%if_enabled python
%files -n python-module-%oname
%files -n python-module-%oname
%dir %python_sitelibdir/%oname
%dir %python_sitelibdir/%oname
...
@@ -409,6 +445,12 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -409,6 +445,12 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
# ..
%changelog
%changelog
* Mon May 11 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt31
- Calibrations: fixed bug
- LogSession: fixed bug
- PQSQL: minor fixes, update requires
- make style
* Fri May 08 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt30
* Fri May 08 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt30
- ModbusSlave: added support nbit='' for 0x06 and 0x10 function (setbug #7337)
- ModbusSlave: added support nbit='' for 0x06 and 0x10 function (setbug #7337)
...
@@ -441,6 +483,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -441,6 +483,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
- fixed bug in 'MBSlave' (thank`s Alexandr Hanadeev)
- fixed bug in 'MBSlave' (thank`s Alexandr Hanadeev)
- add --xxx-set-prop-prefix for MBSlave
- add --xxx-set-prop-prefix for MBSlave
* Sat Apr 04 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt24.1
- test pgsql extension build
* Thu Apr 02 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt24
* Thu Apr 02 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt24
- codegen: modify interface for messages (setMsg())
- codegen: modify interface for messages (setMsg())
- remove alarm() function (deprecated)
- remove alarm() function (deprecated)
...
@@ -498,6 +543,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
...
@@ -498,6 +543,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
- fixed bug in specfile: --enable-doc --> --enable-docs
- fixed bug in specfile: --enable-doc --> --enable-docs
- transition to use shared_ptr wherever possible
- transition to use shared_ptr wherever possible
* Sat Dec 20 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt10.1
- added PostgreSQL support
* Mon Nov 24 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt10
* Mon Nov 24 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt10
- use shared_ptr
- use shared_ptr
...
...
configure.ac
View file @
2b8c397e
...
@@ -81,6 +81,23 @@ fi
...
@@ -81,6 +81,23 @@ fi
AM_CONDITIONAL(DISABLE_MYSQL, test ${buildmysql} = false)
AM_CONDITIONAL(DISABLE_MYSQL, test ${buildmysql} = false)
#check pgsql support
AC_MSG_CHECKING([postgresql support])
buildpgsql=true
AC_ARG_ENABLE(pgsql, AC_HELP_STRING([--disable-pgsql], [disable PostgreSQL support]),
[ if test $enableval = yes; then buildpgsql=true; else buildpgsql=false; fi],[ buildpgsql=true; ])
if test ${buildpgsql} = true; then
AC_MSG_RESULT([enabled])
PKG_CHECK_MODULES(PGSQL,libpqxx)
AC_SUBST(PGSQL_LIBS)
AC_SUBST(PGSQL_CFLAGS)
else
AC_MSG_RESULT([disabled])
fi
AM_CONDITIONAL(DISABLE_PGSQL, test ${buildpgsql} = false)
#check rrd support
#check rrd support
AC_MSG_CHECKING([rrd support])
AC_MSG_CHECKING([rrd support])
...
@@ -330,6 +347,8 @@ AC_CONFIG_FILES([Makefile
...
@@ -330,6 +347,8 @@ AC_CONFIG_FILES([Makefile
extensions/DBServer-MySQL/libUniSet2MySQL.pc
extensions/DBServer-MySQL/libUniSet2MySQL.pc
extensions/DBServer-SQLite/Makefile
extensions/DBServer-SQLite/Makefile
extensions/DBServer-SQLite/libUniSet2SQLite.pc
extensions/DBServer-SQLite/libUniSet2SQLite.pc
extensions/DBServer-PostgreSQL/Makefile
extensions/DBServer-PostgreSQL/libUniSet2PostgreSQL.pc
extensions/IOControl/Makefile
extensions/IOControl/Makefile
extensions/IOControl/libUniSet2IOControl.pc
extensions/IOControl/libUniSet2IOControl.pc
extensions/ModbusMaster/Makefile
extensions/ModbusMaster/Makefile
...
...
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
2b8c397e
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
using
namespace
UniSetTypes
;
using
namespace
UniSetTypes
;
using
namespace
std
;
using
namespace
std
;
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
#define dblog if( ulog()->debugging(DBLogInfoLevel) )
(*(ulog().get()))[DBLogInfoLevel]
#define dblog if( ulog()->debugging(DBLogInfoLevel) )
ulog()->debug(DBLogInfoLevel)
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
DBServer_MySQL
::
DBServer_MySQL
(
ObjectId
id
)
:
DBServer_MySQL
::
DBServer_MySQL
(
ObjectId
id
)
:
DBServer
(
id
),
DBServer
(
id
),
...
...
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
0 → 100644
View file @
2b8c397e
This diff is collapsed.
Click to expand it.
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.h
0 → 100644
View file @
2b8c397e
#ifndef DBServer_PostgreSQL_H_
#define DBServer_PostgreSQL_H_
// --------------------------------------------------------------------------
#include <map>
#include <queue>
#include "UniSetTypes.h"
#include "PostgreSQLInterface.h"
#include "DBServer.h"
//------------------------------------------------------------------------------------------
class
DBServer_PostgreSQL
:
public
DBServer
{
public
:
DBServer_PostgreSQL
(
UniSetTypes
::
ObjectId
id
,
const
std
::
string
&
prefix
);
DBServer_PostgreSQL
();
virtual
~
DBServer_PostgreSQL
();
static
const
Debug
::
type
DBLogInfoLevel
=
Debug
::
LEVEL9
;
/*! глобальная функция для инициализации объекта */
static
std
::
shared_ptr
<
DBServer_PostgreSQL
>
init_dbserver
(
int
argc
,
const
char
*
const
*
argv
,
const
std
::
string
&
prefix
=
"pgsql"
);
/*! глобальная функция для вывода help-а */
static
void
help_print
(
int
argc
,
const
char
*
const
*
argv
);
protected
:
typedef
std
::
map
<
int
,
std
::
string
>
DBTableMap
;
virtual
void
initDB
(
std
::
shared_ptr
<
PostgreSQLInterface
>&
db
)
{};
virtual
void
initDBTableMap
(
DBTableMap
&
tblMap
)
{};
virtual
void
timerInfo
(
const
UniSetTypes
::
TimerMessage
*
tm
)
override
;
virtual
void
sysCommand
(
const
UniSetTypes
::
SystemMessage
*
sm
)
override
;
virtual
void
sensorInfo
(
const
UniSetTypes
::
SensorMessage
*
sm
)
override
;
virtual
void
confirmInfo
(
const
UniSetTypes
::
ConfirmMessage
*
cmsg
)
override
;
virtual
void
sigterm
(
int
signo
)
override
;
bool
writeToBase
(
const
string
&
query
);
virtual
void
init_dbserver
();
void
createTables
(
std
::
shared_ptr
<
PostgreSQLInterface
>&
db
);
inline
const
char
*
tblName
(
int
key
)
{
return
tblMap
[
key
].
c_str
();
}
enum
Timers
{
PingTimer
,
/*!< таймер на переодическую проверку соединения с сервером БД */
ReconnectTimer
,
/*!< таймер на повторную попытку соединения с сервером БД (или восстановления связи) */
lastNumberOfTimer
};
std
::
shared_ptr
<
PostgreSQLInterface
>
db
;
int
PingTime
;
int
ReconnectTime
;
bool
connect_ok
;
/*! признак наличия соеднинения с сервером БД */
bool
activate
;
typedef
std
::
queue
<
std
::
string
>
QueryBuffer
;
QueryBuffer
qbuf
;
unsigned
int
qbufSize
;
// размер буфера сообщений.
bool
lastRemove
;
void
flushBuffer
();
UniSetTypes
::
uniset_mutex
mqbuf
;
private
:
DBTableMap
tblMap
;
};
//------------------------------------------------------------------------------------------
#endif
extensions/DBServer-PostgreSQL/Makefile.am
0 → 100644
View file @
2b8c397e
if
DISABLE_PGSQL
else
UPGSQL_VER
=
@LIBVER@
lib_LTLIBRARIES
=
libUniSet2-pgsql.la
libUniSet2_pgsql_la_LDFLAGS
=
-version-info
$(UPGSQL_VER)
libUniSet2_pgsql_la_SOURCES
=
PostgreSQLInterface.cc DBServer_PostgreSQL.cc
libUniSet2_pgsql_la_LIBADD
=
$(top_builddir)
/lib/libUniSet2.la
$(PGSQL_LIBS)
libUniSet2_pgsql_la_CXXFLAGS
=
$(PGSQL_CFLAGS)
bin_PROGRAMS
=
@PACKAGE@-pgsql-dbserver
@PACKAGE@
_pgsql_dbserver_LDADD
=
libUniSet2-pgsql.la
$(top_builddir)
/lib/libUniSet2.la
$(PGSQL_LIBS)
@PACKAGE@
_pgsql_dbserver_CXXFLAGS
=
$(PGSQL_CFLAGS)
@PACKAGE@
_pgsql_dbserver_SOURCES
=
main.cc
noinst_PROGRAMS
=
pgsql-test
pgsql_test_LDADD
=
libUniSet2-pgsql.la
$(top_builddir)
/lib/libUniSet2.la
$(PGSQL_LIBS)
pgsql_test_CXXFLAGS
=
$(PGSQL_CFLAGS)
pgsql_test_SOURCES
=
test.cc
# install
devel_include_HEADERS
=
*
.h
devel_includedir
=
$(includedir)
/@PACKAGE@/pgsql
pkgconfigdir
=
$(libdir)
/pkgconfig
pkgconfig_DATA
=
libUniSet2PostgreSQL.pc
endif
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
0 → 100644
View file @
2b8c397e
// --------------------------------------------------------------------------
#include <sstream>
#include <cstdio>
#include <UniSetTypes.h>
#include "PostgreSQLInterface.h"
// --------------------------------------------------------------------------
using
namespace
std
;
using
namespace
UniSetTypes
;
using
namespace
pqxx
;
// --------------------------------------------------------------------------
PostgreSQLInterface
::
PostgreSQLInterface
()
:
lastQ
(
""
),
lastE
(
""
),
last_inserted_id
(
0
)
{
//db = make_shared<pqxx::connection>();
}
PostgreSQLInterface
::~
PostgreSQLInterface
()
{
close
();
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
ping
()
{
return
db
&&
db
->
is_open
();
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
connect
(
const
string
&
host
,
const
string
&
user
,
const
string
&
pswd
,
const
string
&
dbname
)
{
if
(
db
)
return
true
;
std
::
string
conninfo
=
"dbname="
+
dbname
+
" host="
+
host
+
" user="
+
user
+
" password="
+
pswd
;
try
{
db
=
make_shared
<
pqxx
::
connection
>
(
conninfo
);
return
db
->
is_open
();
}
catch
(
const
std
::
exception
&
e
)
{
cerr
<<
e
.
what
()
<<
std
::
endl
;
}
return
false
;
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
close
()
{
if
(
db
)
{
db
->
disconnect
();
db
.
reset
();
}
return
true
;
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
insert
(
const
string
&
q
)
{
if
(
!
db
)
return
false
;
try
{
work
w
(
*
(
db
.
get
())
);
w
.
exec
(
q
);
w
.
commit
();
return
true
;
}
catch
(
const
std
::
exception
&
e
)
{
//cerr << e.what() << std::endl;
lastE
=
string
(
e
.
what
());
}
return
false
;
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
insertAndSaveRowid
(
const
string
&
q
)
{
if
(
!
db
)
return
false
;
std
::
string
qplus
=
q
+
" RETURNING id"
;
try
{
work
w
(
*
(
db
.
get
())
);
pqxx
::
result
res
=
w
.
exec
(
qplus
);
w
.
commit
();
save_inserted_id
(
res
);
return
true
;
}
catch
(
const
std
::
exception
&
e
)
{
//cerr << e.what() << std::endl;
lastE
=
string
(
e
.
what
());
}
return
false
;
}
// -----------------------------------------------------------------------------------------
PostgreSQLResult
PostgreSQLInterface
::
query
(
const
string
&
q
)
{
if
(
!
db
)
return
PostgreSQLResult
();
try
{
nontransaction
n
(
*
(
db
.
get
()));
/* Execute SQL query */
result
res
(
n
.
exec
(
q
)
);
return
PostgreSQLResult
(
res
);
}
catch
(
const
std
::
exception
&
e
)
{
lastE
=
string
(
e
.
what
());
}
return
PostgreSQLResult
();
}
// -----------------------------------------------------------------------------------------
string
PostgreSQLInterface
::
error
()
{
return
lastE
;
}
// -----------------------------------------------------------------------------------------
const
string
PostgreSQLInterface
::
lastQuery
()
{
return
lastQ
;
}
// -----------------------------------------------------------------------------------------
double
PostgreSQLInterface
::
insert_id
()
{
return
last_inserted_id
;
}
// -----------------------------------------------------------------------------------------
void
PostgreSQLInterface
::
save_inserted_id
(
const
pqxx
::
result
&
res
)
{
if
(
res
.
size
()
>
0
&&
res
[
0
].
size
()
>
0
)
last_inserted_id
=
res
[
0
][
0
].
as
<
int
>
();
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
isConnection
()
{
return
(
db
&&
db
->
is_open
());
}
// -----------------------------------------------------------------------------------------
int
num_cols
(
PostgreSQLResult
::
iterator
&
it
)
{
return
it
->
size
();
}
// -----------------------------------------------------------------------------------------
int
as_int
(
PostgreSQLResult
::
iterator
&
it
,
int
col
)
{
// if( col<0 || col >it->size() )
// return 0;
return
uni_atoi
(
(
*
it
)[
col
]
);
}
// -----------------------------------------------------------------------------------------
double
as_double
(
PostgreSQLResult
::
iterator
&
it
,
int
col
)
{
return
atof
(
((
*
it
)[
col
]).
c_str
()
);
}
// -----------------------------------------------------------------------------------------
string
as_string
(
PostgreSQLResult
::
iterator
&
it
,
int
col
)
{
return
((
*
it
)[
col
]);
}
// -----------------------------------------------------------------------------------------
int
as_int
(
PostgreSQLResult
::
COL
::
iterator
&
it
)
{
return
uni_atoi
(
(
*
it
)
);
}
// -----------------------------------------------------------------------------------------
double
as_double
(
PostgreSQLResult
::
COL
::
iterator
&
it
)
{
return
atof
(
(
*
it
).
c_str
()
);
}
// -----------------------------------------------------------------------------------------
std
::
string
as_string
(
PostgreSQLResult
::
COL
::
iterator
&
it
)
{
return
(
*
it
);
}
// -----------------------------------------------------------------------------------------
#if 0
PostgreSQLResult::COL get_col( PostgreSQLResult::ROW::iterator& it )
{
return (*it);
}
#endif
// -----------------------------------------------------------------------------------------
PostgreSQLResult
::~
PostgreSQLResult
()
{
}
// -----------------------------------------------------------------------------------------
PostgreSQLResult
::
PostgreSQLResult
(
const
pqxx
::
result
&
res
)
{
for
(
result
::
const_iterator
c
=
res
.
begin
();
c
!=
res
.
end
();
++
c
)
{
COL
col
;
for
(
int
i
=
0
;
i
<
c
.
size
();
i
++
)
col
.
push_back
(
c
[
i
].
as
<
string
>
()
);
row
.
push_back
(
col
);
}
}
// -----------------------------------------------------------------------------------------
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
0 → 100644
View file @
2b8c397e
//----------------------------------------------------------------------------
#ifndef PostgreSQLInterface_H_
#define PostgreSQLInterface_H_
// ---------------------------------------------------------------------------
#include <string>
#include <list>
#include <vector>
#include <iostream>
#include <pqxx/pqxx>
#include <PassiveTimer.h>
// ----------------------------------------------------------------------------
class
PostgreSQLResult
;
// ----------------------------------------------------------------------------
class
PostgreSQLInterface
{
public
:
PostgreSQLInterface
();
~
PostgreSQLInterface
();
bool
connect
(
const
std
::
string
&
host
,
const
std
::
string
&
user
,
const
std
::
string
&
pswd
,
const
std
::
string
&
dbname
);
bool
close
();
bool
isConnection
();
bool
ping
();
// проверка доступности БД
PostgreSQLResult
query
(
const
std
::
string
&
q
);
const
std
::
string
lastQuery
();
bool
insert
(
const
std
::
string
&
q
);
bool
insertAndSaveRowid
(
const
std
::
string
&
q
);
double
insert_id
();
void
save_inserted_id
(
const
pqxx
::
result
&
res
);
std
::
string
error
();
protected
:
private
:
std
::
shared_ptr
<
pqxx
::
connection
>
db
;
std
::
string
lastQ
;
std
::
string
lastE
;
double
last_inserted_id
;
};
// ----------------------------------------------------------------------------------
class
PostgreSQLResult
{
public
:
PostgreSQLResult
()
{}
PostgreSQLResult
(
const
pqxx
::
result
&
res
);
~
PostgreSQLResult
();
typedef
std
::
vector
<
std
::
string
>
COL
;
typedef
std
::
list
<
COL
>
ROW
;
typedef
ROW
::
iterator
iterator
;
inline
iterator
begin
()
{
return
row
.
begin
();
}
inline
iterator
end
()
{
return
row
.
end
();
}
inline
operator
bool
()
{
return
!
row
.
empty
();
}
inline
int
size
()
{
return
row
.
size
();
}
inline
bool
empty
()
{
return
row
.
empty
();
}
protected
:
ROW
row
;
};
// ----------------------------------------------------------------------------
int
num_cols
(
PostgreSQLResult
::
iterator
&
);
// ROW
int
as_int
(
PostgreSQLResult
::
iterator
&
,
int
col
);
double
as_double
(
PostgreSQLResult
::
iterator
&
,
int
col
);
std
::
string
as_text
(
PostgreSQLResult
::
iterator
&
,
int
col
);
// ----------------------------------------------------------------------------
// COL
int
as_int
(
PostgreSQLResult
::
COL
::
iterator
&
);
double
as_double
(
PostgreSQLResult
::
COL
::
iterator
&
);
std
::
string
as_string
(
PostgreSQLResult
::
COL
::
iterator
&
);
//----------------------------------------------------------------------------
#endif
// ----------------------------------------------------------------------------------
extensions/DBServer-PostgreSQL/create_links.sh
0 → 100755
View file @
2b8c397e
#!/bin/sh
ln
-s
-f
/usr/bin/uniset2-stop.sh stop.sh
ln
-s
-f
../../conf/test.xml test.xml
extensions/DBServer-PostgreSQL/libUniSet2PostgreSQL.pc.in
0 → 100644
View file @
2b8c397e
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libUniSet2PostgreSQL
Description: Support library for libUniSet2PostgreSQL
Requires: libUniSet2 libpqxx
Version: @VERSION@
Libs: -L${libdir} -lUniSet2-pgsql
Cflags: -I${includedir}/@PACKAGE@ -I${includedir}/@PACKAGE@/pgsql
extensions/DBServer-PostgreSQL/main.cc
0 → 100644
View file @
2b8c397e
#include "Configuration.h"
#include "DBServer_PostgreSQL.h"
#include "UniSetActivator.h"
#include "Debug.h"
// --------------------------------------------------------------------------
using
namespace
UniSetTypes
;
using
namespace
std
;
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
try
{
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"--help"
)
)
{
DBServer_PostgreSQL
::
help_print
(
argc
,
argv
);
return
0
;
}
auto
conf
=
uniset_init
(
argc
,
argv
,
"configure.xml"
);
auto
dbs
=
DBServer_PostgreSQL
::
init_dbserver
(
argc
,
argv
);
auto
act
=
UniSetActivator
::
Instance
();
act
->
add
(
dbs
);
act
->
run
(
false
);
}
catch
(
const
Exception
&
ex
)
{
cerr
<<
"(DBServer_PosgreSQL::main): "
<<
ex
<<
endl
;
}
catch
(
std
::
exception
&
ex
)
{
cerr
<<
"(DBServer_PosgreSQL::main): "
<<
ex
.
what
()
<<
endl
;
}
catch
(...)
{
cerr
<<
"(DBServer_PosgreSQL::main): catch ..."
<<
endl
;
}
return
0
;
}
extensions/DBServer-PostgreSQL/start_fg.sh
0 → 100755
View file @
2b8c397e
#!/bin/sh
ulimit
-Sc
1000000
uniset2-start.sh
-f
./uniset2-pgsql-dbserver
--confile
test.xml
--name
DBServer1
\
--ulog-add-levels
info,crit,warn,level9,system
\
--dbserver-buffer-size
100
extensions/DBServer-PostgreSQL/test.cc
0 → 100644
View file @
2b8c397e
#include <iostream>
#include <sstream>
#include "Exceptions.h"
#include "PostgreSQLInterface.h"
// --------------------------------------------------------------------------
using
namespace
UniSetTypes
;
using
namespace
std
;
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
std
::
string
dbname
(
"test-db"
);
if
(
argc
>
1
)
dbname
=
string
(
argv
[
1
]);
try
{
PostgreSQLInterface
db
;
if
(
!
db
.
connect
(
"localhost"
,
"dbadmin"
,
"dbadmin"
,
dbname
)
)
{
cerr
<<
"db connect error: "
<<
db
.
error
()
<<
endl
;
return
1
;
}
stringstream
q
;
q
<<
"SELECT * from main_history"
;
PostgreSQLResult
r
=
db
.
query
(
q
.
str
());
if
(
!
r
)
{
cerr
<<
"db connect error: "
<<
db
.
error
()
<<
endl
;
return
1
;
}
for
(
PostgreSQLResult
::
iterator
it
=
r
.
begin
();
it
!=
r
.
end
();
it
++
)
{
cout
<<
"ROW: "
;
PostgreSQLResult
::
COL
col
(
*
it
);
for
(
PostgreSQLResult
::
COL
::
iterator
cit
=
it
->
begin
();
cit
!=
it
->
end
();
cit
++
)
cout
<<
as_string
(
cit
)
<<
"("
<<
as_double
(
cit
)
<<
") | "
;
cout
<<
endl
;
}
db
.
close
();
}
catch
(
const
Exception
&
ex
)
{
cerr
<<
"(test): "
<<
ex
<<
endl
;
}
catch
(
std
::
exception
&
ex
)
{
cerr
<<
"(test): "
<<
ex
.
what
()
<<
endl
;
}
catch
(...)
{
cerr
<<
"(test): catch ..."
<<
endl
;
}
return
0
;
}
extensions/IOControl/Makefile.am
View file @
2b8c397e
...
@@ -20,7 +20,9 @@ libUniSet2IOControl_la_SOURCES = ComediInterface.cc IOControl.cc
...
@@ -20,7 +20,9 @@ libUniSet2IOControl_la_SOURCES = ComediInterface.cc IOControl.cc
@PACKAGE@
_iocontrol_LDADD
=
libUniSet2IOControl.la
\
@PACKAGE@
_iocontrol_LDADD
=
libUniSet2IOControl.la
\
$(top_builddir)
/lib/libUniSet2.la
\
$(top_builddir)
/lib/libUniSet2.la
\
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
$(COMEDI_LIBS)
$(SIGC_LIBS)
$(COMCPP_LIBS)
-lm
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
\
$(top_builddir)
/extensions/SharedMemory/libUniSet2SharedMemory.la
\
$(COMEDI_LIBS)
$(SIGC_LIBS)
$(COMCPP_LIBS)
-lm
@PACKAGE@
_iocontrol_CXXFLAGS
=
$(COMEDI_CFLAGS)
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
\
@PACKAGE@
_iocontrol_CXXFLAGS
=
$(COMEDI_CFLAGS)
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
\
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/SharedMemory
-I
$(top_builddir)
/extensions/SharedMemory
...
@@ -34,6 +36,7 @@ libUniSet2IOControl_la_SOURCES = ComediInterface.cc IOControl.cc
...
@@ -34,6 +36,7 @@ libUniSet2IOControl_la_SOURCES = ComediInterface.cc IOControl.cc
@PACKAGE@
_iocalibr_LDADD
=
$(COMEDI_LIBS)
\
@PACKAGE@
_iocalibr_LDADD
=
$(COMEDI_LIBS)
\
$(top_builddir)
/lib/libUniSet2.la
\
$(top_builddir)
/lib/libUniSet2.la
\
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
\
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
\
$(top_builddir)
/extensions/SharedMemory/libUniSet2SharedMemory.la
\
-lm
-lm
@PACKAGE@
_iocalibr_SOURCES
=
iocalibr.cc
@PACKAGE@
_iocalibr_SOURCES
=
iocalibr.cc
...
...
extensions/LogicProcessor/PassiveLProcessor.cc
View file @
2b8c397e
...
@@ -26,7 +26,8 @@ PassiveLProcessor::PassiveLProcessor( UniSetTypes::ObjectId objId,
...
@@ -26,7 +26,8 @@ PassiveLProcessor::PassiveLProcessor( UniSetTypes::ObjectId objId,
UniXML
::
iterator
it
(
confnode
);
UniXML
::
iterator
it
(
confnode
);
confnode
=
conf
->
getNode
(
myname
);
confnode
=
conf
->
getNode
(
myname
);
string
lfile
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-schema"
,
it
.
getProp
(
"schema"
));
string
lfile
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-schema"
,
it
.
getProp
(
"schema"
));
if
(
lfile
.
empty
()
)
if
(
lfile
.
empty
()
)
{
{
ostringstream
err
;
ostringstream
err
;
...
...
extensions/LogicProcessor/PassiveLProcessor.h
View file @
2b8c397e
...
@@ -30,7 +30,7 @@ class PassiveLProcessor:
...
@@ -30,7 +30,7 @@ class PassiveLProcessor:
static
void
help_print
(
int
argc
,
const
char
*
const
*
argv
);
static
void
help_print
(
int
argc
,
const
char
*
const
*
argv
);
static
std
::
shared_ptr
<
PassiveLProcessor
>
init_plproc
(
int
argc
,
const
char
*
const
*
argv
,
static
std
::
shared_ptr
<
PassiveLProcessor
>
init_plproc
(
int
argc
,
const
char
*
const
*
argv
,
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
=
nullptr
,
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
=
nullptr
,
const
std
::
string
&
prefix
=
"plproc"
);
const
std
::
string
&
prefix
=
"plproc"
);
protected
:
protected
:
...
...
extensions/LogicProcessor/plogicproc.cc
View file @
2b8c397e
...
@@ -60,7 +60,7 @@ int main(int argc, const char** argv)
...
@@ -60,7 +60,7 @@ int main(int argc, const char** argv)
return
1
;
return
1
;
}
}
auto
plp
=
PassiveLProcessor
::
init_plproc
(
argc
,
argv
,
shmID
);
auto
plp
=
PassiveLProcessor
::
init_plproc
(
argc
,
argv
,
shmID
);
auto
act
=
UniSetActivator
::
Instance
();
auto
act
=
UniSetActivator
::
Instance
();
act
->
add
(
plp
);
act
->
add
(
plp
);
...
...
extensions/Makefile.am
View file @
2b8c397e
...
@@ -4,7 +4,8 @@
...
@@ -4,7 +4,8 @@
if
HAVE_EXTENTIONS
if
HAVE_EXTENTIONS
SUBDIRS
=
lib include SharedMemory SharedMemory/tests IOControl LogicProcessor LogicProcessor/tests
\
SUBDIRS
=
lib include SharedMemory SharedMemory/tests IOControl LogicProcessor LogicProcessor/tests
\
ModbusMaster ModbusSlave SMViewer UniNetwork UNetUDP UNetUDP/tests DBServer-MySQL DBServer-SQLite
\
ModbusMaster ModbusSlave SMViewer UniNetwork UNetUDP UNetUDP/tests
\
DBServer-MySQL DBServer-SQLite DBServer-PostgreSQL
\
RRDServer SharedMemoryPlus tests ModbusMaster/tests ModbusSlave/tests
RRDServer SharedMemoryPlus tests ModbusMaster/tests ModbusSlave/tests
#SMDBServer
#SMDBServer
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
2b8c397e
...
@@ -1285,7 +1285,7 @@ ModbusRTU::mbErrCode MBSlave::real_write_it( IOMap::iterator& it, ModbusRTU::Mod
...
@@ -1285,7 +1285,7 @@ ModbusRTU::mbErrCode MBSlave::real_write_it( IOMap::iterator& it, ModbusRTU::Mod
if
(
p
->
bitreg
)
if
(
p
->
bitreg
)
return
real_bitreg_write_it
(
p
->
bitreg
,
dat
[
i
++
]);
return
real_bitreg_write_it
(
p
->
bitreg
,
dat
[
i
++
]);
return
real_write_prop
(
p
,
dat
,
i
,
count
);
return
real_write_prop
(
p
,
dat
,
i
,
count
);
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
ModbusRTU
::
mbErrCode
MBSlave
::
real_bitreg_write_it
(
std
::
shared_ptr
<
BitRegProperty
>&
bp
,
const
ModbusRTU
::
ModbusData
val
)
ModbusRTU
::
mbErrCode
MBSlave
::
real_bitreg_write_it
(
std
::
shared_ptr
<
BitRegProperty
>&
bp
,
const
ModbusRTU
::
ModbusData
val
)
...
@@ -1302,13 +1302,13 @@ ModbusRTU::mbErrCode MBSlave::real_bitreg_write_it( std::shared_ptr<BitRegProper
...
@@ -1302,13 +1302,13 @@ ModbusRTU::mbErrCode MBSlave::real_bitreg_write_it( std::shared_ptr<BitRegProper
if
(
p
->
si
.
id
==
DefaultObjectId
)
if
(
p
->
si
.
id
==
DefaultObjectId
)
continue
;
continue
;
ModbusRTU
::
ModbusData
dat
[]
=
{
d
[
i
]};
ModbusRTU
::
ModbusData
dat
[]
=
{
d
[
i
]};
dinfo
<<
myname
<<
"(real_bitreg_write_it): set "
<<
ModbusRTU
::
dat2str
(
bp
->
mbreg
)
<<
"("
<<
(
int
)
bp
->
mbreg
<<
")"
dinfo
<<
myname
<<
"(real_bitreg_write_it): set "
<<
ModbusRTU
::
dat2str
(
bp
->
mbreg
)
<<
"("
<<
(
int
)
bp
->
mbreg
<<
")"
<<
" bit["
<<
i
<<
"]="
<<
(
int
)
dat
[
0
]
<<
" sid="
<<
p
->
si
.
id
<<
endl
;
<<
" bit["
<<
i
<<
"]="
<<
(
int
)
dat
[
0
]
<<
" sid="
<<
p
->
si
.
id
<<
endl
;
int
k
=
0
;
int
k
=
0
;
real_write_prop
(
p
,
dat
,
k
,
1
);
real_write_prop
(
p
,
dat
,
k
,
1
);
}
}
return
ModbusRTU
::
erNoError
;
return
ModbusRTU
::
erNoError
;
...
@@ -1317,6 +1317,7 @@ ModbusRTU::mbErrCode MBSlave::real_bitreg_write_it( std::shared_ptr<BitRegProper
...
@@ -1317,6 +1317,7 @@ ModbusRTU::mbErrCode MBSlave::real_bitreg_write_it( std::shared_ptr<BitRegProper
ModbusRTU
::
mbErrCode
MBSlave
::
real_write_prop
(
IOProperty
*
p
,
ModbusRTU
::
ModbusData
*
dat
,
int
&
i
,
int
count
)
ModbusRTU
::
mbErrCode
MBSlave
::
real_write_prop
(
IOProperty
*
p
,
ModbusRTU
::
ModbusData
*
dat
,
int
&
i
,
int
count
)
{
{
ModbusRTU
::
ModbusData
mbval
=
dat
[
i
++
];
ModbusRTU
::
ModbusData
mbval
=
dat
[
i
++
];
try
try
{
{
if
(
p
->
amode
==
MBSlave
::
amRO
)
if
(
p
->
amode
==
MBSlave
::
amRO
)
...
...
extensions/ModbusSlave/tests/test_mbslave.cc
View file @
2b8c397e
...
@@ -979,14 +979,14 @@ TEST_CASE("Write(0x06,0x10): nbit", "[modbus][mbslave][mbtcpslave][writenbit]")
...
@@ -979,14 +979,14 @@ TEST_CASE("Write(0x06,0x10): nbit", "[modbus][mbslave][mbtcpslave][writenbit]")
SECTION
(
"Test: write06"
)
SECTION
(
"Test: write06"
)
{
{
ModbusRTU
::
WriteSingleOutputRetMessage
ret
=
mb
->
write06
(
slaveaddr
,
tREG
,
3
);
ModbusRTU
::
WriteSingleOutputRetMessage
ret
=
mb
->
write06
(
slaveaddr
,
tREG
,
3
);
REQUIRE
(
ret
.
start
==
tREG
);
REQUIRE
(
ret
.
start
==
tREG
);
REQUIRE
(
ret
.
data
==
3
);
REQUIRE
(
ret
.
data
==
3
);
REQUIRE
(
ui
->
getValue
(
2020
)
==
1
);
REQUIRE
(
ui
->
getValue
(
2020
)
==
1
);
REQUIRE
(
ui
->
getValue
(
2021
)
==
1
);
REQUIRE
(
ui
->
getValue
(
2021
)
==
1
);
REQUIRE
(
ui
->
getValue
(
2022
)
==
0
);
REQUIRE
(
ui
->
getValue
(
2022
)
==
0
);
ret
=
mb
->
write06
(
slaveaddr
,
tREG
,
0
);
ret
=
mb
->
write06
(
slaveaddr
,
tREG
,
0
);
REQUIRE
(
ret
.
start
==
tREG
);
REQUIRE
(
ret
.
start
==
tREG
);
REQUIRE
(
ret
.
data
==
0
);
REQUIRE
(
ret
.
data
==
0
);
REQUIRE
(
ui
->
getValue
(
2020
)
==
0
);
REQUIRE
(
ui
->
getValue
(
2020
)
==
0
);
...
...
extensions/SharedMemory/SharedMemory.cc
View file @
2b8c397e
...
@@ -243,7 +243,7 @@ bool SharedMemory::activateObject()
...
@@ -243,7 +243,7 @@ bool SharedMemory::activateObject()
res
=
IONotifyController_LT
::
activateObject
();
res
=
IONotifyController_LT
::
activateObject
();
// инициализируем указатели
// инициализируем указатели
for
(
auto
&&
it
:
hlist
)
for
(
auto
&&
it
:
hlist
)
{
{
it
.
a_it
=
myioEnd
();
it
.
a_it
=
myioEnd
();
it
.
d_it
=
myioEnd
();
it
.
d_it
=
myioEnd
();
...
@@ -253,7 +253,7 @@ bool SharedMemory::activateObject()
...
@@ -253,7 +253,7 @@ bool SharedMemory::activateObject()
for
(
auto
&
it
:
hist
)
for
(
auto
&
it
:
hist
)
{
{
for
(
auto
&&
hit
:
it
.
hlst
)
for
(
auto
&&
hit
:
it
.
hlst
)
hit
.
ioit
=
myioEnd
();
hit
.
ioit
=
myioEnd
();
}
}
...
...
extensions/SharedMemory/tests/test_sm.cc
View file @
2b8c397e
...
@@ -37,13 +37,13 @@ TEST_CASE("[SM]: get/set", "[sm][getset]")
...
@@ -37,13 +37,13 @@ TEST_CASE("[SM]: get/set", "[sm][getset]")
{
{
InitTest
();
InitTest
();
ui
->
setValue
(
500
,
30
);
ui
->
setValue
(
500
,
30
);
CHECK
(
ui
->
getValue
(
500
)
==
30
);
CHECK
(
ui
->
getValue
(
500
)
==
30
);
ui
->
setValue
(
500
,
-
30
);
ui
->
setValue
(
500
,
-
30
);
CHECK
(
ui
->
getValue
(
500
)
==
-
30
);
CHECK
(
ui
->
getValue
(
500
)
==
-
30
);
ui
->
setValue
(
500
,
0
);
ui
->
setValue
(
500
,
0
);
CHECK
(
ui
->
getValue
(
500
)
==
0
);
CHECK
(
ui
->
getValue
(
500
)
==
0
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -51,19 +51,20 @@ TEST_CASE("[SM]: threshold", "[sm][threshold]")
...
@@ -51,19 +51,20 @@ TEST_CASE("[SM]: threshold", "[sm][threshold]")
{
{
InitTest
();
InitTest
();
ui
->
setValue
(
503
,
30
);
ui
->
setValue
(
503
,
30
);
CHECK
(
ui
->
getValue
(
504
)
==
0
);
CHECK
(
ui
->
getValue
(
504
)
==
0
);
ui
->
setValue
(
503
,
400
);
ui
->
setValue
(
503
,
400
);
CHECK
(
ui
->
getValue
(
504
)
==
1
);
CHECK
(
ui
->
getValue
(
504
)
==
1
);
ui
->
setValue
(
503
,
25
);
ui
->
setValue
(
503
,
25
);
CHECK
(
ui
->
getValue
(
504
)
==
0
);
CHECK
(
ui
->
getValue
(
504
)
==
0
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
TEST_CASE
(
"[SM]: pulsar"
,
"[sm][pulsar]"
)
TEST_CASE
(
"[SM]: pulsar"
,
"[sm][pulsar]"
)
{
{
InitTest
();
InitTest
();
while
(
ui
->
getValue
(
505
)
)
while
(
ui
->
getValue
(
505
)
)
msleep
(
50
);
msleep
(
50
);
...
@@ -81,13 +82,13 @@ TEST_CASE("[SM]: heartbeat", "[sm][heartbeat]")
...
@@ -81,13 +82,13 @@ TEST_CASE("[SM]: heartbeat", "[sm][heartbeat]")
InitTest
();
InitTest
();
CHECK_FALSE
(
ui
->
getValue
(
507
)
);
CHECK_FALSE
(
ui
->
getValue
(
507
)
);
ui
->
setValue
(
506
,
2
);
ui
->
setValue
(
506
,
2
);
msleep
(
500
);
msleep
(
500
);
CHECK
(
ui
->
getValue
(
507
)
);
CHECK
(
ui
->
getValue
(
507
)
);
msleep
(
2000
);
msleep
(
2000
);
CHECK_FALSE
(
ui
->
getValue
(
507
)
);
CHECK_FALSE
(
ui
->
getValue
(
507
)
);
ui
->
setValue
(
506
,
4
);
ui
->
setValue
(
506
,
4
);
msleep
(
2000
);
msleep
(
2000
);
CHECK
(
ui
->
getValue
(
507
)
);
CHECK
(
ui
->
getValue
(
507
)
);
}
}
...
...
extensions/UniNetwork/Makefile.am
View file @
2b8c397e
...
@@ -12,11 +12,12 @@ libUniSet2Network_la_LIBADD = $(SIGC_LIBS) $(top_builddir)/lib/libUniSet2.la \
...
@@ -12,11 +12,12 @@ libUniSet2Network_la_LIBADD = $(SIGC_LIBS) $(top_builddir)/lib/libUniSet2.la \
libUniSet2Network_la_CPPFLAGS
=
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
\
libUniSet2Network_la_CPPFLAGS
=
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
\
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/SharedMemory
-I
$(top_builddir)
/extensions/SharedMemory
libUniSet2Network_la_SOURCES
=
UniExchange.cc
libUniSet2Network_la_SOURCES
=
UniExchange.cc
@PACKAGE@
_network_LDADD
=
libUniSet2Network.la
\
@PACKAGE@
_network_LDADD
=
libUniSet2Network.la
\
$(top_builddir)
/lib/libUniSet2.la
\
$(top_builddir)
/lib/libUniSet2.la
\
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
\
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
\
$(top_builddir)
/extensions/SharedMemory/libUniSet2SharedMemory.la
\
$(COMCPP_LIBS)
$(COMCPP_LIBS)
@PACKAGE@
_network_CPPFLAGS
=
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
-I
$(top_builddir)
/extensions/include
@PACKAGE@
_network_CPPFLAGS
=
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
-I
$(top_builddir)
/extensions/include
@PACKAGE@
_network_SOURCES
=
uninet.cc
@PACKAGE@
_network_SOURCES
=
uninet.cc
...
...
extensions/include/Calibration.h
View file @
2b8c397e
...
@@ -68,6 +68,9 @@ class Calibration
...
@@ -68,6 +68,9 @@ class Calibration
/*! Тип для хранения значения */
/*! Тип для хранения значения */
typedef
float
TypeOfValue
;
typedef
float
TypeOfValue
;
/*! выход за границы диапазона (TypeOfValue) */
static
const
TypeOfValue
ValueOutOfRange
;
/*! выход за границы диапазона */
/*! выход за границы диапазона */
static
const
long
outOfRange
;
static
const
long
outOfRange
;
...
@@ -75,7 +78,7 @@ class Calibration
...
@@ -75,7 +78,7 @@ class Calibration
Получение калиброванного значения
Получение калиброванного значения
\param raw - сырое значение
\param raw - сырое значение
\param crop_raw - обрезать переданное значение по крайним точкам
\param crop_raw - обрезать переданное значение по крайним точкам
\return Возвращает калиброванное
\return Возвращает калиброванное или outOfRange
*/
*/
long
getValue
(
long
raw
,
bool
crop_raw
=
false
);
long
getValue
(
long
raw
,
bool
crop_raw
=
false
);
...
@@ -199,11 +202,11 @@ class Calibration
...
@@ -199,11 +202,11 @@ class Calibration
bool
checkY
(
const
TypeOfValue
&
y
)
const
;
bool
checkY
(
const
TypeOfValue
&
y
)
const
;
// функции могут вернуть OutOfRange
// функции могут вернуть OutOfRange
TypeOfValue
getY
(
const
TypeOfValue
&
x
)
const
;
/*!< получить значение Y */
TypeOfValue
getY
(
const
TypeOfValue
&
x
)
const
;
/*!< получить значение Y */
TypeOfValue
getX
(
const
TypeOfValue
&
y
)
const
;
/*!< получить значение X */
TypeOfValue
getX
(
const
TypeOfValue
&
y
)
const
;
/*!< получить значение X */
TypeOfValue
calcY
(
const
TypeOfValue
&
x
)
const
;
/*!< расчитать значение для x */
TypeOfValue
calcY
(
const
TypeOfValue
&
x
)
const
;
/*!< расчитать значение для x */
TypeOfValue
calcX
(
const
TypeOfValue
&
y
)
const
;
/*!< расчитать значение для y */
TypeOfValue
calcX
(
const
TypeOfValue
&
y
)
const
;
/*!< расчитать значение для y */
inline
bool
operator
<
(
const
Part
&
p
)
const
inline
bool
operator
<
(
const
Part
&
p
)
const
{
{
...
...
extensions/lib/Calibration.cc
View file @
2b8c397e
...
@@ -10,7 +10,8 @@
...
@@ -10,7 +10,8 @@
using
namespace
std
;
using
namespace
std
;
using
namespace
UniSetTypes
;
using
namespace
UniSetTypes
;
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
const
long
Calibration
::
outOfRange
=
std
::
numeric_limits
<
Calibration
::
TypeOfValue
>::
max
();
const
Calibration
::
TypeOfValue
Calibration
::
ValueOutOfRange
=
std
::
numeric_limits
<
Calibration
::
TypeOfValue
>::
max
();
const
long
Calibration
::
outOfRange
=
std
::
numeric_limits
<
long
>::
max
();
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
Calibration
::
Part
::
Part
()
:
Calibration
::
Part
::
Part
()
:
k
(
0
)
k
(
0
)
...
@@ -63,7 +64,7 @@ bool Calibration::Part::checkY( const TypeOfValue& y ) const
...
@@ -63,7 +64,7 @@ bool Calibration::Part::checkY( const TypeOfValue& y ) const
Calibration
::
TypeOfValue
Calibration
::
Part
::
getY
(
const
TypeOfValue
&
x
)
const
Calibration
::
TypeOfValue
Calibration
::
Part
::
getY
(
const
TypeOfValue
&
x
)
const
{
{
if
(
!
checkX
(
x
)
)
if
(
!
checkX
(
x
)
)
return
Calibration
::
o
utOfRange
;
return
Calibration
::
ValueO
utOfRange
;
if
(
x
==
left_x
()
)
if
(
x
==
left_x
()
)
return
left_y
();
return
left_y
();
...
@@ -77,7 +78,7 @@ Calibration::TypeOfValue Calibration::Part::getY( const TypeOfValue& x ) const
...
@@ -77,7 +78,7 @@ Calibration::TypeOfValue Calibration::Part::getY( const TypeOfValue& x ) const
Calibration
::
TypeOfValue
Calibration
::
Part
::
getX
(
const
TypeOfValue
&
y
)
const
Calibration
::
TypeOfValue
Calibration
::
Part
::
getX
(
const
TypeOfValue
&
y
)
const
{
{
if
(
!
checkY
(
y
)
)
if
(
!
checkY
(
y
)
)
return
Calibration
::
o
utOfRange
;
return
Calibration
::
ValueO
utOfRange
;
if
(
y
==
left_y
()
)
if
(
y
==
left_y
()
)
return
left_x
();
return
left_x
();
...
@@ -307,7 +308,7 @@ long Calibration::getValue( long raw, bool crop_raw )
...
@@ -307,7 +308,7 @@ long Calibration::getValue( long raw, bool crop_raw )
TypeOfValue
q
=
fit
->
getY
(
raw
);
TypeOfValue
q
=
fit
->
getY
(
raw
);
if
(
q
!=
o
utOfRange
)
if
(
q
!=
ValueO
utOfRange
)
{
{
if
(
szCache
)
if
(
szCache
)
insertToCache
(
raw
,
tRound
(
q
)
);
insertToCache
(
raw
,
tRound
(
q
)
);
...
@@ -347,7 +348,7 @@ long Calibration::getRawValue( long cal, bool range )
...
@@ -347,7 +348,7 @@ long Calibration::getRawValue( long cal, bool range )
{
{
TypeOfValue
q
=
it
.
getX
(
cal
);
TypeOfValue
q
=
it
.
getX
(
cal
);
if
(
q
!=
o
utOfRange
)
if
(
q
!=
ValueO
utOfRange
)
return
tRound
(
q
);
return
tRound
(
q
);
}
}
...
...
include/TCPCheck.h
View file @
2b8c397e
...
@@ -35,7 +35,7 @@ class TCPCheck
...
@@ -35,7 +35,7 @@ class TCPCheck
* \note Вызывается через system()! Это может быть опасно с точки зрения безопасности..
* \note Вызывается через system()! Это может быть опасно с точки зрения безопасности..
* \todo Возможно стоит написать свою реализацию ping
* \todo Возможно стоит написать свою реализацию ping
*/
*/
bool
ping
(
const
std
::
string
&
_ip
,
timeout_t
tout
=
1000
,
timeout_t
sleep_msec
=
200
,
const
std
::
string
&
ping_argc
=
"-c 1 -w 0.1 -q -n"
);
bool
ping
(
const
std
::
string
&
_ip
,
timeout_t
tout
=
1000
,
timeout_t
sleep_msec
=
200
,
const
std
::
string
&
ping_argc
=
"-c 1 -w 0.1 -q -n"
);
protected
:
protected
:
...
@@ -52,7 +52,7 @@ class TCPCheck
...
@@ -52,7 +52,7 @@ class TCPCheck
int
port
=
{
0
};
int
port
=
{
0
};
int
tout_msec
;
int
tout_msec
;
std
::
string
ping_args
=
{
"-c 1 -w 0.1 -q -n"
};
std
::
string
ping_args
=
{
"-c 1 -w 0.1 -q -n"
};
};
};
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#endif // _TCPCheck_H_
#endif // _TCPCheck_H_
...
...
src/Communications/TCP/TCPCheck.cc
View file @
2b8c397e
...
@@ -54,6 +54,7 @@ bool TCPCheck::check( const std::string& _ip, int _port, timeout_t tout, timeout
...
@@ -54,6 +54,7 @@ bool TCPCheck::check( const std::string& _ip, int _port, timeout_t tout, timeout
void
TCPCheck
::
check_thread
()
void
TCPCheck
::
check_thread
()
{
{
setResult
(
false
);
setResult
(
false
);
try
try
{
{
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
...
@@ -98,6 +99,6 @@ void TCPCheck::ping_thread()
...
@@ -98,6 +99,6 @@ void TCPCheck::ping_thread()
int
ret
=
system
(
cmd
.
str
().
c_str
());
int
ret
=
system
(
cmd
.
str
().
c_str
());
int
res
=
WEXITSTATUS
(
ret
);
int
res
=
WEXITSTATUS
(
ret
);
setResult
((
res
==
0
));
setResult
((
res
==
0
));
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
src/Log/LogSession.cc
View file @
2b8c397e
...
@@ -16,13 +16,11 @@ using namespace UniSetTypes;
...
@@ -16,13 +16,11 @@ using namespace UniSetTypes;
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
LogSession
::~
LogSession
()
LogSession
::~
LogSession
()
{
{
cancelled
=
true
;
if
(
isRunning
()
)
if
(
isRunning
()
)
{
{
cancelled
=
true
;
ost
::
Thread
::
join
();
disconnect
();
disconnect
();
// if( isRunning() )
// ost::Thread::join();
}
}
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
@@ -277,8 +275,6 @@ void LogSession::final()
...
@@ -277,8 +275,6 @@ void LogSession::final()
{
{
}
}
delete
this
;
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void
LogSession
::
connectFinalSession
(
FinalSlot
sl
)
void
LogSession
::
connectFinalSession
(
FinalSlot
sl
)
...
...
tests/test_tcpcheck.cc
View file @
2b8c397e
...
@@ -33,7 +33,7 @@ class TSRunner
...
@@ -33,7 +33,7 @@ class TSRunner
TSRunner
()
TSRunner
()
{
{
cancel
=
false
;
cancel
=
false
;
res
=
std
::
async
(
std
::
launch
::
async
,
run_test_server
);
res
=
std
::
async
(
std
::
launch
::
async
,
run_test_server
);
}
}
~
TSRunner
()
~
TSRunner
()
...
...
uniset2.files
View file @
2b8c397e
...
@@ -19,6 +19,14 @@ extensions/DBServer-SQLite/SQLiteInterface.cc
...
@@ -19,6 +19,14 @@ extensions/DBServer-SQLite/SQLiteInterface.cc
extensions/DBServer-SQLite/SQLiteInterface.h
extensions/DBServer-SQLite/SQLiteInterface.h
extensions/DBServer-SQLite/test.cc
extensions/DBServer-SQLite/test.cc
extensions/DBServer-SQLite/test.xml
extensions/DBServer-SQLite/test.xml
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.h
extensions/DBServer-PostgreSQL/libUniSet2PostgreSQL.pc.in
extensions/DBServer-PostgreSQL/main.cc
extensions/DBServer-PostgreSQL/Makefile.am
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
extensions/DBServer-PostgreSQL/test.cc
extensions/include/Calibration.h
extensions/include/Calibration.h
extensions/include/ComediInterface.h
extensions/include/ComediInterface.h
extensions/include/DigitalFilter.h
extensions/include/DigitalFilter.h
...
...
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