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
c7609b05
Commit
c7609b05
authored
Dec 16, 2013
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(2.0): небольшая оптимизация по выводу логов
parent
005865f3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
105 deletions
+155
-105
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+101
-11
MBTCPMaster.cc
extensions/ModbusMaster/MBTCPMaster.cc
+5
-0
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+48
-26
IONotifyController.cc
src/Processes/IONotifyController.cc
+1
-68
No files found.
extensions/ModbusMaster/MBExchange.cc
View file @
c7609b05
...
@@ -72,7 +72,6 @@ pollActivated(false)
...
@@ -72,7 +72,6 @@ pollActivated(false)
aftersend_pause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-aftersend-pause"
,
it
.
getProp
(
"aftersend_pause"
),
0
);
aftersend_pause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-aftersend-pause"
,
it
.
getProp
(
"aftersend_pause"
),
0
);
noQueryOptimization
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-no-query-optimization"
,
it
.
getProp
(
"no_query_optimization"
));
noQueryOptimization
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-no-query-optimization"
,
it
.
getProp
(
"no_query_optimization"
));
mbregFromID
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-reg-from-id"
,
it
.
getProp
(
"reg_from_id"
));
mbregFromID
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-reg-from-id"
,
it
.
getProp
(
"reg_from_id"
));
...
@@ -218,6 +217,7 @@ void MBExchange::step()
...
@@ -218,6 +217,7 @@ void MBExchange::step()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(step): (hb) "
<<
ex
<<
std
::
endl
;
<<
"(step): (hb) "
<<
ex
<<
std
::
endl
;
}
}
...
@@ -239,6 +239,7 @@ void MBExchange::setProcActive( bool st )
...
@@ -239,6 +239,7 @@ void MBExchange::setProcActive( bool st )
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
MBExchange
::
sigterm
(
int
signo
)
void
MBExchange
::
sigterm
(
int
signo
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
": ********* SIGTERM("
<<
signo
<<
") ********"
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
": ********* SIGTERM("
<<
signo
<<
") ********"
<<
endl
;
setProcActive
(
false
);
setProcActive
(
false
);
UniSetObject_LT
::
sigterm
(
signo
);
UniSetObject_LT
::
sigterm
(
signo
);
...
@@ -258,6 +259,7 @@ void MBExchange::readConfiguration()
...
@@ -258,6 +259,7 @@ void MBExchange::readConfiguration()
UniXML_iterator
it
(
root
);
UniXML_iterator
it
(
root
);
if
(
!
it
.
goChildren
()
)
if
(
!
it
.
goChildren
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readConfiguration): раздел <sensors> не содержит секций ?!!
\n
"
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readConfiguration): раздел <sensors> не содержит секций ?!!
\n
"
;
return
;
return
;
}
}
...
@@ -492,6 +494,7 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
...
@@ -492,6 +494,7 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
// check correct function...
// check correct function...
if
(
beg
->
second
->
q_count
>
1
&&
beg
->
second
->
mbfunc
==
ModbusRTU
::
fnWriteOutputSingleRegister
)
if
(
beg
->
second
->
q_count
>
1
&&
beg
->
second
->
mbfunc
==
ModbusRTU
::
fnWriteOutputSingleRegister
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(rtuQueryOptimization): "
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(rtuQueryOptimization): "
<<
" optimization change func="
<<
ModbusRTU
::
fnWriteOutputSingleRegister
<<
" optimization change func="
<<
ModbusRTU
::
fnWriteOutputSingleRegister
<<
" <--> func="
<<
ModbusRTU
::
fnWriteOutputRegisters
<<
" <--> func="
<<
ModbusRTU
::
fnWriteOutputRegisters
...
@@ -502,6 +505,7 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
...
@@ -502,6 +505,7 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
}
}
else
if
(
beg
->
second
->
q_count
>
1
&&
beg
->
second
->
mbfunc
==
ModbusRTU
::
fnForceSingleCoil
)
else
if
(
beg
->
second
->
q_count
>
1
&&
beg
->
second
->
mbfunc
==
ModbusRTU
::
fnForceSingleCoil
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(rtuQueryOptimization): "
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(rtuQueryOptimization): "
<<
" optimization change func="
<<
ModbusRTU
::
fnForceSingleCoil
<<
" optimization change func="
<<
ModbusRTU
::
fnForceSingleCoil
<<
" <--> func="
<<
ModbusRTU
::
fnForceMultipleCoils
<<
" <--> func="
<<
ModbusRTU
::
fnForceMultipleCoils
...
@@ -677,6 +681,7 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
...
@@ -677,6 +681,7 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
return
true
;
return
true
;
}
}
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initSMValue): IGNORE item: rnum="
<<
p
->
rnum
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initSMValue): IGNORE item: rnum="
<<
p
->
rnum
<<
" > 1 ?!! for id="
<<
p
->
si
.
id
<<
endl
;
<<
" > 1 ?!! for id="
<<
p
->
si
.
id
<<
endl
;
...
@@ -710,6 +715,7 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
...
@@ -710,6 +715,7 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
{
{
if
(
p
->
nbyte
<=
0
||
p
->
nbyte
>
VTypes
::
Byte
::
bsize
)
if
(
p
->
nbyte
<=
0
||
p
->
nbyte
>
VTypes
::
Byte
::
bsize
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initSMValue): IGNORE item: sid="
<<
ModbusRTU
::
dat2str
(
p
->
si
.
id
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initSMValue): IGNORE item: sid="
<<
ModbusRTU
::
dat2str
(
p
->
si
.
id
)
<<
" vtype="
<<
p
->
vType
<<
" but nbyte="
<<
p
->
nbyte
<<
endl
;
<<
" vtype="
<<
p
->
vType
<<
" but nbyte="
<<
p
->
nbyte
<<
endl
;
return
false
;
return
false
;
...
@@ -744,27 +750,33 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
...
@@ -744,27 +750,33 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue):(NameNotFound) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue):(IOBadParam) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): (BadRange)..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): "
<<
ex
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): CORBA::SystemException: "
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): catch ..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): catch ..."
<<
endl
;
}
}
...
@@ -869,6 +881,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
...
@@ -869,6 +881,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
{
{
if
(
p
->
q_count
!=
1
)
if
(
p
->
q_count
!=
1
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(pollRTU): mbreg="
<<
ModbusRTU
::
dat2str
(
p
->
mbreg
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(pollRTU): mbreg="
<<
ModbusRTU
::
dat2str
(
p
->
mbreg
)
<<
" IGNORE WRITE SINGLE REGISTER (0x06) q_count="
<<
p
->
q_count
<<
" ..."
<<
endl
;
<<
" IGNORE WRITE SINGLE REGISTER (0x06) q_count="
<<
p
->
q_count
<<
" ..."
<<
endl
;
return
false
;
return
false
;
...
@@ -928,6 +941,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
...
@@ -928,6 +941,7 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
{
{
if
(
p
->
q_count
!=
1
)
if
(
p
->
q_count
!=
1
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(pollRTU): mbreg="
<<
ModbusRTU
::
dat2str
(
p
->
mbreg
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(pollRTU): mbreg="
<<
ModbusRTU
::
dat2str
(
p
->
mbreg
)
<<
" IGNORE FORCE SINGLE COIL (0x05) q_count="
<<
p
->
q_count
<<
" ..."
<<
endl
;
<<
" IGNORE FORCE SINGLE COIL (0x05) q_count="
<<
p
->
q_count
<<
" ..."
<<
endl
;
return
false
;
return
false
;
...
@@ -993,27 +1007,33 @@ void MBExchange::updateSM()
...
@@ -993,27 +1007,33 @@ void MBExchange::updateSM()
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(NameNotFound) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(IOBadParam) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): CORBA::SystemException: "
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): check modeSensor..catch ..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): check modeSensor..catch ..."
<<
endl
;
}
}
}
}
...
@@ -1036,27 +1056,33 @@ void MBExchange::updateSM()
...
@@ -1036,27 +1056,33 @@ void MBExchange::updateSM()
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(NameNotFound) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(IOBadParam) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): CORBA::SystemException: "
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): catch ..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): catch ..."
<<
endl
;
}
}
...
@@ -1162,6 +1188,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1162,6 +1188,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
return
;
return
;
}
}
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(updateRSProperty): IGNORE item: rnum="
<<
p
->
rnum
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(updateRSProperty): IGNORE item: rnum="
<<
p
->
rnum
<<
" > 1 ?!! for id="
<<
p
->
si
.
id
<<
endl
;
<<
" > 1 ?!! for id="
<<
p
->
si
.
id
<<
endl
;
return
;
return
;
...
@@ -1232,6 +1259,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1232,6 +1259,7 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
{
{
if
(
p
->
nbyte
<=
0
||
p
->
nbyte
>
VTypes
::
Byte
::
bsize
)
if
(
p
->
nbyte
<=
0
||
p
->
nbyte
>
VTypes
::
Byte
::
bsize
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(updateRSProperty): IGNORE item: reg="
<<
ModbusRTU
::
dat2str
(
r
->
mbreg
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(updateRSProperty): IGNORE item: reg="
<<
ModbusRTU
::
dat2str
(
r
->
mbreg
)
<<
" vtype="
<<
p
->
vType
<<
" but nbyte="
<<
p
->
nbyte
<<
endl
;
<<
" vtype="
<<
p
->
vType
<<
" but nbyte="
<<
p
->
nbyte
<<
endl
;
return
;
return
;
...
@@ -1367,27 +1395,33 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1367,27 +1395,33 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(NameNotFound) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(IOBadParam) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): (BadRange)..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): "
<<
ex
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): CORBA::SystemException: "
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): catch ..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): catch ..."
<<
endl
;
}
}
...
@@ -1465,7 +1499,10 @@ void MBExchange::updateMTR( RegMap::iterator& rit )
...
@@ -1465,7 +1499,10 @@ void MBExchange::updateMTR( RegMap::iterator& rit )
if
(
r
->
mtrType
==
MTR
::
mtT4
)
if
(
r
->
mtrType
==
MTR
::
mtT4
)
{
{
if
(
save
)
if
(
save
)
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(updateMTR): write (T4) reg("
<<
dat2str
(
r
->
mbreg
)
<<
") to MTR NOT YET!!!"
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(updateMTR): write (T4) reg("
<<
dat2str
(
r
->
mbreg
)
<<
") to MTR NOT YET!!!"
<<
endl
;
}
else
else
{
{
MTR
::
T4
t
(
r
->
mbval
);
MTR
::
T4
t
(
r
->
mbval
);
...
@@ -1599,27 +1636,33 @@ void MBExchange::updateMTR( RegMap::iterator& rit )
...
@@ -1599,27 +1636,33 @@ void MBExchange::updateMTR( RegMap::iterator& rit )
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR):(NameNotFound) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR):(IOBadParam) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): (BadRange)..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): "
<<
ex
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): CORBA::SystemException: "
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): catch ..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): catch ..."
<<
endl
;
}
}
}
}
...
@@ -1640,7 +1683,8 @@ void MBExchange::updateRTU188( RegMap::iterator& rit )
...
@@ -1640,7 +1683,8 @@ void MBExchange::updateRTU188( RegMap::iterator& rit )
// не реализованы
// не реализованы
if
(
isWriteFunction
(
r
->
mbfunc
)
)
if
(
isWriteFunction
(
r
->
mbfunc
)
)
{
{
cerr
<<
myname
<<
"(updateRTU188): write reg("
<<
dat2str
(
r
->
mbreg
)
<<
") to RTU188 NOT YET!!!"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): write reg("
<<
dat2str
(
r
->
mbreg
)
<<
") to RTU188 NOT YET!!!"
<<
endl
;
return
;
return
;
}
}
...
@@ -1693,27 +1737,33 @@ void MBExchange::updateRTU188( RegMap::iterator& rit )
...
@@ -1693,27 +1737,33 @@ void MBExchange::updateRTU188( RegMap::iterator& rit )
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188):(NameNotFound) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188):(IOBadParam) "
<<
ex
.
err
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): (BadRange)..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): "
<<
ex
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): CORBA::SystemException: "
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): catch ..."
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): catch ..."
<<
endl
;
}
}
}
}
...
@@ -1728,6 +1778,7 @@ MBExchange::RTUDevice* MBExchange::addDev( RTUDeviceMap& mp, ModbusRTU::ModbusAd
...
@@ -1728,6 +1778,7 @@ MBExchange::RTUDevice* MBExchange::addDev( RTUDeviceMap& mp, ModbusRTU::ModbusAd
DeviceType
dtype
=
getDeviceType
(
xmlit
.
getProp
(
prop_prefix
+
"mbtype"
));
DeviceType
dtype
=
getDeviceType
(
xmlit
.
getProp
(
prop_prefix
+
"mbtype"
));
if
(
it
->
second
->
dtype
!=
dtype
)
if
(
it
->
second
->
dtype
!=
dtype
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(addDev): OTHER mbtype="
<<
dtype
<<
" for "
<<
xmlit
.
getProp
(
"name"
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(addDev): OTHER mbtype="
<<
dtype
<<
" for "
<<
xmlit
.
getProp
(
"name"
)
<<
". Already used devtype="
<<
it
->
second
->
dtype
<<
". Already used devtype="
<<
it
->
second
->
dtype
<<
" for mbaddr="
<<
ModbusRTU
::
addr2str
(
it
->
second
->
mbaddr
)
<<
" for mbaddr="
<<
ModbusRTU
::
addr2str
(
it
->
second
->
mbaddr
)
...
@@ -1735,6 +1786,7 @@ MBExchange::RTUDevice* MBExchange::addDev( RTUDeviceMap& mp, ModbusRTU::ModbusAd
...
@@ -1735,6 +1786,7 @@ MBExchange::RTUDevice* MBExchange::addDev( RTUDeviceMap& mp, ModbusRTU::ModbusAd
return
0
;
return
0
;
}
}
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(addDev): device for addr="
<<
ModbusRTU
::
addr2str
(
a
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(addDev): device for addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
" already added. Ignore device params for "
<<
xmlit
.
getProp
(
"name"
)
<<
" ..."
<<
endl
;
<<
" already added. Ignore device params for "
<<
xmlit
.
getProp
(
"name"
)
<<
" ..."
<<
endl
;
return
it
->
second
;
return
it
->
second
;
...
@@ -1769,6 +1821,7 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, RegID id, ModbusRTU::Modbus
...
@@ -1769,6 +1821,7 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, RegID id, ModbusRTU::Modbus
if
(
it
->
second
->
dev
->
dtype
!=
dev
->
dtype
)
if
(
it
->
second
->
dev
->
dtype
!=
dev
->
dtype
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(addReg): OTHER mbtype="
<<
dev
->
dtype
<<
" for "
<<
xmlit
.
getProp
(
"name"
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(addReg): OTHER mbtype="
<<
dev
->
dtype
<<
" for "
<<
xmlit
.
getProp
(
"name"
)
<<
". Already used devtype="
<<
it
->
second
->
dev
->
dtype
<<
" for "
<<
it
->
second
->
dev
<<
endl
;
<<
". Already used devtype="
<<
it
->
second
->
dev
->
dtype
<<
" for "
<<
it
->
second
->
dev
<<
endl
;
return
0
;
return
0
;
...
@@ -1847,7 +1900,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1847,7 +1900,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
p
.
stype
=
UniSetTypes
::
getIOType
(
stype
);
p
.
stype
=
UniSetTypes
::
getIOType
(
stype
);
if
(
p
.
stype
==
UniversalIO
::
UnknownIOType
)
if
(
p
.
stype
==
UniversalIO
::
UnknownIOType
)
{
{
if
(
dlog
)
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(IOBase::readItem): неизвестный iotype=: "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(IOBase::readItem): неизвестный iotype=: "
<<
stype
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
stype
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
...
@@ -1860,6 +1913,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1860,6 +1913,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
p
.
nbit
=
UniSetTypes
::
uni_atoi
(
sbit
.
c_str
());
p
.
nbit
=
UniSetTypes
::
uni_atoi
(
sbit
.
c_str
());
if
(
p
.
nbit
<
0
||
p
.
nbit
>=
ModbusRTU
::
BitsPerData
)
if
(
p
.
nbit
<
0
||
p
.
nbit
>=
ModbusRTU
::
BitsPerData
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): BAD nbit="
<<
p
.
nbit
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): BAD nbit="
<<
p
.
nbit
<<
". (0 >= nbit < "
<<
ModbusRTU
::
BitsPerData
<<
")."
<<
endl
;
<<
". (0 >= nbit < "
<<
ModbusRTU
::
BitsPerData
<<
")."
<<
endl
;
return
false
;
return
false
;
...
@@ -1870,6 +1924,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1870,6 +1924,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
(
p
.
stype
==
UniversalIO
::
AI
||
(
p
.
stype
==
UniversalIO
::
AI
||
p
.
stype
==
UniversalIO
::
AO
)
)
p
.
stype
==
UniversalIO
::
AO
)
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
"(initRSProperty): (ignore) uncorrect param`s nbit>1 ("
<<
p
.
nbit
<<
")"
dlog
[
Debug
::
WARN
]
<<
"(initRSProperty): (ignore) uncorrect param`s nbit>1 ("
<<
p
.
nbit
<<
")"
<<
" but iotype="
<<
p
.
stype
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" but iotype="
<<
p
.
stype
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
}
}
...
@@ -1880,6 +1935,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1880,6 +1935,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
p
.
nbyte
=
UniSetTypes
::
uni_atoi
(
sbyte
.
c_str
());
p
.
nbyte
=
UniSetTypes
::
uni_atoi
(
sbyte
.
c_str
());
if
(
p
.
nbyte
<
0
||
p
.
nbyte
>
VTypes
::
Byte
::
bsize
)
if
(
p
.
nbyte
<
0
||
p
.
nbyte
>
VTypes
::
Byte
::
bsize
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): BAD nbyte="
<<
p
.
nbyte
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): BAD nbyte="
<<
p
.
nbyte
<<
". (0 >= nbyte < "
<<
VTypes
::
Byte
::
bsize
<<
")."
<<
endl
;
<<
". (0 >= nbyte < "
<<
VTypes
::
Byte
::
bsize
<<
")."
<<
endl
;
return
false
;
return
false
;
...
@@ -1897,6 +1953,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1897,6 +1953,7 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
VTypes
::
VType
v
(
VTypes
::
str2type
(
vt
));
VTypes
::
VType
v
(
VTypes
::
str2type
(
vt
));
if
(
v
==
VTypes
::
vtUnknown
)
if
(
v
==
VTypes
::
vtUnknown
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): Unknown tcp_vtype='"
<<
vt
<<
"' for "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): Unknown tcp_vtype='"
<<
vt
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
endl
;
...
@@ -1943,6 +2000,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
...
@@ -1943,6 +2000,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
}
}
else
else
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRegInfo): Unknown mbtype='"
<<
dev
->
dtype
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRegInfo): Unknown mbtype='"
<<
dev
->
dtype
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
...
@@ -1960,6 +2018,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
...
@@ -1960,6 +2018,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
string
sr
=
it
.
getProp
(
prop_prefix
+
"mbreg"
);
string
sr
=
it
.
getProp
(
prop_prefix
+
"mbreg"
);
if
(
sr
.
empty
()
)
if
(
sr
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'mbreg' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'mbreg' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -1973,6 +2032,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
...
@@ -1973,6 +2032,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
r
->
mbfunc
=
(
ModbusRTU
::
SlaveFunctionCode
)
UniSetTypes
::
uni_atoi
(
f
.
c_str
());
r
->
mbfunc
=
(
ModbusRTU
::
SlaveFunctionCode
)
UniSetTypes
::
uni_atoi
(
f
.
c_str
());
if
(
r
->
mbfunc
==
ModbusRTU
::
fnUnknown
)
if
(
r
->
mbfunc
==
ModbusRTU
::
fnUnknown
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRegInfo): Unknown mbfunc ='"
<<
f
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRegInfo): Unknown mbfunc ='"
<<
f
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
...
@@ -1988,6 +2048,7 @@ bool MBExchange::initRTUDevice( RTUDevice* d, UniXML_iterator& it )
...
@@ -1988,6 +2048,7 @@ bool MBExchange::initRTUDevice( RTUDevice* d, UniXML_iterator& it )
if
(
d
->
dtype
==
dtUnknown
)
if
(
d
->
dtype
==
dtUnknown
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRTUDevice): Unknown tcp_mbtype="
<<
it
.
getProp
(
prop_prefix
+
"mbtype"
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRTUDevice): Unknown tcp_mbtype="
<<
it
.
getProp
(
prop_prefix
+
"mbtype"
)
<<
". Use: rtu "
<<
". Use: rtu "
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
...
@@ -1997,6 +2058,7 @@ bool MBExchange::initRTUDevice( RTUDevice* d, UniXML_iterator& it )
...
@@ -1997,6 +2058,7 @@ bool MBExchange::initRTUDevice( RTUDevice* d, UniXML_iterator& it )
string
addr
=
it
.
getProp
(
prop_prefix
+
"mbaddr"
);
string
addr
=
it
.
getProp
(
prop_prefix
+
"mbaddr"
);
if
(
addr
.
empty
()
)
if
(
addr
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRTUDevice): Unknown mbaddr for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRTUDevice): Unknown mbaddr for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2018,9 +2080,10 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2018,9 +2080,10 @@ bool MBExchange::initItem( UniXML_iterator& it )
if
(
!
initRSProperty
(
p
,
it
)
)
if
(
!
initRSProperty
(
p
,
it
)
)
return
false
;
return
false
;
string
addr
=
it
.
getProp
(
prop_prefix
+
"mbaddr"
);
string
addr
(
it
.
getProp
(
prop_prefix
+
"mbaddr"
)
);
if
(
addr
.
empty
()
)
if
(
addr
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown mbaddr("
<<
prop_prefix
<<
"mbaddr)='"
<<
addr
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown mbaddr("
<<
prop_prefix
<<
"mbaddr)='"
<<
addr
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2030,6 +2093,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2030,6 +2093,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
RTUDevice
*
dev
=
addDev
(
rmap
,
mbaddr
,
it
);
RTUDevice
*
dev
=
addDev
(
rmap
,
mbaddr
,
it
);
if
(
!
dev
)
if
(
!
dev
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): "
<<
it
.
getProp
(
"name"
)
<<
" CAN`T ADD for polling!"
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): "
<<
it
.
getProp
(
"name"
)
<<
" CAN`T ADD for polling!"
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2042,6 +2106,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2042,6 +2106,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
RegInfo
r_tmp
;
RegInfo
r_tmp
;
if
(
!
initRTU188item
(
it
,
&
r_tmp
)
)
if
(
!
initRTU188item
(
it
,
&
r_tmp
)
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): init RTU188 failed for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): init RTU188 failed for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2058,6 +2123,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2058,6 +2123,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
string
reg
=
it
.
getProp
(
prop_prefix
+
"mbreg"
);
string
reg
=
it
.
getProp
(
prop_prefix
+
"mbreg"
);
if
(
reg
.
empty
()
)
if
(
reg
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): unknown mbreg("
<<
prop_prefix
<<
") for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): unknown mbreg("
<<
prop_prefix
<<
") for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2078,6 +2144,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2078,6 +2144,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
p
.
rnum
=
MTR
::
wsize
(
ri
->
mtrType
);
p
.
rnum
=
MTR
::
wsize
(
ri
->
mtrType
);
if
(
p
.
rnum
<=
0
)
if
(
p
.
rnum
<=
0
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): unknown word size for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): unknown word size for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2102,6 +2169,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2102,6 +2169,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
{
{
if
(
p
.
nbit
<
0
&&
ri
->
slst
.
size
()
>
1
)
if
(
p
.
nbit
<
0
&&
ri
->
slst
.
size
()
>
1
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): FAILED! Sharing SAVE (not bit saving) to "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): FAILED! Sharing SAVE (not bit saving) to "
<<
" tcp_mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
<<
" tcp_mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
...
@@ -2115,6 +2183,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2115,6 +2183,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
PList
::
iterator
it2
=
ri
->
slst
.
begin
();
PList
::
iterator
it2
=
ri
->
slst
.
begin
();
if
(
it2
->
nbit
<
0
)
if
(
it2
->
nbit
<
0
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): FAILED! Sharing SAVE (mbreg="
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): FAILED! Sharing SAVE (mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
<<
" already used)!"
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
<<
" already used)!"
<<
" IGNORE --> "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" IGNORE --> "
<<
it
.
getProp
(
"name"
)
<<
endl
;
...
@@ -2164,6 +2233,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2164,6 +2233,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
if
(
ri
->
mbfunc
!=
ModbusRTU
::
fnWriteOutputRegisters
&&
if
(
ri
->
mbfunc
!=
ModbusRTU
::
fnWriteOutputRegisters
&&
ri
->
mbfunc
!=
ModbusRTU
::
fnForceMultipleCoils
)
ri
->
mbfunc
!=
ModbusRTU
::
fnForceMultipleCoils
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Bad write function ='"
<<
ModbusRTU
::
fnWriteOutputSingleRegister
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Bad write function ='"
<<
ModbusRTU
::
fnWriteOutputSingleRegister
<<
"' for vtype='"
<<
p1
->
vType
<<
"'"
<<
"' for vtype='"
<<
p1
->
vType
<<
"'"
<<
" tcp_mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
<<
" tcp_mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
...
@@ -2197,6 +2267,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2197,6 +2267,7 @@ bool MBExchange::initItem( UniXML_iterator& it )
ii
.
mbfunc
=
(
ModbusRTU
::
SlaveFunctionCode
)
UniSetTypes
::
uni_atoi
(
s_mbfunc
);
ii
.
mbfunc
=
(
ModbusRTU
::
SlaveFunctionCode
)
UniSetTypes
::
uni_atoi
(
s_mbfunc
);
if
(
ii
.
mbfunc
==
ModbusRTU
::
fnUnknown
)
if
(
ii
.
mbfunc
==
ModbusRTU
::
fnUnknown
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown tcp_init_mbfunc ='"
<<
s_mbfunc
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown tcp_init_mbfunc ='"
<<
s_mbfunc
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
...
@@ -2241,6 +2312,7 @@ bool MBExchange::initMTRitem( UniXML_iterator& it, RegInfo* p )
...
@@ -2241,6 +2312,7 @@ bool MBExchange::initMTRitem( UniXML_iterator& it, RegInfo* p )
p
->
mtrType
=
MTR
::
str2type
(
it
.
getProp
(
prop_prefix
+
"mtrtype"
));
p
->
mtrType
=
MTR
::
str2type
(
it
.
getProp
(
prop_prefix
+
"mtrtype"
));
if
(
p
->
mtrType
==
MTR
::
mtUnknown
)
if
(
p
->
mtrType
==
MTR
::
mtUnknown
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readMTRItem): Unknown mtrtype '"
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readMTRItem): Unknown mtrtype '"
<<
it
.
getProp
(
prop_prefix
+
"mtrtype"
)
<<
it
.
getProp
(
prop_prefix
+
"mtrtype"
)
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
...
@@ -2258,6 +2330,7 @@ bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
...
@@ -2258,6 +2330,7 @@ bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
if
(
jack
.
empty
()
)
if
(
jack
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown "
<<
prop_prefix
<<
"jack='' "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown "
<<
prop_prefix
<<
"jack='' "
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
...
@@ -2265,6 +2338,7 @@ bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
...
@@ -2265,6 +2338,7 @@ bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
p
->
rtuJack
=
RTUStorage
::
s2j
(
jack
);
p
->
rtuJack
=
RTUStorage
::
s2j
(
jack
);
if
(
p
->
rtuJack
==
RTUStorage
::
nUnknown
)
if
(
p
->
rtuJack
==
RTUStorage
::
nUnknown
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown "
<<
prop_prefix
<<
"jack="
<<
jack
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown "
<<
prop_prefix
<<
"jack="
<<
jack
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
...
@@ -2272,6 +2346,7 @@ bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
...
@@ -2272,6 +2346,7 @@ bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
if
(
chan
.
empty
()
)
if
(
chan
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown channel='' "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown channel='' "
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
...
@@ -2348,10 +2423,10 @@ void MBExchange::initDeviceList()
...
@@ -2348,10 +2423,10 @@ void MBExchange::initDeviceList()
initDeviceInfo
(
rmap
,
a
,
it1
);
initDeviceInfo
(
rmap
,
a
,
it1
);
}
}
}
}
else
else
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): <DeviceList> empty section..."
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): <DeviceList> empty section..."
<<
endl
;
}
}
else
else
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): <DeviceList> not found..."
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): <DeviceList> not found..."
<<
endl
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -2360,12 +2435,14 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
...
@@ -2360,12 +2435,14 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
RTUDeviceMap
::
iterator
d
=
m
.
find
(
a
);
RTUDeviceMap
::
iterator
d
=
m
.
find
(
a
);
if
(
d
==
m
.
end
()
)
if
(
d
==
m
.
end
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(initDeviceInfo): not found device for addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(initDeviceInfo): not found device for addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
return
false
;
return
false
;
}
}
d
->
second
->
ask_every_reg
=
it
.
getIntProp
(
"ask_every_reg"
);
d
->
second
->
ask_every_reg
=
it
.
getIntProp
(
"ask_every_reg"
);
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
" ask_every_reg="
<<
d
->
second
->
ask_every_reg
<<
endl
;
<<
" ask_every_reg="
<<
d
->
second
->
ask_every_reg
<<
endl
;
...
@@ -2375,6 +2452,7 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
...
@@ -2375,6 +2452,7 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
d
->
second
->
resp_id
=
conf
->
getSensorID
(
s
);
d
->
second
->
resp_id
=
conf
->
getSensorID
(
s
);
if
(
d
->
second
->
resp_id
==
DefaultObjectId
)
if
(
d
->
second
->
resp_id
==
DefaultObjectId
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): not found ID for respondSensor="
<<
s
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): not found ID for respondSensor="
<<
s
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2386,6 +2464,7 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
...
@@ -2386,6 +2464,7 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
d
->
second
->
mode_id
=
conf
->
getSensorID
(
mod
);
d
->
second
->
mode_id
=
conf
->
getSensorID
(
mod
);
if
(
d
->
second
->
mode_id
==
DefaultObjectId
)
if
(
d
->
second
->
mode_id
==
DefaultObjectId
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): not found ID for modeSensor="
<<
mod
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): not found ID for modeSensor="
<<
mod
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2393,19 +2472,17 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
...
@@ -2393,19 +2472,17 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
UniversalIO
::
IOType
m_iotype
=
conf
->
getIOType
(
d
->
second
->
mode_id
);
UniversalIO
::
IOType
m_iotype
=
conf
->
getIOType
(
d
->
second
->
mode_id
);
if
(
m_iotype
!=
UniversalIO
::
AI
)
if
(
m_iotype
!=
UniversalIO
::
AI
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): modeSensor='"
<<
mod
<<
"' must be 'AI'"
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): modeSensor='"
<<
mod
<<
"' must be 'AI'"
<<
endl
;
return
false
;
return
false
;
}
}
}
}
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
int
tout
=
it
.
getPIntProp
(
"timeout"
,
5000
);
int
tout
=
it
.
getPIntProp
(
"timeout"
,
5000
);
d
->
second
->
resp_ptTimeout
.
setTiming
(
tout
);
d
->
second
->
resp_ptTimeout
.
setTiming
(
tout
);
d
->
second
->
resp_invert
=
it
.
getIntProp
(
"invert"
);
d
->
second
->
resp_invert
=
it
.
getIntProp
(
"invert"
);
// d->second->no_clean_input = it.getIntProp("no_clean_input");
// dlog[Debug::INFO] << myname << "(initDeviceInfo): add " << (*d->second) << endl;
return
true
;
return
true
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -2460,15 +2537,18 @@ void MBExchange::processingMessage(UniSetTypes::VoidMessage *msg)
...
@@ -2460,15 +2537,18 @@ void MBExchange::processingMessage(UniSetTypes::VoidMessage *msg)
}
}
catch
(
SystemError
&
ex
)
catch
(
SystemError
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(SystemError): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(SystemError): "
<<
ex
<<
std
::
endl
;
// throw SystemError(ex);
// throw SystemError(ex);
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): catch ...
\n
"
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): catch ...
\n
"
;
}
}
}
}
...
@@ -2481,6 +2561,7 @@ void MBExchange::sysCommand( UniSetTypes::SystemMessage *sm )
...
@@ -2481,6 +2561,7 @@ void MBExchange::sysCommand( UniSetTypes::SystemMessage *sm )
{
{
if
(
rmap
.
empty
()
)
if
(
rmap
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): ************* ITEM MAP EMPTY! terminated... *************"
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): ************* ITEM MAP EMPTY! terminated... *************"
<<
endl
;
raise
(
SIGTERM
);
raise
(
SIGTERM
);
return
;
return
;
...
@@ -2506,7 +2587,7 @@ void MBExchange::sysCommand( UniSetTypes::SystemMessage *sm )
...
@@ -2506,7 +2587,7 @@ void MBExchange::sysCommand( UniSetTypes::SystemMessage *sm )
break
;
break
;
}
}
if
(
!
activated
)
if
(
!
activated
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
{
{
...
@@ -2599,10 +2680,12 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -2599,10 +2680,12 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
}
}
catch
(
UniSetTypes
::
Exception
&
ex
)
catch
(
UniSetTypes
::
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): 'sidExchangeMode' catch..."
<<
std
::
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): 'sidExchangeMode' catch..."
<<
std
::
endl
;
}
}
...
@@ -2617,10 +2700,12 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -2617,10 +2700,12 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
}
}
catch
(
UniSetTypes
::
Exception
&
ex
)
catch
(
UniSetTypes
::
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): (mode_id="
<<
d
->
mode_id
<<
").. catch..."
<<
std
::
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): (mode_id="
<<
d
->
mode_id
<<
").. catch..."
<<
std
::
endl
;
}
}
...
@@ -2640,10 +2725,12 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -2640,10 +2725,12 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
}
}
catch
(
UniSetTypes
::
Exception
&
ex
)
catch
(
UniSetTypes
::
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): id="
<<
i
->
si
.
id
<<
" catch..."
<<
std
::
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): id="
<<
i
->
si
.
id
<<
" catch..."
<<
std
::
endl
;
}
}
}
}
...
@@ -2922,6 +3009,7 @@ void MBExchange::updateRespondSensors()
...
@@ -2922,6 +3009,7 @@ void MBExchange::updateRespondSensors()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(step): (respond) "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(step): (respond) "
<<
ex
<<
std
::
endl
;
}
}
}
}
...
@@ -2948,10 +3036,12 @@ void MBExchange::execute()
...
@@ -2948,10 +3036,12 @@ void MBExchange::execute()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): catch ..."
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): catch ..."
<<
endl
;
}
}
...
...
extensions/ModbusMaster/MBTCPMaster.cc
View file @
c7609b05
...
@@ -106,6 +106,7 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
...
@@ -106,6 +106,7 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
mbtcp
->
setAfterSendPause
(
aftersend_pause
);
mbtcp
->
setAfterSendPause
(
aftersend_pause
);
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): ipaddr="
<<
iaddr
<<
" port="
<<
port
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): ipaddr="
<<
iaddr
<<
" port="
<<
port
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL9
)
)
if
(
dlog
.
debugging
(
Debug
::
LEVEL9
)
)
...
@@ -113,6 +114,7 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
...
@@ -113,6 +114,7 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
}
}
catch
(
ModbusRTU
::
mbException
&
ex
)
catch
(
ModbusRTU
::
mbException
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
"(init): "
<<
ex
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
"(init): "
<<
ex
<<
endl
;
}
}
catch
(...)
catch
(...)
...
@@ -180,6 +182,7 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
...
@@ -180,6 +182,7 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
string
name
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-name"
,
"MBTCPMaster1"
);
string
name
=
conf
->
getArgParam
(
"--"
+
prefix
+
"-name"
,
"MBTCPMaster1"
);
if
(
name
.
empty
()
)
if
(
name
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
"(MBTCPMaster): Не задан name'"
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
"(MBTCPMaster): Не задан name'"
<<
endl
;
return
0
;
return
0
;
}
}
...
@@ -187,12 +190,14 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
...
@@ -187,12 +190,14 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
ObjectId
ID
=
conf
->
getObjectID
(
name
);
ObjectId
ID
=
conf
->
getObjectID
(
name
);
if
(
ID
==
UniSetTypes
::
DefaultObjectId
)
if
(
ID
==
UniSetTypes
::
DefaultObjectId
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
"(MBTCPMaster): идентификатор '"
<<
name
dlog
[
Debug
::
CRIT
]
<<
"(MBTCPMaster): идентификатор '"
<<
name
<<
"' не найден в конф. файле!"
<<
"' не найден в конф. файле!"
<<
" в секции "
<<
conf
->
getObjectsSection
()
<<
endl
;
<<
" в секции "
<<
conf
->
getObjectsSection
()
<<
endl
;
return
0
;
return
0
;
}
}
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
"(MBTCPMaster): name = "
<<
name
<<
"("
<<
ID
<<
")"
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
"(MBTCPMaster): name = "
<<
name
<<
"("
<<
ID
<<
")"
<<
endl
;
return
new
MBTCPMaster
(
ID
,
icID
,
ic
,
prefix
);
return
new
MBTCPMaster
(
ID
,
icID
,
ic
,
prefix
);
}
}
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
c7609b05
...
@@ -184,9 +184,11 @@ prefix(prefix)
...
@@ -184,9 +184,11 @@ prefix(prefix)
}
}
askcount_id
=
conf
->
getSensorID
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-askcount-id"
,
it
.
getProp
(
"askcount_id"
)));
askcount_id
=
conf
->
getSensorID
(
conf
->
getArgParam
(
"--"
+
prefix
+
"-askcount-id"
,
it
.
getProp
(
"askcount_id"
)));
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
{
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init askcount_id="
<<
askcount_id
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init askcount_id="
<<
askcount_id
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init test_id="
<<
test_id
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init test_id="
<<
test_id
<<
endl
;
}
wait_msec
=
getHeartBeatTime
()
-
100
;
wait_msec
=
getHeartBeatTime
()
-
100
;
if
(
wait_msec
<
500
)
if
(
wait_msec
<
500
)
...
@@ -197,9 +199,9 @@ prefix(prefix)
...
@@ -197,9 +199,9 @@ prefix(prefix)
timeout_t
msec
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-timeout"
,
it
.
getProp
(
"timeout"
),
3000
);
timeout_t
msec
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-timeout"
,
it
.
getProp
(
"timeout"
),
3000
);
ptTimeout
.
setTiming
(
msec
);
ptTimeout
.
setTiming
(
msec
);
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): rs-timeout="
<<
msec
<<
" msec"
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): rs-timeout="
<<
msec
<<
" msec"
<<
endl
;
// build file list...
// build file list...
xmlNode
*
fnode
=
0
;
xmlNode
*
fnode
=
0
;
UniXML
*
xml
=
conf
->
getConfXML
();
UniXML
*
xml
=
conf
->
getConfXML
();
...
@@ -216,17 +218,19 @@ prefix(prefix)
...
@@ -216,17 +218,19 @@ prefix(prefix)
std
::
string
nm
=
fit
.
getProp
(
"name"
);
std
::
string
nm
=
fit
.
getProp
(
"name"
);
if
(
nm
.
empty
()
)
if
(
nm
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(build file list): ignore empty name... "
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(build file list): ignore empty name... "
<<
endl
;
continue
;
continue
;
}
}
int
id
=
fit
.
getIntProp
(
"id"
);
int
id
=
fit
.
getIntProp
(
"id"
);
if
(
id
==
0
)
if
(
id
==
0
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(build file list): FAILED ID for "
<<
nm
<<
"... ignore..."
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(build file list): FAILED ID for "
<<
nm
<<
"... ignore..."
<<
endl
;
continue
;
continue
;
}
}
std
::
string
dir
=
fit
.
getProp
(
"directory"
);
std
::
string
dir
(
fit
.
getProp
(
"directory"
)
);
if
(
!
dir
.
empty
()
)
if
(
!
dir
.
empty
()
)
{
{
if
(
dir
==
"ConfDir"
)
if
(
dir
==
"ConfDir"
)
...
@@ -237,6 +241,7 @@ prefix(prefix)
...
@@ -237,6 +241,7 @@ prefix(prefix)
nm
=
dir
+
nm
;
nm
=
dir
+
nm
;
}
}
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): add to filelist: "
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): add to filelist: "
<<
"id="
<<
id
<<
"id="
<<
id
<<
" file="
<<
nm
<<
" file="
<<
nm
...
@@ -245,10 +250,10 @@ prefix(prefix)
...
@@ -245,10 +250,10 @@ prefix(prefix)
flist
[
id
]
=
nm
;
flist
[
id
]
=
nm
;
}
}
}
}
else
else
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): <filelist> empty..."
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): <filelist> empty..."
<<
endl
;
}
}
else
else
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): <filelist> not found..."
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): <filelist> not found..."
<<
endl
;
...
@@ -281,6 +286,7 @@ prefix(prefix)
...
@@ -281,6 +286,7 @@ prefix(prefix)
{
{
if
(
dit
.
getProp
(
"id"
).
empty
()
)
if
(
dit
.
getProp
(
"id"
).
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): read <MEI>. Unknown <device id=''>. Ignore.."
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): read <MEI>. Unknown <device id=''>. Ignore.."
<<
endl
;
continue
;
continue
;
}
}
...
@@ -298,6 +304,7 @@ prefix(prefix)
...
@@ -298,6 +304,7 @@ prefix(prefix)
{
{
if
(
dit
.
getProp
(
"id"
).
empty
()
)
if
(
dit
.
getProp
(
"id"
).
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): read <MEI>. Unknown <object id='' (for device id='"
<<
"(init): read <MEI>. Unknown <object id='' (for device id='"
<<
devID
<<
"'). Ignore.."
<<
devID
<<
"'). Ignore.."
...
@@ -347,7 +354,7 @@ prefix(prefix)
...
@@ -347,7 +354,7 @@ prefix(prefix)
if
(
!
meidev
.
empty
()
&&
dlog
.
debugging
(
Debug
::
INFO
)
)
if
(
!
meidev
.
empty
()
&&
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): <MEI> init ok."
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): <MEI> init ok."
<<
endl
;
}
}
else
else
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): <MEI> empty..."
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): <MEI> empty..."
<<
endl
;
}
}
...
@@ -401,7 +408,7 @@ void MBSlave::execute_rtu()
...
@@ -401,7 +408,7 @@ void MBSlave::execute_rtu()
prev
=
res
;
prev
=
res
;
}
}
if
(
res
!=
ModbusRTU
::
erNoError
&&
res
!=
ModbusRTU
::
erTimeOut
)
if
(
res
!=
ModbusRTU
::
erNoError
&&
res
!=
ModbusRTU
::
erTimeOut
&&
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(execute_rtu): "
<<
ModbusRTU
::
mbErr2Str
(
res
)
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(execute_rtu): "
<<
ModbusRTU
::
mbErr2Str
(
res
)
<<
endl
;
if
(
!
activated
)
if
(
!
activated
)
...
@@ -416,6 +423,7 @@ void MBSlave::execute_rtu()
...
@@ -416,6 +423,7 @@ void MBSlave::execute_rtu()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (hb) "
<<
ex
<<
std
::
endl
;
<<
"(execute_rtu): (hb) "
<<
ex
<<
std
::
endl
;
}
}
...
@@ -433,6 +441,7 @@ void MBSlave::execute_rtu()
...
@@ -433,6 +441,7 @@ void MBSlave::execute_rtu()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (respond) "
<<
ex
<<
std
::
endl
;
<<
"(execute_rtu): (respond) "
<<
ex
<<
std
::
endl
;
}
}
...
@@ -446,6 +455,7 @@ void MBSlave::execute_rtu()
...
@@ -446,6 +455,7 @@ void MBSlave::execute_rtu()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (askCount) "
<<
ex
<<
std
::
endl
;
<<
"(execute_rtu): (askCount) "
<<
ex
<<
std
::
endl
;
}
}
...
@@ -482,7 +492,7 @@ void MBSlave::execute_tcp()
...
@@ -482,7 +492,7 @@ void MBSlave::execute_tcp()
prev
=
res
;
prev
=
res
;
}
}
if
(
res
!=
ModbusRTU
::
erNoError
&&
res
!=
ModbusRTU
::
erTimeOut
)
if
(
res
!=
ModbusRTU
::
erNoError
&&
res
!=
ModbusRTU
::
erTimeOut
&&
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(execute_tcp): "
<<
ModbusRTU
::
mbErr2Str
(
res
)
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(execute_tcp): "
<<
ModbusRTU
::
mbErr2Str
(
res
)
<<
endl
;
if
(
!
activated
)
if
(
!
activated
)
...
@@ -497,6 +507,7 @@ void MBSlave::execute_tcp()
...
@@ -497,6 +507,7 @@ void MBSlave::execute_tcp()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_tcp): (hb) "
<<
ex
<<
std
::
endl
;
<<
"(execute_tcp): (hb) "
<<
ex
<<
std
::
endl
;
}
}
...
@@ -513,6 +524,7 @@ void MBSlave::execute_tcp()
...
@@ -513,6 +524,7 @@ void MBSlave::execute_tcp()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (respond) "
<<
ex
<<
std
::
endl
;
<<
"(execute_rtu): (respond) "
<<
ex
<<
std
::
endl
;
}
}
...
@@ -526,6 +538,7 @@ void MBSlave::execute_tcp()
...
@@ -526,6 +538,7 @@ void MBSlave::execute_tcp()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (askCount) "
<<
ex
<<
std
::
endl
;
<<
"(execute_rtu): (askCount) "
<<
ex
<<
std
::
endl
;
}
}
...
@@ -565,16 +578,19 @@ void MBSlave::processingMessage(UniSetTypes::VoidMessage *msg)
...
@@ -565,16 +578,19 @@ void MBSlave::processingMessage(UniSetTypes::VoidMessage *msg)
}
}
catch
(
SystemError
&
ex
)
catch
(
SystemError
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(SystemError): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(SystemError): "
<<
ex
<<
std
::
endl
;
// throw SystemError(ex);
// throw SystemError(ex);
raise
(
SIGTERM
);
raise
(
SIGTERM
);
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): catch ...
\n
"
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): catch ...
\n
"
;
}
}
}
}
...
@@ -587,6 +603,7 @@ void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm)
...
@@ -587,6 +603,7 @@ void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm)
{
{
if
(
iomap
.
empty
()
)
if
(
iomap
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): iomap EMPTY! terminated..."
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): iomap EMPTY! terminated..."
<<
endl
;
raise
(
SIGTERM
);
raise
(
SIGTERM
);
return
;
return
;
...
@@ -606,7 +623,7 @@ void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm)
...
@@ -606,7 +623,7 @@ void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm)
break
;
break
;
}
}
if
(
!
activated
)
if
(
!
activated
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
else
else
{
{
...
@@ -682,18 +699,13 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -682,18 +699,13 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
for
(
;
it
!=
iomap
.
end
();
++
it
)
for
(
;
it
!=
iomap
.
end
();
++
it
)
{
{
IOProperty
*
p
(
&
it
->
second
);
IOProperty
*
p
(
&
it
->
second
);
// if( p->stype != UniversalIO::DO && p->stype != UniversalIO::AO )
// continue;
// if( p->safety == NoSafetyState )
// continue;
try
try
{
{
shm
->
askSensor
(
p
->
si
.
id
,
cmd
);
shm
->
askSensor
(
p
->
si
.
id
,
cmd
);
}
}
catch
(
UniSetTypes
::
Exception
&
ex
)
catch
(
UniSetTypes
::
Exception
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...){}
catch
(...){}
...
@@ -740,7 +752,7 @@ void MBSlave::sensorInfo( UniSetTypes::SensorMessage* sm )
...
@@ -740,7 +752,7 @@ void MBSlave::sensorInfo( UniSetTypes::SensorMessage* sm )
{
{
// вообще этого не может случиться
// вообще этого не может случиться
// потому-что корректность проверяется при загрузке
// потому-что корректность проверяется при загрузке
if
(
i
!=
sz
)
if
(
i
!=
sz
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sensorInfo): update failed for sid="
<<
sm
->
id
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sensorInfo): update failed for sid="
<<
sm
->
id
<<
" (i="
<<
i
<<
" sz="
<<
sz
<<
")"
<<
endl
;
<<
" (i="
<<
i
<<
" sz="
<<
sz
<<
")"
<<
endl
;
}
}
...
@@ -793,7 +805,8 @@ void MBSlave::readConfiguration()
...
@@ -793,7 +805,8 @@ void MBSlave::readConfiguration()
UniXML_iterator
it
(
root
);
UniXML_iterator
it
(
root
);
if
(
!
it
.
goChildren
()
)
if
(
!
it
.
goChildren
()
)
{
{
std
::
cerr
<<
myname
<<
"(readConfiguration): раздел <sensors> не содержит секций ?!!
\n
"
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readConfiguration): раздел <sensors> не содержит секций ?!!
\n
"
;
return
;
return
;
}
}
...
@@ -828,6 +841,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
...
@@ -828,6 +841,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
string
r
=
it
.
getProp
(
"mbreg"
);
string
r
=
it
.
getProp
(
"mbreg"
);
if
(
r
.
empty
()
)
if
(
r
.
empty
()
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'mbreg' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'mbreg' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -842,6 +856,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
...
@@ -842,6 +856,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
p
.
stype
=
UniSetTypes
::
getIOType
(
stype
);
p
.
stype
=
UniSetTypes
::
getIOType
(
stype
);
if
(
p
.
stype
==
UniversalIO
::
UnknownIOType
)
if
(
p
.
stype
==
UniversalIO
::
UnknownIOType
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'iotype' or 'mb_iotype' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'iotype' or 'mb_iotype' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -868,6 +883,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
...
@@ -868,6 +883,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
VTypes
::
VType
v
(
VTypes
::
str2type
(
vt
));
VTypes
::
VType
v
(
VTypes
::
str2type
(
vt
));
if
(
v
==
VTypes
::
vtUnknown
)
if
(
v
==
VTypes
::
vtUnknown
)
{
{
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown rtuVType="
<<
vt
<<
" for "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown rtuVType="
<<
vt
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
endl
;
...
@@ -947,6 +963,7 @@ MBSlave* MBSlave::init_mbslave( int argc, const char* const* argv, UniSetTypes::
...
@@ -947,6 +963,7 @@ MBSlave* MBSlave::init_mbslave( int argc, const char* const* argv, UniSetTypes::
return
0
;
return
0
;
}
}
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
"(mbslave): name = "
<<
name
<<
"("
<<
ID
<<
")"
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
"(mbslave): name = "
<<
name
<<
"("
<<
ID
<<
")"
<<
endl
;
return
new
MBSlave
(
ID
,
icID
,
ic
,
prefix
);
return
new
MBSlave
(
ID
,
icID
,
ic
,
prefix
);
}
}
...
@@ -1161,28 +1178,30 @@ ModbusRTU::mbErrCode MBSlave::real_write_it( IOMap::iterator& it, ModbusRTU::Mod
...
@@ -1161,28 +1178,30 @@ ModbusRTU::mbErrCode MBSlave::real_write_it( IOMap::iterator& it, ModbusRTU::Mod
}
}
catch
(
UniSetTypes
::
NameNotFound
&
ex
)
catch
(
UniSetTypes
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataAddress
;
return
ModbusRTU
::
erBadDataAddress
;
}
}
catch
(
UniSetTypes
::
OutOfRange
&
ex
)
catch
(
UniSetTypes
::
OutOfRange
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataValue
;
return
ModbusRTU
::
erBadDataValue
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(write): СORBA::SystemException: "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(write): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(write) catch ..."
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(write) catch ..."
<<
endl
;
}
}
...
@@ -1334,28 +1353,30 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
...
@@ -1334,28 +1353,30 @@ ModbusRTU::mbErrCode MBSlave::real_read_it( IOMap::iterator& it, ModbusRTU::Modb
}
}
catch
(
UniSetTypes
::
NameNotFound
&
ex
)
catch
(
UniSetTypes
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataAddress
;
return
ModbusRTU
::
erBadDataAddress
;
}
}
catch
(
UniSetTypes
::
OutOfRange
&
ex
)
catch
(
UniSetTypes
::
OutOfRange
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataValue
;
return
ModbusRTU
::
erBadDataValue
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(real_read_it): CORBA::SystemException: "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(real_read_it): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(real_read_it) catch ..."
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(real_read_it) catch ..."
<<
endl
;
}
}
...
@@ -1465,23 +1486,24 @@ ModbusRTU::mbErrCode MBSlave::readInputStatus( ReadInputStatusMessage& query,
...
@@ -1465,23 +1486,24 @@ ModbusRTU::mbErrCode MBSlave::readInputStatus( ReadInputStatusMessage& query,
}
}
catch
(
UniSetTypes
::
NameNotFound
&
ex
)
catch
(
UniSetTypes
::
NameNotFound
&
ex
)
{
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(readInputStatus): "
<<
ex
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(readInputStatus): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataAddress
;
return
ModbusRTU
::
erBadDataAddress
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readInputStatus): "
<<
ex
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readInputStatus): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readInputStatus): СORBA::SystemException: "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readInputStatus): СORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
if
(
pingOK
)
if
(
pingOK
&&
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readInputStatus): catch ..."
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readInputStatus): catch ..."
<<
endl
;
}
}
...
...
src/Processes/IONotifyController.cc
View file @
c7609b05
...
@@ -851,73 +851,6 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
...
@@ -851,73 +851,6 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
}
}
// --------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------
#if 0
void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
const IOController_i::SensorInfo& si,
CORBA::Long value, UniSetTypes::ObjectId sup_id )
{
// Если датчик не найден сдесь сработает исключение NameNotFound
long prevValue = IOController::localGetValue( li,si );
if( unideb.debugging(Debug::INFO) )
{
unideb[Debug::INFO] << myname << "(IONotifyController::setValue): value=" << value
<< " для выхода " << conf->oind->getNameById(si.id,si.node) << endl;
}
// сохраняем новое состояние
IOController::localSetValue( li, si, value, sup_id );
// Рассылаем уведомления только если значение изменилось...
SensorMessage sm;
{ // lock
uniset_rwmutex_rlock lock(li->second.val_lock);
if( prevValue == li->second.value )
return;
sm.id = si.id;
sm.node = si.node;
sm.value = li->second.value;
sm.state = sm.value!=0 ? true:false;
sm.undefined = li->second.undefined;
sm.sm_tv_sec = li->second.tv_sec;
sm.sm_tv_usec = li->second.tv_usec;
sm.priority = (Message::Priority)li->second.priority;
sm.sensor_type = li->second.type;
sm.ci = li->second.ci;
sm.supplier = sup_id;
} // unlock
try
{
uniset_rwmutex_rlock l(sig_mutex);
changeSignal.emit(&sm);
}
catch(...){}
try
{
if( !li->second.db_ignore )
loggingInfo(sm);
}
catch(...){}
AskMap::iterator dit = askAOList.find( UniSetTypes::key(si.id,si.node) );
if( dit!=askAOList.end() )
{ // lock
uniset_rwmutex_rlock lock(askIOMutex);
send(dit->second, sm);
}
// // проверка порогов
// try
// {
// checkThreshold(li,si, value);
// }
// catch(...){}
}
#endif
// --------------------------------------------------------------------------------------------------------------
IONotifyController
::
ThresholdExtList
::
iterator
IONotifyController
::
findThreshold
(
UniSetTypes
::
KeyType
key
,
UniSetTypes
::
ThresholdId
tid
)
IONotifyController
::
ThresholdExtList
::
iterator
IONotifyController
::
findThreshold
(
UniSetTypes
::
KeyType
key
,
UniSetTypes
::
ThresholdId
tid
)
{
{
{
// lock
{
// lock
...
@@ -1030,7 +963,7 @@ IDSeq* IONotifyController::askSensorsSeq( const UniSetTypes::IDSeq& lst,
...
@@ -1030,7 +963,7 @@ IDSeq* IONotifyController::askSensorsSeq( const UniSetTypes::IDSeq& lst,
const
UniSetTypes
::
ConsumerInfo
&
ci
,
const
UniSetTypes
::
ConsumerInfo
&
ci
,
UniversalIO
::
UIOCommand
cmd
)
UniversalIO
::
UIOCommand
cmd
)
{
{
UniSetTypes
::
IDList
badlist
;
// писок не найденных идентификаторов
UniSetTypes
::
IDList
badlist
;
//
c
писок не найденных идентификаторов
IOController_i
::
SensorInfo
si
;
IOController_i
::
SensorInfo
si
;
...
...
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