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
d1460952
Commit
d1460952
authored
Mar 15, 2021
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Plain Diff
backported to p9 as 2.9.4-alt0.M90P.0.3 (with rpmbph script)
parents
d910b649
9f246b4b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
172 additions
and
39 deletions
+172
-39
libuniset2.spec
conf/libuniset2.spec
+5
-2
UWebSocketGate.cc
extensions/UWebSocketGate/UWebSocketGate.cc
+132
-27
UWebSocketGate.h
extensions/UWebSocketGate/UWebSocketGate.h
+24
-5
start_fg.sh
extensions/UWebSocketGate/start_fg.sh
+1
-1
test_digitalfilter.cc
extensions/tests/test_digitalfilter.cc
+10
-4
No files found.
conf/libuniset2.spec
View file @
d1460952
...
...
@@ -27,7 +27,7 @@
Name: libuniset2
Version: 2.9.4
Release: alt0.M90P.0.
2
Release: alt0.M90P.0.
3
Summary: UniSet - library for building distributed industrial control systems
License: LGPL-2.1
...
...
@@ -576,9 +576,12 @@ rm -f %buildroot%_docdir/%oname/html/*.md5
# history of current unpublished changes
%changelog
*
Fri Mar 12 2021 Pavel Vainerman <pv@altlinux.ru> 2.9.4-alt0.M90P.0.2
*
Mon Mar 15 2021 Pavel Vainerman <pv@altlinux.ru> 2.9.4-alt0.M90P.0.3
- backport to ALTLinux p9 (by rpmbph script)
* Mon Mar 15 2021 Pavel Vainerman <pv@altlinux.ru> 2.9.4-alt0.3
- [uwebsocket]: refactoring
* Fri Mar 12 2021 Pavel Vainerman <pv@altlinux.ru> 2.9.4-alt0.2
- test build for websocketgate
...
...
extensions/UWebSocketGate/UWebSocketGate.cc
View file @
d1460952
This diff is collapsed.
Click to expand it.
extensions/UWebSocketGate/UWebSocketGate.h
View file @
d1460952
...
...
@@ -167,6 +167,19 @@ namespace uniset
- "ask:id1,id2,name3,..." - подписаться на уведомления об изменении датчиков (sensorInfo)
- "del:id1,id2,name3,..." - отказаться от уведомления об изменении датчиков
- "get:id1,id2,name3,..." - получить текущее значение датчиков (разовое сообщение ShortSensorInfo)
Если длина команды превышает допустимое значение, то возвращается ошибка
\code
{
"data": [
{"type": "Error", "message": "Payload to big"}
]
}
\endcode
\warning Под хранение сообщений для отправки выделяется Kbuf*maxSend. Kbuf в текущей реализации равен 10.
Т.е. если настроено maxSend=5000 сообщений, то буфер сможет максимально хранить 50000 сообщений.
*/
class
UWebSocketGate
:
public
UniSetObject
,
...
...
@@ -228,6 +241,7 @@ namespace uniset
void
checkMessages
(
ev
::
timer
&
t
,
int
revents
);
virtual
void
sensorInfo
(
const
uniset
::
SensorMessage
*
sm
)
override
;
virtual
uniset
::
SimpleInfo
*
getInfo
(
const
char
*
userparam
=
0
)
override
;
ev
::
timer
iocheck
;
double
check_sec
=
{
0
.
05
};
int
maxMessagesProcessing
=
{
100
};
...
...
@@ -242,10 +256,11 @@ namespace uniset
double
wsHeartbeatTime_sec
=
{
3
.
0
};
double
wsSendTime_sec
=
{
0
.
5
};
size_t
wsMaxSend
=
{
2
00
};
size_t
wsMaxCmd
=
{
1
00
};
size_t
wsMaxSend
=
{
50
00
};
size_t
wsMaxCmd
=
{
2
00
};
static
Poco
::
JSON
::
Object
::
Ptr
to_json
(
const
uniset
::
SensorMessage
*
sm
,
const
std
::
string
&
err
);
static
Poco
::
JSON
::
Object
::
Ptr
error_to_json
(
const
std
::
string
&
err
);
/*! класс реализует работу с websocket через eventloop
* Из-за того, что поступление логов может быть достаточно быстрым
...
...
@@ -263,6 +278,8 @@ namespace uniset
virtual
~
UWebSocket
();
std
::
string
getInfo
()
const
noexcept
;
bool
isActive
();
void
set
(
ev
::
dynamic_loop
&
loop
,
std
::
shared_ptr
<
ev
::
async
>
a
);
...
...
@@ -305,18 +322,20 @@ namespace uniset
void
sendResponse
(
sinfo
&
si
);
void
sendShortResponse
(
sinfo
&
si
);
void
onCommand
(
const
std
::
string
&
cmd
);
void
sendError
(
const
std
::
string
&
message
);
ev
::
timer
iosend
;
double
send_sec
=
{
0
.
5
};
size_t
maxsend
=
{
200
};
size_t
maxcmd
=
{
100
};
size_t
maxsend
=
{
5000
};
size_t
maxcmd
=
{
200
};
const
int
Kbuf
=
{
10
};
// коэффициент для буфера сообщений (maxsend умножается на Kbuf)
ev
::
timer
ioping
;
double
ping_sec
=
{
3
.
0
};
static
const
std
::
string
ping_str
;
ev
::
io
iorecv
;
char
rbuf
[
512
];
//! \todo сделать настраиваемым или применить Poco::FIFOBuffer
char
rbuf
[
32
*
1024
];
//! \todo сделать настраиваемым или применить Poco::FIFOBuffer
timeout_t
recvTimeout
=
{
200
};
// msec
std
::
shared_ptr
<
ev
::
async
>
cmdsignal
;
...
...
extensions/UWebSocketGate/start_fg.sh
View file @
d1460952
...
...
@@ -2,4 +2,4 @@
ulimit
-Sc
1000000
uniset2-start.sh
-f
./uniset2-wsgate
--confile
test.xml
--ws-name
UWebSocketGate1
--ws-log-add-levels
any
--ws-max-cmd
3
$*
uniset2-start.sh
-f
./uniset2-wsgate
--confile
test.xml
--ws-name
UWebSocketGate1
--ws-log-add-levels
any
$*
extensions/tests/test_digitalfilter.cc
View file @
d1460952
...
...
@@ -48,8 +48,8 @@ TEST_CASE("[DigitalFilter]: median", "[DigitalFilter][median]")
REQUIRE
(
df
.
currentMedian
()
==
50
);
DigitalFilter
df1
;
DigitalFilter
df10
;
DigitalFilter
df1
(
1
)
;
DigitalFilter
df10
(
10
)
;
vector
<
long
>
dat
=
{
0
,
234
,
356
,
344
,
234
,
320
,
250
,
250
,
250
,
250
,
250
,
250
,
250
,
251
,
252
,
251
,
252
,
252
,
250
};
for
(
auto
v
:
dat
)
...
...
@@ -58,8 +58,14 @@ TEST_CASE("[DigitalFilter]: median", "[DigitalFilter][median]")
df10
.
median
(
v
);
}
REQUIRE
(
df1
.
currentMedian
()
==
252
);
REQUIRE
(
df10
.
currentMedian
()
==
252
);
REQUIRE
(
df1
.
currentMedian
()
==
250
);
REQUIRE
(
df10
.
currentMedian
()
==
251
);
DigitalFilter
d
(
1
);
d
.
median
(
1
);
d
.
median
(
2
);
d
.
median
(
3
);
REQUIRE
(
d
.
currentMedian
()
==
3
);
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"[DigitalFilter]: filter1"
,
"[DigitalFilter][filter1]"
)
...
...
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