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
4a473ce4
Commit
4a473ce4
authored
Dec 15, 2013
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил простой тест для проверки работы SMemory и TestProc
parent
daa36794
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
212 additions
and
8 deletions
+212
-8
test.xml
conf/test.xml
+7
-0
configure.ac
configure.ac
+1
-0
Makefile.am
extensions/tests/Makefile.am
+2
-0
Makefile.am
extensions/tests/SMemoryTest/Makefile.am
+17
-0
TestProc.cc
extensions/tests/SMemoryTest/TestProc.cc
+47
-0
TestProc.h
extensions/tests/SMemoryTest/TestProc.h
+31
-0
smemory-test.cc
extensions/tests/SMemoryTest/smemory-test.cc
+68
-0
start_fg.sh
extensions/tests/SMemoryTest/start_fg.sh
+5
-0
test.xml
extensions/tests/SMemoryTest/test.xml
+2
-0
testproc.src.xml
extensions/tests/SMemoryTest/testproc.src.xml
+29
-0
UniversalInterface.h
include/UniversalInterface.h
+0
-4
ui.cc
tests/ui.cc
+3
-4
No files found.
conf/test.xml
View file @
4a473ce4
...
@@ -33,6 +33,11 @@
...
@@ -33,6 +33,11 @@
</UniSet>
</UniSet>
<dlog
name=
"dlog"
/>
<dlog
name=
"dlog"
/>
<settings>
<settings>
<TestProc
name=
"TestProc"
on_s=
"Input1_S"
lamp_c=
"Lamp58_C"
/>
<IOControl
name=
"IOControl"
/>
<IOControl
name=
"IOControl"
/>
<testnode
id=
"1000"
id2=
"-100"
name=
"testnode"
/>
<testnode
id=
"1000"
id2=
"-100"
name=
"testnode"
/>
<SharedMemory
name=
"SharedMemory"
shmID=
"SharedMemory"
>
<SharedMemory
name=
"SharedMemory"
shmID=
"SharedMemory"
>
...
@@ -207,6 +212,7 @@
...
@@ -207,6 +212,7 @@
<item
id=
"55"
iotype=
"AI"
name=
"AI55_S"
textname=
"AI sensor 55"
rrd=
"1"
rrd1_ds=
"GAUGE:20:U:U"
/>
<item
id=
"55"
iotype=
"AI"
name=
"AI55_S"
textname=
"AI sensor 55"
rrd=
"1"
rrd1_ds=
"GAUGE: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=
"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"
/>
</sensors>
</sensors>
<thresholds
name=
"thresholds"
>
<thresholds
name=
"thresholds"
>
<sensor
iotype=
"AI"
name=
"AI_AS"
>
<sensor
iotype=
"AI"
name=
"AI_AS"
>
...
@@ -244,6 +250,7 @@
...
@@ -244,6 +250,7 @@
<item
id=
"6009"
name=
"MBMaster2"
/>
<item
id=
"6009"
name=
"MBMaster2"
/>
<item
id=
"6010"
name=
"MBMultiMaster1"
/>
<item
id=
"6010"
name=
"MBMultiMaster1"
/>
<item
id=
"6011"
name=
"RRDServer1"
/>
<item
id=
"6011"
name=
"RRDServer1"
/>
<item
id=
"6012"
name=
"TestProc"
/>
</objects>
</objects>
</ObjectsMap>
</ObjectsMap>
<messages
idfromfile=
"1"
name=
"messages"
>
<messages
idfromfile=
"1"
name=
"messages"
>
...
...
configure.ac
View file @
4a473ce4
...
@@ -260,6 +260,7 @@ AC_CONFIG_FILES([Makefile
...
@@ -260,6 +260,7 @@ AC_CONFIG_FILES([Makefile
extensions/RRDServer/Makefile
extensions/RRDServer/Makefile
extensions/RRDServer/libUniSetRRDServer.pc
extensions/RRDServer/libUniSetRRDServer.pc
extensions/tests/Makefile
extensions/tests/Makefile
extensions/tests/SMemoryTest/Makefile
python/lib/Makefile
python/lib/Makefile
python/lib/pyUniSet/Makefile
python/lib/pyUniSet/Makefile
python/Makefile])
python/Makefile])
...
...
extensions/tests/Makefile.am
View file @
4a473ce4
SUBDIR
=
SMemoryTest
noinst_PROGRAMS
=
calibration
noinst_PROGRAMS
=
calibration
calibration_SOURCES
=
calibration.cc
calibration_SOURCES
=
calibration.cc
...
...
extensions/tests/SMemoryTest/Makefile.am
0 → 100644
View file @
4a473ce4
noinst_PROGRAMS
=
smemory-test
smemory_test_LDADD
=
$(top_builddir)
/lib/libUniSet.la
\
$(top_builddir)
/extensions/lib/libUniSetExtensions.la
\
$(top_builddir)
/extensions/SharedMemory/libUniSetSharedMemory.la
\
$(SIGC_LIBS)
smemory_test_CPPFLAGS
=
-I
$(top_builddir)
/include
\
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/SharedMemory
\
$(SIGC_CFLAGS)
smemory_test_SOURCES
=
TestProc_SK.cc TestProc.cc smemory-test.cc
TestProc_SK.cc
:
testproc.src.xml
# ./uniset-codegen --ask -n TestProc --local-include --topdir $(top_builddir)/ --no-main testproc.src.xml
$(top_builddir)/Utilities/codegen/@PACKAGE@-codegen
-l
$(top_builddir)/Utilities/codegen
--ask
-n
TestProc
--local-include
--topdir
$(top_builddir)/
--no-main
testproc.src.xml
clean-local
:
rm
-rf
*
_SK.cc
*
_SK.h
extensions/tests/SMemoryTest/TestProc.cc
0 → 100644
View file @
4a473ce4
#include "Exceptions.h"
#include "TestProc.h"
// -----------------------------------------------------------------------------
using
namespace
std
;
using
namespace
UniSetTypes
;
// -----------------------------------------------------------------------------
TestProc
::
TestProc
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
confnode
)
:
TestProc_SK
(
id
,
confnode
),
state
(
false
)
{
}
// -----------------------------------------------------------------------------
TestProc
::~
TestProc
()
{
}
// -----------------------------------------------------------------------------
TestProc
::
TestProc
()
:
state
(
false
)
{
cerr
<<
": init failed!!!!!!!!!!!!!!!"
<<
endl
;
throw
Exception
();
}
// -----------------------------------------------------------------------------
void
TestProc
::
step
()
{
}
// -----------------------------------------------------------------------------
void
TestProc
::
sensorInfo
(
SensorMessage
*
sm
)
{
if
(
sm
->
id
==
on_s
)
{
if
(
sm
->
value
)
askTimer
(
tmChange
,
changeTime
);
}
}
// -----------------------------------------------------------------------------
void
TestProc
::
timerInfo
(
TimerMessage
*
tm
)
{
if
(
tm
->
id
==
tmChange
)
{
state
^=
true
;
out_lamp_c
=
(
state
?
lmpBLINK
:
lmpOFF
);
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(timerInfo): state="
<<
state
<<
" lmp="
<<
out_lamp_c
<<
endl
;
}
}
// -----------------------------------------------------------------------------
extensions/tests/SMemoryTest/TestProc.h
0 → 100644
View file @
4a473ce4
// -----------------------------------------------------------------------------
#ifndef TestProc_H_
#define TestProc_H_
// -----------------------------------------------------------------------------
#include "TestProc_SK.h"
// -----------------------------------------------------------------------------
class
TestProc
:
public
TestProc_SK
{
public
:
TestProc
(
UniSetTypes
::
ObjectId
id
,
xmlNode
*
confnode
=
UniSetTypes
::
conf
->
getNode
(
"TestProc"
)
);
virtual
~
TestProc
();
protected
:
TestProc
();
enum
Timers
{
tmChange
};
virtual
void
step
();
void
sensorInfo
(
UniSetTypes
::
SensorMessage
*
sm
);
void
timerInfo
(
UniSetTypes
::
TimerMessage
*
tm
);
private
:
bool
state
;
};
// -----------------------------------------------------------------------------
#endif // TestProc_H_
// -----------------------------------------------------------------------------
extensions/tests/SMemoryTest/smemory-test.cc
0 → 100644
View file @
4a473ce4
#include <string>
#include "Debug.h"
#include "ObjectsActivator.h"
#include "SharedMemory.h"
#include "Extensions.h"
#include "TestProc.h"
// --------------------------------------------------------------------------
using
namespace
std
;
using
namespace
UniSetTypes
;
using
namespace
UniSetExtensions
;
// --------------------------------------------------------------------------
int
main
(
int
argc
,
const
char
**
argv
)
{
if
(
argc
>
1
&&
(
strcmp
(
argv
[
1
],
"--help"
)
==
0
||
strcmp
(
argv
[
1
],
"-h"
)
==
0
)
)
{
cout
<<
"--confile - Использовать указанный конф. файл. По умолчанию configure.xml"
<<
endl
;
SharedMemory
::
help_print
(
argc
,
argv
);
return
0
;
}
try
{
string
confile
=
UniSetTypes
::
getArgParam
(
"--confile"
,
argc
,
argv
,
"configure.xml"
);
conf
=
new
Configuration
(
argc
,
argv
,
confile
);
conf
->
initDebug
(
dlog
,
"dlog"
);
string
logfilename
=
conf
->
getArgParam
(
"--logfile"
,
"smemory.log"
);
string
logname
(
conf
->
getLogDir
()
+
logfilename
);
unideb
.
logFile
(
logname
);
dlog
.
logFile
(
logname
);
SharedMemory
*
shm
=
SharedMemory
::
init_smemory
(
argc
,
argv
);
if
(
!
shm
)
return
1
;
TestProc
tp
(
conf
->
getObjectID
(
"TestProc"
));
tp
.
init_dlog
(
dlog
);
ObjectsActivator
act
;
act
.
addObject
(
static_cast
<
class
UniSetObject
*>
(
shm
));
act
.
addObject
(
static_cast
<
class
UniSetObject
*>
(
&
tp
));
SystemMessage
sm
(
SystemMessage
::
StartUp
);
act
.
broadcast
(
sm
.
transport_msg
()
);
act
.
run
(
false
);
return
0
;
}
catch
(
SystemError
&
err
)
{
unideb
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
err
<<
endl
;
}
catch
(
Exception
&
ex
)
{
unideb
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
ex
<<
endl
;
}
catch
(
std
::
exception
&
e
)
{
unideb
[
Debug
::
CRIT
]
<<
"(smemory): "
<<
e
.
what
()
<<
endl
;
}
catch
(...)
{
unideb
[
Debug
::
CRIT
]
<<
"(smemory): catch(...)"
<<
endl
;
}
return
1
;
}
extensions/tests/SMemoryTest/start_fg.sh
0 → 100755
View file @
4a473ce4
#!/bin/sh
START
=
uniset-start.sh
${
START
}
-f
./smemory-test
--confile
test.xml
--dlog-add-levels
any
--unideb-add-levels
system
--localNode
LocalhostNode
extensions/tests/SMemoryTest/test.xml
0 → 120000
View file @
4a473ce4
../../../conf/test.xml
\ No newline at end of file
extensions/tests/SMemoryTest/testproc.src.xml
0 → 100644
View file @
4a473ce4
<?xml version="1.0" encoding="utf-8"?>
<!--
name - название класса
msgcount - сколько сообщений обрабатывается за один раз
sleep_msec - пауза между итерациями в работе процесса
type
====
in - входные регистры (только для чтения)
out - выходные регистры (запись)
-->
<TestProc>
<settings>
<set
name=
"class-name"
val=
"TestProc"
/>
<set
name=
"msg-count"
val=
"30"
/>
<set
name=
"sleep-msec"
val=
"150"
/>
</settings>
<variables>
<item
name=
"changeTime"
type=
"int"
default=
"2000"
min=
"0"
comment=
"change state time"
const=
"1"
public=
"1"
/>
</variables>
<smap>
<!-- name - название переменной в конф. файле -->
<item
name=
"on_s"
vartype=
"in"
comment=
"Тестовый вход"
smTestID=
"1"
/>
<item
name=
"lamp_c"
vartype=
"out"
comment=
"Лампочка (тестовый выход)"
/>
</smap>
<msgmap>
</msgmap>
</TestProc>
include/UniversalInterface.h
View file @
4a473ce4
...
@@ -87,8 +87,6 @@ class UniversalInterface
...
@@ -87,8 +87,6 @@ class UniversalInterface
//! Заказ по списку
//! Заказ по списку
UniSetTypes
::
IDSeq_var
askSensorsSeq
(
UniSetTypes
::
IDList
&
lst
,
UniversalIO
::
UIOCommand
cmd
,
UniSetTypes
::
IDSeq_var
askSensorsSeq
(
UniSetTypes
::
IDList
&
lst
,
UniversalIO
::
UIOCommand
cmd
,
UniSetTypes
::
ObjectId
backid
=
UniSetTypes
::
DefaultObjectId
);
UniSetTypes
::
ObjectId
backid
=
UniSetTypes
::
DefaultObjectId
);
// ------------------------------------------------------
// ------------------------------------------------------
//! Получение состояния датчика
//! Получение состояния датчика
long
getValue
(
UniSetTypes
::
ObjectId
id
,
UniSetTypes
::
ObjectId
node
)
throw
(
IO_THROW_EXCEPTIONS
);
long
getValue
(
UniSetTypes
::
ObjectId
id
,
UniSetTypes
::
ObjectId
node
)
throw
(
IO_THROW_EXCEPTIONS
);
...
@@ -98,13 +96,11 @@ class UniversalInterface
...
@@ -98,13 +96,11 @@ class UniversalInterface
void
setValue
(
UniSetTypes
::
ObjectId
id
,
long
value
,
UniSetTypes
::
ObjectId
node
)
throw
(
IO_THROW_EXCEPTIONS
);
void
setValue
(
UniSetTypes
::
ObjectId
id
,
long
value
,
UniSetTypes
::
ObjectId
node
)
throw
(
IO_THROW_EXCEPTIONS
);
void
setValue
(
UniSetTypes
::
ObjectId
id
,
long
value
);
void
setValue
(
UniSetTypes
::
ObjectId
id
,
long
value
);
void
setValue
(
IOController_i
::
SensorInfo
&
si
,
long
value
,
UniSetTypes
::
ObjectId
supplier
);
void
setValue
(
IOController_i
::
SensorInfo
&
si
,
long
value
,
UniSetTypes
::
ObjectId
supplier
);
void
fastSetValue
(
IOController_i
::
SensorInfo
&
si
,
long
value
,
UniSetTypes
::
ObjectId
supplier
);
void
fastSetValue
(
IOController_i
::
SensorInfo
&
si
,
long
value
,
UniSetTypes
::
ObjectId
supplier
);
// установка неопределённого состояния
// установка неопределённого состояния
void
setUndefinedState
(
IOController_i
::
SensorInfo
&
si
,
bool
undefined
,
UniSetTypes
::
ObjectId
supplier
);
void
setUndefinedState
(
IOController_i
::
SensorInfo
&
si
,
bool
undefined
,
UniSetTypes
::
ObjectId
supplier
);
CORBA
::
Long
getRawValue
(
const
IOController_i
::
SensorInfo
&
si
);
CORBA
::
Long
getRawValue
(
const
IOController_i
::
SensorInfo
&
si
);
//! калибровка
//! калибровка
...
...
tests/ui.cc
View file @
4a473ce4
...
@@ -50,11 +50,10 @@ int main( int argc, const char **argv )
...
@@ -50,11 +50,10 @@ int main( int argc, const char **argv )
<<
" value="
<<
inf
.
value
<<
" value="
<<
inf
.
value
<<
" last changed: "
<<
string
(
t_str
)
<<
endl
;
<<
" last changed: "
<<
string
(
t_str
)
<<
endl
;
cout
<<
"check getValue: "
<<
ui
.
getValue
(
id1
)
<<
endl
;
cout
<<
"check getValue: "
<<
ui
.
getValue
(
id1
)
<<
endl
;
cout
<<
"check setValue: id='"
<<
id1
<<
"' val=2
"
<<
endl
;
cout
<<
"check setValue: id='"
<<
id1
<<
"' val=2
..."
;
ui
.
setValue
(
id1
,
2
,
DefaultObjectId
);
ui
.
setValue
(
id1
,
2
);
cout
<<
"OK"
<<
endl
;
cout
<<
(
ui
.
getValue
(
id1
)
==
2
?
"OK"
:
"FAIL"
)
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
...
...
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