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
3ef0ac3a
Commit
3ef0ac3a
authored
Oct 30, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(IOBase): добавил возможность переопределять свойства при помощи prefix.
parent
82a6c841
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
54 deletions
+93
-54
libuniset.spec
conf/libuniset.spec
+5
-2
IOControl.cc
extensions/IOControl/IOControl.cc
+1
-1
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+4
-4
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+1
-1
IOBase.h
extensions/include/IOBase.h
+9
-3
IOBase.cc
extensions/lib/IOBase.cc
+73
-43
No files found.
conf/libuniset.spec
View file @
3ef0ac3a
...
...
@@ -7,8 +7,8 @@
%define oname uniset
Name: libuniset
Version: 1.
7
Release: alt1
6
Version: 1.
8
Release: alt1
Summary: UniSet - library for building distributed industrial control systems
...
...
@@ -335,6 +335,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Thu Oct 30 2014 Pavel Vainerman <pv@altlinux.ru> 1.8-alt1
- (IOBase): added the ability to override the basic settings using the prefix.
* Mon Oct 20 2014 Pavel Vainerman <pv@altlinux.ru> 1.7-alt16
- fixed bug in UniXML::iteartor getPIntProp() for prop <= 0
...
...
extensions/IOControl/IOControl.cc
View file @
3ef0ac3a
...
...
@@ -749,7 +749,7 @@ bool IOControl::initIOItem( UniXML_iterator& it )
inf
.
subdev
=
DefaultSubdev
;
}
if
(
!
IOBase
::
initItem
(
&
inf
,
it
,
shm
,
&
unideb
,
myname
,
filtersize
,
filterT
)
)
if
(
!
IOBase
::
initItem
(
&
inf
,
it
,
shm
,
prefix
,
false
,
&
unideb
,
myname
,
filtersize
,
filterT
)
)
return
false
;
// если вектор уже заполнен
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
3ef0ac3a
...
...
@@ -1909,7 +1909,7 @@ MBExchange::RSProperty* MBExchange::addProp( PList& plist, RSProperty& p )
// ------------------------------------------------------------------------------------------
bool
MBExchange
::
initRSProperty
(
RSProperty
&
p
,
UniXML_iterator
&
it
)
{
if
(
!
IOBase
::
initItem
(
&
p
,
it
,
shm
,
&
dlog
,
myname
)
)
if
(
!
IOBase
::
initItem
(
&
p
,
it
,
shm
,
prefix
,
false
,
&
dlog
,
myname
)
)
return
false
;
// проверяем не пороговый ли это датчик (т.е. не связанный с обменом)
...
...
@@ -1918,9 +1918,9 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
{
thrlist
.
push_back
(
p
);
return
true
;
}
}
if
(
it
.
getIntProp
(
prop_prefix
+
"rawdata"
)
)
{
p
.
cal
.
minRaw
=
0
;
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
3ef0ac3a
...
...
@@ -818,7 +818,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
{
IOProperty
p
;
if
(
!
IOBase
::
initItem
(
static_cast
<
IOBase
*>
(
&
p
),
it
,
shm
,
&
dlog
,
myname
)
)
if
(
!
IOBase
::
initItem
(
static_cast
<
IOBase
*>
(
&
p
),
it
,
shm
,
prefix
,
false
,
&
dlog
,
myname
)
)
return
false
;
if
(
mbregFromID
)
...
...
extensions/include/IOBase.h
View file @
3ef0ac3a
...
...
@@ -106,7 +106,7 @@ static const int NoSafety = -1;
IOController
::
AIOStateList
::
iterator
ait
;
IOController
::
DIOStateList
::
iterator
dit
;
UniSetTypes
::
uniset_spin_mutex
val_lock
;
/*!< блокировка на время "работы" со значением */
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
IOBase
&
inf
);
static
void
processingFasAI
(
IOBase
*
it
,
float
new_val
,
SMInterface
*
shm
,
bool
force
);
...
...
@@ -116,11 +116,17 @@ static const int NoSafety = -1;
static
float
processingFasAO
(
IOBase
*
it
,
SMInterface
*
shm
,
bool
force
);
static
bool
processingAsDO
(
IOBase
*
it
,
SMInterface
*
shm
,
bool
force
);
static
void
processingThreshold
(
IOBase
*
it
,
SMInterface
*
shm
,
bool
force
);
static
bool
initItem
(
IOBase
*
b
,
UniXML_iterator
&
it
,
SMInterface
*
shm
,
DebugStream
*
dlog
=
0
,
std
::
string
myname
=
""
,
/*! \param initPrefixOnly - TRUE - инициализировать только свойста с prefix (или брать значения по умолчанию).
FALSE - сперва искать свойство с prefix, если не найдено брать без prefix.
*/
static
bool
initItem
(
IOBase
*
b
,
UniXML_iterator
&
it
,
SMInterface
*
shm
,
const
std
::
string
&
prefix
=
""
,
bool
initPrefixOnly
=
false
,
DebugStream
*
dlog
=
0
,
const
std
::
string
&
myname
=
""
,
int
def_filtersize
=
0
,
float
def_filterT
=
0
.
0
,
float
def_lsparam
=
0
.
2
,
float
def_iir_coeff_prev
=
0
.
5
,
float
def_iir_coeff_new
=
0
.
5
);
};
...
...
extensions/lib/IOBase.cc
View file @
3ef0ac3a
...
...
@@ -431,20 +431,50 @@ void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force )
processingAsDI
(
it
,
set
,
shm
,
force
);
}
// -----------------------------------------------------------------------------
static
std
::
string
initProp
(
UniXML_iterator
&
it
,
const
std
::
string
&
prop
,
const
std
::
string
&
prefix
,
bool
prefonly
,
const
std
::
string
&
defval
=
""
)
{
if
(
!
it
.
getProp
(
prefix
+
prop
).
empty
()
)
return
it
.
getProp
(
prefix
+
prop
);
if
(
prefonly
)
return
defval
;
if
(
!
it
.
getProp
(
prop
).
empty
()
)
return
it
.
getProp
(
prop
);
return
defval
;
}
static
int
initIntProp
(
UniXML_iterator
&
it
,
const
std
::
string
&
prop
,
const
std
::
string
&
prefix
,
bool
prefonly
,
const
int
defval
=
0
)
{
string
pp
(
prefix
+
prop
);
if
(
!
it
.
getProp
(
pp
).
empty
()
)
return
it
.
getIntProp
(
pp
);
if
(
prefonly
)
return
defval
;
if
(
!
it
.
getProp
(
prop
).
empty
()
)
return
it
.
getIntProp
(
prop
);
return
defval
;
}
bool
IOBase
::
initItem
(
IOBase
*
b
,
UniXML_iterator
&
it
,
SMInterface
*
shm
,
DebugStream
*
dlog
,
std
::
string
myname
,
bool
IOBase
::
initItem
(
IOBase
*
b
,
UniXML_iterator
&
it
,
SMInterface
*
shm
,
const
std
::
string
&
prefix
,
bool
init_prefix_only
,
DebugStream
*
dlog
,
const
std
::
string
&
myname
,
int
def_filtersize
,
float
def_filterT
,
float
def_lsparam
,
float
def_iir_coeff_prev
,
float
def_iir_coeff_new
)
{
string
sname
(
i
t
.
getProp
(
"name"
)
);
string
sname
(
i
nitProp
(
it
,
"name"
,
prefix
,
init_prefix_only
)
);
ObjectId
sid
=
DefaultObjectId
;
if
(
i
t
.
getProp
(
"id"
).
empty
()
)
if
(
i
nitProp
(
it
,
"id"
,
prefix
,
init_prefix_only
).
empty
()
)
sid
=
conf
->
getSensorID
(
sname
);
else
{
sid
=
i
t
.
getPIntProp
(
"id"
,
DefaultObjectId
);
sid
=
i
nitIntProp
(
it
,
"id"
,
prefix
,
init_prefix_only
,
DefaultObjectId
);
}
if
(
sid
==
DefaultObjectId
)
...
...
@@ -458,26 +488,26 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
b
->
si
.
id
=
sid
;
b
->
si
.
node
=
conf
->
getLocalNode
();
b
->
nofilter
=
i
t
.
getIntProp
(
"nofilter"
);
b
->
ignore
=
i
t
.
getIntProp
(
"ioignore"
);
b
->
invert
=
i
t
.
getIntProp
(
"ioinvert"
);
b
->
defval
=
i
t
.
getIntProp
(
"default"
);
b
->
noprecision
=
i
t
.
getIntProp
(
"noprecision"
);
b
->
nofilter
=
i
nitIntProp
(
it
,
"nofilter"
,
prefix
,
init_prefix_only
);
b
->
ignore
=
i
nitIntProp
(
it
,
"ioignore"
,
prefix
,
init_prefix_only
);
b
->
invert
=
i
nitIntProp
(
it
,
"ioinvert"
,
prefix
,
init_prefix_only
);
b
->
defval
=
i
nitIntProp
(
it
,
"default"
,
prefix
,
init_prefix_only
);
b
->
noprecision
=
i
nitIntProp
(
it
,
"noprecision"
,
prefix
,
init_prefix_only
);
b
->
value
=
b
->
defval
;
b
->
breaklim
=
i
t
.
getIntProp
(
"breaklim"
);
b
->
breaklim
=
i
nitIntProp
(
it
,
"breaklim"
,
prefix
,
init_prefix_only
);
long
msec
=
i
t
.
getPIntProp
(
"jardelay"
,
UniSetTimer
::
WaitUpTime
);
long
msec
=
i
nitIntProp
(
it
,
"jardelay"
,
prefix
,
init_prefix_only
,
UniSetTimer
::
WaitUpTime
);
b
->
ptJar
.
setTiming
(
msec
);
msec
=
i
t
.
getPIntProp
(
"ondelay"
,
UniSetTimer
::
WaitUpTime
);
msec
=
i
nitIntProp
(
it
,
"ondelay"
,
prefix
,
init_prefix_only
,
UniSetTimer
::
WaitUpTime
);
b
->
ptOnDelay
.
setTiming
(
msec
);
msec
=
i
t
.
getPIntProp
(
"offdelay"
,
UniSetTimer
::
WaitUpTime
);
msec
=
i
nitIntProp
(
it
,
"offdelay"
,
prefix
,
init_prefix_only
,
UniSetTimer
::
WaitUpTime
);
b
->
ptOffDelay
.
setTiming
(
msec
);
b
->
safety
=
i
t
.
getPIntProp
(
"safety"
,
NoSafety
);
b
->
safety
=
i
nitIntProp
(
it
,
"safety"
,
prefix
,
init_prefix_only
,
NoSafety
);
b
->
stype
=
UniSetTypes
::
getIOType
(
it
.
getProp
(
"iotype"
)
);
b
->
stype
=
UniSetTypes
::
getIOType
(
initProp
(
it
,
"iotype"
,
prefix
,
init_prefix_only
)
);
if
(
b
->
stype
==
UniversalIO
::
UnknownIOType
)
{
if
(
dlog
)
...
...
@@ -502,7 +532,7 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
shm
->
initDIterator
(
b
->
dit
);
shm
->
initDIterator
(
b
->
d_dit
);
string
d_txt
(
it
.
getProp
(
"depend"
)
);
string
d_txt
(
initProp
(
it
,
"depend"
,
prefix
,
init_prefix_only
)
);
if
(
!
d_txt
.
empty
()
)
{
b
->
d_id
=
conf
->
getSensorID
(
d_txt
);
...
...
@@ -517,25 +547,25 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
}
// по умолчанию срабатывание на "1"
b
->
d_value
=
i
t
.
getProp
(
"depend_value"
).
empty
()
?
1
:
it
.
getIntProp
(
"depend_value"
);
b
->
d_off_value
=
i
t
.
getIntProp
(
"depend_off_value"
);
b
->
d_value
=
i
nitProp
(
it
,
"depend_value"
,
prefix
,
init_prefix_only
).
empty
()
?
1
:
initIntProp
(
it
,
"depend_value"
,
prefix
,
init_prefix_only
);
b
->
d_off_value
=
i
nitIntProp
(
it
,
"depend_off_value"
,
prefix
,
init_prefix_only
);
b
->
d_iotype
=
conf
->
getIOType
(
b
->
d_id
);
}
if
(
b
->
stype
==
UniversalIO
::
AnalogInput
||
b
->
stype
==
UniversalIO
::
AnalogOutput
)
{
b
->
cal
.
minRaw
=
i
t
.
getIntProp
(
"rmin"
);
b
->
cal
.
maxRaw
=
i
t
.
getIntProp
(
"rmax"
);
b
->
cal
.
minCal
=
i
t
.
getIntProp
(
"cmin"
);
b
->
cal
.
maxCal
=
i
t
.
getIntProp
(
"cmax"
);
b
->
cal
.
sensibility
=
i
t
.
getIntProp
(
"sensibility"
);
b
->
cal
.
precision
=
i
t
.
getIntProp
(
"precision"
);
b
->
cal
.
minRaw
=
i
nitIntProp
(
it
,
"rmin"
,
prefix
,
init_prefix_only
);
b
->
cal
.
maxRaw
=
i
nitIntProp
(
it
,
"rmax"
,
prefix
,
init_prefix_only
);
b
->
cal
.
minCal
=
i
nitIntProp
(
it
,
"cmin"
,
prefix
,
init_prefix_only
);
b
->
cal
.
maxCal
=
i
nitIntProp
(
it
,
"cmax"
,
prefix
,
init_prefix_only
);
b
->
cal
.
sensibility
=
i
nitIntProp
(
it
,
"sensibility"
,
prefix
,
init_prefix_only
);
b
->
cal
.
precision
=
i
nitIntProp
(
it
,
"precision"
,
prefix
,
init_prefix_only
);
int
f_size
=
def_filtersize
;
float
f_T
=
def_filterT
;
float
f_lsparam
=
def_lsparam
;
int
f_median
=
i
t
.
getIntProp
(
"filtermedian"
);
int
f_iir
=
i
t
.
getIntProp
(
"iir_thr"
);
int
f_median
=
i
nitIntProp
(
it
,
"filtermedian"
,
prefix
,
init_prefix_only
);
int
f_iir
=
i
nitIntProp
(
it
,
"iir_thr"
,
prefix
,
init_prefix_only
);
float
f_iir_coeff_prev
=
def_iir_coeff_prev
;
float
f_iir_coeff_new
=
def_iir_coeff_new
;
...
...
@@ -548,29 +578,29 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
{
if
(
f_iir
>
0
)
b
->
f_filter_iir
=
true
;
if
(
!
i
t
.
getProp
(
"filtersize"
).
empty
()
)
f_size
=
i
t
.
getPIntProp
(
"filtersize"
,
def_filtersize
);
if
(
!
i
nitProp
(
it
,
"filtersize"
,
prefix
,
init_prefix_only
).
empty
()
)
f_size
=
i
nitIntProp
(
it
,
"filtersize"
,
prefix
,
init_prefix_only
,
def_filtersize
);
}
if
(
!
i
t
.
getProp
(
"filterT"
).
empty
()
)
if
(
!
i
nitProp
(
it
,
"filterT"
,
prefix
,
init_prefix_only
).
empty
()
)
{
f_T
=
atof
(
i
t
.
getProp
(
"filterT"
).
c_str
());
f_T
=
atof
(
i
nitProp
(
it
,
"filterT"
,
prefix
,
init_prefix_only
).
c_str
());
if
(
f_T
<
0
)
f_T
=
0.0
;
}
if
(
!
i
t
.
getProp
(
"leastsqr"
).
empty
()
)
if
(
!
i
nitProp
(
it
,
"leastsqr"
,
prefix
,
init_prefix_only
).
empty
()
)
{
b
->
f_ls
=
true
;
f_lsparam
=
atof
(
i
t
.
getProp
(
"leastsqr"
).
c_str
());
f_lsparam
=
atof
(
i
nitProp
(
it
,
"leastsqr"
,
prefix
,
init_prefix_only
).
c_str
());
if
(
f_lsparam
<
0
)
f_lsparam
=
def_lsparam
;
}
if
(
!
i
t
.
getProp
(
"iir_coeff_prev"
).
empty
()
)
f_iir_coeff_prev
=
atof
(
i
t
.
getProp
(
"iir_coeff_prev"
).
c_str
());
if
(
!
i
t
.
getProp
(
"iir_coeff_new"
).
empty
()
)
f_iir_coeff_new
=
atof
(
i
t
.
getProp
(
"iir_coeff_new"
).
c_str
());
if
(
!
i
nitProp
(
it
,
"iir_coeff_prev"
,
prefix
,
init_prefix_only
).
empty
()
)
f_iir_coeff_prev
=
atof
(
i
nitProp
(
it
,
"iir_coeff_prev"
,
prefix
,
init_prefix_only
).
c_str
());
if
(
!
i
nitProp
(
it
,
"iir_coeff_new"
,
prefix
,
init_prefix_only
).
empty
()
)
f_iir_coeff_new
=
atof
(
i
nitProp
(
it
,
"iir_coeff_new"
,
prefix
,
init_prefix_only
).
c_str
());
if
(
b
->
stype
==
UniversalIO
::
AnalogInput
)
b
->
df
.
setSettings
(
f_size
,
f_T
,
f_lsparam
,
f_iir
,
...
...
@@ -578,13 +608,13 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
b
->
df
.
init
(
b
->
defval
);
std
::
string
caldiagram
(
i
t
.
getProp
(
"caldiagram"
)
);
std
::
string
caldiagram
(
i
nitProp
(
it
,
"caldiagram"
,
prefix
,
init_prefix_only
)
);
if
(
!
caldiagram
.
empty
()
)
b
->
cdiagram
=
UniSetExtensions
::
buildCalibrationDiagram
(
caldiagram
);
}
else
if
(
b
->
stype
==
UniversalIO
::
DigitalInput
||
b
->
stype
==
UniversalIO
::
DigitalOutput
)
{
string
tai
(
i
t
.
getProp
(
"threshold_aid"
));
string
tai
(
i
nitProp
(
it
,
"threshold_aid"
,
prefix
,
init_prefix_only
));
if
(
!
tai
.
empty
()
)
{
b
->
t_ai
=
conf
->
getSensorID
(
tai
);
...
...
@@ -596,10 +626,10 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
return
false
;
}
b
->
ti
.
lowlimit
=
i
t
.
getIntProp
(
"lowlimit"
);
b
->
ti
.
hilimit
=
i
t
.
getIntProp
(
"hilimit"
);
b
->
ti
.
sensibility
=
i
t
.
getIntProp
(
"sensibility"
);
b
->
ti
.
inverse
=
i
t
.
getIntProp
(
"inverse"
);
b
->
ti
.
lowlimit
=
i
nitIntProp
(
it
,
"lowlimit"
,
prefix
,
init_prefix_only
);
b
->
ti
.
hilimit
=
i
nitIntProp
(
it
,
"hilimit"
,
prefix
,
init_prefix_only
);
b
->
ti
.
sensibility
=
i
nitIntProp
(
it
,
"sensibility"
,
prefix
,
init_prefix_only
);
b
->
ti
.
inverse
=
i
nitIntProp
(
it
,
"inverse"
,
prefix
,
init_prefix_only
);
}
}
// else
...
...
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