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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
22 deletions
+73
-22
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
+0
-0
No files found.
Utilities/codegen/skel.src.xml
View file @
33621363
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
<item
name=
"changeTime"
type=
"int"
default=
"2000"
min=
"0"
comment=
"change state time"
const=
"1"
public=
"1"
/>
<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=
"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=
"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>
</variables>
<smap>
<smap>
<!-- name - название переменной в конф. файле -->
<!-- name - название переменной в конф. файле -->
...
@@ -39,6 +40,11 @@
...
@@ -39,6 +40,11 @@
<!-- проверка работы threshold-ов -->
<!-- проверка работы threshold-ов -->
<item
name=
"t_set_c"
vartype=
"out"
comment=
"аналоговый датчик (для выставления порога)"
/>
<item
name=
"t_set_c"
vartype=
"out"
comment=
"аналоговый датчик (для выставления порога)"
/>
<item
name=
"t_check_s"
vartype=
"in"
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>
</smap>
<msgmap>
<msgmap>
...
...
Utilities/codegen/tests/TestGen.cc
View file @
33621363
...
@@ -9,6 +9,16 @@ TestProc::TestProc( UniSetTypes::ObjectId id, xmlNode* confnode ):
...
@@ -9,6 +9,16 @@ TestProc::TestProc( UniSetTypes::ObjectId id, xmlNode* confnode ):
TestProc_SK
(
id
,
confnode
),
TestProc_SK
(
id
,
confnode
),
state
(
false
)
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
()
TestProc
::~
TestProc
()
...
@@ -33,35 +43,37 @@ void TestProc::sysCommand( UniSetTypes::SystemMessage* sm )
...
@@ -33,35 +43,37 @@ void TestProc::sysCommand( UniSetTypes::SystemMessage* sm )
{
{
askTimer
(
tmCheck
,
checkTime
);
askTimer
(
tmCheck
,
checkTime
);
askTimer
(
tmCheckWorking
,
checkWorkingTime
);
askTimer
(
tmCheckWorking
,
checkWorkingTime
);
askTimer
(
tmLogControl
,
checkLogTime
);
// В начальный момент времени блокирующий датчик =0, поэтому d2_check_s должен быть равен depend_off_value (-50).
// В начальный момент времени блокирующий датчик =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
)
void
TestProc
::
sensorInfo
(
SensorMessage
*
sm
)
{
{
/*
dlog.level2() << myname << "(sensorInfo): id=" << sm->id << " val=" << sm->value
dlog.level2() << myname << "(sensorInfo): id=" << sm->id << " val=" << sm->value
<< " " << timeToString(sm->sm_tv_sec,":")
<< " " << timeToString(sm->sm_tv_sec,":")
<< "(" << setw(6) << sm->sm_tv_usec << "): "
<< "(" << setw(6) << sm->sm_tv_usec << "): "
<< endl;
<< endl;
*/
if
(
sm
->
id
==
on_s
)
if
(
sm
->
id
==
on_s
)
{
{
if
(
sm
->
value
)
if
(
sm
->
value
)
{
{
dlog
.
level1
()
<<
myname
<<
"(sensorInfo): START WORKING.."
<<
endl
;
cerr
<<
myname
<<
"(sensorInfo): START WORKING.."
<<
endl
;
askTimer
(
tmChange
,
changeTime
);
askTimer
(
tmChange
,
changeTime
);
}
}
else
else
{
{
askTimer
(
tmChange
,
0
);
askTimer
(
tmChange
,
0
);
dlog
.
level1
()
<<
myname
<<
"(sensorInfo): STOP WORKING.."
<<
endl
;
cerr
<<
myname
<<
"(sensorInfo): STOP WORKING.."
<<
endl
;
}
}
}
}
else
if
(
sm
->
id
==
check_undef_s
)
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 )
...
@@ -75,19 +87,30 @@ void TestProc::timerInfo( TimerMessage *tm )
askTimer
(
tmCheckWorking
,
checkTime
);
// reset timer
askTimer
(
tmCheckWorking
,
checkTime
);
// reset timer
}
}
else
if
(
tm
->
id
==
tmCheckWorking
)
else
if
(
tm
->
id
==
tmCheckWorking
)
dlog
.
level1
()
<<
myname
<<
": WORKING FAIL!"
<<
endl
;
cerr
<<
myname
<<
": WORKING FAIL!"
<<
endl
;
else
if
(
tm
->
id
==
tmCheck
)
else
if
(
tm
->
id
==
tmCheck
)
{
{
dlog
.
level1
()
<<
endl
<<
endl
<<
"--------"
<<
endl
;
cerr
<<
endl
<<
endl
<<
"--------"
<<
endl
;
test_depend
();
test_depend
();
test_undefined_state
();
test_undefined_state
();
test_thresholds
();
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
()
void
TestProc
::
test_depend
()
{
{
dlog
.
level1
()
<<
myname
<<
": Check depend..."
<<
endl
;
cerr
<<
myname
<<
": Check depend..."
<<
endl
;
long
test_val
=
100
;
long
test_val
=
100
;
...
@@ -95,39 +118,39 @@ void TestProc::test_depend()
...
@@ -95,39 +118,39 @@ void TestProc::test_depend()
setValue
(
depend_c
,
0
);
setValue
(
depend_c
,
0
);
setValue
(
set_d1_check_s
,
test_val
);
setValue
(
set_d1_check_s
,
test_val
);
setValue
(
set_d2_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
;
cerr
<<
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: d2: "
<<
(
getValue
(
d2_check_s
)
==
-
50
?
"OK"
:
"FAIL"
)
<<
endl
;
// set depend 1
// set depend 1
setValue
(
depend_c
,
1
);
setValue
(
depend_c
,
1
);
dlog
.
level1
()
<<
myname
<<
": check depend ON: d1: "
<<
(
getValue
(
d1_check_s
)
==
test_val
?
"OK"
:
"FAIL"
)
<<
endl
;
cerr
<<
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: d2: "
<<
(
getValue
(
d2_check_s
)
==
test_val
?
"OK"
:
"FAIL"
)
<<
endl
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
TestProc
::
test_undefined_state
()
void
TestProc
::
test_undefined_state
()
{
{
// ---------------- Проверка выставления неопределённого состояния ---------------------
// ---------------- Проверка выставления неопределённого состояния ---------------------
dlog
.
level1
()
<<
myname
<<
": Check undef state..."
<<
endl
;
cerr
<<
myname
<<
": Check undef state..."
<<
endl
;
undef
^=
true
;
undef
^=
true
;
si
.
id
=
undef_c
;
si
.
id
=
undef_c
;
si
.
node
=
conf
->
getLocalNode
();
si
.
node
=
conf
->
getLocalNode
();
dlog
.
level1
()
<<
myname
<<
": set undefined="
<<
undef
<<
endl
;
cerr
<<
myname
<<
": set undefined="
<<
undef
<<
endl
;
ui
.
setUndefinedState
(
si
,
undef
,
getId
()
);
ui
.
setUndefinedState
(
si
,
undef
,
getId
()
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
TestProc
::
test_thresholds
()
void
TestProc
::
test_thresholds
()
{
{
// ---------------- Проверка работы порогов ---------------------
// ---------------- Проверка работы порогов ---------------------
dlog
.
level1
()
<<
myname
<<
": Check thresholds..."
<<
endl
;
cerr
<<
myname
<<
": Check thresholds..."
<<
endl
;
setValue
(
t_set_c
,
0
);
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
);
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
try
{
{
...
@@ -136,14 +159,25 @@ void TestProc::test_thresholds()
...
@@ -136,14 +159,25 @@ void TestProc::test_thresholds()
ui
.
askThreshold
(
t_set_c
,
tid
,
UniversalIO
::
UIONotify
,
10
,
20
);
ui
.
askThreshold
(
t_set_c
,
tid
,
UniversalIO
::
UIONotify
,
10
,
20
);
IONotifyController_i
::
ThresholdInfo
ti
=
ui
.
getThresholdInfo
(
t_set_c
,
tid
);
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
);
setValue
(
t_set_c
,
25
);
ti
=
ui
.
getThresholdInfo
(
t_set_c
,
tid
);
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
)
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 @@
...
@@ -2,6 +2,8 @@
#ifndef TestProc_H_
#ifndef TestProc_H_
#define TestProc_H_
#define TestProc_H_
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#include <vector>
#include "Debug.h"
#include "TestProc_SK.h"
#include "TestProc_SK.h"
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
class
TestProc
:
class
TestProc
:
...
@@ -18,7 +20,8 @@ class TestProc:
...
@@ -18,7 +20,8 @@ class TestProc:
{
{
tmChange
,
tmChange
,
tmCheckWorking
,
tmCheckWorking
,
tmCheck
tmCheck
,
tmLogControl
};
};
virtual
void
step
();
virtual
void
step
();
...
@@ -29,10 +32,14 @@ class TestProc:
...
@@ -29,10 +32,14 @@ class TestProc:
void
test_depend
();
void
test_depend
();
void
test_undefined_state
();
void
test_undefined_state
();
void
test_thresholds
();
void
test_thresholds
();
void
test_loglevel
();
private
:
private
:
bool
state
;
bool
state
;
bool
undef
;
bool
undef
;
std
::
vector
<
Debug
::
type
>
loglevels
;
std
::
vector
<
Debug
::
type
>::
iterator
lit
;
};
};
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#endif // TestProc_H_
#endif // TestProc_H_
...
...
conf/test.xml
View file @
33621363
...
@@ -45,6 +45,8 @@
...
@@ -45,6 +45,8 @@
check_undef_s=
"AI54_S"
check_undef_s=
"AI54_S"
t_set_c=
"AI_AS"
t_set_c=
"AI_AS"
t_check_s=
"Threshold1_S"
t_check_s=
"Threshold1_S"
log_c=
"LogLevel_S"
log_s=
"LogLevel_S"
/>
/>
<IOControl
name=
"IOControl"
/>
<IOControl
name=
"IOControl"
/>
...
@@ -221,6 +223,7 @@
...
@@ -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=
"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=
"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=
"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>
</sensors>
<thresholds
name=
"thresholds"
>
<thresholds
name=
"thresholds"
>
<sensor
iotype=
"AI"
name=
"AI_AS"
>
<sensor
iotype=
"AI"
name=
"AI_AS"
>
...
...
include/DebugStream.h
View file @
33621363
...
@@ -183,6 +183,7 @@ public:
...
@@ -183,6 +183,7 @@ public:
DMANIP
(
repository
,
REPOSITORY
)
DMANIP
(
repository
,
REPOSITORY
)
DMANIP
(
system
,
SYSTEM
)
DMANIP
(
system
,
SYSTEM
)
DMANIP
(
exception
,
EXCEPTION
)
DMANIP
(
exception
,
EXCEPTION
)
DMANIP
(
any
,
ANY
)
#undef DMANIP
#undef DMANIP
std
::
ostream
&
printDate
(
Debug
::
type
t
,
char
brk
=
'/'
);
std
::
ostream
&
printDate
(
Debug
::
type
t
,
char
brk
=
'/'
);
...
...
src/Various/Debug.cc
View file @
33621363
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