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
9e672ef7
Commit
9e672ef7
authored
May 19, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ModbusMaster): немного поменял схему выставления датчика связи
parent
061dab12
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
13 deletions
+30
-13
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+25
-13
DelayTimer.h
include/DelayTimer.h
+5
-0
No files found.
extensions/ModbusMaster/MBExchange.cc
View file @
9e672ef7
...
...
@@ -490,7 +490,7 @@ std::ostream& operator<<( std::ostream& os, MBExchange::RTUDevice& d )
os
<<
"addr="
<<
ModbusRTU
::
addr2str
(
d
.
mbaddr
)
<<
" type="
<<
d
.
dtype
<<
" respond_id="
<<
d
.
resp_id
<<
" respond_timeout="
<<
d
.
resp_Delay
.
getO
ff
Delay
()
<<
" respond_timeout="
<<
d
.
resp_Delay
.
getO
n
Delay
()
<<
" respond_state="
<<
d
.
resp_state
<<
" respond_invert="
<<
d
.
resp_invert
<<
endl
;
...
...
@@ -2669,7 +2669,7 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
dinfo
<<
myname
<<
"(initDeviceInfo): add addr="
<<
ModbusRTU
::
addr2str
(
a
)
<<
endl
;
int
tout
=
it
.
getPIntProp
(
"timeout"
,
default_timeout
);
d
->
second
->
resp_Delay
.
set
(
0
,
tout
);
// ставим время на отпускание.. см. checkRespond()
d
->
second
->
resp_Delay
.
set
(
tout
,
false
);
d
->
second
->
resp_invert
=
it
.
getIntProp
(
"invert"
);
return
true
;
}
...
...
@@ -3051,10 +3051,19 @@ bool MBExchange::RTUDevice::checkRespond()
{
bool
prev
=
resp_state
;
resp_state
=
resp_Delay
.
check
(
prev_numreply
!
=
numreply
);
resp_state
=
!
resp_Delay
.
check
(
prev_numreply
=
=
numreply
);
prev_numreply
.
store
(
numreply
);
dlog4
<<
"(checkRespond): addr="
<<
ModbusRTU
::
addr2str
(
mbaddr
)
<<
" respond_id="
<<
resp_id
<<
" state="
<<
resp_state
<<
" current="
<<
resp_Delay
.
getCurrent
()
<<
" [ timeout="
<<
resp_Delay
.
getOnDelay
()
<<
" numreply="
<<
numreply
<<
" prev_numreply="
<<
prev_numreply
<<
" ]"
<<
endl
;
return
(
prev
!=
resp_state
);
}
// -----------------------------------------------------------------------------
...
...
@@ -3064,20 +3073,23 @@ void MBExchange::updateRespondSensors()
{
RTUDevice
*
d
(
it1
.
second
);
dlog4
<<
myname
<<
": check respond addr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" respond_id="
<<
d
->
resp_id
<<
" state="
<<
d
->
resp_state
<<
" [timeout="
<<
d
->
resp_Delay
.
getOffDelay
()
<<
" numreply="
<<
d
->
numreply
<<
" prev_numreply="
<<
d
->
prev_numreply
<<
" ]"
<<
endl
;
if
(
d
->
checkRespond
()
&&
d
->
resp_id
!=
DefaultObjectId
)
if
(
d
->
resp_id
!=
DefaultObjectId
&&
d
->
checkRespond
()
)
{
try
{
bool
set
=
d
->
resp_invert
?
!
d
->
resp_state
:
d
->
resp_state
;
dlog4
<<
myname
<<
": SAVE NEW respond state="
<<
set
<<
" for addr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" respond_id="
<<
d
->
resp_id
<<
" state="
<<
d
->
resp_state
<<
" [ invert="
<<
d
->
resp_invert
<<
" timeout="
<<
d
->
resp_Delay
.
getOnDelay
()
<<
" numreply="
<<
d
->
numreply
<<
" prev_numreply="
<<
d
->
prev_numreply
<<
" ]"
<<
endl
;
shm
->
localSetValue
(
d
->
resp_it
,
d
->
resp_id
,
(
set
?
1
:
0
),
getId
());
}
catch
(
const
Exception
&
ex
)
...
...
include/DelayTimer.h
View file @
9e672ef7
...
...
@@ -132,6 +132,11 @@ class DelayTimer
return
offDelay
;
}
inline
timeout_t
getCurrent
()
{
return
pt
.
getCurrent
();
}
protected
:
PassiveTimer
pt
;
bool
prevState
;
...
...
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