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
078df423
Commit
078df423
authored
May 04, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LProcessor): небольшой рефакоринг
* getScheme() --> getSchema() * help_print() * init_plproc()
parent
347b73f5
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
31 deletions
+80
-31
LProcessor.h
extensions/LogicProcessor/LProcessor.h
+1
-2
Makefile.am
extensions/LogicProcessor/Makefile.am
+0
-1
PassiveLProcessor.cc
extensions/LogicProcessor/PassiveLProcessor.cc
+58
-1
PassiveLProcessor.h
extensions/LogicProcessor/PassiveLProcessor.h
+7
-1
plogicproc.cc
extensions/LogicProcessor/plogicproc.cc
+13
-25
lproc.cc
extensions/LogicProcessor/tests/lproc.cc
+1
-1
No files found.
extensions/LogicProcessor/LProcessor.h
View file @
078df423
...
...
@@ -112,12 +112,11 @@ class LProcessor
canceled
=
true
;
}
inline
std
::
shared_ptr
<
SchemaXML
>
getSchem
e
()
inline
std
::
shared_ptr
<
SchemaXML
>
getSchem
a
()
{
return
sch
;
}
inline
int
getSleepTime
()
{
return
sleepTime
;
...
...
extensions/LogicProcessor/Makefile.am
View file @
078df423
...
...
@@ -14,7 +14,6 @@ libUniSet2LProcessor_la_CXXFLAGS = -I$(top_builddir)/extensions/include \
libUniSet2LProcessor_la_SOURCES
=
Element.cc TOR.cc TAND.cc TDelay.cc TNOT.cc
\
Schema.cc SchemaXML.cc LProcessor.cc PassiveLProcessor.cc
bin_PROGRAMS
=
@PACKAGE@-logicproc @PACKAGE@-plogicproc
@PACKAGE@
_logicproc_SOURCES
=
logicproc.cc
...
...
extensions/LogicProcessor/PassiveLProcessor.cc
View file @
078df423
...
...
@@ -6,7 +6,7 @@ using namespace std;
using
namespace
UniSetTypes
;
using
namespace
UniSetExtensions
;
// -------------------------------------------------------------------------
PassiveLProcessor
::
PassiveLProcessor
(
std
::
string
lfile
,
UniSetTypes
::
ObjectId
objId
,
PassiveLProcessor
::
PassiveLProcessor
(
UniSetTypes
::
ObjectId
objId
,
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
,
const
std
::
string
&
prefix
)
:
UniSetObject_LT
(
objId
),
shm
(
nullptr
)
...
...
@@ -15,6 +15,25 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
logname
=
myname
;
shm
=
make_shared
<
SMInterface
>
(
shmID
,
UniSetObject_LT
::
ui
,
objId
,
ic
);
string
conf_name
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-confnode"
,
myname
));
xmlNode
*
confnode
=
conf
->
getNode
(
conf_name
);
if
(
confnode
==
NULL
)
throw
SystemError
(
"Not found conf-node for "
+
conf_name
);
UniXML
::
iterator
it
(
confnode
);
confnode
=
conf
->
getNode
(
myname
);
string
lfile
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-schema"
,
it
.
getProp
(
"schema"
));
if
(
lfile
.
empty
()
)
{
ostringstream
err
;
err
<<
myname
<<
"(init): Unknown schema file.. Use: --"
<<
prefix
+
"-schema"
;
throw
SystemError
(
err
.
str
());
}
build
(
lfile
);
// ********** HEARTBEAT *************
...
...
@@ -232,3 +251,41 @@ void PassiveLProcessor::sigterm( int signo )
}
}
// -------------------------------------------------------------------------
void
PassiveLProcessor
::
help_print
(
int
argc
,
const
char
*
const
*
argv
)
{
cout
<<
"Default: prefix='plproc'"
<<
endl
;
cout
<<
"--prefix-name name - ObjectID. По умолчанию: PassiveProcessor1"
<<
endl
;
cout
<<
"--prefix-confnode cnode - Возможность задать настроечный узел в configure.xml. По умолчанию: name"
<<
endl
;
cout
<<
endl
;
cout
<<
"--prefix-schema file - Файл с логической схемой."
<<
endl
;
cout
<<
"--prefix-heartbeat-id - Данный процесс связан с указанным аналоговым heartbeat-дачиком."
<<
endl
;
cout
<<
"--prefix-heartbeat-max - Максимальное значение heartbeat-счётчика для данного процесса. По умолчанию 10."
<<
endl
;
}
// -----------------------------------------------------------------------------
std
::
shared_ptr
<
PassiveLProcessor
>
PassiveLProcessor
::
init_plproc
(
int
argc
,
const
char
*
const
*
argv
,
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
,
const
std
::
string
&
prefix
)
{
auto
conf
=
uniset_conf
();
string
name
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-name"
,
"PassiveProcessor1"
);
if
(
name
.
empty
()
)
{
cerr
<<
"(plproc): Не задан name'"
<<
endl
;
return
0
;
}
ObjectId
ID
=
conf
->
getObjectID
(
name
);
if
(
ID
==
UniSetTypes
::
DefaultObjectId
)
{
cerr
<<
"(plproc): идентификатор '"
<<
name
<<
"' не найден в конф. файле!"
<<
" в секции "
<<
conf
->
getObjectsSection
()
<<
endl
;
return
0
;
}
dinfo
<<
"(plproc): name = "
<<
name
<<
"("
<<
ID
<<
")"
<<
endl
;
return
make_shared
<
PassiveLProcessor
>
(
ID
,
shmID
,
ic
,
prefix
);
}
extensions/LogicProcessor/PassiveLProcessor.h
View file @
078df423
...
...
@@ -18,7 +18,7 @@ class PassiveLProcessor:
{
public
:
PassiveLProcessor
(
std
::
string
schema
,
UniSetTypes
::
ObjectId
objId
,
PassiveLProcessor
(
UniSetTypes
::
ObjectId
objId
,
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
=
nullptr
,
const
std
::
string
&
prefix
=
"lproc"
);
virtual
~
PassiveLProcessor
();
...
...
@@ -27,6 +27,12 @@ class PassiveLProcessor:
tidStep
};
static
void
help_print
(
int
argc
,
const
char
*
const
*
argv
);
static
std
::
shared_ptr
<
PassiveLProcessor
>
init_plproc
(
int
argc
,
const
char
*
const
*
argv
,
UniSetTypes
::
ObjectId
shmID
,
const
std
::
shared_ptr
<
SharedMemory
>
ic
=
nullptr
,
const
std
::
string
&
prefix
=
"plproc"
);
protected
:
PassiveLProcessor
()
:
shm
(
0
),
maxHeartBeat
(
0
)
{};
...
...
extensions/LogicProcessor/plogicproc.cc
View file @
078df423
...
...
@@ -13,11 +13,21 @@ int main(int argc, const char** argv)
{
std
::
ios
::
sync_with_stdio
(
false
);
if
(
argc
>
1
&&
(
!
strcmp
(
argv
[
1
],
"--help"
)
||
!
strcmp
(
argv
[
1
],
"-h"
))
)
{
cout
<<
"--smemory-id objectName - SharedMemory objectID. Default: autodetect"
<<
endl
;
cout
<<
"--confile filename - configuration file. Default: configure.xml"
<<
endl
;
cout
<<
"--plproc-logfile filename - logfilename. Default: mbslave.log"
<<
endl
;
cout
<<
endl
;
PassiveLProcessor
::
help_print
(
argc
,
argv
);
return
0
;
}
try
{
auto
conf
=
uniset_init
(
argc
,
argv
);
string
logfilename
(
conf
->
getArgParam
(
"--
logic
proc-logfile"
));
string
logfilename
(
conf
->
getArgParam
(
"--
pl
proc-logfile"
));
if
(
logfilename
.
empty
()
)
logfilename
=
"logicproc.log"
;
...
...
@@ -50,32 +60,10 @@ int main(int argc, const char** argv)
return
1
;
}
cout
<<
"init smemory: "
<<
sID
<<
" ID: "
<<
shmID
<<
endl
;
string
name
=
conf
->
getArgParam
(
"--name"
,
"LProcessor"
);
if
(
name
.
empty
()
)
{
cerr
<<
"(plogicproc): Не задан name'"
<<
endl
;
return
1
;
}
ObjectId
ID
=
conf
->
getObjectID
(
name
);
if
(
ID
==
UniSetTypes
::
DefaultObjectId
)
{
cerr
<<
"(plogicproc): идентификатор '"
<<
name
<<
"' не найден в конф. файле!"
<<
" в секции "
<<
conf
->
getObjectsSection
()
<<
endl
;
return
1
;
}
cout
<<
"init name: "
<<
name
<<
" ID: "
<<
ID
<<
endl
;
PassiveLProcessor
plc
(
schema
,
ID
,
shmID
);
auto
plp
=
PassiveLProcessor
::
init_plproc
(
argc
,
argv
,
shmID
);
auto
act
=
UniSetActivator
::
Instance
();
act
->
add
(
pl
c
.
get_ptr
()
);
act
->
add
(
pl
p
);
SystemMessage
sm
(
SystemMessage
::
StartUp
);
act
->
broadcast
(
sm
.
transport_msg
()
);
...
...
extensions/LogicProcessor/tests/lproc.cc
View file @
078df423
...
...
@@ -176,7 +176,7 @@ TEST_CASE("Logic processor: lp", "[LogicProcessor][logic]")
LPRunner
p
;
auto
lp
=
p
.
get
();
auto
sch
=
lp
->
getSchem
e
();
auto
sch
=
lp
->
getSchem
a
();
CHECK
(
sch
!=
nullptr
);
...
...
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