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
7bda9575
Commit
7bda9575
authored
May 09, 2018
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Plain Diff
backported to p8 as 2.7-alt6.M80P.7 (with rpmbph script)
parents
d473d6ec
5b8d5825
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
195 additions
and
59 deletions
+195
-59
mbslave.cc
Utilities/MBTester/mbslave.cc
+6
-0
libuniset2.spec
conf/libuniset2.spec
+18
-13
release_helper.sh
conf/release_helper.sh
+4
-3
release_helper_arm.sh
conf/release_helper_arm.sh
+3
-0
configure.ac
configure.ac
+26
-1
ComediInterface.cc
extensions/IOControl/ComediInterface.cc
+2
-2
ComediInterface.h
extensions/IOControl/ComediInterface.h
+1
-1
IOControl.cc
extensions/IOControl/IOControl.cc
+6
-3
IOControl.h
extensions/IOControl/IOControl.h
+2
-0
iocalibr.cc
extensions/IOControl/iocalibr.cc
+7
-1
iotest.cc
extensions/IOControl/iotest.cc
+7
-1
FakeIOControl.cc
extensions/IOControl/tests/FakeIOControl.cc
+1
-1
FakeIOControl.h
extensions/IOControl/tests/FakeIOControl.h
+1
-1
LogDB.cc
extensions/LogDB/LogDB.cc
+33
-11
LogDB.h
extensions/LogDB/LogDB.h
+2
-0
MBExchange.h
extensions/ModbusMaster/MBExchange.h
+1
-0
ComPort485F.h
include/ComPort485F.h
+2
-0
Pulse.h
include/Pulse.h
+5
-0
UHttpRequestHandler.h
include/UHttpRequestHandler.h
+5
-1
UHttpServer.h
include/UHttpServer.h
+2
-0
UniSetActivator.h
include/UniSetActivator.h
+2
-0
libUniSet2.include
libUniSet2.include
+11
-11
ComPort485F.cc
src/Communications/ComPort485F.cc
+2
-0
UHttpRequestHandler.cc
src/Communications/Http/UHttpRequestHandler.cc
+16
-4
UHttpServer.cc
src/Communications/Http/UHttpServer.cc
+5
-0
ModbusRTUMaster.cc
src/Communications/Modbus/ModbusRTUMaster.cc
+4
-0
ModbusRTUSlave.cc
src/Communications/Modbus/ModbusRTUSlave.cc
+4
-0
ModbusTCPSession.cc
src/Communications/Modbus/ModbusTCPSession.cc
+3
-2
UniSetActivator.cc
src/Core/UniSetActivator.cc
+2
-0
UniSetTypes.cc
src/Core/UniSetTypes.cc
+2
-1
LogSession.cc
src/Log/LogSession.cc
+10
-2
No files found.
Utilities/MBTester/mbslave.cc
View file @
7bda9575
...
...
@@ -110,6 +110,8 @@ int main( int argc, char** argv )
if
(
f485
)
{
#ifndef DISABLE_COMPORT_485F
ComPort485F
*
cp
;
if
(
dev
==
"/dev/ttyS2"
)
...
...
@@ -126,6 +128,10 @@ int main( int argc, char** argv )
mbs
.
setLog
(
dlog
);
mbs
.
setVerbose
(
verb
);
mbs
.
execute
();
#else
cerr
<<
"DISABLE_COMPORT_485F"
<<
endl
;
return
1
;
#endif // #ifndef DISABLE_COMPORT_485F
}
else
{
...
...
conf/libuniset2.spec
View file @
7bda9575
...
...
@@ -14,12 +14,13 @@
%def_disable netdata
%def_enable api
%def_enable logdb
%def_enable com485f
%define oname uniset2
Name: libuniset2
Version: 2.7
Release: alt
3.M80P.4
Release: alt
6.M80P.7
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
...
...
@@ -313,22 +314,12 @@ Requires: %name-extension-common-devel = %version-%release
Libraries needed to develop for uniset MQTT extension
%endif
%package extension-smplus
Group: Development/C++
Summary: libUniSet2 SharedMemoryPlus extension ('all in one')
Requires: %name-extension-common = %version-%release
%description extension-smplus
SharedMemoryPlus extension ('all in one') for libuniset
%prep
%setup
%build
%autoreconf
%configure %{subst_enable docs} %{subst_enable mysql} %{subst_enable sqlite} %{subst_enable pgsql} %{subst_enable python} %{subst_enable rrd} %{subst_enable io} %{subst_enable logicproc} %{subst_enable tests} %{subst_enable mqtt} %{subst_enable api} %{subst_enable netdata} %{subst_enable logdb}
%configure %{subst_enable docs} %{subst_enable mysql} %{subst_enable sqlite} %{subst_enable pgsql} %{subst_enable python} %{subst_enable rrd} %{subst_enable io} %{subst_enable logicproc} %{subst_enable tests} %{subst_enable mqtt} %{subst_enable api} %{subst_enable netdata} %{subst_enable logdb}
%{subst_enable com485f}
%make_build
# fix for ALTLinux build (noarch)
...
...
@@ -520,9 +511,23 @@ rm -f %buildroot%_libdir/*.la
# history of current unpublished changes
%changelog
*
Fri Feb 23 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt3.M80P.4
*
Wed May 09 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt6.M80P.7
- backport to ALTLinux p8 (by rpmbph script)
* Tue May 08 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt7
- (http): added support "CORS" (Access-Control-Allow-Origin)
- (logdb): added --logdb-httpserver-reply-addr host:port
- minor fixes in LogSession
* Tue Apr 03 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt6
- new minor release
# * Wed Mar 28 2018 Vinogradov Aleksei <uzum@server> 2.7-alt5
# - test build after rebase pv/master
* Fri Mar 09 2018 Alexei Takaseev <taf@altlinux.org> 2.7-alt4.1
- Rebuild with poco 1.9.0
* Wed Feb 21 2018 Pavel Vainerman <pv@altlinux.ru> 2.7-alt4
- (omniThread): fix compile error for 'const' function and other minor fixes
...
...
conf/release_helper.sh
View file @
7bda9575
...
...
@@ -7,6 +7,7 @@ load_mod spec
REL
=
eter
MAILDOMAIN
=
server
OPTS
=
$*
[
-z
"
$TOPDIR
"
]
&&
TOPDIR
=
/var/ftp/pub/Ourside
...
...
@@ -16,10 +17,10 @@ SPECNAME=libuniset2.spec
if
[
-z
"
$PLATFORM
"
]
;
then
PLATFORM
=
i586
[[
`
uname
-m
`
==
"x86_64"
]]
&&
PLATFORM
=
x86_64
[[
`
uname
-m
`
==
"aarch64"
]]
&&
PLATFORM
=
aarch64
fi
PROJECT
=
$1
test
-n
"
$PROJECT
"
||
PROJECT
=
$PKGNAME
PROJECT
=
$PKGNAME
[
-z
"
$GEN
"
]
&&
GEN
=
/var/ftp/pub/Ourside/
$PLATFORM
/genb.sh
[
-a
"
$GEN
"
]
||
GEN
=
"genbasedir --create --progress --topdir=
$TOPDIR
$PLATFORM
$PROJECT
"
...
...
@@ -89,7 +90,7 @@ else
add_changelog_helper
"- new build"
$SPECNAME
fi
rpmbb
${
UNISET_BUILD_ADDON_OPTIONS
}
$SPECNAME
||
fatal
"Can't build"
rpmbb
${
UNISET_BUILD_ADDON_OPTIONS
}
$
{
OPTS
}
$
SPECNAME
||
fatal
"Can't build"
cp2ftp
...
...
conf/release_helper_arm.sh
0 → 100755
View file @
7bda9575
#!/bin/sh
./release_helper.sh
--disable
=
com485f
--disable
=
mqtt
--disable
=
docs
configure.ac
View file @
7bda9575
...
...
@@ -199,6 +199,31 @@ fi
AM_CONDITIONAL(DISABLE_IO, test ${buildio} = false)
AM_CONDITIONAL(ENABLE_IO, test ${buildio} = true)
#check sys/io.h support
AC_MSG_CHECKING([sys/io.h support])
buildcom485f=true
#AC_CHECK_HEADERS
AC_ARG_ENABLE(com485f, AC_HELP_STRING([--disable-com485f], [disable sys/io.h support]),
[ if test $enableval = yes; then buildcom485f=true; else buildcom485f=false; fi],[ buildcom485f=true; ])
COMPORT_485F_CFLAGS=
COMPORT_485F_CLIBS=
DISABLE_COMPORT_485F=
if test ${buildcom485f} = true; then
AC_MSG_RESULT([enabled])
else
AC_MSG_RESULT([disabled])
COMPORT_485F_CFLAGS="-DDISABLE_COMPORT_485F"
DISABLE_COMPORT_485F=1
fi
AM_CONDITIONAL(DISABLE_COMPORT_485F, test ${buildcom485f} = false)
AC_SUBST(DISABLE_COMPORT_485F)
AC_SUBST(COMPORT_485F_CFLAGS)
#AC_SUBST(COMPORT_485F_CLIBS)
#check logicproc build
AC_MSG_CHECKING([build logic processor extension])
buildlproc=true
...
...
@@ -415,7 +440,7 @@ CXX_EXTRA_FLAGS="-Wnon-virtual-dtor -Woverloaded-virtual -Woverflow -D_GLIBCXX_U
# export
LDFLAGS="$LDFLAGS ${OMNI_LIBS} ${XML_LIBS} ${SIGC_LIBS} ${COV_LIBS} ${POCO_LIBS} ${EV_LIBS}"
# all developer liked options add to autogen.sh, please
CXXFLAGS="-I\$(top_builddir)/include $CXXFLAGS -funsigned-char -std=c++11 -g -DCATCH_VERSION_MAJOR=${CATCH_VERSION_MAJOR} -D_GNU_SOURCE ${REST_API_CFLAGS} ${OMNI_CFLAGS} ${XML_CFLAGS} ${SIGC_CFLAGS} ${COV_CFLAGS} ${POCO_CFLAGS} ${EV_CFLAGS} $CXX_EXTRA_FLAGS"
CXXFLAGS="-I\$(top_builddir)/include $CXXFLAGS -funsigned-char -std=c++11 -g -DCATCH_VERSION_MAJOR=${CATCH_VERSION_MAJOR} -D_GNU_SOURCE ${REST_API_CFLAGS} ${
COMPORT_485F_CFLAGS} ${
OMNI_CFLAGS} ${XML_CFLAGS} ${SIGC_CFLAGS} ${COV_CFLAGS} ${POCO_CFLAGS} ${EV_CFLAGS} $CXX_EXTRA_FLAGS"
AC_SUBST(LDFLAGS)
AC_SUBST(CXXFLAGS)
...
...
extensions/IOControl/ComediInterface.cc
View file @
7bda9575
...
...
@@ -42,10 +42,10 @@ ComediInterface::~ComediInterface()
}
// -----------------------------------------------------------------------------
int
ComediInterface
::
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
,
int
aref
)
const
int
ComediInterface
::
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
,
int
aref
,
int
adelay
)
const
{
lsampl_t
data
=
0
;
int
ret
=
comedi_data_read
(
card
,
subdev
,
channel
,
range
,
aref
,
&
data
);
int
ret
=
comedi_data_read
_delayed
(
card
,
subdev
,
channel
,
range
,
aref
,
&
data
,
adelay
);
if
(
ret
<
0
)
{
...
...
extensions/IOControl/ComediInterface.h
View file @
7bda9575
...
...
@@ -32,7 +32,7 @@ namespace uniset
virtual
~
ComediInterface
();
// throw uniset::Exception
virtual
int
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
=
0
,
int
aref
=
AREF_GROUND
)
const
;
virtual
int
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
=
0
,
int
aref
=
AREF_GROUND
,
int
adelay
=
10
*
1000
)
const
;
// adelay = 10 мкс
// throw uniset::Exception
virtual
void
setAnalogChannel
(
int
subdev
,
int
channel
,
int
data
,
int
range
=
0
,
int
aref
=
AREF_GROUND
)
const
;
...
...
extensions/IOControl/IOControl.cc
View file @
7bda9575
...
...
@@ -37,7 +37,7 @@ namespace uniset
{
os
<<
"("
<<
inf
.
si
.
id
<<
")"
<<
uniset_conf
()
->
oind
->
getMapName
(
inf
.
si
.
id
)
<<
" card="
<<
inf
.
ncard
<<
" channel="
<<
inf
.
channel
<<
" subdev="
<<
inf
.
subdev
<<
" aref="
<<
inf
.
aref
<<
" range="
<<
inf
.
range
<<
" aref="
<<
inf
.
aref
<<
" range="
<<
inf
.
range
<<
" adelay="
<<
inf
.
adelay
<<
" default="
<<
inf
.
defval
<<
" safeval="
<<
inf
.
safeval
;
if
(
inf
.
cal
.
minRaw
!=
inf
.
cal
.
maxRaw
)
...
...
@@ -599,7 +599,7 @@ namespace uniset
{
if
(
it
->
stype
==
UniversalIO
::
AI
)
{
int
val
=
card
->
getAnalogChannel
(
it
->
subdev
,
it
->
channel
,
it
->
range
,
it
->
aref
);
int
val
=
card
->
getAnalogChannel
(
it
->
subdev
,
it
->
channel
,
it
->
range
,
it
->
aref
,
it
->
adelay
);
iolog3
<<
myname
<<
"(iopoll): read AI "
<<
" sid="
<<
it
->
si
.
id
...
...
@@ -869,6 +869,7 @@ namespace uniset
inf
->
disable_testmode
=
IOBase
::
initIntProp
(
it
,
"disable_testmode"
,
prop_prefix
,
false
);
inf
->
aref
=
0
;
inf
->
range
=
0
;
inf
->
adelay
=
10000
;
if
(
inf
->
stype
==
UniversalIO
::
AI
||
inf
->
stype
==
UniversalIO
::
AO
)
{
...
...
@@ -891,6 +892,8 @@ namespace uniset
<<
". Must be aref=[0..3]"
<<
endl
;
return
false
;
}
inf
->
adelay
=
IOBase
::
initIntProp
(
it
,
"adelay"
,
prop_prefix
,
false
);
}
iolog3
<<
myname
<<
"(readItem): add: "
<<
inf
->
stype
<<
" "
<<
inf
<<
endl
;
...
...
@@ -1019,7 +1022,7 @@ namespace uniset
else
if
(
it
->
stype
==
UniversalIO
::
AI
)
{
card
->
configureChannel
(
it
->
subdev
,
it
->
channel
,
ComediInterface
::
AI
);
it
->
df
.
init
(
card
->
getAnalogChannel
(
it
->
subdev
,
it
->
channel
,
it
->
range
,
it
->
aref
)
);
it
->
df
.
init
(
card
->
getAnalogChannel
(
it
->
subdev
,
it
->
channel
,
it
->
range
,
it
->
aref
,
it
->
adelay
)
);
}
else
if
(
it
->
stype
==
UniversalIO
::
AO
)
card
->
configureChannel
(
it
->
subdev
,
it
->
channel
,
ComediInterface
::
AO
);
...
...
extensions/IOControl/IOControl.h
View file @
7bda9575
...
...
@@ -276,6 +276,8 @@ namespace uniset
3 - analog ref = other (undefined)
*/
int
aref
;
int
adelay
;
/*! Задержка на чтение аналоговых входов с мультиплексированием ( в мкс ) */
/*! Измерительный диапазон
0 - -10В - 10В
...
...
extensions/IOControl/iocalibr.cc
View file @
7bda9575
...
...
@@ -72,6 +72,7 @@ int subdev = 0;
int
chan
=
0
;
int
range
=
0
;
int
aref
=
AREF_GROUND
;
int
adelay
=
10
*
1000
;
// 10 мкс
static
struct
option
longopts
[]
=
{
...
...
@@ -79,6 +80,7 @@ static struct option longopts[] =
{
"read"
,
required_argument
,
0
,
'r'
},
{
"subdev"
,
required_argument
,
0
,
's'
},
{
"aref"
,
required_argument
,
0
,
'a'
},
{
"adelay"
,
required_argument
,
0
,
'y'
},
{
"range"
,
required_argument
,
0
,
'x'
},
{
"device"
,
required_argument
,
0
,
'd'
},
{
"open_xml"
,
required_argument
,
0
,
'o'
},
...
...
@@ -143,6 +145,10 @@ int main(int argc, char* argv[])
range
=
uni_atoi
(
optarg
);
break
;
case
'y'
:
adelay
=
atoi
(
optarg
);
break
;
case
'a'
:
aref
=
uni_atoi
(
optarg
);
break
;
...
...
@@ -202,7 +208,7 @@ int main(int argc, char* argv[])
while
(
1
)
{
if
(
comedi_data_read
(
card
,
subdev
,
chan
,
range
,
aref
,
&
data
)
<
0
)
if
(
comedi_data_read
_delayed
(
card
,
subdev
,
chan
,
range
,
aref
,
&
data
,
adelay
)
<
0
)
{
fprintf
(
stderr
,
"can't read from channel %d
\n
"
,
chan
);
exit
(
EXIT_FAILURE
);
...
...
extensions/IOControl/iotest.cc
View file @
7bda9575
...
...
@@ -28,6 +28,7 @@
int
subdev
=
0
;
int
range
=
0
;
int
aref
=
AREF_GROUND
;
int
adelay
=
10
*
1000
;
// 10 мкс
int
chan
[
50
];
int
blink_msec
=
300
;
...
...
@@ -42,6 +43,7 @@ static struct option longopts[] =
{
"device"
,
required_argument
,
0
,
'd'
},
{
"verbose"
,
no_argument
,
0
,
'v'
},
{
"aref"
,
required_argument
,
0
,
'z'
},
{
"adelay"
,
required_argument
,
0
,
'y'
},
{
"range"
,
required_argument
,
0
,
'x'
},
{
"config"
,
required_argument
,
0
,
'c'
},
{
"autoconf"
,
no_argument
,
0
,
'a'
},
...
...
@@ -174,6 +176,10 @@ int main(int argc, char* argv[])
range
=
atoi
(
optarg
);
break
;
case
'y'
:
adelay
=
atoi
(
optarg
);
break
;
case
'z'
:
aref
=
atoi
(
optarg
);
break
;
...
...
@@ -312,7 +318,7 @@ int main(int argc, char* argv[])
if
(
autoconf
)
insn_config
(
card
,
subdev
,
chan
[
k
],
100
,
range
,
aref
);
int
ret
=
comedi_data_read
(
card
,
subdev
,
chan
[
k
],
range
,
aref
,
&
data
);
int
ret
=
comedi_data_read
_delayed
(
card
,
subdev
,
chan
[
k
],
range
,
aref
,
&
data
,
adelay
);
if
(
ret
<
0
)
{
...
...
extensions/IOControl/tests/FakeIOControl.cc
View file @
7bda9575
...
...
@@ -96,7 +96,7 @@ namespace uniset
}
// -----------------------------------------------------------------------------
int
FakeComediInterface
::
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
,
int
aref
)
const
int
FakeComediInterface
::
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
,
int
aref
,
int
adelay
)
const
{
if
(
channel
<
0
||
channel
>
maxChannelNum
)
{
...
...
extensions/IOControl/tests/FakeIOControl.h
View file @
7bda9575
...
...
@@ -46,7 +46,7 @@ namespace uniset
// --------------------------------------------
// при тестировании параметры range,aref,subdev игнорируются!
virtual
int
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
=
0
,
int
aref
=
AREF_GROUND
)
const
override
;
virtual
int
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
=
0
,
int
aref
=
AREF_GROUND
,
int
adelay
=
10
*
1000
)
const
override
;
virtual
void
setAnalogChannel
(
int
subdev
,
int
channel
,
int
data
,
int
range
=
0
,
int
aref
=
AREF_GROUND
)
const
override
;
...
...
extensions/LogDB/LogDB.cc
View file @
7bda9575
...
...
@@ -57,7 +57,6 @@ LogDB::LogDB( const string& name, int argc, const char* const* argv, const strin
auto
conf
=
uniset_conf
();
xml
=
conf
->
getConfXML
();
conf
->
initLogStream
(
dblog
,
prefix
+
"log"
);
}
else
{
...
...
@@ -86,6 +85,17 @@ LogDB::LogDB( const string& name, int argc, const char* const* argv, const strin
UniXML
::
iterator
it
(
cnode
);
if
(
specconfig
.
empty
()
)
uniset_conf
()
->
initLogStream
(
dblog
,
prefix
+
"log"
);
else
{
// инициализируем сами, т.к. conf нету..
const
std
::
string
loglevels
=
uniset
::
getArg2Param
(
"--"
+
prefix
+
"log-add-levels"
,
argc
,
argv
,
it
.
getProp
(
"log"
),
""
);
if
(
!
loglevels
.
empty
()
)
dblog
->
level
(
Debug
::
value
(
loglevels
));
}
qbufSize
=
uniset
::
getArgPInt
(
"--"
+
prefix
+
"db-buffer-size"
,
argc
,
argv
,
it
.
getProp
(
"dbBufferSize"
),
qbufSize
);
maxdbRecords
=
uniset
::
getArgPInt
(
"--"
+
prefix
+
"db-max-records"
,
argc
,
argv
,
it
.
getProp
(
"dbMaxRecords"
),
qbufSize
);
maxwsocks
=
uniset
::
getArgPInt
(
"--"
+
prefix
+
"ws-max"
,
argc
,
argv
,
it
.
getProp
(
"wsMax"
),
maxwsocks
);
...
...
@@ -220,6 +230,9 @@ LogDB::LogDB( const string& name, int argc, const char* const* argv, const strin
httpHost
=
uniset
::
getArgParam
(
"--"
+
prefix
+
"httpserver-host"
,
argc
,
argv
,
"localhost"
);
httpPort
=
uniset
::
getArgInt
(
"--"
+
prefix
+
"httpserver-port"
,
argc
,
argv
,
"8080"
);
httpCORS_allow
=
uniset
::
getArgParam
(
"--"
+
prefix
+
"httpserver-cors-allow"
,
argc
,
argv
,
httpCORS_allow
);
httpReplyAddr
=
uniset
::
getArgParam
(
"--"
+
prefix
+
"httpserver-reply-addr"
,
argc
,
argv
,
""
);
dblog1
<<
myname
<<
"(init): http server parameters "
<<
httpHost
<<
":"
<<
httpPort
<<
endl
;
Poco
::
Net
::
SocketAddress
sa
(
httpHost
,
httpPort
);
...
...
@@ -445,10 +458,12 @@ void LogDB::help_print()
cout
<<
"--prefix-ls-read-buffer-size num - Размер буфера для чтения сообщений от логсервера. По умолчанию: 10001"
<<
endl
;
cout
<<
"http: "
<<
endl
;
cout
<<
"--prefix-httpserver-host ip - IP на котором слушает http сервер. По умолчанию: localhost"
<<
endl
;
cout
<<
"--prefix-httpserver-port num - Порт на котором принимать запросы. По умолчанию: 8080"
<<
endl
;
cout
<<
"--prefix-httpserver-max-queued num - Размер очереди запросов к http серверу. По умолчанию: 100"
<<
endl
;
cout
<<
"--prefix-httpserver-max-threads num - Разрешённое количество потоков для http-сервера. По умолчанию: 3"
<<
endl
;
cout
<<
"--prefix-httpserver-host ip - IP на котором слушает http сервер. По умолчанию: localhost"
<<
endl
;
cout
<<
"--prefix-httpserver-port num - Порт на котором принимать запросы. По умолчанию: 8080"
<<
endl
;
cout
<<
"--prefix-httpserver-max-queued num - Размер очереди запросов к http серверу. По умолчанию: 100"
<<
endl
;
cout
<<
"--prefix-httpserver-max-threads num - Разрешённое количество потоков для http-сервера. По умолчанию: 3"
<<
endl
;
cout
<<
"--prefix-httpserver-cors-allow addr - (CORS): Access-Control-Allow-Origin. Default: *"
<<
endl
;
cout
<<
"--prefix-httpserver-reply-addr host[:port] - Адрес отдаваемый клиенту для подключения. По умолчанию адрес узла где запущен logdb"
<<
endl
;
}
// -----------------------------------------------------------------------------
void
LogDB
::
run
(
bool
async
)
...
...
@@ -708,9 +723,10 @@ void LogDB::Log::write( ev::io& io )
if
(
ret
<
0
)
{
dbwarn
<<
peername
<<
"(write): write to socket error("
<<
errno
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
int
errnum
=
errno
;
dbwarn
<<
peername
<<
"(write): write to socket error("
<<
errnum
<<
"): "
<<
strerror
(
errnum
)
<<
endl
;
if
(
errn
o
==
EPIPE
||
errno
==
EBADF
)
if
(
errn
um
==
EPIPE
||
errnum
==
EBADF
)
{
dbwarn
<<
peername
<<
"(write): write error.. terminate session.."
<<
endl
;
io
.
set
(
EV_NONE
);
...
...
@@ -791,6 +807,9 @@ void LogDB::handleRequest( Poco::Net::HTTPServerRequest& req, Poco::Net::HTTPSer
std
::
ostream
&
out
=
resp
.
send
();
resp
.
setContentType
(
"text/json"
);
resp
.
set
(
"Access-Control-Allow-Methods"
,
"GET"
);
resp
.
set
(
"Access-Control-Allow-Request-Method"
,
"*"
);
resp
.
set
(
"Access-Control-Allow-Origin"
,
httpCORS_allow
/* req.get("Origin") */
);
try
{
...
...
@@ -811,6 +830,7 @@ void LogDB::handleRequest( Poco::Net::HTTPServerRequest& req, Poco::Net::HTTPSer
uri
.
getPathSegments
(
seg
);
// проверка подключения к страничке со списком websocket-ов
// http://[xxxx:port]/logdb/ws/
if
(
seg
.
size
()
>
1
&&
seg
[
0
]
==
"logdb"
&&
seg
[
1
]
==
"ws"
)
{
// подключение..
...
...
@@ -1393,10 +1413,12 @@ void LogDB::LogWebSocket::write()
if
(
ret
<
0
)
{
int
errnum
=
errno
;
dblog3
<<
"(websocket): "
<<
req
->
clientAddress
().
toString
()
<<
" write to socket error("
<<
errn
o
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
<<
" write to socket error("
<<
errn
um
<<
"): "
<<
strerror
(
errnum
)
<<
endl
;
if
(
errn
o
==
EPIPE
||
errno
==
EBADF
)
if
(
errn
um
==
EPIPE
||
errnum
==
EBADF
)
{
dblog3
<<
"(websocket): "
<<
req
->
clientAddress
().
toString
()
...
...
@@ -1520,7 +1542,7 @@ void LogDB::httpWebSocketPage( std::ostream& ostr, Poco::Net::HTTPServerRequest&
for
(
const
auto
&
l
:
logservers
)
{
ostr
<<
" <li><a target='_blank' href=
\"
http://"
<<
req
.
serverAddress
().
toString
(
)
<<
(
httpReplyAddr
.
empty
()
?
req
.
serverAddress
().
toString
()
:
httpReplyAddr
)
<<
"/logdb/ws/"
<<
l
->
name
<<
"
\"
>"
<<
l
->
name
<<
"</a> – "
<<
"<i>"
<<
l
->
description
<<
"</i></li>"
...
...
@@ -1569,7 +1591,7 @@ void LogDB::httpWebSocketConnectPage( ostream& ostr,
ostr
<<
" if (
\"
WebSocket
\"
in window)"
<<
endl
;
ostr
<<
" {"
<<
endl
;
ostr
<<
" // LogScrollTimer = setInterval(LogAutoScroll,800);"
<<
endl
;
ostr
<<
" var ws = new WebSocket(
\"
ws://"
<<
req
.
serverAddress
().
toString
(
)
<<
"/logdb/ws/
\"
+ logname);"
<<
endl
;
ostr
<<
" var ws = new WebSocket(
\"
ws://"
<<
(
httpReplyAddr
.
empty
()
?
req
.
serverAddress
().
toString
()
:
httpReplyAddr
)
<<
"/logdb/ws/
\"
+ logname);"
<<
endl
;
ostr
<<
" var l = document.getElementById('logname');"
<<
endl
;
ostr
<<
" l.innerHTML = logname"
<<
endl
;
ostr
<<
" ws.onmessage = function(evt)"
<<
endl
;
...
...
extensions/LogDB/LogDB.h
View file @
7bda9575
...
...
@@ -315,6 +315,8 @@ namespace uniset
std
::
shared_ptr
<
Poco
::
Net
::
HTTPServer
>
httpserv
;
std
::
string
httpHost
=
{
""
};
int
httpPort
=
{
0
};
std
::
string
httpCORS_allow
=
{
"*"
};
std
::
string
httpReplyAddr
=
{
""
};
double
wsHeartbeatTime_sec
=
{
3
.
0
};
double
wsSendTime_sec
=
{
0
.
5
};
...
...
extensions/ModbusMaster/MBExchange.h
View file @
7bda9575
...
...
@@ -39,6 +39,7 @@
#include "modbus/ModbusClient.h"
#include "LogAgregator.h"
#include "LogServer.h"
#include "LogAgregator.h"
#include "VMonitor.h"
// -----------------------------------------------------------------------------
#ifndef vmonit
...
...
include/ComPort485F.h
View file @
7bda9575
#ifndef DISABLE_COMPORT_485F
/*
* Copyright (c) 2015 Pavel Vainerman.
*
...
...
@@ -71,3 +72,4 @@ namespace uniset
// --------------------------------------------------------------------------
#endif // COMPORT_485F_H_
// --------------------------------------------------------------------------
#endif // #ifndef DISABLE_COMPORT_485F
include/Pulse.h
View file @
7bda9575
...
...
@@ -85,6 +85,11 @@ namespace uniset
return
step
();
// ostate;
}
inline
bool
out
()
const
noexcept
{
return
ostate
;
}
inline
void
set
(
bool
state
)
noexcept
{
enabled
=
state
;
...
...
include/UHttpRequestHandler.h
View file @
7bda9575
...
...
@@ -113,7 +113,7 @@ namespace uniset
public
Poco
::
Net
::
HTTPRequestHandler
{
public
:
UHttpRequestHandler
(
std
::
shared_ptr
<
IHttpRequestRegistry
>
_registry
);
UHttpRequestHandler
(
std
::
shared_ptr
<
IHttpRequestRegistry
>
_registry
,
const
std
::
string
&
httpCORS_allow
=
"*"
);
virtual
void
handleRequest
(
Poco
::
Net
::
HTTPServerRequest
&
req
,
Poco
::
Net
::
HTTPServerResponse
&
resp
)
override
;
...
...
@@ -121,6 +121,7 @@ namespace uniset
std
::
shared_ptr
<
IHttpRequestRegistry
>
registry
;
std
::
shared_ptr
<
DebugStream
>
log
;
const
std
::
string
httpCORS_allow
=
{
"*"
};
};
// -------------------------------------------------------------------------
class
UHttpRequestHandlerFactory
:
...
...
@@ -132,8 +133,11 @@ namespace uniset
virtual
Poco
::
Net
::
HTTPRequestHandler
*
createRequestHandler
(
const
Poco
::
Net
::
HTTPServerRequest
&
)
override
;
// (CORS): Access-Control-Allow-Origin. Default: *
void
setCORS_allow
(
const
std
::
string
&
allow
);
private
:
std
::
shared_ptr
<
IHttpRequestRegistry
>
registry
;
std
::
string
httpCORS_allow
=
{
"*"
};
};
}
// -------------------------------------------------------------------------
...
...
include/UHttpServer.h
View file @
7bda9575
...
...
@@ -45,6 +45,8 @@ namespace uniset
std
::
shared_ptr
<
DebugStream
>
log
();
// (CORS): Access-Control-Allow-Origin. Default: *
void
setCORS_allow
(
const
std
::
string
&
CORS_allow
);
protected
:
UHttpServer
();
...
...
include/UniSetActivator.h
View file @
7bda9575
...
...
@@ -55,6 +55,7 @@ namespace uniset
* и перенаправление их указанным объектам. Помимо этого UniSetActivator реализует обработку команд /conf/..
* Для запуска http-сервера необходимо в аргументах командной строки указать --activator-run-httpserver
* Помимо этого можно задать параметры --activator-httpserver-host и --activator-httpserver-port.
* --activator-httpserver-cors-allow addr - (CORS): Access-Control-Allow-Origin. Default: *.
*
*/
class
UniSetActivator
:
...
...
@@ -115,6 +116,7 @@ namespace uniset
std
::
shared_ptr
<
uniset
::
UHttp
::
UHttpServer
>
httpserv
;
std
::
string
httpHost
=
{
""
};
int
httpPort
=
{
0
};
std
::
string
httpCORS_allow
=
{
"*"
};
#endif
};
// -------------------------------------------------------------------------
...
...
libUniSet2.include
View file @
7bda9575
...
...
@@ -53,44 +53,44 @@ ext_libs()
libs
$1
/
$2
}
EXFILE
=
"
$EXPORTPATH
/extensions libUniSet
Extensions2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions libUniSet
2Extensions
.pc"
export
UNISET_EXT_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_LIBS
=
"-L
$EXPORTPATH
/extensions/lib
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/IOControl libUniSet
IOControl2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/IOControl libUniSet
2IOControl
.pc"
export
UNISET_EXT_IO_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_IO_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/SharedMemory libUniSet
SharedMemory2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/SharedMemory libUniSet
2SharedMemory
.pc"
export
UNISET_EXT_SM_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_SM_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/ModbusSlave libUniSet
MBSlave2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/ModbusSlave libUniSet
2MBSlave
.pc"
export
UNISET_EXT_MBS_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_MBS_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/ModbusMaster libUniSet
MBTCPMaster2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/ModbusMaster libUniSet
2MBTCPMaster
.pc"
export
UNISET_EXT_MBM_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_MBM_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/UniNetwork libUniSet
Network2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/UniNetwork libUniSet
2Network
.pc"
export
UNISET_EXT_NET_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_NET_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/UNetUDP libUniSet
UNetUDP2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/UNetUDP libUniSet
2UNetUDP
.pc"
export
UNISET_EXT_UNETUDP_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_UNETUDP_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/ModbusMaster libUniSet
RTU2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/ModbusMaster libUniSet
2RTU
.pc"
export
UNISET_EXT_RTU_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_RTU_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/DBServer-MySQL libUniSet
MySQL2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/DBServer-MySQL libUniSet
2MySQL
.pc"
export
UNISET_EXT_MYSQL_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_MYSQL_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
EXFILE
=
"
$EXPORTPATH
/extensions/LogicProcessor libUniSet
LogicProcessor2
.pc"
EXFILE
=
"
$EXPORTPATH
/extensions/LogicProcessor libUniSet
2LogicProcessor
.pc"
export
UNISET_EXT_LP_CFLAGS
=
"
$(
ext_cflags
$EXFILE
)
"
export
UNISET_EXT_LP_LIBS
=
"
$(
ext_libs
$EXFILE
)
"
export
UNISET_CODEGEN
=
"sh
$EXPORTPATH
/Utilities/codegen/uniset-codegen --path
$EXPORTPATH
/Utilities/codegen"
export
UNISET_CODEGEN
=
"sh
$EXPORTPATH
/Utilities/codegen/uniset
2
-codegen --path
$EXPORTPATH
/Utilities/codegen"
src/Communications/ComPort485F.cc
View file @
7bda9575
#ifndef DISABLE_COMPORT_485F
/*
* Copyright (c) 2015 Pavel Vainerman.
*
...
...
@@ -334,3 +335,4 @@ void ComPort485F::reopen()
ComPort
::
reopen
();
}
// --------------------------------------------------------------------------------
#endif // #ifndef DISABLE_COMPORT_485F
src/Communications/Http/UHttpRequestHandler.cc
View file @
7bda9575
...
...
@@ -28,14 +28,21 @@ namespace uniset
using
namespace
UHttp
;
// -------------------------------------------------------------------------
UHttpRequestHandler
::
UHttpRequestHandler
(
std
::
shared_ptr
<
IHttpRequestRegistry
>
_registry
)
:
registry
(
_registry
)
UHttpRequestHandler
::
UHttpRequestHandler
(
std
::
shared_ptr
<
IHttpRequestRegistry
>
_registry
,
const
std
::
string
&
allow
)
:
registry
(
_registry
)
,
httpCORS_allow
(
allow
)
{
log
=
make_shared
<
DebugStream
>
();
}
// -------------------------------------------------------------------------
void
UHttpRequestHandler
::
handleRequest
(
Poco
::
Net
::
HTTPServerRequest
&
req
,
Poco
::
Net
::
HTTPServerResponse
&
resp
)
void
UHttpRequestHandler
::
handleRequest
(
Poco
::
Net
::
HTTPServerRequest
&
req
,
Poco
::
Net
::
HTTPServerResponse
&
resp
)
{
// В этой версии API поддерживается только GET
resp
.
set
(
"Access-Control-Allow-Methods"
,
"GET"
);
resp
.
set
(
"Access-Control-Allow-Request-Method"
,
"*"
);
resp
.
set
(
"Access-Control-Allow-Origin"
,
httpCORS_allow
/* req.get("Origin") */
);
if
(
!
registry
)
{
resp
.
setStatus
(
HTTPResponse
::
HTTP_INTERNAL_SERVER_ERROR
);
...
...
@@ -159,7 +166,12 @@ namespace uniset
// -------------------------------------------------------------------------
HTTPRequestHandler
*
UHttpRequestHandlerFactory
::
createRequestHandler
(
const
HTTPServerRequest
&
req
)
{
return
new
UHttpRequestHandler
(
registry
);
return
new
UHttpRequestHandler
(
registry
,
httpCORS_allow
);
}
// -------------------------------------------------------------------------
void
UHttpRequestHandlerFactory
::
setCORS_allow
(
const
std
::
string
&
allow
)
{
httpCORS_allow
=
allow
;
}
// -------------------------------------------------------------------------
Poco
::
JSON
::
Object
::
Ptr
IHttpRequest
::
httpRequest
(
const
string
&
req
,
const
Poco
::
URI
::
QueryParameters
&
p
)
...
...
src/Communications/Http/UHttpServer.cc
View file @
7bda9575
...
...
@@ -78,6 +78,11 @@ namespace uniset
return
mylog
;
}
// -------------------------------------------------------------------------
void
UHttpServer
::
setCORS_allow
(
const
std
::
string
&
allow
)
{
reqFactory
->
setCORS_allow
(
allow
);
}
// -------------------------------------------------------------------------
}
// end of namespace uniset
// -------------------------------------------------------------------------
#endif // #ifndef DISABLE_REST_API
src/Communications/Modbus/ModbusRTUMaster.cc
View file @
7bda9575
...
...
@@ -36,6 +36,7 @@ namespace uniset
{
if
(
use485
)
{
#ifndef DISABLE_COMPORT_485F
ComPort485F
*
cp
;
if
(
dev
==
"/dev/ttyS2"
)
...
...
@@ -46,6 +47,9 @@ namespace uniset
throw
Exception
(
"Open ComPort FAILED! dev must be /dev/ttyS2 or /dev/tytS3"
);
port
=
cp
;
#else
throw
Exception
(
"Open ComPort485F FAILED! DISABLE_COMPORT_485F"
);
#endif // #ifndef DISABLE_COMPORT_485F
}
else
port
=
new
ComPort
(
dev
);
...
...
src/Communications/Modbus/ModbusRTUSlave.cc
View file @
7bda9575
...
...
@@ -36,6 +36,7 @@ namespace uniset
{
if
(
use485
)
{
#ifndef DISABLE_COMPORT_485F
ComPort485F
*
cp
;
if
(
dev
==
"/dev/ttyS2"
)
...
...
@@ -46,6 +47,9 @@ namespace uniset
throw
Exception
(
"Open ComPort FAILED! dev must be /dev/ttyS2 or /dev/tytS3"
);
port
=
cp
;
#else
throw
Exception
(
"Open ComPort485F FAILED! DISABLE_COMPORT_485F"
);
#endif // #ifndef DISABLE_COMPORT_485F
}
else
port
=
new
ComPort
(
dev
);
...
...
src/Communications/Modbus/ModbusTCPSession.cc
View file @
7bda9575
...
...
@@ -307,8 +307,9 @@ namespace uniset
if
(
res
<
0
)
{
if
(
errno
!=
EAGAIN
&&
dlog
->
is_warn
()
)
dlog
->
warn
()
<<
peername
<<
"(getNextData): read from socket error("
<<
errno
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
int
errnum
=
errno
;
if
(
errnum
!=
EAGAIN
&&
dlog
->
is_warn
()
)
dlog
->
warn
()
<<
peername
<<
"(getNextData): read from socket error("
<<
errnum
<<
"): "
<<
strerror
(
errnum
)
<<
endl
;
return
0
;
}
...
...
src/Core/UniSetActivator.cc
View file @
7bda9575
...
...
@@ -89,6 +89,7 @@ namespace uniset
s
<<
(
getId
()
==
DefaultObjectId
?
8080
:
getId
()
);
httpPort
=
conf
->
getArgInt
(
"--activator-httpserver-port"
,
s
.
str
());
ulog1
<<
myname
<<
"(init): http server parameters "
<<
httpHost
<<
":"
<<
httpPort
<<
endl
;
httpCORS_allow
=
conf
->
getArgParam
(
"--activator-httpserver-cors-allow"
,
"*"
);
}
#endif
...
...
@@ -153,6 +154,7 @@ namespace uniset
{
auto
reg
=
dynamic_pointer_cast
<
UHttp
::
IHttpRequestRegistry
>
(
shared_from_this
());
httpserv
=
make_shared
<
UHttp
::
UHttpServer
>
(
reg
,
httpHost
,
httpPort
);
httpserv
->
setCORS_allow
(
httpCORS_allow
);
httpserv
->
start
();
}
catch
(
std
::
exception
&
ex
)
...
...
src/Core/UniSetTypes.cc
View file @
7bda9575
...
...
@@ -128,7 +128,8 @@ uniset::IDList::IDList( const std::vector<string>& svec ):
else
id
=
conf
->
getSensorID
(
s
);
add
(
id
);
if
(
id
!=
DefaultObjectId
)
add
(
id
);
}
}
// -------------------------------------------------------------------------
...
...
src/Log/LogSession.cc
View file @
7bda9575
...
...
@@ -301,10 +301,18 @@ namespace uniset
if
(
ret
<
0
)
{
// копируем, а потом проверяем
// хоть POSIX говорит о том, что errno thread-local
// но почему-то словил, что errno (по крайней мере для EPIPE "broken pipe")
// в лог выводилось, а в if( ... ) уже не ловилось
// возможно связано с тем, что ввод/вывод "прерываемая" операция при многопоточности
int
errnum
=
errno
;
// можно было бы конечно убрать вывод лога в else, после проверки в if
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(LogSession::writeEvent): write to socket error("
<<
errn
o
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
mylog
.
warn
()
<<
peername
<<
"(LogSession::writeEvent): write to socket error("
<<
errn
um
<<
"): "
<<
strerror
(
errnum
)
<<
endl
;
if
(
errn
o
==
EPIPE
||
errno
==
EBADF
)
if
(
errn
um
==
EPIPE
||
errnum
==
EBADF
)
{
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(LogSession::writeEvent): write error.. terminate session.."
<<
endl
;
...
...
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