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
33621363
Commit
33621363
authored
Dec 18, 2013
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(2.0): Добавил проверку управления логами через датчик
parent
1de9cd0c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
23 deletions
+74
-23
skel.src.xml
Utilities/codegen/skel.src.xml
+6
-0
TestGen.cc
Utilities/codegen/tests/TestGen.cc
+55
-21
TestGen.h
Utilities/codegen/tests/TestGen.h
+8
-1
test.xml
conf/test.xml
+3
-0
DebugStream.h
include/DebugStream.h
+1
-0
Debug.cc
src/Various/Debug.cc
+1
-1
No files found.
Utilities/codegen/skel.src.xml
View file @
33621363
...
...
@@ -19,6 +19,7 @@
<item
name=
"changeTime"
type=
"int"
default=
"2000"
min=
"0"
comment=
"change state time"
const=
"1"
public=
"1"
/>
<item
name=
"checkWorkingTime"
type=
"int"
default=
"3000"
min=
"0"
comment=
"check working time"
const=
"1"
public=
"1"
/>
<item
name=
"checkTime"
type=
"int"
default=
"3000"
min=
"0"
comment=
"check Working time"
const=
"1"
public=
"1"
/>
<item
name=
"checkLogTime"
type=
"int"
default=
"2500"
min=
"0"
comment=
"Проверка управления логами"
const=
"1"
public=
"1"
/>
</variables>
<smap>
<!-- name - название переменной в конф. файле -->
...
...
@@ -39,6 +40,11 @@
<!-- проверка работы threshold-ов -->
<item
name=
"t_set_c"
vartype=
"out"
comment=
"аналоговый датчик (для выставления порога)"
/>
<item
name=
"t_check_s"
vartype=
"in"
comment=
"датчик для проверки срабатывания"
/>
<!-- Проверка управления логами -->
<item
name=
"log_c"
vartype=
"out"
comment=
"аналоговый датчик для выставления уровня логов"
/>
<item
name=
"log_s"
vartype=
"in"
comment=
"датчик для управления логами"
loglevel=
"1"
/>
</smap>
<msgmap>
...
...
Utilities/codegen/tests/TestGen.cc
View file @
33621363
...
...
@@ -9,6 +9,16 @@ TestProc::TestProc( UniSetTypes::ObjectId id, xmlNode* confnode ):
TestProc_SK
(
id
,
confnode
),
state
(
false
)
{
loglevels
.
push_back
(
Debug
::
INFO
);
loglevels
.
push_back
(
Debug
::
WARN
);
loglevels
.
push_back
(
Debug
::
CRIT
);
loglevels
.
push_back
(
Debug
::
LEVEL1
);
loglevels
.
push_back
(
Debug
::
LEVEL2
);
loglevels
.
push_back
(
Debug
::
type
(
Debug
::
LEVEL2
|
Debug
::
INFO
)
);
loglevels
.
push_back
(
Debug
::
type
(
Debug
::
LEVEL2
|
Debug
::
INFO
|
Debug
::
WARN
|
Debug
::
CRIT
)
);
lit
=
loglevels
.
begin
();
out_log_c
=
(
*
lit
);
}
// -----------------------------------------------------------------------------
TestProc
::~
TestProc
()
...
...
@@ -33,35 +43,37 @@ void TestProc::sysCommand( UniSetTypes::SystemMessage* sm )
{
askTimer
(
tmCheck
,
checkTime
);
askTimer
(
tmCheckWorking
,
checkWorkingTime
);
askTimer
(
tmLogControl
,
checkLogTime
);
// В начальный момент времени блокирующий датчик =0, поэтому d2_check_s должен быть равен depend_off_value (-50).
dlog
.
level1
()
<<
myname
<<
"(startup): check init depend: "
<<
(
getValue
(
d2_check_s
)
==
-
50
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
"(startup): check init depend: "
<<
(
getValue
(
d2_check_s
)
==
-
50
?
"OK"
:
"FAIL"
)
<<
endl
;
}
}
// -----------------------------------------------------------------------------
void
TestProc
::
sensorInfo
(
SensorMessage
*
sm
)
{
/*
dlog.level2() << myname << "(sensorInfo): id=" << sm->id << " val=" << sm->value
<< " " << timeToString(sm->sm_tv_sec,":")
<< "(" << setw(6) << sm->sm_tv_usec << "): "
<< endl;
*/
if
(
sm
->
id
==
on_s
)
{
if
(
sm
->
value
)
{
dlog
.
level1
()
<<
myname
<<
"(sensorInfo): START WORKING.."
<<
endl
;
cerr
<<
myname
<<
"(sensorInfo): START WORKING.."
<<
endl
;
askTimer
(
tmChange
,
changeTime
);
}
else
{
askTimer
(
tmChange
,
0
);
dlog
.
level1
()
<<
myname
<<
"(sensorInfo): STOP WORKING.."
<<
endl
;
cerr
<<
myname
<<
"(sensorInfo): STOP WORKING.."
<<
endl
;
}
}
else
if
(
sm
->
id
==
check_undef_s
)
{
dlog
.
level1
()
<<
myname
<<
"(sensorInfo): CHECK UNDEFINED STATE ==> "
<<
(
sm
->
undefined
==
undef
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
"(sensorInfo): CHECK UNDEFINED STATE ==> "
<<
(
sm
->
undefined
==
undef
?
"OK"
:
"FAIL"
)
<<
endl
;
}
}
// -----------------------------------------------------------------------------
...
...
@@ -75,19 +87,30 @@ void TestProc::timerInfo( TimerMessage *tm )
askTimer
(
tmCheckWorking
,
checkTime
);
// reset timer
}
else
if
(
tm
->
id
==
tmCheckWorking
)
dlog
.
level1
()
<<
myname
<<
": WORKING FAIL!"
<<
endl
;
cerr
<<
myname
<<
": WORKING FAIL!"
<<
endl
;
else
if
(
tm
->
id
==
tmCheck
)
{
dlog
.
level1
()
<<
endl
<<
endl
<<
"--------"
<<
endl
;
cerr
<<
endl
<<
endl
<<
"--------"
<<
endl
;
test_depend
();
test_undefined_state
();
test_thresholds
();
test_loglevel
();
}
else
if
(
tm
->
id
==
tmLogControl
)
{
cerr
<<
endl
;
cerr
<<
"======= TEST LOG PRINT ======"
<<
endl
;
cerr
<<
"LOGLEVEL: ["
<<
(
int
)(
*
lit
)
<<
"] "
<<
(
*
lit
)
<<
endl
;
for
(
std
::
vector
<
Debug
::
type
>::
iterator
it
=
loglevels
.
begin
();
it
!=
loglevels
.
end
();
++
it
)
dlog
[
*
it
]
<<
myname
<<
": test log print..."
<<
endl
;
cerr
<<
"======= END LOG PRINT ======"
<<
endl
;
}
}
// -----------------------------------------------------------------------------
void
TestProc
::
test_depend
()
{
dlog
.
level1
()
<<
myname
<<
": Check depend..."
<<
endl
;
cerr
<<
myname
<<
": Check depend..."
<<
endl
;
long
test_val
=
100
;
...
...
@@ -95,39 +118,39 @@ void TestProc::test_depend()
setValue
(
depend_c
,
0
);
setValue
(
set_d1_check_s
,
test_val
);
setValue
(
set_d2_check_s
,
test_val
);
dlog
.
level1
()
<<
myname
<<
": check depend OFF: d1: "
<<
(
getValue
(
d1_check_s
)
==
0
?
"OK"
:
"FAIL"
)
<<
endl
;
dlog
.
level1
()
<<
myname
<<
": check depend OFF: d2: "
<<
(
getValue
(
d2_check_s
)
==
-
50
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
": check depend OFF: d1: "
<<
(
getValue
(
d1_check_s
)
==
0
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
": check depend OFF: d2: "
<<
(
getValue
(
d2_check_s
)
==
-
50
?
"OK"
:
"FAIL"
)
<<
endl
;
// set depend 1
setValue
(
depend_c
,
1
);
dlog
.
level1
()
<<
myname
<<
": check depend ON: d1: "
<<
(
getValue
(
d1_check_s
)
==
test_val
?
"OK"
:
"FAIL"
)
<<
endl
;
dlog
.
level1
()
<<
myname
<<
": check depend ON: d2: "
<<
(
getValue
(
d2_check_s
)
==
test_val
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
": check depend ON: d1: "
<<
(
getValue
(
d1_check_s
)
==
test_val
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
": check depend ON: d2: "
<<
(
getValue
(
d2_check_s
)
==
test_val
?
"OK"
:
"FAIL"
)
<<
endl
;
}
// -----------------------------------------------------------------------------
void
TestProc
::
test_undefined_state
()
{
// ---------------- Проверка выставления неопределённого состояния ---------------------
dlog
.
level1
()
<<
myname
<<
": Check undef state..."
<<
endl
;
cerr
<<
myname
<<
": Check undef state..."
<<
endl
;
undef
^=
true
;
si
.
id
=
undef_c
;
si
.
node
=
conf
->
getLocalNode
();
dlog
.
level1
()
<<
myname
<<
": set undefined="
<<
undef
<<
endl
;
cerr
<<
myname
<<
": set undefined="
<<
undef
<<
endl
;
ui
.
setUndefinedState
(
si
,
undef
,
getId
()
);
}
// -----------------------------------------------------------------------------
void
TestProc
::
test_thresholds
()
{
// ---------------- Проверка работы порогов ---------------------
dlog
.
level1
()
<<
myname
<<
": Check thresholds..."
<<
endl
;
cerr
<<
myname
<<
": Check thresholds..."
<<
endl
;
setValue
(
t_set_c
,
0
);
dlog
.
level1
()
<<
myname
<<
": check threshold OFF value: "
<<
(
getValue
(
t_check_s
)
==
0
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
": check threshold OFF value: "
<<
(
getValue
(
t_check_s
)
==
0
?
"OK"
:
"FAIL"
)
<<
endl
;
setValue
(
t_set_c
,
378
);
dlog
.
level1
()
<<
myname
<<
": check threshold ON value: "
<<
(
getValue
(
t_check_s
)
==
1
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
": check threshold ON value: "
<<
(
getValue
(
t_check_s
)
==
1
?
"OK"
:
"FAIL"
)
<<
endl
;
dlog
.
level1
()
<<
myname
<<
": ask threshold and check.. "
<<
endl
;
cerr
<<
myname
<<
": ask threshold and check.. "
<<
endl
;
try
{
...
...
@@ -136,14 +159,25 @@ void TestProc::test_thresholds()
ui
.
askThreshold
(
t_set_c
,
tid
,
UniversalIO
::
UIONotify
,
10
,
20
);
IONotifyController_i
::
ThresholdInfo
ti
=
ui
.
getThresholdInfo
(
t_set_c
,
tid
);
dlog
.
level1
()
<<
myname
<<
": ask OFF threshold: "
<<
(
ti
.
state
==
IONotifyController_i
::
NormalThreshold
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
": ask OFF threshold: "
<<
(
ti
.
state
==
IONotifyController_i
::
NormalThreshold
?
"OK"
:
"FAIL"
)
<<
endl
;
setValue
(
t_set_c
,
25
);
ti
=
ui
.
getThresholdInfo
(
t_set_c
,
tid
);
dlog
.
level1
()
<<
myname
<<
": ask ON threshold: "
<<
(
ti
.
state
==
IONotifyController_i
::
HiThreshold
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
myname
<<
": ask ON threshold: "
<<
(
ti
.
state
==
IONotifyController_i
::
HiThreshold
?
"OK"
:
"FAIL"
)
<<
endl
;
}
catch
(
Exception
&
ex
)
{
dlog
.
level2
()
<<
myname
<<
": CHE 'ask and get threshold' FAILED: "
<<
ex
<<
endl
;
dlog
.
level2
()
<<
myname
<<
": CHE
CK
'ask and get threshold' FAILED: "
<<
ex
<<
endl
;
}
}
// -----------------------------------------------------------------------------
void
TestProc
::
test_loglevel
()
{
lit
++
;
if
(
lit
==
loglevels
.
end
()
)
lit
=
loglevels
.
begin
();
cerr
<<
"SET LOGLEVEL: ["
<<
(
int
)(
*
lit
)
<<
"] "
<<
(
*
lit
)
<<
endl
;
setValue
(
log_c
,
(
*
lit
));
askTimer
(
tmLogControl
,
checkLogTime
);
}
// -----------------------------------------------------------------------------
Utilities/codegen/tests/TestGen.h
View file @
33621363
...
...
@@ -2,6 +2,8 @@
#ifndef TestProc_H_
#define TestProc_H_
// -----------------------------------------------------------------------------
#include <vector>
#include "Debug.h"
#include "TestProc_SK.h"
// -----------------------------------------------------------------------------
class
TestProc
:
...
...
@@ -18,7 +20,8 @@ class TestProc:
{
tmChange
,
tmCheckWorking
,
tmCheck
tmCheck
,
tmLogControl
};
virtual
void
step
();
...
...
@@ -29,10 +32,14 @@ class TestProc:
void
test_depend
();
void
test_undefined_state
();
void
test_thresholds
();
void
test_loglevel
();
private
:
bool
state
;
bool
undef
;
std
::
vector
<
Debug
::
type
>
loglevels
;
std
::
vector
<
Debug
::
type
>::
iterator
lit
;
};
// -----------------------------------------------------------------------------
#endif // TestProc_H_
...
...
conf/test.xml
View file @
33621363
...
...
@@ -45,6 +45,8 @@
check_undef_s=
"AI54_S"
t_set_c=
"AI_AS"
t_check_s=
"Threshold1_S"
log_c=
"LogLevel_S"
log_s=
"LogLevel_S"
/>
<IOControl
name=
"IOControl"
/>
...
...
@@ -221,6 +223,7 @@
<item
id=
"56"
iotype=
"AI"
name=
"AI56_S"
textname=
"AI sensor 56"
rrd=
"2"
rrd2_ds=
"COUNTER:20:U:U"
/>
<item
id=
"57"
iotype=
"AI"
name=
"AI57_S"
textname=
"AI sensor 57"
rrd=
"2"
rrd2_ds=
"DERIVE:20:U:U"
/>
<item
id=
"58"
iotype=
"AO"
name=
"Lamp58_C"
textname=
"Lamp 58"
rrd=
"1"
rrd1_ds=
"GAUGE:20:U:U"
/>
<item
id=
"62"
iotype=
"AI"
name=
"LogLevel_S"
textname=
"LogLevel control"
/>
</sensors>
<thresholds
name=
"thresholds"
>
<sensor
iotype=
"AI"
name=
"AI_AS"
>
...
...
include/DebugStream.h
View file @
33621363
...
...
@@ -183,6 +183,7 @@ public:
DMANIP
(
repository
,
REPOSITORY
)
DMANIP
(
system
,
SYSTEM
)
DMANIP
(
exception
,
EXCEPTION
)
DMANIP
(
any
,
ANY
)
#undef DMANIP
std
::
ostream
&
printDate
(
Debug
::
type
t
,
char
brk
=
'/'
);
...
...
src/Various/Debug.cc
View file @
33621363
...
...
@@ -43,7 +43,7 @@ static error_item errorTags[] = {
{
Debug
::
LEVEL7
,
"level7"
,
(
"UniSet debug level7"
)},
{
Debug
::
LEVEL8
,
"level8"
,
(
"UniSet debug level8"
)},
{
Debug
::
LEVEL9
,
"level9"
,
(
"UniSet debug level9"
)},
{
Debug
::
REPOSITORY
,
"repository"
,(
"UniSet repository messages"
)},
{
Debug
::
REPOSITORY
,
"repository"
,(
"UniSet repository messages"
)},
{
Debug
::
ANY
,
"any"
,
(
"All debugging messages"
)},
{
Debug
::
EXCEPTION
,
"exception"
,
(
"Exception debug messages"
)},
...
...
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