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
593678ba
Commit
593678ba
authored
Jul 13, 2010
by
Ivan Donchevskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New parameter for MBTCPMaster (--statistic-sec)
parent
ed6bfc9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
27 deletions
+50
-27
MBTCPMaster.cc
extensions/MBTCPMaster/MBTCPMaster.cc
+42
-25
MBTCPMaster.h
extensions/MBTCPMaster/MBTCPMaster.h
+8
-2
No files found.
extensions/MBTCPMaster/MBTCPMaster.cc
View file @
593678ba
...
...
@@ -47,6 +47,10 @@ no_extimer(false)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): read fileter-field='"
<<
s_field
<<
"' filter-value='"
<<
s_fvalue
<<
"'"
<<
endl
;
//задаем тестовое время (если нет, то оно равно 0)
test_time
=
0
;
test_time
=
conf
->
getArgInt
(
"--"
+
prefix
+
"-statistic-sec"
);
// ---------- init MBTCP ----------
string
pname
(
"--"
+
prefix
+
"-gateway-iaddr"
);
iaddr
=
conf
->
getArgParam
(
pname
,
it
.
getProp
(
"gateway_iaddr"
));
...
...
@@ -128,6 +132,8 @@ no_extimer(false)
printMap
(
rmap
);
// abort();
poll_count
=
0
;
}
// -----------------------------------------------------------------------------
MBTCPMaster
::~
MBTCPMaster
()
...
...
@@ -267,41 +273,52 @@ void MBTCPMaster::poll()
for
(
MBTCPMaster
::
RTUDeviceMap
::
iterator
it1
=
rmap
.
begin
();
it1
!=
rmap
.
end
();
++
it1
)
{
RTUDevice
*
d
(
it1
->
second
);
if
(
dlog
.
debugging
(
Debug
::
INFO
)
)
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(poll): ask addr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" regs="
<<
d
->
regmap
.
size
()
<<
endl
;
d
->
resp_real
=
true
;
for
(
MBTCPMaster
::
RegMap
::
iterator
it
=
d
->
regmap
.
begin
();
it
!=
d
->
regmap
.
end
();
++
it
)
d
->
resp_real
=
true
;
for
(
MBTCPMaster
::
RegMap
::
iterator
it
=
d
->
regmap
.
begin
();
it
!=
d
->
regmap
.
end
();
++
it
)
{
try
{
try
if
(
d
->
dtype
==
MBTCPMaster
::
dtRTU
)
{
if
(
d
->
dtype
==
MBTCPMaster
::
dtRTU
)
{
// if( pollRTU(d,it) )
// d->resp_real = true;
pollRTU
(
d
,
it
);
}
pollRTU
(
d
,
it
);
}
catch
(
ModbusRTU
::
mbException
&
ex
)
{
if
(
d
->
resp_real
)
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(poll): FAILED ask addr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" reg="
<<
ModbusRTU
::
dat2str
(
it
->
second
->
mbreg
)
<<
" -> "
<<
ex
<<
endl
;
}
d
->
resp_real
=
false
;
if
(
!
d
->
ask_every_reg
)
break
;
}
catch
(
ModbusRTU
::
mbException
&
ex
)
{
if
(
d
->
resp_real
)
{
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(poll): FAILED ask addr="
<<
ModbusRTU
::
addr2str
(
d
->
mbaddr
)
<<
" reg="
<<
ModbusRTU
::
dat2str
(
it
->
second
->
mbreg
)
<<
" -> "
<<
ex
<<
endl
;
}
if
(
it
==
d
->
regmap
.
end
()
)
d
->
resp_real
=
false
;
if
(
!
d
->
ask_every_reg
)
break
;
}
if
(
it
==
d
->
regmap
.
end
()
)
break
;
}
if
(
test_time
==
0
)
continue
;
if
(
poll_count
==
0
)
pt
=
PassiveTimer
();
if
((
pt
.
getCurrent
()
>=
test_time
*
1000
)
&&
(
poll_count
!=-
1
))
{
cout
<<
endl
<<
"numbr of calls is "
<<
poll_count
<<
endl
<<
endl
;
poll_count
=-
1
;
pt
.
reset
();
}
poll_count
++
;
// mb->disconnect();
}
...
...
extensions/MBTCPMaster/MBTCPMaster.h
View file @
593678ba
...
...
@@ -82,13 +82,13 @@
\b --xxx-initPause или \b initPause msec - пауза перед началом работы, после активации. По умолчанию 50 мсек.
\b --xxx-force или \b foce [1|0]
\b --xxx-force или \b fo
r
ce [1|0]
- 1 - перечитывать значения входов из SharedMemory на каждом цикле
- 0 - обновлять значения только по изменению
\b --xxx-force-disconnect или \b force_disconnect - закрывать соединение после каждого запроса.
\b --xxx-force-out или \b foce_out [1|0]
\b --xxx-force-out или \b fo
r
ce_out [1|0]
- 1 - перечитывать значения выходов из SharedMemory на каждом цикле
- 0 - обновлять значения только по изменению
...
...
@@ -110,6 +110,8 @@
\b --xxx-filter-value - задаёт значение фильтрующего поля. Необязательный параметр.
\b --xxx-statistic-sec sec - при наличии выведет кол-во посланных запросов за этот промежуток времени.
Если параметры не заданы, будет произведена попытка загрузить все датчики, у которых
присутствуют необходимые настроечные параметры.
...
...
@@ -375,6 +377,10 @@ class MBTCPMaster:
std
::
string
prefix
;
bool
no_extimer
;
timeout_t
test_time
;
/*! При тестировании это время, за которое мы веведем в консоль кол-во посланных запросов MBTCPMaster-ом */
int
poll_count
;
PassiveTimer
pt
;
};
// -----------------------------------------------------------------------------
#endif // _MBTCPMaster_H_
...
...
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