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
dd3b30d8
Commit
dd3b30d8
authored
Jun 09, 2009
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
отладка на стенде
parent
9f8ee6f2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
185 additions
and
40 deletions
+185
-40
TODO
TODO
+5
-0
test.xml
conf/test.xml
+2
-2
uniset.spec
conf/uniset.spec
+4
-1
iocontrol.cc
extentions/IOControl/iocontrol.cc
+1
-1
RTUExchange.cc
extentions/RTUExchange/RTUExchange.cc
+0
-0
RTUExchange.h
extentions/RTUExchange/RTUExchange.h
+9
-4
start_fg.sh
extentions/RTUExchange/start_fg.sh
+6
-4
start_fg.sh
extentions/SharedMemory/start_fg.sh
+1
-1
IOBase.h
extentions/include/IOBase.h
+12
-1
VTypes.h
extentions/include/VTypes.h
+44
-1
IOBase.cc
extentions/lib/IOBase.cc
+89
-25
VTypes.cc
extentions/lib/VTypes.cc
+7
-0
DebugStream.cc
src/Various/DebugStream.cc
+5
-0
No files found.
TODO
View file @
dd3b30d8
...
...
@@ -23,3 +23,7 @@
( ConsumerInfo ..). uniset-codegen,
SensorInfo ObjectId.
----------
RTUExchabge: vtype="Byte"
smonit: processing "precision"
admin: processing "precision"
\ No newline at end of file
conf/test.xml
View file @
dd3b30d8
...
...
@@ -61,7 +61,7 @@
<ObjectsMap
idfromfile=
"1"
no_dep=
"0"
>
<nodes
port=
"2809"
>
<item
id=
"3000"
name=
"LocalhostNode"
alias=
""
textname=
" "
ip=
"127.0.0.1"
CANnodeID=
""
host=
"localhost"
dbserver=
"
DBServer1
"
/>
<item
id=
"3000"
name=
"LocalhostNode"
alias=
""
textname=
" "
ip=
"127.0.0.1"
CANnodeID=
""
host=
"localhost"
dbserver=
""
/>
</nodes>
<!-- ************************ ********************** -->
...
...
@@ -87,7 +87,7 @@
<item
id=
"465002"
name=
"HC_out"
textname=
"HC_out"
iotype=
"DO"
character=
"Info"
rs=
"
2
"
mbtype=
"rtu"
mbaddr=
"0x02"
mbreg=
"0x3000"
mbfunc=
"0x06"
>
rs=
"
1
"
mbtype=
"rtu"
mbaddr=
"0x02"
mbreg=
"0x3000"
mbfunc=
"0x06"
>
<consumers>
</consumers>
</item>
...
...
conf/uniset.spec
View file @
dd3b30d8
...
...
@@ -2,7 +2,7 @@
Name: uniset
Version: 0.96
Release: eter2
3
Release: eter2
6
Summary: UniSet
License: GPL
Group: Development/C++
...
...
@@ -181,6 +181,9 @@ Libraries needed to develop for uniset extentions
%_bindir/%name-smviewer
%changelog
* Mon Jun 08 2009 Pavel Vainerman <pv@aeu> 0.96-eter25
- new build
* Thu Jun 04 2009 Pavel Vainerman <pv@aeu> 0.96-eter23
- new build
...
...
extentions/IOControl/iocontrol.cc
View file @
dd3b30d8
...
...
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
}
IOControl
*
ic
=
IOControl
::
init_iocontrol
(
argc
,
argv
,
shmID
,
0
);
IOControl
*
ic
=
IOControl
::
init_iocontrol
(
argc
,
argv
,
shmID
);
if
(
!
ic
)
{
dlog
[
Debug
::
CRIT
]
<<
"(iocontrol): init ۣ..."
<<
endl
;
...
...
extentions/RTUExchange/RTUExchange.cc
View file @
dd3b30d8
This diff is collapsed.
Click to expand it.
extentions/RTUExchange/RTUExchange.h
View file @
dd3b30d8
...
...
@@ -60,14 +60,15 @@ class RTUExchange:
public
IOBase
{
// only for RTU
short
nbit
;
/*!< bit number
(for func=[0x01,0x02]
) */
short
nbit
;
/*!< bit number) */
VTypes
::
VType
vType
;
/*!< type of value */
short
rnum
;
/*!< count of registers */
short
nbyte
;
/*!< byte number (1-2) */
RSProperty
()
:
nbit
(
-
1
),
vType
(
VTypes
::
vtUnknown
),
rnum
(
VTypes
::
wsize
(
VTypes
::
vtUnknown
)),
reg
(
0
)
nbyte
(
0
),
reg
(
0
)
{}
RegInfo
*
reg
;
...
...
@@ -76,7 +77,8 @@ class RTUExchange:
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
RSProperty
&
p
);
typedef
std
::
list
<
RSProperty
>
PList
;
typedef
std
::
map
<
ModbusRTU
::
ModbusData
,
RegInfo
*>
RegMap
;
struct
RegInfo
{
RegInfo
()
:
...
...
@@ -106,11 +108,13 @@ class RTUExchange:
// optimization
int
q_num
;
/*! number in query */
int
q_count
;
/*! count registers for query */
RegMap
::
iterator
rit
;
};
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
RegInfo
&
r
);
typedef
std
::
map
<
ModbusRTU
::
ModbusData
,
RegInfo
*>
RegMap
;
struct
RTUDevice
{
...
...
@@ -177,6 +181,7 @@ class RTUExchange:
void
updateRTU
(
RegMap
::
iterator
&
it
);
void
updateMTR
(
RegMap
::
iterator
&
it
);
void
updateRTU188
(
RegMap
::
iterator
&
it
);
void
updateRSProperty
(
RSProperty
*
p
,
bool
write_only
=
false
);
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
);
void
sysCommand
(
UniSetTypes
::
SystemMessage
*
msg
);
...
...
extentions/RTUExchange/start_fg.sh
View file @
dd3b30d8
#!/bin/sh
uniset-start.sh
-f
./uniset-rtuexchange
--confile
test.xml
\
--rs-dev
/dev/
cbsideA
0
\
--rs-dev
/dev/
ttyS
0
\
--rs-name
RSExchange
\
--rs-speed
38400
\
--rs-filter-field
rs
\
--rs-filter-value
2
\
--dlog-add-levels
info,crit,warn,level1
--rs-filter-value
3
\
--dlog-add-levels
info,crit,warn
\
--rs-force
0
\
--rs-force-out
0
\
#,level3
# --rs-force 1 \
extentions/SharedMemory/start_fg.sh
View file @
dd3b30d8
...
...
@@ -3,6 +3,6 @@
ulimit
-Sc
1000000000000
uniset-start.sh
-f
./uniset-smemory
--smemory-id
SharedMemory1
\
--confile
test.xml
\
--confile
test.xml
--datfile
/etc/AEU/configure.xml
\
--unideb-add-levels
info,crit,warn,level9,system
extentions/include/IOBase.h
View file @
dd3b30d8
...
...
@@ -33,7 +33,9 @@ static const int NoSafety = -1;
invert
(
false
),
jar_state
(
false
),
ondelay_state
(
false
),
offdelay_state
(
false
)
offdelay_state
(
false
),
t_ai
(
UniSetTypes
::
DefaultObjectId
),
initOK
(
false
)
{}
...
...
@@ -75,6 +77,14 @@ static const int NoSafety = -1;
bool
ondelay_state
;
/*!< */
bool
offdelay_state
;
/*!< */
//
UniSetTypes
::
ObjectId
t_ai
;
/*!< ,
,
*/
IONotifyController_i
::
ThresholdInfo
ti
;
IOController
::
AIOStateList
::
iterator
ait
;
IOController
::
DIOStateList
::
iterator
dit
;
UniSetTypes
::
uniset_spin_mutex
val_lock
;
/*!< */
...
...
@@ -87,6 +97,7 @@ static const int NoSafety = -1;
static
long
processingAsAO
(
IOBase
*
it
,
SMInterface
*
shm
,
bool
force
);
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
=
""
,
int
def_filtersize
=
0
,
float
def_filterT
=
0
.
0
);
...
...
extentions/include/VTypes.h
View file @
dd3b30d8
...
...
@@ -16,7 +16,8 @@ namespace VTypes
{
vtUnknown
,
vtF2
,
vtF4
vtF4
,
vtByte
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
VType
&
vt
);
...
...
@@ -97,6 +98,48 @@ namespace VTypes
F4mem
raw
;
};
// --------------------------------------------------------------------------
class
Byte
{
public
:
static
const
int
bsize
=
2
;
// ------------------------------------------
/*! */
typedef
union
{
unsigned
short
w
;
unsigned
char
b
[
bsize
];
}
Bytemem
;
// ------------------------------------------
// ...
Byte
(){
raw
.
w
=
0
;
}
Byte
(
unsigned
char
b1
,
unsigned
char
b2
){
raw
.
b
[
0
]
=
b1
;
raw
.
b
[
1
]
=
b2
;
}
Byte
(
const
long
val
)
{
raw
.
w
=
val
;
}
Byte
(
const
ModbusRTU
::
ModbusData
dat
)
{
raw
.
w
=
dat
;
}
~
Byte
(){}
// ------------------------------------------
/*! */
static
int
wsize
(){
return
1
;
}
/*! */
static
VType
type
(){
return
vtByte
;
}
// ------------------------------------------
operator
long
(){
return
lroundf
(
raw
.
w
);
}
unsigned
char
operator
[](
const
int
i
){
return
raw
.
b
[
i
];
}
Bytemem
raw
;
};
// --------------------------------------------------------------------------
}
// end of namespace VTypes
// --------------------------------------------------------------------------
...
...
extentions/lib/IOBase.cc
View file @
dd3b30d8
...
...
@@ -105,17 +105,18 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
return
;
}
// ...
if
(
!
it
->
nofilter
)
{
if
(
it
->
df
.
size
()
>
1
)
it
->
df
.
add
(
val
);
val
=
it
->
df
.
filterRC
(
val
);
}
if
(
it
->
cdiagram
)
//
{
// ,
// ,
if
(
!
it
->
nofilter
&&
it
->
df
.
size
()
>
1
)
{
if
(
it
->
f_median
)
val
=
it
->
df
.
median
(
val
);
else
val
=
it
->
df
.
filterRC
(
val
);
}
if
(
it
->
craw
!=
val
)
{
it
->
craw
=
val
;
...
...
@@ -130,6 +131,16 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
IOController_i
::
CalibrateInfo
*
cal
(
&
(
it
->
cal
)
);
if
(
cal
->
maxRaw
!=
0
&&
cal
->
maxRaw
!=
cal
->
minRaw
)
//
val
=
UniSetTypes
::
lcalibrate
(
val
,
cal
->
minRaw
,
cal
->
maxRaw
,
cal
->
minCal
,
cal
->
maxCal
,
true
);
// ,
// ,
if
(
!
it
->
nofilter
&&
it
->
df
.
size
()
>
1
)
{
if
(
it
->
f_median
)
val
=
it
->
df
.
median
(
val
);
else
val
=
it
->
df
.
filterRC
(
val
);
}
}
// "",
...
...
@@ -185,7 +196,7 @@ void IOBase::processingFasAI( IOBase* it, float fval, SMInterface* shm, bool for
IOController_i
::
CalibrateInfo
*
cal
(
&
(
it
->
cal
)
);
if
(
cal
->
maxRaw
!=
0
&&
cal
->
maxRaw
!=
cal
->
minRaw
)
//
val
=
UniSetTypes
::
f
calibrate
(
val
,
cal
->
minRaw
,
cal
->
maxRaw
,
cal
->
minCal
,
cal
->
maxCal
,
true
);
val
=
UniSetTypes
::
l
calibrate
(
val
,
cal
->
minRaw
,
cal
->
maxRaw
,
cal
->
minCal
,
cal
->
maxCal
,
true
);
// "",
//
...
...
@@ -246,12 +257,15 @@ void IOBase::processingAsDI( IOBase* it, bool set, SMInterface* shm, bool force
long
IOBase
::
processingAsAO
(
IOBase
*
it
,
SMInterface
*
shm
,
bool
force
)
{
uniset_spin_lock
lock
(
it
->
val_lock
);
long
val
=
it
->
value
;
if
(
force
)
{
val
=
shm
->
localGetValue
(
it
->
ait
,
it
->
si
.
id
);
if
(
it
->
stype
==
UniversalIO
::
DigitalInput
||
it
->
stype
==
UniversalIO
::
DigitalOutput
)
val
=
shm
->
localGetState
(
it
->
dit
,
it
->
si
.
id
)
?
1
:
0
;
else
if
(
it
->
stype
==
UniversalIO
::
AnalogInput
||
it
->
stype
==
UniversalIO
::
AnalogOutput
)
val
=
shm
->
localGetValue
(
it
->
ait
,
it
->
si
.
id
);
it
->
value
=
val
;
}
...
...
@@ -272,7 +286,7 @@ long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
else
{
IOController_i
::
CalibrateInfo
*
cal
(
&
(
it
->
cal
)
);
if
(
cal
->
maxRaw
!=
0
&&
cal
->
maxRaw
!=
cal
->
minRaw
)
//
if
(
cal
&&
cal
->
maxRaw
!=
0
&&
cal
->
maxRaw
!=
cal
->
minRaw
)
//
{
// !!!
val
=
UniSetTypes
::
lcalibrate
(
it
->
value
,
...
...
@@ -291,19 +305,19 @@ long IOBase::processingAsAO( IOBase* it, SMInterface* shm, bool force )
// -----------------------------------------------------------------------------
bool
IOBase
::
processingAsDO
(
IOBase
*
it
,
SMInterface
*
shm
,
bool
force
)
{
uniset_spin_lock
lock
(
it
->
val_lock
);
bool
set
=
it
->
value
;
if
(
it
->
stype
==
UniversalIO
::
DigitalOutput
||
it
->
stype
==
UniversalIO
::
DigitalInput
)
{
uniset_spin_lock
lock
(
it
->
val_lock
);
bool
set
=
it
->
value
;
if
(
force
)
set
=
shm
->
localGetState
(
it
->
dit
,
it
->
si
.
id
);
{
if
(
it
->
stype
==
UniversalIO
::
DigitalInput
||
it
->
stype
==
UniversalIO
::
DigitalOutput
)
set
=
shm
->
localGetState
(
it
->
dit
,
it
->
si
.
id
);
else
if
(
it
->
stype
==
UniversalIO
::
AnalogInput
||
it
->
stype
==
UniversalIO
::
AnalogOutput
)
set
=
shm
->
localGetValue
(
it
->
ait
,
it
->
si
.
id
)
?
true
:
false
;
}
set
=
it
->
invert
?
!
set
:
set
;
return
set
;
}
return
false
;
}
// -----------------------------------------------------------------------------
float
IOBase
::
processingFasAO
(
IOBase
*
it
,
SMInterface
*
shm
,
bool
force
)
...
...
@@ -351,6 +365,33 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
return
val
;
}
// -----------------------------------------------------------------------------
void
IOBase
::
processingThreshold
(
IOBase
*
it
,
SMInterface
*
shm
,
bool
force
)
{
if
(
it
->
t_ai
==
DefaultObjectId
)
return
;
if
(
!
it
->
initOK
)
{
shm
->
initAIterator
(
it
->
ait
);
shm
->
initDIterator
(
it
->
dit
);
it
->
initOK
=
true
;
}
long
val
=
shm
->
localGetValue
(
it
->
ait
,
it
->
t_ai
);
bool
set
=
it
->
value
?
true
:
false
;
cout
<<
"val="
<<
val
<<
" set="
<<
set
<<
endl
;
//
// lowLimit-
if
(
val
<=
(
it
->
ti
.
lowlimit
-
it
->
ti
.
sensibility
)
)
set
=
false
;
else
if
(
val
>=
(
it
->
ti
.
hilimit
+
it
->
ti
.
sensibility
)
)
set
=
true
;
cout
<<
"thresh: set="
<<
set
<<
endl
;
processingDI
(
it
,
set
,
shm
,
force
);
}
// -----------------------------------------------------------------------------
bool
IOBase
::
initItem
(
IOBase
*
b
,
UniXML_iterator
&
it
,
SMInterface
*
shm
,
DebugStream
*
dlog
,
std
::
string
myname
,
...
...
@@ -456,9 +497,6 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
}
}
for
(
int
i
=
0
;
i
<
f_size
;
i
++
)
b
->
df
.
add
(
b
->
defval
);
if
(
!
it
.
getProp
(
"filterT"
).
empty
()
)
{
f_T
=
atof
(
it
.
getProp
(
"filterT"
).
c_str
());
...
...
@@ -469,10 +507,36 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
if
(
b
->
stype
==
UniversalIO
::
AnalogInput
)
b
->
df
.
setSettings
(
f_size
,
f_T
);
b
->
df
.
init
(
b
->
defval
);
std
::
string
caldiagram
(
it
.
getProp
(
"caldiagram"
)
);
if
(
!
caldiagram
.
empty
()
)
b
->
cdiagram
=
UniSetExtentions
::
buildCalibrationDiagram
(
caldiagram
);
}
else
if
(
b
->
stype
==
UniversalIO
::
DigitalInput
||
b
->
stype
==
UniversalIO
::
DigitalOutput
)
{
string
tai
(
it
.
getProp
(
"threshold_aid"
));
if
(
!
tai
.
empty
()
)
{
b
->
t_ai
=
conf
->
getSensorID
(
tai
);
if
(
b
->
t_ai
==
DefaultObjectId
)
{
if
(
dlog
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(IOBase::readItem): unknown ID for threshold_ai "
<<
tai
<<
endl
;
return
false
;
}
b
->
ti
.
lowlimit
=
uni_atoi
(
it
.
getProp
(
"lowlimit"
).
c_str
()
);
b
->
ti
.
hilimit
=
uni_atoi
(
it
.
getProp
(
"hilimit"
).
c_str
()
);
b
->
ti
.
sensibility
=
uni_atoi
(
it
.
getProp
(
"sensibility"
).
c_str
()
);
}
}
// else
// {
// dlog[Debug::CRIT] << myname << "(IOBase::readItem): iotype=: " << stype << " " << sname << endl;
// return false;
// }
return
true
;
}
...
...
extentions/lib/VTypes.cc
View file @
dd3b30d8
...
...
@@ -16,6 +16,9 @@ std::ostream& operator<<( std::ostream& os, const VType& vt )
VType
str2type
(
const
std
::
string
s
)
{
if
(
s
==
"Byte"
)
return
vtByte
;
if
(
s
==
"F2"
)
return
vtF2
;
if
(
s
==
"F4"
)
...
...
@@ -26,6 +29,8 @@ VType str2type( const std::string s )
// -------------------------------------------------------------------------
string
type2str
(
VType
t
)
{
if
(
t
==
vtByte
)
return
"Byte"
;
if
(
t
==
vtF2
)
return
"F2"
;
if
(
t
==
vtF4
)
...
...
@@ -36,6 +41,8 @@ string type2str( VType t )
// -------------------------------------------------------------------------
int
wsize
(
VType
t
)
{
if
(
t
==
vtByte
)
return
Byte
::
wsize
();
if
(
t
==
vtF2
)
return
F2
::
wsize
();
if
(
t
==
vtF4
)
...
...
src/Various/DebugStream.cc
View file @
dd3b30d8
...
...
@@ -207,11 +207,16 @@ DebugStream::~DebugStream()
//--------------------------------------------------------------------------
const
DebugStream
&
DebugStream
::
operator
=
(
const
DebugStream
&
r
)
{
if
(
r
==
*
this
)
return
*
this
;
dt
=
r
.
dt
;
show_datetime
=
r
.
show_datetime
;
fname
=
r
.
fname
;
if
(
!
r
.
fname
.
empty
()
)
logFile
(
fname
.
c_str
());
return
*
this
;
}
//--------------------------------------------------------------------------
/// Sets the debugstreams' logfile to f.
...
...
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