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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
317 additions
and
267 deletions
+317
-267
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+219
-129
MBTCPMaster.cc
extensions/ModbusMaster/MBTCPMaster.cc
+12
-7
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+85
-63
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,8 +217,9 @@ void MBExchange::step()
...
@@ -218,8 +217,9 @@ void MBExchange::step()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"(step): (hb) "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(step): (hb) "
<<
ex
<<
std
::
endl
;
}
}
}
}
}
}
...
@@ -239,7 +239,8 @@ void MBExchange::setProcActive( bool st )
...
@@ -239,7 +239,8 @@ void MBExchange::setProcActive( bool st )
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
MBExchange
::
sigterm
(
int
signo
)
void
MBExchange
::
sigterm
(
int
signo
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
": ********* SIGTERM("
<<
signo
<<
") ********"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
": ********* SIGTERM("
<<
signo
<<
") ********"
<<
endl
;
setProcActive
(
false
);
setProcActive
(
false
);
UniSetObject_LT
::
sigterm
(
signo
);
UniSetObject_LT
::
sigterm
(
signo
);
}
}
...
@@ -258,7 +259,8 @@ void MBExchange::readConfiguration()
...
@@ -258,7 +259,8 @@ void MBExchange::readConfiguration()
UniXML_iterator
it
(
root
);
UniXML_iterator
it
(
root
);
if
(
!
it
.
goChildren
()
)
if
(
!
it
.
goChildren
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readConfiguration): раздел <sensors> не содержит секций ?!!
\n
"
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readConfiguration): раздел <sensors> не содержит секций ?!!
\n
"
;
return
;
return
;
}
}
...
@@ -492,21 +494,23 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
...
@@ -492,21 +494,23 @@ 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
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(rtuQueryOptimization): "
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
<<
" optimization change func="
<<
ModbusRTU
::
fnWriteOutputSingleRegister
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(rtuQueryOptimization): "
<<
" <--> func="
<<
ModbusRTU
::
fnWriteOutputRegisters
<<
" optimization change func="
<<
ModbusRTU
::
fnWriteOutputSingleRegister
<<
" for mbaddr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" <--> func="
<<
ModbusRTU
::
fnWriteOutputRegisters
<<
" mbreg="
<<
ModbusRTU
::
dat2str
(
beg
->
second
->
mbreg
);
<<
" for mbaddr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" mbreg="
<<
ModbusRTU
::
dat2str
(
beg
->
second
->
mbreg
);
beg
->
second
->
mbfunc
=
ModbusRTU
::
fnWriteOutputRegisters
;
beg
->
second
->
mbfunc
=
ModbusRTU
::
fnWriteOutputRegisters
;
}
}
else
if
(
beg
->
second
->
q_count
>
1
&&
beg
->
second
->
mbfunc
==
ModbusRTU
::
fnForceSingleCoil
)
else
if
(
beg
->
second
->
q_count
>
1
&&
beg
->
second
->
mbfunc
==
ModbusRTU
::
fnForceSingleCoil
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(rtuQueryOptimization): "
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
<<
" optimization change func="
<<
ModbusRTU
::
fnForceSingleCoil
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(rtuQueryOptimization): "
<<
" <--> func="
<<
ModbusRTU
::
fnForceMultipleCoils
<<
" optimization change func="
<<
ModbusRTU
::
fnForceSingleCoil
<<
" for mbaddr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" <--> func="
<<
ModbusRTU
::
fnForceMultipleCoils
<<
" mbreg="
<<
ModbusRTU
::
dat2str
(
beg
->
second
->
mbreg
);
<<
" for mbaddr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" mbreg="
<<
ModbusRTU
::
dat2str
(
beg
->
second
->
mbreg
);
beg
->
second
->
mbfunc
=
ModbusRTU
::
fnForceMultipleCoils
;
beg
->
second
->
mbfunc
=
ModbusRTU
::
fnForceMultipleCoils
;
}
}
...
@@ -677,7 +681,8 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
...
@@ -677,7 +681,8 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
return
true
;
return
true
;
}
}
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initSMValue): IGNORE item: rnum="
<<
p
->
rnum
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initSMValue): IGNORE item: rnum="
<<
p
->
rnum
<<
" > 1 ?!! for id="
<<
p
->
si
.
id
<<
endl
;
<<
" > 1 ?!! for id="
<<
p
->
si
.
id
<<
endl
;
return
false
;
return
false
;
...
@@ -710,7 +715,8 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
...
@@ -710,7 +715,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initSMValue): IGNORE item: sid="
<<
ModbusRTU
::
dat2str
(
p
->
si
.
id
)
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,28 +750,34 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
...
@@ -744,28 +750,34 @@ bool MBExchange::initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue):(NameNotFound) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue):(IOBadParam) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): (BadRange)..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): CORBA::SystemException: "
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
<<
ex
.
NP_minorString
()
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): catch ..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(initSMValue): catch ..."
<<
endl
;
}
}
return
false
;
return
false
;
...
@@ -869,8 +881,9 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
...
@@ -869,8 +881,9 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
{
{
if
(
p
->
q_count
!=
1
)
if
(
p
->
q_count
!=
1
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(pollRTU): mbreg="
<<
ModbusRTU
::
dat2str
(
p
->
mbreg
)
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
" IGNORE WRITE SINGLE REGISTER (0x06) q_count="
<<
p
->
q_count
<<
" ..."
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(pollRTU): mbreg="
<<
ModbusRTU
::
dat2str
(
p
->
mbreg
)
<<
" IGNORE WRITE SINGLE REGISTER (0x06) q_count="
<<
p
->
q_count
<<
" ..."
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -928,8 +941,9 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
...
@@ -928,8 +941,9 @@ bool MBExchange::pollRTU( RTUDevice* dev, RegMap::iterator& it )
{
{
if
(
p
->
q_count
!=
1
)
if
(
p
->
q_count
!=
1
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(pollRTU): mbreg="
<<
ModbusRTU
::
dat2str
(
p
->
mbreg
)
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
" IGNORE FORCE SINGLE COIL (0x05) q_count="
<<
p
->
q_count
<<
" ..."
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(pollRTU): mbreg="
<<
ModbusRTU
::
dat2str
(
p
->
mbreg
)
<<
" IGNORE FORCE SINGLE COIL (0x05) q_count="
<<
p
->
q_count
<<
" ..."
<<
endl
;
return
false
;
return
false
;
}
}
if
(
!
p
->
sm_initOK
)
if
(
!
p
->
sm_initOK
)
...
@@ -993,28 +1007,34 @@ void MBExchange::updateSM()
...
@@ -993,28 +1007,34 @@ void MBExchange::updateSM()
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(NameNotFound) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(IOBadParam) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): CORBA::SystemException: "
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
<<
ex
.
NP_minorString
()
<<
endl
;
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): check modeSensor..catch ..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): check modeSensor..catch ..."
<<
endl
;
}
}
}
}
...
@@ -1036,28 +1056,34 @@ void MBExchange::updateSM()
...
@@ -1036,28 +1056,34 @@ void MBExchange::updateSM()
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(NameNotFound) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(IOBadParam) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): CORBA::SystemException: "
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): catch ..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateSM): catch ..."
<<
endl
;
}
}
if
(
it
==
d
->
regmap
.
end
()
)
if
(
it
==
d
->
regmap
.
end
()
)
...
@@ -1162,7 +1188,8 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1162,7 +1188,8 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
return
;
return
;
}
}
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(updateRSProperty): IGNORE item: rnum="
<<
p
->
rnum
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,7 +1259,8 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1232,7 +1259,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(updateRSProperty): IGNORE item: reg="
<<
ModbusRTU
::
dat2str
(
r
->
mbreg
)
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,28 +1395,34 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
...
@@ -1367,28 +1395,34 @@ void MBExchange::updateRSProperty( RSProperty* p, bool write_only )
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(NameNotFound) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(IOBadParam) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): (BadRange)..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): CORBA::SystemException: "
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): catch ..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRSProperty): catch ..."
<<
endl
;
}
}
// Если SM стала (или была) недоступна
// Если SM стала (или была) недоступна
...
@@ -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
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(updateMTR): write (T4) reg("
<<
dat2str
(
r
->
mbreg
)
<<
") to MTR NOT YET!!!"
<<
endl
;
{
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
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,28 +1636,34 @@ void MBExchange::updateMTR( RegMap::iterator& rit )
...
@@ -1599,28 +1636,34 @@ void MBExchange::updateMTR( RegMap::iterator& rit )
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR):(NameNotFound) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR):(IOBadParam) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): (BadRange)..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): CORBA::SystemException: "
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateMTR): catch ..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
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,28 +1737,34 @@ void MBExchange::updateRTU188( RegMap::iterator& rit )
...
@@ -1693,28 +1737,34 @@ void MBExchange::updateRTU188( RegMap::iterator& rit )
}
}
catch
(
IOController_i
::
NameNotFound
&
ex
)
catch
(
IOController_i
::
NameNotFound
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188):(NameNotFound) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188):(NameNotFound) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IOController_i
::
IOBadParam
&
ex
)
catch
(
IOController_i
::
IOBadParam
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188):(IOBadParam) "
<<
ex
.
err
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188):(IOBadParam) "
<<
ex
.
err
<<
endl
;
}
}
catch
(
IONotifyController_i
::
BadRange
)
catch
(
IONotifyController_i
::
BadRange
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): (BadRange)..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): (BadRange)..."
<<
endl
;
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): "
<<
ex
<<
endl
;
}
}
catch
(
CORBA
::
SystemException
&
ex
)
catch
(
CORBA
::
SystemException
&
ex
)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): CORBA::SystemException: "
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
<<
ex
.
NP_minorString
()
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): catch ..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL3
)
)
dlog
[
Debug
::
LEVEL3
]
<<
myname
<<
"(updateRTU188): catch ..."
<<
endl
;
}
}
}
}
}
}
...
@@ -1728,15 +1778,17 @@ MBExchange::RTUDevice* MBExchange::addDev( RTUDeviceMap& mp, ModbusRTU::ModbusAd
...
@@ -1728,15 +1778,17 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(addDev): OTHER mbtype="
<<
dtype
<<
" for "
<<
xmlit
.
getProp
(
"name"
)
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
". Already used devtype="
<<
it
->
second
->
dtype
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(addDev): OTHER mbtype="
<<
dtype
<<
" for "
<<
xmlit
.
getProp
(
"name"
)
<<
" for mbaddr="
<<
ModbusRTU
::
addr2str
(
it
->
second
->
mbaddr
)
<<
". Already used devtype="
<<
it
->
second
->
dtype
<<
endl
;
<<
" for mbaddr="
<<
ModbusRTU
::
addr2str
(
it
->
second
->
mbaddr
)
<<
endl
;
return
0
;
return
0
;
}
}
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(addDev): device for addr="
<<
ModbusRTU
::
addr2str
(
a
)
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
<<
" already added. Ignore device params for "
<<
xmlit
.
getProp
(
"name"
)
<<
" ..."
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(addDev): device for addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
" already added. Ignore device params for "
<<
xmlit
.
getProp
(
"name"
)
<<
" ..."
<<
endl
;
return
it
->
second
;
return
it
->
second
;
}
}
...
@@ -1769,8 +1821,9 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, RegID id, ModbusRTU::Modbus
...
@@ -1769,8 +1821,9 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, RegID id, ModbusRTU::Modbus
if
(
it
->
second
->
dev
->
dtype
!=
dev
->
dtype
)
if
(
it
->
second
->
dev
->
dtype
!=
dev
->
dtype
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(addReg): OTHER mbtype="
<<
dev
->
dtype
<<
" for "
<<
xmlit
.
getProp
(
"name"
)
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
". Already used devtype="
<<
it
->
second
->
dev
->
dtype
<<
" for "
<<
it
->
second
->
dev
<<
endl
;
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
;
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,8 +1913,9 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1860,8 +1913,9 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): BAD nbit="
<<
p
.
nbit
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
". (0 >= nbit < "
<<
ModbusRTU
::
BitsPerData
<<
")."
<<
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): BAD nbit="
<<
p
.
nbit
<<
". (0 >= nbit < "
<<
ModbusRTU
::
BitsPerData
<<
")."
<<
endl
;
return
false
;
return
false
;
}
}
}
}
...
@@ -1870,8 +1924,9 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1870,8 +1924,9 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
(
p
.
stype
==
UniversalIO
::
AI
||
(
p
.
stype
==
UniversalIO
::
AI
||
p
.
stype
==
UniversalIO
::
AO
)
)
p
.
stype
==
UniversalIO
::
AO
)
)
{
{
dlog
[
Debug
::
WARN
]
<<
"(initRSProperty): (ignore) uncorrect param`s nbit>1 ("
<<
p
.
nbit
<<
")"
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
<<
" but iotype="
<<
p
.
stype
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
dlog
[
Debug
::
WARN
]
<<
"(initRSProperty): (ignore) uncorrect param`s nbit>1 ("
<<
p
.
nbit
<<
")"
<<
" but iotype="
<<
p
.
stype
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
}
}
string
sbyte
(
it
.
getProp
(
prop_prefix
+
"nbyte"
));
string
sbyte
(
it
.
getProp
(
prop_prefix
+
"nbyte"
));
...
@@ -1880,7 +1935,8 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1880,7 +1935,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): BAD nbyte="
<<
p
.
nbyte
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,7 +1953,8 @@ bool MBExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
...
@@ -1897,7 +1953,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): Unknown tcp_vtype='"
<<
vt
<<
"' for "
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRSProperty): Unknown tcp_vtype='"
<<
vt
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
endl
;
...
@@ -1943,7 +2000,8 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
...
@@ -1943,7 +2000,8 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
}
}
else
else
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRegInfo): Unknown mbtype='"
<<
dev
->
dtype
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRegInfo): Unknown mbtype='"
<<
dev
->
dtype
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -1960,7 +2018,8 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
...
@@ -1960,7 +2018,8 @@ 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
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'mbreg' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'mbreg' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
r
->
mbreg
=
ModbusRTU
::
str2mbData
(
sr
);
r
->
mbreg
=
ModbusRTU
::
str2mbData
(
sr
);
...
@@ -1973,7 +2032,8 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
...
@@ -1973,7 +2032,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRegInfo): Unknown mbfunc ='"
<<
f
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRegInfo): Unknown mbfunc ='"
<<
f
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -1988,16 +2048,18 @@ bool MBExchange::initRTUDevice( RTUDevice* d, UniXML_iterator& it )
...
@@ -1988,16 +2048,18 @@ bool MBExchange::initRTUDevice( RTUDevice* d, UniXML_iterator& it )
if
(
d
->
dtype
==
dtUnknown
)
if
(
d
->
dtype
==
dtUnknown
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRTUDevice): Unknown tcp_mbtype="
<<
it
.
getProp
(
prop_prefix
+
"mbtype"
)
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
". Use: rtu "
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRTUDevice): Unknown tcp_mbtype="
<<
it
.
getProp
(
prop_prefix
+
"mbtype"
)
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
". Use: rtu "
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
string
addr
=
it
.
getProp
(
prop_prefix
+
"mbaddr"
);
string
addr
=
it
.
getProp
(
prop_prefix
+
"mbaddr"
);
if
(
addr
.
empty
()
)
if
(
addr
.
empty
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRTUDevice): Unknown mbaddr for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initRTUDevice): Unknown mbaddr for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2018,10 +2080,11 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2018,10 +2080,11 @@ 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
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown mbaddr("
<<
prop_prefix
<<
"mbaddr)='"
<<
addr
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown mbaddr("
<<
prop_prefix
<<
"mbaddr)='"
<<
addr
<<
"' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2030,7 +2093,8 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2030,7 +2093,8 @@ bool MBExchange::initItem( UniXML_iterator& it )
RTUDevice
*
dev
=
addDev
(
rmap
,
mbaddr
,
it
);
RTUDevice
*
dev
=
addDev
(
rmap
,
mbaddr
,
it
);
if
(
!
dev
)
if
(
!
dev
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): "
<<
it
.
getProp
(
"name"
)
<<
" CAN`T ADD for polling!"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): "
<<
it
.
getProp
(
"name"
)
<<
" CAN`T ADD for polling!"
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2042,7 +2106,8 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2042,7 +2106,8 @@ bool MBExchange::initItem( UniXML_iterator& it )
RegInfo
r_tmp
;
RegInfo
r_tmp
;
if
(
!
initRTU188item
(
it
,
&
r_tmp
)
)
if
(
!
initRTU188item
(
it
,
&
r_tmp
)
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): init RTU188 failed for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): init RTU188 failed for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -2058,7 +2123,8 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2058,7 +2123,8 @@ 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
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): unknown mbreg("
<<
prop_prefix
<<
") for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): unknown mbreg("
<<
prop_prefix
<<
") for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
mbreg
=
ModbusRTU
::
str2mbData
(
reg
);
mbreg
=
ModbusRTU
::
str2mbData
(
reg
);
...
@@ -2078,7 +2144,8 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2078,7 +2144,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): unknown word size for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): unknown word size for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
}
}
...
@@ -2102,9 +2169,10 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2102,9 +2169,10 @@ bool MBExchange::initItem( UniXML_iterator& it )
{
{
if
(
p
.
nbit
<
0
&&
ri
->
slst
.
size
()
>
1
)
if
(
p
.
nbit
<
0
&&
ri
->
slst
.
size
()
>
1
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): FAILED! Sharing SAVE (not bit saving) to "
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
" tcp_mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): FAILED! Sharing SAVE (not bit saving) to "
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" tcp_mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
abort
();
// ABORT PROGRAM!!!!
abort
();
// ABORT PROGRAM!!!!
return
false
;
return
false
;
...
@@ -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,10 +2233,11 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2164,10 +2233,11 @@ bool MBExchange::initItem( UniXML_iterator& it )
if
(
ri
->
mbfunc
!=
ModbusRTU
::
fnWriteOutputRegisters
&&
if
(
ri
->
mbfunc
!=
ModbusRTU
::
fnWriteOutputRegisters
&&
ri
->
mbfunc
!=
ModbusRTU
::
fnForceMultipleCoils
)
ri
->
mbfunc
!=
ModbusRTU
::
fnForceMultipleCoils
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Bad write function ='"
<<
ModbusRTU
::
fnWriteOutputSingleRegister
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"' for vtype='"
<<
p1
->
vType
<<
"'"
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Bad write function ='"
<<
ModbusRTU
::
fnWriteOutputSingleRegister
<<
" tcp_mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
<<
"' for vtype='"
<<
p1
->
vType
<<
"'"
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" tcp_mbreg="
<<
ModbusRTU
::
dat2str
(
ri
->
mbreg
)
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
abort
();
// ABORT PROGRAM!!!!
abort
();
// ABORT PROGRAM!!!!
return
false
;
return
false
;
...
@@ -2197,7 +2267,8 @@ bool MBExchange::initItem( UniXML_iterator& it )
...
@@ -2197,7 +2267,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown tcp_init_mbfunc ='"
<<
s_mbfunc
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,7 +2312,8 @@ bool MBExchange::initMTRitem( UniXML_iterator& it, RegInfo* p )
...
@@ -2241,7 +2312,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readMTRItem): Unknown mtrtype '"
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,21 +2330,24 @@ bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
...
@@ -2258,21 +2330,24 @@ bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
if
(
jack
.
empty
()
)
if
(
jack
.
empty
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown "
<<
prop_prefix
<<
"jack='' "
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown "
<<
prop_prefix
<<
"jack='' "
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
p
->
rtuJack
=
RTUStorage
::
s2j
(
jack
);
p
->
rtuJack
=
RTUStorage
::
s2j
(
jack
);
if
(
p
->
rtuJack
==
RTUStorage
::
nUnknown
)
if
(
p
->
rtuJack
==
RTUStorage
::
nUnknown
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown "
<<
prop_prefix
<<
"jack="
<<
jack
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown "
<<
prop_prefix
<<
"jack="
<<
jack
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
if
(
chan
.
empty
()
)
if
(
chan
.
empty
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(readRTU188Item): Unknown channel='' "
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,13 +2435,15 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
...
@@ -2360,13 +2435,15 @@ 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
()
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(initDeviceInfo): not found device for addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
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"
);
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
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
;
string
s
(
it
.
getProp
(
"respondSensor"
));
string
s
(
it
.
getProp
(
"respondSensor"
));
...
@@ -2375,7 +2452,8 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
...
@@ -2375,7 +2452,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): not found ID for respondSensor="
<<
s
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): not found ID for respondSensor="
<<
s
<<
endl
;
return
false
;
return
false
;
}
}
}
}
...
@@ -2386,26 +2464,25 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
...
@@ -2386,26 +2464,25 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): not found ID for modeSensor="
<<
mod
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): not found ID for modeSensor="
<<
mod
<<
endl
;
return
false
;
return
false
;
}
}
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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): modeSensor='"
<<
mod
<<
"' must be 'AI'"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initDeviceInfo): modeSensor='"
<<
mod
<<
"' must be 'AI'"
<<
endl
;
return
false
;
return
false
;
}
}
}
}
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
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,16 +2537,19 @@ void MBExchange::processingMessage(UniSetTypes::VoidMessage *msg)
...
@@ -2460,16 +2537,19 @@ void MBExchange::processingMessage(UniSetTypes::VoidMessage *msg)
}
}
catch
(
SystemError
&
ex
)
catch
(
SystemError
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(SystemError): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(SystemError): "
<<
ex
<<
std
::
endl
;
// throw SystemError(ex);
// throw SystemError(ex);
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): catch ...
\n
"
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): catch ...
\n
"
;
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -2481,7 +2561,8 @@ void MBExchange::sysCommand( UniSetTypes::SystemMessage *sm )
...
@@ -2481,7 +2561,8 @@ void MBExchange::sysCommand( UniSetTypes::SystemMessage *sm )
{
{
if
(
rmap
.
empty
()
)
if
(
rmap
.
empty
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): ************* ITEM MAP EMPTY! terminated... *************"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,11 +2680,13 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -2599,11 +2680,13 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
}
}
catch
(
UniSetTypes
::
Exception
&
ex
)
catch
(
UniSetTypes
::
Exception
&
ex
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): 'sidExchangeMode' catch..."
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): 'sidExchangeMode' catch..."
<<
std
::
endl
;
}
}
for
(
MBExchange
::
RTUDeviceMap
::
iterator
it1
=
rmap
.
begin
();
it1
!=
rmap
.
end
();
++
it1
)
for
(
MBExchange
::
RTUDeviceMap
::
iterator
it1
=
rmap
.
begin
();
it1
!=
rmap
.
end
();
++
it1
)
...
@@ -2617,11 +2700,13 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -2617,11 +2700,13 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
}
}
catch
(
UniSetTypes
::
Exception
&
ex
)
catch
(
UniSetTypes
::
Exception
&
ex
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): (mode_id="
<<
d
->
mode_id
<<
").. catch..."
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): (mode_id="
<<
d
->
mode_id
<<
").. catch..."
<<
std
::
endl
;
}
}
if
(
force_out
)
if
(
force_out
)
...
@@ -2640,11 +2725,13 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -2640,11 +2725,13 @@ void MBExchange::askSensors( UniversalIO::UIOCommand cmd )
}
}
catch
(
UniSetTypes
::
Exception
&
ex
)
catch
(
UniSetTypes
::
Exception
&
ex
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): id="
<<
i
->
si
.
id
<<
" catch..."
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): id="
<<
i
->
si
.
id
<<
" catch..."
<<
std
::
endl
;
}
}
}
}
}
}
...
@@ -2922,7 +3009,8 @@ void MBExchange::updateRespondSensors()
...
@@ -2922,7 +3009,8 @@ void MBExchange::updateRespondSensors()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(step): (respond) "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(step): (respond) "
<<
ex
<<
std
::
endl
;
}
}
}
}
}
}
...
@@ -2948,11 +3036,13 @@ void MBExchange::execute()
...
@@ -2948,11 +3036,13 @@ void MBExchange::execute()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): catch ..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute): catch ..."
<<
endl
;
}
}
msleep
(
polltime
);
msleep
(
polltime
);
...
...
extensions/ModbusMaster/MBTCPMaster.cc
View file @
c7609b05
...
@@ -106,14 +106,16 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
...
@@ -106,14 +106,16 @@ ModbusClient* MBTCPMaster::initMB( bool reopen )
mbtcp
->
setAfterSendPause
(
aftersend_pause
);
mbtcp
->
setAfterSendPause
(
aftersend_pause
);
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): ipaddr="
<<
iaddr
<<
" port="
<<
port
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): ipaddr="
<<
iaddr
<<
" port="
<<
port
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
LEVEL9
)
)
if
(
dlog
.
debugging
(
Debug
::
LEVEL9
)
)
mbtcp
->
setLog
(
dlog
);
mbtcp
->
setLog
(
dlog
);
}
}
catch
(
ModbusRTU
::
mbException
&
ex
)
catch
(
ModbusRTU
::
mbException
&
ex
)
{
{
dlog
[
Debug
::
WARN
]
<<
"(init): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
"(init): "
<<
ex
<<
endl
;
}
}
catch
(...)
catch
(...)
{
{
...
@@ -180,20 +182,23 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
...
@@ -180,20 +182,23 @@ 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
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
"(MBTCPMaster): Не задан name'"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
"(MBTCPMaster): Не задан name'"
<<
endl
;
return
0
;
return
0
;
}
}
ObjectId
ID
=
conf
->
getObjectID
(
name
);
ObjectId
ID
=
conf
->
getObjectID
(
name
);
if
(
ID
==
UniSetTypes
::
DefaultObjectId
)
if
(
ID
==
UniSetTypes
::
DefaultObjectId
)
{
{
dlog
[
Debug
::
CRIT
]
<<
"(MBTCPMaster): идентификатор '"
<<
name
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"' не найден в конф. файле!"
dlog
[
Debug
::
CRIT
]
<<
"(MBTCPMaster): идентификатор '"
<<
name
<<
" в секции "
<<
conf
->
getObjectsSection
()
<<
endl
;
<<
"' не найден в конф. файле!"
<<
" в секции "
<<
conf
->
getObjectsSection
()
<<
endl
;
return
0
;
return
0
;
}
}
dlog
[
Debug
::
INFO
]
<<
"(MBTCPMaster): name = "
<<
name
<<
"("
<<
ID
<<
")"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
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"
)));
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init askcount_id="
<<
askcount_id
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
{
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init test_id="
<<
test_id
<<
endl
;
dlog
[
Debug
::
INFO
]
<<
myname
<<
": init askcount_id="
<<
askcount_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,8 +199,8 @@ prefix(prefix)
...
@@ -197,8 +199,8 @@ 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
);
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): rs-timeout="
<<
msec
<<
" msec"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): rs-timeout="
<<
msec
<<
" msec"
<<
endl
;
// build file list...
// build file list...
xmlNode
*
fnode
=
0
;
xmlNode
*
fnode
=
0
;
...
@@ -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
()
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(build file list): ignore empty name... "
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
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
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(build file list): FAILED ID for "
<<
nm
<<
"... ignore..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
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,7 +241,8 @@ prefix(prefix)
...
@@ -237,7 +241,8 @@ prefix(prefix)
nm
=
dir
+
nm
;
nm
=
dir
+
nm
;
}
}
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): add to filelist: "
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): add to filelist: "
<<
"id="
<<
id
<<
"id="
<<
id
<<
" file="
<<
nm
<<
" file="
<<
nm
<<
endl
;
<<
endl
;
...
@@ -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,7 +286,8 @@ prefix(prefix)
...
@@ -281,7 +286,8 @@ prefix(prefix)
{
{
if
(
dit
.
getProp
(
"id"
).
empty
()
)
if
(
dit
.
getProp
(
"id"
).
empty
()
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): read <MEI>. Unknown <device id=''>. Ignore.."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(init): read <MEI>. Unknown <device id=''>. Ignore.."
<<
endl
;
continue
;
continue
;
}
}
...
@@ -298,10 +304,11 @@ prefix(prefix)
...
@@ -298,10 +304,11 @@ prefix(prefix)
{
{
if
(
dit
.
getProp
(
"id"
).
empty
()
)
if
(
dit
.
getProp
(
"id"
).
empty
()
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
<<
"(init): read <MEI>. Unknown <object id='' (for device id='"
dlog
[
Debug
::
WARN
]
<<
myname
<<
devID
<<
"'). Ignore.."
<<
"(init): read <MEI>. Unknown <object id='' (for device id='"
<<
endl
;
<<
devID
<<
"'). Ignore.."
<<
endl
;
continue
;
continue
;
}
}
...
@@ -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,8 +423,9 @@ void MBSlave::execute_rtu()
...
@@ -416,8 +423,9 @@ void MBSlave::execute_rtu()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"(execute_rtu): (hb) "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (hb) "
<<
ex
<<
std
::
endl
;
}
}
}
}
...
@@ -433,8 +441,9 @@ void MBSlave::execute_rtu()
...
@@ -433,8 +441,9 @@ void MBSlave::execute_rtu()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"(execute_rtu): (respond) "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (respond) "
<<
ex
<<
std
::
endl
;
}
}
}
}
...
@@ -446,8 +455,9 @@ void MBSlave::execute_rtu()
...
@@ -446,8 +455,9 @@ void MBSlave::execute_rtu()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"(execute_rtu): (askCount) "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(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,8 +507,9 @@ void MBSlave::execute_tcp()
...
@@ -497,8 +507,9 @@ void MBSlave::execute_tcp()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"(execute_tcp): (hb) "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_tcp): (hb) "
<<
ex
<<
std
::
endl
;
}
}
}
}
...
@@ -513,8 +524,9 @@ void MBSlave::execute_tcp()
...
@@ -513,8 +524,9 @@ void MBSlave::execute_tcp()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"(execute_rtu): (respond) "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (respond) "
<<
ex
<<
std
::
endl
;
}
}
}
}
...
@@ -526,8 +538,9 @@ void MBSlave::execute_tcp()
...
@@ -526,8 +538,9 @@ void MBSlave::execute_tcp()
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
<<
"(execute_rtu): (askCount) "
<<
ex
<<
std
::
endl
;
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(execute_rtu): (askCount) "
<<
ex
<<
std
::
endl
;
}
}
}
}
...
@@ -565,17 +578,20 @@ void MBSlave::processingMessage(UniSetTypes::VoidMessage *msg)
...
@@ -565,17 +578,20 @@ void MBSlave::processingMessage(UniSetTypes::VoidMessage *msg)
}
}
catch
(
SystemError
&
ex
)
catch
(
SystemError
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(SystemError): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(SystemError): "
<<
ex
<<
std
::
endl
;
// throw SystemError(ex);
// throw SystemError(ex);
raise
(
SIGTERM
);
raise
(
SIGTERM
);
}
}
catch
(
Exception
&
ex
)
catch
(
Exception
&
ex
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): "
<<
ex
<<
std
::
endl
;
}
}
catch
(...)
catch
(...)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): catch ...
\n
"
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(processingMessage): catch ...
\n
"
;
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -587,7 +603,8 @@ void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm)
...
@@ -587,7 +603,8 @@ void MBSlave::sysCommand(UniSetTypes::SystemMessage *sm)
{
{
if
(
iomap
.
empty
()
)
if
(
iomap
.
empty
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): iomap EMPTY! terminated..."
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
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,19 +699,14 @@ void MBSlave::askSensors( UniversalIO::UIOCommand cmd )
...
@@ -682,19 +699,14 @@ 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
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(askSensors): "
<<
ex
<<
std
::
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
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,7 +841,8 @@ bool MBSlave::initItem( UniXML_iterator& it )
...
@@ -828,7 +841,8 @@ bool MBSlave::initItem( UniXML_iterator& it )
string
r
=
it
.
getProp
(
"mbreg"
);
string
r
=
it
.
getProp
(
"mbreg"
);
if
(
r
.
empty
()
)
if
(
r
.
empty
()
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'mbreg' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'mbreg' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -842,7 +856,8 @@ bool MBSlave::initItem( UniXML_iterator& it )
...
@@ -842,7 +856,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'iotype' or 'mb_iotype' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown 'iotype' or 'mb_iotype' for "
<<
it
.
getProp
(
"name"
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -868,7 +883,8 @@ bool MBSlave::initItem( UniXML_iterator& it )
...
@@ -868,7 +883,8 @@ 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
)
{
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown rtuVType="
<<
vt
<<
" for "
if
(
dlog
.
debugging
(
Debug
::
CRIT
)
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(initItem): Unknown rtuVType="
<<
vt
<<
" for "
<<
it
.
getProp
(
"name"
)
<<
it
.
getProp
(
"name"
)
<<
endl
;
<<
endl
;
...
@@ -947,7 +963,8 @@ MBSlave* MBSlave::init_mbslave( int argc, const char* const* argv, UniSetTypes::
...
@@ -947,7 +963,8 @@ MBSlave* MBSlave::init_mbslave( int argc, const char* const* argv, UniSetTypes::
return
0
;
return
0
;
}
}
dlog
[
Debug
::
INFO
]
<<
"(mbslave): name = "
<<
name
<<
"("
<<
ID
<<
")"
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
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
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataAddress
;
return
ModbusRTU
::
erBadDataAddress
;
}
}
catch
(
UniSetTypes
::
OutOfRange
&
ex
)
catch
(
UniSetTypes
::
OutOfRange
&
ex
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(write): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
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
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
return
ModbusRTU
::
erBadDataAddress
;
return
ModbusRTU
::
erBadDataAddress
;
}
}
catch
(
UniSetTypes
::
OutOfRange
&
ex
)
catch
(
UniSetTypes
::
OutOfRange
&
ex
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(real_read_it): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
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
)
{
{
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(readInputStatus): "
<<
ex
<<
endl
;
if
(
dlog
.
debugging
(
Debug
::
WARN
)
)
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