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
189567d1
Commit
189567d1
authored
Oct 04, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(tests): накидал скелет для проверки элементов LogicProcessor
parent
b245e46f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
162 additions
and
2 deletions
+162
-2
configure.ac
configure.ac
+1
-0
Makefile.am
extensions/LogicProcessor/Makefile.am
+1
-0
TDelay.h
extensions/LogicProcessor/TDelay.h
+2
-2
Makefile.am
extensions/LogicProcessor/unit-tests/Makefile.am
+7
-0
lproc.cc
extensions/LogicProcessor/unit-tests/lproc.cc
+102
-0
schema.xml
extensions/LogicProcessor/unit-tests/schema.xml
+44
-0
tests.cc
extensions/LogicProcessor/unit-tests/tests.cc
+5
-0
No files found.
configure.ac
View file @
189567d1
...
...
@@ -279,6 +279,7 @@ AC_CONFIG_FILES([Makefile
extensions/ModbusSlave/libUniSet2MBSlave.pc
extensions/LogicProcessor/Makefile
extensions/LogicProcessor/libUniSet2LogicProcessor.pc
extensions/LogicProcessor/unit-tests/Makefile
extensions/SMViewer/Makefile
extensions/UniNetwork/Makefile
extensions/UniNetwork/libUniSet2Network.pc
...
...
extensions/LogicProcessor/Makefile.am
View file @
189567d1
if
DISABLE_LOGICPROC
else
SUBDIRS
=
unit-tests
# не забывайте править версию в2.pc-файле
ULPROC_VER
=
@LIBVER@
...
...
extensions/LogicProcessor/TDelay.h
View file @
189567d1
...
...
@@ -4,8 +4,8 @@
#include "PassiveTimer.h"
#include "Element.h"
// ---------------------------------------------------------------------------
//
add on delay, off delay
//
"ON" delay element
// Сбрасывается без задержки.. а срабатывает с задержкой.
class
TDelay
:
public
Element
{
...
...
extensions/LogicProcessor/unit-tests/Makefile.am
0 → 100644
View file @
189567d1
noinst_PROGRAMS
=
tests
tests_SOURCES
=
tests.cc lproc.cc
tests_LDADD
=
$(top_builddir)
/lib/libUniSet2.la
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
\
$(top_builddir)
/extensions/LogicProcessor/libUniSet2LProcessor.la
tests_CPPFLAGS
=
-I
$(top_builddir)
/include
-I
$(top_builddir)
/extensions/include
-I
$(top_builddir)
/extensions/LogicProcessor
\
-I
$(includedir)
/Catch
extensions/LogicProcessor/unit-tests/lproc.cc
0 → 100644
View file @
189567d1
#include <catch.hpp>
#include <time.h>
#include "LProcessor.h"
#include "UniSetTypes.h"
#include "Schema.h"
#include "TDelay.h"
using
namespace
std
;
using
namespace
UniSetTypes
;
TEST_CASE
(
"Logic processor"
,
"[LogicProcessor]"
)
{
#if 0
SECTION( "ShemaXML" )
{
SchemaXML sch;
sch.read("schema.xml");
CHECK( !sch.empty() );
}
#endif
SECTION
(
"TOR"
)
{
TOR
e
(
"1"
,
2
);
// элемент на два входа..
REQUIRE
(
e
.
getOut
()
==
0
);
e
.
setIn
(
1
,
true
);
CHECK
(
e
.
getOut
()
);
e
.
setIn
(
2
,
true
);
CHECK
(
e
.
getOut
()
);
e
.
setIn
(
1
,
false
);
CHECK
(
e
.
getOut
()
);
e
.
setIn
(
2
,
false
);
CHECK_FALSE
(
e
.
getOut
()
);
e
.
setIn
(
3
,
true
);
// несуществующий вход..
CHECK_FALSE
(
e
.
getOut
()
);
}
SECTION
(
"TAND"
)
{
TAND
e
(
"1"
,
2
);
// элемент на два входа..
REQUIRE
(
e
.
getOut
()
==
0
);
e
.
setIn
(
1
,
true
);
CHECK_FALSE
(
e
.
getOut
()
);
e
.
setIn
(
2
,
true
);
CHECK
(
e
.
getOut
()
);
e
.
setIn
(
1
,
false
);
CHECK_FALSE
(
e
.
getOut
()
);
e
.
setIn
(
2
,
false
);
CHECK_FALSE
(
e
.
getOut
()
);
e
.
setIn
(
3
,
true
);
// несуществующий вход..
CHECK_FALSE
(
e
.
getOut
()
);
}
SECTION
(
"TNOT"
)
{
TNOT
e
(
"1"
,
false
);
CHECK_FALSE
(
e
.
getOut
()
);
e
.
setIn
(
1
,
true
);
CHECK_FALSE
(
e
.
getOut
()
);
e
.
setIn
(
1
,
false
);
CHECK
(
e
.
getOut
()
);
// other constructor
TNOT
e1
(
"1"
,
true
);
CHECK
(
e1
.
getOut
()
);
e1
.
setIn
(
1
,
true
);
CHECK_FALSE
(
e1
.
getOut
()
);
e1
.
setIn
(
1
,
false
);
CHECK
(
e1
.
getOut
()
);
}
SECTION
(
"TDelay"
)
{
TDelay
e
(
"1"
,
50
,
1
);
CHECK_FALSE
(
e
.
getOut
()
);
// ON DELAY
e
.
setIn
(
1
,
true
);
CHECK_FALSE
(
e
.
getOut
()
);
msleep
(
60
);
e
.
tick
();
CHECK
(
e
.
getOut
()
);
msleep
(
60
);
e
.
tick
();
CHECK
(
e
.
getOut
()
);
// OFF DELAY
e
.
setIn
(
1
,
false
);
CHECK_FALSE
(
e
.
getOut
()
);
// delay 0 msek..
e
.
setDelay
(
0
);
e
.
setIn
(
1
,
true
);
CHECK
(
e
.
getOut
()
);
// delay < 0 === 0
e
.
setIn
(
1
,
false
);
e
.
setDelay
(
-
10
);
e
.
setIn
(
1
,
true
);
CHECK
(
e
.
getOut
()
);
}
}
extensions/LogicProcessor/unit-tests/schema.xml
0 → 100644
View file @
189567d1
<?xml version="1.0" encoding="koi8-r"?>
<Schema>
<text-view>
----
1 --| |
2 --|TOR1|---| 1 -----
| | |----| |
---- 2 | |--|
|----|TAND3| |
---- | | | |
| | | ----- |
1 --|TOR2| | | 1 ---- -------
2 --| |--- | ---- ---| | | | out
| | | 1 | | 2 |TOR5|-----| Delay |----
---- |---|TOR4|-----| | | |
2 ----| | | | | |
---- ---- -------
</text-view>
<elements>
<item
id=
"1"
type=
"OR"
inCount=
"2"
/>
<item
id=
"2"
type=
"OR"
inCount=
"2"
/>
<item
id=
"3"
type=
"AND"
inCount=
"2"
/>
<item
id=
"4"
type=
"OR"
inCount=
"2"
/>
<item
id=
"5"
type=
"OR"
inCount=
"2"
/>
<item
id=
"6"
type=
"Delay"
inCount=
"1"
delayMS=
"3000"
/>
</elements>
<connections>
<item
type=
"ext"
from=
"Input1_S"
to=
"1"
toInput=
"1"
/>
<item
type=
"ext"
from=
"Input2_S"
to=
"1"
toInput=
"2"
/>
<item
type=
"ext"
from=
"Input3_S"
to=
"2"
toInput=
"1"
/>
<item
type=
"ext"
from=
"Input4_S"
to=
"2"
toInput=
"2"
/>
<item
type=
"ext"
from=
"Input5_S"
to=
"4"
toInput=
"2"
/>
<item
type=
"ext"
from=
"Input6_S"
to=
"5"
toInput=
"1"
/>
<item
type=
"int"
from=
"1"
to=
"3"
toInput=
"1"
/>
<item
type=
"int"
from=
"2"
to=
"3"
toInput=
"2"
/>
<item
type=
"int"
from=
"3"
to=
"4"
toInput=
"1"
/>
<item
type=
"int"
from=
"4"
to=
"5"
toInput=
"2"
/>
<item
type=
"int"
from=
"5"
to=
"6"
toInput=
"1"
/>
<item
type=
"out"
from=
"6"
to=
"TestMode_S"
/>
</connections>
</Schema>
extensions/LogicProcessor/unit-tests/tests.cc
0 → 100644
View file @
189567d1
#define CATCH_CONFIG_MAIN
#include <Catch/catch.hpp>
// не удивляйтесь, что тут нет main().. она спрятана в catch.cpp :)
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