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
90ec6540
Commit
90ec6540
authored
May 05, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(SM): исправил ошибку в работе heartbeat, дополнил тесты
parent
078df423
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
11 deletions
+81
-11
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+10
-7
SharedMemory.h
extensions/SharedMemory/SharedMemory.h
+3
-2
sm-configure.xml
extensions/SharedMemory/tests/sm-configure.xml
+3
-1
test_sm.cc
extensions/SharedMemory/tests/test_sm.cc
+61
-0
tests.sh
extensions/SharedMemory/tests/tests.sh
+3
-1
testsuite.at
testsuite/testsuite.at
+1
-0
No files found.
extensions/SharedMemory/SharedMemory.cc
View file @
90ec6540
...
@@ -243,14 +243,17 @@ bool SharedMemory::activateObject()
...
@@ -243,14 +243,17 @@ bool SharedMemory::activateObject()
res
=
IONotifyController_LT
::
activateObject
();
res
=
IONotifyController_LT
::
activateObject
();
// инициализируем указатели
// инициализируем указатели
for
(
auto
&
it
:
hlist
)
for
(
auto
&&
it
:
hlist
)
it
.
ioit
=
myioEnd
();
{
it
.
a_it
=
myioEnd
();
it
.
d_it
=
myioEnd
();
}
itPulsar
=
myioEnd
();
itPulsar
=
myioEnd
();
for
(
auto
&
it
:
hist
)
for
(
auto
&
it
:
hist
)
{
{
for
(
auto
&
hit
:
it
.
hlst
)
for
(
auto
&
&
hit
:
it
.
hlst
)
hit
.
ioit
=
myioEnd
();
hit
.
ioit
=
myioEnd
();
}
}
...
@@ -294,15 +297,15 @@ void SharedMemory::checkHeartBeat()
...
@@ -294,15 +297,15 @@ void SharedMemory::checkHeartBeat()
{
{
try
try
{
{
long
val
=
localGetValue
(
it
.
io
it
,
it
.
a_sid
);
long
val
=
localGetValue
(
it
.
a_
it
,
it
.
a_sid
);
val
--
;
val
--
;
if
(
val
<
-
1
)
if
(
val
<
-
1
)
val
=
-
1
;
val
=
-
1
;
localSetValue
(
it
.
io
it
,
it
.
a_sid
,
val
,
getId
());
localSetValue
(
it
.
a_
it
,
it
.
a_sid
,
val
,
getId
());
localSetValue
(
it
.
io
it
,
it
.
d_sid
,
(
val
>=
0
?
true
:
false
),
getId
());
localSetValue
(
it
.
d_
it
,
it
.
d_sid
,
(
val
>=
0
?
true
:
false
),
getId
());
// проверяем нужна ли "перезагрузка" по данному датчику
// проверяем нужна ли "перезагрузка" по данному датчику
if
(
wdt
&&
it
.
ptReboot
.
getInterval
()
)
if
(
wdt
&&
it
.
ptReboot
.
getInterval
()
)
...
...
extensions/SharedMemory/SharedMemory.h
View file @
90ec6540
...
@@ -404,12 +404,13 @@ class SharedMemory:
...
@@ -404,12 +404,13 @@ class SharedMemory:
UniSetTypes
::
ObjectId
a_sid
;
// аналоговый счётчик
UniSetTypes
::
ObjectId
a_sid
;
// аналоговый счётчик
UniSetTypes
::
ObjectId
d_sid
;
// дискретный датчик состояния процесса
UniSetTypes
::
ObjectId
d_sid
;
// дискретный датчик состояния процесса
IOStateList
::
iterator
ioit
;
IOStateList
::
iterator
a_it
;
IOStateList
::
iterator
d_it
;
int
reboot_msec
;
/*!< Время в течение которого, процесс обязан подтвердить своё существование,
int
reboot_msec
;
/*!< Время в течение которого, процесс обязан подтвердить своё существование,
иначе будет произведена перезагрузка контроллера по WDT (в случае если он включён).
иначе будет произведена перезагрузка контроллера по WDT (в случае если он включён).
Если данный параметр не указывать, то "не живость" процесса просто игнорируется
Если данный параметр не указывать, то "не живость" процесса просто игнорируется
(т.е. только отображение на GUI
). */
(т.е. только сброс датчика heartbeat (d_sid) в ноль
). */
bool
timer_running
;
bool
timer_running
;
PassiveTimer
ptReboot
;
PassiveTimer
ptReboot
;
...
...
extensions/SharedMemory/tests/sm-configure.xml
View file @
90ec6540
...
@@ -42,7 +42,9 @@
...
@@ -42,7 +42,9 @@
<item
id=
"502"
iotype=
"DO"
name=
"DO_C"
priority=
"Medium"
textname=
"Digital output"
/>
<item
id=
"502"
iotype=
"DO"
name=
"DO_C"
priority=
"Medium"
textname=
"Digital output"
/>
<item
id=
"503"
iotype=
"AI"
name=
"AI1_AS"
priority=
"Medium"
textname=
"AI"
/>
<item
id=
"503"
iotype=
"AI"
name=
"AI1_AS"
priority=
"Medium"
textname=
"AI"
/>
<item
id=
"504"
iotype=
"DI"
name=
"Threshold1_S"
priority=
"Medium"
textname=
"Threshold"
/>
<item
id=
"504"
iotype=
"DI"
name=
"Threshold1_S"
priority=
"Medium"
textname=
"Threshold"
/>
<item
id=
"505"
iotype=
"DI"
name=
"Pulsar_S"
priority=
"Medium"
textname=
"pulsar"
/>
<item
heartbeat=
"1"
heartbeat_ds_name=
"Heartbeat_S"
heartbeat_node=
"localhost"
id=
"506"
iotype=
"AI"
name=
"Heart_Counter_AS"
textname=
"Heartbeat counter"
/>
<item
id=
"507"
iotype=
"DI"
name=
"Heartbeat_S"
textname=
"Heartbeat"
/>
</sensors>
</sensors>
<thresholds
name=
"thresholds"
>
<thresholds
name=
"thresholds"
>
<sensor
iotype=
"AI"
name=
"AI1_AS"
>
<sensor
iotype=
"AI"
name=
"AI1_AS"
>
...
...
extensions/SharedMemory/tests/test_sm.cc
View file @
90ec6540
...
@@ -22,6 +22,7 @@ void InitTest()
...
@@ -22,6 +22,7 @@ void InitTest()
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
/*
TEST_CASE("[SM]: init from reserv", "[sm][reserv]")
TEST_CASE("[SM]: init from reserv", "[sm][reserv]")
{
{
InitTest();
InitTest();
...
@@ -30,4 +31,64 @@ TEST_CASE("[SM]: init from reserv", "[sm][reserv]")
...
@@ -30,4 +31,64 @@ TEST_CASE("[SM]: init from reserv", "[sm][reserv]")
CHECK( ui->getValue(503) == 390 );
CHECK( ui->getValue(503) == 390 );
CHECK( ui->getValue(504) == 1 );
CHECK( ui->getValue(504) == 1 );
}
}
*/
// -----------------------------------------------------------------------------
TEST_CASE
(
"[SM]: get/set"
,
"[sm][getset]"
)
{
InitTest
();
ui
->
setValue
(
500
,
30
);
CHECK
(
ui
->
getValue
(
500
)
==
30
);
ui
->
setValue
(
500
,
-
30
);
CHECK
(
ui
->
getValue
(
500
)
==
-
30
);
ui
->
setValue
(
500
,
0
);
CHECK
(
ui
->
getValue
(
500
)
==
0
);
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"[SM]: threshold"
,
"[sm][threshold]"
)
{
InitTest
();
ui
->
setValue
(
503
,
30
);
CHECK
(
ui
->
getValue
(
504
)
==
0
);
ui
->
setValue
(
503
,
400
);
CHECK
(
ui
->
getValue
(
504
)
==
1
);
ui
->
setValue
(
503
,
25
);
CHECK
(
ui
->
getValue
(
504
)
==
0
);
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"[SM]: pulsar"
,
"[sm][pulsar]"
)
{
InitTest
();
while
(
ui
->
getValue
(
505
)
)
msleep
(
50
);
CHECK_FALSE
(
ui
->
getValue
(
505
)
);
msleep
(
1200
);
CHECK
(
ui
->
getValue
(
505
)
);
msleep
(
1200
);
CHECK_FALSE
(
ui
->
getValue
(
505
)
);
msleep
(
1200
);
CHECK
(
ui
->
getValue
(
505
)
);
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"[SM]: heartbeat"
,
"[sm][heartbeat]"
)
{
InitTest
();
CHECK_FALSE
(
ui
->
getValue
(
507
)
);
ui
->
setValue
(
506
,
2
);
msleep
(
500
);
CHECK
(
ui
->
getValue
(
507
)
);
msleep
(
2000
);
CHECK_FALSE
(
ui
->
getValue
(
507
)
);
ui
->
setValue
(
506
,
4
);
msleep
(
2000
);
CHECK
(
ui
->
getValue
(
507
)
);
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
extensions/SharedMemory/tests/tests.sh
View file @
90ec6540
...
@@ -7,4 +7,6 @@
...
@@ -7,4 +7,6 @@
./uniset2-start.sh
-f
./uniset2-admin
--confile
./reserv-sm-configure.xml
--exist
|
grep
-q
UNISET_SM/Controllers
||
exit
1
./uniset2-start.sh
-f
./uniset2-admin
--confile
./reserv-sm-configure.xml
--exist
|
grep
-q
UNISET_SM/Controllers
||
exit
1
./uniset2-start.sh
-f
./tests
$*
--
--confile
./sm-configure.xml
--dlog-add-levels
any
./uniset2-start.sh
-f
./tests
$*
--
--confile
./sm-configure.xml
--pulsar-id
Pulsar_S
--pulsar-msec
1000
\
--heartbeat-node
localhost
--heartbeat-check-time
1000
#--dlog-add-levels any
testsuite/testsuite.at
View file @
90ec6540
...
@@ -6,6 +6,7 @@ AT_INIT([Uniset test suite])
...
@@ -6,6 +6,7 @@ AT_INIT([Uniset test suite])
m4_include(../tests/tests.at)
m4_include(../tests/tests.at)
m4_include(../extensions/tests/extensions-tests.at)
m4_include(../extensions/tests/extensions-tests.at)
m4_include(../extensions/SharedMemory/tests/sm-tests.at)
m4_include(../extensions/LogicProcessor/tests/lproc-tests.at)
m4_include(../extensions/LogicProcessor/tests/lproc-tests.at)
m4_include(../extensions/ModbusSlave/tests/mbslave-tests.at)
m4_include(../extensions/ModbusSlave/tests/mbslave-tests.at)
m4_include(../extensions/UNetUDP/tests/unetudp-tests.at)
m4_include(../extensions/UNetUDP/tests/unetudp-tests.at)
...
...
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