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
9020f80b
Commit
9020f80b
authored
Aug 06, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(IOC): рефакторинг: избавление от лишнего кода
(не пригодившийся механизм IOFilter)
parent
f025a2f7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
3 additions
and
92 deletions
+3
-92
IOController.h
include/IOController.h
+0
-29
IONotifyController.h
include/IONotifyController.h
+0
-3
IOController.cc
src/Processes/IOController.cc
+3
-46
IONotifyController.cc
src/Processes/IONotifyController.cc
+0
-14
No files found.
include/IOController.h
View file @
9020f80b
...
...
@@ -231,33 +231,6 @@ class IOController:
IOStateList
::
iterator
myioEnd
();
IOStateList
::
iterator
myiofind
(
UniSetTypes
::
ObjectId
id
);
// --------------------------
// ФИЛЬТРОВАНИЕ
//
typedef
sigc
::
slot
<
bool
,
std
::
shared_ptr
<
USensorInfo
>&
,
CORBA
::
Long
,
UniSetTypes
::
ObjectId
>
IOFilterSlot
;
typedef
std
::
list
<
IOFilterSlot
>
IOFilterSlotList
;
/*
Фильтрующая функция должна возвращать:
TRUE - если значение 'нормальное'
FALSE - если значение не подходит (отбрасывается)
Пример использования:
addIOFilter( sigc::mem_fun(my,&MyClass::my_filter) );
*/
IOFilterSlotList
::
iterator
addIOFilter
(
IOFilterSlot
sl
,
bool
push_front
=
false
);
void
eraseIOFilter
(
IOFilterSlotList
::
iterator
&
it
);
// функии проверки текущего значения
bool
checkIOFilters
(
std
::
shared_ptr
<
USensorInfo
>&
ai
,
CORBA
::
Long
&
newvalue
,
UniSetTypes
::
ObjectId
sup_id
);
inline
bool
iofiltersEmpty
()
const
{
return
iofilters
.
empty
();
}
inline
int
iodiltersSize
()
const
{
return
iofilters
.
size
();
}
private
:
friend
class
NCRestorer
;
...
...
@@ -274,8 +247,6 @@ class IOController:
bool
isPingDBServer
;
// флаг связи с DBServer-ом
IOFilterSlotList
iofilters
;
/*!< список фильтров для аналоговых значений */
UniSetTypes
::
uniset_rwmutex
loggingMutex
;
/*!< logging info mutex */
public
:
...
...
include/IONotifyController.h
View file @
9020f80b
...
...
@@ -275,9 +275,6 @@ class IONotifyController:
virtual
bool
activateObject
()
override
;
virtual
void
initItem
(
IOStateList
::
iterator
&
it
,
IOController
*
ic
);
// ФИЛЬТРЫ
bool
myIOFilter
(
std
::
shared_ptr
<
USensorInfo
>&
ai
,
CORBA
::
Long
newvalue
,
UniSetTypes
::
ObjectId
sup_id
);
//! посылка информации об изменении состояния датчика
virtual
void
send
(
ConsumerListInfo
&
lst
,
UniSetTypes
::
SensorMessage
&
sm
);
...
...
src/Processes/IOController.cc
View file @
9020f80b
...
...
@@ -285,11 +285,10 @@ void IOController::localSetValue( std::shared_ptr<USensorInfo>& usi,
usi
->
supplier
=
sup_id
;
// запоминаем того кто изменил
// фильтрам может потребоваться измениять исходное значение (например для усреднения)
// поэтому передаём (и затем сохраняем) напрямую(ссылку) value (а не const value)
bool
blocked
=
(
usi
->
blocked
||
usi
->
undefined
);
changed
=
(
usi
->
value
!=
value
);
if
(
ch
eckIOFilters
(
usi
,
value
,
sup_id
)
||
blocked
)
if
(
ch
anged
||
blocked
)
{
ulog4
<<
myname
<<
": save sensor value ("
<<
sid
<<
")"
<<
" name: "
<<
uniset_conf
()
->
oind
->
getNameById
(
sid
)
...
...
@@ -299,20 +298,8 @@ void IOController::localSetValue( std::shared_ptr<USensorInfo>& usi,
<<
" real_value="
<<
usi
->
real_value
<<
endl
;
CORBA
::
Long
prev
=
usi
->
value
;
if
(
blocked
)
{
usi
->
real_value
=
value
;
usi
->
value
=
usi
->
d_off_value
;
}
else
{
usi
->
value
=
value
;
usi
->
real_value
=
value
;
}
changed
=
(
prev
!=
usi
->
value
);
usi
->
value
=
(
blocked
?
usi
->
d_off_value
:
value
);
// запоминаем время изменения
struct
timeval
tm
=
{
0
};
...
...
@@ -641,36 +628,6 @@ void IOController::USensorInfo::init( const IOController_i::SensorIOInfo& s )
(
*
this
)
=
std
::
move
(
r
);
}
// ----------------------------------------------------------------------------------------
bool
IOController
::
checkIOFilters
(
std
::
shared_ptr
<
USensorInfo
>&
usi
,
CORBA
::
Long
&
newvalue
,
UniSetTypes
::
ObjectId
sup_id
)
{
for
(
const
auto
&
it
:
iofilters
)
{
if
(
it
(
usi
,
newvalue
,
sup_id
)
==
false
)
return
false
;
}
return
true
;
}
// ----------------------------------------------------------------------------------------
IOController
::
IOFilterSlotList
::
iterator
IOController
::
addIOFilter
(
IOFilterSlot
sl
,
bool
push_front
)
{
if
(
push_front
==
false
)
{
iofilters
.
push_back
(
sl
);
return
--
iofilters
.
end
();
}
iofilters
.
push_front
(
sl
);
return
iofilters
.
begin
();
}
// ----------------------------------------------------------------------------------------
void
IOController
::
eraseIOFilter
(
IOController
::
IOFilterSlotList
::
iterator
&
it
)
{
iofilters
.
erase
(
it
);
}
// ----------------------------------------------------------------------------------------
IOController
::
IOStateList
::
iterator
IOController
::
myioBegin
()
{
return
ioList
.
begin
();
...
...
src/Processes/IONotifyController.cc
View file @
9020f80b
...
...
@@ -50,8 +50,6 @@ IONotifyController::IONotifyController(const string& name, const string& section
trshMutex
(
name
+
"trshMutex"
),
maxAttemtps
(
uniset_conf
()
->
getPIntField
(
"ConsumerMaxAttempts"
,
5
))
{
// добавляем фильтры
addIOFilter
(
sigc
::
mem_fun
(
this
,
&
IONotifyController
::
myIOFilter
)
);
}
IONotifyController
::
IONotifyController
(
ObjectId
id
,
std
::
shared_ptr
<
NCRestorer
>
d
)
:
...
...
@@ -63,9 +61,6 @@ IONotifyController::IONotifyController( ObjectId id, std::shared_ptr<NCRestorer>
{
conUndef
=
signal_change_undefined_state
().
connect
(
sigc
::
mem_fun
(
*
this
,
&
IONotifyController
::
onChangeUndefinedState
));
conInit
=
signal_init
().
connect
(
sigc
::
mem_fun
(
*
this
,
&
IONotifyController
::
initItem
));
// добавляем фильтры
addIOFilter
(
sigc
::
mem_fun
(
this
,
&
IONotifyController
::
myIOFilter
)
);
}
IONotifyController
::~
IONotifyController
()
...
...
@@ -266,15 +261,6 @@ void IONotifyController::ask( AskMap& askLst, const UniSetTypes::ObjectId sid,
}
}
// ------------------------------------------------------------------------------------------
bool
IONotifyController
::
myIOFilter
(
std
::
shared_ptr
<
USensorInfo
>&
usi
,
CORBA
::
Long
newvalue
,
UniSetTypes
::
ObjectId
sup_id
)
{
if
(
usi
->
value
==
newvalue
)
return
false
;
return
true
;
}
// ------------------------------------------------------------------------------------------
void
IONotifyController
::
localSetValue
(
std
::
shared_ptr
<
IOController
::
USensorInfo
>&
usi
,
UniSetTypes
::
ObjectId
sid
,
CORBA
::
Long
value
,
UniSetTypes
::
ObjectId
sup_id
)
...
...
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