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
7345c868
Commit
7345c868
authored
Dec 18, 2013
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(2.0): переписал интерфейс работы с парогами.
parent
6886264f
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
285 additions
and
99 deletions
+285
-99
IOController_i.idl
IDL/Processes/IOController_i.idl
+25
-14
libuniset.spec
conf/libuniset.spec
+1
-0
IOControl.cc
extensions/IOControl/IOControl.cc
+1
-0
IOControl.h
extensions/IOControl/IOControl.h
+0
-1
IOBase.cc
extensions/lib/IOBase.cc
+2
-7
TestProc.cc
extensions/tests/SMemoryTest/TestProc.cc
+19
-0
testproc.src.xml
extensions/tests/SMemoryTest/testproc.src.xml
+0
-1
IONotifyController.h
include/IONotifyController.h
+29
-9
MessageType.h
include/MessageType.h
+1
-1
UInterface.h
include/UInterface.h
+6
-4
UInterface.cc
src/Interfaces/UInterface.cc
+85
-4
IONotifyController.cc
src/Processes/IONotifyController.cc
+114
-56
NCRestorer_XML.cc
src/Processes/NCRestorer_XML.cc
+2
-2
No files found.
IDL/Processes/IOController_i.idl
View file @
7345c868
...
...
@@ -185,18 +185,6 @@ interface IONotifyController_i : IOController_i
*/
void
askSensor
(
in
SensorInfo
si
,
in
UniSetTypes
::
ConsumerInfo
ci
,
in
UniversalIO
::
UIOCommand
cmd
)
raises
(
NameNotFound
,
IOBadParam
)
;
/*
!
Заказ
порогового
датчика
*
\
sa
UniversalIO
::
UniversalIOController
::
askThreshold
()
*
\
param
tid
-
идентификатор
порога
*
\
param
lowLimit
-
нижний
порог
срабатыания
*
\
param
hiLimit
-
верхний
порог
срабатывания
*
*
Датчик
срабатывает
при
условии
,
что
значение
<=
lowLimit
или
>=
hiLimit
*/
void
askThreshold
(
in
SensorInfo
si
,
in
UniSetTypes
::
ConsumerInfo
ci
,
in
UniSetTypes
::
ThresholdId
tid
,
in
long
lowLimit
,
in
long
hiLimit
,
in
UniversalIO
::
UIOCommand
cmd
)
raises
(
NameNotFound
,
IOBadParam
,
BadRange
)
;
/*
!
Заказ
сразу
списка
объектов.
\
return
Возвращает
список
объектов
заказ
по
котором
не
прошёл.
...
...
@@ -207,6 +195,7 @@ interface IONotifyController_i : IOController_i
in
UniversalIO
::
UIOCommand
cmd
)
;
/*
!
Состояние
порогового
датчика
*/
enum
ThresholdState
{
...
...
@@ -223,11 +212,29 @@ interface IONotifyController_i : IOController_i
ThresholdState
state
;
long
tv_sec
; /*!< время последнего изменения датчика, секунды (gettimeofday) */
long
tv_usec
; /*!< время последнего изменения датчика, мксек (gettimeofday) */
boolean
inver
se
; /*!< инверс
ная логика */
boolean
inver
t
; /*!< инвертирован
ная логика */
}
;
typedef
sequence
<
ThresholdInfo
>
ThresholdInfoSeq
;
/*
!
Заказ
порогового
датчика
*
\
sa
UniversalIO
::
UniversalIOController
::
askThreshold
()
*
\
param
tid
-
идентификатор
порога
*
\
param
lowLimit
-
нижний
порог
срабатыания
*
\
param
hiLimit
-
верхний
порог
срабатывания
*
\
param
invert
-
инвертировать
логику
срабатывания
*
Если
invert
=
false
,
порог
срабатывает
при
условии
>=
hilimit
и
отпускается
при
<=
lowlimit
*
Если
invert
=
true
,
порог
срабатывает
при
условии
<=
lowlimit
и
отпускается
при
<=
hilimit
*/
void
askThreshold
(
in
SensorInfo
si
,
in
UniSetTypes
::
ConsumerInfo
ci
,
in
UniSetTypes
::
ThresholdId
tid
,
in
long
lowLimit
,
in
long
hiLimit
,
in
boolean
invert
,
in
UniversalIO
::
UIOCommand
cmd
)
raises
(
NameNotFound
,
IOBadParam
,
BadRange
)
;
/*
!
Получение
информации
о
пороге
*
Т.к.
пороги
могут
иметь
одинаковый
tid
для
разных
аналоговых
датчиков
,
то
передаётся
и
SensorInfo
*/
ThresholdInfo
getThresholdInfo
(
in
SensorInfo
si
,
in
UniSetTypes
::
ThresholdId
tid
)
raises
(
NameNotFound
)
;
struct
ThresholdList
{
...
...
@@ -238,8 +245,12 @@ interface IONotifyController_i : IOController_i
}
;
typedef
sequence
<
ThresholdList
>
ThresholdsListSeq
;
ThresholdsListSeq
getThresholdsList
()
;
/*
!
получить
список
порогов
для
датчка
"si"
*/
ThresholdList
getThresholds
(
in
SensorInfo
si
)
raises
(
NameNotFound
)
;
/*
!
получить
список
ВСЕХ
датчиков
по
которым
созданы
пороги
*/
ThresholdsListSeq
getThresholdsList
()
;
}
;
//
--------------------------------------------------------------------------
#
endif
conf/libuniset.spec
View file @
7345c868
...
...
@@ -359,6 +359,7 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
- ObjectsManager --> UniSetManager
- ObjectsActitvator --> UniSetActivator
- remove deprecated property: "sensebility"
- rename property "inverse" --> "threshold_invert"
* Tue Dec 10 2013 Pavel Vainerman <pv@altlinux.ru> 1.7-alt3
- add RRDServer
...
...
extensions/IOControl/IOControl.cc
View file @
7345c868
...
...
@@ -1559,6 +1559,7 @@ void IOControl::waitSM()
err
<<
myname
<<
"(execute): did not wait for the ready 'SharedMemory'. Timeout "
<<
smReadyTimeout
<<
" msec"
;
if
(
dlog
.
is_crit
()
)
dlog
.
crit
()
<<
err
.
str
()
<<
endl
;
throw
SystemError
(
err
.
str
());
}
...
...
extensions/IOControl/IOControl.h
View file @
7345c868
...
...
@@ -312,7 +312,6 @@ class IOControl:
CardList
cards
;
/*!< список карт - массив созданных ComediInterface */
bool
noCards
;
typedef
std
::
vector
<
IOInfo
>
IOMap
;
IOMap
iomap
;
/*!< список входов/выходов */
...
...
extensions/lib/IOBase.cc
View file @
7345c868
...
...
@@ -353,7 +353,7 @@ void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force )
// cout << "val=" << val << " set=" << set << endl;
// Проверка нижнего предела
// значение должно быть меньше lowLimit-чуствительность
if
(
it
->
ti
.
inver
se
)
if
(
it
->
ti
.
inver
t
)
{
if
(
val
<=
it
->
ti
.
lowlimit
)
set
=
true
;
...
...
@@ -540,14 +540,9 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
b
->
ti
.
lowlimit
=
it
.
getIntProp
(
"lowlimit"
);
b
->
ti
.
hilimit
=
it
.
getIntProp
(
"hilimit"
);
b
->
ti
.
inver
se
=
it
.
getIntProp
(
"inverse
"
);
b
->
ti
.
inver
t
=
it
.
getIntProp
(
"threshold_invert
"
);
}
}
// else
// {
// dlog.crit() << myname << "(IOBase::readItem): неизвестный iotype=: " << stype << " для " << sname << endl;
// return false;
// }
return
true
;
}
...
...
extensions/tests/SMemoryTest/TestProc.cc
View file @
7345c868
...
...
@@ -126,5 +126,24 @@ void TestProc::test_thresholds()
setValue
(
t_set_c
,
378
);
dlog
.
level1
()
<<
myname
<<
": check threshold ON value: "
<<
(
getValue
(
t_check_s
)
==
1
?
"OK"
:
"FAIL"
)
<<
endl
;
dlog
.
level1
()
<<
myname
<<
": ask threshold and check.. "
<<
endl
;
try
{
setValue
(
t_set_c
,
0
);
UniSetTypes
::
ThresholdId
tid
=
100
;
ui
.
askThreshold
(
t_set_c
,
tid
,
UniversalIO
::
UIONotify
,
10
,
20
);
IONotifyController_i
::
ThresholdInfo
ti
=
ui
.
getThresholdInfo
(
t_set_c
,
tid
);
dlog
.
level1
()
<<
myname
<<
": ask OFF threshold: "
<<
(
ti
.
state
==
IONotifyController_i
::
NormalThreshold
?
"OK"
:
"FAIL"
)
<<
endl
;
setValue
(
t_set_c
,
25
);
ti
=
ui
.
getThresholdInfo
(
t_set_c
,
tid
);
dlog
.
level1
()
<<
myname
<<
": ask ON threshold: "
<<
(
ti
.
state
==
IONotifyController_i
::
HiThreshold
?
"OK"
:
"FAIL"
)
<<
endl
;
}
catch
(
Exception
&
ex
)
{
dlog
.
level2
()
<<
myname
<<
": CHE 'ask and get threshold' FAILED: "
<<
ex
<<
endl
;
}
}
// -----------------------------------------------------------------------------
extensions/tests/SMemoryTest/testproc.src.xml
View file @
7345c868
...
...
@@ -39,7 +39,6 @@
<!-- проверка работы threshold-ов -->
<item
name=
"t_set_c"
vartype=
"out"
comment=
"аналоговый датчик (для выставления порога)"
/>
<item
name=
"t_check_s"
vartype=
"in"
comment=
"датчик для проверки срабатывания"
/>
</smap>
<msgmap>
...
...
include/IONotifyController.h
View file @
7345c868
...
...
@@ -142,17 +142,24 @@ class IONotifyController:
virtual
void
askThreshold
(
const
IOController_i
::
SensorInfo
&
si
,
const
UniSetTypes
::
ConsumerInfo
&
ci
,
UniSetTypes
::
ThresholdId
tid
,
CORBA
::
Long
lowLimit
,
CORBA
::
Long
hiLimit
,
UniversalIO
::
UIOCommand
cmd
);
CORBA
::
Long
lowLimit
,
CORBA
::
Long
hiLimit
,
CORBA
::
Boolean
invert
,
UniversalIO
::
UIOCommand
cmd
);
virtual
IONotifyController_i
::
ThresholdInfo
getThresholdInfo
(
const
IOController_i
::
SensorInfo
&
si
,
UniSetTypes
::
ThresholdId
tid
);
virtual
IONotifyController_i
::
ThresholdList
*
getThresholds
(
const
IOController_i
::
SensorInfo
&
si
);
virtual
IONotifyController_i
::
ThresholdsListSeq
*
getThresholdsList
();
virtual
UniSetTypes
::
IDSeq
*
askSensorsSeq
(
const
UniSetTypes
::
IDSeq
&
lst
,
const
UniSetTypes
::
ConsumerInfo
&
ci
,
UniversalIO
::
UIOCommand
cmd
);
// --------------------------------------------
// функция для работы напрямую черех iterator (оптимизация)
virtual
void
localSetValue
(
IOController
::
IOStateList
::
iterator
&
it
,
const
IOController_i
::
SensorInfo
&
si
,
CORBA
::
Long
value
,
UniSetTypes
::
ObjectId
sup_id
);
// -------------------- !!!!!!!!! ---------------------------------
virtual
IONotifyController_i
::
ThresholdsListSeq
*
getThresholdsList
();
// --------------------------------------------
/*! Информация о заказчике */
struct
ConsumerInfoExt
:
...
...
@@ -173,11 +180,10 @@ class IONotifyController:
struct
ThresholdInfoExt
:
public
IONotifyController_i
::
ThresholdInfo
{
ThresholdInfoExt
(
UniSetTypes
::
ThresholdId
tid
,
CORBA
::
Long
low
,
CORBA
::
Long
hi
,
UniSetTypes
::
ObjectId
_sid
=
UniSetTypes
::
DefaultObjectId
,
bool
inv
=
false
)
:
ThresholdInfoExt
(
UniSetTypes
::
ThresholdId
tid
,
CORBA
::
Long
low
,
CORBA
::
Long
hi
,
bool
inv
,
UniSetTypes
::
ObjectId
_sid
=
UniSetTypes
::
DefaultObjectId
)
:
sid
(
_sid
),
inver
se
(
inv
)
inver
t
(
inv
)
{
id
=
tid
;
hilimit
=
hi
;
...
...
@@ -194,13 +200,27 @@ class IONotifyController:
IOController
::
IOStateList
::
iterator
sit
;
/*! инверсная логика */
bool
inver
se
;
bool
inver
t
;
inline
bool
operator
==
(
const
ThresholdInfo
&
r
)
const
{
return
((
id
==
r
.
id
)
&&
(
hilimit
==
r
.
hilimit
)
&&
(
lowlimit
==
r
.
lowlimit
)
);
(
lowlimit
==
r
.
lowlimit
)
&&
(
invert
==
r
.
invert
)
);
}
operator
IONotifyController_i
::
ThresholdInfo
()
{
IONotifyController_i
::
ThresholdInfo
r
;
r
.
id
=
id
;
r
.
hilimit
=
hilimit
;
r
.
lowlimit
=
lowlimit
;
r
.
invert
=
invert
;
r
.
tv_sec
=
tv_sec
;
r
.
tv_usec
=
tv_usec
;
r
.
state
=
state
;
return
r
;
}
};
...
...
include/MessageType.h
View file @
7345c868
...
...
@@ -115,7 +115,7 @@ namespace UniSetTypes
IOController_i
::
CalibrateInfo
ci
;
// для пороговых датчиков
bool
threshold
;
bool
threshold
;
/*!< TRUE - сработал порог, FALSE - порог отключился */
UniSetTypes
::
ThresholdId
tid
;
SensorMessage
();
...
...
include/UInterface.h
View file @
7345c868
...
...
@@ -120,18 +120,20 @@ class UInterface
IOController_i
::
CalibrateInfo
getCalibrateInfo
(
const
IOController_i
::
SensorInfo
&
si
);
//! Заказ информации об изменении дискретного датчика
//! Заказ информации об изменении порога
void
askThreshold
(
UniSetTypes
::
ObjectId
sensorId
,
UniSetTypes
::
ThresholdId
tid
,
UniversalIO
::
UIOCommand
cmd
,
CORBA
::
Long
lowLimit
=
0
,
CORBA
::
Long
hiLimit
=
0
,
long
lowLimit
,
long
hiLimit
,
bool
invert
=
false
,
UniSetTypes
::
ObjectId
backid
=
UniSetTypes
::
DefaultObjectId
);
void
askRemoteThreshold
(
UniSetTypes
::
ObjectId
sensorId
,
UniSetTypes
::
ObjectId
node
,
UniSetTypes
::
ThresholdId
thresholdId
,
UniversalIO
::
UIOCommand
cmd
,
CORBA
::
Long
lowLimit
=
0
,
CORBA
::
Long
hiLimit
=
0
,
long
lowLimit
,
long
hiLimit
,
bool
invert
=
false
,
UniSetTypes
::
ObjectId
backid
=
UniSetTypes
::
DefaultObjectId
);
IONotifyController_i
::
ThresholdInfo
getThresholdInfo
(
const
IOController_i
::
SensorInfo
&
si
,
UniSetTypes
::
ThresholdId
tid
);
IONotifyController_i
::
ThresholdInfo
getThresholdInfo
(
UniSetTypes
::
ObjectId
sid
,
UniSetTypes
::
ThresholdId
tid
);
// ---------------------------------------------------------------
// Вспомогательные функции
...
...
src/Interfaces/UInterface.cc
View file @
7345c868
...
...
@@ -1219,15 +1219,15 @@ string UInterface::set_err(const string& pre, UniSetTypes::ObjectId id, UniSetTy
// --------------------------------------------------------------------------------------------
void
UInterface
::
askThreshold
(
UniSetTypes
::
ObjectId
sid
,
UniSetTypes
::
ThresholdId
tid
,
UniversalIO
::
UIOCommand
cmd
,
CORBA
::
Long
low
,
CORBA
::
Long
hi
,
long
low
,
long
hi
,
bool
invert
,
UniSetTypes
::
ObjectId
backid
)
{
askRemoteThreshold
(
sid
,
uconf
->
getLocalNode
(),
tid
,
cmd
,
low
,
hi
,
backid
);
askRemoteThreshold
(
sid
,
uconf
->
getLocalNode
(),
tid
,
cmd
,
low
,
hi
,
invert
,
backid
);
}
// --------------------------------------------------------------------------------------------
void
UInterface
::
askRemoteThreshold
(
UniSetTypes
::
ObjectId
sid
,
UniSetTypes
::
ObjectId
node
,
UniSetTypes
::
ThresholdId
tid
,
UniversalIO
::
UIOCommand
cmd
,
CORBA
::
Long
lowLimit
,
CORBA
::
Long
hiLimi
t
,
long
lowLimit
,
long
hiLimit
,
bool
inver
t
,
UniSetTypes
::
ObjectId
backid
)
{
if
(
backid
==
UniSetTypes
::
DefaultObjectId
)
...
...
@@ -1264,7 +1264,7 @@ void UInterface::askRemoteThreshold( UniSetTypes::ObjectId sid, UniSetTypes::Obj
ci
->
id
=
backid
;
ci
->
node
=
uconf
->
getLocalNode
();
inc
->
askThreshold
(
si
,
ci
,
tid
,
lowLimit
,
hiLimit
,
cmd
);
inc
->
askThreshold
(
si
,
ci
,
tid
,
lowLimit
,
hiLimit
,
invert
,
cmd
);
return
;
}
catch
(
CORBA
::
TRANSIENT
){}
...
...
@@ -1315,6 +1315,87 @@ void UInterface::askRemoteThreshold( UniSetTypes::ObjectId sid, UniSetTypes::Obj
}
// --------------------------------------------------------------------------------------------
IONotifyController_i
::
ThresholdInfo
UInterface
::
getThresholdInfo
(
UniSetTypes
::
ObjectId
sid
,
UniSetTypes
::
ThresholdId
tid
)
{
IOController_i
::
SensorInfo
si
;
si
.
id
=
sid
;
si
.
node
=
conf
->
getLocalNode
();
return
getThresholdInfo
(
si
,
tid
);
}
// --------------------------------------------------------------------------------------------------------------
IONotifyController_i
::
ThresholdInfo
UInterface
::
getThresholdInfo
(
const
IOController_i
::
SensorInfo
&
si
,
UniSetTypes
::
ThresholdId
tid
)
{
if
(
si
.
id
==
DefaultObjectId
)
throw
ORepFailed
(
"UI(getThresholdInfo): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"
);
try
{
CORBA
::
Object_var
oref
;
try
{
oref
=
rcache
.
resolve
(
si
.
id
,
si
.
node
);
}
catch
(
NameNotFound
){}
for
(
unsigned
int
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
if
(
CORBA
::
is_nil
(
oref
)
)
oref
=
resolve
(
si
.
id
,
si
.
node
);
IONotifyController_i_var
iom
=
IONotifyController_i
::
_narrow
(
oref
);
return
iom
->
getThresholdInfo
(
si
,
tid
);
}
catch
(
CORBA
::
TRANSIENT
){}
catch
(
CORBA
::
OBJECT_NOT_EXIST
){}
catch
(
CORBA
::
SystemException
&
ex
){}
msleep
(
uconf
->
getRepeatTimeout
());
oref
=
CORBA
::
Object
::
_nil
();
}
}
catch
(
UniSetTypes
::
TimeOut
){}
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
rcache
.
erase
(
si
.
id
,
si
.
node
);
throw
UniSetTypes
::
NameNotFound
(
"UI(getThresholdInfo): "
+
string
(
ex
.
err
));
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
rcache
.
erase
(
si
.
id
,
si
.
node
);
throw
UniSetTypes
::
IOBadParam
(
"UI(getThresholdInfo): "
+
string
(
ex
.
err
));
}
catch
(
ORepFailed
)
{
rcache
.
erase
(
si
.
id
,
si
.
node
);
// не смогли получить ссылку на объект
throw
UniSetTypes
::
IOBadParam
(
set_err
(
"UI(getThresholdInfo): resolve failed "
,
si
.
id
,
si
.
node
));
}
catch
(
CORBA
::
NO_IMPLEMENT
)
{
rcache
.
erase
(
si
.
id
,
si
.
node
);
throw
UniSetTypes
::
IOBadParam
(
set_err
(
"UI(getThresholdInfo): method no implement"
,
si
.
id
,
si
.
node
));
}
catch
(
CORBA
::
OBJECT_NOT_EXIST
)
{
rcache
.
erase
(
si
.
id
,
si
.
node
);
throw
UniSetTypes
::
IOBadParam
(
set_err
(
"UI(getThresholdInfo): object not exist"
,
si
.
id
,
si
.
node
));
}
catch
(
CORBA
::
COMM_FAILURE
&
ex
)
{
// ошибка системы коммуникации
}
catch
(
CORBA
::
SystemException
&
ex
)
{
// ошибка системы коммуникации
// ulog.warn() << "UI(getValue): CORBA::SystemException" << endl;
}
rcache
.
erase
(
si
.
id
,
si
.
node
);
throw
UniSetTypes
::
TimeOut
(
set_err
(
"UI(getThresholdInfo): Timeout"
,
si
.
id
,
si
.
node
));
}
// --------------------------------------------------------------------------------------------
long
UInterface
::
getRawValue
(
const
IOController_i
::
SensorInfo
&
si
)
{
if
(
si
.
id
==
DefaultObjectId
)
...
...
src/Processes/IONotifyController.cc
View file @
7345c868
...
...
@@ -521,7 +521,8 @@ void IONotifyController::dumpThresholdList(const IOController_i::SensorInfo& si,
void
IONotifyController
::
askThreshold
(
const
IOController_i
::
SensorInfo
&
si
,
const
UniSetTypes
::
ConsumerInfo
&
ci
,
UniSetTypes
::
ThresholdId
tid
,
CORBA
::
Long
lowLimit
,
CORBA
::
Long
hiLimit
,
UniversalIO
::
UIOCommand
cmd
)
CORBA
::
Long
lowLimit
,
CORBA
::
Long
hiLimit
,
CORBA
::
Boolean
invert
,
UniversalIO
::
UIOCommand
cmd
)
{
if
(
lowLimit
>
hiLimit
)
throw
IONotifyController_i
::
BadRange
();
...
...
@@ -536,7 +537,7 @@ void IONotifyController::askThreshold(const IOController_i::SensorInfo& si, cons
// поиск датчика в списке
UniSetTypes
::
KeyType
skey
(
key
(
si
.
id
,
si
.
node
)
);
AskThresholdMap
::
iterator
it
=
askTMap
.
find
(
skey
);
ThresholdInfoExt
ti
(
tid
,
lowLimit
,
hiLimit
);
ThresholdInfoExt
ti
(
tid
,
lowLimit
,
hiLimit
,
invert
);
ti
.
sit
=
myioEnd
();
switch
(
cmd
)
...
...
@@ -708,7 +709,7 @@ bool IONotifyController::addThreshold(ThresholdExtList& lst, ThresholdInfoExt& t
return
true
;
}
// --------------------------------------------------------------------------------------------------------------
bool
IONotifyController
::
removeThreshold
(
ThresholdExtList
&
lst
,
ThresholdInfoExt
&
ti
,
const
UniSetTypes
::
ConsumerInfo
&
ci
)
bool
IONotifyController
::
removeThreshold
(
ThresholdExtList
&
lst
,
ThresholdInfoExt
&
ti
,
const
UniSetTypes
::
ConsumerInfo
&
ci
)
{
for
(
ThresholdExtList
::
iterator
it
=
lst
.
begin
();
it
!=
lst
.
end
();
++
it
)
{
...
...
@@ -772,88 +773,61 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
{
// Используем здесь sm.value чтобы не делать ещё раз lock на li->second.value
// Проверка нижнего предела
// значение должно быть меньше lowLimit-чуствительность
if
(
sm
.
value
<=
it
->
lowlimit
)
{
if
(
it
->
state
==
IONotifyController_i
::
LowThreshold
)
continue
;
it
->
state
=
IONotifyController_i
::
LowThreshold
;
sm
.
threshold
=
false
;
sm
.
tid
=
it
->
id
;
// запоминаем время изменения состояния
it
->
tv_sec
=
tm
.
tv_sec
;
it
->
tv_usec
=
tm
.
tv_usec
;
sm
.
sm_tv_sec
=
tm
.
tv_sec
;
sm
.
sm_tv_usec
=
tm
.
tv_usec
;
IONotifyController_i
::
ThresholdState
state
=
it
->
state
;
// порог связан с дискретным датчиком
if
(
it
->
sid
!=
UniSetTypes
::
DefaultObjectId
)
{
try
if
(
!
it
->
invert
)
{
bool
state
(
sm
.
threshold
);
// проверка на инвертированную логику
if
(
it
->
inverse
)
state
^=
1
;
localSetValue
(
it
->
sit
,
SensorInfo
(
it
->
sid
),(
state
?
1
:
0
),
getId
());
// Если логика не инвертированная, то срабатывание это - выход за зону >= hilimit
if
(
sm
.
value
<=
it
->
lowlimit
)
state
=
IONotifyController_i
::
NormalThreshold
;
else
if
(
sm
.
value
>=
it
->
hilimit
)
state
=
IONotifyController_i
::
HiThreshold
;
}
catch
(
UniSetTypes
::
Exception
&
ex
)
else
{
if
(
ulog
.
is_crit
()
)
ulog
.
crit
()
<<
myname
<<
"(checkThreshold): "
<<
ex
<<
endl
;
}
// Если логика инвертированная, то срабатывание это - выход за зону <= lowlimit
if
(
sm
.
value
>=
it
->
hilimit
)
state
=
IONotifyController_i
::
NormalThreshold
;
else
if
(
sm
.
value
<=
it
->
lowlimit
)
state
=
IONotifyController_i
::
LowThreshold
;
}
if
(
send_msg
)
send
(
it
->
clst
,
sm
);
}
// Проверка верхнего предела
// значение должно быть больше hiLimit+чуствительность
else
if
(
sm
.
value
>=
it
->
hilimit
)
{
if
(
it
->
state
==
IONotifyController_i
::
HiThreshold
)
// если ничего не менялось..
if
(
it
->
state
==
state
)
continue
;
it
->
state
=
IONotifyController_i
::
HiThreshold
;
sm
.
threshold
=
true
;
it
->
state
=
state
;
sm
.
tid
=
it
->
id
;
// если состояние не normal, значит порог сработал,
// не важно какой.. нижний или верхний (зависит от inverse)
sm
.
threshold
=
(
state
!=
IONotifyController_i
::
NormalThreshold
)
?
true
:
false
;
// запоминаем время изменения состояния
it
->
tv_sec
=
tm
.
tv_sec
;
it
->
tv_usec
=
tm
.
tv_usec
;
sm
.
sm_tv_sec
=
tm
.
tv_sec
;
sm
.
sm_tv_usec
=
tm
.
tv_usec
;
// порог связан с дискретным датчиком
// если порог связан с ддатчиком, то надо его выставить
if
(
it
->
sid
!=
UniSetTypes
::
DefaultObjectId
)
{
try
{
bool
state
(
sm
.
threshold
);
// проверка на инвертированную логику
if
(
it
->
inverse
)
state
^=
1
;
localSetValue
(
it
->
sit
,
SensorInfo
(
it
->
sid
),(
state
?
1
:
0
),
getId
());
localSetValue
(
it
->
sit
,
SensorInfo
(
it
->
sid
),(
sm
.
threshold
?
1
:
0
),
getId
());
}
catch
(
UniSetTypes
::
Exception
&
ex
)
{
if
(
ulog
.
is_crit
()
)
ulog
.
crit
()
<<
myname
<<
"(checkThreshold): "
<<
ex
<<
endl
;
ulog
.
crit
()
<<
myname
<<
"(checkThreshold): "
<<
ex
<<
endl
;
}
}
// отдельно посылаем сообщения заказчикам порогов, по данному "порогу"
if
(
send_msg
)
send
(
it
->
clst
,
sm
);
}
else
it
->
state
=
IONotifyController_i
::
NormalThreshold
;
}
}
// unlock
}
// --------------------------------------------------------------------------------------------------------------
...
...
@@ -879,6 +853,90 @@ IONotifyController::ThresholdExtList::iterator IONotifyController::findThreshold
return
it
;
}
// --------------------------------------------------------------------------------------------------------------
IONotifyController_i
::
ThresholdInfo
IONotifyController
::
getThresholdInfo
(
const
IOController_i
::
SensorInfo
&
si
,
UniSetTypes
::
ThresholdId
tid
)
{
uniset_rwmutex_rlock
lock
(
trshMutex
);
AskThresholdMap
::
iterator
it
=
askTMap
.
find
(
key
(
si
)
);
if
(
it
==
askTMap
.
end
()
)
{
ostringstream
err
;
err
<<
myname
<<
"(getThresholds): Not found sensor ("
<<
si
.
id
<<
":"
<<
si
.
node
<<
") "
<<
conf
->
oind
->
getNameById
(
si
.
id
);
if
(
ulog
.
is_info
()
)
ulog
.
info
()
<<
err
.
str
()
<<
endl
;
throw
IOController_i
::
NameNotFound
(
err
.
str
().
c_str
());
}
for
(
ThresholdExtList
::
const_iterator
it2
=
it
->
second
.
list
.
begin
();
it2
!=
it
->
second
.
list
.
end
();
++
it2
)
{
if
(
it2
->
id
==
tid
)
return
IONotifyController_i
::
ThresholdInfo
(
*
it2
);
}
ostringstream
err
;
err
<<
myname
<<
"(getThresholds): Not found for sensor ("
<<
si
.
id
<<
":"
<<
si
.
node
<<
") "
<<
conf
->
oind
->
getNameById
(
si
.
id
)
<<
" ThresholdID='"
<<
tid
<<
"'"
;
if
(
ulog
.
is_info
()
)
ulog
.
info
()
<<
err
.
str
()
<<
endl
;
throw
IOController_i
::
NameNotFound
(
err
.
str
().
c_str
());
}
// --------------------------------------------------------------------------------------------------------------
IONotifyController_i
::
ThresholdList
*
IONotifyController
::
getThresholds
(
const
IOController_i
::
SensorInfo
&
si
)
{
uniset_rwmutex_rlock
lock
(
trshMutex
);
AskThresholdMap
::
iterator
it
=
askTMap
.
find
(
key
(
si
)
);
if
(
it
==
askTMap
.
end
()
)
{
ostringstream
err
;
err
<<
myname
<<
"(getThresholds): Not found sensor ("
<<
si
.
id
<<
":"
<<
si
.
node
<<
") "
<<
conf
->
oind
->
getNameById
(
si
.
id
);
if
(
ulog
.
is_info
()
)
ulog
.
info
()
<<
err
.
str
()
<<
endl
;
throw
IOController_i
::
NameNotFound
(
err
.
str
().
c_str
());
}
IONotifyController_i
::
ThresholdList
*
res
=
new
IONotifyController_i
::
ThresholdList
();
try
{
res
->
si
=
it
->
second
.
si
;
res
->
value
=
IOController
::
localGetValue
(
it
->
second
.
ait
,
it
->
second
.
si
);
res
->
type
=
it
->
second
.
type
;
}
catch
(
Exception
&
ex
)
{
if
(
ulog
.
is_warn
()
)
ulog
.
warn
()
<<
myname
<<
"(getThresholdsList): для датчика "
<<
conf
->
oind
->
getNameById
(
it
->
second
.
si
.
id
,
it
->
second
.
si
.
node
)
<<
" "
<<
ex
<<
endl
;
}
res
->
tlist
.
length
(
it
->
second
.
list
.
size
()
);
int
k
=
0
;
for
(
ThresholdExtList
::
const_iterator
it2
=
it
->
second
.
list
.
begin
();
it2
!=
it
->
second
.
list
.
end
();
++
it2
)
{
res
->
tlist
[
k
].
id
=
it2
->
id
;
res
->
tlist
[
k
].
hilimit
=
it2
->
hilimit
;
res
->
tlist
[
k
].
lowlimit
=
it2
->
lowlimit
;
res
->
tlist
[
k
].
state
=
it2
->
state
;
res
->
tlist
[
k
].
tv_sec
=
it2
->
tv_sec
;
res
->
tlist
[
k
].
tv_usec
=
it2
->
tv_usec
;
k
++
;
}
return
res
;
}
// --------------------------------------------------------------------------------------------------------------
IONotifyController_i
::
ThresholdsListSeq
*
IONotifyController
::
getThresholdsList
()
{
// ulog.info() << myname << "(getThresholdsList): ...\n";
...
...
src/Processes/NCRestorer_XML.cc
View file @
7345c868
...
...
@@ -372,7 +372,7 @@ void NCRestorer_XML::read_thresholds(UniXML& xml, xmlNode* node, IONotifyControl
ulog
.
info
()
<<
"(read_thresholds):
\t
threshold low="
<<
ti
.
lowlimit
<<
"
\t
hi="
<<
ti
.
hilimit
<<
"
\t
sid="
<<
ti
.
sid
<<
"
\t
inver
se="
<<
ti
.
inverse
<<
"
\t
inver
t="
<<
ti
.
invert
<<
endl
<<
flush
;
}
...
...
@@ -473,7 +473,7 @@ bool NCRestorer_XML::getThresholdInfo( UniXML& xml,xmlNode* node,
ti
.
id
=
uit
.
getIntProp
(
"id"
);
ti
.
lowlimit
=
uit
.
getIntProp
(
"lowlimit"
);
ti
.
hilimit
=
uit
.
getIntProp
(
"hilimit"
);
ti
.
inver
se
=
uit
.
getIntProp
(
"inverse
"
);
ti
.
inver
t
=
uit
.
getIntProp
(
"invert
"
);
ti
.
state
=
IONotifyController_i
::
NormalThreshold
;
return
true
;
}
...
...
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